@@ -1,14 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function print_select($id, $default, $values, $attributes = "", $name = "") { |
4 | - if (!$name) $name = $id; |
|
4 | + if (!$name) { |
|
5 | + $name = $id; |
|
6 | + } |
|
5 | 7 | |
6 | 8 | print "<select name=\"$name\" id=\"$id\" $attributes>"; |
7 | 9 | foreach ($values as $v) { |
8 | - if ($v == $default) |
|
9 | - $sel = "selected=\"1\""; |
|
10 | - else |
|
11 | - $sel = ""; |
|
10 | + if ($v == $default) { |
|
11 | + $sel = "selected=\"1\""; |
|
12 | + } else { |
|
13 | + $sel = ""; |
|
14 | + } |
|
12 | 15 | |
13 | 16 | $v = trim($v); |
14 | 17 | |
@@ -18,14 +21,17 @@ discard block |
||
18 | 21 | } |
19 | 22 | |
20 | 23 | function print_select_hash($id, $default, $values, $attributes = "", $name = "") { |
21 | - if (!$name) $name = $id; |
|
24 | + if (!$name) { |
|
25 | + $name = $id; |
|
26 | + } |
|
22 | 27 | |
23 | 28 | print "<select name=\"$name\" id='$id' $attributes>"; |
24 | 29 | foreach (array_keys($values) as $v) { |
25 | - if ($v == $default) |
|
26 | - $sel = 'selected="selected"'; |
|
27 | - else |
|
28 | - $sel = ""; |
|
30 | + if ($v == $default) { |
|
31 | + $sel = 'selected="selected"'; |
|
32 | + } else { |
|
33 | + $sel = ""; |
|
34 | + } |
|
29 | 35 | |
30 | 36 | $v = trim($v); |
31 | 37 | |
@@ -53,10 +59,11 @@ discard block |
||
53 | 59 | function print_radio($id, $default, $true_is, $values, $attributes = "") { |
54 | 60 | foreach ($values as $v) { |
55 | 61 | |
56 | - if ($v == $default) |
|
57 | - $sel = "checked"; |
|
58 | - else |
|
59 | - $sel = ""; |
|
62 | + if ($v == $default) { |
|
63 | + $sel = "checked"; |
|
64 | + } else { |
|
65 | + $sel = ""; |
|
66 | + } |
|
60 | 67 | |
61 | 68 | if ($v == $true_is) { |
62 | 69 | $sel .= " value=\"1\""; |
@@ -88,7 +95,9 @@ discard block |
||
88 | 95 | |
89 | 96 | if (get_pref('ENABLE_FEED_CATS')) { |
90 | 97 | |
91 | - if (!$root_id) $root_id = null; |
|
98 | + if (!$root_id) { |
|
99 | + $root_id = null; |
|
100 | + } |
|
92 | 101 | |
93 | 102 | $sth = $pdo->prepare("SELECT id,title, |
94 | 103 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
@@ -101,17 +110,19 @@ discard block |
||
101 | 110 | |
102 | 111 | while ($line = $sth->fetch()) { |
103 | 112 | |
104 | - for ($i = 0; $i < $nest_level; $i++) |
|
105 | - $line["title"] = " - " . $line["title"]; |
|
113 | + for ($i = 0; $i < $nest_level; $i++) { |
|
114 | + $line["title"] = " - " . $line["title"]; |
|
115 | + } |
|
106 | 116 | |
107 | 117 | $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
108 | 118 | |
109 | 119 | printf("<option $is_selected value='CAT:%d'>%s</option>", |
110 | 120 | $line["id"], htmlspecialchars($line["title"])); |
111 | 121 | |
112 | - if ($line["num_children"] > 0) |
|
113 | - print_feed_multi_select($id, $default_ids, $attributes, |
|
122 | + if ($line["num_children"] > 0) { |
|
123 | + print_feed_multi_select($id, $default_ids, $attributes, |
|
114 | 124 | $include_all_feeds, $line["id"], $nest_level+1); |
125 | + } |
|
115 | 126 | |
116 | 127 | $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
117 | 128 | WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
@@ -123,8 +134,9 @@ discard block |
||
123 | 134 | |
124 | 135 | $fline["title"] = " + " . $fline["title"]; |
125 | 136 | |
126 | - for ($i = 0; $i < $nest_level; $i++) |
|
127 | - $fline["title"] = " - " . $fline["title"]; |
|
137 | + for ($i = 0; $i < $nest_level; $i++) { |
|
138 | + $fline["title"] = " - " . $fline["title"]; |
|
139 | + } |
|
128 | 140 | |
129 | 141 | printf("<option $is_selected value='%d'>%s</option>", |
130 | 142 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -146,8 +158,9 @@ discard block |
||
146 | 158 | |
147 | 159 | $fline["title"] = " + " . $fline["title"]; |
148 | 160 | |
149 | - for ($i = 0; $i < $nest_level; $i++) |
|
150 | - $fline["title"] = " - " . $fline["title"]; |
|
161 | + for ($i = 0; $i < $nest_level; $i++) { |
|
162 | + $fline["title"] = " - " . $fline["title"]; |
|
163 | + } |
|
151 | 164 | |
152 | 165 | printf("<option $is_selected value='%d'>%s</option>", |
153 | 166 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -182,7 +195,9 @@ discard block |
||
182 | 195 | |
183 | 196 | $pdo = DB::pdo(); |
184 | 197 | |
185 | - if (!$root_id) $root_id = null; |
|
198 | + if (!$root_id) { |
|
199 | + $root_id = null; |
|
200 | + } |
|
186 | 201 | |
187 | 202 | $sth = $pdo->prepare("SELECT id,title, |
188 | 203 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
@@ -203,16 +218,19 @@ discard block |
||
203 | 218 | $is_selected = ""; |
204 | 219 | } |
205 | 220 | |
206 | - for ($i = 0; $i < $nest_level; $i++) |
|
207 | - $line["title"] = " - " . $line["title"]; |
|
221 | + for ($i = 0; $i < $nest_level; $i++) { |
|
222 | + $line["title"] = " - " . $line["title"]; |
|
223 | + } |
|
208 | 224 | |
209 | - if ($line["title"]) |
|
210 | - printf("<option $is_selected value='%d'>%s</option>", |
|
225 | + if ($line["title"]) { |
|
226 | + printf("<option $is_selected value='%d'>%s</option>", |
|
211 | 227 | $line["id"], htmlspecialchars($line["title"])); |
228 | + } |
|
212 | 229 | |
213 | - if ($line["num_children"] > 0) |
|
214 | - print_feed_cat_select($id, $default_id, $attributes, |
|
230 | + if ($line["num_children"] > 0) { |
|
231 | + print_feed_cat_select($id, $default_id, $attributes, |
|
215 | 232 | $include_all_cats, $line["id"], $nest_level+1); |
233 | + } |
|
216 | 234 | } |
217 | 235 | |
218 | 236 | if (!$root_id) { |
@@ -251,7 +269,9 @@ discard block |
||
251 | 269 | |
252 | 270 | $timestamp = filemtime($filename); |
253 | 271 | |
254 | - if ($query) $timestamp .= "&$query"; |
|
272 | + if ($query) { |
|
273 | + $timestamp .= "&$query"; |
|
274 | + } |
|
255 | 275 | |
256 | 276 | return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
257 | 277 | } |
@@ -299,8 +319,10 @@ discard block |
||
299 | 319 | |
300 | 320 | } |
301 | 321 | |
302 | - if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
322 | + if ($entry) { |
|
323 | + $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
303 | 324 | href=\"$url\">" . basename($url) . "</a>"; |
325 | + } |
|
304 | 326 | |
305 | 327 | $entry .= "</div>"; |
306 | 328 |
@@ -1,339 +1,339 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function print_select($id, $default, $values, $attributes = "", $name = "") { |
4 | - if (!$name) $name = $id; |
|
4 | + if (!$name) $name = $id; |
|
5 | 5 | |
6 | - print "<select name=\"$name\" id=\"$id\" $attributes>"; |
|
7 | - foreach ($values as $v) { |
|
8 | - if ($v == $default) |
|
9 | - $sel = "selected=\"1\""; |
|
10 | - else |
|
11 | - $sel = ""; |
|
6 | + print "<select name=\"$name\" id=\"$id\" $attributes>"; |
|
7 | + foreach ($values as $v) { |
|
8 | + if ($v == $default) |
|
9 | + $sel = "selected=\"1\""; |
|
10 | + else |
|
11 | + $sel = ""; |
|
12 | 12 | |
13 | - $v = trim($v); |
|
13 | + $v = trim($v); |
|
14 | 14 | |
15 | - print "<option value=\"$v\" $sel>$v</option>"; |
|
16 | - } |
|
17 | - print "</select>"; |
|
15 | + print "<option value=\"$v\" $sel>$v</option>"; |
|
16 | + } |
|
17 | + print "</select>"; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function print_select_hash($id, $default, $values, $attributes = "", $name = "") { |
21 | - if (!$name) $name = $id; |
|
21 | + if (!$name) $name = $id; |
|
22 | 22 | |
23 | - print "<select name=\"$name\" id='$id' $attributes>"; |
|
24 | - foreach (array_keys($values) as $v) { |
|
25 | - if ($v == $default) |
|
26 | - $sel = 'selected="selected"'; |
|
27 | - else |
|
28 | - $sel = ""; |
|
23 | + print "<select name=\"$name\" id='$id' $attributes>"; |
|
24 | + foreach (array_keys($values) as $v) { |
|
25 | + if ($v == $default) |
|
26 | + $sel = 'selected="selected"'; |
|
27 | + else |
|
28 | + $sel = ""; |
|
29 | 29 | |
30 | - $v = trim($v); |
|
30 | + $v = trim($v); |
|
31 | 31 | |
32 | - print "<option $sel value=\"$v\">".$values[$v]."</option>"; |
|
33 | - } |
|
32 | + print "<option $sel value=\"$v\">".$values[$v]."</option>"; |
|
33 | + } |
|
34 | 34 | |
35 | - print "</select>"; |
|
35 | + print "</select>"; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function print_hidden($name, $value) { |
39 | - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"$name\" value=\"$value\">"; |
|
39 | + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"$name\" value=\"$value\">"; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function print_checkbox($id, $checked, $value = "", $attributes = "") { |
43 | - $checked_str = $checked ? "checked" : ""; |
|
44 | - $value_str = $value ? "value=\"$value\"" : ""; |
|
43 | + $checked_str = $checked ? "checked" : ""; |
|
44 | + $value_str = $value ? "value=\"$value\"" : ""; |
|
45 | 45 | |
46 | - print "<input dojoType=\"dijit.form.CheckBox\" id=\"$id\" $value_str $checked_str $attributes name=\"$id\">"; |
|
46 | + print "<input dojoType=\"dijit.form.CheckBox\" id=\"$id\" $value_str $checked_str $attributes name=\"$id\">"; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | function print_button($type, $value, $attributes = "") { |
50 | - print "<p><button dojoType=\"dijit.form.Button\" $attributes type=\"$type\">$value</button>"; |
|
50 | + print "<p><button dojoType=\"dijit.form.Button\" $attributes type=\"$type\">$value</button>"; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function print_radio($id, $default, $true_is, $values, $attributes = "") { |
54 | - foreach ($values as $v) { |
|
54 | + foreach ($values as $v) { |
|
55 | 55 | |
56 | - if ($v == $default) |
|
57 | - $sel = "checked"; |
|
58 | - else |
|
59 | - $sel = ""; |
|
56 | + if ($v == $default) |
|
57 | + $sel = "checked"; |
|
58 | + else |
|
59 | + $sel = ""; |
|
60 | 60 | |
61 | - if ($v == $true_is) { |
|
62 | - $sel .= " value=\"1\""; |
|
63 | - } else { |
|
64 | - $sel .= " value=\"0\""; |
|
65 | - } |
|
61 | + if ($v == $true_is) { |
|
62 | + $sel .= " value=\"1\""; |
|
63 | + } else { |
|
64 | + $sel .= " value=\"0\""; |
|
65 | + } |
|
66 | 66 | |
67 | - print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" |
|
67 | + print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" |
|
68 | 68 | type=\"radio\" $sel $attributes name=\"$id\"> $v "; |
69 | 69 | |
70 | - } |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | function print_feed_multi_select($id, $default_ids = [], |
74 | - $attributes = "", $include_all_feeds = true, |
|
75 | - $root_id = null, $nest_level = 0) { |
|
74 | + $attributes = "", $include_all_feeds = true, |
|
75 | + $root_id = null, $nest_level = 0) { |
|
76 | 76 | |
77 | - $pdo = DB::pdo(); |
|
77 | + $pdo = DB::pdo(); |
|
78 | 78 | |
79 | - print_r(in_array("CAT:6",$default_ids)); |
|
79 | + print_r(in_array("CAT:6",$default_ids)); |
|
80 | 80 | |
81 | - if (!$root_id) { |
|
82 | - print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>"; |
|
83 | - if ($include_all_feeds) { |
|
84 | - $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; |
|
85 | - print "<option $is_selected value=\"0\">".__('All feeds')."</option>"; |
|
86 | - } |
|
87 | - } |
|
81 | + if (!$root_id) { |
|
82 | + print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>"; |
|
83 | + if ($include_all_feeds) { |
|
84 | + $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; |
|
85 | + print "<option $is_selected value=\"0\">".__('All feeds')."</option>"; |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - if (get_pref('ENABLE_FEED_CATS')) { |
|
89 | + if (get_pref('ENABLE_FEED_CATS')) { |
|
90 | 90 | |
91 | - if (!$root_id) $root_id = null; |
|
91 | + if (!$root_id) $root_id = null; |
|
92 | 92 | |
93 | - $sth = $pdo->prepare("SELECT id,title, |
|
93 | + $sth = $pdo->prepare("SELECT id,title, |
|
94 | 94 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
95 | 95 | c2.parent_cat = ttrss_feed_categories.id) AS num_children |
96 | 96 | FROM ttrss_feed_categories |
97 | 97 | WHERE owner_uid = :uid AND |
98 | 98 | (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); |
99 | 99 | |
100 | - $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
100 | + $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
101 | 101 | |
102 | - while ($line = $sth->fetch()) { |
|
102 | + while ($line = $sth->fetch()) { |
|
103 | 103 | |
104 | - for ($i = 0; $i < $nest_level; $i++) |
|
105 | - $line["title"] = " - " . $line["title"]; |
|
104 | + for ($i = 0; $i < $nest_level; $i++) |
|
105 | + $line["title"] = " - " . $line["title"]; |
|
106 | 106 | |
107 | - $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
107 | + $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
108 | 108 | |
109 | - printf("<option $is_selected value='CAT:%d'>%s</option>", |
|
110 | - $line["id"], htmlspecialchars($line["title"])); |
|
109 | + printf("<option $is_selected value='CAT:%d'>%s</option>", |
|
110 | + $line["id"], htmlspecialchars($line["title"])); |
|
111 | 111 | |
112 | - if ($line["num_children"] > 0) |
|
113 | - print_feed_multi_select($id, $default_ids, $attributes, |
|
114 | - $include_all_feeds, $line["id"], $nest_level+1); |
|
112 | + if ($line["num_children"] > 0) |
|
113 | + print_feed_multi_select($id, $default_ids, $attributes, |
|
114 | + $include_all_feeds, $line["id"], $nest_level+1); |
|
115 | 115 | |
116 | - $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
116 | + $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
117 | 117 | WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
118 | 118 | |
119 | - $f_sth->execute([$line['id'], $_SESSION['uid']]); |
|
119 | + $f_sth->execute([$line['id'], $_SESSION['uid']]); |
|
120 | 120 | |
121 | - while ($fline = $f_sth->fetch()) { |
|
122 | - $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
121 | + while ($fline = $f_sth->fetch()) { |
|
122 | + $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
123 | 123 | |
124 | - $fline["title"] = " + " . $fline["title"]; |
|
124 | + $fline["title"] = " + " . $fline["title"]; |
|
125 | 125 | |
126 | - for ($i = 0; $i < $nest_level; $i++) |
|
127 | - $fline["title"] = " - " . $fline["title"]; |
|
126 | + for ($i = 0; $i < $nest_level; $i++) |
|
127 | + $fline["title"] = " - " . $fline["title"]; |
|
128 | 128 | |
129 | - printf("<option $is_selected value='%d'>%s</option>", |
|
130 | - $fline["id"], htmlspecialchars($fline["title"])); |
|
131 | - } |
|
132 | - } |
|
129 | + printf("<option $is_selected value='%d'>%s</option>", |
|
130 | + $fline["id"], htmlspecialchars($fline["title"])); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - if (!$root_id) { |
|
135 | - $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : ""; |
|
134 | + if (!$root_id) { |
|
135 | + $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : ""; |
|
136 | 136 | |
137 | - printf("<option $is_selected value='CAT:0'>%s</option>", |
|
138 | - __("Uncategorized")); |
|
137 | + printf("<option $is_selected value='CAT:0'>%s</option>", |
|
138 | + __("Uncategorized")); |
|
139 | 139 | |
140 | - $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
140 | + $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
141 | 141 | WHERE cat_id IS NULL AND owner_uid = ? ORDER BY title"); |
142 | - $f_sth->execute([$_SESSION['uid']]); |
|
142 | + $f_sth->execute([$_SESSION['uid']]); |
|
143 | 143 | |
144 | - while ($fline = $f_sth->fetch()) { |
|
145 | - $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
144 | + while ($fline = $f_sth->fetch()) { |
|
145 | + $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
146 | 146 | |
147 | - $fline["title"] = " + " . $fline["title"]; |
|
147 | + $fline["title"] = " + " . $fline["title"]; |
|
148 | 148 | |
149 | - for ($i = 0; $i < $nest_level; $i++) |
|
150 | - $fline["title"] = " - " . $fline["title"]; |
|
149 | + for ($i = 0; $i < $nest_level; $i++) |
|
150 | + $fline["title"] = " - " . $fline["title"]; |
|
151 | 151 | |
152 | - printf("<option $is_selected value='%d'>%s</option>", |
|
153 | - $fline["id"], htmlspecialchars($fline["title"])); |
|
154 | - } |
|
155 | - } |
|
152 | + printf("<option $is_selected value='%d'>%s</option>", |
|
153 | + $fline["id"], htmlspecialchars($fline["title"])); |
|
154 | + } |
|
155 | + } |
|
156 | 156 | |
157 | - } else { |
|
158 | - $sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
157 | + } else { |
|
158 | + $sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
159 | 159 | WHERE owner_uid = ? ORDER BY title"); |
160 | - $sth->execute([$_SESSION['uid']]); |
|
160 | + $sth->execute([$_SESSION['uid']]); |
|
161 | 161 | |
162 | - while ($line = $sth->fetch()) { |
|
162 | + while ($line = $sth->fetch()) { |
|
163 | 163 | |
164 | - $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
164 | + $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
165 | 165 | |
166 | - printf("<option $is_selected value='%d'>%s</option>", |
|
167 | - $line["id"], htmlspecialchars($line["title"])); |
|
168 | - } |
|
169 | - } |
|
166 | + printf("<option $is_selected value='%d'>%s</option>", |
|
167 | + $line["id"], htmlspecialchars($line["title"])); |
|
168 | + } |
|
169 | + } |
|
170 | 170 | |
171 | - if (!$root_id) { |
|
172 | - print "</select>"; |
|
173 | - } |
|
171 | + if (!$root_id) { |
|
172 | + print "</select>"; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function print_feed_cat_select($id, $default_id, |
177 | - $attributes, $include_all_cats = true, $root_id = null, $nest_level = 0) { |
|
177 | + $attributes, $include_all_cats = true, $root_id = null, $nest_level = 0) { |
|
178 | 178 | |
179 | - if (!$root_id) { |
|
180 | - print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>"; |
|
181 | - } |
|
179 | + if (!$root_id) { |
|
180 | + print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>"; |
|
181 | + } |
|
182 | 182 | |
183 | - $pdo = DB::pdo(); |
|
183 | + $pdo = DB::pdo(); |
|
184 | 184 | |
185 | - if (!$root_id) $root_id = null; |
|
185 | + if (!$root_id) $root_id = null; |
|
186 | 186 | |
187 | - $sth = $pdo->prepare("SELECT id,title, |
|
187 | + $sth = $pdo->prepare("SELECT id,title, |
|
188 | 188 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
189 | 189 | c2.parent_cat = ttrss_feed_categories.id) AS num_children |
190 | 190 | FROM ttrss_feed_categories |
191 | 191 | WHERE owner_uid = :uid AND |
192 | 192 | (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); |
193 | - $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
194 | - |
|
195 | - $found = 0; |
|
196 | - |
|
197 | - while ($line = $sth->fetch()) { |
|
198 | - ++$found; |
|
199 | - |
|
200 | - if ($line["id"] == $default_id) { |
|
201 | - $is_selected = "selected=\"1\""; |
|
202 | - } else { |
|
203 | - $is_selected = ""; |
|
204 | - } |
|
205 | - |
|
206 | - for ($i = 0; $i < $nest_level; $i++) |
|
207 | - $line["title"] = " - " . $line["title"]; |
|
208 | - |
|
209 | - if ($line["title"]) |
|
210 | - printf("<option $is_selected value='%d'>%s</option>", |
|
211 | - $line["id"], htmlspecialchars($line["title"])); |
|
212 | - |
|
213 | - if ($line["num_children"] > 0) |
|
214 | - print_feed_cat_select($id, $default_id, $attributes, |
|
215 | - $include_all_cats, $line["id"], $nest_level+1); |
|
216 | - } |
|
217 | - |
|
218 | - if (!$root_id) { |
|
219 | - if ($include_all_cats) { |
|
220 | - if ($found > 0) { |
|
221 | - print "<option disabled=\"1\">--------</option>"; |
|
222 | - } |
|
223 | - |
|
224 | - if ($default_id == 0) { |
|
225 | - $is_selected = "selected=\"1\""; |
|
226 | - } else { |
|
227 | - $is_selected = ""; |
|
228 | - } |
|
229 | - |
|
230 | - print "<option $is_selected value=\"0\">".__('Uncategorized')."</option>"; |
|
231 | - } |
|
232 | - print "</select>"; |
|
233 | - } |
|
193 | + $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
194 | + |
|
195 | + $found = 0; |
|
196 | + |
|
197 | + while ($line = $sth->fetch()) { |
|
198 | + ++$found; |
|
199 | + |
|
200 | + if ($line["id"] == $default_id) { |
|
201 | + $is_selected = "selected=\"1\""; |
|
202 | + } else { |
|
203 | + $is_selected = ""; |
|
204 | + } |
|
205 | + |
|
206 | + for ($i = 0; $i < $nest_level; $i++) |
|
207 | + $line["title"] = " - " . $line["title"]; |
|
208 | + |
|
209 | + if ($line["title"]) |
|
210 | + printf("<option $is_selected value='%d'>%s</option>", |
|
211 | + $line["id"], htmlspecialchars($line["title"])); |
|
212 | + |
|
213 | + if ($line["num_children"] > 0) |
|
214 | + print_feed_cat_select($id, $default_id, $attributes, |
|
215 | + $include_all_cats, $line["id"], $nest_level+1); |
|
216 | + } |
|
217 | + |
|
218 | + if (!$root_id) { |
|
219 | + if ($include_all_cats) { |
|
220 | + if ($found > 0) { |
|
221 | + print "<option disabled=\"1\">--------</option>"; |
|
222 | + } |
|
223 | + |
|
224 | + if ($default_id == 0) { |
|
225 | + $is_selected = "selected=\"1\""; |
|
226 | + } else { |
|
227 | + $is_selected = ""; |
|
228 | + } |
|
229 | + |
|
230 | + print "<option $is_selected value=\"0\">".__('Uncategorized')."</option>"; |
|
231 | + } |
|
232 | + print "</select>"; |
|
233 | + } |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | function stylesheet_tag($filename, $id = false) { |
237 | - $timestamp = filemtime($filename); |
|
237 | + $timestamp = filemtime($filename); |
|
238 | 238 | |
239 | - $id_part = $id ? "id=\"$id\"" : ""; |
|
239 | + $id_part = $id ? "id=\"$id\"" : ""; |
|
240 | 240 | |
241 | - return "<link rel=\"stylesheet\" $id_part type=\"text/css\" data-orig-href=\"$filename\" href=\"$filename?$timestamp\"/>\n"; |
|
241 | + return "<link rel=\"stylesheet\" $id_part type=\"text/css\" data-orig-href=\"$filename\" href=\"$filename?$timestamp\"/>\n"; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function javascript_tag($filename) { |
245 | - $query = ""; |
|
245 | + $query = ""; |
|
246 | 246 | |
247 | - if (!(strpos($filename, "?") === false)) { |
|
248 | - $query = substr($filename, strpos($filename, "?")+1); |
|
249 | - $filename = substr($filename, 0, strpos($filename, "?")); |
|
250 | - } |
|
247 | + if (!(strpos($filename, "?") === false)) { |
|
248 | + $query = substr($filename, strpos($filename, "?")+1); |
|
249 | + $filename = substr($filename, 0, strpos($filename, "?")); |
|
250 | + } |
|
251 | 251 | |
252 | - $timestamp = filemtime($filename); |
|
252 | + $timestamp = filemtime($filename); |
|
253 | 253 | |
254 | - if ($query) $timestamp .= "&$query"; |
|
254 | + if ($query) $timestamp .= "&$query"; |
|
255 | 255 | |
256 | - return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
256 | + return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | function format_warning($msg, $id = "") { |
260 | - return "<div class=\"alert\" id=\"$id\">$msg</div>"; |
|
260 | + return "<div class=\"alert\" id=\"$id\">$msg</div>"; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | function format_notice($msg, $id = "") { |
264 | - return "<div class=\"alert alert-info\" id=\"$id\">$msg</div>"; |
|
264 | + return "<div class=\"alert alert-info\" id=\"$id\">$msg</div>"; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | function format_error($msg, $id = "") { |
268 | - return "<div class=\"alert alert-danger\" id=\"$id\">$msg</div>"; |
|
268 | + return "<div class=\"alert alert-danger\" id=\"$id\">$msg</div>"; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | function print_notice($msg) { |
272 | - return print format_notice($msg); |
|
272 | + return print format_notice($msg); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | function print_warning($msg) { |
276 | - return print format_warning($msg); |
|
276 | + return print format_warning($msg); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | function print_error($msg) { |
280 | - return print format_error($msg); |
|
280 | + return print format_error($msg); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | function format_inline_player($url, $ctype) { |
284 | 284 | |
285 | - $entry = ""; |
|
285 | + $entry = ""; |
|
286 | 286 | |
287 | - $url = htmlspecialchars($url); |
|
287 | + $url = htmlspecialchars($url); |
|
288 | 288 | |
289 | - if (strpos($ctype, "audio/") === 0) { |
|
289 | + if (strpos($ctype, "audio/") === 0) { |
|
290 | 290 | |
291 | - $entry .= "<div class='inline-player'>"; |
|
291 | + $entry .= "<div class='inline-player'>"; |
|
292 | 292 | |
293 | - if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || |
|
294 | - $_SESSION["hasMp3"])) { |
|
293 | + if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || |
|
294 | + $_SESSION["hasMp3"])) { |
|
295 | 295 | |
296 | - $entry .= "<audio preload=\"none\" controls> |
|
296 | + $entry .= "<audio preload=\"none\" controls> |
|
297 | 297 | <source type=\"$ctype\" src=\"$url\"/> |
298 | 298 | </audio> "; |
299 | 299 | |
300 | - } |
|
300 | + } |
|
301 | 301 | |
302 | - if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
302 | + if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
303 | 303 | href=\"$url\">" . basename($url) . "</a>"; |
304 | 304 | |
305 | - $entry .= "</div>"; |
|
305 | + $entry .= "</div>"; |
|
306 | 306 | |
307 | - return $entry; |
|
307 | + return $entry; |
|
308 | 308 | |
309 | - } |
|
309 | + } |
|
310 | 310 | |
311 | - return ""; |
|
311 | + return ""; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function print_label_select($name, $value, $attributes = "") { |
315 | 315 | |
316 | - $pdo = Db::pdo(); |
|
316 | + $pdo = Db::pdo(); |
|
317 | 317 | |
318 | - $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 |
|
318 | + $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 |
|
319 | 319 | WHERE owner_uid = ? ORDER BY caption"); |
320 | - $sth->execute([$_SESSION['uid']]); |
|
320 | + $sth->execute([$_SESSION['uid']]); |
|
321 | 321 | |
322 | - print "<select default=\"$value\" name=\"" . htmlspecialchars($name) . |
|
323 | - "\" $attributes>"; |
|
322 | + print "<select default=\"$value\" name=\"" . htmlspecialchars($name) . |
|
323 | + "\" $attributes>"; |
|
324 | 324 | |
325 | - while ($line = $sth->fetch()) { |
|
325 | + while ($line = $sth->fetch()) { |
|
326 | 326 | |
327 | - $issel = ($line["caption"] == $value) ? "selected=\"1\"" : ""; |
|
327 | + $issel = ($line["caption"] == $value) ? "selected=\"1\"" : ""; |
|
328 | 328 | |
329 | - print "<option value=\"".htmlspecialchars($line["caption"])."\" |
|
329 | + print "<option value=\"".htmlspecialchars($line["caption"])."\" |
|
330 | 330 | $issel>" . htmlspecialchars($line["caption"]) . "</option>"; |
331 | 331 | |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | 334 | # print "<option value=\"ADD_LABEL\">" .__("Add label...") . "</option>"; |
335 | 335 | |
336 | - print "</select>"; |
|
336 | + print "</select>"; |
|
337 | 337 | |
338 | 338 | |
339 | 339 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | $pdo = DB::pdo(); |
78 | 78 | |
79 | - print_r(in_array("CAT:6",$default_ids)); |
|
79 | + print_r(in_array("CAT:6", $default_ids)); |
|
80 | 80 | |
81 | 81 | if (!$root_id) { |
82 | 82 | print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>"; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | while ($line = $sth->fetch()) { |
103 | 103 | |
104 | 104 | for ($i = 0; $i < $nest_level; $i++) |
105 | - $line["title"] = " - " . $line["title"]; |
|
105 | + $line["title"] = " - ".$line["title"]; |
|
106 | 106 | |
107 | 107 | $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
108 | 108 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | if ($line["num_children"] > 0) |
113 | 113 | print_feed_multi_select($id, $default_ids, $attributes, |
114 | - $include_all_feeds, $line["id"], $nest_level+1); |
|
114 | + $include_all_feeds, $line["id"], $nest_level + 1); |
|
115 | 115 | |
116 | 116 | $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
117 | 117 | WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | while ($fline = $f_sth->fetch()) { |
122 | 122 | $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; |
123 | 123 | |
124 | - $fline["title"] = " + " . $fline["title"]; |
|
124 | + $fline["title"] = " + ".$fline["title"]; |
|
125 | 125 | |
126 | 126 | for ($i = 0; $i < $nest_level; $i++) |
127 | - $fline["title"] = " - " . $fline["title"]; |
|
127 | + $fline["title"] = " - ".$fline["title"]; |
|
128 | 128 | |
129 | 129 | printf("<option $is_selected value='%d'>%s</option>", |
130 | 130 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | while ($fline = $f_sth->fetch()) { |
145 | 145 | $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; |
146 | 146 | |
147 | - $fline["title"] = " + " . $fline["title"]; |
|
147 | + $fline["title"] = " + ".$fline["title"]; |
|
148 | 148 | |
149 | 149 | for ($i = 0; $i < $nest_level; $i++) |
150 | - $fline["title"] = " - " . $fline["title"]; |
|
150 | + $fline["title"] = " - ".$fline["title"]; |
|
151 | 151 | |
152 | 152 | printf("<option $is_selected value='%d'>%s</option>", |
153 | 153 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | for ($i = 0; $i < $nest_level; $i++) |
207 | - $line["title"] = " - " . $line["title"]; |
|
207 | + $line["title"] = " - ".$line["title"]; |
|
208 | 208 | |
209 | 209 | if ($line["title"]) |
210 | 210 | printf("<option $is_selected value='%d'>%s</option>", |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | if ($line["num_children"] > 0) |
214 | 214 | print_feed_cat_select($id, $default_id, $attributes, |
215 | - $include_all_cats, $line["id"], $nest_level+1); |
|
215 | + $include_all_cats, $line["id"], $nest_level + 1); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | if (!$root_id) { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $query = ""; |
246 | 246 | |
247 | 247 | if (!(strpos($filename, "?") === false)) { |
248 | - $query = substr($filename, strpos($filename, "?")+1); |
|
248 | + $query = substr($filename, strpos($filename, "?") + 1); |
|
249 | 249 | $filename = substr($filename, 0, strpos($filename, "?")); |
250 | 250 | } |
251 | 251 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
303 | - href=\"$url\">" . basename($url) . "</a>"; |
|
303 | + href=\"$url\">".basename($url)."</a>"; |
|
304 | 304 | |
305 | 305 | $entry .= "</div>"; |
306 | 306 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | WHERE owner_uid = ? ORDER BY caption"); |
320 | 320 | $sth->execute([$_SESSION['uid']]); |
321 | 321 | |
322 | - print "<select default=\"$value\" name=\"" . htmlspecialchars($name) . |
|
322 | + print "<select default=\"$value\" name=\"".htmlspecialchars($name). |
|
323 | 323 | "\" $attributes>"; |
324 | 324 | |
325 | 325 | while ($line = $sth->fetch()) { |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $issel = ($line["caption"] == $value) ? "selected=\"1\"" : ""; |
328 | 328 | |
329 | 329 | print "<option value=\"".htmlspecialchars($line["caption"])."\" |
330 | - $issel>" . htmlspecialchars($line["caption"]) . "</option>"; |
|
330 | + $issel>".htmlspecialchars($line["caption"])."</option>"; |
|
331 | 331 | |
332 | 332 | } |
333 | 333 |
@@ -7,15 +7,15 @@ |
||
7 | 7 | <link rel="shortcut icon" type="image/png" href="images/favicon.png"> |
8 | 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
9 | 9 | <?php |
10 | - foreach (array("lib/prototype.js", |
|
11 | - "lib/dojo/dojo.js", |
|
12 | - "lib/dojo/tt-rss-layer.js", |
|
13 | - "js/common.js", |
|
14 | - "errors.php?mode=js") as $jsfile) { |
|
10 | + foreach (array("lib/prototype.js", |
|
11 | + "lib/dojo/dojo.js", |
|
12 | + "lib/dojo/tt-rss-layer.js", |
|
13 | + "js/common.js", |
|
14 | + "errors.php?mode=js") as $jsfile) { |
|
15 | 15 | |
16 | - echo javascript_tag($jsfile); |
|
16 | + echo javascript_tag($jsfile); |
|
17 | 17 | |
18 | - } ?> |
|
18 | + } ?> |
|
19 | 19 | |
20 | 20 | <script type="text/javascript"> |
21 | 21 | require({cache:{}}); |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | |
380 | 380 | // TODO: should this support POST requests or not? idk |
381 | 381 | |
382 | - $context_options = array( |
|
383 | - 'http' => array( |
|
382 | + $context_options = array( |
|
383 | + 'http' => array( |
|
384 | 384 | 'header' => array( |
385 | 385 | 'Connection: close' |
386 | 386 | ), |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'ignore_errors' => true, |
389 | 389 | 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT, |
390 | 390 | 'protocol_version'=> 1.1) |
391 | - ); |
|
391 | + ); |
|
392 | 392 | |
393 | 393 | if (!$post_query && $last_modified) |
394 | 394 | array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | function logout_user() { |
660 | 660 | @session_destroy(); |
661 | 661 | if (isset($_COOKIE[session_name()])) { |
662 | - setcookie(session_name(), '', time()-42000, '/'); |
|
662 | + setcookie(session_name(), '', time()-42000, '/'); |
|
663 | 663 | } |
664 | 664 | session_commit(); |
665 | 665 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | if (AUTH_AUTO_LOGIN && authenticate_user(null, null)) { |
700 | 700 | $_SESSION["ref_schema_version"] = get_schema_version(true); |
701 | 701 | } else { |
702 | - authenticate_user(null, null, true); |
|
702 | + authenticate_user(null, null, true); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | if (!$_SESSION["uid"]) { |
@@ -974,9 +974,9 @@ discard block |
||
974 | 974 | $params = array(); |
975 | 975 | |
976 | 976 | foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS", |
977 | - "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", |
|
978 | - "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", |
|
979 | - "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { |
|
977 | + "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", |
|
978 | + "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", |
|
979 | + "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { |
|
980 | 980 | |
981 | 981 | $params[strtolower($param)] = (int) get_pref($param); |
982 | 982 | } |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | libxml_use_internal_errors(true); |
19 | 19 | |
20 | 20 | // separate test because this is included before sanity checks |
21 | -if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8"); |
|
21 | +if (function_exists("mb_internal_encoding")) { |
|
22 | + mb_internal_encoding("UTF-8"); |
|
23 | +} |
|
22 | 24 | |
23 | 25 | date_default_timezone_set('UTC'); |
24 | 26 | if (defined('E_DEPRECATED')) { |
@@ -195,8 +197,9 @@ discard block |
||
195 | 197 | $fetch_last_modified = ""; |
196 | 198 | $fetch_effective_url = ""; |
197 | 199 | |
198 | - if (!is_array($fetch_domain_hits)) |
|
199 | - $fetch_domain_hits = []; |
|
200 | + if (!is_array($fetch_domain_hits)) { |
|
201 | + $fetch_domain_hits = []; |
|
202 | + } |
|
200 | 203 | |
201 | 204 | if (!is_array($options)) { |
202 | 205 | |
@@ -227,8 +230,9 @@ discard block |
||
227 | 230 | $url = ltrim($url, ' '); |
228 | 231 | $url = str_replace(' ', '%20', $url); |
229 | 232 | |
230 | - if (strpos($url, "//") === 0) |
|
231 | - $url = 'http:' . $url; |
|
233 | + if (strpos($url, "//") === 0) { |
|
234 | + $url = 'http:' . $url; |
|
235 | + } |
|
232 | 236 | |
233 | 237 | $url_host = parse_url($url, PHP_URL_HOST); |
234 | 238 | $fetch_domain_hits[$url_host] += 1; |
@@ -246,14 +250,17 @@ discard block |
||
246 | 250 | |
247 | 251 | $curl_http_headers = []; |
248 | 252 | |
249 | - if ($last_modified && !$post_query) |
|
250 | - array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
253 | + if ($last_modified && !$post_query) { |
|
254 | + array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
255 | + } |
|
251 | 256 | |
252 | - if ($http_accept) |
|
253 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
257 | + if ($http_accept) { |
|
258 | + array_push($curl_http_headers, "Accept: " . $http_accept); |
|
259 | + } |
|
254 | 260 | |
255 | - if (count($curl_http_headers) > 0) |
|
256 | - curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
261 | + if (count($curl_http_headers) > 0) { |
|
262 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
263 | + } |
|
257 | 264 | |
258 | 265 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); |
259 | 266 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); |
@@ -267,8 +274,9 @@ discard block |
||
267 | 274 | SELF_USER_AGENT); |
268 | 275 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
269 | 276 | |
270 | - if ($http_referrer) |
|
271 | - curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
277 | + if ($http_referrer) { |
|
278 | + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
279 | + } |
|
272 | 280 | |
273 | 281 | if ($max_size) { |
274 | 282 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
@@ -297,8 +305,9 @@ discard block |
||
297 | 305 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); |
298 | 306 | } |
299 | 307 | |
300 | - if ($login && $pass) |
|
301 | - curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
308 | + if ($login && $pass) { |
|
309 | + curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
310 | + } |
|
302 | 311 | |
303 | 312 | $ret = @curl_exec($ch); |
304 | 313 | |
@@ -357,7 +366,9 @@ discard block |
||
357 | 366 | if ($is_gzipped) { |
358 | 367 | $tmp = @gzdecode($contents); |
359 | 368 | |
360 | - if ($tmp) $contents = $tmp; |
|
369 | + if ($tmp) { |
|
370 | + $contents = $tmp; |
|
371 | + } |
|
361 | 372 | } |
362 | 373 | |
363 | 374 | return $contents; |
@@ -390,14 +401,17 @@ discard block |
||
390 | 401 | 'protocol_version'=> 1.1) |
391 | 402 | ); |
392 | 403 | |
393 | - if (!$post_query && $last_modified) |
|
394 | - array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
404 | + if (!$post_query && $last_modified) { |
|
405 | + array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
406 | + } |
|
395 | 407 | |
396 | - if ($http_accept) |
|
397 | - array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
408 | + if ($http_accept) { |
|
409 | + array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
410 | + } |
|
398 | 411 | |
399 | - if ($http_referrer) |
|
400 | - array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
412 | + if ($http_referrer) { |
|
413 | + array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
414 | + } |
|
401 | 415 | |
402 | 416 | if (defined('_HTTP_PROXY')) { |
403 | 417 | $context_options['http']['request_fulluri'] = true; |
@@ -454,7 +468,9 @@ discard block |
||
454 | 468 | if ($is_gzipped) { |
455 | 469 | $tmp = @gzdecode($data); |
456 | 470 | |
457 | - if ($tmp) $data = $tmp; |
|
471 | + if ($tmp) { |
|
472 | + $data = $tmp; |
|
473 | + } |
|
458 | 474 | } |
459 | 475 | |
460 | 476 | return $data; |
@@ -464,7 +480,9 @@ discard block |
||
464 | 480 | |
465 | 481 | function initialize_user_prefs($uid, $profile = false) { |
466 | 482 | |
467 | - if (get_schema_version() < 63) $profile_qpart = ""; |
|
483 | + if (get_schema_version() < 63) { |
|
484 | + $profile_qpart = ""; |
|
485 | + } |
|
468 | 486 | |
469 | 487 | $pdo = DB::pdo(); |
470 | 488 | $in_nested_tr = false; |
@@ -477,7 +495,9 @@ discard block |
||
477 | 495 | |
478 | 496 | $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); |
479 | 497 | |
480 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
498 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
499 | + $profile = null; |
|
500 | + } |
|
481 | 501 | |
482 | 502 | $u_sth = $pdo->prepare("SELECT pref_name |
483 | 503 | FROM ttrss_user_prefs WHERE owner_uid = :uid AND |
@@ -510,7 +530,9 @@ discard block |
||
510 | 530 | } |
511 | 531 | } |
512 | 532 | |
513 | - if (!$in_nested_tr) $pdo->commit(); |
|
533 | + if (!$in_nested_tr) { |
|
534 | + $pdo->commit(); |
|
535 | + } |
|
514 | 536 | |
515 | 537 | } |
516 | 538 | |
@@ -670,7 +692,9 @@ discard block |
||
670 | 692 | |
671 | 693 | function load_user_plugins($owner_uid, $pluginhost = false) { |
672 | 694 | |
673 | - if (!$pluginhost) $pluginhost = PluginHost::getInstance(); |
|
695 | + if (!$pluginhost) { |
|
696 | + $pluginhost = PluginHost::getInstance(); |
|
697 | + } |
|
674 | 698 | |
675 | 699 | if ($owner_uid && SCHEMA_VERSION >= 100) { |
676 | 700 | $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); |
@@ -692,7 +716,9 @@ discard block |
||
692 | 716 | startup_gettext(); |
693 | 717 | load_user_plugins($_SESSION["uid"]); |
694 | 718 | } else { |
695 | - if (!validate_session()) $_SESSION["uid"] = false; |
|
719 | + if (!validate_session()) { |
|
720 | + $_SESSION["uid"] = false; |
|
721 | + } |
|
696 | 722 | |
697 | 723 | if (!$_SESSION["uid"]) { |
698 | 724 | |
@@ -787,13 +813,19 @@ discard block |
||
787 | 813 | function make_local_datetime($timestamp, $long, $owner_uid = false, |
788 | 814 | $no_smart_dt = false, $eta_min = false) { |
789 | 815 | |
790 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
791 | - if (!$timestamp) $timestamp = '1970-01-01 0:00'; |
|
816 | + if (!$owner_uid) { |
|
817 | + $owner_uid = $_SESSION['uid']; |
|
818 | + } |
|
819 | + if (!$timestamp) { |
|
820 | + $timestamp = '1970-01-01 0:00'; |
|
821 | + } |
|
792 | 822 | |
793 | 823 | global $utc_tz; |
794 | 824 | global $user_tz; |
795 | 825 | |
796 | - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); |
|
826 | + if (!$utc_tz) { |
|
827 | + $utc_tz = new DateTimeZone('UTC'); |
|
828 | + } |
|
797 | 829 | |
798 | 830 | $timestamp = substr($timestamp, 0, 19); |
799 | 831 | |
@@ -805,7 +837,9 @@ discard block |
||
805 | 837 | if ($user_tz_string != 'Automatic') { |
806 | 838 | |
807 | 839 | try { |
808 | - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); |
|
840 | + if (!$user_tz) { |
|
841 | + $user_tz = new DateTimeZone($user_tz_string); |
|
842 | + } |
|
809 | 843 | } catch (Exception $e) { |
810 | 844 | $user_tz = $utc_tz; |
811 | 845 | } |
@@ -821,26 +855,30 @@ discard block |
||
821 | 855 | return smart_date_time($user_timestamp, |
822 | 856 | $tz_offset, $owner_uid, $eta_min); |
823 | 857 | } else { |
824 | - if ($long) |
|
825 | - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
826 | - else |
|
827 | - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
858 | + if ($long) { |
|
859 | + $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
860 | + } else { |
|
861 | + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
862 | + } |
|
828 | 863 | |
829 | 864 | return date($format, $user_timestamp); |
830 | 865 | } |
831 | 866 | } |
832 | 867 | |
833 | 868 | function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { |
834 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
869 | + if (!$owner_uid) { |
|
870 | + $owner_uid = $_SESSION['uid']; |
|
871 | + } |
|
835 | 872 | |
836 | 873 | if ($eta_min && time() + $tz_offset - $timestamp < 3600) { |
837 | 874 | return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); |
838 | 875 | } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { |
839 | 876 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
840 | - if (strpos((strtolower($format)), "a") === false) |
|
841 | - return date("G:i", $timestamp); |
|
842 | - else |
|
843 | - return date("g:i a", $timestamp); |
|
877 | + if (strpos((strtolower($format)), "a") === false) { |
|
878 | + return date("G:i", $timestamp); |
|
879 | + } else { |
|
880 | + return date("g:i a", $timestamp); |
|
881 | + } |
|
844 | 882 | } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { |
845 | 883 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
846 | 884 | return date($format, $timestamp); |
@@ -1250,8 +1288,9 @@ discard block |
||
1250 | 1288 | |
1251 | 1289 | if ($src) { |
1252 | 1290 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { |
1253 | - if ($plugin->hook_iframe_whitelisted($src)) |
|
1254 | - return true; |
|
1291 | + if ($plugin->hook_iframe_whitelisted($src)) { |
|
1292 | + return true; |
|
1293 | + } |
|
1255 | 1294 | } |
1256 | 1295 | } |
1257 | 1296 | |
@@ -1259,9 +1298,13 @@ discard block |
||
1259 | 1298 | } |
1260 | 1299 | |
1261 | 1300 | function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { |
1262 | - if (!$owner) $owner = $_SESSION["uid"]; |
|
1301 | + if (!$owner) { |
|
1302 | + $owner = $_SESSION["uid"]; |
|
1303 | + } |
|
1263 | 1304 | |
1264 | - $res = trim($str); if (!$res) return ''; |
|
1305 | + $res = trim($str); if (!$res) { |
|
1306 | + return ''; |
|
1307 | + } |
|
1265 | 1308 | |
1266 | 1309 | $doc = new DOMDocument(); |
1267 | 1310 | $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
@@ -1323,13 +1366,15 @@ discard block |
||
1323 | 1366 | |
1324 | 1367 | if ($entry->nodeName == 'source') { |
1325 | 1368 | |
1326 | - if ($entry->parentNode && $entry->parentNode->parentNode) |
|
1327 | - $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1369 | + if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
1370 | + $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1371 | + } |
|
1328 | 1372 | |
1329 | 1373 | } else if ($entry->nodeName == 'img') { |
1330 | 1374 | |
1331 | - if ($entry->parentNode) |
|
1332 | - $entry->parentNode->replaceChild($p, $entry); |
|
1375 | + if ($entry->parentNode) { |
|
1376 | + $entry->parentNode->replaceChild($p, $entry); |
|
1377 | + } |
|
1333 | 1378 | |
1334 | 1379 | } |
1335 | 1380 | } |
@@ -1365,7 +1410,9 @@ discard block |
||
1365 | 1410 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
1366 | 1411 | 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
1367 | 1412 | |
1368 | - if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
|
1413 | + if ($_SESSION['hasSandbox']) { |
|
1414 | + $allowed_elements[] = 'iframe'; |
|
1415 | + } |
|
1369 | 1416 | |
1370 | 1417 | $disallowed_attributes = array('id', 'style', 'class'); |
1371 | 1418 | |
@@ -1405,7 +1452,9 @@ discard block |
||
1405 | 1452 | $text = mb_substr($text, $pos + mb_strlen($word)); |
1406 | 1453 | } |
1407 | 1454 | |
1408 | - if (!empty($text)) $fragment->appendChild(new DomText($text)); |
|
1455 | + if (!empty($text)) { |
|
1456 | + $fragment->appendChild(new DomText($text)); |
|
1457 | + } |
|
1409 | 1458 | |
1410 | 1459 | $child->parentNode->replaceChild($fragment, $child); |
1411 | 1460 | } |
@@ -1596,8 +1645,9 @@ discard block |
||
1596 | 1645 | } else { |
1597 | 1646 | $output = ""; |
1598 | 1647 | |
1599 | - for ($i = 0; $i < $length; $i++) |
|
1600 | - $output .= chr(mt_rand(0, 255)); |
|
1648 | + for ($i = 0; $i < $length; $i++) { |
|
1649 | + $output .= chr(mt_rand(0, 255)); |
|
1650 | + } |
|
1601 | 1651 | |
1602 | 1652 | return $output; |
1603 | 1653 | } |
@@ -1667,15 +1717,20 @@ discard block |
||
1667 | 1717 | } |
1668 | 1718 | |
1669 | 1719 | function get_theme_path($theme) { |
1670 | - if ($theme == "default.php") |
|
1671 | - return "css/default.css"; |
|
1720 | + if ($theme == "default.php") { |
|
1721 | + return "css/default.css"; |
|
1722 | + } |
|
1672 | 1723 | |
1673 | 1724 | $check = "themes/$theme"; |
1674 | - if (file_exists($check)) return $check; |
|
1725 | + if (file_exists($check)) { |
|
1726 | + return $check; |
|
1727 | + } |
|
1675 | 1728 | |
1676 | 1729 | $check = "themes.local/$theme"; |
1677 | - if (file_exists($check)) return $check; |
|
1678 | -} |
|
1730 | + if (file_exists($check)) { |
|
1731 | + return $check; |
|
1732 | + } |
|
1733 | + } |
|
1679 | 1734 | |
1680 | 1735 | function theme_exists($theme) { |
1681 | 1736 | return file_exists("themes/$theme") || file_exists("themes.local/$theme"); |
@@ -1731,7 +1786,9 @@ discard block |
||
1731 | 1786 | function send_local_file($filename) { |
1732 | 1787 | if (file_exists($filename)) { |
1733 | 1788 | |
1734 | - if (is_writable($filename)) touch($filename); |
|
1789 | + if (is_writable($filename)) { |
|
1790 | + touch($filename); |
|
1791 | + } |
|
1735 | 1792 | |
1736 | 1793 | $tmppluginhost = new PluginHost(); |
1737 | 1794 | |
@@ -1739,7 +1796,9 @@ discard block |
||
1739 | 1796 | $tmppluginhost->load_data(); |
1740 | 1797 | |
1741 | 1798 | foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { |
1742 | - if ($plugin->hook_send_local_file($filename)) return true; |
|
1799 | + if ($plugin->hook_send_local_file($filename)) { |
|
1800 | + return true; |
|
1801 | + } |
|
1743 | 1802 | } |
1744 | 1803 | |
1745 | 1804 | $mimetype = mime_content_type($filename); |
@@ -1747,8 +1806,9 @@ discard block |
||
1747 | 1806 | // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 |
1748 | 1807 | // video files are detected as octet-stream by mime_content_type() |
1749 | 1808 | |
1750 | - if ($mimetype == "application/octet-stream") |
|
1751 | - $mimetype = "video/mp4"; |
|
1809 | + if ($mimetype == "application/octet-stream") { |
|
1810 | + $mimetype = "video/mp4"; |
|
1811 | + } |
|
1752 | 1812 | |
1753 | 1813 | header("Content-type: $mimetype"); |
1754 | 1814 | |
@@ -1771,7 +1831,9 @@ discard block |
||
1771 | 1831 | |
1772 | 1832 | foreach ($files as $file) { |
1773 | 1833 | $file_ts = filemtime($file); |
1774 | - if ($file_ts > $ts) $ts = $file_ts; |
|
1834 | + if ($file_ts > $ts) { |
|
1835 | + $ts = $file_ts; |
|
1836 | + } |
|
1775 | 1837 | } |
1776 | 1838 | |
1777 | 1839 | return $ts; |
@@ -1784,8 +1846,9 @@ discard block |
||
1784 | 1846 | function get_version(&$git_commit = false, &$git_timestamp = false) { |
1785 | 1847 | global $ttrss_version; |
1786 | 1848 | |
1787 | - if (isset($ttrss_version)) |
|
1788 | - return $ttrss_version; |
|
1849 | + if (isset($ttrss_version)) { |
|
1850 | + return $ttrss_version; |
|
1851 | + } |
|
1789 | 1852 | |
1790 | 1853 | $ttrss_version = "UNKNOWN (Unsupported)"; |
1791 | 1854 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | define('LABEL_BASE_INDEX', -1024); |
6 | 6 | define('PLUGIN_FEED_BASE_INDEX', -128); |
7 | 7 | |
8 | -define('COOKIE_LIFETIME_LONG', 86400*365); |
|
8 | +define('COOKIE_LIFETIME_LONG', 86400 * 365); |
|
9 | 9 | |
10 | 10 | $fetch_last_error = false; |
11 | 11 | $fetch_last_error_code = false; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | // feed limit for one update batch |
58 | 58 | define_default('DAEMON_SLEEP_INTERVAL', 120); |
59 | 59 | // default sleep interval between feed updates (sec) |
60 | -define_default('MAX_CACHE_FILE_SIZE', 64*1024*1024); |
|
60 | +define_default('MAX_CACHE_FILE_SIZE', 64 * 1024 * 1024); |
|
61 | 61 | // do not cache files larger than that (bytes) |
62 | -define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); |
|
62 | +define_default('MAX_DOWNLOAD_FILE_SIZE', 16 * 1024 * 1024); |
|
63 | 63 | // do not download general files larger than that (bytes) |
64 | 64 | define_default('CACHE_MAX_DAYS', 7); |
65 | 65 | // max age in days for various automatically cached (temporary) files |
66 | -define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); |
|
66 | +define_default('MAX_CONDITIONAL_INTERVAL', 3600 * 12); |
|
67 | 67 | // max interval between forced unconditional updates for servers |
68 | 68 | // not complying with http if-modified-since (seconds) |
69 | 69 | define_default('MAX_FETCH_REQUESTS_PER_HOST', 25); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | require_once 'db-prefs.php'; |
158 | 158 | require_once 'controls.php'; |
159 | 159 | |
160 | -define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)'); |
|
160 | +define('SELF_USER_AGENT', 'Tiny Tiny RSS/'.get_version().' (http://tt-rss.org/)'); |
|
161 | 161 | ini_set('user_agent', SELF_USER_AGENT); |
162 | 162 | |
163 | 163 | $schema_version = false; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if (!is_array($options)) { |
202 | 202 | |
203 | 203 | // falling back on compatibility shim |
204 | - $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ]; |
|
204 | + $option_names = ["url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent"]; |
|
205 | 205 | $tmp = []; |
206 | 206 | |
207 | 207 | for ($i = 0; $i < func_num_args(); $i++) { |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | $url = str_replace(' ', '%20', $url); |
229 | 229 | |
230 | 230 | if (strpos($url, "//") === 0) |
231 | - $url = 'http:' . $url; |
|
231 | + $url = 'http:'.$url; |
|
232 | 232 | |
233 | 233 | $url_host = parse_url($url, PHP_URL_HOST); |
234 | 234 | $fetch_domain_hits[$url_host] += 1; |
235 | 235 | |
236 | 236 | if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { |
237 | - user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); |
|
237 | + user_error("Exceeded fetch request quota for $url_host: ".$fetch_domain_hits[$url_host], E_USER_WARNING); |
|
238 | 238 | #return false; |
239 | 239 | } |
240 | 240 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
251 | 251 | |
252 | 252 | if ($http_accept) |
253 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
253 | + array_push($curl_http_headers, "Accept: ".$http_accept); |
|
254 | 254 | |
255 | 255 | if (count($curl_http_headers) > 0) |
256 | 256 | curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
@@ -263,11 +263,10 @@ discard block |
||
263 | 263 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
264 | 264 | curl_setopt($ch, CURLOPT_HEADER, true); |
265 | 265 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
266 | - curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : |
|
267 | - SELF_USER_AGENT); |
|
266 | + curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : SELF_USER_AGENT); |
|
268 | 267 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
269 | 268 | |
270 | - if ($http_referrer) |
|
269 | + if ($http_referrer) |
|
271 | 270 | curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
272 | 271 | |
273 | 272 | if ($max_size) { |
@@ -276,7 +275,7 @@ discard block |
||
276 | 275 | |
277 | 276 | // holy shit closures in php |
278 | 277 | // download & upload are *expected* sizes respectively, could be zero |
279 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { |
|
278 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use(&$max_size) { |
|
280 | 279 | Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); |
281 | 280 | |
282 | 281 | return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it |
@@ -336,7 +335,7 @@ discard block |
||
336 | 335 | if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { |
337 | 336 | |
338 | 337 | if (curl_errno($ch) != 0) { |
339 | - $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); |
|
338 | + $fetch_last_error .= "; ".curl_errno($ch)." ".curl_error($ch); |
|
340 | 339 | } |
341 | 340 | |
342 | 341 | $fetch_last_error_content = $contents; |
@@ -345,7 +344,7 @@ discard block |
||
345 | 344 | } |
346 | 345 | |
347 | 346 | if (!$contents) { |
348 | - $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); |
|
347 | + $fetch_last_error = curl_errno($ch)." ".curl_error($ch); |
|
349 | 348 | curl_close($ch); |
350 | 349 | return false; |
351 | 350 | } |
@@ -365,7 +364,7 @@ discard block |
||
365 | 364 | |
366 | 365 | $fetch_curl_used = false; |
367 | 366 | |
368 | - if ($login && $pass){ |
|
367 | + if ($login && $pass) { |
|
369 | 368 | $url_parts = array(); |
370 | 369 | |
371 | 370 | preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts); |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | $pass = urlencode($pass); |
374 | 373 | |
375 | 374 | if ($url_parts[1] && $url_parts[2]) { |
376 | - $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2]; |
|
375 | + $url = $url_parts[1]."://$login:$pass@".$url_parts[2]; |
|
377 | 376 | } |
378 | 377 | } |
379 | 378 | |
@@ -441,7 +440,7 @@ discard block |
||
441 | 440 | $error = error_get_last(); |
442 | 441 | |
443 | 442 | if ($error['message'] != $old_error['message']) { |
444 | - $fetch_last_error .= "; " . $error["message"]; |
|
443 | + $fetch_last_error .= "; ".$error["message"]; |
|
445 | 444 | } |
446 | 445 | |
447 | 446 | $fetch_last_error_content = $data; |
@@ -516,15 +515,15 @@ discard block |
||
516 | 515 | |
517 | 516 | function get_ssl_certificate_id() { |
518 | 517 | if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { |
519 | - return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . |
|
520 | - $_SERVER["REDIRECT_SSL_CLIENT_V_START"] . |
|
521 | - $_SERVER["REDIRECT_SSL_CLIENT_V_END"] . |
|
518 | + return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]. |
|
519 | + $_SERVER["REDIRECT_SSL_CLIENT_V_START"]. |
|
520 | + $_SERVER["REDIRECT_SSL_CLIENT_V_END"]. |
|
522 | 521 | $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]); |
523 | 522 | } |
524 | 523 | if ($_SERVER["SSL_CLIENT_M_SERIAL"]) { |
525 | - return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] . |
|
526 | - $_SERVER["SSL_CLIENT_V_START"] . |
|
527 | - $_SERVER["SSL_CLIENT_V_END"] . |
|
524 | + return sha1($_SERVER["SSL_CLIENT_M_SERIAL"]. |
|
525 | + $_SERVER["SSL_CLIENT_V_START"]. |
|
526 | + $_SERVER["SSL_CLIENT_V_END"]. |
|
528 | 527 | $_SERVER["SSL_CLIENT_S_DN"]); |
529 | 528 | } |
530 | 529 | return ""; |
@@ -659,7 +658,7 @@ discard block |
||
659 | 658 | function logout_user() { |
660 | 659 | @session_destroy(); |
661 | 660 | if (isset($_COOKIE[session_name()])) { |
662 | - setcookie(session_name(), '', time()-42000, '/'); |
|
661 | + setcookie(session_name(), '', time() - 42000, '/'); |
|
663 | 662 | } |
664 | 663 | session_commit(); |
665 | 664 | } |
@@ -743,7 +742,7 @@ discard block |
||
743 | 742 | |
744 | 743 | function truncate_string($str, $max_len, $suffix = '…') { |
745 | 744 | if (mb_strlen($str, "utf-8") > $max_len) { |
746 | - return mb_substr($str, 0, $max_len, "utf-8") . $suffix; |
|
745 | + return mb_substr($str, 0, $max_len, "utf-8").$suffix; |
|
747 | 746 | } else { |
748 | 747 | return $str; |
749 | 748 | } |
@@ -753,7 +752,7 @@ discard block |
||
753 | 752 | $startString = mb_substr($original, 0, $position, "UTF-8"); |
754 | 753 | $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8"); |
755 | 754 | |
756 | - $out = $startString . $replacement . $endString; |
|
755 | + $out = $startString.$replacement.$endString; |
|
757 | 756 | |
758 | 757 | return $out; |
759 | 758 | } |
@@ -891,9 +890,9 @@ discard block |
||
891 | 890 | } |
892 | 891 | |
893 | 892 | function file_is_locked($filename) { |
894 | - if (file_exists(LOCK_DIRECTORY . "/$filename")) { |
|
893 | + if (file_exists(LOCK_DIRECTORY."/$filename")) { |
|
895 | 894 | if (function_exists('flock')) { |
896 | - $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); |
|
895 | + $fp = @fopen(LOCK_DIRECTORY."/$filename", "r"); |
|
897 | 896 | if ($fp) { |
898 | 897 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
899 | 898 | flock($fp, LOCK_UN); |
@@ -914,11 +913,11 @@ discard block |
||
914 | 913 | |
915 | 914 | |
916 | 915 | function make_lockfile($filename) { |
917 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
916 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
918 | 917 | |
919 | 918 | if ($fp && flock($fp, LOCK_EX | LOCK_NB)) { |
920 | 919 | $stat_h = fstat($fp); |
921 | - $stat_f = stat(LOCK_DIRECTORY . "/$filename"); |
|
920 | + $stat_f = stat(LOCK_DIRECTORY."/$filename"); |
|
922 | 921 | |
923 | 922 | if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { |
924 | 923 | if ($stat_h["ino"] != $stat_f["ino"] || |
@@ -929,7 +928,7 @@ discard block |
||
929 | 928 | } |
930 | 929 | |
931 | 930 | if (function_exists('posix_getpid')) { |
932 | - fwrite($fp, posix_getpid() . "\n"); |
|
931 | + fwrite($fp, posix_getpid()."\n"); |
|
933 | 932 | } |
934 | 933 | return $fp; |
935 | 934 | } else { |
@@ -938,10 +937,10 @@ discard block |
||
938 | 937 | } |
939 | 938 | |
940 | 939 | function make_stampfile($filename) { |
941 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
940 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
942 | 941 | |
943 | 942 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
944 | - fwrite($fp, time() . "\n"); |
|
943 | + fwrite($fp, time()."\n"); |
|
945 | 944 | flock($fp, LOCK_UN); |
946 | 945 | fclose($fp); |
947 | 946 | return true; |
@@ -991,7 +990,7 @@ discard block |
||
991 | 990 | $params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); |
992 | 991 | $params["label_base_index"] = (int) LABEL_BASE_INDEX; |
993 | 992 | |
994 | - $theme = get_pref( "USER_CSS_THEME", false, false); |
|
993 | + $theme = get_pref("USER_CSS_THEME", false, false); |
|
995 | 994 | $params["theme"] = theme_exists($theme) ? $theme : ""; |
996 | 995 | |
997 | 996 | $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); |
@@ -1215,13 +1214,13 @@ discard block |
||
1215 | 1214 | } |
1216 | 1215 | } |
1217 | 1216 | |
1218 | - if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { |
|
1217 | + if (file_exists(LOCK_DIRECTORY."/update_daemon.lock")) { |
|
1219 | 1218 | |
1220 | 1219 | $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); |
1221 | 1220 | |
1222 | 1221 | if (time() - $_SESSION["daemon_stamp_check"] > 30) { |
1223 | 1222 | |
1224 | - $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
1223 | + $stamp = (int) @file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
|
1225 | 1224 | |
1226 | 1225 | if ($stamp) { |
1227 | 1226 | $stamp_delta = time() - $stamp; |
@@ -1264,7 +1263,7 @@ discard block |
||
1264 | 1263 | $res = trim($str); if (!$res) return ''; |
1265 | 1264 | |
1266 | 1265 | $doc = new DOMDocument(); |
1267 | - $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
|
1266 | + $doc->loadHTML('<?xml encoding="UTF-8">'.$res); |
|
1268 | 1267 | $xpath = new DOMXPath($doc); |
1269 | 1268 | |
1270 | 1269 | $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); |
@@ -1363,7 +1362,7 @@ discard block |
||
1363 | 1362 | 'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', |
1364 | 1363 | 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', |
1365 | 1364 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
1366 | - 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
|
1365 | + 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace'); |
|
1367 | 1366 | |
1368 | 1367 | if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
1369 | 1368 | |
@@ -1498,8 +1497,8 @@ discard block |
||
1498 | 1497 | |
1499 | 1498 | // this returns SELF_URL_PATH sans ending slash |
1500 | 1499 | function get_self_url_prefix() { |
1501 | - if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) { |
|
1502 | - return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH)-1); |
|
1500 | + if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH) - 1) { |
|
1501 | + return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH) - 1); |
|
1503 | 1502 | } else { |
1504 | 1503 | return SELF_URL_PATH; |
1505 | 1504 | } |
@@ -1508,11 +1507,11 @@ discard block |
||
1508 | 1507 | /* TODO: This needs to use bcrypt */ |
1509 | 1508 | function encrypt_password($pass, $salt = '', $mode2 = false) { |
1510 | 1509 | if ($salt && $mode2) { |
1511 | - return "MODE2:" . hash('sha256', $salt . $pass); |
|
1510 | + return "MODE2:".hash('sha256', $salt.$pass); |
|
1512 | 1511 | } else if ($salt) { |
1513 | - return "SHA1X:" . sha1("$salt:$pass"); |
|
1512 | + return "SHA1X:".sha1("$salt:$pass"); |
|
1514 | 1513 | } else { |
1515 | - return "SHA1:" . sha1($pass); |
|
1514 | + return "SHA1:".sha1($pass); |
|
1516 | 1515 | } |
1517 | 1516 | } |
1518 | 1517 | |
@@ -1523,7 +1522,7 @@ discard block |
||
1523 | 1522 | } |
1524 | 1523 | |
1525 | 1524 | function build_url($parts) { |
1526 | - return $parts['scheme'] . "://" . $parts['host'] . $parts['path']; |
|
1525 | + return $parts['scheme']."://".$parts['host'].$parts['path']; |
|
1527 | 1526 | } |
1528 | 1527 | |
1529 | 1528 | function cleanup_url_path($path) { |
@@ -1567,7 +1566,7 @@ discard block |
||
1567 | 1566 | $dir = dirname($parts['path']); |
1568 | 1567 | $dir !== '/' && $dir .= '/'; |
1569 | 1568 | } |
1570 | - $parts['path'] = $dir . $rel_url; |
|
1569 | + $parts['path'] = $dir.$rel_url; |
|
1571 | 1570 | $parts['path'] = cleanup_url_path($parts['path']); |
1572 | 1571 | |
1573 | 1572 | return build_url($parts); |
@@ -1654,12 +1653,12 @@ discard block |
||
1654 | 1653 | |
1655 | 1654 | for ($i = 0; $i < $l10n->total; $i++) { |
1656 | 1655 | $orig = $l10n->get_original_string($i); |
1657 | - if(strpos($orig, "\000") !== false) { // Plural forms |
|
1656 | + if (strpos($orig, "\000") !== false) { // Plural forms |
|
1658 | 1657 | $key = explode(chr(0), $orig); |
1659 | 1658 | print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular |
1660 | 1659 | print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural |
1661 | 1660 | } else { |
1662 | - $translation = _dgettext($domain,$orig); |
|
1661 | + $translation = _dgettext($domain, $orig); |
|
1663 | 1662 | print T_js_decl($orig, $translation); |
1664 | 1663 | } |
1665 | 1664 | } |
@@ -1715,7 +1714,7 @@ discard block |
||
1715 | 1714 | if (file_exists($filename)) { |
1716 | 1715 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
1717 | 1716 | |
1718 | - return "data:image/$ext;base64," . base64_encode(file_get_contents($filename)); |
|
1717 | + return "data:image/$ext;base64,".base64_encode(file_get_contents($filename)); |
|
1719 | 1718 | } else { |
1720 | 1719 | return ""; |
1721 | 1720 | } |
@@ -1752,7 +1751,7 @@ discard block |
||
1752 | 1751 | |
1753 | 1752 | header("Content-type: $mimetype"); |
1754 | 1753 | |
1755 | - $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; |
|
1754 | + $stamp = gmdate("D, d M Y H:i:s", filemtime($filename))." GMT"; |
|
1756 | 1755 | header("Last-Modified: $stamp", true); |
1757 | 1756 | |
1758 | 1757 | return readfile($filename); |
@@ -1762,7 +1761,7 @@ discard block |
||
1762 | 1761 | } |
1763 | 1762 | |
1764 | 1763 | function arr_qmarks($arr) { |
1765 | - return str_repeat('?,', count($arr) - 1) . '?'; |
|
1764 | + return str_repeat('?,', count($arr) - 1).'?'; |
|
1766 | 1765 | } |
1767 | 1766 | |
1768 | 1767 | function get_scripts_timestamp() { |
@@ -1797,7 +1796,7 @@ discard block |
||
1797 | 1796 | } else if (PHP_OS === "Darwin") { |
1798 | 1797 | $ttrss_version = "UNKNOWN (Unsupported, Darwin)"; |
1799 | 1798 | } else if (file_exists("$root_dir/version_static.txt")) { |
1800 | - $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; |
|
1799 | + $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt"))." (Unsupported)"; |
|
1801 | 1800 | } else if (is_dir("$root_dir/.git")) { |
1802 | 1801 | $rc = 0; |
1803 | 1802 | $output = []; |
@@ -1815,10 +1814,10 @@ discard block |
||
1815 | 1814 | $git_commit = $commit; |
1816 | 1815 | $git_timestamp = $timestamp; |
1817 | 1816 | |
1818 | - $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit"; |
|
1817 | + $ttrss_version = strftime("%y.%m", $timestamp)."-$commit"; |
|
1819 | 1818 | } |
1820 | 1819 | } else { |
1821 | - user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING); |
|
1820 | + user_error("Unable to determine version (using $root_dir): ".implode("\n", $output), E_USER_WARNING); |
|
1822 | 1821 | } |
1823 | 1822 | } |
1824 | 1823 |
@@ -17,7 +17,9 @@ |
||
17 | 17 | |
18 | 18 | $timestamp = filemtime($filename); |
19 | 19 | |
20 | - if ($query) $timestamp .= "&$query"; |
|
20 | + if ($query) { |
|
21 | + $timestamp .= "&$query"; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
23 | 25 | } |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | - function stylesheet_tag($filename, $id = false) { |
|
3 | - $timestamp = filemtime($filename); |
|
2 | + function stylesheet_tag($filename, $id = false) { |
|
3 | + $timestamp = filemtime($filename); |
|
4 | 4 | |
5 | - $id_part = $id ? "id=\"$id\"" : ""; |
|
5 | + $id_part = $id ? "id=\"$id\"" : ""; |
|
6 | 6 | |
7 | - return "<link rel=\"stylesheet\" $id_part type=\"text/css\" href=\"$filename?$timestamp\"/>\n"; |
|
8 | - } |
|
7 | + return "<link rel=\"stylesheet\" $id_part type=\"text/css\" href=\"$filename?$timestamp\"/>\n"; |
|
8 | + } |
|
9 | 9 | |
10 | - function javascript_tag($filename) { |
|
11 | - $query = ""; |
|
10 | + function javascript_tag($filename) { |
|
11 | + $query = ""; |
|
12 | 12 | |
13 | - if (!(strpos($filename, "?") === false)) { |
|
14 | - $query = substr($filename, strpos($filename, "?")+1); |
|
15 | - $filename = substr($filename, 0, strpos($filename, "?")); |
|
16 | - } |
|
13 | + if (!(strpos($filename, "?") === false)) { |
|
14 | + $query = substr($filename, strpos($filename, "?")+1); |
|
15 | + $filename = substr($filename, 0, strpos($filename, "?")); |
|
16 | + } |
|
17 | 17 | |
18 | - $timestamp = filemtime($filename); |
|
18 | + $timestamp = filemtime($filename); |
|
19 | 19 | |
20 | - if ($query) $timestamp .= "&$query"; |
|
20 | + if ($query) $timestamp .= "&$query"; |
|
21 | 21 | |
22 | - return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
23 | - } |
|
22 | + return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
23 | + } |
|
24 | 24 | ?> |
25 | 25 | <!DOCTYPE html> |
26 | 26 | <html> |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | textarea { font-size : 12px; } |
32 | 32 | </style> |
33 | 33 | <?php |
34 | - echo stylesheet_tag("../css/default.css"); |
|
35 | - echo javascript_tag("../lib/prototype.js"); |
|
36 | - echo javascript_tag("../lib/dojo/dojo.js"); |
|
37 | - echo javascript_tag("../lib/dojo/tt-rss-layer.js"); |
|
38 | - ?> |
|
34 | + echo stylesheet_tag("../css/default.css"); |
|
35 | + echo javascript_tag("../lib/prototype.js"); |
|
36 | + echo javascript_tag("../lib/dojo/dojo.js"); |
|
37 | + echo javascript_tag("../lib/dojo/tt-rss-layer.js"); |
|
38 | + ?> |
|
39 | 39 | </head> |
40 | 40 | <body class="flat ttrss_utility installer"> |
41 | 41 | |
@@ -50,149 +50,149 @@ discard block |
||
50 | 50 | |
51 | 51 | <?php |
52 | 52 | |
53 | - // could be needed because of existing config.php |
|
54 | - function define_default($param, $value) { |
|
55 | - // |
|
56 | - } |
|
53 | + // could be needed because of existing config.php |
|
54 | + function define_default($param, $value) { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | |
58 | - function make_password($length = 12) { |
|
59 | - $password = ""; |
|
60 | - $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; |
|
58 | + function make_password($length = 12) { |
|
59 | + $password = ""; |
|
60 | + $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; |
|
61 | 61 | |
62 | - $i = 0; |
|
62 | + $i = 0; |
|
63 | 63 | |
64 | - while ($i < $length) { |
|
64 | + while ($i < $length) { |
|
65 | 65 | |
66 | - try { |
|
67 | - $idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1); |
|
68 | - } catch (Exception $e) { |
|
69 | - $idx = mt_rand(0, strlen($possible) - 1); |
|
70 | - } |
|
66 | + try { |
|
67 | + $idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1); |
|
68 | + } catch (Exception $e) { |
|
69 | + $idx = mt_rand(0, strlen($possible) - 1); |
|
70 | + } |
|
71 | 71 | |
72 | - $char = substr($possible, $idx, 1); |
|
72 | + $char = substr($possible, $idx, 1); |
|
73 | 73 | |
74 | - if (!strstr($password, $char)) { |
|
75 | - $password .= $char; |
|
76 | - $i++; |
|
77 | - } |
|
78 | - } |
|
74 | + if (!strstr($password, $char)) { |
|
75 | + $password .= $char; |
|
76 | + $i++; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - return $password; |
|
81 | - } |
|
80 | + return $password; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - function sanity_check($db_type) { |
|
85 | - $errors = array(); |
|
84 | + function sanity_check($db_type) { |
|
85 | + $errors = array(); |
|
86 | 86 | |
87 | - if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
88 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
89 | - } |
|
87 | + if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
88 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
89 | + } |
|
90 | 90 | |
91 | - if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
92 | - array_push($errors, "PHP configuration option allow_url_fopen is disabled, and CURL functions are not present. Either enable allow_url_fopen or install PHP extension for CURL."); |
|
93 | - } |
|
91 | + if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
92 | + array_push($errors, "PHP configuration option allow_url_fopen is disabled, and CURL functions are not present. Either enable allow_url_fopen or install PHP extension for CURL."); |
|
93 | + } |
|
94 | 94 | |
95 | - if (!function_exists("json_encode")) { |
|
96 | - array_push($errors, "PHP support for JSON is required, but was not found."); |
|
97 | - } |
|
95 | + if (!function_exists("json_encode")) { |
|
96 | + array_push($errors, "PHP support for JSON is required, but was not found."); |
|
97 | + } |
|
98 | 98 | |
99 | - if (!class_exists("PDO")) { |
|
100 | - array_push($errors, "PHP support for PDO is required but was not found."); |
|
101 | - } |
|
99 | + if (!class_exists("PDO")) { |
|
100 | + array_push($errors, "PHP support for PDO is required but was not found."); |
|
101 | + } |
|
102 | 102 | |
103 | - if (!function_exists("mb_strlen")) { |
|
104 | - array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
105 | - } |
|
103 | + if (!function_exists("mb_strlen")) { |
|
104 | + array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
105 | + } |
|
106 | 106 | |
107 | - if (!function_exists("hash")) { |
|
108 | - array_push($errors, "PHP support for hash() function is required but was not found."); |
|
109 | - } |
|
107 | + if (!function_exists("hash")) { |
|
108 | + array_push($errors, "PHP support for hash() function is required but was not found."); |
|
109 | + } |
|
110 | 110 | |
111 | - if (!function_exists("iconv")) { |
|
112 | - array_push($errors, "PHP support for iconv is required to handle multiple charsets."); |
|
113 | - } |
|
111 | + if (!function_exists("iconv")) { |
|
112 | + array_push($errors, "PHP support for iconv is required to handle multiple charsets."); |
|
113 | + } |
|
114 | 114 | |
115 | - if (ini_get("safe_mode")) { |
|
116 | - array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
117 | - } |
|
115 | + if (ini_get("safe_mode")) { |
|
116 | + array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!class_exists("DOMDocument")) { |
|
120 | - array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
121 | - } |
|
119 | + if (!class_exists("DOMDocument")) { |
|
120 | + array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
121 | + } |
|
122 | 122 | |
123 | - return $errors; |
|
124 | - } |
|
123 | + return $errors; |
|
124 | + } |
|
125 | 125 | |
126 | - function print_error($msg) { |
|
127 | - print "<div class='alert alert-error'>$msg</div>"; |
|
128 | - } |
|
126 | + function print_error($msg) { |
|
127 | + print "<div class='alert alert-error'>$msg</div>"; |
|
128 | + } |
|
129 | 129 | |
130 | - function print_notice($msg) { |
|
131 | - print "<div class=\"alert alert-info\">$msg</div>"; |
|
132 | - } |
|
130 | + function print_notice($msg) { |
|
131 | + print "<div class=\"alert alert-info\">$msg</div>"; |
|
132 | + } |
|
133 | 133 | |
134 | - function pdo_connect($host, $user, $pass, $db, $type, $port = false) { |
|
134 | + function pdo_connect($host, $user, $pass, $db, $type, $port = false) { |
|
135 | 135 | |
136 | - $db_port = $port ? ';port=' . $port : ''; |
|
137 | - $db_host = $host ? ';host=' . $host : ''; |
|
136 | + $db_port = $port ? ';port=' . $port : ''; |
|
137 | + $db_host = $host ? ';host=' . $host : ''; |
|
138 | 138 | |
139 | - try { |
|
140 | - $pdo = new PDO($type . ':dbname=' . $db . $db_host . $db_port, |
|
141 | - $user, |
|
142 | - $pass); |
|
139 | + try { |
|
140 | + $pdo = new PDO($type . ':dbname=' . $db . $db_host . $db_port, |
|
141 | + $user, |
|
142 | + $pass); |
|
143 | 143 | |
144 | - return $pdo; |
|
145 | - } catch (Exception $e) { |
|
146 | - print "<div class='alert alert-danger'>" . $e->getMessage() . "</div>"; |
|
147 | - return null; |
|
144 | + return $pdo; |
|
145 | + } catch (Exception $e) { |
|
146 | + print "<div class='alert alert-danger'>" . $e->getMessage() . "</div>"; |
|
147 | + return null; |
|
148 | 148 | } |
149 | - } |
|
150 | - |
|
151 | - function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
152 | - $DB_PORT, $SELF_URL_PATH) { |
|
153 | - |
|
154 | - $data = explode("\n", file_get_contents("../config.php-dist")); |
|
155 | - |
|
156 | - $rv = ""; |
|
157 | - |
|
158 | - $finished = false; |
|
159 | - |
|
160 | - foreach ($data as $line) { |
|
161 | - if (preg_match("/define\('DB_TYPE'/", $line)) { |
|
162 | - $rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n"; |
|
163 | - } else if (preg_match("/define\('DB_HOST'/", $line)) { |
|
164 | - $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; |
|
165 | - } else if (preg_match("/define\('DB_USER'/", $line)) { |
|
166 | - $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; |
|
167 | - } else if (preg_match("/define\('DB_NAME'/", $line)) { |
|
168 | - $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; |
|
169 | - } else if (preg_match("/define\('DB_PASS'/", $line)) { |
|
170 | - $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; |
|
171 | - } else if (preg_match("/define\('DB_PORT'/", $line)) { |
|
172 | - $rv .= "\tdefine('DB_PORT', '$DB_PORT');\n"; |
|
173 | - } else if (preg_match("/define\('SELF_URL_PATH'/", $line)) { |
|
174 | - $rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n"; |
|
175 | - } else if (!$finished) { |
|
176 | - $rv .= "$line\n"; |
|
177 | - } |
|
178 | - |
|
179 | - if (preg_match("/\?\>/", $line)) { |
|
180 | - $finished = true; |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - return $rv; |
|
185 | - } |
|
186 | - |
|
187 | - function is_server_https() { |
|
188 | - return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); |
|
189 | - } |
|
190 | - |
|
191 | - function make_self_url_path() { |
|
192 | - $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
193 | - |
|
194 | - return $url_path; |
|
195 | - } |
|
149 | + } |
|
150 | + |
|
151 | + function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
152 | + $DB_PORT, $SELF_URL_PATH) { |
|
153 | + |
|
154 | + $data = explode("\n", file_get_contents("../config.php-dist")); |
|
155 | + |
|
156 | + $rv = ""; |
|
157 | + |
|
158 | + $finished = false; |
|
159 | + |
|
160 | + foreach ($data as $line) { |
|
161 | + if (preg_match("/define\('DB_TYPE'/", $line)) { |
|
162 | + $rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n"; |
|
163 | + } else if (preg_match("/define\('DB_HOST'/", $line)) { |
|
164 | + $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; |
|
165 | + } else if (preg_match("/define\('DB_USER'/", $line)) { |
|
166 | + $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; |
|
167 | + } else if (preg_match("/define\('DB_NAME'/", $line)) { |
|
168 | + $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; |
|
169 | + } else if (preg_match("/define\('DB_PASS'/", $line)) { |
|
170 | + $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; |
|
171 | + } else if (preg_match("/define\('DB_PORT'/", $line)) { |
|
172 | + $rv .= "\tdefine('DB_PORT', '$DB_PORT');\n"; |
|
173 | + } else if (preg_match("/define\('SELF_URL_PATH'/", $line)) { |
|
174 | + $rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n"; |
|
175 | + } else if (!$finished) { |
|
176 | + $rv .= "$line\n"; |
|
177 | + } |
|
178 | + |
|
179 | + if (preg_match("/\?\>/", $line)) { |
|
180 | + $finished = true; |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + return $rv; |
|
185 | + } |
|
186 | + |
|
187 | + function is_server_https() { |
|
188 | + return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); |
|
189 | + } |
|
190 | + |
|
191 | + function make_self_url_path() { |
|
192 | + $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
193 | + |
|
194 | + return $url_path; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | ?> |
198 | 198 | |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | |
203 | 203 | <?php |
204 | 204 | |
205 | - if (file_exists("../config.php")) { |
|
206 | - require "../config.php"; |
|
205 | + if (file_exists("../config.php")) { |
|
206 | + require "../config.php"; |
|
207 | 207 | |
208 | - if (!defined('_INSTALLER_IGNORE_CONFIG_CHECK')) { |
|
209 | - print_error("Error: config.php already exists in tt-rss directory; aborting."); |
|
208 | + if (!defined('_INSTALLER_IGNORE_CONFIG_CHECK')) { |
|
209 | + print_error("Error: config.php already exists in tt-rss directory; aborting."); |
|
210 | 210 | |
211 | - print "<form method='GET' action='../index.php'> |
|
211 | + print "<form method='GET' action='../index.php'> |
|
212 | 212 | <button type='submit' dojoType='dijit.form.Button' class='alt-primary'>Return to Tiny Tiny RSS</button> |
213 | 213 | </form>"; |
214 | - exit; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - @$op = $_REQUEST['op']; |
|
219 | - |
|
220 | - @$DB_HOST = strip_tags($_POST['DB_HOST']); |
|
221 | - @$DB_TYPE = strip_tags($_POST['DB_TYPE']); |
|
222 | - @$DB_USER = strip_tags($_POST['DB_USER']); |
|
223 | - @$DB_NAME = strip_tags($_POST['DB_NAME']); |
|
224 | - @$DB_PASS = strip_tags($_POST['DB_PASS']); |
|
225 | - @$DB_PORT = strip_tags($_POST['DB_PORT']); |
|
226 | - @$SELF_URL_PATH = strip_tags($_POST['SELF_URL_PATH']); |
|
227 | - |
|
228 | - if (!$SELF_URL_PATH) { |
|
229 | - $SELF_URL_PATH = preg_replace("/\/install\/$/", "/", make_self_url_path()); |
|
230 | - } |
|
214 | + exit; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + @$op = $_REQUEST['op']; |
|
219 | + |
|
220 | + @$DB_HOST = strip_tags($_POST['DB_HOST']); |
|
221 | + @$DB_TYPE = strip_tags($_POST['DB_TYPE']); |
|
222 | + @$DB_USER = strip_tags($_POST['DB_USER']); |
|
223 | + @$DB_NAME = strip_tags($_POST['DB_NAME']); |
|
224 | + @$DB_PASS = strip_tags($_POST['DB_PASS']); |
|
225 | + @$DB_PORT = strip_tags($_POST['DB_PORT']); |
|
226 | + @$SELF_URL_PATH = strip_tags($_POST['SELF_URL_PATH']); |
|
227 | + |
|
228 | + if (!$SELF_URL_PATH) { |
|
229 | + $SELF_URL_PATH = preg_replace("/\/install\/$/", "/", make_self_url_path()); |
|
230 | + } |
|
231 | 231 | ?> |
232 | 232 | |
233 | 233 | <form action="" method="post"> |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | <h2>Database settings</h2> |
237 | 237 | |
238 | 238 | <?php |
239 | - $issel_pgsql = $DB_TYPE == "pgsql" ? "selected='selected'" : ""; |
|
240 | - $issel_mysql = $DB_TYPE == "mysql" ? "selected='selected'" : ""; |
|
241 | - ?> |
|
239 | + $issel_pgsql = $DB_TYPE == "pgsql" ? "selected='selected'" : ""; |
|
240 | + $issel_mysql = $DB_TYPE == "mysql" ? "selected='selected'" : ""; |
|
241 | + ?> |
|
242 | 242 | |
243 | 243 | <fieldset> |
244 | 244 | <label>Database type:</label> |
@@ -292,87 +292,87 @@ discard block |
||
292 | 292 | <h2>Checking configuration</h2> |
293 | 293 | |
294 | 294 | <?php |
295 | - $errors = sanity_check($DB_TYPE); |
|
295 | + $errors = sanity_check($DB_TYPE); |
|
296 | 296 | |
297 | - if (count($errors) > 0) { |
|
298 | - print "<p>Some configuration tests failed. Please correct them before continuing.</p>"; |
|
297 | + if (count($errors) > 0) { |
|
298 | + print "<p>Some configuration tests failed. Please correct them before continuing.</p>"; |
|
299 | 299 | |
300 | - print "<ul>"; |
|
300 | + print "<ul>"; |
|
301 | 301 | |
302 | - foreach ($errors as $error) { |
|
303 | - print "<li style='color : red'>$error</li>"; |
|
304 | - } |
|
302 | + foreach ($errors as $error) { |
|
303 | + print "<li style='color : red'>$error</li>"; |
|
304 | + } |
|
305 | 305 | |
306 | - print "</ul>"; |
|
306 | + print "</ul>"; |
|
307 | 307 | |
308 | - exit; |
|
309 | - } |
|
308 | + exit; |
|
309 | + } |
|
310 | 310 | |
311 | - $notices = array(); |
|
311 | + $notices = array(); |
|
312 | 312 | |
313 | - if (!function_exists("curl_init")) { |
|
314 | - array_push($notices, "It is highly recommended to enable support for CURL in PHP."); |
|
315 | - } |
|
313 | + if (!function_exists("curl_init")) { |
|
314 | + array_push($notices, "It is highly recommended to enable support for CURL in PHP."); |
|
315 | + } |
|
316 | 316 | |
317 | - if (function_exists("curl_init") && ini_get("open_basedir")) { |
|
318 | - array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information."); |
|
319 | - } |
|
317 | + if (function_exists("curl_init") && ini_get("open_basedir")) { |
|
318 | + array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information."); |
|
319 | + } |
|
320 | 320 | |
321 | - if (!function_exists("idn_to_ascii")) { |
|
322 | - array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names."); |
|
323 | - } |
|
321 | + if (!function_exists("idn_to_ascii")) { |
|
322 | + array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names."); |
|
323 | + } |
|
324 | 324 | |
325 | 325 | if ($DB_TYPE == "mysql" && !function_exists("mysqli_connect")) { |
326 | 326 | array_push($notices, "PHP extension for MySQL (mysqli) is missing. This may prevent legacy plugins from working."); |
327 | 327 | } |
328 | 328 | |
329 | 329 | if ($DB_TYPE == "pgsql" && !function_exists("pg_connect")) { |
330 | - array_push($notices, "PHP extension for PostgreSQL is missing. This may prevent legacy plugins from working."); |
|
330 | + array_push($notices, "PHP extension for PostgreSQL is missing. This may prevent legacy plugins from working."); |
|
331 | 331 | } |
332 | 332 | |
333 | - if (count($notices) > 0) { |
|
334 | - print_notice("Configuration check succeeded with minor problems:"); |
|
333 | + if (count($notices) > 0) { |
|
334 | + print_notice("Configuration check succeeded with minor problems:"); |
|
335 | 335 | |
336 | - print "<ul>"; |
|
336 | + print "<ul>"; |
|
337 | 337 | |
338 | - foreach ($notices as $notice) { |
|
339 | - print "<li>$notice</li>"; |
|
340 | - } |
|
338 | + foreach ($notices as $notice) { |
|
339 | + print "<li>$notice</li>"; |
|
340 | + } |
|
341 | 341 | |
342 | - print "</ul>"; |
|
343 | - } else { |
|
344 | - print_notice("Configuration check succeeded."); |
|
345 | - } |
|
342 | + print "</ul>"; |
|
343 | + } else { |
|
344 | + print_notice("Configuration check succeeded."); |
|
345 | + } |
|
346 | 346 | |
347 | - ?> |
|
347 | + ?> |
|
348 | 348 | |
349 | 349 | <h2>Checking database</h2> |
350 | 350 | |
351 | 351 | <?php |
352 | - $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
352 | + $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
353 | 353 | |
354 | - if (!$pdo) { |
|
355 | - print_error("Unable to connect to database using specified parameters (driver: $DB_TYPE)."); |
|
356 | - exit; |
|
357 | - } |
|
354 | + if (!$pdo) { |
|
355 | + print_error("Unable to connect to database using specified parameters (driver: $DB_TYPE)."); |
|
356 | + exit; |
|
357 | + } |
|
358 | 358 | |
359 | - print_notice("Database test succeeded."); |
|
360 | - ?> |
|
359 | + print_notice("Database test succeeded."); |
|
360 | + ?> |
|
361 | 361 | |
362 | 362 | <h2>Initialize database</h2> |
363 | 363 | |
364 | 364 | <p>Before you can start using tt-rss, database needs to be initialized. Click on the button below to do that now.</p> |
365 | 365 | |
366 | 366 | <?php |
367 | - $res = $pdo->query("SELECT true FROM ttrss_feeds"); |
|
367 | + $res = $pdo->query("SELECT true FROM ttrss_feeds"); |
|
368 | 368 | |
369 | - if ($res && $res->fetch()) { |
|
370 | - print_error("Some tt-rss data already exists in this database. If you continue with database initialization your current data <b>WILL BE LOST</b>."); |
|
371 | - $need_confirm = true; |
|
372 | - } else { |
|
373 | - $need_confirm = false; |
|
374 | - } |
|
375 | - ?> |
|
369 | + if ($res && $res->fetch()) { |
|
370 | + print_error("Some tt-rss data already exists in this database. If you continue with database initialization your current data <b>WILL BE LOST</b>."); |
|
371 | + $need_confirm = true; |
|
372 | + } else { |
|
373 | + $need_confirm = false; |
|
374 | + } |
|
375 | + ?> |
|
376 | 376 | |
377 | 377 | <table><tr><td> |
378 | 378 | <form method="post"> |
@@ -415,44 +415,44 @@ discard block |
||
415 | 415 | |
416 | 416 | <?php |
417 | 417 | |
418 | - } else if ($op == 'installschema' || $op == 'skipschema') { |
|
418 | + } else if ($op == 'installschema' || $op == 'skipschema') { |
|
419 | 419 | |
420 | - $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
420 | + $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
421 | 421 | |
422 | - if (!$pdo) { |
|
423 | - print_error("Unable to connect to database using specified parameters."); |
|
424 | - exit; |
|
425 | - } |
|
422 | + if (!$pdo) { |
|
423 | + print_error("Unable to connect to database using specified parameters."); |
|
424 | + exit; |
|
425 | + } |
|
426 | 426 | |
427 | - if ($op == 'installschema') { |
|
427 | + if ($op == 'installschema') { |
|
428 | 428 | |
429 | - print "<h2>Initializing database...</h2>"; |
|
429 | + print "<h2>Initializing database...</h2>"; |
|
430 | 430 | |
431 | - $lines = explode(";", preg_replace("/[\r\n]/", "", |
|
431 | + $lines = explode(";", preg_replace("/[\r\n]/", "", |
|
432 | 432 | file_get_contents("../schema/ttrss_schema_".basename($DB_TYPE).".sql"))); |
433 | 433 | |
434 | - foreach ($lines as $line) { |
|
435 | - if (strpos($line, "--") !== 0 && $line) { |
|
436 | - $res = $pdo->query($line); |
|
434 | + foreach ($lines as $line) { |
|
435 | + if (strpos($line, "--") !== 0 && $line) { |
|
436 | + $res = $pdo->query($line); |
|
437 | 437 | |
438 | - if (!$res) { |
|
439 | - print_notice("Query: $line"); |
|
440 | - print_error("Error: " . implode(", ", $pdo->errorInfo())); |
|
438 | + if (!$res) { |
|
439 | + print_notice("Query: $line"); |
|
440 | + print_error("Error: " . implode(", ", $pdo->errorInfo())); |
|
441 | 441 | } |
442 | - } |
|
443 | - } |
|
442 | + } |
|
443 | + } |
|
444 | 444 | |
445 | - print_notice("Database initialization completed."); |
|
445 | + print_notice("Database initialization completed."); |
|
446 | 446 | |
447 | - } else { |
|
448 | - print_notice("Database initialization skipped."); |
|
449 | - } |
|
447 | + } else { |
|
448 | + print_notice("Database initialization skipped."); |
|
449 | + } |
|
450 | 450 | |
451 | - print "<h2>Generated configuration file</h2>"; |
|
451 | + print "<h2>Generated configuration file</h2>"; |
|
452 | 452 | |
453 | - print "<p>Copy following text and save as <code>config.php</code> in tt-rss main directory. It is suggested to read through the file to the end in case you need any options changed fom default values.</p>"; |
|
453 | + print "<p>Copy following text and save as <code>config.php</code> in tt-rss main directory. It is suggested to read through the file to the end in case you need any options changed fom default values.</p>"; |
|
454 | 454 | |
455 | - print "<p>After copying the file, you will be able to login with default username and password combination: <code>admin</code> and <code>password</code>. Don't forget to change the password immediately!</p>"; ?> |
|
455 | + print "<p>After copying the file, you will be able to login with default username and password combination: <code>admin</code> and <code>password</code>. Don't forget to change the password immediately!</p>"; ?> |
|
456 | 456 | |
457 | 457 | <form action="" method="post"> |
458 | 458 | <input type="hidden" name="op" value="saveconfig"> |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | <input type="hidden" name="DB_TYPE" value="<?php echo $DB_TYPE ?>"/> |
465 | 465 | <input type="hidden" name="SELF_URL_PATH" value="<?php echo $SELF_URL_PATH ?>"/> |
466 | 466 | <?php print "<textarea rows='20' style='width : 100%'>"; |
467 | - echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
468 | - $DB_PORT, $SELF_URL_PATH); |
|
469 | - print "</textarea>"; ?> |
|
467 | + echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
468 | + $DB_PORT, $SELF_URL_PATH); |
|
469 | + print "</textarea>"; ?> |
|
470 | 470 | |
471 | 471 | <hr/> |
472 | 472 | |
@@ -476,40 +476,40 @@ discard block |
||
476 | 476 | <p><button type="submit" dojoType='dijit.form.Button' class='alt-primary'>Save configuration</button></p> |
477 | 477 | </form> |
478 | 478 | <?php } else { |
479 | - print_error("Unfortunately, parent directory is not writable, so we're unable to save config.php automatically."); |
|
480 | - } |
|
479 | + print_error("Unfortunately, parent directory is not writable, so we're unable to save config.php automatically."); |
|
480 | + } |
|
481 | 481 | |
482 | - print_notice("You can generate the file again by changing the form above."); |
|
482 | + print_notice("You can generate the file again by changing the form above."); |
|
483 | 483 | |
484 | - } else if ($op == "saveconfig") { |
|
484 | + } else if ($op == "saveconfig") { |
|
485 | 485 | |
486 | - print "<h2>Saving configuration file to parent directory...</h2>"; |
|
486 | + print "<h2>Saving configuration file to parent directory...</h2>"; |
|
487 | 487 | |
488 | - if (!file_exists("../config.php")) { |
|
488 | + if (!file_exists("../config.php")) { |
|
489 | 489 | |
490 | - $fp = fopen("../config.php", "w"); |
|
490 | + $fp = fopen("../config.php", "w"); |
|
491 | 491 | |
492 | - if ($fp) { |
|
493 | - $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, |
|
494 | - $DB_USER, $DB_NAME, $DB_PASS, |
|
495 | - $DB_PORT, $SELF_URL_PATH)); |
|
492 | + if ($fp) { |
|
493 | + $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, |
|
494 | + $DB_USER, $DB_NAME, $DB_PASS, |
|
495 | + $DB_PORT, $SELF_URL_PATH)); |
|
496 | 496 | |
497 | - if ($written > 0) { |
|
498 | - print_notice("Successfully saved config.php. You can try <a href=\"..\">loading tt-rss now</a>."); |
|
497 | + if ($written > 0) { |
|
498 | + print_notice("Successfully saved config.php. You can try <a href=\"..\">loading tt-rss now</a>."); |
|
499 | 499 | |
500 | - } else { |
|
501 | - print_notice("Unable to write into config.php in tt-rss directory."); |
|
502 | - } |
|
500 | + } else { |
|
501 | + print_notice("Unable to write into config.php in tt-rss directory."); |
|
502 | + } |
|
503 | 503 | |
504 | - fclose($fp); |
|
505 | - } else { |
|
506 | - print_error("Unable to open config.php in tt-rss directory for writing."); |
|
507 | - } |
|
508 | - } else { |
|
509 | - print_error("config.php already present in tt-rss directory, refusing to overwrite."); |
|
510 | - } |
|
511 | - } |
|
512 | - ?> |
|
504 | + fclose($fp); |
|
505 | + } else { |
|
506 | + print_error("Unable to open config.php in tt-rss directory for writing."); |
|
507 | + } |
|
508 | + } else { |
|
509 | + print_error("config.php already present in tt-rss directory, refusing to overwrite."); |
|
510 | + } |
|
511 | + } |
|
512 | + ?> |
|
513 | 513 | |
514 | 514 | </div> |
515 | 515 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | $query = ""; |
12 | 12 | |
13 | 13 | if (!(strpos($filename, "?") === false)) { |
14 | - $query = substr($filename, strpos($filename, "?")+1); |
|
14 | + $query = substr($filename, strpos($filename, "?") + 1); |
|
15 | 15 | $filename = substr($filename, 0, strpos($filename, "?")); |
16 | 16 | } |
17 | 17 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $errors = array(); |
86 | 86 | |
87 | 87 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
88 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
88 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using ".PHP_VERSION."."); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | |
134 | 134 | function pdo_connect($host, $user, $pass, $db, $type, $port = false) { |
135 | 135 | |
136 | - $db_port = $port ? ';port=' . $port : ''; |
|
137 | - $db_host = $host ? ';host=' . $host : ''; |
|
136 | + $db_port = $port ? ';port='.$port : ''; |
|
137 | + $db_host = $host ? ';host='.$host : ''; |
|
138 | 138 | |
139 | 139 | try { |
140 | - $pdo = new PDO($type . ':dbname=' . $db . $db_host . $db_port, |
|
140 | + $pdo = new PDO($type.':dbname='.$db.$db_host.$db_port, |
|
141 | 141 | $user, |
142 | 142 | $pass); |
143 | 143 | |
144 | 144 | return $pdo; |
145 | 145 | } catch (Exception $e) { |
146 | - print "<div class='alert alert-danger'>" . $e->getMessage() . "</div>"; |
|
146 | + print "<div class='alert alert-danger'>".$e->getMessage()."</div>"; |
|
147 | 147 | return null; |
148 | 148 | } |
149 | 149 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | function make_self_url_path() { |
192 | - $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
192 | + $url_path = (is_server_https() ? 'https://' : 'http://').$_SERVER["HTTP_HOST"].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
193 | 193 | |
194 | 194 | return $url_path; |
195 | 195 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | if (!$res) { |
439 | 439 | print_notice("Query: $line"); |
440 | - print_error("Error: " . implode(", ", $pdo->errorInfo())); |
|
440 | + print_error("Error: ".implode(", ", $pdo->errorInfo())); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | } |
@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php |
2 | 2 | class Swap_JK extends Plugin { |
3 | 3 | |
4 | - private $host; |
|
4 | + private $host; |
|
5 | 5 | |
6 | - public function about() { |
|
7 | - return array(1.0, |
|
8 | - "Swap j and k hotkeys (for vi brethren)", |
|
9 | - "fox"); |
|
10 | - } |
|
6 | + public function about() { |
|
7 | + return array(1.0, |
|
8 | + "Swap j and k hotkeys (for vi brethren)", |
|
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_HOTKEY_MAP, $this); |
|
16 | - } |
|
15 | + $host->add_hook($host::HOOK_HOTKEY_MAP, $this); |
|
16 | + } |
|
17 | 17 | |
18 | - public function hook_hotkey_map($hotkeys) { |
|
18 | + public function hook_hotkey_map($hotkeys) { |
|
19 | 19 | |
20 | - $hotkeys["j"] = "next_feed"; |
|
21 | - $hotkeys["k"] = "prev_feed"; |
|
20 | + $hotkeys["j"] = "next_feed"; |
|
21 | + $hotkeys["k"] = "prev_feed"; |
|
22 | 22 | |
23 | - return $hotkeys; |
|
24 | - } |
|
23 | + return $hotkeys; |
|
24 | + } |
|
25 | 25 | |
26 | - public function api_version() { |
|
27 | - return 2; |
|
28 | - } |
|
26 | + public function api_version() { |
|
27 | + return 2; |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | class Close_Button extends Plugin { |
3 | - private $host; |
|
4 | - |
|
5 | - public function init($host) { |
|
6 | - $this->host = $host; |
|
7 | - |
|
8 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
9 | - } |
|
10 | - |
|
11 | - public function about() { |
|
12 | - return array(1.0, |
|
13 | - "Adds a button to close article panel", |
|
14 | - "fox"); |
|
15 | - } |
|
16 | - |
|
17 | - public function get_css() { |
|
18 | - return "i.icon-close-article { color : red; }"; |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
23 | - */ |
|
24 | - public function hook_article_button($line) { |
|
25 | - if (!get_pref("COMBINED_DISPLAY_MODE")) { |
|
26 | - $rv = "<i class='material-icons icon-close-article' |
|
3 | + private $host; |
|
4 | + |
|
5 | + public function init($host) { |
|
6 | + $this->host = $host; |
|
7 | + |
|
8 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
9 | + } |
|
10 | + |
|
11 | + public function about() { |
|
12 | + return array(1.0, |
|
13 | + "Adds a button to close article panel", |
|
14 | + "fox"); |
|
15 | + } |
|
16 | + |
|
17 | + public function get_css() { |
|
18 | + return "i.icon-close-article { color : red; }"; |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
23 | + */ |
|
24 | + public function hook_article_button($line) { |
|
25 | + if (!get_pref("COMBINED_DISPLAY_MODE")) { |
|
26 | + $rv = "<i class='material-icons icon-close-article' |
|
27 | 27 | style='cursor : pointer' onclick='Article.close()' |
28 | 28 | title='".__('Close article')."'>close</i>"; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - return $rv; |
|
32 | - } |
|
31 | + return $rv; |
|
32 | + } |
|
33 | 33 | |
34 | - public function api_version() { |
|
35 | - return 2; |
|
36 | - } |
|
34 | + public function api_version() { |
|
35 | + return 2; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -1,78 +1,78 @@ |
||
1 | 1 | <?php |
2 | 2 | class VF_Shared 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 | - "Feed for all articles actively shared by URL", |
|
10 | - "fox", |
|
11 | - false); |
|
12 | - } |
|
7 | + public function about() { |
|
8 | + return array(1.0, |
|
9 | + "Feed for all articles actively shared by URL", |
|
10 | + "fox", |
|
11 | + false); |
|
12 | + } |
|
13 | 13 | |
14 | - public function init($host) { |
|
15 | - $this->host = $host; |
|
14 | + public function init($host) { |
|
15 | + $this->host = $host; |
|
16 | 16 | |
17 | - $host->add_feed(-1, __("Shared articles"), 'link', $this); |
|
18 | - } |
|
17 | + $host->add_feed(-1, __("Shared articles"), 'link', $this); |
|
18 | + } |
|
19 | 19 | |
20 | - public function api_version() { |
|
21 | - return 2; |
|
22 | - } |
|
20 | + public function api_version() { |
|
21 | + return 2; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
26 | - */ |
|
27 | - public function get_unread($feed_id) { |
|
28 | - $sth = $this->pdo->prepare("select count(int_id) AS count |
|
24 | + /** |
|
25 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
26 | + */ |
|
27 | + public function get_unread($feed_id) { |
|
28 | + $sth = $this->pdo->prepare("select count(int_id) AS count |
|
29 | 29 | from ttrss_user_entries where owner_uid = ? and unread = true and uuid != ''"); |
30 | - $sth->execute([$_SESSION['uid']]); |
|
30 | + $sth->execute([$_SESSION['uid']]); |
|
31 | 31 | |
32 | - if ($row = $sth->fetch()) { |
|
33 | - return $row['count']; |
|
34 | - } |
|
32 | + if ($row = $sth->fetch()) { |
|
33 | + return $row['count']; |
|
34 | + } |
|
35 | 35 | |
36 | - return 0; |
|
37 | - } |
|
36 | + return 0; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
41 | - */ |
|
42 | - public function get_total($feed_id) { |
|
43 | - $sth = $this->pdo->prepare("select count(int_id) AS count |
|
39 | + /** |
|
40 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
41 | + */ |
|
42 | + public function get_total($feed_id) { |
|
43 | + $sth = $this->pdo->prepare("select count(int_id) AS count |
|
44 | 44 | from ttrss_user_entries where owner_uid = ? and uuid != ''"); |
45 | - $sth->execute([$_SESSION['uid']]); |
|
45 | + $sth->execute([$_SESSION['uid']]); |
|
46 | 46 | |
47 | - if ($row = $sth->fetch()) { |
|
48 | - return $row['count']; |
|
49 | - } |
|
47 | + if ($row = $sth->fetch()) { |
|
48 | + return $row['count']; |
|
49 | + } |
|
50 | 50 | |
51 | - return 0; |
|
52 | - } |
|
51 | + return 0; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
56 | - */ |
|
57 | - public function get_headlines($feed_id, $options) { |
|
58 | - $params = array( |
|
59 | - "feed" => -4, |
|
60 | - "limit" => $options["limit"], |
|
61 | - "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles", |
|
62 | - "search" => $options['search'], |
|
63 | - "override_order" => $options['override_order'], |
|
64 | - "offset" => $options["offset"], |
|
65 | - "filter" => $options["filter"], |
|
66 | - "since_id" => $options["since_id"], |
|
67 | - "include_children" => $options["include_children"], |
|
68 | - "override_strategy" => "uuid != ''", |
|
69 | - "override_vfeed" => "ttrss_feeds.title AS feed_title," |
|
70 | - ); |
|
54 | + /** |
|
55 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
56 | + */ |
|
57 | + public function get_headlines($feed_id, $options) { |
|
58 | + $params = array( |
|
59 | + "feed" => -4, |
|
60 | + "limit" => $options["limit"], |
|
61 | + "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles", |
|
62 | + "search" => $options['search'], |
|
63 | + "override_order" => $options['override_order'], |
|
64 | + "offset" => $options["offset"], |
|
65 | + "filter" => $options["filter"], |
|
66 | + "since_id" => $options["since_id"], |
|
67 | + "include_children" => $options["include_children"], |
|
68 | + "override_strategy" => "uuid != ''", |
|
69 | + "override_vfeed" => "ttrss_feeds.title AS feed_title," |
|
70 | + ); |
|
71 | 71 | |
72 | - $qfh_ret = Feeds::queryFeedHeadlines($params); |
|
73 | - $qfh_ret[1] = __("Shared articles"); |
|
72 | + $qfh_ret = Feeds::queryFeedHeadlines($params); |
|
73 | + $qfh_ret[1] = __("Shared articles"); |
|
74 | 74 | |
75 | - return $qfh_ret; |
|
76 | - } |
|
75 | + return $qfh_ret; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class Af_ComicFilter { |
3 | - public abstract function supported(); |
|
4 | - public abstract function process(&$article); |
|
3 | + public abstract function supported(); |
|
4 | + public abstract function process(&$article); |
|
5 | 5 | } |
6 | 6 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics_Template extends Af_ComicFilter { |
3 | 3 | |
4 | - public function supported() { |
|
5 | - return array("Example"); |
|
6 | - } |
|
4 | + public function supported() { |
|
5 | + return array("Example"); |
|
6 | + } |
|
7 | 7 | |
8 | - public function process(&$article) { |
|
9 | - //$owner_uid = $article["owner_uid"]; |
|
8 | + public function process(&$article) { |
|
9 | + //$owner_uid = $article["owner_uid"]; |
|
10 | 10 | |
11 | - return false; |
|
12 | - } |
|
11 | + return false; |
|
12 | + } |
|
13 | 13 | } |