Пример #1
0
 function get_module_list_data($page = 1, $page_sum = 5)
 {
     $cmd = 'amh ls_modules';
     $result = trim(shell_exec($cmd), "\n");
     if (empty($result)) {
         return array('data' => array(), 'sum' => 0);
     }
     $run_list = explode("\n", $result);
     $sum = count($run_list);
     $run_list = array_slice($run_list, ($page - 1) * $page_sum, $page_sum);
     $param_arr = array('AMH-ModuleName', 'AMH-ModuleIco', 'AMH-ModuleDescription', 'AMH-ModuleButton', 'AMH-ModuleDate', 'AMH-ModuleAdmin', 'AMH-ModuleWebSite', 'AMH-ModuleScriptBy');
     $module_data = array();
     if (is_array($run_list)) {
         Functions::get_module_score();
         foreach ($run_list as $key => $val) {
             // Module Info
             $cmd = "amh module {$val} info";
             $cmd = Functions::trim_cmd($cmd);
             $result = trim(shell_exec($cmd), "\n");
             $result = Functions::trim_result($result);
             foreach ($param_arr as $k => $v) {
                 preg_match("/{$v}:(.*)/", $result, $param_value);
                 $arr[$v] = trim($param_value[1]);
             }
             // Module Status
             $cmd = "amh module {$val} status";
             $cmd = Functions::trim_cmd($cmd);
             exec($cmd, $tmp, $status);
             $arr['AMH-ModuleStatus'] = $status ? 'false' : 'true';
             $arr['AMH-ModuleName'] = addslashes($arr['AMH-ModuleName']);
             $arr['AMH-ModuleButton'] = explode('/', $arr['AMH-ModuleButton']);
             if ($arr['AMH-ModuleStatus'] == 'true') {
                 $arr['AMH-ModuleButton'] = $arr['AMH-ModuleButton'][1];
                 $arr['AMH-ModuleAction'] = 'uninstall';
             } else {
                 $arr['AMH-ModuleButton'] = $arr['AMH-ModuleButton'][0];
                 $arr['AMH-ModuleAction'] = 'install';
             }
             $arr['AMH-ModuleScore'] = isset($_SESSION['module_score'][$arr['AMH-ModuleName']]) ? $_SESSION['module_score'][$arr['AMH-ModuleName']] : '';
             $arr['AMH-ModuleIco'] = isset($_SESSION['module_score']) && count($_SESSION['module_score']) > 0 ? $arr['AMH-ModuleIco'] : '';
             $i = strtotime($arr['AMH-ModuleDate']) + $key;
             $data[$i] = $arr;
         }
         if (is_array($data)) {
             krsort($data);
             $i = 0;
             foreach ($data as $key => $val) {
                 $module_data[$i++ % 3][] = $val;
             }
             unset($data);
         }
     }
     return array('data' => $module_data, 'sum' => $sum);
 }
Пример #2
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');
 }
Пример #3
0
 function get_mysql_param($param_list)
 {
     $cmd = "amh cat_my_cnf";
     $cmd = Functions::trim_cmd($cmd);
     $my_cnf = Functions::trim_result(shell_exec($cmd));
     foreach ($param_list as $key => $val) {
         preg_match("/{$val['1']} = (.*)/", $my_cnf, $param_val);
         if ($val[1] == 'InnoDB_Engine') {
             $param_val[1] = preg_match("/innodb = OFF/", $my_cnf) ? 'Off' : 'On';
         }
         $param_list[$key][3] = $param_val[1];
     }
     return $param_list;
 }
Пример #4
0
 function get_amh_config()
 {
     $sql = "SELECT * FROM amh_config";
     $result = $this->_query($sql);
     while ($rs = mysql_fetch_assoc($result)) {
         $data[$rs['config_name']] = $rs;
     }
     $cmd = "amh cat_nginx";
     $result = trim(shell_exec($cmd), "\n");
     $result = Functions::trim_result($result);
     preg_match('/listen[\\s]*([0-9]+)/', $result, $listen);
     $data['AMHListen']['config_value'] = $listen[1];
     preg_match('/\\$host != \'(.*)\'/', $result, $domain);
     $data['AMHDomain']['config_value'] = isset($domain[1]) ? $domain[1] : 'Off';
     return $data;
 }
