@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | $doc = new DOMDocument(); |
| 21 | 21 | |
| 22 | - @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 22 | + @$doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 23 | 23 | |
| 24 | 24 | if ($doc) { |
| 25 | 25 | $xpath = new DOMXPath($doc); |
@@ -1,47 +1,47 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Fsckportal extends Plugin { |
| 3 | 3 | |
| 4 | - private $host; |
|
| 4 | + private $host; |
|
| 5 | 5 | |
| 6 | - public function about() { |
|
| 7 | - return array(1.0, |
|
| 8 | - "Remove feedsportal spamlinks from article content", |
|
| 9 | - "fox"); |
|
| 10 | - } |
|
| 6 | + public function about() { |
|
| 7 | + return array(1.0, |
|
| 8 | + "Remove feedsportal spamlinks from article content", |
|
| 9 | + "fox"); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function init($host) { |
|
| 13 | - $this->host = $host; |
|
| 12 | + public function init($host) { |
|
| 13 | + $this->host = $host; |
|
| 14 | 14 | |
| 15 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | - } |
|
| 15 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function hook_article_filter($article) { |
|
| 18 | + public function hook_article_filter($article) { |
|
| 19 | 19 | |
| 20 | - $doc = new DOMDocument(); |
|
| 20 | + $doc = new DOMDocument(); |
|
| 21 | 21 | |
| 22 | - @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 22 | + @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 23 | 23 | |
| 24 | - if ($doc) { |
|
| 25 | - $xpath = new DOMXPath($doc); |
|
| 26 | - $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 24 | + if ($doc) { |
|
| 25 | + $xpath = new DOMXPath($doc); |
|
| 26 | + $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 27 | 27 | |
| 28 | - foreach ($entries as $entry) { |
|
| 29 | - if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | - $entry->parentNode->removeChild($entry); |
|
| 31 | - } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | - $entry->parentNode->removeChild($entry); |
|
| 33 | - } |
|
| 34 | - } |
|
| 28 | + foreach ($entries as $entry) { |
|
| 29 | + if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | + $entry->parentNode->removeChild($entry); |
|
| 31 | + } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | + $entry->parentNode->removeChild($entry); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $article["content"] = $doc->saveHTML(); |
|
| 36 | + $article["content"] = $doc->saveHTML(); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $article; |
|
| 41 | - } |
|
| 40 | + return $article; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function api_version() { |
|
| 44 | - return 2; |
|
| 45 | - } |
|
| 43 | + public function api_version() { |
|
| 44 | + return 2; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | $er = error_reporting(E_ALL); |
| 25 | 25 | |
| 26 | 26 | switch (DB_TYPE) { |
| 27 | - case "mysql": |
|
| 28 | - $this->adapter = new Db_Mysqli(); |
|
| 29 | - break; |
|
| 30 | - case "pgsql": |
|
| 31 | - $this->adapter = new Db_Pgsql(); |
|
| 32 | - break; |
|
| 33 | - default: |
|
| 34 | - die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 27 | + case "mysql": |
|
| 28 | + $this->adapter = new Db_Mysqli(); |
|
| 29 | + break; |
|
| 30 | + case "pgsql": |
|
| 31 | + $this->adapter = new Db_Pgsql(); |
|
| 32 | + break; |
|
| 33 | + default: |
|
| 34 | + die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (!$this->adapter) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private function legacy_connect() { |
| 21 | 21 | |
| 22 | - user_error("Legacy connect requested to " . DB_TYPE, E_USER_NOTICE); |
|
| 22 | + user_error("Legacy connect requested to ".DB_TYPE, E_USER_NOTICE); |
|
| 23 | 23 | |
| 24 | 24 | $er = error_reporting(E_ALL); |
| 25 | 25 | |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | $this->adapter = new Db_Pgsql(); |
| 32 | 32 | break; |
| 33 | 33 | default: |
| 34 | - die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 34 | + die("Unknown DB_TYPE: ".DB_TYPE); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (!$this->adapter) { |
| 38 | - print("Error initializing database adapter for " . DB_TYPE); |
|
| 38 | + print("Error initializing database adapter for ".DB_TYPE); |
|
| 39 | 39 | exit(100); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : ""); |
| 43 | 43 | |
| 44 | 44 | if (!$this->link) { |
| 45 | - print("Error connecting through adapter: " . $this->adapter->last_error()); |
|
| 45 | + print("Error connecting through adapter: ".$this->adapter->last_error()); |
|
| 46 | 46 | exit(101); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -53,15 +53,15 @@ discard block |
||
| 53 | 53 | // normal usage is Db::pdo()->prepare(...) etc |
| 54 | 54 | public function pdo_connect() { |
| 55 | 55 | |
| 56 | - $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : ''; |
|
| 57 | - $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : ''; |
|
| 56 | + $db_port = defined('DB_PORT') && DB_PORT ? ';port='.DB_PORT : ''; |
|
| 57 | + $db_host = defined('DB_HOST') && DB_HOST ? ';host='.DB_HOST : ''; |
|
| 58 | 58 | |
| 59 | 59 | try { |
| 60 | - $pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port, |
|
| 60 | + $pdo = new PDO(DB_TYPE.':dbname='.DB_NAME.$db_host.$db_port, |
|
| 61 | 61 | DB_USER, |
| 62 | 62 | DB_PASS); |
| 63 | 63 | } catch (Exception $e) { |
| 64 | - print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>"; |
|
| 64 | + print "<pre>Exception while creating PDO object:".$e->getMessage()."</pre>"; |
|
| 65 | 65 | exit(101); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $pdo->query("SET time_zone = '+0:0'"); |
| 79 | 79 | |
| 80 | 80 | if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
| 81 | - $pdo->query("SET NAMES " . MYSQL_CHARSET); |
|
| 81 | + $pdo->query("SET NAMES ".MYSQL_CHARSET); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -86,15 +86,17 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public static function instance() { |
| 89 | - if (self::$instance == null) |
|
| 90 | - self::$instance = new self(); |
|
| 89 | + if (self::$instance == null) { |
|
| 90 | + self::$instance = new self(); |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | return self::$instance; |
| 93 | 94 | } |
| 94 | 95 | |
| 95 | 96 | public static function get() { |
| 96 | - if (self::$instance == null) |
|
| 97 | - self::$instance = new self(); |
|
| 97 | + if (self::$instance == null) { |
|
| 98 | + self::$instance = new self(); |
|
| 99 | + } |
|
| 98 | 100 | |
| 99 | 101 | if (!self::$instance->adapter) { |
| 100 | 102 | self::$instance->legacy_connect(); |
@@ -104,8 +106,9 @@ discard block |
||
| 104 | 106 | } |
| 105 | 107 | |
| 106 | 108 | public static function pdo() { |
| 107 | - if (self::$instance == null) |
|
| 108 | - self::$instance = new self(); |
|
| 109 | + if (self::$instance == null) { |
|
| 110 | + self::$instance = new self(); |
|
| 111 | + } |
|
| 109 | 112 | |
| 110 | 113 | if (!self::$instance->pdo) { |
| 111 | 114 | self::$instance->pdo = self::$instance->pdo_connect(); |
@@ -2,115 +2,115 @@ |
||
| 2 | 2 | class Db |
| 3 | 3 | { |
| 4 | 4 | |
| 5 | - /* @var Db $instance */ |
|
| 6 | - private static $instance; |
|
| 5 | + /* @var Db $instance */ |
|
| 6 | + private static $instance; |
|
| 7 | 7 | |
| 8 | - /* @var IDb $adapter */ |
|
| 9 | - private $adapter; |
|
| 8 | + /* @var IDb $adapter */ |
|
| 9 | + private $adapter; |
|
| 10 | 10 | |
| 11 | - private $link; |
|
| 11 | + private $link; |
|
| 12 | 12 | |
| 13 | - /* @var PDO $pdo */ |
|
| 14 | - private $pdo; |
|
| 13 | + /* @var PDO $pdo */ |
|
| 14 | + private $pdo; |
|
| 15 | 15 | |
| 16 | - private function __clone() { |
|
| 17 | - // |
|
| 18 | - } |
|
| 16 | + private function __clone() { |
|
| 17 | + // |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - private function legacy_connect() { |
|
| 20 | + private function legacy_connect() { |
|
| 21 | 21 | |
| 22 | - user_error("Legacy connect requested to " . DB_TYPE, E_USER_NOTICE); |
|
| 22 | + user_error("Legacy connect requested to " . DB_TYPE, E_USER_NOTICE); |
|
| 23 | 23 | |
| 24 | - $er = error_reporting(E_ALL); |
|
| 24 | + $er = error_reporting(E_ALL); |
|
| 25 | 25 | |
| 26 | - switch (DB_TYPE) { |
|
| 27 | - case "mysql": |
|
| 28 | - $this->adapter = new Db_Mysqli(); |
|
| 29 | - break; |
|
| 30 | - case "pgsql": |
|
| 31 | - $this->adapter = new Db_Pgsql(); |
|
| 32 | - break; |
|
| 33 | - default: |
|
| 34 | - die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 35 | - } |
|
| 26 | + switch (DB_TYPE) { |
|
| 27 | + case "mysql": |
|
| 28 | + $this->adapter = new Db_Mysqli(); |
|
| 29 | + break; |
|
| 30 | + case "pgsql": |
|
| 31 | + $this->adapter = new Db_Pgsql(); |
|
| 32 | + break; |
|
| 33 | + default: |
|
| 34 | + die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if (!$this->adapter) { |
|
| 38 | - print("Error initializing database adapter for " . DB_TYPE); |
|
| 39 | - exit(100); |
|
| 40 | - } |
|
| 37 | + if (!$this->adapter) { |
|
| 38 | + print("Error initializing database adapter for " . DB_TYPE); |
|
| 39 | + exit(100); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : ""); |
|
| 42 | + $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : ""); |
|
| 43 | 43 | |
| 44 | - if (!$this->link) { |
|
| 45 | - print("Error connecting through adapter: " . $this->adapter->last_error()); |
|
| 46 | - exit(101); |
|
| 47 | - } |
|
| 44 | + if (!$this->link) { |
|
| 45 | + print("Error connecting through adapter: " . $this->adapter->last_error()); |
|
| 46 | + exit(101); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - error_reporting($er); |
|
| 50 | - } |
|
| 49 | + error_reporting($er); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // this really shouldn't be used unless a separate PDO connection is needed |
|
| 53 | - // normal usage is Db::pdo()->prepare(...) etc |
|
| 54 | - public function pdo_connect() { |
|
| 52 | + // this really shouldn't be used unless a separate PDO connection is needed |
|
| 53 | + // normal usage is Db::pdo()->prepare(...) etc |
|
| 54 | + public function pdo_connect() { |
|
| 55 | 55 | |
| 56 | - $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : ''; |
|
| 57 | - $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : ''; |
|
| 56 | + $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : ''; |
|
| 57 | + $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : ''; |
|
| 58 | 58 | |
| 59 | - try { |
|
| 60 | - $pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port, |
|
| 61 | - DB_USER, |
|
| 62 | - DB_PASS); |
|
| 63 | - } catch (Exception $e) { |
|
| 64 | - print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>"; |
|
| 65 | - exit(101); |
|
| 66 | - } |
|
| 59 | + try { |
|
| 60 | + $pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port, |
|
| 61 | + DB_USER, |
|
| 62 | + DB_PASS); |
|
| 63 | + } catch (Exception $e) { |
|
| 64 | + print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>"; |
|
| 65 | + exit(101); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 68 | + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 69 | 69 | |
| 70 | - if (DB_TYPE == "pgsql") { |
|
| 70 | + if (DB_TYPE == "pgsql") { |
|
| 71 | 71 | |
| 72 | - $pdo->query("set client_encoding = 'UTF-8'"); |
|
| 73 | - $pdo->query("set datestyle = 'ISO, european'"); |
|
| 74 | - $pdo->query("set TIME ZONE 0"); |
|
| 75 | - $pdo->query("set cpu_tuple_cost = 0.5"); |
|
| 72 | + $pdo->query("set client_encoding = 'UTF-8'"); |
|
| 73 | + $pdo->query("set datestyle = 'ISO, european'"); |
|
| 74 | + $pdo->query("set TIME ZONE 0"); |
|
| 75 | + $pdo->query("set cpu_tuple_cost = 0.5"); |
|
| 76 | 76 | |
| 77 | - } else if (DB_TYPE == "mysql") { |
|
| 78 | - $pdo->query("SET time_zone = '+0:0'"); |
|
| 77 | + } else if (DB_TYPE == "mysql") { |
|
| 78 | + $pdo->query("SET time_zone = '+0:0'"); |
|
| 79 | 79 | |
| 80 | - if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
|
| 81 | - $pdo->query("SET NAMES " . MYSQL_CHARSET); |
|
| 82 | - } |
|
| 83 | - } |
|
| 80 | + if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
|
| 81 | + $pdo->query("SET NAMES " . MYSQL_CHARSET); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return $pdo; |
|
| 86 | - } |
|
| 85 | + return $pdo; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public static function instance() { |
|
| 89 | - if (self::$instance == null) |
|
| 90 | - self::$instance = new self(); |
|
| 88 | + public static function instance() { |
|
| 89 | + if (self::$instance == null) |
|
| 90 | + self::$instance = new self(); |
|
| 91 | 91 | |
| 92 | - return self::$instance; |
|
| 93 | - } |
|
| 92 | + return self::$instance; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - public static function get() { |
|
| 96 | - if (self::$instance == null) |
|
| 97 | - self::$instance = new self(); |
|
| 95 | + public static function get() { |
|
| 96 | + if (self::$instance == null) |
|
| 97 | + self::$instance = new self(); |
|
| 98 | 98 | |
| 99 | - if (!self::$instance->adapter) { |
|
| 100 | - self::$instance->legacy_connect(); |
|
| 101 | - } |
|
| 99 | + if (!self::$instance->adapter) { |
|
| 100 | + self::$instance->legacy_connect(); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - return self::$instance->adapter; |
|
| 104 | - } |
|
| 103 | + return self::$instance->adapter; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - public static function pdo() { |
|
| 107 | - if (self::$instance == null) |
|
| 108 | - self::$instance = new self(); |
|
| 106 | + public static function pdo() { |
|
| 107 | + if (self::$instance == null) |
|
| 108 | + self::$instance = new self(); |
|
| 109 | 109 | |
| 110 | - if (!self::$instance->pdo) { |
|
| 111 | - self::$instance->pdo = self::$instance->pdo_connect(); |
|
| 112 | - } |
|
| 110 | + if (!self::$instance->pdo) { |
|
| 111 | + self::$instance->pdo = self::$instance->pdo_connect(); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return self::$instance->pdo; |
|
| 115 | - } |
|
| 114 | + return self::$instance->pdo; |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | return 0; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ]; |
|
| 41 | + $headers = ["From: $from_combined", "Content-Type: text/plain; charset=UTF-8"]; |
|
| 42 | 42 | |
| 43 | 43 | return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers))); |
| 44 | 44 | } |
@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | $from_combined = $from_name ? "$from_name <$from_address>" : $from_address; |
| 20 | 20 | $to_combined = $to_name ? "$to_name <$to_address>" : $to_address; |
| 21 | 21 | |
| 22 | - if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) |
|
| 23 | - Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message"); |
|
| 22 | + if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) { |
|
| 23 | + Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message"); |
|
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | // HOOK_SEND_MAIL plugin instructions: |
| 26 | 27 | // 1. return 1 or true if mail is handled |
@@ -31,11 +32,13 @@ discard block |
||
| 31 | 32 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) { |
| 32 | 33 | $rc = $p->hook_send_mail($this, $params); |
| 33 | 34 | |
| 34 | - if ($rc == 1) |
|
| 35 | - return $rc; |
|
| 35 | + if ($rc == 1) { |
|
| 36 | + return $rc; |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | - if ($rc == -1) |
|
| 38 | - return 0; |
|
| 39 | + if ($rc == -1) { |
|
| 40 | + return 0; |
|
| 41 | + } |
|
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ]; |
@@ -1,52 +1,52 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Mailer { |
| 3 | - // TODO: support HTML mail (i.e. MIME messages) |
|
| 3 | + // TODO: support HTML mail (i.e. MIME messages) |
|
| 4 | 4 | |
| 5 | - private $last_error = "Unable to send mail: check local configuration."; |
|
| 5 | + private $last_error = "Unable to send mail: check local configuration."; |
|
| 6 | 6 | |
| 7 | - public function mail($params) { |
|
| 7 | + public function mail($params) { |
|
| 8 | 8 | |
| 9 | - $to_name = $params["to_name"]; |
|
| 10 | - $to_address = $params["to_address"]; |
|
| 11 | - $subject = $params["subject"]; |
|
| 12 | - $message = $params["message"]; |
|
| 13 | - $from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME; |
|
| 14 | - $from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS; |
|
| 9 | + $to_name = $params["to_name"]; |
|
| 10 | + $to_address = $params["to_address"]; |
|
| 11 | + $subject = $params["subject"]; |
|
| 12 | + $message = $params["message"]; |
|
| 13 | + $from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME; |
|
| 14 | + $from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS; |
|
| 15 | 15 | |
| 16 | - $additional_headers = $params["headers"] ? $params["headers"] : []; |
|
| 16 | + $additional_headers = $params["headers"] ? $params["headers"] : []; |
|
| 17 | 17 | |
| 18 | - $from_combined = $from_name ? "$from_name <$from_address>" : $from_address; |
|
| 19 | - $to_combined = $to_name ? "$to_name <$to_address>" : $to_address; |
|
| 18 | + $from_combined = $from_name ? "$from_name <$from_address>" : $from_address; |
|
| 19 | + $to_combined = $to_name ? "$to_name <$to_address>" : $to_address; |
|
| 20 | 20 | |
| 21 | - if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) |
|
| 22 | - Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message"); |
|
| 21 | + if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) |
|
| 22 | + Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message"); |
|
| 23 | 23 | |
| 24 | - // HOOK_SEND_MAIL plugin instructions: |
|
| 25 | - // 1. return 1 or true if mail is handled |
|
| 26 | - // 2. return -1 if there's been a fatal error and no further action is allowed |
|
| 27 | - // 3. any other return value will allow cycling to the next handler and, eventually, to default mail() function |
|
| 28 | - // 4. set error message if needed via passed Mailer instance function set_error() |
|
| 24 | + // HOOK_SEND_MAIL plugin instructions: |
|
| 25 | + // 1. return 1 or true if mail is handled |
|
| 26 | + // 2. return -1 if there's been a fatal error and no further action is allowed |
|
| 27 | + // 3. any other return value will allow cycling to the next handler and, eventually, to default mail() function |
|
| 28 | + // 4. set error message if needed via passed Mailer instance function set_error() |
|
| 29 | 29 | |
| 30 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) { |
|
| 31 | - $rc = $p->hook_send_mail($this, $params); |
|
| 30 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) { |
|
| 31 | + $rc = $p->hook_send_mail($this, $params); |
|
| 32 | 32 | |
| 33 | - if ($rc == 1) |
|
| 34 | - return $rc; |
|
| 33 | + if ($rc == 1) |
|
| 34 | + return $rc; |
|
| 35 | 35 | |
| 36 | - if ($rc == -1) |
|
| 37 | - return 0; |
|
| 38 | - } |
|
| 36 | + if ($rc == -1) |
|
| 37 | + return 0; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ]; |
|
| 40 | + $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ]; |
|
| 41 | 41 | |
| 42 | - return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers))); |
|
| 43 | - } |
|
| 42 | + return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers))); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function set_error($message) { |
|
| 46 | - $this->last_error = $message; |
|
| 47 | - } |
|
| 45 | + public function set_error($message) { |
|
| 46 | + $this->last_error = $message; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function error() { |
|
| 50 | - return $this->last_error; |
|
| 51 | - } |
|
| 49 | + public function error() { |
|
| 50 | + return $this->last_error; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | if ($type_name == "bool") { |
| 103 | 103 | return $value == "true"; |
| 104 | 104 | } else if ($type_name == "integer") { |
| 105 | - return (int)$value; |
|
| 105 | + return (int) $value; |
|
| 106 | 106 | } else { |
| 107 | 107 | return $value; |
| 108 | 108 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $value = "false"; |
| 150 | 150 | } |
| 151 | 151 | } else if ($type_name == "integer") { |
| 152 | - $value = (int)$value; |
|
| 152 | + $value = (int) $value; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
@@ -1,30 +1,30 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Db_Prefs { |
| 3 | - private $pdo; |
|
| 4 | - private static $instance; |
|
| 5 | - private $cache; |
|
| 3 | + private $pdo; |
|
| 4 | + private static $instance; |
|
| 5 | + private $cache; |
|
| 6 | 6 | |
| 7 | - public function __construct() { |
|
| 8 | - $this->pdo = Db::pdo(); |
|
| 9 | - $this->cache = array(); |
|
| 7 | + public function __construct() { |
|
| 8 | + $this->pdo = Db::pdo(); |
|
| 9 | + $this->cache = array(); |
|
| 10 | 10 | |
| 11 | - if ($_SESSION["uid"]) $this->cache(); |
|
| 12 | - } |
|
| 11 | + if ($_SESSION["uid"]) $this->cache(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public static function get() { |
|
| 15 | - if (self::$instance == null) |
|
| 16 | - self::$instance = new self(); |
|
| 14 | + public static function get() { |
|
| 15 | + if (self::$instance == null) |
|
| 16 | + self::$instance = new self(); |
|
| 17 | 17 | |
| 18 | - return self::$instance; |
|
| 19 | - } |
|
| 18 | + return self::$instance; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function cache() { |
|
| 22 | - $user_id = $_SESSION["uid"]; |
|
| 23 | - @$profile = $_SESSION["profile"]; |
|
| 21 | + public function cache() { |
|
| 22 | + $user_id = $_SESSION["uid"]; |
|
| 23 | + @$profile = $_SESSION["profile"]; |
|
| 24 | 24 | |
| 25 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 25 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 26 | 26 | |
| 27 | - $sth = $this->pdo->prepare("SELECT |
|
| 27 | + $sth = $this->pdo->prepare("SELECT |
|
| 28 | 28 | value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name |
| 29 | 29 | FROM |
| 30 | 30 | ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types |
@@ -35,35 +35,35 @@ discard block |
||
| 35 | 35 | owner_uid = :uid AND |
| 36 | 36 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name"); |
| 37 | 37 | |
| 38 | - $sth->execute([":profile" => $profile, ":uid" => $user_id]); |
|
| 38 | + $sth->execute([":profile" => $profile, ":uid" => $user_id]); |
|
| 39 | 39 | |
| 40 | - while ($line = $sth->fetch()) { |
|
| 41 | - if ($user_id == $_SESSION["uid"]) { |
|
| 42 | - $pref_name = $line["pref_name"]; |
|
| 40 | + while ($line = $sth->fetch()) { |
|
| 41 | + if ($user_id == $_SESSION["uid"]) { |
|
| 42 | + $pref_name = $line["pref_name"]; |
|
| 43 | 43 | |
| 44 | - $this->cache[$pref_name]["type"] = $line["type_name"]; |
|
| 45 | - $this->cache[$pref_name]["value"] = $line["value"]; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 44 | + $this->cache[$pref_name]["type"] = $line["type_name"]; |
|
| 45 | + $this->cache[$pref_name]["value"] = $line["value"]; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function read($pref_name, $user_id = false, $die_on_error = false) { |
|
| 50 | + public function read($pref_name, $user_id = false, $die_on_error = false) { |
|
| 51 | 51 | |
| 52 | - if (!$user_id) { |
|
| 53 | - $user_id = $_SESSION["uid"]; |
|
| 54 | - @$profile = $_SESSION["profile"]; |
|
| 55 | - } else { |
|
| 56 | - $profile = false; |
|
| 57 | - } |
|
| 52 | + if (!$user_id) { |
|
| 53 | + $user_id = $_SESSION["uid"]; |
|
| 54 | + @$profile = $_SESSION["profile"]; |
|
| 55 | + } else { |
|
| 56 | + $profile = false; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { |
|
| 60 | - $tuple = $this->cache[$pref_name]; |
|
| 61 | - return $this->convert($tuple["value"], $tuple["type"]); |
|
| 62 | - } |
|
| 59 | + if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { |
|
| 60 | + $tuple = $this->cache[$pref_name]; |
|
| 61 | + return $this->convert($tuple["value"], $tuple["type"]); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 64 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 65 | 65 | |
| 66 | - $sth = $this->pdo->prepare("SELECT |
|
| 66 | + $sth = $this->pdo->prepare("SELECT |
|
| 67 | 67 | value,ttrss_prefs_types.type_name as type_name |
| 68 | 68 | FROM |
| 69 | 69 | ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types |
@@ -73,96 +73,96 @@ discard block |
||
| 73 | 73 | ttrss_prefs_types.id = type_id AND |
| 74 | 74 | owner_uid = :uid AND |
| 75 | 75 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name"); |
| 76 | - $sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]); |
|
| 77 | - |
|
| 78 | - if ($row = $sth->fetch()) { |
|
| 79 | - $value = $row["value"]; |
|
| 80 | - $type_name = $row["type_name"]; |
|
| 81 | - |
|
| 82 | - if ($user_id == $_SESSION["uid"]) { |
|
| 83 | - $this->cache[$pref_name]["type"] = $type_name; |
|
| 84 | - $this->cache[$pref_name]["value"] = $value; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this->convert($value, $type_name); |
|
| 88 | - |
|
| 89 | - } else if ($die_on_error) { |
|
| 90 | - user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR); |
|
| 91 | - return null; |
|
| 92 | - } else { |
|
| 93 | - return null; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function convert($value, $type_name) { |
|
| 98 | - if ($type_name == "bool") { |
|
| 99 | - return $value == "true"; |
|
| 100 | - } else if ($type_name == "integer") { |
|
| 101 | - return (int)$value; |
|
| 102 | - } else { |
|
| 103 | - return $value; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
|
| 108 | - if ($strip_tags) $value = strip_tags($value); |
|
| 109 | - |
|
| 110 | - if (!$user_id) { |
|
| 111 | - $user_id = $_SESSION["uid"]; |
|
| 112 | - @$profile = $_SESSION["profile"]; |
|
| 113 | - } else { |
|
| 114 | - $profile = null; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 118 | - |
|
| 119 | - $type_name = ""; |
|
| 120 | - $current_value = ""; |
|
| 121 | - |
|
| 122 | - if (isset($this->cache[$pref_name])) { |
|
| 123 | - $type_name = $this->cache[$pref_name]["type"]; |
|
| 124 | - $current_value = $this->cache[$pref_name]["value"]; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - if (!$type_name) { |
|
| 128 | - $sth = $this->pdo->prepare("SELECT type_name |
|
| 76 | + $sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]); |
|
| 77 | + |
|
| 78 | + if ($row = $sth->fetch()) { |
|
| 79 | + $value = $row["value"]; |
|
| 80 | + $type_name = $row["type_name"]; |
|
| 81 | + |
|
| 82 | + if ($user_id == $_SESSION["uid"]) { |
|
| 83 | + $this->cache[$pref_name]["type"] = $type_name; |
|
| 84 | + $this->cache[$pref_name]["value"] = $value; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + return $this->convert($value, $type_name); |
|
| 88 | + |
|
| 89 | + } else if ($die_on_error) { |
|
| 90 | + user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR); |
|
| 91 | + return null; |
|
| 92 | + } else { |
|
| 93 | + return null; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function convert($value, $type_name) { |
|
| 98 | + if ($type_name == "bool") { |
|
| 99 | + return $value == "true"; |
|
| 100 | + } else if ($type_name == "integer") { |
|
| 101 | + return (int)$value; |
|
| 102 | + } else { |
|
| 103 | + return $value; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
|
| 108 | + if ($strip_tags) $value = strip_tags($value); |
|
| 109 | + |
|
| 110 | + if (!$user_id) { |
|
| 111 | + $user_id = $_SESSION["uid"]; |
|
| 112 | + @$profile = $_SESSION["profile"]; |
|
| 113 | + } else { |
|
| 114 | + $profile = null; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 118 | + |
|
| 119 | + $type_name = ""; |
|
| 120 | + $current_value = ""; |
|
| 121 | + |
|
| 122 | + if (isset($this->cache[$pref_name])) { |
|
| 123 | + $type_name = $this->cache[$pref_name]["type"]; |
|
| 124 | + $current_value = $this->cache[$pref_name]["value"]; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + if (!$type_name) { |
|
| 128 | + $sth = $this->pdo->prepare("SELECT type_name |
|
| 129 | 129 | FROM ttrss_prefs,ttrss_prefs_types |
| 130 | 130 | WHERE pref_name = ? AND type_id = ttrss_prefs_types.id"); |
| 131 | - $sth->execute([$pref_name]); |
|
| 132 | - |
|
| 133 | - if ($row = $sth->fetch()) |
|
| 134 | - $type_name = $row["type_name"]; |
|
| 135 | - |
|
| 136 | - } else if ($current_value == $value) { |
|
| 137 | - return; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ($type_name) { |
|
| 141 | - if ($type_name == "bool") { |
|
| 142 | - if ($value == "1" || $value == "true") { |
|
| 143 | - $value = "true"; |
|
| 144 | - } else { |
|
| 145 | - $value = "false"; |
|
| 146 | - } |
|
| 147 | - } else if ($type_name == "integer") { |
|
| 148 | - $value = (int)$value; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
|
| 152 | - $value = 'UTC'; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET |
|
| 131 | + $sth->execute([$pref_name]); |
|
| 132 | + |
|
| 133 | + if ($row = $sth->fetch()) |
|
| 134 | + $type_name = $row["type_name"]; |
|
| 135 | + |
|
| 136 | + } else if ($current_value == $value) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ($type_name) { |
|
| 141 | + if ($type_name == "bool") { |
|
| 142 | + if ($value == "1" || $value == "true") { |
|
| 143 | + $value = "true"; |
|
| 144 | + } else { |
|
| 145 | + $value = "false"; |
|
| 146 | + } |
|
| 147 | + } else if ($type_name == "integer") { |
|
| 148 | + $value = (int)$value; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
|
| 152 | + $value = 'UTC'; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET |
|
| 156 | 156 | value = :value WHERE pref_name = :pref_name |
| 157 | 157 | AND (profile = :profile OR (:profile IS NULL AND profile IS NULL)) |
| 158 | 158 | AND owner_uid = :uid"); |
| 159 | 159 | |
| 160 | - $sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]); |
|
| 160 | + $sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]); |
|
| 161 | 161 | |
| 162 | - if ($user_id == $_SESSION["uid"]) { |
|
| 163 | - $this->cache[$pref_name]["type"] = $type_name; |
|
| 164 | - $this->cache[$pref_name]["value"] = $value; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } |
|
| 162 | + if ($user_id == $_SESSION["uid"]) { |
|
| 163 | + $this->cache[$pref_name]["type"] = $type_name; |
|
| 164 | + $this->cache[$pref_name]["value"] = $value; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | } |
@@ -8,12 +8,15 @@ discard block |
||
| 8 | 8 | $this->pdo = Db::pdo(); |
| 9 | 9 | $this->cache = array(); |
| 10 | 10 | |
| 11 | - if ($_SESSION["uid"]) $this->cache(); |
|
| 11 | + if ($_SESSION["uid"]) { |
|
| 12 | + $this->cache(); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | public static function get() { |
| 15 | - if (self::$instance == null) |
|
| 16 | - self::$instance = new self(); |
|
| 17 | + if (self::$instance == null) { |
|
| 18 | + self::$instance = new self(); |
|
| 19 | + } |
|
| 17 | 20 | |
| 18 | 21 | return self::$instance; |
| 19 | 22 | } |
@@ -22,7 +25,9 @@ discard block |
||
| 22 | 25 | $user_id = $_SESSION["uid"]; |
| 23 | 26 | @$profile = $_SESSION["profile"]; |
| 24 | 27 | |
| 25 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 28 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
| 29 | + $profile = null; |
|
| 30 | + } |
|
| 26 | 31 | |
| 27 | 32 | $sth = $this->pdo->prepare("SELECT |
| 28 | 33 | value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name |
@@ -61,7 +66,9 @@ discard block |
||
| 61 | 66 | return $this->convert($tuple["value"], $tuple["type"]); |
| 62 | 67 | } |
| 63 | 68 | |
| 64 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 69 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
| 70 | + $profile = null; |
|
| 71 | + } |
|
| 65 | 72 | |
| 66 | 73 | $sth = $this->pdo->prepare("SELECT |
| 67 | 74 | value,ttrss_prefs_types.type_name as type_name |
@@ -105,7 +112,9 @@ discard block |
||
| 105 | 112 | } |
| 106 | 113 | |
| 107 | 114 | public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
| 108 | - if ($strip_tags) $value = strip_tags($value); |
|
| 115 | + if ($strip_tags) { |
|
| 116 | + $value = strip_tags($value); |
|
| 117 | + } |
|
| 109 | 118 | |
| 110 | 119 | if (!$user_id) { |
| 111 | 120 | $user_id = $_SESSION["uid"]; |
@@ -114,7 +123,9 @@ discard block |
||
| 114 | 123 | $profile = null; |
| 115 | 124 | } |
| 116 | 125 | |
| 117 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
| 126 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
| 127 | + $profile = null; |
|
| 128 | + } |
|
| 118 | 129 | |
| 119 | 130 | $type_name = ""; |
| 120 | 131 | $current_value = ""; |
@@ -130,8 +141,9 @@ discard block |
||
| 130 | 141 | WHERE pref_name = ? AND type_id = ttrss_prefs_types.id"); |
| 131 | 142 | $sth->execute([$pref_name]); |
| 132 | 143 | |
| 133 | - if ($row = $sth->fetch()) |
|
| 134 | - $type_name = $row["type_name"]; |
|
| 144 | + if ($row = $sth->fetch()) { |
|
| 145 | + $type_name = $row["type_name"]; |
|
| 146 | + } |
|
| 135 | 147 | |
| 136 | 148 | } else if ($current_value == $value) { |
| 137 | 149 | return; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | return $this->link; |
| 16 | 16 | } else { |
| 17 | - print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); |
|
| 17 | + print("Unable to connect to database (as $user to $host, database $db): ".mysqli_connect_error()); |
|
| 18 | 18 | exit(102); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $this->last_error = @mysqli_error($this->link); |
| 32 | 32 | |
| 33 | 33 | @mysqli_query($this->link, "ROLLBACK"); |
| 34 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 34 | + user_error("Query $query failed: ".($this->link ? $this->last_error : "No connection"), |
|
| 35 | 35 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | $this->last_error = @mysqli_error($this->link); |
| 32 | 32 | |
| 33 | 33 | @mysqli_query($this->link, "ROLLBACK"); |
| 34 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 34 | + user_error("query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 35 | 35 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -1,85 +1,85 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Db_Mysqli implements IDb { |
| 3 | - private $link; |
|
| 4 | - private $last_error; |
|
| 5 | - |
|
| 6 | - public function connect($host, $user, $pass, $db, $port) { |
|
| 7 | - if ($port) |
|
| 8 | - $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
| 9 | - else |
|
| 10 | - $this->link = mysqli_connect($host, $user, $pass, $db); |
|
| 11 | - |
|
| 12 | - if ($this->link) { |
|
| 13 | - $this->init(); |
|
| 14 | - |
|
| 15 | - return $this->link; |
|
| 16 | - } else { |
|
| 17 | - print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); |
|
| 18 | - exit(102); |
|
| 19 | - } |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function escape_string($s, $strip_tags = true) { |
|
| 23 | - if ($strip_tags) $s = strip_tags($s); |
|
| 24 | - |
|
| 25 | - return mysqli_real_escape_string($this->link, $s); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function query($query, $die_on_error = true) { |
|
| 29 | - $result = @mysqli_query($this->link, $query); |
|
| 30 | - if (!$result) { |
|
| 31 | - $this->last_error = @mysqli_error($this->link); |
|
| 32 | - |
|
| 33 | - @mysqli_query($this->link, "ROLLBACK"); |
|
| 34 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 35 | - $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - return $result; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function fetch_assoc($result) { |
|
| 42 | - return mysqli_fetch_assoc($result); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - public function num_rows($result) { |
|
| 47 | - return mysqli_num_rows($result); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function fetch_result($result, $row, $param) { |
|
| 51 | - if (mysqli_data_seek($result, $row)) { |
|
| 52 | - $line = mysqli_fetch_assoc($result); |
|
| 53 | - return $line[$param]; |
|
| 54 | - } else { |
|
| 55 | - return false; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function close() { |
|
| 60 | - return mysqli_close($this->link); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function affected_rows($result) { |
|
| 64 | - return mysqli_affected_rows($this->link); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public function last_error() { |
|
| 68 | - return mysqli_error($this->link); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function last_query_error() { |
|
| 72 | - return $this->last_error; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function init() { |
|
| 76 | - $this->query("SET time_zone = '+0:0'"); |
|
| 77 | - |
|
| 78 | - if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
|
| 79 | - mysqli_set_charset($this->link, MYSQL_CHARSET); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 3 | + private $link; |
|
| 4 | + private $last_error; |
|
| 5 | + |
|
| 6 | + public function connect($host, $user, $pass, $db, $port) { |
|
| 7 | + if ($port) |
|
| 8 | + $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
| 9 | + else |
|
| 10 | + $this->link = mysqli_connect($host, $user, $pass, $db); |
|
| 11 | + |
|
| 12 | + if ($this->link) { |
|
| 13 | + $this->init(); |
|
| 14 | + |
|
| 15 | + return $this->link; |
|
| 16 | + } else { |
|
| 17 | + print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); |
|
| 18 | + exit(102); |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function escape_string($s, $strip_tags = true) { |
|
| 23 | + if ($strip_tags) $s = strip_tags($s); |
|
| 24 | + |
|
| 25 | + return mysqli_real_escape_string($this->link, $s); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function query($query, $die_on_error = true) { |
|
| 29 | + $result = @mysqli_query($this->link, $query); |
|
| 30 | + if (!$result) { |
|
| 31 | + $this->last_error = @mysqli_error($this->link); |
|
| 32 | + |
|
| 33 | + @mysqli_query($this->link, "ROLLBACK"); |
|
| 34 | + user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 35 | + $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + return $result; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function fetch_assoc($result) { |
|
| 42 | + return mysqli_fetch_assoc($result); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + public function num_rows($result) { |
|
| 47 | + return mysqli_num_rows($result); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function fetch_result($result, $row, $param) { |
|
| 51 | + if (mysqli_data_seek($result, $row)) { |
|
| 52 | + $line = mysqli_fetch_assoc($result); |
|
| 53 | + return $line[$param]; |
|
| 54 | + } else { |
|
| 55 | + return false; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function close() { |
|
| 60 | + return mysqli_close($this->link); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function affected_rows($result) { |
|
| 64 | + return mysqli_affected_rows($this->link); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public function last_error() { |
|
| 68 | + return mysqli_error($this->link); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function last_query_error() { |
|
| 72 | + return $this->last_error; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function init() { |
|
| 76 | + $this->query("SET time_zone = '+0:0'"); |
|
| 77 | + |
|
| 78 | + if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
|
| 79 | + mysqli_set_charset($this->link, MYSQL_CHARSET); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
@@ -4,10 +4,11 @@ discard block |
||
| 4 | 4 | private $last_error; |
| 5 | 5 | |
| 6 | 6 | public function connect($host, $user, $pass, $db, $port) { |
| 7 | - if ($port) |
|
| 8 | - $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
| 9 | - else |
|
| 10 | - $this->link = mysqli_connect($host, $user, $pass, $db); |
|
| 7 | + if ($port) { |
|
| 8 | + $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
| 9 | + } else { |
|
| 10 | + $this->link = mysqli_connect($host, $user, $pass, $db); |
|
| 11 | + } |
|
| 11 | 12 | |
| 12 | 13 | if ($this->link) { |
| 13 | 14 | $this->init(); |
@@ -20,7 +21,9 @@ discard block |
||
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | public function escape_string($s, $strip_tags = true) { |
| 23 | - if ($strip_tags) $s = strip_tags($s); |
|
| 24 | + if ($strip_tags) { |
|
| 25 | + $s = strip_tags($s); |
|
| 26 | + } |
|
| 24 | 27 | |
| 25 | 28 | return mysqli_real_escape_string($this->link, $s); |
| 26 | 29 | } |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (is_numeric($port) && $port > 0) { |
| 18 | - $string = "$string port=" . $port; |
|
| 18 | + $string = "$string port=".$port; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $this->link = pg_connect($string); |
| 22 | 22 | |
| 23 | 23 | if (!$this->link) { |
| 24 | - print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); |
|
| 24 | + print("Unable to connect to database (as $user to $host, database $db):".pg_last_error()); |
|
| 25 | 25 | exit(102); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | @pg_query($this->link, "ROLLBACK"); |
| 46 | 46 | $query = htmlspecialchars($query); // just in case |
| 47 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 47 | + user_error("Query $query failed: ".($this->link ? $this->last_error : "No connection"), |
|
| 48 | 48 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
| 49 | 49 | } |
| 50 | 50 | return $result; |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | @pg_query($this->link, "ROLLBACK"); |
| 46 | 46 | $query = htmlspecialchars($query); // just in case |
| 47 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 47 | + user_error("query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 48 | 48 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
| 49 | 49 | } |
| 50 | 50 | return $result; |
@@ -1,91 +1,91 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Db_Pgsql implements IDb { |
| 3 | - private $link; |
|
| 4 | - private $last_error; |
|
| 3 | + private $link; |
|
| 4 | + private $last_error; |
|
| 5 | 5 | |
| 6 | - public function connect($host, $user, $pass, $db, $port) { |
|
| 7 | - $string = "dbname=$db user=$user"; |
|
| 6 | + public function connect($host, $user, $pass, $db, $port) { |
|
| 7 | + $string = "dbname=$db user=$user"; |
|
| 8 | 8 | |
| 9 | - if ($pass) { |
|
| 10 | - $string .= " password=$pass"; |
|
| 11 | - } |
|
| 9 | + if ($pass) { |
|
| 10 | + $string .= " password=$pass"; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - if ($host) { |
|
| 14 | - $string .= " host=$host"; |
|
| 15 | - } |
|
| 13 | + if ($host) { |
|
| 14 | + $string .= " host=$host"; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - if (is_numeric($port) && $port > 0) { |
|
| 18 | - $string = "$string port=" . $port; |
|
| 19 | - } |
|
| 17 | + if (is_numeric($port) && $port > 0) { |
|
| 18 | + $string = "$string port=" . $port; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $this->link = pg_connect($string); |
|
| 21 | + $this->link = pg_connect($string); |
|
| 22 | 22 | |
| 23 | - if (!$this->link) { |
|
| 24 | - print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); |
|
| 25 | - exit(102); |
|
| 26 | - } |
|
| 23 | + if (!$this->link) { |
|
| 24 | + print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); |
|
| 25 | + exit(102); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $this->init(); |
|
| 28 | + $this->init(); |
|
| 29 | 29 | |
| 30 | - return $this->link; |
|
| 31 | - } |
|
| 30 | + return $this->link; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function escape_string($s, $strip_tags = true) { |
|
| 34 | - if ($strip_tags) $s = strip_tags($s); |
|
| 33 | + public function escape_string($s, $strip_tags = true) { |
|
| 34 | + if ($strip_tags) $s = strip_tags($s); |
|
| 35 | 35 | |
| 36 | - return pg_escape_string($s); |
|
| 37 | - } |
|
| 36 | + return pg_escape_string($s); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function query($query, $die_on_error = true) { |
|
| 40 | - $result = @pg_query($this->link, $query); |
|
| 39 | + public function query($query, $die_on_error = true) { |
|
| 40 | + $result = @pg_query($this->link, $query); |
|
| 41 | 41 | |
| 42 | - if (!$result) { |
|
| 43 | - $this->last_error = @pg_last_error($this->link); |
|
| 42 | + if (!$result) { |
|
| 43 | + $this->last_error = @pg_last_error($this->link); |
|
| 44 | 44 | |
| 45 | - @pg_query($this->link, "ROLLBACK"); |
|
| 46 | - $query = htmlspecialchars($query); // just in case |
|
| 47 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 48 | - $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
|
| 49 | - } |
|
| 50 | - return $result; |
|
| 51 | - } |
|
| 45 | + @pg_query($this->link, "ROLLBACK"); |
|
| 46 | + $query = htmlspecialchars($query); // just in case |
|
| 47 | + user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
| 48 | + $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
|
| 49 | + } |
|
| 50 | + return $result; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function fetch_assoc($result) { |
|
| 54 | - return pg_fetch_assoc($result); |
|
| 55 | - } |
|
| 53 | + public function fetch_assoc($result) { |
|
| 54 | + return pg_fetch_assoc($result); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - public function num_rows($result) { |
|
| 59 | - return pg_num_rows($result); |
|
| 60 | - } |
|
| 58 | + public function num_rows($result) { |
|
| 59 | + return pg_num_rows($result); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function fetch_result($result, $row, $param) { |
|
| 63 | - return pg_fetch_result($result, $row, $param); |
|
| 64 | - } |
|
| 62 | + public function fetch_result($result, $row, $param) { |
|
| 63 | + return pg_fetch_result($result, $row, $param); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function close() { |
|
| 67 | - return pg_close($this->link); |
|
| 68 | - } |
|
| 66 | + public function close() { |
|
| 67 | + return pg_close($this->link); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function affected_rows($result) { |
|
| 71 | - return pg_affected_rows($result); |
|
| 72 | - } |
|
| 70 | + public function affected_rows($result) { |
|
| 71 | + return pg_affected_rows($result); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function last_error() { |
|
| 75 | - return pg_last_error($this->link); |
|
| 76 | - } |
|
| 74 | + public function last_error() { |
|
| 75 | + return pg_last_error($this->link); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function last_query_error() { |
|
| 79 | - return $this->last_error; |
|
| 80 | - } |
|
| 78 | + public function last_query_error() { |
|
| 79 | + return $this->last_error; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function init() { |
|
| 83 | - $this->query("set client_encoding = 'UTF-8'"); |
|
| 84 | - pg_set_client_encoding("UNICODE"); |
|
| 85 | - $this->query("set datestyle = 'ISO, european'"); |
|
| 86 | - $this->query("set TIME ZONE 0"); |
|
| 87 | - $this->query("set cpu_tuple_cost = 0.5"); |
|
| 82 | + public function init() { |
|
| 83 | + $this->query("set client_encoding = 'UTF-8'"); |
|
| 84 | + pg_set_client_encoding("UNICODE"); |
|
| 85 | + $this->query("set datestyle = 'ISO, european'"); |
|
| 86 | + $this->query("set TIME ZONE 0"); |
|
| 87 | + $this->query("set cpu_tuple_cost = 0.5"); |
|
| 88 | 88 | |
| 89 | - return true; |
|
| 90 | - } |
|
| 89 | + return true; |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -31,7 +31,9 @@ |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function escape_string($s, $strip_tags = true) { |
| 34 | - if ($strip_tags) $s = strip_tags($s); |
|
| 34 | + if ($strip_tags) { |
|
| 35 | + $s = strip_tags($s); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | return pg_escape_string($s); |
| 37 | 39 | } |
@@ -218,16 +218,16 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $override_order = false; |
| 220 | 220 | switch (clean($_REQUEST["order_by"])) { |
| 221 | - case "title": |
|
| 222 | - $override_order = "ttrss_entries.title, date_entered, updated"; |
|
| 223 | - break; |
|
| 224 | - case "date_reverse": |
|
| 225 | - $override_order = "score DESC, date_entered, updated"; |
|
| 226 | - $skip_first_id_check = true; |
|
| 227 | - break; |
|
| 228 | - case "feed_dates": |
|
| 229 | - $override_order = "updated DESC"; |
|
| 230 | - break; |
|
| 221 | + case "title": |
|
| 222 | + $override_order = "ttrss_entries.title, date_entered, updated"; |
|
| 223 | + break; |
|
| 224 | + case "date_reverse": |
|
| 225 | + $override_order = "score DESC, date_entered, updated"; |
|
| 226 | + $skip_first_id_check = true; |
|
| 227 | + break; |
|
| 228 | + case "feed_dates": |
|
| 229 | + $override_order = "updated DESC"; |
|
| 230 | + break; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /* do not rely on params below */ |
@@ -259,32 +259,32 @@ discard block |
||
| 259 | 259 | $set_to = ""; |
| 260 | 260 | |
| 261 | 261 | switch ($field_raw) { |
| 262 | - case 0: |
|
| 263 | - $field = "marked"; |
|
| 264 | - $additional_fields = ",last_marked = NOW()"; |
|
| 265 | - break; |
|
| 266 | - case 1: |
|
| 267 | - $field = "published"; |
|
| 268 | - $additional_fields = ",last_published = NOW()"; |
|
| 269 | - break; |
|
| 270 | - case 2: |
|
| 271 | - $field = "unread"; |
|
| 272 | - $additional_fields = ",last_read = NOW()"; |
|
| 273 | - break; |
|
| 274 | - case 3: |
|
| 275 | - $field = "note"; |
|
| 262 | + case 0: |
|
| 263 | + $field = "marked"; |
|
| 264 | + $additional_fields = ",last_marked = NOW()"; |
|
| 265 | + break; |
|
| 266 | + case 1: |
|
| 267 | + $field = "published"; |
|
| 268 | + $additional_fields = ",last_published = NOW()"; |
|
| 269 | + break; |
|
| 270 | + case 2: |
|
| 271 | + $field = "unread"; |
|
| 272 | + $additional_fields = ",last_read = NOW()"; |
|
| 273 | + break; |
|
| 274 | + case 3: |
|
| 275 | + $field = "note"; |
|
| 276 | 276 | }; |
| 277 | 277 | |
| 278 | 278 | switch ($mode) { |
| 279 | - case 1: |
|
| 280 | - $set_to = "true"; |
|
| 281 | - break; |
|
| 282 | - case 0: |
|
| 283 | - $set_to = "false"; |
|
| 284 | - break; |
|
| 285 | - case 2: |
|
| 286 | - $set_to = "NOT $field"; |
|
| 287 | - break; |
|
| 279 | + case 1: |
|
| 280 | + $set_to = "true"; |
|
| 281 | + break; |
|
| 282 | + case 0: |
|
| 283 | + $set_to = "false"; |
|
| 284 | + break; |
|
| 285 | + case 2: |
|
| 286 | + $set_to = "NOT $field"; |
|
| 287 | + break; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if ($field == "note") $set_to = $this->pdo->quote($data); |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (get_pref("ENABLE_API_ACCESS", $uid)) { |
| 77 | - if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
| 77 | + if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
| 78 | 78 | $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
| 79 | 79 | "api_level" => self::API_LEVEL)); |
| 80 | 80 | } else if (authenticate_user($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password |
| 81 | - $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 81 | + $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 82 | 82 | "api_level" => self::API_LEVEL)); |
| 83 | 83 | } else { // else we are not logged in |
| 84 | 84 | user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - foreach (array(-2,-1,0) as $cat_id) { |
|
| 172 | + foreach (array(-2, -1, 0) as $cat_id) { |
|
| 173 | 173 | if ($include_empty || !$this->isCategoryEmpty($cat_id)) { |
| 174 | 174 | $unread = getFeedUnread($cat_id, true); |
| 175 | 175 | |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
| 192 | 192 | |
| 193 | - $limit = (int)clean($_REQUEST["limit"]); |
|
| 193 | + $limit = (int) clean($_REQUEST["limit"]); |
|
| 194 | 194 | |
| 195 | 195 | if (!$limit || $limit >= 200) $limit = 200; |
| 196 | 196 | |
| 197 | - $offset = (int)clean($_REQUEST["skip"]); |
|
| 197 | + $offset = (int) clean($_REQUEST["skip"]); |
|
| 198 | 198 | $filter = clean($_REQUEST["filter"]); |
| 199 | 199 | $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); |
| 200 | 200 | $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | /* all_articles, unread, adaptive, marked, updated */ |
| 203 | 203 | $view_mode = clean($_REQUEST["view_mode"]); |
| 204 | 204 | $include_attachments = API::param_to_bool(clean($_REQUEST["include_attachments"])); |
| 205 | - $since_id = (int)clean($_REQUEST["since_id"]); |
|
| 205 | + $since_id = (int) clean($_REQUEST["since_id"]); |
|
| 206 | 206 | $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
| 207 | 207 | $sanitize_content = !isset($_REQUEST["sanitize"]) || |
| 208 | 208 | API::param_to_bool($_REQUEST["sanitize"]); |
| 209 | 209 | $force_update = API::param_to_bool(clean($_REQUEST["force_update"])); |
| 210 | 210 | $has_sandbox = API::param_to_bool(clean($_REQUEST["has_sandbox"])); |
| 211 | - $excerpt_length = (int)clean($_REQUEST["excerpt_length"]); |
|
| 212 | - $check_first_id = (int)clean($_REQUEST["check_first_id"]); |
|
| 211 | + $excerpt_length = (int) clean($_REQUEST["excerpt_length"]); |
|
| 212 | + $check_first_id = (int) clean($_REQUEST["check_first_id"]); |
|
| 213 | 213 | $include_header = API::param_to_bool(clean($_REQUEST["include_header"])); |
| 214 | 214 | |
| 215 | 215 | $_SESSION['hasSandbox'] = $has_sandbox; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
| 254 | 254 | $mode = (int) clean($_REQUEST["mode"]); |
| 255 | 255 | $data = clean($_REQUEST["data"]); |
| 256 | - $field_raw = (int)clean($_REQUEST["field"]); |
|
| 256 | + $field_raw = (int) clean($_REQUEST["field"]); |
|
| 257 | 257 | |
| 258 | 258 | $field = ""; |
| 259 | 259 | $set_to = ""; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | "updated" => (int) strtotime($line["updated"]), |
| 361 | 361 | "feed_id" => $line["feed_id"], |
| 362 | 362 | "attachments" => $attachments, |
| 363 | - "score" => (int)$line["score"], |
|
| 363 | + "score" => (int) $line["score"], |
|
| 364 | 364 | "feed_title" => $line["feed_title"], |
| 365 | 365 | "note" => $line["note"], |
| 366 | 366 | "lang" => $line["lang"] |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | public function getLabels() { |
| 437 | - $article_id = (int)clean($_REQUEST['article_id']); |
|
| 437 | + $article_id = (int) clean($_REQUEST['article_id']); |
|
| 438 | 438 | |
| 439 | 439 | $rv = array(); |
| 440 | 440 | |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | array_push($rv, array( |
| 462 | - "id" => (int)Labels::label_to_feed_id($line['id']), |
|
| 462 | + "id" => (int) Labels::label_to_feed_id($line['id']), |
|
| 463 | 463 | "caption" => $line['caption'], |
| 464 | 464 | "fg_color" => $line['fg_color'], |
| 465 | 465 | "bg_color" => $line['bg_color'], |
@@ -644,10 +644,10 @@ discard block |
||
| 644 | 644 | $row = array( |
| 645 | 645 | "feed_url" => $line["feed_url"], |
| 646 | 646 | "title" => $line["title"], |
| 647 | - "id" => (int)$line["id"], |
|
| 648 | - "unread" => (int)$unread, |
|
| 647 | + "id" => (int) $line["id"], |
|
| 648 | + "unread" => (int) $unread, |
|
| 649 | 649 | "has_icon" => $has_icon, |
| 650 | - "cat_id" => (int)$line["cat_id"], |
|
| 650 | + "cat_id" => (int) $line["cat_id"], |
|
| 651 | 651 | "last_updated" => (int) strtotime($line["last_updated"]), |
| 652 | 652 | "order_id" => (int) $line["order_id"], |
| 653 | 653 | ); |
@@ -748,12 +748,12 @@ discard block |
||
| 748 | 748 | if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
| 749 | 749 | |
| 750 | 750 | $headline_row = array( |
| 751 | - "id" => (int)$line["id"], |
|
| 751 | + "id" => (int) $line["id"], |
|
| 752 | 752 | "guid" => $line["guid"], |
| 753 | 753 | "unread" => API::param_to_bool($line["unread"]), |
| 754 | 754 | "marked" => API::param_to_bool($line["marked"]), |
| 755 | 755 | "published" => API::param_to_bool($line["published"]), |
| 756 | - "updated" => (int)strtotime($line["updated"]), |
|
| 756 | + "updated" => (int) strtotime($line["updated"]), |
|
| 757 | 757 | "is_updated" => $is_updated, |
| 758 | 758 | "title" => $line["title"], |
| 759 | 759 | "link" => $line["link"], |
@@ -786,17 +786,16 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $headline_row["labels"] = $labels; |
| 788 | 788 | |
| 789 | - $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : |
|
| 790 | - $feed_title; |
|
| 789 | + $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title; |
|
| 791 | 790 | |
| 792 | - $headline_row["comments_count"] = (int)$line["num_comments"]; |
|
| 791 | + $headline_row["comments_count"] = (int) $line["num_comments"]; |
|
| 793 | 792 | $headline_row["comments_link"] = $line["comments"]; |
| 794 | 793 | |
| 795 | 794 | $headline_row["always_display_attachments"] = API::param_to_bool($line["always_display_enclosures"]); |
| 796 | 795 | |
| 797 | 796 | $headline_row["author"] = $line["author"]; |
| 798 | 797 | |
| 799 | - $headline_row["score"] = (int)$line["score"]; |
|
| 798 | + $headline_row["score"] = (int) $line["score"]; |
|
| 800 | 799 | $headline_row["note"] = $line["note"]; |
| 801 | 800 | $headline_row["lang"] = $line["lang"]; |
| 802 | 801 | |
@@ -858,7 +857,7 @@ discard block |
||
| 858 | 857 | $_REQUEST['mode'] = 2; |
| 859 | 858 | $_REQUEST['force_show_empty'] = $include_empty; |
| 860 | 859 | |
| 861 | - if ($pf){ |
|
| 860 | + if ($pf) { |
|
| 862 | 861 | $data = $pf->makefeedtree(); |
| 863 | 862 | $this->wrap(self::STATUS_OK, array("categories" => $data)); |
| 864 | 863 | } else { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $set_to = "false"; |
| 284 | 284 | break; |
| 285 | 285 | case 2: |
| 286 | - $set_to = "NOT $field"; |
|
| 286 | + $set_to = "not $field"; |
|
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | /* Real feeds */ |
| 608 | 608 | |
| 609 | 609 | if ($limit) { |
| 610 | - $limit_qpart = "LIMIT $limit OFFSET $offset"; |
|
| 610 | + $limit_qpart = "limit $limit OFFSET $offset"; |
|
| 611 | 611 | } else { |
| 612 | 612 | $limit_qpart = ""; |
| 613 | 613 | } |
@@ -1,145 +1,145 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class API extends Handler { |
| 3 | 3 | |
| 4 | - const API_LEVEL = 14; |
|
| 5 | - |
|
| 6 | - const STATUS_OK = 0; |
|
| 7 | - const STATUS_ERR = 1; |
|
| 8 | - |
|
| 9 | - private $seq; |
|
| 10 | - |
|
| 11 | - public static function param_to_bool($p) { |
|
| 12 | - return $p && ($p !== "f" && $p !== "false"); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - public function before($method) { |
|
| 16 | - if (parent::before($method)) { |
|
| 17 | - header("Content-Type: text/json"); |
|
| 18 | - |
|
| 19 | - if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") { |
|
| 20 | - $this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN')); |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) { |
|
| 25 | - $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED')); |
|
| 26 | - return false; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - $this->seq = (int) clean($_REQUEST['seq']); |
|
| 30 | - |
|
| 31 | - return true; |
|
| 32 | - } |
|
| 33 | - return false; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function wrap($status, $reply) { |
|
| 37 | - print json_encode(array("seq" => $this->seq, |
|
| 38 | - "status" => $status, |
|
| 39 | - "content" => $reply)); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function getVersion() { |
|
| 43 | - $rv = array("version" => VERSION); |
|
| 44 | - $this->wrap(self::STATUS_OK, $rv); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function getApiLevel() { |
|
| 48 | - $rv = array("level" => self::API_LEVEL); |
|
| 49 | - $this->wrap(self::STATUS_OK, $rv); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function login() { |
|
| 53 | - @session_destroy(); |
|
| 54 | - @session_start(); |
|
| 55 | - |
|
| 56 | - $login = clean($_REQUEST["user"]); |
|
| 57 | - $password = clean($_REQUEST["password"]); |
|
| 58 | - $password_base64 = base64_decode(clean($_REQUEST["password"])); |
|
| 59 | - |
|
| 60 | - if (SINGLE_USER_MODE) $login = "admin"; |
|
| 61 | - |
|
| 62 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
| 63 | - $sth->execute([$login]); |
|
| 64 | - |
|
| 65 | - if ($row = $sth->fetch()) { |
|
| 66 | - $uid = $row["id"]; |
|
| 67 | - } else { |
|
| 68 | - $uid = 0; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (!$uid) { |
|
| 72 | - $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR")); |
|
| 73 | - return; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if (get_pref("ENABLE_API_ACCESS", $uid)) { |
|
| 77 | - if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
| 78 | - $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 79 | - "api_level" => self::API_LEVEL)); |
|
| 80 | - } else if (authenticate_user($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password |
|
| 81 | - $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 82 | - "api_level" => self::API_LEVEL)); |
|
| 83 | - } else { // else we are not logged in |
|
| 84 | - user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); |
|
| 85 | - $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR")); |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - $this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED")); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - public function logout() { |
|
| 94 | - logout_user(); |
|
| 95 | - $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - public function isLoggedIn() { |
|
| 99 | - $this->wrap(self::STATUS_OK, array("status" => $_SESSION["uid"] != '')); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - public function getUnread() { |
|
| 103 | - $feed_id = clean($_REQUEST["feed_id"]); |
|
| 104 | - $is_cat = clean($_REQUEST["is_cat"]); |
|
| 105 | - |
|
| 106 | - if ($feed_id) { |
|
| 107 | - $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat))); |
|
| 108 | - } else { |
|
| 109 | - $this->wrap(self::STATUS_OK, array("unread" => Feeds::getGlobalUnread())); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /* Method added for ttrss-reader for Android */ |
|
| 114 | - public function getCounters() { |
|
| 115 | - $this->wrap(self::STATUS_OK, Counters::getAllCounters()); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function getFeeds() { |
|
| 119 | - $cat_id = clean($_REQUEST["cat_id"]); |
|
| 120 | - $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); |
|
| 121 | - $limit = (int) clean($_REQUEST["limit"]); |
|
| 122 | - $offset = (int) clean($_REQUEST["offset"]); |
|
| 123 | - $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
|
| 124 | - |
|
| 125 | - $feeds = $this->api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested); |
|
| 126 | - |
|
| 127 | - $this->wrap(self::STATUS_OK, $feeds); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - public function getCategories() { |
|
| 131 | - $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); |
|
| 132 | - $enable_nested = API::param_to_bool(clean($_REQUEST["enable_nested"])); |
|
| 133 | - $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); |
|
| 134 | - |
|
| 135 | - // TODO do not return empty categories, return Uncategorized and standard virtual cats |
|
| 136 | - |
|
| 137 | - if ($enable_nested) |
|
| 138 | - $nested_qpart = "parent_cat IS NULL"; |
|
| 139 | - else |
|
| 140 | - $nested_qpart = "true"; |
|
| 141 | - |
|
| 142 | - $sth = $this->pdo->prepare("SELECT |
|
| 4 | + const API_LEVEL = 14; |
|
| 5 | + |
|
| 6 | + const STATUS_OK = 0; |
|
| 7 | + const STATUS_ERR = 1; |
|
| 8 | + |
|
| 9 | + private $seq; |
|
| 10 | + |
|
| 11 | + public static function param_to_bool($p) { |
|
| 12 | + return $p && ($p !== "f" && $p !== "false"); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + public function before($method) { |
|
| 16 | + if (parent::before($method)) { |
|
| 17 | + header("Content-Type: text/json"); |
|
| 18 | + |
|
| 19 | + if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") { |
|
| 20 | + $this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN')); |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) { |
|
| 25 | + $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED')); |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + $this->seq = (int) clean($_REQUEST['seq']); |
|
| 30 | + |
|
| 31 | + return true; |
|
| 32 | + } |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function wrap($status, $reply) { |
|
| 37 | + print json_encode(array("seq" => $this->seq, |
|
| 38 | + "status" => $status, |
|
| 39 | + "content" => $reply)); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function getVersion() { |
|
| 43 | + $rv = array("version" => VERSION); |
|
| 44 | + $this->wrap(self::STATUS_OK, $rv); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function getApiLevel() { |
|
| 48 | + $rv = array("level" => self::API_LEVEL); |
|
| 49 | + $this->wrap(self::STATUS_OK, $rv); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function login() { |
|
| 53 | + @session_destroy(); |
|
| 54 | + @session_start(); |
|
| 55 | + |
|
| 56 | + $login = clean($_REQUEST["user"]); |
|
| 57 | + $password = clean($_REQUEST["password"]); |
|
| 58 | + $password_base64 = base64_decode(clean($_REQUEST["password"])); |
|
| 59 | + |
|
| 60 | + if (SINGLE_USER_MODE) $login = "admin"; |
|
| 61 | + |
|
| 62 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
| 63 | + $sth->execute([$login]); |
|
| 64 | + |
|
| 65 | + if ($row = $sth->fetch()) { |
|
| 66 | + $uid = $row["id"]; |
|
| 67 | + } else { |
|
| 68 | + $uid = 0; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (!$uid) { |
|
| 72 | + $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR")); |
|
| 73 | + return; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if (get_pref("ENABLE_API_ACCESS", $uid)) { |
|
| 77 | + if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
| 78 | + $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 79 | + "api_level" => self::API_LEVEL)); |
|
| 80 | + } else if (authenticate_user($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password |
|
| 81 | + $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
| 82 | + "api_level" => self::API_LEVEL)); |
|
| 83 | + } else { // else we are not logged in |
|
| 84 | + user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); |
|
| 85 | + $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR")); |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + $this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED")); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + public function logout() { |
|
| 94 | + logout_user(); |
|
| 95 | + $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + public function isLoggedIn() { |
|
| 99 | + $this->wrap(self::STATUS_OK, array("status" => $_SESSION["uid"] != '')); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + public function getUnread() { |
|
| 103 | + $feed_id = clean($_REQUEST["feed_id"]); |
|
| 104 | + $is_cat = clean($_REQUEST["is_cat"]); |
|
| 105 | + |
|
| 106 | + if ($feed_id) { |
|
| 107 | + $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat))); |
|
| 108 | + } else { |
|
| 109 | + $this->wrap(self::STATUS_OK, array("unread" => Feeds::getGlobalUnread())); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /* Method added for ttrss-reader for Android */ |
|
| 114 | + public function getCounters() { |
|
| 115 | + $this->wrap(self::STATUS_OK, Counters::getAllCounters()); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function getFeeds() { |
|
| 119 | + $cat_id = clean($_REQUEST["cat_id"]); |
|
| 120 | + $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); |
|
| 121 | + $limit = (int) clean($_REQUEST["limit"]); |
|
| 122 | + $offset = (int) clean($_REQUEST["offset"]); |
|
| 123 | + $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
|
| 124 | + |
|
| 125 | + $feeds = $this->api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested); |
|
| 126 | + |
|
| 127 | + $this->wrap(self::STATUS_OK, $feeds); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + public function getCategories() { |
|
| 131 | + $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); |
|
| 132 | + $enable_nested = API::param_to_bool(clean($_REQUEST["enable_nested"])); |
|
| 133 | + $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); |
|
| 134 | + |
|
| 135 | + // TODO do not return empty categories, return Uncategorized and standard virtual cats |
|
| 136 | + |
|
| 137 | + if ($enable_nested) |
|
| 138 | + $nested_qpart = "parent_cat IS NULL"; |
|
| 139 | + else |
|
| 140 | + $nested_qpart = "true"; |
|
| 141 | + |
|
| 142 | + $sth = $this->pdo->prepare("SELECT |
|
| 143 | 143 | id, title, order_id, (SELECT COUNT(id) FROM |
| 144 | 144 | ttrss_feeds WHERE |
| 145 | 145 | ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds, |
@@ -148,188 +148,188 @@ discard block |
||
| 148 | 148 | c2.parent_cat = ttrss_feed_categories.id) AS num_cats |
| 149 | 149 | FROM ttrss_feed_categories |
| 150 | 150 | WHERE $nested_qpart AND owner_uid = ?"); |
| 151 | - $sth->execute([$_SESSION['uid']]); |
|
| 152 | - |
|
| 153 | - $cats = array(); |
|
| 154 | - |
|
| 155 | - while ($line = $sth->fetch()) { |
|
| 156 | - if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) { |
|
| 157 | - $unread = getFeedUnread($line["id"], true); |
|
| 158 | - |
|
| 159 | - if ($enable_nested) |
|
| 160 | - $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 161 | - |
|
| 162 | - if ($unread || !$unread_only) { |
|
| 163 | - array_push($cats, array("id" => $line["id"], |
|
| 164 | - "title" => $line["title"], |
|
| 165 | - "unread" => $unread, |
|
| 166 | - "order_id" => (int) $line["order_id"], |
|
| 167 | - )); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - foreach (array(-2,-1,0) as $cat_id) { |
|
| 173 | - if ($include_empty || !$this->isCategoryEmpty($cat_id)) { |
|
| 174 | - $unread = getFeedUnread($cat_id, true); |
|
| 175 | - |
|
| 176 | - if ($unread || !$unread_only) { |
|
| 177 | - array_push($cats, array("id" => $cat_id, |
|
| 178 | - "title" => Feeds::getCategoryTitle($cat_id), |
|
| 179 | - "unread" => $unread)); |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $this->wrap(self::STATUS_OK, $cats); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - public function getHeadlines() { |
|
| 188 | - $feed_id = clean($_REQUEST["feed_id"]); |
|
| 189 | - if ($feed_id !== "") { |
|
| 190 | - |
|
| 191 | - if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
|
| 192 | - |
|
| 193 | - $limit = (int)clean($_REQUEST["limit"]); |
|
| 194 | - |
|
| 195 | - if (!$limit || $limit >= 200) $limit = 200; |
|
| 196 | - |
|
| 197 | - $offset = (int)clean($_REQUEST["skip"]); |
|
| 198 | - $filter = clean($_REQUEST["filter"]); |
|
| 199 | - $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); |
|
| 200 | - $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); |
|
| 201 | - $show_content = API::param_to_bool(clean($_REQUEST["show_content"])); |
|
| 202 | - /* all_articles, unread, adaptive, marked, updated */ |
|
| 203 | - $view_mode = clean($_REQUEST["view_mode"]); |
|
| 204 | - $include_attachments = API::param_to_bool(clean($_REQUEST["include_attachments"])); |
|
| 205 | - $since_id = (int)clean($_REQUEST["since_id"]); |
|
| 206 | - $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
|
| 207 | - $sanitize_content = !isset($_REQUEST["sanitize"]) || |
|
| 208 | - API::param_to_bool($_REQUEST["sanitize"]); |
|
| 209 | - $force_update = API::param_to_bool(clean($_REQUEST["force_update"])); |
|
| 210 | - $has_sandbox = API::param_to_bool(clean($_REQUEST["has_sandbox"])); |
|
| 211 | - $excerpt_length = (int)clean($_REQUEST["excerpt_length"]); |
|
| 212 | - $check_first_id = (int)clean($_REQUEST["check_first_id"]); |
|
| 213 | - $include_header = API::param_to_bool(clean($_REQUEST["include_header"])); |
|
| 214 | - |
|
| 215 | - $_SESSION['hasSandbox'] = $has_sandbox; |
|
| 216 | - |
|
| 217 | - $skip_first_id_check = false; |
|
| 218 | - |
|
| 219 | - $override_order = false; |
|
| 220 | - switch (clean($_REQUEST["order_by"])) { |
|
| 221 | - case "title": |
|
| 222 | - $override_order = "ttrss_entries.title, date_entered, updated"; |
|
| 223 | - break; |
|
| 224 | - case "date_reverse": |
|
| 225 | - $override_order = "score DESC, date_entered, updated"; |
|
| 226 | - $skip_first_id_check = true; |
|
| 227 | - break; |
|
| 228 | - case "feed_dates": |
|
| 229 | - $override_order = "updated DESC"; |
|
| 230 | - break; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /* do not rely on params below */ |
|
| 234 | - |
|
| 235 | - $search = clean($_REQUEST["search"]); |
|
| 236 | - |
|
| 237 | - list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset, |
|
| 238 | - $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, |
|
| 239 | - $include_attachments, $since_id, $search, |
|
| 240 | - $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id, $skip_first_id_check); |
|
| 241 | - |
|
| 242 | - if ($include_header) { |
|
| 243 | - $this->wrap(self::STATUS_OK, array($headlines_header, $headlines)); |
|
| 244 | - } else { |
|
| 245 | - $this->wrap(self::STATUS_OK, $headlines); |
|
| 246 | - } |
|
| 247 | - } else { |
|
| 248 | - $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - public function updateArticle() { |
|
| 253 | - $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
|
| 254 | - $mode = (int) clean($_REQUEST["mode"]); |
|
| 255 | - $data = clean($_REQUEST["data"]); |
|
| 256 | - $field_raw = (int)clean($_REQUEST["field"]); |
|
| 257 | - |
|
| 258 | - $field = ""; |
|
| 259 | - $set_to = ""; |
|
| 260 | - |
|
| 261 | - switch ($field_raw) { |
|
| 262 | - case 0: |
|
| 263 | - $field = "marked"; |
|
| 264 | - $additional_fields = ",last_marked = NOW()"; |
|
| 265 | - break; |
|
| 266 | - case 1: |
|
| 267 | - $field = "published"; |
|
| 268 | - $additional_fields = ",last_published = NOW()"; |
|
| 269 | - break; |
|
| 270 | - case 2: |
|
| 271 | - $field = "unread"; |
|
| 272 | - $additional_fields = ",last_read = NOW()"; |
|
| 273 | - break; |
|
| 274 | - case 3: |
|
| 275 | - $field = "note"; |
|
| 276 | - }; |
|
| 277 | - |
|
| 278 | - switch ($mode) { |
|
| 279 | - case 1: |
|
| 280 | - $set_to = "true"; |
|
| 281 | - break; |
|
| 282 | - case 0: |
|
| 283 | - $set_to = "false"; |
|
| 284 | - break; |
|
| 285 | - case 2: |
|
| 286 | - $set_to = "NOT $field"; |
|
| 287 | - break; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($field == "note") $set_to = $this->pdo->quote($data); |
|
| 291 | - |
|
| 292 | - if ($field && $set_to && count($article_ids) > 0) { |
|
| 293 | - |
|
| 294 | - $article_qmarks = arr_qmarks($article_ids); |
|
| 295 | - |
|
| 296 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
| 151 | + $sth->execute([$_SESSION['uid']]); |
|
| 152 | + |
|
| 153 | + $cats = array(); |
|
| 154 | + |
|
| 155 | + while ($line = $sth->fetch()) { |
|
| 156 | + if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) { |
|
| 157 | + $unread = getFeedUnread($line["id"], true); |
|
| 158 | + |
|
| 159 | + if ($enable_nested) |
|
| 160 | + $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 161 | + |
|
| 162 | + if ($unread || !$unread_only) { |
|
| 163 | + array_push($cats, array("id" => $line["id"], |
|
| 164 | + "title" => $line["title"], |
|
| 165 | + "unread" => $unread, |
|
| 166 | + "order_id" => (int) $line["order_id"], |
|
| 167 | + )); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + foreach (array(-2,-1,0) as $cat_id) { |
|
| 173 | + if ($include_empty || !$this->isCategoryEmpty($cat_id)) { |
|
| 174 | + $unread = getFeedUnread($cat_id, true); |
|
| 175 | + |
|
| 176 | + if ($unread || !$unread_only) { |
|
| 177 | + array_push($cats, array("id" => $cat_id, |
|
| 178 | + "title" => Feeds::getCategoryTitle($cat_id), |
|
| 179 | + "unread" => $unread)); |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $this->wrap(self::STATUS_OK, $cats); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + public function getHeadlines() { |
|
| 188 | + $feed_id = clean($_REQUEST["feed_id"]); |
|
| 189 | + if ($feed_id !== "") { |
|
| 190 | + |
|
| 191 | + if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
|
| 192 | + |
|
| 193 | + $limit = (int)clean($_REQUEST["limit"]); |
|
| 194 | + |
|
| 195 | + if (!$limit || $limit >= 200) $limit = 200; |
|
| 196 | + |
|
| 197 | + $offset = (int)clean($_REQUEST["skip"]); |
|
| 198 | + $filter = clean($_REQUEST["filter"]); |
|
| 199 | + $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); |
|
| 200 | + $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); |
|
| 201 | + $show_content = API::param_to_bool(clean($_REQUEST["show_content"])); |
|
| 202 | + /* all_articles, unread, adaptive, marked, updated */ |
|
| 203 | + $view_mode = clean($_REQUEST["view_mode"]); |
|
| 204 | + $include_attachments = API::param_to_bool(clean($_REQUEST["include_attachments"])); |
|
| 205 | + $since_id = (int)clean($_REQUEST["since_id"]); |
|
| 206 | + $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
|
| 207 | + $sanitize_content = !isset($_REQUEST["sanitize"]) || |
|
| 208 | + API::param_to_bool($_REQUEST["sanitize"]); |
|
| 209 | + $force_update = API::param_to_bool(clean($_REQUEST["force_update"])); |
|
| 210 | + $has_sandbox = API::param_to_bool(clean($_REQUEST["has_sandbox"])); |
|
| 211 | + $excerpt_length = (int)clean($_REQUEST["excerpt_length"]); |
|
| 212 | + $check_first_id = (int)clean($_REQUEST["check_first_id"]); |
|
| 213 | + $include_header = API::param_to_bool(clean($_REQUEST["include_header"])); |
|
| 214 | + |
|
| 215 | + $_SESSION['hasSandbox'] = $has_sandbox; |
|
| 216 | + |
|
| 217 | + $skip_first_id_check = false; |
|
| 218 | + |
|
| 219 | + $override_order = false; |
|
| 220 | + switch (clean($_REQUEST["order_by"])) { |
|
| 221 | + case "title": |
|
| 222 | + $override_order = "ttrss_entries.title, date_entered, updated"; |
|
| 223 | + break; |
|
| 224 | + case "date_reverse": |
|
| 225 | + $override_order = "score DESC, date_entered, updated"; |
|
| 226 | + $skip_first_id_check = true; |
|
| 227 | + break; |
|
| 228 | + case "feed_dates": |
|
| 229 | + $override_order = "updated DESC"; |
|
| 230 | + break; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /* do not rely on params below */ |
|
| 234 | + |
|
| 235 | + $search = clean($_REQUEST["search"]); |
|
| 236 | + |
|
| 237 | + list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset, |
|
| 238 | + $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, |
|
| 239 | + $include_attachments, $since_id, $search, |
|
| 240 | + $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id, $skip_first_id_check); |
|
| 241 | + |
|
| 242 | + if ($include_header) { |
|
| 243 | + $this->wrap(self::STATUS_OK, array($headlines_header, $headlines)); |
|
| 244 | + } else { |
|
| 245 | + $this->wrap(self::STATUS_OK, $headlines); |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + public function updateArticle() { |
|
| 253 | + $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
|
| 254 | + $mode = (int) clean($_REQUEST["mode"]); |
|
| 255 | + $data = clean($_REQUEST["data"]); |
|
| 256 | + $field_raw = (int)clean($_REQUEST["field"]); |
|
| 257 | + |
|
| 258 | + $field = ""; |
|
| 259 | + $set_to = ""; |
|
| 260 | + |
|
| 261 | + switch ($field_raw) { |
|
| 262 | + case 0: |
|
| 263 | + $field = "marked"; |
|
| 264 | + $additional_fields = ",last_marked = NOW()"; |
|
| 265 | + break; |
|
| 266 | + case 1: |
|
| 267 | + $field = "published"; |
|
| 268 | + $additional_fields = ",last_published = NOW()"; |
|
| 269 | + break; |
|
| 270 | + case 2: |
|
| 271 | + $field = "unread"; |
|
| 272 | + $additional_fields = ",last_read = NOW()"; |
|
| 273 | + break; |
|
| 274 | + case 3: |
|
| 275 | + $field = "note"; |
|
| 276 | + }; |
|
| 277 | + |
|
| 278 | + switch ($mode) { |
|
| 279 | + case 1: |
|
| 280 | + $set_to = "true"; |
|
| 281 | + break; |
|
| 282 | + case 0: |
|
| 283 | + $set_to = "false"; |
|
| 284 | + break; |
|
| 285 | + case 2: |
|
| 286 | + $set_to = "NOT $field"; |
|
| 287 | + break; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($field == "note") $set_to = $this->pdo->quote($data); |
|
| 291 | + |
|
| 292 | + if ($field && $set_to && count($article_ids) > 0) { |
|
| 293 | + |
|
| 294 | + $article_qmarks = arr_qmarks($article_ids); |
|
| 295 | + |
|
| 296 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
| 297 | 297 | $field = $set_to $additional_fields |
| 298 | 298 | WHERE ref_id IN ($article_qmarks) AND owner_uid = ?"); |
| 299 | - $sth->execute(array_merge($article_ids, [$_SESSION['uid']])); |
|
| 299 | + $sth->execute(array_merge($article_ids, [$_SESSION['uid']])); |
|
| 300 | 300 | |
| 301 | - $num_updated = $sth->rowCount(); |
|
| 301 | + $num_updated = $sth->rowCount(); |
|
| 302 | 302 | |
| 303 | - if ($num_updated > 0 && $field == "unread") { |
|
| 304 | - $sth = $this->pdo->prepare("SELECT DISTINCT feed_id FROM ttrss_user_entries |
|
| 303 | + if ($num_updated > 0 && $field == "unread") { |
|
| 304 | + $sth = $this->pdo->prepare("SELECT DISTINCT feed_id FROM ttrss_user_entries |
|
| 305 | 305 | WHERE ref_id IN ($article_qmarks)"); |
| 306 | - $sth->execute($article_ids); |
|
| 306 | + $sth->execute($article_ids); |
|
| 307 | 307 | |
| 308 | - while ($line = $sth->fetch()) { |
|
| 309 | - CCache::update($line["feed_id"], $_SESSION["uid"]); |
|
| 310 | - } |
|
| 311 | - } |
|
| 308 | + while ($line = $sth->fetch()) { |
|
| 309 | + CCache::update($line["feed_id"], $_SESSION["uid"]); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - $this->wrap(self::STATUS_OK, array("status" => "OK", |
|
| 314 | - "updated" => $num_updated)); |
|
| 313 | + $this->wrap(self::STATUS_OK, array("status" => "OK", |
|
| 314 | + "updated" => $num_updated)); |
|
| 315 | 315 | |
| 316 | - } else { |
|
| 317 | - $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 318 | - } |
|
| 316 | + } else { |
|
| 317 | + $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - public function getArticle() { |
|
| 322 | + public function getArticle() { |
|
| 323 | 323 | |
| 324 | - $article_ids = explode(",", clean($_REQUEST["article_id"])); |
|
| 325 | - $sanitize_content = !isset($_REQUEST["sanitize"]) || |
|
| 326 | - API::param_to_bool($_REQUEST["sanitize"]); |
|
| 324 | + $article_ids = explode(",", clean($_REQUEST["article_id"])); |
|
| 325 | + $sanitize_content = !isset($_REQUEST["sanitize"]) || |
|
| 326 | + API::param_to_bool($_REQUEST["sanitize"]); |
|
| 327 | 327 | |
| 328 | - if ($article_ids) { |
|
| 328 | + if ($article_ids) { |
|
| 329 | 329 | |
| 330 | - $article_qmarks = arr_qmarks($article_ids); |
|
| 330 | + $article_qmarks = arr_qmarks($article_ids); |
|
| 331 | 331 | |
| 332 | - $sth = $this->pdo->prepare("SELECT id,guid,title,link,content,feed_id,comments,int_id, |
|
| 332 | + $sth = $this->pdo->prepare("SELECT id,guid,title,link,content,feed_id,comments,int_id, |
|
| 333 | 333 | marked,unread,published,score,note,lang, |
| 334 | 334 | ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, |
| 335 | 335 | author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title, |
@@ -338,559 +338,559 @@ discard block |
||
| 338 | 338 | FROM ttrss_entries,ttrss_user_entries |
| 339 | 339 | WHERE id IN ($article_qmarks) AND ref_id = id AND owner_uid = ?"); |
| 340 | 340 | |
| 341 | - $sth->execute(array_merge($article_ids, [$_SESSION['uid']])); |
|
| 342 | - |
|
| 343 | - $articles = array(); |
|
| 344 | - |
|
| 345 | - while ($line = $sth->fetch()) { |
|
| 346 | - |
|
| 347 | - $attachments = Article::get_article_enclosures($line['id']); |
|
| 348 | - |
|
| 349 | - $article = array( |
|
| 350 | - "id" => $line["id"], |
|
| 351 | - "guid" => $line["guid"], |
|
| 352 | - "title" => $line["title"], |
|
| 353 | - "link" => $line["link"], |
|
| 354 | - "labels" => Article::get_article_labels($line['id']), |
|
| 355 | - "unread" => API::param_to_bool($line["unread"]), |
|
| 356 | - "marked" => API::param_to_bool($line["marked"]), |
|
| 357 | - "published" => API::param_to_bool($line["published"]), |
|
| 358 | - "comments" => $line["comments"], |
|
| 359 | - "author" => $line["author"], |
|
| 360 | - "updated" => (int) strtotime($line["updated"]), |
|
| 361 | - "feed_id" => $line["feed_id"], |
|
| 362 | - "attachments" => $attachments, |
|
| 363 | - "score" => (int)$line["score"], |
|
| 364 | - "feed_title" => $line["feed_title"], |
|
| 365 | - "note" => $line["note"], |
|
| 366 | - "lang" => $line["lang"] |
|
| 367 | - ); |
|
| 368 | - |
|
| 369 | - if ($sanitize_content) { |
|
| 370 | - $article["content"] = sanitize( |
|
| 371 | - $line["content"], |
|
| 372 | - API::param_to_bool($line['hide_images']), |
|
| 373 | - false, $line["site_url"], false, $line["id"]); |
|
| 374 | - } else { |
|
| 375 | - $article["content"] = $line["content"]; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { |
|
| 379 | - $article = $p->hook_render_article_api(array("article" => $article)); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - $article['content'] = DiskCache::rewriteUrls($article['content']); |
|
| 383 | - |
|
| 384 | - array_push($articles, $article); |
|
| 385 | - |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - $this->wrap(self::STATUS_OK, $articles); |
|
| 389 | - } else { |
|
| 390 | - $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - public function getConfig() { |
|
| 395 | - $config = array( |
|
| 396 | - "icons_dir" => ICONS_DIR, |
|
| 397 | - "icons_url" => ICONS_URL); |
|
| 398 | - |
|
| 399 | - $config["daemon_is_running"] = file_is_locked("update_daemon.lock"); |
|
| 400 | - |
|
| 401 | - $sth = $this->pdo->prepare("SELECT COUNT(*) AS cf FROM |
|
| 341 | + $sth->execute(array_merge($article_ids, [$_SESSION['uid']])); |
|
| 342 | + |
|
| 343 | + $articles = array(); |
|
| 344 | + |
|
| 345 | + while ($line = $sth->fetch()) { |
|
| 346 | + |
|
| 347 | + $attachments = Article::get_article_enclosures($line['id']); |
|
| 348 | + |
|
| 349 | + $article = array( |
|
| 350 | + "id" => $line["id"], |
|
| 351 | + "guid" => $line["guid"], |
|
| 352 | + "title" => $line["title"], |
|
| 353 | + "link" => $line["link"], |
|
| 354 | + "labels" => Article::get_article_labels($line['id']), |
|
| 355 | + "unread" => API::param_to_bool($line["unread"]), |
|
| 356 | + "marked" => API::param_to_bool($line["marked"]), |
|
| 357 | + "published" => API::param_to_bool($line["published"]), |
|
| 358 | + "comments" => $line["comments"], |
|
| 359 | + "author" => $line["author"], |
|
| 360 | + "updated" => (int) strtotime($line["updated"]), |
|
| 361 | + "feed_id" => $line["feed_id"], |
|
| 362 | + "attachments" => $attachments, |
|
| 363 | + "score" => (int)$line["score"], |
|
| 364 | + "feed_title" => $line["feed_title"], |
|
| 365 | + "note" => $line["note"], |
|
| 366 | + "lang" => $line["lang"] |
|
| 367 | + ); |
|
| 368 | + |
|
| 369 | + if ($sanitize_content) { |
|
| 370 | + $article["content"] = sanitize( |
|
| 371 | + $line["content"], |
|
| 372 | + API::param_to_bool($line['hide_images']), |
|
| 373 | + false, $line["site_url"], false, $line["id"]); |
|
| 374 | + } else { |
|
| 375 | + $article["content"] = $line["content"]; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { |
|
| 379 | + $article = $p->hook_render_article_api(array("article" => $article)); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + $article['content'] = DiskCache::rewriteUrls($article['content']); |
|
| 383 | + |
|
| 384 | + array_push($articles, $article); |
|
| 385 | + |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + $this->wrap(self::STATUS_OK, $articles); |
|
| 389 | + } else { |
|
| 390 | + $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + public function getConfig() { |
|
| 395 | + $config = array( |
|
| 396 | + "icons_dir" => ICONS_DIR, |
|
| 397 | + "icons_url" => ICONS_URL); |
|
| 398 | + |
|
| 399 | + $config["daemon_is_running"] = file_is_locked("update_daemon.lock"); |
|
| 400 | + |
|
| 401 | + $sth = $this->pdo->prepare("SELECT COUNT(*) AS cf FROM |
|
| 402 | 402 | ttrss_feeds WHERE owner_uid = ?"); |
| 403 | - $sth->execute([$_SESSION['uid']]); |
|
| 404 | - $row = $sth->fetch(); |
|
| 403 | + $sth->execute([$_SESSION['uid']]); |
|
| 404 | + $row = $sth->fetch(); |
|
| 405 | 405 | |
| 406 | - $config["num_feeds"] = $row["cf"]; |
|
| 406 | + $config["num_feeds"] = $row["cf"]; |
|
| 407 | 407 | |
| 408 | - $this->wrap(self::STATUS_OK, $config); |
|
| 409 | - } |
|
| 408 | + $this->wrap(self::STATUS_OK, $config); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - public function updateFeed() { |
|
| 412 | - $feed_id = (int) clean($_REQUEST["feed_id"]); |
|
| 411 | + public function updateFeed() { |
|
| 412 | + $feed_id = (int) clean($_REQUEST["feed_id"]); |
|
| 413 | 413 | |
| 414 | - if (!ini_get("open_basedir")) { |
|
| 415 | - RSSUtils::update_rss_feed($feed_id); |
|
| 416 | - } |
|
| 414 | + if (!ini_get("open_basedir")) { |
|
| 415 | + RSSUtils::update_rss_feed($feed_id); |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 419 | - } |
|
| 418 | + $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - public function catchupFeed() { |
|
| 422 | - $feed_id = clean($_REQUEST["feed_id"]); |
|
| 423 | - $is_cat = clean($_REQUEST["is_cat"]); |
|
| 421 | + public function catchupFeed() { |
|
| 422 | + $feed_id = clean($_REQUEST["feed_id"]); |
|
| 423 | + $is_cat = clean($_REQUEST["is_cat"]); |
|
| 424 | 424 | |
| 425 | - Feeds::catchup_feed($feed_id, $is_cat); |
|
| 425 | + Feeds::catchup_feed($feed_id, $is_cat); |
|
| 426 | 426 | |
| 427 | - $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 428 | - } |
|
| 427 | + $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - public function getPref() { |
|
| 431 | - $pref_name = clean($_REQUEST["pref_name"]); |
|
| 430 | + public function getPref() { |
|
| 431 | + $pref_name = clean($_REQUEST["pref_name"]); |
|
| 432 | 432 | |
| 433 | - $this->wrap(self::STATUS_OK, array("value" => get_pref($pref_name))); |
|
| 434 | - } |
|
| 433 | + $this->wrap(self::STATUS_OK, array("value" => get_pref($pref_name))); |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - public function getLabels() { |
|
| 437 | - $article_id = (int)clean($_REQUEST['article_id']); |
|
| 436 | + public function getLabels() { |
|
| 437 | + $article_id = (int)clean($_REQUEST['article_id']); |
|
| 438 | 438 | |
| 439 | - $rv = array(); |
|
| 439 | + $rv = array(); |
|
| 440 | 440 | |
| 441 | - $sth = $this->pdo->prepare("SELECT id, caption, fg_color, bg_color |
|
| 441 | + $sth = $this->pdo->prepare("SELECT id, caption, fg_color, bg_color |
|
| 442 | 442 | FROM ttrss_labels2 |
| 443 | 443 | WHERE owner_uid = ? ORDER BY caption"); |
| 444 | - $sth->execute([$_SESSION['uid']]); |
|
| 444 | + $sth->execute([$_SESSION['uid']]); |
|
| 445 | 445 | |
| 446 | - if ($article_id) |
|
| 447 | - $article_labels = Article::get_article_labels($article_id); |
|
| 448 | - else |
|
| 449 | - $article_labels = array(); |
|
| 446 | + if ($article_id) |
|
| 447 | + $article_labels = Article::get_article_labels($article_id); |
|
| 448 | + else |
|
| 449 | + $article_labels = array(); |
|
| 450 | 450 | |
| 451 | - while ($line = $sth->fetch()) { |
|
| 451 | + while ($line = $sth->fetch()) { |
|
| 452 | 452 | |
| 453 | - $checked = false; |
|
| 454 | - foreach ($article_labels as $al) { |
|
| 455 | - if (Labels::feed_to_label_id($al[0]) == $line['id']) { |
|
| 456 | - $checked = true; |
|
| 457 | - break; |
|
| 458 | - } |
|
| 459 | - } |
|
| 453 | + $checked = false; |
|
| 454 | + foreach ($article_labels as $al) { |
|
| 455 | + if (Labels::feed_to_label_id($al[0]) == $line['id']) { |
|
| 456 | + $checked = true; |
|
| 457 | + break; |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | 460 | |
| 461 | - array_push($rv, array( |
|
| 462 | - "id" => (int)Labels::label_to_feed_id($line['id']), |
|
| 463 | - "caption" => $line['caption'], |
|
| 464 | - "fg_color" => $line['fg_color'], |
|
| 465 | - "bg_color" => $line['bg_color'], |
|
| 466 | - "checked" => $checked)); |
|
| 467 | - } |
|
| 461 | + array_push($rv, array( |
|
| 462 | + "id" => (int)Labels::label_to_feed_id($line['id']), |
|
| 463 | + "caption" => $line['caption'], |
|
| 464 | + "fg_color" => $line['fg_color'], |
|
| 465 | + "bg_color" => $line['bg_color'], |
|
| 466 | + "checked" => $checked)); |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $this->wrap(self::STATUS_OK, $rv); |
|
| 470 | - } |
|
| 469 | + $this->wrap(self::STATUS_OK, $rv); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - public function setArticleLabel() { |
|
| 472 | + public function setArticleLabel() { |
|
| 473 | 473 | |
| 474 | - $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
|
| 475 | - $label_id = (int) clean($_REQUEST['label_id']); |
|
| 476 | - $assign = API::param_to_bool(clean($_REQUEST['assign'])); |
|
| 474 | + $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
|
| 475 | + $label_id = (int) clean($_REQUEST['label_id']); |
|
| 476 | + $assign = API::param_to_bool(clean($_REQUEST['assign'])); |
|
| 477 | 477 | |
| 478 | - $label = Labels::find_caption(Labels::feed_to_label_id($label_id), $_SESSION["uid"]); |
|
| 478 | + $label = Labels::find_caption(Labels::feed_to_label_id($label_id), $_SESSION["uid"]); |
|
| 479 | 479 | |
| 480 | - $num_updated = 0; |
|
| 480 | + $num_updated = 0; |
|
| 481 | 481 | |
| 482 | - if ($label) { |
|
| 482 | + if ($label) { |
|
| 483 | 483 | |
| 484 | - foreach ($article_ids as $id) { |
|
| 484 | + foreach ($article_ids as $id) { |
|
| 485 | 485 | |
| 486 | - if ($assign) |
|
| 487 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 488 | - else |
|
| 489 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 486 | + if ($assign) |
|
| 487 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 488 | + else |
|
| 489 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 490 | 490 | |
| 491 | - ++$num_updated; |
|
| 491 | + ++$num_updated; |
|
| 492 | 492 | |
| 493 | - } |
|
| 494 | - } |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - $this->wrap(self::STATUS_OK, array("status" => "OK", |
|
| 497 | - "updated" => $num_updated)); |
|
| 496 | + $this->wrap(self::STATUS_OK, array("status" => "OK", |
|
| 497 | + "updated" => $num_updated)); |
|
| 498 | 498 | |
| 499 | - } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - public function index($method) { |
|
| 502 | - $plugin = PluginHost::getInstance()->get_api_method(strtolower($method)); |
|
| 501 | + public function index($method) { |
|
| 502 | + $plugin = PluginHost::getInstance()->get_api_method(strtolower($method)); |
|
| 503 | 503 | |
| 504 | - if ($plugin && method_exists($plugin, $method)) { |
|
| 505 | - $reply = $plugin->$method(); |
|
| 504 | + if ($plugin && method_exists($plugin, $method)) { |
|
| 505 | + $reply = $plugin->$method(); |
|
| 506 | 506 | |
| 507 | - $this->wrap($reply[0], $reply[1]); |
|
| 507 | + $this->wrap($reply[0], $reply[1]); |
|
| 508 | 508 | |
| 509 | - } else { |
|
| 510 | - $this->wrap(self::STATUS_ERR, array("error" => 'UNKNOWN_METHOD', "method" => $method)); |
|
| 511 | - } |
|
| 512 | - } |
|
| 509 | + } else { |
|
| 510 | + $this->wrap(self::STATUS_ERR, array("error" => 'UNKNOWN_METHOD', "method" => $method)); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - public function shareToPublished() { |
|
| 515 | - $title = strip_tags(clean($_REQUEST["title"])); |
|
| 516 | - $url = strip_tags(clean($_REQUEST["url"])); |
|
| 517 | - $content = strip_tags(clean($_REQUEST["content"])); |
|
| 514 | + public function shareToPublished() { |
|
| 515 | + $title = strip_tags(clean($_REQUEST["title"])); |
|
| 516 | + $url = strip_tags(clean($_REQUEST["url"])); |
|
| 517 | + $content = strip_tags(clean($_REQUEST["content"])); |
|
| 518 | 518 | |
| 519 | - if (Article::create_published_article($title, $url, $content, "", $_SESSION["uid"])) { |
|
| 520 | - $this->wrap(self::STATUS_OK, array("status" => 'OK')); |
|
| 521 | - } else { |
|
| 522 | - $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed')); |
|
| 523 | - } |
|
| 524 | - } |
|
| 519 | + if (Article::create_published_article($title, $url, $content, "", $_SESSION["uid"])) { |
|
| 520 | + $this->wrap(self::STATUS_OK, array("status" => 'OK')); |
|
| 521 | + } else { |
|
| 522 | + $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed')); |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - public static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested = false) { |
|
| 526 | + public static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested = false) { |
|
| 527 | 527 | |
| 528 | - $feeds = array(); |
|
| 528 | + $feeds = array(); |
|
| 529 | 529 | |
| 530 | - $pdo = Db::pdo(); |
|
| 530 | + $pdo = Db::pdo(); |
|
| 531 | 531 | |
| 532 | - $limit = (int) $limit; |
|
| 533 | - $offset = (int) $offset; |
|
| 534 | - $cat_id = (int) $cat_id; |
|
| 532 | + $limit = (int) $limit; |
|
| 533 | + $offset = (int) $offset; |
|
| 534 | + $cat_id = (int) $cat_id; |
|
| 535 | 535 | |
| 536 | - /* Labels */ |
|
| 536 | + /* Labels */ |
|
| 537 | 537 | |
| 538 | - /* API only: -4 All feeds, including virtual feeds */ |
|
| 539 | - if ($cat_id == -4 || $cat_id == -2) { |
|
| 540 | - $counters = Counters::getLabelCounters(true); |
|
| 538 | + /* API only: -4 All feeds, including virtual feeds */ |
|
| 539 | + if ($cat_id == -4 || $cat_id == -2) { |
|
| 540 | + $counters = Counters::getLabelCounters(true); |
|
| 541 | 541 | |
| 542 | - foreach (array_values($counters) as $cv) { |
|
| 542 | + foreach (array_values($counters) as $cv) { |
|
| 543 | 543 | |
| 544 | - $unread = $cv["counter"]; |
|
| 544 | + $unread = $cv["counter"]; |
|
| 545 | 545 | |
| 546 | - if ($unread || !$unread_only) { |
|
| 546 | + if ($unread || !$unread_only) { |
|
| 547 | 547 | |
| 548 | - $row = array( |
|
| 549 | - "id" => (int) $cv["id"], |
|
| 550 | - "title" => $cv["description"], |
|
| 551 | - "unread" => $cv["counter"], |
|
| 552 | - "cat_id" => -2, |
|
| 553 | - ); |
|
| 548 | + $row = array( |
|
| 549 | + "id" => (int) $cv["id"], |
|
| 550 | + "title" => $cv["description"], |
|
| 551 | + "unread" => $cv["counter"], |
|
| 552 | + "cat_id" => -2, |
|
| 553 | + ); |
|
| 554 | 554 | |
| 555 | - array_push($feeds, $row); |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - } |
|
| 555 | + array_push($feeds, $row); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - /* Virtual feeds */ |
|
| 560 | + /* Virtual feeds */ |
|
| 561 | 561 | |
| 562 | - if ($cat_id == -4 || $cat_id == -1) { |
|
| 563 | - foreach (array(-1, -2, -3, -4, -6, 0) as $i) { |
|
| 564 | - $unread = getFeedUnread($i); |
|
| 562 | + if ($cat_id == -4 || $cat_id == -1) { |
|
| 563 | + foreach (array(-1, -2, -3, -4, -6, 0) as $i) { |
|
| 564 | + $unread = getFeedUnread($i); |
|
| 565 | 565 | |
| 566 | - if ($unread || !$unread_only) { |
|
| 567 | - $title = Feeds::getFeedTitle($i); |
|
| 566 | + if ($unread || !$unread_only) { |
|
| 567 | + $title = Feeds::getFeedTitle($i); |
|
| 568 | 568 | |
| 569 | - $row = array( |
|
| 570 | - "id" => $i, |
|
| 571 | - "title" => $title, |
|
| 572 | - "unread" => $unread, |
|
| 573 | - "cat_id" => -1, |
|
| 574 | - ); |
|
| 575 | - array_push($feeds, $row); |
|
| 576 | - } |
|
| 569 | + $row = array( |
|
| 570 | + "id" => $i, |
|
| 571 | + "title" => $title, |
|
| 572 | + "unread" => $unread, |
|
| 573 | + "cat_id" => -1, |
|
| 574 | + ); |
|
| 575 | + array_push($feeds, $row); |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - } |
|
| 579 | - } |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - /* Child cats */ |
|
| 581 | + /* Child cats */ |
|
| 582 | 582 | |
| 583 | - if ($include_nested && $cat_id) { |
|
| 584 | - $sth = $pdo->prepare("SELECT |
|
| 583 | + if ($include_nested && $cat_id) { |
|
| 584 | + $sth = $pdo->prepare("SELECT |
|
| 585 | 585 | id, title, order_id FROM ttrss_feed_categories |
| 586 | 586 | WHERE parent_cat = ? AND owner_uid = ? ORDER BY order_id, title"); |
| 587 | 587 | |
| 588 | - $sth->execute([$cat_id, $_SESSION['uid']]); |
|
| 588 | + $sth->execute([$cat_id, $_SESSION['uid']]); |
|
| 589 | 589 | |
| 590 | - while ($line = $sth->fetch()) { |
|
| 591 | - $unread = getFeedUnread($line["id"], true) + |
|
| 592 | - Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 590 | + while ($line = $sth->fetch()) { |
|
| 591 | + $unread = getFeedUnread($line["id"], true) + |
|
| 592 | + Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 593 | 593 | |
| 594 | - if ($unread || !$unread_only) { |
|
| 595 | - $row = array( |
|
| 596 | - "id" => (int) $line["id"], |
|
| 597 | - "title" => $line["title"], |
|
| 598 | - "unread" => $unread, |
|
| 599 | - "is_cat" => true, |
|
| 594 | + if ($unread || !$unread_only) { |
|
| 595 | + $row = array( |
|
| 596 | + "id" => (int) $line["id"], |
|
| 597 | + "title" => $line["title"], |
|
| 598 | + "unread" => $unread, |
|
| 599 | + "is_cat" => true, |
|
| 600 | 600 | "order_id" => (int) $line["order_id"] |
| 601 | - ); |
|
| 602 | - array_push($feeds, $row); |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - /* Real feeds */ |
|
| 608 | - |
|
| 609 | - if ($limit) { |
|
| 610 | - $limit_qpart = "LIMIT $limit OFFSET $offset"; |
|
| 611 | - } else { |
|
| 612 | - $limit_qpart = ""; |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - /* API only: -3 All feeds, excluding virtual feeds (e.g. Labels and such) */ |
|
| 616 | - if ($cat_id == -4 || $cat_id == -3) { |
|
| 617 | - $sth = $pdo->prepare("SELECT |
|
| 601 | + ); |
|
| 602 | + array_push($feeds, $row); |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + /* Real feeds */ |
|
| 608 | + |
|
| 609 | + if ($limit) { |
|
| 610 | + $limit_qpart = "LIMIT $limit OFFSET $offset"; |
|
| 611 | + } else { |
|
| 612 | + $limit_qpart = ""; |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + /* API only: -3 All feeds, excluding virtual feeds (e.g. Labels and such) */ |
|
| 616 | + if ($cat_id == -4 || $cat_id == -3) { |
|
| 617 | + $sth = $pdo->prepare("SELECT |
|
| 618 | 618 | id, feed_url, cat_id, title, order_id, ". |
| 619 | - SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 619 | + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 620 | 620 | FROM ttrss_feeds WHERE owner_uid = ? |
| 621 | 621 | ORDER BY order_id, title " . $limit_qpart); |
| 622 | - $sth->execute([$_SESSION['uid']]); |
|
| 622 | + $sth->execute([$_SESSION['uid']]); |
|
| 623 | 623 | |
| 624 | - } else { |
|
| 624 | + } else { |
|
| 625 | 625 | |
| 626 | - $sth = $pdo->prepare("SELECT |
|
| 626 | + $sth = $pdo->prepare("SELECT |
|
| 627 | 627 | id, feed_url, cat_id, title, order_id, ". |
| 628 | - SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 628 | + SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 629 | 629 | FROM ttrss_feeds WHERE |
| 630 | 630 | (cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) |
| 631 | 631 | AND owner_uid = :uid |
| 632 | 632 | ORDER BY order_id, title " . $limit_qpart); |
| 633 | - $sth->execute([":uid" => $_SESSION['uid'], ":cat" => $cat_id]); |
|
| 634 | - } |
|
| 633 | + $sth->execute([":uid" => $_SESSION['uid'], ":cat" => $cat_id]); |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | - while ($line = $sth->fetch()) { |
|
| 636 | + while ($line = $sth->fetch()) { |
|
| 637 | 637 | |
| 638 | - $unread = getFeedUnread($line["id"]); |
|
| 638 | + $unread = getFeedUnread($line["id"]); |
|
| 639 | 639 | |
| 640 | - $has_icon = Feeds::feedHasIcon($line['id']); |
|
| 640 | + $has_icon = Feeds::feedHasIcon($line['id']); |
|
| 641 | 641 | |
| 642 | - if ($unread || !$unread_only) { |
|
| 642 | + if ($unread || !$unread_only) { |
|
| 643 | 643 | |
| 644 | - $row = array( |
|
| 645 | - "feed_url" => $line["feed_url"], |
|
| 646 | - "title" => $line["title"], |
|
| 647 | - "id" => (int)$line["id"], |
|
| 648 | - "unread" => (int)$unread, |
|
| 649 | - "has_icon" => $has_icon, |
|
| 650 | - "cat_id" => (int)$line["cat_id"], |
|
| 651 | - "last_updated" => (int) strtotime($line["last_updated"]), |
|
| 652 | - "order_id" => (int) $line["order_id"], |
|
| 653 | - ); |
|
| 644 | + $row = array( |
|
| 645 | + "feed_url" => $line["feed_url"], |
|
| 646 | + "title" => $line["title"], |
|
| 647 | + "id" => (int)$line["id"], |
|
| 648 | + "unread" => (int)$unread, |
|
| 649 | + "has_icon" => $has_icon, |
|
| 650 | + "cat_id" => (int)$line["cat_id"], |
|
| 651 | + "last_updated" => (int) strtotime($line["last_updated"]), |
|
| 652 | + "order_id" => (int) $line["order_id"], |
|
| 653 | + ); |
|
| 654 | 654 | |
| 655 | - array_push($feeds, $row); |
|
| 656 | - } |
|
| 657 | - } |
|
| 655 | + array_push($feeds, $row); |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - return $feeds; |
|
| 660 | - } |
|
| 659 | + return $feeds; |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | - /** |
|
| 663 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 664 | - */ |
|
| 665 | - public static function api_get_headlines($feed_id, $limit, $offset, |
|
| 666 | - $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, |
|
| 667 | - $include_attachments, $since_id, |
|
| 668 | - $search = "", $include_nested = false, $sanitize_content = true, |
|
| 669 | - $force_update = false, $excerpt_length = 100, $check_first_id = false, $skip_first_id_check = false) { |
|
| 662 | + /** |
|
| 663 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 664 | + */ |
|
| 665 | + public static function api_get_headlines($feed_id, $limit, $offset, |
|
| 666 | + $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, |
|
| 667 | + $include_attachments, $since_id, |
|
| 668 | + $search = "", $include_nested = false, $sanitize_content = true, |
|
| 669 | + $force_update = false, $excerpt_length = 100, $check_first_id = false, $skip_first_id_check = false) { |
|
| 670 | 670 | |
| 671 | - $pdo = Db::pdo(); |
|
| 671 | + $pdo = Db::pdo(); |
|
| 672 | 672 | |
| 673 | - if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { |
|
| 674 | - // Update the feed if required with some basic flood control |
|
| 673 | + if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { |
|
| 674 | + // Update the feed if required with some basic flood control |
|
| 675 | 675 | |
| 676 | - $sth = $pdo->prepare( |
|
| 677 | - "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 676 | + $sth = $pdo->prepare( |
|
| 677 | + "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated |
|
| 678 | 678 | FROM ttrss_feeds WHERE id = ?"); |
| 679 | - $sth->execute([$feed_id]); |
|
| 679 | + $sth->execute([$feed_id]); |
|
| 680 | 680 | |
| 681 | - if ($row = $sth->fetch()) { |
|
| 682 | - $last_updated = strtotime($row["last_updated"]); |
|
| 683 | - $cache_images = API::param_to_bool($row["cache_images"]); |
|
| 681 | + if ($row = $sth->fetch()) { |
|
| 682 | + $last_updated = strtotime($row["last_updated"]); |
|
| 683 | + $cache_images = API::param_to_bool($row["cache_images"]); |
|
| 684 | 684 | |
| 685 | - if (!$cache_images && time() - $last_updated > 120) { |
|
| 686 | - RSSUtils::update_rss_feed($feed_id, true); |
|
| 687 | - } else { |
|
| 688 | - $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01' |
|
| 685 | + if (!$cache_images && time() - $last_updated > 120) { |
|
| 686 | + RSSUtils::update_rss_feed($feed_id, true); |
|
| 687 | + } else { |
|
| 688 | + $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01' |
|
| 689 | 689 | WHERE id = ?"); |
| 690 | - $sth->execute([$feed_id]); |
|
| 691 | - } |
|
| 692 | - } |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - $params = array( |
|
| 696 | - "feed" => $feed_id, |
|
| 697 | - "limit" => $limit, |
|
| 698 | - "view_mode" => $view_mode, |
|
| 699 | - "cat_view" => $is_cat, |
|
| 700 | - "search" => $search, |
|
| 701 | - "override_order" => $order, |
|
| 702 | - "offset" => $offset, |
|
| 703 | - "since_id" => $since_id, |
|
| 704 | - "include_children" => $include_nested, |
|
| 705 | - "check_first_id" => $check_first_id, |
|
| 706 | - "skip_first_id_check" => $skip_first_id_check |
|
| 707 | - ); |
|
| 708 | - |
|
| 709 | - $qfh_ret = Feeds::queryFeedHeadlines($params); |
|
| 710 | - |
|
| 711 | - $result = $qfh_ret[0]; |
|
| 712 | - $feed_title = $qfh_ret[1]; |
|
| 713 | - $first_id = $qfh_ret[6]; |
|
| 714 | - |
|
| 715 | - $headlines = array(); |
|
| 716 | - |
|
| 717 | - $headlines_header = array( |
|
| 718 | - 'id' => $feed_id, |
|
| 719 | - 'first_id' => $first_id, |
|
| 720 | - 'is_cat' => $is_cat); |
|
| 721 | - |
|
| 722 | - if (!is_numeric($result)) { |
|
| 723 | - while ($line = $result->fetch()) { |
|
| 724 | - $line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length); |
|
| 725 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
| 726 | - $line = $p->hook_query_headlines($line, $excerpt_length, true); |
|
| 727 | - } |
|
| 728 | - |
|
| 729 | - $is_updated = ($line["last_read"] == "" && |
|
| 730 | - ($line["unread"] != "t" && $line["unread"] != "1")); |
|
| 731 | - |
|
| 732 | - $tags = explode(",", $line["tag_cache"]); |
|
| 733 | - |
|
| 734 | - $label_cache = $line["label_cache"]; |
|
| 735 | - $labels = false; |
|
| 736 | - |
|
| 737 | - if ($label_cache) { |
|
| 738 | - $label_cache = json_decode($label_cache, true); |
|
| 739 | - |
|
| 740 | - if ($label_cache) { |
|
| 741 | - if ($label_cache["no-labels"] == 1) |
|
| 742 | - $labels = array(); |
|
| 743 | - else |
|
| 744 | - $labels = $label_cache; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
|
| 749 | - |
|
| 750 | - $headline_row = array( |
|
| 751 | - "id" => (int)$line["id"], |
|
| 752 | - "guid" => $line["guid"], |
|
| 753 | - "unread" => API::param_to_bool($line["unread"]), |
|
| 754 | - "marked" => API::param_to_bool($line["marked"]), |
|
| 755 | - "published" => API::param_to_bool($line["published"]), |
|
| 756 | - "updated" => (int)strtotime($line["updated"]), |
|
| 757 | - "is_updated" => $is_updated, |
|
| 758 | - "title" => $line["title"], |
|
| 759 | - "link" => $line["link"], |
|
| 760 | - "feed_id" => $line["feed_id"] ? $line['feed_id'] : 0, |
|
| 761 | - "tags" => $tags, |
|
| 762 | - ); |
|
| 763 | - |
|
| 764 | - $enclosures = Article::get_article_enclosures($line['id']); |
|
| 765 | - |
|
| 766 | - if ($include_attachments) |
|
| 767 | - $headline_row['attachments'] = $enclosures; |
|
| 768 | - |
|
| 769 | - if ($show_excerpt) |
|
| 770 | - $headline_row["excerpt"] = $line["content_preview"]; |
|
| 771 | - |
|
| 772 | - if ($show_content) { |
|
| 773 | - |
|
| 774 | - if ($sanitize_content) { |
|
| 775 | - $headline_row["content"] = sanitize( |
|
| 776 | - $line["content"], |
|
| 777 | - API::param_to_bool($line['hide_images']), |
|
| 778 | - false, $line["site_url"], false, $line["id"]); |
|
| 779 | - } else { |
|
| 780 | - $headline_row["content"] = $line["content"]; |
|
| 781 | - } |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - // unify label output to ease parsing |
|
| 785 | - if ($labels["no-labels"] == 1) $labels = array(); |
|
| 786 | - |
|
| 787 | - $headline_row["labels"] = $labels; |
|
| 788 | - |
|
| 789 | - $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : |
|
| 790 | - $feed_title; |
|
| 791 | - |
|
| 792 | - $headline_row["comments_count"] = (int)$line["num_comments"]; |
|
| 793 | - $headline_row["comments_link"] = $line["comments"]; |
|
| 690 | + $sth->execute([$feed_id]); |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + $params = array( |
|
| 696 | + "feed" => $feed_id, |
|
| 697 | + "limit" => $limit, |
|
| 698 | + "view_mode" => $view_mode, |
|
| 699 | + "cat_view" => $is_cat, |
|
| 700 | + "search" => $search, |
|
| 701 | + "override_order" => $order, |
|
| 702 | + "offset" => $offset, |
|
| 703 | + "since_id" => $since_id, |
|
| 704 | + "include_children" => $include_nested, |
|
| 705 | + "check_first_id" => $check_first_id, |
|
| 706 | + "skip_first_id_check" => $skip_first_id_check |
|
| 707 | + ); |
|
| 708 | + |
|
| 709 | + $qfh_ret = Feeds::queryFeedHeadlines($params); |
|
| 710 | + |
|
| 711 | + $result = $qfh_ret[0]; |
|
| 712 | + $feed_title = $qfh_ret[1]; |
|
| 713 | + $first_id = $qfh_ret[6]; |
|
| 714 | + |
|
| 715 | + $headlines = array(); |
|
| 716 | + |
|
| 717 | + $headlines_header = array( |
|
| 718 | + 'id' => $feed_id, |
|
| 719 | + 'first_id' => $first_id, |
|
| 720 | + 'is_cat' => $is_cat); |
|
| 721 | + |
|
| 722 | + if (!is_numeric($result)) { |
|
| 723 | + while ($line = $result->fetch()) { |
|
| 724 | + $line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length); |
|
| 725 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
| 726 | + $line = $p->hook_query_headlines($line, $excerpt_length, true); |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + $is_updated = ($line["last_read"] == "" && |
|
| 730 | + ($line["unread"] != "t" && $line["unread"] != "1")); |
|
| 731 | + |
|
| 732 | + $tags = explode(",", $line["tag_cache"]); |
|
| 733 | + |
|
| 734 | + $label_cache = $line["label_cache"]; |
|
| 735 | + $labels = false; |
|
| 736 | + |
|
| 737 | + if ($label_cache) { |
|
| 738 | + $label_cache = json_decode($label_cache, true); |
|
| 739 | + |
|
| 740 | + if ($label_cache) { |
|
| 741 | + if ($label_cache["no-labels"] == 1) |
|
| 742 | + $labels = array(); |
|
| 743 | + else |
|
| 744 | + $labels = $label_cache; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
|
| 749 | + |
|
| 750 | + $headline_row = array( |
|
| 751 | + "id" => (int)$line["id"], |
|
| 752 | + "guid" => $line["guid"], |
|
| 753 | + "unread" => API::param_to_bool($line["unread"]), |
|
| 754 | + "marked" => API::param_to_bool($line["marked"]), |
|
| 755 | + "published" => API::param_to_bool($line["published"]), |
|
| 756 | + "updated" => (int)strtotime($line["updated"]), |
|
| 757 | + "is_updated" => $is_updated, |
|
| 758 | + "title" => $line["title"], |
|
| 759 | + "link" => $line["link"], |
|
| 760 | + "feed_id" => $line["feed_id"] ? $line['feed_id'] : 0, |
|
| 761 | + "tags" => $tags, |
|
| 762 | + ); |
|
| 763 | + |
|
| 764 | + $enclosures = Article::get_article_enclosures($line['id']); |
|
| 765 | + |
|
| 766 | + if ($include_attachments) |
|
| 767 | + $headline_row['attachments'] = $enclosures; |
|
| 768 | + |
|
| 769 | + if ($show_excerpt) |
|
| 770 | + $headline_row["excerpt"] = $line["content_preview"]; |
|
| 771 | + |
|
| 772 | + if ($show_content) { |
|
| 773 | + |
|
| 774 | + if ($sanitize_content) { |
|
| 775 | + $headline_row["content"] = sanitize( |
|
| 776 | + $line["content"], |
|
| 777 | + API::param_to_bool($line['hide_images']), |
|
| 778 | + false, $line["site_url"], false, $line["id"]); |
|
| 779 | + } else { |
|
| 780 | + $headline_row["content"] = $line["content"]; |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + // unify label output to ease parsing |
|
| 785 | + if ($labels["no-labels"] == 1) $labels = array(); |
|
| 786 | + |
|
| 787 | + $headline_row["labels"] = $labels; |
|
| 788 | + |
|
| 789 | + $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : |
|
| 790 | + $feed_title; |
|
| 791 | + |
|
| 792 | + $headline_row["comments_count"] = (int)$line["num_comments"]; |
|
| 793 | + $headline_row["comments_link"] = $line["comments"]; |
|
| 794 | 794 | |
| 795 | - $headline_row["always_display_attachments"] = API::param_to_bool($line["always_display_enclosures"]); |
|
| 795 | + $headline_row["always_display_attachments"] = API::param_to_bool($line["always_display_enclosures"]); |
|
| 796 | 796 | |
| 797 | - $headline_row["author"] = $line["author"]; |
|
| 797 | + $headline_row["author"] = $line["author"]; |
|
| 798 | 798 | |
| 799 | - $headline_row["score"] = (int)$line["score"]; |
|
| 800 | - $headline_row["note"] = $line["note"]; |
|
| 801 | - $headline_row["lang"] = $line["lang"]; |
|
| 799 | + $headline_row["score"] = (int)$line["score"]; |
|
| 800 | + $headline_row["note"] = $line["note"]; |
|
| 801 | + $headline_row["lang"] = $line["lang"]; |
|
| 802 | 802 | |
| 803 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { |
|
| 804 | - $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); |
|
| 805 | - } |
|
| 803 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { |
|
| 804 | + $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | - $headline_row["content"] = DiskCache::rewriteUrls($headline_row['content']); |
|
| 807 | + $headline_row["content"] = DiskCache::rewriteUrls($headline_row['content']); |
|
| 808 | 808 | |
| 809 | - list ($flavor_image, $flavor_stream) = Article::get_article_image($enclosures, $line["content"], $line["site_url"]); |
|
| 809 | + list ($flavor_image, $flavor_stream) = Article::get_article_image($enclosures, $line["content"], $line["site_url"]); |
|
| 810 | 810 | |
| 811 | - $headline_row["flavor_image"] = $flavor_image; |
|
| 812 | - $headline_row["flavor_stream"] = $flavor_stream; |
|
| 811 | + $headline_row["flavor_image"] = $flavor_image; |
|
| 812 | + $headline_row["flavor_stream"] = $flavor_stream; |
|
| 813 | 813 | |
| 814 | - array_push($headlines, $headline_row); |
|
| 815 | - } |
|
| 816 | - } else if (is_numeric($result) && $result == -1) { |
|
| 817 | - $headlines_header['first_id_changed'] = true; |
|
| 818 | - } |
|
| 814 | + array_push($headlines, $headline_row); |
|
| 815 | + } |
|
| 816 | + } else if (is_numeric($result) && $result == -1) { |
|
| 817 | + $headlines_header['first_id_changed'] = true; |
|
| 818 | + } |
|
| 819 | 819 | |
| 820 | - return array($headlines, $headlines_header); |
|
| 821 | - } |
|
| 820 | + return array($headlines, $headlines_header); |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - public function unsubscribeFeed() { |
|
| 824 | - $feed_id = (int) clean($_REQUEST["feed_id"]); |
|
| 823 | + public function unsubscribeFeed() { |
|
| 824 | + $feed_id = (int) clean($_REQUEST["feed_id"]); |
|
| 825 | 825 | |
| 826 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
| 826 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
| 827 | 827 | id = ? AND owner_uid = ?"); |
| 828 | - $sth->execute([$feed_id, $_SESSION['uid']]); |
|
| 829 | - |
|
| 830 | - if ($sth->fetch()) { |
|
| 831 | - Pref_Feeds::remove_feed($feed_id, $_SESSION["uid"]); |
|
| 832 | - $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 833 | - } else { |
|
| 834 | - $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND")); |
|
| 835 | - } |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - public function subscribeToFeed() { |
|
| 839 | - $feed_url = clean($_REQUEST["feed_url"]); |
|
| 840 | - $category_id = (int) clean($_REQUEST["category_id"]); |
|
| 841 | - $login = clean($_REQUEST["login"]); |
|
| 842 | - $password = clean($_REQUEST["password"]); |
|
| 843 | - |
|
| 844 | - if ($feed_url) { |
|
| 845 | - $rc = Feeds::subscribe_to_feed($feed_url, $category_id, $login, $password); |
|
| 846 | - |
|
| 847 | - $this->wrap(self::STATUS_OK, array("status" => $rc)); |
|
| 848 | - } else { |
|
| 849 | - $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 850 | - } |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - public function getFeedTree() { |
|
| 854 | - $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); |
|
| 855 | - |
|
| 856 | - $pf = new Pref_Feeds($_REQUEST); |
|
| 857 | - |
|
| 858 | - $_REQUEST['mode'] = 2; |
|
| 859 | - $_REQUEST['force_show_empty'] = $include_empty; |
|
| 860 | - |
|
| 861 | - if ($pf){ |
|
| 862 | - $data = $pf->makefeedtree(); |
|
| 863 | - $this->wrap(self::STATUS_OK, array("categories" => $data)); |
|
| 864 | - } else { |
|
| 865 | - $this->wrap(self::STATUS_ERR, array("error" => |
|
| 866 | - 'UNABLE_TO_INSTANTIATE_OBJECT')); |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - // only works for labels or uncategorized for the time being |
|
| 872 | - private function isCategoryEmpty($id) { |
|
| 873 | - |
|
| 874 | - if ($id == -2) { |
|
| 875 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS count FROM ttrss_labels2 |
|
| 828 | + $sth->execute([$feed_id, $_SESSION['uid']]); |
|
| 829 | + |
|
| 830 | + if ($sth->fetch()) { |
|
| 831 | + Pref_Feeds::remove_feed($feed_id, $_SESSION["uid"]); |
|
| 832 | + $this->wrap(self::STATUS_OK, array("status" => "OK")); |
|
| 833 | + } else { |
|
| 834 | + $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND")); |
|
| 835 | + } |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + public function subscribeToFeed() { |
|
| 839 | + $feed_url = clean($_REQUEST["feed_url"]); |
|
| 840 | + $category_id = (int) clean($_REQUEST["category_id"]); |
|
| 841 | + $login = clean($_REQUEST["login"]); |
|
| 842 | + $password = clean($_REQUEST["password"]); |
|
| 843 | + |
|
| 844 | + if ($feed_url) { |
|
| 845 | + $rc = Feeds::subscribe_to_feed($feed_url, $category_id, $login, $password); |
|
| 846 | + |
|
| 847 | + $this->wrap(self::STATUS_OK, array("status" => $rc)); |
|
| 848 | + } else { |
|
| 849 | + $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE')); |
|
| 850 | + } |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + public function getFeedTree() { |
|
| 854 | + $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); |
|
| 855 | + |
|
| 856 | + $pf = new Pref_Feeds($_REQUEST); |
|
| 857 | + |
|
| 858 | + $_REQUEST['mode'] = 2; |
|
| 859 | + $_REQUEST['force_show_empty'] = $include_empty; |
|
| 860 | + |
|
| 861 | + if ($pf){ |
|
| 862 | + $data = $pf->makefeedtree(); |
|
| 863 | + $this->wrap(self::STATUS_OK, array("categories" => $data)); |
|
| 864 | + } else { |
|
| 865 | + $this->wrap(self::STATUS_ERR, array("error" => |
|
| 866 | + 'UNABLE_TO_INSTANTIATE_OBJECT')); |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + // only works for labels or uncategorized for the time being |
|
| 872 | + private function isCategoryEmpty($id) { |
|
| 873 | + |
|
| 874 | + if ($id == -2) { |
|
| 875 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS count FROM ttrss_labels2 |
|
| 876 | 876 | WHERE owner_uid = ?"); |
| 877 | - $sth->execute([$_SESSION['uid']]); |
|
| 878 | - $row = $sth->fetch(); |
|
| 877 | + $sth->execute([$_SESSION['uid']]); |
|
| 878 | + $row = $sth->fetch(); |
|
| 879 | 879 | |
| 880 | - return $row["count"] == 0; |
|
| 880 | + return $row["count"] == 0; |
|
| 881 | 881 | |
| 882 | - } else if ($id == 0) { |
|
| 883 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS count FROM ttrss_feeds |
|
| 882 | + } else if ($id == 0) { |
|
| 883 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS count FROM ttrss_feeds |
|
| 884 | 884 | WHERE cat_id IS NULL AND owner_uid = ?"); |
| 885 | - $sth->execute([$_SESSION['uid']]); |
|
| 886 | - $row = $sth->fetch(); |
|
| 885 | + $sth->execute([$_SESSION['uid']]); |
|
| 886 | + $row = $sth->fetch(); |
|
| 887 | 887 | |
| 888 | - return $row["count"] == 0; |
|
| 888 | + return $row["count"] == 0; |
|
| 889 | 889 | |
| 890 | - } |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - return false; |
|
| 893 | - } |
|
| 892 | + return false; |
|
| 893 | + } |
|
| 894 | 894 | |
| 895 | 895 | |
| 896 | 896 | } |
@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | $password = clean($_REQUEST["password"]); |
| 58 | 58 | $password_base64 = base64_decode(clean($_REQUEST["password"])); |
| 59 | 59 | |
| 60 | - if (SINGLE_USER_MODE) $login = "admin"; |
|
| 60 | + if (SINGLE_USER_MODE) { |
|
| 61 | + $login = "admin"; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
| 63 | 65 | $sth->execute([$login]); |
@@ -134,10 +136,11 @@ discard block |
||
| 134 | 136 | |
| 135 | 137 | // TODO do not return empty categories, return Uncategorized and standard virtual cats |
| 136 | 138 | |
| 137 | - if ($enable_nested) |
|
| 138 | - $nested_qpart = "parent_cat IS NULL"; |
|
| 139 | - else |
|
| 140 | - $nested_qpart = "true"; |
|
| 139 | + if ($enable_nested) { |
|
| 140 | + $nested_qpart = "parent_cat IS NULL"; |
|
| 141 | + } else { |
|
| 142 | + $nested_qpart = "true"; |
|
| 143 | + } |
|
| 141 | 144 | |
| 142 | 145 | $sth = $this->pdo->prepare("SELECT |
| 143 | 146 | id, title, order_id, (SELECT COUNT(id) FROM |
@@ -156,8 +159,9 @@ discard block |
||
| 156 | 159 | if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) { |
| 157 | 160 | $unread = getFeedUnread($line["id"], true); |
| 158 | 161 | |
| 159 | - if ($enable_nested) |
|
| 160 | - $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 162 | + if ($enable_nested) { |
|
| 163 | + $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
| 164 | + } |
|
| 161 | 165 | |
| 162 | 166 | if ($unread || !$unread_only) { |
| 163 | 167 | array_push($cats, array("id" => $line["id"], |
@@ -188,11 +192,15 @@ discard block |
||
| 188 | 192 | $feed_id = clean($_REQUEST["feed_id"]); |
| 189 | 193 | if ($feed_id !== "") { |
| 190 | 194 | |
| 191 | - if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
|
| 195 | + if (is_numeric($feed_id)) { |
|
| 196 | + $feed_id = (int) $feed_id; |
|
| 197 | + } |
|
| 192 | 198 | |
| 193 | 199 | $limit = (int)clean($_REQUEST["limit"]); |
| 194 | 200 | |
| 195 | - if (!$limit || $limit >= 200) $limit = 200; |
|
| 201 | + if (!$limit || $limit >= 200) { |
|
| 202 | + $limit = 200; |
|
| 203 | + } |
|
| 196 | 204 | |
| 197 | 205 | $offset = (int)clean($_REQUEST["skip"]); |
| 198 | 206 | $filter = clean($_REQUEST["filter"]); |
@@ -287,7 +295,9 @@ discard block |
||
| 287 | 295 | break; |
| 288 | 296 | } |
| 289 | 297 | |
| 290 | - if ($field == "note") $set_to = $this->pdo->quote($data); |
|
| 298 | + if ($field == "note") { |
|
| 299 | + $set_to = $this->pdo->quote($data); |
|
| 300 | + } |
|
| 291 | 301 | |
| 292 | 302 | if ($field && $set_to && count($article_ids) > 0) { |
| 293 | 303 | |
@@ -443,10 +453,11 @@ discard block |
||
| 443 | 453 | WHERE owner_uid = ? ORDER BY caption"); |
| 444 | 454 | $sth->execute([$_SESSION['uid']]); |
| 445 | 455 | |
| 446 | - if ($article_id) |
|
| 447 | - $article_labels = Article::get_article_labels($article_id); |
|
| 448 | - else |
|
| 449 | - $article_labels = array(); |
|
| 456 | + if ($article_id) { |
|
| 457 | + $article_labels = Article::get_article_labels($article_id); |
|
| 458 | + } else { |
|
| 459 | + $article_labels = array(); |
|
| 460 | + } |
|
| 450 | 461 | |
| 451 | 462 | while ($line = $sth->fetch()) { |
| 452 | 463 | |
@@ -483,10 +494,11 @@ discard block |
||
| 483 | 494 | |
| 484 | 495 | foreach ($article_ids as $id) { |
| 485 | 496 | |
| 486 | - if ($assign) |
|
| 487 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 488 | - else |
|
| 489 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 497 | + if ($assign) { |
|
| 498 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 499 | + } else { |
|
| 500 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 501 | + } |
|
| 490 | 502 | |
| 491 | 503 | ++$num_updated; |
| 492 | 504 | |
@@ -738,14 +750,17 @@ discard block |
||
| 738 | 750 | $label_cache = json_decode($label_cache, true); |
| 739 | 751 | |
| 740 | 752 | if ($label_cache) { |
| 741 | - if ($label_cache["no-labels"] == 1) |
|
| 742 | - $labels = array(); |
|
| 743 | - else |
|
| 744 | - $labels = $label_cache; |
|
| 753 | + if ($label_cache["no-labels"] == 1) { |
|
| 754 | + $labels = array(); |
|
| 755 | + } else { |
|
| 756 | + $labels = $label_cache; |
|
| 757 | + } |
|
| 745 | 758 | } |
| 746 | 759 | } |
| 747 | 760 | |
| 748 | - if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
|
| 761 | + if (!is_array($labels)) { |
|
| 762 | + $labels = Article::get_article_labels($line["id"]); |
|
| 763 | + } |
|
| 749 | 764 | |
| 750 | 765 | $headline_row = array( |
| 751 | 766 | "id" => (int)$line["id"], |
@@ -763,11 +778,13 @@ discard block |
||
| 763 | 778 | |
| 764 | 779 | $enclosures = Article::get_article_enclosures($line['id']); |
| 765 | 780 | |
| 766 | - if ($include_attachments) |
|
| 767 | - $headline_row['attachments'] = $enclosures; |
|
| 781 | + if ($include_attachments) { |
|
| 782 | + $headline_row['attachments'] = $enclosures; |
|
| 783 | + } |
|
| 768 | 784 | |
| 769 | - if ($show_excerpt) |
|
| 770 | - $headline_row["excerpt"] = $line["content_preview"]; |
|
| 785 | + if ($show_excerpt) { |
|
| 786 | + $headline_row["excerpt"] = $line["content_preview"]; |
|
| 787 | + } |
|
| 771 | 788 | |
| 772 | 789 | if ($show_content) { |
| 773 | 790 | |
@@ -782,7 +799,9 @@ discard block |
||
| 782 | 799 | } |
| 783 | 800 | |
| 784 | 801 | // unify label output to ease parsing |
| 785 | - if ($labels["no-labels"] == 1) $labels = array(); |
|
| 802 | + if ($labels["no-labels"] == 1) { |
|
| 803 | + $labels = array(); |
|
| 804 | + } |
|
| 786 | 805 | |
| 787 | 806 | $headline_row["labels"] = $labels; |
| 788 | 807 | |
@@ -126,14 +126,14 @@ |
||
| 126 | 126 | $tmp = ''; |
| 127 | 127 | foreach (str_split($keys[$i]) as $c) { |
| 128 | 128 | switch ($c) { |
| 129 | - case '*': |
|
| 130 | - $tmp .= __('Shift') . '+'; |
|
| 131 | - break; |
|
| 132 | - case '^': |
|
| 133 | - $tmp .= __('Ctrl') . '+'; |
|
| 134 | - break; |
|
| 135 | - default: |
|
| 136 | - $tmp .= $c; |
|
| 129 | + case '*': |
|
| 130 | + $tmp .= __('Shift') . '+'; |
|
| 131 | + break; |
|
| 132 | + case '^': |
|
| 133 | + $tmp .= __('Ctrl') . '+'; |
|
| 134 | + break; |
|
| 135 | + default: |
|
| 136 | + $tmp .= $c; |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | $keys[$i] = $tmp; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | class Backend extends Handler { |
| 3 | 3 | public function loading() { |
| 4 | 4 | header("Content-type: text/html"); |
| 5 | - print __("Loading, please wait...") . " " . |
|
| 5 | + print __("Loading, please wait...")." ". |
|
| 6 | 6 | "<img src='images/indicator_tiny.gif'>"; |
| 7 | 7 | } |
| 8 | 8 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | foreach ($info as $section => $hotkeys) { |
| 42 | 42 | |
| 43 | 43 | if ($cur_section) print "<li> </li>"; |
| 44 | - print "<li><h3>" . $section . "</h3></li>"; |
|
| 44 | + print "<li><h3>".$section."</h3></li>"; |
|
| 45 | 45 | $cur_section = $section; |
| 46 | 46 | |
| 47 | 47 | foreach ($hotkeys as $action => $description) { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | foreach ($omap[$action] as $sequence) { |
| 51 | 51 | if (strpos($sequence, "|") !== FALSE) { |
| 52 | 52 | $sequence = substr($sequence, |
| 53 | - strpos($sequence, "|")+1, |
|
| 53 | + strpos($sequence, "|") + 1, |
|
| 54 | 54 | strlen($sequence)); |
| 55 | 55 | } else { |
| 56 | 56 | $keys = explode(" ", $sequence); |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | foreach (str_split($keys[$i]) as $c) { |
| 62 | 62 | switch ($c) { |
| 63 | 63 | case '*': |
| 64 | - $tmp .= __('Shift') . '+'; |
|
| 64 | + $tmp .= __('Shift').'+'; |
|
| 65 | 65 | break; |
| 66 | 66 | case '^': |
| 67 | - $tmp .= __('Ctrl') . '+'; |
|
| 67 | + $tmp .= __('Ctrl').'+'; |
|
| 68 | 68 | break; |
| 69 | 69 | default: |
| 70 | 70 | $tmp .= $c; |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | if (is_array($omap[$action])) { |
| 50 | 50 | foreach ($omap[$action] as $sequence) { |
| 51 | - if (strpos($sequence, "|") !== FALSE) { |
|
| 51 | + if (strpos($sequence, "|") !== false) { |
|
| 52 | 52 | $sequence = substr($sequence, |
| 53 | 53 | strpos($sequence, "|")+1, |
| 54 | 54 | strlen($sequence)); |
@@ -1,97 +1,97 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Backend extends Handler { |
| 3 | - public function loading() { |
|
| 4 | - header("Content-type: text/html"); |
|
| 5 | - print __("Loading, please wait...") . " " . |
|
| 6 | - "<img src='images/indicator_tiny.gif'>"; |
|
| 7 | - } |
|
| 8 | - |
|
| 9 | - public function digestTest() { |
|
| 10 | - if (isset($_SESSION['uid'])) { |
|
| 11 | - header("Content-type: text/html"); |
|
| 12 | - |
|
| 13 | - $rv = Digest::prepare_headlines_digest($_SESSION['uid'], 1, 1000); |
|
| 14 | - |
|
| 15 | - print "<h1>HTML</h1>"; |
|
| 16 | - print $rv[0]; |
|
| 17 | - print "<h1>Plain text</h1>"; |
|
| 18 | - print "<pre>".$rv[3]."</pre>"; |
|
| 19 | - } else { |
|
| 20 | - print error_json(6); |
|
| 21 | - } |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function help() { |
|
| 25 | - $topic = clean_filename($_REQUEST["topic"]); // only one for now |
|
| 26 | - |
|
| 27 | - if ($topic == "main") { |
|
| 28 | - $info = get_hotkeys_info(); |
|
| 29 | - $imap = get_hotkeys_map(); |
|
| 30 | - $omap = array(); |
|
| 31 | - |
|
| 32 | - foreach ($imap[1] as $sequence => $action) { |
|
| 33 | - if (!isset($omap[$action])) $omap[$action] = array(); |
|
| 34 | - |
|
| 35 | - array_push($omap[$action], $sequence); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - print "<ul class='panel panel-scrollable hotkeys-help' style='height : 300px'>"; |
|
| 39 | - |
|
| 40 | - $cur_section = ""; |
|
| 41 | - foreach ($info as $section => $hotkeys) { |
|
| 42 | - |
|
| 43 | - if ($cur_section) print "<li> </li>"; |
|
| 44 | - print "<li><h3>" . $section . "</h3></li>"; |
|
| 45 | - $cur_section = $section; |
|
| 46 | - |
|
| 47 | - foreach ($hotkeys as $action => $description) { |
|
| 48 | - |
|
| 49 | - if (is_array($omap[$action])) { |
|
| 50 | - foreach ($omap[$action] as $sequence) { |
|
| 51 | - if (strpos($sequence, "|") !== FALSE) { |
|
| 52 | - $sequence = substr($sequence, |
|
| 53 | - strpos($sequence, "|")+1, |
|
| 54 | - strlen($sequence)); |
|
| 55 | - } else { |
|
| 56 | - $keys = explode(" ", $sequence); |
|
| 57 | - |
|
| 58 | - for ($i = 0; $i < count($keys); $i++) { |
|
| 59 | - if (strlen($keys[$i]) > 1) { |
|
| 60 | - $tmp = ''; |
|
| 61 | - foreach (str_split($keys[$i]) as $c) { |
|
| 62 | - switch ($c) { |
|
| 63 | - case '*': |
|
| 64 | - $tmp .= __('Shift') . '+'; |
|
| 65 | - break; |
|
| 66 | - case '^': |
|
| 67 | - $tmp .= __('Ctrl') . '+'; |
|
| 68 | - break; |
|
| 69 | - default: |
|
| 70 | - $tmp .= $c; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - $keys[$i] = $tmp; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - $sequence = join(" ", $keys); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - print "<li>"; |
|
| 80 | - print "<div class='hk'><code>$sequence</code></div>"; |
|
| 81 | - print "<div class='desc'>$description</div>"; |
|
| 82 | - print "</li>"; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - print "</ul>"; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - print "<footer class='text-center'>"; |
|
| 92 | - print "<button dojoType='dijit.form.Button' |
|
| 3 | + public function loading() { |
|
| 4 | + header("Content-type: text/html"); |
|
| 5 | + print __("Loading, please wait...") . " " . |
|
| 6 | + "<img src='images/indicator_tiny.gif'>"; |
|
| 7 | + } |
|
| 8 | + |
|
| 9 | + public function digestTest() { |
|
| 10 | + if (isset($_SESSION['uid'])) { |
|
| 11 | + header("Content-type: text/html"); |
|
| 12 | + |
|
| 13 | + $rv = Digest::prepare_headlines_digest($_SESSION['uid'], 1, 1000); |
|
| 14 | + |
|
| 15 | + print "<h1>HTML</h1>"; |
|
| 16 | + print $rv[0]; |
|
| 17 | + print "<h1>Plain text</h1>"; |
|
| 18 | + print "<pre>".$rv[3]."</pre>"; |
|
| 19 | + } else { |
|
| 20 | + print error_json(6); |
|
| 21 | + } |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function help() { |
|
| 25 | + $topic = clean_filename($_REQUEST["topic"]); // only one for now |
|
| 26 | + |
|
| 27 | + if ($topic == "main") { |
|
| 28 | + $info = get_hotkeys_info(); |
|
| 29 | + $imap = get_hotkeys_map(); |
|
| 30 | + $omap = array(); |
|
| 31 | + |
|
| 32 | + foreach ($imap[1] as $sequence => $action) { |
|
| 33 | + if (!isset($omap[$action])) $omap[$action] = array(); |
|
| 34 | + |
|
| 35 | + array_push($omap[$action], $sequence); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + print "<ul class='panel panel-scrollable hotkeys-help' style='height : 300px'>"; |
|
| 39 | + |
|
| 40 | + $cur_section = ""; |
|
| 41 | + foreach ($info as $section => $hotkeys) { |
|
| 42 | + |
|
| 43 | + if ($cur_section) print "<li> </li>"; |
|
| 44 | + print "<li><h3>" . $section . "</h3></li>"; |
|
| 45 | + $cur_section = $section; |
|
| 46 | + |
|
| 47 | + foreach ($hotkeys as $action => $description) { |
|
| 48 | + |
|
| 49 | + if (is_array($omap[$action])) { |
|
| 50 | + foreach ($omap[$action] as $sequence) { |
|
| 51 | + if (strpos($sequence, "|") !== FALSE) { |
|
| 52 | + $sequence = substr($sequence, |
|
| 53 | + strpos($sequence, "|")+1, |
|
| 54 | + strlen($sequence)); |
|
| 55 | + } else { |
|
| 56 | + $keys = explode(" ", $sequence); |
|
| 57 | + |
|
| 58 | + for ($i = 0; $i < count($keys); $i++) { |
|
| 59 | + if (strlen($keys[$i]) > 1) { |
|
| 60 | + $tmp = ''; |
|
| 61 | + foreach (str_split($keys[$i]) as $c) { |
|
| 62 | + switch ($c) { |
|
| 63 | + case '*': |
|
| 64 | + $tmp .= __('Shift') . '+'; |
|
| 65 | + break; |
|
| 66 | + case '^': |
|
| 67 | + $tmp .= __('Ctrl') . '+'; |
|
| 68 | + break; |
|
| 69 | + default: |
|
| 70 | + $tmp .= $c; |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + $keys[$i] = $tmp; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + $sequence = join(" ", $keys); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + print "<li>"; |
|
| 80 | + print "<div class='hk'><code>$sequence</code></div>"; |
|
| 81 | + print "<div class='desc'>$description</div>"; |
|
| 82 | + print "</li>"; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + print "</ul>"; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + print "<footer class='text-center'>"; |
|
| 92 | + print "<button dojoType='dijit.form.Button' |
|
| 93 | 93 | onclick=\"return dijit.byId('helpDlg').hide()\">".__('Close this window')."</button>"; |
| 94 | - print "</footer>"; |
|
| 94 | + print "</footer>"; |
|
| 95 | 95 | |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -30,7 +30,9 @@ discard block |
||
| 30 | 30 | $omap = array(); |
| 31 | 31 | |
| 32 | 32 | foreach ($imap[1] as $sequence => $action) { |
| 33 | - if (!isset($omap[$action])) $omap[$action] = array(); |
|
| 33 | + if (!isset($omap[$action])) { |
|
| 34 | + $omap[$action] = array(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | array_push($omap[$action], $sequence); |
| 36 | 38 | } |
@@ -40,7 +42,9 @@ discard block |
||
| 40 | 42 | $cur_section = ""; |
| 41 | 43 | foreach ($info as $section => $hotkeys) { |
| 42 | 44 | |
| 43 | - if ($cur_section) print "<li> </li>"; |
|
| 45 | + if ($cur_section) { |
|
| 46 | + print "<li> </li>"; |
|
| 47 | + } |
|
| 44 | 48 | print "<li><h3>" . $section . "</h3></li>"; |
| 45 | 49 | $cur_section = $section; |
| 46 | 50 | |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | $line[$k] = htmlspecialchars($v); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; |
|
| 64 | - print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; |
|
| 65 | - print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>"; |
|
| 66 | - print "<td class='login'>" . $line["login"] . "</td>"; |
|
| 63 | + print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>"; |
|
| 64 | + print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>"; |
|
| 65 | + print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>"; |
|
| 66 | + print "<td class='login'>".$line["login"]."</td>"; |
|
| 67 | 67 | |
| 68 | - print "<td class='timestamp'>" . |
|
| 68 | + print "<td class='timestamp'>". |
|
| 69 | 69 | make_local_datetime( |
| 70 | - $line["created_at"], false) . "</td>"; |
|
| 70 | + $line["created_at"], false)."</td>"; |
|
| 71 | 71 | |
| 72 | 72 | print "</tr>"; |
| 73 | 73 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ob_end_clean(); |
| 91 | 91 | |
| 92 | 92 | print "<div class='phpinfo'>"; |
| 93 | - print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
| 93 | + print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info); |
|
| 94 | 94 | print "</div>"; |
| 95 | 95 | |
| 96 | 96 | print "</div>"; |
@@ -2,50 +2,50 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class Pref_System extends Handler_Protected { |
| 4 | 4 | |
| 5 | - public function before($method) { |
|
| 6 | - if (parent::before($method)) { |
|
| 7 | - if ($_SESSION["access_level"] < 10) { |
|
| 8 | - print __("Your access level is insufficient to open this tab."); |
|
| 9 | - return false; |
|
| 10 | - } |
|
| 11 | - return true; |
|
| 12 | - } |
|
| 13 | - return false; |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public function csrf_ignore($method) { |
|
| 17 | - $csrf_ignored = array("index"); |
|
| 18 | - |
|
| 19 | - return array_search($method, $csrf_ignored) !== false; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function clearLog() { |
|
| 23 | - $this->pdo->query("DELETE FROM ttrss_error_log"); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function index() { |
|
| 27 | - |
|
| 28 | - print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
|
| 29 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 5 | + public function before($method) { |
|
| 6 | + if (parent::before($method)) { |
|
| 7 | + if ($_SESSION["access_level"] < 10) { |
|
| 8 | + print __("Your access level is insufficient to open this tab."); |
|
| 9 | + return false; |
|
| 10 | + } |
|
| 11 | + return true; |
|
| 12 | + } |
|
| 13 | + return false; |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + public function csrf_ignore($method) { |
|
| 17 | + $csrf_ignored = array("index"); |
|
| 18 | + |
|
| 19 | + return array_search($method, $csrf_ignored) !== false; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function clearLog() { |
|
| 23 | + $this->pdo->query("DELETE FROM ttrss_error_log"); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function index() { |
|
| 27 | + |
|
| 28 | + print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
|
| 29 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 30 | 30 | title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">"; |
| 31 | 31 | |
| 32 | - if (LOG_DESTINATION == "sql") { |
|
| 32 | + if (LOG_DESTINATION == "sql") { |
|
| 33 | 33 | |
| 34 | - $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, |
|
| 34 | + $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, |
|
| 35 | 35 | created_at, login, context FROM ttrss_error_log |
| 36 | 36 | LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) |
| 37 | 37 | ORDER BY ttrss_error_log.id DESC |
| 38 | 38 | LIMIT 100"); |
| 39 | 39 | |
| 40 | - print "<button dojoType=\"dijit.form.Button\" |
|
| 40 | + print "<button dojoType=\"dijit.form.Button\" |
|
| 41 | 41 | onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> "; |
| 42 | 42 | |
| 43 | - print " <button dojoType=\"dijit.form.Button\" |
|
| 43 | + print " <button dojoType=\"dijit.form.Button\" |
|
| 44 | 44 | class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> "; |
| 45 | 45 | |
| 46 | - print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
|
| 46 | + print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
|
| 47 | 47 | |
| 48 | - print "<tr class=\"title\"> |
|
| 48 | + print "<tr class=\"title\"> |
|
| 49 | 49 | <td width='5%'>".__("Error")."</td> |
| 50 | 50 | <td>".__("Filename")."</td> |
| 51 | 51 | <td>".__("Message")."</td> |
@@ -53,52 +53,52 @@ discard block |
||
| 53 | 53 | <td width='5%'>".__("Date")."</td> |
| 54 | 54 | </tr>"; |
| 55 | 55 | |
| 56 | - while ($line = $res->fetch()) { |
|
| 57 | - print "<tr>"; |
|
| 56 | + while ($line = $res->fetch()) { |
|
| 57 | + print "<tr>"; |
|
| 58 | 58 | |
| 59 | - foreach ($line as $k => $v) { |
|
| 60 | - $line[$k] = htmlspecialchars($v); |
|
| 61 | - } |
|
| 59 | + foreach ($line as $k => $v) { |
|
| 60 | + $line[$k] = htmlspecialchars($v); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; |
|
| 64 | - print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; |
|
| 65 | - print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>"; |
|
| 66 | - print "<td class='login'>" . $line["login"] . "</td>"; |
|
| 63 | + print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; |
|
| 64 | + print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; |
|
| 65 | + print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>"; |
|
| 66 | + print "<td class='login'>" . $line["login"] . "</td>"; |
|
| 67 | 67 | |
| 68 | - print "<td class='timestamp'>" . |
|
| 69 | - make_local_datetime( |
|
| 70 | - $line["created_at"], false) . "</td>"; |
|
| 68 | + print "<td class='timestamp'>" . |
|
| 69 | + make_local_datetime( |
|
| 70 | + $line["created_at"], false) . "</td>"; |
|
| 71 | 71 | |
| 72 | - print "</tr>"; |
|
| 73 | - } |
|
| 72 | + print "</tr>"; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - print "</table>"; |
|
| 76 | - } else { |
|
| 75 | + print "</table>"; |
|
| 76 | + } else { |
|
| 77 | 77 | |
| 78 | - print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
|
| 78 | + print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
|
| 79 | 79 | |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - print "</div>"; |
|
| 82 | + print "</div>"; |
|
| 83 | 83 | |
| 84 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 84 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 85 | 85 | title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">"; |
| 86 | 86 | |
| 87 | - ob_start(); |
|
| 88 | - phpinfo(); |
|
| 89 | - $info = ob_get_contents(); |
|
| 90 | - ob_end_clean(); |
|
| 87 | + ob_start(); |
|
| 88 | + phpinfo(); |
|
| 89 | + $info = ob_get_contents(); |
|
| 90 | + ob_end_clean(); |
|
| 91 | 91 | |
| 92 | - print "<div class='phpinfo'>"; |
|
| 93 | - print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
| 94 | - print "</div>"; |
|
| 92 | + print "<div class='phpinfo'>"; |
|
| 93 | + print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
| 94 | + print "</div>"; |
|
| 95 | 95 | |
| 96 | - print "</div>"; |
|
| 96 | + print "</div>"; |
|
| 97 | 97 | |
| 98 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
| 99 | - "hook_prefs_tab", "prefSystem"); |
|
| 98 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
| 99 | + "hook_prefs_tab", "prefSystem"); |
|
| 100 | 100 | |
| 101 | - print "</div>"; #container |
|
| 102 | - } |
|
| 101 | + print "</div>"; #container |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | } |