Beispiel #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;
 }
Beispiel #2
0
function isLoggedIn()
{
    return Account_AccountAPI::getLoggedIn() !== false;
}
Beispiel #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;
 }