Example #1
0
 public static function parseURL()
 {
     if (isset($_GET['deprecationDate'])) {
         self::$deprecationDate = $_GET['deprecationDate'];
         self::$root = "/api-" . self::$deprecationDate;
         unset($_GET['deprecationDate']);
     } else {
         self::$root = "/api";
     }
     $_url = trim($_GET['_url'], " \\/\\\t\n\r\v");
     if (!$_url) {
         PhlatMedia::write(self::getLinks());
     }
     list(self::$resource, self::$id, self::$subresource) = explode("/", $_url);
     unset($_GET['_url']);
     if (self::$subresource == 'collection' and self::$id) {
         Error::http(404, "A generic 'collection' subresource for " . self::$resource . " #" . self::$id . " does not exist.");
     }
     if (!self::$subresource and !is_numeric(self::$id)) {
         self::$subresource = self::$id;
     }
 }
Example #2
0
 static function http($numCode, $errorMssg = "", $output = array())
 {
     if (self::$format == 'sms') {
         self::sms($errorMssg);
     } else {
         if (function_exists("http_response_code")) {
             http_response_code($numCode);
         } else {
             header("HTTP/1.1 {$numCode}");
         }
         if (self::$log) {
             file_put_contents(self::$log, $errorMssg, FILE_APPEND);
         }
         exit(PhlatMedia::write($output, $errorMssg));
     }
 }