Пример #1
0
 function AMNetwork_ps()
 {
     $this->title = '系统进程 - AMNetwork - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $cmd = "amh module AMNetwork-1.0 admin ps";
     $ps_list = Functions::trim_result(shell_exec($cmd));
     $ps_list = trim(str_replace(array('[OK] AMNetwork is already installed.', '[AMNetwork-1.0 admin]'), '', $ps_list));
     $this->ps_list = $ps_list;
     $this->_view('AMNetwork_ps');
 }
Пример #2
0
 function mysql_list()
 {
     $this->title = 'AMH - MySQL';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_GET['ams'])) {
         // 打开数据库列表
         if ($_GET['ams'] == 'OpenDatabaseJs') {
             header('Content-type: application/x-javascript');
             $open_database = isset($_SESSION['open_database_name']) && !empty($_SESSION['open_database_name']) ? true : false;
             $AmysqlHomeStatus = $open_database ? 'Normal' : 'Activate';
             $_AmysqlTabJson = "var _AmysqlTabJson = [";
             $_AmysqlTabJson .= "{'type':'" . $AmysqlHomeStatus . "','id':'AmysqlHome','name':'AmysqlHome - localhost', 'url': '" . _Http . "ams/index.php?c=ams&a=AmysqlHome'}";
             if ($open_database) {
                 $ODN = $_SESSION['open_database_name'];
                 $_AmysqlTabJson .= ", {'type':'Activate','id':'AmysqlDatabase_" . $ODN . "','name':'" . $ODN . "', 'url': '" . _Http . "ams/index.php?c=ams&a=AmysqlDatabase&DatabaseName=" . $ODN . "'}";
             }
             $_AmysqlTabJson .= "];";
             echo $_AmysqlTabJson;
             exit;
         } elseif ($_GET['ams'] == 'OpenCreate') {
             header('Content-type: application/x-javascript');
             if (isset($_SESSION['create_database']) && !empty($_SESSION['create_database'])) {
                 echo " AddEvent({'load':function () { NavigationObject.ActiveSet(NavigationObject.Item['N_DatabaseAdd']);} },window); ";
             }
             exit;
         } elseif ($_GET['ams'] == 'index') {
             $_SESSION['open_database_name'] = null;
             $_SESSION['create_database'] = null;
         } elseif ($_GET['ams'] == 'database') {
             if (!empty($_GET['name'])) {
                 $_SESSION['open_database_name'] = $_GET['name'];
             }
             $_SESSION['create_database'] = null;
         } elseif ($_GET['ams'] == 'create') {
             $_SESSION['open_database_name'] = null;
             $_SESSION['create_database'] = 'yes';
         }
         header('location:./ams/');
         exit;
     }
     $this->databases = $this->mysqls->databases();
     $this->_view('mysql');
 }
Пример #3
0
 function module_down()
 {
     $this->title = 'AMH - Module';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_POST['download_submit'])) {
         $module_name = $_POST['module_name'];
         if (!empty($module_name)) {
             if ($this->modules->module_download($module_name)) {
                 $this->status = 'success';
                 $this->notice = "模块下载成功:{$module_name}";
             } else {
                 $this->status = 'error';
                 $this->notice = "模块下载失败:{$module_name}";
             }
         } else {
             $this->status = 'error';
             $this->notice = "请输入模块名字。";
         }
     }
     $this->indexs->log_insert($this->notice);
     $this->_view('module_down');
 }
Пример #4
0
 function IndexAction()
 {
     $this->title = 'AMH - AMChroot';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_GET['domain']) && !empty($_GET['domain']) && isset($_GET['mode']) && in_array($_GET['mode'], array('chroot', 'normal'))) {
         $domain = $_GET['domain'];
         $mode = $_GET['mode'];
         if ($_SESSION['amh_config']['DataPrivate']['config_value'] == 'on' && $_GET['mode'] == 'normal') {
             $this->status = 'error';
             $this->notice .= "AMChroot设置:{$domain}域名设置{$mode}模式失败: 您已开启面板数据私有保护,面板不可切换主机为兼容模式。";
         } elseif ($this->amchroots->amchroot_edit($domain, $mode)) {
             $this->status = 'success';
             $this->notice = " AMChroot设置:{$domain}域名设置{$mode}模式成功。";
         } else {
             $this->status = 'error';
             $this->notice = " AMChroot设置:{$domain}域名设置{$mode}模式失败。";
         }
     }
     $this->indexs->log_insert($this->notice);
     $this->amchroot_list = $this->amchroots->amchroot_list();
     $this->_view('amchroot');
 }
