Passed
Push — master ( 678db7...164b32 )
by Cody
06:12 queued 03:06
created
plugins/share/init.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,142 +1,142 @@
 block discarded – undo
1 1
 <?php
2 2
 class Share extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Share article by unique URL",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Share article by unique URL",
8
+            "fox");
9
+    }
10 10
 
11
-	/* @var PluginHost $host */
12
-	public function init($host) {
13
-		$this->host = $host;
11
+    /* @var PluginHost $host */
12
+    public function init($host) {
13
+        $this->host = $host;
14 14
 
15
-		$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
16
-		$host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this);
17
-	}
15
+        $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
16
+        $host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this);
17
+    }
18 18
 
19
-	public function get_js() {
20
-		return file_get_contents(dirname(__FILE__)."/share.js");
21
-	}
19
+    public function get_js() {
20
+        return file_get_contents(dirname(__FILE__)."/share.js");
21
+    }
22 22
 
23
-	public function get_css() {
24
-		return file_get_contents(dirname(__FILE__)."/share.css");
25
-	}
23
+    public function get_css() {
24
+        return file_get_contents(dirname(__FILE__)."/share.css");
25
+    }
26 26
 
27
-	public function get_prefs_js() {
28
-		return file_get_contents(dirname(__FILE__)."/share_prefs.js");
29
-	}
27
+    public function get_prefs_js() {
28
+        return file_get_contents(dirname(__FILE__)."/share_prefs.js");
29
+    }
30 30
 
31 31
 
32
-	public function unshare() {
33
-		$id = $_REQUEST['id'];
32
+    public function unshare() {
33
+        $id = $_REQUEST['id'];
34 34
 
35
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = ?
35
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = ?
36 36
 			AND owner_uid = ?");
37
-		$sth->execute([$id, $_SESSION['uid']]);
37
+        $sth->execute([$id, $_SESSION['uid']]);
38 38
 
39
-		print "OK";
40
-	}
39
+        print "OK";
40
+    }
41 41
 
42
-	public function hook_prefs_tab_section($id) {
43
-		if ($id == "prefFeedsPublishedGenerated") {
42
+    public function hook_prefs_tab_section($id) {
43
+        if ($id == "prefFeedsPublishedGenerated") {
44 44
 
45
-			print "<h3>".__("You can disable all articles shared by unique URLs here.")."</h3>";
45
+            print "<h3>".__("You can disable all articles shared by unique URLs here.")."</h3>";
46 46
 
47
-			print "<button class='alt-danger' dojoType='dijit.form.Button' onclick=\"return Plugins.Share.clearKeys()\">".
48
-				__('Unshare all articles')."</button> ";
47
+            print "<button class='alt-danger' dojoType='dijit.form.Button' onclick=\"return Plugins.Share.clearKeys()\">".
48
+                __('Unshare all articles')."</button> ";
49 49
 
50
-			print "</p>";
50
+            print "</p>";
51 51
 
52
-		}
53
-	}
52
+        }
53
+    }
54 54
 
55
-	// Silent
56
-	public function clearArticleKeys() {
57
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE
55
+    // Silent
56
+    public function clearArticleKeys() {
57
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE
58 58
 			owner_uid = ?");
59
-		$sth->execute([$_SESSION['uid']]);
59
+        $sth->execute([$_SESSION['uid']]);
60 60
 
61
-		return;
62
-	}
61
+        return;
62
+    }
63 63
 
64 64
 
65
-	public function newkey() {
66
-		$id = $_REQUEST['id'];
67
-		$uuid = uniqid_short();
65
+    public function newkey() {
66
+        $id = $_REQUEST['id'];
67
+        $uuid = uniqid_short();
68 68
 
69
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
69
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
70 70
 			AND owner_uid = ?");
71
-		$sth->execute([$uuid, $id, $_SESSION['uid']]);
71
+        $sth->execute([$uuid, $id, $_SESSION['uid']]);
72 72
 
73
-		print json_encode(array("link" => $uuid));
74
-	}
73
+        print json_encode(array("link" => $uuid));
74
+    }
75 75
 
76
-	public function hook_article_button($line) {
77
-		$img_class = $line['uuid'] ? "shared" : "";
76
+    public function hook_article_button($line) {
77
+        $img_class = $line['uuid'] ? "shared" : "";
78 78
 
79
-		return "<i id='SHARE-IMG-".$line['int_id']."' class='material-icons icon-share $img_class'
79
+        return "<i id='SHARE-IMG-".$line['int_id']."' class='material-icons icon-share $img_class'
80 80
 			style='cursor : pointer' onclick=\"Plugins.Share.shareArticle(".$line['int_id'].")\"
81 81
 			title='".__('Share by URL')."'>link</i>";
82
-	}
82
+    }
83 83
 
84
-	public function shareArticle() {
85
-		$param = $_REQUEST['param'];
84
+    public function shareArticle() {
85
+        $param = $_REQUEST['param'];
86 86
 
87
-		$sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ?
87
+        $sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ?
88 88
 			AND owner_uid = ?");
89
-		$sth->execute([$param, $_SESSION['uid']]);
89
+        $sth->execute([$param, $_SESSION['uid']]);
90 90
 
91
-		if ($row = $sth->fetch()) {
91
+        if ($row = $sth->fetch()) {
92 92
 
93
-			$uuid = $row['uuid'];
93
+            $uuid = $row['uuid'];
94 94
 
95
-			if (!$uuid) {
96
-				$uuid = uniqid_short();
95
+            if (!$uuid) {
96
+                $uuid = uniqid_short();
97 97
 
98
-				$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
98
+                $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
99 99
 					AND owner_uid = ?");
100
-				$sth->execute([$uuid, $param, $_SESSION['uid']]);
101
-			}
100
+                $sth->execute([$uuid, $param, $_SESSION['uid']]);
101
+            }
102 102
 
103
-			print "<header>".__("You can share this article by the following unique URL:")."</header>";
103
+            print "<header>".__("You can share this article by the following unique URL:")."</header>";
104 104
 
105
-			$url_path = get_self_url_prefix();
106
-			$url_path .= "/public.php?op=share&key=$uuid";
105
+            $url_path = get_self_url_prefix();
106
+            $url_path .= "/public.php?op=share&key=$uuid";
107 107
 
108
-			print "<section>
108
+            print "<section>
109 109
 				<div class='panel text-center'>
110 110
 				<a id='gen_article_url' href='$url_path' target='_blank' rel='noopener noreferrer'>$url_path</a>
111 111
 				</div>
112 112
 				</section>";
113 113
 
114
-			/* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
114
+            /* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
115 115
 				label_create(__('Shared'), $_SESSION["uid"]);
116 116
 
117 117
 			label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */
118 118
 
119 119
 
120
-		} else {
121
-			print "Article not found.";
122
-		}
120
+        } else {
121
+            print "Article not found.";
122
+        }
123 123
 
124
-		print "<footer class='text-center'>";
124
+        print "<footer class='text-center'>";
125 125
 
126
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').unshare()\">".
127
-			__('Unshare article')."</button>";
126
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').unshare()\">".
127
+            __('Unshare article')."</button>";
128 128
 
129
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').newurl()\">".
130
-			__('Generate new URL')."</button>";
129
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').newurl()\">".
130
+            __('Generate new URL')."</button>";
131 131
 
132
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
133
-			__('Close this window')."</button>";
132
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
133
+            __('Close this window')."</button>";
134 134
 
135
-		print "</footer>";
136
-	}
135
+        print "</footer>";
136
+    }
137 137
 
138
-	public function api_version() {
139
-		return 2;
140
-	}
138
+    public function api_version() {
139
+        return 2;
140
+    }
141 141
 
142 142
 }
Please login to merge, or discard this patch.
plugins/mail/init.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
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") {
34
-		    return;
35
-		}
32
+    public function hook_prefs_tab($args) {
33
+        if ($args != "prefPrefs") {
34
+            return;
35
+        }
36 36
 
37
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
37
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
38 38
 			title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">";
39 39
 
40
-		print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>";
40
+        print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>";
41 41
 
42
-		print "<form dojoType=\"dijit.form.Form\">";
42
+        print "<form dojoType=\"dijit.form.Form\">";
43 43
 
44
-		print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
44
+        print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
45 45
 			evt.preventDefault();
46 46
 			if (this.validate()) {
47 47
 				console.log(dojo.objectToQuery(this.getValues()));
@@ -55,140 +55,140 @@  discard block
 block discarded – undo
55 55
 			}
56 56
 			</script>";
57 57
 
58
-			print_hidden("op", "pluginhandler");
59
-			print_hidden("method", "save");
60
-			print_hidden("plugin", "mail");
58
+            print_hidden("op", "pluginhandler");
59
+            print_hidden("method", "save");
60
+            print_hidden("plugin", "mail");
61 61
 
62
-			$addresslist = $this->host->get($this, "addresslist");
62
+            $addresslist = $this->host->get($this, "addresslist");
63 63
 
64
-			print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\"
64
+            print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\"
65 65
 				name='addresslist'>$addresslist</textarea>";
66 66
 
67
-			print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
68
-				__("Save")."</button>";
67
+            print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
68
+                __("Save")."</button>";
69 69
 
70
-			print "</form>";
70
+            print "</form>";
71 71
 
72
-		print "</div>";
73
-	}
72
+        print "</div>";
73
+    }
74 74
 
75
-	public function hook_article_button($line) {
76
-		return "<i class='material-icons' style=\"cursor : pointer\"
75
+    public function hook_article_button($line) {
76
+        return "<i class='material-icons' style=\"cursor : pointer\"
77 77
 					onclick=\"Plugins.Mail.send(".$line["id"].")\"
78 78
 					title='".__('Forward by email')."'>mail</i>";
79
-	}
79
+    }
80 80
 
81
-	public function emailArticle() {
81
+    public function emailArticle() {
82 82
 
83
-		$ids = explode(",", $_REQUEST['param']);
84
-		$ids_qmarks = arr_qmarks($ids);
83
+        $ids = explode(",", $_REQUEST['param']);
84
+        $ids_qmarks = arr_qmarks($ids);
85 85
 
86
-		print_hidden("op", "pluginhandler");
87
-		print_hidden("plugin", "mail");
88
-		print_hidden("method", "sendEmail");
86
+        print_hidden("op", "pluginhandler");
87
+        print_hidden("plugin", "mail");
88
+        print_hidden("method", "sendEmail");
89 89
 
90
-		$sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE
90
+        $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE
91 91
 			id = ?");
92
-		$sth->execute([$_SESSION['uid']]);
92
+        $sth->execute([$_SESSION['uid']]);
93 93
 
94
-		if ($row = $sth->fetch()) {
95
-			$user_email = htmlspecialchars($row['email']);
96
-			$user_name = htmlspecialchars($row['full_name']);
97
-		}
94
+        if ($row = $sth->fetch()) {
95
+            $user_email = htmlspecialchars($row['email']);
96
+            $user_name = htmlspecialchars($row['full_name']);
97
+        }
98 98
 
99
-		if (!$user_name) {
100
-		    $user_name = $_SESSION['name'];
101
-		}
99
+        if (!$user_name) {
100
+            $user_name = $_SESSION['name'];
101
+        }
102 102
 
103
-		print_hidden("from_email", "$user_email");
104
-		print_hidden("from_name", "$user_name");
103
+        print_hidden("from_email", "$user_email");
104
+        print_hidden("from_name", "$user_name");
105 105
 
106
-		require_once "lib/MiniTemplator.class.php";
106
+        require_once "lib/MiniTemplator.class.php";
107 107
 
108
-		$tpl = new MiniTemplator;
108
+        $tpl = new MiniTemplator;
109 109
 
110
-		$tpl->readTemplateFromFile("templates/email_article_template.txt");
110
+        $tpl->readTemplateFromFile("templates/email_article_template.txt");
111 111
 
112
-		$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
113
-		$tpl->setVariable('USER_EMAIL', $user_email, true);
114
-		$tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
112
+        $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
113
+        $tpl->setVariable('USER_EMAIL', $user_email, true);
114
+        $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
115 115
 
116
-		$sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note
116
+        $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note
117 117
 			FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
118 118
 			id IN ($ids_qmarks) AND owner_uid = ?");
119
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
119
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
120 120
 
121
-		if (count($ids) > 1) {
122
-			$subject = __("[Forwarded]")." ".__("Multiple articles");
123
-		}
121
+        if (count($ids) > 1) {
122
+            $subject = __("[Forwarded]")." ".__("Multiple articles");
123
+        }
124 124
 
125
-		while ($line = $sth->fetch()) {
125
+        while ($line = $sth->fetch()) {
126 126
 
127
-			if (!$subject)
128
-				$subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]);
127
+            if (!$subject)
128
+                $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]);
129 129
 
130
-			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
131
-			$tnote = strip_tags($line["note"]);
132
-			if ($tnote != '') {
133
-				$tpl->setVariable('ARTICLE_NOTE', $tnote, true);
134
-				$tpl->addBlock('note');
135
-			}
136
-			$tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
130
+            $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
131
+            $tnote = strip_tags($line["note"]);
132
+            if ($tnote != '') {
133
+                $tpl->setVariable('ARTICLE_NOTE', $tnote, true);
134
+                $tpl->addBlock('note');
135
+            }
136
+            $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
137 137
 
138
-			$tpl->addBlock('article');
139
-		}
138
+            $tpl->addBlock('article');
139
+        }
140 140
 
141
-		$tpl->addBlock('email');
141
+        $tpl->addBlock('email');
142 142
 
143
-		$content = "";
144
-		$tpl->generateOutputToString($content);
143
+        $content = "";
144
+        $tpl->generateOutputToString($content);
145 145
 
146
-		print "<table width='100%'><tr><td>";
146
+        print "<table width='100%'><tr><td>";
147 147
 
148
-		$addresslist = explode(",", $this->host->get($this, "addresslist"));
148
+        $addresslist = explode(",", $this->host->get($this, "addresslist"));
149 149
 
150
-		print __('To:');
150
+        print __('To:');
151 151
 
152
-		print "</td><td>";
152
+        print "</td><td>";
153 153
 
154 154
 /*		print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
155 155
 				style=\"width : 30em;\"
156 156
 				name=\"destination\" id=\"emailArticleDlg_destination\">"; */
157 157
 
158
-		print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"');
158
+        print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"');
159 159
 
160 160
 /*		print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\"
161 161
 	style=\"z-index: 30; display : none\"></div>"; */
162 162
 
163
-		print "</td></tr><tr><td>";
163
+        print "</td></tr><tr><td>";
164 164
 
165
-		print __('Subject:');
165
+        print __('Subject:');
166 166
 
167
-		print "</td><td>";
167
+        print "</td><td>";
168 168
 
169
-		print "<input dojoType='dijit.form.ValidationTextBox' required='true'
169
+        print "<input dojoType='dijit.form.ValidationTextBox' required='true'
170 170
 				style='width : 30em;' name='subject' value=\"$subject\" id='subject'>";
171 171
 
172
-		print "</td></tr>";
172
+        print "</td></tr>";
173 173
 
174
-		print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea'
174
+        print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea'
175 175
 			style='height : 200px; font-size : 12px; width : 98%' rows=\"20\"
176 176
 			name='content'>$content</textarea>";
177 177
 
178
-		print "</td></tr></table>";
178
+        print "</td></tr></table>";
179 179
 
180
-		print "<footer>";
181
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
182
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
183
-		print "</footer>";
180
+        print "<footer>";
181
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
182
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
183
+        print "</footer>";
184 184
 
185
-		//return;
186
-	}
185
+        //return;
186
+    }
187 187
 
188
-	public function sendEmail() {
189
-		$reply = array();
188
+    public function sendEmail() {
189
+        $reply = array();
190 190
 
191
-		/*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
191
+        /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
192 192
 			strip_tags($_REQUEST['from_name']));
193 193
 		//$mail->AddAddress($_REQUEST['destination']);
194 194
 		$addresses = explode(';', $_REQUEST['destination']);
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
 
202 202
 		$rc = $mail->Send(); */
203 203
 
204
-		$to = $_REQUEST["destination"];
205
-		$subject = strip_tags($_REQUEST["subject"]);
206
-		$message = strip_tags($_REQUEST["content"]);
207
-		$from = strip_tags($_REQUEST["from_email"]);
204
+        $to = $_REQUEST["destination"];
205
+        $subject = strip_tags($_REQUEST["subject"]);
206
+        $message = strip_tags($_REQUEST["content"]);
207
+        $from = strip_tags($_REQUEST["from_email"]);
208 208
 
209
-		$mailer = new Mailer();
209
+        $mailer = new Mailer();
210 210
 
211
-		$rc = $mailer->mail(["to_address" => $to,
212
-			"headers" => ["Reply-To: $from"],
213
-			"subject" => $subject,
214
-			"message" => $message]);
211
+        $rc = $mailer->mail(["to_address" => $to,
212
+            "headers" => ["Reply-To: $from"],
213
+            "subject" => $subject,
214
+            "message" => $message]);
215 215
 
216
-		if (!$rc) {
217
-			$reply['error'] = $mailer->error();
218
-		} else {
219
-			//save_email_address($destination);
220
-			$reply['message'] = "UPDATE_COUNTERS";
221
-		}
216
+        if (!$rc) {
217
+            $reply['error'] = $mailer->error();
218
+        } else {
219
+            //save_email_address($destination);
220
+            $reply['message'] = "UPDATE_COUNTERS";
221
+        }
222 222
 
223
-		print json_encode($reply);
224
-	}
223
+        print json_encode($reply);
224
+    }
225 225
 
226
-	/* function completeEmails() {
226
+    /* function completeEmails() {
227 227
 		$search = $_REQUEST["search"];
228 228
 
229 229
 		print "<ul>";
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 		print "</ul>";
238 238
 	} */
239 239
 
240
-	public function api_version() {
241
-		return 2;
242
-	}
240
+    public function api_version() {
241
+        return 2;
242
+    }
243 243
 
