X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Ffunctions.php;h=f0d5e85faf8325250ae1dc24d16b21f2ebfeabe3;hb=404e2e3603c852a3f82a21c14b8888005e2b3f99;hp=d77cb199e309d60b8bdf2c77bd8631548f04195d;hpb=0db61af84176a39cf1dfd90f62985d0728822b03;p=tt-rss.git diff --git a/include/functions.php b/include/functions.php index d77cb199..f0d5e85f 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,25 +1,15 @@ NOW() - INTERVAL '$intl hour' "; + $match_part = "date_entered > NOW() - INTERVAL '$intl hour' "; } else { - $match_part = "updated > DATE_SUB(NOW(), + $match_part = "date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; } @@ -1086,7 +1095,7 @@ SET unread = false, last_read = NOW() WHERE ref_id IN (SELECT id FROM (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id - AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart AND $match_part) as tmp)"); + AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $match_part) as tmp)"); } if ($feed == -4) { @@ -1461,7 +1470,8 @@ $result = db_query($link, "SELECT id,caption,COUNT(unread) AS unread FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON (ttrss_labels2.id = label_id) - LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND unread = true) + LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND unread = true + AND ttrss_user_entries.owner_uid = $owner_uid) WHERE ttrss_labels2.owner_uid = $owner_uid GROUP BY ttrss_labels2.id, ttrss_labels2.caption"); @@ -1594,12 +1604,22 @@ "SELECT id FROM ttrss_feeds WHERE feed_url = '$url' AND owner_uid = ".$_SESSION["uid"]); + if (strlen(FEED_CRYPT_KEY) > 0) { + require_once "crypt.php"; + $auth_pass = substr(encrypt_string($auth_pass), 0, 250); + $auth_pass_encrypted = 'true'; + } else { + $auth_pass_encrypted = 'false'; + } + + $auth_pass = db_escape_string($link, $auth_pass); + if (db_num_rows($result) == 0) { $result = db_query($link, "INSERT INTO ttrss_feeds - (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method) + (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted) VALUES ('".$_SESSION["uid"]."', '$url', - '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass', 0)"); + '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass', 0, $auth_pass_encrypted)"); $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE feed_url = '$url' @@ -1820,6 +1840,8 @@ } break; } + + return false; } function getFeedTitle($link, $id, $cat = false) { @@ -1906,6 +1928,8 @@ "prev_article" => __("Open previous article"), "next_article_noscroll" => __("Open next article (don't scroll long articles)"), "prev_article_noscroll" => __("Open previous article (don't scroll long articles)"), + "next_article_noexpand" => __("Move to next article (don't expand or mark read)"), + "prev_article_noexpand" => __("Move to previous article (don't expand or mark read)"), "search_dialog" => __("Show search dialog")), __("Article") => array( "toggle_mark" => __("Toggle starred"), @@ -1922,6 +1946,7 @@ "select_article_cursor" => __("Select article under cursor"), "email_article" => __("Email article"), "close_article" => __("Close/collapse article"), + "toggle_expand" => __("Toggle article expansion (combined mode)"), "toggle_widescreen" => __("Toggle widescreen mode"), "toggle_embed_original" => __("Toggle embed original")), __("Article selection") => array( @@ -2126,39 +2151,77 @@ $commandpair = explode(":", mb_strtolower($k), 2); - if ($commandpair[0] == "note" && $commandpair[1]) { - - if ($commandpair[1] == "true") - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); - else - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); - - } else if ($commandpair[0] == "star" && $commandpair[1]) { - - if ($commandpair[1] == "true") - array_push($query_keywords, "($not (marked = true))"); - else - array_push($query_keywords, "($not (marked = false))"); - - } else if ($commandpair[0] == "pub" && $commandpair[1]) { + switch ($commandpair[0]) { + case "title": + if ($commandpair[1]) { + array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE '%". + db_escape_string($link, mb_strtolower($commandpair[1]))."%'))"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } + break; + case "author": + if ($commandpair[1]) { + array_push($query_keywords, "($not (LOWER(author) LIKE '%". + db_escape_string($link, mb_strtolower($commandpair[1]))."%'))"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } + break; + case "note": + if ($commandpair[1]) { + if ($commandpair[1] == "true") + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); + else if ($commandpair[1] == "false") + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); + else + array_push($query_keywords, "($not (LOWER(note) LIKE '%". + db_escape_string($link, mb_strtolower($commandpair[1]))."%'))"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } + break; + case "star": - if ($commandpair[1] == "true") - array_push($query_keywords, "($not (published = true))"); - else - array_push($query_keywords, "($not (published = false))"); + if ($commandpair[1]) { + if ($commandpair[1] == "true") + array_push($query_keywords, "($not (marked = true))"); + else + array_push($query_keywords, "($not (marked = false))"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } + break; + case "pub": + if ($commandpair[1]) { + if ($commandpair[1] == "true") + array_push($query_keywords, "($not (published = true))"); + else + array_push($query_keywords, "($not (published = false))"); - } else if (strpos($k, "@") === 0) { + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } + break; + default: + if (strpos($k, "@") === 0) { - $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']); - $orig_ts = strtotime(substr($k, 1)); - $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); + $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']); + $orig_ts = strtotime(substr($k, 1)); + $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); - //$k = date("Y-m-d", strtotime(substr($k, 1))); + //$k = date("Y-m-d", strtotime(substr($k, 1))); - array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); - } else { - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') - OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') + OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))"); + } } } @@ -2408,6 +2471,7 @@ $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else if ($feed == -4) { // all articles virtual feed + $allow_archived = true; $query_strategy_part = "true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else if ($feed <= LABEL_BASE_INDEX) { // labels @@ -2425,13 +2489,7 @@ $query_strategy_part = "true"; } - if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) { - $date_sort_field = "updated"; - } else { - $date_sort_field = "date_entered"; - } - - $order_by = "$date_sort_field DESC, updated DESC"; + $order_by = "score DESC, date_entered DESC, updated DESC"; if ($view_mode == "unread_first") { $order_by = "unread DESC, $order_by"; @@ -2494,6 +2552,9 @@ LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; } + if ($vfeed_query_part) + $vfeed_query_part .= "favicon_avg_color,"; + $query = "SELECT DISTINCT date_entered, guid, @@ -2676,14 +2737,16 @@ } - $allowed_elements = array('a', 'address', 'audio', 'article', - 'b', 'big', 'blockquote', 'body', 'br', 'cite', 'center', - 'code', 'dd', 'del', 'details', 'div', 'dl', 'font', - 'dt', 'em', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', - 'header', 'html', 'i', 'img', 'ins', 'kbd', - 'li', 'nav', 'noscript', 'ol', 'p', 'pre', 'q', 's','small', - 'source', 'span', 'strike', 'strong', 'sub', 'summary', - 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', + $allowed_elements = array('a', 'address', 'audio', 'article', 'aside', + 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', + 'caption', 'cite', 'center', 'code', 'col', 'colgroup', + 'data', 'dd', 'del', 'details', 'div', 'dl', 'font', + 'dt', 'em', 'footer', 'figure', 'figcaption', + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'html', 'i', + 'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript', + 'ol', 'p', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', + 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', + 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video' ); if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; @@ -2867,19 +2930,12 @@ } function render_login_form($link) { + header('Cache-Control: public'); + require_once "login_form.php"; exit; } - // from http://developer.apple.com/internet/safari/faq.html - function no_cache_incantation() { - header("Expires: Mon, 22 Dec 1980 00:00:00 GMT"); // Happy birthday to me :) - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified - header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); // HTTP/1.1 - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); // HTTP/1.0 - } - function format_warning($msg, $id = "") { global $link; return "
@@ -2925,19 +2981,12 @@ if (strpos($ctype, "audio/") === 0) { if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || - strpos($_SERVER['HTTP_USER_AGENT'], "Chrome") !== false || - strpos($_SERVER['HTTP_USER_AGENT'], "Safari") !== false )) { + $_SESSION["hasMp3"])) { - $id = 'AUDIO-' . uniqid(); - - $entry .= "