@@ -1,23 +1,23 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Zz_NoAutoPlay extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Don't autoplay HTML5 videos", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Don't autoplay 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,24 +1,24 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class No_URL_Hashes extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Disable URL hash usage (e.g. #f=10, etc)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Disable URL hash usage (e.g. #f=10, etc)", |
|
| 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,45 +1,45 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Mail extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | 6 | |
| 7 | - public function about() { |
|
| 8 | - return array(1.0, |
|
| 9 | - "Share article via email", |
|
| 10 | - "fox"); |
|
| 11 | - } |
|
| 7 | + public function about() { |
|
| 8 | + return array(1.0, |
|
| 9 | + "Share article via email", |
|
| 10 | + "fox"); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function init($host) { |
|
| 14 | - $this->host = $host; |
|
| 13 | + public function init($host) { |
|
| 14 | + $this->host = $host; |
|
| 15 | 15 | |
| 16 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 17 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 18 | - } |
|
| 16 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 17 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function get_js() { |
|
| 21 | - return file_get_contents(dirname(__FILE__) . "/mail.js"); |
|
| 22 | - } |
|
| 20 | + public function get_js() { |
|
| 21 | + return file_get_contents(dirname(__FILE__) . "/mail.js"); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function save() { |
|
| 25 | - $addresslist = $_POST["addresslist"]; |
|
| 24 | + public function save() { |
|
| 25 | + $addresslist = $_POST["addresslist"]; |
|
| 26 | 26 | |
| 27 | - $this->host->set($this, "addresslist", $addresslist); |
|
| 27 | + $this->host->set($this, "addresslist", $addresslist); |
|
| 28 | 28 | |
| 29 | - echo __("Mail addresses saved."); |
|
| 30 | - } |
|
| 29 | + echo __("Mail addresses saved."); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function hook_prefs_tab($args) { |
|
| 33 | - if ($args != "prefPrefs") return; |
|
| 32 | + public function hook_prefs_tab($args) { |
|
| 33 | + if ($args != "prefPrefs") return; |
|
| 34 | 34 | |
| 35 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 35 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 36 | 36 | title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">"; |
| 37 | 37 | |
| 38 | - print "<p>" . __("You can set predefined email addressed here (comma-separated list):") . "</p>"; |
|
| 38 | + print "<p>" . __("You can set predefined email addressed here (comma-separated list):") . "</p>"; |
|
| 39 | 39 | |
| 40 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
| 40 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
| 41 | 41 | |
| 42 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 42 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 43 | 43 | evt.preventDefault(); |
| 44 | 44 | if (this.validate()) { |
| 45 | 45 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -53,138 +53,138 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | </script>"; |
| 55 | 55 | |
| 56 | - print_hidden("op", "pluginhandler"); |
|
| 57 | - print_hidden("method", "save"); |
|
| 58 | - print_hidden("plugin", "mail"); |
|
| 56 | + print_hidden("op", "pluginhandler"); |
|
| 57 | + print_hidden("method", "save"); |
|
| 58 | + print_hidden("plugin", "mail"); |
|
| 59 | 59 | |
| 60 | - $addresslist = $this->host->get($this, "addresslist"); |
|
| 60 | + $addresslist = $this->host->get($this, "addresslist"); |
|
| 61 | 61 | |
| 62 | - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
| 62 | + print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
| 63 | 63 | name='addresslist'>$addresslist</textarea>"; |
| 64 | 64 | |
| 65 | - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 66 | - __("Save")."</button>"; |
|
| 65 | + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 66 | + __("Save")."</button>"; |
|
| 67 | 67 | |
| 68 | - print "</form>"; |
|
| 68 | + print "</form>"; |
|
| 69 | 69 | |
| 70 | - print "</div>"; |
|
| 71 | - } |
|
| 70 | + print "</div>"; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function hook_article_button($line) { |
|
| 74 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 73 | + public function hook_article_button($line) { |
|
| 74 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 75 | 75 | onclick=\"Plugins.Mail.send(".$line["id"].")\" |
| 76 | 76 | title='".__('Forward by email')."'>mail</i>"; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - public function emailArticle() { |
|
| 79 | + public function emailArticle() { |
|
| 80 | 80 | |
| 81 | - $ids = explode(",", $_REQUEST['param']); |
|
| 82 | - $ids_qmarks = arr_qmarks($ids); |
|
| 81 | + $ids = explode(",", $_REQUEST['param']); |
|
| 82 | + $ids_qmarks = arr_qmarks($ids); |
|
| 83 | 83 | |
| 84 | - print_hidden("op", "pluginhandler"); |
|
| 85 | - print_hidden("plugin", "mail"); |
|
| 86 | - print_hidden("method", "sendEmail"); |
|
| 84 | + print_hidden("op", "pluginhandler"); |
|
| 85 | + print_hidden("plugin", "mail"); |
|
| 86 | + print_hidden("method", "sendEmail"); |
|
| 87 | 87 | |
| 88 | - $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
| 88 | + $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
| 89 | 89 | id = ?"); |
| 90 | - $sth->execute([$_SESSION['uid']]); |
|
| 90 | + $sth->execute([$_SESSION['uid']]); |
|
| 91 | 91 | |
| 92 | - if ($row = $sth->fetch()) { |
|
| 93 | - $user_email = htmlspecialchars($row['email']); |
|
| 94 | - $user_name = htmlspecialchars($row['full_name']); |
|
| 95 | - } |
|
| 92 | + if ($row = $sth->fetch()) { |
|
| 93 | + $user_email = htmlspecialchars($row['email']); |
|
| 94 | + $user_name = htmlspecialchars($row['full_name']); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - if (!$user_name) $user_name = $_SESSION['name']; |
|
| 97 | + if (!$user_name) $user_name = $_SESSION['name']; |
|
| 98 | 98 | |
| 99 | - print_hidden("from_email", "$user_email"); |
|
| 100 | - print_hidden("from_name", "$user_name"); |
|
| 99 | + print_hidden("from_email", "$user_email"); |
|
| 100 | + print_hidden("from_name", "$user_name"); |
|
| 101 | 101 | |
| 102 | - require_once "lib/MiniTemplator.class.php"; |
|
| 102 | + require_once "lib/MiniTemplator.class.php"; |
|
| 103 | 103 | |
| 104 | - $tpl = new MiniTemplator; |
|
| 104 | + $tpl = new MiniTemplator; |
|
| 105 | 105 | |
| 106 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 106 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 107 | 107 | |
| 108 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 109 | - $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 110 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 108 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 109 | + $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 110 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 111 | 111 | |
| 112 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
| 112 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
| 113 | 113 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
| 114 | 114 | id IN ($ids_qmarks) AND owner_uid = ?"); |
| 115 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 115 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 116 | 116 | |
| 117 | - if (count($ids) > 1) { |
|
| 118 | - $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
| 119 | - } |
|
| 117 | + if (count($ids) > 1) { |
|
| 118 | + $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - while ($line = $sth->fetch()) { |
|
| 121 | + while ($line = $sth->fetch()) { |
|
| 122 | 122 | |
| 123 | - if (!$subject) |
|
| 124 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 123 | + if (!$subject) |
|
| 124 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 125 | 125 | |
| 126 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 127 | - $tnote = strip_tags($line["note"]); |
|
| 128 | - if( $tnote != ''){ |
|
| 129 | - $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
| 130 | - $tpl->addBlock('note'); |
|
| 131 | - } |
|
| 132 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 126 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 127 | + $tnote = strip_tags($line["note"]); |
|
| 128 | + if( $tnote != ''){ |
|
| 129 | + $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
| 130 | + $tpl->addBlock('note'); |
|
| 131 | + } |
|
| 132 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 133 | 133 | |
| 134 | - $tpl->addBlock('article'); |
|
| 135 | - } |
|
| 134 | + $tpl->addBlock('article'); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - $tpl->addBlock('email'); |
|
| 137 | + $tpl->addBlock('email'); |
|
| 138 | 138 | |
| 139 | - $content = ""; |
|
| 140 | - $tpl->generateOutputToString($content); |
|
| 139 | + $content = ""; |
|
| 140 | + $tpl->generateOutputToString($content); |
|
| 141 | 141 | |
| 142 | - print "<table width='100%'><tr><td>"; |
|
| 142 | + print "<table width='100%'><tr><td>"; |
|
| 143 | 143 | |
| 144 | - $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
| 144 | + $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
| 145 | 145 | |
| 146 | - print __('To:'); |
|
| 146 | + print __('To:'); |
|
| 147 | 147 | |
| 148 | - print "</td><td>"; |
|
| 148 | + print "</td><td>"; |
|
| 149 | 149 | |
| 150 | 150 | /* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" |
| 151 | 151 | style=\"width : 30em;\" |
| 152 | 152 | name=\"destination\" id=\"emailArticleDlg_destination\">"; */ |
| 153 | 153 | |
| 154 | - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
| 154 | + print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
| 155 | 155 | |
| 156 | 156 | /* print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\" |
| 157 | 157 | style=\"z-index: 30; display : none\"></div>"; */ |
| 158 | 158 | |
| 159 | - print "</td></tr><tr><td>"; |
|
| 159 | + print "</td></tr><tr><td>"; |
|
| 160 | 160 | |
| 161 | - print __('Subject:'); |
|
| 161 | + print __('Subject:'); |
|
| 162 | 162 | |
| 163 | - print "</td><td>"; |
|
| 163 | + print "</td><td>"; |
|
| 164 | 164 | |
| 165 | - print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
| 165 | + print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
| 166 | 166 | style='width : 30em;' name='subject' value=\"$subject\" id='subject'>"; |
| 167 | 167 | |
| 168 | - print "</td></tr>"; |
|
| 168 | + print "</td></tr>"; |
|
| 169 | 169 | |
| 170 | - print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
| 170 | + print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
| 171 | 171 | style='height : 200px; font-size : 12px; width : 98%' rows=\"20\" |
| 172 | 172 | name='content'>$content</textarea>"; |
| 173 | 173 | |
| 174 | - print "</td></tr></table>"; |
|
| 174 | + print "</td></tr></table>"; |
|
| 175 | 175 | |
| 176 | - print "<footer>"; |
|
| 177 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
| 178 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
| 179 | - print "</footer>"; |
|
| 176 | + print "<footer>"; |
|
| 177 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
| 178 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
| 179 | + print "</footer>"; |
|
| 180 | 180 | |
| 181 | - //return; |
|
| 182 | - } |
|
| 181 | + //return; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - public function sendEmail() { |
|
| 185 | - $reply = array(); |
|
| 184 | + public function sendEmail() { |
|
| 185 | + $reply = array(); |
|
| 186 | 186 | |
| 187 | - /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
| 187 | + /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
| 188 | 188 | strip_tags($_REQUEST['from_name'])); |
| 189 | 189 | //$mail->AddAddress($_REQUEST['destination']); |
| 190 | 190 | $addresses = explode(';', $_REQUEST['destination']); |
@@ -197,29 +197,29 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $rc = $mail->Send(); */ |
| 199 | 199 | |
| 200 | - $to = $_REQUEST["destination"]; |
|
| 201 | - $subject = strip_tags($_REQUEST["subject"]); |
|
| 202 | - $message = strip_tags($_REQUEST["content"]); |
|
| 203 | - $from = strip_tags($_REQUEST["from_email"]); |
|
| 200 | + $to = $_REQUEST["destination"]; |
|
| 201 | + $subject = strip_tags($_REQUEST["subject"]); |
|
| 202 | + $message = strip_tags($_REQUEST["content"]); |
|
| 203 | + $from = strip_tags($_REQUEST["from_email"]); |
|
| 204 | 204 | |
| 205 | - $mailer = new Mailer(); |
|
| 205 | + $mailer = new Mailer(); |
|
| 206 | 206 | |
| 207 | - $rc = $mailer->mail(["to_address" => $to, |
|
| 208 | - "headers" => ["Reply-To: $from"], |
|
| 209 | - "subject" => $subject, |
|
| 210 | - "message" => $message]); |
|
| 207 | + $rc = $mailer->mail(["to_address" => $to, |
|
| 208 | + "headers" => ["Reply-To: $from"], |
|
| 209 | + "subject" => $subject, |
|
| 210 | + "message" => $message]); |
|
| 211 | 211 | |
| 212 | - if (!$rc) { |
|
| 213 | - $reply['error'] = $mailer->error(); |
|
| 214 | - } else { |
|
| 215 | - //save_email_address($destination); |
|
| 216 | - $reply['message'] = "UPDATE_COUNTERS"; |
|
| 217 | - } |
|
| 212 | + if (!$rc) { |
|
| 213 | + $reply['error'] = $mailer->error(); |
|
| 214 | + } else { |
|
| 215 | + //save_email_address($destination); |
|
| 216 | + $reply['message'] = "UPDATE_COUNTERS"; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - print json_encode($reply); |
|
| 220 | - } |
|
| 219 | + print json_encode($reply); |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /* function completeEmails() { |
|
| 222 | + /* function completeEmails() { |
|
| 223 | 223 | $search = $_REQUEST["search"]; |
| 224 | 224 | |
| 225 | 225 | print "<ul>"; |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | print "</ul>"; |
| 234 | 234 | } */ |
| 235 | 235 | |
| 236 | - public function api_version() { |
|
| 237 | - return 2; |
|
| 238 | - } |
|
| 236 | + public function api_version() { |
|
| 237 | + return 2; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | abstract class Af_ComicFilter { |
| 3 | - public abstract function supported(); |
|
| 4 | - public abstract function process(&$article); |
|
| 3 | + public abstract function supported(); |
|
| 4 | + public abstract function process(&$article); |
|
| 5 | 5 | } |
| 6 | 6 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Template extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Example"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Example"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - //$owner_uid = $article["owner_uid"]; |
|
| 8 | + public function process(&$article) { |
|
| 9 | + //$owner_uid = $article["owner_uid"]; |
|
| 10 | 10 | |
| 11 | - return false; |
|
| 12 | - } |
|
| 11 | + return false; |
|
| 12 | + } |
|
| 13 | 13 | } |
@@ -1,219 +1,219 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Proxy_Http extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | 6 | |
| 7 | - /* @var DiskCache $cache */ |
|
| 8 | - private $cache; |
|
| 7 | + /* @var DiskCache $cache */ |
|
| 8 | + private $cache; |
|
| 9 | 9 | |
| 10 | - public function about() { |
|
| 11 | - return array(1.0, |
|
| 12 | - "Loads media served over plain HTTP via built-in secure proxy", |
|
| 13 | - "fox"); |
|
| 14 | - } |
|
| 10 | + public function about() { |
|
| 11 | + return array(1.0, |
|
| 12 | + "Loads media served over plain HTTP via built-in secure proxy", |
|
| 13 | + "fox"); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - private $ssl_known_whitelist = "imgur.com gfycat.com i.reddituploads.com pbs.twimg.com i.redd.it i.sli.mg media.tumblr.com"; |
|
| 16 | + private $ssl_known_whitelist = "imgur.com gfycat.com i.reddituploads.com pbs.twimg.com i.redd.it i.sli.mg media.tumblr.com"; |
|
| 17 | 17 | |
| 18 | - public function is_public_method($method) { |
|
| 19 | - return $method === "imgproxy"; |
|
| 20 | - } |
|
| 18 | + public function is_public_method($method) { |
|
| 19 | + return $method === "imgproxy"; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function init($host) { |
|
| 23 | - $this->host = $host; |
|
| 24 | - $this->cache = new DiskCache("images"); |
|
| 22 | + public function init($host) { |
|
| 23 | + $this->host = $host; |
|
| 24 | + $this->cache = new DiskCache("images"); |
|
| 25 | 25 | |
| 26 | - $host->add_hook($host::HOOK_RENDER_ARTICLE, $this, 150); |
|
| 27 | - $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this, 150); |
|
| 28 | - $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 26 | + $host->add_hook($host::HOOK_RENDER_ARTICLE, $this, 150); |
|
| 27 | + $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this, 150); |
|
| 28 | + $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 29 | 29 | |
| 30 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 31 | - } |
|
| 30 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function hook_enclosure_entry($enc) { |
|
| 34 | - if (preg_match("/image/", $enc["content_type"])) { |
|
| 35 | - $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 33 | + public function hook_enclosure_entry($enc) { |
|
| 34 | + if (preg_match("/image/", $enc["content_type"])) { |
|
| 35 | + $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 36 | 36 | |
| 37 | - $enc["content_url"] = $this->rewrite_url_if_needed($enc["content_url"], $proxy_all); |
|
| 38 | - } |
|
| 37 | + $enc["content_url"] = $this->rewrite_url_if_needed($enc["content_url"], $proxy_all); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $enc; |
|
| 41 | - } |
|
| 40 | + return $enc; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function hook_render_article($article) { |
|
| 44 | - return $this->hook_render_article_cdm($article); |
|
| 45 | - } |
|
| 43 | + public function hook_render_article($article) { |
|
| 44 | + return $this->hook_render_article_cdm($article); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function imgproxy() { |
|
| 47 | + public function imgproxy() { |
|
| 48 | 48 | |
| 49 | - $url = rewrite_relative_url(get_self_url_prefix(), $_REQUEST["url"]); |
|
| 49 | + $url = rewrite_relative_url(get_self_url_prefix(), $_REQUEST["url"]); |
|
| 50 | 50 | |
| 51 | - // called without user context, let's just redirect to original URL |
|
| 52 | - if (!$_SESSION["uid"]) { |
|
| 53 | - header("Location: $url"); |
|
| 54 | - return; |
|
| 55 | - } |
|
| 51 | + // called without user context, let's just redirect to original URL |
|
| 52 | + if (!$_SESSION["uid"]) { |
|
| 53 | + header("Location: $url"); |
|
| 54 | + return; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $local_filename = sha1($url); |
|
| 57 | + $local_filename = sha1($url); |
|
| 58 | 58 | |
| 59 | - if ($this->cache->exists($local_filename)) { |
|
| 60 | - header("Location: " . $this->cache->getUrl($local_filename)); |
|
| 61 | - return; |
|
| 62 | - //$this->cache->send($local_filename); |
|
| 63 | - } else { |
|
| 64 | - $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 59 | + if ($this->cache->exists($local_filename)) { |
|
| 60 | + header("Location: " . $this->cache->getUrl($local_filename)); |
|
| 61 | + return; |
|
| 62 | + //$this->cache->send($local_filename); |
|
| 63 | + } else { |
|
| 64 | + $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 65 | 65 | |
| 66 | - if ($data) { |
|
| 66 | + if ($data) { |
|
| 67 | 67 | |
| 68 | - $disable_cache = $this->host->get($this, "disable_cache"); |
|
| 68 | + $disable_cache = $this->host->get($this, "disable_cache"); |
|
| 69 | 69 | |
| 70 | - if (!$disable_cache) { |
|
| 71 | - if ($this->cache->put($local_filename, $data)) { |
|
| 72 | - header("Location: " . $this->cache->getUrl($local_filename)); |
|
| 73 | - return; |
|
| 74 | - } |
|
| 75 | - } |
|
| 70 | + if (!$disable_cache) { |
|
| 71 | + if ($this->cache->put($local_filename, $data)) { |
|
| 72 | + header("Location: " . $this->cache->getUrl($local_filename)); |
|
| 73 | + return; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - print $data; |
|
| 78 | - } else { |
|
| 79 | - global $fetch_last_error; |
|
| 80 | - global $fetch_last_error_code; |
|
| 81 | - global $fetch_last_error_content; |
|
| 77 | + print $data; |
|
| 78 | + } else { |
|
| 79 | + global $fetch_last_error; |
|
| 80 | + global $fetch_last_error_code; |
|
| 81 | + global $fetch_last_error_content; |
|
| 82 | 82 | |
| 83 | - if (function_exists("imagecreate") && !isset($_REQUEST["text"])) { |
|
| 84 | - $img = imagecreate(450, 75); |
|
| 83 | + if (function_exists("imagecreate") && !isset($_REQUEST["text"])) { |
|
| 84 | + $img = imagecreate(450, 75); |
|
| 85 | 85 | |
| 86 | - /*$bg =*/ imagecolorallocate($img, 255, 255, 255); |
|
| 87 | - $textcolor = imagecolorallocate($img, 255, 0, 0); |
|
| 86 | + /*$bg =*/ imagecolorallocate($img, 255, 255, 255); |
|
| 87 | + $textcolor = imagecolorallocate($img, 255, 0, 0); |
|
| 88 | 88 | |
| 89 | - imagerectangle($img, 0, 0, 450-1, 75-1, $textcolor); |
|
| 89 | + imagerectangle($img, 0, 0, 450-1, 75-1, $textcolor); |
|
| 90 | 90 | |
| 91 | - imagestring($img, 5, 5, 5, "Proxy request failed", $textcolor); |
|
| 92 | - imagestring($img, 5, 5, 30, truncate_middle($url, 46, "..."), $textcolor); |
|
| 93 | - imagestring($img, 5, 5, 55, "HTTP Code: $fetch_last_error_code", $textcolor); |
|
| 91 | + imagestring($img, 5, 5, 5, "Proxy request failed", $textcolor); |
|
| 92 | + imagestring($img, 5, 5, 30, truncate_middle($url, 46, "..."), $textcolor); |
|
| 93 | + imagestring($img, 5, 5, 55, "HTTP Code: $fetch_last_error_code", $textcolor); |
|
| 94 | 94 | |
| 95 | - header("Content-type: image/png"); |
|
| 96 | - print imagepng($img); |
|
| 97 | - imagedestroy($img); |
|
| 95 | + header("Content-type: image/png"); |
|
| 96 | + print imagepng($img); |
|
| 97 | + imagedestroy($img); |
|
| 98 | 98 | |
| 99 | - } else { |
|
| 100 | - header("Content-type: text/html"); |
|
| 99 | + } else { |
|
| 100 | + header("Content-type: text/html"); |
|
| 101 | 101 | |
| 102 | - http_response_code(400); |
|
| 102 | + http_response_code(400); |
|
| 103 | 103 | |
| 104 | - print "<h1>Proxy request failed.</h1>"; |
|
| 105 | - print "<p>Fetch error $fetch_last_error ($fetch_last_error_code)</p>"; |
|
| 106 | - print "<p>URL: $url</p>"; |
|
| 107 | - print "<textarea cols='80' rows='25'>" . htmlspecialchars($fetch_last_error_content) . "</textarea>"; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 104 | + print "<h1>Proxy request failed.</h1>"; |
|
| 105 | + print "<p>Fetch error $fetch_last_error ($fetch_last_error_code)</p>"; |
|
| 106 | + print "<p>URL: $url</p>"; |
|
| 107 | + print "<textarea cols='80' rows='25'>" . htmlspecialchars($fetch_last_error_content) . "</textarea>"; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - private function rewrite_url_if_needed($url, $all_remote = false) { |
|
| 114 | - /* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */ |
|
| 115 | - if (!$this->cache->exists(sha1($url))) { |
|
| 113 | + private function rewrite_url_if_needed($url, $all_remote = false) { |
|
| 114 | + /* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */ |
|
| 115 | + if (!$this->cache->exists(sha1($url))) { |
|
| 116 | 116 | |
| 117 | - $scheme = parse_url($url, PHP_URL_SCHEME); |
|
| 117 | + $scheme = parse_url($url, PHP_URL_SCHEME); |
|
| 118 | 118 | |
| 119 | - if ($all_remote) { |
|
| 120 | - $host = parse_url($url, PHP_URL_HOST); |
|
| 121 | - $self_host = parse_url(get_self_url_prefix(), PHP_URL_HOST); |
|
| 119 | + if ($all_remote) { |
|
| 120 | + $host = parse_url($url, PHP_URL_HOST); |
|
| 121 | + $self_host = parse_url(get_self_url_prefix(), PHP_URL_HOST); |
|
| 122 | 122 | |
| 123 | - $is_remote = $host != $self_host; |
|
| 124 | - } else { |
|
| 125 | - $is_remote = false; |
|
| 126 | - } |
|
| 123 | + $is_remote = $host != $self_host; |
|
| 124 | + } else { |
|
| 125 | + $is_remote = false; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - if (($scheme != 'https' && $scheme != "") || $is_remote) { |
|
| 129 | - if (strpos($url, "data:") !== 0) { |
|
| 130 | - $parts = parse_url($url); |
|
| 131 | - |
|
| 132 | - foreach (explode(" " , $this->ssl_known_whitelist) as $host) { |
|
| 133 | - if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) { |
|
| 134 | - $parts['scheme'] = 'https'; |
|
| 135 | - $url = build_url($parts); |
|
| 136 | - if ($all_remote && $is_remote) { |
|
| 137 | - break; |
|
| 138 | - } else { |
|
| 139 | - return $url; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - } |
|
| 128 | + if (($scheme != 'https' && $scheme != "") || $is_remote) { |
|
| 129 | + if (strpos($url, "data:") !== 0) { |
|
| 130 | + $parts = parse_url($url); |
|
| 143 | 131 | |
| 144 | - return $this->host->get_public_method_url($this, "imgproxy", ["url" => $url]); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 132 | + foreach (explode(" " , $this->ssl_known_whitelist) as $host) { |
|
| 133 | + if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) { |
|
| 134 | + $parts['scheme'] = 'https'; |
|
| 135 | + $url = build_url($parts); |
|
| 136 | + if ($all_remote && $is_remote) { |
|
| 137 | + break; |
|
| 138 | + } else { |
|
| 139 | + return $url; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + } |
|
| 148 | 143 | |
| 149 | - return $url; |
|
| 150 | - } |
|
| 144 | + return $this->host->get_public_method_url($this, "imgproxy", ["url" => $url]); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 151 | 148 | |
| 152 | - /** |
|
| 153 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 154 | - */ |
|
| 155 | - public function hook_render_article_cdm($article, $api_mode = false) { |
|
| 149 | + return $url; |
|
| 150 | + } |
|
| 156 | 151 | |
| 157 | - $need_saving = false; |
|
| 158 | - $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 152 | + /** |
|
| 153 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 154 | + */ |
|
| 155 | + public function hook_render_article_cdm($article, $api_mode = false) { |
|
| 159 | 156 | |
| 160 | - $doc = new DOMDocument(); |
|
| 161 | - if (@$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"])) { |
|
| 162 | - $xpath = new DOMXPath($doc); |
|
| 163 | - $imgs = $xpath->query("//img[@src]"); |
|
| 157 | + $need_saving = false; |
|
| 158 | + $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 164 | 159 | |
| 165 | - foreach ($imgs as $img) { |
|
| 166 | - $new_src = $this->rewrite_url_if_needed($img->getAttribute("src"), $proxy_all); |
|
| 160 | + $doc = new DOMDocument(); |
|
| 161 | + if (@$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"])) { |
|
| 162 | + $xpath = new DOMXPath($doc); |
|
| 163 | + $imgs = $xpath->query("//img[@src]"); |
|
| 167 | 164 | |
| 168 | - if ($new_src != $img->getAttribute("src")) { |
|
| 169 | - $img->setAttribute("src", $new_src); |
|
| 170 | - $img->removeAttribute("srcset"); |
|
| 165 | + foreach ($imgs as $img) { |
|
| 166 | + $new_src = $this->rewrite_url_if_needed($img->getAttribute("src"), $proxy_all); |
|
| 171 | 167 | |
| 172 | - $need_saving = true; |
|
| 173 | - } |
|
| 174 | - } |
|
| 168 | + if ($new_src != $img->getAttribute("src")) { |
|
| 169 | + $img->setAttribute("src", $new_src); |
|
| 170 | + $img->removeAttribute("srcset"); |
|
| 175 | 171 | |
| 176 | - $vids = $xpath->query("(//video|//picture)"); |
|
| 172 | + $need_saving = true; |
|
| 173 | + } |
|
| 174 | + } |
|
| 177 | 175 | |
| 178 | - foreach ($vids as $vid) { |
|
| 179 | - if ($vid->hasAttribute("poster")) { |
|
| 180 | - $new_src = $this->rewrite_url_if_needed($vid->getAttribute("poster"), $proxy_all); |
|
| 176 | + $vids = $xpath->query("(//video|//picture)"); |
|
| 181 | 177 | |
| 182 | - if ($new_src != $vid->getAttribute("poster")) { |
|
| 183 | - $vid->setAttribute("poster", $new_src); |
|
| 178 | + foreach ($vids as $vid) { |
|
| 179 | + if ($vid->hasAttribute("poster")) { |
|
| 180 | + $new_src = $this->rewrite_url_if_needed($vid->getAttribute("poster"), $proxy_all); |
|
| 184 | 181 | |
| 185 | - $need_saving = true; |
|
| 186 | - } |
|
| 187 | - } |
|
| 182 | + if ($new_src != $vid->getAttribute("poster")) { |
|
| 183 | + $vid->setAttribute("poster", $new_src); |
|
| 188 | 184 | |
| 189 | - $vsrcs = $xpath->query("source", $vid); |
|
| 185 | + $need_saving = true; |
|
| 186 | + } |
|
| 187 | + } |
|
| 190 | 188 | |
| 191 | - foreach ($vsrcs as $vsrc) { |
|
| 192 | - $new_src = $this->rewrite_url_if_needed($vsrc->getAttribute("src"), $proxy_all); |
|
| 189 | + $vsrcs = $xpath->query("source", $vid); |
|
| 193 | 190 | |
| 194 | - if ($new_src != $vsrc->getAttribute("src")) { |
|
| 195 | - $vid->setAttribute("src", $new_src); |
|
| 191 | + foreach ($vsrcs as $vsrc) { |
|
| 192 | + $new_src = $this->rewrite_url_if_needed($vsrc->getAttribute("src"), $proxy_all); |
|
| 196 | 193 | |
| 197 | - $need_saving = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 194 | + if ($new_src != $vsrc->getAttribute("src")) { |
|
| 195 | + $vid->setAttribute("src", $new_src); |
|
| 202 | 196 | |
| 203 | - if ($need_saving) $article["content"] = $doc->saveHTML(); |
|
| 197 | + $need_saving = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 204 | 202 | |
| 205 | - return $article; |
|
| 206 | - } |
|
| 203 | + if ($need_saving) $article["content"] = $doc->saveHTML(); |
|
| 204 | + |
|
| 205 | + return $article; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - public function hook_prefs_tab($args) { |
|
| 209 | - if ($args != "prefFeeds") return; |
|
| 208 | + public function hook_prefs_tab($args) { |
|
| 209 | + if ($args != "prefFeeds") return; |
|
| 210 | 210 | |
| 211 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 211 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 212 | 212 | title=\"<i class='material-icons'>extension</i> ".__('Image proxy settings (af_proxy_http)')."\">"; |
| 213 | 213 | |
| 214 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
| 214 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
| 215 | 215 | |
| 216 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 216 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 217 | 217 | evt.preventDefault(); |
| 218 | 218 | if (this.validate()) { |
| 219 | 219 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -227,36 +227,36 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | </script>"; |
| 229 | 229 | |
| 230 | - print_hidden("op", "pluginhandler"); |
|
| 231 | - print_hidden("method", "save"); |
|
| 232 | - print_hidden("plugin", "af_proxy_http"); |
|
| 230 | + print_hidden("op", "pluginhandler"); |
|
| 231 | + print_hidden("method", "save"); |
|
| 232 | + print_hidden("plugin", "af_proxy_http"); |
|
| 233 | 233 | |
| 234 | - $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 235 | - print_checkbox("proxy_all", $proxy_all); |
|
| 236 | - print " <label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>"; |
|
| 234 | + $proxy_all = $this->host->get($this, "proxy_all"); |
|
| 235 | + print_checkbox("proxy_all", $proxy_all); |
|
| 236 | + print " <label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>"; |
|
| 237 | 237 | |
| 238 | - $disable_cache = $this->host->get($this, "disable_cache"); |
|
| 239 | - print_checkbox("disable_cache", $disable_cache); |
|
| 240 | - print " <label for=\"disable_cache\">" . __("Don't cache files locally.") . "</label>"; |
|
| 238 | + $disable_cache = $this->host->get($this, "disable_cache"); |
|
| 239 | + print_checkbox("disable_cache", $disable_cache); |
|
| 240 | + print " <label for=\"disable_cache\">" . __("Don't cache files locally.") . "</label>"; |
|
| 241 | 241 | |
| 242 | - print "<p>"; print_button("submit", __("Save")); |
|
| 242 | + print "<p>"; print_button("submit", __("Save")); |
|
| 243 | 243 | |
| 244 | - print "</form>"; |
|
| 244 | + print "</form>"; |
|
| 245 | 245 | |
| 246 | - print "</div>"; |
|
| 247 | - } |
|
| 246 | + print "</div>"; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - public function save() { |
|
| 250 | - $proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]); |
|
| 251 | - $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]); |
|
| 249 | + public function save() { |
|
| 250 | + $proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]); |
|
| 251 | + $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]); |
|
| 252 | 252 | |
| 253 | - $this->host->set($this, "proxy_all", $proxy_all, false); |
|
| 254 | - $this->host->set($this, "disable_cache", $disable_cache); |
|
| 253 | + $this->host->set($this, "proxy_all", $proxy_all, false); |
|
| 254 | + $this->host->set($this, "disable_cache", $disable_cache); |
|
| 255 | 255 | |
| 256 | - echo __("Configuration saved"); |
|
| 257 | - } |
|
| 256 | + echo __("Configuration saved"); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - public function api_version() { |
|
| 260 | - return 2; |
|
| 261 | - } |
|
| 259 | + public function api_version() { |
|
| 260 | + return 2; |
|
| 261 | + } |
|
| 262 | 262 | } |
@@ -1,28 +1,28 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Shorten_Expanded extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Shorten overly long articles in CDM/expanded", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Shorten overly long articles in CDM/expanded", |
|
| 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_css() { |
|
| 17 | - return file_get_contents(__DIR__ . "/init.css"); |
|
| 18 | - } |
|
| 16 | + public function get_css() { |
|
| 17 | + return file_get_contents(__DIR__ . "/init.css"); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function get_js() { |
|
| 21 | - return file_get_contents(__DIR__ . "/init.js"); |
|
| 22 | - } |
|
| 20 | + public function get_js() { |
|
| 21 | + return file_get_contents(__DIR__ . "/init.js"); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function api_version() { |
|
| 25 | - return 2; |
|
| 26 | - } |
|
| 24 | + public function api_version() { |
|
| 25 | + return 2; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | } |
@@ -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,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 | } |