diff options
-rwxr-xr-x | classes/api.php | 14 | ||||
-rw-r--r-- | classes/config.php | 4 | ||||
-rw-r--r-- | include/functions.php | 19 |
3 files changed, 25 insertions, 12 deletions
diff --git a/classes/api.php b/classes/api.php index 262d5c5bc..09f190451 100755 --- a/classes/api.php +++ b/classes/api.php @@ -1,7 +1,7 @@ <?php class API extends Handler { - const API_LEVEL = 18; + const API_LEVEL = 19; const STATUS_OK = 0; const STATUS_ERR = 1; @@ -12,6 +12,7 @@ class API extends Handler { const E_INCORRECT_USAGE = "INCORRECT_USAGE"; const E_UNKNOWN_METHOD = "UNKNOWN_METHOD"; const E_OPERATION_FAILED = "E_OPERATION_FAILED"; + const E_NOT_FOUND = "E_NOT_FOUND"; /** @var int|null */ private $seq; @@ -912,6 +913,17 @@ class API extends Handler { array("categories" => $pf->_makefeedtree())); } + function getFeedIcon(): bool { + $id = (int)$_REQUEST['id']; + $cache = DiskCache::instance('feed-icons'); + + if ($cache->exists((string)$id)) { + return $cache->send((string)$id) > 0; + } else { + return $this->_wrap(self::STATUS_ERR, array("error" => self::E_NOT_FOUND)); + } + } + // only works for labels or uncategorized for the time being private function _is_cat_empty(int $id): bool { if ($id == -2) { diff --git a/classes/config.php b/classes/config.php index 9a8b466ab..a865266ca 100644 --- a/classes/config.php +++ b/classes/config.php @@ -541,6 +541,10 @@ class Config { array_push($errors, "PHP support for JSON is required, but was not found."); } + if (!function_exists("flock")) { + array_push($errors, "PHP support for flock() function is required."); + } + if (!class_exists("PDO")) { array_push($errors, "PHP support for PDO is required but was not found."); } diff --git a/include/functions.php b/include/functions.php index 0d7f8c756..5096e9c65 100644 --- a/include/functions.php +++ b/include/functions.php @@ -366,21 +366,18 @@ function file_is_locked(string $filename): bool { if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/$filename")) { - if (function_exists('flock')) { - $fp = @fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "r"); - if ($fp) { - if (flock($fp, LOCK_EX | LOCK_NB)) { - flock($fp, LOCK_UN); - fclose($fp); - return false; - } + $fp = @fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "r"); + if ($fp) { + if (flock($fp, LOCK_EX | LOCK_NB)) { + flock($fp, LOCK_UN); fclose($fp); - return true; - } else { return false; } + fclose($fp); + return true; + } else { + return false; } - return true; // consider the file always locked and skip the test } else { return false; } |