@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | // 1) templates/register_notice.txt - displayed above the registration form |
| 5 | 5 | // 2) register_expire_do.php - contains user expiration queries when necessary |
| 6 | 6 | |
| 7 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
| 7 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
| 8 | 8 | get_include_path()); |
| 9 | 9 | |
| 10 | 10 | require_once "autoload.php"; |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | print '<?xml version="1.0" encoding="utf-8"?>'; |
| 27 | 27 | print "<feed xmlns=\"http://www.w3.org/2005/Atom\"> |
| 28 | - <id>".htmlspecialchars(SELF_URL_PATH . "/register.php")."</id> |
|
| 28 | + <id>".htmlspecialchars(SELF_URL_PATH."/register.php")."</id> |
|
| 29 | 29 | <title>Tiny Tiny RSS registration slots</title> |
| 30 | - <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php?format=feed")."\"/> |
|
| 30 | + <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH."/register.php?format=feed")."\"/> |
|
| 31 | 31 | <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH)."\"/>"; |
| 32 | 32 | |
| 33 | 33 | if (ENABLE_REGISTRATION) { |
| 34 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
| 34 | + $result = db_query("SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
| 35 | 35 | $num_users = db_fetch_result($result, 0, "cu"); |
| 36 | 36 | |
| 37 | 37 | $num_users = REG_MAX_USERS - $num_users; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | print "<entry> |
| 46 | 46 | <id>".htmlspecialchars(SELF_URL_PATH)."/register.php?$num_users"."</id> |
| 47 | - <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php")."\"/>"; |
|
| 47 | + <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH."/register.php")."\"/>"; |
|
| 48 | 48 | |
| 49 | 49 | print "<title>$num_users slots are currently available, registration $reg_suffix</title>"; |
| 50 | 50 | print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>"; |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | /* Remove users which didn't login after receiving their registration information */ |
| 60 | 60 | |
| 61 | 61 | if (DB_TYPE == "pgsql") { |
| 62 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
| 62 | + db_query("DELETE FROM ttrss_users WHERE last_login IS NULL |
|
| 63 | 63 | AND created < NOW() - INTERVAL '1 day' AND access_level = 0"); |
| 64 | 64 | } else { |
| 65 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
| 65 | + db_query("DELETE FROM ttrss_users WHERE last_login IS NULL |
|
| 66 | 66 | AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0"); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | if ($action == "check") { |
| 74 | 74 | header("Content-Type: application/xml"); |
| 75 | 75 | |
| 76 | - $login = trim(db_escape_string( $_REQUEST['login'])); |
|
| 76 | + $login = trim(db_escape_string($_REQUEST['login'])); |
|
| 77 | 77 | |
| 78 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
| 78 | + $result = db_query("SELECT id FROM ttrss_users WHERE |
|
| 79 | 79 | LOWER(login) = LOWER('$login')"); |
| 80 | 80 | |
| 81 | 81 | $is_registered = db_num_rows($result) > 0; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | ?> |
| 198 | 198 | |
| 199 | 199 | <?php if (REG_MAX_USERS > 0) { |
| 200 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
| 200 | + $result = db_query("SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
| 201 | 201 | $num_users = db_fetch_result($result, 0, "cu"); |
| 202 | 202 | } ?> |
| 203 | 203 | |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | <?php } else if ($action == "do_register") { ?> |
| 242 | 242 | |
| 243 | 243 | <?php |
| 244 | - $login = mb_strtolower(trim(db_escape_string( $_REQUEST["login"]))); |
|
| 245 | - $email = trim(db_escape_string( $_REQUEST["email"])); |
|
| 246 | - $test = trim(db_escape_string( $_REQUEST["turing_test"])); |
|
| 244 | + $login = mb_strtolower(trim(db_escape_string($_REQUEST["login"]))); |
|
| 245 | + $email = trim(db_escape_string($_REQUEST["email"])); |
|
| 246 | + $test = trim(db_escape_string($_REQUEST["turing_test"])); |
|
| 247 | 247 | |
| 248 | 248 | if (!$login || !$email || !$test) { |
| 249 | 249 | print_error(__("Your registration information is incomplete.")); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | if ($test == "four" || $test == "4") { |
| 257 | 257 | |
| 258 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
| 258 | + $result = db_query("SELECT id FROM ttrss_users WHERE |
|
| 259 | 259 | login = '$login'"); |
| 260 | 260 | |
| 261 | 261 | $is_registered = db_num_rows($result) > 0; |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
| 273 | 273 | $pwd_hash = encrypt_password($password, $salt, true); |
| 274 | 274 | |
| 275 | - db_query( "INSERT INTO ttrss_users |
|
| 275 | + db_query("INSERT INTO ttrss_users |
|
| 276 | 276 | (login,pwd_hash,access_level,last_login, email, created, salt) |
| 277 | 277 | VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW(), '$salt')"); |
| 278 | 278 | |
| 279 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
| 279 | + $result = db_query("SELECT id FROM ttrss_users WHERE |
|
| 280 | 280 | login = '$login' AND pwd_hash = '$pwd_hash'"); |
| 281 | 281 | |
| 282 | 282 | if (db_num_rows($result) != 1) { |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | $new_uid = db_fetch_result($result, 0, "id"); |
| 290 | 290 | |
| 291 | - initialize_user( $new_uid); |
|
| 291 | + initialize_user($new_uid); |
|
| 292 | 292 | |
| 293 | 293 | $reg_text = "Hi!\n". |
| 294 | 294 | "\n". |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $action = $_REQUEST["action"]; |
| 20 | 20 | |
| 21 | - if (!init_plugins()) return; |
|
| 21 | + if (!init_plugins()) { |
|
| 22 | + return; |
|
| 23 | + } |
|
| 22 | 24 | |
| 23 | 25 | if ($_REQUEST["format"] == "feed") { |
| 24 | 26 | header("Content-Type: text/xml"); |
@@ -35,7 +37,9 @@ discard block |
||
| 35 | 37 | $num_users = db_fetch_result($result, 0, "cu"); |
| 36 | 38 | |
| 37 | 39 | $num_users = REG_MAX_USERS - $num_users; |
| 38 | - if ($num_users < 0) $num_users = 0; |
|
| 40 | + if ($num_users < 0) { |
|
| 41 | + $num_users = 0; |
|
| 42 | + } |
|
| 39 | 43 | $reg_suffix = "enabled"; |
| 40 | 44 | } else { |
| 41 | 45 | $num_users = 0; |
@@ -310,7 +314,9 @@ discard block |
||
| 310 | 314 | "subject" => "Registration information for Tiny Tiny RSS", |
| 311 | 315 | "message" => $reg_text]); |
| 312 | 316 | |
| 313 | - if (!$rc) print_error($mailer->error()); |
|
| 317 | + if (!$rc) { |
|
| 318 | + print_error($mailer->error()); |
|
| 319 | + } |
|
| 314 | 320 | |
| 315 | 321 | $reg_text = "Hi!\n". |
| 316 | 322 | "\n". |
@@ -324,7 +330,9 @@ discard block |
||
| 324 | 330 | "subject" => "Registration notice for Tiny Tiny RSS", |
| 325 | 331 | "message" => $reg_text]); |
| 326 | 332 | |
| 327 | - if (!$rc) print_error($mailer->error()); |
|
| 333 | + if (!$rc) { |
|
| 334 | + print_error($mailer->error()); |
|
| 335 | + } |
|
| 328 | 336 | |
| 329 | 337 | print_notice(__("Account created successfully.")); |
| 330 | 338 | |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | require_once "../config.php"; |
| 5 | 5 | |
| 6 | - set_include_path(dirname(__FILE__) . PATH_SEPARATOR . |
|
| 7 | - dirname(dirname(__FILE__)) . PATH_SEPARATOR . |
|
| 8 | - dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR . |
|
| 6 | + set_include_path(dirname(__FILE__).PATH_SEPARATOR. |
|
| 7 | + dirname(dirname(__FILE__)).PATH_SEPARATOR. |
|
| 8 | + dirname(dirname(__FILE__))."/include".PATH_SEPARATOR. |
|
| 9 | 9 | get_include_path()); |
| 10 | 10 | |
| 11 | 11 | chdir(".."); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - load_user_plugins( $_SESSION["uid"]); |
|
| 70 | + load_user_plugins($_SESSION["uid"]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $method = strtolower($_REQUEST["op"]); |
@@ -83,6 +83,6 @@ discard block |
||
| 83 | 83 | $handler->after(); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - header("Api-Content-Length: " . ob_get_length()); |
|
| 86 | + header("Api-Content-Length: ".ob_get_length()); |
|
| 87 | 87 | |
| 88 | 88 | ob_end_flush(); |
@@ -37,7 +37,9 @@ discard block |
||
| 37 | 37 | // fallback on HTTP parameters |
| 38 | 38 | if ($input) { |
| 39 | 39 | $input = json_decode($input, true); |
| 40 | - if ($input) $_REQUEST = $input; |
|
| 40 | + if ($input) { |
|
| 41 | + $_REQUEST = $input; |
|
| 42 | + } |
|
| 41 | 43 | } |
| 42 | 44 | } else { |
| 43 | 45 | // Accept JSON only |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | startup_gettext(); |
| 56 | 58 | |
| 57 | - if (!init_plugins()) return; |
|
| 59 | + if (!init_plugins()) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | if ($_SESSION["uid"]) { |
| 60 | 64 | if (!validate_session()) { |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | Debug::set_enabled(true); |
| 166 | 166 | |
| 167 | 167 | if (isset($options["log-level"])) { |
| 168 | - Debug::set_loglevel((int)$options["log-level"]); |
|
| 169 | - } |
|
| 168 | + Debug::set_loglevel((int)$options["log-level"]); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | if (isset($options["log"])) { |
| 172 | 172 | Debug::set_quiet(isset($options['quiet'])); |
| 173 | 173 | Debug::set_logfile($options["log"]); |
| 174 | - Debug::log("Logging to " . $options["log"]); |
|
| 175 | - } else { |
|
| 176 | - if (isset($options['quiet'])) { |
|
| 174 | + Debug::log("Logging to " . $options["log"]); |
|
| 175 | + } else { |
|
| 176 | + if (isset($options['quiet'])) { |
|
| 177 | 177 | Debug::set_loglevel(Debug::$LOG_DISABLED); |
| 178 | - } |
|
| 179 | - } |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | 181 | if (!isset($options["daemon"])) { |
| 182 | 182 | $lock_filename = "update.lock"; |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | if (isset($options["daemon"])) { |
| 230 | 230 | while (true) { |
| 231 | 231 | $quiet = (isset($options["quiet"])) ? "--quiet" : ""; |
| 232 | - $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
|
| 233 | - $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
|
| 232 | + $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
|
| 233 | + $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
|
| 234 | 234 | |
| 235 | 235 | passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
| 236 | 236 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | #!/usr/bin/env php |
| 2 | 2 | <?php |
| 3 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
| 3 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
| 4 | 4 | get_include_path()); |
| 5 | 5 | |
| 6 | 6 | define('DISABLE_SESSIONS', true); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | "help"); |
| 89 | 89 | |
| 90 | 90 | foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
| 91 | - array_push($longopts, $command . $data["suffix"]); |
|
| 91 | + array_push($longopts, $command.$data["suffix"]); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $options = getopt("", $longopts); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | exit; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if (count($options) == 0 || isset($options["help"]) ) { |
|
| 122 | + if (count($options) == 0 || isset($options["help"])) { |
|
| 123 | 123 | print "Tiny Tiny RSS data update script.\n\n"; |
| 124 | 124 | print "Options:\n"; |
| 125 | 125 | print " --feeds - update feeds\n"; |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | Debug::set_enabled(true); |
| 166 | 166 | |
| 167 | 167 | if (isset($options["log-level"])) { |
| 168 | - Debug::set_loglevel((int)$options["log-level"]); |
|
| 168 | + Debug::set_loglevel((int) $options["log-level"]); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if (isset($options["log"])) { |
| 172 | 172 | Debug::set_quiet(isset($options['quiet'])); |
| 173 | 173 | Debug::set_logfile($options["log"]); |
| 174 | - Debug::log("Logging to " . $options["log"]); |
|
| 174 | + Debug::log("Logging to ".$options["log"]); |
|
| 175 | 175 | } else { |
| 176 | 176 | if (isset($options['quiet'])) { |
| 177 | 177 | Debug::set_loglevel(Debug::$LOG_DISABLED); |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | if (isset($options["task"])) { |
| 188 | - Debug::log("Using task id " . $options["task"]); |
|
| 189 | - $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
| 188 | + Debug::log("Using task id ".$options["task"]); |
|
| 189 | + $lock_filename = $lock_filename."-task_".$options["task"]; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if (isset($options["pidlock"])) { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | if (isset($options["force-update"])) { |
| 216 | 216 | Debug::log("marking all feeds as needing update..."); |
| 217 | 217 | |
| 218 | - $pdo->query( "UPDATE ttrss_feeds SET |
|
| 218 | + $pdo->query("UPDATE ttrss_feeds SET |
|
| 219 | 219 | last_update_started = '1970-01-01', last_updated = '1970-01-01'"); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
| 233 | 233 | $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
| 234 | 234 | |
| 235 | - passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
| 235 | + passthru(PHP_EXECUTABLE." ".$argv[0]." --daemon-loop $quiet $log $log_level"); |
|
| 236 | 236 | |
| 237 | 237 | // let's enforce a minimum spawn interval as to not forkbomb the host |
| 238 | 238 | $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | if (isset($options["cleanup-tags"])) { |
| 259 | - $rc = cleanup_tags( 14, 50000); |
|
| 259 | + $rc = cleanup_tags(14, 50000); |
|
| 260 | 260 | Debug::log("$rc tags deleted.\n"); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -270,18 +270,18 @@ discard block |
||
| 270 | 270 | Debug::log("clearing existing indexes..."); |
| 271 | 271 | |
| 272 | 272 | if (DB_TYPE == "pgsql") { |
| 273 | - $sth = $pdo->query( "SELECT relname FROM |
|
| 273 | + $sth = $pdo->query("SELECT relname FROM |
|
| 274 | 274 | pg_catalog.pg_class WHERE relname LIKE 'ttrss_%' |
| 275 | 275 | AND relname NOT LIKE '%_pkey' |
| 276 | 276 | AND relkind = 'i'"); |
| 277 | 277 | } else { |
| 278 | - $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
| 278 | + $sth = $pdo->query("SELECT index_name,table_name FROM |
|
| 279 | 279 | information_schema.statistics WHERE index_name LIKE 'ttrss_%'"); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | while ($line = $sth->fetch()) { |
| 283 | 283 | if (DB_TYPE == "pgsql") { |
| 284 | - $statement = "DROP INDEX " . $line["relname"]; |
|
| 284 | + $statement = "DROP INDEX ".$line["relname"]; |
|
| 285 | 285 | Debug::log($statement); |
| 286 | 286 | } else { |
| 287 | 287 | $statement = "ALTER TABLE ". |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | $pdo->query($statement); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
| 294 | + Debug::log("reading indexes from schema for: ".DB_TYPE); |
|
| 295 | 295 | |
| 296 | - $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
| 296 | + $fp = fopen("schema/ttrss_schema_".DB_TYPE.".sql", "r"); |
|
| 297 | 297 | if ($fp) { |
| 298 | 298 | while ($line = fgets($fp)) { |
| 299 | 299 | $matches = array(); |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | $filter = array(); |
| 337 | 337 | |
| 338 | 338 | if (sql_bool_to_bool($line["cat_filter"])) { |
| 339 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
| 339 | + $feed_id = "CAT:".(int) $line["cat_id"]; |
|
| 340 | 340 | } else { |
| 341 | - $feed_id = (int)$line["feed_id"]; |
|
| 341 | + $feed_id = (int) $line["feed_id"]; |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (isset($options["update-schema"])) { |
| 370 | - Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
| 370 | + Debug::log("Checking for updates (".DB_TYPE.")..."); |
|
| 371 | 371 | |
| 372 | 372 | $updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION); |
| 373 | 373 | |
| 374 | 374 | if ($updater->isUpdateRequired()) { |
| 375 | - Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
| 375 | + Debug::log("Schema update required, version ".$updater->getSchemaVersion()." to ".SCHEMA_VERSION); |
|
| 376 | 376 | |
| 377 | 377 | if (DB_TYPE == "mysql") |
| 378 | 378 | Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | if (read_stdin() != 'yes') |
| 386 | 386 | exit; |
| 387 | 387 | |
| 388 | - Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
| 388 | + Debug::log("Performing updates to version ".SCHEMA_VERSION); |
|
| 389 | 389 | |
| 390 | 390 | for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
| 391 | 391 | Debug::log("* Updating to version $i..."); |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | while (true) { |
| 429 | 429 | |
| 430 | 430 | while ($line = $sth->fetch()) { |
| 431 | - $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
| 431 | + $tsvector_combined = mb_substr(strip_tags($line["title"]." ".$line["content"]), 0, 1000000); |
|
| 432 | 432 | |
| 433 | 433 | $usth->execute([$tsvector_combined, $line['id']]); |
| 434 | 434 | |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | |
| 486 | 486 | PluginHost::getInstance()->run_commands($options); |
| 487 | 487 | |
| 488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
| 488 | + if (file_exists(LOCK_DIRECTORY."/$lock_filename")) |
|
| 489 | 489 | if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
| 490 | 490 | fclose($lock_handle); |
| 491 | - unlink(LOCK_DIRECTORY . "/$lock_filename"); |
|
| 491 | + unlink(LOCK_DIRECTORY."/$lock_filename"); |
|
@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | return $tags_deleted; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if (!defined('PHP_EXECUTABLE')) |
|
| 63 | - define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
| 62 | + if (!defined('PHP_EXECUTABLE')) { |
|
| 63 | + define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
| 64 | + } |
|
| 64 | 65 | |
| 65 | 66 | $pdo = Db::pdo(); |
| 66 | 67 | |
@@ -249,8 +250,9 @@ discard block |
||
| 249 | 250 | |
| 250 | 251 | RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
| 251 | 252 | |
| 252 | - if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
| 253 | - RSSUtils::housekeeping_common(true); |
|
| 253 | + if (!isset($options["pidlock"]) || $options["task"] == 0) { |
|
| 254 | + RSSUtils::housekeeping_common(true); |
|
| 255 | + } |
|
| 254 | 256 | |
| 255 | 257 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
| 256 | 258 | } |
@@ -264,8 +266,9 @@ discard block |
||
| 264 | 266 | Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
| 265 | 267 | Debug::log("Type 'yes' to continue."); |
| 266 | 268 | |
| 267 | - if (read_stdin() != 'yes') |
|
| 268 | - exit; |
|
| 269 | + if (read_stdin() != 'yes') { |
|
| 270 | + exit; |
|
| 271 | + } |
|
| 269 | 272 | |
| 270 | 273 | Debug::log("clearing existing indexes..."); |
| 271 | 274 | |
@@ -319,8 +322,9 @@ discard block |
||
| 319 | 322 | Debug::log("WARNING: this will remove all existing type2 filters."); |
| 320 | 323 | Debug::log("Type 'yes' to continue."); |
| 321 | 324 | |
| 322 | - if (read_stdin() != 'yes') |
|
| 323 | - exit; |
|
| 325 | + if (read_stdin() != 'yes') { |
|
| 326 | + exit; |
|
| 327 | + } |
|
| 324 | 328 | |
| 325 | 329 | Debug::log("converting filters..."); |
| 326 | 330 | |
@@ -374,16 +378,18 @@ discard block |
||
| 374 | 378 | if ($updater->isUpdateRequired()) { |
| 375 | 379 | Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
| 376 | 380 | |
| 377 | - if (DB_TYPE == "mysql") |
|
| 378 | - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
| 381 | + if (DB_TYPE == "mysql") { |
|
| 382 | + Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
| 379 | 383 | "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
| 380 | - else |
|
| 381 | - Debug::log("WARNING: please backup your database before continuing."); |
|
| 384 | + } else { |
|
| 385 | + Debug::log("WARNING: please backup your database before continuing."); |
|
| 386 | + } |
|
| 382 | 387 | |
| 383 | 388 | Debug::log("Type 'yes' to continue."); |
| 384 | 389 | |
| 385 | - if (read_stdin() != 'yes') |
|
| 386 | - exit; |
|
| 390 | + if (read_stdin() != 'yes') { |
|
| 391 | + exit; |
|
| 392 | + } |
|
| 387 | 393 | |
| 388 | 394 | Debug::log("Performing updates to version " . SCHEMA_VERSION); |
| 389 | 395 | |
@@ -456,7 +462,9 @@ discard block |
||
| 456 | 462 | |
| 457 | 463 | $status = $about[3] ? "system" : "user"; |
| 458 | 464 | |
| 459 | - if (in_array($name, $enabled)) $name .= "*"; |
|
| 465 | + if (in_array($name, $enabled)) { |
|
| 466 | + $name .= "*"; |
|
| 467 | + } |
|
| 460 | 468 | |
| 461 | 469 | printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
| 462 | 470 | $name, $status, $about[0], $about[2], $about[1]); |
@@ -469,8 +477,12 @@ discard block |
||
| 469 | 477 | if (isset($options["debug-feed"])) { |
| 470 | 478 | $feed = $options["debug-feed"]; |
| 471 | 479 | |
| 472 | - if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
| 473 | - if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
| 480 | + if (isset($options["force-refetch"])) { |
|
| 481 | + $_REQUEST["force_refetch"] = true; |
|
| 482 | + } |
|
| 483 | + if (isset($options["force-rehash"])) { |
|
| 484 | + $_REQUEST["force_rehash"] = true; |
|
| 485 | + } |
|
| 474 | 486 | |
| 475 | 487 | Debug::set_loglevel(Debug::$LOG_EXTENDED); |
| 476 | 488 | |
@@ -485,7 +497,8 @@ discard block |
||
| 485 | 497 | |
| 486 | 498 | PluginHost::getInstance()->run_commands($options); |
| 487 | 499 | |
| 488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
| 489 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 500 | + if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) { |
|
| 501 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 490 | 502 | fclose($lock_handle); |
| 503 | + } |
|
| 491 | 504 | unlink(LOCK_DIRECTORY . "/$lock_filename"); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
| 2 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
| 3 | 3 | get_include_path()); |
| 4 | 4 | |
| 5 | 5 | $op = $_REQUEST["op"]; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | "fbexport", "logout", "pubsub"); |
| 17 | 17 | |
| 18 | 18 | if (array_search($op, $public_calls) !== false) { |
| 19 | - header("Location: public.php?" . $_SERVER['QUERY_STRING']); |
|
| 19 | + header("Location: public.php?".$_SERVER['QUERY_STRING']); |
|
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if (SINGLE_USER_MODE) { |
| 45 | - authenticate_user( "admin", null); |
|
| 45 | + authenticate_user("admin", null); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | if ($_SESSION["uid"]) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | print error_json(6); |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | - load_user_plugins( $_SESSION["uid"]); |
|
| 54 | + load_user_plugins($_SESSION["uid"]); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $purge_intervals = array( |
@@ -5,10 +5,11 @@ discard block |
||
| 5 | 5 | $op = $_REQUEST["op"]; |
| 6 | 6 | @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
| 7 | 7 | |
| 8 | - if (!$method) |
|
| 9 | - $method = 'index'; |
|
| 10 | - else |
|
| 11 | - $method = strtolower($method); |
|
| 8 | + if (!$method) { |
|
| 9 | + $method = 'index'; |
|
| 10 | + } else { |
|
| 11 | + $method = strtolower($method); |
|
| 12 | + } |
|
| 12 | 13 | |
| 13 | 14 | /* Public calls compatibility shim */ |
| 14 | 15 | |
@@ -33,7 +34,9 @@ discard block |
||
| 33 | 34 | |
| 34 | 35 | $script_started = microtime(true); |
| 35 | 36 | |
| 36 | - if (!init_plugins()) return; |
|
| 37 | + if (!init_plugins()) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | header("Content-Type: text/json; charset=utf-8"); |
| 39 | 42 | |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
| 2 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
| 3 | 3 | get_include_path()); |
| 4 | 4 | |
| 5 | 5 | require_once "autoload.php"; |
@@ -14,7 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | $script_started = microtime(true); |
| 16 | 16 | |
| 17 | - if (!init_plugins()) return; |
|
| 17 | + if (!init_plugins()) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
| 20 | 22 | ob_start("ob_gzhandler"); |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | return Db::get()->last_query_error(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -function db_quote($str){ |
|
| 36 | +function db_quote($str) { |
|
| 37 | 37 | return Db::get()->quote($str); |
| 38 | 38 | } |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 85 | 85 | */ |
| 86 | - function ttrss_open ($s, $n) { |
|
| 86 | + function ttrss_open($s, $n) { |
|
| 87 | 87 | return true; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - function ttrss_read ($id){ |
|
| 90 | + function ttrss_read($id) { |
|
| 91 | 91 | global $session_expire; |
| 92 | 92 | |
| 93 | 93 | $sth = Db::pdo()->prepare("SELECT data FROM ttrss_sessions WHERE id=?"); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - function ttrss_write ($id, $data) { |
|
| 112 | + function ttrss_write($id, $data) { |
|
| 113 | 113 | global $session_expire; |
| 114 | 114 | |
| 115 | 115 | $data = base64_encode($data); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return true; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - function ttrss_close () { |
|
| 133 | + function ttrss_close() { |
|
| 134 | 134 | return true; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | /** |
| 145 | 145 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 146 | 146 | */ |
| 147 | - function ttrss_gc ($expire) { |
|
| 148 | - Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < " . time()); |
|
| 147 | + function ttrss_gc($expire) { |
|
| 148 | + Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < ".time()); |
|
| 149 | 149 | |
| 150 | 150 | return true; |
| 151 | 151 | } |
@@ -37,7 +37,9 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | function validate_session() { |
| 40 | - if (SINGLE_USER_MODE) return true; |
|
| 40 | + if (SINGLE_USER_MODE) { |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version()) { |
| 43 | 45 | $_SESSION["login_error_msg"] = |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * @SuppressWarnings(PHPMD.UnusedLocalVariable) |
|
| 48 | - */ |
|
| 47 | + * @SuppressWarnings(PHPMD.UnusedLocalVariable) |
|
| 48 | + */ |
|
| 49 | 49 | function initial_sanity_check() { |
| 50 | 50 | |
| 51 | 51 | $errors = array(); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (SINGLE_USER_MODE && class_exists("PDO")) { |
| 108 | - $pdo = DB::pdo(); |
|
| 108 | + $pdo = DB::pdo(); |
|
| 109 | 109 | |
| 110 | 110 | $res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1"); |
| 111 | 111 | |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | function make_self_url() { |
| 18 | 18 | $proto = is_server_https() ? 'https' : 'http'; |
| 19 | 19 | |
| 20 | - return $proto . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; |
|
| 20 | + return $proto.'://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | function make_self_url_path() { |
| 24 | 24 | $proto = is_server_https() ? 'https' : 'http'; |
| 25 | - $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
| 25 | + $url_path = $proto.'://'.$_SERVER["HTTP_HOST"].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
| 26 | 26 | |
| 27 | 27 | return $url_path; |
| 28 | 28 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 72 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
| 72 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using ".PHP_VERSION."."); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if (!class_exists("UConverter")) { |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | array_push($errors, "Configuration file (config.php) has incorrect version. Update it with new options from config.php-dist and set CONFIG_VERSION to the correct value."); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if (!is_writable(CACHE_DIR . "/images")) { |
|
| 83 | + if (!is_writable(CACHE_DIR."/images")) { |
|
| 84 | 84 | array_push($errors, "Image cache is not writable (chmod -R 777 ".CACHE_DIR."/images)"); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (!is_writable(CACHE_DIR . "/upload")) { |
|
| 87 | + if (!is_writable(CACHE_DIR."/upload")) { |
|
| 88 | 88 | array_push($errors, "Upload cache is not writable (chmod -R 777 ".CACHE_DIR."/upload)"); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (!is_writable(CACHE_DIR . "/export")) { |
|
| 91 | + if (!is_writable(CACHE_DIR."/export")) { |
|
| 92 | 92 | array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | if (isset($_SERVER["HTTP_HOST"]) && |
| 126 | 126 | (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && |
| 127 | - SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { |
|
| 127 | + SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path) - 1)) { |
|
| 128 | 128 | array_push($errors, |
| 129 | 129 | "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); |
| 130 | 130 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | array_push($bad_tables_fmt, sprintf("%s (%s)", $bt['table_name'], $bt['engine'])); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $msg = "<p>The following tables use an unsupported MySQL engine: <b>" . |
|
| 191 | - implode(", ", $bad_tables_fmt) . "</b>.</p>"; |
|
| 190 | + $msg = "<p>The following tables use an unsupported MySQL engine: <b>". |
|
| 191 | + implode(", ", $bad_tables_fmt)."</b>.</p>"; |
|
| 192 | 192 | |
| 193 | 193 | $msg .= "<p>The only supported engine on MySQL is InnoDB. MyISAM lacks functionality to run |
| 194 | 194 | tt-rss. |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | |
| 164 | 164 | // TODO: compat wrapper, remove at some point |
| 165 | 165 | function _debug($msg) { |
| 166 | - Debug::log($msg); |
|
| 166 | + Debug::log($msg); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | function reset_fetch_domain_quota() { |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | define('LABEL_BASE_INDEX', -1024); |
| 6 | 6 | define('PLUGIN_FEED_BASE_INDEX', -128); |
| 7 | 7 | |
| 8 | - define('COOKIE_LIFETIME_LONG', 86400*365); |
|
| 8 | + define('COOKIE_LIFETIME_LONG', 86400 * 365); |
|
| 9 | 9 | |
| 10 | 10 | $fetch_last_error = false; |
| 11 | 11 | $fetch_last_error_code = false; |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | // feed limit for one update batch |
| 58 | 58 | define_default('DAEMON_SLEEP_INTERVAL', 120); |
| 59 | 59 | // default sleep interval between feed updates (sec) |
| 60 | - define_default('MAX_CACHE_FILE_SIZE', 64*1024*1024); |
|
| 60 | + define_default('MAX_CACHE_FILE_SIZE', 64 * 1024 * 1024); |
|
| 61 | 61 | // do not cache files larger than that (bytes) |
| 62 | - define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); |
|
| 62 | + define_default('MAX_DOWNLOAD_FILE_SIZE', 16 * 1024 * 1024); |
|
| 63 | 63 | // do not download general files larger than that (bytes) |
| 64 | 64 | define_default('CACHE_MAX_DAYS', 7); |
| 65 | 65 | // max age in days for various automatically cached (temporary) files |
| 66 | - define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); |
|
| 66 | + define_default('MAX_CONDITIONAL_INTERVAL', 3600 * 12); |
|
| 67 | 67 | // max interval between forced unconditional updates for servers |
| 68 | 68 | // not complying with http if-modified-since (seconds) |
| 69 | 69 | define_default('MAX_FETCH_REQUESTS_PER_HOST', 25); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | require_once 'db-prefs.php'; |
| 157 | 157 | require_once 'controls.php'; |
| 158 | 158 | |
| 159 | - define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)'); |
|
| 159 | + define('SELF_USER_AGENT', 'Tiny Tiny RSS/'.get_version().' (http://tt-rss.org/)'); |
|
| 160 | 160 | ini_set('user_agent', SELF_USER_AGENT); |
| 161 | 161 | |
| 162 | 162 | $schema_version = false; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | if (!is_array($options)) { |
| 201 | 201 | |
| 202 | 202 | // falling back on compatibility shim |
| 203 | - $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ]; |
|
| 203 | + $option_names = ["url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent"]; |
|
| 204 | 204 | $tmp = []; |
| 205 | 205 | |
| 206 | 206 | for ($i = 0; $i < func_num_args(); $i++) { |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | $url = str_replace(' ', '%20', $url); |
| 239 | 239 | |
| 240 | 240 | if (strpos($url, "//") === 0) |
| 241 | - $url = 'http:' . $url; |
|
| 241 | + $url = 'http:'.$url; |
|
| 242 | 242 | |
| 243 | 243 | $url_host = parse_url($url, PHP_URL_HOST); |
| 244 | 244 | $fetch_domain_hits[$url_host] += 1; |
| 245 | 245 | |
| 246 | 246 | if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { |
| 247 | - user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); |
|
| 247 | + user_error("Exceeded fetch request quota for $url_host: ".$fetch_domain_hits[$url_host], E_USER_WARNING); |
|
| 248 | 248 | #return false; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
| 261 | 261 | |
| 262 | 262 | if ($http_accept) |
| 263 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
| 263 | + array_push($curl_http_headers, "Accept: ".$http_accept); |
|
| 264 | 264 | |
| 265 | 265 | if (count($curl_http_headers) > 0) |
| 266 | 266 | curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
@@ -273,11 +273,10 @@ discard block |
||
| 273 | 273 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 274 | 274 | curl_setopt($ch, CURLOPT_HEADER, true); |
| 275 | 275 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
| 276 | - curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : |
|
| 277 | - SELF_USER_AGENT); |
|
| 276 | + curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : SELF_USER_AGENT); |
|
| 278 | 277 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
| 279 | 278 | |
| 280 | - if ($http_referrer) |
|
| 279 | + if ($http_referrer) |
|
| 281 | 280 | curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
| 282 | 281 | |
| 283 | 282 | if ($max_size) { |
@@ -286,7 +285,7 @@ discard block |
||
| 286 | 285 | |
| 287 | 286 | // holy shit closures in php |
| 288 | 287 | // download & upload are *expected* sizes respectively, could be zero |
| 289 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { |
|
| 288 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use(&$max_size) { |
|
| 290 | 289 | Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); |
| 291 | 290 | |
| 292 | 291 | return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it |
@@ -346,7 +345,7 @@ discard block |
||
| 346 | 345 | if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { |
| 347 | 346 | |
| 348 | 347 | if (curl_errno($ch) != 0) { |
| 349 | - $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); |
|
| 348 | + $fetch_last_error .= "; ".curl_errno($ch)." ".curl_error($ch); |
|
| 350 | 349 | } |
| 351 | 350 | |
| 352 | 351 | $fetch_last_error_content = $contents; |
@@ -355,7 +354,7 @@ discard block |
||
| 355 | 354 | } |
| 356 | 355 | |
| 357 | 356 | if (!$contents) { |
| 358 | - $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); |
|
| 357 | + $fetch_last_error = curl_errno($ch)." ".curl_error($ch); |
|
| 359 | 358 | curl_close($ch); |
| 360 | 359 | return false; |
| 361 | 360 | } |
@@ -375,7 +374,7 @@ discard block |
||
| 375 | 374 | |
| 376 | 375 | $fetch_curl_used = false; |
| 377 | 376 | |
| 378 | - if ($login && $pass){ |
|
| 377 | + if ($login && $pass) { |
|
| 379 | 378 | $url_parts = array(); |
| 380 | 379 | |
| 381 | 380 | preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts); |
@@ -383,7 +382,7 @@ discard block |
||
| 383 | 382 | $pass = urlencode($pass); |
| 384 | 383 | |
| 385 | 384 | if ($url_parts[1] && $url_parts[2]) { |
| 386 | - $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2]; |
|
| 385 | + $url = $url_parts[1]."://$login:$pass@".$url_parts[2]; |
|
| 387 | 386 | } |
| 388 | 387 | } |
| 389 | 388 | |
@@ -451,7 +450,7 @@ discard block |
||
| 451 | 450 | $error = error_get_last(); |
| 452 | 451 | |
| 453 | 452 | if ($error['message'] != $old_error['message']) { |
| 454 | - $fetch_last_error .= "; " . $error["message"]; |
|
| 453 | + $fetch_last_error .= "; ".$error["message"]; |
|
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | $fetch_last_error_content = $data; |
@@ -526,15 +525,15 @@ discard block |
||
| 526 | 525 | |
| 527 | 526 | function get_ssl_certificate_id() { |
| 528 | 527 | if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { |
| 529 | - return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . |
|
| 530 | - $_SERVER["REDIRECT_SSL_CLIENT_V_START"] . |
|
| 531 | - $_SERVER["REDIRECT_SSL_CLIENT_V_END"] . |
|
| 528 | + return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]. |
|
| 529 | + $_SERVER["REDIRECT_SSL_CLIENT_V_START"]. |
|
| 530 | + $_SERVER["REDIRECT_SSL_CLIENT_V_END"]. |
|
| 532 | 531 | $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]); |
| 533 | 532 | } |
| 534 | 533 | if ($_SERVER["SSL_CLIENT_M_SERIAL"]) { |
| 535 | - return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] . |
|
| 536 | - $_SERVER["SSL_CLIENT_V_START"] . |
|
| 537 | - $_SERVER["SSL_CLIENT_V_END"] . |
|
| 534 | + return sha1($_SERVER["SSL_CLIENT_M_SERIAL"]. |
|
| 535 | + $_SERVER["SSL_CLIENT_V_START"]. |
|
| 536 | + $_SERVER["SSL_CLIENT_V_END"]. |
|
| 538 | 537 | $_SERVER["SSL_CLIENT_S_DN"]); |
| 539 | 538 | } |
| 540 | 539 | return ""; |
@@ -669,7 +668,7 @@ discard block |
||
| 669 | 668 | function logout_user() { |
| 670 | 669 | @session_destroy(); |
| 671 | 670 | if (isset($_COOKIE[session_name()])) { |
| 672 | - setcookie(session_name(), '', time()-42000, '/'); |
|
| 671 | + setcookie(session_name(), '', time() - 42000, '/'); |
|
| 673 | 672 | } |
| 674 | 673 | session_commit(); |
| 675 | 674 | } |
@@ -753,7 +752,7 @@ discard block |
||
| 753 | 752 | |
| 754 | 753 | function truncate_string($str, $max_len, $suffix = '…') { |
| 755 | 754 | if (mb_strlen($str, "utf-8") > $max_len) { |
| 756 | - return mb_substr($str, 0, $max_len, "utf-8") . $suffix; |
|
| 755 | + return mb_substr($str, 0, $max_len, "utf-8").$suffix; |
|
| 757 | 756 | } else { |
| 758 | 757 | return $str; |
| 759 | 758 | } |
@@ -763,7 +762,7 @@ discard block |
||
| 763 | 762 | $startString = mb_substr($original, 0, $position, "UTF-8"); |
| 764 | 763 | $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8"); |
| 765 | 764 | |
| 766 | - $out = $startString . $replacement . $endString; |
|
| 765 | + $out = $startString.$replacement.$endString; |
|
| 767 | 766 | |
| 768 | 767 | return $out; |
| 769 | 768 | } |
@@ -901,9 +900,9 @@ discard block |
||
| 901 | 900 | } |
| 902 | 901 | |
| 903 | 902 | function file_is_locked($filename) { |
| 904 | - if (file_exists(LOCK_DIRECTORY . "/$filename")) { |
|
| 903 | + if (file_exists(LOCK_DIRECTORY."/$filename")) { |
|
| 905 | 904 | if (function_exists('flock')) { |
| 906 | - $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); |
|
| 905 | + $fp = @fopen(LOCK_DIRECTORY."/$filename", "r"); |
|
| 907 | 906 | if ($fp) { |
| 908 | 907 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
| 909 | 908 | flock($fp, LOCK_UN); |
@@ -924,11 +923,11 @@ discard block |
||
| 924 | 923 | |
| 925 | 924 | |
| 926 | 925 | function make_lockfile($filename) { |
| 927 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
| 926 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
| 928 | 927 | |
| 929 | 928 | if ($fp && flock($fp, LOCK_EX | LOCK_NB)) { |
| 930 | 929 | $stat_h = fstat($fp); |
| 931 | - $stat_f = stat(LOCK_DIRECTORY . "/$filename"); |
|
| 930 | + $stat_f = stat(LOCK_DIRECTORY."/$filename"); |
|
| 932 | 931 | |
| 933 | 932 | if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { |
| 934 | 933 | if ($stat_h["ino"] != $stat_f["ino"] || |
@@ -939,7 +938,7 @@ discard block |
||
| 939 | 938 | } |
| 940 | 939 | |
| 941 | 940 | if (function_exists('posix_getpid')) { |
| 942 | - fwrite($fp, posix_getpid() . "\n"); |
|
| 941 | + fwrite($fp, posix_getpid()."\n"); |
|
| 943 | 942 | } |
| 944 | 943 | return $fp; |
| 945 | 944 | } else { |
@@ -948,10 +947,10 @@ discard block |
||
| 948 | 947 | } |
| 949 | 948 | |
| 950 | 949 | function make_stampfile($filename) { |
| 951 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
| 950 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
| 952 | 951 | |
| 953 | 952 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
| 954 | - fwrite($fp, time() . "\n"); |
|
| 953 | + fwrite($fp, time()."\n"); |
|
| 955 | 954 | flock($fp, LOCK_UN); |
| 956 | 955 | fclose($fp); |
| 957 | 956 | return true; |
@@ -1001,7 +1000,7 @@ discard block |
||
| 1001 | 1000 | $params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); |
| 1002 | 1001 | $params["label_base_index"] = (int) LABEL_BASE_INDEX; |
| 1003 | 1002 | |
| 1004 | - $theme = get_pref( "USER_CSS_THEME", false, false); |
|
| 1003 | + $theme = get_pref("USER_CSS_THEME", false, false); |
|
| 1005 | 1004 | $params["theme"] = theme_exists($theme) ? $theme : ""; |
| 1006 | 1005 | |
| 1007 | 1006 | $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); |
@@ -1226,13 +1225,13 @@ discard block |
||
| 1226 | 1225 | } |
| 1227 | 1226 | } |
| 1228 | 1227 | |
| 1229 | - if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { |
|
| 1228 | + if (file_exists(LOCK_DIRECTORY."/update_daemon.lock")) { |
|
| 1230 | 1229 | |
| 1231 | 1230 | $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); |
| 1232 | 1231 | |
| 1233 | 1232 | if (time() - $_SESSION["daemon_stamp_check"] > 30) { |
| 1234 | 1233 | |
| 1235 | - $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
| 1234 | + $stamp = (int) @file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
|
| 1236 | 1235 | |
| 1237 | 1236 | if ($stamp) { |
| 1238 | 1237 | $stamp_delta = time() - $stamp; |
@@ -1275,7 +1274,7 @@ discard block |
||
| 1275 | 1274 | $res = trim($str); if (!$res) return ''; |
| 1276 | 1275 | |
| 1277 | 1276 | $doc = new DOMDocument(); |
| 1278 | - $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
|
| 1277 | + $doc->loadHTML('<?xml encoding="UTF-8">'.$res); |
|
| 1279 | 1278 | $xpath = new DOMXPath($doc); |
| 1280 | 1279 | |
| 1281 | 1280 | $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); |
@@ -1374,7 +1373,7 @@ discard block |
||
| 1374 | 1373 | 'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', |
| 1375 | 1374 | 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', |
| 1376 | 1375 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
| 1377 | - 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
|
| 1376 | + 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace'); |
|
| 1378 | 1377 | |
| 1379 | 1378 | if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
| 1380 | 1379 | |
@@ -1509,8 +1508,8 @@ discard block |
||
| 1509 | 1508 | |
| 1510 | 1509 | // this returns SELF_URL_PATH sans ending slash |
| 1511 | 1510 | function get_self_url_prefix() { |
| 1512 | - if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) { |
|
| 1513 | - return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH)-1); |
|
| 1511 | + if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH) - 1) { |
|
| 1512 | + return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH) - 1); |
|
| 1514 | 1513 | } else { |
| 1515 | 1514 | return SELF_URL_PATH; |
| 1516 | 1515 | } |
@@ -1519,11 +1518,11 @@ discard block |
||
| 1519 | 1518 | /* TODO: This needs to use bcrypt */ |
| 1520 | 1519 | function encrypt_password($pass, $salt = '', $mode2 = false) { |
| 1521 | 1520 | if ($salt && $mode2) { |
| 1522 | - return "MODE2:" . hash('sha256', $salt . $pass); |
|
| 1521 | + return "MODE2:".hash('sha256', $salt.$pass); |
|
| 1523 | 1522 | } else if ($salt) { |
| 1524 | - return "SHA1X:" . sha1("$salt:$pass"); |
|
| 1523 | + return "SHA1X:".sha1("$salt:$pass"); |
|
| 1525 | 1524 | } else { |
| 1526 | - return "SHA1:" . sha1($pass); |
|
| 1525 | + return "SHA1:".sha1($pass); |
|
| 1527 | 1526 | } |
| 1528 | 1527 | } // function encrypt_password |
| 1529 | 1528 | |
@@ -1534,7 +1533,7 @@ discard block |
||
| 1534 | 1533 | } |
| 1535 | 1534 | |
| 1536 | 1535 | function build_url($parts) { |
| 1537 | - return $parts['scheme'] . "://" . $parts['host'] . $parts['path']; |
|
| 1536 | + return $parts['scheme']."://".$parts['host'].$parts['path']; |
|
| 1538 | 1537 | } |
| 1539 | 1538 | |
| 1540 | 1539 | function cleanup_url_path($path) { |
@@ -1578,7 +1577,7 @@ discard block |
||
| 1578 | 1577 | $dir = dirname($parts['path']); |
| 1579 | 1578 | $dir !== '/' && $dir .= '/'; |
| 1580 | 1579 | } |
| 1581 | - $parts['path'] = $dir . $rel_url; |
|
| 1580 | + $parts['path'] = $dir.$rel_url; |
|
| 1582 | 1581 | $parts['path'] = cleanup_url_path($parts['path']); |
| 1583 | 1582 | |
| 1584 | 1583 | return build_url($parts); |
@@ -1755,12 +1754,12 @@ discard block |
||
| 1755 | 1754 | |
| 1756 | 1755 | for ($i = 0; $i < $l10n->total; $i++) { |
| 1757 | 1756 | $orig = $l10n->get_original_string($i); |
| 1758 | - if(strpos($orig, "\000") !== FALSE) { // Plural forms |
|
| 1757 | + if (strpos($orig, "\000") !== FALSE) { // Plural forms |
|
| 1759 | 1758 | $key = explode(chr(0), $orig); |
| 1760 | 1759 | print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular |
| 1761 | 1760 | print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural |
| 1762 | 1761 | } else { |
| 1763 | - $translation = _dgettext($domain,$orig); |
|
| 1762 | + $translation = _dgettext($domain, $orig); |
|
| 1764 | 1763 | print T_js_decl($orig, $translation); |
| 1765 | 1764 | } |
| 1766 | 1765 | } |
@@ -1824,7 +1823,7 @@ discard block |
||
| 1824 | 1823 | if (file_exists($filename)) { |
| 1825 | 1824 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 1826 | 1825 | |
| 1827 | - return "data:image/$ext;base64," . base64_encode(file_get_contents($filename)); |
|
| 1826 | + return "data:image/$ext;base64,".base64_encode(file_get_contents($filename)); |
|
| 1828 | 1827 | } else { |
| 1829 | 1828 | return ""; |
| 1830 | 1829 | } |
@@ -1861,7 +1860,7 @@ discard block |
||
| 1861 | 1860 | |
| 1862 | 1861 | header("Content-type: $mimetype"); |
| 1863 | 1862 | |
| 1864 | - $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; |
|
| 1863 | + $stamp = gmdate("D, d M Y H:i:s", filemtime($filename))." GMT"; |
|
| 1865 | 1864 | header("Last-Modified: $stamp", true); |
| 1866 | 1865 | |
| 1867 | 1866 | return readfile($filename); |
@@ -1871,7 +1870,7 @@ discard block |
||
| 1871 | 1870 | } |
| 1872 | 1871 | |
| 1873 | 1872 | function arr_qmarks($arr) { |
| 1874 | - return str_repeat('?,', count($arr) - 1) . '?'; |
|
| 1873 | + return str_repeat('?,', count($arr) - 1).'?'; |
|
| 1875 | 1874 | } |
| 1876 | 1875 | |
| 1877 | 1876 | function get_scripts_timestamp() { |
@@ -1906,7 +1905,7 @@ discard block |
||
| 1906 | 1905 | } else if (PHP_OS === "Darwin") { |
| 1907 | 1906 | $ttrss_version = "UNKNOWN (Unsupported, Darwin)"; |
| 1908 | 1907 | } else if (file_exists("$root_dir/version_static.txt")) { |
| 1909 | - $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; |
|
| 1908 | + $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt"))." (Unsupported)"; |
|
| 1910 | 1909 | } else if (is_dir("$root_dir/.git")) { |
| 1911 | 1910 | $rc = 0; |
| 1912 | 1911 | $output = []; |
@@ -1924,10 +1923,10 @@ discard block |
||
| 1924 | 1923 | $git_commit = $commit; |
| 1925 | 1924 | $git_timestamp = $timestamp; |
| 1926 | 1925 | |
| 1927 | - $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit"; |
|
| 1926 | + $ttrss_version = strftime("%y.%m", $timestamp)."-$commit"; |
|
| 1928 | 1927 | } |
| 1929 | 1928 | } else { |
| 1930 | - user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING); |
|
| 1929 | + user_error("Unable to determine version (using $root_dir): ".implode("\n", $output), E_USER_WARNING); |
|
| 1931 | 1930 | } |
| 1932 | 1931 | } |
| 1933 | 1932 | |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | libxml_use_internal_errors(true); |
| 19 | 19 | |
| 20 | 20 | // separate test because this is included before sanity checks |
| 21 | - if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8"); |
|
| 21 | + if (function_exists("mb_internal_encoding")) { |
|
| 22 | + mb_internal_encoding("UTF-8"); |
|
| 23 | + } |
|
| 22 | 24 | |
| 23 | 25 | date_default_timezone_set('UTC'); |
| 24 | 26 | if (defined('E_DEPRECATED')) { |
@@ -194,8 +196,9 @@ discard block |
||
| 194 | 196 | $fetch_last_modified = ""; |
| 195 | 197 | $fetch_effective_url = ""; |
| 196 | 198 | |
| 197 | - if (!is_array($fetch_domain_hits)) |
|
| 198 | - $fetch_domain_hits = []; |
|
| 199 | + if (!is_array($fetch_domain_hits)) { |
|
| 200 | + $fetch_domain_hits = []; |
|
| 201 | + } |
|
| 199 | 202 | |
| 200 | 203 | if (!is_array($options)) { |
| 201 | 204 | |
@@ -237,8 +240,9 @@ discard block |
||
| 237 | 240 | $url = ltrim($url, ' '); |
| 238 | 241 | $url = str_replace(' ', '%20', $url); |
| 239 | 242 | |
| 240 | - if (strpos($url, "//") === 0) |
|
| 241 | - $url = 'http:' . $url; |
|
| 243 | + if (strpos($url, "//") === 0) { |
|
| 244 | + $url = 'http:' . $url; |
|
| 245 | + } |
|
| 242 | 246 | |
| 243 | 247 | $url_host = parse_url($url, PHP_URL_HOST); |
| 244 | 248 | $fetch_domain_hits[$url_host] += 1; |
@@ -256,14 +260,17 @@ discard block |
||
| 256 | 260 | |
| 257 | 261 | $curl_http_headers = []; |
| 258 | 262 | |
| 259 | - if ($last_modified && !$post_query) |
|
| 260 | - array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
| 263 | + if ($last_modified && !$post_query) { |
|
| 264 | + array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
| 265 | + } |
|
| 261 | 266 | |
| 262 | - if ($http_accept) |
|
| 263 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
| 267 | + if ($http_accept) { |
|
| 268 | + array_push($curl_http_headers, "Accept: " . $http_accept); |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | - if (count($curl_http_headers) > 0) |
|
| 266 | - curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
| 271 | + if (count($curl_http_headers) > 0) { |
|
| 272 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
| 273 | + } |
|
| 267 | 274 | |
| 268 | 275 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); |
| 269 | 276 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); |
@@ -277,8 +284,9 @@ discard block |
||
| 277 | 284 | SELF_USER_AGENT); |
| 278 | 285 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
| 279 | 286 | |
| 280 | - if ($http_referrer) |
|
| 281 | - curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
| 287 | + if ($http_referrer) { |
|
| 288 | + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
| 289 | + } |
|
| 282 | 290 | |
| 283 | 291 | if ($max_size) { |
| 284 | 292 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
@@ -307,8 +315,9 @@ discard block |
||
| 307 | 315 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); |
| 308 | 316 | } |
| 309 | 317 | |
| 310 | - if ($login && $pass) |
|
| 311 | - curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
| 318 | + if ($login && $pass) { |
|
| 319 | + curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
| 320 | + } |
|
| 312 | 321 | |
| 313 | 322 | $ret = @curl_exec($ch); |
| 314 | 323 | |
@@ -367,7 +376,9 @@ discard block |
||
| 367 | 376 | if ($is_gzipped) { |
| 368 | 377 | $tmp = @gzdecode($contents); |
| 369 | 378 | |
| 370 | - if ($tmp) $contents = $tmp; |
|
| 379 | + if ($tmp) { |
|
| 380 | + $contents = $tmp; |
|
| 381 | + } |
|
| 371 | 382 | } |
| 372 | 383 | |
| 373 | 384 | return $contents; |
@@ -400,14 +411,17 @@ discard block |
||
| 400 | 411 | 'protocol_version'=> 1.1) |
| 401 | 412 | ); |
| 402 | 413 | |
| 403 | - if (!$post_query && $last_modified) |
|
| 404 | - array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
| 414 | + if (!$post_query && $last_modified) { |
|
| 415 | + array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
| 416 | + } |
|
| 405 | 417 | |
| 406 | - if ($http_accept) |
|
| 407 | - array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
| 418 | + if ($http_accept) { |
|
| 419 | + array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
| 420 | + } |
|
| 408 | 421 | |
| 409 | - if ($http_referrer) |
|
| 410 | - array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
| 422 | + if ($http_referrer) { |
|
| 423 | + array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
| 424 | + } |
|
| 411 | 425 | |
| 412 | 426 | if (defined('_HTTP_PROXY')) { |
| 413 | 427 | $context_options['http']['request_fulluri'] = true; |
@@ -464,7 +478,9 @@ discard block |
||
| 464 | 478 | if ($is_gzipped) { |
| 465 | 479 | $tmp = @gzdecode($data); |
| 466 | 480 | |
| 467 | - if ($tmp) $data = $tmp; |
|
| 481 | + if ($tmp) { |
|
| 482 | + $data = $tmp; |
|
| 483 | + } |
|
| 468 | 484 | } |
| 469 | 485 | |
| 470 | 486 | return $data; |
@@ -474,7 +490,9 @@ discard block |
||
| 474 | 490 | |
| 475 | 491 | function initialize_user_prefs($uid, $profile = false) { |
| 476 | 492 | |
| 477 | - if (get_schema_version() < 63) $profile_qpart = ""; |
|
| 493 | + if (get_schema_version() < 63) { |
|
| 494 | + $profile_qpart = ""; |
|
| 495 | + } |
|
| 478 | 496 | |
| 479 | 497 | $pdo = DB::pdo(); |
| 480 | 498 | $in_nested_tr = false; |
@@ -487,7 +505,9 @@ discard block |
||
| 487 | 505 | |
| 488 | 506 | $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); |
| 489 | 507 | |
| 490 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 508 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
| 509 | + $profile = null; |
|
| 510 | + } |
|
| 491 | 511 | |
| 492 | 512 | $u_sth = $pdo->prepare("SELECT pref_name |
| 493 | 513 | FROM ttrss_user_prefs WHERE owner_uid = :uid AND |
@@ -520,7 +540,9 @@ discard block |
||
| 520 | 540 | } |
| 521 | 541 | } |
| 522 | 542 | |
| 523 | - if (!$in_nested_tr) $pdo->commit(); |
|
| 543 | + if (!$in_nested_tr) { |
|
| 544 | + $pdo->commit(); |
|
| 545 | + } |
|
| 524 | 546 | |
| 525 | 547 | } |
| 526 | 548 | |
@@ -680,7 +702,9 @@ discard block |
||
| 680 | 702 | |
| 681 | 703 | function load_user_plugins($owner_uid, $pluginhost = false) { |
| 682 | 704 | |
| 683 | - if (!$pluginhost) $pluginhost = PluginHost::getInstance(); |
|
| 705 | + if (!$pluginhost) { |
|
| 706 | + $pluginhost = PluginHost::getInstance(); |
|
| 707 | + } |
|
| 684 | 708 | |
| 685 | 709 | if ($owner_uid && SCHEMA_VERSION >= 100) { |
| 686 | 710 | $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); |
@@ -702,7 +726,9 @@ discard block |
||
| 702 | 726 | startup_gettext(); |
| 703 | 727 | load_user_plugins($_SESSION["uid"]); |
| 704 | 728 | } else { |
| 705 | - if (!validate_session()) $_SESSION["uid"] = false; |
|
| 729 | + if (!validate_session()) { |
|
| 730 | + $_SESSION["uid"] = false; |
|
| 731 | + } |
|
| 706 | 732 | |
| 707 | 733 | if (!$_SESSION["uid"]) { |
| 708 | 734 | |
@@ -797,13 +823,19 @@ discard block |
||
| 797 | 823 | function make_local_datetime($timestamp, $long, $owner_uid = false, |
| 798 | 824 | $no_smart_dt = false, $eta_min = false) { |
| 799 | 825 | |
| 800 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 801 | - if (!$timestamp) $timestamp = '1970-01-01 0:00'; |
|
| 826 | + if (!$owner_uid) { |
|
| 827 | + $owner_uid = $_SESSION['uid']; |
|
| 828 | + } |
|
| 829 | + if (!$timestamp) { |
|
| 830 | + $timestamp = '1970-01-01 0:00'; |
|
| 831 | + } |
|
| 802 | 832 | |
| 803 | 833 | global $utc_tz; |
| 804 | 834 | global $user_tz; |
| 805 | 835 | |
| 806 | - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); |
|
| 836 | + if (!$utc_tz) { |
|
| 837 | + $utc_tz = new DateTimeZone('UTC'); |
|
| 838 | + } |
|
| 807 | 839 | |
| 808 | 840 | $timestamp = substr($timestamp, 0, 19); |
| 809 | 841 | |
@@ -815,7 +847,9 @@ discard block |
||
| 815 | 847 | if ($user_tz_string != 'Automatic') { |
| 816 | 848 | |
| 817 | 849 | try { |
| 818 | - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); |
|
| 850 | + if (!$user_tz) { |
|
| 851 | + $user_tz = new DateTimeZone($user_tz_string); |
|
| 852 | + } |
|
| 819 | 853 | } catch (Exception $e) { |
| 820 | 854 | $user_tz = $utc_tz; |
| 821 | 855 | } |
@@ -831,26 +865,30 @@ discard block |
||
| 831 | 865 | return smart_date_time($user_timestamp, |
| 832 | 866 | $tz_offset, $owner_uid, $eta_min); |
| 833 | 867 | } else { |
| 834 | - if ($long) |
|
| 835 | - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
| 836 | - else |
|
| 837 | - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
| 868 | + if ($long) { |
|
| 869 | + $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
| 870 | + } else { |
|
| 871 | + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
| 872 | + } |
|
| 838 | 873 | |
| 839 | 874 | return date($format, $user_timestamp); |
| 840 | 875 | } |
| 841 | 876 | } |
| 842 | 877 | |
| 843 | 878 | function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { |
| 844 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 879 | + if (!$owner_uid) { |
|
| 880 | + $owner_uid = $_SESSION['uid']; |
|
| 881 | + } |
|
| 845 | 882 | |
| 846 | 883 | if ($eta_min && time() + $tz_offset - $timestamp < 3600) { |
| 847 | 884 | return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); |
| 848 | 885 | } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { |
| 849 | 886 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
| 850 | - if (strpos((strtolower($format)), "a") === false) |
|
| 851 | - return date("G:i", $timestamp); |
|
| 852 | - else |
|
| 853 | - return date("g:i a", $timestamp); |
|
| 887 | + if (strpos((strtolower($format)), "a") === false) { |
|
| 888 | + return date("G:i", $timestamp); |
|
| 889 | + } else { |
|
| 890 | + return date("g:i a", $timestamp); |
|
| 891 | + } |
|
| 854 | 892 | } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { |
| 855 | 893 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
| 856 | 894 | return date($format, $timestamp); |
@@ -1261,8 +1299,9 @@ discard block |
||
| 1261 | 1299 | |
| 1262 | 1300 | if ($src) { |
| 1263 | 1301 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { |
| 1264 | - if ($plugin->hook_iframe_whitelisted($src)) |
|
| 1265 | - return true; |
|
| 1302 | + if ($plugin->hook_iframe_whitelisted($src)) { |
|
| 1303 | + return true; |
|
| 1304 | + } |
|
| 1266 | 1305 | } |
| 1267 | 1306 | } |
| 1268 | 1307 | |
@@ -1270,9 +1309,13 @@ discard block |
||
| 1270 | 1309 | } |
| 1271 | 1310 | |
| 1272 | 1311 | function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { |
| 1273 | - if (!$owner) $owner = $_SESSION["uid"]; |
|
| 1312 | + if (!$owner) { |
|
| 1313 | + $owner = $_SESSION["uid"]; |
|
| 1314 | + } |
|
| 1274 | 1315 | |
| 1275 | - $res = trim($str); if (!$res) return ''; |
|
| 1316 | + $res = trim($str); if (!$res) { |
|
| 1317 | + return ''; |
|
| 1318 | + } |
|
| 1276 | 1319 | |
| 1277 | 1320 | $doc = new DOMDocument(); |
| 1278 | 1321 | $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
@@ -1334,13 +1377,15 @@ discard block |
||
| 1334 | 1377 | |
| 1335 | 1378 | if ($entry->nodeName == 'source') { |
| 1336 | 1379 | |
| 1337 | - if ($entry->parentNode && $entry->parentNode->parentNode) |
|
| 1338 | - $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
| 1380 | + if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
| 1381 | + $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
| 1382 | + } |
|
| 1339 | 1383 | |
| 1340 | 1384 | } else if ($entry->nodeName == 'img') { |
| 1341 | 1385 | |
| 1342 | - if ($entry->parentNode) |
|
| 1343 | - $entry->parentNode->replaceChild($p, $entry); |
|
| 1386 | + if ($entry->parentNode) { |
|
| 1387 | + $entry->parentNode->replaceChild($p, $entry); |
|
| 1388 | + } |
|
| 1344 | 1389 | |
| 1345 | 1390 | } |
| 1346 | 1391 | } |
@@ -1376,7 +1421,9 @@ discard block |
||
| 1376 | 1421 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
| 1377 | 1422 | 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
| 1378 | 1423 | |
| 1379 | - if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
|
| 1424 | + if ($_SESSION['hasSandbox']) { |
|
| 1425 | + $allowed_elements[] = 'iframe'; |
|
| 1426 | + } |
|
| 1380 | 1427 | |
| 1381 | 1428 | $disallowed_attributes = array('id', 'style', 'class'); |
| 1382 | 1429 | |
@@ -1416,7 +1463,9 @@ discard block |
||
| 1416 | 1463 | $text = mb_substr($text, $pos + mb_strlen($word)); |
| 1417 | 1464 | } |
| 1418 | 1465 | |
| 1419 | - if (!empty($text)) $fragment->appendChild(new DomText($text)); |
|
| 1466 | + if (!empty($text)) { |
|
| 1467 | + $fragment->appendChild(new DomText($text)); |
|
| 1468 | + } |
|
| 1420 | 1469 | |
| 1421 | 1470 | $child->parentNode->replaceChild($fragment, $child); |
| 1422 | 1471 | } |
@@ -1697,8 +1746,9 @@ discard block |
||
| 1697 | 1746 | } else { |
| 1698 | 1747 | $output = ""; |
| 1699 | 1748 | |
| 1700 | - for ($i = 0; $i < $length; $i++) |
|
| 1701 | - $output .= chr(mt_rand(0, 255)); |
|
| 1749 | + for ($i = 0; $i < $length; $i++) { |
|
| 1750 | + $output .= chr(mt_rand(0, 255)); |
|
| 1751 | + } |
|
| 1702 | 1752 | |
| 1703 | 1753 | return $output; |
| 1704 | 1754 | } |
@@ -1769,14 +1819,19 @@ discard block |
||
| 1769 | 1819 | } |
| 1770 | 1820 | |
| 1771 | 1821 | function get_theme_path($theme) { |
| 1772 | - if ($theme == "default.php") |
|
| 1773 | - return "css/default.css"; |
|
| 1822 | + if ($theme == "default.php") { |
|
| 1823 | + return "css/default.css"; |
|
| 1824 | + } |
|
| 1774 | 1825 | |
| 1775 | 1826 | $check = "themes/$theme"; |
| 1776 | - if (file_exists($check)) return $check; |
|
| 1827 | + if (file_exists($check)) { |
|
| 1828 | + return $check; |
|
| 1829 | + } |
|
| 1777 | 1830 | |
| 1778 | 1831 | $check = "themes.local/$theme"; |
| 1779 | - if (file_exists($check)) return $check; |
|
| 1832 | + if (file_exists($check)) { |
|
| 1833 | + return $check; |
|
| 1834 | + } |
|
| 1780 | 1835 | } |
| 1781 | 1836 | |
| 1782 | 1837 | function theme_exists($theme) { |
@@ -1840,7 +1895,9 @@ discard block |
||
| 1840 | 1895 | function send_local_file($filename) { |
| 1841 | 1896 | if (file_exists($filename)) { |
| 1842 | 1897 | |
| 1843 | - if (is_writable($filename)) touch($filename); |
|
| 1898 | + if (is_writable($filename)) { |
|
| 1899 | + touch($filename); |
|
| 1900 | + } |
|
| 1844 | 1901 | |
| 1845 | 1902 | $tmppluginhost = new PluginHost(); |
| 1846 | 1903 | |
@@ -1848,7 +1905,9 @@ discard block |
||
| 1848 | 1905 | $tmppluginhost->load_data(); |
| 1849 | 1906 | |
| 1850 | 1907 | foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { |
| 1851 | - if ($plugin->hook_send_local_file($filename)) return true; |
|
| 1908 | + if ($plugin->hook_send_local_file($filename)) { |
|
| 1909 | + return true; |
|
| 1910 | + } |
|
| 1852 | 1911 | } |
| 1853 | 1912 | |
| 1854 | 1913 | $mimetype = mime_content_type($filename); |
@@ -1856,8 +1915,9 @@ discard block |
||
| 1856 | 1915 | // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 |
| 1857 | 1916 | // video files are detected as octet-stream by mime_content_type() |
| 1858 | 1917 | |
| 1859 | - if ($mimetype == "application/octet-stream") |
|
| 1860 | - $mimetype = "video/mp4"; |
|
| 1918 | + if ($mimetype == "application/octet-stream") { |
|
| 1919 | + $mimetype = "video/mp4"; |
|
| 1920 | + } |
|
| 1861 | 1921 | |
| 1862 | 1922 | header("Content-type: $mimetype"); |
| 1863 | 1923 | |
@@ -1880,7 +1940,9 @@ discard block |
||
| 1880 | 1940 | |
| 1881 | 1941 | foreach ($files as $file) { |
| 1882 | 1942 | $file_ts = filemtime($file); |
| 1883 | - if ($file_ts > $ts) $ts = $file_ts; |
|
| 1943 | + if ($file_ts > $ts) { |
|
| 1944 | + $ts = $file_ts; |
|
| 1945 | + } |
|
| 1884 | 1946 | } |
| 1885 | 1947 | |
| 1886 | 1948 | return $ts; |
@@ -1893,8 +1955,9 @@ discard block |
||
| 1893 | 1955 | function get_version(&$git_commit = false, &$git_timestamp = false) { |
| 1894 | 1956 | global $ttrss_version; |
| 1895 | 1957 | |
| 1896 | - if (isset($ttrss_version)) |
|
| 1897 | - return $ttrss_version; |
|
| 1958 | + if (isset($ttrss_version)) { |
|
| 1959 | + return $ttrss_version; |
|
| 1960 | + } |
|
| 1898 | 1961 | |
| 1899 | 1962 | $ttrss_version = "UNKNOWN (Unsupported)"; |
| 1900 | 1963 | |