244 244
 }
Please login to merge, or discard this patch.
plugins/af_zz_noautoplay/init.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Zz_NoAutoPlay extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Don't autoplay HTML5 videos",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Don't autoplay HTML5 videos",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
13
-	}
11
+    public function init($host) {
12
+        $this->host = $host;
13
+    }
14 14
 
15
-	public function get_js() {
16
-		return file_get_contents(__DIR__."/init.js");
17
-	}
15
+    public function get_js() {
16
+        return file_get_contents(__DIR__."/init.js");
17
+    }
18 18
 
19
-	public function api_version() {
20
-		return 2;
21
-	}
19
+    public function api_version() {
20
+        return 2;
21
+    }
22 22
 
23 23
 }
Please login to merge, or discard this patch.
plugins/no_url_hashes/init.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
 class No_URL_Hashes extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Disable URL hash usage (e.g. #f=10, etc)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Disable URL hash usage (e.g. #f=10, etc)",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
11
+    public function init($host) {
12
+        $this->host = $host;
13 13
 
14
-	}
14
+    }
15 15
 
16
-	public function get_js() {
17
-		return file_get_contents(__DIR__."/init.js");
18
-	}
16
+    public function get_js() {
17
+        return file_get_contents(__DIR__."/init.js");
18
+    }
19 19
 
20
-	public function api_version() {
21
-		return 2;
22
-	}
20
+    public function api_version() {
21
+        return 2;
22
+    }
23 23
 
24 24
 }
Please login to merge, or discard this patch.
plugins/shorten_expanded/init.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if (file_exists("install") && !file_exists("config.php")) {
3
-		header("Location: install/");
4
-	}
2
+    if (file_exists("install") && !file_exists("config.php")) {
3
+        header("Location: install/");
4
+    }
5 5
 
6
-	if (!file_exists("config.php")) {
7
-		print "<b>Fatal Error</b>: You forgot to copy
6
+    if (!file_exists("config.php")) {
7
+        print "<b>Fatal Error</b>: You forgot to copy
8 8
 		<b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
9
-		exit;
10
-	}
9
+        exit;
10
+    }
11 11
 
12
-	// we need a separate check here because functions.php might get parsed
13
-	// incorrectly before 5.3 because of :: syntax.
14
-	if (version_compare(PHP_VERSION, '5.6.0', '<')) {
15
-		print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using ".PHP_VERSION.".\n";
16
-		exit;
17
-	}
12
+    // we need a separate check here because functions.php might get parsed
13
+    // incorrectly before 5.3 because of :: syntax.
14
+    if (version_compare(PHP_VERSION, '5.6.0', '<')) {
15
+        print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using ".PHP_VERSION.".\n";
16
+        exit;
17
+    }
18 18
 
19
-	set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR.
20
-		get_include_path());
19
+    set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR.
20
+        get_include_path());
21 21
 
22
-	require_once "autoload.php";
23
-	require_once "sessions.php";
24
-	require_once "functions.php";
25
-	require_once "sanity_check.php";
26
-	require_once "config.php";
27
-	require_once "db-prefs.php";
22
+    require_once "autoload.php";
23
+    require_once "sessions.php";
24
+    require_once "functions.php";
25
+    require_once "sanity_check.php";
26
+    require_once "config.php";
27
+    require_once "db-prefs.php";
28 28
 
29
-	if (!init_plugins()) {
30
-	    return;
31
-	}
29
+    if (!init_plugins()) {
30
+        return;
31
+    }
32 32
 
33
-	login_sequence();
33
+    login_sequence();
34 34
 
35
-	header('Content-Type: text/html; charset=utf-8');
35
+    header('Content-Type: text/html; charset=utf-8');
36 36
 
37 37
 ?>
38 38
 <!DOCTYPE html>
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
     <meta name="viewport" content="initial-scale=1,width=device-width" />
43 43
 
44 44
 	<?php if ($_SESSION["uid"]) {
45
-		$theme = get_pref("USER_CSS_THEME", false, false);
46
-		if ($theme && theme_exists("$theme")) {
47
-			echo stylesheet_tag(get_theme_path($theme), 'theme_css');
48
-		}
49
-	}
45
+        $theme = get_pref("USER_CSS_THEME", false, false);
46
+        if ($theme && theme_exists("$theme")) {
47
+            echo stylesheet_tag(get_theme_path($theme), 'theme_css');
48
+        }
49
+    }
50 50
 
51
-	print_user_stylesheet()
51
+    print_user_stylesheet()
52 52
 
53
-	?>
53
+    ?>
54 54
 	<style type="text/css">
55 55
 	<?php
56
-		foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
57
-			if (method_exists($p, "get_css")) {
58
-				echo $p->get_css();
59
-			}
60
-		}
61
-	?>
56
+        foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
57
+            if (method_exists($p, "get_css")) {
58
+                echo $p->get_css();
59
+            }
60
+        }
61
+    ?>
62 62
 	</style>
63 63
 
64 64
 	<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 	</script>
76 76
 
77 77
 	<?php
78
-	foreach (array("lib/prototype.js",
79
-				"lib/scriptaculous/scriptaculous.js?load=effects,controls",
80
-				"lib/dojo/dojo.js",
81
-				"lib/dojo/tt-rss-layer.js",
82
-				"js/tt-rss.js",
83
-				"js/common.js",
84
-				"errors.php?mode=js") as $jsfile) {
78
+    foreach (array("lib/prototype.js",
79
+                "lib/scriptaculous/scriptaculous.js?load=effects,controls",
80
+                "lib/dojo/dojo.js",
81
+                "lib/dojo/tt-rss-layer.js",
82
+                "js/tt-rss.js",
83
+                "js/common.js",
84
+                "errors.php?mode=js") as $jsfile) {
85 85
 
86
-		echo javascript_tag($jsfile);
86
+        echo javascript_tag($jsfile);
87 87
 
88
-	} ?>
88
+    } ?>
89 89
 
90 90
 	<script type="text/javascript">
91 91
 		require({cache:{}});
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
 
94 94
 	<script type="text/javascript">
95 95
 	<?php
96
-		foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
97
-			if (method_exists($p, "get_js")) {
98
-			    $script = $p->get_js();
96
+        foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
97
+            if (method_exists($p, "get_js")) {
98
+                $script = $p->get_js();
99 99
 
100
-			    if ($script) {
101
-					echo "try {
100
+                if ($script) {
101
+                    echo "try {
102 102
 					    $script
103 103
 					} catch (e) {
104 104
                         console.warn('failed to initialize plugin JS: $n', e);
105 105
                     }";
106
-				}
107
-			}
108
-		}
106
+                }
107
+            }
108
+        }
109 109
 
110
-		init_js_translations();
111
-	?>
110
+        init_js_translations();
111
+    ?>
112 112
 	</script>
113 113
 
114 114
 	<style type="text/css">
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
             <img src='images/indicator_tiny.gif'/>
149 149
             <?php echo  __("Loading, please wait..."); ?></div>
150 150
         <?php
151
-          foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) {
151
+            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) {
152 152
             echo $p->hook_feed_tree();
153
-          }
153
+            }
154 154
         ?>
155 155
         <div id="feedTree"></div>
156 156
     </div>
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
                 <?php
225 225
                     foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
226
-                         echo $p->hook_toolbar_button();
226
+                            echo $p->hook_toolbar_button();
227 227
                     }
228 228
                 ?>
229 229
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 
246 246
                         <?php
247 247
                             foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
248
-                             echo $p->hook_action_item();
248
+                                echo $p->hook_action_item();
249 249
                             }
250 250
                         ?>
251 251
 
Please login to merge, or discard this patch.
public.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
1 1
 <?php
2
-	set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR.
3
-		get_include_path());
4
-
5
-	require_once "autoload.php";
6
-	require_once "sessions.php";
7
-	require_once "functions.php";
8
-	require_once "sanity_check.php";
9
-	require_once "config.php";
10
-	require_once "db.php";
11
-	require_once "db-prefs.php";
12
-
13
-	startup_gettext();
14
-
15
-	$script_started = microtime(true);
16
-
17
-	if (!init_plugins()) {
18
-	    return;
19
-	}
20
-
21
-	if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
22
-		ob_start("ob_gzhandler");
23
-	}
24
-
25
-	$method = $_REQUEST["op"];
26
-
27
-	$override = PluginHost::getInstance()->lookup_handler("public", $method);
28
-
29
-	if ($override) {
30
-		$handler = $override;
31
-	} else {
32
-		$handler = new Handler_Public($_REQUEST);
33
-	}
34
-
35
-	if (implements_interface($handler, "IHandler") && $handler->before($method)) {
36
-		if ($method && method_exists($handler, $method)) {
37
-			$handler->$method();
38
-		} else if (method_exists($handler, 'index')) {
39
-			$handler->index();
40
-		}
41
-		$handler->after();
42
-		return;
43
-	}
44
-
45
-	header("Content-Type: text/plain");
46
-	print error_json(13);
2
+    set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR.
3
+        get_include_path());
4
+
5
+    require_once "autoload.php";
6
+    require_once "sessions.php";
7
+    require_once "functions.php";
8
+    require_once "sanity_check.php";
9
+    require_once "config.php";
10
+    require_once "db.php";
11
+    require_once "db-prefs.php";
12
+
13
+    startup_gettext();
14
+
15
+    $script_started = microtime(true);
16
+
17
+    if (!init_plugins()) {
18
+        return;
19
+    }
20
+
21
+    if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
22
+        ob_start("ob_gzhandler");
23
+    }
24
+
25
+    $method = $_REQUEST["op"];
26
+
27
+    $override = PluginHost::getInstance()->lookup_handler("public", $method);
28
+
29
+    if ($override) {
30
+        $handler = $override;
31
+    } else {
32
+        $handler = new Handler_Public($_REQUEST);
33
+    }
34
+
35
+    if (implements_interface($handler, "IHandler") && $handler->before($method)) {
36
+        if ($method && method_exists($handler, $method)) {
37
+            $handler->$method();
38
+        } else if (method_exists($handler, 'index')) {
39
+            $handler->index();
40
+        }
41
+        $handler->after();
42
+        return;
43
+    }
44
+
45
+    header("Content-Type: text/plain");
46
+    print error_json(13);
Please login to merge, or discard this patch.
update.php 1 patch
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -1,108 +1,108 @@  discard block
 block discarded – undo
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
-
66
-	$pdo = Db::pdo();
67
-
68
-	init_plugins();
69
-
70
-	$longopts = array("feeds",
71
-			"daemon",
72
-			"daemon-loop",
73
-			"send-digests",
74
-			"task:",
75
-			"cleanup-tags",
76
-			"quiet",
77
-			"log:",
78
-			"log-level:",
79
-			"indexes",
80
-			"pidlock:",
81
-			"update-schema",
82
-			"convert-filters",
83
-			"force-update",
84
-			"gen-search-idx",
85
-			"list-plugins",
86
-			"debug-feed:",
87
-			"force-refetch",
88
-			"force-rehash",
89
-			"help");
90
-
91
-	foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
92
-		array_push($longopts, $command.$data["suffix"]);
93
-	}
94
-
95
-	$options = getopt("", $longopts);
96
-
97
-	if (!is_array($options)) {
98
-		die("error: getopt() failed. ".
99
-			"Most probably you are using PHP CGI to run this script ".
100
-			"instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ".
101
-			"additional information.\n");
102
-	}
103
-
104
-	if (count($options) == 0 && !defined('STDIN')) {
105
-		?>
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
+
66
+    $pdo = Db::pdo();
67
+
68
+    init_plugins();
69
+
70
+    $longopts = array("feeds",
71
+            "daemon",
72
+            "daemon-loop",
73
+            "send-digests",
74
+            "task:",
75
+            "cleanup-tags",
76
+            "quiet",
77
+            "log:",
78
+            "log-level:",
79
+            "indexes",
80
+            "pidlock:",
81
+            "update-schema",
82
+            "convert-filters",
83
+            "force-update",
84
+            "gen-search-idx",
85
+            "list-plugins",
86
+            "debug-feed:",
87
+            "force-refetch",
88
+            "force-rehash",
89
+            "help");
90
+
91
+    foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
92
+        array_push($longopts, $command.$data["suffix"]);
93
+    }
94
+
95
+    $options = getopt("", $longopts);
96
+
97
+    if (!is_array($options)) {
98
+        die("error: getopt() failed. ".
99
+            "Most probably you are using PHP CGI to run this script ".
100
+            "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ".
101
+            "additional information.\n");
102
+    }
103
+
104
+    if (count($options) == 0 && !defined('STDIN')) {
105
+        ?>
106 106
 		<!DOCTYPE html>
107 107
 		<html>
108 108
 		<head>
@@ -117,387 +117,387 @@  discard block
 block discarded – undo
117 117
 
118 118
 		</body></html>
119 119
 	<?php
120
-		exit;
121
-	}
122
-
123
-	if (count($options) == 0 || isset($options["help"])) {
124
-		print "Tiny Tiny RSS data update script.\n\n";
125
-		print "Options:\n";
126
-		print "  --feeds              - update feeds\n";
127
-		print "  --daemon             - start single-process update daemon\n";
128
-		print "  --task N             - create lockfile using this task id\n";
129
-		print "  --cleanup-tags       - perform tags table maintenance\n";
130
-		print "  --quiet              - don't output messages to stdout\n";
131
-		print "  --log FILE           - log messages to FILE\n";
132
-		print "  --log-level N        - log verbosity level\n";
133
-		print "  --indexes            - recreate missing schema indexes\n";
134
-		print "  --update-schema      - update database schema\n";
135
-		print "  --gen-search-idx     - generate basic PostgreSQL fulltext search index\n";
136
-		print "  --convert-filters    - convert type1 filters to type2\n";
137
-		print "  --send-digests       - send pending email digests\n";
138
-		print "  --force-update       - force update of all feeds\n";
139
-		print "  --list-plugins       - list all available plugins\n";
140
-		print "  --debug-feed N       - perform debug update of feed N\n";
141
-		print "  --force-refetch      - debug update: force refetch feed data\n";
142
-		print "  --force-rehash       - debug update: force rehash articles\n";
143
-		print "  --help               - show this help\n";
144
-		print "Plugin options:\n";
145
-
146
-		foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
147
-			$args = $data['arghelp'];
148
-			printf(" --%-19s - %s\n", "$command $args", $data["description"]);
149
-		}
150
-
151
-		return;
152
-	}
153
-
154
-	if (!isset($options['daemon'])) {
155
-		require_once "errorhandler.php";
156
-	}
157
-
158
-	if (!isset($options['update-schema'])) {
159
-		$schema_version = get_schema_version();
160
-
161
-		if ($schema_version != SCHEMA_VERSION) {
162
-			die("Schema version is wrong, please upgrade the database (--update-schema).\n");
163
-		}
164
-	}
165
-
166
-	Debug::set_enabled(true);
167
-
168
-	if (isset($options["log-level"])) {
169
-	    Debug::set_loglevel((int) $options["log-level"]);
120
+        exit;
121
+    }
122
+
123
+    if (count($options) == 0 || isset($options["help"])) {
124
+        print "Tiny Tiny RSS data update script.\n\n";
125
+        print "Options:\n";
126
+        print "  --feeds              - update feeds\n";
127
+        print "  --daemon             - start single-process update daemon\n";
128
+        print "  --task N             - create lockfile using this task id\n";
129
+        print "  --cleanup-tags       - perform tags table maintenance\n";
130
+        print "  --quiet              - don't output messages to stdout\n";
131
+        print "  --log FILE           - log messages to FILE\n";
132
+        print "  --log-level N        - log verbosity level\n";
133
+        print "  --indexes            - recreate missing schema indexes\n";
134
+        print "  --update-schema      - update database schema\n";
135
+        print "  --gen-search-idx     - generate basic PostgreSQL fulltext search index\n";
136
+        print "  --convert-filters    - convert type1 filters to type2\n";
137
+        print "  --send-digests       - send pending email digests\n";
138
+        print "  --force-update       - force update of all feeds\n";
139
+        print "  --list-plugins       - list all available plugins\n";
140
+        print "  --debug-feed N       - perform debug update of feed N\n";
141
+        print "  --force-refetch      - debug update: force refetch feed data\n";
142
+        print "  --force-rehash       - debug update: force rehash articles\n";
143
+        print "  --help               - show this help\n";
144
+        print "Plugin options:\n";
145
+
146
+        foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
147
+            $args = $data['arghelp'];
148
+            printf(" --%-19s - %s\n", "$command $args", $data["description"]);
149
+        }
150
+
151
+        return;
152
+    }
153
+
154
+    if (!isset($options['daemon'])) {
155
+        require_once "errorhandler.php";
156
+    }
157
+
158
+    if (!isset($options['update-schema'])) {
159
+        $schema_version = get_schema_version();
160
+
161
+        if ($schema_version != SCHEMA_VERSION) {
162
+            die("Schema version is wrong, please upgrade the database (--update-schema).\n");
163
+        }
164
+    }
165
+
166
+    Debug::set_enabled(true);
167
+
168
+    if (isset($options["log-level"])) {
169
+        Debug::set_loglevel((int) $options["log-level"]);
170 170
     }
171 171
 
