parent
764b9c0aaa
commit
5a3b977f1b
|
|
@ -1,24 +1,30 @@
|
||||||
<?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;
|
{
|
||||||
|
if ($this -> indexs) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this -> _class('Functions');
|
$this -> _class('Functions');
|
||||||
$this -> indexs = $this -> _model('indexs');
|
$this -> indexs = $this -> _model('indexs');
|
||||||
$this -> hyproxys = $this -> _model('hyproxys');
|
$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 -> title = '反代列表 - HYProxy'; // 面板模块标题
|
||||||
$this -> AmysqlModelBase();
|
$this -> AmysqlModelBase();
|
||||||
Functions::CheckLogin(); // 面板登录检查函数
|
Functions::CheckLogin(); // 面板登录检查函数
|
||||||
|
|
@ -31,7 +37,7 @@ class hyproxy extends AmysqlController {
|
||||||
'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'];
|
||||||
|
|
@ -92,37 +98,32 @@ class hyproxy extends AmysqlController {
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 缓存设置
|
// 缓存设置
|
||||||
function hyproxy_cache(){
|
function hyproxy_cache()
|
||||||
|
{
|
||||||
$this -> title = '缓存设置 - HYProxy - AMH';
|
$this -> title = '缓存设置 - HYProxy - AMH';
|
||||||
$this -> AmysqlModelBase();
|
$this -> AmysqlModelBase();
|
||||||
Functions::CheckLogin();
|
Functions::CheckLogin();
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
if (isset($_POST['save']))
|
if (isset($_POST['save'])) {
|
||||||
{
|
|
||||||
$this -> status = 'error';
|
$this -> status = 'error';
|
||||||
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive');
|
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive');
|
||||||
foreach ($field as $key=>$val)
|
foreach ($field as $key => $val) {
|
||||||
{
|
if (!isset($_POST[$val]) || empty($_POST[$val])) {
|
||||||
if (!isset($_POST[$val]) || empty($_POST[$val]))
|
|
||||||
{
|
|
||||||
$error = true;
|
$error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($error))
|
if (isset($error)) {
|
||||||
$this -> notice = '请填写完整数据。';
|
$this -> notice = '请填写完整数据。';
|
||||||
else
|
} else {
|
||||||
{
|
if ($this -> hyproxys -> save_hyproxy_cache()) {
|
||||||
if ($this -> hyproxys -> save_hyproxy_cache())
|
|
||||||
{
|
|
||||||
$this -> status = 'success';
|
$this -> status = 'success';
|
||||||
$this -> notice = 'HYProxy 缓存设置成功。';
|
$this -> notice = 'HYProxy 缓存设置成功。';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$this -> notice = 'HYProxy 缓存设置失败。';
|
$this -> notice = 'HYProxy 缓存设置失败。';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this -> indexs -> log_insert($this -> notice);
|
$this -> indexs -> log_insert($this -> notice);
|
||||||
|
|
@ -133,20 +134,17 @@ class hyproxy extends AmysqlController {
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 缓存索引
|
// 缓存索引
|
||||||
function hyproxy_cache_index(){
|
function hyproxy_cache_index()
|
||||||
|
{
|
||||||
$this -> title = '缓存索引 - HYProxy - AMH';
|
$this -> title = '缓存索引 - HYProxy - AMH';
|
||||||
$this -> AmysqlModelBase();
|
$this -> AmysqlModelBase();
|
||||||
Functions::CheckLogin();
|
Functions::CheckLogin();
|
||||||
|
|
||||||
if (isset($_POST['post_submit']))
|
if (isset($_POST['post_submit'])) {
|
||||||
{
|
if ($this -> hyproxys -> create_hyproxy_cache_index()) {
|
||||||
if ($this -> hyproxys -> create_hyproxy_cache_index())
|
|
||||||
{
|
|
||||||
$this -> status = 'success';
|
$this -> status = 'success';
|
||||||
$this -> notice = 'HYProxy 创建缓存索引成功。';
|
$this -> notice = 'HYProxy 创建缓存索引成功。';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this -> status = 'error';
|
$this -> status = 'error';
|
||||||
$this -> notice = 'HYProxy 创建缓存索引失败。';
|
$this -> notice = 'HYProxy 创建缓存索引失败。';
|
||||||
}
|
}
|
||||||
|
|
@ -159,21 +157,18 @@ class hyproxy extends AmysqlController {
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 缓存删除
|
// 缓存删除
|
||||||
function hyproxy_cache_del(){
|
function hyproxy_cache_del()
|
||||||
|
{
|
||||||
$this -> title = '缓存删除 - HYProxy - AMH';
|
$this -> title = '缓存删除 - HYProxy - AMH';
|
||||||
$this -> AmysqlModelBase();
|
$this -> AmysqlModelBase();
|
||||||
Functions::CheckLogin();
|
Functions::CheckLogin();
|
||||||
|
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
if (isset($_POST['post_delete']))
|
if (isset($_POST['post_delete'])) {
|
||||||
{
|
if ($this -> hyproxys -> hyproxy_cache_delete()) {
|
||||||
if ($this -> hyproxys -> hyproxy_cache_delete())
|
|
||||||
{
|
|
||||||
$this -> status = 'success';
|
$this -> status = 'success';
|
||||||
$this -> notice = 'HYProxy 缓存删除成功。';
|
$this -> notice = 'HYProxy 缓存删除成功。';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this -> status = 'error';
|
$this -> status = 'error';
|
||||||
$this -> notice = 'HYProxy 缓存删除失败。';
|
$this -> notice = 'HYProxy 缓存删除失败。';
|
||||||
}
|
}
|
||||||
|
|
@ -181,12 +176,12 @@ class hyproxy extends AmysqlController {
|
||||||
|
|
||||||
// 取得域名列表与缓存文件类型
|
// 取得域名列表与缓存文件类型
|
||||||
$hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index();
|
$hyproxy_cache_index = $this -> hyproxys -> get_hyproxy_cache_index();
|
||||||
foreach ($hyproxy_cache_index as $key=>$val)
|
foreach ($hyproxy_cache_index as $key => $val) {
|
||||||
{
|
|
||||||
$cache_host[] = $key;
|
$cache_host[] = $key;
|
||||||
foreach ($val as $k=>$v)
|
foreach ($val as $k => $v) {
|
||||||
$cache_type[$k] = $k;
|
$cache_type[$k] = $k;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 缓存列表
|
// 缓存列表
|
||||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||||
|
|
@ -205,5 +200,4 @@ class hyproxy extends AmysqlController {
|
||||||
$this -> indexs -> log_insert($this -> notice);
|
$this -> indexs -> log_insert($this -> notice);
|
||||||
$this -> _view('hyproxy_cache_del');
|
$this -> _view('hyproxy_cache_del');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class hyproxys extends AmysqlModel{
|
class hyproxys extends AmysqlModel
|
||||||
function hyclear_result($str){
|
{
|
||||||
|
function hyclear_result($str)
|
||||||
|
{
|
||||||
$str = Functions::trim_result($str);
|
$str = Functions::trim_result($str);
|
||||||
$str = str_replace(array('[OK] HYProxy is already installed.', '[OK] Nginx reload','[HYProxy-1.0 admin]'), '', $str);
|
$str = str_replace(array('[OK] HYProxy is already installed.', '[OK] Nginx reload','[HYProxy-1.0 admin]'), '', $str);
|
||||||
$arr = explode("\n", $str); //分割为数组,每行为一个数组元素
|
$arr = explode("\n", $str); //分割为数组,每行为一个数组元素
|
||||||
$arr = array_filter(array_map('trim',$arr)); //去除数组中的空元素
|
$arr = array_filter(array_map('trim', $arr)); //去除数组中的空元素
|
||||||
return implode(PHP_EOL,$arr); //用换行符连结数组为字符串
|
return implode(PHP_EOL, $arr); //用换行符连结数组为字符串
|
||||||
}
|
}
|
||||||
|
|
||||||
// 反代列表
|
// 反代列表
|
||||||
function hyproxy_list($args=''){//OK
|
function hyproxy_list($args = '')
|
||||||
|
{
|
||||||
|
//OK
|
||||||
//TODO
|
//TODO
|
||||||
//$server_name = $args['server_name'];域名搜索
|
//$server_name = $args['server_name'];域名搜索
|
||||||
//$status;//状态搜索start/stop
|
//$status;//状态搜索start/stop
|
||||||
|
|
@ -19,12 +23,16 @@ class hyproxys extends AmysqlModel{
|
||||||
return $this -> _all($sql);
|
return $this -> _all($sql);
|
||||||
}
|
}
|
||||||
// 取得反代网站
|
// 取得反代网站
|
||||||
function hyproxy_get($name){//OK
|
function hyproxy_get($name)
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'";
|
$sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'";
|
||||||
return $this -> _row($sql);
|
return $this -> _row($sql);
|
||||||
}
|
}
|
||||||
// 增加反代网站
|
// 增加反代网站
|
||||||
function hyproxy_add($server_name, $proxy_pass){//OK
|
function hyproxy_add($server_name, $proxy_pass)
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$server_name = trim($server_name);
|
$server_name = trim($server_name);
|
||||||
$proxy_pass = trim($proxy_pass);
|
$proxy_pass = trim($proxy_pass);
|
||||||
$proxy = $this->hyproxy_get($server_name);
|
$proxy = $this->hyproxy_get($server_name);
|
||||||
|
|
@ -32,7 +40,7 @@ class hyproxys extends AmysqlModel{
|
||||||
return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' );
|
return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' );
|
||||||
} else {
|
} else {
|
||||||
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
||||||
if(!preg_match('/^http(s)?:\\/\\/.+/',$proxy_pass)){
|
if (!preg_match('/^http(s)?:\\/\\/.+/', $proxy_pass)) {
|
||||||
$proxy_pass = 'http://'.$proxy_pass;
|
$proxy_pass = 'http://'.$proxy_pass;
|
||||||
}
|
}
|
||||||
$data = array(
|
$data = array(
|
||||||
|
|
@ -50,13 +58,15 @@ class hyproxys extends AmysqlModel{
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
shell_exec($cmd);
|
shell_exec($cmd);
|
||||||
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' );
|
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' );
|
||||||
}else {
|
} else {
|
||||||
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名增加失败。' );
|
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名增加失败。' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 编辑反代网站
|
// 编辑反代网站
|
||||||
function hyproxy_edit(){//OK
|
function hyproxy_edit()
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$server_name = trim($_POST['server_name']);
|
$server_name = trim($_POST['server_name']);
|
||||||
if ($_POST['index']!=$_POST['index_hidden']) {//默认首页
|
if ($_POST['index']!=$_POST['index_hidden']) {//默认首页
|
||||||
$data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']);
|
$data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']);
|
||||||
|
|
@ -67,79 +77,86 @@ class hyproxys extends AmysqlModel{
|
||||||
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址
|
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址
|
||||||
$data['proxy_pass'] = trim($_POST['proxy_pass']);
|
$data['proxy_pass'] = trim($_POST['proxy_pass']);
|
||||||
empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name;
|
empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name;
|
||||||
if(!preg_match('/^http(s)?:\\/\\/.+/',$data['proxy_pass'])){
|
if (!preg_match('/^http(s)?:\\/\\/.+/', $data['proxy_pass'])) {
|
||||||
$data['proxy_pass'] = 'http://'.$data['proxy_pass'];
|
$data['proxy_pass'] = 'http://'.$data['proxy_pass'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$data['time'] = time();//时间戳
|
$data['time'] = time();//时间戳
|
||||||
$where = sprintf("WHERE `server_name` = '%s'",$server_name);//查询条件
|
$where = sprintf("WHERE `server_name` = '%s'", $server_name);//查询条件
|
||||||
$res = $this -> _update('module_hyproxy',$data,$where);
|
$res = $this -> _update('module_hyproxy', $data, $where);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$server_name";
|
$cmd = "amh module HYProxy-1.0 admin make,$server_name";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
shell_exec($cmd);
|
shell_exec($cmd);
|
||||||
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' );
|
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' );
|
||||||
}else {
|
} else {
|
||||||
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' );
|
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除反代网站
|
// 删除反代网站
|
||||||
function hyproxy_del($del_name){//OK
|
function hyproxy_del($del_name)
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$del_name = trim($del_name);
|
$del_name = trim($del_name);
|
||||||
$cmd = "amh module HYProxy-1.0 admin del,$del_name";
|
$cmd = "amh module HYProxy-1.0 admin del,$del_name";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
$result = $this->hyclear_result(shell_exec($cmd));
|
$result = $this->hyclear_result(shell_exec($cmd));
|
||||||
if (strpos($result, '[ERROR]') === false){
|
if (strpos($result, '[ERROR]') === false) {
|
||||||
return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' );
|
return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' );
|
||||||
}else{
|
} else {
|
||||||
return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' );
|
return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 状态
|
// 状态
|
||||||
function hyproxy_run($run_name, $g){//OK
|
function hyproxy_run($run_name, $g)
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$run_zh = array(
|
$run_zh = array(
|
||||||
'start' => '启动',
|
'start' => '启动',
|
||||||
'stop' => '停止'
|
'stop' => '停止'
|
||||||
);
|
);
|
||||||
$data['status'] = $g;
|
$data['status'] = $g;
|
||||||
$data['time'] = time();//时间戳
|
$data['time'] = time();//时间戳
|
||||||
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件
|
$where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
|
||||||
$res = $this -> _update('module_hyproxy',$data,$where);
|
$res = $this -> _update('module_hyproxy', $data, $where);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
shell_exec($cmd);
|
shell_exec($cmd);
|
||||||
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' );
|
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' );
|
||||||
}else {
|
} else {
|
||||||
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' );
|
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 缓存状态
|
// 缓存状态
|
||||||
function hyproxy_run_cache($run_name, $g){//OK
|
function hyproxy_run_cache($run_name, $g)
|
||||||
|
{
|
||||||
|
//OK
|
||||||
$run_zh = array(
|
$run_zh = array(
|
||||||
'1' => '启动',
|
'1' => '启动',
|
||||||
'0' => '停止'
|
'0' => '停止'
|
||||||
);
|
);
|
||||||
$data['proxy_cache'] = $g;
|
$data['proxy_cache'] = $g;
|
||||||
$data['time'] = time();//时间戳
|
$data['time'] = time();//时间戳
|
||||||
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件
|
$where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
|
||||||
$res = $this -> _update('module_hyproxy',$data,$where);
|
$res = $this -> _update('module_hyproxy', $data, $where);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
shell_exec($cmd);
|
shell_exec($cmd);
|
||||||
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' );
|
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' );
|
||||||
}else {
|
} else {
|
||||||
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' );
|
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 取得缓存
|
// 取得缓存
|
||||||
function get_hyproxy_cache(){
|
function get_hyproxy_cache()
|
||||||
|
{
|
||||||
$name = trim($name);
|
$name = trim($name);
|
||||||
$cmd = "amh cat_nginx";
|
$cmd = "amh cat_nginx";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
|
|
@ -152,32 +169,33 @@ class hyproxys extends AmysqlModel{
|
||||||
$data['inactive'] = $arr[3];
|
$data['inactive'] = $arr[3];
|
||||||
$data['max_size'] = $arr[4];
|
$data['max_size'] = $arr[4];
|
||||||
$data['valid'] = $arr2[1];
|
$data['valid'] = $arr2[1];
|
||||||
foreach ($data as $key=>$val)
|
foreach ($data as $key => $val) {
|
||||||
$data[$key] = trim($val);
|
$data[$key] = trim($val);
|
||||||
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存缓存
|
// 保存缓存
|
||||||
function save_hyproxy_cache(){
|
function save_hyproxy_cache()
|
||||||
|
{
|
||||||
$run_name = trim($run_name);
|
$run_name = trim($run_name);
|
||||||
$cmd = "amh module HYProxy-1.0 admin cache,{$_POST['levels']},{$_POST['keys_zone']},{$_POST['max_size']},{$_POST['valid']},{$_POST['inactive']}";
|
$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);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
exec($cmd, $tmp, $status);
|
exec($cmd, $tmp, $status);
|
||||||
Return !$status;
|
return !$status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 取得缓存索引
|
// 取得缓存索引
|
||||||
function get_hyproxy_cache_index(){
|
function get_hyproxy_cache_index()
|
||||||
|
{
|
||||||
// $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type ";
|
// $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type ";
|
||||||
$sql = "SELECT * FROM module_hyproxy_cache";
|
$sql = "SELECT * FROM module_hyproxy_cache";
|
||||||
$result = $this -> _query($sql);
|
$result = $this -> _query($sql);
|
||||||
while ($rs = mysql_fetch_assoc($result))
|
while ($rs = mysql_fetch_assoc($result)) {
|
||||||
{
|
|
||||||
$url_info = parse_url($rs['hyproxy_key']);
|
$url_info = parse_url($rs['hyproxy_key']);
|
||||||
if (isset($url_info['host']) && !empty($url_info['host']))
|
if (isset($url_info['host']) && !empty($url_info['host'])) {
|
||||||
{
|
|
||||||
++$data[$url_info['host']]['all']['sum'];
|
++$data[$url_info['host']]['all']['sum'];
|
||||||
$data[$url_info['host']]['all']['size'] += $rs['hyproxy_size'];
|
$data[$url_info['host']]['all']['size'] += $rs['hyproxy_size'];
|
||||||
|
|
||||||
|
|
@ -185,11 +203,12 @@ class hyproxys extends AmysqlModel{
|
||||||
$data[$url_info['host']][$rs['hyproxy_type']]['size'] += $rs['hyproxy_size'];
|
$data[$url_info['host']][$rs['hyproxy_type']]['size'] += $rs['hyproxy_size'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建缓存索引
|
// 创建缓存索引
|
||||||
function create_hyproxy_cache_index(){
|
function create_hyproxy_cache_index()
|
||||||
|
{
|
||||||
$val = (int)$_POST['cache_index_time_val'];
|
$val = (int)$_POST['cache_index_time_val'];
|
||||||
$type = array('1' => 60*24, '2' => 60, '3' => 1);
|
$type = array('1' => 60*24, '2' => 60, '3' => 1);
|
||||||
$area = array('1' => '-', '2' => '+');
|
$area = array('1' => '-', '2' => '+');
|
||||||
|
|
@ -200,29 +219,30 @@ class hyproxys extends AmysqlModel{
|
||||||
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode";
|
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
exec($cmd, $tmp, $status);
|
exec($cmd, $tmp, $status);
|
||||||
Return !$status;
|
return !$status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *********************************************************
|
// *********************************************************
|
||||||
// 取得缓存列表
|
// 取得缓存列表
|
||||||
function get_hyproxy_cache_list($page = 1, $page_sum = 20){
|
function get_hyproxy_cache_list($page = 1, $page_sum = 20)
|
||||||
|
{
|
||||||
$where = '';
|
$where = '';
|
||||||
|
|
||||||
if (isset($_GET['cache_key']) && !empty($_GET['cache_key']))
|
if (isset($_GET['cache_key']) && !empty($_GET['cache_key'])) {
|
||||||
{
|
|
||||||
$_GET['cache_key'] = trim($_GET['cache_key']);
|
$_GET['cache_key'] = trim($_GET['cache_key']);
|
||||||
$where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'";
|
$where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all')
|
if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all') {
|
||||||
$where .= " AND hyproxy_type LIKE '{$_GET['cache_type']}'";
|
$where .= " AND hyproxy_type LIKE '{$_GET['cache_type']}'";
|
||||||
|
}
|
||||||
|
|
||||||
$limit = ' LIMIT ' . ($page-1)*$page_sum . ' , ' . $page_sum;
|
$limit = ' LIMIT ' . ($page-1)*$page_sum . ' , ' . $page_sum;
|
||||||
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where";
|
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where";
|
||||||
$sum = $this -> _sum($sql);
|
$sum = $this -> _sum($sql);
|
||||||
|
|
||||||
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where $limit";
|
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where $limit";
|
||||||
Return array('data' => $this -> _all($sql), 'sum' => $sum);
|
return array('data' => $this -> _all($sql), 'sum' => $sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
|
|
@ -233,6 +253,6 @@ class hyproxys extends AmysqlModel{
|
||||||
$cmd = "amh module HYProxy-1.0 admin cache-delete,$url_param,$file_type";
|
$cmd = "amh module HYProxy-1.0 admin cache-delete,$url_param,$file_type";
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
exec($cmd, $tmp, $status);
|
exec($cmd, $tmp, $status);
|
||||||
Return !$status;
|
return !$status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
<?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>
|
<p>反代缓存设置:</p>
|
||||||
<form action="./index.php?c=hyproxy&a=hyproxy_cache" method="POST" >
|
<form action="./index.php?c=hyproxy&a=hyproxy_cache" method="POST" >
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@ var cache_delete_submit = function ()
|
||||||
<?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>
|
<div>
|
||||||
|
|
@ -51,13 +53,11 @@ var cache_delete_submit = function ()
|
||||||
<input type="hidden" value="hyproxy_cache_del" name="a"/>
|
<input type="hidden" value="hyproxy_cache_del" name="a"/>
|
||||||
<input type="hidden" value="hyproxy" name="c"/>
|
<input type="hidden" value="hyproxy" name="c"/>
|
||||||
索引域名 <select name="cache_host" id="cache_host" style="width:180px;">
|
索引域名 <select name="cache_host" id="cache_host" style="width:180px;">
|
||||||
<?php if (is_array($cache_host))
|
<?php if (is_array($cache_host)) {
|
||||||
{
|
foreach ($cache_host as $key => $val) {
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -66,14 +66,12 @@ var cache_delete_submit = function ()
|
||||||
<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;"/>
|
网址匹配 (可使用%通配符) <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;"/>
|
||||||
文件类型 <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>
|
<option value="<?php echo $val;?>"><?php echo $val;?></option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,17 +101,13 @@ var cache_delete_submit = function ()
|
||||||
<th>创建时间</th>
|
<th>创建时间</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
if(!is_array($hyproxy_cache_list['data']) || count($hyproxy_cache_list['data']) < 1)
|
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>
|
<tr><td colspan="7" style="padding:10px;text-align:center;">没找到缓存索引数据。</td></tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$k = 0;
|
$k = 0;
|
||||||
foreach ($hyproxy_cache_list['data'] as $key=>$val)
|
foreach ($hyproxy_cache_list['data'] as $key => $val) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="i"><?php echo $val['hyproxy_id'];?></th>
|
<th class="i"><?php echo $val['hyproxy_id'];?></th>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ var cache_index_submit = function ()
|
||||||
<?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>
|
<p>反代缓存索引:</p>
|
||||||
<table border="0" cellspacing="1" id="STable" style="width:720px;">
|
<table border="0" cellspacing="1" id="STable" style="width:720px;">
|
||||||
|
|
@ -52,12 +54,11 @@ var cache_index_submit = function ()
|
||||||
$host_sum = 0;
|
$host_sum = 0;
|
||||||
$file_sum = 0;
|
$file_sum = 0;
|
||||||
$file_size = 0;
|
$file_size = 0;
|
||||||
foreach ($hyproxy_cache_index as $key=>$val)
|
foreach ($hyproxy_cache_index as $key => $val) {
|
||||||
{
|
|
||||||
$file_sum += $val['all']['sum'];
|
$file_sum += $val['all']['sum'];
|
||||||
$file_size += $val['all']['size'];
|
$file_size += $val['all']['size'];
|
||||||
++$host_sum;
|
++$host_sum;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="http://<?php echo $key;?>" class="button" target="_blank"><span class="home icon"></span>主页</a> <?php echo $key;?></td>
|
<td><a href="http://<?php echo $key;?>" class="button" target="_blank"><span class="home icon"></span>主页</a> <?php echo $key;?></td>
|
||||||
<td style="padding:8px">总缓存文件 <b><?php echo $val['all']['sum'];?></b> 个</td>
|
<td style="padding:8px">总缓存文件 <b><?php echo $val['all']['sum'];?></b> 个</td>
|
||||||
|
|
@ -71,26 +72,24 @@ foreach ($hyproxy_cache_index as $key=>$val)
|
||||||
<th>缓存数量</th>
|
<th>缓存数量</th>
|
||||||
<th>使用空间</th>
|
<th>使用空间</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
foreach ($val as $k=>$v)
|
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>
|
||||||
|
|
|
||||||
|
|
@ -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;">
|
||||||
|
|
@ -16,18 +18,14 @@
|
||||||
<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>
|
||||||
|
|
@ -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" >
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue