@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | $ERRORS[0] = ""; |
8 | 8 | |
9 | 9 | $ERRORS[1] = __("This program requires XmlHttpRequest " . |
10 | - "to function properly. Your browser doesn't seem to support it."); |
|
10 | + "to function properly. Your browser doesn't seem to support it."); |
|
11 | 11 | |
12 | 12 | $ERRORS[2] = __("This program requires cookies " . |
13 | - "to function properly. Your browser doesn't seem to support them."); |
|
13 | + "to function properly. Your browser doesn't seem to support them."); |
|
14 | 14 | |
15 | 15 | $ERRORS[3] = __("Backend sanity check failed."); |
16 | 16 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $ERRORS[15] = __("Encoding data as JSON failed"); |
42 | 42 | |
43 | 43 | if ($_REQUEST['mode'] == 'js') { |
44 | - header("Content-Type: text/javascript; charset=UTF-8"); |
|
44 | + header("Content-Type: text/javascript; charset=UTF-8"); |
|
45 | 45 | |
46 | - print "var ERRORS = [];\n"; |
|
46 | + print "var ERRORS = [];\n"; |
|
47 | 47 | |
48 | - foreach ($ERRORS as $id => $error) { |
|
48 | + foreach ($ERRORS as $id => $error) { |
|
49 | 49 | |
50 | - $error = preg_replace("/\n/", "", $error); |
|
51 | - $error = preg_replace("/\"/", "\\\"", $error); |
|
50 | + $error = preg_replace("/\n/", "", $error); |
|
51 | + $error = preg_replace("/\"/", "\\\"", $error); |
|
52 | 52 | |
53 | - print "ERRORS[$id] = \"$error\";\n"; |
|
54 | - } |
|
53 | + print "ERRORS[$id] = \"$error\";\n"; |
|
54 | + } |
|
55 | 55 | } |
@@ -173,29 +173,29 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Maximum matrix size for maximum version (version 40 is 177*177 matrix). |
175 | 175 | */ |
176 | - define('QRSPEC_WIDTH_MAX', 177); |
|
176 | + define('QRSPEC_WIDTH_MAX', 177); |
|
177 | 177 | |
178 | 178 | // ----------------------------------------------------- |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Matrix index to get width from $capacity array. |
182 | 182 | */ |
183 | - define('QRCAP_WIDTH', 0); |
|
183 | + define('QRCAP_WIDTH', 0); |
|
184 | 184 | |
185 | - /** |
|
185 | + /** |
|
186 | 186 | * Matrix index to get number of words from $capacity array. |
187 | 187 | */ |
188 | - define('QRCAP_WORDS', 1); |
|
188 | + define('QRCAP_WORDS', 1); |
|
189 | 189 | |
190 | - /** |
|
190 | + /** |
|
191 | 191 | * Matrix index to get remainder from $capacity array. |
192 | 192 | */ |
193 | - define('QRCAP_REMINDER', 2); |
|
193 | + define('QRCAP_REMINDER', 2); |
|
194 | 194 | |
195 | - /** |
|
195 | + /** |
|
196 | 196 | * Matrix index to get error correction level from $capacity array. |
197 | 197 | */ |
198 | - define('QRCAP_EC', 3); |
|
198 | + define('QRCAP_EC', 3); |
|
199 | 199 | |
200 | 200 | // ----------------------------------------------------- |
201 | 201 | |
@@ -204,33 +204,33 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * Number of header bits for structured mode |
206 | 206 | */ |
207 | - define('STRUCTURE_HEADER_BITS', 20); |
|
207 | + define('STRUCTURE_HEADER_BITS', 20); |
|
208 | 208 | |
209 | - /** |
|
209 | + /** |
|
210 | 210 | * Max number of symbols for structured mode |
211 | 211 | */ |
212 | - define('MAX_STRUCTURED_SYMBOLS', 16); |
|
212 | + define('MAX_STRUCTURED_SYMBOLS', 16); |
|
213 | 213 | |
214 | 214 | // ----------------------------------------------------- |
215 | 215 | |
216 | - // Masks |
|
216 | + // Masks |
|
217 | 217 | |
218 | - /** |
|
218 | + /** |
|
219 | 219 | * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) |
220 | 220 | */ |
221 | - define('N1', 3); |
|
221 | + define('N1', 3); |
|
222 | 222 | |
223 | - /** |
|
223 | + /** |
|
224 | 224 | * Down point base value for case 2 mask pattern (module block of same color) |
225 | 225 | */ |
226 | 226 | define('N2', 3); |
227 | 227 | |
228 | - /** |
|
228 | + /** |
|
229 | 229 | * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) |
230 | 230 | */ |
231 | 231 | define('N3', 40); |
232 | 232 | |
233 | - /** |
|
233 | + /** |
|
234 | 234 | * Down point base value for case 4 mask pattern (ration of dark modules in whole) |
235 | 235 | */ |
236 | 236 | define('N4', 10); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | |
265 | 265 | // for compaibility with PHP4 |
266 | 266 | if (!function_exists('str_split')) { |
267 | - /** |
|
268 | - * Convert a string to an array (needed for PHP4 compatibility) |
|
269 | - * @param string $string The input string. |
|
270 | - * @param int $split_length Maximum length of the chunk. |
|
271 | - * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
272 | - */ |
|
267 | + /** |
|
268 | + * Convert a string to an array (needed for PHP4 compatibility) |
|
269 | + * @param string $string The input string. |
|
270 | + * @param int $split_length Maximum length of the chunk. |
|
271 | + * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
272 | + */ |
|
273 | 273 | public function str_split($string, $split_length=1) { |
274 | 274 | if ((strlen($string) > $split_length) OR (!$split_length)) { |
275 | 275 | do { |
@@ -2622,7 +2622,7 @@ discard block |
||
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | /** |
2625 | - * Return block number 1 |
|
2625 | + * Return block number 1 |
|
2626 | 2626 | * @param array $spec |
2627 | 2627 | * @return int value |
2628 | 2628 | */ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries |
14 | 14 | WHERE id = ? AND id = ref_id AND owner_uid = ? |
15 | 15 | LIMIT 1"); |
16 | - $sth->execute([$id, $_SESSION['uid']]); |
|
16 | + $sth->execute([$id, $_SESSION['uid']]); |
|
17 | 17 | |
18 | 18 | if ($row = $sth->fetch()) { |
19 | 19 | $article_url = $row['link']; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | $sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
78 | 78 | ref_id = ? AND owner_uid = ? LIMIT 1"); |
79 | - $sth->execute([$ref_id, $owner_uid]); |
|
79 | + $sth->execute([$ref_id, $owner_uid]); |
|
80 | 80 | |
81 | 81 | if ($row = $sth->fetch()) { |
82 | 82 | $int_id = $row['int_id']; |
@@ -616,22 +616,22 @@ discard block |
||
616 | 616 | |
617 | 617 | public static function purge_orphans() { |
618 | 618 | |
619 | - // purge orphaned posts in main content table |
|
619 | + // purge orphaned posts in main content table |
|
620 | 620 | |
621 | - if (DB_TYPE == "mysql") |
|
622 | - $limit_qpart = "LIMIT 5000"; |
|
623 | - else |
|
624 | - $limit_qpart = ""; |
|
621 | + if (DB_TYPE == "mysql") |
|
622 | + $limit_qpart = "LIMIT 5000"; |
|
623 | + else |
|
624 | + $limit_qpart = ""; |
|
625 | 625 | |
626 | - $pdo = Db::pdo(); |
|
627 | - $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
|
626 | + $pdo = Db::pdo(); |
|
627 | + $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
|
628 | 628 | NOT EXISTS (SELECT ref_id FROM ttrss_user_entries WHERE ref_id = id) $limit_qpart"); |
629 | 629 | |
630 | - if (Debug::enabled()) { |
|
631 | - $rows = $res->rowCount(); |
|
632 | - Debug::log("Purged $rows orphaned posts."); |
|
633 | - } |
|
634 | - } |
|
630 | + if (Debug::enabled()) { |
|
631 | + $rows = $res->rowCount(); |
|
632 | + Debug::log("Purged $rows orphaned posts."); |
|
633 | + } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
637 | 637 |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
6 | 6 | const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
7 | 7 | |
8 | - private $params; |
|
8 | + private $params; |
|
9 | 9 | |
10 | - function csrf_ignore($method) { |
|
10 | + function csrf_ignore($method) { |
|
11 | 11 | $csrf_ignored = array("index", "quickaddfeed", "search"); |
12 | 12 | |
13 | 13 | return array_search($method, $csrf_ignored) !== false; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; |
102 | 102 | |
103 | 103 | $reply .= "<option value=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">". |
104 | - __('Show as feed')."</option>"; |
|
104 | + __('Show as feed')."</option>"; |
|
105 | 105 | |
106 | 106 | $reply .= "</select>"; |
107 | 107 | |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | $method_split = explode(":", $method); |
134 | 134 | |
135 | 135 | if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { |
136 | - $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
|
136 | + $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
|
137 | 137 | SET last_updated = '1970-01-01', last_update_started = '1970-01-01' |
138 | 138 | WHERE id = ?"); |
139 | - $sth->execute([$feed]); |
|
139 | + $sth->execute([$feed]); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ($method_split[0] == "MarkAllReadGR") { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | "include_children" => $include_children, |
198 | 198 | "check_first_id" => $check_first_id, |
199 | 199 | "skip_first_id_check" => $skip_first_id_check, |
200 | - "order_by" => $order_by |
|
200 | + "order_by" => $order_by |
|
201 | 201 | ); |
202 | 202 | |
203 | 203 | $qfh_ret = $this->queryFeedHeadlines($params); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $headlines_count = 0; |
237 | 237 | |
238 | - if (is_object($result)) { |
|
238 | + if (is_object($result)) { |
|
239 | 239 | while ($line = $result->fetch(PDO::FETCH_ASSOC)) { |
240 | 240 | |
241 | 241 | ++$headlines_count; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
249 | 249 | $line = $p->hook_query_headlines($line, 250, false); |
250 | 250 | } |
251 | - } |
|
251 | + } |
|
252 | 252 | |
253 | 253 | $id = $line["id"]; |
254 | 254 | |
@@ -295,53 +295,53 @@ discard block |
||
295 | 295 | |
296 | 296 | if (!$line["feed_title"]) $line["feed_title"] = ""; |
297 | 297 | |
298 | - $line["buttons_left"] = ""; |
|
299 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
|
300 | - $line["buttons_left"] .= $p->hook_article_left_button($line); |
|
301 | - } |
|
298 | + $line["buttons_left"] = ""; |
|
299 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
|
300 | + $line["buttons_left"] .= $p->hook_article_left_button($line); |
|
301 | + } |
|
302 | 302 | |
303 | - $line["buttons"] = ""; |
|
304 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { |
|
305 | - $line["buttons"] .= $p->hook_article_button($line); |
|
306 | - } |
|
303 | + $line["buttons"] = ""; |
|
304 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { |
|
305 | + $line["buttons"] .= $p->hook_article_button($line); |
|
306 | + } |
|
307 | 307 | |
308 | - $line["content"] = sanitize($line["content"], |
|
309 | - $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); |
|
308 | + $line["content"] = sanitize($line["content"], |
|
309 | + $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); |
|
310 | 310 | |
311 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { |
|
312 | - $line = $p->hook_render_article_cdm($line); |
|
313 | - } |
|
311 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { |
|
312 | + $line = $p->hook_render_article_cdm($line); |
|
313 | + } |
|
314 | 314 | |
315 | - $line['content'] = DiskCache::rewriteUrls($line['content']); |
|
315 | + $line['content'] = DiskCache::rewriteUrls($line['content']); |
|
316 | 316 | |
317 | - if ($line['note']) |
|
318 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
319 | - else |
|
320 | - $line['note'] = ""; |
|
317 | + if ($line['note']) |
|
318 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
319 | + else |
|
320 | + $line['note'] = ""; |
|
321 | 321 | |
322 | - if (!get_pref("CDM_EXPANDED")) { |
|
323 | - $line["cdm_excerpt"] = "<span class='collapse'> |
|
322 | + if (!get_pref("CDM_EXPANDED")) { |
|
323 | + $line["cdm_excerpt"] = "<span class='collapse'> |
|
324 | 324 | <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' |
325 | 325 | title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; |
326 | 326 | |
327 | - if (get_pref('SHOW_CONTENT_PREVIEW')) { |
|
328 | - $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
329 | - } |
|
330 | - } |
|
327 | + if (get_pref('SHOW_CONTENT_PREVIEW')) { |
|
328 | + $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
329 | + } |
|
330 | + } |
|
331 | 331 | |
332 | - $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], |
|
333 | - $line["content"], $line["hide_images"]); |
|
332 | + $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], |
|
333 | + $line["content"], $line["hide_images"]); |
|
334 | 334 | |
335 | - if ($line["orig_feed_id"]) { |
|
335 | + if ($line["orig_feed_id"]) { |
|
336 | 336 | |
337 | - $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
337 | + $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
338 | 338 | WHERE id = ? AND owner_uid = ?"); |
339 | - $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
|
339 | + $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
|
340 | 340 | |
341 | - if ($tmp_line = $ofgh->fetch()) { |
|
342 | - $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
343 | - } |
|
344 | - } |
|
341 | + if ($tmp_line = $ofgh->fetch()) { |
|
342 | + $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
343 | + } |
|
344 | + } |
|
345 | 345 | |
346 | 346 | $line["updated_long"] = make_local_datetime($line["updated"],true); |
347 | 347 | $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; |
364 | 364 | } |
365 | 365 | |
366 | - //setting feed headline background color, needs to change text color based on dark/light |
|
366 | + //setting feed headline background color, needs to change text color based on dark/light |
|
367 | 367 | $fav_color = $line['favicon_avg_color']; |
368 | 368 | |
369 | 369 | require_once "colors.php"; |
@@ -377,18 +377,18 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | if (isset($rgba_cache[$feed_id])) { |
380 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
381 | - } |
|
380 | + $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
381 | + } |
|
382 | 382 | |
383 | 383 | /* we don't need those */ |
384 | 384 | |
385 | - foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
|
386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
387 | - unset($line[$k]); |
|
385 | + foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
|
386 | + "uuid", "label_cache", "yyiw"] as $k) |
|
387 | + unset($line[$k]); |
|
388 | 388 | |
389 | 389 | array_push($reply['content'], $line); |
390 | 390 | } |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | 393 | if (!$headlines_count) { |
394 | 394 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $reply['headlines']['is_cat'] = (bool) $cat_view; |
571 | 571 | |
572 | 572 | $reply['headlines-info'] = ["count" => (int) $headlines_count, |
573 | - "disable_cache" => (bool) $disable_cache]; |
|
573 | + "disable_cache" => (bool) $disable_cache]; |
|
574 | 574 | |
575 | 575 | // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc |
576 | 576 | $reply['runtime-info'] = make_runtime_info(); |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | $reply_json = json_encode($reply); |
579 | 579 | |
580 | 580 | if (!$reply_json) { |
581 | - $reply_json = json_encode(["error" => ["code" => 15, |
|
582 | - "message" => json_last_error_msg()]]); |
|
583 | - } |
|
581 | + $reply_json = json_encode(["error" => ["code" => 15, |
|
582 | + "message" => json_last_error_msg()]]); |
|
583 | + } |
|
584 | 584 | |
585 | 585 | print $reply_json; |
586 | 586 | |
@@ -780,9 +780,9 @@ discard block |
||
780 | 780 | $sth->execute([$feed_id, $_SESSION['uid']]); |
781 | 781 | |
782 | 782 | if (!$sth->fetch()) { |
783 | - print "Access denied."; |
|
784 | - return; |
|
785 | - } |
|
783 | + print "Access denied."; |
|
784 | + return; |
|
785 | + } |
|
786 | 786 | |
787 | 787 | $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : ""; |
788 | 788 | $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : ""; |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | } else { |
1231 | 1231 | $icon = self::getIconFile($id); |
1232 | 1232 | |
1233 | - if ($icon && file_exists($icon)) { |
|
1233 | + if ($icon && file_exists($icon)) { |
|
1234 | 1234 | return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
1235 | 1235 | } |
1236 | 1236 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | public static function getFeedTitle($id, $cat = false) { |
1243 | - $pdo = Db::pdo(); |
|
1243 | + $pdo = Db::pdo(); |
|
1244 | 1244 | |
1245 | 1245 | if ($cat) { |
1246 | 1246 | return Feeds::getCategoryTitle($id); |
@@ -1271,10 +1271,10 @@ discard block |
||
1271 | 1271 | |
1272 | 1272 | } else if (is_numeric($id) && $id > 0) { |
1273 | 1273 | |
1274 | - $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
1275 | - $sth->execute([$id]); |
|
1274 | + $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
1275 | + $sth->execute([$id]); |
|
1276 | 1276 | |
1277 | - if ($row = $sth->fetch()) { |
|
1277 | + if ($row = $sth->fetch()) { |
|
1278 | 1278 | return $row["title"]; |
1279 | 1279 | } else { |
1280 | 1280 | return "Unknown feed ($id)"; |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | |
1294 | 1294 | if ($cat >= 0) { |
1295 | 1295 | |
1296 | - if (!$cat) $cat = null; |
|
1296 | + if (!$cat) $cat = null; |
|
1297 | 1297 | |
1298 | 1298 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
1299 | 1299 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | WHERE article_id = ref_id AND unread = true |
1334 | 1334 | AND ttrss_user_entries.owner_uid = ?"); |
1335 | 1335 | $sth->execute([$owner_uid]); |
1336 | - $row = $sth->fetch(); |
|
1336 | + $row = $sth->fetch(); |
|
1337 | 1337 | |
1338 | 1338 | return $row["unread"]; |
1339 | 1339 | } |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | return __("Labels"); |
1382 | 1382 | } else { |
1383 | 1383 | |
1384 | - $pdo = Db::pdo(); |
|
1384 | + $pdo = Db::pdo(); |
|
1385 | 1385 | |
1386 | 1386 | $sth = $pdo->prepare("SELECT title FROM ttrss_feed_categories WHERE |
1387 | 1387 | id = ?"); |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | $pdo = Db::pdo(); |
1418 | 1418 | |
1419 | 1419 | // WARNING: due to highly dynamic nature of this query its going to quote parameters |
1420 | - // right before adding them to SQL part |
|
1420 | + // right before adding them to SQL part |
|
1421 | 1421 | |
1422 | 1422 | $feed = $params["feed"]; |
1423 | 1423 | $limit = isset($params["limit"]) ? $params["limit"] : 30; |
@@ -1661,7 +1661,7 @@ discard block |
||
1661 | 1661 | $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated |
1662 | 1662 | FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
1663 | 1663 | $ssth->execute([$feed, $owner_uid]); |
1664 | - $row = $ssth->fetch(); |
|
1664 | + $row = $ssth->fetch(); |
|
1665 | 1665 | |
1666 | 1666 | $feed_title = $row["title"]; |
1667 | 1667 | $feed_site_url = $row["site_url"]; |
@@ -1899,9 +1899,9 @@ discard block |
||
1899 | 1899 | public static function getFeedCategory($feed) { |
1900 | 1900 | $pdo = Db::pdo(); |
1901 | 1901 | |
1902 | - $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
1902 | + $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
1903 | 1903 | WHERE id = ?"); |
1904 | - $sth->execute([$feed]); |
|
1904 | + $sth->execute([$feed]); |
|
1905 | 1905 | |
1906 | 1906 | if ($row = $sth->fetch()) { |
1907 | 1907 | return $row["cat_id"]; |
@@ -1911,20 +1911,20 @@ discard block |
||
1911 | 1911 | |
1912 | 1912 | } |
1913 | 1913 | |
1914 | - function color_of($name) { |
|
1915 | - $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
1916 | - "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
1917 | - "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
1914 | + function color_of($name) { |
|
1915 | + $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
1916 | + "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
1917 | + "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
1918 | 1918 | |
1919 | - $sum = 0; |
|
1919 | + $sum = 0; |
|
1920 | 1920 | |
1921 | - for ($i = 0; $i < strlen($name); $i++) { |
|
1922 | - $sum += ord($name[$i]); |
|
1923 | - } |
|
1921 | + for ($i = 0; $i < strlen($name); $i++) { |
|
1922 | + $sum += ord($name[$i]); |
|
1923 | + } |
|
1924 | 1924 | |
1925 | - $sum %= count($colormap); |
|
1925 | + $sum %= count($colormap); |
|
1926 | 1926 | |
1927 | - return $colormap[$sum]; |
|
1927 | + return $colormap[$sum]; |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | public static function get_feeds_from_html($url, $content) { |
@@ -1568,8 +1568,8 @@ |
||
1568 | 1568 | public static function remove_feed($id, $owner_uid) { |
1569 | 1569 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) { |
1570 | 1570 | if (! $p->hook_unsubscribe_feed($id, $owner_uid)) { |
1571 | - user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING); |
|
1572 | - return; |
|
1571 | + user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING); |
|
1572 | + return; |
|
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 |
@@ -2,72 +2,72 @@ |
||
2 | 2 | |
3 | 3 | class Logger { |
4 | 4 | |
5 | - /** |
|
6 | - * @var Logger |
|
7 | - */ |
|
8 | - private static $instance; |
|
5 | + /** |
|
6 | + * @var Logger |
|
7 | + */ |
|
8 | + private static $instance; |
|
9 | 9 | |
10 | - /** |
|
11 | - * @var bool|Logger_SQL|Logger_Syslog |
|
12 | - */ |
|
13 | - private $adapter; |
|
10 | + /** |
|
11 | + * @var bool|Logger_SQL|Logger_Syslog |
|
12 | + */ |
|
13 | + private $adapter; |
|
14 | 14 | |
15 | - public static $errornames = array( |
|
16 | - 1 => 'E_ERROR', |
|
17 | - 2 => 'E_WARNING', |
|
18 | - 4 => 'E_PARSE', |
|
19 | - 8 => 'E_NOTICE', |
|
20 | - 16 => 'E_CORE_ERROR', |
|
21 | - 32 => 'E_CORE_WARNING', |
|
22 | - 64 => 'E_COMPILE_ERROR', |
|
23 | - 128 => 'E_COMPILE_WARNING', |
|
24 | - 256 => 'E_USER_ERROR', |
|
25 | - 512 => 'E_USER_WARNING', |
|
26 | - 1024 => 'E_USER_NOTICE', |
|
27 | - 2048 => 'E_STRICT', |
|
28 | - 4096 => 'E_RECOVERABLE_ERROR', |
|
29 | - 8192 => 'E_DEPRECATED', |
|
30 | - 16384 => 'E_USER_DEPRECATED', |
|
31 | - 32767 => 'E_ALL'); |
|
15 | + public static $errornames = array( |
|
16 | + 1 => 'E_ERROR', |
|
17 | + 2 => 'E_WARNING', |
|
18 | + 4 => 'E_PARSE', |
|
19 | + 8 => 'E_NOTICE', |
|
20 | + 16 => 'E_CORE_ERROR', |
|
21 | + 32 => 'E_CORE_WARNING', |
|
22 | + 64 => 'E_COMPILE_ERROR', |
|
23 | + 128 => 'E_COMPILE_WARNING', |
|
24 | + 256 => 'E_USER_ERROR', |
|
25 | + 512 => 'E_USER_WARNING', |
|
26 | + 1024 => 'E_USER_NOTICE', |
|
27 | + 2048 => 'E_STRICT', |
|
28 | + 4096 => 'E_RECOVERABLE_ERROR', |
|
29 | + 8192 => 'E_DEPRECATED', |
|
30 | + 16384 => 'E_USER_DEPRECATED', |
|
31 | + 32767 => 'E_ALL'); |
|
32 | 32 | |
33 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
34 | - if ($errno === E_NOTICE) { |
|
35 | - return false; |
|
36 | - } |
|
33 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
34 | + if ($errno === E_NOTICE) { |
|
35 | + return false; |
|
36 | + } |
|
37 | 37 | |
38 | - if ($this->adapter) { |
|
39 | - return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
40 | - } |
|
38 | + if ($this->adapter) { |
|
39 | + return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
40 | + } |
|
41 | 41 | |
42 | - return false; |
|
43 | - } |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | - public function log($string, $context = "") { |
|
46 | - if ($this->adapter) { |
|
47 | - return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
48 | - } |
|
45 | + public function log($string, $context = "") { |
|
46 | + if ($this->adapter) { |
|
47 | + return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
48 | + } |
|
49 | 49 | |
50 | - return false; |
|
51 | - } |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | |
53 | - public function __construct() { |
|
54 | - switch (LOG_DESTINATION) { |
|
55 | - case "sql": |
|
56 | - $this->adapter = new Logger_SQL(); |
|
57 | - break; |
|
58 | - case "syslog": |
|
59 | - $this->adapter = new Logger_Syslog(); |
|
60 | - break; |
|
61 | - default: |
|
62 | - $this->adapter = false; |
|
63 | - } |
|
64 | - } |
|
53 | + public function __construct() { |
|
54 | + switch (LOG_DESTINATION) { |
|
55 | + case "sql": |
|
56 | + $this->adapter = new Logger_SQL(); |
|
57 | + break; |
|
58 | + case "syslog": |
|
59 | + $this->adapter = new Logger_Syslog(); |
|
60 | + break; |
|
61 | + default: |
|
62 | + $this->adapter = false; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - public static function get(): Logger { |
|
67 | - if (self::$instance == null) { |
|
68 | - self::$instance = new self(); |
|
69 | - } |
|
70 | - return self::$instance; |
|
71 | - } |
|
66 | + public static function get(): Logger { |
|
67 | + if (self::$instance == null) { |
|
68 | + self::$instance = new self(); |
|
69 | + } |
|
70 | + return self::$instance; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Dlg extends Handler_Protected { |
3 | 3 | private $param; |
4 | - private $params; |
|
4 | + private $params; |
|
5 | 5 | |
6 | - function before($method) { |
|
6 | + function before($method) { |
|
7 | 7 | if (parent::before($method)) { |
8 | 8 | header("Content-Type: text/html"); # required for iframe |
9 | 9 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $tags[$line["tag_name"]] = $line["count"]; |
109 | 109 | } |
110 | 110 | |
111 | - if(count($tags) == 0 ){ return; } |
|
111 | + if(count($tags) == 0 ){ return; } |
|
112 | 112 | |
113 | 113 | ksort($tags); |
114 | 114 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | public function defaultPasswordWarning() { |
195 | 195 | |
196 | - print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
196 | + print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
197 | 197 | |
198 | 198 | print "<footer class='text-center'>"; |
199 | 199 | print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |
@@ -1,355 +1,355 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (file_exists("lib/floIcon.php")) { |
4 | - require_once "lib/floIcon.php"; |
|
4 | + require_once "lib/floIcon.php"; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function _resolve_htmlcolor($color) { |
8 | - $htmlcolors = array( |
|
9 | - "aliceblue" => "#f0f8ff", |
|
10 | - "antiquewhite" => "#faebd7", |
|
11 | - "aqua" => "#00ffff", |
|
12 | - "aquamarine" => "#7fffd4", |
|
13 | - "azure" => "#f0ffff", |
|
14 | - "beige" => "#f5f5dc", |
|
15 | - "bisque" => "#ffe4c4", |
|
16 | - "black" => "#000000", |
|
17 | - "blanchedalmond" => "#ffebcd", |
|
18 | - "blue" => "#0000ff", |
|
19 | - "blueviolet" => "#8a2be2", |
|
20 | - "brown" => "#a52a2a", |
|
21 | - "burlywood" => "#deb887", |
|
22 | - "cadetblue" => "#5f9ea0", |
|
23 | - "chartreuse" => "#7fff00", |
|
24 | - "chocolate" => "#d2691e", |
|
25 | - "coral" => "#ff7f50", |
|
26 | - "cornflowerblue" => "#6495ed", |
|
27 | - "cornsilk" => "#fff8dc", |
|
28 | - "crimson" => "#dc143c", |
|
29 | - "cyan" => "#00ffff", |
|
30 | - "darkblue" => "#00008b", |
|
31 | - "darkcyan" => "#008b8b", |
|
32 | - "darkgoldenrod" => "#b8860b", |
|
33 | - "darkgray" => "#a9a9a9", |
|
34 | - "darkgrey" => "#a9a9a9", |
|
35 | - "darkgreen" => "#006400", |
|
36 | - "darkkhaki" => "#bdb76b", |
|
37 | - "darkmagenta" => "#8b008b", |
|
38 | - "darkolivegreen" => "#556b2f", |
|
39 | - "darkorange" => "#ff8c00", |
|
40 | - "darkorchid" => "#9932cc", |
|
41 | - "darkred" => "#8b0000", |
|
42 | - "darksalmon" => "#e9967a", |
|
43 | - "darkseagreen" => "#8fbc8f", |
|
44 | - "darkslateblue" => "#483d8b", |
|
45 | - "darkslategray" => "#2f4f4f", |
|
46 | - "darkslategrey" => "#2f4f4f", |
|
47 | - "darkturquoise" => "#00ced1", |
|
48 | - "darkviolet" => "#9400d3", |
|
49 | - "deeppink" => "#ff1493", |
|
50 | - "deepskyblue" => "#00bfff", |
|
51 | - "dimgray" => "#696969", |
|
52 | - "dimgrey" => "#696969", |
|
53 | - "dodgerblue" => "#1e90ff", |
|
54 | - "firebrick" => "#b22222", |
|
55 | - "floralwhite" => "#fffaf0", |
|
56 | - "forestgreen" => "#228b22", |
|
57 | - "fuchsia" => "#ff00ff", |
|
58 | - "gainsboro" => "#dcdcdc", |
|
59 | - "ghostwhite" => "#f8f8ff", |
|
60 | - "gold" => "#ffd700", |
|
61 | - "goldenrod" => "#daa520", |
|
62 | - "gray" => "#808080", |
|
63 | - "grey" => "#808080", |
|
64 | - "green" => "#008000", |
|
65 | - "greenyellow" => "#adff2f", |
|
66 | - "honeydew" => "#f0fff0", |
|
67 | - "hotpink" => "#ff69b4", |
|
68 | - "indianred " => "#cd5c5c", |
|
69 | - "indigo " => "#4b0082", |
|
70 | - "ivory" => "#fffff0", |
|
71 | - "khaki" => "#f0e68c", |
|
72 | - "lavender" => "#e6e6fa", |
|
73 | - "lavenderblush" => "#fff0f5", |
|
74 | - "lawngreen" => "#7cfc00", |
|
75 | - "lemonchiffon" => "#fffacd", |
|
76 | - "lightblue" => "#add8e6", |
|
77 | - "lightcoral" => "#f08080", |
|
78 | - "lightcyan" => "#e0ffff", |
|
79 | - "lightgoldenrodyellow" => "#fafad2", |
|
80 | - "lightgray" => "#d3d3d3", |
|
81 | - "lightgrey" => "#d3d3d3", |
|
82 | - "lightgreen" => "#90ee90", |
|
83 | - "lightpink" => "#ffb6c1", |
|
84 | - "lightsalmon" => "#ffa07a", |
|
85 | - "lightseagreen" => "#20b2aa", |
|
86 | - "lightskyblue" => "#87cefa", |
|
87 | - "lightslategray" => "#778899", |
|
88 | - "lightslategrey" => "#778899", |
|
89 | - "lightsteelblue" => "#b0c4de", |
|
90 | - "lightyellow" => "#ffffe0", |
|
91 | - "lime" => "#00ff00", |
|
92 | - "limegreen" => "#32cd32", |
|
93 | - "linen" => "#faf0e6", |
|
94 | - "magenta" => "#ff00ff", |
|
95 | - "maroon" => "#800000", |
|
96 | - "mediumaquamarine" => "#66cdaa", |
|
97 | - "mediumblue" => "#0000cd", |
|
98 | - "mediumorchid" => "#ba55d3", |
|
99 | - "mediumpurple" => "#9370db", |
|
100 | - "mediumseagreen" => "#3cb371", |
|
101 | - "mediumslateblue" => "#7b68ee", |
|
102 | - "mediumspringgreen" => "#00fa9a", |
|
103 | - "mediumturquoise" => "#48d1cc", |
|
104 | - "mediumvioletred" => "#c71585", |
|
105 | - "midnightblue" => "#191970", |
|
106 | - "mintcream" => "#f5fffa", |
|
107 | - "mistyrose" => "#ffe4e1", |
|
108 | - "moccasin" => "#ffe4b5", |
|
109 | - "navajowhite" => "#ffdead", |
|
110 | - "navy" => "#000080", |
|
111 | - "oldlace" => "#fdf5e6", |
|
112 | - "olive" => "#808000", |
|
113 | - "olivedrab" => "#6b8e23", |
|
114 | - "orange" => "#ffa500", |
|
115 | - "orangered" => "#ff4500", |
|
116 | - "orchid" => "#da70d6", |
|
117 | - "palegoldenrod" => "#eee8aa", |
|
118 | - "palegreen" => "#98fb98", |
|
119 | - "paleturquoise" => "#afeeee", |
|
120 | - "palevioletred" => "#db7093", |
|
121 | - "papayawhip" => "#ffefd5", |
|
122 | - "peachpuff" => "#ffdab9", |
|
123 | - "peru" => "#cd853f", |
|
124 | - "pink" => "#ffc0cb", |
|
125 | - "plum" => "#dda0dd", |
|
126 | - "powderblue" => "#b0e0e6", |
|
127 | - "purple" => "#800080", |
|
128 | - "red" => "#ff0000", |
|
129 | - "rosybrown" => "#bc8f8f", |
|
130 | - "royalblue" => "#4169e1", |
|
131 | - "saddlebrown" => "#8b4513", |
|
132 | - "salmon" => "#fa8072", |
|
133 | - "sandybrown" => "#f4a460", |
|
134 | - "seagreen" => "#2e8b57", |
|
135 | - "seashell" => "#fff5ee", |
|
136 | - "sienna" => "#a0522d", |
|
137 | - "silver" => "#c0c0c0", |
|
138 | - "skyblue" => "#87ceeb", |
|
139 | - "slateblue" => "#6a5acd", |
|
140 | - "slategray" => "#708090", |
|
141 | - "slategrey" => "#708090", |
|
142 | - "snow" => "#fffafa", |
|
143 | - "springgreen" => "#00ff7f", |
|
144 | - "steelblue" => "#4682b4", |
|
145 | - "tan" => "#d2b48c", |
|
146 | - "teal" => "#008080", |
|
147 | - "thistle" => "#d8bfd8", |
|
148 | - "tomato" => "#ff6347", |
|
149 | - "turquoise" => "#40e0d0", |
|
150 | - "violet" => "#ee82ee", |
|
151 | - "wheat" => "#f5deb3", |
|
152 | - "white" => "#ffffff", |
|
153 | - "whitesmoke" => "#f5f5f5", |
|
154 | - "yellow" => "#ffff00", |
|
155 | - "yellowgreen" => "#9acd32" |
|
156 | - ); |
|
157 | - |
|
158 | - $color = strtolower($color); |
|
159 | - |
|
160 | - if (isset($htmlcolors[$color])) |
|
161 | - return $htmlcolors[$color]; |
|
162 | - else |
|
163 | - return $color; |
|
8 | + $htmlcolors = array( |
|
9 | + "aliceblue" => "#f0f8ff", |
|
10 | + "antiquewhite" => "#faebd7", |
|
11 | + "aqua" => "#00ffff", |
|
12 | + "aquamarine" => "#7fffd4", |
|
13 | + "azure" => "#f0ffff", |
|
14 | + "beige" => "#f5f5dc", |
|
15 | + "bisque" => "#ffe4c4", |
|
16 | + "black" => "#000000", |
|
17 | + "blanchedalmond" => "#ffebcd", |
|
18 | + "blue" => "#0000ff", |
|
19 | + "blueviolet" => "#8a2be2", |
|
20 | + "brown" => "#a52a2a", |
|
21 | + "burlywood" => "#deb887", |
|
22 | + "cadetblue" => "#5f9ea0", |
|
23 | + "chartreuse" => "#7fff00", |
|
24 | + "chocolate" => "#d2691e", |
|
25 | + "coral" => "#ff7f50", |
|
26 | + "cornflowerblue" => "#6495ed", |
|
27 | + "cornsilk" => "#fff8dc", |
|
28 | + "crimson" => "#dc143c", |
|
29 | + "cyan" => "#00ffff", |
|
30 | + "darkblue" => "#00008b", |
|
31 | + "darkcyan" => "#008b8b", |
|
32 | + "darkgoldenrod" => "#b8860b", |
|
33 | + "darkgray" => "#a9a9a9", |
|
34 | + "darkgrey" => "#a9a9a9", |
|
35 | + "darkgreen" => "#006400", |
|
36 | + "darkkhaki" => "#bdb76b", |
|
37 | + "darkmagenta" => "#8b008b", |
|
38 | + "darkolivegreen" => "#556b2f", |
|
39 | + "darkorange" => "#ff8c00", |
|
40 | + "darkorchid" => "#9932cc", |
|
41 | + "darkred" => "#8b0000", |
|
42 | + "darksalmon" => "#e9967a", |
|
43 | + "darkseagreen" => "#8fbc8f", |
|
44 | + "darkslateblue" => "#483d8b", |
|
45 | + "darkslategray" => "#2f4f4f", |
|
46 | + "darkslategrey" => "#2f4f4f", |
|
47 | + "darkturquoise" => "#00ced1", |
|
48 | + "darkviolet" => "#9400d3", |
|
49 | + "deeppink" => "#ff1493", |
|
50 | + "deepskyblue" => "#00bfff", |
|
51 | + "dimgray" => "#696969", |
|
52 | + "dimgrey" => "#696969", |
|
53 | + "dodgerblue" => "#1e90ff", |
|
54 | + "firebrick" => "#b22222", |
|
55 | + "floralwhite" => "#fffaf0", |
|
56 | + "forestgreen" => "#228b22", |
|
57 | + "fuchsia" => "#ff00ff", |
|
58 | + "gainsboro" => "#dcdcdc", |
|
59 | + "ghostwhite" => "#f8f8ff", |
|
60 | + "gold" => "#ffd700", |
|
61 | + "goldenrod" => "#daa520", |
|
62 | + "gray" => "#808080", |
|
63 | + "grey" => "#808080", |
|
64 | + "green" => "#008000", |
|
65 | + "greenyellow" => "#adff2f", |
|
66 | + "honeydew" => "#f0fff0", |
|
67 | + "hotpink" => "#ff69b4", |
|
68 | + "indianred " => "#cd5c5c", |
|
69 | + "indigo " => "#4b0082", |
|
70 | + "ivory" => "#fffff0", |
|
71 | + "khaki" => "#f0e68c", |
|
72 | + "lavender" => "#e6e6fa", |
|
73 | + "lavenderblush" => "#fff0f5", |
|
74 | + "lawngreen" => "#7cfc00", |
|
75 | + "lemonchiffon" => "#fffacd", |
|
76 | + "lightblue" => "#add8e6", |
|
77 | + "lightcoral" => "#f08080", |
|
78 | + "lightcyan" => "#e0ffff", |
|
79 | + "lightgoldenrodyellow" => "#fafad2", |
|
80 | + "lightgray" => "#d3d3d3", |
|
81 | + "lightgrey" => "#d3d3d3", |
|
82 | + "lightgreen" => "#90ee90", |
|
83 | + "lightpink" => "#ffb6c1", |
|
84 | + "lightsalmon" => "#ffa07a", |
|
85 | + "lightseagreen" => "#20b2aa", |
|
86 | + "lightskyblue" => "#87cefa", |
|
87 | + "lightslategray" => "#778899", |
|
88 | + "lightslategrey" => "#778899", |
|
89 | + "lightsteelblue" => "#b0c4de", |
|
90 | + "lightyellow" => "#ffffe0", |
|
91 | + "lime" => "#00ff00", |
|
92 | + "limegreen" => "#32cd32", |
|
93 | + "linen" => "#faf0e6", |
|
94 | + "magenta" => "#ff00ff", |
|
95 | + "maroon" => "#800000", |
|
96 | + "mediumaquamarine" => "#66cdaa", |
|
97 | + "mediumblue" => "#0000cd", |
|
98 | + "mediumorchid" => "#ba55d3", |
|
99 | + "mediumpurple" => "#9370db", |
|
100 | + "mediumseagreen" => "#3cb371", |
|
101 | + "mediumslateblue" => "#7b68ee", |
|
102 | + "mediumspringgreen" => "#00fa9a", |
|
103 | + "mediumturquoise" => "#48d1cc", |
|
104 | + "mediumvioletred" => "#c71585", |
|
105 | + "midnightblue" => "#191970", |
|
106 | + "mintcream" => "#f5fffa", |
|
107 | + "mistyrose" => "#ffe4e1", |
|
108 | + "moccasin" => "#ffe4b5", |
|
109 | + "navajowhite" => "#ffdead", |
|
110 | + "navy" => "#000080", |
|
111 | + "oldlace" => "#fdf5e6", |
|
112 | + "olive" => "#808000", |
|
113 | + "olivedrab" => "#6b8e23", |
|
114 | + "orange" => "#ffa500", |
|
115 | + "orangered" => "#ff4500", |
|
116 | + "orchid" => "#da70d6", |
|
117 | + "palegoldenrod" => "#eee8aa", |
|
118 | + "palegreen" => "#98fb98", |
|
119 | + "paleturquoise" => "#afeeee", |
|
120 | + "palevioletred" => "#db7093", |
|
121 | + "papayawhip" => "#ffefd5", |
|
122 | + "peachpuff" => "#ffdab9", |
|
123 | + "peru" => "#cd853f", |
|
124 | + "pink" => "#ffc0cb", |
|
125 | + "plum" => "#dda0dd", |
|
126 | + "powderblue" => "#b0e0e6", |
|
127 | + "purple" => "#800080", |
|
128 | + "red" => "#ff0000", |
|
129 | + "rosybrown" => "#bc8f8f", |
|
130 | + "royalblue" => "#4169e1", |
|
131 | + "saddlebrown" => "#8b4513", |
|
132 | + "salmon" => "#fa8072", |
|
133 | + "sandybrown" => "#f4a460", |
|
134 | + "seagreen" => "#2e8b57", |
|
135 | + "seashell" => "#fff5ee", |
|
136 | + "sienna" => "#a0522d", |
|
137 | + "silver" => "#c0c0c0", |
|
138 | + "skyblue" => "#87ceeb", |
|
139 | + "slateblue" => "#6a5acd", |
|
140 | + "slategray" => "#708090", |
|
141 | + "slategrey" => "#708090", |
|
142 | + "snow" => "#fffafa", |
|
143 | + "springgreen" => "#00ff7f", |
|
144 | + "steelblue" => "#4682b4", |
|
145 | + "tan" => "#d2b48c", |
|
146 | + "teal" => "#008080", |
|
147 | + "thistle" => "#d8bfd8", |
|
148 | + "tomato" => "#ff6347", |
|
149 | + "turquoise" => "#40e0d0", |
|
150 | + "violet" => "#ee82ee", |
|
151 | + "wheat" => "#f5deb3", |
|
152 | + "white" => "#ffffff", |
|
153 | + "whitesmoke" => "#f5f5f5", |
|
154 | + "yellow" => "#ffff00", |
|
155 | + "yellowgreen" => "#9acd32" |
|
156 | + ); |
|
157 | + |
|
158 | + $color = strtolower($color); |
|
159 | + |
|
160 | + if (isset($htmlcolors[$color])) |
|
161 | + return $htmlcolors[$color]; |
|
162 | + else |
|
163 | + return $color; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | ### RGB >> HSL |
167 | 167 | function _color_rgb2hsl($rgb) { |
168 | - $r = $rgb[0]; $g = $rgb[1]; $b = $rgb[2]; |
|
169 | - $min = min($r, min($g, $b)); $max = max($r, max($g, $b)); |
|
170 | - $delta = $max - $min; $l = ($min + $max) / 2; $s = 0; |
|
171 | - if ($l > 0 && $l < 1) { |
|
172 | - $s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l)); |
|
173 | - } |
|
174 | - $h = 0; |
|
175 | - if ($delta > 0) { |
|
176 | - if ($max == $r && $max != $g) $h += ($g - $b) / $delta; |
|
177 | - if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta); |
|
178 | - if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta); |
|
179 | - $h /= 6; |
|
180 | - } return array($h, $s, $l); |
|
168 | + $r = $rgb[0]; $g = $rgb[1]; $b = $rgb[2]; |
|
169 | + $min = min($r, min($g, $b)); $max = max($r, max($g, $b)); |
|
170 | + $delta = $max - $min; $l = ($min + $max) / 2; $s = 0; |
|
171 | + if ($l > 0 && $l < 1) { |
|
172 | + $s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l)); |
|
173 | + } |
|
174 | + $h = 0; |
|
175 | + if ($delta > 0) { |
|
176 | + if ($max == $r && $max != $g) $h += ($g - $b) / $delta; |
|
177 | + if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta); |
|
178 | + if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta); |
|
179 | + $h /= 6; |
|
180 | + } return array($h, $s, $l); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | ### HSL >> RGB |
184 | 184 | function _color_hsl2rgb($hsl) { |
185 | - $h = $hsl[0]; $s = $hsl[1]; $l = $hsl[2]; |
|
186 | - $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s; |
|
187 | - $m1 = $l * 2 - $m2; |
|
188 | - return array(_color_hue2rgb($m1, $m2, $h + 0.33333), |
|
189 | - _color_hue2rgb($m1, $m2, $h), |
|
190 | - _color_hue2rgb($m1, $m2, $h - 0.33333)); |
|
185 | + $h = $hsl[0]; $s = $hsl[1]; $l = $hsl[2]; |
|
186 | + $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s; |
|
187 | + $m1 = $l * 2 - $m2; |
|
188 | + return array(_color_hue2rgb($m1, $m2, $h + 0.33333), |
|
189 | + _color_hue2rgb($m1, $m2, $h), |
|
190 | + _color_hue2rgb($m1, $m2, $h - 0.33333)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | ### Helper function for _color_hsl2rgb(). |
194 | 194 | function _color_hue2rgb($m1, $m2, $h) { |
195 | - $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h); |
|
196 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
197 | - if ($h * 2 < 1) return $m2; |
|
198 | - if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6; |
|
199 | - return $m1; |
|
195 | + $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h); |
|
196 | + if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
197 | + if ($h * 2 < 1) return $m2; |
|
198 | + if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6; |
|
199 | + return $m1; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | ### Convert a hex color into an RGB triplet. |
203 | 203 | function _color_unpack($hex, $normalize = false) { |
204 | 204 | |
205 | - if (strpos($hex, '#') !== 0) |
|
206 | - $hex = _resolve_htmlcolor($hex); |
|
207 | - else |
|
208 | - $hex = substr($hex, 1); |
|
209 | - |
|
210 | - if (strlen($hex) == 4) { |
|
211 | - $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3]; |
|
212 | - } |
|
213 | - $c = hexdec($hex); |
|
214 | - for ($i = 16; $i >= 0; $i -= 8) { |
|
215 | - $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1); |
|
216 | - } return $out; |
|
205 | + if (strpos($hex, '#') !== 0) |
|
206 | + $hex = _resolve_htmlcolor($hex); |
|
207 | + else |
|
208 | + $hex = substr($hex, 1); |
|
209 | + |
|
210 | + if (strlen($hex) == 4) { |
|
211 | + $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3]; |
|
212 | + } |
|
213 | + $c = hexdec($hex); |
|
214 | + for ($i = 16; $i >= 0; $i -= 8) { |
|
215 | + $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1); |
|
216 | + } return $out; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | ### Convert an RGB triplet to a hex color. |
220 | 220 | function _color_pack($rgb, $normalize = false) { |
221 | - foreach ($rgb as $k => $v) { |
|
222 | - $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8)); |
|
223 | - }return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT); |
|
221 | + foreach ($rgb as $k => $v) { |
|
222 | + $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8)); |
|
223 | + }return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | function rgb2hsl($arr) { |
227 | - $r = $arr[0]; |
|
228 | - $g = $arr[1]; |
|
229 | - $b = $arr[2]; |
|
227 | + $r = $arr[0]; |
|
228 | + $g = $arr[1]; |
|
229 | + $b = $arr[2]; |
|
230 | 230 | |
231 | - $var_R = ($r / 255); |
|
232 | - $var_G = ($g / 255); |
|
233 | - $var_B = ($b / 255); |
|
231 | + $var_R = ($r / 255); |
|
232 | + $var_G = ($g / 255); |
|
233 | + $var_B = ($b / 255); |
|
234 | 234 | |
235 | - $var_Min = min($var_R, $var_G, $var_B); |
|
236 | - $var_Max = max($var_R, $var_G, $var_B); |
|
237 | - $del_Max = $var_Max - $var_Min; |
|
235 | + $var_Min = min($var_R, $var_G, $var_B); |
|
236 | + $var_Max = max($var_R, $var_G, $var_B); |
|
237 | + $del_Max = $var_Max - $var_Min; |
|
238 | 238 | |
239 | - $v = $var_Max; |
|
239 | + $v = $var_Max; |
|
240 | 240 | |
241 | - if ($del_Max == 0) { |
|
242 | - $h = 0; |
|
243 | - $s = 0; |
|
244 | - } else { |
|
245 | - $s = $del_Max / $var_Max; |
|
241 | + if ($del_Max == 0) { |
|
242 | + $h = 0; |
|
243 | + $s = 0; |
|
244 | + } else { |
|
245 | + $s = $del_Max / $var_Max; |
|
246 | 246 | |
247 | - $del_R = ((($var_Max - $var_R ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
248 | - $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
249 | - $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
247 | + $del_R = ((($var_Max - $var_R ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
248 | + $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
249 | + $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max; |
|
250 | 250 | |
251 | - if ($var_R == $var_Max) $h = $del_B - $del_G; |
|
252 | - else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B; |
|
253 | - else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R; |
|
251 | + if ($var_R == $var_Max) $h = $del_B - $del_G; |
|
252 | + else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B; |
|
253 | + else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R; |
|
254 | 254 | |
255 | - if ($h < 0) $h++; |
|
256 | - if ($h > 1) $h--; |
|
257 | - } |
|
255 | + if ($h < 0) $h++; |
|
256 | + if ($h > 1) $h--; |
|
257 | + } |
|
258 | 258 | |
259 | - return array($h, $s, $v); |
|
259 | + return array($h, $s, $v); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | function hsl2rgb($arr) { |
263 | - $h = $arr[0]; |
|
264 | - $s = $arr[1]; |
|
265 | - $v = $arr[2]; |
|
266 | - |
|
267 | - if($s == 0) { |
|
268 | - $r = $g = $B = $v * 255; |
|
269 | - } else { |
|
270 | - $var_H = $h * 6; |
|
271 | - $var_i = floor($var_H ); |
|
272 | - $var_1 = $v * (1 - $s ); |
|
273 | - $var_2 = $v * (1 - $s * ($var_H - $var_i ) ); |
|
274 | - $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i ) ) ); |
|
275 | - |
|
276 | - if ($var_i == 0) { $var_R = $v ; $var_G = $var_3 ; $var_B = $var_1 ; } |
|
277 | - else if ($var_i == 1) { $var_R = $var_2 ; $var_G = $v ; $var_B = $var_1 ; } |
|
278 | - else if ($var_i == 2) { $var_R = $var_1 ; $var_G = $v ; $var_B = $var_3 ; } |
|
279 | - else if ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2 ; $var_B = $v ; } |
|
280 | - else if ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1 ; $var_B = $v ; } |
|
281 | - else { $var_R = $v ; $var_G = $var_1 ; $var_B = $var_2 ; } |
|
282 | - |
|
283 | - $r = $var_R * 255; |
|
284 | - $g = $var_G * 255; |
|
285 | - $B = $var_B * 255; |
|
286 | - } |
|
287 | - return array($r, $g, $B); |
|
263 | + $h = $arr[0]; |
|
264 | + $s = $arr[1]; |
|
265 | + $v = $arr[2]; |
|
266 | + |
|
267 | + if($s == 0) { |
|
268 | + $r = $g = $B = $v * 255; |
|
269 | + } else { |
|
270 | + $var_H = $h * 6; |
|
271 | + $var_i = floor($var_H ); |
|
272 | + $var_1 = $v * (1 - $s ); |
|
273 | + $var_2 = $v * (1 - $s * ($var_H - $var_i ) ); |
|
274 | + $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i ) ) ); |
|
275 | + |
|
276 | + if ($var_i == 0) { $var_R = $v ; $var_G = $var_3 ; $var_B = $var_1 ; } |
|
277 | + else if ($var_i == 1) { $var_R = $var_2 ; $var_G = $v ; $var_B = $var_1 ; } |
|
278 | + else if ($var_i == 2) { $var_R = $var_1 ; $var_G = $v ; $var_B = $var_3 ; } |
|
279 | + else if ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2 ; $var_B = $v ; } |
|
280 | + else if ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1 ; $var_B = $v ; } |
|
281 | + else { $var_R = $v ; $var_G = $var_1 ; $var_B = $var_2 ; } |
|
282 | + |
|
283 | + $r = $var_R * 255; |
|
284 | + $g = $var_G * 255; |
|
285 | + $B = $var_B * 255; |
|
286 | + } |
|
287 | + return array($r, $g, $B); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | function colorPalette($imageFile, $numColors, $granularity = 5) { |
291 | - $granularity = max(1, abs((int)$granularity)); |
|
292 | - $colors = array(); |
|
293 | - |
|
294 | - $size = @getimagesize($imageFile); |
|
295 | - |
|
296 | - // to enable .ico support place floIcon.php into lib/ |
|
297 | - if (strtolower($size['mime']) == 'image/vnd.microsoft.icon') { |
|
298 | - |
|
299 | - if (class_exists("floIcon")) { |
|
300 | - |
|
301 | - $ico = new floIcon(); |
|
302 | - @$ico->readICO($imageFile); |
|
303 | - |
|
304 | - if(count($ico->images)==0) |
|
305 | - return false; |
|
306 | - else |
|
307 | - $img = @$ico->images[count($ico->images)-1]->getImageResource(); |
|
308 | - |
|
309 | - } else { |
|
310 | - return false; |
|
311 | - } |
|
312 | - |
|
313 | - } else if ($size[0] > 0 && $size[1] > 0) { |
|
314 | - $img = @imagecreatefromstring(file_get_contents($imageFile)); |
|
315 | - } |
|
316 | - |
|
317 | - if (!$img) return false; |
|
318 | - |
|
319 | - for($x = 0; $x < $size[0]; $x += $granularity) { |
|
320 | - for($y = 0; $y < $size[1]; $y += $granularity) { |
|
321 | - $thisColor = imagecolorat($img, $x, $y); |
|
322 | - $rgb = imagecolorsforindex($img, $thisColor); |
|
323 | - $red = round(round(($rgb['red'] / 0x33)) * 0x33); |
|
324 | - $green = round(round(($rgb['green'] / 0x33)) * 0x33); |
|
325 | - $blue = round(round(($rgb['blue'] / 0x33)) * 0x33); |
|
326 | - $thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue); |
|
327 | - if(array_key_exists($thisRGB, $colors)) { |
|
328 | - $colors[$thisRGB]++; |
|
329 | - } else{ |
|
330 | - $colors[$thisRGB] = 1; |
|
331 | - } |
|
332 | - } |
|
333 | - } |
|
334 | - |
|
335 | - arsort($colors); |
|
336 | - return array_slice(array_keys($colors), 0, $numColors); |
|
291 | + $granularity = max(1, abs((int)$granularity)); |
|
292 | + $colors = array(); |
|
293 | + |
|
294 | + $size = @getimagesize($imageFile); |
|
295 | + |
|
296 | + // to enable .ico support place floIcon.php into lib/ |
|
297 | + if (strtolower($size['mime']) == 'image/vnd.microsoft.icon') { |
|
298 | + |
|
299 | + if (class_exists("floIcon")) { |
|
300 | + |
|
301 | + $ico = new floIcon(); |
|
302 | + @$ico->readICO($imageFile); |
|
303 | + |
|
304 | + if(count($ico->images)==0) |
|
305 | + return false; |
|
306 | + else |
|
307 | + $img = @$ico->images[count($ico->images)-1]->getImageResource(); |
|
308 | + |
|
309 | + } else { |
|
310 | + return false; |
|
311 | + } |
|
312 | + |
|
313 | + } else if ($size[0] > 0 && $size[1] > 0) { |
|
314 | + $img = @imagecreatefromstring(file_get_contents($imageFile)); |
|
315 | + } |
|
316 | + |
|
317 | + if (!$img) return false; |
|
318 | + |
|
319 | + for($x = 0; $x < $size[0]; $x += $granularity) { |
|
320 | + for($y = 0; $y < $size[1]; $y += $granularity) { |
|
321 | + $thisColor = imagecolorat($img, $x, $y); |
|
322 | + $rgb = imagecolorsforindex($img, $thisColor); |
|
323 | + $red = round(round(($rgb['red'] / 0x33)) * 0x33); |
|
324 | + $green = round(round(($rgb['green'] / 0x33)) * 0x33); |
|
325 | + $blue = round(round(($rgb['blue'] / 0x33)) * 0x33); |
|
326 | + $thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue); |
|
327 | + if(array_key_exists($thisRGB, $colors)) { |
|
328 | + $colors[$thisRGB]++; |
|
329 | + } else{ |
|
330 | + $colors[$thisRGB] = 1; |
|
331 | + } |
|
332 | + } |
|
333 | + } |
|
334 | + |
|
335 | + arsort($colors); |
|
336 | + return array_slice(array_keys($colors), 0, $numColors); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | function calculate_avg_color($iconFile) { |
340 | - $palette = colorPalette($iconFile, 4, 4); |
|
340 | + $palette = colorPalette($iconFile, 4, 4); |
|
341 | 341 | |
342 | - if (is_array($palette)) { |
|
343 | - foreach ($palette as $p) { |
|
344 | - $hsl = rgb2hsl(_color_unpack("#$p")); |
|
342 | + if (is_array($palette)) { |
|
343 | + foreach ($palette as $p) { |
|
344 | + $hsl = rgb2hsl(_color_unpack("#$p")); |
|
345 | 345 | |
346 | - if ($hsl[1] > 0.25 && $hsl[2] > 0.25 && |
|
347 | - !($hsl[0] >= 0 && $hsl[0] < 0.01 && $hsl[1] < 0.01) && |
|
348 | - !($hsl[0] >= 0 && $hsl[0] < 0.01 && $hsl[2] > 0.99)) { |
|
346 | + if ($hsl[1] > 0.25 && $hsl[2] > 0.25 && |
|
347 | + !($hsl[0] >= 0 && $hsl[0] < 0.01 && $hsl[1] < 0.01) && |
|
348 | + !($hsl[0] >= 0 && $hsl[0] < 0.01 && $hsl[2] > 0.99)) { |
|
349 | 349 | |
350 | - return _color_pack(hsl2rgb($hsl)); |
|
351 | - } |
|
352 | - } |
|
353 | - } |
|
354 | - return ''; |
|
350 | + return _color_pack(hsl2rgb($hsl)); |
|
351 | + } |
|
352 | + } |
|
353 | + } |
|
354 | + return ''; |
|
355 | 355 | } |
@@ -3,9 +3,9 @@ |
||
3 | 3 | require_once "db.php"; |
4 | 4 | |
5 | 5 | function get_pref($pref_name, $user_id = false, $die_on_error = false) { |
6 | - return Db_Prefs::get()->read($pref_name, $user_id, $die_on_error); |
|
6 | + return Db_Prefs::get()->read($pref_name, $user_id, $die_on_error); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | function set_pref($pref_name, $value, $user_id = false, $strip_tags = true) { |
10 | - return Db_Prefs::get()->write($pref_name, $value, $user_id, $strip_tags); |
|
10 | + return Db_Prefs::get()->write($pref_name, $value, $user_id, $strip_tags); |
|
11 | 11 | } |