@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function get_js() { |
21 | - return file_get_contents(dirname(__FILE__) . "/mail.js"); |
|
21 | + return file_get_contents(dirname(__FILE__)."/mail.js"); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function save() { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 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 | 40 | print "<form dojoType=\"dijit.form.Form\">"; |
41 | 41 | |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
116 | 116 | |
117 | 117 | if (count($ids) > 1) { |
118 | - $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
118 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | while ($line = $sth->fetch()) { |
122 | 122 | |
123 | 123 | if (!$subject) |
124 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
124 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
125 | 125 | |
126 | 126 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
127 | 127 | $tnote = strip_tags($line["note"]); |
128 | - if( $tnote != ''){ |
|
128 | + if ($tnote != '') { |
|
129 | 129 | $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
130 | 130 | $tpl->addBlock('note'); |
131 | 131 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | "message" => $message]); |
211 | 211 | |
212 | 212 | if (!$rc) { |
213 | - $reply['error'] = $mailer->error(); |
|
213 | + $reply['error'] = $mailer->error(); |
|
214 | 214 | } else { |
215 | 215 | //save_email_address($destination); |
216 | 216 | $reply['message'] = "UPDATE_COUNTERS"; |
@@ -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 | } |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | public function hook_prefs_tab($args) { |
33 | - if ($args != "prefPrefs") return; |
|
33 | + if ($args != "prefPrefs") { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
36 | 38 | title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">"; |
@@ -94,7 +96,9 @@ discard block |
||
94 | 96 | $user_name = htmlspecialchars($row['full_name']); |
95 | 97 | } |
96 | 98 | |
97 | - if (!$user_name) $user_name = $_SESSION['name']; |
|
99 | + if (!$user_name) { |
|
100 | + $user_name = $_SESSION['name']; |
|
101 | + } |
|
98 | 102 | |
99 | 103 | print_hidden("from_email", "$user_email"); |
100 | 104 | print_hidden("from_name", "$user_name"); |
@@ -120,8 +124,9 @@ discard block |
||
120 | 124 | |
121 | 125 | while ($line = $sth->fetch()) { |
122 | 126 | |
123 | - if (!$subject) |
|
124 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
127 | + if (!$subject) { |
|
128 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
129 | + } |
|
125 | 130 | |
126 | 131 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
127 | 132 | $tnote = strip_tags($line["note"]); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
20 | 20 | $host->add_hook($host::HOOK_PREFS_TAB, $this); |
21 | 21 | |
22 | - require_once __DIR__ . "/filter_base.php"; |
|
22 | + require_once __DIR__."/filter_base.php"; |
|
23 | 23 | |
24 | - $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php")); |
|
24 | + $filters = array_merge(glob(__DIR__."/filters.local/*.php"), glob(__DIR__."/filters/*.php")); |
|
25 | 25 | $names = []; |
26 | 26 | |
27 | 27 | foreach ($filters as $file) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
51 | 51 | title=\"<i class='material-icons'>photo</i> ".__('Feeds supported by af_comics')."\">"; |
52 | 52 | |
53 | - print "<p>" . __("The following comics are currently supported:") . "</p>"; |
|
53 | + print "<p>".__("The following comics are currently supported:")."</p>"; |
|
54 | 54 | |
55 | 55 | $comics = array("GoComics"); |
56 | 56 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | return $feed_data; |
94 | 94 | |
95 | 95 | if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
96 | - $site_url = 'https://www.gocomics.com/' . $comic[1]; |
|
96 | + $site_url = 'https://www.gocomics.com/'.$comic[1]; |
|
97 | 97 | |
98 | - $article_link = $site_url . date('/Y/m/d'); |
|
98 | + $article_link = $site_url.date('/Y/m/d'); |
|
99 | 99 | |
100 | 100 | $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); |
101 | 101 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $title = date('l, F d, Y'); |
132 | 132 | } |
133 | 133 | |
134 | - foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr ) { |
|
134 | + foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr) { |
|
135 | 135 | $node->removeAttribute($attr); |
136 | 136 | } |
137 | 137 |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | public function hook_prefs_tab($args) { |
48 | - if ($args != "prefFeeds") return; |
|
48 | + if ($args != "prefFeeds") { |
|
49 | + return; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
51 | 53 | title=\"<i class='material-icons'>photo</i> ".__('Feeds supported by af_comics')."\">"; |
@@ -77,8 +79,9 @@ discard block |
||
77 | 79 | |
78 | 80 | public function hook_article_filter($article) { |
79 | 81 | foreach ($this->filters as $f) { |
80 | - if ($f->process($article)) |
|
81 | - break; |
|
82 | + if ($f->process($article)) { |
|
83 | + break; |
|
84 | + } |
|
82 | 85 | } |
83 | 86 | |
84 | 87 | return $article; |
@@ -89,8 +92,9 @@ discard block |
||
89 | 92 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
90 | 93 | */ |
91 | 94 | public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) { |
92 | - if ($auth_login || $auth_pass) |
|
93 | - return $feed_data; |
|
95 | + if ($auth_login || $auth_pass) { |
|
96 | + return $feed_data; |
|
97 | + } |
|
94 | 98 | |
95 | 99 | if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
96 | 100 | $site_url = 'https://www.gocomics.com/' . $comic[1]; |
@@ -153,29 +157,35 @@ discard block |
||
153 | 157 | |
154 | 158 | $tpl->addBlock('feed'); |
155 | 159 | |
156 | - if ($tpl->generateOutputToString($tmp_data)) |
|
157 | - $feed_data = $tmp_data; |
|
160 | + if ($tpl->generateOutputToString($tmp_data)) { |
|
161 | + $feed_data = $tmp_data; |
|
162 | + } |
|
158 | 163 | } |
159 | 164 | |
160 | 165 | return $feed_data; |
161 | 166 | } |
162 | 167 | |
163 | 168 | public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { |
164 | - if ($auth_login || $auth_pass) |
|
165 | - return $contents; |
|
169 | + if ($auth_login || $auth_pass) { |
|
170 | + return $contents; |
|
171 | + } |
|
166 | 172 | |
167 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) |
|
168 | - return '<?xml version="1.0" encoding="utf-8"?>'; // Get is_html() to return false. |
|
173 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) { |
|
174 | + return '<?xml version="1.0" encoding="utf-8"?>'; |
|
175 | + } |
|
176 | + // Get is_html() to return false. |
|
169 | 177 | |
170 | 178 | return $contents; |
171 | 179 | } |
172 | 180 | |
173 | 181 | public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) { |
174 | - if ($auth_login || $auth_pass) |
|
175 | - return $basic_info; |
|
182 | + if ($auth_login || $auth_pass) { |
|
183 | + return $basic_info; |
|
184 | + } |
|
176 | 185 | |
177 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) |
|
178 | - $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
186 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) { |
|
187 | + $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
188 | + } |
|
179 | 189 | |
180 | 190 | return $basic_info; |
181 | 191 | } |
@@ -1,187 +1,187 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics extends Plugin { |
3 | 3 | |
4 | - private $host; |
|
5 | - private $filters = array(); |
|
4 | + private $host; |
|
5 | + private $filters = array(); |
|
6 | 6 | |
7 | - public function about() { |
|
8 | - return array(2.0, |
|
9 | - "Fixes RSS feeds of assorted comic strips", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(2.0, |
|
9 | + "Fixes RSS feeds of assorted comic strips", |
|
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_FETCH_FEED, $this); |
|
17 | - $host->add_hook($host::HOOK_FEED_BASIC_INFO, $this); |
|
18 | - $host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this); |
|
19 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
16 | + $host->add_hook($host::HOOK_FETCH_FEED, $this); |
|
17 | + $host->add_hook($host::HOOK_FEED_BASIC_INFO, $this); |
|
18 | + $host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this); |
|
19 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
21 | 21 | |
22 | - require_once __DIR__ . "/filter_base.php"; |
|
22 | + require_once __DIR__ . "/filter_base.php"; |
|
23 | 23 | |
24 | - $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php")); |
|
25 | - $names = []; |
|
24 | + $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php")); |
|
25 | + $names = []; |
|
26 | 26 | |
27 | - foreach ($filters as $file) { |
|
28 | - $filter_name = preg_replace("/\..*$/", "", basename($file)); |
|
27 | + foreach ($filters as $file) { |
|
28 | + $filter_name = preg_replace("/\..*$/", "", basename($file)); |
|
29 | 29 | |
30 | - if (array_search($filter_name, $names) === false) { |
|
31 | - if (!class_exists($filter_name)) { |
|
32 | - require_once $file; |
|
33 | - } |
|
30 | + if (array_search($filter_name, $names) === false) { |
|
31 | + if (!class_exists($filter_name)) { |
|
32 | + require_once $file; |
|
33 | + } |
|
34 | 34 | |
35 | - array_push($names, $filter_name); |
|
35 | + array_push($names, $filter_name); |
|
36 | 36 | |
37 | - $filter = new $filter_name(); |
|
37 | + $filter = new $filter_name(); |
|
38 | 38 | |
39 | - if (is_subclass_of($filter, "Af_ComicFilter")) { |
|
40 | - array_push($this->filters, $filter); |
|
41 | - array_push($names, $filter_name); |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
39 | + if (is_subclass_of($filter, "Af_ComicFilter")) { |
|
40 | + array_push($this->filters, $filter); |
|
41 | + array_push($names, $filter_name); |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - public function hook_prefs_tab($args) { |
|
48 | - if ($args != "prefFeeds") return; |
|
47 | + public function hook_prefs_tab($args) { |
|
48 | + if ($args != "prefFeeds") return; |
|
49 | 49 | |
50 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
50 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
51 | 51 | title=\"<i class='material-icons'>photo</i> ".__('Feeds supported by af_comics')."\">"; |
52 | 52 | |
53 | - print "<p>" . __("The following comics are currently supported:") . "</p>"; |
|
53 | + print "<p>" . __("The following comics are currently supported:") . "</p>"; |
|
54 | 54 | |
55 | - $comics = array("GoComics"); |
|
55 | + $comics = array("GoComics"); |
|
56 | 56 | |
57 | - foreach ($this->filters as $f) { |
|
58 | - foreach ($f->supported() as $comic) { |
|
59 | - array_push($comics, $comic); |
|
60 | - } |
|
61 | - } |
|
57 | + foreach ($this->filters as $f) { |
|
58 | + foreach ($f->supported() as $comic) { |
|
59 | + array_push($comics, $comic); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - asort($comics); |
|
63 | + asort($comics); |
|
64 | 64 | |
65 | - print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
66 | - foreach ($comics as $comic) { |
|
67 | - print "<li>$comic</li>"; |
|
68 | - } |
|
69 | - print "</ul>"; |
|
65 | + print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
66 | + foreach ($comics as $comic) { |
|
67 | + print "<li>$comic</li>"; |
|
68 | + } |
|
69 | + print "</ul>"; |
|
70 | 70 | |
71 | - print "<p>".__("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the <em>Garfield</em> comic use <code>http://www.gocomics.com/garfield</code>).")."</p>"; |
|
71 | + print "<p>".__("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the <em>Garfield</em> comic use <code>http://www.gocomics.com/garfield</code>).")."</p>"; |
|
72 | 72 | |
73 | - print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>"; |
|
73 | + print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>"; |
|
74 | 74 | |
75 | - print "</div>"; |
|
76 | - } |
|
75 | + print "</div>"; |
|
76 | + } |
|
77 | 77 | |
78 | - public function hook_article_filter($article) { |
|
79 | - foreach ($this->filters as $f) { |
|
80 | - if ($f->process($article)) |
|
81 | - break; |
|
82 | - } |
|
78 | + public function hook_article_filter($article) { |
|
79 | + foreach ($this->filters as $f) { |
|
80 | + if ($f->process($article)) |
|
81 | + break; |
|
82 | + } |
|
83 | 83 | |
84 | - return $article; |
|
85 | - } |
|
84 | + return $article; |
|
85 | + } |
|
86 | 86 | |
87 | - // GoComics dropped feed support so it needs to be handled when fetching the feed. |
|
88 | - /** |
|
89 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
90 | - */ |
|
91 | - public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) { |
|
92 | - if ($auth_login || $auth_pass) |
|
93 | - return $feed_data; |
|
87 | + // GoComics dropped feed support so it needs to be handled when fetching the feed. |
|
88 | + /** |
|
89 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
90 | + */ |
|
91 | + public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) { |
|
92 | + if ($auth_login || $auth_pass) |
|
93 | + return $feed_data; |
|
94 | 94 | |
95 | - if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
|
96 | - $site_url = 'https://www.gocomics.com/' . $comic[1]; |
|
95 | + if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
|
96 | + $site_url = 'https://www.gocomics.com/' . $comic[1]; |
|
97 | 97 | |
98 | - $article_link = $site_url . date('/Y/m/d'); |
|
98 | + $article_link = $site_url . date('/Y/m/d'); |
|
99 | 99 | |
100 | - $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); |
|
100 | + $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); |
|
101 | 101 | |
102 | - require_once 'lib/MiniTemplator.class.php'; |
|
102 | + require_once 'lib/MiniTemplator.class.php'; |
|
103 | 103 | |
104 | - $feed_title = htmlspecialchars($comic[1]); |
|
105 | - $site_url = htmlspecialchars($site_url); |
|
106 | - $article_link = htmlspecialchars($article_link); |
|
104 | + $feed_title = htmlspecialchars($comic[1]); |
|
105 | + $site_url = htmlspecialchars($site_url); |
|
106 | + $article_link = htmlspecialchars($article_link); |
|
107 | 107 | |
108 | - $tpl = new MiniTemplator(); |
|
108 | + $tpl = new MiniTemplator(); |
|
109 | 109 | |
110 | - $tpl->readTemplateFromFile('templates/generated_feed.txt'); |
|
110 | + $tpl->readTemplateFromFile('templates/generated_feed.txt'); |
|
111 | 111 | |
112 | - $tpl->setVariable('FEED_TITLE', $feed_title, true); |
|
113 | - $tpl->setVariable('VERSION', get_version(), true); |
|
114 | - $tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true); |
|
115 | - $tpl->setVariable('SELF_URL', $site_url, true); |
|
112 | + $tpl->setVariable('FEED_TITLE', $feed_title, true); |
|
113 | + $tpl->setVariable('VERSION', get_version(), true); |
|
114 | + $tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true); |
|
115 | + $tpl->setVariable('SELF_URL', $site_url, true); |
|
116 | 116 | |
117 | - if ($body) { |
|
118 | - $doc = new DOMDocument(); |
|
117 | + if ($body) { |
|
118 | + $doc = new DOMDocument(); |
|
119 | 119 | |
120 | - if (@$doc->loadHTML($body)) { |
|
121 | - $xpath = new DOMXPath($doc); |
|
120 | + if (@$doc->loadHTML($body)) { |
|
121 | + $xpath = new DOMXPath($doc); |
|
122 | 122 | |
123 | - $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); |
|
123 | + $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); |
|
124 | 124 | |
125 | - if ($node) { |
|
126 | - $title = $xpath->query('//h1')->item(0); |
|
125 | + if ($node) { |
|
126 | + $title = $xpath->query('//h1')->item(0); |
|
127 | 127 | |
128 | - if ($title) { |
|
129 | - $title = clean(trim($title->nodeValue)); |
|
130 | - } else { |
|
131 | - $title = date('l, F d, Y'); |
|
132 | - } |
|
128 | + if ($title) { |
|
129 | + $title = clean(trim($title->nodeValue)); |
|
130 | + } else { |
|
131 | + $title = date('l, F d, Y'); |
|
132 | + } |
|
133 | 133 | |
134 | - foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr ) { |
|
135 | - $node->removeAttribute($attr); |
|
136 | - } |
|
134 | + foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr ) { |
|
135 | + $node->removeAttribute($attr); |
|
136 | + } |
|
137 | 137 | |
138 | - $tpl->setVariable('ARTICLE_ID', $article_link, true); |
|
139 | - $tpl->setVariable('ARTICLE_LINK', $article_link, true); |
|
140 | - $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', mktime(11, 0, 0)), true); |
|
141 | - $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($title), true); |
|
142 | - $tpl->setVariable('ARTICLE_EXCERPT', '', true); |
|
143 | - $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true); |
|
138 | + $tpl->setVariable('ARTICLE_ID', $article_link, true); |
|
139 | + $tpl->setVariable('ARTICLE_LINK', $article_link, true); |
|
140 | + $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', mktime(11, 0, 0)), true); |
|
141 | + $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($title), true); |
|
142 | + $tpl->setVariable('ARTICLE_EXCERPT', '', true); |
|
143 | + $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true); |
|
144 | 144 | |
145 | - $tpl->setVariable('ARTICLE_AUTHOR', '', true); |
|
146 | - $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true); |
|
147 | - $tpl->setVariable('ARTICLE_SOURCE_TITLE', $feed_title, true); |
|
145 | + $tpl->setVariable('ARTICLE_AUTHOR', '', true); |
|
146 | + $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true); |
|
147 | + $tpl->setVariable('ARTICLE_SOURCE_TITLE', $feed_title, true); |
|
148 | 148 | |
149 | - $tpl->addBlock('entry'); |
|
150 | - } |
|
151 | - } |
|
152 | - } |
|
149 | + $tpl->addBlock('entry'); |
|
150 | + } |
|
151 | + } |
|
152 | + } |
|
153 | 153 | |
154 | - $tpl->addBlock('feed'); |
|
154 | + $tpl->addBlock('feed'); |
|
155 | 155 | |
156 | - if ($tpl->generateOutputToString($tmp_data)) |
|
157 | - $feed_data = $tmp_data; |
|
158 | - } |
|
156 | + if ($tpl->generateOutputToString($tmp_data)) |
|
157 | + $feed_data = $tmp_data; |
|
158 | + } |
|
159 | 159 | |
160 | - return $feed_data; |
|
161 | - } |
|
160 | + return $feed_data; |
|
161 | + } |
|
162 | 162 | |
163 | - public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { |
|
164 | - if ($auth_login || $auth_pass) |
|
165 | - return $contents; |
|
163 | + public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { |
|
164 | + if ($auth_login || $auth_pass) |
|
165 | + return $contents; |
|
166 | 166 | |
167 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) |
|
168 | - return '<?xml version="1.0" encoding="utf-8"?>'; // Get is_html() to return false. |
|
167 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) |
|
168 | + return '<?xml version="1.0" encoding="utf-8"?>'; // Get is_html() to return false. |
|
169 | 169 | |
170 | - return $contents; |
|
171 | - } |
|
170 | + return $contents; |
|
171 | + } |
|
172 | 172 | |
173 | - public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) { |
|
174 | - if ($auth_login || $auth_pass) |
|
175 | - return $basic_info; |
|
173 | + public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) { |
|
174 | + if ($auth_login || $auth_pass) |
|
175 | + return $basic_info; |
|
176 | 176 | |
177 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) |
|
178 | - $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
177 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) |
|
178 | + $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
179 | 179 | |
180 | - return $basic_info; |
|
181 | - } |
|
180 | + return $basic_info; |
|
181 | + } |
|
182 | 182 | |
183 | - public function api_version() { |
|
184 | - return 2; |
|
185 | - } |
|
183 | + public function api_version() { |
|
184 | + return 2; |
|
185 | + } |
|
186 | 186 | |
187 | 187 | } |
@@ -14,11 +14,11 @@ |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | public function get_css() { |
17 | - return file_get_contents(__DIR__ . "/init.css"); |
|
17 | + return file_get_contents(__DIR__."/init.css"); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function get_js() { |
21 | - return file_get_contents(__DIR__ . "/init.js"); |
|
21 | + return file_get_contents(__DIR__."/init.js"); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function api_version() { |
@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | user_error("Your PHP has a separate systemwide Sphinx client installed which conflicts with the client library used by tt-rss. Either remove the system library or disable Sphinx support."); |
18 | 18 | } |
19 | 19 | |
20 | - require_once __DIR__ . "/sphinxapi.php"; |
|
20 | + require_once __DIR__."/sphinxapi.php"; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function hook_search($search) { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $sphinxpair = explode(":", SPHINX_SERVER, 2); |
30 | 30 | |
31 | - $sphinxClient->SetServer($sphinxpair[0], (int)$sphinxpair[1]); |
|
31 | + $sphinxClient->SetServer($sphinxpair[0], (int) $sphinxpair[1]); |
|
32 | 32 | $sphinxClient->SetConnectTimeout(1); |
33 | 33 | |
34 | 34 | $sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30, |
@@ -53,10 +53,11 @@ |
||
53 | 53 | |
54 | 54 | $ids = join(",", $ids); |
55 | 55 | |
56 | - if ($ids) |
|
57 | - return array("ref_id IN ($ids)", array()); |
|
58 | - else |
|
59 | - return array("ref_id = -1", array()); |
|
56 | + if ($ids) { |
|
57 | + return array("ref_id IN ($ids)", array()); |
|
58 | + } else { |
|
59 | + return array("ref_id = -1", array()); |
|
60 | + } |
|
60 | 61 | } |
61 | 62 | |
62 | 63 | public function api_version() { |
@@ -1,65 +1,65 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class Search_Sphinx extends Plugin { |
4 | - public function about() { |
|
5 | - return array(1.0, |
|
6 | - "Delegate searching for articles to Sphinx (don't forget to set options in config.php)", |
|
7 | - "hoelzro", |
|
8 | - true, |
|
9 | - "https://git.tt-rss.org/fox/tt-rss/wiki/SphinxSearch"); |
|
10 | - } |
|
4 | + public function about() { |
|
5 | + return array(1.0, |
|
6 | + "Delegate searching for articles to Sphinx (don't forget to set options in config.php)", |
|
7 | + "hoelzro", |
|
8 | + true, |
|
9 | + "https://git.tt-rss.org/fox/tt-rss/wiki/SphinxSearch"); |
|
10 | + } |
|
11 | 11 | |
12 | - public function init($host) { |
|
13 | - $host->add_hook($host::HOOK_SEARCH, $this); |
|
12 | + public function init($host) { |
|
13 | + $host->add_hook($host::HOOK_SEARCH, $this); |
|
14 | 14 | |
15 | - // idk if that would work but checking for the class being loaded is somehow not enough |
|
16 | - if (class_exists("SphinxClient") && !defined('SEARCHD_COMMAND_SEARCH')) { |
|
17 | - user_error("Your PHP has a separate systemwide Sphinx client installed which conflicts with the client library used by tt-rss. Either remove the system library or disable Sphinx support."); |
|
18 | - } |
|
15 | + // idk if that would work but checking for the class being loaded is somehow not enough |
|
16 | + if (class_exists("SphinxClient") && !defined('SEARCHD_COMMAND_SEARCH')) { |
|
17 | + user_error("Your PHP has a separate systemwide Sphinx client installed which conflicts with the client library used by tt-rss. Either remove the system library or disable Sphinx support."); |
|
18 | + } |
|
19 | 19 | |
20 | - require_once __DIR__ . "/sphinxapi.php"; |
|
21 | - } |
|
20 | + require_once __DIR__ . "/sphinxapi.php"; |
|
21 | + } |
|
22 | 22 | |
23 | - public function hook_search($search) { |
|
24 | - $offset = 0; |
|
25 | - $limit = 500; |
|
23 | + public function hook_search($search) { |
|
24 | + $offset = 0; |
|
25 | + $limit = 500; |
|
26 | 26 | |
27 | - $sphinxClient = new SphinxClient(); |
|
27 | + $sphinxClient = new SphinxClient(); |
|
28 | 28 | |
29 | - $sphinxpair = explode(":", SPHINX_SERVER, 2); |
|
29 | + $sphinxpair = explode(":", SPHINX_SERVER, 2); |
|
30 | 30 | |
31 | - $sphinxClient->SetServer($sphinxpair[0], (int)$sphinxpair[1]); |
|
32 | - $sphinxClient->SetConnectTimeout(1); |
|
31 | + $sphinxClient->SetServer($sphinxpair[0], (int)$sphinxpair[1]); |
|
32 | + $sphinxClient->SetConnectTimeout(1); |
|
33 | 33 | |
34 | - $sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30, |
|
35 | - 'feed_title' => 20)); |
|
34 | + $sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30, |
|
35 | + 'feed_title' => 20)); |
|
36 | 36 | |
37 | - $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2); |
|
38 | - $sphinxClient->SetRankingMode(SPH_RANK_PROXIMITY_BM25); |
|
39 | - $sphinxClient->SetLimits($offset, $limit, 1000); |
|
40 | - $sphinxClient->SetArrayResult(false); |
|
41 | - $sphinxClient->SetFilter('owner_uid', array($_SESSION['uid'])); |
|
37 | + $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2); |
|
38 | + $sphinxClient->SetRankingMode(SPH_RANK_PROXIMITY_BM25); |
|
39 | + $sphinxClient->SetLimits($offset, $limit, 1000); |
|
40 | + $sphinxClient->SetArrayResult(false); |
|
41 | + $sphinxClient->SetFilter('owner_uid', array($_SESSION['uid'])); |
|
42 | 42 | |
43 | - $result = $sphinxClient->Query($search, SPHINX_INDEX); |
|
43 | + $result = $sphinxClient->Query($search, SPHINX_INDEX); |
|
44 | 44 | |
45 | - $ids = array(); |
|
45 | + $ids = array(); |
|
46 | 46 | |
47 | - if (is_array($result['matches'])) { |
|
48 | - foreach (array_keys($result['matches']) as $int_id) { |
|
49 | - $ref_id = $result['matches'][$int_id]['attrs']['ref_id']; |
|
50 | - array_push($ids, $ref_id); |
|
51 | - } |
|
52 | - } |
|
47 | + if (is_array($result['matches'])) { |
|
48 | + foreach (array_keys($result['matches']) as $int_id) { |
|
49 | + $ref_id = $result['matches'][$int_id]['attrs']['ref_id']; |
|
50 | + array_push($ids, $ref_id); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - $ids = join(",", $ids); |
|
54 | + $ids = join(",", $ids); |
|
55 | 55 | |
56 | - if ($ids) |
|
57 | - return array("ref_id IN ($ids)", array()); |
|
58 | - else |
|
59 | - return array("ref_id = -1", array()); |
|
60 | - } |
|
56 | + if ($ids) |
|
57 | + return array("ref_id IN ($ids)", array()); |
|
58 | + else |
|
59 | + return array("ref_id = -1", array()); |
|
60 | + } |
|
61 | 61 | |
62 | - public function api_version() { |
|
63 | - return 2; |
|
64 | - } |
|
62 | + public function api_version() { |
|
63 | + return 2; |
|
64 | + } |
|
65 | 65 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public function get_js() { |
44 | - return file_get_contents(__DIR__ . "/init.js"); |
|
44 | + return file_get_contents(__DIR__."/init.js"); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function showrelated() { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | print "</div>"; |
100 | 100 | |
101 | - print "<div style='text-align : right' class='text-muted'>" . smart_date_time(strtotime($line["updated"])) . "</div>"; |
|
101 | + print "<div style='text-align : right' class='text-muted'>".smart_date_time(strtotime($line["updated"]))."</div>"; |
|
102 | 102 | |
103 | 103 | print "</li>"; |
104 | 104 | } |
@@ -163,24 +163,24 @@ discard block |
||
163 | 163 | print_hidden("method", "save"); |
164 | 164 | print_hidden("plugin", "af_psql_trgm"); |
165 | 165 | |
166 | - print "<h2>" . __("Global settings") . "</h2>"; |
|
166 | + print "<h2>".__("Global settings")."</h2>"; |
|
167 | 167 | |
168 | 168 | print_notice("Enable for specific feeds in the feed editor."); |
169 | 169 | |
170 | 170 | print "<fieldset>"; |
171 | 171 | |
172 | - print "<label>" . __("Minimum similarity:") . "</label> "; |
|
172 | + print "<label>".__("Minimum similarity:")."</label> "; |
|
173 | 173 | print "<input dojoType=\"dijit.form.NumberSpinner\" |
174 | 174 | placeholder=\"0.75\" id='psql_trgm_similarity' |
175 | 175 | required=\"1\" name=\"similarity\" value=\"$similarity\">"; |
176 | 176 | |
177 | - print "<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>" . |
|
178 | - __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . |
|
177 | + print "<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>". |
|
178 | + __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking."). |
|
179 | 179 | "</div>"; |
180 | 180 | |
181 | 181 | print "</fieldset><fieldset>"; |
182 | 182 | |
183 | - print "<label>" . __("Minimum title length:") . "</label> "; |
|
183 | + print "<label>".__("Minimum title length:")."</label> "; |
|
184 | 184 | print "<input dojoType=\"dijit.form.NumberSpinner\" |
185 | 185 | placeholder=\"32\" |
186 | 186 | required=\"1\" name=\"min_title_length\" value=\"$min_title_length\">"; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | print "<label class='checkbox'>"; |
191 | 191 | print_checkbox("enable_globally", $enable_globally); |
192 | - print " " . __("Enable for all feeds:"); |
|
192 | + print " ".__("Enable for all feeds:"); |
|
193 | 193 | print "</label>"; |
194 | 194 | |
195 | 195 | print "</fieldset>"; |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | $this->host->set($this, "enabled_feeds", $enabled_feeds); |
205 | 205 | |
206 | 206 | if (count($enabled_feeds) > 0) { |
207 | - print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; |
|
207 | + print "<h3>".__("Currently enabled for (click to edit):")."</h3>"; |
|
208 | 208 | |
209 | 209 | print "<ul class=\"panel panel-scrollable list list-unstyled\">"; |
210 | 210 | foreach ($enabled_feeds as $f) { |
211 | - print "<li>" . |
|
211 | + print "<li>". |
|
212 | 212 | "<i class='material-icons'>rss_feed</i> <a href='#' |
213 | - onclick='CommonDialogs.editFeed($f)'>" . |
|
214 | - Feeds::getFeedTitle($f) . "</a></li>"; |
|
213 | + onclick='CommonDialogs.editFeed($f)'>". |
|
214 | + Feeds::getFeedTitle($f)."</a></li>"; |
|
215 | 215 | } |
216 | 216 | print "</ul>"; |
217 | 217 | } |
@@ -1,64 +1,64 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Af_Psql_Trgm 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 | - "Marks similar articles as read (requires pg_trgm)", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(1.0, |
|
9 | + "Marks similar articles as read (requires pg_trgm)", |
|
10 | + "fox"); |
|
11 | + } |
|
12 | 12 | |
13 | - public function save() { |
|
14 | - $similarity = (float) $_POST["similarity"]; |
|
15 | - $min_title_length = (int) $_POST["min_title_length"]; |
|
16 | - $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]); |
|
13 | + public function save() { |
|
14 | + $similarity = (float) $_POST["similarity"]; |
|
15 | + $min_title_length = (int) $_POST["min_title_length"]; |
|
16 | + $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]); |
|
17 | 17 | |
18 | - if ($similarity < 0) $similarity = 0; |
|
19 | - if ($similarity > 1) $similarity = 1; |
|
18 | + if ($similarity < 0) $similarity = 0; |
|
19 | + if ($similarity > 1) $similarity = 1; |
|
20 | 20 | |
21 | - if ($min_title_length < 0) $min_title_length = 0; |
|
21 | + if ($min_title_length < 0) $min_title_length = 0; |
|
22 | 22 | |
23 | - $similarity = sprintf("%.2f", $similarity); |
|
23 | + $similarity = sprintf("%.2f", $similarity); |
|
24 | 24 | |
25 | - $this->host->set($this, "similarity", $similarity); |
|
26 | - $this->host->set($this, "min_title_length", $min_title_length); |
|
27 | - $this->host->set($this, "enable_globally", $enable_globally); |
|
25 | + $this->host->set($this, "similarity", $similarity); |
|
26 | + $this->host->set($this, "min_title_length", $min_title_length); |
|
27 | + $this->host->set($this, "enable_globally", $enable_globally); |
|
28 | 28 | |
29 | - echo T_sprintf("Data saved (%s, %d)", $similarity, $enable_globally); |
|
30 | - } |
|
29 | + echo T_sprintf("Data saved (%s, %d)", $similarity, $enable_globally); |
|
30 | + } |
|
31 | 31 | |
32 | - public function init($host) { |
|
33 | - $this->host = $host; |
|
32 | + public function init($host) { |
|
33 | + $this->host = $host; |
|
34 | 34 | |
35 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
36 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
37 | - $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); |
|
38 | - $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); |
|
39 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
35 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
36 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
37 | + $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); |
|
38 | + $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); |
|
39 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function get_js() { |
|
44 | - return file_get_contents(__DIR__ . "/init.js"); |
|
45 | - } |
|
43 | + public function get_js() { |
|
44 | + return file_get_contents(__DIR__ . "/init.js"); |
|
45 | + } |
|
46 | 46 | |
47 | - public function showrelated() { |
|
48 | - $id = (int) $_REQUEST['param']; |
|
49 | - $owner_uid = $_SESSION["uid"]; |
|
47 | + public function showrelated() { |
|
48 | + $id = (int) $_REQUEST['param']; |
|
49 | + $owner_uid = $_SESSION["uid"]; |
|
50 | 50 | |
51 | - $sth = $this->pdo->prepare("SELECT title FROM ttrss_entries, ttrss_user_entries |
|
51 | + $sth = $this->pdo->prepare("SELECT title FROM ttrss_entries, ttrss_user_entries |
|
52 | 52 | WHERE ref_id = id AND id = ? AND owner_uid = ?"); |
53 | - $sth->execute([$id, $owner_uid]); |
|
53 | + $sth->execute([$id, $owner_uid]); |
|
54 | 54 | |
55 | - if ($row = $sth->fetch()) { |
|
55 | + if ($row = $sth->fetch()) { |
|
56 | 56 | |
57 | - $title = $row['title']; |
|
57 | + $title = $row['title']; |
|
58 | 58 | |
59 | - print "<p>$title</p>"; |
|
59 | + print "<p>$title</p>"; |
|
60 | 60 | |
61 | - $sth = $this->pdo->prepare("SELECT ttrss_entries.id AS id, |
|
61 | + $sth = $this->pdo->prepare("SELECT ttrss_entries.id AS id, |
|
62 | 62 | feed_id, |
63 | 63 | ttrss_entries.title AS title, |
64 | 64 | updated, link, |
@@ -75,77 +75,77 @@ discard block |
||
75 | 75 | sm DESC, date_entered DESC |
76 | 76 | LIMIT 10"); |
77 | 77 | |
78 | - $sth->execute([$title, $owner_uid, $id]); |
|
78 | + $sth->execute([$title, $owner_uid, $id]); |
|
79 | 79 | |
80 | - print "<ul class='panel panel-scrollable'>"; |
|
80 | + print "<ul class='panel panel-scrollable'>"; |
|
81 | 81 | |
82 | - while ($line = $sth->fetch()) { |
|
83 | - print "<li style='display : flex'>"; |
|
84 | - print "<i class='material-icons'>bookmark_outline</i>"; |
|
82 | + while ($line = $sth->fetch()) { |
|
83 | + print "<li style='display : flex'>"; |
|
84 | + print "<i class='material-icons'>bookmark_outline</i>"; |
|
85 | 85 | |
86 | - $sm = sprintf("%.2f", $line['sm']); |
|
87 | - $article_link = htmlspecialchars($line["link"]); |
|
86 | + $sm = sprintf("%.2f", $line['sm']); |
|
87 | + $article_link = htmlspecialchars($line["link"]); |
|
88 | 88 | |
89 | - print "<div style='flex-grow : 2'>"; |
|
89 | + print "<div style='flex-grow : 2'>"; |
|
90 | 90 | |
91 | - print " <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"$article_link\">". |
|
92 | - $line["title"]."</a>"; |
|
91 | + print " <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"$article_link\">". |
|
92 | + $line["title"]."</a>"; |
|
93 | 93 | |
94 | - print " (<a href=\"#\" onclick=\"Feeds.open({feed:".$line["feed_id"]."})\">". |
|
95 | - htmlspecialchars($line["feed_title"])."</a>)"; |
|
94 | + print " (<a href=\"#\" onclick=\"Feeds.open({feed:".$line["feed_id"]."})\">". |
|
95 | + htmlspecialchars($line["feed_title"])."</a>)"; |
|
96 | 96 | |
97 | - print " — $sm"; |
|
97 | + print " — $sm"; |
|
98 | 98 | |
99 | - print "</div>"; |
|
99 | + print "</div>"; |
|
100 | 100 | |
101 | - print "<div style='text-align : right' class='text-muted'>" . smart_date_time(strtotime($line["updated"])) . "</div>"; |
|
101 | + print "<div style='text-align : right' class='text-muted'>" . smart_date_time(strtotime($line["updated"])) . "</div>"; |
|
102 | 102 | |
103 | - print "</li>"; |
|
104 | - } |
|
103 | + print "</li>"; |
|
104 | + } |
|
105 | 105 | |
106 | - print "</ul>"; |
|
106 | + print "</ul>"; |
|
107 | 107 | |
108 | - } |
|
108 | + } |
|
109 | 109 | |
110 | - print "<footer class='text-center'>"; |
|
111 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('trgmRelatedDlg').hide()\">".__('Close this window')."</button>"; |
|
112 | - print "</footer>"; |
|
110 | + print "<footer class='text-center'>"; |
|
111 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('trgmRelatedDlg').hide()\">".__('Close this window')."</button>"; |
|
112 | + print "</footer>"; |
|
113 | 113 | |
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - public function hook_article_button($line) { |
|
118 | - return "<i style=\"cursor : pointer\" class='material-icons' |
|
117 | + public function hook_article_button($line) { |
|
118 | + return "<i style=\"cursor : pointer\" class='material-icons' |
|
119 | 119 | onclick=\"Plugins.Psql_Trgm.showRelated(".$line["id"].")\" |
120 | 120 | title='".__('Show related articles')."'>bookmark_outline</i>"; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - public function hook_prefs_tab($args) { |
|
124 | - if ($args != "prefFeeds") return; |
|
123 | + public function hook_prefs_tab($args) { |
|
124 | + if ($args != "prefFeeds") return; |
|
125 | 125 | |
126 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
126 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
127 | 127 | title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">"; |
128 | 128 | |
129 | - if (DB_TYPE != "pgsql") { |
|
130 | - print_error("Database type not supported."); |
|
131 | - } else { |
|
129 | + if (DB_TYPE != "pgsql") { |
|
130 | + print_error("Database type not supported."); |
|
131 | + } else { |
|
132 | 132 | |
133 | - $res = $this->pdo->query("select 'similarity'::regproc"); |
|
133 | + $res = $this->pdo->query("select 'similarity'::regproc"); |
|
134 | 134 | |
135 | - if (!$res->fetch()) { |
|
136 | - print_error("pg_trgm extension not found."); |
|
137 | - } |
|
135 | + if (!$res->fetch()) { |
|
136 | + print_error("pg_trgm extension not found."); |
|
137 | + } |
|
138 | 138 | |
139 | - $similarity = $this->host->get($this, "similarity"); |
|
140 | - $min_title_length = $this->host->get($this, "min_title_length"); |
|
141 | - $enable_globally = $this->host->get($this, "enable_globally"); |
|
139 | + $similarity = $this->host->get($this, "similarity"); |
|
140 | + $min_title_length = $this->host->get($this, "min_title_length"); |
|
141 | + $enable_globally = $this->host->get($this, "enable_globally"); |
|
142 | 142 | |
143 | - if (!$similarity) $similarity = '0.75'; |
|
144 | - if (!$min_title_length) $min_title_length = '32'; |
|
143 | + if (!$similarity) $similarity = '0.75'; |
|
144 | + if (!$min_title_length) $min_title_length = '32'; |
|
145 | 145 | |
146 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
146 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
147 | 147 | |
148 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
148 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
149 | 149 | evt.preventDefault(); |
150 | 150 | if (this.validate()) { |
151 | 151 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -159,190 +159,190 @@ discard block |
||
159 | 159 | } |
160 | 160 | </script>"; |
161 | 161 | |
162 | - print_hidden("op", "pluginhandler"); |
|
163 | - print_hidden("method", "save"); |
|
164 | - print_hidden("plugin", "af_psql_trgm"); |
|
162 | + print_hidden("op", "pluginhandler"); |
|
163 | + print_hidden("method", "save"); |
|
164 | + print_hidden("plugin", "af_psql_trgm"); |
|
165 | 165 | |
166 | - print "<h2>" . __("Global settings") . "</h2>"; |
|
166 | + print "<h2>" . __("Global settings") . "</h2>"; |
|
167 | 167 | |
168 | - print_notice("Enable for specific feeds in the feed editor."); |
|
168 | + print_notice("Enable for specific feeds in the feed editor."); |
|
169 | 169 | |
170 | - print "<fieldset>"; |
|
170 | + print "<fieldset>"; |
|
171 | 171 | |
172 | - print "<label>" . __("Minimum similarity:") . "</label> "; |
|
173 | - print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
172 | + print "<label>" . __("Minimum similarity:") . "</label> "; |
|
173 | + print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
174 | 174 | placeholder=\"0.75\" id='psql_trgm_similarity' |
175 | 175 | required=\"1\" name=\"similarity\" value=\"$similarity\">"; |
176 | 176 | |
177 | - print "<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>" . |
|
178 | - __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . |
|
179 | - "</div>"; |
|
177 | + print "<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>" . |
|
178 | + __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . |
|
179 | + "</div>"; |
|
180 | 180 | |
181 | - print "</fieldset><fieldset>"; |
|
181 | + print "</fieldset><fieldset>"; |
|
182 | 182 | |
183 | - print "<label>" . __("Minimum title length:") . "</label> "; |
|
184 | - print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
183 | + print "<label>" . __("Minimum title length:") . "</label> "; |
|
184 | + print "<input dojoType=\"dijit.form.NumberSpinner\" |
|
185 | 185 | placeholder=\"32\" |
186 | 186 | required=\"1\" name=\"min_title_length\" value=\"$min_title_length\">"; |
187 | 187 | |
188 | - print "</fieldset><fieldset>"; |
|
188 | + print "</fieldset><fieldset>"; |
|
189 | 189 | |
190 | - print "<label class='checkbox'>"; |
|
191 | - print_checkbox("enable_globally", $enable_globally); |
|
192 | - print " " . __("Enable for all feeds:"); |
|
193 | - print "</label>"; |
|
190 | + print "<label class='checkbox'>"; |
|
191 | + print_checkbox("enable_globally", $enable_globally); |
|
192 | + print " " . __("Enable for all feeds:"); |
|
193 | + print "</label>"; |
|
194 | 194 | |
195 | - print "</fieldset>"; |
|
195 | + print "</fieldset>"; |
|
196 | 196 | |
197 | - print_button("submit", __("Save"), "class='alt-primary'"); |
|
198 | - print "</form>"; |
|
197 | + print_button("submit", __("Save"), "class='alt-primary'"); |
|
198 | + print "</form>"; |
|
199 | 199 | |
200 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
201 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
200 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
201 | + if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
202 | 202 | |
203 | - $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
|
204 | - $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
203 | + $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
|
204 | + $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
205 | 205 | |
206 | - if (count($enabled_feeds) > 0) { |
|
207 | - print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; |
|
206 | + if (count($enabled_feeds) > 0) { |
|
207 | + print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; |
|
208 | 208 | |
209 | - print "<ul class=\"panel panel-scrollable list list-unstyled\">"; |
|
210 | - foreach ($enabled_feeds as $f) { |
|
211 | - print "<li>" . |
|
212 | - "<i class='material-icons'>rss_feed</i> <a href='#' |
|
209 | + print "<ul class=\"panel panel-scrollable list list-unstyled\">"; |
|
210 | + foreach ($enabled_feeds as $f) { |
|
211 | + print "<li>" . |
|
212 | + "<i class='material-icons'>rss_feed</i> <a href='#' |
|
213 | 213 | onclick='CommonDialogs.editFeed($f)'>" . |
214 | - Feeds::getFeedTitle($f) . "</a></li>"; |
|
215 | - } |
|
216 | - print "</ul>"; |
|
217 | - } |
|
218 | - } |
|
214 | + Feeds::getFeedTitle($f) . "</a></li>"; |
|
215 | + } |
|
216 | + print "</ul>"; |
|
217 | + } |
|
218 | + } |
|
219 | 219 | |
220 | - print "</div>"; |
|
221 | - } |
|
220 | + print "</div>"; |
|
221 | + } |
|
222 | 222 | |
223 | - public function hook_prefs_edit_feed($feed_id) { |
|
224 | - print "<header>".__("Similarity (pg_trgm)")."</header>"; |
|
225 | - print "<section>"; |
|
223 | + public function hook_prefs_edit_feed($feed_id) { |
|
224 | + print "<header>".__("Similarity (pg_trgm)")."</header>"; |
|
225 | + print "<section>"; |
|
226 | 226 | |
227 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
228 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
227 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
228 | + if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
229 | 229 | |
230 | - $key = array_search($feed_id, $enabled_feeds); |
|
231 | - $checked = $key !== false ? "checked" : ""; |
|
230 | + $key = array_search($feed_id, $enabled_feeds); |
|
231 | + $checked = $key !== false ? "checked" : ""; |
|
232 | 232 | |
233 | - print "<fieldset>"; |
|
233 | + print "<fieldset>"; |
|
234 | 234 | |
235 | - print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='trgm_similarity_enabled' |
|
235 | + print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='trgm_similarity_enabled' |
|
236 | 236 | name='trgm_similarity_enabled' $checked> ".__('Mark similar articles as read')."</label>"; |
237 | 237 | |
238 | - print "</fieldset>"; |
|
238 | + print "</fieldset>"; |
|
239 | 239 | |
240 | - print "</section>"; |
|
241 | - } |
|
240 | + print "</section>"; |
|
241 | + } |
|
242 | 242 | |
243 | - public function hook_prefs_save_feed($feed_id) { |
|
244 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
245 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
243 | + public function hook_prefs_save_feed($feed_id) { |
|
244 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
245 | + if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
246 | 246 | |
247 | - $enable = checkbox_to_sql_bool($_POST["trgm_similarity_enabled"]); |
|
248 | - $key = array_search($feed_id, $enabled_feeds); |
|
247 | + $enable = checkbox_to_sql_bool($_POST["trgm_similarity_enabled"]); |
|
248 | + $key = array_search($feed_id, $enabled_feeds); |
|
249 | 249 | |
250 | - if ($enable) { |
|
251 | - if ($key === false) { |
|
252 | - array_push($enabled_feeds, $feed_id); |
|
253 | - } |
|
254 | - } else { |
|
255 | - if ($key !== false) { |
|
256 | - unset($enabled_feeds[$key]); |
|
257 | - } |
|
258 | - } |
|
250 | + if ($enable) { |
|
251 | + if ($key === false) { |
|
252 | + array_push($enabled_feeds, $feed_id); |
|
253 | + } |
|
254 | + } else { |
|
255 | + if ($key !== false) { |
|
256 | + unset($enabled_feeds[$key]); |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
261 | - } |
|
260 | + $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
261 | + } |
|
262 | 262 | |
263 | - public function hook_article_filter($article) { |
|
263 | + public function hook_article_filter($article) { |
|
264 | 264 | |
265 | - if (DB_TYPE != "pgsql") return $article; |
|
265 | + if (DB_TYPE != "pgsql") return $article; |
|
266 | 266 | |
267 | - $res = $this->pdo->query("select 'similarity'::regproc"); |
|
268 | - if (!$res->fetch()) return $article; |
|
267 | + $res = $this->pdo->query("select 'similarity'::regproc"); |
|
268 | + if (!$res->fetch()) return $article; |
|
269 | 269 | |
270 | - $enable_globally = $this->host->get($this, "enable_globally"); |
|
270 | + $enable_globally = $this->host->get($this, "enable_globally"); |
|
271 | 271 | |
272 | - if (!$enable_globally) { |
|
273 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
274 | - $key = array_search($article["feed"]["id"], $enabled_feeds); |
|
275 | - if ($key === false) return $article; |
|
276 | - } |
|
272 | + if (!$enable_globally) { |
|
273 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
274 | + $key = array_search($article["feed"]["id"], $enabled_feeds); |
|
275 | + if ($key === false) return $article; |
|
276 | + } |
|
277 | 277 | |
278 | - $similarity = (float) $this->host->get($this, "similarity"); |
|
279 | - if ($similarity < 0.01) return $article; |
|
278 | + $similarity = (float) $this->host->get($this, "similarity"); |
|
279 | + if ($similarity < 0.01) return $article; |
|
280 | 280 | |
281 | - $min_title_length = (int) $this->host->get($this, "min_title_length"); |
|
282 | - if (mb_strlen($article["title"]) < $min_title_length) return $article; |
|
281 | + $min_title_length = (int) $this->host->get($this, "min_title_length"); |
|
282 | + if (mb_strlen($article["title"]) < $min_title_length) return $article; |
|
283 | 283 | |
284 | - $owner_uid = $article["owner_uid"]; |
|
285 | - $entry_guid = $article["guid_hashed"]; |
|
286 | - $title_escaped = $article["title"]; |
|
284 | + $owner_uid = $article["owner_uid"]; |
|
285 | + $entry_guid = $article["guid_hashed"]; |
|
286 | + $title_escaped = $article["title"]; |
|
287 | 287 | |
288 | - // trgm does not return similarity=1 for completely equal strings |
|
288 | + // trgm does not return similarity=1 for completely equal strings |
|
289 | 289 | |
290 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS nequal |
|
290 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS nequal |
|
291 | 291 | FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND |
292 | 292 | date_entered >= NOW() - interval '3 days' AND |
293 | 293 | title = ? AND |
294 | 294 | guid != ? AND |
295 | 295 | owner_uid = ?"); |
296 | - $sth->execute([$title_escaped, $entry_guid, $owner_uid]); |
|
296 | + $sth->execute([$title_escaped, $entry_guid, $owner_uid]); |
|
297 | 297 | |
298 | - $row = $sth->fetch(); |
|
299 | - $nequal = $row['nequal']; |
|
298 | + $row = $sth->fetch(); |
|
299 | + $nequal = $row['nequal']; |
|
300 | 300 | |
301 | - Debug::log("af_psql_trgm: num equals: $nequal", Debug::$LOG_EXTENDED); |
|
301 | + Debug::log("af_psql_trgm: num equals: $nequal", Debug::$LOG_EXTENDED); |
|
302 | 302 | |
303 | - if ($nequal != 0) { |
|
304 | - $article["force_catchup"] = true; |
|
305 | - return $article; |
|
306 | - } |
|
303 | + if ($nequal != 0) { |
|
304 | + $article["force_catchup"] = true; |
|
305 | + return $article; |
|
306 | + } |
|
307 | 307 | |
308 | - $sth = $this->pdo->prepare("SELECT MAX(SIMILARITY(title, ?)) AS ms |
|
308 | + $sth = $this->pdo->prepare("SELECT MAX(SIMILARITY(title, ?)) AS ms |
|
309 | 309 | FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND |
310 | 310 | date_entered >= NOW() - interval '1 day' AND |
311 | 311 | guid != ? AND |
312 | 312 | owner_uid = ?"); |
313 | - $sth->execute([$title_escaped, $entry_guid, $owner_uid]); |
|
313 | + $sth->execute([$title_escaped, $entry_guid, $owner_uid]); |
|
314 | 314 | |
315 | - $row = $sth->fetch(); |
|
316 | - $similarity_result = $row['ms']; |
|
315 | + $row = $sth->fetch(); |
|
316 | + $similarity_result = $row['ms']; |
|
317 | 317 | |
318 | - Debug::log("af_psql_trgm: similarity result: $similarity_result", Debug::$LOG_EXTENDED); |
|
318 | + Debug::log("af_psql_trgm: similarity result: $similarity_result", Debug::$LOG_EXTENDED); |
|
319 | 319 | |
320 | - if ($similarity_result >= $similarity) { |
|
321 | - $article["force_catchup"] = true; |
|
322 | - } |
|
320 | + if ($similarity_result >= $similarity) { |
|
321 | + $article["force_catchup"] = true; |
|
322 | + } |
|
323 | 323 | |
324 | - return $article; |
|
324 | + return $article; |
|
325 | 325 | |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - public function api_version() { |
|
329 | - return 2; |
|
330 | - } |
|
328 | + public function api_version() { |
|
329 | + return 2; |
|
330 | + } |
|
331 | 331 | |
332 | - private function filter_unknown_feeds($enabled_feeds) { |
|
333 | - $tmp = array(); |
|
332 | + private function filter_unknown_feeds($enabled_feeds) { |
|
333 | + $tmp = array(); |
|
334 | 334 | |
335 | - foreach ($enabled_feeds as $feed) { |
|
335 | + foreach ($enabled_feeds as $feed) { |
|
336 | 336 | |
337 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
338 | - $sth->execute([$feed, $_SESSION['uid']]); |
|
337 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
338 | + $sth->execute([$feed, $_SESSION['uid']]); |
|
339 | 339 | |
340 | - if ($row = $sth->fetch()) { |
|
341 | - array_push($tmp, $feed); |
|
342 | - } |
|
343 | - } |
|
340 | + if ($row = $sth->fetch()) { |
|
341 | + array_push($tmp, $feed); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | - return $tmp; |
|
346 | - } |
|
345 | + return $tmp; |
|
346 | + } |
|
347 | 347 | |
348 | 348 | } |
@@ -15,10 +15,16 @@ discard block |
||
15 | 15 | $min_title_length = (int) $_POST["min_title_length"]; |
16 | 16 | $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]); |
17 | 17 | |
18 | - if ($similarity < 0) $similarity = 0; |
|
19 | - if ($similarity > 1) $similarity = 1; |
|
18 | + if ($similarity < 0) { |
|
19 | + $similarity = 0; |
|
20 | + } |
|
21 | + if ($similarity > 1) { |
|
22 | + $similarity = 1; |
|
23 | + } |
|
20 | 24 | |
21 | - if ($min_title_length < 0) $min_title_length = 0; |
|
25 | + if ($min_title_length < 0) { |
|
26 | + $min_title_length = 0; |
|
27 | + } |
|
22 | 28 | |
23 | 29 | $similarity = sprintf("%.2f", $similarity); |
24 | 30 | |
@@ -121,7 +127,9 @@ discard block |
||
121 | 127 | } |
122 | 128 | |
123 | 129 | public function hook_prefs_tab($args) { |
124 | - if ($args != "prefFeeds") return; |
|
130 | + if ($args != "prefFeeds") { |
|
131 | + return; |
|
132 | + } |
|
125 | 133 | |
126 | 134 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
127 | 135 | title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">"; |
@@ -140,8 +148,12 @@ discard block |
||
140 | 148 | $min_title_length = $this->host->get($this, "min_title_length"); |
141 | 149 | $enable_globally = $this->host->get($this, "enable_globally"); |
142 | 150 | |
143 | - if (!$similarity) $similarity = '0.75'; |
|
144 | - if (!$min_title_length) $min_title_length = '32'; |
|
151 | + if (!$similarity) { |
|
152 | + $similarity = '0.75'; |
|
153 | + } |
|
154 | + if (!$min_title_length) { |
|
155 | + $min_title_length = '32'; |
|
156 | + } |
|
145 | 157 | |
146 | 158 | print "<form dojoType=\"dijit.form.Form\">"; |
147 | 159 | |
@@ -198,7 +210,9 @@ discard block |
||
198 | 210 | print "</form>"; |
199 | 211 | |
200 | 212 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
201 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
213 | + if (!array($enabled_feeds)) { |
|
214 | + $enabled_feeds = array(); |
|
215 | + } |
|
202 | 216 | |
203 | 217 | $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
204 | 218 | $this->host->set($this, "enabled_feeds", $enabled_feeds); |
@@ -225,7 +239,9 @@ discard block |
||
225 | 239 | print "<section>"; |
226 | 240 | |
227 | 241 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
228 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
242 | + if (!array($enabled_feeds)) { |
|
243 | + $enabled_feeds = array(); |
|
244 | + } |
|
229 | 245 | |
230 | 246 | $key = array_search($feed_id, $enabled_feeds); |
231 | 247 | $checked = $key !== false ? "checked" : ""; |
@@ -242,7 +258,9 @@ discard block |
||
242 | 258 | |
243 | 259 | public function hook_prefs_save_feed($feed_id) { |
244 | 260 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
245 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
261 | + if (!is_array($enabled_feeds)) { |
|
262 | + $enabled_feeds = array(); |
|
263 | + } |
|
246 | 264 | |
247 | 265 | $enable = checkbox_to_sql_bool($_POST["trgm_similarity_enabled"]); |
248 | 266 | $key = array_search($feed_id, $enabled_feeds); |
@@ -262,24 +280,34 @@ discard block |
||
262 | 280 | |
263 | 281 | public function hook_article_filter($article) { |
264 | 282 | |
265 | - if (DB_TYPE != "pgsql") return $article; |
|
283 | + if (DB_TYPE != "pgsql") { |
|
284 | + return $article; |
|
285 | + } |
|
266 | 286 | |
267 | 287 | $res = $this->pdo->query("select 'similarity'::regproc"); |
268 | - if (!$res->fetch()) return $article; |
|
288 | + if (!$res->fetch()) { |
|
289 | + return $article; |
|
290 | + } |
|
269 | 291 | |
270 | 292 | $enable_globally = $this->host->get($this, "enable_globally"); |
271 | 293 | |
272 | 294 | if (!$enable_globally) { |
273 | 295 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
274 | 296 | $key = array_search($article["feed"]["id"], $enabled_feeds); |
275 | - if ($key === false) return $article; |
|
297 | + if ($key === false) { |
|
298 | + return $article; |
|
299 | + } |
|
276 | 300 | } |
277 | 301 | |
278 | 302 | $similarity = (float) $this->host->get($this, "similarity"); |
279 | - if ($similarity < 0.01) return $article; |
|
303 | + if ($similarity < 0.01) { |
|
304 | + return $article; |
|
305 | + } |
|
280 | 306 | |
281 | 307 | $min_title_length = (int) $this->host->get($this, "min_title_length"); |
282 | - if (mb_strlen($article["title"]) < $min_title_length) return $article; |
|
308 | + if (mb_strlen($article["title"]) < $min_title_length) { |
|
309 | + return $article; |
|
310 | + } |
|
283 | 311 | |
284 | 312 | $owner_uid = $article["owner_uid"]; |
285 | 313 | $entry_guid = $article["guid_hashed"]; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function get_js() { |
19 | - return file_get_contents(__DIR__ . "/init.js"); |
|
19 | + return file_get_contents(__DIR__."/init.js"); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function hook_main_toolbar_button() { |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Toggle_Sidebar extends Plugin { |
3 | 3 | |
4 | - private $host; |
|
4 | + private $host; |
|
5 | 5 | |
6 | - public function about() { |
|
7 | - return array(1.0, |
|
8 | - "Adds a main toolbar button to toggle sidebar", |
|
9 | - "fox"); |
|
10 | - } |
|
6 | + public function about() { |
|
7 | + return array(1.0, |
|
8 | + "Adds a main toolbar button to toggle sidebar", |
|
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_MAIN_TOOLBAR_BUTTON, $this); |
|
16 | - } |
|
15 | + $host->add_hook($host::HOOK_MAIN_TOOLBAR_BUTTON, $this); |
|
16 | + } |
|
17 | 17 | |
18 | - public function get_js() { |
|
19 | - return file_get_contents(__DIR__ . "/init.js"); |
|
20 | - } |
|
18 | + public function get_js() { |
|
19 | + return file_get_contents(__DIR__ . "/init.js"); |
|
20 | + } |
|
21 | 21 | |
22 | - public function hook_main_toolbar_button() { |
|
23 | - ?> |
|
22 | + public function hook_main_toolbar_button() { |
|
23 | + ?> |
|
24 | 24 | |
25 | 25 | <button dojoType="dijit.form.Button" onclick="Plugins.Toggle_Sidebar.toggle(this)"> |
26 | 26 | <i class="material-icons toggle-sidebar-label" |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | </button> |
29 | 29 | |
30 | 30 | <?php |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - public function api_version() { |
|
34 | - return 2; |
|
35 | - } |
|
33 | + public function api_version() { |
|
34 | + return 2; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | ?> |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | - load_user_plugins( $_SESSION["uid"]); |
|
71 | + load_user_plugins($_SESSION["uid"]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $method = strtolower($_REQUEST["op"]); |
@@ -84,6 +84,6 @@ discard block |
||
84 | 84 | $handler->after(); |
85 | 85 | } |
86 | 86 | |
87 | -header("Api-Content-Length: " . ob_get_length()); |
|
87 | +header("Api-Content-Length: ".ob_get_length()); |
|
88 | 88 | |
89 | 89 | ob_end_flush(); |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | // fallback on HTTP parameters |
39 | 39 | if ($input) { |
40 | 40 | $input = json_decode($input, true); |
41 | - if ($input) $_REQUEST = $input; |
|
41 | + if ($input) { |
|
42 | + $_REQUEST = $input; |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } else { |
44 | 46 | // Accept JSON only |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | |
56 | 58 | startup_gettext(); |
57 | 59 | |
58 | -if (!init_plugins()) return; |
|
60 | +if (!init_plugins()) { |
|
61 | + return; |
|
62 | +} |
|
59 | 63 | |
60 | 64 | if ($_SESSION["uid"]) { |
61 | 65 | if (!validate_session()) { |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | -set_include_path(dirname(__FILE__) .DIRECTORY_SEPARATOR."include" . PATH_SEPARATOR . |
|
3 | +set_include_path(dirname(__FILE__).DIRECTORY_SEPARATOR."include".PATH_SEPARATOR. |
|
4 | 4 | get_include_path()); |
5 | 5 | |
6 | -declare(ticks = 1); |
|
6 | +declare(ticks=1); |
|
7 | 7 | chdir(dirname(__FILE__)); |
8 | 8 | |
9 | 9 | define('DISABLE_SESSIONS', true); |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | |
94 | 94 | function shutdown($caller_pid) { |
95 | 95 | if ($caller_pid == posix_getpid()) { |
96 | - if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { |
|
96 | + if (file_exists(LOCK_DIRECTORY."/update_daemon.lock")) { |
|
97 | 97 | Debug::log("removing lockfile (master)..."); |
98 | - unlink(LOCK_DIRECTORY . "/update_daemon.lock"); |
|
98 | + unlink(LOCK_DIRECTORY."/update_daemon.lock"); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | function task_shutdown() { |
104 | 104 | $pid = posix_getpid(); |
105 | 105 | |
106 | - if (file_exists(LOCK_DIRECTORY . "/update_daemon-$pid.lock")) { |
|
106 | + if (file_exists(LOCK_DIRECTORY."/update_daemon-$pid.lock")) { |
|
107 | 107 | Debug::log("removing lockfile ($pid)..."); |
108 | - unlink(LOCK_DIRECTORY . "/update_daemon-$pid.lock"); |
|
108 | + unlink(LOCK_DIRECTORY."/update_daemon-$pid.lock"); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | |
135 | 135 | $options = getopt("", $longopts); |
136 | 136 | |
137 | -if (isset($options["help"]) ) { |
|
137 | +if (isset($options["help"])) { |
|
138 | 138 | print "Tiny Tiny RSS update daemon.\n\n"; |
139 | 139 | print "Options:\n"; |
140 | 140 | print " --log FILE - log messages to FILE\n"; |
141 | 141 | print " --log-level N - log verbosity level\n"; |
142 | 142 | print " --tasks N - amount of update tasks to spawn\n"; |
143 | - print " default: " . MAX_JOBS . "\n"; |
|
143 | + print " default: ".MAX_JOBS."\n"; |
|
144 | 144 | print " --interval N - task spawn interval\n"; |
145 | - print " default: " . SPAWN_INTERVAL . " seconds.\n"; |
|
145 | + print " default: ".SPAWN_INTERVAL." seconds.\n"; |
|
146 | 146 | print " --quiet - don't output messages to stdout\n"; |
147 | 147 | return; |
148 | 148 | } |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | Debug::set_enabled(true); |
151 | 151 | |
152 | 152 | if (isset($options["log-level"])) { |
153 | - Debug::set_loglevel((int)$options["log-level"]); |
|
153 | + Debug::set_loglevel((int) $options["log-level"]); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (isset($options["log"])) { |
157 | 157 | Debug::set_quiet(isset($options['quiet'])); |
158 | 158 | Debug::set_logfile($options["log"]); |
159 | - Debug::log("Logging to " . $options["log"]); |
|
159 | + Debug::log("Logging to ".$options["log"]); |
|
160 | 160 | } else { |
161 | 161 | if (isset($options['quiet'])) { |
162 | 162 | Debug::set_loglevel(Debug::$LOG_DISABLED); |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | if (isset($options["tasks"])) { |
167 | - Debug::log("Set to spawn " . $options["tasks"] . " children."); |
|
167 | + Debug::log("Set to spawn ".$options["tasks"]." children."); |
|
168 | 168 | $max_jobs = $options["tasks"]; |
169 | 169 | } else { |
170 | 170 | $max_jobs = MAX_JOBS; |
171 | 171 | } |
172 | 172 | |
173 | 173 | if (isset($options["interval"])) { |
174 | - Debug::log("Spawn interval: " . $options["interval"] . " seconds."); |
|
174 | + Debug::log("Spawn interval: ".$options["interval"]." seconds."); |
|
175 | 175 | $spawn_interval = $options["interval"]; |
176 | 176 | } else { |
177 | 177 | $spawn_interval = SPAWN_INTERVAL; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | $my_pid = posix_getpid(); |
248 | 248 | |
249 | - passthru(PHP_EXECUTABLE . " update.php --daemon-loop $quiet $log --task $j --pidlock $my_pid"); |
|
249 | + passthru(PHP_EXECUTABLE." update.php --daemon-loop $quiet $log --task $j --pidlock $my_pid"); |
|
250 | 250 | |
251 | 251 | sleep(1); |
252 | 252 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
4 | 4 | get_include_path()); |
5 | 5 | |
6 | 6 | define('DISABLE_SESSIONS', true); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | "help"); |
89 | 89 | |
90 | 90 | foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
91 | - array_push($longopts, $command . $data["suffix"]); |
|
91 | + array_push($longopts, $command.$data["suffix"]); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | $options = getopt("", $longopts); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | exit; |
120 | 120 | } |
121 | 121 | |
122 | - if (count($options) == 0 || isset($options["help"]) ) { |
|
122 | + if (count($options) == 0 || isset($options["help"])) { |
|
123 | 123 | print "Tiny Tiny RSS data update script.\n\n"; |
124 | 124 | print "Options:\n"; |
125 | 125 | print " --feeds - update feeds\n"; |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | Debug::set_enabled(true); |
166 | 166 | |
167 | 167 | if (isset($options["log-level"])) { |
168 | - Debug::set_loglevel((int)$options["log-level"]); |
|
168 | + Debug::set_loglevel((int) $options["log-level"]); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | if (isset($options["log"])) { |
172 | 172 | Debug::set_quiet(isset($options['quiet'])); |
173 | 173 | Debug::set_logfile($options["log"]); |
174 | - Debug::log("Logging to " . $options["log"]); |
|
174 | + Debug::log("Logging to ".$options["log"]); |
|
175 | 175 | } else { |
176 | 176 | if (isset($options['quiet'])) { |
177 | 177 | Debug::set_loglevel(Debug::$LOG_DISABLED); |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | if (isset($options["task"])) { |
188 | - Debug::log("Using task id " . $options["task"]); |
|
189 | - $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
188 | + Debug::log("Using task id ".$options["task"]); |
|
189 | + $lock_filename = $lock_filename."-task_".$options["task"]; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if (isset($options["pidlock"])) { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if (isset($options["force-update"])) { |
216 | 216 | Debug::log("marking all feeds as needing update..."); |
217 | 217 | |
218 | - $pdo->query( "UPDATE ttrss_feeds SET |
|
218 | + $pdo->query("UPDATE ttrss_feeds SET |
|
219 | 219 | last_update_started = '1970-01-01', last_updated = '1970-01-01'"); |
220 | 220 | } |
221 | 221 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
233 | 233 | $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
234 | 234 | |
235 | - passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
235 | + passthru(PHP_EXECUTABLE." ".$argv[0]." --daemon-loop $quiet $log $log_level"); |
|
236 | 236 | |
237 | 237 | // let's enforce a minimum spawn interval as to not forkbomb the host |
238 | 238 | $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($options["cleanup-tags"])) { |
259 | - $rc = cleanup_tags( 14, 50000); |
|
259 | + $rc = cleanup_tags(14, 50000); |
|
260 | 260 | Debug::log("$rc tags deleted.\n"); |
261 | 261 | } |
262 | 262 | |
@@ -270,18 +270,18 @@ discard block |
||
270 | 270 | Debug::log("clearing existing indexes..."); |
271 | 271 | |
272 | 272 | if (DB_TYPE == "pgsql") { |
273 | - $sth = $pdo->query( "SELECT relname FROM |
|
273 | + $sth = $pdo->query("SELECT relname FROM |
|
274 | 274 | pg_catalog.pg_class WHERE relname LIKE 'ttrss_%' |
275 | 275 | AND relname NOT LIKE '%_pkey' |
276 | 276 | AND relkind = 'i'"); |
277 | 277 | } else { |
278 | - $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
278 | + $sth = $pdo->query("SELECT index_name,table_name FROM |
|
279 | 279 | information_schema.statistics WHERE index_name LIKE 'ttrss_%'"); |
280 | 280 | } |
281 | 281 | |
282 | 282 | while ($line = $sth->fetch()) { |
283 | 283 | if (DB_TYPE == "pgsql") { |
284 | - $statement = "DROP INDEX " . $line["relname"]; |
|
284 | + $statement = "DROP INDEX ".$line["relname"]; |
|
285 | 285 | Debug::log($statement); |
286 | 286 | } else { |
287 | 287 | $statement = "ALTER TABLE ". |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | $pdo->query($statement); |
292 | 292 | } |
293 | 293 | |
294 | - Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
294 | + Debug::log("reading indexes from schema for: ".DB_TYPE); |
|
295 | 295 | |
296 | - $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
296 | + $fp = fopen("schema/ttrss_schema_".DB_TYPE.".sql", "r"); |
|
297 | 297 | if ($fp) { |
298 | 298 | while ($line = fgets($fp)) { |
299 | 299 | $matches = array(); |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | $filter = array(); |
337 | 337 | |
338 | 338 | if (sql_bool_to_bool($line["cat_filter"])) { |
339 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
339 | + $feed_id = "CAT:".(int) $line["cat_id"]; |
|
340 | 340 | } else { |
341 | - $feed_id = (int)$line["feed_id"]; |
|
341 | + $feed_id = (int) $line["feed_id"]; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | if (isset($options["update-schema"])) { |
370 | - Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
370 | + Debug::log("Checking for updates (".DB_TYPE.")..."); |
|
371 | 371 | |
372 | 372 | $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION); |
373 | 373 | |
374 | 374 | if ($updater->isUpdateRequired()) { |
375 | - Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
375 | + Debug::log("Schema update required, version ".$updater->getSchemaVersion()." to ".SCHEMA_VERSION); |
|
376 | 376 | |
377 | 377 | if (DB_TYPE == "mysql") |
378 | 378 | Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | if (read_stdin() != 'yes') |
386 | 386 | exit; |
387 | 387 | |
388 | - Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
388 | + Debug::log("Performing updates to version ".SCHEMA_VERSION); |
|
389 | 389 | |
390 | 390 | for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
391 | 391 | Debug::log("* Updating to version $i..."); |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | while (true) { |
429 | 429 | |
430 | 430 | while ($line = $sth->fetch()) { |
431 | - $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
431 | + $tsvector_combined = mb_substr(strip_tags($line["title"]." ".$line["content"]), 0, 1000000); |
|
432 | 432 | |
433 | 433 | $usth->execute([$tsvector_combined, $line['id']]); |
434 | 434 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | PluginHost::getInstance()->run_commands($options); |
487 | 487 | |
488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
488 | + if (file_exists(LOCK_DIRECTORY."/$lock_filename")) |
|
489 | 489 | if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
490 | 490 | fclose($lock_handle); |
491 | - unlink(LOCK_DIRECTORY . "/$lock_filename"); |
|
491 | + unlink(LOCK_DIRECTORY."/$lock_filename"); |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | return $tags_deleted; |
60 | 60 | } |
61 | 61 | |
62 | - if (!defined('PHP_EXECUTABLE')) |
|
63 | - define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
62 | + if (!defined('PHP_EXECUTABLE')) { |
|
63 | + define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | + } |
|
64 | 65 | |
65 | 66 | $pdo = Db::pdo(); |
66 | 67 | |
@@ -249,8 +250,9 @@ discard block |
||
249 | 250 | |
250 | 251 | RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
251 | 252 | |
252 | - if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | - RSSUtils::housekeeping_common(true); |
|
253 | + if (!isset($options["pidlock"]) || $options["task"] == 0) { |
|
254 | + RSSUtils::housekeeping_common(true); |
|
255 | + } |
|
254 | 256 | |
255 | 257 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
256 | 258 | } |
@@ -264,8 +266,9 @@ discard block |
||
264 | 266 | Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
265 | 267 | Debug::log("Type 'yes' to continue."); |
266 | 268 | |
267 | - if (read_stdin() != 'yes') |
|
268 | - exit; |
|
269 | + if (read_stdin() != 'yes') { |
|
270 | + exit; |
|
271 | + } |
|
269 | 272 | |
270 | 273 | Debug::log("clearing existing indexes..."); |
271 | 274 | |
@@ -319,8 +322,9 @@ discard block |
||
319 | 322 | Debug::log("WARNING: this will remove all existing type2 filters."); |
320 | 323 | Debug::log("Type 'yes' to continue."); |
321 | 324 | |
322 | - if (read_stdin() != 'yes') |
|
323 | - exit; |
|
325 | + if (read_stdin() != 'yes') { |
|
326 | + exit; |
|
327 | + } |
|
324 | 328 | |
325 | 329 | Debug::log("converting filters..."); |
326 | 330 | |
@@ -374,16 +378,18 @@ discard block |
||
374 | 378 | if ($updater->isUpdateRequired()) { |
375 | 379 | Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
376 | 380 | |
377 | - if (DB_TYPE == "mysql") |
|
378 | - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
381 | + if (DB_TYPE == "mysql") { |
|
382 | + Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | 383 | "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
380 | - else |
|
381 | - Debug::log("WARNING: please backup your database before continuing."); |
|
384 | + } else { |
|
385 | + Debug::log("WARNING: please backup your database before continuing."); |
|
386 | + } |
|
382 | 387 | |
383 | 388 | Debug::log("Type 'yes' to continue."); |
384 | 389 | |
385 | - if (read_stdin() != 'yes') |
|
386 | - exit; |
|
390 | + if (read_stdin() != 'yes') { |
|
391 | + exit; |
|
392 | + } |
|
387 | 393 | |
388 | 394 | Debug::log("Performing updates to version " . SCHEMA_VERSION); |
389 | 395 | |
@@ -456,7 +462,9 @@ discard block |
||
456 | 462 | |
457 | 463 | $status = $about[3] ? "system" : "user"; |
458 | 464 | |
459 | - if (in_array($name, $enabled)) $name .= "*"; |
|
465 | + if (in_array($name, $enabled)) { |
|
466 | + $name .= "*"; |
|
467 | + } |
|
460 | 468 | |
461 | 469 | printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
462 | 470 | $name, $status, $about[0], $about[2], $about[1]); |
@@ -469,8 +477,12 @@ discard block |
||
469 | 477 | if (isset($options["debug-feed"])) { |
470 | 478 | $feed = $options["debug-feed"]; |
471 | 479 | |
472 | - if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | - if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
480 | + if (isset($options["force-refetch"])) { |
|
481 | + $_REQUEST["force_refetch"] = true; |
|
482 | + } |
|
483 | + if (isset($options["force-rehash"])) { |
|
484 | + $_REQUEST["force_rehash"] = true; |
|
485 | + } |
|
474 | 486 | |
475 | 487 | Debug::set_loglevel(Debug::$LOG_EXTENDED); |
476 | 488 | |
@@ -485,7 +497,8 @@ discard block |
||
485 | 497 | |
486 | 498 | PluginHost::getInstance()->run_commands($options); |
487 | 499 | |
488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
500 | + if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) { |
|
501 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | 502 | fclose($lock_handle); |
503 | + } |
|
491 | 504 | unlink(LOCK_DIRECTORY . "/$lock_filename"); |
@@ -1,107 +1,107 @@ discard block |
||
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
4 | - get_include_path()); |
|
3 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
4 | + get_include_path()); |
|
5 | 5 | |
6 | - define('DISABLE_SESSIONS', true); |
|
6 | + define('DISABLE_SESSIONS', true); |
|
7 | 7 | |
8 | - chdir(dirname(__FILE__)); |
|
8 | + chdir(dirname(__FILE__)); |
|
9 | 9 | |
10 | - require_once "autoload.php"; |
|
11 | - require_once "functions.php"; |
|
12 | - require_once "config.php"; |
|
13 | - require_once "sanity_check.php"; |
|
14 | - require_once "db.php"; |
|
15 | - require_once "db-prefs.php"; |
|
10 | + require_once "autoload.php"; |
|
11 | + require_once "functions.php"; |
|
12 | + require_once "config.php"; |
|
13 | + require_once "sanity_check.php"; |
|
14 | + require_once "db.php"; |
|
15 | + require_once "db-prefs.php"; |
|
16 | 16 | |
17 | - function cleanup_tags($days = 14, $limit = 1000) { |
|
17 | + function cleanup_tags($days = 14, $limit = 1000) { |
|
18 | 18 | |
19 | - $days = (int) $days; |
|
19 | + $days = (int) $days; |
|
20 | 20 | |
21 | - if (DB_TYPE == "pgsql") { |
|
22 | - $interval_query = "date_updated < NOW() - INTERVAL '$days days'"; |
|
23 | - } else if (DB_TYPE == "mysql") { |
|
24 | - $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
25 | - } |
|
21 | + if (DB_TYPE == "pgsql") { |
|
22 | + $interval_query = "date_updated < NOW() - INTERVAL '$days days'"; |
|
23 | + } else if (DB_TYPE == "mysql") { |
|
24 | + $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
25 | + } |
|
26 | 26 | |
27 | - $tags_deleted = 0; |
|
27 | + $tags_deleted = 0; |
|
28 | 28 | |
29 | - $pdo = Db::pdo(); |
|
29 | + $pdo = Db::pdo(); |
|
30 | 30 | |
31 | - while ($limit > 0) { |
|
32 | - $limit_part = 500; |
|
31 | + while ($limit > 0) { |
|
32 | + $limit_part = 500; |
|
33 | 33 | |
34 | - $sth = $pdo->prepare("SELECT ttrss_tags.id AS id |
|
34 | + $sth = $pdo->prepare("SELECT ttrss_tags.id AS id |
|
35 | 35 | FROM ttrss_tags, ttrss_user_entries, ttrss_entries |
36 | 36 | WHERE post_int_id = int_id AND $interval_query AND |
37 | 37 | ref_id = ttrss_entries.id AND tag_cache != '' LIMIT ?"); |
38 | - $sth->bindValue(1, $limit_part, PDO::PARAM_INT); |
|
39 | - $sth->execute(); |
|
40 | - |
|
41 | - $ids = array(); |
|
42 | - |
|
43 | - while ($line = $sth->fetch()) { |
|
44 | - array_push($ids, $line['id']); |
|
45 | - } |
|
46 | - |
|
47 | - if (count($ids) > 0) { |
|
48 | - $ids = join(",", $ids); |
|
49 | - |
|
50 | - $usth = $pdo->query("DELETE FROM ttrss_tags WHERE id IN ($ids)"); |
|
51 | - $tags_deleted = $usth->rowCount(); |
|
52 | - } else { |
|
53 | - break; |
|
54 | - } |
|
55 | - |
|
56 | - $limit -= $limit_part; |
|
57 | - } |
|
58 | - |
|
59 | - return $tags_deleted; |
|
60 | - } |
|
61 | - |
|
62 | - if (!defined('PHP_EXECUTABLE')) |
|
63 | - define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | - |
|
65 | - $pdo = Db::pdo(); |
|
66 | - |
|
67 | - init_plugins(); |
|
68 | - |
|
69 | - $longopts = array("feeds", |
|
70 | - "daemon", |
|
71 | - "daemon-loop", |
|
72 | - "send-digests", |
|
73 | - "task:", |
|
74 | - "cleanup-tags", |
|
75 | - "quiet", |
|
76 | - "log:", |
|
77 | - "log-level:", |
|
78 | - "indexes", |
|
79 | - "pidlock:", |
|
80 | - "update-schema", |
|
81 | - "convert-filters", |
|
82 | - "force-update", |
|
83 | - "gen-search-idx", |
|
84 | - "list-plugins", |
|
85 | - "debug-feed:", |
|
86 | - "force-refetch", |
|
87 | - "force-rehash", |
|
88 | - "help"); |
|
89 | - |
|
90 | - foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
91 | - array_push($longopts, $command . $data["suffix"]); |
|
92 | - } |
|
93 | - |
|
94 | - $options = getopt("", $longopts); |
|
95 | - |
|
96 | - if (!is_array($options)) { |
|
97 | - die("error: getopt() failed. ". |
|
98 | - "Most probably you are using PHP CGI to run this script ". |
|
99 | - "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". |
|
100 | - "additional information.\n"); |
|
101 | - } |
|
102 | - |
|
103 | - if (count($options) == 0 && !defined('STDIN')) { |
|
104 | - ?> |
|
38 | + $sth->bindValue(1, $limit_part, PDO::PARAM_INT); |
|
39 | + $sth->execute(); |
|
40 | + |
|
41 | + $ids = array(); |
|
42 | + |
|
43 | + while ($line = $sth->fetch()) { |
|
44 | + array_push($ids, $line['id']); |
|
45 | + } |
|
46 | + |
|
47 | + if (count($ids) > 0) { |
|
48 | + $ids = join(",", $ids); |
|
49 | + |
|
50 | + $usth = $pdo->query("DELETE FROM ttrss_tags WHERE id IN ($ids)"); |
|
51 | + $tags_deleted = $usth->rowCount(); |
|
52 | + } else { |
|
53 | + break; |
|
54 | + } |
|
55 | + |
|
56 | + $limit -= $limit_part; |
|
57 | + } |
|
58 | + |
|
59 | + return $tags_deleted; |
|
60 | + } |
|
61 | + |
|
62 | + if (!defined('PHP_EXECUTABLE')) |
|
63 | + define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | + |
|
65 | + $pdo = Db::pdo(); |
|
66 | + |
|
67 | + init_plugins(); |
|
68 | + |
|
69 | + $longopts = array("feeds", |
|
70 | + "daemon", |
|
71 | + "daemon-loop", |
|
72 | + "send-digests", |
|
73 | + "task:", |
|
74 | + "cleanup-tags", |
|
75 | + "quiet", |
|
76 | + "log:", |
|
77 | + "log-level:", |
|
78 | + "indexes", |
|
79 | + "pidlock:", |
|
80 | + "update-schema", |
|
81 | + "convert-filters", |
|
82 | + "force-update", |
|
83 | + "gen-search-idx", |
|
84 | + "list-plugins", |
|
85 | + "debug-feed:", |
|
86 | + "force-refetch", |
|
87 | + "force-rehash", |
|
88 | + "help"); |
|
89 | + |
|
90 | + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
91 | + array_push($longopts, $command . $data["suffix"]); |
|
92 | + } |
|
93 | + |
|
94 | + $options = getopt("", $longopts); |
|
95 | + |
|
96 | + if (!is_array($options)) { |
|
97 | + die("error: getopt() failed. ". |
|
98 | + "Most probably you are using PHP CGI to run this script ". |
|
99 | + "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". |
|
100 | + "additional information.\n"); |
|
101 | + } |
|
102 | + |
|
103 | + if (count($options) == 0 && !defined('STDIN')) { |
|
104 | + ?> |
|
105 | 105 | <!DOCTYPE html> |
106 | 106 | <html> |
107 | 107 | <head> |
@@ -116,376 +116,376 @@ discard block |
||
116 | 116 | |
117 | 117 | </body></html> |
118 | 118 | <?php |
119 | - exit; |
|
120 | - } |
|
121 | - |
|
122 | - if (count($options) == 0 || isset($options["help"]) ) { |
|
123 | - print "Tiny Tiny RSS data update script.\n\n"; |
|
124 | - print "Options:\n"; |
|
125 | - print " --feeds - update feeds\n"; |
|
126 | - print " --daemon - start single-process update daemon\n"; |
|
127 | - print " --task N - create lockfile using this task id\n"; |
|
128 | - print " --cleanup-tags - perform tags table maintenance\n"; |
|
129 | - print " --quiet - don't output messages to stdout\n"; |
|
130 | - print " --log FILE - log messages to FILE\n"; |
|
131 | - print " --log-level N - log verbosity level\n"; |
|
132 | - print " --indexes - recreate missing schema indexes\n"; |
|
133 | - print " --update-schema - update database schema\n"; |
|
134 | - print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; |
|
135 | - print " --convert-filters - convert type1 filters to type2\n"; |
|
136 | - print " --send-digests - send pending email digests\n"; |
|
137 | - print " --force-update - force update of all feeds\n"; |
|
138 | - print " --list-plugins - list all available plugins\n"; |
|
139 | - print " --debug-feed N - perform debug update of feed N\n"; |
|
140 | - print " --force-refetch - debug update: force refetch feed data\n"; |
|
141 | - print " --force-rehash - debug update: force rehash articles\n"; |
|
142 | - print " --help - show this help\n"; |
|
143 | - print "Plugin options:\n"; |
|
144 | - |
|
145 | - foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
146 | - $args = $data['arghelp']; |
|
147 | - printf(" --%-19s - %s\n", "$command $args", $data["description"]); |
|
148 | - } |
|
149 | - |
|
150 | - return; |
|
151 | - } |
|
152 | - |
|
153 | - if (!isset($options['daemon'])) { |
|
154 | - require_once "errorhandler.php"; |
|
155 | - } |
|
156 | - |
|
157 | - if (!isset($options['update-schema'])) { |
|
158 | - $schema_version = get_schema_version(); |
|
159 | - |
|
160 | - if ($schema_version != SCHEMA_VERSION) { |
|
161 | - die("Schema version is wrong, please upgrade the database (--update-schema).\n"); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - Debug::set_enabled(true); |
|
166 | - |
|
167 | - if (isset($options["log-level"])) { |
|
168 | - Debug::set_loglevel((int)$options["log-level"]); |
|
119 | + exit; |
|
120 | + } |
|
121 | + |
|
122 | + if (count($options) == 0 || isset($options["help"]) ) { |
|
123 | + print "Tiny Tiny RSS data update script.\n\n"; |
|
124 | + print "Options:\n"; |
|
125 | + print " --feeds - update feeds\n"; |
|
126 | + print " --daemon - start single-process update daemon\n"; |
|
127 | + print " --task N - create lockfile using this task id\n"; |
|
128 | + print " --cleanup-tags - perform tags table maintenance\n"; |
|
129 | + print " --quiet - don't output messages to stdout\n"; |
|
130 | + print " --log FILE - log messages to FILE\n"; |
|
131 | + print " --log-level N - log verbosity level\n"; |
|
132 | + print " --indexes - recreate missing schema indexes\n"; |
|
133 | + print " --update-schema - update database schema\n"; |
|
134 | + print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; |
|
135 | + print " --convert-filters - convert type1 filters to type2\n"; |
|
136 | + print " --send-digests - send pending email digests\n"; |
|
137 | + print " --force-update - force update of all feeds\n"; |
|
138 | + print " --list-plugins - list all available plugins\n"; |
|
139 | + print " --debug-feed N - perform debug update of feed N\n"; |
|
140 | + print " --force-refetch - debug update: force refetch feed data\n"; |
|
141 | + print " --force-rehash - debug update: force rehash articles\n"; |
|
142 | + print " --help - show this help\n"; |
|
143 | + print "Plugin options:\n"; |
|
144 | + |
|
145 | + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
146 | + $args = $data['arghelp']; |
|
147 | + printf(" --%-19s - %s\n", "$command $args", $data["description"]); |
|
148 | + } |
|
149 | + |
|
150 | + return; |
|
151 | + } |
|
152 | + |
|
153 | + if (!isset($options['daemon'])) { |
|
154 | + require_once "errorhandler.php"; |
|
155 | + } |
|
156 | + |
|
157 | + if (!isset($options['update-schema'])) { |
|
158 | + $schema_version = get_schema_version(); |
|
159 | + |
|
160 | + if ($schema_version != SCHEMA_VERSION) { |
|
161 | + die("Schema version is wrong, please upgrade the database (--update-schema).\n"); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + Debug::set_enabled(true); |
|
166 | + |
|
167 | + if (isset($options["log-level"])) { |
|
168 | + Debug::set_loglevel((int)$options["log-level"]); |
|
169 | 169 | } |
170 | 170 | |
171 | - if (isset($options["log"])) { |
|
172 | - Debug::set_quiet(isset($options['quiet'])); |
|
173 | - Debug::set_logfile($options["log"]); |
|
171 | + if (isset($options["log"])) { |
|
172 | + Debug::set_quiet(isset($options['quiet'])); |
|
173 | + Debug::set_logfile($options["log"]); |
|
174 | 174 | Debug::log("Logging to " . $options["log"]); |
175 | 175 | } else { |
176 | - if (isset($options['quiet'])) { |
|
177 | - Debug::set_loglevel(Debug::$LOG_DISABLED); |
|
176 | + if (isset($options['quiet'])) { |
|
177 | + Debug::set_loglevel(Debug::$LOG_DISABLED); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if (!isset($options["daemon"])) { |
|
182 | - $lock_filename = "update.lock"; |
|
183 | - } else { |
|
184 | - $lock_filename = "update_daemon.lock"; |
|
185 | - } |
|
181 | + if (!isset($options["daemon"])) { |
|
182 | + $lock_filename = "update.lock"; |
|
183 | + } else { |
|
184 | + $lock_filename = "update_daemon.lock"; |
|
185 | + } |
|
186 | 186 | |
187 | - if (isset($options["task"])) { |
|
188 | - Debug::log("Using task id " . $options["task"]); |
|
189 | - $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
190 | - } |
|
187 | + if (isset($options["task"])) { |
|
188 | + Debug::log("Using task id " . $options["task"]); |
|
189 | + $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
190 | + } |
|
191 | 191 | |
192 | - if (isset($options["pidlock"])) { |
|
193 | - $my_pid = $options["pidlock"]; |
|
194 | - $lock_filename = "update_daemon-$my_pid.lock"; |
|
192 | + if (isset($options["pidlock"])) { |
|
193 | + $my_pid = $options["pidlock"]; |
|
194 | + $lock_filename = "update_daemon-$my_pid.lock"; |
|
195 | 195 | |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - Debug::log("Lock: $lock_filename"); |
|
198 | + Debug::log("Lock: $lock_filename"); |
|
199 | 199 | |
200 | - $lock_handle = make_lockfile($lock_filename); |
|
201 | - $must_exit = false; |
|
200 | + $lock_handle = make_lockfile($lock_filename); |
|
201 | + $must_exit = false; |
|
202 | 202 | |
203 | - if (isset($options["task"]) && isset($options["pidlock"])) { |
|
204 | - $waits = $options["task"] * 5; |
|
205 | - Debug::log("Waiting before update ($waits)"); |
|
206 | - sleep($waits); |
|
207 | - } |
|
203 | + if (isset($options["task"]) && isset($options["pidlock"])) { |
|
204 | + $waits = $options["task"] * 5; |
|
205 | + Debug::log("Waiting before update ($waits)"); |
|
206 | + sleep($waits); |
|
207 | + } |
|
208 | 208 | |
209 | - // Try to lock a file in order to avoid concurrent update. |
|
210 | - if (!$lock_handle) { |
|
211 | - die("error: Can't create lockfile ($lock_filename). ". |
|
212 | - "Maybe another update process is already running.\n"); |
|
213 | - } |
|
209 | + // Try to lock a file in order to avoid concurrent update. |
|
210 | + if (!$lock_handle) { |
|
211 | + die("error: Can't create lockfile ($lock_filename). ". |
|
212 | + "Maybe another update process is already running.\n"); |
|
213 | + } |
|
214 | 214 | |
215 | - if (isset($options["force-update"])) { |
|
216 | - Debug::log("marking all feeds as needing update..."); |
|
215 | + if (isset($options["force-update"])) { |
|
216 | + Debug::log("marking all feeds as needing update..."); |
|
217 | 217 | |
218 | - $pdo->query( "UPDATE ttrss_feeds SET |
|
218 | + $pdo->query( "UPDATE ttrss_feeds SET |
|
219 | 219 | last_update_started = '1970-01-01', last_updated = '1970-01-01'"); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - if (isset($options["feeds"])) { |
|
223 | - RSSUtils::update_daemon_common(); |
|
224 | - RSSUtils::housekeeping_common(true); |
|
222 | + if (isset($options["feeds"])) { |
|
223 | + RSSUtils::update_daemon_common(); |
|
224 | + RSSUtils::housekeeping_common(true); |
|
225 | 225 | |
226 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
227 | - } |
|
226 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
227 | + } |
|
228 | 228 | |
229 | - if (isset($options["daemon"])) { |
|
230 | - while (true) { |
|
231 | - $quiet = (isset($options["quiet"])) ? "--quiet" : ""; |
|
229 | + if (isset($options["daemon"])) { |
|
230 | + while (true) { |
|
231 | + $quiet = (isset($options["quiet"])) ? "--quiet" : ""; |
|
232 | 232 | $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
233 | 233 | $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
234 | 234 | |
235 | - passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
235 | + passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
236 | 236 | |
237 | - // let's enforce a minimum spawn interval as to not forkbomb the host |
|
238 | - $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
|
237 | + // let's enforce a minimum spawn interval as to not forkbomb the host |
|
238 | + $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
|
239 | 239 | |
240 | - Debug::log("Sleeping for $spawn_interval seconds..."); |
|
241 | - sleep($spawn_interval); |
|
242 | - } |
|
243 | - } |
|
240 | + Debug::log("Sleeping for $spawn_interval seconds..."); |
|
241 | + sleep($spawn_interval); |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | - if (isset($options["daemon-loop"])) { |
|
246 | - if (!make_stampfile('update_daemon.stamp')) { |
|
247 | - Debug::log("warning: unable to create stampfile\n"); |
|
248 | - } |
|
245 | + if (isset($options["daemon-loop"])) { |
|
246 | + if (!make_stampfile('update_daemon.stamp')) { |
|
247 | + Debug::log("warning: unable to create stampfile\n"); |
|
248 | + } |
|
249 | 249 | |
250 | - RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
|
250 | + RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
|
251 | 251 | |
252 | - if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | - RSSUtils::housekeeping_common(true); |
|
252 | + if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | + RSSUtils::housekeeping_common(true); |
|
254 | 254 | |
255 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
256 | - } |
|
255 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
256 | + } |
|
257 | 257 | |
258 | - if (isset($options["cleanup-tags"])) { |
|
259 | - $rc = cleanup_tags( 14, 50000); |
|
260 | - Debug::log("$rc tags deleted.\n"); |
|
261 | - } |
|
258 | + if (isset($options["cleanup-tags"])) { |
|
259 | + $rc = cleanup_tags( 14, 50000); |
|
260 | + Debug::log("$rc tags deleted.\n"); |
|
261 | + } |
|
262 | 262 | |
263 | - if (isset($options["indexes"])) { |
|
264 | - Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
|
265 | - Debug::log("Type 'yes' to continue."); |
|
263 | + if (isset($options["indexes"])) { |
|
264 | + Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
|
265 | + Debug::log("Type 'yes' to continue."); |
|
266 | 266 | |
267 | - if (read_stdin() != 'yes') |
|
268 | - exit; |
|
267 | + if (read_stdin() != 'yes') |
|
268 | + exit; |
|
269 | 269 | |
270 | - Debug::log("clearing existing indexes..."); |
|
270 | + Debug::log("clearing existing indexes..."); |
|
271 | 271 | |
272 | - if (DB_TYPE == "pgsql") { |
|
273 | - $sth = $pdo->query( "SELECT relname FROM |
|
272 | + if (DB_TYPE == "pgsql") { |
|
273 | + $sth = $pdo->query( "SELECT relname FROM |
|
274 | 274 | pg_catalog.pg_class WHERE relname LIKE 'ttrss_%' |
275 | 275 | AND relname NOT LIKE '%_pkey' |
276 | 276 | AND relkind = 'i'"); |
277 | - } else { |
|
278 | - $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
277 | + } else { |
|
278 | + $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
279 | 279 | information_schema.statistics WHERE index_name LIKE 'ttrss_%'"); |
280 | - } |
|
281 | - |
|
282 | - while ($line = $sth->fetch()) { |
|
283 | - if (DB_TYPE == "pgsql") { |
|
284 | - $statement = "DROP INDEX " . $line["relname"]; |
|
285 | - Debug::log($statement); |
|
286 | - } else { |
|
287 | - $statement = "ALTER TABLE ". |
|
288 | - $line['table_name']." DROP INDEX ".$line['index_name']; |
|
289 | - Debug::log($statement); |
|
290 | - } |
|
291 | - $pdo->query($statement); |
|
292 | - } |
|
280 | + } |
|
293 | 281 | |
294 | - Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
282 | + while ($line = $sth->fetch()) { |
|
283 | + if (DB_TYPE == "pgsql") { |
|
284 | + $statement = "DROP INDEX " . $line["relname"]; |
|
285 | + Debug::log($statement); |
|
286 | + } else { |
|
287 | + $statement = "ALTER TABLE ". |
|
288 | + $line['table_name']." DROP INDEX ".$line['index_name']; |
|
289 | + Debug::log($statement); |
|
290 | + } |
|
291 | + $pdo->query($statement); |
|
292 | + } |
|
295 | 293 | |
296 | - $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
297 | - if ($fp) { |
|
298 | - while ($line = fgets($fp)) { |
|
299 | - $matches = array(); |
|
294 | + Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
300 | 295 | |
301 | - if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) { |
|
302 | - $index = $matches[1]; |
|
303 | - $table = $matches[2]; |
|
296 | + $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
297 | + if ($fp) { |
|
298 | + while ($line = fgets($fp)) { |
|
299 | + $matches = array(); |
|
304 | 300 | |
305 | - $statement = "CREATE INDEX $index ON $table"; |
|
301 | + if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) { |
|
302 | + $index = $matches[1]; |
|
303 | + $table = $matches[2]; |
|
306 | 304 | |
307 | - Debug::log($statement); |
|
308 | - $pdo->query($statement); |
|
309 | - } |
|
310 | - } |
|
311 | - fclose($fp); |
|
312 | - } else { |
|
313 | - Debug::log("unable to open schema file."); |
|
314 | - } |
|
315 | - Debug::log("all done."); |
|
316 | - } |
|
305 | + $statement = "CREATE INDEX $index ON $table"; |
|
317 | 306 | |
318 | - if (isset($options["convert-filters"])) { |
|
319 | - Debug::log("WARNING: this will remove all existing type2 filters."); |
|
320 | - Debug::log("Type 'yes' to continue."); |
|
307 | + Debug::log($statement); |
|
308 | + $pdo->query($statement); |
|
309 | + } |
|
310 | + } |
|
311 | + fclose($fp); |
|
312 | + } else { |
|
313 | + Debug::log("unable to open schema file."); |
|
314 | + } |
|
315 | + Debug::log("all done."); |
|
316 | + } |
|
321 | 317 | |
322 | - if (read_stdin() != 'yes') |
|
323 | - exit; |
|
318 | + if (isset($options["convert-filters"])) { |
|
319 | + Debug::log("WARNING: this will remove all existing type2 filters."); |
|
320 | + Debug::log("Type 'yes' to continue."); |
|
324 | 321 | |
325 | - Debug::log("converting filters..."); |
|
322 | + if (read_stdin() != 'yes') |
|
323 | + exit; |
|
326 | 324 | |
327 | - $pdo->query("DELETE FROM ttrss_filters2"); |
|
325 | + Debug::log("converting filters..."); |
|
328 | 326 | |
329 | - $res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id"); |
|
327 | + $pdo->query("DELETE FROM ttrss_filters2"); |
|
330 | 328 | |
331 | - while ($line = $res->fetch()) { |
|
332 | - $owner_uid = $line["owner_uid"]; |
|
329 | + $res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id"); |
|
333 | 330 | |
334 | - // date filters are removed |
|
335 | - if ($line["filter_type"] != 5) { |
|
336 | - $filter = array(); |
|
331 | + while ($line = $res->fetch()) { |
|
332 | + $owner_uid = $line["owner_uid"]; |
|
337 | 333 | |
338 | - if (sql_bool_to_bool($line["cat_filter"])) { |
|
339 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
340 | - } else { |
|
341 | - $feed_id = (int)$line["feed_id"]; |
|
342 | - } |
|
334 | + // date filters are removed |
|
335 | + if ($line["filter_type"] != 5) { |
|
336 | + $filter = array(); |
|
343 | 337 | |
344 | - $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
|
345 | - $filter["rule"] = array( |
|
346 | - json_encode(array( |
|
347 | - "reg_exp" => $line["reg_exp"], |
|
348 | - "feed_id" => $feed_id, |
|
349 | - "filter_type" => $line["filter_type"]))); |
|
338 | + if (sql_bool_to_bool($line["cat_filter"])) { |
|
339 | + $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
340 | + } else { |
|
341 | + $feed_id = (int)$line["feed_id"]; |
|
342 | + } |
|
350 | 343 | |
351 | - $filter["action"] = array( |
|
352 | - json_encode(array( |
|
353 | - "action_id" => $line["action_id"], |
|
354 | - "action_param_label" => $line["action_param"], |
|
355 | - "action_param" => $line["action_param"]))); |
|
344 | + $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
|
345 | + $filter["rule"] = array( |
|
346 | + json_encode(array( |
|
347 | + "reg_exp" => $line["reg_exp"], |
|
348 | + "feed_id" => $feed_id, |
|
349 | + "filter_type" => $line["filter_type"]))); |
|
356 | 350 | |
357 | - // Oh god it's full of hacks |
|
351 | + $filter["action"] = array( |
|
352 | + json_encode(array( |
|
353 | + "action_id" => $line["action_id"], |
|
354 | + "action_param_label" => $line["action_param"], |
|
355 | + "action_param" => $line["action_param"]))); |
|
358 | 356 | |
359 | - $_REQUEST = $filter; |
|
360 | - $_SESSION["uid"] = $owner_uid; |
|
357 | + // Oh god it's full of hacks |
|
361 | 358 | |
362 | - $filters = new Pref_Filters($_REQUEST); |
|
363 | - $filters->add(); |
|
364 | - } |
|
365 | - } |
|
359 | + $_REQUEST = $filter; |
|
360 | + $_SESSION["uid"] = $owner_uid; |
|
366 | 361 | |
367 | - } |
|
362 | + $filters = new Pref_Filters($_REQUEST); |
|
363 | + $filters->add(); |
|
364 | + } |
|
365 | + } |
|
368 | 366 | |
369 | - if (isset($options["update-schema"])) { |
|
370 | - Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
367 | + } |
|
368 | + |
|
369 | + if (isset($options["update-schema"])) { |
|
370 | + Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
371 | 371 | |
372 | - $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION); |
|
372 | + $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION); |
|
373 | 373 | |
374 | - if ($updater->isUpdateRequired()) { |
|
375 | - Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
374 | + if ($updater->isUpdateRequired()) { |
|
375 | + Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
376 | 376 | |
377 | - if (DB_TYPE == "mysql") |
|
378 | - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | - "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
|
380 | - else |
|
381 | - Debug::log("WARNING: please backup your database before continuing."); |
|
377 | + if (DB_TYPE == "mysql") |
|
378 | + Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | + "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
|
380 | + else |
|
381 | + Debug::log("WARNING: please backup your database before continuing."); |
|
382 | 382 | |
383 | - Debug::log("Type 'yes' to continue."); |
|
383 | + Debug::log("Type 'yes' to continue."); |
|
384 | 384 | |
385 | - if (read_stdin() != 'yes') |
|
386 | - exit; |
|
385 | + if (read_stdin() != 'yes') |
|
386 | + exit; |
|
387 | 387 | |
388 | - Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
388 | + Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
389 | 389 | |
390 | - for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
|
391 | - Debug::log("* Updating to version $i..."); |
|
390 | + for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
|
391 | + Debug::log("* Updating to version $i..."); |
|
392 | 392 | |
393 | - $result = $updater->performUpdateTo($i, false); |
|
393 | + $result = $updater->performUpdateTo($i, false); |
|
394 | 394 | |
395 | - if ($result) { |
|
396 | - Debug::log("* Completed."); |
|
397 | - } else { |
|
398 | - Debug::log("One of the updates failed. Either retry the process or perform updates manually."); |
|
399 | - return; |
|
400 | - } |
|
395 | + if ($result) { |
|
396 | + Debug::log("* Completed."); |
|
397 | + } else { |
|
398 | + Debug::log("One of the updates failed. Either retry the process or perform updates manually."); |
|
399 | + return; |
|
400 | + } |
|
401 | 401 | |
402 | - } |
|
403 | - } else { |
|
404 | - Debug::log("Update not required."); |
|
405 | - } |
|
402 | + } |
|
403 | + } else { |
|
404 | + Debug::log("Update not required."); |
|
405 | + } |
|
406 | 406 | |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - if (isset($options["gen-search-idx"])) { |
|
410 | - echo "Generating search index (stemming set to English)...\n"; |
|
409 | + if (isset($options["gen-search-idx"])) { |
|
410 | + echo "Generating search index (stemming set to English)...\n"; |
|
411 | 411 | |
412 | - $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL"); |
|
413 | - $row = $res->fetch(); |
|
414 | - $count = $row['count']; |
|
412 | + $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL"); |
|
413 | + $row = $res->fetch(); |
|
414 | + $count = $row['count']; |
|
415 | 415 | |
416 | - print "Articles to process: $count.\n"; |
|
416 | + print "Articles to process: $count.\n"; |
|
417 | 417 | |
418 | - $limit = 500; |
|
419 | - $processed = 0; |
|
418 | + $limit = 500; |
|
419 | + $processed = 0; |
|
420 | 420 | |
421 | - $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE |
|
421 | + $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE |
|
422 | 422 | tsvector_combined IS NULL ORDER BY id LIMIT ?"); |
423 | - $sth->execute([$limit]); |
|
423 | + $sth->execute([$limit]); |
|
424 | 424 | |
425 | - $usth = $pdo->prepare("UPDATE ttrss_entries |
|
425 | + $usth = $pdo->prepare("UPDATE ttrss_entries |
|
426 | 426 | SET tsvector_combined = to_tsvector('english', ?) WHERE id = ?"); |
427 | 427 | |
428 | - while (true) { |
|
428 | + while (true) { |
|
429 | 429 | |
430 | - while ($line = $sth->fetch()) { |
|
431 | - $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
430 | + while ($line = $sth->fetch()) { |
|
431 | + $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
432 | 432 | |
433 | - $usth->execute([$tsvector_combined, $line['id']]); |
|
433 | + $usth->execute([$tsvector_combined, $line['id']]); |
|
434 | 434 | |
435 | - $processed++; |
|
436 | - } |
|
435 | + $processed++; |
|
436 | + } |
|
437 | 437 | |
438 | - print "processed $processed articles...\n"; |
|
438 | + print "processed $processed articles...\n"; |
|
439 | 439 | |
440 | - if ($processed < $limit) { |
|
441 | - echo "All done.\n"; |
|
442 | - break; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
440 | + if ($processed < $limit) { |
|
441 | + echo "All done.\n"; |
|
442 | + break; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | 446 | |
447 | - if (isset($options["list-plugins"])) { |
|
448 | - $tmppluginhost = new PluginHost(); |
|
449 | - $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false); |
|
450 | - $enabled = array_map("trim", explode(",", PLUGINS)); |
|
447 | + if (isset($options["list-plugins"])) { |
|
448 | + $tmppluginhost = new PluginHost(); |
|
449 | + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false); |
|
450 | + $enabled = array_map("trim", explode(",", PLUGINS)); |
|
451 | 451 | |
452 | - echo "List of all available plugins:\n"; |
|
452 | + echo "List of all available plugins:\n"; |
|
453 | 453 | |
454 | - foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
455 | - $about = $plugin->about(); |
|
454 | + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
455 | + $about = $plugin->about(); |
|
456 | 456 | |
457 | - $status = $about[3] ? "system" : "user"; |
|
457 | + $status = $about[3] ? "system" : "user"; |
|
458 | 458 | |
459 | - if (in_array($name, $enabled)) $name .= "*"; |
|
459 | + if (in_array($name, $enabled)) $name .= "*"; |
|
460 | 460 | |
461 | - printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
|
462 | - $name, $status, $about[0], $about[2], $about[1]); |
|
463 | - } |
|
461 | + printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
|
462 | + $name, $status, $about[0], $about[2], $about[1]); |
|
463 | + } |
|
464 | 464 | |
465 | - echo "Plugins marked by * are currently enabled for all users.\n"; |
|
465 | + echo "Plugins marked by * are currently enabled for all users.\n"; |
|
466 | 466 | |
467 | - } |
|
467 | + } |
|
468 | 468 | |
469 | - if (isset($options["debug-feed"])) { |
|
470 | - $feed = $options["debug-feed"]; |
|
469 | + if (isset($options["debug-feed"])) { |
|
470 | + $feed = $options["debug-feed"]; |
|
471 | 471 | |
472 | - if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | - if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
472 | + if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | + if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
474 | 474 | |
475 | - Debug::set_loglevel(Debug::$LOG_EXTENDED); |
|
475 | + Debug::set_loglevel(Debug::$LOG_EXTENDED); |
|
476 | 476 | |
477 | - $rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1; |
|
477 | + $rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1; |
|
478 | 478 | |
479 | - exit($rc); |
|
480 | - } |
|
479 | + exit($rc); |
|
480 | + } |
|
481 | 481 | |
482 | - if (isset($options["send-digests"])) { |
|
483 | - Digest::send_headlines_digests(); |
|
484 | - } |
|
482 | + if (isset($options["send-digests"])) { |
|
483 | + Digest::send_headlines_digests(); |
|
484 | + } |
|
485 | 485 | |
486 | - PluginHost::getInstance()->run_commands($options); |
|
486 | + PluginHost::getInstance()->run_commands($options); |
|
487 | 487 | |
488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | - fclose($lock_handle); |
|
491 | - unlink(LOCK_DIRECTORY . "/$lock_filename"); |
|
488 | + if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | + fclose($lock_handle); |
|
491 | + unlink(LOCK_DIRECTORY . "/$lock_filename"); |