12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * Created by benzhan on 15/8/13.
- */
- var util = require('util');
- var Controller = require('./../framework/Controller.js');
- util.inherits(SystemController, Controller);
- /**
- * @type {MenuController}
- */
- var that;
- var process = require('child_process');
- var php = require('phpjs');
- function SystemController() {
- Controller.apply(this, arguments);
- that = this;
- }
- $white_ip_array = ['183.60.177.224/27','58.248.138.0/28', '113.108.232.32/28', '172.16.53.148/8'];
- function check_ip(ip_array){
- var remote_ip = getClientIp();
- return checkIpRange(remote_ip, $white_ip_array);
- }
- /**
- * 安装依赖的组件
- */
- SystemController.prototype.actionNpmInstall = function() {
- //不在ip白名单内,显示404页面
- if( !check_ip($white_ip_array) ){
- _res.statusCode = 302;
- _res.header('Location', '/public/403.html');
- Response.exitMsg('...');
- } else {
- process.exec('npm install &', function(err, stdout, stderr) {
- if (err) {
- Response.exitMsg('出错啦...【' + err + '】')
- } else {
- Response.exitMsg('执行完毕:' + stdout);
- }
- });
- }
- }
- /**
- * 重启服务
- */
- SystemController.prototype.actionRestart = function() {
- //不在ip白名单内,显示404页面
- if( !check_ip($white_ip_array) ){
- _res.statusCode = 302;
- _res.header('Location', '/public/403.html');
- Response.exitMsg('...');
- } else {
- process.exec('/bin/bash ./admin/restart.sh &');
- Response.exitMsg('restart');
- }
- }
- module.exports = SystemController;
|