コード例 #1
0
ファイル: Admin.php プロジェクト: hisune/tinymvc-demo
 public static function modModPostBefore(&$post)
 {
     if (isset($post['password']) && $post['password']) {
         if (strlen($post['password']) < 6) {
             tiny\Error::echoJson(-3, 'password must have 6 character at least');
         }
         $post['password'] = tiny\Auth::getPassword($post['password'], false);
     } else {
         if (isset($post['id'])) {
             $adminModel = new \Demo\Model\Admin();
             $admin = $adminModel->findOne($post['id']);
             $post['password'] = $admin->password;
         }
     }
 }
コード例 #2
0
ファイル: ThemeBuilder.php プロジェクト: hisune/tinymvc-demo
 public function run()
 {
     $post = Request::post();
     $post['table'] = Helper::parseName($post['table'], 1);
     $controller = \Demo\Helper\ThemeBuilder::generateController($post);
     $helper = \Demo\Helper\ThemeBuilder::generateHelper($post);
     $model = \Demo\Helper\ThemeBuilder::generateModel($post);
     $controllerFile = __DIR__ . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php';
     $helperFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Helper' . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php';
     $modelFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php';
     if (file_exists($controllerFile)) {
         Error::echoJson(-1, 'controller file ' . $controllerFile . ' exits already!');
     }
     if (file_exists($helperFile)) {
         Error::echoJson(-1, 'helper file ' . $helperFile . ' exits already!');
     }
     if (file_exists($modelFile)) {
         Error::echoJson(-1, 'model file ' . $modelFile . ' exits already!');
     }
     file_put_contents($controllerFile, $controller);
     file_put_contents($helperFile, $helper);
     file_put_contents($modelFile, $model);
     Error::echoJson(-1, 'Success!');
 }