@@ -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 | } |
@@ -170,22 +170,22 @@ |
||
| 170 | 170 | $value = $_POST[$pref_name]; |
| 171 | 171 | |
| 172 | 172 | switch ($pref_name) { |
| 173 | - case 'DIGEST_PREFERRED_TIME': |
|
| 174 | - if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
| 173 | + case 'DIGEST_PREFERRED_TIME': |
|
| 174 | + if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
| 175 | 175 | |
| 176 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 176 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 177 | 177 | last_digest_sent = NULL WHERE id = ?"); |
| 178 | - $sth->execute([$_SESSION['uid']]); |
|
| 178 | + $sth->execute([$_SESSION['uid']]); |
|
| 179 | 179 | |
| 180 | - } |
|
| 181 | - break; |
|
| 182 | - case 'USER_LANGUAGE': |
|
| 183 | - if (!$need_reload) $need_reload = $_SESSION["language"] != $value; |
|
| 184 | - break; |
|
| 185 | - |
|
| 186 | - case 'USER_CSS_THEME': |
|
| 187 | - if (!$need_reload) $need_reload = get_pref($pref_name) != $value; |
|
| 188 | - break; |
|
| 180 | + } |
|
| 181 | + break; |
|
| 182 | + case 'USER_LANGUAGE': |
|
| 183 | + if (!$need_reload) $need_reload = $_SESSION["language"] != $value; |
|
| 184 | + break; |
|
| 185 | + |
|
| 186 | + case 'USER_CSS_THEME': |
|
| 187 | + if (!$need_reload) $need_reload = get_pref($pref_name) != $value; |
|
| 188 | + break; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | set_pref($pref_name, $value); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | "ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")), |
| 83 | 83 | "ENABLE_FEED_CATS" => array(__("Enable categories")), |
| 84 | 84 | "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""), |
| 85 | - "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>" . __("hours") . "</strong>"), |
|
| 85 | + "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>".__("hours")."</strong>"), |
|
| 86 | 86 | "HIDE_READ_FEEDS" => array(__("Hide read feeds")), |
| 87 | 87 | "HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")), |
| 88 | 88 | "LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")), |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | if ($_SESSION["auth_module"] == "auth_internal") { |
| 405 | 405 | |
| 406 | - print "<div dojoType='dijit.layout.ContentPane' title=\"" . __('App passwords') . "\">"; |
|
| 406 | + print "<div dojoType='dijit.layout.ContentPane' title=\"".__('App passwords')."\">"; |
|
| 407 | 407 | |
| 408 | 408 | print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); |
| 409 | 409 | |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | print "<button style='float : left' class='alt-primary' dojoType='dijit.form.Button' |
| 417 | 417 | onclick=\"Helpers.AppPasswords.generate()\">" . |
| 418 | - __('Generate new password') . "</button> "; |
|
| 418 | + __('Generate new password')."</button> "; |
|
| 419 | 419 | |
| 420 | 420 | print "<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' |
| 421 | 421 | onclick=\"Helpers.AppPasswords.removeSelected()\">" . |
| 422 | - __('Remove selected passwords') . "</button>"; |
|
| 422 | + __('Remove selected passwords')."</button>"; |
|
| 423 | 423 | |
| 424 | 424 | print "</div>"; # content pane |
| 425 | 425 | } |
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | print_notice("You will need to generate app passwords for the API clients if you enable OTP."); |
| 475 | 475 | |
| 476 | 476 | if (function_exists("imagecreatefromstring")) { |
| 477 | - print "<h3>" . __("Scan the following code by the Authenticator application or copy the key manually") . "</h3>"; |
|
| 477 | + print "<h3>".__("Scan the following code by the Authenticator application or copy the key manually")."</h3>"; |
|
| 478 | 478 | |
| 479 | 479 | $csrf_token = $_SESSION["csrf_token"]; |
| 480 | 480 | print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>"; |
| 481 | 481 | } else { |
| 482 | 482 | print_error("PHP GD functions are required to generate QR codes."); |
| 483 | - print "<h3>" . __("Use the following OTP key with a compatible Authenticator application") . "</h3>"; |
|
| 483 | + print "<h3>".__("Use the following OTP key with a compatible Authenticator application")."</h3>"; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | print "<form dojoType='dijit.form.Form' id='changeOtpForm'>"; |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | print "<fieldset class='prefs'>"; |
| 648 | 648 | |
| 649 | 649 | print "<label for='CB_$pref_name'>"; |
| 650 | - print $item['short_desc'] . ":"; |
|
| 650 | + print $item['short_desc'].":"; |
|
| 651 | 651 | print "</label>"; |
| 652 | 652 | |
| 653 | 653 | $value = $item['value']; |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | print "</select>"; |
| 685 | 685 | |
| 686 | 686 | print " <button dojoType=\"dijit.form.Button\" class='alt-info' |
| 687 | - onclick=\"Helpers.customizeCSS()\">" . __('Customize') . "</button>"; |
|
| 687 | + onclick=\"Helpers.customizeCSS()\">" . __('Customize')."</button>"; |
|
| 688 | 688 | |
| 689 | 689 | print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'> |
| 690 | 690 | <i class='material-icons'>open_in_new</i> ".__("More themes...")."</button>"; |
@@ -747,12 +747,12 @@ discard block |
||
| 747 | 747 | $has_serial = ($cert_serial) ? "false" : "true"; |
| 748 | 748 | |
| 749 | 749 | print "<button dojoType='dijit.form.Button' disabled='$has_serial' |
| 750 | - onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '$cert_serial')\">" . |
|
| 751 | - __('Register') . "</button>"; |
|
| 750 | + onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '$cert_serial')\">". |
|
| 751 | + __('Register')."</button>"; |
|
| 752 | 752 | |
| 753 | 753 | print "<button dojoType='dijit.form.Button' class='alt-danger' |
| 754 | 754 | onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '')\">" . |
| 755 | - __('Clear') . "</button>"; |
|
| 755 | + __('Clear')."</button>"; |
|
| 756 | 756 | |
| 757 | 757 | print "<button dojoType='dijit.form.Button' class='alt-info' |
| 758 | 758 | onclick='window.open(\"https://tt-rss.org/wiki/SSL%20Certificate%20Authentication\")'> |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\" |
| 764 | 764 | name=\"$pref_name\" value=\"$value\">"; |
| 765 | 765 | |
| 766 | - $item['help_text'] .= ". " . T_sprintf("Current server time: %s", date("H:i")); |
|
| 766 | + $item['help_text'] .= ". ".T_sprintf("Current server time: %s", date("H:i")); |
|
| 767 | 767 | } else { |
| 768 | 768 | $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; |
| 769 | 769 | |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - $feed_handler_whitelist = [ "Af_Comics" ]; |
|
| 852 | + $feed_handler_whitelist = ["Af_Comics"]; |
|
| 853 | 853 | |
| 854 | 854 | $feed_handlers = array_merge( |
| 855 | 855 | PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), |
@@ -861,9 +861,9 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | if (count($feed_handlers) > 0) { |
| 863 | 863 | print_error( |
| 864 | - T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>" , |
|
| 864 | + T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>", |
|
| 865 | 865 | implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) |
| 866 | - ) . " (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)" |
|
| 866 | + )." (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)" |
|
| 867 | 867 | ); |
| 868 | 868 | } |
| 869 | 869 | |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | <label class='checkbox description text-muted' id='PLABEL-$name'> |
| 893 | 893 | <input disabled='1' |
| 894 | 894 | dojoType='dijit.form.CheckBox' $checked type='checkbox'> |
| 895 | - ".htmlspecialchars($about[1]). "</label>"; |
|
| 895 | + ".htmlspecialchars($about[1])."</label>"; |
|
| 896 | 896 | |
| 897 | 897 | if (@$about[4]) { |
| 898 | 898 | print "<button dojoType='dijit.form.Button' class='alt-info' |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | print "<div dojoType='fox.Toolbar'>"; |
| 1155 | 1155 | |
| 1156 | 1156 | print "<div dojoType='fox.form.DropDownButton'>". |
| 1157 | - "<span>" . __('Select')."</span>"; |
|
| 1157 | + "<span>".__('Select')."</span>"; |
|
| 1158 | 1158 | print "<div dojoType='dijit.Menu' style='display: none'>"; |
| 1159 | 1159 | print "<div onclick=\"Tables.select('pref-profiles-list', true)\" |
| 1160 | 1160 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | $is_active = ""; |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | - print "<td width='100%'><span>" . __("Default profile") . " $is_active</span></td>"; |
|
| 1195 | + print "<td width='100%'><span>".__("Default profile")." $is_active</span></td>"; |
|
| 1196 | 1196 | |
| 1197 | 1197 | print "</tr>"; |
| 1198 | 1198 | |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | |
| 1215 | 1215 | print "<td><span dojoType='dijit.InlineEditBox' |
| 1216 | 1216 | width='300px' autoSave='false' |
| 1217 | - profile-id='$profile_id'>" . $edit_title . |
|
| 1217 | + profile-id='$profile_id'>".$edit_title. |
|
| 1218 | 1218 | "<script type='dojo/method' event='onChange' args='item'> |
| 1219 | 1219 | var elem = this; |
| 1220 | 1220 | dojo.xhrPost({ |
@@ -1263,13 +1263,13 @@ discard block |
||
| 1263 | 1263 | |
| 1264 | 1264 | private function appPasswordList() { |
| 1265 | 1265 | print "<div dojoType='fox.Toolbar'>"; |
| 1266 | - print "<div dojoType='fox.form.DropDownButton'>" . |
|
| 1267 | - "<span>" . __('Select') . "</span>"; |
|
| 1266 | + print "<div dojoType='fox.form.DropDownButton'>". |
|
| 1267 | + "<span>".__('Select')."</span>"; |
|
| 1268 | 1268 | print "<div dojoType='dijit.Menu' style='display: none'>"; |
| 1269 | 1269 | print "<div onclick=\"Tables.select('app-password-list', true)\" |
| 1270 | - dojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; |
|
| 1270 | + dojoType=\"dijit.MenuItem\">" . __('All')."</div>"; |
|
| 1271 | 1271 | print "<div onclick=\"Tables.select('app-password-list', false)\" |
| 1272 | - dojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; |
|
| 1272 | + dojoType=\"dijit.MenuItem\">" . __('None')."</div>"; |
|
| 1273 | 1273 | print "</div></div>"; |
| 1274 | 1274 | print "</div>"; #toolbar |
| 1275 | 1275 | |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | |
| 1295 | 1295 | print "<td align='center'> |
| 1296 | 1296 | <input onclick='Tables.onRowChecked(this)' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
| 1297 | - print "<td>" . htmlspecialchars($row["title"]) . "</td>"; |
|
| 1297 | + print "<td>".htmlspecialchars($row["title"])."</td>"; |
|
| 1298 | 1298 | |
| 1299 | 1299 | print "<td align='right' class='text-muted'>"; |
| 1300 | 1300 | print make_local_datetime($row['created'], false); |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | private function encryptAppPassword($password) { |
| 1315 | 1315 | $salt = substr(bin2hex(get_random_bytes(24)), 0, 24); |
| 1316 | 1316 | |
| 1317 | - return "SSHA-512:".hash('sha512', $salt . $password). ":$salt"; |
|
| 1317 | + return "SSHA-512:".hash('sha512', $salt.$password).":$salt"; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | public function deleteAppPassword() { |
@@ -857,7 +857,7 @@ |
||
| 857 | 857 | PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); |
| 858 | 858 | |
| 859 | 859 | $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { |
| 860 | - return in_array(get_class($plugin), $feed_handler_whitelist) === FALSE; }); |
|
| 860 | + return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); |
|
| 861 | 861 | |
| 862 | 862 | if (count($feed_handlers) > 0) { |
| 863 | 863 | print_error( |
@@ -2,278 +2,278 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class Pref_Prefs extends Handler_Protected { |
| 4 | 4 | |
| 5 | - private $pref_help = []; |
|
| 6 | - private $pref_item_map = []; |
|
| 7 | - private $pref_blacklist = []; |
|
| 8 | - private $profile_blacklist = []; |
|
| 9 | - |
|
| 10 | - public function csrf_ignore($method) { |
|
| 11 | - $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles"); |
|
| 12 | - |
|
| 13 | - return array_search($method, $csrf_ignored) !== false; |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public function __construct($args) { |
|
| 17 | - parent::__construct($args); |
|
| 18 | - |
|
| 19 | - $this->pref_item_map = [ |
|
| 20 | - __('General') => [ |
|
| 21 | - 'USER_LANGUAGE', |
|
| 22 | - 'USER_TIMEZONE', |
|
| 23 | - 'BLOCK_SEPARATOR', |
|
| 24 | - 'USER_CSS_THEME', |
|
| 25 | - 'BLOCK_SEPARATOR', |
|
| 26 | - 'ENABLE_API_ACCESS', |
|
| 27 | - ], |
|
| 28 | - __('Feeds') => [ |
|
| 29 | - 'DEFAULT_UPDATE_INTERVAL', |
|
| 30 | - 'FRESH_ARTICLE_MAX_AGE', |
|
| 31 | - 'DEFAULT_SEARCH_LANGUAGE', |
|
| 32 | - 'BLOCK_SEPARATOR', |
|
| 33 | - 'ENABLE_FEED_CATS', |
|
| 34 | - 'BLOCK_SEPARATOR', |
|
| 35 | - 'CONFIRM_FEED_CATCHUP', |
|
| 36 | - 'ON_CATCHUP_SHOW_NEXT_FEED', |
|
| 37 | - 'BLOCK_SEPARATOR', |
|
| 38 | - 'HIDE_READ_FEEDS', |
|
| 39 | - 'HIDE_READ_SHOWS_SPECIAL', |
|
| 40 | - ], |
|
| 41 | - __('Articles') => [ |
|
| 42 | - 'PURGE_OLD_DAYS', |
|
| 43 | - 'PURGE_UNREAD_ARTICLES', |
|
| 44 | - 'BLOCK_SEPARATOR', |
|
| 45 | - 'COMBINED_DISPLAY_MODE', |
|
| 46 | - 'CDM_EXPANDED', |
|
| 47 | - 'BLOCK_SEPARATOR', |
|
| 48 | - 'CDM_AUTO_CATCHUP', |
|
| 49 | - 'VFEED_GROUP_BY_FEED', |
|
| 50 | - 'BLOCK_SEPARATOR', |
|
| 51 | - 'SHOW_CONTENT_PREVIEW', |
|
| 52 | - 'STRIP_IMAGES', |
|
| 53 | - ], |
|
| 54 | - __('Digest') => [ |
|
| 55 | - 'DIGEST_ENABLE', |
|
| 56 | - 'DIGEST_CATCHUP', |
|
| 57 | - 'DIGEST_PREFERRED_TIME', |
|
| 58 | - ], |
|
| 59 | - __('Advanced') => [ |
|
| 60 | - 'BLACKLISTED_TAGS', |
|
| 61 | - 'BLOCK_SEPARATOR', |
|
| 62 | - 'LONG_DATE_FORMAT', |
|
| 63 | - 'SHORT_DATE_FORMAT', |
|
| 64 | - 'BLOCK_SEPARATOR', |
|
| 65 | - 'SSL_CERT_SERIAL', |
|
| 66 | - ] |
|
| 67 | - ]; |
|
| 68 | - |
|
| 69 | - $this->pref_help = [ |
|
| 70 | - "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""), |
|
| 71 | - "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("Never apply these tags automatically (comma-separated list).")), |
|
| 72 | - "DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")), |
|
| 73 | - "CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")), |
|
| 74 | - "CDM_EXPANDED" => array(__("Always expand articles")), |
|
| 75 | - "COMBINED_DISPLAY_MODE" => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")), |
|
| 76 | - "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feeds as read")), |
|
| 77 | - "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once")), |
|
| 78 | - "DEFAULT_UPDATE_INTERVAL" => array(__("Default update interval")), |
|
| 79 | - "DIGEST_CATCHUP" => array(__("Mark sent articles as read")), |
|
| 80 | - "DIGEST_ENABLE" => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")), |
|
| 81 | - "DIGEST_PREFERRED_TIME" => array(__("Try to send around this time"), __("Time in UTC")), |
|
| 82 | - "ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")), |
|
| 83 | - "ENABLE_FEED_CATS" => array(__("Enable categories")), |
|
| 84 | - "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""), |
|
| 85 | - "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>" . __("hours") . "</strong>"), |
|
| 86 | - "HIDE_READ_FEEDS" => array(__("Hide read feeds")), |
|
| 87 | - "HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")), |
|
| 88 | - "LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")), |
|
| 89 | - "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("Automatically show next feed"), __("After marking one as read")), |
|
| 90 | - "PURGE_OLD_DAYS" => array(__("Purge articles older than"), __("<strong>days</strong> (0 disables)")), |
|
| 91 | - "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles")), |
|
| 92 | - "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)")), |
|
| 93 | - "SHORT_DATE_FORMAT" => array(__("Short date format")), |
|
| 94 | - "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines")), |
|
| 95 | - "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")), |
|
| 96 | - "SSL_CERT_SERIAL" => array(__("SSL client certificate")), |
|
| 97 | - "STRIP_IMAGES" => array(__("Do not embed media")), |
|
| 98 | - "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")), |
|
| 99 | - "USER_STYLESHEET" => array(__("Customize stylesheet")), |
|
| 100 | - "USER_TIMEZONE" => array(__("Time zone")), |
|
| 101 | - "VFEED_GROUP_BY_FEED" => array(__("Group by feed"), __("Group multiple-feed output by originating feed")), |
|
| 102 | - "USER_LANGUAGE" => array(__("Language")), |
|
| 103 | - "USER_CSS_THEME" => array(__("Theme")) |
|
| 104 | - ]; |
|
| 105 | - |
|
| 106 | - $this->pref_blacklist = ["ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES", |
|
| 107 | - "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT", |
|
| 108 | - "FEEDS_SORT_BY_UNREAD", "USER_STYLESHEET"]; |
|
| 109 | - |
|
| 110 | - /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ |
|
| 111 | - |
|
| 112 | - $this->profile_blacklist = ["ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", |
|
| 113 | - "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", |
|
| 114 | - "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", |
|
| 115 | - "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", |
|
| 116 | - "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"]; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function changepassword() { |
|
| 120 | - |
|
| 121 | - if (defined('_TTRSS_DEMO_INSTANCE')) { |
|
| 122 | - print "ERROR: ".format_error("Disabled in demo version."); |
|
| 123 | - return; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $old_pw = clean($_POST["old_password"]); |
|
| 127 | - $new_pw = clean($_POST["new_password"]); |
|
| 128 | - $con_pw = clean($_POST["confirm_password"]); |
|
| 129 | - |
|
| 130 | - if ($old_pw == $new_pw) { |
|
| 131 | - print "ERROR: ".format_error("New password must be different from the old one."); |
|
| 132 | - return; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if ($old_pw == "") { |
|
| 136 | - print "ERROR: ".format_error("Old password cannot be blank."); |
|
| 137 | - return; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ($new_pw == "") { |
|
| 141 | - print "ERROR: ".format_error("New password cannot be blank."); |
|
| 142 | - return; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if ($new_pw != $con_pw) { |
|
| 146 | - print "ERROR: ".format_error("Entered passwords do not match."); |
|
| 147 | - return; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 151 | - |
|
| 152 | - if (method_exists($authenticator, "change_password")) { |
|
| 153 | - print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw)); |
|
| 154 | - } else { |
|
| 155 | - print "ERROR: ".format_error("Function not supported by authentication module."); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - public function saveconfig() { |
|
| 160 | - $boolean_prefs = explode(",", clean($_POST["boolean_prefs"])); |
|
| 161 | - |
|
| 162 | - foreach ($boolean_prefs as $pref) { |
|
| 163 | - if (!isset($_POST[$pref])) $_POST[$pref] = 'false'; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $need_reload = false; |
|
| 167 | - |
|
| 168 | - foreach (array_keys($_POST) as $pref_name) { |
|
| 169 | - |
|
| 170 | - $value = $_POST[$pref_name]; |
|
| 171 | - |
|
| 172 | - switch ($pref_name) { |
|
| 173 | - case 'DIGEST_PREFERRED_TIME': |
|
| 174 | - if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
| 175 | - |
|
| 176 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 5 | + private $pref_help = []; |
|
| 6 | + private $pref_item_map = []; |
|
| 7 | + private $pref_blacklist = []; |
|
| 8 | + private $profile_blacklist = []; |
|
| 9 | + |
|
| 10 | + public function csrf_ignore($method) { |
|
| 11 | + $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles"); |
|
| 12 | + |
|
| 13 | + return array_search($method, $csrf_ignored) !== false; |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + public function __construct($args) { |
|
| 17 | + parent::__construct($args); |
|
| 18 | + |
|
| 19 | + $this->pref_item_map = [ |
|
| 20 | + __('General') => [ |
|
| 21 | + 'USER_LANGUAGE', |
|
| 22 | + 'USER_TIMEZONE', |
|
| 23 | + 'BLOCK_SEPARATOR', |
|
| 24 | + 'USER_CSS_THEME', |
|
| 25 | + 'BLOCK_SEPARATOR', |
|
| 26 | + 'ENABLE_API_ACCESS', |
|
| 27 | + ], |
|
| 28 | + __('Feeds') => [ |
|
| 29 | + 'DEFAULT_UPDATE_INTERVAL', |
|
| 30 | + 'FRESH_ARTICLE_MAX_AGE', |
|
| 31 | + 'DEFAULT_SEARCH_LANGUAGE', |
|
| 32 | + 'BLOCK_SEPARATOR', |
|
| 33 | + 'ENABLE_FEED_CATS', |
|
| 34 | + 'BLOCK_SEPARATOR', |
|
| 35 | + 'CONFIRM_FEED_CATCHUP', |
|
| 36 | + 'ON_CATCHUP_SHOW_NEXT_FEED', |
|
| 37 | + 'BLOCK_SEPARATOR', |
|
| 38 | + 'HIDE_READ_FEEDS', |
|
| 39 | + 'HIDE_READ_SHOWS_SPECIAL', |
|
| 40 | + ], |
|
| 41 | + __('Articles') => [ |
|
| 42 | + 'PURGE_OLD_DAYS', |
|
| 43 | + 'PURGE_UNREAD_ARTICLES', |
|
| 44 | + 'BLOCK_SEPARATOR', |
|
| 45 | + 'COMBINED_DISPLAY_MODE', |
|
| 46 | + 'CDM_EXPANDED', |
|
| 47 | + 'BLOCK_SEPARATOR', |
|
| 48 | + 'CDM_AUTO_CATCHUP', |
|
| 49 | + 'VFEED_GROUP_BY_FEED', |
|
| 50 | + 'BLOCK_SEPARATOR', |
|
| 51 | + 'SHOW_CONTENT_PREVIEW', |
|
| 52 | + 'STRIP_IMAGES', |
|
| 53 | + ], |
|
| 54 | + __('Digest') => [ |
|
| 55 | + 'DIGEST_ENABLE', |
|
| 56 | + 'DIGEST_CATCHUP', |
|
| 57 | + 'DIGEST_PREFERRED_TIME', |
|
| 58 | + ], |
|
| 59 | + __('Advanced') => [ |
|
| 60 | + 'BLACKLISTED_TAGS', |
|
| 61 | + 'BLOCK_SEPARATOR', |
|
| 62 | + 'LONG_DATE_FORMAT', |
|
| 63 | + 'SHORT_DATE_FORMAT', |
|
| 64 | + 'BLOCK_SEPARATOR', |
|
| 65 | + 'SSL_CERT_SERIAL', |
|
| 66 | + ] |
|
| 67 | + ]; |
|
| 68 | + |
|
| 69 | + $this->pref_help = [ |
|
| 70 | + "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""), |
|
| 71 | + "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("Never apply these tags automatically (comma-separated list).")), |
|
| 72 | + "DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")), |
|
| 73 | + "CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")), |
|
| 74 | + "CDM_EXPANDED" => array(__("Always expand articles")), |
|
| 75 | + "COMBINED_DISPLAY_MODE" => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")), |
|
| 76 | + "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feeds as read")), |
|
| 77 | + "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once")), |
|
| 78 | + "DEFAULT_UPDATE_INTERVAL" => array(__("Default update interval")), |
|
| 79 | + "DIGEST_CATCHUP" => array(__("Mark sent articles as read")), |
|
| 80 | + "DIGEST_ENABLE" => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")), |
|
| 81 | + "DIGEST_PREFERRED_TIME" => array(__("Try to send around this time"), __("Time in UTC")), |
|
| 82 | + "ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")), |
|
| 83 | + "ENABLE_FEED_CATS" => array(__("Enable categories")), |
|
| 84 | + "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""), |
|
| 85 | + "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>" . __("hours") . "</strong>"), |
|
| 86 | + "HIDE_READ_FEEDS" => array(__("Hide read feeds")), |
|
| 87 | + "HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")), |
|
| 88 | + "LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")), |
|
| 89 | + "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("Automatically show next feed"), __("After marking one as read")), |
|
| 90 | + "PURGE_OLD_DAYS" => array(__("Purge articles older than"), __("<strong>days</strong> (0 disables)")), |
|
| 91 | + "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles")), |
|
| 92 | + "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)")), |
|
| 93 | + "SHORT_DATE_FORMAT" => array(__("Short date format")), |
|
| 94 | + "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines")), |
|
| 95 | + "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")), |
|
| 96 | + "SSL_CERT_SERIAL" => array(__("SSL client certificate")), |
|
| 97 | + "STRIP_IMAGES" => array(__("Do not embed media")), |
|
| 98 | + "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")), |
|
| 99 | + "USER_STYLESHEET" => array(__("Customize stylesheet")), |
|
| 100 | + "USER_TIMEZONE" => array(__("Time zone")), |
|
| 101 | + "VFEED_GROUP_BY_FEED" => array(__("Group by feed"), __("Group multiple-feed output by originating feed")), |
|
| 102 | + "USER_LANGUAGE" => array(__("Language")), |
|
| 103 | + "USER_CSS_THEME" => array(__("Theme")) |
|
| 104 | + ]; |
|
| 105 | + |
|
| 106 | + $this->pref_blacklist = ["ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES", |
|
| 107 | + "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT", |
|
| 108 | + "FEEDS_SORT_BY_UNREAD", "USER_STYLESHEET"]; |
|
| 109 | + |
|
| 110 | + /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ |
|
| 111 | + |
|
| 112 | + $this->profile_blacklist = ["ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", |
|
| 113 | + "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", |
|
| 114 | + "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", |
|
| 115 | + "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", |
|
| 116 | + "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"]; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function changepassword() { |
|
| 120 | + |
|
| 121 | + if (defined('_TTRSS_DEMO_INSTANCE')) { |
|
| 122 | + print "ERROR: ".format_error("Disabled in demo version."); |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $old_pw = clean($_POST["old_password"]); |
|
| 127 | + $new_pw = clean($_POST["new_password"]); |
|
| 128 | + $con_pw = clean($_POST["confirm_password"]); |
|
| 129 | + |
|
| 130 | + if ($old_pw == $new_pw) { |
|
| 131 | + print "ERROR: ".format_error("New password must be different from the old one."); |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if ($old_pw == "") { |
|
| 136 | + print "ERROR: ".format_error("Old password cannot be blank."); |
|
| 137 | + return; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ($new_pw == "") { |
|
| 141 | + print "ERROR: ".format_error("New password cannot be blank."); |
|
| 142 | + return; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if ($new_pw != $con_pw) { |
|
| 146 | + print "ERROR: ".format_error("Entered passwords do not match."); |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 151 | + |
|
| 152 | + if (method_exists($authenticator, "change_password")) { |
|
| 153 | + print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw)); |
|
| 154 | + } else { |
|
| 155 | + print "ERROR: ".format_error("Function not supported by authentication module."); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + public function saveconfig() { |
|
| 160 | + $boolean_prefs = explode(",", clean($_POST["boolean_prefs"])); |
|
| 161 | + |
|
| 162 | + foreach ($boolean_prefs as $pref) { |
|
| 163 | + if (!isset($_POST[$pref])) $_POST[$pref] = 'false'; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $need_reload = false; |
|
| 167 | + |
|
| 168 | + foreach (array_keys($_POST) as $pref_name) { |
|
| 169 | + |
|
| 170 | + $value = $_POST[$pref_name]; |
|
| 171 | + |
|
| 172 | + switch ($pref_name) { |
|
| 173 | + case 'DIGEST_PREFERRED_TIME': |
|
| 174 | + if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
| 175 | + |
|
| 176 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 177 | 177 | last_digest_sent = NULL WHERE id = ?"); |
| 178 | - $sth->execute([$_SESSION['uid']]); |
|
| 178 | + $sth->execute([$_SESSION['uid']]); |
|
| 179 | 179 | |
| 180 | - } |
|
| 181 | - break; |
|
| 182 | - case 'USER_LANGUAGE': |
|
| 183 | - if (!$need_reload) $need_reload = $_SESSION["language"] != $value; |
|
| 184 | - break; |
|
| 185 | - |
|
| 186 | - case 'USER_CSS_THEME': |
|
| 187 | - if (!$need_reload) $need_reload = get_pref($pref_name) != $value; |
|
| 188 | - break; |
|
| 189 | - } |
|
| 180 | + } |
|
| 181 | + break; |
|
| 182 | + case 'USER_LANGUAGE': |
|
| 183 | + if (!$need_reload) $need_reload = $_SESSION["language"] != $value; |
|
| 184 | + break; |
|
| 190 | 185 | |
| 191 | - set_pref($pref_name, $value); |
|
| 192 | - } |
|
| 186 | + case 'USER_CSS_THEME': |
|
| 187 | + if (!$need_reload) $need_reload = get_pref($pref_name) != $value; |
|
| 188 | + break; |
|
| 189 | + } |
|
| 193 | 190 | |
| 194 | - if ($need_reload) { |
|
| 195 | - print "PREFS_NEED_RELOAD"; |
|
| 196 | - } else { |
|
| 197 | - print __("The configuration was saved."); |
|
| 198 | - } |
|
| 199 | - } |
|
| 191 | + set_pref($pref_name, $value); |
|
| 192 | + } |
|
| 200 | 193 | |
| 201 | - public function changeemail() { |
|
| 194 | + if ($need_reload) { |
|
| 195 | + print "PREFS_NEED_RELOAD"; |
|
| 196 | + } else { |
|
| 197 | + print __("The configuration was saved."); |
|
| 198 | + } |
|
| 199 | + } |
|
| 202 | 200 | |
| 203 | - $email = clean($_POST["email"]); |
|
| 204 | - $full_name = clean($_POST["full_name"]); |
|
| 205 | - $active_uid = $_SESSION["uid"]; |
|
| 201 | + public function changeemail() { |
|
| 206 | 202 | |
| 207 | - $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?"); |
|
| 208 | - $sth->execute([$active_uid]); |
|
| 203 | + $email = clean($_POST["email"]); |
|
| 204 | + $full_name = clean($_POST["full_name"]); |
|
| 205 | + $active_uid = $_SESSION["uid"]; |
|
| 209 | 206 | |
| 210 | - if ($row = $sth->fetch()) { |
|
| 211 | - $old_email = $row["email"]; |
|
| 207 | + $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?"); |
|
| 208 | + $sth->execute([$active_uid]); |
|
| 212 | 209 | |
| 213 | - if ($old_email != $email) { |
|
| 214 | - $mailer = new Mailer(); |
|
| 210 | + if ($row = $sth->fetch()) { |
|
| 211 | + $old_email = $row["email"]; |
|
| 215 | 212 | |
| 216 | - require_once "lib/MiniTemplator.class.php"; |
|
| 213 | + if ($old_email != $email) { |
|
| 214 | + $mailer = new Mailer(); |
|
| 217 | 215 | |
| 218 | - $tpl = new MiniTemplator; |
|
| 216 | + require_once "lib/MiniTemplator.class.php"; |
|
| 219 | 217 | |
| 220 | - $tpl->readTemplateFromFile("templates/mail_change_template.txt"); |
|
| 218 | + $tpl = new MiniTemplator; |
|
| 221 | 219 | |
| 222 | - $tpl->setVariable('LOGIN', $row["login"]); |
|
| 223 | - $tpl->setVariable('NEWMAIL', $email); |
|
| 224 | - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 220 | + $tpl->readTemplateFromFile("templates/mail_change_template.txt"); |
|
| 225 | 221 | |
| 226 | - $tpl->addBlock('message'); |
|
| 222 | + $tpl->setVariable('LOGIN', $row["login"]); |
|
| 223 | + $tpl->setVariable('NEWMAIL', $email); |
|
| 224 | + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 227 | 225 | |
| 228 | - $tpl->generateOutputToString($message); |
|
| 226 | + $tpl->addBlock('message'); |
|
| 229 | 227 | |
| 230 | - $mailer->mail(["to_name" => $row["login"], |
|
| 231 | - "to_address" => $row["email"], |
|
| 232 | - "subject" => "[tt-rss] Mail address change notification", |
|
| 233 | - "message" => $message]); |
|
| 228 | + $tpl->generateOutputToString($message); |
|
| 234 | 229 | |
| 235 | - } |
|
| 236 | - } |
|
| 230 | + $mailer->mail(["to_name" => $row["login"], |
|
| 231 | + "to_address" => $row["email"], |
|
| 232 | + "subject" => "[tt-rss] Mail address change notification", |
|
| 233 | + "message" => $message]); |
|
| 234 | + |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?, |
|
| 238 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?, |
|
| 239 | 239 | full_name = ? WHERE id = ?"); |
| 240 | - $sth->execute([$email, $full_name, $active_uid]); |
|
| 240 | + $sth->execute([$email, $full_name, $active_uid]); |
|
| 241 | 241 | |
| 242 | - print __("Your personal data has been saved."); |
|
| 242 | + print __("Your personal data has been saved."); |
|
| 243 | 243 | |
| 244 | - return; |
|
| 245 | - } |
|
| 244 | + return; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - public function resetconfig() { |
|
| 247 | + public function resetconfig() { |
|
| 248 | 248 | |
| 249 | - $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
|
| 249 | + $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
|
| 250 | 250 | |
| 251 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs |
|
| 251 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs |
|
| 252 | 252 | WHERE (profile = :profile OR (:profile IS NULL AND profile IS NULL)) |
| 253 | 253 | AND owner_uid = :uid"); |
| 254 | - $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); |
|
| 254 | + $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); |
|
| 255 | 255 | |
| 256 | - initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); |
|
| 256 | + initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); |
|
| 257 | 257 | |
| 258 | - echo __("Your preferences are now set to default values."); |
|
| 259 | - } |
|
| 258 | + echo __("Your preferences are now set to default values."); |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - public function index() { |
|
| 261 | + public function index() { |
|
| 262 | 262 | |
| 263 | - global $access_level_names; |
|
| 263 | + global $access_level_names; |
|
| 264 | 264 | |
| 265 | - $_SESSION["prefs_op_result"] = ""; |
|
| 265 | + $_SESSION["prefs_op_result"] = ""; |
|
| 266 | 266 | |
| 267 | - print "<div dojoType='dijit.layout.AccordionContainer' region='center'>"; |
|
| 268 | - print "<div dojoType='dijit.layout.AccordionPane' |
|
| 267 | + print "<div dojoType='dijit.layout.AccordionContainer' region='center'>"; |
|
| 268 | + print "<div dojoType='dijit.layout.AccordionPane' |
|
| 269 | 269 | title=\"<i class='material-icons'>person</i> ".__('Personal data / Authentication')."\">"; |
| 270 | 270 | |
| 271 | - print "<div dojoType='dijit.layout.TabContainer'>"; |
|
| 272 | - print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Personal data')."\">"; |
|
| 271 | + print "<div dojoType='dijit.layout.TabContainer'>"; |
|
| 272 | + print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Personal data')."\">"; |
|
| 273 | 273 | |
| 274 | - print "<form dojoType='dijit.form.Form' id='changeUserdataForm'>"; |
|
| 274 | + print "<form dojoType='dijit.form.Form' id='changeUserdataForm'>"; |
|
| 275 | 275 | |
| 276 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 276 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 277 | 277 | evt.preventDefault(); |
| 278 | 278 | if (this.validate()) { |
| 279 | 279 | Notify.progress('Saving data...', true); |
@@ -287,61 +287,61 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | </script>"; |
| 289 | 289 | |
| 290 | - $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled, |
|
| 290 | + $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled, |
|
| 291 | 291 | access_level FROM ttrss_users |
| 292 | 292 | WHERE id = ?"); |
| 293 | - $sth->execute([$_SESSION["uid"]]); |
|
| 294 | - $row = $sth->fetch(); |
|
| 295 | - |
|
| 296 | - $email = htmlspecialchars($row["email"]); |
|
| 297 | - $full_name = htmlspecialchars($row["full_name"]); |
|
| 298 | - $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); |
|
| 299 | - |
|
| 300 | - print "<fieldset>"; |
|
| 301 | - print "<label>".__('Full name:')."</label>"; |
|
| 302 | - print "<input dojoType='dijit.form.ValidationTextBox' name='full_name' required='1' value='$full_name'>"; |
|
| 303 | - print "</fieldset>"; |
|
| 304 | - |
|
| 305 | - print "<fieldset>"; |
|
| 306 | - print "<label>".__('E-mail:')."</label>"; |
|
| 307 | - print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>"; |
|
| 308 | - print "</fieldset>"; |
|
| 309 | - |
|
| 310 | - if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { |
|
| 311 | - |
|
| 312 | - $access_level = $row["access_level"]; |
|
| 313 | - print "<fieldset>"; |
|
| 314 | - print "<label>".__('Access level:')."</label>"; |
|
| 315 | - print $access_level_names[$access_level]; |
|
| 316 | - print "</fieldset>"; |
|
| 317 | - } |
|
| 293 | + $sth->execute([$_SESSION["uid"]]); |
|
| 294 | + $row = $sth->fetch(); |
|
| 318 | 295 | |
| 319 | - print_hidden("op", "pref-prefs"); |
|
| 320 | - print_hidden("method", "changeemail"); |
|
| 296 | + $email = htmlspecialchars($row["email"]); |
|
| 297 | + $full_name = htmlspecialchars($row["full_name"]); |
|
| 298 | + $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); |
|
| 321 | 299 | |
| 322 | - print "<hr/>"; |
|
| 300 | + print "<fieldset>"; |
|
| 301 | + print "<label>".__('Full name:')."</label>"; |
|
| 302 | + print "<input dojoType='dijit.form.ValidationTextBox' name='full_name' required='1' value='$full_name'>"; |
|
| 303 | + print "</fieldset>"; |
|
| 323 | 304 | |
| 324 | - print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 325 | - __("Save data")."</button>"; |
|
| 305 | + print "<fieldset>"; |
|
| 306 | + print "<label>".__('E-mail:')."</label>"; |
|
| 307 | + print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>"; |
|
| 308 | + print "</fieldset>"; |
|
| 326 | 309 | |
| 327 | - print "</form>"; |
|
| 310 | + if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { |
|
| 328 | 311 | |
| 329 | - print "</div>"; # content pane |
|
| 330 | - print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Password')."\">"; |
|
| 312 | + $access_level = $row["access_level"]; |
|
| 313 | + print "<fieldset>"; |
|
| 314 | + print "<label>".__('Access level:')."</label>"; |
|
| 315 | + print $access_level_names[$access_level]; |
|
| 316 | + print "</fieldset>"; |
|
| 317 | + } |
|
| 331 | 318 | |
| 332 | - if ($_SESSION["auth_module"]) { |
|
| 333 | - $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 334 | - } else { |
|
| 335 | - $authenticator = false; |
|
| 336 | - } |
|
| 319 | + print_hidden("op", "pref-prefs"); |
|
| 320 | + print_hidden("method", "changeemail"); |
|
| 337 | 321 | |
| 338 | - if ($authenticator && method_exists($authenticator, "change_password")) { |
|
| 322 | + print "<hr/>"; |
|
| 339 | 323 | |
| 340 | - print "<div style='display : none' id='pwd_change_infobox'></div>"; |
|
| 324 | + print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 325 | + __("Save data")."</button>"; |
|
| 341 | 326 | |
| 342 | - print "<form dojoType='dijit.form.Form'>"; |
|
| 327 | + print "</form>"; |
|
| 343 | 328 | |
| 344 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 329 | + print "</div>"; # content pane |
|
| 330 | + print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Password')."\">"; |
|
| 331 | + |
|
| 332 | + if ($_SESSION["auth_module"]) { |
|
| 333 | + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 334 | + } else { |
|
| 335 | + $authenticator = false; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + if ($authenticator && method_exists($authenticator, "change_password")) { |
|
| 339 | + |
|
| 340 | + print "<div style='display : none' id='pwd_change_infobox'></div>"; |
|
| 341 | + |
|
| 342 | + print "<form dojoType='dijit.form.Form'>"; |
|
| 343 | + |
|
| 344 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 345 | 345 | evt.preventDefault(); |
| 346 | 346 | if (this.validate()) { |
| 347 | 347 | Notify.progress('Changing password...', true); |
@@ -370,71 +370,71 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | </script>"; |
| 372 | 372 | |
| 373 | - if ($otp_enabled) { |
|
| 374 | - print_notice(__("Changing your current password will disable OTP.")); |
|
| 375 | - } |
|
| 373 | + if ($otp_enabled) { |
|
| 374 | + print_notice(__("Changing your current password will disable OTP.")); |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - print "<fieldset>"; |
|
| 378 | - print "<label>".__("Old password:")."</label>"; |
|
| 379 | - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='old_password'>"; |
|
| 380 | - print "</fieldset>"; |
|
| 377 | + print "<fieldset>"; |
|
| 378 | + print "<label>".__("Old password:")."</label>"; |
|
| 379 | + print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='old_password'>"; |
|
| 380 | + print "</fieldset>"; |
|
| 381 | 381 | |
| 382 | - print "<fieldset>"; |
|
| 383 | - print "<label>".__("New password:")."</label>"; |
|
| 384 | - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='new_password'>"; |
|
| 385 | - print "</fieldset>"; |
|
| 382 | + print "<fieldset>"; |
|
| 383 | + print "<label>".__("New password:")."</label>"; |
|
| 384 | + print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='new_password'>"; |
|
| 385 | + print "</fieldset>"; |
|
| 386 | 386 | |
| 387 | - print "<fieldset>"; |
|
| 388 | - print "<label>".__("Confirm password:")."</label>"; |
|
| 389 | - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='confirm_password'>"; |
|
| 390 | - print "</fieldset>"; |
|
| 387 | + print "<fieldset>"; |
|
| 388 | + print "<label>".__("Confirm password:")."</label>"; |
|
| 389 | + print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='confirm_password'>"; |
|
| 390 | + print "</fieldset>"; |
|
| 391 | 391 | |
| 392 | - print_hidden("op", "pref-prefs"); |
|
| 393 | - print_hidden("method", "changepassword"); |
|
| 392 | + print_hidden("op", "pref-prefs"); |
|
| 393 | + print_hidden("method", "changepassword"); |
|
| 394 | 394 | |
| 395 | - print "<hr/>"; |
|
| 395 | + print "<hr/>"; |
|
| 396 | 396 | |
| 397 | - print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 398 | - __("Change password")."</button>"; |
|
| 397 | + print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 398 | + __("Change password")."</button>"; |
|
| 399 | 399 | |
| 400 | - print "</form>"; |
|
| 400 | + print "</form>"; |
|
| 401 | 401 | |
| 402 | - print "</div>"; # content pane |
|
| 402 | + print "</div>"; # content pane |
|
| 403 | 403 | |
| 404 | - if ($_SESSION["auth_module"] == "auth_internal") { |
|
| 404 | + if ($_SESSION["auth_module"] == "auth_internal") { |
|
| 405 | 405 | |
| 406 | - print "<div dojoType='dijit.layout.ContentPane' title=\"" . __('App passwords') . "\">"; |
|
| 406 | + print "<div dojoType='dijit.layout.ContentPane' title=\"" . __('App passwords') . "\">"; |
|
| 407 | 407 | |
| 408 | - print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); |
|
| 408 | + print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); |
|
| 409 | 409 | |
| 410 | - print "<div id='app_passwords_holder'>"; |
|
| 411 | - $this->appPasswordList(); |
|
| 412 | - print "</div>"; |
|
| 410 | + print "<div id='app_passwords_holder'>"; |
|
| 411 | + $this->appPasswordList(); |
|
| 412 | + print "</div>"; |
|
| 413 | 413 | |
| 414 | - print "<hr>"; |
|
| 414 | + print "<hr>"; |
|
| 415 | 415 | |
| 416 | - print "<button style='float : left' class='alt-primary' dojoType='dijit.form.Button' |
|
| 416 | + print "<button style='float : left' class='alt-primary' dojoType='dijit.form.Button' |
|
| 417 | 417 | onclick=\"Helpers.AppPasswords.generate()\">" . |
| 418 | - __('Generate new password') . "</button> "; |
|
| 418 | + __('Generate new password') . "</button> "; |
|
| 419 | 419 | |
| 420 | - print "<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' |
|
| 420 | + print "<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' |
|
| 421 | 421 | onclick=\"Helpers.AppPasswords.removeSelected()\">" . |
| 422 | - __('Remove selected passwords') . "</button>"; |
|
| 422 | + __('Remove selected passwords') . "</button>"; |
|
| 423 | 423 | |
| 424 | - print "</div>"; # content pane |
|
| 425 | - } |
|
| 424 | + print "</div>"; # content pane |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - print "<div dojoType='dijit.layout.ContentPane' title=\"".__('One time passwords / Authenticator')."\">"; |
|
| 427 | + print "<div dojoType='dijit.layout.ContentPane' title=\"".__('One time passwords / Authenticator')."\">"; |
|
| 428 | 428 | |
| 429 | - if ($_SESSION["auth_module"] == "auth_internal") { |
|
| 429 | + if ($_SESSION["auth_module"] == "auth_internal") { |
|
| 430 | 430 | |
| 431 | - if ($otp_enabled) { |
|
| 431 | + if ($otp_enabled) { |
|
| 432 | 432 | |
| 433 | - print_warning("One time passwords are currently enabled. Enter your current password below to disable."); |
|
| 433 | + print_warning("One time passwords are currently enabled. Enter your current password below to disable."); |
|
| 434 | 434 | |
| 435 | - print "<form dojoType='dijit.form.Form'>"; |
|
| 435 | + print "<form dojoType='dijit.form.Form'>"; |
|
| 436 | 436 | |
| 437 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 437 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 438 | 438 | evt.preventDefault(); |
| 439 | 439 | if (this.validate()) { |
| 440 | 440 | Notify.progress('Disabling OTP', true); |
@@ -453,49 +453,49 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | </script>"; |
| 455 | 455 | |
| 456 | - print "<fieldset>"; |
|
| 457 | - print "<label>".__("Your password:")."</label>"; |
|
| 458 | - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='password'>"; |
|
| 459 | - print "</fieldset>"; |
|
| 456 | + print "<fieldset>"; |
|
| 457 | + print "<label>".__("Your password:")."</label>"; |
|
| 458 | + print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='password'>"; |
|
| 459 | + print "</fieldset>"; |
|
| 460 | 460 | |
| 461 | - print_hidden("op", "pref-prefs"); |
|
| 462 | - print_hidden("method", "otpdisable"); |
|
| 461 | + print_hidden("op", "pref-prefs"); |
|
| 462 | + print_hidden("method", "otpdisable"); |
|
| 463 | 463 | |
| 464 | - print "<hr/>"; |
|
| 464 | + print "<hr/>"; |
|
| 465 | 465 | |
| 466 | - print "<button dojoType='dijit.form.Button' type='submit'>". |
|
| 467 | - __("Disable OTP")."</button>"; |
|
| 466 | + print "<button dojoType='dijit.form.Button' type='submit'>". |
|
| 467 | + __("Disable OTP")."</button>"; |
|
| 468 | 468 | |
| 469 | - print "</form>"; |
|
| 469 | + print "</form>"; |
|
| 470 | 470 | |
| 471 | - } else { |
|
| 471 | + } else { |
|
| 472 | 472 | |
| 473 | - print_warning("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP."); |
|
| 474 | - print_notice("You will need to generate app passwords for the API clients if you enable OTP."); |
|
| 473 | + print_warning("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP."); |
|
| 474 | + print_notice("You will need to generate app passwords for the API clients if you enable OTP."); |
|
| 475 | 475 | |
| 476 | - if (function_exists("imagecreatefromstring")) { |
|
| 477 | - print "<h3>" . __("Scan the following code by the Authenticator application or copy the key manually") . "</h3>"; |
|
| 476 | + if (function_exists("imagecreatefromstring")) { |
|
| 477 | + print "<h3>" . __("Scan the following code by the Authenticator application or copy the key manually") . "</h3>"; |
|
| 478 | 478 | |
| 479 | - $csrf_token = $_SESSION["csrf_token"]; |
|
| 480 | - print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>"; |
|
| 481 | - } else { |
|
| 482 | - print_error("PHP GD functions are required to generate QR codes."); |
|
| 483 | - print "<h3>" . __("Use the following OTP key with a compatible Authenticator application") . "</h3>"; |
|
| 484 | - } |
|
| 479 | + $csrf_token = $_SESSION["csrf_token"]; |
|
| 480 | + print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>"; |
|
| 481 | + } else { |
|
| 482 | + print_error("PHP GD functions are required to generate QR codes."); |
|
| 483 | + print "<h3>" . __("Use the following OTP key with a compatible Authenticator application") . "</h3>"; |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - print "<form dojoType='dijit.form.Form' id='changeOtpForm'>"; |
|
| 486 | + print "<form dojoType='dijit.form.Form' id='changeOtpForm'>"; |
|
| 487 | 487 | |
| 488 | - $otp_secret = $this->otpsecret(); |
|
| 488 | + $otp_secret = $this->otpsecret(); |
|
| 489 | 489 | |
| 490 | - print "<fieldset>"; |
|
| 491 | - print "<label>".__("OTP Key:")."</label>"; |
|
| 492 | - print "<input dojoType='dijit.form.ValidationTextBox' disabled='disabled' value='$otp_secret' size='32'>"; |
|
| 493 | - print "</fieldset>"; |
|
| 490 | + print "<fieldset>"; |
|
| 491 | + print "<label>".__("OTP Key:")."</label>"; |
|
| 492 | + print "<input dojoType='dijit.form.ValidationTextBox' disabled='disabled' value='$otp_secret' size='32'>"; |
|
| 493 | + print "</fieldset>"; |
|
| 494 | 494 | |
| 495 | - print_hidden("op", "pref-prefs"); |
|
| 496 | - print_hidden("method", "otpenable"); |
|
| 495 | + print_hidden("op", "pref-prefs"); |
|
| 496 | + print_hidden("method", "otpenable"); |
|
| 497 | 497 | |
| 498 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 498 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 499 | 499 | evt.preventDefault(); |
| 500 | 500 | if (this.validate()) { |
| 501 | 501 | Notify.progress('Saving data...', true); |
@@ -514,43 +514,43 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | </script>"; |
| 516 | 516 | |
| 517 | - print "<fieldset>"; |
|
| 518 | - print "<label>".__("Your password:")."</label>"; |
|
| 519 | - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' |
|
| 517 | + print "<fieldset>"; |
|
| 518 | + print "<label>".__("Your password:")."</label>"; |
|
| 519 | + print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' |
|
| 520 | 520 | name='password'>"; |
| 521 | - print "</fieldset>"; |
|
| 521 | + print "</fieldset>"; |
|
| 522 | 522 | |
| 523 | - print "<fieldset>"; |
|
| 524 | - print "<label>".__("One time password:")."</label>"; |
|
| 525 | - print "<input dojoType='dijit.form.ValidationTextBox' autocomplete='off' |
|
| 523 | + print "<fieldset>"; |
|
| 524 | + print "<label>".__("One time password:")."</label>"; |
|
| 525 | + print "<input dojoType='dijit.form.ValidationTextBox' autocomplete='off' |
|
| 526 | 526 | required='1' name='otp'>"; |
| 527 | - print "</fieldset>"; |
|
| 527 | + print "</fieldset>"; |
|
| 528 | 528 | |
| 529 | - print "<hr/>"; |
|
| 530 | - print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 531 | - __("Enable OTP")."</button>"; |
|
| 529 | + print "<hr/>"; |
|
| 530 | + print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>". |
|
| 531 | + __("Enable OTP")."</button>"; |
|
| 532 | 532 | |
| 533 | - print "</form>"; |
|
| 533 | + print "</form>"; |
|
| 534 | 534 | |
| 535 | - } |
|
| 536 | - } |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | 537 | |
| 538 | - print "</div>"; # content pane |
|
| 539 | - print "</div>"; # tab container |
|
| 538 | + print "</div>"; # content pane |
|
| 539 | + print "</div>"; # tab container |
|
| 540 | 540 | |
| 541 | - } |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 544 | - "hook_prefs_tab_section", "prefPrefsAuth"); |
|
| 543 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 544 | + "hook_prefs_tab_section", "prefPrefsAuth"); |
|
| 545 | 545 | |
| 546 | - print "</div>"; #pane |
|
| 546 | + print "</div>"; #pane |
|
| 547 | 547 | |
| 548 | - print "<div dojoType='dijit.layout.AccordionPane' selected='true' |
|
| 548 | + print "<div dojoType='dijit.layout.AccordionPane' selected='true' |
|
| 549 | 549 | title=\"<i class='material-icons'>settings</i> ".__('Preferences')."\">"; |
| 550 | 550 | |
| 551 | - print "<form dojoType='dijit.form.Form' id='changeSettingsForm'>"; |
|
| 551 | + print "<form dojoType='dijit.form.Form' id='changeSettingsForm'>"; |
|
| 552 | 552 | |
| 553 | - print "<script type='dojo/method' event='onSubmit' args='evt, quit'> |
|
| 553 | + print "<script type='dojo/method' event='onSubmit' args='evt, quit'> |
|
| 554 | 554 | if (evt) evt.preventDefault(); |
| 555 | 555 | if (this.validate()) { |
| 556 | 556 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -572,23 +572,23 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | </script>"; |
| 574 | 574 | |
| 575 | - print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; |
|
| 575 | + print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; |
|
| 576 | 576 | |
| 577 | - print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; |
|
| 577 | + print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; |
|
| 578 | 578 | |
| 579 | - $profile = $_SESSION["profile"]; |
|
| 579 | + $profile = $_SESSION["profile"]; |
|
| 580 | 580 | |
| 581 | - if ($profile) { |
|
| 582 | - print_notice(__("Some preferences are only available in default profile.")); |
|
| 581 | + if ($profile) { |
|
| 582 | + print_notice(__("Some preferences are only available in default profile.")); |
|
| 583 | 583 | |
| 584 | - initialize_user_prefs($_SESSION["uid"], $profile); |
|
| 585 | - } else { |
|
| 586 | - initialize_user_prefs($_SESSION["uid"]); |
|
| 587 | - } |
|
| 584 | + initialize_user_prefs($_SESSION["uid"], $profile); |
|
| 585 | + } else { |
|
| 586 | + initialize_user_prefs($_SESSION["uid"]); |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - $prefs_available = []; |
|
| 589 | + $prefs_available = []; |
|
| 590 | 590 | |
| 591 | - $sth = $this->pdo->prepare("SELECT DISTINCT |
|
| 591 | + $sth = $this->pdo->prepare("SELECT DISTINCT |
|
| 592 | 592 | ttrss_user_prefs.pref_name,value,type_name, |
| 593 | 593 | ttrss_prefs_sections.order_id, |
| 594 | 594 | def_value,section_id |
@@ -599,230 +599,230 @@ discard block |
||
| 599 | 599 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
| 600 | 600 | owner_uid = :uid |
| 601 | 601 | ORDER BY ttrss_prefs_sections.order_id,pref_name"); |
| 602 | - $sth->execute([":uid" => $_SESSION['uid'], ":profile" => $profile]); |
|
| 602 | + $sth->execute([":uid" => $_SESSION['uid'], ":profile" => $profile]); |
|
| 603 | 603 | |
| 604 | - $listed_boolean_prefs = []; |
|
| 604 | + $listed_boolean_prefs = []; |
|
| 605 | 605 | |
| 606 | - while ($line = $sth->fetch()) { |
|
| 606 | + while ($line = $sth->fetch()) { |
|
| 607 | 607 | |
| 608 | - if (in_array($line["pref_name"], $this->pref_blacklist)) { |
|
| 609 | - continue; |
|
| 610 | - } |
|
| 608 | + if (in_array($line["pref_name"], $this->pref_blacklist)) { |
|
| 609 | + continue; |
|
| 610 | + } |
|
| 611 | 611 | |
| 612 | - if ($profile && in_array($line["pref_name"], $this->profile_blacklist)) { |
|
| 613 | - continue; |
|
| 614 | - } |
|
| 612 | + if ($profile && in_array($line["pref_name"], $this->profile_blacklist)) { |
|
| 613 | + continue; |
|
| 614 | + } |
|
| 615 | 615 | |
| 616 | - $pref_name = $line["pref_name"]; |
|
| 617 | - $short_desc = $this->getShortDesc($pref_name); |
|
| 616 | + $pref_name = $line["pref_name"]; |
|
| 617 | + $short_desc = $this->getShortDesc($pref_name); |
|
| 618 | 618 | |
| 619 | - if (!$short_desc) |
|
| 620 | - continue; |
|
| 619 | + if (!$short_desc) |
|
| 620 | + continue; |
|
| 621 | 621 | |
| 622 | - $prefs_available[$pref_name] = [ |
|
| 623 | - 'type_name' => $line["type_name"], |
|
| 624 | - 'value' => $line['value'], |
|
| 625 | - 'help_text' => $this->getHelpText($pref_name), |
|
| 626 | - 'short_desc' => $short_desc |
|
| 627 | - ]; |
|
| 628 | - } |
|
| 622 | + $prefs_available[$pref_name] = [ |
|
| 623 | + 'type_name' => $line["type_name"], |
|
| 624 | + 'value' => $line['value'], |
|
| 625 | + 'help_text' => $this->getHelpText($pref_name), |
|
| 626 | + 'short_desc' => $short_desc |
|
| 627 | + ]; |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - foreach (array_keys($this->pref_item_map) as $section) { |
|
| 630 | + foreach (array_keys($this->pref_item_map) as $section) { |
|
| 631 | 631 | |
| 632 | - print "<h2>$section</h2>"; |
|
| 632 | + print "<h2>$section</h2>"; |
|
| 633 | 633 | |
| 634 | - foreach ($this->pref_item_map[$section] as $pref_name) { |
|
| 634 | + foreach ($this->pref_item_map[$section] as $pref_name) { |
|
| 635 | 635 | |
| 636 | - if ($pref_name == 'BLOCK_SEPARATOR' && !$profile) { |
|
| 637 | - print "<hr/>"; |
|
| 638 | - continue; |
|
| 639 | - } |
|
| 636 | + if ($pref_name == 'BLOCK_SEPARATOR' && !$profile) { |
|
| 637 | + print "<hr/>"; |
|
| 638 | + continue; |
|
| 639 | + } |
|
| 640 | 640 | |
| 641 | - if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && DB_TYPE != "pgsql") { |
|
| 642 | - continue; |
|
| 643 | - } |
|
| 641 | + if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && DB_TYPE != "pgsql") { |
|
| 642 | + continue; |
|
| 643 | + } |
|
| 644 | 644 | |
| 645 | - if ($item = $prefs_available[$pref_name]) { |
|
| 645 | + if ($item = $prefs_available[$pref_name]) { |
|
| 646 | 646 | |
| 647 | - print "<fieldset class='prefs'>"; |
|
| 647 | + print "<fieldset class='prefs'>"; |
|
| 648 | 648 | |
| 649 | - print "<label for='CB_$pref_name'>"; |
|
| 650 | - print $item['short_desc'] . ":"; |
|
| 651 | - print "</label>"; |
|
| 649 | + print "<label for='CB_$pref_name'>"; |
|
| 650 | + print $item['short_desc'] . ":"; |
|
| 651 | + print "</label>"; |
|
| 652 | 652 | |
| 653 | - $value = $item['value']; |
|
| 654 | - $type_name = $item['type_name']; |
|
| 653 | + $value = $item['value']; |
|
| 654 | + $type_name = $item['type_name']; |
|
| 655 | 655 | |
| 656 | - if ($pref_name == "USER_LANGUAGE") { |
|
| 657 | - print_select_hash($pref_name, $value, get_translations(), |
|
| 658 | - "style='width : 220px; margin : 0px' dojoType='fox.form.Select'"); |
|
| 656 | + if ($pref_name == "USER_LANGUAGE") { |
|
| 657 | + print_select_hash($pref_name, $value, get_translations(), |
|
| 658 | + "style='width : 220px; margin : 0px' dojoType='fox.form.Select'"); |
|
| 659 | 659 | |
| 660 | - } else if ($pref_name == "USER_TIMEZONE") { |
|
| 660 | + } else if ($pref_name == "USER_TIMEZONE") { |
|
| 661 | 661 | |
| 662 | - $timezones = explode("\n", file_get_contents("lib/timezones.txt")); |
|
| 662 | + $timezones = explode("\n", file_get_contents("lib/timezones.txt")); |
|
| 663 | 663 | |
| 664 | - print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); |
|
| 665 | - } else if ($pref_name == "USER_CSS_THEME") { |
|
| 664 | + print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); |
|
| 665 | + } else if ($pref_name == "USER_CSS_THEME") { |
|
| 666 | 666 | |
| 667 | - $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css")); |
|
| 668 | - $themes = array_map("basename", $themes); |
|
| 669 | - $themes = array_filter($themes, "theme_exists"); |
|
| 670 | - asort($themes); |
|
| 667 | + $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css")); |
|
| 668 | + $themes = array_map("basename", $themes); |
|
| 669 | + $themes = array_filter($themes, "theme_exists"); |
|
| 670 | + asort($themes); |
|
| 671 | 671 | |
| 672 | - if (!theme_exists($value)) $value = "default.php"; |
|
| 672 | + if (!theme_exists($value)) $value = "default.php"; |
|
| 673 | 673 | |
| 674 | - print "<select name='$pref_name' id='$pref_name' dojoType='fox.form.Select'>"; |
|
| 674 | + print "<select name='$pref_name' id='$pref_name' dojoType='fox.form.Select'>"; |
|
| 675 | 675 | |
| 676 | - $issel = $value == "default.php" ? "selected='selected'" : ""; |
|
| 677 | - print "<option $issel value='default.php'>".__("default")."</option>"; |
|
| 676 | + $issel = $value == "default.php" ? "selected='selected'" : ""; |
|
| 677 | + print "<option $issel value='default.php'>".__("default")."</option>"; |
|
| 678 | 678 | |
| 679 | - foreach ($themes as $theme) { |
|
| 680 | - $issel = $value == $theme ? "selected='selected'" : ""; |
|
| 681 | - print "<option $issel value='$theme'>$theme</option>"; |
|
| 682 | - } |
|
| 679 | + foreach ($themes as $theme) { |
|
| 680 | + $issel = $value == $theme ? "selected='selected'" : ""; |
|
| 681 | + print "<option $issel value='$theme'>$theme</option>"; |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | - print "</select>"; |
|
| 684 | + print "</select>"; |
|
| 685 | 685 | |
| 686 | - print " <button dojoType=\"dijit.form.Button\" class='alt-info' |
|
| 686 | + print " <button dojoType=\"dijit.form.Button\" class='alt-info' |
|
| 687 | 687 | onclick=\"Helpers.customizeCSS()\">" . __('Customize') . "</button>"; |
| 688 | 688 | |
| 689 | - print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'> |
|
| 689 | + print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'> |
|
| 690 | 690 | <i class='material-icons'>open_in_new</i> ".__("More themes...")."</button>"; |
| 691 | 691 | |
| 692 | - } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { |
|
| 692 | + } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { |
|
| 693 | 693 | |
| 694 | - global $update_intervals_nodefault; |
|
| 694 | + global $update_intervals_nodefault; |
|
| 695 | 695 | |
| 696 | - print_select_hash($pref_name, $value, $update_intervals_nodefault, |
|
| 697 | - 'dojoType="fox.form.Select"'); |
|
| 698 | - } else if ($pref_name == "DEFAULT_SEARCH_LANGUAGE") { |
|
| 696 | + print_select_hash($pref_name, $value, $update_intervals_nodefault, |
|
| 697 | + 'dojoType="fox.form.Select"'); |
|
| 698 | + } else if ($pref_name == "DEFAULT_SEARCH_LANGUAGE") { |
|
| 699 | 699 | |
| 700 | - print_select($pref_name, $value, Pref_Feeds::get_ts_languages(), |
|
| 701 | - 'dojoType="fox.form.Select"'); |
|
| 700 | + print_select($pref_name, $value, Pref_Feeds::get_ts_languages(), |
|
| 701 | + 'dojoType="fox.form.Select"'); |
|
| 702 | 702 | |
| 703 | - } else if ($type_name == "bool") { |
|
| 703 | + } else if ($type_name == "bool") { |
|
| 704 | 704 | |
| 705 | - array_push($listed_boolean_prefs, $pref_name); |
|
| 705 | + array_push($listed_boolean_prefs, $pref_name); |
|
| 706 | 706 | |
| 707 | - $checked = ($value == "true") ? "checked=\"checked\"" : ""; |
|
| 707 | + $checked = ($value == "true") ? "checked=\"checked\"" : ""; |
|
| 708 | 708 | |
| 709 | - if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { |
|
| 710 | - $disabled = "disabled=\"1\""; |
|
| 711 | - $checked = "checked=\"checked\""; |
|
| 712 | - } else { |
|
| 713 | - $disabled = ""; |
|
| 714 | - } |
|
| 709 | + if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { |
|
| 710 | + $disabled = "disabled=\"1\""; |
|
| 711 | + $checked = "checked=\"checked\""; |
|
| 712 | + } else { |
|
| 713 | + $disabled = ""; |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | - print "<input type='checkbox' name='$pref_name' $checked $disabled |
|
| 716 | + print "<input type='checkbox' name='$pref_name' $checked $disabled |
|
| 717 | 717 | dojoType='dijit.form.CheckBox' id='CB_$pref_name' value='1'>"; |
| 718 | 718 | |
| 719 | - } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', |
|
| 720 | - 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { |
|
| 719 | + } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', |
|
| 720 | + 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { |
|
| 721 | 721 | |
| 722 | - $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; |
|
| 722 | + $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; |
|
| 723 | 723 | |
| 724 | - if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { |
|
| 725 | - $disabled = "disabled='1'"; |
|
| 726 | - $value = FORCE_ARTICLE_PURGE; |
|
| 727 | - } else { |
|
| 728 | - $disabled = ""; |
|
| 729 | - } |
|
| 724 | + if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { |
|
| 725 | + $disabled = "disabled='1'"; |
|
| 726 | + $value = FORCE_ARTICLE_PURGE; |
|
| 727 | + } else { |
|
| 728 | + $disabled = ""; |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | - if ($type_name == 'integer') |
|
| 732 | - print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
| 731 | + if ($type_name == 'integer') |
|
| 732 | + print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
| 733 | 733 | required='1' $disabled |
| 734 | 734 | name=\"$pref_name\" value=\"$value\">"; |
| 735 | - else |
|
| 736 | - print "<input dojoType=\"dijit.form.TextBox\" |
|
| 735 | + else |
|
| 736 | + print "<input dojoType=\"dijit.form.TextBox\" |
|
| 737 | 737 | required='1' $regexp $disabled |
| 738 | 738 | name=\"$pref_name\" value=\"$value\">"; |
| 739 | 739 | |
| 740 | - } else if ($pref_name == "SSL_CERT_SERIAL") { |
|
| 740 | + } else if ($pref_name == "SSL_CERT_SERIAL") { |
|
| 741 | 741 | |
| 742 | - print "<input dojoType='dijit.form.ValidationTextBox' |
|
| 742 | + print "<input dojoType='dijit.form.ValidationTextBox' |
|
| 743 | 743 | id='SSL_CERT_SERIAL' readonly='1' |
| 744 | 744 | name=\"$pref_name\" value=\"$value\">"; |
| 745 | 745 | |
| 746 | - $cert_serial = htmlspecialchars(get_ssl_certificate_id()); |
|
| 747 | - $has_serial = ($cert_serial) ? "false" : "true"; |
|
| 746 | + $cert_serial = htmlspecialchars(get_ssl_certificate_id()); |
|
| 747 | + $has_serial = ($cert_serial) ? "false" : "true"; |
|
| 748 | 748 | |
| 749 | - print "<button dojoType='dijit.form.Button' disabled='$has_serial' |
|
| 749 | + print "<button dojoType='dijit.form.Button' disabled='$has_serial' |
|
| 750 | 750 | onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '$cert_serial')\">" . |
| 751 | - __('Register') . "</button>"; |
|
| 751 | + __('Register') . "</button>"; |
|
| 752 | 752 | |
| 753 | - print "<button dojoType='dijit.form.Button' class='alt-danger' |
|
| 753 | + print "<button dojoType='dijit.form.Button' class='alt-danger' |
|
| 754 | 754 | onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '')\">" . |
| 755 | - __('Clear') . "</button>"; |
|
| 755 | + __('Clear') . "</button>"; |
|
| 756 | 756 | |
| 757 | - print "<button dojoType='dijit.form.Button' class='alt-info' |
|
| 757 | + print "<button dojoType='dijit.form.Button' class='alt-info' |
|
| 758 | 758 | onclick='window.open(\"https://tt-rss.org/wiki/SSL%20Certificate%20Authentication\")'> |
| 759 | 759 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
| 760 | 760 | |
| 761 | - } else if ($pref_name == 'DIGEST_PREFERRED_TIME') { |
|
| 762 | - print "<input dojoType=\"dijit.form.ValidationTextBox\" |
|
| 761 | + } else if ($pref_name == 'DIGEST_PREFERRED_TIME') { |
|
| 762 | + print "<input dojoType=\"dijit.form.ValidationTextBox\" |
|
| 763 | 763 | id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\" |
| 764 | 764 | name=\"$pref_name\" value=\"$value\">"; |
| 765 | 765 | |
| 766 | - $item['help_text'] .= ". " . T_sprintf("Current server time: %s", date("H:i")); |
|
| 767 | - } else { |
|
| 768 | - $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; |
|
| 766 | + $item['help_text'] .= ". " . T_sprintf("Current server time: %s", date("H:i")); |
|
| 767 | + } else { |
|
| 768 | + $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; |
|
| 769 | 769 | |
| 770 | - print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">"; |
|
| 771 | - } |
|
| 770 | + print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">"; |
|
| 771 | + } |
|
| 772 | 772 | |
| 773 | - if ($item['help_text']) |
|
| 774 | - print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>"; |
|
| 773 | + if ($item['help_text']) |
|
| 774 | + print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>"; |
|
| 775 | 775 | |
| 776 | - print "</fieldset>"; |
|
| 777 | - } |
|
| 778 | - } |
|
| 779 | - } |
|
| 776 | + print "</fieldset>"; |
|
| 777 | + } |
|
| 778 | + } |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs)); |
|
| 781 | + $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs)); |
|
| 782 | 782 | |
| 783 | - print_hidden("boolean_prefs", "$listed_boolean_prefs"); |
|
| 783 | + print_hidden("boolean_prefs", "$listed_boolean_prefs"); |
|
| 784 | 784 | |
| 785 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 786 | - "hook_prefs_tab_section", "prefPrefsPrefsInside"); |
|
| 785 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 786 | + "hook_prefs_tab_section", "prefPrefsPrefsInside"); |
|
| 787 | 787 | |
| 788 | - print '</div>'; # inside pane |
|
| 789 | - print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; |
|
| 788 | + print '</div>'; # inside pane |
|
| 789 | + print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; |
|
| 790 | 790 | |
| 791 | - print_hidden("op", "pref-prefs"); |
|
| 792 | - print_hidden("method", "saveconfig"); |
|
| 791 | + print_hidden("op", "pref-prefs"); |
|
| 792 | + print_hidden("method", "saveconfig"); |
|
| 793 | 793 | |
| 794 | - print "<div dojoType=\"fox.form.ComboButton\" type=\"submit\" class=\"alt-primary\"> |
|
| 794 | + print "<div dojoType=\"fox.form.ComboButton\" type=\"submit\" class=\"alt-primary\"> |
|
| 795 | 795 | <span>".__('Save configuration')."</span> |
| 796 | 796 | <div dojoType=\"dijit.DropDownMenu\"> |
| 797 | 797 | <div dojoType=\"dijit.MenuItem\" |
| 798 | 798 | onclick=\"dijit.byId('changeSettingsForm').onSubmit(null, true)\">". |
| 799 | - __("Save and exit preferences")."</div> |
|
| 799 | + __("Save and exit preferences")."</div> |
|
| 800 | 800 | </div> |
| 801 | 801 | </div>"; |
| 802 | 802 | |
| 803 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.editProfiles()\">". |
|
| 804 | - __('Manage profiles')."</button> "; |
|
| 803 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.editProfiles()\">". |
|
| 804 | + __('Manage profiles')."</button> "; |
|
| 805 | 805 | |
| 806 | - print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.confirmReset()\">". |
|
| 807 | - __('Reset to defaults')."</button>"; |
|
| 806 | + print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.confirmReset()\">". |
|
| 807 | + __('Reset to defaults')."</button>"; |
|
| 808 | 808 | |
| 809 | - print " "; |
|
| 809 | + print " "; |
|
| 810 | 810 | |
| 811 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 812 | - "hook_prefs_tab_section", "prefPrefsPrefsOutside"); |
|
| 811 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, |
|
| 812 | + "hook_prefs_tab_section", "prefPrefsPrefsOutside"); |
|
| 813 | 813 | |
| 814 | - print "</form>"; |
|
| 815 | - print '</div>'; # inner pane |
|
| 816 | - print '</div>'; # border container |
|
| 814 | + print "</form>"; |
|
| 815 | + print '</div>'; # inner pane |
|
| 816 | + print '</div>'; # border container |
|
| 817 | 817 | |
| 818 | - print "</div>"; #pane |
|
| 818 | + print "</div>"; #pane |
|
| 819 | 819 | |
| 820 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 820 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 821 | 821 | title=\"<i class='material-icons'>extension</i> ".__('Plugins')."\">"; |
| 822 | 822 | |
| 823 | - print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">"; |
|
| 823 | + print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">"; |
|
| 824 | 824 | |
| 825 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 825 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 826 | 826 | evt.preventDefault(); |
| 827 | 827 | if (this.validate()) { |
| 828 | 828 | Notify.progress('Saving data...', true); |
@@ -839,383 +839,383 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | </script>"; |
| 841 | 841 | |
| 842 | - print_hidden("op", "pref-prefs"); |
|
| 843 | - print_hidden("method", "setplugins"); |
|
| 842 | + print_hidden("op", "pref-prefs"); |
|
| 843 | + print_hidden("method", "setplugins"); |
|
| 844 | 844 | |
| 845 | - print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; |
|
| 846 | - print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; |
|
| 845 | + print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; |
|
| 846 | + print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; |
|
| 847 | 847 | |
| 848 | - if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) { |
|
| 849 | - print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); |
|
| 850 | - } |
|
| 848 | + if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) { |
|
| 849 | + print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - $feed_handler_whitelist = [ "Af_Comics" ]; |
|
| 852 | + $feed_handler_whitelist = [ "Af_Comics" ]; |
|
| 853 | 853 | |
| 854 | - $feed_handlers = array_merge( |
|
| 855 | - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), |
|
| 856 | - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), |
|
| 857 | - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); |
|
| 854 | + $feed_handlers = array_merge( |
|
| 855 | + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), |
|
| 856 | + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), |
|
| 857 | + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); |
|
| 858 | 858 | |
| 859 | - $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { |
|
| 860 | - return in_array(get_class($plugin), $feed_handler_whitelist) === FALSE; }); |
|
| 859 | + $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { |
|
| 860 | + return in_array(get_class($plugin), $feed_handler_whitelist) === FALSE; }); |
|
| 861 | 861 | |
| 862 | - if (count($feed_handlers) > 0) { |
|
| 863 | - print_error( |
|
| 864 | - T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>" , |
|
| 865 | - implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) |
|
| 866 | - ) . " (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)" |
|
| 867 | - ); |
|
| 868 | - } |
|
| 862 | + if (count($feed_handlers) > 0) { |
|
| 863 | + print_error( |
|
| 864 | + T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>" , |
|
| 865 | + implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) |
|
| 866 | + ) . " (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)" |
|
| 867 | + ); |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | - print "<h2>".__("System plugins")."</h2>"; |
|
| 871 | - print_notice("System plugins are enabled in <strong>config.php</strong> for all users."); |
|
| 870 | + print "<h2>".__("System plugins")."</h2>"; |
|
| 871 | + print_notice("System plugins are enabled in <strong>config.php</strong> for all users."); |
|
| 872 | 872 | |
| 873 | - $system_enabled = array_map("trim", explode(",", PLUGINS)); |
|
| 874 | - $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); |
|
| 873 | + $system_enabled = array_map("trim", explode(",", PLUGINS)); |
|
| 874 | + $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); |
|
| 875 | 875 | |
| 876 | - $tmppluginhost = new PluginHost(); |
|
| 877 | - $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); |
|
| 878 | - $tmppluginhost->load_data(); |
|
| 876 | + $tmppluginhost = new PluginHost(); |
|
| 877 | + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); |
|
| 878 | + $tmppluginhost->load_data(); |
|
| 879 | 879 | |
| 880 | - foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
| 881 | - $about = $plugin->about(); |
|
| 880 | + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
| 881 | + $about = $plugin->about(); |
|
| 882 | 882 | |
| 883 | - if ($about[3]) { |
|
| 884 | - if (in_array($name, $system_enabled)) { |
|
| 885 | - $checked = "checked='1'"; |
|
| 886 | - } else { |
|
| 887 | - $checked = ""; |
|
| 888 | - } |
|
| 883 | + if ($about[3]) { |
|
| 884 | + if (in_array($name, $system_enabled)) { |
|
| 885 | + $checked = "checked='1'"; |
|
| 886 | + } else { |
|
| 887 | + $checked = ""; |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | - print "<fieldset class='prefs plugin'> |
|
| 890 | + print "<fieldset class='prefs plugin'> |
|
| 891 | 891 | <label>$name:</label> |
| 892 | 892 | <label class='checkbox description text-muted' id='PLABEL-$name'> |
| 893 | 893 | <input disabled='1' |
| 894 | 894 | dojoType='dijit.form.CheckBox' $checked type='checkbox'> |
| 895 | 895 | ".htmlspecialchars($about[1]). "</label>"; |
| 896 | 896 | |
| 897 | - if (@$about[4]) { |
|
| 898 | - print "<button dojoType='dijit.form.Button' class='alt-info' |
|
| 897 | + if (@$about[4]) { |
|
| 898 | + print "<button dojoType='dijit.form.Button' class='alt-info' |
|
| 899 | 899 | onclick='window.open(\"".htmlspecialchars($about[4])."\")'> |
| 900 | 900 | <i class='material-icons'>open_in_new</i> ".__("More info...")."</button>"; |
| 901 | - } |
|
| 901 | + } |
|
| 902 | 902 | |
| 903 | - print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>". |
|
| 904 | - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). |
|
| 905 | - "</div>"; |
|
| 903 | + print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>". |
|
| 904 | + htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). |
|
| 905 | + "</div>"; |
|
| 906 | 906 | |
| 907 | - print "</fieldset>"; |
|
| 907 | + print "</fieldset>"; |
|
| 908 | 908 | |
| 909 | - } |
|
| 910 | - } |
|
| 909 | + } |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | - print "<h2>".__("User plugins")."</h2>"; |
|
| 912 | + print "<h2>".__("User plugins")."</h2>"; |
|
| 913 | 913 | |
| 914 | - foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
| 915 | - $about = $plugin->about(); |
|
| 914 | + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
| 915 | + $about = $plugin->about(); |
|
| 916 | 916 | |
| 917 | - if (!$about[3]) { |
|
| 917 | + if (!$about[3]) { |
|
| 918 | 918 | |
| 919 | - $checked = ""; |
|
| 920 | - $disabled = ""; |
|
| 919 | + $checked = ""; |
|
| 920 | + $disabled = ""; |
|
| 921 | 921 | |
| 922 | - if (in_array($name, $system_enabled)) { |
|
| 923 | - $checked = "checked='1'"; |
|
| 924 | - $disabled = "disabled='1'"; |
|
| 925 | - } else if (in_array($name, $user_enabled)) { |
|
| 926 | - $checked = "checked='1'"; |
|
| 927 | - } |
|
| 922 | + if (in_array($name, $system_enabled)) { |
|
| 923 | + $checked = "checked='1'"; |
|
| 924 | + $disabled = "disabled='1'"; |
|
| 925 | + } else if (in_array($name, $user_enabled)) { |
|
| 926 | + $checked = "checked='1'"; |
|
| 927 | + } |
|
| 928 | 928 | |
| 929 | - print "<fieldset class='prefs plugin'> |
|
| 929 | + print "<fieldset class='prefs plugin'> |
|
| 930 | 930 | <label>$name:</label> |
| 931 | 931 | <label class='checkbox description text-muted' id='PLABEL-$name'> |
| 932 | 932 | <input name='plugins[]' value='$name' dojoType='dijit.form.CheckBox' $checked $disabled type='checkbox'> |
| 933 | 933 | ".htmlspecialchars($about[1])."</label>"; |
| 934 | 934 | |
| 935 | - if (count($tmppluginhost->get_all($plugin)) > 0) { |
|
| 936 | - if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { |
|
| 937 | - print " <button dojoType='dijit.form.Button' |
|
| 935 | + if (count($tmppluginhost->get_all($plugin)) > 0) { |
|
| 936 | + if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { |
|
| 937 | + print " <button dojoType='dijit.form.Button' |
|
| 938 | 938 | onclick=\"Helpers.clearPluginData('$name')\"> |
| 939 | 939 | <i class='material-icons'>clear</i> ".__("Clear data")."</button>"; |
| 940 | - } |
|
| 941 | - } |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - if (@$about[4]) { |
|
| 944 | - print " <button dojoType='dijit.form.Button' class='alt-info' |
|
| 943 | + if (@$about[4]) { |
|
| 944 | + print " <button dojoType='dijit.form.Button' class='alt-info' |
|
| 945 | 945 | onclick='window.open(\"".htmlspecialchars($about[4])."\")'> |
| 946 | 946 | <i class='material-icons'>open_in_new</i> ".__("More info...")."</button>"; |
| 947 | - } |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>". |
|
| 950 | - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). |
|
| 951 | - "</div>"; |
|
| 949 | + print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>". |
|
| 950 | + htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). |
|
| 951 | + "</div>"; |
|
| 952 | 952 | |
| 953 | - print "</fieldset>"; |
|
| 954 | - } |
|
| 955 | - } |
|
| 953 | + print "</fieldset>"; |
|
| 954 | + } |
|
| 955 | + } |
|
| 956 | 956 | |
| 957 | - print "</div>"; #content-pane |
|
| 958 | - print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; |
|
| 957 | + print "</div>"; #content-pane |
|
| 958 | + print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; |
|
| 959 | 959 | |
| 960 | - print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/Plugins\")'> |
|
| 960 | + print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/Plugins\")'> |
|
| 961 | 961 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
| 962 | 962 | |
| 963 | - print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>". |
|
| 964 | - __("Enable selected plugins")."</button>"; |
|
| 965 | - print "</div>"; #pane |
|
| 963 | + print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>". |
|
| 964 | + __("Enable selected plugins")."</button>"; |
|
| 965 | + print "</div>"; #pane |
|
| 966 | 966 | |
| 967 | - print "</div>"; #pane |
|
| 968 | - print "</div>"; #border-container |
|
| 967 | + print "</div>"; #pane |
|
| 968 | + print "</div>"; #border-container |
|
| 969 | 969 | |
| 970 | - print "</form>"; |
|
| 970 | + print "</form>"; |
|
| 971 | 971 | |
| 972 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
| 973 | - "hook_prefs_tab", "prefPrefs"); |
|
| 972 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
| 973 | + "hook_prefs_tab", "prefPrefs"); |
|
| 974 | 974 | |
| 975 | - print "</div>"; #container |
|
| 975 | + print "</div>"; #container |
|
| 976 | 976 | |
| 977 | - } |
|
| 977 | + } |
|
| 978 | 978 | |
| 979 | - public function toggleAdvanced() { |
|
| 980 | - $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"]; |
|
| 981 | - } |
|
| 979 | + public function toggleAdvanced() { |
|
| 980 | + $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"]; |
|
| 981 | + } |
|
| 982 | 982 | |
| 983 | - public function otpsecret() { |
|
| 984 | - $sth = $this->pdo->prepare("SELECT salt, otp_enabled |
|
| 983 | + public function otpsecret() { |
|
| 984 | + $sth = $this->pdo->prepare("SELECT salt, otp_enabled |
|
| 985 | 985 | FROM ttrss_users |
| 986 | 986 | WHERE id = ?"); |
| 987 | - $sth->execute([$_SESSION['uid']]); |
|
| 987 | + $sth->execute([$_SESSION['uid']]); |
|
| 988 | 988 | |
| 989 | - if ($row = $sth->fetch()) { |
|
| 990 | - $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); |
|
| 989 | + if ($row = $sth->fetch()) { |
|
| 990 | + $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); |
|
| 991 | 991 | |
| 992 | - if (!$otp_enabled) { |
|
| 993 | - $base32 = new \OTPHP\Base32(); |
|
| 994 | - $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false); |
|
| 992 | + if (!$otp_enabled) { |
|
| 993 | + $base32 = new \OTPHP\Base32(); |
|
| 994 | + $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false); |
|
| 995 | 995 | |
| 996 | - return $secret; |
|
| 997 | - } |
|
| 998 | - } |
|
| 996 | + return $secret; |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | 999 | |
| 1000 | - return false; |
|
| 1001 | - } |
|
| 1000 | + return false; |
|
| 1001 | + } |
|
| 1002 | 1002 | |
| 1003 | - public function otpqrcode() { |
|
| 1004 | - require_once "lib/phpqrcode/phpqrcode.php"; |
|
| 1003 | + public function otpqrcode() { |
|
| 1004 | + require_once "lib/phpqrcode/phpqrcode.php"; |
|
| 1005 | 1005 | |
| 1006 | - $sth = $this->pdo->prepare("SELECT login |
|
| 1006 | + $sth = $this->pdo->prepare("SELECT login |
|
| 1007 | 1007 | FROM ttrss_users |
| 1008 | 1008 | WHERE id = ?"); |
| 1009 | - $sth->execute([$_SESSION['uid']]); |
|
| 1009 | + $sth->execute([$_SESSION['uid']]); |
|
| 1010 | 1010 | |
| 1011 | - if ($row = $sth->fetch()) { |
|
| 1012 | - $secret = $this->otpsecret(); |
|
| 1013 | - $login = $row['login']; |
|
| 1011 | + if ($row = $sth->fetch()) { |
|
| 1012 | + $secret = $this->otpsecret(); |
|
| 1013 | + $login = $row['login']; |
|
| 1014 | 1014 | |
| 1015 | - if ($secret) { |
|
| 1016 | - QRcode::png("otpauth://totp/".urlencode($login). |
|
| 1017 | - "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS")); |
|
| 1018 | - } |
|
| 1019 | - } |
|
| 1020 | - } |
|
| 1015 | + if ($secret) { |
|
| 1016 | + QRcode::png("otpauth://totp/".urlencode($login). |
|
| 1017 | + "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS")); |
|
| 1018 | + } |
|
| 1019 | + } |
|
| 1020 | + } |
|
| 1021 | 1021 | |
| 1022 | - public function otpenable() { |
|
| 1022 | + public function otpenable() { |
|
| 1023 | 1023 | |
| 1024 | - $password = clean($_REQUEST["password"]); |
|
| 1025 | - $otp = clean($_REQUEST["otp"]); |
|
| 1024 | + $password = clean($_REQUEST["password"]); |
|
| 1025 | + $otp = clean($_REQUEST["otp"]); |
|
| 1026 | 1026 | |
| 1027 | - $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1027 | + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1028 | 1028 | |
| 1029 | - if ($authenticator->check_password($_SESSION["uid"], $password)) { |
|
| 1029 | + if ($authenticator->check_password($_SESSION["uid"], $password)) { |
|
| 1030 | 1030 | |
| 1031 | - $secret = $this->otpsecret(); |
|
| 1031 | + $secret = $this->otpsecret(); |
|
| 1032 | 1032 | |
| 1033 | - if ($secret) { |
|
| 1034 | - $topt = new \OTPHP\TOTP($secret); |
|
| 1035 | - $otp_check = $topt->now(); |
|
| 1033 | + if ($secret) { |
|
| 1034 | + $topt = new \OTPHP\TOTP($secret); |
|
| 1035 | + $otp_check = $topt->now(); |
|
| 1036 | 1036 | |
| 1037 | - if ($otp == $otp_check) { |
|
| 1038 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = true WHERE id = ?"); |
|
| 1037 | + if ($otp == $otp_check) { |
|
| 1038 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = true WHERE id = ?"); |
|
| 1039 | 1039 | |
| 1040 | - $sth->execute([$_SESSION['uid']]); |
|
| 1040 | + $sth->execute([$_SESSION['uid']]); |
|
| 1041 | 1041 | |
| 1042 | - print "OK"; |
|
| 1043 | - } else { |
|
| 1044 | - print "ERROR:".__("Incorrect one time password"); |
|
| 1045 | - } |
|
| 1046 | - } |
|
| 1042 | + print "OK"; |
|
| 1043 | + } else { |
|
| 1044 | + print "ERROR:".__("Incorrect one time password"); |
|
| 1045 | + } |
|
| 1046 | + } |
|
| 1047 | 1047 | |
| 1048 | - } else { |
|
| 1049 | - print "ERROR:".__("Incorrect password"); |
|
| 1050 | - } |
|
| 1048 | + } else { |
|
| 1049 | + print "ERROR:".__("Incorrect password"); |
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | |
| 1054 | - public static function isdefaultpassword() { |
|
| 1055 | - $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1054 | + public static function isdefaultpassword() { |
|
| 1055 | + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1056 | 1056 | |
| 1057 | - if ($authenticator && |
|
| 1057 | + if ($authenticator && |
|
| 1058 | 1058 | method_exists($authenticator, "check_password") && |
| 1059 | 1059 | $authenticator->check_password($_SESSION["uid"], "password")) { |
| 1060 | 1060 | |
| 1061 | - return true; |
|
| 1062 | - } |
|
| 1061 | + return true; |
|
| 1062 | + } |
|
| 1063 | 1063 | |
| 1064 | - return false; |
|
| 1065 | - } |
|
| 1064 | + return false; |
|
| 1065 | + } |
|
| 1066 | 1066 | |
| 1067 | - public function otpdisable() { |
|
| 1068 | - $password = clean($_REQUEST["password"]); |
|
| 1067 | + public function otpdisable() { |
|
| 1068 | + $password = clean($_REQUEST["password"]); |
|
| 1069 | 1069 | |
| 1070 | - $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1070 | + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
|
| 1071 | 1071 | |
| 1072 | - if ($authenticator->check_password($_SESSION["uid"], $password)) { |
|
| 1072 | + if ($authenticator->check_password($_SESSION["uid"], $password)) { |
|
| 1073 | 1073 | |
| 1074 | - $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?"); |
|
| 1075 | - $sth->execute([$_SESSION['uid']]); |
|
| 1074 | + $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?"); |
|
| 1075 | + $sth->execute([$_SESSION['uid']]); |
|
| 1076 | 1076 | |
| 1077 | - if ($row = $sth->fetch()) { |
|
| 1078 | - $mailer = new Mailer(); |
|
| 1077 | + if ($row = $sth->fetch()) { |
|
| 1078 | + $mailer = new Mailer(); |
|
| 1079 | 1079 | |
| 1080 | - require_once "lib/MiniTemplator.class.php"; |
|
| 1080 | + require_once "lib/MiniTemplator.class.php"; |
|
| 1081 | 1081 | |
| 1082 | - $tpl = new MiniTemplator; |
|
| 1082 | + $tpl = new MiniTemplator; |
|
| 1083 | 1083 | |
| 1084 | - $tpl->readTemplateFromFile("templates/otp_disabled_template.txt"); |
|
| 1084 | + $tpl->readTemplateFromFile("templates/otp_disabled_template.txt"); |
|
| 1085 | 1085 | |
| 1086 | - $tpl->setVariable('LOGIN', $row["login"]); |
|
| 1087 | - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 1086 | + $tpl->setVariable('LOGIN', $row["login"]); |
|
| 1087 | + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 1088 | 1088 | |
| 1089 | - $tpl->addBlock('message'); |
|
| 1089 | + $tpl->addBlock('message'); |
|
| 1090 | 1090 | |
| 1091 | - $tpl->generateOutputToString($message); |
|
| 1091 | + $tpl->generateOutputToString($message); |
|
| 1092 | 1092 | |
| 1093 | - $mailer->mail(["to_name" => $row["login"], |
|
| 1094 | - "to_address" => $row["email"], |
|
| 1095 | - "subject" => "[tt-rss] OTP change notification", |
|
| 1096 | - "message" => $message]); |
|
| 1097 | - } |
|
| 1093 | + $mailer->mail(["to_name" => $row["login"], |
|
| 1094 | + "to_address" => $row["email"], |
|
| 1095 | + "subject" => "[tt-rss] OTP change notification", |
|
| 1096 | + "message" => $message]); |
|
| 1097 | + } |
|
| 1098 | 1098 | |
| 1099 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE |
|
| 1099 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE |
|
| 1100 | 1100 | id = ?"); |
| 1101 | - $sth->execute([$_SESSION['uid']]); |
|
| 1101 | + $sth->execute([$_SESSION['uid']]); |
|
| 1102 | 1102 | |
| 1103 | - print "OK"; |
|
| 1104 | - } else { |
|
| 1105 | - print "ERROR: ".__("Incorrect password"); |
|
| 1106 | - } |
|
| 1103 | + print "OK"; |
|
| 1104 | + } else { |
|
| 1105 | + print "ERROR: ".__("Incorrect password"); |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | - } |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | - public function setplugins() { |
|
| 1111 | - if (is_array(clean($_REQUEST["plugins"]))) |
|
| 1112 | - $plugins = join(",", clean($_REQUEST["plugins"])); |
|
| 1113 | - else |
|
| 1114 | - $plugins = ""; |
|
| 1110 | + public function setplugins() { |
|
| 1111 | + if (is_array(clean($_REQUEST["plugins"]))) |
|
| 1112 | + $plugins = join(",", clean($_REQUEST["plugins"])); |
|
| 1113 | + else |
|
| 1114 | + $plugins = ""; |
|
| 1115 | 1115 | |
| 1116 | - set_pref("_ENABLED_PLUGINS", $plugins); |
|
| 1117 | - } |
|
| 1116 | + set_pref("_ENABLED_PLUGINS", $plugins); |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | - public function clearplugindata() { |
|
| 1120 | - $name = clean($_REQUEST["name"]); |
|
| 1119 | + public function clearplugindata() { |
|
| 1120 | + $name = clean($_REQUEST["name"]); |
|
| 1121 | 1121 | |
| 1122 | - PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name)); |
|
| 1123 | - } |
|
| 1122 | + PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name)); |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | - public function customizeCSS() { |
|
| 1126 | - $value = get_pref("USER_STYLESHEET"); |
|
| 1127 | - $value = str_replace("<br/>", "\n", $value); |
|
| 1125 | + public function customizeCSS() { |
|
| 1126 | + $value = get_pref("USER_STYLESHEET"); |
|
| 1127 | + $value = str_replace("<br/>", "\n", $value); |
|
| 1128 | 1128 | |
| 1129 | - print_notice(__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")); |
|
| 1129 | + print_notice(__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")); |
|
| 1130 | 1130 | |
| 1131 | - print_hidden("op", "rpc"); |
|
| 1132 | - print_hidden("method", "setpref"); |
|
| 1133 | - print_hidden("key", "USER_STYLESHEET"); |
|
| 1131 | + print_hidden("op", "rpc"); |
|
| 1132 | + print_hidden("method", "setpref"); |
|
| 1133 | + print_hidden("key", "USER_STYLESHEET"); |
|
| 1134 | 1134 | |
| 1135 | - print "<div id='css_edit_apply_msg' style='display : none'>"; |
|
| 1136 | - print_warning(__("User CSS has been applied, you might need to reload the page to see all changes.")); |
|
| 1137 | - print "</div>"; |
|
| 1135 | + print "<div id='css_edit_apply_msg' style='display : none'>"; |
|
| 1136 | + print_warning(__("User CSS has been applied, you might need to reload the page to see all changes.")); |
|
| 1137 | + print "</div>"; |
|
| 1138 | 1138 | |
| 1139 | - print "<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea' |
|
| 1139 | + print "<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea' |
|
| 1140 | 1140 | style='font-size : 12px;' name='value'>$value</textarea>"; |
| 1141 | 1141 | |
| 1142 | - print "<footer>"; |
|
| 1143 | - print "<button dojoType='dijit.form.Button' class='alt-success' |
|
| 1142 | + print "<footer>"; |
|
| 1143 | + print "<button dojoType='dijit.form.Button' class='alt-success' |
|
| 1144 | 1144 | onclick=\"dijit.byId('cssEditDlg').apply()\">".__('Apply')."</button> "; |
| 1145 | - print "<button dojoType='dijit.form.Button' class='alt-primary' |
|
| 1145 | + print "<button dojoType='dijit.form.Button' class='alt-primary' |
|
| 1146 | 1146 | onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save and reload')."</button> "; |
| 1147 | - print "<button dojoType='dijit.form.Button' |
|
| 1147 | + print "<button dojoType='dijit.form.Button' |
|
| 1148 | 1148 | onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>"; |
| 1149 | - print "</footer>"; |
|
| 1149 | + print "</footer>"; |
|
| 1150 | 1150 | |
| 1151 | - } |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | - public function editPrefProfiles() { |
|
| 1154 | - print "<div dojoType='fox.Toolbar'>"; |
|
| 1153 | + public function editPrefProfiles() { |
|
| 1154 | + print "<div dojoType='fox.Toolbar'>"; |
|
| 1155 | 1155 | |
| 1156 | - print "<div dojoType='fox.form.DropDownButton'>". |
|
| 1157 | - "<span>" . __('Select')."</span>"; |
|
| 1158 | - print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
| 1159 | - print "<div onclick=\"Tables.select('pref-profiles-list', true)\" |
|
| 1156 | + print "<div dojoType='fox.form.DropDownButton'>". |
|
| 1157 | + "<span>" . __('Select')."</span>"; |
|
| 1158 | + print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
| 1159 | + print "<div onclick=\"Tables.select('pref-profiles-list', true)\" |
|
| 1160 | 1160 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
| 1161 | - print "<div onclick=\"Tables.select('pref-profiles-list', false)\" |
|
| 1161 | + print "<div onclick=\"Tables.select('pref-profiles-list', false)\" |
|
| 1162 | 1162 | dojoType='dijit.MenuItem'>".__('None')."</div>"; |
| 1163 | - print "</div></div>"; |
|
| 1163 | + print "</div></div>"; |
|
| 1164 | 1164 | |
| 1165 | - print "<div style='float : right'>"; |
|
| 1165 | + print "<div style='float : right'>"; |
|
| 1166 | 1166 | |
| 1167 | - print "<input name='newprofile' dojoType='dijit.form.ValidationTextBox' |
|
| 1167 | + print "<input name='newprofile' dojoType='dijit.form.ValidationTextBox' |
|
| 1168 | 1168 | required='1'> |
| 1169 | 1169 | <button dojoType='dijit.form.Button' |
| 1170 | 1170 | onclick=\"dijit.byId('profileEditDlg').addProfile()\">". |
| 1171 | - __('Create profile')."</button></div>"; |
|
| 1171 | + __('Create profile')."</button></div>"; |
|
| 1172 | 1172 | |
| 1173 | - print "</div>"; |
|
| 1173 | + print "</div>"; |
|
| 1174 | 1174 | |
| 1175 | - $sth = $this->pdo->prepare("SELECT title,id FROM ttrss_settings_profiles |
|
| 1175 | + $sth = $this->pdo->prepare("SELECT title,id FROM ttrss_settings_profiles |
|
| 1176 | 1176 | WHERE owner_uid = ? ORDER BY title"); |
| 1177 | - $sth->execute([$_SESSION['uid']]); |
|
| 1177 | + $sth->execute([$_SESSION['uid']]); |
|
| 1178 | 1178 | |
| 1179 | - print "<div class='panel panel-scrollable'>"; |
|
| 1179 | + print "<div class='panel panel-scrollable'>"; |
|
| 1180 | 1180 | |
| 1181 | - print "<form id='profile_edit_form' onsubmit='return false'>"; |
|
| 1181 | + print "<form id='profile_edit_form' onsubmit='return false'>"; |
|
| 1182 | 1182 | |
| 1183 | - print "<table width='100%' id='pref-profiles-list'>"; |
|
| 1183 | + print "<table width='100%' id='pref-profiles-list'>"; |
|
| 1184 | 1184 | |
| 1185 | - print "<tr>"; # data-row-id='0' <-- no point, shouldn't be removed |
|
| 1185 | + print "<tr>"; # data-row-id='0' <-- no point, shouldn't be removed |
|
| 1186 | 1186 | |
| 1187 | - print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
|
| 1187 | + print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
|
| 1188 | 1188 | |
| 1189 | - if (!$_SESSION["profile"]) { |
|
| 1190 | - $is_active = __("(active)"); |
|
| 1191 | - } else { |
|
| 1192 | - $is_active = ""; |
|
| 1193 | - } |
|
| 1189 | + if (!$_SESSION["profile"]) { |
|
| 1190 | + $is_active = __("(active)"); |
|
| 1191 | + } else { |
|
| 1192 | + $is_active = ""; |
|
| 1193 | + } |
|
| 1194 | 1194 | |
| 1195 | - print "<td width='100%'><span>" . __("Default profile") . " $is_active</span></td>"; |
|
| 1195 | + print "<td width='100%'><span>" . __("Default profile") . " $is_active</span></td>"; |
|
| 1196 | 1196 | |
| 1197 | - print "</tr>"; |
|
| 1197 | + print "</tr>"; |
|
| 1198 | 1198 | |
| 1199 | - while ($line = $sth->fetch()) { |
|
| 1199 | + while ($line = $sth->fetch()) { |
|
| 1200 | 1200 | |
| 1201 | - $profile_id = $line["id"]; |
|
| 1201 | + $profile_id = $line["id"]; |
|
| 1202 | 1202 | |
| 1203 | - print "<tr data-row-id='$profile_id'>"; |
|
| 1203 | + print "<tr data-row-id='$profile_id'>"; |
|
| 1204 | 1204 | |
| 1205 | - $edit_title = htmlspecialchars($line["title"]); |
|
| 1205 | + $edit_title = htmlspecialchars($line["title"]); |
|
| 1206 | 1206 | |
| 1207 | - print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
|
| 1207 | + print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
|
| 1208 | 1208 | |
| 1209 | - if ($_SESSION["profile"] == $line["id"]) { |
|
| 1210 | - $is_active = __("(active)"); |
|
| 1211 | - } else { |
|
| 1212 | - $is_active = ""; |
|
| 1213 | - } |
|
| 1209 | + if ($_SESSION["profile"] == $line["id"]) { |
|
| 1210 | + $is_active = __("(active)"); |
|
| 1211 | + } else { |
|
| 1212 | + $is_active = ""; |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | - print "<td><span dojoType='dijit.InlineEditBox' |
|
| 1215 | + print "<td><span dojoType='dijit.InlineEditBox' |
|
| 1216 | 1216 | width='300px' autoSave='false' |
| 1217 | 1217 | profile-id='$profile_id'>" . $edit_title . |
| 1218 | - "<script type='dojo/method' event='onChange' args='item'> |
|
| 1218 | + "<script type='dojo/method' event='onChange' args='item'> |
|
| 1219 | 1219 | var elem = this; |
| 1220 | 1220 | dojo.xhrPost({ |
| 1221 | 1221 | url: 'backend.php', |
@@ -1229,118 +1229,118 @@ discard block |
||
| 1229 | 1229 | </script> |
| 1230 | 1230 | </span> $is_active</td>"; |
| 1231 | 1231 | |
| 1232 | - print "</tr>"; |
|
| 1233 | - } |
|
| 1232 | + print "</tr>"; |
|
| 1233 | + } |
|
| 1234 | 1234 | |
| 1235 | - print "</table>"; |
|
| 1236 | - print "</form>"; |
|
| 1237 | - print "</div>"; |
|
| 1235 | + print "</table>"; |
|
| 1236 | + print "</form>"; |
|
| 1237 | + print "</div>"; |
|
| 1238 | 1238 | |
| 1239 | - print "<footer> |
|
| 1239 | + print "<footer> |
|
| 1240 | 1240 | <button style='float : left' class='alt-danger' dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">". |
| 1241 | - __('Remove selected profiles')."</button> |
|
| 1241 | + __('Remove selected profiles')."</button> |
|
| 1242 | 1242 | <button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"dijit.byId('profileEditDlg').activateProfile()\">". |
| 1243 | - __('Activate profile')."</button> |
|
| 1243 | + __('Activate profile')."</button> |
|
| 1244 | 1244 | <button dojoType='dijit.form.Button' onclick=\"dijit.byId('profileEditDlg').hide()\">". |
| 1245 | - __('Cancel')."</button>"; |
|
| 1246 | - print "</footer>"; |
|
| 1247 | - |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - private function getShortDesc($pref_name) { |
|
| 1251 | - if (isset($this->pref_help[$pref_name])) { |
|
| 1252 | - return $this->pref_help[$pref_name][0]; |
|
| 1253 | - } |
|
| 1254 | - return ""; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - private function getHelpText($pref_name) { |
|
| 1258 | - if (isset($this->pref_help[$pref_name])) { |
|
| 1259 | - return $this->pref_help[$pref_name][1]; |
|
| 1260 | - } |
|
| 1261 | - return ""; |
|
| 1262 | - } |
|
| 1263 | - |
|
| 1264 | - private function appPasswordList() { |
|
| 1265 | - print "<div dojoType='fox.Toolbar'>"; |
|
| 1266 | - print "<div dojoType='fox.form.DropDownButton'>" . |
|
| 1267 | - "<span>" . __('Select') . "</span>"; |
|
| 1268 | - print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
| 1269 | - print "<div onclick=\"Tables.select('app-password-list', true)\" |
|
| 1245 | + __('Cancel')."</button>"; |
|
| 1246 | + print "</footer>"; |
|
| 1247 | + |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + private function getShortDesc($pref_name) { |
|
| 1251 | + if (isset($this->pref_help[$pref_name])) { |
|
| 1252 | + return $this->pref_help[$pref_name][0]; |
|
| 1253 | + } |
|
| 1254 | + return ""; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + private function getHelpText($pref_name) { |
|
| 1258 | + if (isset($this->pref_help[$pref_name])) { |
|
| 1259 | + return $this->pref_help[$pref_name][1]; |
|
| 1260 | + } |
|
| 1261 | + return ""; |
|
| 1262 | + } |
|
| 1263 | + |
|
| 1264 | + private function appPasswordList() { |
|
| 1265 | + print "<div dojoType='fox.Toolbar'>"; |
|
| 1266 | + print "<div dojoType='fox.form.DropDownButton'>" . |
|
| 1267 | + "<span>" . __('Select') . "</span>"; |
|
| 1268 | + print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
| 1269 | + print "<div onclick=\"Tables.select('app-password-list', true)\" |
|
| 1270 | 1270 | dojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; |
| 1271 | - print "<div onclick=\"Tables.select('app-password-list', false)\" |
|
| 1271 | + print "<div onclick=\"Tables.select('app-password-list', false)\" |
|
| 1272 | 1272 | dojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; |
| 1273 | - print "</div></div>"; |
|
| 1274 | - print "</div>"; #toolbar |
|
| 1275 | - |
|
| 1276 | - print "<div class='panel panel-scrollable'>"; |
|
| 1277 | - print "<table width='100%' id='app-password-list'>"; |
|
| 1278 | - print "<tr>"; |
|
| 1279 | - print "<th width='2%'></th>"; |
|
| 1280 | - print "<th align='left'>".__("Description")."</th>"; |
|
| 1281 | - print "<th align='right'>".__("Created")."</th>"; |
|
| 1282 | - print "<th align='right'>".__("Last used")."</th>"; |
|
| 1283 | - print "</tr>"; |
|
| 1284 | - |
|
| 1285 | - $sth = $this->pdo->prepare("SELECT id, title, created, last_used |
|
| 1273 | + print "</div></div>"; |
|
| 1274 | + print "</div>"; #toolbar |
|
| 1275 | + |
|
| 1276 | + print "<div class='panel panel-scrollable'>"; |
|
| 1277 | + print "<table width='100%' id='app-password-list'>"; |
|
| 1278 | + print "<tr>"; |
|
| 1279 | + print "<th width='2%'></th>"; |
|
| 1280 | + print "<th align='left'>".__("Description")."</th>"; |
|
| 1281 | + print "<th align='right'>".__("Created")."</th>"; |
|
| 1282 | + print "<th align='right'>".__("Last used")."</th>"; |
|
| 1283 | + print "</tr>"; |
|
| 1284 | + |
|
| 1285 | + $sth = $this->pdo->prepare("SELECT id, title, created, last_used |
|
| 1286 | 1286 | FROM ttrss_app_passwords WHERE owner_uid = ?"); |
| 1287 | - $sth->execute([$_SESSION['uid']]); |
|
| 1287 | + $sth->execute([$_SESSION['uid']]); |
|
| 1288 | 1288 | |
| 1289 | - while ($row = $sth->fetch()) { |
|
| 1289 | + while ($row = $sth->fetch()) { |
|
| 1290 | 1290 | |
| 1291 | - $row_id = $row["id"]; |
|
| 1291 | + $row_id = $row["id"]; |
|
| 1292 | 1292 | |
| 1293 | - print "<tr data-row-id='$row_id'>"; |
|
| 1293 | + print "<tr data-row-id='$row_id'>"; |
|
| 1294 | 1294 | |
| 1295 | - print "<td align='center'> |
|
| 1295 | + print "<td align='center'> |
|
| 1296 | 1296 | <input onclick='Tables.onRowChecked(this)' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; |
| 1297 | - print "<td>" . htmlspecialchars($row["title"]) . "</td>"; |
|
| 1297 | + print "<td>" . htmlspecialchars($row["title"]) . "</td>"; |
|
| 1298 | 1298 | |
| 1299 | - print "<td align='right' class='text-muted'>"; |
|
| 1300 | - print make_local_datetime($row['created'], false); |
|
| 1301 | - print "</td>"; |
|
| 1299 | + print "<td align='right' class='text-muted'>"; |
|
| 1300 | + print make_local_datetime($row['created'], false); |
|
| 1301 | + print "</td>"; |
|
| 1302 | 1302 | |
| 1303 | - print "<td align='right' class='text-muted'>"; |
|
| 1304 | - print make_local_datetime($row['last_used'], false); |
|
| 1305 | - print "</td>"; |
|
| 1303 | + print "<td align='right' class='text-muted'>"; |
|
| 1304 | + print make_local_datetime($row['last_used'], false); |
|
| 1305 | + print "</td>"; |
|
| 1306 | 1306 | |
| 1307 | - print "</tr>"; |
|
| 1308 | - } |
|
| 1307 | + print "</tr>"; |
|
| 1308 | + } |
|
| 1309 | 1309 | |
| 1310 | - print "</table>"; |
|
| 1311 | - print "</div>"; |
|
| 1312 | - } |
|
| 1310 | + print "</table>"; |
|
| 1311 | + print "</div>"; |
|
| 1312 | + } |
|
| 1313 | 1313 | |
| 1314 | - private function encryptAppPassword($password) { |
|
| 1315 | - $salt = substr(bin2hex(get_random_bytes(24)), 0, 24); |
|
| 1314 | + private function encryptAppPassword($password) { |
|
| 1315 | + $salt = substr(bin2hex(get_random_bytes(24)), 0, 24); |
|
| 1316 | 1316 | |
| 1317 | - return "SSHA-512:".hash('sha512', $salt . $password). ":$salt"; |
|
| 1318 | - } |
|
| 1317 | + return "SSHA-512:".hash('sha512', $salt . $password). ":$salt"; |
|
| 1318 | + } |
|
| 1319 | 1319 | |
| 1320 | - public function deleteAppPassword() { |
|
| 1321 | - $ids = explode(",", clean($_REQUEST['ids'])); |
|
| 1322 | - $ids_qmarks = arr_qmarks($ids); |
|
| 1320 | + public function deleteAppPassword() { |
|
| 1321 | + $ids = explode(",", clean($_REQUEST['ids'])); |
|
| 1322 | + $ids_qmarks = arr_qmarks($ids); |
|
| 1323 | 1323 | |
| 1324 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_app_passwords WHERE id IN ($ids_qmarks) AND owner_uid = ?"); |
|
| 1325 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 1324 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_app_passwords WHERE id IN ($ids_qmarks) AND owner_uid = ?"); |
|
| 1325 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 1326 | 1326 | |
| 1327 | - $this->appPasswordList(); |
|
| 1328 | - } |
|
| 1327 | + $this->appPasswordList(); |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - public function generateAppPassword() { |
|
| 1331 | - $title = clean($_REQUEST['title']); |
|
| 1332 | - $new_password = make_password(16); |
|
| 1333 | - $new_password_hash = $this->encryptAppPassword($new_password); |
|
| 1330 | + public function generateAppPassword() { |
|
| 1331 | + $title = clean($_REQUEST['title']); |
|
| 1332 | + $new_password = make_password(16); |
|
| 1333 | + $new_password_hash = $this->encryptAppPassword($new_password); |
|
| 1334 | 1334 | |
| 1335 | - print_warning(T_sprintf("Generated password <strong>%s</strong> for %s. Please remember it for future reference.", $new_password, $title)); |
|
| 1335 | + print_warning(T_sprintf("Generated password <strong>%s</strong> for %s. Please remember it for future reference.", $new_password, $title)); |
|
| 1336 | 1336 | |
| 1337 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_app_passwords |
|
| 1337 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_app_passwords |
|
| 1338 | 1338 | (title, pwd_hash, service, created, owner_uid) |
| 1339 | 1339 | VALUES |
| 1340 | 1340 | (?, ?, ?, NOW(), ?)"); |
| 1341 | 1341 | |
| 1342 | - $sth->execute([$title, $new_password_hash, Auth_Base::AUTH_SERVICE_API, $_SESSION['uid']]); |
|
| 1342 | + $sth->execute([$title, $new_password_hash, Auth_Base::AUTH_SERVICE_API, $_SESSION['uid']]); |
|
| 1343 | 1343 | |
| 1344 | - $this->appPasswordList(); |
|
| 1345 | - } |
|
| 1344 | + $this->appPasswordList(); |
|
| 1345 | + } |
|
| 1346 | 1346 | } |
@@ -160,7 +160,9 @@ discard block |
||
| 160 | 160 | $boolean_prefs = explode(",", clean($_POST["boolean_prefs"])); |
| 161 | 161 | |
| 162 | 162 | foreach ($boolean_prefs as $pref) { |
| 163 | - if (!isset($_POST[$pref])) $_POST[$pref] = 'false'; |
|
| 163 | + if (!isset($_POST[$pref])) { |
|
| 164 | + $_POST[$pref] = 'false'; |
|
| 165 | + } |
|
| 164 | 166 | } |
| 165 | 167 | |
| 166 | 168 | $need_reload = false; |
@@ -180,11 +182,15 @@ discard block |
||
| 180 | 182 | } |
| 181 | 183 | break; |
| 182 | 184 | case 'USER_LANGUAGE': |
| 183 | - if (!$need_reload) $need_reload = $_SESSION["language"] != $value; |
|
| 185 | + if (!$need_reload) { |
|
| 186 | + $need_reload = $_SESSION["language"] != $value; |
|
| 187 | + } |
|
| 184 | 188 | break; |
| 185 | 189 | |
| 186 | 190 | case 'USER_CSS_THEME': |
| 187 | - if (!$need_reload) $need_reload = get_pref($pref_name) != $value; |
|
| 191 | + if (!$need_reload) { |
|
| 192 | + $need_reload = get_pref($pref_name) != $value; |
|
| 193 | + } |
|
| 188 | 194 | break; |
| 189 | 195 | } |
| 190 | 196 | |
@@ -616,8 +622,9 @@ discard block |
||
| 616 | 622 | $pref_name = $line["pref_name"]; |
| 617 | 623 | $short_desc = $this->getShortDesc($pref_name); |
| 618 | 624 | |
| 619 | - if (!$short_desc) |
|
| 620 | - continue; |
|
| 625 | + if (!$short_desc) { |
|
| 626 | + continue; |
|
| 627 | + } |
|
| 621 | 628 | |
| 622 | 629 | $prefs_available[$pref_name] = [ |
| 623 | 630 | 'type_name' => $line["type_name"], |
@@ -669,7 +676,9 @@ discard block |
||
| 669 | 676 | $themes = array_filter($themes, "theme_exists"); |
| 670 | 677 | asort($themes); |
| 671 | 678 | |
| 672 | - if (!theme_exists($value)) $value = "default.php"; |
|
| 679 | + if (!theme_exists($value)) { |
|
| 680 | + $value = "default.php"; |
|
| 681 | + } |
|
| 673 | 682 | |
| 674 | 683 | print "<select name='$pref_name' id='$pref_name' dojoType='fox.form.Select'>"; |
| 675 | 684 | |
@@ -728,14 +737,15 @@ discard block |
||
| 728 | 737 | $disabled = ""; |
| 729 | 738 | } |
| 730 | 739 | |
| 731 | - if ($type_name == 'integer') |
|
| 732 | - print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
| 740 | + if ($type_name == 'integer') { |
|
| 741 | + print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
| 733 | 742 | required='1' $disabled |
| 734 | 743 | name=\"$pref_name\" value=\"$value\">"; |
| 735 | - else |
|
| 736 | - print "<input dojoType=\"dijit.form.TextBox\" |
|
| 744 | + } else { |
|
| 745 | + print "<input dojoType=\"dijit.form.TextBox\" |
|
| 737 | 746 | required='1' $regexp $disabled |
| 738 | 747 | name=\"$pref_name\" value=\"$value\">"; |
| 748 | + } |
|
| 739 | 749 | |
| 740 | 750 | } else if ($pref_name == "SSL_CERT_SERIAL") { |
| 741 | 751 | |
@@ -770,8 +780,9 @@ discard block |
||
| 770 | 780 | print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">"; |
| 771 | 781 | } |
| 772 | 782 | |
| 773 | - if ($item['help_text']) |
|
| 774 | - print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>"; |
|
| 783 | + if ($item['help_text']) { |
|
| 784 | + print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>"; |
|
| 785 | + } |
|
| 775 | 786 | |
| 776 | 787 | print "</fieldset>"; |
| 777 | 788 | } |
@@ -1108,10 +1119,11 @@ discard block |
||
| 1108 | 1119 | } |
| 1109 | 1120 | |
| 1110 | 1121 | public function setplugins() { |
| 1111 | - if (is_array(clean($_REQUEST["plugins"]))) |
|
| 1112 | - $plugins = join(",", clean($_REQUEST["plugins"])); |
|
| 1113 | - else |
|
| 1114 | - $plugins = ""; |
|
| 1122 | + if (is_array(clean($_REQUEST["plugins"]))) { |
|
| 1123 | + $plugins = join(",", clean($_REQUEST["plugins"])); |
|
| 1124 | + } else { |
|
| 1125 | + $plugins = ""; |
|
| 1126 | + } |
|
| 1115 | 1127 | |
| 1116 | 1128 | set_pref("_ENABLED_PLUGINS", $plugins); |
| 1117 | 1129 | } |