Пример #5
0
 function account_pass()
 {
     $this->title = '更改密码 - 账号 - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_POST['submit'])) {
         $user_password = $_POST['user_password'];
         $new_user_password = $_POST['new_user_password'];
         $new_user_password2 = $_POST['new_user_password2'];
         $error = '';
         $this->status = 'error';
         $status = $this->indexs->logins($_SESSION['amh_user_name'], $user_password);
         if ($status) {
             if (empty($new_user_password) || empty($new_user_password2)) {
                 $error = '新密码与确认新密码不能为空。';
             } elseif ($new_user_password != $new_user_password2) {
                 $error = '新密码与确认新密码不一致。';
             }
         } else {
             $error = '旧密码错误。';
         }
         if (empty($error)) {
             $status = $this->accounts->change_pass($new_user_password);
             if ($status) {
                 $this->status = 'success';
                 $this->notice = '更改密码成功。';
             } else {
                 $this->notice = '更改密码失败。';
             }
         } else {
             $this->notice = $error;
         }
     }
     $this->indexs->log_insert($this->notice);
     $this->_view('account_pass');
 }
Пример #6
0
 function backup_list()
 {
     $this->title = 'AMH - Backup';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     $category = isset($_GET['category']) ? $_GET['category'] : 'backup_list';
     $category_array = array('backup_list', 'backup_remote', 'backup_now', 'backup_revert');
     if (!in_array($category, $category_array)) {
         $category = 'backup_list';
     }
     $input_item = array('remote_type', 'remote_status', 'remote_ip', 'remote_path', 'remote_user', 'remote_password');
     if ($category == 'backup_list') {
         $this->title = 'AMH - Backup - 备份列表';
         if (isset($_GET['del'])) {
             $del_id = (int) $_GET['del'];
             $del_info = $this->backups->get_backup($del_id);
             if (isset($del_info['backup_file'])) {
                 $file = str_replace('.amh', '', $del_info['backup_file']);
                 $cmd = "amh rm_backup {$file}";
                 $cmd = Functions::trim_cmd($cmd);
                 $result = shell_exec($cmd);
                 $this->status = 'success';
                 $this->notice = "删除备份文件({$file}.amh)执行完成。";
             }
         }
         $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
         $page_sum = 20;
         $this->backups->backup_list_update();
         $backup_list = $this->backups->get_backup_list($page, $page_sum);
         $total_page = ceil($backup_list['sum'] / $page_sum);
         $page_list = Functions::page('BackupList', $backup_list['sum'], $total_page, $page, 'c=backup&a=backup_list&category=backup_list');
         // 分页列表
         global $Config;
         $Config['XSS'] = false;
         $this->page = $page;
         $this->total_page = $total_page;
         $this->backup_list = $backup_list;
         $this->page_list = $page_list;
     } elseif ($category == 'backup_remote') {
         $this->title = 'AMH - Backup - 远程设置';
         // 连接测试
         if (isset($_GET['check'])) {
             $id = (int) $_GET['check'];
             $data = $this->backups->get_backup_remote($id);
             if ($data['remote_type'] == 'FTP') {
                 $cmd = "amh BRftp check {$id}";
             } else {
                 $cmd = "amh BRssh check {$id}";
             }
             $cmd = Functions::trim_cmd($cmd);
             $result = shell_exec($cmd);
             $result = trim(Functions::trim_result($result), "\n ");
             echo $result;
             exit;
         }
         // 保存远程配置
         if (isset($_POST['save'])) {
             $save = true;
             foreach ($input_item as $val) {
                 if (empty($_POST[$val])) {
                     $this->notice = '新增远程备份配置失败,请填写完整数据,*号为必填项。';
                     $save = false;
                 }
             }
             if ($save) {
                 $id = $this->backups->backup_remote_insert();
                 if ($id) {
                     $this->status = 'success';
                     $this->notice = 'ID:' . $id . ' 新增远程备份配置成功。';
                     $_POST = array();
                 } else {
                     $this->notice = ' 新增远程备份配置失败。';
                 }
             }
         }
         // 删除远程配置
         if (isset($_GET['del'])) {
             $id = (int) $_GET['del'];
             if (!empty($id)) {
                 $result = $this->backups->backup_remote_del($id);
                 if ($result) {
                     $this->status = 'success';
                     $this->notice = 'ID:' . $id . ' 删除远程备份配置成功。';
                 } else {
                     $this->notice = 'ID:' . $id . ' 删除远程备份配置失败。';
                 }
             }
         }
         // 编辑远程配置
         if (isset($_GET['edit'])) {
             $id = (int) $_GET['edit'];
             $_POST = $this->backups->get_backup_remote($id);
             if ($_POST['remote_id']) {
                 $this->edit_remote = true;
             }
         }
         // 保存编辑远程配置
         if (isset($_POST['save_edit'])) {
             $id = $_POST['remote_id'] = (int) $_POST['save_edit'];
             $save = true;
             foreach ($input_item as $val) {
                 if (empty($_POST[$val]) && $val != 'remote_password') {
                     $this->notice = 'ID:' . $id . ' 编辑远程备份配置失败。*号为必填项。';
                     $save = false;
                     $this->edit_remote = true;
                 }
             }
             if ($save) {
                 $result = $this->backups->backup_remote_update();
                 if ($result) {
                     $this->status = 'success';
                     $this->notice = 'ID:' . $id . ' 编辑远程备份配置成功。';
                     $_POST = array();
                 } else {
                     $this->notice = 'ID:' . $id . ' 编辑远程备份配置失败。';
                     $this->edit_remote = true;
                 }
             }
         }
         $this->remote_list = $this->backups->backup_remote_list();
     } elseif ($category == 'backup_now') {
         $this->title = 'AMH - Backup - 即时备份';
         if (isset($_POST['backup_now'])) {
             $backup_retemo = $_POST['backup_retemo'] == 'on' ? 'y' : 'n';
             $backup_password = !empty($_POST['backup_password']) ? $_POST['backup_password'] : '******';
             $backup_comment = !empty($_POST['backup_comment']) ? $_POST['backup_comment'] : '';
             if ((!empty($_POST['backup_password2']) || !empty($_POST['backup_password'])) && $_POST['backup_password'] != $_POST['backup_password2']) {
                 $this->notice = ' 两次密码不一致,请确认。';
             } else {
                 $cmd = "amh backup {$backup_retemo} {$backup_password} {$backup_comment}";
                 $cmd = Functions::trim_cmd($cmd);
                 $result = shell_exec($cmd);
                 $result = trim(Functions::trim_result($result), "\n ");
                 if (strpos($result, '[OK]') !== false) {
                     $this->status = 'success';
                     $this->notice = $result . ' 已成功创建备份文件。';
                     $_POST = array();
                 } else {
                     $this->notice = $result . ' 备份文件创建失败';
                 }
             }
         }
     } elseif ($category == 'backup_revert') {
         $this->title = 'AMH - Backup - 一键还原';
         $this->notice = ' 还原失败!';
         //			$revert_id = isset($_GET['revert_id']) ? (int)$_GET['revert_id'] : '';
         //			if (!empty($revert_id))
         //				$revert = $this -> backups -> get_backup($revert_id);
         //
         //			if (isset($_POST['revert_submit']))
         //			{
         //				$backup_file = $revert['backup_file'];
         //				$backup_password = empty($_POST['backup_password']) ? 'n' : $_POST['backup_password'];
         //				$cmd = "amh revert $backup_file $backup_password noreload";
         //				$cmd = Functions::trim_cmd($cmd);
         //				$result = shell_exec($cmd);
         //				$result = trim(Functions::trim_result($result), "\n ");
         //				if (strpos($result, '[OK]') !== false)
         //				{
         //					$this -> status = 'success';
         //					$this -> notice = $backup_file . ' 数据还原成功。';
         //				}
         //				else
         //					$this -> notice = $result . ' ' . $backup_file . ' 还原失败。' ;
         //
         //			}
         //			$this -> revert = $revert;
     }
     $this->indexs->log_insert($this->notice);
     $this->category = $category;
     $this->_view('backup');
 }
