示例#1
0
 public static function valid($token)
 {
     if (!CSRF::valid($token)) {
         $css_files = array();
         $view = "access_denied";
         \CODOF\Smarty\Layout::load($view, $css_files);
         return false;
     }
     return true;
 }
示例#2
0
 public static function tpl($tpl)
 {
     \CODOF\Smarty\Layout::load('file:' . PLUGIN_DIR . $tpl);
 }
示例#3
0
    //exit;
});
//-------------PAGES--------------------------
dispatch_get('/page/:id/:url', function ($id, $url) {
    $pid = (int) $id;
    $user = \CODOF\User\User::get();
    $qry = 'SELECT title, content FROM ' . PREFIX . 'codo_pages p ' . ' LEFT JOIN ' . PREFIX . 'codo_page_roles r ON r.pid=p.id ' . ' WHERE (r.rid IS NULL OR  (r.rid IS NOT NULL AND r.rid IN (' . implode($user->rids) . ')))' . ' AND p.id=' . $pid;
    $res = \DB::getPDO()->query($qry);
    $row = $res->fetch();
    if ($row) {
        $title = $row['title'];
        $content = $row['content'];
        $smarty = CODOF\Smarty\Single::get_instance();
        $smarty->assign('contents', $content);
        \CODOF\Store::set('sub_title', $title);
        \CODOF\Smarty\Layout::load('page');
        \CODOF\Hook::call('on_page_load', array($id));
    } else {
        $page = \DB::table(PREFIX . 'codo_pages')->where('id', $id)->first();
        if ($page == null) {
            \CODOF\Smarty\Layout::not_found();
        } else {
            \CODOF\Smarty\Layout::access_denied();
        }
    }
});
//-------------USER-------------------------------------------------------------
dispatch_get('/user/logout', function () {
    $user = new \Controller\user();
    $user->logout();
    CODOF\Smarty\Layout::load($user->view, $user->css_files, $user->js_files);