private function process_post()
 {
     // 接收参数
     $action = $this->request->get_parameter('action') ? $this->request->get_parameter('action') : 'createPage';
     $dir = $this->request->get_parameter('dir') ? trim($this->request->get_parameter('dir'), '/') : '';
     $headerType = $this->request->get_parameter('headerType') ? $this->request->get_parameter('headerType') : 'normal';
     $fileName = $this->request->get_parameter('fileName') ? $this->request->get_parameter('fileName') : 'new';
     // 首字母大写
     $fileName = ucfirst(trim($fileName, '/'));
     $title = $this->request->get_parameter('title') ? $this->request->get_parameter('title') : '安居客';
     $desc = $this->request->get_parameter('desc') ? $this->request->get_parameter('desc') : '';
     $scriptUrl = $this->request->get_parameter('scriptUrl') ? $this->request->get_parameter('scriptUrl') : '';
     if (!in_array($action, $this->actionConfig)) {
         return Util_GlobalFunc::buildReturn(0, 'invalid param: action');
     }
     switch ($action) {
         case 'createPage':
             $result = Bll_Tools_AutoCreate::createPage($dir, $fileName, $title, $desc, $headerType, $scriptUrl);
             break;
         default:
             $result = Bll_Tools_AutoCreate::createPage($dir, $fileName, $title, $desc, $headerType, $scriptUrl);
             break;
     }
     return $result;
 }
Exemple #2
0
 public function handle_request()
 {
     $this->response->set_content_type('text/html', 'utf-8');
     if (Bll_Tools_AutoCreate::allowIp()) {
         $this->out = $this->getUpDownRuntimeInfo();
     } else {
         $this->out['status'] = 0;
         $this->out['msg'] = array('你所在Ip不在允许操作权限内');
     }
     $this->setAttribute('out', $this->out);
     return 'Tools_Updown';
 }
Exemple #3
0
 public function handle_request()
 {
     $this->response->set_content_type('text/html', 'utf-8');
     if (Bll_Tools_AutoCreate::allowIp()) {
         // 分发对应工具controller
         if ($action = trim($this->getRouterMatches(1), '/')) {
             $controller = 'Tools_' . $action . 'Controller';
             if (class_exists($controller)) {
                 $obj = new $controller();
                 return $obj->handle_request();
             }
         }
     } else {
         $this->out['result']['status'] = 0;
         $this->out['result']['msg'] = array('你所在Ip不在允许操作权限内');
     }
     $this->out['result']['msg'] = $this->getTools();
     $this->setAttribute('out', $this->out);
     return 'Tools_Tools';
 }
 /**
  * @param $dir
  * @param $fileName
  * @param $title
  * @param string $desc
  * @param $headerType
  * @return array
  */
 public static function createPage($dir, $fileName, $title, $desc = '描述', $headerType, $uri)
 {
     $result = array();
     if (trim($uri)) {
         $createRoute = Bll_Tools_AutoCreate::createRoute($uri, $dir, $fileName, $title, $desc);
         if ($createRoute['status'] == 0) {
             return $createRoute;
         }
         $result[] = '生成route文件成功';
     }
     $controllerOut = self::getControllerOut($dir, $fileName, $desc);
     $pagePhpOut = self::getPagePhpOut($dir, $fileName, $title, $desc, $headerType);
     $controllerFileName = self::getLocalFilePath($dir, $fileName);
     if (file_exists($controllerFileName)) {
         $result[] = 'controller文件已经存在';
     } else {
         if (self::createFile($controllerFileName, $controllerOut)) {
             $result[] = '生成controller文件成功';
         } else {
             return Util_GlobalFunc::buildReturn(0, '生成controller文件失败');
         }
     }
     $pagePhpFileName = self::getLocalFilePath($dir, $fileName, 'page');
     if (file_exists($pagePhpFileName)) {
         $result[] = 'page的php文件已经存在';
     } else {
         if (self::createFile($pagePhpFileName, $pagePhpOut)) {
             $result[] = '生成page的php文件成功';
         } else {
             return Util_GlobalFunc::buildReturn(0, '生成page的php文件失败');
         }
     }
     $pagePhtmlFileName = self::getLocalFilePath($dir, $fileName, 'page', 'phtml');
     if (file_exists($pagePhtmlFileName)) {
         $result[] = 'page的phtml文件已经存在';
     } else {
         if (self::createFile($pagePhtmlFileName, '')) {
             $result[] = '生成page的phtml文件成功';
         } else {
             return Util_GlobalFunc::buildReturn(0, '生成page的phtml文件失败');
         }
     }
     $pageJsFileName = self::getLocalFilePath($dir, $fileName, 'page', 'js');
     if (file_exists($pageJsFileName)) {
         $result[] = 'page的js文件已经存在';
     } else {
         if (self::createFile($pageJsFileName, '')) {
             $result[] = '生成js的js文件成功';
         } else {
             return Util_GlobalFunc::buildReturn(0, '生成page的js文件失败');
         }
     }
     $pageCssFileName = self::getLocalFilePath($dir, $fileName, 'page', 'css');
     if (file_exists($pageCssFileName)) {
         $result[] = 'page的css文件已经存在';
     } else {
         if (self::createFile($pageCssFileName, '')) {
             $result[] = '生成page的css文件成功';
         } else {
             return Util_GlobalFunc::buildReturn(0, '生成page的css文件失败');
         }
     }
     return Util_GlobalFunc::buildReturn(1, $result);
 }