public static function get($cat = null, $id = null, $returnasjson = false) { if (!$cat) { return $returnasjson ? \SYSTEM\LOG\JsonResult::toString(self::$folders) : self::$folders; } if (!array_key_exists($cat, self::$folders)) { throw new \SYSTEM\LOG\ERROR("No matching Cat '" . $cat . "' found."); } $folder = self::getFolder(self::$folders[$cat]); if ($id == null) { return $returnasjson ? \SYSTEM\LOG\JsonResult::toString($folder) : $folder; } if (!in_array($id, $folder)) { throw new \SYSTEM\LOG\ERROR("No matching ID '" . $id . "' found."); } $ext = pathinfo(self::$folders[$cat] . $id); $ext = strtoupper(array_key_exists('extension', $ext) ? $ext['extension'] : ''); if (\SYSTEM\HEADER::available($ext)) { call_user_func('\\SYSTEM\\HEADER::' . $ext); } else { \SYSTEM\HEADER::FILE($id); } //Allow Caching for all files header('Cache-Control: public;'); if (!self::file_get_contents_chunked(self::$folders[$cat] . $id, 4096, function ($chunk, &$handle, $iteration) { echo $chunk; })) { throw new \SYSTEM\LOG\ERROR("Could not transfere File."); } return; }
public static function toString($json_array, $status = self::JSONRESULT_OK, $start_time = NULL) { if ($start_time == NULL) { $start_time = \SYSTEM\time::getStartTime(); } $json = array(); $json['querytime'] = round(microtime(true) - $start_time, 5); $json['status'] = $status; $json['result'] = $json_array; if (\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_RESULT) == \SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_RESULT_MSGPACK) { //send Header \SYSTEM\HEADER::JSON(); if ($json = msgpack_pack($json)) { return $json; } throw new \SYSTEM\LOG\ERROR('MSGPack could not be encoded'); } else { //send Header \SYSTEM\HEADER::JSON(); if ($json = json_encode($json)) { return $json; } throw new \SYSTEM\LOG\ERROR('JSON could not be encoded'); } }
public static function get($cache, $ident, $header = false) { $result = \SYSTEM\SQL\SYS_CACHE_CHECK::Q1(array($cache, $ident)); if (!$result) { return NULL; } if ($header) { if (\SYSTEM\HEADER::available($result['type'])) { call_user_func('\\SYSTEM\\HEADER::' . $result['type']); } else { \SYSTEM\HEADER::FILE($ident); } } return $result['cache'] == \SYSTEM\CACHE\cache_filemask::CACHE_FILEMASK ? \file_get_contents($result['data']) : $result['data']; }