@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Dlg extends Handler_Protected { |
| 3 | 3 | private $param; |
| 4 | - private $params; |
|
| 4 | + private $params; |
|
| 5 | 5 | |
| 6 | - function before($method) { |
|
| 6 | + function before($method) { |
|
| 7 | 7 | if (parent::before($method)) { |
| 8 | 8 | header("Content-Type: text/html"); # required for iframe |
| 9 | 9 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $tags[$line["tag_name"]] = $line["count"]; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(count($tags) == 0 ){ return; } |
|
| 111 | + if(count($tags) == 0 ){ return; } |
|
| 112 | 112 | |
| 113 | 113 | ksort($tags); |
| 114 | 114 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | function defaultPasswordWarning() { |
| 195 | 195 | |
| 196 | - print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
| 196 | + print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
| 197 | 197 | |
| 198 | 198 | print "<footer class='text-center'>"; |
| 199 | 199 | print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function pubOPMLUrl() { |
| 39 | 39 | $url_path = Opml::opml_publish_url(); |
| 40 | 40 | |
| 41 | - print "<header>" . __("Your Public OPML URL is:") . "</header>"; |
|
| 41 | + print "<header>".__("Your Public OPML URL is:")."</header>"; |
|
| 42 | 42 | |
| 43 | 43 | print "<section>"; |
| 44 | 44 | |
@@ -67,18 +67,18 @@ discard block |
||
| 67 | 67 | if ($this->param == 1) { |
| 68 | 68 | print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner."); |
| 69 | 69 | |
| 70 | - $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
| 70 | + $stamp = (int) file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
|
| 71 | 71 | |
| 72 | - print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
| 72 | + print "<p>".__("Last update:")." ".date("Y.m.d, G:i", $stamp); |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if ($this->param == 3) { |
| 77 | 77 | print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner."); |
| 78 | 78 | |
| 79 | - $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
| 79 | + $stamp = (int) file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
|
| 80 | 80 | |
| 81 | - print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
| 81 | + print "<p>".__("Last update:")." ".date("Y.m.d, G:i", $stamp); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $tags[$line["tag_name"]] = $line["count"]; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(count($tags) == 0 ){ return; } |
|
| 111 | + if (count($tags) == 0) { return; } |
|
| 112 | 112 | |
| 113 | 113 | ksort($tags); |
| 114 | 114 | |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $key_escaped = str_replace("'", "\\'", $key); |
| 140 | 140 | |
| 141 | - echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " . |
|
| 142 | - $size . "px\" title=\"$value articles tagged with " . |
|
| 143 | - $key . '">' . $key . '</a> '; |
|
| 141 | + echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: ". |
|
| 142 | + $size."px\" title=\"$value articles tagged with ". |
|
| 143 | + $key.'">'.$key.'</a> '; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $key = Feeds::get_feed_access_key($feed_id, $is_cat); |
| 165 | 165 | |
| 166 | - $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; |
|
| 166 | + $url_path = htmlspecialchars($this->params[2])."&key=".$key; |
|
| 167 | 167 | |
| 168 | 168 | $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); |
| 169 | 169 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $new_feed_id = $row['id']; |
| 238 | 238 | } else { |
| 239 | 239 | $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
| 240 | - $new_feed_id = (int)$row['id'] + 1; |
|
| 240 | + $new_feed_id = (int) $row['id'] + 1; |
|
| 241 | 241 | |
| 242 | 242 | $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
| 243 | 243 | (id, owner_uid, title, feed_url, site_url, created) |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
| 288 | 288 | function catchupSelected() { |
| 289 | 289 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 290 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 290 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 291 | 291 | |
| 292 | 292 | Article::catchupArticlesById($ids, $cmode); |
| 293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | function markSelected() { |
| 298 | 298 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 299 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 299 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 300 | 300 | |
| 301 | 301 | $this->markArticlesById($ids, $cmode); |
| 302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | function publishSelected() { |
| 307 | 307 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 308 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 308 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 309 | 309 | |
| 310 | 310 | $this->publishArticlesById($ids, $cmode); |
| 311 | 311 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | print "<ul>"; |
| 344 | 344 | while ($line = $sth->fetch()) { |
| 345 | - print "<li>" . $line["caption"] . "</li>"; |
|
| 345 | + print "<li>".$line["caption"]."</li>"; |
|
| 346 | 346 | } |
| 347 | 347 | print "</ul>"; |
| 348 | 348 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | if ($msg) { |
| 580 | 580 | Logger::get()->log_error(E_USER_WARNING, |
| 581 | - $msg, 'client-js:' . $file, $line, $context); |
|
| 581 | + $msg, 'client-js:'.$file, $line, $context); |
|
| 582 | 582 | |
| 583 | 583 | echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
| 584 | 584 | } else { |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | $content = json_decode($content, true); |
| 603 | 603 | |
| 604 | 604 | if ($content && isset($content["changeset"])) { |
| 605 | - if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
| 605 | + if ($git_timestamp < (int) $content["changeset"]["timestamp"] && |
|
| 606 | 606 | $git_commit != $content["changeset"]["id"]) { |
| 607 | 607 | |
| 608 | 608 | $rv = $content["changeset"]; |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | $_SESSION["profile"] = (int) clean($_REQUEST["id"]); |
| 12 | 12 | |
| 13 | 13 | // default value |
| 14 | - if (!$_SESSION["profile"]) $_SESSION["profile"] = null; |
|
| 14 | + if (!$_SESSION["profile"]) { |
|
| 15 | + $_SESSION["profile"] = null; |
|
| 16 | + } |
|
| 15 | 17 | } |
| 16 | 18 | |
| 17 | 19 | function remprofiles() { |
@@ -173,7 +175,9 @@ discard block |
||
| 173 | 175 | if ($row = $sth->fetch()) { |
| 174 | 176 | $feed_id = $row["id"]; |
| 175 | 177 | } else { |
| 176 | - if (!$title) $title = '[Unknown]'; |
|
| 178 | + if (!$title) { |
|
| 179 | + $title = '[Unknown]'; |
|
| 180 | + } |
|
| 177 | 181 | |
| 178 | 182 | $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
| 179 | 183 | (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method) |
@@ -216,7 +220,9 @@ discard block |
||
| 216 | 220 | private function archive_article($id, $owner_uid) { |
| 217 | 221 | $this->pdo->beginTransaction(); |
| 218 | 222 | |
| 219 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 223 | + if (!$owner_uid) { |
|
| 224 | + $owner_uid = $_SESSION['uid']; |
|
| 225 | + } |
|
| 220 | 226 | |
| 221 | 227 | $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
| 222 | 228 | WHERE ref_id = ? AND owner_uid = ?"); |
@@ -278,8 +284,9 @@ discard block |
||
| 278 | 284 | 'seq' => $seq |
| 279 | 285 | ]; |
| 280 | 286 | |
| 281 | - if ($seq % 2 == 0) |
|
| 282 | - $reply['runtime-info'] = make_runtime_info(); |
|
| 287 | + if ($seq % 2 == 0) { |
|
| 288 | + $reply['runtime-info'] = make_runtime_info(); |
|
| 289 | + } |
|
| 283 | 290 | |
| 284 | 291 | print json_encode($reply); |
| 285 | 292 | } |
@@ -353,7 +360,9 @@ discard block |
||
| 353 | 360 | $payload = json_decode(clean($_REQUEST["payload"]), false); |
| 354 | 361 | $mode = clean($_REQUEST["mode"]); |
| 355 | 362 | |
| 356 | - if (!$payload || !is_array($payload)) return; |
|
| 363 | + if (!$payload || !is_array($payload)) { |
|
| 364 | + return; |
|
| 365 | + } |
|
| 357 | 366 | |
| 358 | 367 | if ($mode == 1) { |
| 359 | 368 | foreach ($payload as $feed) { |
@@ -22,19 +22,23 @@ discard block |
||
| 22 | 22 | 32767 => 'E_ALL'); |
| 23 | 23 | |
| 24 | 24 | function log_error($errno, $errstr, $file, $line, $context) { |
| 25 | - if ($errno == E_NOTICE) return false; |
|
| 26 | - |
|
| 27 | - if ($this->adapter) |
|
| 28 | - return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
| 29 | - else |
|
| 25 | + if ($errno == E_NOTICE) { |
|
| 30 | 26 | return false; |
| 27 | + } |
|
| 28 | + |
|
| 29 | + if ($this->adapter) { |
|
| 30 | + return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
| 31 | + } else { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | function log($string, $context = "") { |
| 34 | - if ($this->adapter) |
|
| 35 | - return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
| 36 | - else |
|
| 37 | - return false; |
|
| 37 | + if ($this->adapter) { |
|
| 38 | + return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
| 39 | + } else { |
|
| 40 | + return false; |
|
| 41 | + } |
|
| 38 | 42 | } |
| 39 | 43 | |
| 40 | 44 | private function __clone() { |
@@ -58,8 +62,9 @@ discard block |
||
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | public static function get() { |
| 61 | - if (self::$instance == null) |
|
| 62 | - self::$instance = new self(); |
|
| 65 | + if (self::$instance == null) { |
|
| 66 | + self::$instance = new self(); |
|
| 67 | + } |
|
| 63 | 68 | |
| 64 | 69 | return self::$instance; |
| 65 | 70 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - static function get_all_labels($owner_uid) { |
|
| 40 | + static function get_all_labels($owner_uid) { |
|
| 41 | 41 | $rv = array(); |
| 42 | 42 | |
| 43 | 43 | $pdo = Db::pdo(); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - static function clear_cache($id) { |
|
| 73 | + static function clear_cache($id) { |
|
| 74 | 74 | |
| 75 | 75 | $pdo = Db::pdo(); |
| 76 | 76 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | Labels::clear_cache($id); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - static function add_article($id, $label, $owner_uid) { |
|
| 101 | + static function add_article($id, $label, $owner_uid) { |
|
| 102 | 102 | |
| 103 | 103 | $label_id = Labels::find_id($label, $owner_uid); |
| 104 | 104 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | if (!$tr_in_progress) $pdo->commit(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
|
| 174 | + static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
|
| 175 | 175 | |
| 176 | 176 | if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
| 177 | 177 | |
@@ -56,11 +56,13 @@ discard block |
||
| 56 | 56 | static function update_cache($owner_uid, $id, $labels = false, $force = false) { |
| 57 | 57 | $pdo = Db::pdo(); |
| 58 | 58 | |
| 59 | - if ($force) |
|
| 60 | - Labels::clear_cache($id); |
|
| 59 | + if ($force) { |
|
| 60 | + Labels::clear_cache($id); |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | - if (!$labels) |
|
| 63 | - $labels = Article::get_article_labels($id); |
|
| 63 | + if (!$labels) { |
|
| 64 | + $labels = Article::get_article_labels($id); |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | $labels = json_encode($labels); |
| 66 | 68 | |
@@ -84,7 +86,9 @@ discard block |
||
| 84 | 86 | |
| 85 | 87 | $label_id = Labels::find_id($label, $owner_uid); |
| 86 | 88 | |
| 87 | - if (!$label_id) return; |
|
| 89 | + if (!$label_id) { |
|
| 90 | + return; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $pdo = Db::pdo(); |
| 90 | 94 | |
@@ -102,7 +106,9 @@ discard block |
||
| 102 | 106 | |
| 103 | 107 | $label_id = Labels::find_id($label, $owner_uid); |
| 104 | 108 | |
| 105 | - if (!$label_id) return; |
|
| 109 | + if (!$label_id) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 106 | 112 | |
| 107 | 113 | $pdo = Db::pdo(); |
| 108 | 114 | |
@@ -128,7 +134,9 @@ discard block |
||
| 128 | 134 | } |
| 129 | 135 | |
| 130 | 136 | static function remove($id, $owner_uid) { |
| 131 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 137 | + if (!$owner_uid) { |
|
| 138 | + $owner_uid = $_SESSION["uid"]; |
|
| 139 | + } |
|
| 132 | 140 | |
| 133 | 141 | $pdo = Db::pdo(); |
| 134 | 142 | $tr_in_progress = false; |
@@ -168,12 +176,16 @@ discard block |
||
| 168 | 176 | |
| 169 | 177 | } |
| 170 | 178 | |
| 171 | - if (!$tr_in_progress) $pdo->commit(); |
|
| 179 | + if (!$tr_in_progress) { |
|
| 180 | + $pdo->commit(); |
|
| 181 | + } |
|
| 172 | 182 | } |
| 173 | 183 | |
| 174 | 184 | static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
| 175 | 185 | |
| 176 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 186 | + if (!$owner_uid) { |
|
| 187 | + $owner_uid = $_SESSION['uid']; |
|
| 188 | + } |
|
| 177 | 189 | |
| 178 | 190 | $pdo = Db::pdo(); |
| 179 | 191 | |
@@ -198,7 +210,9 @@ discard block |
||
| 198 | 210 | $result = $sth->rowCount(); |
| 199 | 211 | } |
| 200 | 212 | |
| 201 | - if (!$tr_in_progress) $pdo->commit(); |
|
| 213 | + if (!$tr_in_progress) { |
|
| 214 | + $pdo->commit(); |
|
| 215 | + } |
|
| 202 | 216 | |
| 203 | 217 | return $result; |
| 204 | 218 | } |
@@ -1,86 +1,86 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Debug { |
| 3 | 3 | public static $LOG_DISABLED = -1; |
| 4 | - public static $LOG_NORMAL = 0; |
|
| 5 | - public static $LOG_VERBOSE = 1; |
|
| 6 | - public static $LOG_EXTENDED = 2; |
|
| 4 | + public static $LOG_NORMAL = 0; |
|
| 5 | + public static $LOG_VERBOSE = 1; |
|
| 6 | + public static $LOG_EXTENDED = 2; |
|
| 7 | 7 | |
| 8 | - private static $enabled = false; |
|
| 9 | - private static $quiet = false; |
|
| 10 | - private static $logfile = false; |
|
| 11 | - private static $loglevel = 0; |
|
| 8 | + private static $enabled = false; |
|
| 9 | + private static $quiet = false; |
|
| 10 | + private static $logfile = false; |
|
| 11 | + private static $loglevel = 0; |
|
| 12 | 12 | |
| 13 | 13 | public static function set_logfile($logfile) { |
| 14 | - Debug::$logfile = $logfile; |
|
| 15 | - } |
|
| 14 | + Debug::$logfile = $logfile; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function enabled() { |
|
| 18 | - return Debug::$enabled; |
|
| 19 | - } |
|
| 17 | + public static function enabled() { |
|
| 18 | + return Debug::$enabled; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public static function set_enabled($enable) { |
|
| 22 | - Debug::$enabled = $enable; |
|
| 23 | - } |
|
| 21 | + public static function set_enabled($enable) { |
|
| 22 | + Debug::$enabled = $enable; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public static function set_quiet($quiet) { |
|
| 26 | - Debug::$quiet = $quiet; |
|
| 27 | - } |
|
| 25 | + public static function set_quiet($quiet) { |
|
| 26 | + Debug::$quiet = $quiet; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public static function set_loglevel($level) { |
|
| 30 | - Debug::$loglevel = $level; |
|
| 31 | - } |
|
| 29 | + public static function set_loglevel($level) { |
|
| 30 | + Debug::$loglevel = $level; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public static function get_loglevel() { |
|
| 34 | - return Debug::$loglevel; |
|
| 35 | - } |
|
| 33 | + public static function get_loglevel() { |
|
| 34 | + return Debug::$loglevel; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function log($message, $level = 0) { |
|
| 37 | + public static function log($message, $level = 0) { |
|
| 38 | 38 | |
| 39 | - if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
| 39 | + if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
| 40 | 40 | |
| 41 | - $ts = strftime("%H:%M:%S", time()); |
|
| 42 | - if (function_exists('posix_getpid')) { |
|
| 43 | - $ts = "$ts/" . posix_getpid(); |
|
| 44 | - } |
|
| 41 | + $ts = strftime("%H:%M:%S", time()); |
|
| 42 | + if (function_exists('posix_getpid')) { |
|
| 43 | + $ts = "$ts/" . posix_getpid(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - if (Debug::$logfile) { |
|
| 47 | - $fp = fopen(Debug::$logfile, 'a+'); |
|
| 46 | + if (Debug::$logfile) { |
|
| 47 | + $fp = fopen(Debug::$logfile, 'a+'); |
|
| 48 | 48 | |
| 49 | - if ($fp) { |
|
| 50 | - $locked = false; |
|
| 49 | + if ($fp) { |
|
| 50 | + $locked = false; |
|
| 51 | 51 | |
| 52 | - if (function_exists("flock")) { |
|
| 53 | - $tries = 0; |
|
| 52 | + if (function_exists("flock")) { |
|
| 53 | + $tries = 0; |
|
| 54 | 54 | |
| 55 | - // try to lock logfile for writing |
|
| 56 | - while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { |
|
| 57 | - sleep(1); |
|
| 58 | - ++$tries; |
|
| 59 | - } |
|
| 55 | + // try to lock logfile for writing |
|
| 56 | + while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { |
|
| 57 | + sleep(1); |
|
| 58 | + ++$tries; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - if (!$locked) { |
|
| 62 | - fclose($fp); |
|
| 63 | - user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 64 | - return; |
|
| 65 | - } |
|
| 66 | - } |
|
| 61 | + if (!$locked) { |
|
| 62 | + fclose($fp); |
|
| 63 | + user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - fputs($fp, "[$ts] $message\n"); |
|
| 68 | + fputs($fp, "[$ts] $message\n"); |
|
| 69 | 69 | |
| 70 | - if (function_exists("flock")) { |
|
| 71 | - flock($fp, LOCK_UN); |
|
| 72 | - } |
|
| 70 | + if (function_exists("flock")) { |
|
| 71 | + flock($fp, LOCK_UN); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - fclose($fp); |
|
| 74 | + fclose($fp); |
|
| 75 | 75 | |
| 76 | - if (Debug::$quiet) |
|
| 77 | - return; |
|
| 76 | + if (Debug::$quiet) |
|
| 77 | + return; |
|
| 78 | 78 | |
| 79 | - } else { |
|
| 80 | - user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 81 | - } |
|
| 82 | - } |
|
| 79 | + } else { |
|
| 80 | + user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - print "[$ts] $message\n"; |
|
| 85 | - } |
|
| 84 | + print "[$ts] $message\n"; |
|
| 85 | + } |
|
| 86 | 86 | } |
| 87 | 87 | \ No newline at end of file |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $ts = strftime("%H:%M:%S", time()); |
| 42 | 42 | if (function_exists('posix_getpid')) { |
| 43 | - $ts = "$ts/" . posix_getpid(); |
|
| 43 | + $ts = "$ts/".posix_getpid(); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if (Debug::$logfile) { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | if (!$locked) { |
| 62 | 62 | fclose($fp); |
| 63 | - user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 63 | + user_error("Unable to lock debugging log file: ".Debug::$logfile, E_USER_WARNING); |
|
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | return; |
| 78 | 78 | |
| 79 | 79 | } else { |
| 80 | - user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
| 80 | + user_error("Unable to open debugging log file: ".Debug::$logfile, E_USER_WARNING); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public static function log($message, $level = 0) { |
| 38 | 38 | |
| 39 | - if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
| 39 | + if (!Debug::$enabled || Debug::$loglevel < $level) { |
|
| 40 | + return false; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $ts = strftime("%H:%M:%S", time()); |
| 42 | 44 | if (function_exists('posix_getpid')) { |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | |
| 74 | 76 | fclose($fp); |
| 75 | 77 | |
| 76 | - if (Debug::$quiet) |
|
| 77 | - return; |
|
| 78 | + if (Debug::$quiet) { |
|
| 79 | + return; |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | 82 | } else { |
| 80 | 83 | user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | $priority = LOG_INFO; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - $errname = Logger::$errornames[$errno] . " ($errno)"; |
|
| 27 | + $errname = Logger::$errornames[$errno]." ($errno)"; |
|
| 28 | 28 | |
| 29 | 29 | syslog($priority, "[tt-rss] $errname ($file:$line) $errstr"); |
| 30 | 30 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | foreach ($server_params as $n => $p) { |
| 25 | 25 | if (isset($_SERVER[$p])) |
| 26 | - $context .= "\n$n: " . $_SERVER[$p]; |
|
| 26 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // passed error message may contain invalid unicode characters, failing to insert an error here |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | function log_error($errno, $errstr, $file, $line, $context) { |
| 7 | 7 | |
| 8 | 8 | // separate PDO connection object is used for logging |
| 9 | - if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect(); |
|
| 9 | + if (!$this->pdo) { |
|
| 10 | + $this->pdo = Db::instance()->pdo_connect(); |
|
| 11 | + } |
|
| 10 | 12 | |
| 11 | 13 | if ($this->pdo && get_schema_version() > 117) { |
| 12 | 14 | |
@@ -22,8 +24,9 @@ discard block |
||
| 22 | 24 | ]; |
| 23 | 25 | |
| 24 | 26 | foreach ($server_params as $n => $p) { |
| 25 | - if (isset($_SERVER[$p])) |
|
| 26 | - $context .= "\n$n: " . $_SERVER[$p]; |
|
| 27 | + if (isset($_SERVER[$p])) { |
|
| 28 | + $context .= "\n$n: " . $_SERVER[$p]; |
|
| 29 | + } |
|
| 27 | 30 | } |
| 28 | 31 | |
| 29 | 32 | // passed error message may contain invalid unicode characters, failing to insert an error here |
@@ -702,7 +702,7 @@ |
||
| 702 | 702 | $entry_plugin_data .= mb_strtolower(get_class($plugin)) . ","; |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - if (Debug::get_loglevel() >= 3) { |
|
| 705 | + if (Debug::get_loglevel() >= 3) { |
|
| 706 | 706 | print "processed content: "; |
| 707 | 707 | print htmlspecialchars($article["content"]); |
| 708 | 708 | print "\n"; |
@@ -1349,35 +1349,35 @@ |
||
| 1349 | 1349 | continue; |
| 1350 | 1350 | |
| 1351 | 1351 | switch ($rule["type"]) { |
| 1352 | - case "title": |
|
| 1353 | - $match = @preg_match("/$reg_exp/iu", $title); |
|
| 1354 | - break; |
|
| 1355 | - case "content": |
|
| 1356 | - // we don't need to deal with multiline regexps |
|
| 1357 | - $content = preg_replace("/[\r\n\t]/", "", $content); |
|
| 1352 | + case "title": |
|
| 1353 | + $match = @preg_match("/$reg_exp/iu", $title); |
|
| 1354 | + break; |
|
| 1355 | + case "content": |
|
| 1356 | + // we don't need to deal with multiline regexps |
|
| 1357 | + $content = preg_replace("/[\r\n\t]/", "", $content); |
|
| 1358 | 1358 | |
| 1359 | - $match = @preg_match("/$reg_exp/iu", $content); |
|
| 1360 | - break; |
|
| 1361 | - case "both": |
|
| 1362 | - // we don't need to deal with multiline regexps |
|
| 1363 | - $content = preg_replace("/[\r\n\t]/", "", $content); |
|
| 1359 | + $match = @preg_match("/$reg_exp/iu", $content); |
|
| 1360 | + break; |
|
| 1361 | + case "both": |
|
| 1362 | + // we don't need to deal with multiline regexps |
|
| 1363 | + $content = preg_replace("/[\r\n\t]/", "", $content); |
|
| 1364 | 1364 | |
| 1365 | - $match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content)); |
|
| 1366 | - break; |
|
| 1367 | - case "link": |
|
| 1368 | - $match = @preg_match("/$reg_exp/iu", $link); |
|
| 1369 | - break; |
|
| 1370 | - case "author": |
|
| 1371 | - $match = @preg_match("/$reg_exp/iu", $author); |
|
| 1372 | - break; |
|
| 1373 | - case "tag": |
|
| 1374 | - foreach ($tags as $tag) { |
|
| 1375 | - if (@preg_match("/$reg_exp/iu", $tag)) { |
|
| 1376 | - $match = true; |
|
| 1377 | - break; |
|
| 1378 | - } |
|
| 1365 | + $match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content)); |
|
| 1366 | + break; |
|
| 1367 | + case "link": |
|
| 1368 | + $match = @preg_match("/$reg_exp/iu", $link); |
|
| 1369 | + break; |
|
| 1370 | + case "author": |
|
| 1371 | + $match = @preg_match("/$reg_exp/iu", $author); |
|
| 1372 | + break; |
|
| 1373 | + case "tag": |
|
| 1374 | + foreach ($tags as $tag) { |
|
| 1375 | + if (@preg_match("/$reg_exp/iu", $tag)) { |
|
| 1376 | + $match = true; |
|
| 1377 | + break; |
|
| 1379 | 1378 | } |
| 1380 | - break; |
|
| 1379 | + } |
|
| 1380 | + break; |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | if ($rule_inverse) $match = !$match; |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | if ($k != "feed" && isset($v)) { |
| 8 | 8 | $x = strip_tags(is_array($v) ? implode(",", $v) : $v); |
| 9 | 9 | |
| 10 | - $tmp .= sha1("$k:" . sha1($x)); |
|
| 10 | + $tmp .= sha1("$k:".sha1($x)); |
|
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - return sha1(implode(",", $pluginhost->get_plugin_names()) . $tmp); |
|
| 14 | + return sha1(implode(",", $pluginhost->get_plugin_names()).$tmp); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Strips utf8mb4 characters (i.e. emoji) for mysql |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | //update_rss_feed($line["id"], true); |
| 138 | 138 | |
| 139 | 139 | if ($tline = $usth->fetch()) { |
| 140 | - Debug::log(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); |
|
| 140 | + Debug::log(" => ".$tline["last_updated"].", ".$tline["id"]." ".$tline["owner_uid"]); |
|
| 141 | 141 | |
| 142 | 142 | if (array_search($tline["owner_uid"], $batch_owners) === FALSE) |
| 143 | 143 | array_push($batch_owners, $tline["owner_uid"]); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $date_feed_processed = date('Y-m-d H:i'); |
| 325 | 325 | |
| 326 | - $cache_filename = CACHE_DIR . "/feeds/" . sha1($fetch_url) . ".xml"; |
|
| 326 | + $cache_filename = CACHE_DIR."/feeds/".sha1($fetch_url).".xml"; |
|
| 327 | 327 | |
| 328 | 328 | $pluginhost = new PluginHost(); |
| 329 | 329 | $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | Debug::log("running HOOK_FETCH_FEED handlers...", Debug::$LOG_VERBOSE); |
| 341 | 341 | |
| 342 | 342 | foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) { |
| 343 | - Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 343 | + Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 344 | 344 | $start = microtime(true); |
| 345 | 345 | $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, 0, $auth_login, $auth_pass); |
| 346 | 346 | Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $feed_data = trim($feed_data); |
| 403 | 403 | |
| 404 | 404 | Debug::log("fetch done.", Debug::$LOG_VERBOSE); |
| 405 | - Debug::log("source last modified: " . $fetch_last_modified, Debug::$LOG_VERBOSE); |
|
| 405 | + Debug::log("source last modified: ".$fetch_last_modified, Debug::$LOG_VERBOSE); |
|
| 406 | 406 | |
| 407 | 407 | if ($feed_data && $fetch_last_modified != $stored_last_modified) { |
| 408 | 408 | $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_modified = ? WHERE id = ?"); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // cache vanilla feed data for re-use |
| 413 | - if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/feeds")) { |
|
| 413 | + if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR."/feeds")) { |
|
| 414 | 414 | $new_rss_hash = sha1($feed_data); |
| 415 | 415 | |
| 416 | 416 | if ($new_rss_hash != $rss_hash) { |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | $feed_data_checksum = md5($feed_data); |
| 446 | 446 | |
| 447 | 447 | foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) { |
| 448 | - Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 448 | + Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 449 | 449 | $start = microtime(true); |
| 450 | 450 | $feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed); |
| 451 | 451 | Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | // We use local pluginhost here because we need to load different per-user feed plugins |
| 468 | 468 | |
| 469 | 469 | foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_PARSED) as $plugin) { |
| 470 | - Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 470 | + Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 471 | 471 | $start = microtime(true); |
| 472 | 472 | $plugin->hook_feed_parsed($rss); |
| 473 | 473 | Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE); |
@@ -499,14 +499,14 @@ discard block |
||
| 499 | 499 | $site_url = mb_substr(rewrite_relative_url($fetch_url, clean($rss->get_link())), 0, 245); |
| 500 | 500 | |
| 501 | 501 | Debug::log("site_url: $site_url", Debug::$LOG_VERBOSE); |
| 502 | - Debug::log("feed_title: " . clean($rss->get_title()), Debug::$LOG_VERBOSE); |
|
| 502 | + Debug::log("feed_title: ".clean($rss->get_title()), Debug::$LOG_VERBOSE); |
|
| 503 | 503 | |
| 504 | 504 | if ($favicon_needs_check || $force_refetch) { |
| 505 | 505 | |
| 506 | 506 | /* terrible hack: if we crash on floicon shit here, we won't check |
| 507 | 507 | * the icon avgcolor again (unless the icon got updated) */ |
| 508 | 508 | |
| 509 | - $favicon_file = ICONS_DIR . "/$feed.ico"; |
|
| 509 | + $favicon_file = ICONS_DIR."/$feed.ico"; |
|
| 510 | 510 | $favicon_modified = @filemtime($favicon_file); |
| 511 | 511 | |
| 512 | 512 | Debug::log("checking favicon...", Debug::$LOG_VERBOSE); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $favicon_color = calculate_avg_color($favicon_file); |
| 529 | 529 | |
| 530 | - $favicon_colorstring = ",favicon_avg_color = " . $pdo->quote($favicon_color); |
|
| 530 | + $favicon_colorstring = ",favicon_avg_color = ".$pdo->quote($favicon_color); |
|
| 531 | 531 | |
| 532 | 532 | } else if ($favicon_avg_color == 'fail') { |
| 533 | 533 | Debug::log("floicon failed on this file, not trying to recalculate avg color", Debug::$LOG_VERBOSE); |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | print_r($filters); |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - Debug::log("" . count($filters) . " filters loaded.", Debug::$LOG_VERBOSE); |
|
| 549 | + Debug::log("".count($filters)." filters loaded.", Debug::$LOG_VERBOSE); |
|
| 550 | 550 | |
| 551 | 551 | $items = $rss->get_items(); |
| 552 | 552 | |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | $entry_guid = "$owner_uid,$entry_guid"; |
| 590 | 590 | |
| 591 | - $entry_guid_hashed = 'SHA1:' . sha1($entry_guid); |
|
| 591 | + $entry_guid_hashed = 'SHA1:'.sha1($entry_guid); |
|
| 592 | 592 | |
| 593 | 593 | Debug::log("guid $entry_guid / $entry_guid_hashed", Debug::$LOG_VERBOSE); |
| 594 | 594 | |
| 595 | - $entry_timestamp = (int)$item->get_date(); |
|
| 595 | + $entry_timestamp = (int) $item->get_date(); |
|
| 596 | 596 | |
| 597 | - Debug::log("orig date: " . $item->get_date(), Debug::$LOG_VERBOSE); |
|
| 597 | + Debug::log("orig date: ".$item->get_date(), Debug::$LOG_VERBOSE); |
|
| 598 | 598 | |
| 599 | 599 | $entry_title = strip_tags($item->get_title()); |
| 600 | 600 | |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | Debug::log("link $entry_link", Debug::$LOG_VERBOSE); |
| 607 | 607 | Debug::log("language $entry_language", Debug::$LOG_VERBOSE); |
| 608 | 608 | |
| 609 | - if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);; |
|
| 609 | + if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp); ; |
|
| 610 | 610 | |
| 611 | 611 | $entry_content = $item->get_content(); |
| 612 | 612 | if (!$entry_content) $entry_content = $item->get_description(); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | Debug::log("looking for tags...", Debug::$LOG_VERBOSE); |
| 628 | 628 | |
| 629 | 629 | $entry_tags = $item->get_categories(); |
| 630 | - Debug::log("tags found: " . join(", ", $entry_tags), Debug::$LOG_VERBOSE); |
|
| 630 | + Debug::log("tags found: ".join(", ", $entry_tags), Debug::$LOG_VERBOSE); |
|
| 631 | 631 | |
| 632 | 632 | Debug::log("done collecting data.", Debug::$LOG_VERBOSE); |
| 633 | 633 | |
@@ -692,14 +692,14 @@ discard block |
||
| 692 | 692 | Debug::log("hash differs, applying plugin filters:", Debug::$LOG_VERBOSE); |
| 693 | 693 | |
| 694 | 694 | foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) { |
| 695 | - Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 695 | + Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE); |
|
| 696 | 696 | |
| 697 | 697 | $start = microtime(true); |
| 698 | 698 | $article = $plugin->hook_article_filter($article); |
| 699 | 699 | |
| 700 | 700 | Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE); |
| 701 | 701 | |
| 702 | - $entry_plugin_data .= mb_strtolower(get_class($plugin)) . ","; |
|
| 702 | + $entry_plugin_data .= mb_strtolower(get_class($plugin)).","; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | if (Debug::get_loglevel() >= 3) { |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | Debug::log("applying plugin filter actions...", Debug::$LOG_VERBOSE); |
| 773 | 773 | |
| 774 | 774 | foreach ($plugin_filter_names as $pfn) { |
| 775 | - list($pfclass,$pfaction) = explode(":", $pfn["param"]); |
|
| 775 | + list($pfclass, $pfaction) = explode(":", $pfn["param"]); |
|
| 776 | 776 | |
| 777 | 777 | if (isset($plugin_filter_actions[$pfclass])) { |
| 778 | 778 | $plugin = $pluginhost->get_plugin($pfclass); |
@@ -867,7 +867,7 @@ discard block |
||
| 867 | 867 | $entry_current_hash, |
| 868 | 868 | $date_feed_processed, |
| 869 | 869 | $entry_comments, |
| 870 | - (int)$num_comments, |
|
| 870 | + (int) $num_comments, |
|
| 871 | 871 | $entry_plugin_data, |
| 872 | 872 | "$entry_language", |
| 873 | 873 | "$entry_author"]); |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | ":content" => "$entry_content", |
| 980 | 980 | ":content_hash" => $entry_current_hash, |
| 981 | 981 | ":updated" => $entry_timestamp_fmt, |
| 982 | - ":num_comments" => (int)$num_comments, |
|
| 982 | + ":num_comments" => (int) $num_comments, |
|
| 983 | 983 | ":plugin_data" => $entry_plugin_data, |
| 984 | 984 | ":author" => "$entry_author", |
| 985 | 985 | ":lang" => $entry_language, |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | |
| 988 | 988 | if (DB_TYPE == "pgsql") { |
| 989 | 989 | $params[":ts_lang"] = $feed_language; |
| 990 | - $params[":ts_content"] = mb_substr(strip_tags($entry_title . " " . $entry_content), 0, 900000); |
|
| 990 | + $params[":ts_content"] = mb_substr(strip_tags($entry_title." ".$entry_content), 0, 900000); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | $sth->execute($params); |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | foreach ($enclosures as $enc) { |
| 1068 | 1068 | $enc_url = $enc[0]; |
| 1069 | 1069 | $enc_type = $enc[1]; |
| 1070 | - $enc_dur = (int)$enc[2]; |
|
| 1070 | + $enc_dur = (int) $enc[2]; |
|
| 1071 | 1071 | $enc_title = $enc[3]; |
| 1072 | 1072 | $enc_width = intval($enc[4]); |
| 1073 | 1073 | $enc_height = intval($enc[5]); |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | $esth->execute([$enc_url, $enc_type, $entry_ref_id]); |
| 1076 | 1076 | |
| 1077 | 1077 | if (!$esth->fetch()) { |
| 1078 | - $usth->execute([$enc_url, $enc_type, (string)$enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]); |
|
| 1078 | + $usth->execute([$enc_url, $enc_type, (string) $enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | } |
| 1081 | 1081 | |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | $filtered_tags = array_unique($filtered_tags); |
| 1110 | 1110 | |
| 1111 | 1111 | if (Debug::get_loglevel() >= Debug::$LOG_VERBOSE) { |
| 1112 | - Debug::log("filtered tags: " . implode(", ", $filtered_tags), Debug::$LOG_VERBOSE); |
|
| 1112 | + Debug::log("filtered tags: ".implode(", ", $filtered_tags), Debug::$LOG_VERBOSE); |
|
| 1113 | 1113 | |
| 1114 | 1114 | } |
| 1115 | 1115 | |
@@ -1297,11 +1297,11 @@ discard block |
||
| 1297 | 1297 | $num_deleted = 0; |
| 1298 | 1298 | |
| 1299 | 1299 | if (is_writable(LOCK_DIRECTORY)) { |
| 1300 | - $files = glob(LOCK_DIRECTORY . "/*.lock"); |
|
| 1300 | + $files = glob(LOCK_DIRECTORY."/*.lock"); |
|
| 1301 | 1301 | |
| 1302 | 1302 | if ($files) { |
| 1303 | 1303 | foreach ($files as $file) { |
| 1304 | - if (!file_is_locked(basename($file)) && time() - filemtime($file) > 86400*2) { |
|
| 1304 | + if (!file_is_locked(basename($file)) && time() - filemtime($file) > 86400 * 2) { |
|
| 1305 | 1305 | unlink($file); |
| 1306 | 1306 | ++$num_deleted; |
| 1307 | 1307 | } |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | static function check_feed_favicon($site_url, $feed) { |
| 1517 | 1517 | # print "FAVICON [$site_url]: $favicon_url\n"; |
| 1518 | 1518 | |
| 1519 | - $icon_file = ICONS_DIR . "/$feed.ico"; |
|
| 1519 | + $icon_file = ICONS_DIR."/$feed.ico"; |
|
| 1520 | 1520 | |
| 1521 | 1521 | if (!file_exists($icon_file)) { |
| 1522 | 1522 | $favicon_url = RSSUtils::get_favicon_url($site_url); |
@@ -1570,14 +1570,14 @@ discard block |
||
| 1570 | 1570 | |
| 1571 | 1571 | static function is_gzipped($feed_data) { |
| 1572 | 1572 | return strpos(substr($feed_data, 0, 3), |
| 1573 | - "\x1f" . "\x8b" . "\x08", 0) === 0; |
|
| 1573 | + "\x1f"."\x8b"."\x08", 0) === 0; |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | static function load_filters($feed_id, $owner_uid) { |
| 1577 | 1577 | $filters = array(); |
| 1578 | 1578 | |
| 1579 | 1579 | $feed_id = (int) $feed_id; |
| 1580 | - $cat_id = (int)Feeds::getFeedCategory($feed_id); |
|
| 1580 | + $cat_id = (int) Feeds::getFeedCategory($feed_id); |
|
| 1581 | 1581 | |
| 1582 | 1582 | if ($cat_id == 0) |
| 1583 | 1583 | $null_cat_qpart = "cat_id IS NULL OR"; |
@@ -80,7 +80,9 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | // Update the least recently updated feeds first |
| 82 | 82 | $query_order = "ORDER BY last_updated"; |
| 83 | - if (DB_TYPE == "pgsql") $query_order .= " NULLS FIRST"; |
|
| 83 | + if (DB_TYPE == "pgsql") { |
|
| 84 | + $query_order .= " NULLS FIRST"; |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | $query = "SELECT DISTINCT ttrss_feeds.feed_url, ttrss_feeds.last_updated |
| 86 | 88 | FROM |
@@ -139,8 +141,9 @@ discard block |
||
| 139 | 141 | if ($tline = $usth->fetch()) { |
| 140 | 142 | Debug::log(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); |
| 141 | 143 | |
| 142 | - if (array_search($tline["owner_uid"], $batch_owners) === FALSE) |
|
| 143 | - array_push($batch_owners, $tline["owner_uid"]); |
|
| 144 | + if (array_search($tline["owner_uid"], $batch_owners) === FALSE) { |
|
| 145 | + array_push($batch_owners, $tline["owner_uid"]); |
|
| 146 | + } |
|
| 144 | 147 | |
| 145 | 148 | $fstarted = microtime(true); |
| 146 | 149 | |
@@ -311,11 +314,13 @@ discard block |
||
| 311 | 314 | |
| 312 | 315 | $feed_language = mb_strtolower($row["feed_language"]); |
| 313 | 316 | |
| 314 | - if (!$feed_language) |
|
| 315 | - $feed_language = mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)); |
|
| 317 | + if (!$feed_language) { |
|
| 318 | + $feed_language = mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)); |
|
| 319 | + } |
|
| 316 | 320 | |
| 317 | - if (!$feed_language) |
|
| 318 | - $feed_language = 'simple'; |
|
| 321 | + if (!$feed_language) { |
|
| 322 | + $feed_language = 'simple'; |
|
| 323 | + } |
|
| 319 | 324 | |
| 320 | 325 | } else { |
| 321 | 326 | return false; |
@@ -514,8 +519,9 @@ discard block |
||
| 514 | 519 | RSSUtils::check_feed_favicon($site_url, $feed); |
| 515 | 520 | $favicon_modified_new = @filemtime($favicon_file); |
| 516 | 521 | |
| 517 | - if ($favicon_modified_new > $favicon_modified) |
|
| 518 | - $favicon_avg_color = ''; |
|
| 522 | + if ($favicon_modified_new > $favicon_modified) { |
|
| 523 | + $favicon_avg_color = ''; |
|
| 524 | + } |
|
| 519 | 525 | |
| 520 | 526 | $favicon_colorstring = ""; |
| 521 | 527 | if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color == '') { |
@@ -578,8 +584,12 @@ discard block |
||
| 578 | 584 | } |
| 579 | 585 | |
| 580 | 586 | $entry_guid = strip_tags($item->get_id()); |
| 581 | - if (!$entry_guid) $entry_guid = strip_tags($item->get_link()); |
|
| 582 | - if (!$entry_guid) $entry_guid = RSSUtils::make_guid_from_title($item->get_title()); |
|
| 587 | + if (!$entry_guid) { |
|
| 588 | + $entry_guid = strip_tags($item->get_link()); |
|
| 589 | + } |
|
| 590 | + if (!$entry_guid) { |
|
| 591 | + $entry_guid = RSSUtils::make_guid_from_title($item->get_title()); |
|
| 592 | + } |
|
| 583 | 593 | |
| 584 | 594 | if (!$entry_guid) { |
| 585 | 595 | $pdo->commit(); |
@@ -606,10 +616,15 @@ discard block |
||
| 606 | 616 | Debug::log("link $entry_link", Debug::$LOG_VERBOSE); |
| 607 | 617 | Debug::log("language $entry_language", Debug::$LOG_VERBOSE); |
| 608 | 618 | |
| 609 | - if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);; |
|
| 619 | + if (!$entry_title) { |
|
| 620 | + $entry_title = date("Y-m-d H:i:s", $entry_timestamp); |
|
| 621 | + } |
|
| 622 | + ; |
|
| 610 | 623 | |
| 611 | 624 | $entry_content = $item->get_content(); |
| 612 | - if (!$entry_content) $entry_content = $item->get_description(); |
|
| 625 | + if (!$entry_content) { |
|
| 626 | + $entry_content = $item->get_description(); |
|
| 627 | + } |
|
| 613 | 628 | |
| 614 | 629 | if (Debug::get_loglevel() >= 3) { |
| 615 | 630 | print "content: "; |
@@ -824,8 +839,9 @@ discard block |
||
| 824 | 839 | |
| 825 | 840 | Debug::log("force catchup: $entry_force_catchup", Debug::$LOG_VERBOSE); |
| 826 | 841 | |
| 827 | - if ($cache_images) |
|
| 828 | - RSSUtils::cache_media($entry_content, $site_url); |
|
| 842 | + if ($cache_images) { |
|
| 843 | + RSSUtils::cache_media($entry_content, $site_url); |
|
| 844 | + } |
|
| 829 | 845 | |
| 830 | 846 | $csth = $pdo->prepare("SELECT id FROM ttrss_entries |
| 831 | 847 | WHERE guid = ? OR guid = ?"); |
@@ -951,16 +967,18 @@ discard block |
||
| 951 | 967 | |
| 952 | 968 | $sth->execute([$ref_id, $owner_uid, $feed]); |
| 953 | 969 | |
| 954 | - if ($row = $sth->fetch()) |
|
| 955 | - $entry_int_id = $row['int_id']; |
|
| 970 | + if ($row = $sth->fetch()) { |
|
| 971 | + $entry_int_id = $row['int_id']; |
|
| 972 | + } |
|
| 956 | 973 | } |
| 957 | 974 | |
| 958 | 975 | Debug::log("resulting RID: $entry_ref_id, IID: $entry_int_id", Debug::$LOG_VERBOSE); |
| 959 | 976 | |
| 960 | - if (DB_TYPE == "pgsql") |
|
| 961 | - $tsvector_qpart = "tsvector_combined = to_tsvector(:ts_lang, :ts_content),"; |
|
| 962 | - else |
|
| 963 | - $tsvector_qpart = ""; |
|
| 977 | + if (DB_TYPE == "pgsql") { |
|
| 978 | + $tsvector_qpart = "tsvector_combined = to_tsvector(:ts_lang, :ts_content),"; |
|
| 979 | + } else { |
|
| 980 | + $tsvector_qpart = ""; |
|
| 981 | + } |
|
| 964 | 982 | |
| 965 | 983 | $sth = $pdo->prepare("UPDATE ttrss_entries |
| 966 | 984 | SET title = :title, |
@@ -1049,8 +1067,9 @@ discard block |
||
| 1049 | 1067 | } |
| 1050 | 1068 | } |
| 1051 | 1069 | |
| 1052 | - if ($cache_images) |
|
| 1053 | - RSSUtils::cache_enclosures($enclosures, $site_url); |
|
| 1070 | + if ($cache_images) { |
|
| 1071 | + RSSUtils::cache_enclosures($enclosures, $site_url); |
|
| 1072 | + } |
|
| 1054 | 1073 | |
| 1055 | 1074 | if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) { |
| 1056 | 1075 | Debug::log("article enclosures:", Debug::$LOG_VERBOSE); |
@@ -1345,8 +1364,9 @@ discard block |
||
| 1345 | 1364 | $reg_exp = str_replace('/', '\/', $rule["reg_exp"]); |
| 1346 | 1365 | $rule_inverse = $rule["inverse"]; |
| 1347 | 1366 | |
| 1348 | - if (!$reg_exp) |
|
| 1349 | - continue; |
|
| 1367 | + if (!$reg_exp) { |
|
| 1368 | + continue; |
|
| 1369 | + } |
|
| 1350 | 1370 | |
| 1351 | 1371 | switch ($rule["type"]) { |
| 1352 | 1372 | case "title": |
@@ -1380,7 +1400,9 @@ discard block |
||
| 1380 | 1400 | break; |
| 1381 | 1401 | } |
| 1382 | 1402 | |
| 1383 | - if ($rule_inverse) $match = !$match; |
|
| 1403 | + if ($rule_inverse) { |
|
| 1404 | + $match = !$match; |
|
| 1405 | + } |
|
| 1384 | 1406 | |
| 1385 | 1407 | if ($match_any_rule) { |
| 1386 | 1408 | if ($match) { |
@@ -1395,17 +1417,25 @@ discard block |
||
| 1395 | 1417 | } |
| 1396 | 1418 | } |
| 1397 | 1419 | |
| 1398 | - if ($inverse) $filter_match = !$filter_match; |
|
| 1420 | + if ($inverse) { |
|
| 1421 | + $filter_match = !$filter_match; |
|
| 1422 | + } |
|
| 1399 | 1423 | |
| 1400 | 1424 | if ($filter_match) { |
| 1401 | - if (is_array($matched_rules)) array_push($matched_rules, $rule); |
|
| 1402 | - if (is_array($matched_filters)) array_push($matched_filters, $filter); |
|
| 1425 | + if (is_array($matched_rules)) { |
|
| 1426 | + array_push($matched_rules, $rule); |
|
| 1427 | + } |
|
| 1428 | + if (is_array($matched_filters)) { |
|
| 1429 | + array_push($matched_filters, $filter); |
|
| 1430 | + } |
|
| 1403 | 1431 | |
| 1404 | 1432 | foreach ($filter["actions"] AS $action) { |
| 1405 | 1433 | array_push($matches, $action); |
| 1406 | 1434 | |
| 1407 | 1435 | // if Stop action encountered, perform no further processing |
| 1408 | - if (isset($action["type"]) && $action["type"] == "stop") return $matches; |
|
| 1436 | + if (isset($action["type"]) && $action["type"] == "stop") { |
|
| 1437 | + return $matches; |
|
| 1438 | + } |
|
| 1409 | 1439 | } |
| 1410 | 1440 | } |
| 1411 | 1441 | } |
@@ -1531,24 +1561,19 @@ discard block |
||
| 1531 | 1561 | if (preg_match('/^\x00\x00\x01\x00/', $contents)) { |
| 1532 | 1562 | // 0 string \000\000\001\000 MS Windows icon resource |
| 1533 | 1563 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa MS Windows icon resource"); |
| 1534 | - } |
|
| 1535 | - elseif (preg_match('/^GIF8/', $contents)) { |
|
| 1564 | + } elseif (preg_match('/^GIF8/', $contents)) { |
|
| 1536 | 1565 | // 0 string GIF8 GIF image data |
| 1537 | 1566 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa GIF image"); |
| 1538 | - } |
|
| 1539 | - elseif (preg_match('/^\x89PNG\x0d\x0a\x1a\x0a/', $contents)) { |
|
| 1567 | + } elseif (preg_match('/^\x89PNG\x0d\x0a\x1a\x0a/', $contents)) { |
|
| 1540 | 1568 | // 0 string \x89PNG\x0d\x0a\x1a\x0a PNG image data |
| 1541 | 1569 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa PNG image"); |
| 1542 | - } |
|
| 1543 | - elseif (preg_match('/^\xff\xd8/', $contents)) { |
|
| 1570 | + } elseif (preg_match('/^\xff\xd8/', $contents)) { |
|
| 1544 | 1571 | // 0 beshort 0xffd8 JPEG image data |
| 1545 | 1572 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa JPG image"); |
| 1546 | - } |
|
| 1547 | - elseif (preg_match('/^BM/', $contents)) { |
|
| 1573 | + } elseif (preg_match('/^BM/', $contents)) { |
|
| 1548 | 1574 | // 0 string BM PC bitmap (OS2, Windows BMP files) |
| 1549 | 1575 | //error_log("check_feed_favicon, favicon_url=$favicon_url isa BMP image"); |
| 1550 | - } |
|
| 1551 | - else { |
|
| 1576 | + } else { |
|
| 1552 | 1577 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa UNKNOWN type"); |
| 1553 | 1578 | $contents = ""; |
| 1554 | 1579 | } |
@@ -1579,10 +1604,11 @@ discard block |
||
| 1579 | 1604 | $feed_id = (int) $feed_id; |
| 1580 | 1605 | $cat_id = (int)Feeds::getFeedCategory($feed_id); |
| 1581 | 1606 | |
| 1582 | - if ($cat_id == 0) |
|
| 1583 | - $null_cat_qpart = "cat_id IS NULL OR"; |
|
| 1584 | - else |
|
| 1585 | - $null_cat_qpart = ""; |
|
| 1607 | + if ($cat_id == 0) { |
|
| 1608 | + $null_cat_qpart = "cat_id IS NULL OR"; |
|
| 1609 | + } else { |
|
| 1610 | + $null_cat_qpart = ""; |
|
| 1611 | + } |
|
| 1586 | 1612 | |
| 1587 | 1613 | $pdo = Db::pdo(); |
| 1588 | 1614 | |
@@ -1718,8 +1744,9 @@ discard block |
||
| 1718 | 1744 | } |
| 1719 | 1745 | } |
| 1720 | 1746 | |
| 1721 | - if (!$favicon_url) |
|
| 1722 | - $favicon_url = rewrite_relative_url($url, "/favicon.ico"); |
|
| 1747 | + if (!$favicon_url) { |
|
| 1748 | + $favicon_url = rewrite_relative_url($url, "/favicon.ico"); |
|
| 1749 | + } |
|
| 1723 | 1750 | |
| 1724 | 1751 | return $favicon_url; |
| 1725 | 1752 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | time() - $preferred_ts <= 7200 |
| 38 | 38 | ) { |
| 39 | 39 | |
| 40 | - Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); |
|
| 40 | + Debug::log("Sending digest for UID:".$line['id']." - ".$line["email"]); |
|
| 41 | 41 | |
| 42 | 42 | $do_catchup = get_pref('DIGEST_CATCHUP', $line['id'], false); |
| 43 | 43 | |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $sth = $pdo->prepare("SELECT ttrss_entries.title, |
| 125 | 125 | ttrss_feeds.title AS feed_title, |
| 126 | - COALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS cat_title, |
|
| 126 | + COALESCE(ttrss_feed_categories.title, '" . __('Uncategorized')."') AS cat_title, |
|
| 127 | 127 | date_updated, |
| 128 | 128 | ttrss_user_entries.ref_id, |
| 129 | 129 | link, |
| 130 | 130 | score, |
| 131 | 131 | content, |
| 132 | - " . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated |
|
| 132 | + " . SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 133 | 133 | FROM |
| 134 | 134 | ttrss_user_entries,ttrss_entries,ttrss_feeds |
| 135 | 135 | LEFT JOIN |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $user_id); |
| 166 | 166 | |
| 167 | 167 | if (get_pref('ENABLE_FEED_CATS', $user_id)) { |
| 168 | - $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title']; |
|
| 168 | + $line['feed_title'] = $line['cat_title']." / ".$line['feed_title']; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $article_labels = Article::get_article_labels($line["ref_id"], $user_id); |