Пример #7
0
 function task_set()
 {
     $this->title = 'AMH - Task';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     if (isset($_POST['save_submit'])) {
         $id = (int) $_POST['crontab_id'];
         $save_status = $this->tasks->save_task($id);
         if ($save_status) {
             $this->status = 'success';
             $this->notice = 'ID' . $id . ' : 编辑保存任务计划成功。';
             $_POST = array();
         } else {
             $this->notice = '编辑保存任务计划失败。';
         }
     } elseif (isset($_POST['task_submit'])) {
         $insert_status = $this->tasks->insert_task();
         if ($insert_status) {
             $this->status = 'success';
             $this->notice = 'ID' . $insert_status . ' : 新增任务计划成功。';
             $_POST = array();
         } else {
             $this->notice = '新增任务计划失败。';
         }
     } elseif (isset($_GET['del'])) {
         $id = (int) $_GET['del'];
         $del_status = $this->tasks->del_task($id);
         if ($del_status) {
             $this->status = 'success';
             $this->top_notice = 'ID' . $id . ' : 删除任务计划成功。';
         } else {
             $this->top_notice = '删除任务计划失败。';
         }
     } elseif (isset($_GET['edit'])) {
         $id = (int) $_GET['edit'];
         $edit_task = $this->tasks->get_task($id);
         if (is_array($edit_task) && $edit_task['crontab_type'] != 'ssh') {
             foreach ($edit_task as $key => $val) {
                 if (in_array($key, array('crontab_minute', 'crontab_hour', 'crontab_day', 'crontab_month', 'crontab_week'))) {
                     $_key = str_replace('crontab_', '', $key);
                     if (strpos($val, '/') !== false) {
                         $_val = explode('/', $val);
                         $_val2 = explode('-', $_val[0]);
                         $_POST[$_key . '_average_start'] = $_val2[0];
                         $_POST[$_key . '_average_end'] = isset($_val2[1]) ? $_val2[1] : '*';
                         $_POST[$_key . '_average_input'] = $_val[1];
                         $_POST[$_key . '_select'] = '/';
                     } elseif (strpos($val, '-') !== false) {
                         $_val = explode('-', $val);
                         $_POST[$_key . '_period_start'] = $_val[0];
                         $_POST[$_key . '_period_end'] = $_val[1];
                         $_POST[$_key . '_select'] = '-';
                     } elseif (strpos($val, ',') !== false) {
                         $_POST[$_key . '_respectively'] = explode(',', $val);
                         $_POST[$_key . '_select'] = ',';
                     } else {
                         $_POST[$_key . '_time'] = $val;
                         $_POST[$_key . '_select'] = '*';
                     }
                 } else {
                     $_POST[$key] = $val;
                 }
             }
             $this->edit_task = true;
         } else {
             $this->top_notice = 'WEB不可编辑的任务计划。';
         }
     }
     $this->crontab_list = $this->tasks->get_task_list();
     $this->indexs->log_insert($this->top_notice . $this->notice);
     $this->_view('crontab');
 }
