格式代码

Signed-off-by: HITSword <admin@huayizhiyun.com>
master
HITSword 2020-01-09 17:39:19 +08:00
parent 764b9c0aaa
commit 5a3b977f1b
7 changed files with 892 additions and 885 deletions

View File

@ -1,209 +1,203 @@
<?php <?php
class hyproxy extends AmysqlController { class hyproxy extends AmysqlController
{
public $indexs = null; public $indexs = null;
public $hyproxys = null; public $hyproxys = null;
public $notice = null; public $notice = null;
// 载入数据模型(Model) // 载入数据模型(Model)
function AmysqlModelBase() { function AmysqlModelBase()
if($this -> indexs) return; {
$this -> _class('Functions'); if ($this -> indexs) {
$this -> indexs = $this -> _model('indexs'); return;
$this -> hyproxys = $this -> _model('hyproxys'); }
} $this -> _class('Functions');
$this -> indexs = $this -> _model('indexs');
$this -> hyproxys = $this -> _model('hyproxys');
}
function IndexAction(){ function IndexAction()
$this -> hyproxy_list(); {
} $this -> hyproxy_list();
}
// 反代列表 // 反代列表
function hyproxy_list(){ function hyproxy_list()
$this -> title = '反代列表 - HYProxy'; // 面板模块标题 {
$this -> AmysqlModelBase(); $this -> title = '反代列表 - HYProxy'; // 面板模块标题
Functions::CheckLogin(); // 面板登录检查函数 $this -> AmysqlModelBase();
Functions::CheckLogin(); // 面板登录检查函数
$this -> status = 'error'; $this -> status = 'error';
// 状态 // 状态
if (isset($_GET['run'])) { if (isset($_GET['run'])) {
$run_name = $_GET['run']; $run_name = $_GET['run'];
$run_zh = array( $run_zh = array(
'start' => '启动', 'start' => '启动',
'stop' => '停止' 'stop' => '停止'
); );
if ( !empty($run_name) && isset($run_zh[$_GET['g']]) ) { if (!empty($run_name) && isset($run_zh[$_GET['g']])) {
$g = $_GET['g']; $g = $_GET['g'];
$result = $this->hyproxys->hyproxy_run($run_name, $g); $result = $this->hyproxys->hyproxy_run($run_name, $g);
$this->status = $result['status']; $this->status = $result['status'];
$this->notice = $result['notice']; $this->notice = $result['notice'];
} }
} }
// 缓存状态 // 缓存状态
if (isset($_GET['run_cache'])) { if (isset($_GET['run_cache'])) {
$run_name = $_GET['run_cache']; $run_name = $_GET['run_cache'];
$run_zh = array( $run_zh = array(
'1' => '启动', '1' => '启动',
'0' => '停止' '0' => '停止'
); );
if (!empty($run_name) && isset($run_zh[$_GET['g']])) { if (!empty($run_name) && isset($run_zh[$_GET['g']])) {
$g = $_GET['g']; $g = $_GET['g'];
$result = $this->hyproxys->hyproxy_run_cache($run_name, $g); $result = $this->hyproxys->hyproxy_run_cache($run_name, $g);
$this->status = $result['status']; $this->status = $result['status'];
$this->notice = $result['notice']; $this->notice = $result['notice'];
} }
} }
// 删除 // 删除
if (isset($_GET['del'])) { if (isset($_GET['del'])) {
$del_name = $_GET['del']; $del_name = $_GET['del'];
if (!empty($del_name)) { if (!empty($del_name)) {
$result = $this->hyproxys->hyproxy_del($del_name); $result = $this->hyproxys->hyproxy_del($del_name);
$this->status = $result['status']; $this->status = $result['status'];
$this->notice = $result['notice']; $this->notice = $result['notice'];
} }
} }
// 管理 // 管理
if (isset($_GET['admin'])) { if (isset($_GET['admin'])) {
if (isset($_POST['edit'])) { if (isset($_POST['edit'])) {
$result = $this->hyproxys->hyproxy_edit(); $result = $this->hyproxys->hyproxy_edit();
$this->status = $result['status']; $this->status = $result['status'];
$this->notice = $result['notice']; $this->notice = $result['notice'];
} }
$name = $_GET['admin']; $name = $_GET['admin'];
$this->hyproxy_get = $this->hyproxys->hyproxy_get($name); $this->hyproxy_get = $this->hyproxys->hyproxy_get($name);
} }
// 新增 // 新增
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
$server_name = $_POST['server_name']; $server_name = $_POST['server_name'];
$proxy_pass = $_POST['proxy_pass']; $proxy_pass = $_POST['proxy_pass'];
if (!empty($server_name) && !empty($proxy_pass)) { if (!empty($server_name) && !empty($proxy_pass)) {
$result = $this->hyproxys->hyproxy_add($server_name, $proxy_pass); $result = $this->hyproxys->hyproxy_add($server_name, $proxy_pass);
$this->status = $result['status']; $this->status = $result['status'];
$this->notice = $result['notice']; $this->notice = $result['notice'];
} else { } else {
$this->notice = '请填写完整数据。'; $this->notice = '请填写完整数据。';
} }
} }
$this -> indexs -> log_insert($this -> notice); $this -> indexs -> log_insert($this -> notice);
$this -> hyproxy_list = $this -> hyproxys -> hyproxy_list(); $this -> hyproxy_list = $this -> hyproxys -> hyproxy_list();
$this -> _view('hyproxy_list'); $this -> _view('hyproxy_list');
} }
// ********************************************************* // *********************************************************
// 缓存设置 // 缓存设置
function hyproxy_cache(){ function hyproxy_cache()
$this -> title = '缓存设置 - HYProxy - AMH';
$this -> AmysqlModelBase();
Functions::CheckLogin();
// 保存
if (isset($_POST['save']))
{ {
$this -> status = 'error'; $this -> title = '缓存设置 - HYProxy - AMH';
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive'); $this -> AmysqlModelBase();
foreach ($field as $key=>$val) Functions::CheckLogin();
{
if (!isset($_POST[$val]) || empty($_POST[$val]))
{
$error = true;
break;
}
}
if (isset($error))
$this -> notice = '请填写完整数据。';
else
{
if ($this -> hyproxys -> save_hyproxy_cache())
{
$this -> status = 'success';
$this -> notice = 'HYProxy 缓存设置成功。';
}
else
$this -> notice = 'HYProxy 缓存设置失败。';
}
// 保存
if (isset($_POST['save'])) {
$this -> status = 'error';
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive');
foreach ($field as $key => $val) {
if (!isset($_POST[$val]) || empty($_POST[$val])) {
$error = true;
break;
}
}
if (isset($error)) {
$this -> notice = '请填写完整数据。';
} else {
if ($this -> hyproxys -> save_hyproxy_cache()) {
$this -> status = 'success';
$this -> notice = 'HYProxy 缓存设置成功。';
} else {
$this -> notice = 'HYProxy 缓存设置失败。';
}
}
}
$this -> indexs -> log_insert($this -> notice);
$this -> hyproxy_cache = $this -> hyproxys -> get_hyproxy_cache();
$this -> _view('hyproxy_cache');
} }
$this -> indexs -> log_insert($this -> notice);
$this -> hyproxy_cache = $this -> hyproxys -> get_hyproxy_cache();
$this -> _view('hyproxy_cache');
}
// ********************************************************* // *********************************************************
// 缓存索引 // 缓存索引
function hyproxy_cache_index(){ function hyproxy_cache_index()
$this -> title = '缓存索引 - HYProxy - AMH';
$this -> AmysqlModelBase();
Functions::CheckLogin();
if (isset($_POST['post_submit']))
{ {
if ($this -> hyproxys -> create_hyproxy_cache_index()) $this -> title = '缓存索引 - HYProxy - AMH';
{ $this -> AmysqlModelBase();
$this -> status = 'success'; Functions::CheckLogin();
$this -> notice = 'HYProxy 创建缓存索引成功。';
}
else
{
$this -> status = 'error';
$this -> notice = 'HYProxy 创建缓存索引失败。';
}
}
$this -> indexs -> log_insert($this -> notice); if (isset($_POST['post_submit'])) {
$this -> hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index(); if ($this -> hyproxys -> create_hyproxy_cache_index()) {
$this -> _view('hyproxy_cache_index'); $this -> status = 'success';
} $this -> notice = 'HYProxy 创建缓存索引成功。';
} else {
$this -> status = 'error';
$this -> notice = 'HYProxy 创建缓存索引失败。';
}
}
$this -> indexs -> log_insert($this -> notice);
$this -> hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index();
$this -> _view('hyproxy_cache_index');
}
// ********************************************************* // *********************************************************
// 缓存删除 // 缓存删除
function hyproxy_cache_del(){ function hyproxy_cache_del()
$this -> title = '缓存删除 - HYProxy - AMH';
$this -> AmysqlModelBase();
Functions::CheckLogin();
// 删除缓存
if (isset($_POST['post_delete']))
{ {
if ($this -> hyproxys -> hyproxy_cache_delete()) $this -> title = '缓存删除 - HYProxy - AMH';
{ $this -> AmysqlModelBase();
$this -> status = 'success'; Functions::CheckLogin();
$this -> notice = 'HYProxy 缓存删除成功。';
} // 删除缓存
else if (isset($_POST['post_delete'])) {
{ if ($this -> hyproxys -> hyproxy_cache_delete()) {
$this -> status = 'error'; $this -> status = 'success';
$this -> notice = 'HYProxy 缓存删除失败。'; $this -> notice = 'HYProxy 缓存删除成功。';
} } else {
$this -> status = 'error';
$this -> notice = 'HYProxy 缓存删除失败。';
}
}
// 取得域名列表与缓存文件类型
$hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index();
foreach ($hyproxy_cache_index as $key => $val) {
$cache_host[] = $key;
foreach ($val as $k => $v) {
$cache_type[$k] = $k;
}
}
// 缓存列表
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$page_sum = 20;
$hyproxy_cache_list = $this -> hyproxys -> get_hyproxy_cache_list($page, $page_sum);
$total_page = ceil($hyproxy_cache_list['sum'] / $page_sum);
$page_list = Functions::page('AccountLog', $hyproxy_cache_list['sum'], $total_page, $page); // 分页列表
$this -> page = $page;
$this -> total_page = $total_page;
$this -> page_list = $page_list;
$this -> hyproxy_cache_list = $hyproxy_cache_list;
$this -> cache_host = $cache_host;
$this -> cache_type = $cache_type;
$this -> indexs -> log_insert($this -> notice);
$this -> _view('hyproxy_cache_del');
} }
}
// 取得域名列表与缓存文件类型
$hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index();
foreach ($hyproxy_cache_index as $key=>$val)
{
$cache_host[] = $key;
foreach ($val as $k=>$v)
$cache_type[$k] = $k;
}
// 缓存列表
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$page_sum = 20;
$hyproxy_cache_list = $this -> hyproxys -> get_hyproxy_cache_list($page, $page_sum);
$total_page = ceil($hyproxy_cache_list['sum'] / $page_sum);
$page_list = Functions::page('AccountLog', $hyproxy_cache_list['sum'], $total_page, $page); // 分页列表
$this -> page = $page;
$this -> total_page = $total_page;
$this -> page_list = $page_list;
$this -> hyproxy_cache_list = $hyproxy_cache_list;
$this -> cache_host = $cache_host;
$this -> cache_type = $cache_type;
$this -> indexs -> log_insert($this -> notice);
$this -> _view('hyproxy_cache_del');
}
}

