@@ -1,23 +1,23 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Zz_VidMute extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Mute audio in HTML5 videos", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Mute audio in HTML5 videos", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function init($host) { |
|
| 12 | - $this->host = $host; |
|
| 13 | - } |
|
| 11 | + public function init($host) { |
|
| 12 | + $this->host = $host; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function get_js() { |
|
| 16 | - return file_get_contents(__DIR__."/init.js"); |
|
| 17 | - } |
|
| 15 | + public function get_js() { |
|
| 16 | + return file_get_contents(__DIR__."/init.js"); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function api_version() { |
|
| 20 | - return 2; |
|
| 21 | - } |
|
| 19 | + public function api_version() { |
|
| 20 | + return 2; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | } |
@@ -1,45 +1,45 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Cache_Starred_Images extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 6 | - /* @var DiskCache $cache */ |
|
| 7 | - private $cache; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | + /* @var DiskCache $cache */ |
|
| 7 | + private $cache; |
|
| 8 | 8 | private $max_cache_attempts = 5; // per-article |
| 9 | 9 | |
| 10 | - public function about() { |
|
| 11 | - return array(1.0, |
|
| 12 | - "Automatically cache media files in Starred articles", |
|
| 13 | - "fox"); |
|
| 14 | - } |
|
| 10 | + public function about() { |
|
| 11 | + return array(1.0, |
|
| 12 | + "Automatically cache media files in Starred articles", |
|
| 13 | + "fox"); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function init($host) { |
|
| 17 | - $this->host = $host; |
|
| 18 | - $this->cache = new DiskCache("starred-images"); |
|
| 16 | + public function init($host) { |
|
| 17 | + $this->host = $host; |
|
| 18 | + $this->cache = new DiskCache("starred-images"); |
|
| 19 | 19 | |
| 20 | - if ($this->cache->makeDir()) { |
|
| 21 | - chmod($this->cache->getDir(), 0777); |
|
| 22 | - } |
|
| 20 | + if ($this->cache->makeDir()) { |
|
| 21 | + chmod($this->cache->getDir(), 0777); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - if (!$this->cache->exists(".no-auto-expiry")) { |
|
| 25 | - $this->cache->touch(".no-auto-expiry"); |
|
| 26 | - } |
|
| 24 | + if (!$this->cache->exists(".no-auto-expiry")) { |
|
| 25 | + $this->cache->touch(".no-auto-expiry"); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - if ($this->cache->isWritable()) { |
|
| 29 | - $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); |
|
| 30 | - $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 31 | - $host->add_hook($host::HOOK_SANITIZE, $this); |
|
| 32 | - } else { |
|
| 33 | - user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING); |
|
| 34 | - } |
|
| 35 | - } |
|
| 28 | + if ($this->cache->isWritable()) { |
|
| 29 | + $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); |
|
| 30 | + $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 31 | + $host->add_hook($host::HOOK_SANITIZE, $this); |
|
| 32 | + } else { |
|
| 33 | + user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function hook_house_keeping() { |
|
| 38 | - /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
|
| 37 | + public function hook_house_keeping() { |
|
| 38 | + /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
|
| 39 | 39 | |
| 40 | - Debug::log("caching media of starred articles for user ".$this->host->get_owner_uid()."..."); |
|
| 40 | + Debug::log("caching media of starred articles for user ".$this->host->get_owner_uid()."..."); |
|
| 41 | 41 | |
| 42 | - $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
|
| 42 | + $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
|
| 43 | 43 | ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data |
| 44 | 44 | FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON |
| 45 | 45 | (ttrss_user_entries.feed_id = ttrss_feeds.id) |
@@ -50,117 +50,117 @@ discard block |
||
| 50 | 50 | plugin_data NOT LIKE '%starred_cache_images%' |
| 51 | 51 | ORDER BY ".sql_random_function()." LIMIT 100"); |
| 52 | 52 | |
| 53 | - if ($sth->execute([$this->host->get_owner_uid()])) { |
|
| 53 | + if ($sth->execute([$this->host->get_owner_uid()])) { |
|
| 54 | 54 | |
| 55 | - $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
|
| 55 | + $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
|
| 56 | 56 | |
| 57 | - while ($line = $sth->fetch()) { |
|
| 58 | - Debug::log("processing article ".$line["title"], Debug::$LOG_VERBOSE); |
|
| 57 | + while ($line = $sth->fetch()) { |
|
| 58 | + Debug::log("processing article ".$line["title"], Debug::$LOG_VERBOSE); |
|
| 59 | 59 | |
| 60 | - if ($line["site_url"]) { |
|
| 61 | - $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
|
| 60 | + if ($line["site_url"]) { |
|
| 61 | + $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
|
| 62 | 62 | |
| 63 | - if ($success) { |
|
| 64 | - $plugin_data = "starred_cache_images,${line['owner_uid']}:".$line["plugin_data"]; |
|
| 63 | + if ($success) { |
|
| 64 | + $plugin_data = "starred_cache_images,${line['owner_uid']}:".$line["plugin_data"]; |
|
| 65 | 65 | |
| 66 | - $usth->execute([$plugin_data, $line['id']]); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 66 | + $usth->execute([$plugin_data, $line['id']]); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /* actual housekeeping */ |
|
| 72 | + /* actual housekeeping */ |
|
| 73 | 73 | |
| 74 | - Debug::log("expiring ".$this->cache->getDir()."..."); |
|
| 74 | + Debug::log("expiring ".$this->cache->getDir()."..."); |
|
| 75 | 75 | |
| 76 | - $files = glob($this->cache->getDir()."/*.{png,mp4,status}", GLOB_BRACE); |
|
| 76 | + $files = glob($this->cache->getDir()."/*.{png,mp4,status}", GLOB_BRACE); |
|
| 77 | 77 | |
| 78 | - $last_article_id = 0; |
|
| 79 | - $article_exists = 1; |
|
| 78 | + $last_article_id = 0; |
|
| 79 | + $article_exists = 1; |
|
| 80 | 80 | |
| 81 | - foreach ($files as $file) { |
|
| 82 | - list ($article_id, $hash) = explode("-", basename($file)); |
|
| 81 | + foreach ($files as $file) { |
|
| 82 | + list ($article_id, $hash) = explode("-", basename($file)); |
|
| 83 | 83 | |
| 84 | - if ($article_id != $last_article_id) { |
|
| 85 | - $last_article_id = $article_id; |
|
| 84 | + if ($article_id != $last_article_id) { |
|
| 85 | + $last_article_id = $article_id; |
|
| 86 | 86 | |
| 87 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?"); |
|
| 88 | - $sth->execute([$article_id]); |
|
| 87 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?"); |
|
| 88 | + $sth->execute([$article_id]); |
|
| 89 | 89 | |
| 90 | - $article_exists = $sth->fetch(); |
|
| 91 | - } |
|
| 90 | + $article_exists = $sth->fetch(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if (!$article_exists) { |
|
| 94 | - unlink($file); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 93 | + if (!$article_exists) { |
|
| 94 | + unlink($file); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function hook_enclosure_entry($enc, $article_id) { |
|
| 100 | - $local_filename = $article_id."-".sha1($enc["content_url"]); |
|
| 99 | + public function hook_enclosure_entry($enc, $article_id) { |
|
| 100 | + $local_filename = $article_id."-".sha1($enc["content_url"]); |
|
| 101 | 101 | |
| 102 | - if ($this->cache->exists($local_filename)) { |
|
| 103 | - $enc["content_url"] = $this->cache->getUrl($local_filename); |
|
| 104 | - } |
|
| 102 | + if ($this->cache->exists($local_filename)) { |
|
| 103 | + $enc["content_url"] = $this->cache->getUrl($local_filename); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return $enc; |
|
| 107 | - } |
|
| 106 | + return $enc; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { |
|
| 110 | - $xpath = new DOMXpath($doc); |
|
| 109 | + public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { |
|
| 110 | + $xpath = new DOMXpath($doc); |
|
| 111 | 111 | |
| 112 | - if ($article_id) { |
|
| 113 | - $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 112 | + if ($article_id) { |
|
| 113 | + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 114 | 114 | |
| 115 | - foreach ($entries as $entry) { |
|
| 116 | - if ($entry->hasAttribute('src')) { |
|
| 117 | - $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 115 | + foreach ($entries as $entry) { |
|
| 116 | + if ($entry->hasAttribute('src')) { |
|
| 117 | + $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 118 | 118 | |
| 119 | - $local_filename = $article_id."-".sha1($src); |
|
| 119 | + $local_filename = $article_id."-".sha1($src); |
|
| 120 | 120 | |
| 121 | - if ($this->cache->exists($local_filename)) { |
|
| 122 | - $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
|
| 123 | - $entry->removeAttribute("srcset"); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 121 | + if ($this->cache->exists($local_filename)) { |
|
| 122 | + $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
|
| 123 | + $entry->removeAttribute("srcset"); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return $doc; |
|
| 130 | - } |
|
| 129 | + return $doc; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - private function cache_url($article_id, $url) { |
|
| 133 | - $local_filename = $article_id."-".sha1($url); |
|
| 132 | + private function cache_url($article_id, $url) { |
|
| 133 | + $local_filename = $article_id."-".sha1($url); |
|
| 134 | 134 | |
| 135 | - if (!$this->cache->exists($local_filename)) { |
|
| 136 | - Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
|
| 135 | + if (!$this->cache->exists($local_filename)) { |
|
| 136 | + Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
|
| 137 | 137 | |
| 138 | - $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 138 | + $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 139 | 139 | |
| 140 | - if ($data) { |
|
| 141 | - return $this->cache->put($local_filename, $data); |
|
| 142 | - } |
|
| 143 | - ; |
|
| 140 | + if ($data) { |
|
| 141 | + return $this->cache->put($local_filename, $data); |
|
| 142 | + } |
|
| 143 | + ; |
|
| 144 | 144 | |
| 145 | - } else { |
|
| 146 | - //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
|
| 145 | + } else { |
|
| 146 | + //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
|
| 147 | 147 | |
| 148 | - return true; |
|
| 149 | - } |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - return false; |
|
| 152 | - } |
|
| 151 | + return false; |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
|
| 155 | - $status_filename = $article_id."-".sha1($site_url).".status"; |
|
| 154 | + private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
|
| 155 | + $status_filename = $article_id."-".sha1($site_url).".status"; |
|
| 156 | 156 | |
| 157 | - /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
|
| 158 | - if (!$this->cache->isWritable($status_filename)) { |
|
| 159 | - Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE); |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 157 | + /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
|
| 158 | + if (!$this->cache->isWritable($status_filename)) { |
|
| 159 | + Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE); |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
|
| 163 | + Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
|
| 164 | 164 | |
| 165 | 165 | if ($this->cache->exists($status_filename)) { |
| 166 | 166 | $status = json_decode($this->cache->get($status_filename), true); |
@@ -181,49 +181,49 @@ discard block |
||
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $doc = new DOMDocument(); |
|
| 184 | + $doc = new DOMDocument(); |
|
| 185 | 185 | |
| 186 | - $has_images = false; |
|
| 187 | - $success = false; |
|
| 186 | + $has_images = false; |
|
| 187 | + $success = false; |
|
| 188 | 188 | |
| 189 | 189 | if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) { |
| 190 | - $xpath = new DOMXPath($doc); |
|
| 191 | - $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 190 | + $xpath = new DOMXPath($doc); |
|
| 191 | + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 192 | 192 | |
| 193 | - foreach ($entries as $entry) { |
|
| 193 | + foreach ($entries as $entry) { |
|
| 194 | 194 | |
| 195 | - if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) { |
|
| 195 | + if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) { |
|
| 196 | 196 | |
| 197 | - $has_images = true; |
|
| 197 | + $has_images = true; |
|
| 198 | 198 | |
| 199 | - $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 199 | + $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 200 | 200 | |
| 201 | - if ($this->cache_url($article_id, $src)) { |
|
| 202 | - $success = true; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 201 | + if ($this->cache_url($article_id, $src)) { |
|
| 202 | + $success = true; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND |
|
| 208 | + $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND |
|
| 209 | 209 | (content_type LIKE '%image%' OR content_type LIKE '%video%')"); |
| 210 | 210 | |
| 211 | 211 | if ($esth->execute([$article_id])) { |
| 212 | - while ($enc = $esth->fetch()) { |
|
| 212 | + while ($enc = $esth->fetch()) { |
|
| 213 | 213 | |
| 214 | - $has_images = true; |
|
| 215 | - $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 214 | + $has_images = true; |
|
| 215 | + $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 216 | 216 | |
| 217 | - if ($this->cache_url($article_id, $url)) { |
|
| 218 | - $success = true; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - } |
|
| 217 | + if ($this->cache_url($article_id, $url)) { |
|
| 218 | + $success = true; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - return $success || !$has_images; |
|
| 224 | - } |
|
| 223 | + return $success || !$has_images; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - public function api_version() { |
|
| 227 | - return 2; |
|
| 228 | - } |
|
| 226 | + public function api_version() { |
|
| 227 | + return 2; |
|
| 228 | + } |
|
| 229 | 229 | } |
@@ -1,94 +1,94 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Auth_Remote extends Plugin implements IAuthModule { |
| 3 | 3 | |
| 4 | - private $host; |
|
| 5 | - /* @var Auth_Base $base */ |
|
| 6 | - private $base; |
|
| 7 | - |
|
| 8 | - public function about() { |
|
| 9 | - return array(1.0, |
|
| 10 | - "Authenticates against remote password (e.g. supplied by Apache)", |
|
| 11 | - "fox", |
|
| 12 | - true); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /* @var PluginHost $host */ |
|
| 16 | - public function init($host) { |
|
| 17 | - $this->host = $host; |
|
| 18 | - $this->base = new Auth_Base(); |
|
| 19 | - |
|
| 20 | - $host->add_hook($host::HOOK_AUTH_USER, $this); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function get_login_by_ssl_certificate() { |
|
| 24 | - $cert_serial = get_ssl_certificate_id(); |
|
| 25 | - |
|
| 26 | - if ($cert_serial) { |
|
| 27 | - $sth = $this->pdo->prepare("SELECT login FROM ttrss_user_prefs, ttrss_users |
|
| 4 | + private $host; |
|
| 5 | + /* @var Auth_Base $base */ |
|
| 6 | + private $base; |
|
| 7 | + |
|
| 8 | + public function about() { |
|
| 9 | + return array(1.0, |
|
| 10 | + "Authenticates against remote password (e.g. supplied by Apache)", |
|
| 11 | + "fox", |
|
| 12 | + true); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /* @var PluginHost $host */ |
|
| 16 | + public function init($host) { |
|
| 17 | + $this->host = $host; |
|
| 18 | + $this->base = new Auth_Base(); |
|
| 19 | + |
|
| 20 | + $host->add_hook($host::HOOK_AUTH_USER, $this); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function get_login_by_ssl_certificate() { |
|
| 24 | + $cert_serial = get_ssl_certificate_id(); |
|
| 25 | + |
|
| 26 | + if ($cert_serial) { |
|
| 27 | + $sth = $this->pdo->prepare("SELECT login FROM ttrss_user_prefs, ttrss_users |
|
| 28 | 28 | WHERE pref_name = 'SSL_CERT_SERIAL' AND value = ? AND |
| 29 | 29 | owner_uid = ttrss_users.id"); |
| 30 | - $sth->execute([$cert_serial]); |
|
| 31 | - |
|
| 32 | - if ($row = $sth->fetch()) { |
|
| 33 | - return $row['login']; |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return ""; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 42 | - */ |
|
| 43 | - public function authenticate($login, $password) { |
|
| 44 | - $try_login = $_SERVER["REMOTE_USER"]; |
|
| 45 | - |
|
| 46 | - // php-cgi |
|
| 47 | - if (!$try_login) { |
|
| 48 | - $try_login = $_SERVER["REDIRECT_REMOTE_USER"]; |
|
| 49 | - } |
|
| 50 | - if (!$try_login) { |
|
| 51 | - $try_login = $_SERVER["PHP_AUTH_USER"]; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (!$try_login) { |
|
| 55 | - $try_login = $this->get_login_by_ssl_certificate(); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if ($try_login) { |
|
| 59 | - $user_id = $this->base->auto_create_user($try_login, $password); |
|
| 60 | - |
|
| 61 | - if ($user_id) { |
|
| 62 | - $_SESSION["fake_login"] = $try_login; |
|
| 63 | - $_SESSION["fake_password"] = "******"; |
|
| 64 | - $_SESSION["hide_hello"] = true; |
|
| 65 | - $_SESSION["hide_logout"] = true; |
|
| 66 | - |
|
| 67 | - // LemonLDAP can send user informations via HTTP HEADER |
|
| 68 | - if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
| 69 | - // update user name |
|
| 70 | - $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN']; |
|
| 71 | - if ($fullname) { |
|
| 72 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?"); |
|
| 73 | - $sth->execute([$fullname, $user_id]); |
|
| 74 | - } |
|
| 75 | - // update user mail |
|
| 76 | - $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL']; |
|
| 77 | - if ($email) { |
|
| 78 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?"); |
|
| 79 | - $sth->execute([$email, $user_id]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - return $user_id; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return false; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function api_version() { |
|
| 91 | - return 2; |
|
| 92 | - } |
|
| 30 | + $sth->execute([$cert_serial]); |
|
| 31 | + |
|
| 32 | + if ($row = $sth->fetch()) { |
|
| 33 | + return $row['login']; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return ""; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 42 | + */ |
|
| 43 | + public function authenticate($login, $password) { |
|
| 44 | + $try_login = $_SERVER["REMOTE_USER"]; |
|
| 45 | + |
|
| 46 | + // php-cgi |
|
| 47 | + if (!$try_login) { |
|
| 48 | + $try_login = $_SERVER["REDIRECT_REMOTE_USER"]; |
|
| 49 | + } |
|
| 50 | + if (!$try_login) { |
|
| 51 | + $try_login = $_SERVER["PHP_AUTH_USER"]; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (!$try_login) { |
|
| 55 | + $try_login = $this->get_login_by_ssl_certificate(); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if ($try_login) { |
|
| 59 | + $user_id = $this->base->auto_create_user($try_login, $password); |
|
| 60 | + |
|
| 61 | + if ($user_id) { |
|
| 62 | + $_SESSION["fake_login"] = $try_login; |
|
| 63 | + $_SESSION["fake_password"] = "******"; |
|
| 64 | + $_SESSION["hide_hello"] = true; |
|
| 65 | + $_SESSION["hide_logout"] = true; |
|
| 66 | + |
|
| 67 | + // LemonLDAP can send user informations via HTTP HEADER |
|
| 68 | + if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
| 69 | + // update user name |
|
| 70 | + $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN']; |
|
| 71 | + if ($fullname) { |
|
| 72 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?"); |
|
| 73 | + $sth->execute([$fullname, $user_id]); |
|
| 74 | + } |
|
| 75 | + // update user mail |
|
| 76 | + $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL']; |
|
| 77 | + if ($email) { |
|
| 78 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?"); |
|
| 79 | + $sth->execute([$email, $user_id]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + return $user_id; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + return false; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function api_version() { |
|
| 91 | + return 2; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class NSFW extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Hide article content based on tags", |
|
| 8 | - "fox", |
|
| 9 | - false); |
|
| 10 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Hide article content based on tags", |
|
| 8 | + "fox", |
|
| 9 | + false); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function init($host) { |
|
| 13 | - $this->host = $host; |
|
| 12 | + public function init($host) { |
|
| 13 | + $this->host = $host; |
|
| 14 | 14 | |
| 15 | - $host->add_hook($host::HOOK_RENDER_ARTICLE, $this); |
|
| 16 | - $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this); |
|
| 17 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 15 | + $host->add_hook($host::HOOK_RENDER_ARTICLE, $this); |
|
| 16 | + $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this); |
|
| 17 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function get_js() { |
|
| 22 | - return file_get_contents(dirname(__FILE__)."/init.js"); |
|
| 23 | - } |
|
| 21 | + public function get_js() { |
|
| 22 | + return file_get_contents(dirname(__FILE__)."/init.js"); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function hook_render_article($article) { |
|
| 26 | - $tags = array_map("trim", explode(",", $this->host->get($this, "tags"))); |
|
| 27 | - $a_tags = array_map("trim", explode(",", $article["tag_cache"])); |
|
| 25 | + public function hook_render_article($article) { |
|
| 26 | + $tags = array_map("trim", explode(",", $this->host->get($this, "tags"))); |
|
| 27 | + $a_tags = array_map("trim", explode(",", $article["tag_cache"])); |
|
| 28 | 28 | |
| 29 | - if (count(array_intersect($tags, $a_tags)) > 0) { |
|
| 30 | - $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button> |
|
| 29 | + if (count(array_intersect($tags, $a_tags)) > 0) { |
|
| 30 | + $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button> |
|
| 31 | 31 | <div class='nswf content' style='display : none'>".$article["content"]."</div></div>"; |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return $article; |
|
| 35 | - } |
|
| 34 | + return $article; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function hook_render_article_cdm($article) { |
|
| 38 | - $tags = array_map("trim", explode(",", $this->host->get($this, "tags"))); |
|
| 39 | - $a_tags = array_map("trim", explode(",", $article["tag_cache"])); |
|
| 37 | + public function hook_render_article_cdm($article) { |
|
| 38 | + $tags = array_map("trim", explode(",", $this->host->get($this, "tags"))); |
|
| 39 | + $a_tags = array_map("trim", explode(",", $article["tag_cache"])); |
|
| 40 | 40 | |
| 41 | - if (count(array_intersect($tags, $a_tags)) > 0) { |
|
| 42 | - $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button> |
|
| 41 | + if (count(array_intersect($tags, $a_tags)) > 0) { |
|
| 42 | + $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button> |
|
| 43 | 43 | <div class='nswf content' style='display : none'>".$article["content"]."</div></div>"; |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return $article; |
|
| 47 | - } |
|
| 46 | + return $article; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function hook_prefs_tab($args) { |
|
| 50 | - if ($args != "prefPrefs") { |
|
| 51 | - return; |
|
| 52 | - } |
|
| 49 | + public function hook_prefs_tab($args) { |
|
| 50 | + if ($args != "prefPrefs") { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 54 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 55 | 55 | title=\"<i class='material-icons'>extension</i> ".__("NSFW Plugin")."\">"; |
| 56 | 56 | |
| 57 | - print "<br/>"; |
|
| 57 | + print "<br/>"; |
|
| 58 | 58 | |
| 59 | - $tags = $this->host->get($this, "tags"); |
|
| 59 | + $tags = $this->host->get($this, "tags"); |
|
| 60 | 60 | |
| 61 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
| 61 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
| 62 | 62 | |
| 63 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 63 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 64 | 64 | evt.preventDefault(); |
| 65 | 65 | if (this.validate()) { |
| 66 | 66 | new Ajax.Request('backend.php', { |
@@ -73,38 +73,38 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | </script>"; |
| 75 | 75 | |
| 76 | - print_hidden("op", "pluginhandler"); |
|
| 77 | - print_hidden("method", "save"); |
|
| 78 | - print_hidden("plugin", "nsfw"); |
|
| 76 | + print_hidden("op", "pluginhandler"); |
|
| 77 | + print_hidden("method", "save"); |
|
| 78 | + print_hidden("plugin", "nsfw"); |
|
| 79 | 79 | |
| 80 | - print "<table width=\"100%\" class=\"prefPrefsList\">"; |
|
| 80 | + print "<table width=\"100%\" class=\"prefPrefsList\">"; |
|
| 81 | 81 | |
| 82 | - print "<tr><td width=\"40%\">".__("Tags to consider NSFW (comma-separated)")."</td>"; |
|
| 83 | - print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"tags\" value=\"$tags\"></td></tr>"; |
|
| 82 | + print "<tr><td width=\"40%\">".__("Tags to consider NSFW (comma-separated)")."</td>"; |
|
| 83 | + print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"tags\" value=\"$tags\"></td></tr>"; |
|
| 84 | 84 | |
| 85 | - print "</table>"; |
|
| 85 | + print "</table>"; |
|
| 86 | 86 | |
| 87 | - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 88 | - __("Save")."</button>"; |
|
| 87 | + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 88 | + __("Save")."</button>"; |
|
| 89 | 89 | |
| 90 | - print "</form>"; |
|
| 90 | + print "</form>"; |
|
| 91 | 91 | |
| 92 | - print "</div>"; #pane |
|
| 93 | - } |
|
| 92 | + print "</div>"; #pane |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - public function save() { |
|
| 96 | - $tags = explode(",", $_POST["tags"]); |
|
| 97 | - $tags = array_map("trim", $tags); |
|
| 98 | - $tags = array_map("mb_strtolower", $tags); |
|
| 99 | - $tags = join(", ", $tags); |
|
| 95 | + public function save() { |
|
| 96 | + $tags = explode(",", $_POST["tags"]); |
|
| 97 | + $tags = array_map("trim", $tags); |
|
| 98 | + $tags = array_map("mb_strtolower", $tags); |
|
| 99 | + $tags = join(", ", $tags); |
|
| 100 | 100 | |
| 101 | - $this->host->set($this, "tags", $tags); |
|
| 101 | + $this->host->set($this, "tags", $tags); |
|
| 102 | 102 | |
| 103 | - echo __("Configuration saved."); |
|
| 104 | - } |
|
| 103 | + echo __("Configuration saved."); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - public function api_version() { |
|
| 107 | - return 2; |
|
| 108 | - } |
|
| 106 | + public function api_version() { |
|
| 107 | + return 2; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | } |
@@ -1,47 +1,47 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Fsckportal extends Plugin { |
| 3 | 3 | |
| 4 | - private $host; |
|
| 4 | + private $host; |
|
| 5 | 5 | |
| 6 | - public function about() { |
|
| 7 | - return array(1.0, |
|
| 8 | - "Remove feedsportal spamlinks from article content", |
|
| 9 | - "fox"); |
|
| 10 | - } |
|
| 6 | + public function about() { |
|
| 7 | + return array(1.0, |
|
| 8 | + "Remove feedsportal spamlinks from article content", |
|
| 9 | + "fox"); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function init($host) { |
|
| 13 | - $this->host = $host; |
|
| 12 | + public function init($host) { |
|
| 13 | + $this->host = $host; |
|
| 14 | 14 | |
| 15 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | - } |
|
| 15 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function hook_article_filter($article) { |
|
| 18 | + public function hook_article_filter($article) { |
|
| 19 | 19 | |
| 20 | - $doc = new DOMDocument(); |
|
| 20 | + $doc = new DOMDocument(); |
|
| 21 | 21 | |
| 22 | - @$doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 22 | + @$doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 23 | 23 | |
| 24 | - if ($doc) { |
|
| 25 | - $xpath = new DOMXPath($doc); |
|
| 26 | - $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 24 | + if ($doc) { |
|
| 25 | + $xpath = new DOMXPath($doc); |
|
| 26 | + $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 27 | 27 | |
| 28 | - foreach ($entries as $entry) { |
|
| 29 | - if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | - $entry->parentNode->removeChild($entry); |
|
| 31 | - } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | - $entry->parentNode->removeChild($entry); |
|
| 33 | - } |
|
| 34 | - } |
|
| 28 | + foreach ($entries as $entry) { |
|
| 29 | + if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | + $entry->parentNode->removeChild($entry); |
|
| 31 | + } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | + $entry->parentNode->removeChild($entry); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $article["content"] = $doc->saveHTML(); |
|
| 36 | + $article["content"] = $doc->saveHTML(); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $article; |
|
| 41 | - } |
|
| 40 | + return $article; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function api_version() { |
|
| 44 | - return 2; |
|
| 45 | - } |
|
| 43 | + public function api_version() { |
|
| 44 | + return 2; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -1,96 +1,96 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class MailTo extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Share article via email (using mailto: links, invoking your mail client)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Share article via email (using mailto: links, invoking your mail client)", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function init($host) { |
|
| 12 | - $this->host = $host; |
|
| 11 | + public function init($host) { |
|
| 12 | + $this->host = $host; |
|
| 13 | 13 | |
| 14 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 15 | - } |
|
| 14 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function get_js() { |
|
| 18 | - return file_get_contents(dirname(__FILE__)."/init.js"); |
|
| 19 | - } |
|
| 17 | + public function get_js() { |
|
| 18 | + return file_get_contents(dirname(__FILE__)."/init.js"); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function hook_article_button($line) { |
|
| 22 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 21 | + public function hook_article_button($line) { |
|
| 22 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 23 | 23 | onclick=\"Plugins.Mailto.send(".$line["id"].")\" |
| 24 | 24 | title='".__('Forward by email')."'>mail_outline</i>"; |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function emailArticle() { |
|
| 27 | + public function emailArticle() { |
|
| 28 | 28 | |
| 29 | - $ids = explode(",", $_REQUEST['param']); |
|
| 30 | - $ids_qmarks = arr_qmarks($ids); |
|
| 29 | + $ids = explode(",", $_REQUEST['param']); |
|
| 30 | + $ids_qmarks = arr_qmarks($ids); |
|
| 31 | 31 | |
| 32 | - require_once "lib/MiniTemplator.class.php"; |
|
| 32 | + require_once "lib/MiniTemplator.class.php"; |
|
| 33 | 33 | |
| 34 | - $tpl = new MiniTemplator; |
|
| 34 | + $tpl = new MiniTemplator; |
|
| 35 | 35 | |
| 36 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 36 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 37 | 37 | |
| 38 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 39 | - //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 40 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 38 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 39 | + //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 40 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
| 43 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
| 44 | 44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
| 45 | 45 | id IN ($ids_qmarks) AND owner_uid = ?"); |
| 46 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 46 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 47 | 47 | |
| 48 | - if (count($ids) > 1) { |
|
| 49 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
| 50 | - } else { |
|
| 51 | - $subject = ""; |
|
| 52 | - } |
|
| 48 | + if (count($ids) > 1) { |
|
| 49 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
| 50 | + } else { |
|
| 51 | + $subject = ""; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - while ($line = $sth->fetch()) { |
|
| 54 | + while ($line = $sth->fetch()) { |
|
| 55 | 55 | |
| 56 | - if (!$subject) { |
|
| 57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 58 | - } |
|
| 56 | + if (!$subject) { |
|
| 57 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 61 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 60 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 61 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 62 | 62 | |
| 63 | - $tpl->addBlock('article'); |
|
| 64 | - } |
|
| 63 | + $tpl->addBlock('article'); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $tpl->addBlock('email'); |
|
| 66 | + $tpl->addBlock('email'); |
|
| 67 | 67 | |
| 68 | - $content = ""; |
|
| 69 | - $tpl->generateOutputToString($content); |
|
| 68 | + $content = ""; |
|
| 69 | + $tpl->generateOutputToString($content); |
|
| 70 | 70 | |
| 71 | - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
| 72 | - "&body=".rawurlencode($content)); |
|
| 71 | + $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
| 72 | + "&body=".rawurlencode($content)); |
|
| 73 | 73 | |
| 74 | - print __("Clicking the following link to invoke your mail client:"); |
|
| 74 | + print __("Clicking the following link to invoke your mail client:"); |
|
| 75 | 75 | |
| 76 | - print "<div class='panel text-center'>"; |
|
| 77 | - print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
| 78 | - __("Forward selected article(s) by email.")."</a>"; |
|
| 79 | - print "</div>"; |
|
| 76 | + print "<div class='panel text-center'>"; |
|
| 77 | + print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
| 78 | + __("Forward selected article(s) by email.")."</a>"; |
|
| 79 | + print "</div>"; |
|
| 80 | 80 | |
| 81 | - print __("You should be able to edit the message before sending in your mail client."); |
|
| 81 | + print __("You should be able to edit the message before sending in your mail client."); |
|
| 82 | 82 | |
| 83 | - print "<p>"; |
|
| 83 | + print "<p>"; |
|
| 84 | 84 | |
| 85 | - print "<footer class='text-center'>"; |
|
| 86 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
| 87 | - print "</footer>"; |
|
| 85 | + print "<footer class='text-center'>"; |
|
| 86 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
| 87 | + print "</footer>"; |
|
| 88 | 88 | |
| 89 | - //return; |
|
| 90 | - } |
|
| 89 | + //return; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - public function api_version() { |
|
| 93 | - return 2; |
|
| 94 | - } |
|
| 92 | + public function api_version() { |
|
| 93 | + return 2; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | } |
@@ -1,92 +1,92 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Tumblr_1280 extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Replace Tumblr pictures and videos with largest size if available (requires CURL)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Replace Tumblr pictures and videos with largest size if available (requires CURL)", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function flags() { |
|
| 12 | - return array("needs_curl" => true); |
|
| 13 | - } |
|
| 11 | + public function flags() { |
|
| 12 | + return array("needs_curl" => true); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function init($host) { |
|
| 16 | - $this->host = $host; |
|
| 15 | + public function init($host) { |
|
| 16 | + $this->host = $host; |
|
| 17 | 17 | |
| 18 | - if (function_exists("curl_init")) { |
|
| 19 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 20 | - } |
|
| 21 | - } |
|
| 18 | + if (function_exists("curl_init")) { |
|
| 19 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function hook_article_filter($article) { |
|
| 23 | + public function hook_article_filter($article) { |
|
| 24 | 24 | |
| 25 | - if (!function_exists("curl_init") || ini_get("open_basedir")) { |
|
| 26 | - return $article; |
|
| 27 | - } |
|
| 25 | + if (!function_exists("curl_init") || ini_get("open_basedir")) { |
|
| 26 | + return $article; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $doc = new DOMDocument(); |
|
| 30 | - $doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 29 | + $doc = new DOMDocument(); |
|
| 30 | + $doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 31 | 31 | |
| 32 | - $found = false; |
|
| 32 | + $found = false; |
|
| 33 | 33 | |
| 34 | - if ($doc) { |
|
| 35 | - $xpath = new DOMXpath($doc); |
|
| 34 | + if ($doc) { |
|
| 35 | + $xpath = new DOMXpath($doc); |
|
| 36 | 36 | |
| 37 | - $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); |
|
| 37 | + $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); |
|
| 38 | 38 | |
| 39 | - foreach ($images as $img) { |
|
| 40 | - $src = $img->getAttribute("src"); |
|
| 39 | + foreach ($images as $img) { |
|
| 40 | + $src = $img->getAttribute("src"); |
|
| 41 | 41 | |
| 42 | - $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); |
|
| 42 | + $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); |
|
| 43 | 43 | |
| 44 | - if ($src != $test_src) { |
|
| 44 | + if ($src != $test_src) { |
|
| 45 | 45 | |
| 46 | - $ch = curl_init($test_src); |
|
| 47 | - curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 48 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 49 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 50 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 51 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 52 | - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
| 46 | + $ch = curl_init($test_src); |
|
| 47 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 48 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 49 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 50 | + curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 51 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 52 | + curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
| 53 | 53 | |
| 54 | - @$result = curl_exec($ch); |
|
| 55 | - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 54 | + @$result = curl_exec($ch); |
|
| 55 | + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 56 | 56 | |
| 57 | - if ($result && $http_code == 200) { |
|
| 58 | - $img->setAttribute("src", $test_src); |
|
| 59 | - $found = true; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 57 | + if ($result && $http_code == 200) { |
|
| 58 | + $img->setAttribute("src", $test_src); |
|
| 59 | + $found = true; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); |
|
| 64 | + $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); |
|
| 65 | 65 | |
| 66 | - foreach ($video_sources as $source) { |
|
| 67 | - $src = $source->getAttribute("src"); |
|
| 66 | + foreach ($video_sources as $source) { |
|
| 67 | + $src = $source->getAttribute("src"); |
|
| 68 | 68 | |
| 69 | - $new_src = preg_replace("/\/\d{3}$/", "", $src); |
|
| 69 | + $new_src = preg_replace("/\/\d{3}$/", "", $src); |
|
| 70 | 70 | |
| 71 | - if ($src != $new_src) { |
|
| 72 | - $source->setAttribute("src", $new_src); |
|
| 73 | - $found = true; |
|
| 74 | - } |
|
| 75 | - } |
|
| 71 | + if ($src != $new_src) { |
|
| 72 | + $source->setAttribute("src", $new_src); |
|
| 73 | + $found = true; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - if ($found) { |
|
| 78 | - $doc->removeChild($doc->firstChild); //remove doctype |
|
| 79 | - $article["content"] = $doc->saveHTML(); |
|
| 80 | - } |
|
| 81 | - } |
|
| 77 | + if ($found) { |
|
| 78 | + $doc->removeChild($doc->firstChild); //remove doctype |
|
| 79 | + $article["content"] = $doc->saveHTML(); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $article; |
|
| 83 | + return $article; |
|
| 84 | 84 | |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - public function api_version() { |
|
| 89 | - return 2; |
|
| 90 | - } |
|
| 88 | + public function api_version() { |
|
| 89 | + return 2; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | } |
@@ -1,24 +1,24 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class No_Title_Counters extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Remove counters from window title (prevents tab flashing on new articles)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Remove counters from window title (prevents tab flashing on new articles)", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function init($host) { |
|
| 12 | - $this->host = $host; |
|
| 11 | + public function init($host) { |
|
| 12 | + $this->host = $host; |
|
| 13 | 13 | |
| 14 | - } |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function get_js() { |
|
| 17 | - return file_get_contents(__DIR__."/init.js"); |
|
| 18 | - } |
|
| 16 | + public function get_js() { |
|
| 17 | + return file_get_contents(__DIR__."/init.js"); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function api_version() { |
|
| 21 | - return 2; |
|
| 22 | - } |
|
| 20 | + public function api_version() { |
|
| 21 | + return 2; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | } |
@@ -1,63 +1,63 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Auth_Internal extends Plugin implements IAuthModule { |
| 3 | 3 | |
| 4 | - private $host; |
|
| 4 | + private $host; |
|
| 5 | 5 | |
| 6 | - public function about() { |
|
| 7 | - return array(1.0, |
|
| 8 | - "Authenticates against internal tt-rss database", |
|
| 9 | - "fox", |
|
| 10 | - true); |
|
| 11 | - } |
|
| 6 | + public function about() { |
|
| 7 | + return array(1.0, |
|
| 8 | + "Authenticates against internal tt-rss database", |
|
| 9 | + "fox", |
|
| 10 | + true); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - /* @var PluginHost $host */ |
|
| 14 | - public function init($host) { |
|
| 15 | - $this->host = $host; |
|
| 16 | - $this->pdo = Db::pdo(); |
|
| 13 | + /* @var PluginHost $host */ |
|
| 14 | + public function init($host) { |
|
| 15 | + $this->host = $host; |
|
| 16 | + $this->pdo = Db::pdo(); |
|
| 17 | 17 | |
| 18 | - $host->add_hook($host::HOOK_AUTH_USER, $this); |
|
| 19 | - } |
|
| 18 | + $host->add_hook($host::HOOK_AUTH_USER, $this); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function authenticate($login, $password, $service = '') { |
|
| 21 | + public function authenticate($login, $password, $service = '') { |
|
| 22 | 22 | |
| 23 | - $pwd_hash1 = encrypt_password($password); |
|
| 24 | - $pwd_hash2 = encrypt_password($password, $login); |
|
| 25 | - $otp = $_REQUEST["otp"]; |
|
| 23 | + $pwd_hash1 = encrypt_password($password); |
|
| 24 | + $pwd_hash2 = encrypt_password($password, $login); |
|
| 25 | + $otp = $_REQUEST["otp"]; |
|
| 26 | 26 | |
| 27 | - if (get_schema_version() > 96) { |
|
| 27 | + if (get_schema_version() > 96) { |
|
| 28 | 28 | |
| 29 | - $sth = $this->pdo->prepare("SELECT otp_enabled,salt FROM ttrss_users WHERE |
|
| 29 | + $sth = $this->pdo->prepare("SELECT otp_enabled,salt FROM ttrss_users WHERE |
|
| 30 | 30 | login = ?"); |
| 31 | - $sth->execute([$login]); |
|
| 31 | + $sth->execute([$login]); |
|
| 32 | 32 | |
| 33 | - if ($row = $sth->fetch()) { |
|
| 34 | - $otp_enabled = $row['otp_enabled']; |
|
| 33 | + if ($row = $sth->fetch()) { |
|
| 34 | + $otp_enabled = $row['otp_enabled']; |
|
| 35 | 35 | |
| 36 | - if ($otp_enabled) { |
|
| 36 | + if ($otp_enabled) { |
|
| 37 | 37 | |
| 38 | - // only allow app password checking if OTP is enabled |
|
| 39 | - if ($service && get_schema_version() > 138) { |
|
| 40 | - return $this->check_app_password($login, $password, $service); |
|
| 41 | - } |
|
| 38 | + // only allow app password checking if OTP is enabled |
|
| 39 | + if ($service && get_schema_version() > 138) { |
|
| 40 | + return $this->check_app_password($login, $password, $service); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - if ($otp) { |
|
| 44 | - $base32 = new \OTPHP\Base32(); |
|
| 43 | + if ($otp) { |
|
| 44 | + $base32 = new \OTPHP\Base32(); |
|
| 45 | 45 | |
| 46 | - $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false); |
|
| 47 | - $secret_legacy = $base32->encode(sha1($row["salt"])); |
|
| 46 | + $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false); |
|
| 47 | + $secret_legacy = $base32->encode(sha1($row["salt"])); |
|
| 48 | 48 | |
| 49 | - $totp = new \OTPHP\TOTP($secret); |
|
| 50 | - $otp_check = $totp->now(); |
|
| 49 | + $totp = new \OTPHP\TOTP($secret); |
|
| 50 | + $otp_check = $totp->now(); |
|
| 51 | 51 | |
| 52 | - $totp_legacy = new \OTPHP\TOTP($secret_legacy); |
|
| 53 | - $otp_check_legacy = $totp_legacy->now(); |
|
| 52 | + $totp_legacy = new \OTPHP\TOTP($secret_legacy); |
|
| 53 | + $otp_check_legacy = $totp_legacy->now(); |
|
| 54 | 54 | |
| 55 | - if ($otp != $otp_check && $otp != $otp_check_legacy) { |
|
| 56 | - return false; |
|
| 57 | - } |
|
| 58 | - } else { |
|
| 59 | - $return = urlencode($_REQUEST["return"]); |
|
| 60 | - ?> |
|
| 55 | + if ($otp != $otp_check && $otp != $otp_check_legacy) { |
|
| 56 | + return false; |
|
| 57 | + } |
|
| 58 | + } else { |
|
| 59 | + $return = urlencode($_REQUEST["return"]); |
|
| 60 | + ?> |
|
| 61 | 61 | <!DOCTYPE html> |
| 62 | 62 | <html> |
| 63 | 63 | <head> |
@@ -87,209 +87,209 @@ discard block |
||
| 87 | 87 | document.forms[0].otp.focus(); |
| 88 | 88 | </script> |
| 89 | 89 | <?php |
| 90 | - exit; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 90 | + exit; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - // check app passwords first but allow regular password as a fallback for the time being |
|
| 97 | - // if OTP is not enabled |
|
| 96 | + // check app passwords first but allow regular password as a fallback for the time being |
|
| 97 | + // if OTP is not enabled |
|
| 98 | 98 | |
| 99 | - if ($service && get_schema_version() > 138) { |
|
| 100 | - $user_id = $this->check_app_password($login, $password, $service); |
|
| 99 | + if ($service && get_schema_version() > 138) { |
|
| 100 | + $user_id = $this->check_app_password($login, $password, $service); |
|
| 101 | 101 | |
| 102 | - if ($user_id) { |
|
| 103 | - return $user_id; |
|
| 104 | - } |
|
| 105 | - } |
|
| 102 | + if ($user_id) { |
|
| 103 | + return $user_id; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - if (get_schema_version() > 87) { |
|
| 107 | + if (get_schema_version() > 87) { |
|
| 108 | 108 | |
| 109 | - $sth = $this->pdo->prepare("SELECT salt FROM ttrss_users WHERE login = ?"); |
|
| 110 | - $sth->execute([$login]); |
|
| 109 | + $sth = $this->pdo->prepare("SELECT salt FROM ttrss_users WHERE login = ?"); |
|
| 110 | + $sth->execute([$login]); |
|
| 111 | 111 | |
| 112 | - if ($row = $sth->fetch()) { |
|
| 113 | - $salt = $row['salt']; |
|
| 112 | + if ($row = $sth->fetch()) { |
|
| 113 | + $salt = $row['salt']; |
|
| 114 | 114 | |
| 115 | - if ($salt == "") { |
|
| 115 | + if ($salt == "") { |
|
| 116 | 116 | |
| 117 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 117 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 118 | 118 | login = ? AND (pwd_hash = ? OR pwd_hash = ?)"); |
| 119 | 119 | |
| 120 | - $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 120 | + $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 121 | 121 | |
| 122 | - // verify and upgrade password to new salt base |
|
| 122 | + // verify and upgrade password to new salt base |
|
| 123 | 123 | |
| 124 | - if ($row = $sth->fetch()) { |
|
| 125 | - // upgrade password to MODE2 |
|
| 124 | + if ($row = $sth->fetch()) { |
|
| 125 | + // upgrade password to MODE2 |
|
| 126 | 126 | |
| 127 | - $user_id = $row['id']; |
|
| 127 | + $user_id = $row['id']; |
|
| 128 | 128 | |
| 129 | - $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 130 | - $pwd_hash = encrypt_password($password, $salt, true); |
|
| 129 | + $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 130 | + $pwd_hash = encrypt_password($password, $salt, true); |
|
| 131 | 131 | |
| 132 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 132 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 133 | 133 | pwd_hash = ?, salt = ? WHERE login = ?"); |
| 134 | 134 | |
| 135 | - $sth->execute([$pwd_hash, $salt, $login]); |
|
| 135 | + $sth->execute([$pwd_hash, $salt, $login]); |
|
| 136 | 136 | |
| 137 | - return $user_id; |
|
| 137 | + return $user_id; |
|
| 138 | 138 | |
| 139 | - } else { |
|
| 140 | - return false; |
|
| 141 | - } |
|
| 139 | + } else { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - } else { |
|
| 144 | - $pwd_hash = encrypt_password($password, $salt, true); |
|
| 143 | + } else { |
|
| 144 | + $pwd_hash = encrypt_password($password, $salt, true); |
|
| 145 | 145 | |
| 146 | - $sth = $this->pdo->prepare("SELECT id |
|
| 146 | + $sth = $this->pdo->prepare("SELECT id |
|
| 147 | 147 | FROM ttrss_users WHERE |
| 148 | 148 | login = ? AND pwd_hash = ?"); |
| 149 | - $sth->execute([$login, $pwd_hash]); |
|
| 149 | + $sth->execute([$login, $pwd_hash]); |
|
| 150 | 150 | |
| 151 | - if ($row = $sth->fetch()) { |
|
| 152 | - return $row['id']; |
|
| 153 | - } |
|
| 154 | - } |
|
| 151 | + if ($row = $sth->fetch()) { |
|
| 152 | + return $row['id']; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - } else { |
|
| 157 | - $sth = $this->pdo->prepare("SELECT id |
|
| 156 | + } else { |
|
| 157 | + $sth = $this->pdo->prepare("SELECT id |
|
| 158 | 158 | FROM ttrss_users WHERE |
| 159 | 159 | login = ? AND (pwd_hash = ? OR pwd_hash = ?)"); |
| 160 | 160 | |
| 161 | - $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 161 | + $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 162 | 162 | |
| 163 | - if ($row = $sth->fetch()) { |
|
| 164 | - return $row['id']; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } else { |
|
| 168 | - $sth = $this->pdo->prepare("SELECT id |
|
| 163 | + if ($row = $sth->fetch()) { |
|
| 164 | + return $row['id']; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } else { |
|
| 168 | + $sth = $this->pdo->prepare("SELECT id |
|
| 169 | 169 | FROM ttrss_users WHERE |
| 170 | 170 | login = ? AND (pwd_hash = ? OR pwd_hash = ?)"); |
| 171 | 171 | |
| 172 | - $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 172 | + $sth->execute([$login, $pwd_hash1, $pwd_hash2]); |
|
| 173 | 173 | |
| 174 | - if ($row = $sth->fetch()) { |
|
| 175 | - return $row['id']; |
|
| 176 | - } |
|
| 177 | - } |
|
| 174 | + if ($row = $sth->fetch()) { |
|
| 175 | + return $row['id']; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - return false; |
|
| 180 | - } |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - public function check_password($owner_uid, $password) { |
|
| 182 | + public function check_password($owner_uid, $password) { |
|
| 183 | 183 | |
| 184 | - $sth = $this->pdo->prepare("SELECT salt,login,otp_enabled FROM ttrss_users WHERE |
|
| 184 | + $sth = $this->pdo->prepare("SELECT salt,login,otp_enabled FROM ttrss_users WHERE |
|
| 185 | 185 | id = ?"); |
| 186 | - $sth->execute([$owner_uid]); |
|
| 186 | + $sth->execute([$owner_uid]); |
|
| 187 | 187 | |
| 188 | - if ($row = $sth->fetch()) { |
|
| 188 | + if ($row = $sth->fetch()) { |
|
| 189 | 189 | |
| 190 | - $salt = $row['salt']; |
|
| 191 | - $login = $row['login']; |
|
| 190 | + $salt = $row['salt']; |
|
| 191 | + $login = $row['login']; |
|
| 192 | 192 | |
| 193 | - if (!$salt) { |
|
| 194 | - $password_hash1 = encrypt_password($password); |
|
| 195 | - $password_hash2 = encrypt_password($password, $login); |
|
| 193 | + if (!$salt) { |
|
| 194 | + $password_hash1 = encrypt_password($password); |
|
| 195 | + $password_hash2 = encrypt_password($password, $login); |
|
| 196 | 196 | |
| 197 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 197 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 198 | 198 | id = ? AND (pwd_hash = ? OR pwd_hash = ?)"); |
| 199 | 199 | |
| 200 | - $sth->execute([$owner_uid, $password_hash1, $password_hash2]); |
|
| 200 | + $sth->execute([$owner_uid, $password_hash1, $password_hash2]); |
|
| 201 | 201 | |
| 202 | - return $sth->fetch(); |
|
| 202 | + return $sth->fetch(); |
|
| 203 | 203 | |
| 204 | - } else { |
|
| 205 | - $password_hash = encrypt_password($password, $salt, true); |
|
| 204 | + } else { |
|
| 205 | + $password_hash = encrypt_password($password, $salt, true); |
|
| 206 | 206 | |
| 207 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 207 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE |
|
| 208 | 208 | id = ? AND pwd_hash = ?"); |
| 209 | 209 | |
| 210 | - $sth->execute([$owner_uid, $password_hash]); |
|
| 210 | + $sth->execute([$owner_uid, $password_hash]); |
|
| 211 | 211 | |
| 212 | - return $sth->fetch(); |
|
| 213 | - } |
|
| 214 | - } |
|
| 212 | + return $sth->fetch(); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - return false; |
|
| 217 | - } |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - public function change_password($owner_uid, $old_password, $new_password) { |
|
| 219 | + public function change_password($owner_uid, $old_password, $new_password) { |
|
| 220 | 220 | |
| 221 | - if ($this->check_password($owner_uid, $old_password)) { |
|
| 221 | + if ($this->check_password($owner_uid, $old_password)) { |
|
| 222 | 222 | |
| 223 | - $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 224 | - $new_password_hash = encrypt_password($new_password, $new_salt, true); |
|
| 223 | + $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 224 | + $new_password_hash = encrypt_password($new_password, $new_salt, true); |
|
| 225 | 225 | |
| 226 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 226 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
| 227 | 227 | pwd_hash = ?, salt = ?, otp_enabled = false |
| 228 | 228 | WHERE id = ?"); |
| 229 | - $sth->execute([$new_password_hash, $new_salt, $owner_uid]); |
|
| 229 | + $sth->execute([$new_password_hash, $new_salt, $owner_uid]); |
|
| 230 | 230 | |
| 231 | - $_SESSION["pwd_hash"] = $new_password_hash; |
|
| 231 | + $_SESSION["pwd_hash"] = $new_password_hash; |
|
| 232 | 232 | |
| 233 | - $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?"); |
|
| 234 | - $sth->execute([$owner_uid]); |
|
| 233 | + $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?"); |
|
| 234 | + $sth->execute([$owner_uid]); |
|
| 235 | 235 | |
| 236 | - if ($row = $sth->fetch()) { |
|
| 237 | - $mailer = new Mailer(); |
|
| 236 | + if ($row = $sth->fetch()) { |
|
| 237 | + $mailer = new Mailer(); |
|
| 238 | 238 | |
| 239 | - require_once "lib/MiniTemplator.class.php"; |
|
| 239 | + require_once "lib/MiniTemplator.class.php"; |
|
| 240 | 240 | |
| 241 | - $tpl = new MiniTemplator; |
|
| 241 | + $tpl = new MiniTemplator; |
|
| 242 | 242 | |
| 243 | - $tpl->readTemplateFromFile("templates/password_change_template.txt"); |
|
| 243 | + $tpl->readTemplateFromFile("templates/password_change_template.txt"); |
|
| 244 | 244 | |
| 245 | - $tpl->setVariable('LOGIN', $row["login"]); |
|
| 246 | - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 245 | + $tpl->setVariable('LOGIN', $row["login"]); |
|
| 246 | + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
| 247 | 247 | |
| 248 | - $tpl->addBlock('message'); |
|
| 248 | + $tpl->addBlock('message'); |
|
| 249 | 249 | |
| 250 | - $tpl->generateOutputToString($message); |
|
| 250 | + $tpl->generateOutputToString($message); |
|
| 251 | 251 | |
| 252 | - $mailer->mail(["to_name" => $row["login"], |
|
| 253 | - "to_address" => $row["email"], |
|
| 254 | - "subject" => "[tt-rss] Password change notification", |
|
| 255 | - "message" => $message]); |
|
| 252 | + $mailer->mail(["to_name" => $row["login"], |
|
| 253 | + "to_address" => $row["email"], |
|
| 254 | + "subject" => "[tt-rss] Password change notification", |
|
| 255 | + "message" => $message]); |
|
| 256 | 256 | |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - return __("Password has been changed."); |
|
| 260 | - } else { |
|
| 261 | - return "ERROR: ".__('Old password is incorrect.'); |
|
| 262 | - } |
|
| 263 | - } |
|
| 259 | + return __("Password has been changed."); |
|
| 260 | + } else { |
|
| 261 | + return "ERROR: ".__('Old password is incorrect.'); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - private function check_app_password($login, $password, $service) { |
|
| 266 | - $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid |
|
| 265 | + private function check_app_password($login, $password, $service) { |
|
| 266 | + $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid |
|
| 267 | 267 | FROM ttrss_app_passwords p, ttrss_users u |
| 268 | 268 | WHERE p.owner_uid = u.id AND u.login = ? AND service = ?"); |
| 269 | - $sth->execute([$login, $service]); |
|
| 269 | + $sth->execute([$login, $service]); |
|
| 270 | 270 | |
| 271 | - while ($row = $sth->fetch()) { |
|
| 272 | - list ($algo, $hash, $salt) = explode(":", $row["pwd_hash"]); |
|
| 271 | + while ($row = $sth->fetch()) { |
|
| 272 | + list ($algo, $hash, $salt) = explode(":", $row["pwd_hash"]); |
|
| 273 | 273 | |
| 274 | - if ($algo == "SSHA-512") { |
|
| 275 | - $test_hash = hash('sha512', $salt.$password); |
|
| 274 | + if ($algo == "SSHA-512") { |
|
| 275 | + $test_hash = hash('sha512', $salt.$password); |
|
| 276 | 276 | |
| 277 | - if ($test_hash == $hash) { |
|
| 278 | - $usth = $this->pdo->prepare("UPDATE ttrss_app_passwords SET last_used = NOW() WHERE id = ?"); |
|
| 279 | - $usth->execute([$row['id']]); |
|
| 277 | + if ($test_hash == $hash) { |
|
| 278 | + $usth = $this->pdo->prepare("UPDATE ttrss_app_passwords SET last_used = NOW() WHERE id = ?"); |
|
| 279 | + $usth->execute([$row['id']]); |
|
| 280 | 280 | |
| 281 | - return $row['uid']; |
|
| 282 | - } |
|
| 283 | - } else { |
|
| 284 | - user_error("Got unknown algo of app password for user $login: $algo"); |
|
| 285 | - } |
|
| 286 | - } |
|
| 281 | + return $row['uid']; |
|
| 282 | + } |
|
| 283 | + } else { |
|
| 284 | + user_error("Got unknown algo of app password for user $login: $algo"); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - return false; |
|
| 289 | - } |
|
| 288 | + return false; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - public function api_version() { |
|
| 292 | - return 2; |
|
| 293 | - } |
|
| 291 | + public function api_version() { |
|
| 292 | + return 2; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | 295 | } |