Ejemplo n.º 1
0
 public function canView()
 {
     $loggedIn = Account_AccountAPI::getLoggedIn();
     if ($loggedIn === false) {
         /* if we're not logged in and the page isn't assecible to anyone */
         if ($this->privelage !== 'NONE') {
             Lunor::$base->router->throwError('needlogin');
             return false;
         }
     } else {
         /* if we are logged in and the page is only accessible to admins */
         if ($this->privelage === 'ADMIN' && !Account_AccountAPI::isAdmin()) {
             Lunor::$base->router->throwError('adminarea');
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
function isLoggedIn()
{
    return Account_AccountAPI::getLoggedIn() !== false;
}
Ejemplo n.º 3
0
 public static function forId($id)
 {
     $paste = new PasteHandler_Paste();
     $paste->forId(PASTE_TABLE_PREFIX . 'paste', $id);
     if ($paste->id === false) {
         return false;
     }
     /* check privelages to see it */
     if ($paste->exposure === 'private') {
         if (Account_AccountAPI::getLoggedIn() === false || $paste->findAuthor() !== Account_AccountAPI::getUsername()) {
             /* it is private to ourself and we are looking at it */
             Lunor::$base->router->throwError('private');
             return true;
         }
     }
     /* check view/data limit */
     $res = Lunor::$base->dbi->select(PASTE_TABLE_PREFIX . 'expiration_views')->where(array('paste_id' => $paste->id))->go();
     /* too many people have viewed it, delete paste! */
     if ($res !== false && !empty($res) && $paste->views >= $res[0]['view_limit']) {
         self::delete($return, $paste->id);
         Lunor::$base->router->throwError(404);
         return true;
     }
     return $paste;
 }
Ejemplo n.º 4
0
<?php

/* add in custom route */
Routing::custom('a', function ($extra) {
    if (isset($_POST['type']) && !empty($_POST['type'])) {
        $type = $_POST['type'];
        $return = array('sucess' => 'false');
        if ($type == 'register') {
            Account_AccountAPI::register($return);
        } else {
            if ($type == 'login') {
                Account_AccountAPI::login($return);
            } else {
                if ($type == 'logout') {
                    Account_AccountAPI::logout($return);
                } else {
                    if ($type == 'changepass') {
                        Account_AccountAPI::changePass($return);
                    } else {
                        $return['error'] = 'Invalid AccountAPI type! : ' . $type;
                    }
                }
            }
        }
        echo json_encode($return);
        return true;
    }
    return false;
});