Пример #8
0
 function account_my()
 {
     $this->title = 'AMH - Account';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     $category = isset($_GET['category']) ? $_GET['category'] : 'account_info';
     $category_array = array('account_info', 'account_config');
     if (!in_array($category, $category_array)) {
         $category = 'account_info';
     }
     if ($category == 'account_info') {
         $this->login_list = $this->accounts->login_list();
         $this->log_list = $this->accounts->log_list();
         if (isset($_POST['submit'])) {
             $user_password = $_POST['user_password'];
             $new_user_password = $_POST['new_user_password'];
             $new_user_password2 = $_POST['new_user_password2'];
             $error = '';
             $this->status = 'error';
             $status = $this->indexs->logins($_SESSION['amh_user_name'], $user_password);
             if ($status) {
                 if (empty($new_user_password) || empty($new_user_password2)) {
                     $error = '新密码与确认新密码不能为空。';
                 } elseif ($new_user_password != $new_user_password2) {
                     $error = '新密码与确认新密码不一致。';
                 }
             } else {
                 $error = '旧密码错误。';
             }
             if (empty($error)) {
                 $status = $this->accounts->change_pass($new_user_password);
                 if ($status) {
                     $this->status = 'success';
                     $this->notice = '更改密码成功。';
                 } else {
                     $this->notice = '更改密码失败。';
                 }
             } else {
                 $this->notice = $error;
             }
         }
     } elseif ($category == 'account_config') {
         if (isset($_POST['submit'])) {
             $_POST['LoginErrorLimit'] = (int) $_POST['LoginErrorLimit'];
             $_POST['AMHListen'] = (int) $_POST['AMHListen'];
             if (empty($_POST['LoginErrorLimit'])) {
                 $_POST['LoginErrorLimit'] = 1;
             }
             if (!isset($_POST['HelpDoc'])) {
                 $_POST['HelpDoc'] = 'no';
             }
             if (!isset($_POST['VerifyCode'])) {
                 $_POST['VerifyCode'] = 'no';
             }
             $up_status = $this->accounts->up_amh_config();
             if ($up_status) {
                 $status = 'success';
                 $this->notice = '系统配置更改成功。';
             } else {
                 $this->notice = '系统配置更改失败。';
             }
         }
         $AMHDomain_text = $_POST['AMHDomain'] == 'Off' ? $_SERVER['SERVER_ADDR'] : $_POST['AMHDomain'];
         if ($_POST['AMHListen'] != $_POST['AMHListen_old'] || $_POST['AMHDomain'] != 'Off' && $_POST['AMHDomain'] != $_POST['AMHDomain_old']) {
             $this->notice .= "面板允许域或端口已更改,请使用 {$AMHDomain_text}:{$_POST['AMHListen']} 访问。";
         }
         $amh_config = $this->accounts->get_amh_config();
         if ($status == 'success') {
             $_SESSION['amh_config'] = $amh_config;
             $this->status = $status;
         }
         $this->amh_config = $amh_config;
         $this->amh_domain_list = $this->accounts->get_amh_domain_list();
     }
     $this->indexs->log_insert($this->notice);
     $this->category = $category;
     $this->_view('account');
 }
Пример #9
0
 function ajax()
 {
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $html = file_get_contents('http://amysql.com/index.php?c=index&a=AMH&tag=ajax&V=3.1');
     $html = htmlspecialchars($html);
     $html = str_replace('[br]', '<br />', $html);
     $html = preg_replace('/\\[url\\]([a-z\\_]+)\\[\\/url\\]/i', '<a href="http://amysql.com/AMH.htm?tag=$1" target="_blank"> http://amysql.com/AMH.htm?tag=$1</a>', $html);
     echo $html;
     exit;
 }
