62,266
社区成员
发帖
与我相关
我的任务
分享public function Reboot_Act() {
if (empty ( $_SESSION ))
session_start ();
if ($_SESSION ['AdvOp']) {
$_SESSION ['AdvOp'] = null;
$this->WriteLog ( true, _ ( 'NM_LINUX_REBOOT' ), $this->oAdmin->Get ( 'name' ), null, USER_LOG_TYPE_SHUTDOWN_SYSTEM );
$handle = popen ( "sudo -u \\#0 /sbin/shutdown -r now 2>&1 ", "r" );
pclose ( $handle );
}
}
public function Shutdown_Act() {
if (empty ( $_SESSION ))
session_start ();
if ($_SESSION ['AdvOp']) {
$_SESSION ['AdvOp'] = null;
$this->WriteLog ( true, _ ( 'NM_LINUX_REBOOT' ), $this->oAdmin->Get ( 'name' ), null, USER_LOG_TYPE_SHUTDOWN_SYSTEM );
$cmd = "sudo -u \\#0 /sbin/shutdown -h now 2>&1 ";
$result = shell_exec ( $cmd );
}
}
function LoginDialog(type){
var confirm = _('NM_CONFIRM');
var close = _('NM_CLOSE');
$('#Login_Panel').dialog({
autoOpen: false,
width: 220,
height: 120,
minWidth: 200,
minHeight: 120,
maxWidth: 200,
maxHeight: 120,
draggable: true,
closeOnEscape: true,
modal: true,
title: sprintf(_('SPF_PLEASE_INPUT'), sprintf(_('SPF_ADMIN'), _('NM_PASSWORD'))),
buttons: [{
text: confirm,
click: function(){
var p = $.trim($('#password').val());
if (p == '') {
global.custom.alert(sprintf(_('SPF_EMPTY_ERROR'), _('NM_PASSWORD')), function(){
setTimeout(function(){
$('#password').focus();
}, 1);
});
return false;
}
var params = {};
params.p = p;
global.ajax('index.php?c=Login&a=AdvancedOperationsVerify', params, 'post', '', 0, function(data){
if (0 === data.status) {
if (type == 1) {
$('#reboot').prop('disabled', 'disabled');
global.ajax('index.php?c=Linux&a=Reboot', null, 'post', '', 0, function(data){
});
global.custom.loading();
$('.loadingmsg').html('' + _('NM_WAIT_FOR_REBOOT') + ' ... <span id="_timer"></span>');
var m = setInterval(function(){
global.ajax('index.php?c=Linux&a=GetServerState', null, 'post', '', 0, function(data){
if (data == 'OK') {
clearInterval(m);
global.custom.unloading();
global.custom.loading();
$('.loadingmsg').html('' + _('NM_REBOOTSUCCESS_LOGIN') + ' ... <span id="_timer"></span>');
var d = setTimeout(function(){
global.custom.unloading();
window.location = 'index.php?c=Login&a=Logout';
}, 5000);
}
});
}, 2000);
}
else {
$('#shutdown').prop('disabled', 'disabled');
global.ajax('index.php?c=Linux&a=Shutdown', null, 'post', '', 0, function(data){
});
global.custom.loading();
$('.loadingmsg').html('' + _('NM_WAIT_FOR_SHUTDOWN') + ' ... <span id="_timer"></span>');
var m = setTimeout(function(){
global.custom.unloading();
global.custom.alert(_('NM_SHUTDOWN_SUCCESS'), function(){
window.opener = null;
window.open('', '_top', '');
window.parent.close();
}, 'successful');
}, 5000);
}
}
});
}
}, {
text: close,
click: function(){
$('#password').val('');
$(this).dialog("close");
}
}]
});
$('#Login_Panel').dialog('open');
}
$(document).ready(function(){
$('#password').val('');
$('#reboot').click(function(){
global.custom.confirm(_('SPF_REBOOT_CONFIRM'), function(){
LoginDialog(1);
})
});
$('#shutdown').click(function(){
global.custom.confirm(_('SPF_SHUTDOWN_CONFIRM'), function(){
LoginDialog(0);
});
});
});