View File

@ -1,238 +1,258 @@
<?php <?php
class hyproxys extends AmysqlModel{ class hyproxys extends AmysqlModel
function hyclear_result($str){ {
$str = Functions::trim_result($str); function hyclear_result($str)
$str = str_replace(array('[OK] HYProxy is already installed.', '[OK] Nginx reload','[HYProxy-1.0 admin]'), '', $str); {
$arr = explode("\n", $str); //分割为数组,每行为一个数组元素 $str = Functions::trim_result($str);
$arr = array_filter(array_map('trim',$arr)); //去除数组中的空元素 $str = str_replace(array('[OK] HYProxy is already installed.', '[OK] Nginx reload','[HYProxy-1.0 admin]'), '', $str);
return implode(PHP_EOL,$arr); //用换行符连结数组为字符串 $arr = explode("\n", $str); //分割为数组,每行为一个数组元素
} $arr = array_filter(array_map('trim', $arr)); //去除数组中的空元素
return implode(PHP_EOL, $arr); //用换行符连结数组为字符串
// 反代列表 }
function hyproxy_list($args=''){//OK
//TODO // 反代列表
//$server_name = $args['server_name'];域名搜索 function hyproxy_list($args = '')
//$status;//状态搜索start/stop {
//分页 //OK
$sql = "SELECT * FROM module_hyproxy ORDER BY hyproxy_id ASC"; //TODO
return $this -> _all($sql); //$server_name = $args['server_name'];域名搜索
} //$status;//状态搜索start/stop
// 取得反代网站 //分页
function hyproxy_get($name){//OK $sql = "SELECT * FROM module_hyproxy ORDER BY hyproxy_id ASC";
$sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'"; return $this -> _all($sql);
return $this -> _row($sql); }
} // 取得反代网站
// 增加反代网站 function hyproxy_get($name)
function hyproxy_add($server_name, $proxy_pass){//OK {
$server_name = trim($server_name); //OK
$proxy_pass = trim($proxy_pass); $sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'";
$proxy = $this->hyproxy_get($server_name); return $this -> _row($sql);
if ($proxy) { }
return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' ); // 增加反代网站
} else { function hyproxy_add($server_name, $proxy_pass)
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name; {
if(!preg_match('/^http(s)?:\\/\\/.+/',$proxy_pass)){ //OK
$proxy_pass = 'http://'.$proxy_pass; $server_name = trim($server_name);
} $proxy_pass = trim($proxy_pass);
$data = array( $proxy = $this->hyproxy_get($server_name);
'server_name' => $server_name, if ($proxy) {
'index' => 'index.php index.html index.htm', return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' );
'header_host' => '$host', } else {
'proxy_pass' => $proxy_pass, empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
'proxy_cache' => 1, if (!preg_match('/^http(s)?:\\/\\/.+/', $proxy_pass)) {
'status' => 'start', $proxy_pass = 'http://'.$proxy_pass;
'time' => time() }
); $data = array(
$res = $this -> _insert('module_hyproxy', $data); 'server_name' => $server_name,
if ($res) { 'index' => 'index.php index.html index.htm',
$cmd = "amh module HYProxy-1.0 admin make,$server_name"; 'header_host' => '$host',
$cmd = Functions::trim_cmd($cmd); 'proxy_pass' => $proxy_pass,
shell_exec($cmd); 'proxy_cache' => 1,
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' ); 'status' => 'start',
}else { 'time' => time()
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名增加失败。' ); );
} $res = $this -> _insert('module_hyproxy', $data);
} if ($res) {
} $cmd = "amh module HYProxy-1.0 admin make,$server_name";
// 编辑反代网站 $cmd = Functions::trim_cmd($cmd);
function hyproxy_edit(){//OK shell_exec($cmd);
$server_name = trim($_POST['server_name']); return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' );
if ($_POST['index']!=$_POST['index_hidden']) {//默认首页 } else {
$data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']); return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名增加失败。' );
} }
if ($_POST['header_host']!=$_POST['header_host_hidden']) {//Host头 }
$data['header_host'] = empty($_POST['header_host']) ? '$host' : trim($_POST['header_host']); }
} // 编辑反代网站
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址 function hyproxy_edit()
$data['proxy_pass'] = trim($_POST['proxy_pass']); {
empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name; //OK
if(!preg_match('/^http(s)?:\\/\\/.+/',$data['proxy_pass'])){ $server_name = trim($_POST['server_name']);
$data['proxy_pass'] = 'http://'.$data['proxy_pass']; if ($_POST['index']!=$_POST['index_hidden']) {//默认首页
} $data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']);
} }
$data['time'] = time();//时间戳 if ($_POST['header_host']!=$_POST['header_host_hidden']) {//Host头
$where = sprintf("WHERE `server_name` = '%s'",$server_name);//查询条件 $data['header_host'] = empty($_POST['header_host']) ? '$host' : trim($_POST['header_host']);
$res = $this -> _update('module_hyproxy',$data,$where); }
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址
if ($res) { $data['proxy_pass'] = trim($_POST['proxy_pass']);
$cmd = "amh module HYProxy-1.0 admin make,$server_name"; empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name;
$cmd = Functions::trim_cmd($cmd); if (!preg_match('/^http(s)?:\\/\\/.+/', $data['proxy_pass'])) {
shell_exec($cmd); $data['proxy_pass'] = 'http://'.$data['proxy_pass'];
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' ); }
}else { }
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' ); $data['time'] = time();//时间戳
} $where = sprintf("WHERE `server_name` = '%s'", $server_name);//查询条件
} $res = $this -> _update('module_hyproxy', $data, $where);
// 删除反代网站
function hyproxy_del($del_name){//OK if ($res) {
$del_name = trim($del_name); $cmd = "amh module HYProxy-1.0 admin make,$server_name";
$cmd = "amh module HYProxy-1.0 admin del,$del_name"; $cmd = Functions::trim_cmd($cmd);
$cmd = Functions::trim_cmd($cmd); shell_exec($cmd);
$result = $this->hyclear_result(shell_exec($cmd)); return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' );
if (strpos($result, '[ERROR]') === false){ } else {
return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' ); return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' );
}else{ }
return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' ); }
} // 删除反代网站
} function hyproxy_del($del_name)
// 状态 {
function hyproxy_run($run_name, $g){//OK //OK
$run_zh = array( $del_name = trim($del_name);
'start' => '启动', $cmd = "amh module HYProxy-1.0 admin del,$del_name";
'stop' => '停止' $cmd = Functions::trim_cmd($cmd);
); $result = $this->hyclear_result(shell_exec($cmd));
$data['status'] = $g; if (strpos($result, '[ERROR]') === false) {
$data['time'] = time();//时间戳 return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' );
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件 } else {
$res = $this -> _update('module_hyproxy',$data,$where); return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' );
}
if ($res) { }
$cmd = "amh module HYProxy-1.0 admin make,$run_name"; // 状态
$cmd = Functions::trim_cmd($cmd); function hyproxy_run($run_name, $g)
shell_exec($cmd); {
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' ); //OK
}else { $run_zh = array(
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' ); 'start' => '启动',
} 'stop' => '停止'
} );
// 缓存状态 $data['status'] = $g;
function hyproxy_run_cache($run_name, $g){//OK $data['time'] = time();//时间戳
$run_zh = array( $where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
'1' => '启动', $res = $this -> _update('module_hyproxy', $data, $where);
'0' => '停止'
); if ($res) {
$data['proxy_cache'] = $g; $cmd = "amh module HYProxy-1.0 admin make,$run_name";
$data['time'] = time();//时间戳 $cmd = Functions::trim_cmd($cmd);
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件 shell_exec($cmd);
$res = $this -> _update('module_hyproxy',$data,$where); return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' );
} else {
if ($res) { return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' );
$cmd = "amh module HYProxy-1.0 admin make,$run_name"; }
$cmd = Functions::trim_cmd($cmd); }
shell_exec($cmd); // 缓存状态
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' ); function hyproxy_run_cache($run_name, $g)
}else { {
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' ); //OK
} $run_zh = array(
} '1' => '启动',
'0' => '停止'
// ********************************************************* );
// 取得缓存 $data['proxy_cache'] = $g;
function get_hyproxy_cache(){ $data['time'] = time();//时间戳
$name = trim($name); $where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
$cmd = "amh cat_nginx"; $res = $this -> _update('module_hyproxy', $data, $where);
$cmd = Functions::trim_cmd($cmd);
$result = trim(shell_exec($cmd), "\n"); if ($res) {
$result = Functions::trim_result($result); $cmd = "amh module HYProxy-1.0 admin make,$run_name";
preg_match("/hyproxy_cache levels=(.*)keys_zone=hyproxy:(.*)inactive=(.*)max_size=(.*);/", $result, $arr); $cmd = Functions::trim_cmd($cmd);
preg_match("/proxy_cache_valid 200 304(.*);/", $result, $arr2); shell_exec($cmd);
$data['levels'] = $arr[1]; return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' );
$data['keys_zone'] = $arr[2]; } else {
$data['inactive'] = $arr[3]; return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' );
$data['max_size'] = $arr[4]; }
$data['valid'] = $arr2[1]; }
foreach ($data as $key=>$val)
$data[$key] = trim($val); // *********************************************************
return $data; // 取得缓存
} function get_hyproxy_cache()
{
// 保存缓存 $name = trim($name);
function save_hyproxy_cache(){ $cmd = "amh cat_nginx";
$run_name = trim($run_name); $cmd = Functions::trim_cmd($cmd);
$cmd = "amh module HYProxy-1.0 admin cache,{$_POST['levels']},{$_POST['keys_zone']},{$_POST['max_size']},{$_POST['valid']},{$_POST['inactive']}"; $result = trim(shell_exec($cmd), "\n");
$cmd = Functions::trim_cmd($cmd); $result = Functions::trim_result($result);
exec($cmd, $tmp, $status); preg_match("/hyproxy_cache levels=(.*)keys_zone=hyproxy:(.*)inactive=(.*)max_size=(.*);/", $result, $arr);
Return !$status; preg_match("/proxy_cache_valid 200 304(.*);/", $result, $arr2);
} $data['levels'] = $arr[1];
$data['keys_zone'] = $arr[2];
$data['inactive'] = $arr[3];
// ********************************************************* $data['max_size'] = $arr[4];
// 取得缓存索引 $data['valid'] = $arr2[1];
function get_hyproxy_cache_index(){ foreach ($data as $key => $val) {
// $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type "; $data[$key] = trim($val);
$sql = "SELECT * FROM module_hyproxy_cache"; }
$result = $this -> _query($sql); return $data;
while ($rs = mysql_fetch_assoc($result)) }
{
$url_info = parse_url($rs['hyproxy_key']); // 保存缓存
if (isset($url_info['host']) && !empty($url_info['host'])) function save_hyproxy_cache()
{ {
++$data[$url_info['host']]['all']['sum']; $run_name = trim($run_name);
$data[$url_info['host']]['all']['size'] += $rs['hyproxy_size']; $cmd = "amh module HYProxy-1.0 admin cache,{$_POST['levels']},{$_POST['keys_zone']},{$_POST['max_size']},{$_POST['valid']},{$_POST['inactive']}";
$cmd = Functions::trim_cmd($cmd);
++$data[$url_info['host']][$rs['hyproxy_type']]['sum']; exec($cmd, $tmp, $status);
$data[$url_info['host']][$rs['hyproxy_type']]['size'] += $rs['hyproxy_size']; return !$status;
} }
}
Return $data;
} // *********************************************************
// 取得缓存索引
// 创建缓存索引 function get_hyproxy_cache_index()
function create_hyproxy_cache_index(){ {
$val = (int)$_POST['cache_index_time_val']; // $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type ";
$type = array('1' => 60*24, '2' => 60, '3' => 1); $sql = "SELECT * FROM module_hyproxy_cache";
$area = array('1' => '-', '2' => '+'); $result = $this -> _query($sql);
$val = isset($type[$_POST['cache_index_time_type']]) ? $val * $type[$_POST['cache_index_time_type']] : $val * $type[1]; // 时间类型 while ($rs = mysql_fetch_assoc($result)) {
$val = isset($area[$_POST['cache_index_time_type']]) ? $area[$_POST['cache_index_time_area']] . $val : '-' . $val; // 时间范围 $url_info = parse_url($rs['hyproxy_key']);
$mode = $_POST['cache_index_time_mode'] == '2' ? 'truncate' : ''; if (isset($url_info['host']) && !empty($url_info['host'])) {
++$data[$url_info['host']]['all']['sum'];
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode"; $data[$url_info['host']]['all']['size'] += $rs['hyproxy_size'];
$cmd = Functions::trim_cmd($cmd);
exec($cmd, $tmp, $status); ++$data[$url_info['host']][$rs['hyproxy_type']]['sum'];
Return !$status; $data[$url_info['host']][$rs['hyproxy_type']]['size'] += $rs['hyproxy_size'];
} }
}
// ********************************************************* return $data;
// 取得缓存列表 }
function get_hyproxy_cache_list($page = 1, $page_sum = 20){
$where = ''; // 创建缓存索引
function create_hyproxy_cache_index()
if (isset($_GET['cache_key']) && !empty($_GET['cache_key'])) {
{ $val = (int)$_POST['cache_index_time_val'];
$_GET['cache_key'] = trim($_GET['cache_key']); $type = array('1' => 60*24, '2' => 60, '3' => 1);
$where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'"; $area = array('1' => '-', '2' => '+');
} $val = isset($type[$_POST['cache_index_time_type']]) ? $val * $type[$_POST['cache_index_time_type']] : $val * $type[1]; // 时间类型
$val = isset($area[$_POST['cache_index_time_type']]) ? $area[$_POST['cache_index_time_area']] . $val : '-' . $val; // 时间范围
if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all') $mode = $_POST['cache_index_time_mode'] == '2' ? 'truncate' : '';
$where .= " AND hyproxy_type LIKE '{$_GET['cache_type']}'";
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode";
$limit = ' LIMIT ' . ($page-1)*$page_sum . ' , ' . $page_sum; $cmd = Functions::trim_cmd($cmd);
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where"; exec($cmd, $tmp, $status);
$sum = $this -> _sum($sql); return !$status;
}
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where $limit";
Return array('data' => $this -> _all($sql), 'sum' => $sum); // *********************************************************
} // 取得缓存列表
function get_hyproxy_cache_list($page = 1, $page_sum = 20)
// 删除缓存 {
function hyproxy_cache_delete() $where = '';
{
$url_param = (isset($_POST['cache_key']) && !empty($_POST['cache_key'])) ? $_POST['cache_key'] : '-all'; if (isset($_GET['cache_key']) && !empty($_GET['cache_key'])) {
$file_type = (isset($_POST['cache_type']) && !empty($_POST['cache_type']) && $_POST['cache_type'] != 'all') ? $_POST['cache_type'] : '-all'; $_GET['cache_key'] = trim($_GET['cache_key']);
$cmd = "amh module HYProxy-1.0 admin cache-delete,$url_param,$file_type"; $where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'";
$cmd = Functions::trim_cmd($cmd); }
exec($cmd, $tmp, $status);
Return !$status; if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all') {
} $where .= " AND hyproxy_type LIKE '{$_GET['cache_type']}'";
} }
$limit = ' LIMIT ' . ($page-1)*$page_sum . ' , ' . $page_sum;
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where";
$sum = $this -> _sum($sql);
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where $limit";
return array('data' => $this -> _all($sql), 'sum' => $sum);
}
// 删除缓存
function hyproxy_cache_delete()
{
$url_param = (isset($_POST['cache_key']) && !empty($_POST['cache_key'])) ? $_POST['cache_key'] : '-all';
$file_type = (isset($_POST['cache_type']) && !empty($_POST['cache_type']) && $_POST['cache_type'] != 'all') ? $_POST['cache_type'] : '-all';
$cmd = "amh module HYProxy-1.0 admin cache-delete,$url_param,$file_type";
$cmd = Functions::trim_cmd($cmd);
exec($cmd, $tmp, $status);
return !$status;
}
}

