<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 127);
+ define('SCHEMA_VERSION', 130);
define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128);
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);
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);
}
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 smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
- if ($eta_min && date("Y.m.d.G", $timestamp) == date("Y.m.d.G", 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);
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)) {
}
}
+ function uniqid_short() {
+ return uniqid(base_convert(rand(), 10, 36));
+ }
+
// TODO: less dumb splitting
require_once "functions2.php";