status) || !is_numeric($data->status) || $data->status !== 0) { return false; } if (!isset($data->version) || !is_string($data->version)) { return false; } if (!isset($data->lifetime) || !is_numeric($data->lifetime)) { return false; } if (!isset($data->timestamp) || !is_numeric($data->timestamp)) { return false; } if (!isset($data->name) || !is_string($data->name)) { return false; } if (!isset($data->levelcap) || !is_numeric($data->levelcap)) { return false; } if (!isset($data->ip) || !is_string($data->ip)) { return false; } if (!isset($data->website) || !is_string($data->website)) { return false; } if (!isset($data->discord) || !is_string($data->discord)) { return false; } if (!isset($data->total) || !is_numeric($data->total)) { return false; } if (!isset($data->unique) || !is_numeric($data->unique)) { return false; } return true; } /** * Obtains the cached data from the given file. * * @param {string} $file - The file path to the cache data to obtain. * @return {bool|string} False if invalid or not found, string of the cached data if found and valid. */ function getCachedData($file) { // Ensure the cache file exists.. if (!file_exists($file)) { return false; } try { // Open the cache file for reading.. $f = fopen($file, "r"); if ($f === FALSE) { return false; } // Read the cached file contents.. $cache = fread($f, filesize($file)); fclose($f); // Parse the file data as json.. $data = json_decode($cache); if (json_last_error() !== JSON_ERROR_NONE) { return false; } // Validate the cache file.. if (!isValidCachedFile($data)) { return false; } // Cache is valid, return it.. return $cache; } catch (Exception $e) { return false; } }