X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Ffunctions.php;h=b338bde5bc5eb468c43d99db34a61c51a68268c7;hb=8dcb2b47628346226b18940b5cde7849f7a24687;hp=4d7f61a2bc10faf3e7d99b3a0e1c963cc52d5b31;hpb=b24504b121315813939fa5af1963bee93b6d9d4d;p=tt-rss.git diff --git a/include/functions.php b/include/functions.php index 4d7f61a2..b338bde5 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@ 0) { - setcookie("ttrss_lang", $_SESSION["language"], - time() + SESSION_COOKIE_LIFETIME); - } } - } - } - - - /* function login_sequence($link, $mobile = false) { - $_SESSION["prefs_cache"] = array(); - - if (!SINGLE_USER_MODE) { - - $login_action = $_POST["login_action"]; - - # try to authenticate user if called from login form - if ($login_action == "do_login") { - $login = db_escape_string($_POST["login"]); - $password = $_POST["password"]; - $remember_me = $_POST["remember_me"]; - - if (authenticate_user($link, $login, $password)) { - $_POST["password"] = ""; - - $_SESSION["language"] = $_POST["language"]; - $_SESSION["ref_schema_version"] = get_schema_version($link, true); - $_SESSION["bw_limit"] = !!$_POST["bw_limit"]; - - if ($_POST["profile"]) { - - $profile = db_escape_string($_POST["profile"]); - - $result = db_query($link, "SELECT id FROM ttrss_settings_profiles - WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]); - - if (db_num_rows($result) != 0) { - $_SESSION["profile"] = $profile; - $_SESSION["prefs_cache"] = array(); - } - } - - if ($_REQUEST['return']) { - header("Location: " . $_REQUEST['return']); - } else { - header("Location: " . $_SERVER["REQUEST_URI"]); - } - - exit; - return; - } else { - $_SESSION["login_error_msg"] = __("Incorrect username or password"); - } + if ($_SESSION["uid"] && $_SESSION["language"] && SESSION_COOKIE_LIFETIME > 0) { + setcookie("ttrss_lang", $_SESSION["language"], + time() + SESSION_COOKIE_LIFETIME); } - - if (!$_SESSION["uid"] || !validate_session($link)) { - - if (AUTH_AUTO_LOGIN && authenticate_user($link, null, null)) { - $_SESSION["ref_schema_version"] = get_schema_version($link, true); - } else { - authenticate_user($link, null, null, true); - render_login_form($link, $mobile); - exit; - } - } else { - // bump login timestamp - db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " . - $_SESSION["uid"]); - - if ($_SESSION["language"] && SESSION_COOKIE_LIFETIME > 0) { - setcookie("ttrss_lang", $_SESSION["language"], - time() + SESSION_COOKIE_LIFETIME); - } - - // try to remove possible duplicates from feed counter cache -// ccache_cleanup($link, $_SESSION["uid"]); - } - - } else { - return authenticate_user($link, "admin", null); } - } */ + } function truncate_string($str, $max_len, $suffix = '…') { if (mb_strlen($str, "utf-8") > $max_len - 3) { @@ -2446,7 +2368,7 @@ } } - $content_query_part = "content as content_preview,"; + $content_query_part = "content as content_preview, cached_content, "; if (is_numeric($feed)) { @@ -2593,7 +2515,7 @@ $res = trim($str); if (!$res) return ''; - $config = array('safe' => 1, 'deny_attribute' => 'style', 'comment' => 1, 'cdata' => 1); + $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1); $res = htmLawed($res, $config); if (get_pref($link, "STRIP_IMAGES", $owner)) { @@ -3190,15 +3112,17 @@ //if (!$zoom_mode) { print "
"; - $button_plugins = explode(",", ARTICLE_BUTTON_PLUGINS); - - foreach ($button_plugins as $p) { - $pclass = "button_" . trim($p); + global $pluginhost; - if (class_exists($pclass)) { - $plugin = new $pclass($link); - $rv['content'] .= $plugin->render($id, $line); - } + foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) { + $rv['content'] .= $p->hook_article_button($line); } $rv['content'] .= "load(PLUGINS); + return true; } else { print "Unable to connect to database:" . db_last_error(); @@ -3868,24 +3802,26 @@ } } - function get_article_labels($link, $id) { + function get_article_labels($link, $id, $owner_uid = false) { $rv = array(); + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $result = db_query($link, "SELECT label_cache FROM ttrss_user_entries WHERE ref_id = '$id' AND owner_uid = " . - $_SESSION["uid"]); - - $label_cache = db_fetch_result($result, 0, "label_cache"); + $owner_uid); - if ($label_cache) { + if (db_num_rows($result) > 0) { + $label_cache = db_fetch_result($result, 0, "label_cache"); - $label_cache = json_decode($label_cache, true); + if ($label_cache) { + $label_cache = json_decode($label_cache, true); - if ($label_cache["no-labels"] == 1) - return $rv; - else - return $label_cache; + if ($label_cache["no-labels"] == 1) + return $rv; + else + return $label_cache; + } } $result = db_query($link, @@ -3893,7 +3829,7 @@ FROM ttrss_labels2, ttrss_user_labels2 WHERE id = label_id AND article_id = '$id' - AND owner_uid = ".$_SESSION["uid"] . " + AND owner_uid = ". $owner_uid . " ORDER BY caption"); while ($line = db_fetch_assoc($result)) { @@ -3903,9 +3839,9 @@ } if (count($rv) > 0) - label_update_cache($link, $id, $rv); + label_update_cache($link, $owner_uid, $id, $rv); else - label_update_cache($link, $id, array("no-labels" => 1)); + label_update_cache($link, $owner_uid, $id, array("no-labels" => 1)); return $rv; } @@ -3935,7 +3871,7 @@ return $rv; } - function label_update_cache($link, $id, $labels = false, $force = false) { + function label_update_cache($link, $owner_uid, $id, $labels = false, $force = false) { if ($force) label_clear_cache($link, $id); @@ -3946,7 +3882,7 @@ $labels = db_escape_string(json_encode($labels)); db_query($link, "UPDATE ttrss_user_entries SET - label_cache = '$labels' WHERE ref_id = '$id'"); + label_cache = '$labels' WHERE ref_id = '$id' AND owner_uid = '$owner_uid'"); } @@ -4537,6 +4473,11 @@ } if ($show_content) { + + if ($line["cached_content"] != "") { + $line["content_preview"] =& $line["cached_content"]; + } + if ($sanitize_content) { $headline_row["content"] = sanitize($link, $line["content_preview"], false, false, $line["site_url"]); @@ -4705,7 +4646,7 @@ } function is_html($content) { - return preg_match("/