Пример #10
0
 function ftp_list()
 {
     $this->title = 'AMH - FTP';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     // 删除ftp
     if (isset($_GET['del'])) {
         $del_name = $_GET['del'];
         if (!empty($del_name)) {
             $get_ftp = $this->ftps->get_ftp($del_name);
             if ($get_ftp['ftp_type'] == 'web') {
                 $result = $this->ftps->ftp_del_ssh($del_name);
                 if (strpos($result, '[OK]') !== false) {
                     $this->status = 'success';
                     $this->top_notice = $del_name . ' : 删除FTP账号成功。';
                 } else {
                     $this->top_notice = $del_name . ' : 删除FTP账号失败。' . $result;
                 }
             } else {
                 $this->top_notice = $del_name . ' : ssh FTP账号web端不可删除。';
             }
         }
     }
     // 保存ftp
     if (isset($_POST['save'])) {
         if (empty($_POST['ftp_name']) || empty($_POST['ftp_password']) || empty($_POST['ftp_root'])) {
             $this->notice = '账号与密码与根目录不能为空。';
         } else {
             $result = $this->ftps->ftp_insert_ssh($_POST);
             if (strpos($result, '[OK]') !== false) {
                 $this->ftps->ftp_insert($_POST);
                 $this->status = 'success';
                 $this->notice = $_POST['ftp_name'] . ' : 新增FTP账号成功。';
                 $_POST = array();
             } else {
                 $this->notice = $_POST['ftp_name'] . ' : 新增FTP账号失败。' . $result;
             }
         }
     }
     // 编辑ftp
     if (isset($_GET['edit'])) {
         $edit_name = $_GET['edit'];
         $_POST = $this->ftps->get_ftp($edit_name);
         if ($_POST['ftp_type'] == 'web') {
             $_POST['ftp_password'] = '';
             if (!empty($_POST['ftp_upload_bandwidth'])) {
                 $_POST['ftp_upload_bandwidth'] /= 1024;
             }
             if (!empty($_POST['ftp_download_bandwidth'])) {
                 $_POST['ftp_download_bandwidth'] /= 1024;
             }
             if (!empty($_POST['ftp_max_mbytes'])) {
                 $_POST['ftp_max_mbytes'] /= 1024 * 1024;
             }
             $this->edit_ftp = true;
         } else {
             $this->top_notice = $edit_name . ' : ssh FTP账号web端不可编辑。';
             $_POST = array();
         }
     }
     // 保存编辑ftp
     if (isset($_POST['save_edit'])) {
         $_POST['ftp_name'] = $ftp_name = $_POST['save_edit'];
         $edit_ftp = $this->ftps->get_ftp($ftp_name);
         if ($edit_ftp['ftp_type'] == 'web') {
             $this->status = 'success';
             $result = $this->ftps->edit_ftp();
             if (strpos($result[0], '[OK]') !== false) {
                 $status = true;
                 $top_notice = $ftp_name . ' : 编辑FTP账号成功。';
             } else {
                 $this->status = 'error';
                 $top_notice = $ftp_name . ' : 编辑FTP账号失败。' . $result[0];
             }
             if (!empty($_POST['ftp_password'])) {
                 if (strpos($result[1], '[OK]') !== false) {
                     $status = true;
                     $top_notice .= $ftp_name . ' : 更改FTP密码成功。';
                 } else {
                     $this->status = 'error';
                     $top_notice .= $ftp_name . ' 更改FTP密码失败。' . $result[1];
                 }
             }
             if (isset($status)) {
                 $_POST = array();
             } else {
                 $this->edit_ftp = true;
             }
             $this->top_notice = $top_notice;
         }
     }
     $ftp_list_ssh = explode("\n", trim(shell_exec("amh ls_ftp"), "\n"));
     $this->ftps->ftp_update($ftp_list_ssh);
     $this->ftp_list = $this->ftps->ftp_list();
     $dir_str = trim(shell_exec("amh ls_wwwroot"), "\n");
     $this->dirs = explode("\n", $dir_str);
     $_POST['ftp_root'] = explode('/', $_POST['ftp_root']);
     $_POST['ftp_root'] = $_POST['ftp_root'][3];
     $this->indexs->log_insert($this->top_notice . $this->notice);
     $this->_view('ftp');
 }
Пример #11
0
 function php_setparam()
 {
     $this->title = 'PHP参数设置 - 虚拟主机 - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $param_list = array(array('设置PHP时区', 'date.timezone', 'Asia/Hong_Kong'), array('是否显示PHP错误信息', 'display_errors', 'On / Off'), array('PHP运行内存限制', 'memory_limit', '68M'), array('POST数据最大限制', 'post_max_size', '4M'), array('上传文件最大限制', 'upload_max_filesize', '2M'), array('上传文件个数限制', 'max_file_uploads', '10'), array('脚本超时时间', 'max_execution_time', '20'), array('socket超时时间', 'default_socket_timeout', '60'), array('SESSION过期时间', 'session.cache_expire', '180'), array('是否开启短标签', 'short_open_tag', 'On / Off'));
     if (isset($_POST['submit'])) {
         foreach ($param_list as $key => $val) {
             $post_keyname = str_replace('.', '_', $val[1]);
             $cmd = "amh SetParam php {$val['1']} {$_POST[$post_keyname]}";
             $cmd = Functions::trim_cmd($cmd . ' noreload');
             // 只更改参数不重启
             exec($cmd, $tmp, $status);
         }
         if (!$status) {
             $this->status = 'success';
             $this->notice = 'PHP配置更改成功。';
         } else {
             $this->status = 'error';
             $this->notice = 'PHP配置更改失败。';
         }
     }
     $param_list = $this->hosts->get_php_param($param_list);
     $this->param_list = $param_list;
     $this->indexs->log_insert($this->top_notice . $this->notice);
     $this->_view('host_php_setparam');
 }
