示例#1
0
文件: api.php 项目: Verisor/tt-rss
 function before($method)
 {
     if (parent::before($method)) {
         header("Content-Type: text/json");
         if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") {
             $this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN'));
             return false;
         }
         if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) {
             $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
             return false;
         }
         $this->seq = (int) $_REQUEST['seq'];
         return true;
     }
     return false;
 }
示例#2
0
 function before($method)
 {
     return parent::before($method) && $_SESSION['uid'];
 }
 function before($method)
 {
     // Check for all client in Android except ReadKit in Mac, Mr. Reader and Dalvik
     if (strpos($_SERVER['HTTP_USER_AGENT'], "Dalvik") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "ReadKit") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "Mr. Reader") !== false) {
         $this->ID_HACK_FOR_MRREADER = 0;
     } else {
         $this->ID_HACK_FOR_MRREADER = 1;
         // and readkit and dalvik...
     }
     if (parent::before($method)) {
         if (self::DEBUG) {
             // add request to debug log
             file_put_contents(self::DEBUG_FILE, 'parameter: ' . json_encode($_REQUEST) . "\n", FILE_APPEND);
         }
         // set the user from the db
         $this->setUser();
         // are we xml or json?
         $this->setXml();
         if ($this->xml) {
             header("Content-Type: text/xml");
         } else {
             header("Content-Type: application/json");
         }
         // check we have a valid user
         if (!$_SESSION["uid"]) {
             $this->wrap(self::STATUS_ERR, NULL);
             return false;
         }
         // check if user has api access enabled
         if ($_SESSION["uid"] && !get_pref('ENABLE_API_ACCESS')) {
             $this->wrap(self::STATUS_ERR, NULL);
             return false;
         }
         return true;
     }
     return false;
 }