pull/109/head
Mr Chen 6 years ago
parent 9809a6e880
commit e1400d72df
  1. 16
      class/core/task_api.py
  2. 21
      plugins/php/index.py
  3. 140
      plugins/php/js/php.js
  4. 95
      plugins/php/versions/56/yaf.sh

@ -10,6 +10,9 @@ import json
import pwd import pwd
from flask import request
class task_api: class task_api:
def __init__(self): def __init__(self):
@ -20,8 +23,16 @@ class task_api:
return str(c) return str(c)
def listApi(self): def listApi(self):
_list = public.M('tasks').where('', ()).field('id,name,type,status,addtime,start,end').limit(
'0,5').order('id desc').select() p = request.form.get('p', '1').encode('utf-8')
limit = request.form.get('limit', '10').strip()
search = request.form.get('search', '').strip()
start = (int(p) - 1) * int(limit)
limit_str = str(start) + ',' + str(limit)
_list = public.M('tasks').where('', ()).field(
'id,name,type,status,addtime,start,end').limit(limit_str).order('id desc').select()
_ret = {} _ret = {}
_ret['data'] = _list _ret['data'] = _list
@ -29,6 +40,7 @@ class task_api:
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'remind' _page['tojs'] = 'remind'
_page['p'] = p
_ret['page'] = public.getPage(_page) _ret['page'] = public.getPage(_page)
return public.getJson(_ret) return public.getJson(_ret)

@ -538,25 +538,36 @@ def getLibConf(version):
def installLib(version): def installLib(version):
args = getArgs() args = getArgs()
data = checkArgs(args, ['type', 'name']) data = checkArgs(args, ['name'])
if not data[0]: if not data[0]:
return data[1] return data[1]
name = args['name'] name = args['name']
stype = args['type']
execstr = "cd " + getPluginDir() + '/versions/' + version + " && /bin/bash " + \ execstr = "cd " + getPluginDir() + '/versions/' + version + " && /bin/bash " + \
name + '.sh' + " " + stype + " " + version name + '.sh' + ' install ' + version
rettime = time.strftime('%Y-%m-%d %H:%M:%S') rettime = time.strftime('%Y-%m-%d %H:%M:%S')
insert_info = (None, '安装[' + name + '-' + version + ']', insert_info = (None, '安装[' + name + '-' + version + ']',
'execshell', '0', rettime, execstr) 'execshell', '0', rettime, execstr)
public.M('tasks').add('id,name,type,status,addtime,execstr', insert_info) public.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
# print execstr
return public.returnJson(True, '已将下载任务添加到队列!') return public.returnJson(True, '已将下载任务添加到队列!')
def uninstallLib(version): def uninstallLib(version):
return 'ok' args = getArgs()
data = checkArgs(args, ['name'])
if not data[0]:
return data[1]
name = args['name']
execstr = "cd " + getPluginDir() + '/versions/' + version + " && /bin/bash " + \
name + '.sh' + ' uninstall ' + version
rettime = time.strftime('%Y-%m-%d %H:%M:%S')
insert_info = (None, '安装[' + name + '-' + version + ']',
'execshell', '0', rettime, execstr)
public.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
return public.returnJson(True, '已将卸载载任务添加到队列!')
if __name__ == "__main__": if __name__ == "__main__":