Пример #12
0
 function account_templet()
 {
     $this->title = 'AMH - AMWebsite - 账号模板';
     // 面板模板标题
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     // 面板登录检查函数
     // 删除
     if (isset($_GET['del'])) {
         $id = (int) $_GET['del'];
         if ($this->AccountTemplets->del_account($id)) {
             $this->status = 'success';
             $this->notice = "AMWebsite:删除账号模板({$id})成功。";
         } else {
             $this->status = 'error';
             $this->notice = "AMWebsite:删除账号模板({$id})失败。";
         }
     }
     // 编辑
     if (isset($_GET['user_id'])) {
         $user_id = (int) $_GET['user_id'];
         $_POST = $this->AccountTemplets->get_account_list($user_id);
     }
     // 保存编辑
     if (isset($_POST['save'])) {
         if ($this->AccountTemplets->save_account($_POST)) {
             $this->status = 'success';
             $this->notice = "AMWebsite:保存账号模板({$_POST['user_id']})成功。";
             $_POST = null;
         } else {
             $this->status = 'error';
             $this->notice = "AMWebsite:保存账号模板({$_POST['user_id']})失败。";
         }
     }
     // 新增
     if (isset($_POST['add'])) {
         if ($this->AccountTemplets->add_account($_POST)) {
             $this->status = 'success';
             $this->notice = "AMWebsite:新增账号模板({$_POST['user_id']})成功。";
             $_POST = null;
         } else {
             $this->status = 'error';
             $this->notice = "AMWebsite:新增账号模板({$_POST['user_id']})失败。";
         }
     }
     $this->indexs->log_insert($this->notice);
     $this->account_list = $this->AccountTemplets->get_account_list();
     $this->_view('AMWebsite_account_templet');
     // 加载模板文件
 }
Пример #13
0
 function module_ajax()
 {
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     Functions::get_module_score();
     Functions::get_module_available();
     echo json_encode($_SESSION['module_available']);
 }
Пример #14
0
 function php_setparam()
 {
     $this->title = 'AMH - Host - PHPSetParam';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $param_list = array(array('设置PHP时区', 'date.timezone', 'Asia/Hong_Kong'), array('是否显示PHP错误信息', 'display_errors', 'On / Off'), array('PHP运行内存限制', 'memory_limit', '68M'), array('POST数据最大限制', 'post_max_size', '4M'), array('上传文件最大限制', 'upload_max_filesize', '2M'), array('上传文件个数限制', 'max_file_uploads', '10'), array('脚本超时时间', 'max_execution_time', '20'), array('socket超时时间', 'default_socket_timeout', '60'), array('SESSION过期时间', 'session.cache_expire', '180'), array('是否开启短标签', 'short_open_tag', 'On / Off'), array('是否开启自动字符串转义', 'magic_quotes_gpc', 'On / Off'), array('是否外部字符串自动转义', 'magic_quotes_runtime', 'On / Off'));
     if (isset($_POST['submit'])) {
         foreach ($param_list as $key => $val) {
             $post_keyname = str_replace('.', '_', $val[1]);
             $cmd = "amh SetParam php {$val['1']} {$_POST[$post_keyname]}";
             $cmd = Functions::trim_cmd($cmd . ' noreload');
             // 只更改参数不重启
             $result = Functions::trim_result(shell_exec($cmd));
         }
         if (strpos($result, '[OK]') !== false) {
             $this->status = 'success';
             $this->notice = 'PHP配置更改成功。';
         } else {
             $this->status = 'error';
             $this->notice = 'PHP配置更改失败。';
         }
     }
     $param_list = $this->hosts->get_php_param($param_list);
     $this->param_list = $param_list;
     $this->_view('host_php_setparam');
 }
