<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 115);
+ define('SCHEMA_VERSION', 118);
define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128);
$fetch_last_error = false;
$fetch_last_error_code = false;
+ $fetch_last_content_type = false;
$pluginhost = false;
- function __autoload($class) {
- $class_file = str_replace("_", "/", strtolower(basename($class)));
-
- $file = dirname(__FILE__)."/../classes/$class_file.php";
-
- if (file_exists($file)) {
- require $file;
- }
-
- }
-
mb_internal_encoding("UTF-8");
date_default_timezone_set('UTC');
if (defined('E_DEPRECATED')) {
global $fetch_last_error;
global $fetch_last_error_code;
+ global $fetch_last_content_type;
$url = str_replace(' ', '%20', $url);
if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
- if (ini_get("safe_mode")) {
+ if (ini_get("safe_mode") || ini_get("open_basedir")) {
$ch = curl_init(geturl($url));
} else {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode"));
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode") && !ini_get("open_basedir"));
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
}
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
+ $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$fetch_last_error_code = $http_code;
- if ($http_code != 200 || $type && strpos($content_type, "$type") === false) {
+ if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) {
if (curl_errno($ch) != 0) {
$fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
} else {
$data = @file_get_contents($url);
+ $fetch_last_content_type = false; // reset if no type was sent from server
+ foreach ($http_response_header as $h) {
+ if (substr(strtolower($h), 0, 13) == 'content-type:') {
+ $fetch_last_content_type = substr($h, 14);
+ // don't abort here b/c there might be more than one
+ // e.g. if we were being redirected -- last one is the right one
+ }
+ }
+
if (!$data && function_exists('error_get_last')) {
$error = error_get_last();
$fetch_last_error = $error["message"];
}
}
}
+ return $icon_file;
}
}
"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'
}
break;
}
+
+ return false;
}
function getFeedTitle($link, $id, $cat = false) {
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":
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":
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":
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%'))");
}
break;
default:
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,
'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', 'small',
- 'source', 'span', 'strike', 'strong', 'sub', 'summary',
+ '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' );
}
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 "<div class=\"warning\" id=\"$id\">
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 .= "<audio id=\"$id\"\" controls style='display : none'>
+ $entry .= "<audio controls>
<source type=\"$ctype\" src=\"$url\"></source>
</audio>";
- $entry .= "<span onclick=\"player(this)\"
- title=\"".__("Click to play")."\" status=\"0\"
- class=\"player\" audio-id=\"$id\">".__("Play")."</span>";
-
} else {
$entry .= "<object type=\"application/x-shockwave-flash\"
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
(SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
(SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images,
+ (SELECT always_display_enclosures FROM ttrss_feeds WHERE id = feed_id) as always_display_enclosures,
num_comments,
tag_cache,
author,
position=\"below\">$tags_str_full</div>";
global $pluginhost;
-
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {
$rv['content'] .= $p->hook_article_button($line);
}
-
} else {
$tags_str = strip_tags($tags_str);
$rv['content'] .= "<span id=\"ATSTR-$id\">$tags_str</span>";
}
$rv['content'] .= "</div>";
- $rv['content'] .= "<div clear='both'>$entry_comments</div>";
+ $rv['content'] .= "<div clear='both'>";
+
+ global $pluginhost;
+ foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
+ $rv['content'] .= $p->hook_article_left_button($line);
+ }
+
+ $rv['content'] .= "$entry_comments</div>";
if ($line["orig_feed_id"]) {
$rv['content'] .= "<div class=\"postContent\">";
$rv['content'] .= $line["content"];
-
$rv['content'] .= format_article_enclosures($link, $id,
- $always_display_enclosures, $line["content"], $line["hide_images"]);
+ sql_bool_to_bool($line["always_display_enclosures"]),
+ $line["content"],
+ sql_bool_to_bool($line["hide_images"]));
$rv['content'] .= "</div>";
return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
}
- function init_connection($link) {
- if ($link) {
-
- if (DB_TYPE == "pgsql") {
- pg_query($link, "set client_encoding = 'UTF-8'");
- pg_set_client_encoding("UNICODE");
- pg_query($link, "set datestyle = 'ISO, european'");
- pg_query($link, "set TIME ZONE 0");
- } else {
- db_query($link, "SET time_zone = '+0:0'");
-
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
- }
- }
-
- global $pluginhost;
+ function init_plugins($link) {
+ global $pluginhost;
- $pluginhost = new PluginHost($link);
- $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
+ $pluginhost = new PluginHost($link);
+ $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
- return true;
- } else {
- print "Unable to connect to database:" . db_last_error();
- return false;
- }
+ return true;
}
function format_tags_string($tags, $id) {
function format_article_labels($labels, $id) {
+ if (is_array($labels)) return '';
+
$labels_str = "";
foreach ($labels as $l) {
$sphinxClient = new SphinxClient();
- $sphinxClient->SetServer('localhost', 9312);
+ $sphinxpair = explode(":", SPHINX_SERVER, 2);
+
+ $sphinxClient->SetServer($sphinxpair[0], $sphinxpair[1]);
$sphinxClient->SetConnectTimeout(1);
$sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30,