本文整理汇总了PHP中Functions::trim_result方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::trim_result方法的具体用法?PHP Functions::trim_result怎么用?PHP Functions::trim_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::trim_result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_module_list_data
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: AMNetwork_ps
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: get_mysql_param
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: get_amh_config
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: get_module_list_data
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: module_list
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: get_php_param
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: get_upgrade_notice
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: infos
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: backup_remote
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: backup_list
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'];
//.........这里部分代码省略.........
示例12: get_module_available
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: IndexAction
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 {
//.........这里部分代码省略.........
示例14: get_task_list
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: ftp_del_ssh
function ftp_del_ssh($del_name)
{
$cmd = "amh ftp del {$del_name}";
$cmd = Functions::trim_cmd($cmd);
return Functions::trim_result(shell_exec($cmd));
}