Compare commits
No commits in common. "master" and "HYProxy1.0" have entirely different histories.
master
...
HYProxy1.0
|
|
@ -1 +0,0 @@
|
||||||
.idea
|
|
||||||
45
AMHScript
45
AMHScript
|
|
@ -20,36 +20,19 @@ function amh_module_install()
|
||||||
if amh_module_status ; then
|
if amh_module_status ; then
|
||||||
exit;
|
exit;
|
||||||
else
|
else
|
||||||
#Fix 'Too many open files' Error
|
|
||||||
if ! cat /etc/security/limits.conf | grep -q '* soft nofile 40960'; then
|
|
||||||
echo '* soft nofile 40960' >> /etc/security/limits.conf;
|
|
||||||
fi;
|
|
||||||
if ! cat /etc/security/limits.conf | grep -q '* hard nofile 40960'; then
|
|
||||||
echo '* hard nofile 40960' >> /etc/security/limits.conf;
|
|
||||||
fi;
|
|
||||||
#Delete other version
|
#Delete other version
|
||||||
for module_name in `ls /root/amh/modules/ | grep 'HYProxy' | grep -v 'HYProxy-1.0'`; do
|
for module_name in `ls /root/amh/modules/ | grep 'HYProxy' | grep -v 'HYProxy-1.0'`; do
|
||||||
#amh module $module_name uninstall force;
|
#amh module $module_name uninstall force;
|
||||||
#amh module $module_name delete y;
|
#amh module $module_name delete y;
|
||||||
rm -rf /root/amh/modules/$module_name;
|
rm -rf /root/amh/modules/$module_name;
|
||||||
done;
|
done;
|
||||||
#Delete conflict modules
|
|
||||||
if ls /root/amh/modules/ | grep -q 'limit_req2_nginx_module-1.2'; then
|
|
||||||
amh module limit_req2_nginx_module-1.2 uninstall force;
|
|
||||||
amh module limit_req2_nginx_module-1.2 delete y;
|
|
||||||
fi;
|
|
||||||
#install PDO_MYSQL module and set InnoDB_Engine On
|
#install PDO_MYSQL module and set InnoDB_Engine On
|
||||||
if ! ls /root/amh/modules/ | grep -q 'PDO_MYSQL-1.0.2'; then
|
amh module download PDO_MYSQL-1.0.2;
|
||||||
amh module download PDO_MYSQL-1.0.2;
|
amh module PDO_MYSQL-1.0.2 install force;
|
||||||
fi;
|
|
||||||
if ! cat /etc/php.ini | grep -q 'pdo_mysql.so'; then
|
|
||||||
amh module PDO_MYSQL-1.0.2 install force;
|
|
||||||
fi;
|
|
||||||
amh SetParam mysql InnoDB_Engine On;
|
amh SetParam mysql InnoDB_Engine On;
|
||||||
#install nginx module
|
#install nginx module
|
||||||
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
||||||
nginx_configure='--prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-ipv6';
|
nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
|
||||||
new_nginx_configure=$nginx_configure;
|
new_nginx_configure=$nginx_configure;
|
||||||
if ! echo "$new_nginx_configure" | grep 'with-http_stub_status_module' > /dev/null; then
|
if ! echo "$new_nginx_configure" | grep 'with-http_stub_status_module' > /dev/null; then
|
||||||
new_nginx_configure="${new_nginx_configure} --with-http_stub_status_module";
|
new_nginx_configure="${new_nginx_configure} --with-http_stub_status_module";
|
||||||
|
|
@ -78,7 +61,8 @@ function amh_module_install()
|
||||||
\cp -a ./objs/nginx /usr/local/nginx/sbin/;
|
\cp -a ./objs/nginx /usr/local/nginx/sbin/;
|
||||||
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`;
|
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`;
|
||||||
cd /usr/local/;
|
cd /usr/local/;
|
||||||
rm -rf tengine-2.3.2 tengine-2.3.2.tar.gz ngx_cache_purge-2.3.tar.gz;
|
rm -rf tengine-2.3.2 tengine-2.3.2.tar.gz;
|
||||||
|
rm -rf ngx_cache_purge-2.3 ngx_cache_purge-2.3.tar.gz;
|
||||||
#rm -rf /usr/local/nginx/sbin/nginx-old;
|
#rm -rf /usr/local/nginx/sbin/nginx-old;
|
||||||
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`;
|
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`;
|
||||||
if grep -q -e "Tengine.*<br />" /home/wwwroot/index/web/View/index.php; then
|
if grep -q -e "Tengine.*<br />" /home/wwwroot/index/web/View/index.php; then
|
||||||
|
|
@ -101,7 +85,7 @@ function amh_module_install()
|
||||||
sed -i "/include vhost/a\ \tinclude hyproxy/*.conf;" /usr/local/nginx/conf/nginx.conf;
|
sed -i "/include vhost/a\ \tinclude hyproxy/*.conf;" /usr/local/nginx/conf/nginx.conf;
|
||||||
mysql -uroot -p$MysqlPass < ./hyproxy.sql && touch ./InstallComplete && amh module HYProxy-1.0 admin cache,1:2:2,256m,10g,4h,1d;
|
mysql -uroot -p$MysqlPass < ./hyproxy.sql && touch ./InstallComplete && amh module HYProxy-1.0 admin cache,1:2:2,256m,10g,4h,1d;
|
||||||
|
|
||||||
amh nginx restart;
|
amh nginx reload;
|
||||||
amh_module_status;
|
amh_module_status;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
@ -254,6 +238,7 @@ function amh_module_admin()
|
||||||
|
|
||||||
elif [ "$action" == 'del' ]; then
|
elif [ "$action" == 'del' ]; then
|
||||||
php ${module_dir}hyproxy-cli.php --action='del' --server_name=${domain}
|
php ${module_dir}hyproxy-cli.php --action='del' --server_name=${domain}
|
||||||
|
rm -f "$domain_conf" && echo "[OK] successfully delete $domain HYProxy.";
|
||||||
amh nginx reload;
|
amh nginx reload;
|
||||||
elif [ "$action" == 'start' ]; then
|
elif [ "$action" == 'start' ]; then
|
||||||
php ${module_dir}hyproxy-cli.php --action='edit' --server_name=${domain} --field_name='status' --value='start';
|
php ${module_dir}hyproxy-cli.php --action='edit' --server_name=${domain} --field_name='status' --value='start';
|
||||||
|
|
@ -285,13 +270,9 @@ function amh_module_uninstall()
|
||||||
{
|
{
|
||||||
if amh_module_status ; then
|
if amh_module_status ; then
|
||||||
|
|
||||||
#backup proxys
|
|
||||||
php ${module_dir}hyproxy-cli.php --action='backup';
|
|
||||||
|
|
||||||
#uninstall nginx modules
|
#uninstall nginx modules
|
||||||
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
||||||
nginx_configure='--prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-ipv6';
|
nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
|
||||||
new_nginx_configure=$nginx_configure;
|
new_nginx_configure=$nginx_configure;
|
||||||
if echo "$new_nginx_configure" | grep 'add-module=/usr/local/ngx_cache_purge-2.3' > /dev/null; then
|
if echo "$new_nginx_configure" | grep 'add-module=/usr/local/ngx_cache_purge-2.3' > /dev/null; then
|
||||||
new_nginx_configure=`echo $new_nginx_configure | sed "s|--add-module=/usr/local/ngx_cache_purge-2.3||"`;
|
new_nginx_configure=`echo $new_nginx_configure | sed "s|--add-module=/usr/local/ngx_cache_purge-2.3||"`;
|
||||||
|
|
@ -317,14 +298,14 @@ function amh_module_uninstall()
|
||||||
MysqlPass=`cat /home/wwwroot/index/web/Amysql/Config.php | awk '{ FS="\047Password\047] = \047"; RS="\047;" } { print $2}' | sed '/^$/d'`;
|
MysqlPass=`cat /home/wwwroot/index/web/Amysql/Config.php | awk '{ FS="\047Password\047] = \047"; RS="\047;" } { print $2}' | sed '/^$/d'`;
|
||||||
cd /usr/local/;
|
cd /usr/local/;
|
||||||
rm -rf ngx_cache_purge-2.3 ngx_cache_purge-2.3.tar.gz;
|
rm -rf ngx_cache_purge-2.3 ngx_cache_purge-2.3.tar.gz;
|
||||||
rm -rf /usr/local/nginx/conf/hyproxy /home/hyproxy_cache /home/hyproxy_cache_tmp /home/hyproxy_logs;
|
rm -rf /usr/local/nginx/conf/hyproxy /home/hyproxy_cache /home/hyproxy_cache_tmp;
|
||||||
rm -f /home/wwwroot/index/web/Controller/hyproxy.php /home/wwwroot/index/web/Model/hyproxys.php /home/wwwroot/index/web/View/{hyproxy_category.php,hyproxy_list.php,hyproxy_cache.php,hyproxy_cache_index.php,hyproxy_cache_del.php};
|
rm -f /home/wwwroot/index/web/Controller/hyproxy.php /home/wwwroot/index/web/Model/hyproxys.php /home/wwwroot/index/web/View/{hyproxy_category.php,hyproxy_list.php,hyproxy_cache.php,hyproxy_cache_index.php,hyproxy_cache_del.php};
|
||||||
sed -i "/include hyproxy/d" /usr/local/nginx/conf/nginx.conf;
|
sed -i "/include hyproxy/d" /usr/local/nginx/conf/nginx.conf;
|
||||||
sed -i "/proxy_/d" /usr/local/nginx/conf/nginx.conf;
|
sed -i "/proxy_/d" /usr/local/nginx/conf/nginx.conf;
|
||||||
rm -f /root/amh/modules/HYProxy-1.0/InstallComplete;
|
rm -f /root/amh/modules/HYProxy-1.0/InstallComplete;
|
||||||
mysql -uroot -p${MysqlPass} -B -N -e "DROP TABLE amh.module_hyproxy;DROP TABLE amh.module_hyproxy_cache" ;
|
mysql -uroot -p${MysqlPass} -B -N -e "DROP TABLE amh.module_hyproxy;DROP TABLE amh.module_hyproxy_cache" ;
|
||||||
|
|
||||||
amh nginx restart;
|
amh nginx reload;
|
||||||
echo '[OK] HYProxy Uninstall successful.';
|
echo '[OK] HYProxy Uninstall successful.';
|
||||||
else
|
else
|
||||||
exit;
|
exit;
|
||||||
|
|
|
||||||
|
|
@ -1,203 +1,209 @@
|
||||||
<?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) {
|
$this -> _class('Functions');
|
||||||
return;
|
$this -> indexs = $this -> _model('indexs');
|
||||||
}
|
$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 -> title = '反代列表 - HYProxy'; // 面板模块标题
|
$this -> AmysqlModelBase();
|
||||||
$this -> AmysqlModelBase();
|
Functions::CheckLogin(); // 面板登录检查函数
|
||||||
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'])) {
|
|
||||||
$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');
|
|
||||||
}
|
}
|
||||||
|
// 缓存状态
|
||||||
|
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()
|
function hyproxy_cache(){
|
||||||
|
$this -> title = '缓存设置 - HYProxy - AMH';
|
||||||
|
$this -> AmysqlModelBase();
|
||||||
|
Functions::CheckLogin();
|
||||||
|
|
||||||
|
// 保存
|
||||||
|
if (isset($_POST['save']))
|
||||||
{
|
{
|
||||||
$this -> title = '缓存设置 - HYProxy - AMH';
|
$this -> status = 'error';
|
||||||
$this -> AmysqlModelBase();
|
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive');
|
||||||
Functions::CheckLogin();
|
foreach ($field as $key=>$val)
|
||||||
|
{
|
||||||
// 保存
|
if (!isset($_POST[$val]) || empty($_POST[$val]))
|
||||||
if (isset($_POST['save'])) {
|
{
|
||||||
$this -> status = 'error';
|
$error = true;
|
||||||
$field = array('levels', 'keys_zone', 'max_size', 'valid', 'inactive');
|
break;
|
||||||
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 缓存设置失败。';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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']))
|
||||||
{
|
{
|
||||||
$this -> title = '缓存索引 - HYProxy - AMH';
|
if ($this -> hyproxys -> create_hyproxy_cache_index())
|
||||||
$this -> AmysqlModelBase();
|
{
|
||||||
Functions::CheckLogin();
|
$this -> status = 'success';
|
||||||
|
$this -> notice = 'HYProxy 创建缓存索引成功。';
|
||||||
if (isset($_POST['post_submit'])) {
|
}
|
||||||
if ($this -> hyproxys -> create_hyproxy_cache_index()) {
|
else
|
||||||
$this -> status = 'success';
|
{
|
||||||
$this -> notice = 'HYProxy 创建缓存索引成功。';
|
$this -> status = 'error';
|
||||||
} else {
|
$this -> notice = 'HYProxy 创建缓存索引失败。';
|
||||||
$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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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']))
|
||||||
{
|
{
|
||||||
$this -> title = '缓存删除 - HYProxy - AMH';
|
if ($this -> hyproxys -> hyproxy_cache_delete())
|
||||||
$this -> AmysqlModelBase();
|
{
|
||||||
Functions::CheckLogin();
|
$this -> status = 'success';
|
||||||
|
$this -> notice = 'HYProxy 缓存删除成功。';
|
||||||
// 删除缓存
|
}
|
||||||
if (isset($_POST['post_delete'])) {
|
else
|
||||||
if ($this -> hyproxys -> hyproxy_cache_delete()) {
|
{
|
||||||
$this -> status = 'success';
|
$this -> status = 'error';
|
||||||
$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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,258 +1,238 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class hyproxys extends AmysqlModel
|
class hyproxys extends AmysqlModel{
|
||||||
{
|
function hyclear_result($str){
|
||||||
function hyclear_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 = Functions::trim_result($str);
|
$arr = explode("\n", $str); //分割为数组,每行为一个数组元素
|
||||||
$str = str_replace(array('[OK] HYProxy is already installed.', '[OK] Nginx reload','[HYProxy-1.0 admin]'), '', $str);
|
$arr = array_filter(array_map('trim',$arr)); //去除数组中的空元素
|
||||||
$arr = explode("\n", $str); //分割为数组,每行为一个数组元素
|
return implode(PHP_EOL,$arr); //用换行符连结数组为字符串
|
||||||
$arr = array_filter(array_map('trim', $arr)); //去除数组中的空元素
|
}
|
||||||
return implode(PHP_EOL, $arr); //用换行符连结数组为字符串
|
|
||||||
}
|
// 反代列表
|
||||||
|
function hyproxy_list($args=''){//OK
|
||||||
// 反代列表
|
//TODO
|
||||||
function hyproxy_list($args = '')
|
//$server_name = $args['server_name'];域名搜索
|
||||||
{
|
//$status;//状态搜索start/stop
|
||||||
//OK
|
//分页
|
||||||
//TODO
|
$sql = "SELECT * FROM module_hyproxy ORDER BY hyproxy_id ASC";
|
||||||
//$server_name = $args['server_name'];域名搜索
|
return $this -> _all($sql);
|
||||||
//$status;//状态搜索start/stop
|
}
|
||||||
//分页
|
// 取得反代网站
|
||||||
$sql = "SELECT * FROM module_hyproxy ORDER BY hyproxy_id ASC";
|
function hyproxy_get($name){//OK
|
||||||
return $this -> _all($sql);
|
$sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'";
|
||||||
}
|
return $this -> _row($sql);
|
||||||
// 取得反代网站
|
}
|
||||||
function hyproxy_get($name)
|
// 增加反代网站
|
||||||
{
|
function hyproxy_add($server_name, $proxy_pass){//OK
|
||||||
//OK
|
$server_name = trim($server_name);
|
||||||
$sql = "SELECT * FROM module_hyproxy WHERE `server_name` = '$name'";
|
$proxy_pass = trim($proxy_pass);
|
||||||
return $this -> _row($sql);
|
$proxy = $this->hyproxy_get($server_name);
|
||||||
}
|
if ($proxy) {
|
||||||
// 增加反代网站
|
return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' );
|
||||||
function hyproxy_add($server_name, $proxy_pass)
|
} else {
|
||||||
{
|
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
||||||
//OK
|
if(!preg_match('/^http(s)?:\\/\\/.+/',$proxy_pass)){
|
||||||
$server_name = trim($server_name);
|
$proxy_pass = 'http://'.$proxy_pass;
|
||||||
$proxy_pass = trim($proxy_pass);
|
}
|
||||||
$proxy = $this->hyproxy_get($server_name);
|
$data = array(
|
||||||
if ($proxy) {
|
'server_name' => $server_name,
|
||||||
return array( 'status' => 'error' , 'notice' => '绑定域名已存在,请删除旧记录或更换域名。' );
|
'index' => 'index.php index.html index.htm',
|
||||||
} else {
|
'header_host' => '$host',
|
||||||
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
'proxy_pass' => $proxy_pass,
|
||||||
if (!preg_match('/^http(s)?:\\/\\/.+/', $proxy_pass)) {
|
'proxy_cache' => 1,
|
||||||
$proxy_pass = 'http://'.$proxy_pass;
|
'status' => 'start',
|
||||||
}
|
'time' => time()
|
||||||
$data = array(
|
);
|
||||||
'server_name' => $server_name,
|
$res = $this -> _insert('module_hyproxy', $data);
|
||||||
'index' => 'index.php index.html index.htm',
|
if ($res) {
|
||||||
'header_host' => '$host',
|
$cmd = "amh module HYProxy-1.0 admin make,$server_name";
|
||||||
'proxy_pass' => $proxy_pass,
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
'proxy_cache' => 1,
|
shell_exec($cmd);
|
||||||
'status' => 'start',
|
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' );
|
||||||
'time' => time()
|
}else {
|
||||||
);
|
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);
|
// 编辑反代网站
|
||||||
shell_exec($cmd);
|
function hyproxy_edit(){//OK
|
||||||
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名增加成功。' );
|
$server_name = trim($_POST['server_name']);
|
||||||
} else {
|
if ($_POST['index']!=$_POST['index_hidden']) {//默认首页
|
||||||
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名增加失败。' );
|
$data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']);
|
||||||
}
|
}
|
||||||
}
|
if ($_POST['header_host']!=$_POST['header_host_hidden']) {//Host头
|
||||||
}
|
$data['header_host'] = empty($_POST['header_host']) ? '$host' : trim($_POST['header_host']);
|
||||||
// 编辑反代网站
|
}
|
||||||
function hyproxy_edit()
|
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址
|
||||||
{
|
$data['proxy_pass'] = trim($_POST['proxy_pass']);
|
||||||
//OK
|
empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name;
|
||||||
$server_name = trim($_POST['server_name']);
|
if(!preg_match('/^http(s)?:\\/\\/.+/',$data['proxy_pass'])){
|
||||||
if ($_POST['index']!=$_POST['index_hidden']) {//默认首页
|
$data['proxy_pass'] = 'http://'.$data['proxy_pass'];
|
||||||
$data['index'] = empty($_POST['index']) ? 'index.php index.html index.htm' : trim($_POST['index']);
|
}
|
||||||
}
|
}
|
||||||
if ($_POST['header_host']!=$_POST['header_host_hidden']) {//Host头
|
$data['time'] = time();//时间戳
|
||||||
$data['header_host'] = empty($_POST['header_host']) ? '$host' : trim($_POST['header_host']);
|
$where = sprintf("WHERE `server_name` = '%s'",$server_name);//查询条件
|
||||||
}
|
$res = $this -> _update('module_hyproxy',$data,$where);
|
||||||
if ($_POST['proxy_pass']!=$_POST['proxy_pass_hidden']) {//后端地址
|
|
||||||
$data['proxy_pass'] = trim($_POST['proxy_pass']);
|
if ($res) {
|
||||||
empty($data['proxy_pass']) && $data['proxy_pass'] = 'http://'.$server_name;
|
$cmd = "amh module HYProxy-1.0 admin make,$server_name";
|
||||||
if (!preg_match('/^http(s)?:\\/\\/.+/', $data['proxy_pass'])) {
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
$data['proxy_pass'] = 'http://'.$data['proxy_pass'];
|
shell_exec($cmd);
|
||||||
}
|
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' );
|
||||||
}
|
}else {
|
||||||
$data['time'] = time();//时间戳
|
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' );
|
||||||
$where = sprintf("WHERE `server_name` = '%s'", $server_name);//查询条件
|
}
|
||||||
$res = $this -> _update('module_hyproxy', $data, $where);
|
}
|
||||||
|
// 删除反代网站
|
||||||
if ($res) {
|
function hyproxy_del($del_name){//OK
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$server_name";
|
$del_name = trim($del_name);
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$cmd = "amh module HYProxy-1.0 admin del,$del_name";
|
||||||
shell_exec($cmd);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
return array( 'status' => 'success' , 'notice' => $server_name.' : HYProxy域名修改成功。' );
|
$result = $this->hyclear_result(shell_exec($cmd));
|
||||||
} else {
|
if (strpos($result, '[ERROR]') === false){
|
||||||
return array( 'status' => 'error' , 'notice' => $server_name.' : HYProxy域名修改失败。' );
|
return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' );
|
||||||
}
|
}else{
|
||||||
}
|
return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' );
|
||||||
// 删除反代网站
|
}
|
||||||
function hyproxy_del($del_name)
|
}
|
||||||
{
|
// 状态
|
||||||
//OK
|
function hyproxy_run($run_name, $g){//OK
|
||||||
$del_name = trim($del_name);
|
$run_zh = array(
|
||||||
$cmd = "amh module HYProxy-1.0 admin del,$del_name";
|
'start' => '启动',
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
'stop' => '停止'
|
||||||
$result = $this->hyclear_result(shell_exec($cmd));
|
);
|
||||||
if (strpos($result, '[ERROR]') === false) {
|
$data['status'] = $g;
|
||||||
return array( 'status' => 'success' , 'notice' => $del_name.' : HYProxy域名删除成功。' );
|
$data['time'] = time();//时间戳
|
||||||
} else {
|
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件
|
||||||
return array( 'status' => 'error' , 'notice' => $del_name.' : HYProxy域名删除失败。' );
|
$res = $this -> _update('module_hyproxy',$data,$where);
|
||||||
}
|
|
||||||
}
|
if ($res) {
|
||||||
// 状态
|
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
||||||
function hyproxy_run($run_name, $g)
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
{
|
shell_exec($cmd);
|
||||||
//OK
|
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' );
|
||||||
$run_zh = array(
|
}else {
|
||||||
'start' => '启动',
|
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' );
|
||||||
'stop' => '停止'
|
}
|
||||||
);
|
}
|
||||||
$data['status'] = $g;
|
// 缓存状态
|
||||||
$data['time'] = time();//时间戳
|
function hyproxy_run_cache($run_name, $g){//OK
|
||||||
$where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
|
$run_zh = array(
|
||||||
$res = $this -> _update('module_hyproxy', $data, $where);
|
'1' => '启动',
|
||||||
|
'0' => '停止'
|
||||||
if ($res) {
|
);
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
$data['proxy_cache'] = $g;
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$data['time'] = time();//时间戳
|
||||||
shell_exec($cmd);
|
$where = sprintf("WHERE `server_name` = '%s'",$run_name);//查询条件
|
||||||
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '成功。' );
|
$res = $this -> _update('module_hyproxy',$data,$where);
|
||||||
} else {
|
|
||||||
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名' . $run_zh[$g] . '失败。' );
|
if ($res) {
|
||||||
}
|
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
||||||
}
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
// 缓存状态
|
shell_exec($cmd);
|
||||||
function hyproxy_run_cache($run_name, $g)
|
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' );
|
||||||
{
|
}else {
|
||||||
//OK
|
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' );
|
||||||
$run_zh = array(
|
}
|
||||||
'1' => '启动',
|
}
|
||||||
'0' => '停止'
|
|
||||||
);
|
// *********************************************************
|
||||||
$data['proxy_cache'] = $g;
|
// 取得缓存
|
||||||
$data['time'] = time();//时间戳
|
function get_hyproxy_cache(){
|
||||||
$where = sprintf("WHERE `server_name` = '%s'", $run_name);//查询条件
|
$name = trim($name);
|
||||||
$res = $this -> _update('module_hyproxy', $data, $where);
|
$cmd = "amh cat_nginx";
|
||||||
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
if ($res) {
|
$result = trim(shell_exec($cmd), "\n");
|
||||||
$cmd = "amh module HYProxy-1.0 admin make,$run_name";
|
$result = Functions::trim_result($result);
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
preg_match("/hyproxy_cache levels=(.*)keys_zone=hyproxy:(.*)inactive=(.*)max_size=(.*);/", $result, $arr);
|
||||||
shell_exec($cmd);
|
preg_match("/proxy_cache_valid 200 304(.*);/", $result, $arr2);
|
||||||
return array( 'status' => 'success' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '成功。' );
|
$data['levels'] = $arr[1];
|
||||||
} else {
|
$data['keys_zone'] = $arr[2];
|
||||||
return array( 'status' => 'error' , 'notice' => $run_name . ' : HYProxy域名缓存' . $run_zh[$g] . '失败。' );
|
$data['inactive'] = $arr[3];
|
||||||
}
|
$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);
|
// 保存缓存
|
||||||
$cmd = "amh cat_nginx";
|
function save_hyproxy_cache(){
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$run_name = trim($run_name);
|
||||||
$result = trim(shell_exec($cmd), "\n");
|
$cmd = "amh module HYProxy-1.0 admin cache,{$_POST['levels']},{$_POST['keys_zone']},{$_POST['max_size']},{$_POST['valid']},{$_POST['inactive']}";
|
||||||
$result = Functions::trim_result($result);
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
preg_match("/hyproxy_cache levels=(.*)keys_zone=hyproxy:(.*)inactive=(.*)max_size=(.*);/", $result, $arr);
|
exec($cmd, $tmp, $status);
|
||||||
preg_match("/proxy_cache_valid 200 304(.*);/", $result, $arr2);
|
Return !$status;
|
||||||
$data['levels'] = $arr[1];
|
}
|
||||||
$data['keys_zone'] = $arr[2];
|
|
||||||
$data['inactive'] = $arr[3];
|
|
||||||
$data['max_size'] = $arr[4];
|
// *********************************************************
|
||||||
$data['valid'] = $arr2[1];
|
// 取得缓存索引
|
||||||
foreach ($data as $key => $val) {
|
function get_hyproxy_cache_index(){
|
||||||
$data[$key] = trim($val);
|
// $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type ";
|
||||||
}
|
$sql = "SELECT * FROM module_hyproxy_cache";
|
||||||
return $data;
|
$result = $this -> _query($sql);
|
||||||
}
|
while ($rs = mysql_fetch_assoc($result))
|
||||||
|
{
|
||||||
// 保存缓存
|
$url_info = parse_url($rs['hyproxy_key']);
|
||||||
function save_hyproxy_cache()
|
if (isset($url_info['host']) && !empty($url_info['host']))
|
||||||
{
|
{
|
||||||
$run_name = trim($run_name);
|
++$data[$url_info['host']]['all']['sum'];
|
||||||
$cmd = "amh module HYProxy-1.0 admin cache,{$_POST['levels']},{$_POST['keys_zone']},{$_POST['max_size']},{$_POST['valid']},{$_POST['inactive']}";
|
$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_index()
|
// 创建缓存索引
|
||||||
{
|
function create_hyproxy_cache_index(){
|
||||||
// $sql = "SELECT count(*) FROM module_hyproxy GROUP BY hyproxy_type ";
|
$val = (int)$_POST['cache_index_time_val'];
|
||||||
$sql = "SELECT * FROM module_hyproxy_cache";
|
$type = array('1' => 60*24, '2' => 60, '3' => 1);
|
||||||
$result = $this -> _query($sql);
|
$area = array('1' => '-', '2' => '+');
|
||||||
while ($rs = mysql_fetch_assoc($result)) {
|
$val = isset($type[$_POST['cache_index_time_type']]) ? $val * $type[$_POST['cache_index_time_type']] : $val * $type[1]; // 时间类型
|
||||||
$url_info = parse_url($rs['hyproxy_key']);
|
$val = isset($area[$_POST['cache_index_time_type']]) ? $area[$_POST['cache_index_time_area']] . $val : '-' . $val; // 时间范围
|
||||||
if (isset($url_info['host']) && !empty($url_info['host'])) {
|
$mode = $_POST['cache_index_time_mode'] == '2' ? 'truncate' : '';
|
||||||
++$data[$url_info['host']]['all']['sum'];
|
|
||||||
$data[$url_info['host']]['all']['size'] += $rs['hyproxy_size'];
|
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode";
|
||||||
|
$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_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'];
|
{
|
||||||
$type = array('1' => 60*24, '2' => 60, '3' => 1);
|
$_GET['cache_key'] = trim($_GET['cache_key']);
|
||||||
$area = array('1' => '-', '2' => '+');
|
$where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'";
|
||||||
$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; // 时间范围
|
|
||||||
$mode = $_POST['cache_index_time_mode'] == '2' ? 'truncate' : '';
|
if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all')
|
||||||
|
$where .= " AND hyproxy_type LIKE '{$_GET['cache_type']}'";
|
||||||
$cmd = "amh module HYProxy-1.0 admin cache-index,$val,$mode";
|
|
||||||
$cmd = Functions::trim_cmd($cmd);
|
$limit = ' LIMIT ' . ($page-1)*$page_sum . ' , ' . $page_sum;
|
||||||
exec($cmd, $tmp, $status);
|
$sql = "SELECT * FROM module_hyproxy_cache WHERE 1 $where";
|
||||||
return !$status;
|
$sum = $this -> _sum($sql);
|
||||||
}
|
|
||||||
|
$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)
|
|
||||||
{
|
// 删除缓存
|
||||||
$where = '';
|
function hyproxy_cache_delete()
|
||||||
|
{
|
||||||
if (isset($_GET['cache_key']) && !empty($_GET['cache_key'])) {
|
$url_param = (isset($_POST['cache_key']) && !empty($_POST['cache_key'])) ? $_POST['cache_key'] : '-all';
|
||||||
$_GET['cache_key'] = trim($_GET['cache_key']);
|
$file_type = (isset($_POST['cache_type']) && !empty($_POST['cache_type']) && $_POST['cache_type'] != 'all') ? $_POST['cache_type'] : '-all';
|
||||||
$where .= " AND hyproxy_key LIKE '{$_GET['cache_key']}'";
|
$cmd = "amh module HYProxy-1.0 admin cache-delete,$url_param,$file_type";
|
||||||
}
|
$cmd = Functions::trim_cmd($cmd);
|
||||||
|
exec($cmd, $tmp, $status);
|
||||||
if (isset($_GET['cache_type']) && $_GET['cache_type'] != 'all') {
|
Return !$status;
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
||||||
nginx_configure='--prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-ipv6';
|
nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
|
||||||
new_nginx_configure=$nginx_configure;
|
new_nginx_configure=$nginx_configure;
|
||||||
if ! echo "$new_nginx_configure" | grep 'with-http_stub_status_module' > /dev/null; then
|
|
||||||
new_nginx_configure="${new_nginx_configure} --with-http_stub_status_module";
|
|
||||||
fi;
|
|
||||||
if ! echo "$new_nginx_configure" | grep 'with-stream' > /dev/null; then
|
|
||||||
new_nginx_configure="${new_nginx_configure} --with-stream";
|
|
||||||
fi;
|
|
||||||
if echo "$new_nginx_configure" | grep 'ngx_http_upstream_check_module' > /dev/null; then
|
if echo "$new_nginx_configure" | grep 'ngx_http_upstream_check_module' > /dev/null; then
|
||||||
new_nginx_configure=`echo $new_nginx_configure | sed "s| --add-module=modules/ngx_http_upstream_check_module||"`;
|
new_nginx_configure=`echo $new_nginx_configure | sed "s| --add-module=modules/ngx_http_upstream_check_module||"`;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
nginx_version='';
|
nginx_version=`/usr/local/nginx/sbin/nginx -v 2> /tmp/nginx_version && cat /tmp/nginx_version && rm -f /tmp/nginx_version`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_version=`/usr/local/nginx/sbin/nginx -v 2> /tmp/nginx_version && cat /tmp/nginx_version && rm -f /tmp/nginx_version`;
|
|
||||||
echo $nginx_version;
|
echo $nginx_version;
|
||||||
|
|
||||||
if [ "$nginx_version" != "nginx version: nginx/1.14.0" ]; then
|
if [ "$nginx_version" != "nginx version: nginx/1.14.0" ]; then
|
||||||
|
|
@ -30,7 +22,7 @@ if [ "$nginx_version" != "nginx version: nginx/1.14.0" ]; then
|
||||||
cd /usr/local/;
|
cd /usr/local/;
|
||||||
rm -rf nginx-1.14.0 nginx-1.14.0.tar.gz;
|
rm -rf nginx-1.14.0 nginx-1.14.0.tar.gz;
|
||||||
if grep -q -e "Tengine.*<br />" /home/wwwroot/index/web/View/index.php; then
|
if grep -q -e "Tengine.*<br />" /home/wwwroot/index/web/View/index.php; then
|
||||||
sed -i "s|Tengine.*<br />|Nginx 1.14.0 <br />|" /home/wwwroot/index/web/View/index.php;
|
sed -i "s|Nginx.*<br />|Nginx 1.14.0 <br />|" /home/wwwroot/index/web/View/index.php;
|
||||||
fi
|
fi
|
||||||
if grep -q -e "Nginx.*<br />" /home/wwwroot/index/web/View/index.php; then
|
if grep -q -e "Nginx.*<br />" /home/wwwroot/index/web/View/index.php; then
|
||||||
sed -i "s|Nginx.*<br />|Nginx 1.14.0 <br />|" /home/wwwroot/index/web/View/index.php;
|
sed -i "s|Nginx.*<br />|Nginx 1.14.0 <br />|" /home/wwwroot/index/web/View/index.php;
|
||||||
|
|
@ -38,4 +30,4 @@ if [ "$nginx_version" != "nginx version: nginx/1.14.0" ]; then
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
nginx -v
|
nginx -v
|
||||||
echo 'AMH Nginx Update successful'
|
echo 'AMH Nginx Update Done'
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
Cpunum=`cat /proc/cpuinfo |grep 'processor'|wc -l`;
|
||||||
nginx_configure='--prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-ipv6';
|
nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_configure=`/usr/local/nginx/sbin/nginx -V 2> /tmp/nginx_configure && cat /tmp/nginx_configure | grep 'configure arguments' | cut -d: -f2 && rm -f /tmp/nginx_configure`;
|
|
||||||
new_nginx_configure=$nginx_configure;
|
new_nginx_configure=$nginx_configure;
|
||||||
if ! echo "$new_nginx_configure" | grep 'with-http_stub_status_module' > /dev/null; then
|
if ! echo "$new_nginx_configure" | grep 'with-http_stub_status_module' > /dev/null; then
|
||||||
new_nginx_configure="${new_nginx_configure} --with-http_stub_status_module";
|
new_nginx_configure="${new_nginx_configure} --with-http_stub_status_module";
|
||||||
|
|
@ -13,8 +12,7 @@ if ! echo "$new_nginx_configure" | grep 'ngx_http_upstream_check_module' > /dev/
|
||||||
new_nginx_configure="${new_nginx_configure} --add-module=modules/ngx_http_upstream_check_module";
|
new_nginx_configure="${new_nginx_configure} --add-module=modules/ngx_http_upstream_check_module";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
nginx_version='';
|
nginx_version=`/usr/local/nginx/sbin/nginx -v 2> /tmp/nginx_version && cat /tmp/nginx_version | grep 'Tengine' && rm -f /tmp/nginx_version`;
|
||||||
[ -f /usr/local/nginx/sbin/nginx ] && nginx_version=`/usr/local/nginx/sbin/nginx -v 2> /tmp/nginx_version && cat /tmp/nginx_version && rm -f /tmp/nginx_version`;
|
|
||||||
echo $nginx_version;
|
echo $nginx_version;
|
||||||
|
|
||||||
if [ "$nginx_version" != "Tengine version: Tengine/2.3.2" ]; then
|
if [ "$nginx_version" != "Tengine version: Tengine/2.3.2" ]; then
|
||||||
|
|
@ -38,4 +36,4 @@ if [ "$nginx_version" != "Tengine version: Tengine/2.3.2" ]; then
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
nginx -v
|
nginx -v
|
||||||
echo 'AMH Tengine Update successful'
|
echo 'AMH Tengine Update Done'
|
||||||
|
|
@ -1,93 +1,91 @@
|
||||||
<?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)) {
|
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
|
||||||
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" >
|
||||||
<p>反代缓存设置:</p>
|
<table border="0" cellspacing="1" id="STable" style="width:720px;">
|
||||||
<form action="./index.php?c=hyproxy&a=hyproxy_cache" method="POST" >
|
<tr>
|
||||||
<table border="0" cellspacing="1" id="STable" style="width:720px;">
|
<th>名称</th>
|
||||||
<tr>
|
<th>值</th>
|
||||||
<th>名称</th>
|
<th>说明</th>
|
||||||
<th>值</th>
|
</tr>
|
||||||
<th>说明</th>
|
|
||||||
</tr>
|
<td>缓存数据目录</td>
|
||||||
|
<td style="padding:8px">
|
||||||
<td>缓存数据目录</td>
|
/home/hyproxy_cache
|
||||||
<td style="padding:8px">
|
</td>
|
||||||
/home/hyproxy_cache
|
<td>缓存数据保存的位置</td>
|
||||||
</td>
|
</tr>
|
||||||
<td>缓存数据保存的位置</td>
|
<tr>
|
||||||
</tr>
|
<td>数据目录层次(levels)</td>
|
||||||
<tr>
|
<td><input type="text" name="levels" class="input_text" value="<?php echo $hyproxy_cache['levels'];?>" /> <font class="red">*</font>
|
||||||
<td>数据目录层次(levels)</td>
|
</td>
|
||||||
<td><input type="text" name="levels" class="input_text" value="<?php echo $hyproxy_cache['levels'];?>" /> <font class="red">*</font>
|
<td>缓存数据目录层次<br />允许使用1或2 / 最大3层
|
||||||
</td>
|
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 1:2)</div>
|
||||||
<td>缓存数据目录层次<br />允许使用1或2 / 最大3层
|
</td>
|
||||||
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 1:2)</div>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<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>
|
||||||
<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>
|
<td>设置缓存区域内存大小
|
||||||
</td>
|
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 20m)</div>
|
||||||
<td>设置缓存区域内存大小
|
</td>
|
||||||
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 20m)</div>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<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>
|
||||||
<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>
|
<td>限制缓存磁盘空间大小
|
||||||
</td>
|
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 2g)</div>
|
||||||
<td>限制缓存磁盘空间大小
|
</td>
|
||||||
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 2g)</div>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<td>缓存文件有效时间(valid)</td>
|
||||||
<tr>
|
<td><input type="text" name="valid" class="input_text" value="<?php echo $hyproxy_cache['valid'];?>" /> <font class="red">*</font>
|
||||||
<td>缓存文件有效时间(valid)</td>
|
</td>
|
||||||
<td><input type="text" name="valid" class="input_text" value="<?php echo $hyproxy_cache['valid'];?>" /> <font class="red">*</font>
|
<td>设置缓存文件有效时间<br />
|
||||||
</td>
|
超过设定时间即重新请求
|
||||||
<td>设置缓存文件有效时间<br />
|
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 12h)</div>
|
||||||
超过设定时间即重新请求
|
</td>
|
||||||
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 12h)</div>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<td>缓存文件删除时间(inactive)</td>
|
||||||
<tr>
|
<td><input type="text" name="inactive" class="input_text" value="<?php echo $hyproxy_cache['inactive'];?>" /> <font class="red">*</font>
|
||||||
<td>缓存文件删除时间(inactive)</td>
|
</td>
|
||||||
<td><input type="text" name="inactive" class="input_text" value="<?php echo $hyproxy_cache['inactive'];?>" /> <font class="red">*</font>
|
<td>缓存文件无新访问之后删除时间<br />
|
||||||
</td>
|
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 10d)</div>
|
||||||
<td>缓存文件无新访问之后删除时间<br />
|
</td>
|
||||||
<div style="font-size:11px;color:#848484;margin:5px;">(e.g: 10d)</div>
|
</tr>
|
||||||
</td>
|
|
||||||
</tr>
|
<tr><th colspan="3" style="padding:10px;text-align:left;">
|
||||||
|
<button type="submit" class="primary button" name="save"><span class="check icon"></span>保存</button>
|
||||||
<tr><th colspan="3" style="padding:10px;text-align:left;">
|
</th></tr>
|
||||||
<button type="submit" class="primary button" name="save"><span class="check icon"></span>保存</button>
|
</table>
|
||||||
</th></tr>
|
</form>
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
<div id="notice_message" style="width:880px;">
|
||||||
|
<h3>» SSH HYProxy 缓存设置</h3>
|
||||||
<div id="notice_message" style="width:880px;">
|
cache: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache,levels,keys_zone,max_size,valid,inactive)<br />
|
||||||
<h3>» SSH HYProxy 缓存设置</h3>
|
cache 参数说明: <br />
|
||||||
cache: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache,levels,keys_zone,max_size,valid,inactive)<br />
|
<ul>
|
||||||
cache 参数说明: <br />
|
<li>levels: 缓存数据目录层次,最多可为3层。示例值: 1:2:2</li>
|
||||||
<ul>
|
<li>keys_zone: 缓存区域内存大小。示例值: 20m</li>
|
||||||
<li>levels: 缓存数据目录层次,最多可为3层。示例值: 1:2:2</li>
|
<li>max_size: 限制缓存磁盘空间大小。示例值:2g</li>
|
||||||
<li>keys_zone: 缓存区域内存大小。示例值: 20m</li>
|
<li>valid: 设置缓存文件有效时间,超过设定时间即重新请求。示例值:12h</li>
|
||||||
<li>max_size: 限制缓存磁盘空间大小。示例值:2g</li>
|
<li>inactive: 缓存文件删除时间,超过设置的时间内如无新访问请求缓存将自动删除。示例值: 10d</li>
|
||||||
<li>valid: 设置缓存文件有效时间,超过设定时间即重新请求。示例值:12h</li>
|
</ul>
|
||||||
<li>inactive: 缓存文件删除时间,超过设置的时间内如无新访问请求缓存将自动删除。示例值: 10d</li>
|
start-cache: 域名开启缓存 (ssh命令: amh module HYProxy-1.0 admin start-cache,amysql.com) 启动amysql.com反代网站缓存。<br />
|
||||||
</ul>
|
stop-cache: 域名停止缓存 (ssh命令: amh module HYProxy-1.0 admin stop-cache,amysql.com) 停止amysql.com反代网站缓存。<br />
|
||||||
start-cache: 域名开启缓存 (ssh命令: amh module HYProxy-1.0 admin start-cache,amysql.com) 启动amysql.com反代网站缓存。<br />
|
|
||||||
stop-cache: 域名停止缓存 (ssh命令: amh module HYProxy-1.0 admin stop-cache,amysql.com) 停止amysql.com反代网站缓存。<br />
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
<?php include('footer.php'); ?>
|
||||||
|
|
||||||
<?php include('footer.php'); ?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,155 +1,161 @@
|
||||||
<?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)) {
|
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
|
||||||
echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
|
?>
|
||||||
}
|
|
||||||
?>
|
<div>
|
||||||
|
<p>搜索查看缓存与删除</p>
|
||||||
<div>
|
<form action="" method="GET">
|
||||||
<p>搜索查看缓存与删除</p>
|
<input type="hidden" value="hyproxy_cache_del" name="a"/>
|
||||||
<form action="" method="GET">
|
<input type="hidden" value="hyproxy" name="c"/>
|
||||||
<input type="hidden" value="hyproxy_cache_del" name="a"/>
|
索引域名 <select name="cache_host" id="cache_host" style="width:180px;">
|
||||||
<input type="hidden" value="hyproxy" name="c"/>
|
<?php if (is_array($cache_host))
|
||||||
索引域名 <select name="cache_host" id="cache_host" style="width:180px;">
|
{
|
||||||
<?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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<option value="">所有</option>
|
<option value="">所有</option>
|
||||||
</select>
|
</select>
|
||||||
<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) {
|
{
|
||||||
if ($val != 'all') {
|
foreach ($cache_type as $key=>$val)
|
||||||
?>
|
{
|
||||||
<option value="<?php echo $val;?>"><?php echo $val;?></option>
|
if($val != 'all') {
|
||||||
<?php
|
?>
|
||||||
}
|
<option value="<?php echo $val;?>"><?php echo $val;?></option>
|
||||||
}
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
}
|
||||||
<option value="all">所有</option>
|
}
|
||||||
</select>
|
?>
|
||||||
<script>G('cache_type').value = '<?php echo isset($_GET['cache_type']) ? $_GET['cache_type'] : all;?>';</script>
|
<option value="all">所有</option>
|
||||||
<button type="submit" class="primary button" >搜索</button>
|
</select>
|
||||||
</form>
|
<script>G('cache_type').value = '<?php echo isset($_GET['cache_type']) ? $_GET['cache_type'] : all;?>';</script>
|
||||||
</div>
|
<button type="submit" class="primary button" >搜索</button>
|
||||||
|
</form>
|
||||||
<style>
|
</div>
|
||||||
#STable td {
|
|
||||||
text-align:left;
|
<style>
|
||||||
padding-left:10px;
|
#STable td {
|
||||||
}
|
text-align:left;
|
||||||
</style>
|
padding-left:10px;
|
||||||
<div id="HYProxy_list">
|
}
|
||||||
<table border="0" cellspacing="1" id="STable" style="width:1150px;">
|
</style>
|
||||||
<tr>
|
<div id="HYProxy_list">
|
||||||
<th>编号</th>
|
<table border="0" cellspacing="1" id="STable" style="width:1150px;">
|
||||||
<th>缓存文件</th>
|
<tr>
|
||||||
<th width="380">网址</th>
|
<th>编号</th>
|
||||||
<th>状态码</th>
|
<th>缓存文件</th>
|
||||||
<th>文件类型</th>
|
<th width="380">网址</th>
|
||||||
<th>大小 / MB</th>
|
<th>状态码</th>
|
||||||
<th>创建时间</th>
|
<th>文件类型</th>
|
||||||
</tr>
|
<th>大小 / MB</th>
|
||||||
<?php
|
<th>创建时间</th>
|
||||||
if (!is_array($hyproxy_cache_list['data']) || count($hyproxy_cache_list['data']) < 1) {
|
</tr>
|
||||||
?>
|
<?php
|
||||||
<tr><td colspan="7" style="padding:10px;text-align:center;">没找到缓存索引数据。</td></tr>
|
if(!is_array($hyproxy_cache_list['data']) || count($hyproxy_cache_list['data']) < 1)
|
||||||
<?php
|
{
|
||||||
} else {
|
?>
|
||||||
$k = 0;
|
<tr><td colspan="7" style="padding:10px;text-align:center;">没找到缓存索引数据。</td></tr>
|
||||||
foreach ($hyproxy_cache_list['data'] as $key => $val) {
|
<?php
|
||||||
?>
|
}
|
||||||
<tr>
|
else
|
||||||
<th class="i"><?php echo $val['hyproxy_id'];?></th>
|
{
|
||||||
<td><?php echo $val['hyproxy_file'];?></td>
|
$k = 0;
|
||||||
<td><a href="<?php echo $val['hyproxy_key'];?>" target="_blank"><?php echo $val['hyproxy_key'];?></a></td>
|
foreach ($hyproxy_cache_list['data'] as $key=>$val)
|
||||||
<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>
|
<tr>
|
||||||
<td><?php echo $val['hyproxy_time'];?></td>
|
<th class="i"><?php echo $val['hyproxy_id'];?></th>
|
||||||
</tr>
|
<td><?php echo $val['hyproxy_file'];?></td>
|
||||||
<?php
|
<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>
|
||||||
?>
|
<td><?php echo !empty($val['hyproxy_size']) ? $val['hyproxy_size'] : 0;?></td>
|
||||||
<tr>
|
<td><?php echo $val['hyproxy_time'];?></td>
|
||||||
<td colspan="7" class="object_list_last">
|
</tr>
|
||||||
<form action="" method="POST" onsubmit="return cache_delete_submit()">
|
<?php
|
||||||
删除当前搜索结果(缓存索引&缓存文件) <?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"/>
|
?>
|
||||||
<input type="hidden" value="<?php echo $_GET['cache_type'];?>" name="cache_type"/>
|
<tr>
|
||||||
<input type="hidden" value="<?php echo $_GET['cache_key'];?>" name="cache_key"/>
|
<td colspan="7" class="object_list_last">
|
||||||
</form>
|
<form action="" method="POST" onsubmit="return cache_delete_submit()">
|
||||||
</td>
|
删除当前搜索结果(缓存索引&缓存文件) <?php echo $hyproxy_cache_list['sum'];?> 项
|
||||||
</tr>
|
<button type="submit" class="primary button" id="cache_delete_button"> 确认删除</button>
|
||||||
</table>
|
<input type="hidden" name="post_delete" value="y"/>
|
||||||
<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_type'];?>" name="cache_type"/>
|
||||||
<button type="button" class="primary button" onclick="WindowLocation('/index.php?c=hyproxy&a=hyproxy_cache_del')"><span class="home icon"></span> 返回列表</button>
|
<input type="hidden" value="<?php echo $_GET['cache_key'];?>" name="cache_key"/>
|
||||||
|
</form>
|
||||||
<div id="notice_message" style="width:880px;">
|
</td>
|
||||||
<h3>» SSH HYProxy 缓存删除</h3>
|
</tr>
|
||||||
cache-delete: 缓存删除 (ssh命令: amh module HYProxy-1.0 admin cache-delete,url-param,file-type)<br />
|
</table>
|
||||||
cache-delete 参数说明: <br />
|
<div id="page_list">总<?php echo $total_page;?>页 - <?php echo $hyproxy_cache_list['sum'];?>记录 » 页码 <?php echo htmlspecialchars_decode($page_list);?> </div>
|
||||||
<ul>
|
<button type="button" class="primary button" onclick="WindowLocation('/index.php?c=hyproxy&a=hyproxy_cache_del')"><span class="home icon"></span> 返回列表</button>
|
||||||
<li>url-param: 网址匹配参数,可使用%通配符进行匹配删除。预设参数值有: -all (使用-all即匹配所有网址)</li>
|
|
||||||
<li>file-type: 缓存文件类型匹配参数,可匹配text/html、image/gif等相关文件类型进行删除。预设参数值有: -all (使用-all即匹配所有文件类型)</li>
|
<div id="notice_message" style="width:880px;">
|
||||||
</ul>
|
<h3>» SSH HYProxy 缓存删除</h3>
|
||||||
|
cache-delete: 缓存删除 (ssh命令: amh module HYProxy-1.0 admin cache-delete,url-param,file-type)<br />
|
||||||
</div>
|
cache-delete 参数说明: <br />
|
||||||
</div>
|
<ul>
|
||||||
|
<li>url-param: 网址匹配参数,可使用%通配符进行匹配删除。预设参数值有: -all (使用-all即匹配所有网址)</li>
|
||||||
</div>
|
<li>file-type: 缓存文件类型匹配参数,可匹配text/html、image/gif等相关文件类型进行删除。预设参数值有: -all (使用-all即匹配所有文件类型)</li>
|
||||||
<?php include('footer.php'); ?>
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php include('footer.php'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,162 +1,163 @@
|
||||||
<?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)) {
|
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
|
||||||
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;">
|
||||||
<p>反代缓存索引:</p>
|
<tr>
|
||||||
<table border="0" cellspacing="1" id="STable" style="width:720px;">
|
<th>索引域名</th>
|
||||||
<tr>
|
<th>总缓存数量</th>
|
||||||
<th>索引域名</th>
|
<th>总使用空间</th>
|
||||||
<th>总缓存数量</th>
|
</tr>
|
||||||
<th>总使用空间</th>
|
|
||||||
</tr>
|
<?php
|
||||||
|
$host_sum = 0;
|
||||||
<?php
|
$file_sum = 0;
|
||||||
$host_sum = 0;
|
$file_size = 0;
|
||||||
$file_sum = 0;
|
foreach ($hyproxy_cache_index as $key=>$val)
|
||||||
$file_size = 0;
|
{
|
||||||
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>
|
<td>总使用空间 <b><?php echo $val['all']['size'];?></b> MB</td>
|
||||||
<td>总使用空间 <b><?php echo $val['all']['size'];?></b> MB</td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td colspan="3" class="object_list">
|
||||||
<td colspan="3" class="object_list">
|
<table border="0" cellspacing="0" id="STable" style="width:580px;" class="Object_list">
|
||||||
<table border="0" cellspacing="0" id="STable" style="width:580px;" class="Object_list">
|
<tr>
|
||||||
<tr>
|
<th class="object_name">缓存文件类型</th>
|
||||||
<th class="object_name">缓存文件类型</th>
|
<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>
|
?>
|
||||||
<td class="object_name"><?php echo $k;?></td>
|
<tr>
|
||||||
<td style="padding:8px">缓存文件 <b><?php echo $v['sum'];?></b> 个</td>
|
<td class="object_name"><?php echo $k;?></td>
|
||||||
<td>使用空间 <b><?php echo $v['size'];?></b> MB</td>
|
<td style="padding:8px">缓存文件 <b><?php echo $v['sum'];?></b> 个</td>
|
||||||
</tr>
|
<td>使用空间 <b><?php echo $v['size'];?></b> MB</td>
|
||||||
<?php
|
</tr>
|
||||||
}
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
}
|
||||||
</table>
|
?>
|
||||||
</td>
|
</table>
|
||||||
</tr>
|
</td>
|
||||||
|
</tr>
|
||||||
<?php
|
|
||||||
}
|
<?php
|
||||||
?>
|
}
|
||||||
<tr>
|
?>
|
||||||
<td colspan="3" class="object_list_last"><font>共索引域名 <b><?php echo $host_sum;?></b> 个: </font>
|
<tr>
|
||||||
全部缓存文件 <b><?php echo $file_sum;?></b> 个 /
|
<td colspan="3" class="object_list_last"><font>共索引域名 <b><?php echo $host_sum;?></b> 个: </font>
|
||||||
全部缓存文件已用 <b><?php echo $file_size;?></b> MB</td>
|
全部缓存文件 <b><?php echo $file_sum;?></b> 个 /
|
||||||
</tr>
|
全部缓存文件已用 <b><?php echo $file_size;?></b> MB</td>
|
||||||
</table>
|
</tr>
|
||||||
|
</table>
|
||||||
<br /><br />
|
|
||||||
<form action="./index.php?c=hyproxy&a=hyproxy_cache_index" method="POST" id="cache_index_form" onsubmit="return cache_index_submit()">
|
<br /><br />
|
||||||
<p>建立缓存索引:</p>
|
<form action="./index.php?c=hyproxy&a=hyproxy_cache_index" method="POST" id="cache_index_form" onsubmit="return cache_index_submit()">
|
||||||
<table border="0" cellspacing="1" id="STable" style="width:560px;">
|
<p>建立缓存索引:</p>
|
||||||
<tr>
|
<table border="0" cellspacing="1" id="STable" style="width:560px;">
|
||||||
<th></th>
|
<tr>
|
||||||
<th>时间单位</th>
|
<th></th>
|
||||||
<th>时间范围</th>
|
<th>时间单位</th>
|
||||||
<th>使用模式</th>
|
<th>时间范围</th>
|
||||||
</tr>
|
<th>使用模式</th>
|
||||||
<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>
|
<tr>
|
||||||
<td><select name="cache_index_time_type" id="cache_index_time_type" style="width:110px;">
|
<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>
|
||||||
<option value="1">天</option>
|
<td><select name="cache_index_time_type" id="cache_index_time_type" style="width:110px;">
|
||||||
<option value="2">小时</option>
|
<option value="1">天</option>
|
||||||
<option value="3">分钟</option>
|
<option value="2">小时</option>
|
||||||
</select>
|
<option value="3">分钟</option>
|
||||||
<script>
|
</select>
|
||||||
G('cache_index_time_type').value = '<?php echo isset($_POST['cache_index_time_type']) ? $_POST['cache_index_time_type'] : 1;?>';
|
<script>
|
||||||
</script>
|
G('cache_index_time_type').value = '<?php echo isset($_POST['cache_index_time_type']) ? $_POST['cache_index_time_type'] : 1;?>';
|
||||||
</td>
|
</script>
|
||||||
<td><select name="cache_index_time_area" id="cache_index_time_area" style="width:110px;">
|
</td>
|
||||||
<option value="1">之内</option>
|
<td><select name="cache_index_time_area" id="cache_index_time_area" style="width:110px;">
|
||||||
<option value="2">之外</option>
|
<option value="1">之内</option>
|
||||||
</select>
|
<option value="2">之外</option>
|
||||||
<script>
|
</select>
|
||||||
G('cache_index_time_area').value = '<?php echo isset($_POST['cache_index_time_area']) ? $_POST['cache_index_time_area'] : 1;?>';
|
<script>
|
||||||
</script>
|
G('cache_index_time_area').value = '<?php echo isset($_POST['cache_index_time_area']) ? $_POST['cache_index_time_area'] : 1;?>';
|
||||||
</td>
|
</script>
|
||||||
<td><select name="cache_index_time_mode" id="cache_index_time_mode" style="width:110px;">
|
</td>
|
||||||
<option value="1">更新与追加</option>
|
<td><select name="cache_index_time_mode" id="cache_index_time_mode" style="width:110px;">
|
||||||
<option value="2">清空后重建</option>
|
<option value="1">更新与追加</option>
|
||||||
</select>
|
<option value="2">清空后重建</option>
|
||||||
<script>
|
</select>
|
||||||
G('cache_index_time_mode').value = '<?php echo isset($_POST['cache_index_time_mode']) ? $_POST['cache_index_time_mode'] : 1;?>';
|
<script>
|
||||||
</script>
|
G('cache_index_time_mode').value = '<?php echo isset($_POST['cache_index_time_mode']) ? $_POST['cache_index_time_mode'] : 1;?>';
|
||||||
</td>
|
</script>
|
||||||
</tr>
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
|
||||||
<input type="hidden" name="post_submit" value="y"/>
|
</table>
|
||||||
<button type="submit" class="primary button" id="cache_index_button"><span class="check icon"></span>建立索引</button>
|
<input type="hidden" name="post_submit" value="y"/>
|
||||||
</form>
|
<button type="submit" class="primary button" id="cache_index_button"><span class="check icon"></span>建立索引</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<div id="notice_message" style="width:880px;">
|
|
||||||
<h3>» SSH HYProxy 缓存索引</h3>
|
<div id="notice_message" style="width:880px;">
|
||||||
cache-index: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache-index,cmin,mode)<br />
|
<h3>» SSH HYProxy 缓存索引</h3>
|
||||||
cache-index 参数说明: <br />
|
cache-index: 设置缓存 (ssh命令: amh module HYProxy-1.0 admin cache-index,cmin,mode)<br />
|
||||||
<ul>
|
cache-index 参数说明: <br />
|
||||||
<li>cmin: 索引缓存文件使用的时间,单位为分钟。可使用:+分钟 / -分钟</li>
|
<ul>
|
||||||
<li>+分钟: 索引N分钟之前的缓存数据。</li>
|
<li>cmin: 索引缓存文件使用的时间,单位为分钟。可使用:+分钟 / -分钟</li>
|
||||||
<li>-分钟: 索引N分钟之内的缓存数据。</li>
|
<li>+分钟: 索引N分钟之前的缓存数据。</li>
|
||||||
<li>mode: 索引数据模式,可选参数。可用值:truncate (清空模式,清空旧索引数据后再建立索引)
|
<li>-分钟: 索引N分钟之内的缓存数据。</li>
|
||||||
</ul>
|
<li>mode: 索引数据模式,可选参数。可用值:truncate (清空模式,清空旧索引数据后再建立索引)
|
||||||
|
</ul>
|
||||||
</div>
|
|
||||||
|
</div>
|
||||||
</div>
|
|
||||||
|
</div>
|
||||||
<?php include('footer.php'); ?>
|
|
||||||
|
<?php include('footer.php'); ?>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -4,10 +4,8 @@
|
||||||
<div id="body">
|
<div id="body">
|
||||||
<?php include('hyproxy_category.php'); ?>
|
<?php include('hyproxy_category.php'); ?>
|
||||||
<?php
|
<?php
|
||||||
if (!empty($notice)) {
|
if (!empty($notice)) echo '<div style="margin:5px 2px;width:500px;"><p id="' . $status . '">' . $notice . '</p></div>';
|
||||||
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;">
|
||||||
|
|
@ -17,26 +15,30 @@
|
||||||
<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 {
|
}
|
||||||
foreach ($hyproxy_list as $key => $val) {
|
else
|
||||||
?>
|
{
|
||||||
|
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 />
|
||||||
|
|
@ -91,7 +93,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" >
|
||||||
|
|
@ -122,7 +124,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 />
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
#禁用反向代理缓存模板
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name {$server_name};
|
|
||||||
index {$index};
|
|
||||||
|
|
||||||
location / {
|
|
||||||
default_type text/html;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host {$header_host};
|
|
||||||
proxy_pass {$proxy_pass};
|
|
||||||
}
|
|
||||||
|
|
||||||
access_log {$access_log_path} combined; #access_log end
|
|
||||||
error_log {$error_log_path} crit; #error_log end
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#启用反向代理缓存模板
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name {$server_name};
|
|
||||||
index {$index};
|
|
||||||
|
|
||||||
location / {
|
|
||||||
default_type text/html;
|
|
||||||
proxy_cache hyproxy;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host {$header_host};
|
|
||||||
proxy_pass {$proxy_pass};
|
|
||||||
if ($http_Cache_Control = "no-cache") {
|
|
||||||
rewrite ^(.*)$ /purge$1 last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ /purge(/.*){
|
|
||||||
proxy_cache_purge hyproxy $scheme://$host$1$is_args$args;
|
|
||||||
}
|
|
||||||
|
|
||||||
access_log {$access_log_path} combined; #access_log end
|
|
||||||
error_log {$error_log_path} crit; #error_log end
|
|
||||||
}
|
|
||||||
750
hyproxy-cli.php
750
hyproxy-cli.php
|
|
@ -1,510 +1,274 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* HYPorxy CLI 文件
|
* HYPorxy CLI 文件
|
||||||
* 依赖PDO 、InnoDB
|
* 依赖PDO 、InnoDB
|
||||||
* 需要安装PDO_MYSQL-1.0.2插件
|
* 需要安装PDO_MYSQL-1.0.2插件
|
||||||
* 需要打开InnoDB支持
|
* 需要打开InnoDB支持
|
||||||
*/
|
*/
|
||||||
if (PHP_SAPI !== "cli") {
|
if (PHP_SAPI !== "cli") {
|
||||||
header('HTTP/1.1 404 Not Found');
|
header('HTTP/1.1 404 Not Found');
|
||||||
header("status: 404 Not Found");
|
header("status: 404 Not Found");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
define ('AMH_ROOT', '/home/wwwroot/index/web' . DIRECTORY_SEPARATOR); // AHM根目录
|
||||||
|
define ('AMH_Amysql', AMH_ROOT . 'Amysql' . DIRECTORY_SEPARATOR); // 系统目录
|
||||||
|
define ('_HYProxy', dirname(__FILE__) . DIRECTORY_SEPARATOR); // HYProxy插件根目录
|
||||||
|
define ('_HYCONF', '/usr/local/nginx/conf/hyproxy' . DIRECTORY_SEPARATOR); // HY Nginx conf目录
|
||||||
|
|
||||||
define('DS', DIRECTORY_SEPARATOR); // 目录分隔符
|
require_once(AMH_Amysql . 'Config.php'); //加载配置参数
|
||||||
define('AMH_ROOT', '/home/wwwroot/index/web' . DS); // AHM根目录
|
require_once(_HYProxy . 'Class/medoo.php'); //加载medoo数据库类库
|
||||||
define('AMH_AMYSQL', AMH_ROOT . 'Amysql' . DS); // 系统目录
|
|
||||||
define('_HYPROXY', dirname(__FILE__) . DS); // HYProxy插件根目录
|
|
||||||
define('_HYCONF', '/usr/local/nginx/conf/hyproxy' . DS); // HYProxy Nginx conf目录
|
|
||||||
define('_HYLOGS', '/home/hyproxy_logs' . DS); // HYProxy Nginx logs目录
|
|
||||||
define('_HYBAKS', '/home/hyproxy_backup' . DS); // HYProxy Backup目录
|
|
||||||
|
|
||||||
require_once(AMH_AMYSQL . 'Config.php'); //加载配置参数
|
$HYConfig = array(
|
||||||
require_once(_HYPROXY . 'Class/medoo.php'); //加载medoo数据库类库
|
'database_type' => 'mysql',
|
||||||
|
'database_name' => $Config['DBname'],
|
||||||
$HYConfig = array(
|
'server' => 'localhost',
|
||||||
'database_type' => 'mysql',
|
'username' => $Config['User'],
|
||||||
'database_name' => $Config['DBname'],
|
'password' => $Config['Password'],
|
||||||
'server' => 'localhost',
|
'charset' => 'utf8'
|
||||||
'username' => $Config['User'],
|
);
|
||||||
'password' => $Config['Password'],
|
$medoo = new medoo($HYConfig);
|
||||||
'charset' => 'utf8'
|
|
||||||
);
|
|
||||||
$medoo = new medoo($HYConfig);
|
|
||||||
|
|
||||||
$opt = array(
|
$opt = array(
|
||||||
'action:',
|
'action:',
|
||||||
'proxy_status::',//状态
|
'proxy_status::',//状态
|
||||||
'server_name::',//域名
|
'server_name::',//域名
|
||||||
'proxy_pass::',//后端
|
'proxy_pass::',//后端
|
||||||
'field_name::',//字段名
|
'field_name::',//字段名
|
||||||
'value::',//字段内容
|
'value::',//字段内容
|
||||||
'bak_name::',//备份名称
|
);
|
||||||
);
|
$param = getopt('', $opt);
|
||||||
$param = getopt('', $opt);
|
//print_r($param);
|
||||||
//print_r($param);
|
switch ($param['action']) {
|
||||||
switch ($param['action']) {
|
case 'list':
|
||||||
case 'list':
|
echo hyproxy_list($param['proxy_status']);
|
||||||
echo hyproxy_list($param['proxy_status']);
|
break;
|
||||||
break;
|
case 'make':
|
||||||
case 'make':
|
echo hyproxy_make($param['server_name']);
|
||||||
echo hyproxy_make($param['server_name']);
|
break;
|
||||||
break;
|
case 'add':
|
||||||
case 'add':
|
echo hyproxy_add($param['server_name'],$param['proxy_pass']);
|
||||||
echo hyproxy_add($param['server_name'], $param['proxy_pass']);
|
break;
|
||||||
break;
|
case 'edit':
|
||||||
case 'edit':
|
echo hyproxy_edit($param['server_name'],$param['field_name'],$param['value']);
|
||||||
echo hyproxy_edit($param['server_name'], $param['field_name'], $param['value']);
|
break;
|
||||||
break;
|
case 'del':
|
||||||
case 'del':
|
echo hyproxy_del($param['server_name']);
|
||||||
echo hyproxy_del($param['server_name']);
|
break;
|
||||||
break;
|
default:
|
||||||
case 'uninstall':
|
echo 'error action';
|
||||||
echo '';
|
}
|
||||||
// echo hyproxy_uninstall();
|
|
||||||
break;
|
|
||||||
case 'backup':
|
|
||||||
echo hyproxy_backup();
|
|
||||||
break;
|
|
||||||
case 'restore':
|
|
||||||
echo hyproxy_restore($param['bak_name']);
|
|
||||||
break;
|
|
||||||
case 'amproxy_bak' :
|
|
||||||
echo hyproxy_amproxy_bak();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
echo 'error action';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function hyproxy_list($proxy_status){//done 列出站点列表ID,域名,状态
|
||||||
* 列出站点列表ID,域名,状态
|
global $medoo;
|
||||||
* @param $proxy_status
|
empty($proxy_status) && $proxy_status = 'start';
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_list($proxy_status)
|
|
||||||
{
|
|
||||||
global $medoo;
|
|
||||||
empty($proxy_status) && $proxy_status = 'start';
|
|
||||||
|
|
||||||
$table = 'module_hyproxy';
|
$table = 'module_hyproxy';
|
||||||
$columns = array('hyproxy_id','server_name','status');
|
$columns = array('hyproxy_id','server_name','status');
|
||||||
$where = array('status'=>$proxy_status);
|
$where = array('status'=>$proxy_status);
|
||||||
$list = $medoo->select($table, $columns, $where);
|
$data = $medoo->select($table,$columns,$where);
|
||||||
$res = '';
|
$res = '';
|
||||||
foreach ($list as $row) {
|
foreach ($data as &$value) {
|
||||||
$res.=sprintf("%d,%s,%s\n", $row['hyproxy_id'], $row['server_name'], $row['status']);
|
$res.=sprintf("%d,%s,%s\n",$value['hyproxy_id'],$value['server_name'],$value['status']);
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hyproxy_make($server_name){//done
|
||||||
|
global $medoo;
|
||||||
|
$table = 'module_hyproxy';
|
||||||
|
$columns = '*';
|
||||||
|
$where = '';
|
||||||
|
if (!empty($server_name)) {//指定域名
|
||||||
|
$where = array('server_name'=>trim($server_name));
|
||||||
|
}
|
||||||
|
$data = $medoo->select($table,$columns,$where);
|
||||||
|
$res = '';
|
||||||
|
if (empty($data)) {
|
||||||
|
$res = "[ERROR] The server_name does not exist.\n";
|
||||||
|
} else {
|
||||||
|
if (empty($server_name)) {
|
||||||
|
hy_deldir(_HYCONF);//删除所有
|
||||||
}
|
}
|
||||||
|
foreach ($data as &$value) {
|
||||||
|
if (!empty($value['proxy_cache'])) {
|
||||||
|
$nginx = sprintf('server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name %s;
|
||||||
|
index %s;
|
||||||
|
|
||||||
/**
|
location / {
|
||||||
* 生成nginx配置文件
|
default_type text/html;
|
||||||
* @param $server_name
|
proxy_cache hyproxy;
|
||||||
* @return string
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
*/
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
function hyproxy_make($server_name = null)
|
proxy_set_header Host %s;
|
||||||
{
|
proxy_pass %s;
|
||||||
global $medoo;
|
if ($http_Cache_Control = "no-cache") {
|
||||||
$table = 'module_hyproxy';
|
rewrite ^(.*)$ /purge$1 last;
|
||||||
$columns = '*';
|
|
||||||
$where = '';
|
|
||||||
if (!empty($server_name)) {//指定域名
|
|
||||||
$where = array('server_name'=>trim($server_name));
|
|
||||||
}
|
|
||||||
$list = $medoo->select($table, $columns, $where);
|
|
||||||
$res = '';
|
|
||||||
if (empty($list)) {
|
|
||||||
$res = "[ERROR] The server_name does not exist.\n";
|
|
||||||
} else {
|
|
||||||
if (empty($server_name)) {
|
|
||||||
hy_deldir(_HYCONF);//删除所有
|
|
||||||
}
|
|
||||||
foreach ($list as $row) {
|
|
||||||
//定义日志完整路径
|
|
||||||
$row['access_log_path'] = _HYLOGS . $row['server_name'] . '.access.log';
|
|
||||||
$row['error_log_path'] = _HYLOGS . $row['server_name'] . '.error.log';
|
|
||||||
//构建conf内容
|
|
||||||
$conf = hy_build_nginx_conf($row);
|
|
||||||
|
|
||||||
//文件操作
|
|
||||||
$filebytes = false;
|
|
||||||
if ($row['status']!='start') {
|
|
||||||
$filebytes = unlink(_HYCONF.$row['server_name'].'.conf');//删除
|
|
||||||
} elseif (!empty($conf)) {
|
|
||||||
if (!is_dir(_HYCONF)) {
|
|
||||||
mkdir(_HYCONF, 0755);
|
|
||||||
}
|
|
||||||
if (!is_dir(_HYLOGS)) {
|
|
||||||
mkdir(_HYLOGS, 0755);
|
|
||||||
}
|
|
||||||
$filebytes = file_put_contents(_HYCONF.$row['server_name'].'.conf', $conf); //写入内容
|
|
||||||
//access_log_path不存在的话创建
|
|
||||||
if (!file_exists($row['access_log_path'])) {
|
|
||||||
file_put_contents($row['access_log_path'], '');
|
|
||||||
}
|
|
||||||
//error_log_path不存在的话创建
|
|
||||||
if (!file_exists($row['error_log_path'])) {
|
|
||||||
file_put_contents($row['error_log_path'], '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /purge(/.*){
|
||||||
|
proxy_cache_purge hyproxy $scheme://$host$1$is_args$args;
|
||||||
|
}
|
||||||
|
}',$value['server_name'],$value['index'],$value['header_host'],$value['proxy_pass']);
|
||||||
|
} else {
|
||||||
|
$nginx = sprintf('server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name %s;
|
||||||
|
index %s;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
default_type text/html;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host %s;
|
||||||
|
proxy_pass %s;
|
||||||
|
}
|
||||||
|
}',$value['server_name'],$value['index'],$value['header_host'],$value['proxy_pass']);
|
||||||
|
}
|
||||||
|
if ($value['status']=='start') {
|
||||||
|
$filebytes = file_put_contents(_HYCONF.$value['server_name'].'.conf', $nginx); //写入内容
|
||||||
|
} else {
|
||||||
|
$filebytes = unlink(_HYCONF.$value['server_name'].'.conf');//删除
|
||||||
|
}
|
||||||
|
|
||||||
if ($filebytes) {
|
if($filebytes){
|
||||||
$res.=sprintf("[OK] %s conf make is done.\n", $row['server_name']);
|
$res.=sprintf("[OK] %s conf make is done.\n",$value['server_name']);
|
||||||
} else {
|
}else{
|
||||||
$res.=sprintf("[ERROR] %s conf make is error.\n", $row['server_name']);
|
$res.=sprintf("[ERROR] %s conf make is error.\n",$value['server_name']);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
function hyproxy_add($server_name,$proxy_pass=''){//done
|
||||||
* 新建反向代理
|
if (empty($server_name)) {
|
||||||
* @param $server_name
|
return "[ERROR] The server_name is empty.\n";//不能为空
|
||||||
* @param string $proxy_pass
|
}
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_add($server_name, $proxy_pass = '')
|
|
||||||
{
|
|
||||||
if (empty($server_name)) {
|
|
||||||
return "[ERROR] The server_name is empty.\n";//不能为空
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
global $medoo;
|
global $medoo;
|
||||||
$table = 'module_hyproxy';
|
$table = 'module_hyproxy';
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
$where = array('server_name'=>trim($server_name));
|
$where = array('server_name'=>trim($server_name));
|
||||||
$proxy = $medoo->get($table, $columns, $where);
|
$proxy = $medoo->get($table, $columns, $where);
|
||||||
|
|
||||||
if ($proxy) {
|
if ($proxy) {
|
||||||
return "[ERROR] The server_name is exist.\n";//已存在
|
return "[ERROR] The server_name is exist.\n";//已存在
|
||||||
|
} else {
|
||||||
|
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
||||||
|
if(!preg_match('/^http(s)?:\\/\\/.+/',$proxy_pass)){
|
||||||
|
$proxy_pass = 'http://'.$proxy_pass;
|
||||||
|
}
|
||||||
|
$data = array(
|
||||||
|
'server_name' => $server_name,
|
||||||
|
'`index`' => 'index.php index.html index.htm',//index是保留字段
|
||||||
|
'header_host' => '$host',
|
||||||
|
'proxy_pass' => $proxy_pass,
|
||||||
|
'proxy_cache' => 1,
|
||||||
|
'status' => 'start',
|
||||||
|
'time' => time()
|
||||||
|
);
|
||||||
|
$mysqlres = $medoo->insert($table, $data);
|
||||||
|
if ($mysqlres) {
|
||||||
|
$res = "[OK] Proxy add success.\n";
|
||||||
|
$res.= hyproxy_make($server_name);
|
||||||
|
}else {
|
||||||
|
$res = "[ERROR] Proxy add error.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hyproxy_edit($server_name,$field_name='',$value=''){//done
|
||||||
|
if (empty($server_name)) {
|
||||||
|
return "[ERROR] The server_name is empty.\n";//不能为空
|
||||||
|
}
|
||||||
|
if (empty($field_name)) {
|
||||||
|
return "[ERROR] The field_name is empty.\n";//不能为空
|
||||||
|
}
|
||||||
|
$value = trim($value);
|
||||||
|
$res = '';
|
||||||
|
global $medoo;
|
||||||
|
$table = 'module_hyproxy';
|
||||||
|
$columns = '*';
|
||||||
|
$where = array('server_name'=>trim($server_name));
|
||||||
|
$proxy = $medoo->get($table, $columns, $where);
|
||||||
|
|
||||||
|
if (empty($proxy)) {
|
||||||
|
return "[ERROR] The server_name is not exist.\n";//不存在
|
||||||
|
} else {
|
||||||
|
if ($field_name=='proxy_pass') {
|
||||||
|
empty($value) && $value = 'http://'.$server_name;
|
||||||
|
if(!preg_match('/^http(s)?:\\/\\/.+/',$value)){
|
||||||
|
$value = 'http://'.$value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($field_name=='header_host') {
|
||||||
|
empty($value) && $value = '$host';
|
||||||
|
}
|
||||||
|
$data = array(
|
||||||
|
$field_name => $value,
|
||||||
|
'time' => time()
|
||||||
|
);
|
||||||
|
$mysqlres = $medoo->update($table, $data,array('hyproxy_id'=>$proxy['hyproxy_id']));
|
||||||
|
if ($mysqlres) {
|
||||||
|
$res = "[OK] Proxy edit success.\n";
|
||||||
|
$res.= hyproxy_make($server_name);
|
||||||
|
}else {
|
||||||
|
$res = "[ERROR] Proxy edit error.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hyproxy_del($server_name){
|
||||||
|
if (empty($server_name)) {
|
||||||
|
return "[ERROR] The server_name is empty.\n";//不能为空
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = '';
|
||||||
|
global $medoo;
|
||||||
|
$table = 'module_hyproxy';
|
||||||
|
$columns = '*';
|
||||||
|
$where = array('server_name'=>trim($server_name));
|
||||||
|
$proxy = $medoo->get($table, $columns, $where);
|
||||||
|
if (empty($proxy)) {
|
||||||
|
return "[ERROR] The server_name is not exist.\n";//不存在
|
||||||
|
} else {
|
||||||
|
$mysqlres = $medoo->delete($table, $where);
|
||||||
|
if ($mysqlres) {
|
||||||
|
$res = "[OK] Proxy del success.\n";
|
||||||
|
}else {
|
||||||
|
$res = "[ERROR] Proxy del error.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hy_deldir($path) {
|
||||||
|
//如果是目录则继续
|
||||||
|
if (is_dir($path)) {
|
||||||
|
//扫描一个文件夹内的所有文件夹和文件并返回数组
|
||||||
|
$p = scandir($path);
|
||||||
|
foreach ($p as $val) {
|
||||||
|
//排除目录中的.和..
|
||||||
|
if ($val != "." && $val != "..") {
|
||||||
|
//如果是目录则递归子目录,继续操作
|
||||||
|
if (is_dir($path . $val)) {
|
||||||
|
//子目录中操作删除文件夹和文件
|
||||||
|
deldir($path . $val . '/');
|
||||||
|
//目录清空后删除空文件夹
|
||||||
|
@rmdir($path . $val . '/');
|
||||||
} else {
|
} else {
|
||||||
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
//如果是文件直接删除
|
||||||
if (!preg_match('/^http(s)?:\\/\\/.+/', $proxy_pass)) {
|
unlink($path . $val);
|
||||||
$proxy_pass = 'http://'.$proxy_pass;
|
|
||||||
}
|
|
||||||
$data = array(
|
|
||||||
'server_name' => $server_name,
|
|
||||||
'`index`' => 'index.php index.html index.htm',//index是保留字段
|
|
||||||
'header_host' => '$host',
|
|
||||||
'proxy_pass' => $proxy_pass,
|
|
||||||
'proxy_cache' => 1,
|
|
||||||
'status' => 'start',
|
|
||||||
'time' => time()
|
|
||||||
);
|
|
||||||
$mysqlres = $medoo->insert($table, $data);
|
|
||||||
if ($mysqlres) {
|
|
||||||
$res = "[OK] Proxy add success.\n";
|
|
||||||
$res.= hyproxy_make($server_name);
|
|
||||||
} else {
|
|
||||||
$res = "[ERROR] Proxy add error.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改反向代理参数
|
|
||||||
* @param $server_name
|
|
||||||
* @param string $field_name
|
|
||||||
* @param string $value
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_edit($server_name, $field_name = '', $value = '')
|
|
||||||
{
|
|
||||||
if (empty($server_name)) {
|
|
||||||
return "[ERROR] The server_name is empty.\n";//不能为空
|
|
||||||
}
|
|
||||||
if (empty($field_name)) {
|
|
||||||
return "[ERROR] The field_name is empty.\n";//不能为空
|
|
||||||
}
|
|
||||||
$value = trim($value);
|
|
||||||
$res = '';
|
|
||||||
global $medoo;
|
|
||||||
$table = 'module_hyproxy';
|
|
||||||
$columns = '*';
|
|
||||||
$where = array('server_name'=>trim($server_name));
|
|
||||||
$proxy = $medoo->get($table, $columns, $where);
|
|
||||||
|
|
||||||
if (empty($proxy)) {
|
|
||||||
return "[ERROR] The server_name is not exist.\n";//不存在
|
|
||||||
} else {
|
|
||||||
if ($field_name=='proxy_pass') {
|
|
||||||
empty($value) && $value = 'http://'.$server_name;
|
|
||||||
if (!preg_match('/^http(s)?:\\/\\/.+/', $value)) {
|
|
||||||
$value = 'http://'.$value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($field_name=='header_host') {
|
|
||||||
empty($value) && $value = '$host';
|
|
||||||
}
|
|
||||||
$data = array(
|
|
||||||
$field_name => $value,
|
|
||||||
'time' => time()
|
|
||||||
);
|
|
||||||
$mysqlres = $medoo->update($table, $data, array('hyproxy_id'=>$proxy['hyproxy_id']));
|
|
||||||
if ($mysqlres) {
|
|
||||||
$res = "[OK] Proxy edit success.\n";
|
|
||||||
$res.= hyproxy_make($server_name);
|
|
||||||
} else {
|
|
||||||
$res = "[ERROR] Proxy edit error.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除反向代理
|
|
||||||
* @param $server_name
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_del($server_name = null)
|
|
||||||
{
|
|
||||||
$res = '';
|
|
||||||
if (empty($server_name)) {
|
|
||||||
$res = "[ERROR] The server_name is empty.\n";//不能为空
|
|
||||||
} else {
|
|
||||||
global $medoo;
|
|
||||||
$table = 'module_hyproxy';
|
|
||||||
$columns = '*';
|
|
||||||
$where = array('server_name'=>trim($server_name));
|
|
||||||
$row = $medoo->get($table, $columns, $where);
|
|
||||||
if (empty($row)) {
|
|
||||||
$res = "[ERROR] The server_name is not exist.\n";//不存在
|
|
||||||
} else {
|
|
||||||
$mysqlres = $medoo->delete($table, $where);
|
|
||||||
if ($mysqlres) {
|
|
||||||
$res = "[OK] Proxy del success.\n";
|
|
||||||
} else {
|
|
||||||
$res = "[ERROR] Proxy del error.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unlink(_HYCONF . $server_name . '.conf');//删除配置文件
|
|
||||||
unlink(_HYLOGS . $server_name . '.access.log');//删除日志文件
|
|
||||||
unlink(_HYLOGS . $server_name . '.error.log');//删除日志文件
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已作废
|
|
||||||
* 卸载插件时做的一些处理
|
|
||||||
* 谨慎使用
|
|
||||||
*/
|
|
||||||
function hyproxy_uninstall()
|
|
||||||
{
|
|
||||||
//先备份
|
|
||||||
hyproxy_backup();
|
|
||||||
//循环删除所有站点
|
|
||||||
global $medoo;
|
|
||||||
$table = 'module_hyproxy';
|
|
||||||
$columns = array('hyproxy_id','server_name','status');
|
|
||||||
$list = $medoo->select($table, $columns);
|
|
||||||
if (!empty($list)) {
|
|
||||||
$medoo->delete($table, null);
|
|
||||||
foreach ($list as $row) {
|
|
||||||
unlink(_HYCONF . $row['server_name'] . '.conf');//删除配置文件
|
|
||||||
unlink(_HYLOGS . $row['server_name'] . '.access.log');//删除日志文件
|
|
||||||
unlink(_HYLOGS . $row['server_name'] . '.error.log');//删除日志文件
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "[OK] All proxy del success.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备份所有反向代理
|
|
||||||
*/
|
|
||||||
function hyproxy_backup()
|
|
||||||
{
|
|
||||||
if (!is_dir(_HYBAKS)) {
|
|
||||||
mkdir(_HYBAKS, 0755);
|
|
||||||
}
|
|
||||||
global $medoo;
|
|
||||||
$table = 'module_hyproxy';
|
|
||||||
$list = $medoo->select($table, '*');
|
|
||||||
$filebytes = false;
|
|
||||||
$filename = _HYBAKS . date("Y-m-d-H:i:s") . '.bak';
|
|
||||||
$filebytes = file_put_contents($filename, json_encode($list));//写入内容
|
|
||||||
if ($filebytes) {
|
|
||||||
$res="[OK] All proxy backup success.\n";
|
|
||||||
} else {
|
|
||||||
$res="[ERROR] All proxy backup error.\n";
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 还原所有反向代理
|
|
||||||
* @param null $bak_name
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_restore($bak_name = null)
|
|
||||||
{
|
|
||||||
$backup_path = _HYBAKS. DS . $bak_name;
|
|
||||||
if (file_exists($backup_path)) {
|
|
||||||
$backup = file_get_contents($backup_path);
|
|
||||||
$list = json_decode($backup, true);
|
|
||||||
//修复mysql保留字段index问题导致无法写入
|
|
||||||
foreach ($list as &$row) {
|
|
||||||
$row['`index`'] = $row['index'];
|
|
||||||
unset($row['index']);
|
|
||||||
}
|
|
||||||
global $medoo;
|
|
||||||
$table = 'module_hyproxy';
|
|
||||||
$medoo->delete($table, null);
|
|
||||||
$medoo->query("alter table $table auto_increment=1");
|
|
||||||
$medoo->insert($table, $list);
|
|
||||||
hyproxy_make();
|
|
||||||
return "[OK] Proxy restore success\n";
|
|
||||||
} else {
|
|
||||||
return "[ERROR] Backup file not exist!\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备份AMProxy的反向代理
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hyproxy_amproxy_bak()
|
|
||||||
{
|
|
||||||
$dir = '/usr/local/nginx/conf/proxy/';
|
|
||||||
if (is_dir($dir)) {
|
|
||||||
$list = scandir($dir);
|
|
||||||
foreach ($list as $row) {
|
|
||||||
unset($conf, $data);
|
|
||||||
//排除目录中的.和..
|
|
||||||
if ($row != "." && $row != ".." && is_file($dir.$row)) {
|
|
||||||
$conf = file_get_contents($dir.$row);
|
|
||||||
|
|
||||||
$data = array(
|
|
||||||
'server_name' => trim(hy_get_body($conf, 'server_name', ';', 1)),
|
|
||||||
'index' => 'index.php index.html index.htm',//index是保留字段
|
|
||||||
'header_host' => '$host',
|
|
||||||
'proxy_pass' => trim(hy_get_body($conf, 'proxy_pass', ';', 1)),
|
|
||||||
'proxy_cache' => 1,
|
|
||||||
'status' => 'start',
|
|
||||||
'time' => time()
|
|
||||||
);
|
|
||||||
if (trim(hy_get_body($conf, 'proxy_set_header Host ', ';', 1)) != $data['server_name']) {
|
|
||||||
$data['header_host'] = trim(hy_get_body($conf, 'proxy_set_header Host ', ';', 1));
|
|
||||||
}
|
|
||||||
$proxy[] = $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($proxy)) {
|
|
||||||
if (!is_dir(_HYBAKS)) {
|
|
||||||
mkdir(_HYBAKS, 0755);
|
|
||||||
}
|
|
||||||
$filebytes = false;
|
|
||||||
$filename = _HYBAKS . 'AMProxy' .date("Y-m-d-H:i:s") . '.bak';
|
|
||||||
$filebytes = file_put_contents($filename, json_encode($proxy));//写入内容
|
|
||||||
if ($filebytes) {
|
|
||||||
$res="[OK] AMProxy proxy backup success.\n";
|
|
||||||
} else {
|
|
||||||
$res="[ERROR] AMProxy proxy backup error.\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$res = '[ERROR] No AMProxy.';
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除目录和子目录
|
|
||||||
* @param $path
|
|
||||||
*/
|
|
||||||
function hy_deldir($path)
|
|
||||||
{
|
|
||||||
//如果是目录则继续
|
|
||||||
if (is_dir($path)) {
|
|
||||||
//扫描一个文件夹内的所有文件夹和文件并返回数组
|
|
||||||
$p = scandir($path);
|
|
||||||
foreach ($p as $val) {
|
|
||||||
//排除目录中的.和..
|
|
||||||
if ($val != "." && $val != "..") {
|
|
||||||
//如果是目录则递归子目录,继续操作
|
|
||||||
if (is_dir($path . $val)) {
|
|
||||||
//子目录中操作删除文件夹和文件
|
|
||||||
deldir($path . $val . '/');
|
|
||||||
//目录清空后删除空文件夹
|
|
||||||
@rmdir($path . $val . '/');
|
|
||||||
} else {
|
|
||||||
//如果是文件直接删除
|
|
||||||
unlink($path . $val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据传入数据构建nginx配置内容
|
|
||||||
* @param $row
|
|
||||||
*/
|
|
||||||
function hy_build_nginx_conf($row)
|
|
||||||
{
|
|
||||||
//开启反向代理缓存模板
|
|
||||||
$proxy_cache_template_path = _HYPROXY . 'conf' . DS . 'proxy_cache_template.conf';
|
|
||||||
$proxy_cache_template = '';
|
|
||||||
if (file_exists($proxy_cache_template_path)) {
|
|
||||||
$proxy_cache_template = file_get_contents($proxy_cache_template_path);
|
|
||||||
}
|
|
||||||
//禁用反向代理缓存模板
|
|
||||||
$no_cache_template_path = _HYPROXY . 'conf' . DS . 'no_cache_template.conf';
|
|
||||||
$no_cache_template = '';
|
|
||||||
if (file_exists($no_cache_template_path)) {
|
|
||||||
$no_cache_template = file_get_contents($no_cache_template_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$conf = false;
|
|
||||||
if (!empty($row['server_name'])) {
|
|
||||||
//判断使用哪个模板
|
|
||||||
$template = false;
|
|
||||||
if (!empty($row['proxy_cache']) && !empty($proxy_cache_template)) {
|
|
||||||
$template = $proxy_cache_template;
|
|
||||||
} elseif (!empty($no_cache_template)) {
|
|
||||||
$template = $no_cache_template;
|
|
||||||
}
|
|
||||||
|
|
||||||
//模板有效的话,进行遍历数组替换模板变量
|
|
||||||
if ($template) {
|
|
||||||
foreach ($row as $k => $v) {
|
|
||||||
$template=str_replace('{$'.$k.'}', $v, $template);
|
|
||||||
}
|
|
||||||
$conf = $template;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输入始末关键词提取主要内容
|
|
||||||
* @param $str string 提取前内容
|
|
||||||
* @param $start string 开始关键词
|
|
||||||
* @param $end string 结束关键词
|
|
||||||
* @param $option int 选项 1:不包含前后关键词 2:包含前关键词 3:包含后关键词 其他(默认):包含前后关键词
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function hy_get_body($str, $start, $end, $option)
|
|
||||||
{
|
|
||||||
$str_array=explode($start, $str);
|
|
||||||
$tem=$str_array[1];
|
|
||||||
if (empty($end)) {
|
|
||||||
return $tem;
|
|
||||||
} else {
|
|
||||||
$str_array=explode($end, $tem);
|
|
||||||
if ($option==1) {
|
|
||||||
return $str_array[0];
|
|
||||||
}
|
|
||||||
if ($option==2) {
|
|
||||||
return $start.$str_array[0];
|
|
||||||
}
|
|
||||||
if ($option==3) {
|
|
||||||
return $str_array[0].$end;
|
|
||||||
} else {
|
|
||||||
return $start.$str_array[0].$end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue