209 lines
6.0 KiB
PHP
209 lines
6.0 KiB
PHP
<?php
|
|
class hyproxy extends AmysqlController {
|
|
|
|
public $indexs = null;
|
|
public $hyproxys = null;
|
|
public $notice = null;
|
|
|
|
// 载入数据模型(Model)
|
|
function AmysqlModelBase() {
|
|
if($this -> indexs) return;
|
|
$this -> _class('Functions');
|
|
$this -> indexs = $this -> _model('indexs');
|
|
$this -> hyproxys = $this -> _model('hyproxys');
|
|
}
|
|
|
|
function IndexAction(){
|
|
$this -> hyproxy_list();
|
|
}
|
|
|
|
// 反代列表
|
|
function hyproxy_list(){
|
|
$this -> title = '反代列表 - HYProxy'; // 面板模块标题
|
|
$this -> AmysqlModelBase();
|
|
Functions::CheckLogin(); // 面板登录检查函数
|
|
|
|
$this -> status = 'error';
|
|
// 状态
|
|
if (isset($_GET['run'])) {
|
|
$run_name = $_GET['run'];
|
|
$run_zh = array(
|
|
'start' => '启动',
|
|
'stop' => '停止'
|
|
);
|
|
if ( !empty($run_name) && isset($run_zh[$_GET['g']]) ) {
|
|
$g = $_GET['g'];
|
|
$result = $this->hyproxys->hyproxy_run($run_name, $g);
|
|
$this->status = $result['status'];
|
|
$this->notice = $result['notice'];
|
|
}
|
|
}
|
|
// 缓存状态
|
|
if (isset($_GET['run_cache'])) {
|
|
$run_name = $_GET['run_cache'];
|
|
$run_zh = array(
|
|
'1' => '启动',
|
|
'0' => '停止'
|
|
);
|
|
if (!empty($run_name) && isset($run_zh[$_GET['g']])) {
|
|
$g = $_GET['g'];
|
|
$result = $this->hyproxys->hyproxy_run_cache($run_name, $g);
|
|
$this->status = $result['status'];
|
|
$this->notice = $result['notice'];
|
|
}
|
|
}
|
|
// 删除
|
|
if (isset($_GET['del'])) {
|
|
$del_name = $_GET['del'];
|
|
if (!empty($del_name)) {
|
|
$result = $this->hyproxys->hyproxy_del($del_name);
|
|
$this->status = $result['status'];
|
|
$this->notice = $result['notice'];
|
|
}
|
|
}
|
|
// 管理
|
|
if (isset($_GET['admin'])) {
|
|
if (isset($_POST['edit'])) {
|
|
$result = $this->hyproxys->hyproxy_edit();
|
|
$this->status = $result['status'];
|
|
$this->notice = $result['notice'];
|
|
}
|
|
$name = $_GET['admin'];
|
|
$this->hyproxy_get = $this->hyproxys->hyproxy_get($name);
|
|
}
|
|
|
|
// 新增
|
|
if (isset($_POST['submit'])) {
|
|
$server_name = $_POST['server_name'];
|
|
$proxy_pass = $_POST['proxy_pass'];
|
|
if (!empty($server_name) && !empty($proxy_pass)) {
|
|
$result = $this->hyproxys->hyproxy_add($server_name, $proxy_pass);
|
|
$this->status = $result['status'];
|
|
$this->notice = $result['notice'];
|
|
} else {
|
|
$this->notice = '请填写完整数据。';
|
|
}
|
|
}
|
|
|
|
$this -> indexs -> log_insert($this -> notice);
|
|
$this -> hyproxy_list = $this -> hyproxys -> hyproxy_list();
|
|
$this -> _view('hyproxy_list');
|
|
}
|
|
|
|
// *********************************************************
|
|
// 缓存设置
|
|
function hyproxy_cache(){
|
|
$this -> title = '缓存设置 - HYProxy - AMH';
|
|
$this -> AmysqlModelBase();
|
|
Functions::CheckLogin();
|
|
|
|
// 保存
|
|
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');
|
|
}
|
|
|
|
|
|
// *********************************************************
|
|
// 缓存索引
|
|
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 -> 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(){
|
|
$this -> title = '缓存删除 - HYProxy - AMH';
|
|
$this -> AmysqlModelBase();
|
|
Functions::CheckLogin();
|
|
|
|
// 删除缓存
|
|
if (isset($_POST['post_delete']))
|
|
{
|
|
if ($this -> hyproxys -> hyproxy_cache_delete())
|
|
{
|
|
$this -> status = 'success';
|
|
$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');
|
|
}
|
|
|
|
} |