View File

@ -1,91 +1,93 @@
<?php include('header.php'); ?> <?php include('header.php'); ?>
<div id="body"> <div id="body">
<?php include('hyproxy_category.php'); ?> <?php include('hyproxy_category.php'); ?>
<?php <?php
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>'; if (!empty($notice)) {
?> echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
<p>反代缓存设置:</p> }
<form action="./index.php?c=hyproxy&a=hyproxy_cache" method="POST" > ?>
<table border="0" cellspacing="1" id="STable" style="width:720px;"> <p>反代缓存设置:</p>
<tr> <form action="./index.php?c=hyproxy&a=hyproxy_cache" method="POST" >
<th>名称</th> <table border="0" cellspacing="1" id="STable" style="width:720px;">
<th></th> <tr>
<th>说明</th> <th>名称</th>
</tr> <th></th>
<th>说明</th>
<td>缓存数据目录</td> </tr>
<td style="padding:8px">
/home/hyproxy_cache <td>缓存数据目录</td>
</td> <td style="padding:8px">
<td>缓存数据保存的位置</td> /home/hyproxy_cache
</tr> </td>
<tr> <td>缓存数据保存的位置</td>
<td>数据目录层次(levels)</td> </tr>
<td><input type="text" name="levels" class="input_text" value="<?php echo $hyproxy_cache['levels'];?>" /> <font class="red">*</font> <tr>
</td> <td>数据目录层次(levels)</td>
<td>缓存数据目录层次<br />允许使用1或2 / 最大3层 <td><input type="text" name="levels" class="input_text" value="<?php echo $hyproxy_cache['levels'];?>" /> <font class="red">*</font>
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 1:2)</div> </td>
</td> <td>缓存数据目录层次<br />允许使用1或2 / 最大3层
</tr> <div style="font-size:11px;color:#848484;margin:5px;">(e.g: 1:2)</div>
<tr> </td>
<td>区域内存大小(keys_zone)</td> </tr>
<td><input type="text" name="keys_zone" class="input_text" value="<?php echo $hyproxy_cache['keys_zone'];?>" /> <font class="red">*</font> <tr>
</td> <td>区域内存大小(keys_zone)</td>
<td>设置缓存区域内存大小 <td><input type="text" name="keys_zone" class="input_text" value="<?php echo $hyproxy_cache['keys_zone'];?>" /> <font class="red">*</font>
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 20m)</div> </td>
</td> <td>设置缓存区域内存大小
</tr> <div style="font-size:11px;color:#848484;margin:5px;">(e.g: 20m)</div>
<tr> </td>
<td>磁盘空间大小(max_size)</td> </tr>
<td><input type="text" name="max_size" class="input_text" value="<?php echo $hyproxy_cache['max_size'];?>" /> <font class="red">*</font> <tr>
</td> <td>磁盘空间大小(max_size)</td>
<td>限制缓存磁盘空间大小 <td><input type="text" name="max_size" class="input_text" value="<?php echo $hyproxy_cache['max_size'];?>" /> <font class="red">*</font>
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 2g)</div> </td>
</td> <td>限制缓存磁盘空间大小
</tr> <div style="font-size:11px;color:#848484;margin:5px;">(e.g: 2g)</div>
<tr> </td>
<td>缓存文件有效时间(valid)</td> </tr>
<td><input type="text" name="valid" class="input_text" value="<?php echo $hyproxy_cache['valid'];?>" /> <font class="red">*</font> <tr>
</td> <td>缓存文件有效时间(valid)</td>
<td>设置缓存文件有效时间<br /> <td><input type="text" name="valid" class="input_text" value="<?php echo $hyproxy_cache['valid'];?>" /> <font class="red">*</font>
超过设定时间即重新请求 </td>
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 12h)</div> <td>设置缓存文件有效时间<br />
</td> 超过设定时间即重新请求
</tr> <div style="font-size:11px;color:#848484;margin:5px;">(e.g: 12h)</div>
<tr> </td>
<td>缓存文件删除时间(inactive)</td> </tr>
<td><input type="text" name="inactive" class="input_text" value="<?php echo $hyproxy_cache['inactive'];?>" /> <font class="red">*</font> <tr>
</td> <td>缓存文件删除时间(inactive)</td>
<td>缓存文件无新访问之后删除时间<br /> <td><input type="text" name="inactive" class="input_text" value="<?php echo $hyproxy_cache['inactive'];?>" /> <font class="red">*</font>
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 10d)</div> </td>
</td> <td>缓存文件无新访问之后删除时间<br />
</tr> <div style="font-size:11px;color:#848484;margin:5px;">(e.g: 10d)</div>
</td>
<tr><th colspan="3" style="padding:10px;text-align:left;"> </tr>
<button type="submit" class="primary button" name="save"><span class="check icon"></span>保存</button>
</th></tr> <tr><th colspan="3" style="padding:10px;text-align:left;">
</table> <button type="submit" class="primary button" name="save"><span class="check icon"></span>保存</button>
</form> </th></tr>
</table>
</form>
<div id="notice_message" style="width:880px;">
<h3>» SSH HYProxy 缓存设置</h3>
cache: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache,levels,keys_zone,max_size,valid,inactive)<br /> <div id="notice_message" style="width:880px;">
cache 参数说明: <br /> <h3>» SSH HYProxy 缓存设置</h3>
<ul> cache: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache,levels,keys_zone,max_size,valid,inactive)<br />
<li>levels: 缓存数据目录层次最多可为3层。示例值: 1:2:2</li> cache 参数说明: <br />
<li>keys_zone: 缓存区域内存大小。示例值: 20m</li> <ul>
<li>max_size: 限制缓存磁盘空间大小。示例值2g</li> <li>levels: 缓存数据目录层次最多可为3层。示例值: 1:2:2</li>
<li>valid: 设置缓存文件有效时间超过设定时间即重新请求。示例值12h</li> <li>keys_zone: 缓存区域内存大小。示例值: 20m</li>
<li>inactive: 缓存文件删除时间,超过设置的时间内如无新访问请求缓存将自动删除。示例值: 10d</li> <li>max_size: 限制缓存磁盘空间大小。示例值2g</li>
</ul> <li>valid: 设置缓存文件有效时间超过设定时间即重新请求。示例值12h</li>
start-cache: 域名开启缓存 (ssh命令: amh module HYProxy-1.0 admin start-cache,amysql.com) 启动amysql.com反代网站缓存。<br /> <li>inactive: 缓存文件删除时间,超过设置的时间内如无新访问请求缓存将自动删除。示例值: 10d</li>
stop-cache: 域名停止缓存 (ssh命令: amh module HYProxy-1.0 admin stop-cache,amysql.com) 停止amysql.com反代网站缓存。<br /> </ul>
start-cache: 域名开启缓存 (ssh命令: amh module HYProxy-1.0 admin start-cache,amysql.com) 启动amysql.com反代网站缓存。<br />
</div> stop-cache: 域名停止缓存 (ssh命令: amh module HYProxy-1.0 admin stop-cache,amysql.com) 停止amysql.com反代网站缓存。<br />
</div> </div>
<?php include('footer.php'); ?> </div>
<?php include('footer.php'); ?>

View File

@ -1,161 +1,155 @@
<?php include('header.php'); ?> <?php include('header.php'); ?>
<style> <style>
#STable td.object_list_last { #STable td.object_list_last {
background:url("View/images/Listbj.gif") repeat-x scroll left top white; background:url("View/images/Listbj.gif") repeat-x scroll left top white;
padding:8px; padding:8px;
text-align:right; text-align:right;
line-height:18px; line-height:18px;
color:#607993; color:#607993;
} }
</style> </style>
<script> <script>
var cache_host; var cache_host;
var cache_key; var cache_key;
var cache_host_js = <?php echo json_encode($cache_host);?>; var cache_host_js = <?php echo json_encode($cache_host);?>;
window.onload = function () window.onload = function ()
{ {
cache_host = G('cache_host'); cache_host = G('cache_host');
cache_key = G('cache_key'); cache_key = G('cache_key');
cache_host.onchange = function () cache_host.onchange = function ()
{ {
for (var k in cache_host_js) for (var k in cache_host_js)
{ {
var reg = new RegExp('http://' + cache_host_js[k], "gmi"); var reg = new RegExp('http://' + cache_host_js[k], "gmi");
cache_key.value = cache_key.value.replace(reg,''); cache_key.value = cache_key.value.replace(reg,'');
} }
if (cache_host.value != '') if (cache_host.value != '')
cache_key.value = 'http://' + cache_host.value + cache_key.value + (cache_key.value == '' ? '%' : ''); cache_key.value = 'http://' + cache_host.value + cache_key.value + (cache_key.value == '' ? '%' : '');
cache_key.value = cache_key.value == '%' ? '' : cache_key.value; cache_key.value = cache_key.value == '%' ? '' : cache_key.value;
} }
} }
var cache_delete_submit = function () var cache_delete_submit = function ()
{ {
if (!confirm('删除当前搜索结果(缓存索引&缓存文件) <?php echo $hyproxy_cache_list['sum'];?> 项吗?')) if (!confirm('删除当前搜索结果(缓存索引&缓存文件) <?php echo $hyproxy_cache_list['sum'];?> 项吗?'))
return false; return false;
G('cache_delete_button').innerHTML = '删除缓存中…'; G('cache_delete_button').innerHTML = '删除缓存中…';
G('cache_delete_button').disabled = true; G('cache_delete_button').disabled = true;
return true; return true;
} }
</script> </script>
<div id="body"> <div id="body">
<?php include('hyproxy_category.php'); ?> <?php include('hyproxy_category.php'); ?>
<?php <?php
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>'; if (!empty($notice)) {
?> echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
}
<div> ?>
<p>搜索查看缓存与删除</p>
<form action="" method="GET"> <div>
<input type="hidden" value="hyproxy_cache_del" name="a"/> <p>搜索查看缓存与删除</p>
<input type="hidden" value="hyproxy" name="c"/> <form action="" method="GET">
索引域名 <select name="cache_host" id="cache_host" style="width:180px;"> <input type="hidden" value="hyproxy_cache_del" name="a"/>
<?php if (is_array($cache_host)) <input type="hidden" value="hyproxy" name="c"/>
{ 索引域名 <select name="cache_host" id="cache_host" style="width:180px;">
foreach ($cache_host as $key=>$val) <?php if (is_array($cache_host)) {
{ foreach ($cache_host as $key => $val) {
?> ?>
<option value="<?php echo $val;?>"><?php echo $val;?></option> <option value="<?php echo $val;?>"><?php echo $val;?></option>
<?php <?php
} }
} }
?> ?>
<option value="">所有</option> <option value="">所有</option>
</select> &nbsp; </select> &nbsp;
<script>G('cache_host').value = '<?php echo isset($_GET['cache_host']) ? $_GET['cache_host'] : '';?>';</script> <script>G('cache_host').value = '<?php echo isset($_GET['cache_host']) ? $_GET['cache_host'] : '';?>';</script>
网址匹配 (可使用%通配符) <input type="text" name="cache_key" id="cache_key" class="input_text" value="<?php echo isset($_GET['cache_key']) ? $_GET['cache_key'] : '';?>" style="width:250px;"/> &nbsp; 网址匹配 (可使用%通配符) <input type="text" name="cache_key" id="cache_key" class="input_text" value="<?php echo isset($_GET['cache_key']) ? $_GET['cache_key'] : '';?>" style="width:250px;"/> &nbsp;
文件类型 <select name="cache_type" id="cache_type" style="width:180px;"> 文件类型 <select name="cache_type" id="cache_type" style="width:180px;">
<?php if (is_array($cache_type)) <?php if (is_array($cache_type)) {
{ foreach ($cache_type as $key => $val) {
foreach ($cache_type as $key=>$val) if ($val != 'all') {
{ ?>
if($val != 'all') { <option value="<?php echo $val;?>"><?php echo $val;?></option>
?> <?php
<option value="<?php echo $val;?>"><?php echo $val;?></option> }
<?php }
} }
} ?>
} <option value="all">所有</option>
?> </select> &nbsp;
<option value="all">所有</option> <script>G('cache_type').value = '<?php echo isset($_GET['cache_type']) ? $_GET['cache_type'] : all;?>';</script>
</select> &nbsp; <button type="submit" class="primary button" >搜索</button>
<script>G('cache_type').value = '<?php echo isset($_GET['cache_type']) ? $_GET['cache_type'] : all;?>';</script> </form>
<button type="submit" class="primary button" >搜索</button> </div>
</form>
</div> <style>
#STable td {
<style> text-align:left;
#STable td { padding-left:10px;
text-align:left; }
padding-left:10px; </style>
} <div id="HYProxy_list">
</style> <table border="0" cellspacing="1" id="STable" style="width:1150px;">
<div id="HYProxy_list"> <tr>
<table border="0" cellspacing="1" id="STable" style="width:1150px;"> <th>编号</th>
<tr> <th>缓存文件</th>
<th>编号</th> <th width="380">网址</th>
<th>缓存文件</th> <th>状态码</th>
<th width="380">网址</th> <th>文件类型</th>
<th>状态码</th> <th>大小 / MB</th>
<th>文件类型</th> <th>创建时间</th>
<th>大小 / MB</th> </tr>
<th>创建时间</th> <?php
</tr> if (!is_array($hyproxy_cache_list['data']) || count($hyproxy_cache_list['data']) < 1) {
<?php ?>
if(!is_array($hyproxy_cache_list['data']) || count($hyproxy_cache_list['data']) < 1) <tr><td colspan="7" style="padding:10px;text-align:center;">没找到缓存索引数据。</td></tr>
{ <?php
?> } else {
<tr><td colspan="7" style="padding:10px;text-align:center;">没找到缓存索引数据。</td></tr> $k = 0;
<?php foreach ($hyproxy_cache_list['data'] as $key => $val) {
} ?>
else <tr>
{ <th class="i"><?php echo $val['hyproxy_id'];?></th>
$k = 0; <td><?php echo $val['hyproxy_file'];?></td>
foreach ($hyproxy_cache_list['data'] as $key=>$val) <td><a href="<?php echo $val['hyproxy_key'];?>" target="_blank"><?php echo $val['hyproxy_key'];?></a></td>
{ <td><?php echo $val['hyproxy_http_s'];?></td>
?> <td><?php echo $val['hyproxy_type'];?></td>
<tr> <td><?php echo !empty($val['hyproxy_size']) ? $val['hyproxy_size'] : 0;?></td>
<th class="i"><?php echo $val['hyproxy_id'];?></th> <td><?php echo $val['hyproxy_time'];?></td>
<td><?php echo $val['hyproxy_file'];?></td> </tr>
<td><a href="<?php echo $val['hyproxy_key'];?>" target="_blank"><?php echo $val['hyproxy_key'];?></a></td> <?php
<td><?php echo $val['hyproxy_http_s'];?></td> }
<td><?php echo $val['hyproxy_type'];?></td> }
<td><?php echo !empty($val['hyproxy_size']) ? $val['hyproxy_size'] : 0;?></td> ?>
<td><?php echo $val['hyproxy_time'];?></td> <tr>
</tr> <td colspan="7" class="object_list_last">
<?php <form action="" method="POST" onsubmit="return cache_delete_submit()">
} 删除当前搜索结果(缓存索引&缓存文件) <?php echo $hyproxy_cache_list['sum'];?>
} <button type="submit" class="primary button" id="cache_delete_button"> 确认删除</button>
?> <input type="hidden" name="post_delete" value="y"/>
<tr> <input type="hidden" value="<?php echo $_GET['cache_type'];?>" name="cache_type"/>
<td colspan="7" class="object_list_last"> <input type="hidden" value="<?php echo $_GET['cache_key'];?>" name="cache_key"/>
<form action="" method="POST" onsubmit="return cache_delete_submit()"> </form>
删除当前搜索结果(缓存索引&缓存文件) <?php echo $hyproxy_cache_list['sum'];?> </td>
<button type="submit" class="primary button" id="cache_delete_button"> 确认删除</button> </tr>
<input type="hidden" name="post_delete" value="y"/> </table>
<input type="hidden" value="<?php echo $_GET['cache_type'];?>" name="cache_type"/> <div id="page_list"><?php echo $total_page;?>页 - <?php echo $hyproxy_cache_list['sum'];?>记录 » 页码 <?php echo htmlspecialchars_decode($page_list);?> </div>
<input type="hidden" value="<?php echo $_GET['cache_key'];?>" name="cache_key"/> <button type="button" class="primary button" onclick="WindowLocation('/index.php?c=hyproxy&a=hyproxy_cache_del')"><span class="home icon"></span> 返回列表</button>
</form>
</td> <div id="notice_message" style="width:880px;">
</tr> <h3>» SSH HYProxy 缓存删除</h3>
</table> cache-delete: 缓存删除 (ssh命令: amh module HYProxy-1.0 admin cache-delete,url-param,file-type)<br />
<div id="page_list"><?php echo $total_page;?>页 - <?php echo $hyproxy_cache_list['sum'];?>记录 » 页码 <?php echo htmlspecialchars_decode($page_list);?> </div> cache-delete 参数说明: <br />
<button type="button" class="primary button" onclick="WindowLocation('/index.php?c=hyproxy&a=hyproxy_cache_del')"><span class="home icon"></span> 返回列表</button> <ul>
<li>url-param: 网址匹配参数,可使用%通配符进行匹配删除。预设参数值有: -all (使用-all即匹配所有网址)</li>
<div id="notice_message" style="width:880px;"> <li>file-type: 缓存文件类型匹配参数可匹配text/html、image/gif等相关文件类型进行删除。预设参数值有: -all (使用-all即匹配所有文件类型)</li>
<h3>» SSH HYProxy 缓存删除</h3> </ul>
cache-delete: 缓存删除 (ssh命令: amh module HYProxy-1.0 admin cache-delete,url-param,file-type)<br />
cache-delete 参数说明: <br /> </div>
<ul> </div>
<li>url-param: 网址匹配参数,可使用%通配符进行匹配删除。预设参数值有: -all (使用-all即匹配所有网址)</li>
<li>file-type: 缓存文件类型匹配参数可匹配text/html、image/gif等相关文件类型进行删除。预设参数值有: -all (使用-all即匹配所有文件类型)</li> </div>
</ul> <?php include('footer.php'); ?>
</div>
</div>
</div>
<?php include('footer.php'); ?>

View File

@ -1,163 +1,162 @@
<?php include('header.php'); ?> <?php include('header.php'); ?>
<style> <style>
#STable td.object_list { #STable td.object_list {
background:url("View/images/Listbj01.gif") repeat-x scroll left top white; background:url("View/images/Listbj01.gif") repeat-x scroll left top white;
padding:20px; padding:20px;
} }
#STable td.object_list_last { #STable td.object_list_last {
background:url("View/images/Listbj.gif") repeat-x scroll left top white; background:url("View/images/Listbj.gif") repeat-x scroll left top white;
padding:8px; padding:8px;
text-align:right; text-align:right;
line-height:18px; line-height:18px;
color:#607993; color:#607993;
} }
#STable td.object_list_last font{ #STable td.object_list_last font{
font-size:14px; font-size:14px;
} }
#STable td.object_name, #STable th.object_name { #STable td.object_name, #STable th.object_name {
text-align:left; text-align:left;
padding-left:22px; padding-left:22px;
} }
#STable .Object_list { #STable .Object_list {
width:930px; width:930px;
background:none; background:none;
border:1px solid #E7E7E7; border:1px solid #E7E7E7;
} }
#STable .Object_list td { #STable .Object_list td {
border-bottom:1px solid #E0E0E0; border-bottom:1px solid #E0E0E0;
} }
</style> </style>
<script> <script>
var cache_index_submit = function () var cache_index_submit = function ()
{ {
G('cache_index_button').innerHTML = '创建索引中…'; G('cache_index_button').innerHTML = '创建索引中…';
G('cache_index_button').disabled = true; G('cache_index_button').disabled = true;
} }
</script> </script>
<div id="body"> <div id="body">
<?php include('hyproxy_category.php'); ?> <?php include('hyproxy_category.php'); ?>
<?php <?php
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>'; if (!empty($notice)) {
?> echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
<p>反代缓存索引:</p> }
<table border="0" cellspacing="1" id="STable" style="width:720px;"> ?>
<tr> <p>反代缓存索引:</p>
<th>索引域名</th> <table border="0" cellspacing="1" id="STable" style="width:720px;">
<th>总缓存数量</th> <tr>
<th>总使用空间</th> <th>索引域名</th>
</tr> <th>总缓存数量</th>
<th>总使用空间</th>
<?php </tr>
$host_sum = 0;
$file_sum = 0; <?php
$file_size = 0; $host_sum = 0;
foreach ($hyproxy_cache_index as $key=>$val) $file_sum = 0;
{ $file_size = 0;
$file_sum += $val['all']['sum']; foreach ($hyproxy_cache_index as $key => $val) {
$file_size += $val['all']['size']; $file_sum += $val['all']['sum'];
++$host_sum; $file_size += $val['all']['size'];
?> ++$host_sum;
<tr> ?>
<td><a href="http://<?php echo $key;?>" class="button" target="_blank"><span class="home icon"></span>主页</a> <?php echo $key;?></td> <tr>
<td style="padding:8px">总缓存文件 <b><?php echo $val['all']['sum'];?></b> 个</td> <td><a href="http://<?php echo $key;?>" class="button" target="_blank"><span class="home icon"></span>主页</a> <?php echo $key;?></td>
<td>总使用空间 <b><?php echo $val['all']['size'];?></b> MB</td> <td style="padding:8px">总缓存文件 <b><?php echo $val['all']['sum'];?></b> 个</td>
</tr> <td>总使用空间 <b><?php echo $val['all']['size'];?></b> MB</td>
<tr> </tr>
<td colspan="3" class="object_list"> <tr>
<table border="0" cellspacing="0" id="STable" style="width:580px;" class="Object_list"> <td colspan="3" class="object_list">
<tr> <table border="0" cellspacing="0" id="STable" style="width:580px;" class="Object_list">
<th class="object_name">缓存文件类型</th> <tr>
<th>缓存数量</th> <th class="object_name">缓存文件类型</th>
<th>使用空间</th> <th>缓存数量</th>
</tr> <th>使用空间</th>
<?php </tr>
foreach ($val as $k=>$v) <?php
{ foreach ($val as $k => $v) {
if($k != 'all') if ($k != 'all') {
{ ?>
?> <tr>
<tr> <td class="object_name"><?php echo $k;?></td>
<td class="object_name"><?php echo $k;?></td> <td style="padding:8px">缓存文件 <b><?php echo $v['sum'];?></b> 个</td>
<td style="padding:8px">缓存文件 <b><?php echo $v['sum'];?></b> 个</td> <td>使用空间 <b><?php echo $v['size'];?></b> MB</td>
<td>使用空间 <b><?php echo $v['size'];?></b> MB</td> </tr>
</tr> <?php
<?php }
} }
} ?>
?> </table>
</table> </td>
</td> </tr>
</tr>
<?php
<?php }
} ?>
?> <tr>
<tr> <td colspan="3" class="object_list_last"><font>共索引域名 <b><?php echo $host_sum;?></b> 个: </font>
<td colspan="3" class="object_list_last"><font>共索引域名 <b><?php echo $host_sum;?></b> 个: </font> 全部缓存文件 <b><?php echo $file_sum;?></b> 个 /
全部缓存文件 <b><?php echo $file_sum;?></b> 个 / 全部缓存文件已用 <b><?php echo $file_size;?></b> MB</td>
全部缓存文件已用 <b><?php echo $file_size;?></b> MB</td> </tr>
</tr> </table>
</table>
<br /><br />
<br /><br /> <form action="./index.php?c=hyproxy&a=hyproxy_cache_index" method="POST" id="cache_index_form" onsubmit="return cache_index_submit()">
<form action="./index.php?c=hyproxy&a=hyproxy_cache_index" method="POST" id="cache_index_form" onsubmit="return cache_index_submit()"> <p>建立缓存索引:</p>
<p>建立缓存索引:</p> <table border="0" cellspacing="1" id="STable" style="width:560px;">
<table border="0" cellspacing="1" id="STable" style="width:560px;"> <tr>
<tr> <th></th>
<th></th> <th>时间单位</th>
<th>时间单位</th> <th>时间范围</th>
<th>时间范围</th> <th>使用模式</th>
<th>使用模式</th> </tr>
</tr> <tr>
<tr> <td><input type="text" name="cache_index_time_val" class="input_text" value="<?php echo isset($_POST['cache_index_time_val']) ? $_POST['cache_index_time_val'] : 2;?>" style="width:50px;"/></td>
<td><input type="text" name="cache_index_time_val" class="input_text" value="<?php echo isset($_POST['cache_index_time_val']) ? $_POST['cache_index_time_val'] : 2;?>" style="width:50px;"/></td> <td><select name="cache_index_time_type" id="cache_index_time_type" style="width:110px;">
<td><select name="cache_index_time_type" id="cache_index_time_type" style="width:110px;"> <option value="1"></option>
<option value="1"></option> <option value="2">小时</option>
<option value="2">小时</option> <option value="3">分钟</option>
<option value="3">分钟</option> </select>
</select> <script>
<script> G('cache_index_time_type').value = '<?php echo isset($_POST['cache_index_time_type']) ? $_POST['cache_index_time_type'] : 1;?>';
G('cache_index_time_type').value = '<?php echo isset($_POST['cache_index_time_type']) ? $_POST['cache_index_time_type'] : 1;?>'; </script>
</script> </td>
</td> <td><select name="cache_index_time_area" id="cache_index_time_area" style="width:110px;">
<td><select name="cache_index_time_area" id="cache_index_time_area" style="width:110px;"> <option value="1">之内</option>
<option value="1">之内</option> <option value="2">之外</option>
<option value="2">之外</option> </select>
</select> <script>
<script> G('cache_index_time_area').value = '<?php echo isset($_POST['cache_index_time_area']) ? $_POST['cache_index_time_area'] : 1;?>';
G('cache_index_time_area').value = '<?php echo isset($_POST['cache_index_time_area']) ? $_POST['cache_index_time_area'] : 1;?>'; </script>
</script> </td>
</td> <td><select name="cache_index_time_mode" id="cache_index_time_mode" style="width:110px;">
<td><select name="cache_index_time_mode" id="cache_index_time_mode" style="width:110px;"> <option value="1">更新与追加</option>
<option value="1">更新与追加</option> <option value="2">清空后重建</option>
<option value="2">清空后重建</option> </select>
</select> <script>
<script> G('cache_index_time_mode').value = '<?php echo isset($_POST['cache_index_time_mode']) ? $_POST['cache_index_time_mode'] : 1;?>';
G('cache_index_time_mode').value = '<?php echo isset($_POST['cache_index_time_mode']) ? $_POST['cache_index_time_mode'] : 1;?>'; </script>
</script> </td>
</td> </tr>
</tr>
</table>
</table> <input type="hidden" name="post_submit" value="y"/>
<input type="hidden" name="post_submit" value="y"/> <button type="submit" class="primary button" id="cache_index_button"><span class="check icon"></span>建立索引</button>
<button type="submit" class="primary button" id="cache_index_button"><span class="check icon"></span>建立索引</button> </form>
</form>
<div id="notice_message" style="width:880px;">
<div id="notice_message" style="width:880px;"> <h3>» SSH HYProxy 缓存索引</h3>
<h3>» SSH HYProxy 缓存索引</h3> cache-index: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache-index,cmin,mode)<br />
cache-index: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache-index,cmin,mode)<br /> cache-index 参数说明: <br />
cache-index 参数说明: <br /> <ul>
<ul> <li>cmin: 索引缓存文件使用的时间,单位为分钟。可使用:+分钟 / -分钟</li>
<li>cmin: 索引缓存文件使用的时间,单位为分钟。可使用:+分钟 / -分钟</li> <li>+分钟: 索引N分钟之前的缓存数据。</li>
<li>+分钟: 索引N分钟之前的缓存数据。</li> <li>-分钟: 索引N分钟之内的缓存数据。</li>
<li>-分钟: 索引N分钟之内的缓存数据。</li> <li>mode: 索引数据模式可选参数。可用值truncate (清空模式,清空旧索引数据后再建立索引)
<li>mode: 索引数据模式可选参数。可用值truncate (清空模式,清空旧索引数据后再建立索引) </ul>
</ul>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>
<?php include('footer.php'); ?>