Пример #5
0
 function get_module_list_data($page = 1, $page_sum = 5)
 {
     $cmd = 'amh ls_modules';
     $result = trim(shell_exec($cmd), "\n");
     if (empty($result)) {
         return array('data' => array(), 'sum' => 0);
     }
     $run_list = explode("\n", $result);
     $sum = count($run_list);
     $run_list = array_slice($run_list, ($page - 1) * $page_sum, $page_sum);
     $param_arr = array('AMH-ModuleName', 'AMH-ModuleDescription', 'AMH-ModuleButton', 'AMH-ModuleDate', 'AMH-ModuleAdmin', 'AMH-ModuleWebSite', 'AMH-MoudleScriptBy');
     if (is_array($run_list)) {
         foreach ($run_list as $key => $val) {
             // Module Info
             $cmd = "amh module {$val} info";
             $cmd = Functions::trim_cmd($cmd);
             $result = trim(shell_exec($cmd), "\n");
             $result = Functions::trim_result($result);
             foreach ($param_arr as $k => $v) {
                 preg_match("/{$v}:(.*)/", $result, $param_value);
                 $arr[$v] = trim($param_value[1]);
             }
             // Module Status
             $cmd = "amh module {$val} status";
             $cmd = Functions::trim_cmd($cmd);
             exec($cmd, $tmp, $status);
             $arr['AMH-ModuleStatus'] = $status ? 'false' : 'true';
             $arr['AMH-ModuleName'] = addslashes($arr['AMH-ModuleName']);
             $arr['AMH-ModuleButton'] = explode('/', $arr['AMH-ModuleButton']);
             if ($arr['AMH-ModuleStatus'] == 'true') {
                 $arr['AMH-ModuleButton'] = $arr['AMH-ModuleButton'][1];
                 $arr['AMH-ModuleAction'] = 'uninstall';
             } else {
                 $arr['AMH-ModuleButton'] = $arr['AMH-ModuleButton'][0];
                 $arr['AMH-ModuleAction'] = 'install';
             }
             $data[] = $arr;
         }
     }
     return array('data' => $data, 'sum' => $sum);
 }
Пример #6
0
 function module_list()
 {
     $this->title = 'AMH - Module';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     if (isset($_GET['action']) && isset($_GET['name'])) {
         $name = $_GET['name'];
         $action = $_GET['action'];
         $action_list = array('install' => '安装', 'uninstall' => '卸载', 'delete' => '删除');
         $result = '';
         if (isset($action_list[$action])) {
             $cmd = "amh module {$name} {$action} y";
             $cmd = Functions::trim_cmd($cmd);
             $result = trim(shell_exec($cmd), "\n");
             $result = Functions::trim_result($result);
         }
         if (strpos($result, '[OK]') !== false && strpos($result, '[Error]') == false) {
             $this->status = 'success';
             $this->notice = "{$name} {$action_list[$action]}成功。";
         } else {
             $this->status = 'error';
             $this->notice = "{$name} {$action_list[$action]}失败。";
         }
     }
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $page_sum = 5;
     $get_module_list_data = $this->modules->get_module_list_data($page, $page_sum);
     $total_page = ceil($get_module_list_data['sum'] / $page_sum);
     $page_list = Functions::page('ModuleList', $get_module_list_data['sum'], $total_page, $page, 'c=module&a=module_list');
     // 分页列表
     global $Config;
     $Config['XSS'] = false;
     $this->page = $page;
     $this->total_page = $total_page;
     $this->page_list = $page_list;
     $this->module_list_data = $get_module_list_data;
     $this->indexs->log_insert($this->notice);
     $this->_view('module_list');
 }
Пример #7
0
 function get_php_param($param_list)
 {
     $cmd = "amh cat_php_ini";
     $cmd = Functions::trim_cmd($cmd);
     $php_ini = Functions::trim_result(shell_exec($cmd));
     foreach ($param_list as $key => $val) {
         preg_match("/{$val['1']} = (.*)/", $php_ini, $param_val);
         $param_list[$key][3] = $param_val[1];
     }
     return $param_list;
 }
Пример #8
0
 function get_upgrade_notice()
 {
     $cmd = 'amh upgrade list';
     $result = shell_exec($cmd);
     $result = Functions::trim_result($result);
     $upgrade_list = explode("\n", trim($result));
     $upgrade_sum = 0;
     foreach ($upgrade_list as $key => $val) {
         if (!empty($val)) {
             // Upgrade install_status
             $cmd = "amh upgrade {$val} install_status";
             $cmd = Functions::trim_cmd($cmd);
             exec($cmd, $tmp, $status);
             if ($status) {
                 ++$upgrade_sum;
             }
         }
     }
     $sql = "UPDATE amh_config SET config_value = '{$upgrade_sum}' WHERE config_name = 'UpgradeSum' ";
     $this->_query($sql);
     $_SESSION['amh_config'] = $this->get_amh_config();
     return $upgrade_sum;
 }