172
-	if (isset($options["log"])) {
173
-		Debug::set_quiet(isset($options['quiet']));
174
-		Debug::set_logfile($options["log"]);
172
+    if (isset($options["log"])) {
173
+        Debug::set_quiet(isset($options['quiet']));
174
+        Debug::set_logfile($options["log"]);
175 175
         Debug::log("Logging to ".$options["log"]);
176 176
     } else {
177
-	    if (isset($options['quiet'])) {
178
-			Debug::set_loglevel(Debug::$LOG_DISABLED);
177
+        if (isset($options['quiet'])) {
178
+            Debug::set_loglevel(Debug::$LOG_DISABLED);
179 179
         }
180 180
     }
181 181
 
182
-	if (!isset($options["daemon"])) {
183
-		$lock_filename = "update.lock";
184
-	} else {
185
-		$lock_filename = "update_daemon.lock";
186
-	}
182
+    if (!isset($options["daemon"])) {
183
+        $lock_filename = "update.lock";
184
+    } else {
185
+        $lock_filename = "update_daemon.lock";
186
+    }
187 187
 
188
-	if (isset($options["task"])) {
189
-		Debug::log("Using task id ".$options["task"]);
190
-		$lock_filename = $lock_filename."-task_".$options["task"];
191
-	}
188
+    if (isset($options["task"])) {
189
+        Debug::log("Using task id ".$options["task"]);
190
+        $lock_filename = $lock_filename."-task_".$options["task"];
191
+    }
192 192
 
193
-	if (isset($options["pidlock"])) {
194
-		$my_pid = $options["pidlock"];
195
-		$lock_filename = "update_daemon-$my_pid.lock";
193
+    if (isset($options["pidlock"])) {
194
+        $my_pid = $options["pidlock"];
195
+        $lock_filename = "update_daemon-$my_pid.lock";
196 196
 
197
-	}
197
+    }
198 198
 
199
-	Debug::log("Lock: $lock_filename");
199
+    Debug::log("Lock: $lock_filename");
200 200
 
201
-	$lock_handle = make_lockfile($lock_filename);
202
-	$must_exit = false;
201
+    $lock_handle = make_lockfile($lock_filename);
202
+    $must_exit = false;
203 203
 
204
-	if (isset($options["task"]) && isset($options["pidlock"])) {
205
-		$waits = $options["task"] * 5;
206
-		Debug::log("Waiting before update ($waits)");
207
-		sleep($waits);
208
-	}
204
+    if (isset($options["task"]) && isset($options["pidlock"])) {
205
+        $waits = $options["task"] * 5;
206
+        Debug::log("Waiting before update ($waits)");
207
+        sleep($waits);
208
+    }
209 209
 
210
-	// Try to lock a file in order to avoid concurrent update.
211
-	if (!$lock_handle) {
212
-		die("error: Can't create lockfile ($lock_filename). ".
213
-			"Maybe another update process is already running.\n");
214
-	}
210
+    // Try to lock a file in order to avoid concurrent update.
211
+    if (!$lock_handle) {
212
+        die("error: Can't create lockfile ($lock_filename). ".
213
+            "Maybe another update process is already running.\n");
214
+    }
215 215
 
216
-	if (isset($options["force-update"])) {
217
-		Debug::log("marking all feeds as needing update...");
216
+    if (isset($options["force-update"])) {
217
+        Debug::log("marking all feeds as needing update...");
218 218
 
219
-		$pdo->query("UPDATE ttrss_feeds SET
219
+        $pdo->query("UPDATE ttrss_feeds SET
220 220
           last_update_started = '1970-01-01', last_updated = '1970-01-01'");
221
-	}
221
+    }
222 222
 
223
-	if (isset($options["feeds"])) {
224
-		RSSUtils::update_daemon_common();
225
-		RSSUtils::housekeeping_common(true);
223
+    if (isset($options["feeds"])) {
224
+        RSSUtils::update_daemon_common();
225
+        RSSUtils::housekeeping_common(true);
226 226
 
227
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
228
-	}
227
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
228
+    }
229 229
 
230
-	if (isset($options["daemon"])) {
231
-		while (true) {
232
-			$quiet = (isset($options["quiet"])) ? "--quiet" : "";
230
+    if (isset($options["daemon"])) {
231
+        while (true) {
232
+            $quiet = (isset($options["quiet"])) ? "--quiet" : "";
233 233
             $log = isset($options['log']) ? '--log '.$options['log'] : '';
234 234
             $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : '';
235 235
 
236
-			passthru(PHP_EXECUTABLE." ".$argv[0]." --daemon-loop $quiet $log $log_level");
236
+            passthru(PHP_EXECUTABLE." ".$argv[0]." --daemon-loop $quiet $log $log_level");
237 237
 
238
-			// let's enforce a minimum spawn interval as to not forkbomb the host
239
-			$spawn_interval = max(60, DAEMON_SLEEP_INTERVAL);
238
+            // let's enforce a minimum spawn interval as to not forkbomb the host
239
+            $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL);
240 240
 
241
-			Debug::log("Sleeping for $spawn_interval seconds...");
242
-			sleep($spawn_interval);
243
-		}
244
-	}
241
+            Debug::log("Sleeping for $spawn_interval seconds...");
242
+            sleep($spawn_interval);
243
+        }
244
+    }
245 245
 
246
-	if (isset($options["daemon-loop"])) {
247
-		if (!make_stampfile('update_daemon.stamp')) {
248
-			Debug::log("warning: unable to create stampfile\n");
249
-		}
246
+    if (isset($options["daemon-loop"])) {
247
+        if (!make_stampfile('update_daemon.stamp')) {
248
+            Debug::log("warning: unable to create stampfile\n");
249
+        }
250 250
 
251
-		RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT);
251
+        RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT);
252 252
 
253
-		if (!isset($options["pidlock"]) || $options["task"] == 0) {
254
-					RSSUtils::housekeeping_common(true);
255
-		}
253
+        if (!isset($options["pidlock"]) || $options["task"] == 0) {
254
+                    RSSUtils::housekeeping_common(true);
255
+        }
256 256
 
257
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
258
-	}
257
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
258
+    }
259 259
 
260
-	if (isset($options["cleanup-tags"])) {
261
-		$rc = cleanup_tags(14, 50000);
262
-		Debug::log("$rc tags deleted.\n");
263
-	}
260
+    if (isset($options["cleanup-tags"])) {
261
+        $rc = cleanup_tags(14, 50000);
262
+        Debug::log("$rc tags deleted.\n");
263
+    }
264 264
 
265
-	if (isset($options["indexes"])) {
266
-		Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!");
267
-		Debug::log("Type 'yes' to continue.");
265
+    if (isset($options["indexes"])) {
266
+        Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!");
267
+        Debug::log("Type 'yes' to continue.");
268 268
 
269
-		if (read_stdin() != 'yes') {
270
-					exit;
271
-		}
269
+        if (read_stdin() != 'yes') {
270
+                    exit;
271
+        }
272 272
 
273
-		Debug::log("clearing existing indexes...");
273
+        Debug::log("clearing existing indexes...");
274 274
 
275
-		if (DB_TYPE == "pgsql") {
276
-			$sth = $pdo->query("SELECT relname FROM
275
+        if (DB_TYPE == "pgsql") {
276
+            $sth = $pdo->query("SELECT relname FROM
277 277
 				pg_catalog.pg_class WHERE relname LIKE 'ttrss_%'
278 278
 					AND relname NOT LIKE '%_pkey'
279 279
 				AND relkind = 'i'");
280
-		} else {
281
-			$sth = $pdo->query("SELECT index_name,table_name FROM
280
+        } else {
281
+            $sth = $pdo->query("SELECT index_name,table_name FROM
282 282
 				information_schema.statistics WHERE index_name LIKE 'ttrss_%'");
283
-		}
284
-
285
-		while ($line = $sth->fetch()) {
286
-			if (DB_TYPE == "pgsql") {
287
-				$statement = "DROP INDEX ".$line["relname"];
288
-				Debug::log($statement);
289
-			} else {
290
-				$statement = "ALTER TABLE ".
291
-					$line['table_name']." DROP INDEX ".$line['index_name'];
292
-				Debug::log($statement);
293
-			}
294
-			$pdo->query($statement);
295
-		}
283
+        }
296 284
 
297
-		Debug::log("reading indexes from schema for: ".DB_TYPE);
285
+        while ($line = $sth->fetch()) {
286
+            if (DB_TYPE == "pgsql") {
287
+                $statement = "DROP INDEX ".$line["relname"];
288
+                Debug::log($statement);
289
+            } else {
290
+                $statement = "ALTER TABLE ".
291
+                    $line['table_name']." DROP INDEX ".$line['index_name'];
292
+                Debug::log($statement);
293
+            }
294
+            $pdo->query($statement);
295
+        }
298 296
 
299
-		$fp = fopen("schema/ttrss_schema_".DB_TYPE.".sql", "r");
300
-		if ($fp) {
301
-			while ($line = fgets($fp)) {
302
-				$matches = array();
297
+        Debug::log("reading indexes from schema for: ".DB_TYPE);
303 298
 
304
-				if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) {
305
-					$index = $matches[1];
306
-					$table = $matches[2];
299
+        $fp = fopen("schema/ttrss_schema_".DB_TYPE.".sql", "r");
300
+        if ($fp) {
301
+            while ($line = fgets($fp)) {
302
+                $matches = array();
307 303
 
308
-					$statement = "CREATE INDEX $index ON $table";
304
+                if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) {
305
+                    $index = $matches[1];
306
+                    $table = $matches[2];
309 307
 
310
-					Debug::log($statement);
311
-					$pdo->query($statement);
312
-				}
313
-			}
314
-			fclose($fp);
315
-		} else {
316
-			Debug::log("unable to open schema file.");
317
-		}
318
-		Debug::log("all done.");
319
-	}
308
+                    $statement = "CREATE INDEX $index ON $table";
320 309
 
321
-	if (isset($options["convert-filters"])) {
322
-		Debug::log("WARNING: this will remove all existing type2 filters.");
323
-		Debug::log("Type 'yes' to continue.");
310
+                    Debug::log($statement);
311
+                    $pdo->query($statement);
312
+                }
313
+            }
314
+            fclose($fp);
315
+        } else {
316
+            Debug::log("unable to open schema file.");
317
+        }
318
+        Debug::log("all done.");
319
+    }
320
+
321
+    if (isset($options["convert-filters"])) {
322
+        Debug::log("WARNING: this will remove all existing type2 filters.");
323
+        Debug::log("Type 'yes' to continue.");
324 324
 
325
-		if (read_stdin() != 'yes') {
326
-					exit;
327
-		}
325
+        if (read_stdin() != 'yes') {
326
+                    exit;
327
+        }
328 328
 
329
-		Debug::log("converting filters...");
329
+        Debug::log("converting filters...");
330 330
 
331
-		$pdo->query("DELETE FROM ttrss_filters2");
331
+        $pdo->query("DELETE FROM ttrss_filters2");
332 332
 
333
-		$res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id");
333
+        $res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id");
334 334
 
335
-		while ($line = $res->fetch()) {
336
-			$owner_uid = $line["owner_uid"];
335
+        while ($line = $res->fetch()) {
336
+            $owner_uid = $line["owner_uid"];
337 337
 
338
-			// date filters are removed
339
-			if ($line["filter_type"] != 5) {
340
-				$filter = array();
338
+            // date filters are removed
339
+            if ($line["filter_type"] != 5) {
340
+                $filter = array();
341 341
 
342
-				if (sql_bool_to_bool($line["cat_filter"])) {
343
-					$feed_id = "CAT:".(int) $line["cat_id"];
344
-				} else {
345
-					$feed_id = (int) $line["feed_id"];
346
-				}
342
+                if (sql_bool_to_bool($line["cat_filter"])) {
343
+                    $feed_id = "CAT:".(int) $line["cat_id"];
344
+                } else {
345
+                    $feed_id = (int) $line["feed_id"];
346
+                }
347 347
 
348
-				$filter["enabled"] = $line["enabled"] ? "on" : "off";
349
-				$filter["rule"] = array(
350
-					json_encode(array(
351
-						"reg_exp" => $line["reg_exp"],
352
-						"feed_id" => $feed_id,
353
-						"filter_type" => $line["filter_type"])));
348
+                $filter["enabled"] = $line["enabled"] ? "on" : "off";
349
+                $filter["rule"] = array(
350
+                    json_encode(array(
351
+                        "reg_exp" => $line["reg_exp"],
352
+                        "feed_id" => $feed_id,
353
+                        "filter_type" => $line["filter_type"])));
354 354
 
355
-				$filter["action"] = array(
356
-					json_encode(array(
357
-						"action_id" => $line["action_id"],
358
-						"action_param_label" => $line["action_param"],
359
-						"action_param" => $line["action_param"])));
355
+                $filter["action"] = array(
356
+                    json_encode(array(
357
+                        "action_id" => $line["action_id"],
358
+                        "action_param_label" => $line["action_param"],
359
+                        "action_param" => $line["action_param"])));
360 360
 
361
-				// Oh god it's full of hacks
361
+                // Oh god it's full of hacks
362 362
 
363
-				$_REQUEST = $filter;
364
-				$_SESSION["uid"] = $owner_uid;
363
+                $_REQUEST = $filter;
364
+                $_SESSION["uid"] = $owner_uid;
365 365
 
366
-				$filters = new Pref_Filters($_REQUEST);
367
-				$filters->add();
368
-			}
369
-		}
366
+                $filters = new Pref_Filters($_REQUEST);
367
+                $filters->add();
368
+            }
369
+        }
370 370
 
371
-	}
371
+    }
372 372
 
373
-	if (isset($options["update-schema"])) {
374
-		Debug::log("Checking for updates (".DB_TYPE.")...");
373
+    if (isset($options["update-schema"])) {
374
+        Debug::log("Checking for updates (".DB_TYPE.")...");
375 375
 
376
-		$updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
376
+        $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
377 377
 
378
-		if ($updater->isUpdateRequired()) {
379
-			Debug::log("Schema update required, version ".$updater->getSchemaVersion()." to ".SCHEMA_VERSION);
378
+        if ($updater->isUpdateRequired()) {
379
+            Debug::log("Schema update required, version ".$updater->getSchemaVersion()." to ".SCHEMA_VERSION);
380 380
 
381
-			if (DB_TYPE == "mysql") {
382
-							Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n".
383
-					"Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING.");
384
-			} else {
385
-							Debug::log("WARNING: please backup your database before continuing.");
386
-			}
381
+            if (DB_TYPE == "mysql") {
382
+                            Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n".
383
+                    "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING.");
384
+            } else {
385
+                            Debug::log("WARNING: please backup your database before continuing.");
386
+            }
387 387
 
388
-			Debug::log("Type 'yes' to continue.");
388
+            Debug::log("Type 'yes' to continue.");
389 389
 
390
-			if (read_stdin() != 'yes') {
391
-							exit;
392
-			}
390
+            if (read_stdin() != 'yes') {
391
+                            exit;
392
+            }
393 393
 
394
-			Debug::log("Performing updates to version ".SCHEMA_VERSION);
394
+            Debug::log("Performing updates to version ".SCHEMA_VERSION);
395 395
 
396
-			for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
397
-				Debug::log("* Updating to version $i...");
396
+            for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
397
+                Debug::log("* Updating to version $i...");
398 398
 
399
-				$result = $updater->performUpdateTo($i, false);
399
+                $result = $updater->performUpdateTo($i, false);
400 400
 
401
-				if ($result) {
402
-					Debug::log("* Completed.");
403
-				} else {
404
-					Debug::log("One of the updates failed. Either retry the process or perform updates manually.");
405
-					return;
406
-				}
401
+                if ($result) {
402
+                    Debug::log("* Completed.");
403
+                } else {
404
+                    Debug::log("One of the updates failed. Either retry the process or perform updates manually.");
405
+                    return;
406
+                }
407 407
 
408
-			}
409
-		} else {
410
-			Debug::log("Update not required.");
411
-		}
408
+            }
409
+        } else {
410
+            Debug::log("Update not required.");
411
+        }
412 412
 
413
-	}
413
+    }
414 414
 
415
-	if (isset($options["gen-search-idx"])) {
416
-		echo "Generating search index (stemming set to English)...\n";
415
+    if (isset($options["gen-search-idx"])) {
416
+        echo "Generating search index (stemming set to English)...\n";
417 417
 
418
-		$res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL");
419
-		$row = $res->fetch();
420
-		$count = $row['count'];
418
+        $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL");
419
+        $row = $res->fetch();
420
+        $count = $row['count'];
421 421
 
422
-		print "Articles to process: $count.\n";
422
+        print "Articles to process: $count.\n";
423 423
 
424
-		$limit = 500;
425
-		$processed = 0;
424
+        $limit = 500;
425
+        $processed = 0;
426 426
 
427
-		$sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE
427
+        $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE
428 428
           tsvector_combined IS NULL ORDER BY id LIMIT ?");
429
-		$sth->execute([$limit]);
429
+        $sth->execute([$limit]);
430 430
 
431
-		$usth = $pdo->prepare("UPDATE ttrss_entries
431
+        $usth = $pdo->prepare("UPDATE ttrss_entries
432 432
           SET tsvector_combined = to_tsvector('english', ?) WHERE id = ?");
433 433
 
434
-		while (true) {
434
+        while (true) {
435 435
 
436
-			while ($line = $sth->fetch()) {
437
-				$tsvector_combined = mb_substr(strip_tags($line["title"]." ".$line["content"]), 0, 1000000);
436
+            while ($line = $sth->fetch()) {
437
+                $tsvector_combined = mb_substr(strip_tags($line["title"]." ".$line["content"]), 0, 1000000);
438 438
 
439
-				$usth->execute([$tsvector_combined, $line['id']]);
439
+                $usth->execute([$tsvector_combined, $line['id']]);
440 440
 
441
-				$processed++;
442
-			}
441
+                $processed++;
442
+            }
443 443
 
444
-			print "processed $processed articles...\n";
444
+            print "processed $processed articles...\n";
445 445
 
446
-			if ($processed < $limit) {
447
-				echo "All done.\n";
448
-				break;
449
-			}
450
-		}
451
-	}
446
+            if ($processed < $limit) {
447
+                echo "All done.\n";
448
+                break;
449
+            }
450
+        }
451
+    }
452 452
 
453
-	if (isset($options["list-plugins"])) {
454
-		$tmppluginhost = new PluginHost();
455
-		$tmppluginhost->load_all($tmppluginhost::KIND_ALL, false);
456
-		$enabled = array_map("trim", explode(",", PLUGINS));
453
+    if (isset($options["list-plugins"])) {
454
+        $tmppluginhost = new PluginHost();
455
+        $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false);
456
+        $enabled = array_map("trim", explode(",", PLUGINS));
457 457
 
458
-		echo "List of all available plugins:\n";
458
+        echo "List of all available plugins:\n";
459 459
 
460
-		foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
461
-			$about = $plugin->about();
460
+        foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
461
+            $about = $plugin->about();
462 462
 
463
-			$status = $about[3] ? "system" : "user";
463
+            $status = $about[3] ? "system" : "user";
464 464
 
465
-			if (in_array($name, $enabled)) {
466
-			    $name .= "*";
467
-			}
465
+            if (in_array($name, $enabled)) {
466
+                $name .= "*";
467
+            }
468 468
 
469
-			printf("%-50s %-10s v%.2f (by %s)\n%s\n\n",
470
-				$name, $status, $about[0], $about[2], $about[1]);
471
-		}
469
+            printf("%-50s %-10s v%.2f (by %s)\n%s\n\n",
470
+                $name, $status, $about[0], $about[2], $about[1]);
471
+        }
472 472
 
473
-		echo "Plugins marked by * are currently enabled for all users.\n";
473
+        echo "Plugins marked by * are currently enabled for all users.\n";
474 474
 
475
-	}
475
+    }
476 476
 
