Exemplo n.º 1
0
 public static function cache_get($directory, $file, $later_than = "-5 minutes")
 {
     $file = TBA::cache_clean_filename($file);
     if (!file_exists("{$directory}/{$file}.json")) {
         return FALSE;
     }
     $file_contents = json_decode(file_get_contents("{$directory}/{$file}.json"), 1);
     if (!count($file_contents)) {
         return FALSE;
     }
     if (!is_integer($later_than) && strlen($later_than)) {
         $later_than = strtotime($later_than);
     }
     if ($later_than > $file_contents["timestamp"]) {
         return FALSE;
     }
     return $file_contents["contents"];
 }