diff options
Diffstat (limited to 'include/functions.php')
-rwxr-xr-x | include/functions.php | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/include/functions.php b/include/functions.php index d5095b071..97dbbff15 100755 --- a/include/functions.php +++ b/include/functions.php @@ -437,6 +437,14 @@ curl_close($ch); + $is_gzipped = RSSUtils::is_gzipped($contents); + + if ($is_gzipped) { + $tmp = @gzdecode($contents); + + if ($tmp) $contents = $tmp; + } + return $contents; } else { @@ -522,6 +530,15 @@ return false; } + + $is_gzipped = RSSUtils::is_gzipped($data); + + if ($is_gzipped) { + $tmp = @gzdecode($data); + + if ($tmp) $data = $tmp; + } + return $data; } @@ -679,8 +696,6 @@ $_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']); $_SESSION["pwd_hash"] = $row["pwd_hash"]; - $_SESSION["last_version_check"] = time(); - initialize_user_prefs($_SESSION["uid"]); return true; @@ -848,10 +863,18 @@ } } - // is not utf8 clean + function mb_substr_replace($original, $replacement, $position, $length) { + $startString = mb_substr($original, 0, $position, "UTF-8"); + $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8"); + + $out = $startString . $replacement . $endString; + + return $out; + } + function truncate_middle($str, $max_len, $suffix = '…') { - if (strlen($str) > $max_len) { - return substr_replace($str, $suffix, $max_len / 2, mb_strlen($str) - $max_len); + if (mb_strlen($str) > $max_len) { + return mb_substr_replace($str, $suffix, $max_len / 2, mb_strlen($str) - $max_len); } else { return $str; } @@ -1068,6 +1091,7 @@ $params[strtolower($param)] = (int) get_pref($param); } + $params["check_for_updates"] = CHECK_FOR_UPDATES; $params["icons_url"] = ICONS_URL; $params["cookie_lifetime"] = SESSION_COOKIE_LIFETIME; $params["default_view_mode"] = get_pref("_DEFAULT_VIEW_MODE"); @@ -1270,27 +1294,7 @@ return array($prefixes, $hotkeys); } - function check_for_update() { - if (defined("GIT_VERSION_TIMESTAMP")) { - $content = @fetch_file_contents(array("url" => "http://tt-rss.org/version.json", "timeout" => 5)); - - 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($disable_update_check = false) { + function make_runtime_info() { $data = array(); $pdo = Db::pdo(); @@ -1323,14 +1327,6 @@ } } - if (CHECK_FOR_UPDATES && !$disable_update_check && $_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"); |