477
-	if (isset($options["debug-feed"])) {
478
-		$feed = $options["debug-feed"];
477
+    if (isset($options["debug-feed"])) {
478
+        $feed = $options["debug-feed"];
479 479
 
480
-		if (isset($options["force-refetch"])) {
481
-		    $_REQUEST["force_refetch"] = true;
482
-		}
483
-		if (isset($options["force-rehash"])) {
484
-		    $_REQUEST["force_rehash"] = true;
485
-		}
480
+        if (isset($options["force-refetch"])) {
481
+            $_REQUEST["force_refetch"] = true;
482
+        }
483
+        if (isset($options["force-rehash"])) {
484
+            $_REQUEST["force_rehash"] = true;
485
+        }
486 486
 
487
-		Debug::set_loglevel(Debug::$LOG_EXTENDED);
487
+        Debug::set_loglevel(Debug::$LOG_EXTENDED);
488 488
 
489
-		$rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1;
489
+        $rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1;
490 490
 
491
-		exit($rc);
492
-	}
491
+        exit($rc);
492
+    }
493 493
 
494
-	if (isset($options["send-digests"])) {
495
-		Digest::send_headlines_digests();
496
-	}
494
+    if (isset($options["send-digests"])) {
495
+        Digest::send_headlines_digests();
496
+    }
497 497
 
498
-	PluginHost::getInstance()->run_commands($options);
498
+    PluginHost::getInstance()->run_commands($options);
499 499
 
