diff options
author | Andrew Dolgov <[email protected]> | 2020-09-25 10:04:09 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-09-25 10:04:09 +0300 |
commit | e993d4feb2e90600f5c896f1e3508f7f95e81c84 (patch) | |
tree | 3f3cf10fbf124c49b61bf81fef5f82caa5db2068 /include/functions.php | |
parent | 71e9f70b8a5fa128204eb4a47c06639206824500 (diff) | |
parent | d0ed7890df949669261f52235151c93cf324714e (diff) |
Merge branch 'master' of git.fakecake.org:tt-rss
Diffstat (limited to 'include/functions.php')
-rw-r--r-- | include/functions.php | 108 |
1 files changed, 20 insertions, 88 deletions
diff --git a/include/functions.php b/include/functions.php index 506d426b1..cf3362e71 100644 --- a/include/functions.php +++ b/include/functions.php @@ -168,26 +168,46 @@ Debug::log($msg); } + // @deprecated + function getFeedUnread($feed, $is_cat = false) { + return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); + } + + // @deprecated function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id); } + // @deprecated function fetch_file_contents($params) { return UrlHelper::fetch($params); } + // @deprecated function rewrite_relative_url($url, $rel_url) { return UrlHelper::rewrite_relative($url, $rel_url); } + // @deprecated function validate_url($url) { return UrlHelper::validate($url); } + // @deprecated function authenticate_user($login, $password, $check_only = false, $service = false) { return UserHelper::authenticate($login, $password, $check_only, $service); } + // @deprecated + function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { + return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min); + } + + // @deprecated + function make_local_datetime($timestamp, $long, $owner_uid = false, $no_smart_dt = false, $eta_min = false) { + return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min); + } + /* end compat shims */ function get_ssl_certificate_id() { @@ -271,90 +291,6 @@ } } - function convert_timestamp($timestamp, $source_tz, $dest_tz) { - - try { - $source_tz = new DateTimeZone($source_tz); - } catch (Exception $e) { - $source_tz = new DateTimeZone('UTC'); - } - - try { - $dest_tz = new DateTimeZone($dest_tz); - } catch (Exception $e) { - $dest_tz = new DateTimeZone('UTC'); - } - - $dt = new DateTime(date('Y-m-d H:i:s', $timestamp), $source_tz); - return $dt->format('U') + $dest_tz->getOffset($dt); - } - - function make_local_datetime($timestamp, $long, $owner_uid = false, - $no_smart_dt = false, $eta_min = false) { - - if (!$owner_uid) $owner_uid = $_SESSION['uid']; - if (!$timestamp) $timestamp = '1970-01-01 0:00'; - - global $utc_tz; - global $user_tz; - - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); - - $timestamp = substr($timestamp, 0, 19); - - # We store date in UTC internally - $dt = new DateTime($timestamp, $utc_tz); - - $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid); - - if ($user_tz_string != 'Automatic') { - - try { - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); - } catch (Exception $e) { - $user_tz = $utc_tz; - } - - $tz_offset = $user_tz->getOffset($dt); - } else { - $tz_offset = (int) -$_SESSION["clientTzOffset"]; - } - - $user_timestamp = $dt->format('U') + $tz_offset; - - if (!$no_smart_dt) { - return smart_date_time($user_timestamp, - $tz_offset, $owner_uid, $eta_min); - } else { - if ($long) - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); - else - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - - return date($format, $user_timestamp); - } - } - - function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { - if (!$owner_uid) $owner_uid = $_SESSION['uid']; - - if ($eta_min && time() + $tz_offset - $timestamp < 3600) { - return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); - } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - if (strpos((strtolower($format)), "a") === false) - return date("G:i", $timestamp); - else - return date("g:i a", $timestamp); - } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - return date($format, $timestamp); - } else { - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); - return date($format, $timestamp); - } - } - function sql_bool_to_bool($s) { return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer } @@ -441,10 +377,6 @@ } } - function getFeedUnread($feed, $is_cat = false) { - return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); - } - function checkbox_to_sql_bool($val) { return ($val == "on") ? 1 : 0; } |