Пример #15
0
 function IndexAction()
 {
     $this->title = 'AMH - AMRewrite';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_GET['check_config'])) {
         $amh_cmd = 'amh module AMRewrite-1.0 admin check_config';
         $result = shell_exec($amh_cmd);
         $result = Functions::trim_result($result);
         if (strpos($result, 'is successful') !== false) {
             $this->status = 'success';
             $status = '[正确] Nginx配置Rewrite规则校验成功。';
         } else {
             $this->status = 'error';
             $status = '[警告] Nginx配置Rewrite规则错误,请查检改正。';
         }
         $this->notice = $status . "\n" . $result;
     }
     // 删除
     if (isset($_GET['del'])) {
         $del = $_GET['del'];
         if (strpos($del, '..') !== false || strpos($del, '/') !== false || strpos($del, 'amh.conf') !== false) {
             $this->status = 'error';
             $this->notice = "{$del}: 非法请求,删除Rewrite规则失败。";
         } else {
             $del_file = "/usr/local/nginx/conf/rewrite/{$del}";
             if (is_file($del_file) && unlink($del_file)) {
                 $this->status = 'success';
                 $this->notice = "{$del}: 删除成功,Rewrite规则删除成功。";
             } else {
                 $this->status = 'error';
                 $this->notice = "{$del}: 删除出错,Rewrite规则删除失败。";
             }
         }
     }
     // 新增规则 ***********
     if (isset($_POST['add'])) {
         if (!empty($_POST['rewrite_name'])) {
             $rewrite_name = $_POST['rewrite_name'];
             $rewrite_content = stripslashes($_POST['rewrite_content']);
             if (strpos($rewrite_name, '..') !== false || strpos($rewrite_name, '/') !== false) {
                 $this->status = 'error';
                 $this->notice = "{$rewrite_name}: 存在非法字符,添加新Rewrite规则失败。";
             } else {
                 $file = "/usr/local/nginx/conf/rewrite/{$rewrite_name}.conf";
                 if (is_file($file)) {
                     $this->status = 'error';
                     $this->notice = "{$rewrite_name}: 已存在,添加新Rewrite规则失败。";
                 } else {
                     file_put_contents($file, $rewrite_content);
                     if (is_file($file)) {
                         $_POST = null;
                         $this->status = 'success';
                         $this->notice = "{$rewrite_name}: 添加新Rewrite规则成功。";
                     } else {
                         $this->status = 'error';
                         $this->notice = "{$rewrite_name}: 添加新Rewrite规则失败。";
                     }
                 }
             }
         } else {
             $this->status = 'error';
             $this->notice = '添加新Rewrite规则失败,请填写规则名称。';
         }
     }
     // 查看
     if (isset($_GET['name'])) {
         $name = $_GET['name'];
         $file = "/usr/local/nginx/conf/rewrite/{$name}.conf";
         if (is_file($file)) {
             $_POST['rewrite_content'] = file_get_contents($file);
         }
     }
     // 保存
     if (isset($_POST['save'])) {
         if (!empty($_POST['rewrite_name'])) {
             $rewrite_name = $_POST['rewrite_name'];
             $rewrite_content = stripslashes($_POST['rewrite_content']);
             if (strpos($rewrite_name, '..') !== false || strpos($rewrite_name, '/') !== false) {
                 $this->status = 'error';
                 $this->notice = "{$rewrite_name}: 存在非法字符,保存Rewrite规则失败。";
             } else {
                 $file = "/usr/local/nginx/conf/rewrite/{$rewrite_name}.conf";
                 if (is_file($file)) {
                     file_put_contents($file, $rewrite_content);
                     if (file_get_contents($file) == $rewrite_content) {
                         $_POST = null;
                         $_POST['reload_nginx'] = true;
                         $this->status = 'success';
                         $this->notice = "{$rewrite_name}: 保存Rewrite规则成功。";
                     } else {
                         $this->status = 'error';
                         $this->notice = "{$rewrite_name}: 保存Rewrite规则失败。";
                     }
                 } else {
                     $this->status = 'error';
                     $this->notice = "{$rewrite_name}: 不存在,保存Rewrite规则失败。";
                 }
             }
         } else {
             $this->status = 'error';
             $this->notice = '保存Rewrite规则失败,错误的规则名称。';
         }
     }
     // 列表 ***********
     $rewrite_file = scandir("/usr/local/nginx/conf/rewrite");
     $host_list = $this->hosts->host_list();
     foreach ($rewrite_file as $key => $val) {
         if (!in_array($val, array('.', '..'))) {
             $rewrite_list[$val] = array();
         }
     }
     foreach ($host_list as $key => $val) {
         if (isset($rewrite_list[$val['host_rewrite']])) {
             $rewrite_list[$val['host_rewrite']][] = $val['host_domain'];
         }
     }
     $this->indexs->log_insert($this->notice);
     $this->rewrite_list = $rewrite_list;
     $this->_view('amrewrite');
 }
Пример #16
0
 function backup_revert()
 {
     $this->title = '一键还原 - 备份 - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     $revert_id = isset($_GET['revert_id']) ? (int) $_GET['revert_id'] : '';
     if (!empty($revert_id)) {
         $revert = $this->backups->get_backup($revert_id);
     }
     $this->revert = $revert;
     if (isset($_POST['revert_submit'])) {
         set_time_limit(0);
         $backup_file = $revert['backup_file'];
         $backup_password = empty($_POST['backup_password']) ? 'n' : $_POST['backup_password'];
         $this->category = $category;
         $this->_view('backup_revert_ing');
         $cmd = "amh revert {$backup_file} {$backup_password} noreload";
         $cmd = Functions::trim_cmd($cmd);
         $popen_handle = popen($cmd, 'r');
         $i = 0;
         $_i = 50;
         echo '<div id="show_result">';
         while (!feof($popen_handle)) {
             $line = fgets($popen_handle);
             echo $line . '<br />';
             if ($i % 200 == 0) {
                 ++$_i;
             }
             if ($i % $_i == 0) {
                 echo "<script>amh_cmd_ing();</script>\n";
             }
             ++$i;
             if (!empty($line)) {
                 $result = $line;
             }
         }
         $revert_ing_status = json_encode(pclose($popen_handle));
         $result_status = !$revert_ing_status ? true : false;
         if ($result_status) {
             $this->status = 'success';
             $this->notice = $backup_file . ' 数据一键还原成功。';
             $_POST = array();
         } else {
             $this->status = 'error';
             $this->notice = $result . $backup_file . ' 一键还原失败。';
         }
         $notice = json_encode($this->notice);
         echo "<script>amh_cmd_ing();revert_ing_status = {$revert_ing_status}; revert_result = {$notice}; revert_end();</script>{$line}</div>";
         $this->indexs->log_insert($this->notice);
         exit;
     }
     $this->indexs->log_insert($this->notice);
     $this->_view('backup_revert');
 }
