X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Ffunctions.php;h=8ede14a0bfa7a188b036d8ac704aff70dd7c22a9;hb=a33558a61efc244ad8c809748e6ee64413e3a217;hp=56361472ee5f4cc9b280fc6a5fce02932c89d7bf;hpb=910592b49a86273a30150bfdb67d9b49409e32f2;p=tt-rss.git diff --git a/include/functions.php b/include/functions.php index 56361472..8ede14a0 100644 --- a/include/functions.php +++ b/include/functions.php @@ -139,6 +139,8 @@ * @return void */ function _debug($msg, $show = true) { + if (defined('SUPPRESS_DEBUGGING')) + return false; $ts = strftime("%H:%M:%S", time()); if (function_exists('posix_getpid')) { @@ -153,7 +155,29 @@ $fp = fopen(LOGFILE, 'a+'); if ($fp) { + $locked = false; + + if (function_exists("flock")) { + $tries = 0; + + // try to lock logfile for writing + while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { + sleep(1); + ++$tries; + } + + if (!$locked) { + fclose($fp); + return; + } + } + fputs($fp, "[$ts] $msg\n"); + + if (function_exists("flock")) { + flock($fp, LOCK_UN); + } + fclose($fp); } } @@ -3039,10 +3063,6 @@ if (preg_match("/^[0-9]*$/", $tag)) return false; if (mb_strlen($tag) > 250) return false; - if (function_exists('iconv')) { - $tag = iconv("utf-8", "utf-8", $tag); - } - if (!$tag) return false; return true; @@ -3415,6 +3435,11 @@ $cat_id = (int)getFeedCategory($feed_id); + if ($cat_id == 0) + $null_cat_qpart = "cat_id IS NULL OR"; + else + $null_cat_qpart = ""; + $result = db_query("SELECT * FROM ttrss_filters2 WHERE owner_uid = $owner_uid AND enabled = true ORDER BY order_id, title"); @@ -3430,7 +3455,7 @@ FROM ttrss_filters2_rules AS r, ttrss_filter_types AS t WHERE - (cat_id IS NULL OR cat_id IN ($check_cats)) AND + ($null_cat_qpart (cat_id IS NULL AND cat_filter = false) OR cat_id IN ($check_cats)) AND (feed_id IS NULL OR feed_id = '$feed_id') AND filter_type = t.id AND filter_id = '$filter_id'"); @@ -3776,6 +3801,7 @@ $url = $line["content_url"]; $ctype = $line["content_type"]; + $title = $line["title"]; if (!$ctype) $ctype = __("unknown type"); @@ -3798,6 +3824,7 @@ $entry["type"] = $ctype; $entry["filename"] = $filename; $entry["url"] = $url; + $entry["title"] = $title; array_push($entries, $entry); } @@ -3819,7 +3846,10 @@ $rv .= "

" .htmlspecialchars($entry["url"]) . "

"; + } + if ($entry['title']) { + $rv.= "
${entry['title']}
"; } } } @@ -3836,7 +3866,12 @@ ""; foreach ($entries as $entry) { - $rv .= ""; + if ($entry["title"]) + $title = "— " . truncate_string($entry["title"], 30); + else + $title = ""; + + $rv .= ""; }; @@ -4052,6 +4087,8 @@ $qpart .= " AND $cat_qpart"; } + $qpart .= " AND feed_id IS NOT NULL"; + array_push($query, "($qpart)"); }