Пример #9
0
 function infos()
 {
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $cmd = "amh info";
     $result = shell_exec($cmd);
     $result = trim(Functions::trim_result($result), "\n ");
     $this->infos = $result;
     $this->_view('infos');
 }
Пример #10
0
 function backup_remote()
 {
     $this->title = '远程设置 - 备份 - AMH';
     $this->AmysqlModelBase();
     Functions::CheckLogin();
     $this->status = 'error';
     $input_item = array('remote_type', 'remote_status', 'remote_ip', 'remote_path', 'remote_user', 'remote_password');
     // 连接测试
     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}";
         }
         if ($data['remote_type'] == 'SSH') {
             $cmd = "amh BRssh check {$id}";
         }
         if ($cmd) {
             $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->top_notice = 'ID:' . $id . ' 删除远程备份配置成功。';
             } else {
                 $this->top_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();
     $this->indexs->log_insert($this->notice);
     $this->_view('backup_remote');
 }
Пример #11
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');
 }
Пример #12
0
 function get_module_available()
 {
     // if (isset($_SESSION['module_available'])) Return;
     $cmd = 'amh ls_modules';
     $result = trim(shell_exec($cmd), "\n");
     if (empty($result)) {
         return array();
     }
     $data = array();
     $run_list = explode("\n", $result);
     foreach ($run_list as $key => $val) {
         // Module Status
         $cmd = "amh module {$val} status";
         $cmd = Functions::trim_cmd($cmd);
         exec($cmd, $tmp, $status);
         if (!$status) {
             // Module Info
             $cmd = "amh module {$val} info";
             $cmd = Functions::trim_cmd($cmd);
             $result = trim(shell_exec($cmd), "\n");
             $result = Functions::trim_result($result);
             preg_match("/AMH-ModuleAdmin:(.*)/", $result, $ModuleAdmin);
             // preg_match("/AMH-ModuleIco:(.*)/", $result, $ModuleIco);
             $ModuleID = explode('-', $val);
             $data[] = array('ModuleID' => $ModuleID[0], 'ModuleName' => $val, 'ModuleAdmin' => $ModuleAdmin[1]);
         }
     }
     $_SESSION['module_available'] = $data;
 }
Пример #13
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');
 }
Пример #14
0
 function get_task_list()
 {
     $cmd = 'amh crontab list';
     $result = shell_exec($cmd);
     $task_list = explode("\n", Functions::trim_result($result));
     foreach ($task_list as $key => $val) {
         $val_arr = explode(' ', preg_replace("/[ ]+/", " ", trim($val)));
         if ($val_arr[0] != '#' && $val_arr[0][0] != '#' && count($val_arr) > 5) {
             $crontab_minute = $val_arr[0];
             $crontab_hour = $val_arr[1];
             $crontab_day = $val_arr[2];
             $crontab_month = $val_arr[3];
             $crontab_week = $val_arr[4];
             $crontab_ssh = '';
             $crontab_type = 'ssh';
             foreach ($val_arr as $k => $v) {
                 if ($k > 4) {
                     $crontab_ssh .= ' ' . $v;
                 }
             }
             $crontab_ssh = trim($crontab_ssh);
             $crontab_md5 = md5($crontab_minute . $crontab_hour . $crontab_day . $crontab_month . $crontab_week . $crontab_ssh);
             $all_task_list[] = $crontab_md5;
             $task_info = $this->get_task(null, $crontab_md5);
             if (!isset($task_info['crontab_id'])) {
                 $this->_insert('amh_crontab', array('crontab_minute' => $crontab_minute, 'crontab_hour' => $crontab_hour, 'crontab_day' => $crontab_day, 'crontab_month' => $crontab_month, 'crontab_week' => $crontab_week, 'crontab_ssh' => $crontab_ssh, 'crontab_type' => $crontab_type, 'crontab_md5' => $crontab_md5));
             }
         }
     }
     if (count($all_task_list) > 0) {
         $sql = "DELETE FROM amh_crontab WHERE crontab_md5 NOT IN ('" . implode("','", $all_task_list) . "')";
         $this->_query($sql);
     } else {
         $sql = "TRUNCATE TABLE `amh_crontab`";
         $this->_query($sql);
     }
     $sql = "SELECT * FROM amh_crontab ORDER BY crontab_id ASC ";
     return $this->_all($sql);
 }
Пример #15
0
 function ftp_del_ssh($del_name)
 {
     $cmd = "amh ftp del {$del_name}";
     $cmd = Functions::trim_cmd($cmd);
     return Functions::trim_result(shell_exec($cmd));
 }
Пример #16
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');
 }