View File

@ -1,31 +1,31 @@
<?php !defined('_Amysql') && exit; ?> <?php !defined('_Amysql') && exit; ?>
<style> <style>
#HYProxy_list input.input_text { #HYProxy_list input.input_text {
width: 292px; width: 292px;
} }
#HYProxy_list textarea { #HYProxy_list textarea {
display:inline; display:inline;
} }
</style> </style>
<script> <script>
if(!WindowLocation){ if(!WindowLocation){
var WindowLocation = function (url){ var WindowLocation = function (url){
window.location = url; window.location = url;
} }
var WindowOpen = function (url){ var WindowOpen = function (url){
window.open(url); window.open(url);
} }
} }
</script> </script>
<h2>AMH » HYProxy</h2> <h2>AMH » HYProxy</h2>
<div id="category"> <div id="category">
<a href="index.php?c=hyproxy&a=hyproxy_list" id="hyproxy_list" >反代列表</a> <a href="index.php?c=hyproxy&a=hyproxy_list" id="hyproxy_list" >反代列表</a>
<a href="index.php?c=hyproxy&a=hyproxy_cache" id="hyproxy_cache">缓存设置</a> <a href="index.php?c=hyproxy&a=hyproxy_cache" id="hyproxy_cache">缓存设置</a>
<a href="index.php?c=hyproxy&a=hyproxy_cache_index" id="hyproxy_cache_index">缓存索引</a> <a href="index.php?c=hyproxy&a=hyproxy_cache_index" id="hyproxy_cache_index">缓存索引</a>
<a href="index.php?c=hyproxy&a=hyproxy_cache_del" id="hyproxy_cache_del">缓存删除</a> <a href="index.php?c=hyproxy&a=hyproxy_cache_del" id="hyproxy_cache_del">缓存删除</a>
<script> <script>
var action = '<?php echo $_GET['a'];?>'; var action = '<?php echo $_GET['a'];?>';
var action_dom = G(action) ? G(action) : G('hyproxy_list'); var action_dom = G(action) ? G(action) : G('hyproxy_list');
action_dom.className = 'activ'; action_dom.className = 'activ';
</script> </script>
</div> </div>