Пример #17
0
 function module_down()
 {
     $this->title = '下载模块 - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_GET['module_name'])) {
         $module_name = $_GET['module_name'];
         if (!empty($module_name)) {
             $status = $this->modules->module_download($module_name);
             if ($status[0]) {
                 $this->status = 'success';
                 $this->notice = "模块下载成功:{$module_name}";
             } else {
                 $this->status = 'error';
                 if (strpos(serialize($status[1]), 'already exist.') !== false) {
                     $this->notice = "模块已存在下载失败:{$module_name}";
                 } else {
                     $this->notice = "模块下载失败:{$module_name}";
                 }
             }
         } else {
             $this->status = 'error';
             $this->notice = "请输入模块名字。";
         }
     }
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $page_sum = 5;
     $new_module_list = $this->modules->get_new_module_list($page, $page_sum);
     $total_page = ceil($new_module_list['sum'] / $page_sum);
     $page_list = Functions::page('NewModuleList', $new_module_list['sum'], $total_page, $page, "c=module&a=module_down&search_type={$_GET['search_type']}&m_txt={$_GET['m_txt']}");
     // 分页列表
     $this->page = $page;
     $this->total_page = $total_page;
     $this->page_list = $page_list;
     $this->new_module_list = $new_module_list;
     $this->indexs->log_insert($this->notice);
     $this->_view('module_down');
 }
Пример #18
0
 function upgrade_notice()
 {
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $upgrade_sum = $this->configs->get_upgrade_notice();
     echo (int) $upgrade_sum;
 }
Пример #19
0
 function mysql_password()
 {
     $this->title = '修改密码 - MySQL - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_POST['submit'])) {
         $user_action = $_POST['user_action'];
         $user_password1 = $_POST['user_password1'];
         $user_password2 = $_POST['user_password2'];
         $mysql_user_list = json_decode(base64_decode($_POST['mysql_user_list']));
         $user_name = $mysql_user_list[$_POST['user_name']];
         // 删除或修改密码
         if ($user_action == 'del') {
             if ($user_name->User == 'root') {
                 $this->status = 'error';
                 $this->notice .= ' MySQL用户删除失败: 面板不允许删除root账号。';
             } elseif ($this->mysqls->del_mysql_user($user_name)) {
                 $this->status = 'success';
                 $this->notice .= ' MySQL用户删除成功:' . $user_name->User . ' - ' . $user_name->Host;
                 $_POST = array();
             } else {
                 $this->status = 'error';
                 $this->notice .= ' MySQL用户删除失败:' . mysql_error();
             }
         } else {
             if ($user_password1 == $user_password2) {
                 if ($_SESSION['amh_config']['DataPrivate']['config_value'] == 'on' && $user_name->User == 'root') {
                     $this->status = 'error';
                     $this->notice .= ' MySQL用户密码修改失败: 您已开启面板数据私有保护,面板不可更改root账号密码。';
                 } elseif ($this->mysqls->set_mysql_password($user_name, $user_password1)) {
                     $this->status = 'success';
                     $this->notice .= ' MySQL用户密码修改成功:' . $user_name->User . ' - ' . $user_name->Host;
                     if ($user_name->User == 'root' && $user_name->Host == 'localhost') {
                         $file = '/home/wwwroot/index/web/Amysql/Config.php';
                         $contents = file_get_contents($file);
                         $root_pass = str_replace('$', '\\$', $user_password1);
                         $contents = preg_replace("/\\\$Config\\['Password'\\] = '.*';/", "\$Config['Password'] = '******';", $contents);
                         file_put_contents($file, $contents);
                     }
                     $_POST = array();
                 } else {
                     $this->status = 'error';
                     $this->notice .= ' MySQL用户密码修改失败:' . mysql_error();
                 }
             } else {
                 $this->status = 'error';
                 $this->notice = 'MySQL用户密码修改失败:两次密码不一致。';
             }
         }
     }
     $mysql_user_list = $this->mysqls->get_mysql_user_list();
     $this->mysql_user_list = $mysql_user_list;
     $this->indexs->log_insert($this->top_notice . $this->notice);
     $this->_view('mysql_password');
 }