500
-	if (file_exists(LOCK_DIRECTORY."/$lock_filename"))
501
-		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
502
-			fclose($lock_handle);
503
-		unlink(LOCK_DIRECTORY."/$lock_filename");
500
+    if (file_exists(LOCK_DIRECTORY."/$lock_filename"))
501
+        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
502
+            fclose($lock_handle);
503
+        unlink(LOCK_DIRECTORY."/$lock_filename");
Please login to merge, or discard this patch.
classes/counters.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -1,174 +1,174 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Counters {
3 3
 
4
-	public static function getAllCounters() {
5
-		$data = Counters::getGlobalCounters();
4
+    public static function getAllCounters() {
5
+        $data = Counters::getGlobalCounters();
6 6
 
7
-		$data = array_merge($data, Counters::getVirtCounters());
8
-		$data = array_merge($data, Counters::getLabelCounters());
9
-		$data = array_merge($data, Counters::getFeedCounters());
10
-		$data = array_merge($data, Counters::getCategoryCounters());
7
+        $data = array_merge($data, Counters::getVirtCounters());
8
+        $data = array_merge($data, Counters::getLabelCounters());
9
+        $data = array_merge($data, Counters::getFeedCounters());
10
+        $data = array_merge($data, Counters::getCategoryCounters());
11 11
 
12
-		return $data;
13
-	}
12
+        return $data;
13
+    }
14 14
 
15
-	public static function getCategoryCounters() {
16
-		$ret_arr = array();
15
+    public static function getCategoryCounters() {
16
+        $ret_arr = array();
17 17
 
18
-		/* Labels category */
18
+        /* Labels category */
19 19
 
20
-		$cv = array("id" => -2, "kind" => "cat",
21
-			"counter" => Feeds::getCategoryUnread(-2));
20
+        $cv = array("id" => -2, "kind" => "cat",
21
+            "counter" => Feeds::getCategoryUnread(-2));
22 22
 
23
-		array_push($ret_arr, $cv);
23
+        array_push($ret_arr, $cv);
24 24
 
25
-		$pdo = DB::pdo();
25
+        $pdo = DB::pdo();
26 26
 
27
-		$sth = $pdo->prepare("SELECT ttrss_feed_categories.id AS cat_id, value AS unread,
27
+        $sth = $pdo->prepare("SELECT ttrss_feed_categories.id AS cat_id, value AS unread,
28 28
 			(SELECT COUNT(id) FROM ttrss_feed_categories AS c2
29 29
 				WHERE c2.parent_cat = ttrss_feed_categories.id) AS num_children
30 30
 			FROM ttrss_feed_categories, ttrss_cat_counters_cache
31 31
 			WHERE ttrss_cat_counters_cache.feed_id = ttrss_feed_categories.id AND
32 32
 			ttrss_cat_counters_cache.owner_uid = ttrss_feed_categories.owner_uid AND
33 33
 			ttrss_feed_categories.owner_uid = ?");
34
-		$sth->execute([$_SESSION['uid']]);
34
+        $sth->execute([$_SESSION['uid']]);
35 35
 
36
-		while ($line = $sth->fetch()) {
37
-			$line["cat_id"] = (int) $line["cat_id"];
36
+        while ($line = $sth->fetch()) {
37
+            $line["cat_id"] = (int) $line["cat_id"];
38 38
 
39
-			if ($line["num_children"] > 0) {
40
-				$child_counter = Feeds::getCategoryChildrenUnread($line["cat_id"], $_SESSION["uid"]);
41
-			} else {
42
-				$child_counter = 0;
43
-			}
39
+            if ($line["num_children"] > 0) {
40
+                $child_counter = Feeds::getCategoryChildrenUnread($line["cat_id"], $_SESSION["uid"]);
41
+            } else {
42
+                $child_counter = 0;
43
+            }
44 44
 
45
-			$cv = array("id" => $line["cat_id"], "kind" => "cat",
46
-				"counter" => $line["unread"] + $child_counter);
45
+            $cv = array("id" => $line["cat_id"], "kind" => "cat",
46
+                "counter" => $line["unread"] + $child_counter);
47 47
 
48
-			array_push($ret_arr, $cv);
49
-		}
48
+            array_push($ret_arr, $cv);
49
+        }
50 50
 
51
-		/* Special case: NULL category doesn't actually exist in the DB */
51
+        /* Special case: NULL category doesn't actually exist in the DB */
52 52
 
53
-		$cv = array("id" => 0, "kind" => "cat",
54
-			"counter" => (int) CCache::find(0, $_SESSION["uid"], true));
53
+        $cv = array("id" => 0, "kind" => "cat",
54
+            "counter" => (int) CCache::find(0, $_SESSION["uid"], true));
55 55
 
56
-		array_push($ret_arr, $cv);
56
+        array_push($ret_arr, $cv);
57 57
 
58
-		return $ret_arr;
59
-	}
58
+        return $ret_arr;
59
+    }
60 60
 
61
-	public static function getGlobalCounters($global_unread = -1) {
62
-		$ret_arr = array();
61
+    public static function getGlobalCounters($global_unread = -1) {
62
+        $ret_arr = array();
63 63
 
64
-		if ($global_unread == -1) {
65
-			$global_unread = Feeds::getGlobalUnread();
66
-		}
64
+        if ($global_unread == -1) {
65
+            $global_unread = Feeds::getGlobalUnread();
66
+        }
67 67
 
68
-		$cv = array("id" => "global-unread",
69
-			"counter" => (int) $global_unread);
68
+        $cv = array("id" => "global-unread",
69
+            "counter" => (int) $global_unread);
70 70
 
71
-		array_push($ret_arr, $cv);
71
+        array_push($ret_arr, $cv);
72 72
 
73
-		$pdo = Db::pdo();
73
+        $pdo = Db::pdo();
74 74
 
75
-		$sth = $pdo->prepare("SELECT COUNT(id) AS fn FROM
75
+        $sth = $pdo->prepare("SELECT COUNT(id) AS fn FROM
76 76
 			ttrss_feeds WHERE owner_uid = ?");
77
-		$sth->execute([$_SESSION['uid']]);
78
-		$row = $sth->fetch();
77
+        $sth->execute([$_SESSION['uid']]);
78
+        $row = $sth->fetch();
79 79
 
80
-		$subscribed_feeds = $row["fn"];
80
+        $subscribed_feeds = $row["fn"];
81 81
 
82
-		$cv = array("id" => "subscribed-feeds",
83
-			"counter" => (int) $subscribed_feeds);
82
+        $cv = array("id" => "subscribed-feeds",
83
+            "counter" => (int) $subscribed_feeds);
84 84
 
85
-		array_push($ret_arr, $cv);
85
+        array_push($ret_arr, $cv);
86 86
 
87
-		return $ret_arr;
88
-	}
87
+        return $ret_arr;
88
+    }
89 89
 
90
-	public static function getVirtCounters() {
90
+    public static function getVirtCounters() {
91 91
 
92
-		$ret_arr = array();
92
+        $ret_arr = array();
93 93
 
94
-		for ($i = 0; $i >= -4; $i--) {
94
+        for ($i = 0; $i >= -4; $i--) {
95 95
 
96
-			$count = getFeedUnread($i);
96
+            $count = getFeedUnread($i);
97 97
 
98
-			if ($i == 0 || $i == -1 || $i == -2) {
99
-							$auxctr = Feeds::getFeedArticles($i, false);
100
-			} else {
101
-							$auxctr = 0;
102
-			}
98
+            if ($i == 0 || $i == -1 || $i == -2) {
99
+                            $auxctr = Feeds::getFeedArticles($i, false);
100
+            } else {
101
+                            $auxctr = 0;
102
+            }
103 103
 
104
-			$cv = array("id" => $i,
105
-				"counter" => (int) $count,
106
-				"auxcounter" => (int) $auxctr);
104
+            $cv = array("id" => $i,
105
+                "counter" => (int) $count,
106
+                "auxcounter" => (int) $auxctr);
107 107
 
108 108
 //			if (get_pref('EXTENDED_FEEDLIST'))
109 109
 //				$cv["xmsg"] = getFeedArticles($i)." ".__("total");
110 110
 
111
-			array_push($ret_arr, $cv);
112
-		}
111
+            array_push($ret_arr, $cv);
112
+        }
113 113
 
114
-		$feeds = PluginHost::getInstance()->get_feeds(-1);
114
+        $feeds = PluginHost::getInstance()->get_feeds(-1);
115 115
 
116
-		if (is_array($feeds)) {
117
-			foreach ($feeds as $feed) {
118
-				$cv = array("id" => PluginHost::pfeed_to_feed_id($feed['id']),
119
-					"counter" => $feed['sender']->get_unread($feed['id']));
116
+        if (is_array($feeds)) {
117
+            foreach ($feeds as $feed) {
118
+                $cv = array("id" => PluginHost::pfeed_to_feed_id($feed['id']),
119
+                    "counter" => $feed['sender']->get_unread($feed['id']));
120 120
 
121
-				if (method_exists($feed['sender'], 'get_total')) {
122
-									$cv["auxcounter"] = $feed['sender']->get_total($feed['id']);
123
-				}
121
+                if (method_exists($feed['sender'], 'get_total')) {
122
+                                    $cv["auxcounter"] = $feed['sender']->get_total($feed['id']);
123
+                }
124 124
 
125
-				array_push($ret_arr, $cv);
126
-			}
127
-		}
125
+                array_push($ret_arr, $cv);
126
+            }
127
+        }
128 128
 
129
-		return $ret_arr;
130
-	}
129
+        return $ret_arr;
130
+    }
131 131
 
132
-	public static function getLabelCounters($descriptions = false) {
132
+    public static function getLabelCounters($descriptions = false) {
133 133
 
134
-		$ret_arr = array();
134
+        $ret_arr = array();
135 135
 
136
-		$pdo = Db::pdo();
136
+        $pdo = Db::pdo();
137 137
 
138
-		$sth = $pdo->prepare("SELECT id,caption,SUM(CASE WHEN u1.unread = true THEN 1 ELSE 0 END) AS unread, COUNT(u1.unread) AS total
138
+        $sth = $pdo->prepare("SELECT id,caption,SUM(CASE WHEN u1.unread = true THEN 1 ELSE 0 END) AS unread, COUNT(u1.unread) AS total
139 139
 			FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
140 140
 				(ttrss_labels2.id = label_id)
141 141
 				LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id
142 142
 				WHERE ttrss_labels2.owner_uid = :uid AND u1.owner_uid = :uid
143 143
 				GROUP BY ttrss_labels2.id,
144 144
 					ttrss_labels2.caption");
145
-		$sth->execute([":uid" => $_SESSION['uid']]);
145
+        $sth->execute([":uid" => $_SESSION['uid']]);
146 146
 
147
-		while ($line = $sth->fetch()) {
147
+        while ($line = $sth->fetch()) {
148 148
 
149
-			$id = Labels::label_to_feed_id($line["id"]);
149
+            $id = Labels::label_to_feed_id($line["id"]);
150 150
 
151
-			$cv = array("id" => $id,
152
-				"counter" => (int) $line["unread"],
153
-				"auxcounter" => (int) $line["total"]);
151
+            $cv = array("id" => $id,
152
+                "counter" => (int) $line["unread"],
153
+                "auxcounter" => (int) $line["total"]);
154 154
 
155
-			if ($descriptions) {
156
-							$cv["description"] = $line["caption"];
157
-			}
155
+            if ($descriptions) {
156
+                            $cv["description"] = $line["caption"];
157
+            }
158 158
 
159
-			array_push($ret_arr, $cv);
160
-		}
159
+            array_push($ret_arr, $cv);
160
+        }
161 161
 
162
-		return $ret_arr;
163
-	}
162
+        return $ret_arr;
163
+    }
164 164
 
165
-	public static function getFeedCounters($active_feed = false) {
165
+    public static function getFeedCounters($active_feed = false) {
166 166
 
167
-		$ret_arr = array();
167
+        $ret_arr = array();
168 168
 
169
-		$pdo = Db::pdo();
169
+        $pdo = Db::pdo();
170 170
 
171
-		$sth = $pdo->prepare("SELECT ttrss_feeds.id,
171
+        $sth = $pdo->prepare("SELECT ttrss_feeds.id,
172 172
 				ttrss_feeds.title,
173 173
 				".SUBSTRING_FOR_DATE."(ttrss_feeds.last_updated,1,19) AS last_updated,
174 174
 				last_error, value AS count
@@ -176,47 +176,47 @@  discard block
 block discarded – undo
176 176
 			WHERE ttrss_feeds.owner_uid = ?
177 177
 				AND ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid
178 178
 				AND ttrss_counters_cache.feed_id = ttrss_feeds.id");
179
-		$sth->execute([$_SESSION['uid']]);
179
+        $sth->execute([$_SESSION['uid']]);
180 180
 
181
-		while ($line = $sth->fetch()) {
181
+        while ($line = $sth->fetch()) {
182 182
 
183
-			$id = $line["id"];
184
-			$count = $line["count"];
185
-			$last_error = htmlspecialchars($line["last_error"]);
183
+            $id = $line["id"];
184
+            $count = $line["count"];
185
+            $last_error = htmlspecialchars($line["last_error"]);
186 186
 
187
-			$last_updated = make_local_datetime($line['last_updated'], false);
187
+            $last_updated = make_local_datetime($line['last_updated'], false);
188 188
 
189
-			if (Feeds::feedHasIcon($id)) {
190
-				$has_img = filemtime(Feeds::getIconFile($id));
191
-			} else {
192
-				$has_img = false;
193
-			}
189
+            if (Feeds::feedHasIcon($id)) {
190
+                $has_img = filemtime(Feeds::getIconFile($id));
191
+            } else {
192
+                $has_img = false;
193
+            }
194 194
 
195
-			if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2) {
196
-							$last_updated = '';
197
-			}
195
+            if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2) {
196
+                            $last_updated = '';
197
+            }
198 198
 
199
-			$cv = array("id" => $id,
200
-				"updated" => $last_updated,
201
-				"counter" => (int) $count,
202
-				"has_img" => (int) $has_img);
199
+            $cv = array("id" => $id,
200
+                "updated" => $last_updated,
201
+                "counter" => (int) $count,
202
+                "has_img" => (int) $has_img);
203 203
 
204
-			if ($last_error) {
205
-							$cv["error"] = $last_error;
206
-			}
204
+            if ($last_error) {
205
+                            $cv["error"] = $last_error;
206
+            }
207 207
 
208 208
 //			if (get_pref('EXTENDED_FEEDLIST'))
209 209
 //				$cv["xmsg"] = getFeedArticles($id)." ".__("total");
210 210
 
211
-			if ($active_feed && $id == $active_feed) {
212
-							$cv["title"] = truncate_string($line["title"], 30);
213
-			}
211
+            if ($active_feed && $id == $active_feed) {
212
+                            $cv["title"] = truncate_string($line["title"], 30);
213
+            }
214 214
 
215
-			array_push($ret_arr, $cv);
215
+            array_push($ret_arr, $cv);
216 216
 
217
-		}
217
+        }
218 218
 
219
-		return $ret_arr;
220
-	}
219
+        return $ret_arr;
220
+    }
221 221
 
222 222
 }
Please login to merge, or discard this patch.