<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 125);
+ define('SCHEMA_VERSION', 130);
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;
+ $fetch_last_error_content = false; // curl only for the time being
$fetch_curl_used = false;
$suppress_debugging = false;
+ libxml_disable_entity_loader(true);
+
mb_internal_encoding("UTF-8");
date_default_timezone_set('UTC');
if (defined('E_DEPRECATED')) {
function get_translations() {
$tr = array(
"auto" => "Detect automatically",
+ "ar_SA" => "العربيّة (Arabic)",
+ "bg_BG" => "Bulgarian",
"da_DA" => "Dansk",
"ca_CA" => "Català",
"cs_CZ" => "Česky",
require_once "lib/accept-to-gettext.php";
require_once "lib/gettext/gettext.inc";
- require_once "lib/languagedetect/LanguageDetect.php";
-
function startup_gettext() {
# Get locale from Accept-Language header
if (!$purge_unread) $query_limit = " unread = false AND ";
if (DB_TYPE == "pgsql") {
- $pg_version = get_pgsql_version();
-
- if (preg_match("/^7\./", $pg_version) || preg_match("/^8\.0/", $pg_version)) {
-
- $result = db_query("DELETE FROM ttrss_user_entries WHERE
- ttrss_entries.id = ref_id AND
- marked = false AND
- feed_id = '$feed_id' AND
- $query_limit
- ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
-
- } else {
-
- $result = db_query("DELETE FROM ttrss_user_entries
- USING ttrss_entries
- WHERE ttrss_entries.id = ref_id AND
- marked = false AND
- feed_id = '$feed_id' AND
- $query_limit
- ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
- }
+ $result = db_query("DELETE FROM ttrss_user_entries
+ USING ttrss_entries
+ WHERE ttrss_entries.id = ref_id AND
+ marked = false AND
+ feed_id = '$feed_id' AND
+ $query_limit
+ ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
} else {
// purge orphaned posts in main content table
$result = db_query("DELETE FROM ttrss_entries WHERE
- (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
+ NOT EXISTS (SELECT ref_id FROM ttrss_user_entries WHERE ref_id = id)");
if ($do_output) {
$rows = db_affected_rows($result);
global $fetch_last_error;
global $fetch_last_error_code;
+ global $fetch_last_error_content;
global $fetch_last_content_type;
global $fetch_curl_used;
+ $url = ltrim($url, ' ');
$url = str_replace(' ', '%20', $url);
+ if (strpos($url, "//") === 0)
+ $url = 'http:' . $url;
+
if (!defined('NO_CURL') && function_exists('curl_init')) {
$fetch_curl_used = true;
- if (ini_get("safe_mode") || ini_get("open_basedir")) {
+ if (ini_get("safe_mode") || ini_get("open_basedir") || defined("FORCE_GETURL")) {
$new_url = geturl($url);
if (!$new_url) {
// geturl has already populated $fetch_last_error
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent :
SELF_USER_AGENT);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query);
}
- if ((OPENSSL_VERSION_NUMBER >= 0x0090808f) && (OPENSSL_VERSION_NUMBER < 0x10000000)) {
- curl_setopt($ch, CURLOPT_SSLVERSION, 3);
- }
-
if ($login && $pass)
curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
} else {
$fetch_last_error = "HTTP Code: $http_code";
}
+ $fetch_last_error_content = $contents;
curl_close($ch);
return false;
}
}
if (!$post_query && $timestamp) {
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'GET',
- 'header' => "If-Modified-Since: ".gmdate("D, d M Y H:i:s \\G\\M\\T\r\n", $timestamp)
- )));
+ $context = stream_context_create(array(
+ 'http' => array(
+ 'method' => 'GET',
+ 'protocol_version'=> 1.1,
+ 'header' => "If-Modified-Since: ".gmdate("D, d M Y H:i:s \\G\\M\\T\r\n", $timestamp)
+ )));
} else {
- $context = NULL;
+ $context = stream_context_create(array(
+ 'http' => array(
+ 'method' => 'GET',
+ 'protocol_version'=> 1.1
+ )));
}
$old_error = error_get_last();
}
}
- function print_select($id, $default, $values, $attributes = "") {
- print "<select name=\"$id\" id=\"$id\" $attributes>";
+ function print_select($id, $default, $values, $attributes = "", $name = "") {
+ if (!$name) $name = $id;
+
+ print "<select name=\"$name\" id=\"$id\" $attributes>";
foreach ($values as $v) {
if ($v == $default)
$sel = "selected=\"1\"";
print "</select>";
}
- function print_select_hash($id, $default, $values, $attributes = "") {
- print "<select name=\"$id\" id='$id' $attributes>";
+ function print_select_hash($id, $default, $values, $attributes = "", $name = "") {
+ if (!$name) $name = $id;
+
+ print "<select name=\"$name\" id='$id' $attributes>";
foreach (array_keys($values) as $v) {
if ($v == $default)
$sel = 'selected="selected"';
$_SESSION["name"] = db_fetch_result($result, 0, "login");
$_SESSION["access_level"] = db_fetch_result($result, 0, "access_level");
- $_SESSION["csrf_token"] = uniqid(rand(), true);
+ $_SESSION["csrf_token"] = uniqid_short();
db_query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
$_SESSION["uid"]);
$_SESSION["auth_module"] = false;
if (!$_SESSION["csrf_token"]) {
- $_SESSION["csrf_token"] = uniqid(rand(), true);
+ $_SESSION["csrf_token"] = uniqid_short();
}
$_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
function initialize_user($uid) {
- db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
- values ('$uid', 'Tiny Tiny RSS: New Releases',
- 'http://tt-rss.org/releases.rss')");
-
db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
values ('$uid', 'Tiny Tiny RSS: Forum',
'http://tt-rss.org/forum/rss.php')");
}
function make_local_datetime($timestamp, $long, $owner_uid = false,
- $no_smart_dt = false) {
+ $no_smart_dt = false, $eta_min = false) {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
if (!$timestamp) $timestamp = '1970-01-01 0:00';
if (!$no_smart_dt) {
return smart_date_time($user_timestamp,
- $tz_offset, $owner_uid);
+ $tz_offset, $owner_uid, $eta_min);
} else {
if ($long)
$format = get_pref('LONG_DATE_FORMAT', $owner_uid);
}
}
- function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false) {
+ function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
- if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
+ 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)) {
return date("G:i", $timestamp);
} else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
$format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
(ttrss_labels2.id = label_id)
LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id
- WHERE ttrss_labels2.owner_uid = $owner_uid GROUP BY ttrss_labels2.id,
+ WHERE ttrss_labels2.owner_uid = $owner_uid AND u1.owner_uid = $owner_uid
+ GROUP BY ttrss_labels2.id,
ttrss_labels2.caption");
while ($line = db_fetch_assoc($result)) {
$url = key($feedUrls);
}
- /* libxml_use_internal_errors(true);
- $doc = new DOMDocument();
- $doc->loadXML($contents);
- $error = libxml_get_last_error();
- libxml_clear_errors();
-
- if ($error) {
- $error_message = format_libxml_error($error);
-
- return array("code" => 6, "message" => $error_message);
- } */
-
if ($cat_id == "0" || !$cat_id) {
$cat_qpart = "NULL";
} else {
$feed_id = db_fetch_result($result, 0, "id");
if ($feed_id) {
- update_rss_feed($feed_id, true);
+ set_basic_feed_info($feed_id);
}
return array("code" => 1);
function getFeedTitle($id, $cat = false) {
if ($cat) {
return getCategoryTitle($id);
- } else if ($id == 0) {
- return __("All feeds");
} else if ($id == -1) {
return __("Starred articles");
} else if ($id == -2) {
}
}
+ function uniqid_short() {
+ return uniqid(base_convert(rand(), 10, 36));
+ }
+
// TODO: less dumb splitting
require_once "functions2.php";