View File

@ -4,8 +4,10 @@
<div id="body"> <div id="body">
<?php include('hyproxy_category.php'); ?> <?php include('hyproxy_category.php'); ?>
<?php <?php
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>'; if (!empty($notice)) {
?> echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
}
?>
<p>HYProxy反向代理:</p> <p>HYProxy反向代理:</p>
<div id="HYProxy_list"> <div id="HYProxy_list">
<table border="0" cellspacing="1" id="STable" style="width:850px;"> <table border="0" cellspacing="1" id="STable" style="width:850px;">
@ -15,30 +17,26 @@
<th>最后修改</th> <th>最后修改</th>
<th>管理</th> <th>管理</th>
</tr> </tr>
<?php <?php
if(!is_array($hyproxy_list) || count($hyproxy_list) < 1) if (!is_array($hyproxy_list) || count($hyproxy_list) < 1) {
{ ?>
?>
<tr> <tr>
<td colspan="4" style="padding:10px;">暂无绑定域名。</td> <td colspan="4" style="padding:10px;">暂无绑定域名。</td>
</tr> </tr>
<?php <?php
} } else {
else foreach ($hyproxy_list as $key => $val) {
{ ?>
foreach ($hyproxy_list as $key=>$val)
{
?>
<tr> <tr>
<th class="i"><?php echo $val['hyproxy_id'];?></th> <th class="i"><?php echo $val['hyproxy_id'];?></th>
<td><a href="http://<?php echo $val['server_name'];?>" target="_blank"><?php echo $val['server_name'];?></a></td> <td><a href="http://<?php echo $val['server_name'];?>" target="_blank"><?php echo $val['server_name'];?></a></td>
<td><?php echo date("Y-m-d H:i:s", $val['time']);?></td> <td><?php echo date("Y-m-d H:i:s", $val['time']);?></td>
<td><a href="index.php?c=hyproxy&run=<?php echo $val['server_name'];?>&g=<?php echo $val['status'] != 'stop' ? 'stop' : 'start';?>" > <span <?php echo $val['status'] != 'stop' ? 'class="run_start"' : 'class="run_stop"';?>><?php echo $val['status'] != 'stop' ? '运行中' : '已停止' ;?></span> </a> <a href="index.php?c=hyproxy&run_cache=<?php echo $val['server_name'];?>&g=<?php echo $val['proxy_cache'] != '0' ? '0' : '1';?>" > <span <?php echo $val['proxy_cache'] != '0' ? 'class="run_start"' : 'class="run_stop"';?>><?php echo $val['proxy_cache'] != '0' ? '有缓存' : '没缓存' ;?></span> </a> <a href="./index.php?c=hyproxy&admin=<?php echo $val['server_name'];?>" class="button"><span class="cog icon"></span> 管理</a> <a href="./index.php?c=hyproxy&del=<?php echo $val['server_name'];?>" class="button" onClick="return confirm('确认删除域名:<?php echo $val['server_name'];?>?');"><span class="cross icon"></span> 删除</a> </td> <td><a href="index.php?c=hyproxy&run=<?php echo $val['server_name'];?>&g=<?php echo $val['status'] != 'stop' ? 'stop' : 'start';?>" > <span <?php echo $val['status'] != 'stop' ? 'class="run_start"' : 'class="run_stop"';?>><?php echo $val['status'] != 'stop' ? '运行中' : '已停止' ;?></span> </a> <a href="index.php?c=hyproxy&run_cache=<?php echo $val['server_name'];?>&g=<?php echo $val['proxy_cache'] != '0' ? '0' : '1';?>" > <span <?php echo $val['proxy_cache'] != '0' ? 'class="run_start"' : 'class="run_stop"';?>><?php echo $val['proxy_cache'] != '0' ? '有缓存' : '没缓存' ;?></span> </a> <a href="./index.php?c=hyproxy&admin=<?php echo $val['server_name'];?>" class="button"><span class="cog icon"></span> 管理</a> <a href="./index.php?c=hyproxy&del=<?php echo $val['server_name'];?>" class="button" onClick="return confirm('确认删除域名:<?php echo $val['server_name'];?>?');"><span class="cross icon"></span> 删除</a> </td>
</tr> </tr>
<?php <?php
} }
} }
?> ?>
</table> </table>
<button type="button" class="primary button" onClick="WindowLocation('/index.php?c=hyproxy')"><span class="home icon"></span> 返回列表</button> <button type="button" class="primary button" onClick="WindowLocation('/index.php?c=hyproxy')"><span class="home icon"></span> 返回列表</button>
<br /> <br />
@ -93,7 +91,7 @@
</tr> </tr>
</table> </table>
</form> </form>
<?php }else { ?> <?php } else { ?>
<!--------------------------------------------------------------------------------------------------------> <!-------------------------------------------------------------------------------------------------------->
<br /> <br />
<form action="./index.php?c=hyproxy" method="POST" > <form action="./index.php?c=hyproxy" method="POST" >
@ -124,7 +122,7 @@
</table> </table>
</form> </form>
</div> </div>
<?php } ?> <?php } ?>
<div id="notice_message" style="width:880px;"> <div id="notice_message" style="width:880px;">
<h3>» SSH HYProxy</h3> <h3>» SSH HYProxy</h3>
1) 有步骤提示操作: <br /> 1) 有步骤提示操作: <br />