/** * @desc Checks if the database exists. */ public static function checkDatabaseExists() { try { if (empty(self::$databaseTextPlain) == true) { throw new Exception("ldItemDatabase::\$databaseTextPlain is null."); } if (empty(self::$databaseSerialized) == true) { throw new Exception("ldItemDatabase::\$databaseSerialized is null."); } if (file_exists(self::$path . self::$databaseSerialized) == false) { return false; } else { $dbHandle = fopen(self::$path . self::$databaseSerialized, "r"); $dbContent = fread($dbHandle, filesize(self::$path . self::$databaseSerialized)); fclose($dbHandle); self::$dbItem = unserialize($dbContent); if (self::$dbItem["fileHash"] != @md5_file(self::$path . self::$databaseTextPlain)) { return false; } else { return true; } } } catch (Exception $msg) { exit($msg->getMessage()); } }