Example #1
0
    public static function back()
    {
        echo <<<EOF
        <script type="text/javascript">
            window.history.go(-1);
        </script>
EOF;
        Boot::shutdown();
    }
Example #2
0
File: csrf.php Project: uwitec/mgoa
 public static function deny($base_app)
 {
     header('HTTP/1.1 403 Forbidden');
     $smarty = $base_app->load('smarty');
     $smarty->assign('page_title', 'Error - HTTP 403 Forbidden');
     $smarty->assign('message_title', 'Your request has been expired');
     $smarty->assign('message', 'Please do not report a duplicate data or refresh the page.');
     $smarty->display('403');
     Boot::shutdown();
 }
Example #3
0
    public function alert($msg, $to = null)
    {
        header('content:text/html; charset=utf-8');
        if (!$to) {
            $to = 'window.history.go(-1);';
        } else {
            $to = 'window.location.href="' . $to . '"';
        }
        $msg = addslashes($msg);
        echo <<<EOF
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
            <script type="text/javascript">
                alert('{$msg}');
                {$to}
            </script>
            </head>
            <body></body>
            </html>
EOF;
        Boot::shutdown();
    }
Example #4
0
 public static function required($base_app, $role_id_or_name, $only_check = false)
 {
     $has_permission = false;
     $base_app->load('model', 'system/contrib/auth.User', false);
     $userinfo = User::info();
     /*
      * Multi check
      */
     if (is_array($role_id_or_name)) {
         foreach ($role_id_or_name as $value) {
             if (abs(intval($value)) > 0) {
                 $field = 'id';
             } else {
                 $field = 'alias';
             }
             $has_permission = self::__required($userinfo['role'], $value, $field);
             if ($has_permission) {
                 return true;
             }
         }
     }
     /*
      * check by id or name
      */
     if (abs(intval($role_id_or_name)) > 0) {
         $field = 'id';
     } else {
         $field = 'alias';
     }
     $has_permission = self::__required($userinfo['role'], $role_id_or_name, $field);
     if ($has_permission) {
         return true;
     }
     if ($only_check) {
         return false;
     } else {
         $base_app->smarty->display(403);
         Boot::shutdown();
     }
 }
Example #5
0
 public function delete($id)
 {
     parent::load('model', 'articles');
     parent::load('model', 'system/contrib/auth.User');
     $article = ArticleTable::getInstance()->find($id);
     /*
      * 判断是否有权限修改此类文章
      */
     $has_role = Category::has_role($article->Category->id, User::info());
     if (!$has_role || !User::has_role('人力资源') || !User::has_role('总经理')) {
         $this->smarty->display(403);
         Boot::shutdown();
     }
     if ($article) {
         $article->delete();
         $message = '删除成功';
     } else {
         $message = '文章不存在';
     }
     import('system/share/network/redirect');
     HTTPRedirect::flash_to('', $message, $this->smarty);
 }