@ -469,93 +469,80 @@ function phpLibConfig(version){
//PHP扩展配置 //PHP扩展配置
function setPHPConfig(version, pathinfo, go) { // function setPHPConfig(version, pathinfo, go) {
$.get('/ajax?action=GetPHPConfig&version=' + version, function(rdata) { // $.get('/ajax?action=GetPHPConfig&version=' + version, function(rdata) {
var body = "" // var body = ""
var opt = "" // var opt = ""
for (var i = 0; i < rdata.libs.length; i++) { // for (var i = 0; i < rdata.libs.length; i++) {
if (rdata.libs[i].versions.indexOf(version) == -1) continue; // if (rdata.libs[i].versions.indexOf(version) == -1) continue;
if (rdata.libs[i]['task'] == '-1' && rdata.libs[i].phpversions.indexOf(version) != -1) { // if (rdata.libs[i]['task'] == '-1' && rdata.libs[i].phpversions.indexOf(version) != -1) {
opt = '<a style="color:green;" href="javascript:messageBox();">' + lan.soft.the_install + '</a>' // opt = '<a style="color:green;" href="javascript:messageBox();">' + lan.soft.the_install + '</a>'
} else if (rdata.libs[i]['task'] == '0' && rdata.libs[i].phpversions.indexOf(version) != -1) { // } else if (rdata.libs[i]['task'] == '0' && rdata.libs[i].phpversions.indexOf(version) != -1) {
opt = '<a style="color:#C0C0C0;" href="javascript:messageBox();">' + lan.soft.sleep_install + '</a>' // opt = '<a style="color:#C0C0C0;" href="javascript:messageBox();">' + lan.soft.sleep_install + '</a>'
} else if (rdata.libs[i].status) { // } else if (rdata.libs[i].status) {
opt = '<a style="color:red;" href="javascript:UninstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.uninstall + '</a>' // opt = '<a style="color:red;" href="javascript:UninstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.uninstall + '</a>'
} else { // } else {
opt = '<a class="btlink" href="javascript:InstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.install + '</a>' // opt = '<a class="btlink" href="javascript:InstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.install + '</a>'
} // }
body += '<tr>' + // body += '<tr>' +
'<td>' + rdata.libs[i].name + '</td>' + // '<td>' + rdata.libs[i].name + '</td>' +
'<td>' + rdata.libs[i].type + '</td>' + // '<td>' + rdata.libs[i].type + '</td>' +
'<td>' + rdata.libs[i].msg + '</td>' + // '<td>' + rdata.libs[i].msg + '</td>' +
'<td><span class="ico-' + (rdata.libs[i].status ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.libs[i].status ? 'ok' : 'remove') + '"></span></td>' + // '<td><span class="ico-' + (rdata.libs[i].status ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.libs[i].status ? 'ok' : 'remove') + '"></span></td>' +
'<td style="text-align: right;">' + opt + '</td>' + // '<td style="text-align: right;">' + opt + '</td>' +
'</tr>' // '</tr>'
} // }
var pathinfoOpt = '<a style="color:red;" href="javascript:SetPathInfo(\'' + version + '\',\'off\');">' + lan.soft.off + '</a>' // var pathinfoOpt = '<a style="color:red;" href="javascript:SetPathInfo(\'' + version + '\',\'off\');">' + lan.soft.off + '</a>'
if (!rdata.pathinfo) { // if (!rdata.pathinfo) {
pathinfoOpt = '<a class="btlink" href="javascript:SetPathInfo(\'' + version + '\',\'on\');">' + lan.soft.on + '</a>' // pathinfoOpt = '<a class="btlink" href="javascript:SetPathInfo(\'' + version + '\',\'on\');">' + lan.soft.on + '</a>'
} // }
var pathinfo1 = '<tr id="pathInfo"><td>PATH_INFO</td><td>' + lan.soft.php_menu_ext + '</td><td>' + lan.soft.mvc_ps + '</td><td><span class="ico-' + (rdata.pathinfo ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.pathinfo ? 'ok' : 'remove') + '"></span></td><td style="text-align: right;" width="50">' + pathinfoOpt + '</td></tr>'; // var pathinfo1 = '<tr id="pathInfo"><td>PATH_INFO</td><td>' + lan.soft.php_menu_ext + '</td><td>' + lan.soft.mvc_ps + '</td><td><span class="ico-' + (rdata.pathinfo ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.pathinfo ? 'ok' : 'remove') + '"></span></td><td style="text-align: right;" width="50">' + pathinfoOpt + '</td></tr>';
var con = '<div class="divtable" id="phpextdiv" style="margin-right:10px;height: 420px; overflow: auto; margin-right: 0px;">' + // var con = '<div class="divtable" id="phpextdiv" style="margin-right:10px;height: 420px; overflow: auto; margin-right: 0px;">' +
'<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">' + // '<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">' +
'<thead>' + // '<thead>' +
'<tr>' + // '<tr>' +
'<th>' + lan.soft.php_ext_name + '</th>' + // '<th>' + lan.soft.php_ext_name + '</th>' +
'<th width="64">' + lan.soft.php_ext_type + '</th>' + // '<th width="64">' + lan.soft.php_ext_type + '</th>' +
'<th>' + lan.soft.php_ext_ps + '</th>' + // '<th>' + lan.soft.php_ext_ps + '</th>' +
'<th width="40">' + lan.soft.php_ext_status + '</th>' + // '<th width="40">' + lan.soft.php_ext_status + '</th>' +
'<th style="text-align: right;" width="50">' + lan.public.action + '</th>' + // '<th style="text-align: right;" width="50">' + lan.public.action + '</th>' +
'</tr>' + // '</tr>' +
'</thead>' + // '</thead>' +
'<tbody>' + pathinfo1 + body + '</tbody>' + // '<tbody>' + pathinfo1 + body + '</tbody>' +
'</table>' + // '</table>' +
'</div>' + // '</div>' +
'<ul class="help-info-text c7 pull-left"><li>请按实际需求安装扩展,不要安装不必要的PHP扩展,这会影响PHP执行效率,甚至出现异常</li><li>Redis扩展只允许在1个PHP版本中使用,安装到其它PHP版本请在[软件管理]重装Redis</li><li>opcache/xcache/apc等脚本缓存扩展,请只安装其中1个,否则可能导致您的站点程序异常</li></ul>'; // '<ul class="help-info-text c7 pull-left"><li>请按实际需求安装扩展,不要安装不必要的PHP扩展,这会影响PHP执行效率,甚至出现异常</li><li>Redis扩展只允许在1个PHP版本中使用,安装到其它PHP版本请在[软件管理]重装Redis</li><li>opcache/xcache/apc等脚本缓存扩展,请只安装其中1个,否则可能导致您的站点程序异常</li></ul>';
var divObj = document.getElementById('phpextdiv'); // var divObj = document.getElementById('phpextdiv');
var scrollTopNum = 0; // var scrollTopNum = 0;
if (divObj) scrollTopNum = divObj.scrollTop; // if (divObj) scrollTopNum = divObj.scrollTop;
$(".soft-man-con").html(con); // $(".soft-man-con").html(con);
document.getElementById('phpextdiv').scrollTop = scrollTopNum; // document.getElementById('phpextdiv').scrollTop = scrollTopNum;
}); // });
if (go == undefined) { // if (go == undefined) {
setTimeout(function() { // setTimeout(function() {
if ($(".bgw #phpext").html() != '安装扩展') { // if ($(".bgw #phpext").html() != '安装扩展') {
return; // return;
} // }
SetPHPConfig(version, pathinfo); // SetPHPConfig(version, pathinfo);
}, 3000); // }, 3000);
} // }
} // }
//安装扩展 //安装扩展
function installPHPLib(version, name, title, pathinfo) { function installPHPLib(version, name, title, pathinfo) {
layer.confirm('您真的要安装{1}吗?'.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() { layer.confirm('您真的要安装{1}吗?'.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() {
name = name.toLowerCase(); name = name.toLowerCase();
var data = "name=" + name + "&version=" + version + "&type=1"; var data = "name=" + name + "&version=" + version + "&type=1";
// var loadT = layer.msg('正在添加到安装器...', { icon: 16, time: 0, shade: [0.3, '#000'] });
// $.post('/files?action=InstallSoft', data, function(rdata) {
// setTimeout(function() {
// layer.close(loadT);
// SetPHPConfig(version, pathinfo, true);
// setTimeout(function() {
// layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
// }, 1000);
// }, 1000);
// });
phpPost('install_lib', version, data, function(data){ phpPost('install_lib', version, data, function(data){
var rdata = $.parseJSON(data.data); var rdata = $.parseJSON(data.data);
console.log(rdata); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
// fly("bi-btn");
// installTips();
getTaskCount(); getTaskCount();
}); });
});
} }
//卸载扩展 //卸载扩展
@ -563,11 +550,10 @@ function uninstallPHPLib(version, name, title, pathinfo) {
layer.confirm('您真的要安装{1}吗?'.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() { layer.confirm('您真的要安装{1}吗?'.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() {
name = name.toLowerCase(); name = name.toLowerCase();
var data = 'name=' + name + '&version=' + version; var data = 'name=' + name + '&version=' + version;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); phpPost('uninstall_lib', version, data, function(data){
$.post('/files?action=UninstallSoft', data, function(rdata) { var rdata = $.parseJSON(data.data);
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
SetPHPConfig(version, pathinfo, true); getTaskCount();
}); });
}); });
} }

@ -2,58 +2,42 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
echo $serverPath,$sourcePath
Install_yaf() Install_yaf()
{ {
case "${version}" in extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20131226/yaf.so
'54')
extFile='/www/server/php/54/lib/php/extensions/no-debug-non-zts-20100525/yaf.so' isInstall=`cat $serverPath/php/$version/etc/php.ini|grep 'yaf.so'`
;;
'55')
extFile='/www/server/php/55/lib/php/extensions/no-debug-non-zts-20121212/yaf.so'
;;
'56')
extFile='/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/yaf.so'
;;
'70')
extFile='/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/yaf.so'
;;
'71')
extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so'
;;
'71')
extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so'
;;
'72')
extFile='/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/yaf.so'
;;
esac
isInstall=`cat /www/server/php/$version/etc/php.ini|grep 'yaf.so'`
if [ "${isInstall}" != "" ];then if [ "${isInstall}" != "" ];then
echo "php-$vphp 已安装yaf,请选择其它版本!" echo "php-$version 已安装yaf,请选择其它版本!"
return return
fi fi
if [ ! -f "$extFile" ];then if [ ! -f "$extFile" ];then
public_file=/www/server/panel/install/public.sh
if [ ! -f $public_file ];then
wget -O $public_file http://download.bt.cn/install/public.sh -T 5;
fi
. $public_file
download_Url=$NODE_URL
wafV='2.3.5'; wafV='2.3.5';
if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then
wafV='3.0.7'; wafV='3.0.7';
fi fi
wget -O yaf-$wafV.tgz $download_Url/src/yaf-$wafV.tgz
php_lib=$sourcePath/php_${version}_lib
mkdir -p $php_lib
wget -O $php_lib/yaf-$wafV.tgz http://pecl.php.net/get/yaf-$wafV.tgz
cd $php_lib
tar xvf yaf-$wafV.tgz tar xvf yaf-$wafV.tgz
cd yaf-$wafV cd yaf-$wafV
/www/server/php/$version/bin/phpize echo "$serverPath/php/$version/bin/phpize"
./configure --with-php-config=/www/server/php/$version/bin/php-config $serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
make && make install make && make install
cd .. cd ..
rm -rf yaf-* rm -rf yaf-*
@ -64,9 +48,10 @@ Install_yaf()
echo "ERROR!" echo "ERROR!"
return; return;
fi fi
echo "extension=$extFile" >> /www/server/php/$version/etc/php.ini echo "extension=$extFile"
echo "extension=$extFile" >> $serverPath/php/$version/etc/php.ini
service php-fpm-$version reload $serverPath/php/init.d/php$version reload
echo '===========================================================' echo '==========================================================='
echo 'successful!' echo 'successful!'
} }
@ -74,39 +59,22 @@ Install_yaf()
Uninstall_yaf() Uninstall_yaf()
{ {
if [ ! -f "/www/server/php/$version/bin/php-config" ];then if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php-$vphp 未安装,请选择其它版本!" echo "php$version 未安装,请选择其它版本!"
return return
fi fi
case "${version}" in extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20131226/yaf.so
'54')
extFile='/www/server/php/54/lib/php/extensions/no-debug-non-zts-20100525/yaf.so'
;;
'55')
extFile='/www/server/php/55/lib/php/extensions/no-debug-non-zts-20121212/yaf.so'
;;
'56')
extFile='/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/yaf.so'
;;
'70')
extFile='/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/yaf.so'
;;
'71')
extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so'
;;
'72')
extFile='/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/yaf.so'
esac
if [ ! -f "$extFile" ];then if [ ! -f "$extFile" ];then
echo "php-$vphp 未安装yaf,请选择其它版本!" echo "php$version 未安装yaf,请选择其它版本!"
return return
fi fi
sed -i '/yaf.so/d' /www/server/php/$version/etc/php.ini echo $serverPath/php/$version/etc/php.ini
sed -i '_bak' '/yaf.so/d' $serverPath/php/$version/etc/php.ini
rm -f $extFile rm -f $extFile
/etc/init.d/php-fpm-$version reload $serverPath/php/init.d/php$version reload
echo '===============================================' echo '==============================================='
echo 'successful!' echo 'successful!'
} }
@ -114,7 +82,6 @@ Uninstall_yaf()
actionType=$1 actionType=$1
version=$2 version=$2
vphp=${version:0:1}.${version:1:1}
if [ "$actionType" == 'install' ];then if [ "$actionType" == 'install' ];then
Install_yaf Install_yaf
elif [ "$actionType" == 'uninstall' ];then elif [ "$actionType" == 'uninstall' ];then

Loading…
Cancel
Save