X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Ffunctions2.php;h=a73f9a7a786342f0563e77680937fdbaffefbee0;hb=27f7b59353a076120407d8873ea86f5eea7d1dcf;hp=4e133dde44792bd7f33b5310d4db072c2889edc8;hpb=ed775e4e8dba0e3a527ea13b5581c1ce6ee752bc;p=tt-rss.git diff --git a/include/functions2.php b/include/functions2.php index 4e133dde..a73f9a7a 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -203,6 +203,26 @@ return array($prefixes, $hotkeys); } + function check_for_update() { + if (defined("GIT_VERSION_TIMESTAMP")) { + $content = @fetch_file_contents("http://tt-rss.org/version.json"); + + if ($content) { + $content = json_decode($content, true); + + if ($content && isset($content["changeset"])) { + if ((int)GIT_VERSION_TIMESTAMP < (int)$content["changeset"]["timestamp"] && + GIT_VERSION_HEAD != $content["changeset"]["id"]) { + + return $content["changeset"]["id"]; + } + } + } + } + + return ""; + } + function make_runtime_info() { $data = array(); @@ -221,6 +241,15 @@ $data['dep_ts'] = calculate_dep_timestamp(); $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE'); + + if (CHECK_FOR_UPDATES && $_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) { + $update_result = @check_for_update(); + + $data["update_result"] = $update_result; + + $_SESSION["last_version_check"] = time(); + } + if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); @@ -325,6 +354,19 @@ else array_push($query_keywords, "($not (published = false))"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + if (!$not) array_push($search_words, $k); + } + break; + case "unread": + if ($commandpair[1]) { + if ($commandpair[1] == "true") + array_push($query_keywords, "($not (unread = true))"); + else + array_push($query_keywords, "($not (unread = false))"); + } else { array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); @@ -623,10 +665,6 @@ $order_by = "score DESC, date_entered DESC, updated DESC"; - if ($view_mode == "unread_first") { - $order_by = "unread DESC, $order_by"; - } - if ($override_order) { $order_by = $override_order; } @@ -871,7 +909,7 @@ $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png'; if (file_exists($cached_filename)) { - $src = SELF_URL_PATH . '/image.php?hash=' . sha1($src); + $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src); } $entry->setAttribute('src', $src); @@ -2414,4 +2452,14 @@ return false; } + + function error_json($code) { + require_once "errors.php"; + + @$message = $ERRORS[$code]; + + return json_encode(array("error" => + array("code" => $code, "message" => $message))); + + } ?>