Passed
Push — master ( a3c0d0...678db7 )
by Cody
06:27 queued 03:12
created
plugins/hotkeys_noscroll/init.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
 class Hotkeys_Noscroll extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"n/p hotkeys move between articles without scrolling",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "n/p hotkeys move between articles without scrolling",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
11
+    public function init($host) {
12
+        $this->host = $host;
13 13
 
14
-		$host->add_hook($host::HOOK_HOTKEY_MAP, $this);
15
-	}
14
+        $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
15
+    }
16 16
 
17
-	public function hook_hotkey_map($hotkeys) {
17
+    public function hook_hotkey_map($hotkeys) {
18 18
 
19
-		$hotkeys["(40)|Down"] = "next_article_noscroll";
20
-		$hotkeys["(38)|Up"] = "prev_article_noscroll";
21
-		$hotkeys["n"] = "next_article_noscroll";
22
-		$hotkeys["p"] = "prev_article_noscroll";
19
+        $hotkeys["(40)|Down"] = "next_article_noscroll";
20
+        $hotkeys["(38)|Up"] = "prev_article_noscroll";
21
+        $hotkeys["n"] = "next_article_noscroll";
22
+        $hotkeys["p"] = "prev_article_noscroll";
23 23
 
24
-		return $hotkeys;
25
-	}
24
+        return $hotkeys;
25
+    }
26 26
 
27
-	public function api_version() {
28
-		return 2;
29
-	}
27
+    public function api_version() {
28
+        return 2;
29
+    }
30 30
 
31 31
 }
Please login to merge, or discard this patch.
plugins/af_youtube_embed/init.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Youtube_Embed extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
11
+    public function init($host) {
12
+        $this->host = $host;
13 13
 
14
-		$host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
15
-		$host->add_hook($host::HOOK_IFRAME_WHITELISTED, $this);
16
-	}
14
+        $host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
15
+        $host->add_hook($host::HOOK_IFRAME_WHITELISTED, $this);
16
+    }
17 17
 
18
-	public function hook_iframe_whitelisted($src) {
19
-		return in_array($src, ["www.youtube.com", "youtube.com", "youtu.be"]);
20
-	}
18
+    public function hook_iframe_whitelisted($src) {
19
+        return in_array($src, ["www.youtube.com", "youtube.com", "youtu.be"]);
20
+    }
21 21
 
22
-	/**
23
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
24
-	 */
25
-	public function hook_render_enclosure($entry, $hide_images) {
22
+    /**
23
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
24
+     */
25
+    public function hook_render_enclosure($entry, $hide_images) {
26 26
 
27
-		$matches = array();
27
+        $matches = array();
28 28
 
29
-		if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) ||
30
-			preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) ||
31
-			preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) {
29
+        if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) ||
30
+            preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) ||
31
+            preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) {
32 32
 
33
-			$vid_id = $matches[1];
33
+            $vid_id = $matches[1];
34 34
 
35
-			return "<iframe class=\"youtube-player\"
35
+            return "<iframe class=\"youtube-player\"
36 36
 				type=\"text/html\" width=\"640\" height=\"385\"
37 37
 				src=\"https://www.youtube.com/embed/$vid_id\"
38 38
 				allowfullscreen frameborder=\"0\"></iframe>";
39 39
 
40
-		}
41
-	}
40
+        }
41
+    }
42 42
 
43
-	public function api_version() {
44
-		return 2;
45
-	}
43
+    public function api_version() {
44
+        return 2;
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
plugins/af_comics/filters/af_comics_twp.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Comics_Twp extends Af_ComicFilter {
3 3
 
4
-	public function supported() {
5
-		return array("Three Word Phrase");
6
-	}
4
+    public function supported() {
5
+        return array("Three Word Phrase");
6
+    }
7 7
 
8
-	public function process(&$article) {
8
+    public function process(&$article) {
9 9
 
10
-		if (strpos($article["link"], "threewordphrase.com") !== false) {
10
+        if (strpos($article["link"], "threewordphrase.com") !== false) {
11 11
 
12
-				$doc = new DOMDocument();
12
+                $doc = new DOMDocument();
13 13
 
14
-				if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
15
-					$xpath = new DOMXpath($doc);
14
+                if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
15
+                    $xpath = new DOMXpath($doc);
16 16
 
17
-					$basenode = $xpath->query("//td/center/img")->item(0);
17
+                    $basenode = $xpath->query("//td/center/img")->item(0);
18 18
 
19
-					if ($basenode) {
20
-						$article["content"] = $doc->saveHTML($basenode);
21
-					}
22
-				}
19
+                    if ($basenode) {
20
+                        $article["content"] = $doc->saveHTML($basenode);
21
+                    }
22
+                }
23 23
 
24
-			return true;
25
-		}
24
+            return true;
25
+        }
26 26
 
27
-		return false;
28
-	}
27
+        return false;
28
+    }
29 29
 }
Please login to merge, or discard this patch.
plugins/af_comics/filters/af_comics_explosm.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Comics_Explosm extends Af_ComicFilter {
3 3
 
4
-	public function supported() {
5
-		return array("Cyanide and Happiness");
6
-	}
4
+    public function supported() {
5
+        return array("Cyanide and Happiness");
6
+    }
7 7
 
8
-	public function process(&$article) {
8
+    public function process(&$article) {
9 9
 
10
-		if (strpos($article["link"], "explosm.net/comics") !== false) {
10
+        if (strpos($article["link"], "explosm.net/comics") !== false) {
11 11
 
12
-				$doc = new DOMDocument();
12
+                $doc = new DOMDocument();
13 13
 
14
-				if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
15
-					$xpath = new DOMXPath($doc);
16
-					$basenode = $xpath->query('(//img[@id="main-comic"])')->item(0);
14
+                if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
15
+                    $xpath = new DOMXPath($doc);
16
+                    $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0);
17 17
 
18
-					if ($basenode) {
19
-						$article["content"] = $doc->saveHTML($basenode);
20
-					}
21
-				}
18
+                    if ($basenode) {
19
+                        $article["content"] = $doc->saveHTML($basenode);
20
+                    }
21
+                }
22 22
 
23
-			return true;
24
-		}
23
+            return true;
24
+        }
25 25
 
26
-		return false;
27
-	}
26
+        return false;
27
+    }
28 28
 }
Please login to merge, or discard this patch.
plugins/af_comics/filters/af_comics_comicclass.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,34 +1,34 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Comics_ComicClass extends Af_ComicFilter {
3 3
 
4
-	public function supported() {
5
-		return array("Loading Artist");
6
-	}
4
+    public function supported() {
5
+        return array("Loading Artist");
6
+    }
7 7
 
8
-	public function process(&$article) {
9
-		if (strpos($article["guid"], "loadingartist.com") !== false) {
8
+    public function process(&$article) {
9
+        if (strpos($article["guid"], "loadingartist.com") !== false) {
10 10
 
11
-				// lol at people who block clients by user agent
12
-				// oh noes my ad revenue Q_Q
11
+                // lol at people who block clients by user agent
12
+                // oh noes my ad revenue Q_Q
13 13
 
14
-				$res = fetch_file_contents($article["link"], false, false, false,
15
-					 false, false, 0,
16
-					 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
14
+                $res = fetch_file_contents($article["link"], false, false, false,
15
+                        false, false, 0,
16
+                        "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
17 17
 
18
-				$doc = new DOMDocument();
18
+                $doc = new DOMDocument();
19 19
 
20
-				if (@$doc->loadHTML($res)) {
21
-					$xpath = new DOMXPath($doc);
22
-					$basenode = $xpath->query('//div[@class="comic"]')->item(0);
20
+                if (@$doc->loadHTML($res)) {
21
+                    $xpath = new DOMXPath($doc);
22
+                    $basenode = $xpath->query('//div[@class="comic"]')->item(0);
23 23
 
24
-					if ($basenode) {
25
-						$article["content"] = $doc->saveHTML($basenode);
26
-					}
27
-				}
24
+                    if ($basenode) {
25
+                        $article["content"] = $doc->saveHTML($basenode);
26
+                    }
27
+                }
28 28
 
29
-			 return true;
30
-		}
29
+                return true;
30
+        }
31 31
 
32
-		return false;
33
-	}
32
+        return false;
33
+    }
34 34
 }
Please login to merge, or discard this patch.
plugins/af_comics/filters/af_comics_pvp.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Comics_Pvp extends Af_ComicFilter {
3 3
 
4
-	public function supported() {
5
-		return array("PvP Online");
6
-	}
4
+    public function supported() {
5
+        return array("PvP Online");
6
+    }
7 7
 
8
-	public function process(&$article) {
9
-		if (strpos($article["guid"], "pvponline.com") !== false) {
8
+    public function process(&$article) {
9
+        if (strpos($article["guid"], "pvponline.com") !== false) {
10 10
 
11
-				$res = fetch_file_contents($article["link"], false, false, false,
12
-					 false, false, 0,
13
-					 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
11
+                $res = fetch_file_contents($article["link"], false, false, false,
12
+                        false, false, 0,
13
+                        "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
14 14
 
15
-				$doc = new DOMDocument();
15
+                $doc = new DOMDocument();
16 16
 
17
-				if (@$doc->loadHTML($res)) {
18
-					$xpath = new DOMXPath($doc);
19
-					$basenode = $xpath->query('//section[@class="comic-art"]')->item(0);
17
+                if (@$doc->loadHTML($res)) {
18
+                    $xpath = new DOMXPath($doc);
19
+                    $basenode = $xpath->query('//section[@class="comic-art"]')->item(0);
20 20
 
21
-					if ($basenode) {
22
-						$article["content"] = $doc->saveHTML($basenode);
23
-					}
24
-				}
21
+                    if ($basenode) {
22
+                        $article["content"] = $doc->saveHTML($basenode);
23
+                    }
24
+                }
25 25
 
26
-			 return true;
27
-		}
26
+                return true;
27
+        }
28 28
 
29
-		return false;
30
-	}
29
+        return false;
30
+    }
31 31
 }
Please login to merge, or discard this patch.
plugins/af_comics/filters/af_comics_comicpress.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Comics_ComicPress extends Af_ComicFilter {
3 3
 
4
-	public function supported() {
5
-		return array("Buni", "Buttersafe", "Happy Jar", "CSection",
6
-			"Extra Fabulous Comics", "Nedroid", "Stonetoss");
7
-	}
4
+    public function supported() {
5
+        return array("Buni", "Buttersafe", "Happy Jar", "CSection",
6
+            "Extra Fabulous Comics", "Nedroid", "Stonetoss");
7
+    }
8 8
 
9
-	public function process(&$article) {
10
-		if (strpos($article["guid"], "bunicomic.com") !== false ||
11
-				strpos($article["guid"], "buttersafe.com") !== false ||
12
-				strpos($article["guid"], "extrafabulouscomics.com") !== false ||
13
-				strpos($article["guid"], "happyjar.com") !== false ||
14
-				strpos($article["guid"], "nedroid.com") !== false ||
15
-				strpos($article["guid"], "stonetoss.com") !== false ||
16
-				strpos($article["guid"], "csectioncomics.com") !== false) {
9
+    public function process(&$article) {
10
+        if (strpos($article["guid"], "bunicomic.com") !== false ||
11
+                strpos($article["guid"], "buttersafe.com") !== false ||
12
+                strpos($article["guid"], "extrafabulouscomics.com") !== false ||
13
+                strpos($article["guid"], "happyjar.com") !== false ||
14
+                strpos($article["guid"], "nedroid.com") !== false ||
15
+                strpos($article["guid"], "stonetoss.com") !== false ||
16
+                strpos($article["guid"], "csectioncomics.com") !== false) {
17 17
 
18
-				// lol at people who block clients by user agent
19
-				// oh noes my ad revenue Q_Q
18
+                // lol at people who block clients by user agent
19
+                // oh noes my ad revenue Q_Q
20 20
 
21
-				$res = fetch_file_contents(["url" => $article["link"],
22
-					"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
21
+                $res = fetch_file_contents(["url" => $article["link"],
22
+                    "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
23 23
 
24
-				$doc = new DOMDocument();
24
+                $doc = new DOMDocument();
25 25
 
26
-				if (@$doc->loadHTML($res)) {
27
-					$xpath = new DOMXPath($doc);
28
-					$basenode = $xpath->query('//div[@id="comic"]')->item(0);
26
+                if (@$doc->loadHTML($res)) {
27
+                    $xpath = new DOMXPath($doc);
28
+                    $basenode = $xpath->query('//div[@id="comic"]')->item(0);
29 29
 
30
-					if ($basenode) {
31
-						$article["content"] = $doc->saveHTML($basenode);
32
-						return true;
33
-					}
30
+                    if ($basenode) {
31
+                        $article["content"] = $doc->saveHTML($basenode);
32
+                        return true;
33
+                    }
34 34
 
35
-					// buni-specific
36
-					$webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0);
35
+                    // buni-specific
36
+                    $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0);
37 37
 
38
-					if ($webtoon_link) {
38
+                    if ($webtoon_link) {
39 39
 
40
-						$res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"),
41
-							"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
40
+                        $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"),
41
+                            "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
42 42
 
43
-						if (@$doc->loadHTML($res)) {
44
-							$xpath = new DOMXPath($doc);
45
-							$basenode = $xpath->query('//div[@id="_viewerBox"]')->item(0);
43
+                        if (@$doc->loadHTML($res)) {
44
+                            $xpath = new DOMXPath($doc);
45
+                            $basenode = $xpath->query('//div[@id="_viewerBox"]')->item(0);
46 46
 
47
-							if ($basenode) {
48
-								$imgs = $xpath->query("//img[@data-url]", $basenode);
47
+                            if ($basenode) {
48
+                                $imgs = $xpath->query("//img[@data-url]", $basenode);
49 49
 
50
-								foreach ($imgs as $img) {
51
-									$img->setAttribute("src", $img->getAttribute("data-url"));
52
-								}
50
+                                foreach ($imgs as $img) {
51
+                                    $img->setAttribute("src", $img->getAttribute("data-url"));
52
+                                }
53 53
 
54
-								$article["content"] = $doc->saveHTML($basenode);
55
-								return true;
56
-							}
57
-						}
58
-					}
59
-				}
60
-		}
54
+                                $article["content"] = $doc->saveHTML($basenode);
55
+                                return true;
56
+                            }
57
+                        }
58
+                    }
59
+                }
60
+        }
61 61
 
62
-		return false;
63
-	}
62
+        return false;
63
+    }
64 64
 }
Please login to merge, or discard this patch.
plugins/af_redditimgur/init.php 3 patches
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Af_RedditImgur 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
-			"Inline images (and other content) in Reddit RSS feeds",
10
-			"fox");
11
-	}
7
+    public function about() {
8
+        return array(1.0,
9
+            "Inline images (and other content) in Reddit RSS feeds",
10
+            "fox");
11
+    }
12 12
 
13
-	public function flags() {
14
-		return array("needs_curl" => true);
15
-	}
13
+    public function flags() {
14
+        return array("needs_curl" => true);
15
+    }
16 16
 
17
-	public function init($host) {
18
-		$this->host = $host;
17
+    public function init($host) {
18
+        $this->host = $host;
19 19
 
20
-		$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
21
-		$host->add_hook($host::HOOK_PREFS_TAB, $this);
22
-	}
20
+        $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
21
+        $host->add_hook($host::HOOK_PREFS_TAB, $this);
22
+    }
23 23
 
24
-	public function hook_prefs_tab($args) {
25
-		if ($args != "prefFeeds") return;
24
+    public function hook_prefs_tab($args) {
25
+        if ($args != "prefFeeds") return;
26 26
 
27
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
27
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
28 28
 			title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">";
29 29
 
30
-		$enable_readability = $this->host->get($this, "enable_readability");
31
-		$enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
30
+        $enable_readability = $this->host->get($this, "enable_readability");
31
+        $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
32 32
 
33
-		if (version_compare(PHP_VERSION, '5.6.0', '<')) {
34
-			print_error("Readability requires PHP version 5.6.");
35
-		}
33
+        if (version_compare(PHP_VERSION, '5.6.0', '<')) {
34
+            print_error("Readability requires PHP version 5.6.");
35
+        }
36 36
 
37
-		print "<form dojoType='dijit.form.Form'>";
37
+        print "<form dojoType='dijit.form.Form'>";
38 38
 
39
-		print "<script type='dojo/method' event='onSubmit' args='evt'>
39
+        print "<script type='dojo/method' event='onSubmit' args='evt'>
40 40
 			evt.preventDefault();
41 41
 			if (this.validate()) {
42 42
 				console.log(dojo.objectToQuery(this.getValues()));
@@ -50,235 +50,235 @@  discard block
 block discarded – undo
50 50
 			}
51 51
 			</script>";
52 52
 
53
-		print_hidden("op", "pluginhandler");
54
-		print_hidden("method", "save");
55
-		print_hidden("plugin", "af_redditimgur");
53
+        print_hidden("op", "pluginhandler");
54
+        print_hidden("method", "save");
55
+        print_hidden("plugin", "af_redditimgur");
56 56
 
57
-		print "<fieldset class='narrow'>";
58
-		print "<label class='checkbox'>";
59
-		print_checkbox("enable_readability", $enable_readability);
60
-		print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
61
-		print "</fieldset>";
57
+        print "<fieldset class='narrow'>";
58
+        print "<label class='checkbox'>";
59
+        print_checkbox("enable_readability", $enable_readability);
60
+        print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
61
+        print "</fieldset>";
62 62
 
63
-		print "<fieldset class='narrow'>";
64
-		print "<label class='checkbox'>";
65
-		print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
66
-		print " " . __("Enable additional duplicate checking") . "</label>";
67
-		print "</fieldset>";
63
+        print "<fieldset class='narrow'>";
64
+        print "<label class='checkbox'>";
65
+        print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
66
+        print " " . __("Enable additional duplicate checking") . "</label>";
67
+        print "</fieldset>";
68 68
 
69
-		print_button("submit", __("Save"), 'class="alt-primary"');
70
-		print "</form>";
69
+        print_button("submit", __("Save"), 'class="alt-primary"');
70
+        print "</form>";
71 71
 
72
-		print "</div>";
73
-	}
72
+        print "</div>";
73
+    }
74 74
 
75
-	public function save() {
76
-		$enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]);
77
-		$enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]);
75
+    public function save() {
76
+        $enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]);
77
+        $enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]);
78 78
 
79
-		$this->host->set($this, "enable_readability", $enable_readability, false);
80
-		$this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck);
79
+        $this->host->set($this, "enable_readability", $enable_readability, false);
80
+        $this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck);
81 81
 
82
-		echo __("Configuration saved");
83
-	}
82
+        echo __("Configuration saved");
83
+    }
84 84
 
85
-	/**
86
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
87
-	 */
88
-	private function inline_stuff($article, &$doc, $xpath) {
85
+    /**
86
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
87
+     */
88
+    private function inline_stuff($article, &$doc, $xpath) {
89 89
 
90
-		$entries = $xpath->query('(//a[@href]|//img[@src])');
91
-		$img_entries = $xpath->query("(//img[@src])");
90
+        $entries = $xpath->query('(//a[@href]|//img[@src])');
91
+        $img_entries = $xpath->query("(//img[@src])");
92 92
 
93
-		$found = false;
94
-		//$debug = 1;
93
+        $found = false;
94
+        //$debug = 1;
95 95
 
96
-		foreach ($entries as $entry) {
97
-			if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) {
96
+        foreach ($entries as $entry) {
97
+            if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) {
98 98
 
99
-				Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
99
+                Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
100 100
 
101
-				$matches = array();
101
+                $matches = array();
102 102
 
103
-				if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
104
-					Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
103
+                if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
104
+                    Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
105 105
 
106
-					$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
106
+                    $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
107 107
 
108
-					if ($oembed_result) {
109
-						$oembed_result = json_decode($oembed_result, true);
108
+                    if ($oembed_result) {
109
+                        $oembed_result = json_decode($oembed_result, true);
110 110
 
111
-						if ($oembed_result && isset($oembed_result["html"])) {
111
+                        if ($oembed_result && isset($oembed_result["html"])) {
112 112
 
113
-							$tmp = new DOMDocument();
114
-							if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
115
-								$p = $doc->createElement("p");
113
+                            $tmp = new DOMDocument();
114
+                            if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
115
+                                $p = $doc->createElement("p");
116 116
 
117
-								$p->appendChild($doc->importNode(
118
-									$tmp->getElementsByTagName("blockquote")->item(0), true));
117
+                                $p->appendChild($doc->importNode(
118
+                                    $tmp->getElementsByTagName("blockquote")->item(0), true));
119 119
 
120
-								$br = $doc->createElement('br');
121
-								$entry->parentNode->insertBefore($p, $entry);
122
-								$entry->parentNode->insertBefore($br, $entry);
120
+                                $br = $doc->createElement('br');
121
+                                $entry->parentNode->insertBefore($p, $entry);
122
+                                $entry->parentNode->insertBefore($br, $entry);
123 123
 
124
-								$found = 1;
125
-							}
126
-						}
127
-					}
128
-				}
124
+                                $found = 1;
125
+                            }
126
+                        }
127
+                    }
128
+                }
129 129
 
130
-				if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
131
-					$entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
132
-				}
130
+                if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
131
+                    $entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
132
+                }
133 133
 
134
-				if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
134
+                if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
135 135
 
136
-					Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
136
+                    Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
137 137
 
138
-					$source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
139
-					$poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
138
+                    $source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
139
+                    $poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
140 140
 
141
-					$content_type = $this->get_content_type($source_stream);
141
+                    $content_type = $this->get_content_type($source_stream);
142 142
 
143
-					if (strpos($content_type, "video/") !== false) {
144
-						$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
145
-						$found = 1;
146
-					}
147
-				}
143
+                    if (strpos($content_type, "video/") !== false) {
144
+                        $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
145
+                        $found = 1;
146
+                    }
147
+                }
148 148
 
149
-				if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
149
+                if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
150 150
 
151
-					Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE);
151
+                    Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE);
152 152
 
153
-					$img = $img_entries->item(0);
153
+                    $img = $img_entries->item(0);
154 154
 
155
-					if ($img) {
156
-						$poster_url = $img->getAttribute("src");
157
-					} else {
158
-						$poster_url = false;
159
-					}
155
+                    if ($img) {
156
+                        $poster_url = $img->getAttribute("src");
157
+                    } else {
158
+                        $poster_url = false;
159
+                    }
160 160
 
161
-					// Get original article URL from v.redd.it redirects
162
-					$source_article_url = $this->get_location($matches[0]);
163
-					Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE);
164
-
165
-					$source_stream = false;
166
-
167
-					if ($source_article_url) {
168
-						$j = json_decode(fetch_file_contents($source_article_url.".json"), true);
169
-
170
-						if ($j) {
171
-							foreach ($j as $listing) {
172
-								foreach ($listing["data"]["children"] as $child) {
173
-									if ($child["data"]["url"] == $matches[0]) {
174
-										try {
175
-											$source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
-										}
177
-										catch (Exception $e) {
178
-										}
179
-										break 2;
180
-									}
181
-								}
182
-							}
183
-						}
184
-					}
161
+                    // Get original article URL from v.redd.it redirects
162
+                    $source_article_url = $this->get_location($matches[0]);
163
+                    Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE);
164
+
165
+                    $source_stream = false;
166
+
167
+                    if ($source_article_url) {
168
+                        $j = json_decode(fetch_file_contents($source_article_url.".json"), true);
169
+
170
+                        if ($j) {
171
+                            foreach ($j as $listing) {
172
+                                foreach ($listing["data"]["children"] as $child) {
173
+                                    if ($child["data"]["url"] == $matches[0]) {
174
+                                        try {
175
+                                            $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
+                                        }
177
+                                        catch (Exception $e) {
178
+                                        }
179
+                                        break 2;
180
+                                    }
181
+                                }
182
+                            }
183
+                        }
184
+                    }
185 185
 
186
-					if (!$source_stream) {
187
-						$source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
188
-					}
186
+                    if (!$source_stream) {
187
+                        $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
188
+                    }
189 189
 
190
-					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
191
-					$found = 1;
192
-				}
190
+                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
191
+                    $found = 1;
192
+                }
193 193
 
194
-				if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
194
+                if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
195 195
 
196
-					Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
196
+                    Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
197 197
 
198
-					$tmp = fetch_file_contents($entry->getAttribute("href"));
198
+                    $tmp = fetch_file_contents($entry->getAttribute("href"));
199 199
 
200
-					if ($tmp) {
201
-						$tmpdoc = new DOMDocument();
200
+                    if ($tmp) {
201
+                        $tmpdoc = new DOMDocument();
202 202
 
203
-						if (@$tmpdoc->loadHTML($tmp)) {
204
-							$tmpxpath = new DOMXPath($tmpdoc);
203
+                        if (@$tmpdoc->loadHTML($tmp)) {
204
+                            $tmpxpath = new DOMXPath($tmpdoc);
205 205
 
206
-							$source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0);
207
-							$poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0);
206
+                            $source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0);
207
+                            $poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0);
208 208
 
209
-							if ($source_node && $poster_node) {
210
-								$source_stream = $source_node->getAttribute("src");
211
-								$poster_url = $poster_node->getAttribute("poster");
209
+                            if ($source_node && $poster_node) {
210
+                                $source_stream = $source_node->getAttribute("src");
211
+                                $poster_url = $poster_node->getAttribute("poster");
212 212
 
213
-								$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
214
-								$found = 1;
215
-							}
216
-						}
217
-					}
218
-				}
213
+                                $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
214
+                                $found = 1;
215
+                            }
216
+                        }
217
+                    }
218
+                }
219 219
 
220
-				// imgur .gif -> .gifv
221
-				if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
222
-					Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE);
220
+                // imgur .gif -> .gifv
221
+                if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
222
+                    Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE);
223 223
 
224
-					$entry->setAttribute("href",
225
-						str_replace(".gif", ".gifv", $entry->getAttribute("href")));
226
-				}
224
+                    $entry->setAttribute("href",
225
+                        str_replace(".gif", ".gifv", $entry->getAttribute("href")));
226
+                }
227 227
 
228
-				if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
229
-					Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE);
228
+                if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
229
+                    Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE);
230 230
 
231
-					$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
231
+                    $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
232 232
 
233
-					if (strpos($source_stream, "imgur.com") !== false)
234
-						$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
233
+                    if (strpos($source_stream, "imgur.com") !== false)
234
+                        $poster_url = str_replace(".mp4", "h.jpg", $source_stream);
235 235
 
236
-					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
236
+                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
237 237
 
238
-					$found = true;
239
-				}
238
+                    $found = true;
239
+                }
240 240
 
241
-				$matches = array();
242
-				if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
243
-					preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
244
-					preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
245
-					preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
241
+                $matches = array();
242
+                if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
243
+                    preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
244
+                    preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
245
+                    preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
246 246
 
247
-					$vid_id = $matches[1];
247
+                    $vid_id = $matches[1];
248 248
 
249
-					Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE);
249
+                    Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE);
250 250
 
251
-					$iframe = $doc->createElement("iframe");
252
-					$iframe->setAttribute("class", "youtube-player");
253
-					$iframe->setAttribute("type", "text/html");
254
-					$iframe->setAttribute("width", "640");
255
-					$iframe->setAttribute("height", "385");
256
-					$iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
257
-					$iframe->setAttribute("allowfullscreen", "1");
258
-					$iframe->setAttribute("frameborder", "0");
251
+                    $iframe = $doc->createElement("iframe");
252
+                    $iframe->setAttribute("class", "youtube-player");
253
+                    $iframe->setAttribute("type", "text/html");
254
+                    $iframe->setAttribute("width", "640");
255
+                    $iframe->setAttribute("height", "385");
256
+                    $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
257
+                    $iframe->setAttribute("allowfullscreen", "1");
258
+                    $iframe->setAttribute("frameborder", "0");
259 259
 
260
-					$br = $doc->createElement('br');
261
-					$entry->parentNode->insertBefore($iframe, $entry);
262
-					$entry->parentNode->insertBefore($br, $entry);
260
+                    $br = $doc->createElement('br');
261
+                    $entry->parentNode->insertBefore($iframe, $entry);
262
+                    $entry->parentNode->insertBefore($br, $entry);
263 263
 
264
-					$found = true;
265
-				}
264
+                    $found = true;
265
+                }
266 266
 
267
-				if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) ||
268
-					mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false ||
269
-					mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false) {
267
+                if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) ||
268
+                    mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false ||
269
+                    mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false) {
270 270
 
271
-					Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
271
+                    Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
272 272
 
273
-					$img = $doc->createElement('img');
274
-					$img->setAttribute("src", $entry->getAttribute("href"));
273
+                    $img = $doc->createElement('img');
274
+                    $img->setAttribute("src", $entry->getAttribute("href"));
275 275
 
276
-					$br = $doc->createElement('br');
277
-					$entry->parentNode->insertBefore($img, $entry);
278
-					$entry->parentNode->insertBefore($br, $entry);
276
+                    $br = $doc->createElement('br');
277
+                    $entry->parentNode->insertBefore($img, $entry);
278
+                    $entry->parentNode->insertBefore($br, $entry);
279 279
 
280
-					$found = true;
281
-				}
280
+                    $found = true;
281
+                }
282 282
 
283 283
                 // imgur via link rel="image_src" href="..."
284 284
                 if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) {
@@ -311,109 +311,109 @@  discard block
 block discarded – undo
311 311
                     }
312 312
                 }
313 313
 
314
-				// wtf is this even
315
-				if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
316
-					$img_id = $matches[1];
314
+                // wtf is this even
315
+                if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
316
+                    $img_id = $matches[1];
317 317
 
318
-					Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE);
318
+                    Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE);
319 319
 
320
-					$img = $doc->createElement('img');
321
-					$img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
320
+                    $img = $doc->createElement('img');
321
+                    $img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
322 322
 
323
-					$br = $doc->createElement('br');
324
-					$entry->parentNode->insertBefore($img, $entry);
325
-					$entry->parentNode->insertBefore($br, $entry);
323
+                    $br = $doc->createElement('br');
324
+                    $entry->parentNode->insertBefore($img, $entry);
325
+                    $entry->parentNode->insertBefore($br, $entry);
326 326
 
327
-					$found = true;
328
-				}
327
+                    $found = true;
328
+                }
329 329
 
330
-				// let's try meta properties
331
-				if (!$found) {
332
-					Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
330
+                // let's try meta properties
331
+                if (!$found) {
332
+                    Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
333 333
 
334
-					$content = fetch_file_contents(["url" => $entry->getAttribute("href"),
335
-						"http_accept" => "text/*"]);
334
+                    $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
335
+                        "http_accept" => "text/*"]);
336 336
 
337
-					if ($content) {
338
-						$cdoc = new DOMDocument();
337
+                    if ($content) {
338
+                        $cdoc = new DOMDocument();
339 339
 
340
-						if (@$cdoc->loadHTML($content)) {
341
-							$cxpath = new DOMXPath($cdoc);
340
+                        if (@$cdoc->loadHTML($content)) {
341
+                            $cxpath = new DOMXPath($cdoc);
342 342
 
343
-							$og_image = $cxpath->query("//meta[@property='og:image']")->item(0);
344
-							$og_video = $cxpath->query("//meta[@property='og:video']")->item(0);
343
+                            $og_image = $cxpath->query("//meta[@property='og:image']")->item(0);
344
+                            $og_video = $cxpath->query("//meta[@property='og:video']")->item(0);
345 345
 
346
-							if ($og_video) {
346
+                            if ($og_video) {
347 347
 
348
-								$source_stream = $og_video->getAttribute("content");
348
+                                $source_stream = $og_video->getAttribute("content");
349 349
 
350
-								if ($source_stream) {
350
+                                if ($source_stream) {
351 351
 
352
-									if ($og_image) {
353
-										$poster_url = $og_image->getAttribute("content");
354
-									} else {
355
-										$poster_url = false;
356
-									}
352
+                                    if ($og_image) {
353
+                                        $poster_url = $og_image->getAttribute("content");
354
+                                    } else {
355
+                                        $poster_url = false;
356
+                                    }
357 357
 
358
-									$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
359
-									$found = true;
360
-								}
358
+                                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
359
+                                    $found = true;
360
+                                }
361 361
 
362
-							} else if ($og_image) {
362
+                            } else if ($og_image) {
363 363
 
364
-								$og_src = $og_image->getAttribute("content");
364
+                                $og_src = $og_image->getAttribute("content");
365 365
 
366
-								if ($og_src) {
367
-									$img = $doc->createElement('img');
368
-									$img->setAttribute("src", $og_src);
366
+                                if ($og_src) {
367
+                                    $img = $doc->createElement('img');
368
+                                    $img->setAttribute("src", $og_src);
369 369
 
370
-									$br = $doc->createElement('br');
371
-									$entry->parentNode->insertBefore($img, $entry);
372
-									$entry->parentNode->insertBefore($br, $entry);
370
+                                    $br = $doc->createElement('br');
371
+                                    $entry->parentNode->insertBefore($img, $entry);
372
+                                    $entry->parentNode->insertBefore($br, $entry);
373 373
 
374
-									$found = true;
375
-								}
376
-							}
377
-						}
378
-					}
379
-				}
374
+                                    $found = true;
375
+                                }
376
+                            }
377
+                        }
378
+                    }
379
+                }
380 380
 
381
-			}
381
+            }
382 382
 
383
-			// remove tiny thumbnails
384
-			if ($entry->hasAttribute("src")) {
385
-				if ($entry->parentNode && $entry->parentNode->parentNode) {
386
-					$entry->parentNode->parentNode->removeChild($entry->parentNode);
387
-				}
388
-			}
389
-		}
383
+            // remove tiny thumbnails
384
+            if ($entry->hasAttribute("src")) {
385
+                if ($entry->parentNode && $entry->parentNode->parentNode) {
386
+                    $entry->parentNode->parentNode->removeChild($entry->parentNode);
387
+                }
388
+            }
389
+        }
390 390
 
391
-		return $found;
392
-	}
391
+        return $found;
392
+    }
393 393
 
394
-	public function hook_article_filter($article) {
394
+    public function hook_article_filter($article) {
395 395
 
396
-		if (strpos($article["link"], "reddit.com/r/") !== false) {
397
-			$doc = new DOMDocument();
398
-			@$doc->loadHTML($article["content"]);
399
-			$xpath = new DOMXPath($doc);
396
+        if (strpos($article["link"], "reddit.com/r/") !== false) {
397
+            $doc = new DOMDocument();
398
+            @$doc->loadHTML($article["content"]);
399
+            $xpath = new DOMXPath($doc);
400 400
 
401
-			$content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
401
+            $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
402 402
 
403
-			if ($this->host->get($this, "enable_content_dupcheck")) {
403
+            if ($this->host->get($this, "enable_content_dupcheck")) {
404 404
 
405
-				if ($content_link) {
406
-					$content_href = $content_link->getAttribute("href");
407
-					$entry_guid = $article["guid_hashed"];
408
-					$owner_uid = $article["owner_uid"];
405
+                if ($content_link) {
406
+                    $content_href = $content_link->getAttribute("href");
407
+                    $entry_guid = $article["guid_hashed"];
408
+                    $owner_uid = $article["owner_uid"];
409 409
 
410
-					if (DB_TYPE == "pgsql") {
411
-						$interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
412
-					} else {
413
-						$interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
414
-					}
410
+                    if (DB_TYPE == "pgsql") {
411
+                        $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
412
+                    } else {
413
+                        $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
414
+                    }
415 415
 
416
-					$sth = $this->pdo->prepare("SELECT COUNT(id) AS cid
416
+                    $sth = $this->pdo->prepare("SELECT COUNT(id) AS cid
417 417
 						FROM ttrss_entries, ttrss_user_entries WHERE
418 418
 							ref_id = id AND
419 419
 							$interval_qpart AND
@@ -421,149 +421,149 @@  discard block
 block discarded – undo
421 421
 							owner_uid = ? AND
422 422
 							content LIKE ?");
423 423
 
424
-					$sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]);
424
+                    $sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]);
425 425
 
426
-					if ($row = $sth->fetch()) {
427
-						$num_found = $row['cid'];
426
+                    if ($row = $sth->fetch()) {
427
+                        $num_found = $row['cid'];
428 428
 
429
-						if ($num_found > 0) $article["force_catchup"] = true;
430
-					}
431
-				}
432
-			}
429
+                        if ($num_found > 0) $article["force_catchup"] = true;
430
+                    }
431
+                }
432
+            }
433 433
 
434
-			$found = $this->inline_stuff($article, $doc, $xpath);
434
+            $found = $this->inline_stuff($article, $doc, $xpath);
435 435
 
436
-			$node = $doc->getElementsByTagName('body')->item(0);
436
+            $node = $doc->getElementsByTagName('body')->item(0);
437 437
 
438
-			if ($node && $found) {
439
-				$article["content"] = $doc->saveHTML($node);
440
-			} else if ($content_link) {
441
-				$article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
442
-			}
443
-		}
438
+            if ($node && $found) {
439
+                $article["content"] = $doc->saveHTML($node);
440
+            } else if ($content_link) {
441
+                $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
442
+            }
443
+        }
444 444
 
445
-		return $article;
446
-	}
445
+        return $article;
446
+    }
447 447
 
448
-	public function api_version() {
449
-		return 2;
450
-	}
448
+    public function api_version() {
449
+        return 2;
450
+    }
451 451
 
452
-	private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) {
452
+    private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) {
453 453
 
454
-		Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE);
454
+        Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE);
455 455
 
456
-		$video = $doc->createElement('video');
457
-		$video->setAttribute("autoplay", "1");
458
-		$video->setAttribute("controls", "1");
459
-		$video->setAttribute("loop", "1");
456
+        $video = $doc->createElement('video');
457
+        $video->setAttribute("autoplay", "1");
458
+        $video->setAttribute("controls", "1");
459
+        $video->setAttribute("loop", "1");
460 460
 
461
-		if ($poster_url) $video->setAttribute("poster", $poster_url);
461
+        if ($poster_url) $video->setAttribute("poster", $poster_url);
462 462
 
463
-		$source = $doc->createElement('source');
464
-		$source->setAttribute("src", $source_stream);
465
-		$source->setAttribute("type", "video/mp4");
463
+        $source = $doc->createElement('source');
464
+        $source->setAttribute("src", $source_stream);
465
+        $source->setAttribute("type", "video/mp4");
466 466
 
467
-		$video->appendChild($source);
467
+        $video->appendChild($source);
468 468
 
469
-		$br = $doc->createElement('br');
470
-		$entry->parentNode->insertBefore($video, $entry);
471
-		$entry->parentNode->insertBefore($br, $entry);
469
+        $br = $doc->createElement('br');
470
+        $entry->parentNode->insertBefore($video, $entry);
471
+        $entry->parentNode->insertBefore($br, $entry);
472 472
 
473
-		$img = $doc->createElement('img');
474
-		$img->setAttribute("src",
475
-			"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
473
+        $img = $doc->createElement('img');
474
+        $img->setAttribute("src",
475
+            "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
476 476
 
477
-		$entry->parentNode->insertBefore($img, $entry);
478
-	}
477
+        $entry->parentNode->insertBefore($img, $entry);
478
+    }
479 479
 
480
-	public function testurl() {
481
-		$url = htmlspecialchars($_REQUEST["url"]);
480
+    public function testurl() {
481
+        $url = htmlspecialchars($_REQUEST["url"]);
482 482
 
483
-		header("Content-type: text/plain");
483
+        header("Content-type: text/plain");
484 484
 
485
-		print "URL: $url\n";
485
+        print "URL: $url\n";
486 486
 
487
-		$doc = new DOMDocument();
488
-		@$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
489
-		$xpath = new DOMXPath($doc);
487
+        $doc = new DOMDocument();
488
+        @$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
489
+        $xpath = new DOMXPath($doc);
490 490
 
491
-		$found = $this->inline_stuff([], $doc, $xpath);
491
+        $found = $this->inline_stuff([], $doc, $xpath);
492 492
 
493
-		print "Inline result: $found\n";
493
+        print "Inline result: $found\n";
494 494
 
495
-		if (!$found) {
496
-			print "\nReadability result:\n";
495
+        if (!$found) {
496
+            print "\nReadability result:\n";
497 497
 
498
-			$article = $this->readability([], $url, $doc, $xpath);
498
+            $article = $this->readability([], $url, $doc, $xpath);
499 499
 
500
-			print_r($article);
501
-		} else {
502
-			print "\nResulting HTML:\n";
500
+            print_r($article);
501
+        } else {
502
+            print "\nResulting HTML:\n";
503 503
 
504
-			print $doc->saveHTML();
505
-		}
506
-	}
504
+            print $doc->saveHTML();
505
+        }
506
+    }
507 507
 
508
-	private function get_header($url, $useragent = SELF_USER_AGENT, $header) {
509
-		$ret = false;
508
+    private function get_header($url, $useragent = SELF_USER_AGENT, $header) {
509
+        $ret = false;
510 510
 
511
-		if (function_exists("curl_init") && !defined("NO_CURL")) {
512
-			$ch = curl_init($url);
513
-			curl_setopt($ch, CURLOPT_TIMEOUT, 5);
514
-			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
515
-			curl_setopt($ch, CURLOPT_HEADER, true);
516
-			curl_setopt($ch, CURLOPT_NOBODY, true);
517
-			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
518
-			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
511
+        if (function_exists("curl_init") && !defined("NO_CURL")) {
512
+            $ch = curl_init($url);
513
+            curl_setopt($ch, CURLOPT_TIMEOUT, 5);
514
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
515
+            curl_setopt($ch, CURLOPT_HEADER, true);
516
+            curl_setopt($ch, CURLOPT_NOBODY, true);
517
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
518
+            curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
519 519
 
520
-			@curl_exec($ch);
521
-			$ret = curl_getinfo($ch, $header);
522
-		}
520
+            @curl_exec($ch);
521
+            $ret = curl_getinfo($ch, $header);
522
+        }
523 523
 
524
-		return $ret;
525
-	}
524
+        return $ret;
525
+    }
526 526
 
527
-	private function get_content_type($url, $useragent = SELF_USER_AGENT) {
528
-		return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE);
529
-	}
527
+    private function get_content_type($url, $useragent = SELF_USER_AGENT) {
528
+        return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE);
529
+    }
530 530
 
531
-	private function get_location($url, $useragent = SELF_USER_AGENT) {
532
-		return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL);
533
-	}
531
+    private function get_location($url, $useragent = SELF_USER_AGENT) {
532
+        return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL);
533
+    }
534 534
 
535
-	/**
536
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
537
-	 */
538
-	private function readability($article, $url, $doc, $xpath, $debug = false) {
535
+    /**
536
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
537
+     */
538
+    private function readability($article, $url, $doc, $xpath, $debug = false) {
539 539
 
540
-		if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
541
-			mb_strlen(strip_tags($article["content"])) <= 150) {
540
+        if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
541
+            mb_strlen(strip_tags($article["content"])) <= 150) {
542 542
 
543
-			// do not try to embed posts linking back to other reddit posts
544
-			// readability.php requires PHP 5.6
545
-			if ($url &&	strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) {
543
+            // do not try to embed posts linking back to other reddit posts
544
+            // readability.php requires PHP 5.6
545
+            if ($url &&	strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) {
546 546
 
547
-				/* link may lead to a huge video file or whatever, we need to check content type before trying to
547
+                /* link may lead to a huge video file or whatever, we need to check content type before trying to
548 548
 				parse it which p much requires curl */
549 549
 
550
-				$useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
551
-				$content_type = $this->get_content_type($url, $useragent_compat);
550
+                $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
551
+                $content_type = $this->get_content_type($url, $useragent_compat);
552 552
 
553
-				if ($content_type && strpos($content_type, "text/html") !== false) {
553
+                if ($content_type && strpos($content_type, "text/html") !== false) {
554 554
 
555
-					foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
556
-						$extracted_content = $p->hook_get_full_text($url);
555
+                    foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
556
+                        $extracted_content = $p->hook_get_full_text($url);
557 557
 
558
-						if ($extracted_content) {
559
-							$article["content"] = $extracted_content;
560
-							break;
561
-						}
562
-					}
563
-				}
564
-			}
565
-		}
558
+                        if ($extracted_content) {
559
+                            $article["content"] = $extracted_content;
560
+                            break;
561
+                        }
562
+                    }
563
+                }
564
+            }
565
+        }
566 566
 
567
-		return $article;
568
-	}
567
+        return $article;
568
+    }
569 569
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 		print "<fieldset class='narrow'>";
58 58
 		print "<label class='checkbox'>";
59 59
 		print_checkbox("enable_readability", $enable_readability);
60
-		print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
60
+		print " ".__("Extract missing content using Readability (requires af_readability)")."</label>";
61 61
 		print "</fieldset>";
62 62
 
63 63
 		print "<fieldset class='narrow'>";
64 64
 		print "<label class='checkbox'>";
65 65
 		print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
66
-		print " " . __("Enable additional duplicate checking") . "</label>";
66
+		print " ".__("Enable additional duplicate checking")."</label>";
67 67
 		print "</fieldset>";
68 68
 
69 69
 		print_button("submit", __("Save"), 'class="alt-primary"');
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 		foreach ($entries as $entry) {
97 97
 			if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) {
98 98
 
99
-				Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
99
+				Debug::log("processing href: ".$entry->getAttribute("href"), Debug::$LOG_VERBOSE);
100 100
 
101 101
 				$matches = array();
102 102
 
103 103
 				if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
104
-					Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
104
+					Debug::log("handling as twitter: ".$matches[1]." ".$matches[2], Debug::$LOG_VERBOSE);
105 105
 
106
-					$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
106
+					$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=".urlencode($entry->getAttribute("href")));
107 107
 
108 108
 					if ($oembed_result) {
109 109
 						$oembed_result = json_decode($oembed_result, true);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 						if ($oembed_result && isset($oembed_result["html"])) {
112 112
 
113 113
 							$tmp = new DOMDocument();
114
-							if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
114
+							if ($tmp->loadHTML('<?xml encoding="utf-8" ?>'.$oembed_result["html"])) {
115 115
 								$p = $doc->createElement("p");
116 116
 
117 117
 								$p->appendChild($doc->importNode(
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 
136 136
 					Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
137 137
 
138
-					$source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
139
-					$poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
138
+					$source_stream = 'https://giant.gfycat.com/'.$matches[2].'.mp4';
139
+					$poster_url = 'https://thumbs.gfycat.com/'.$matches[2].'-mobile.jpg';
140 140
 
141 141
 					$content_type = $this->get_content_type($source_stream);
142 142
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 					}
185 185
 
186 186
 					if (!$source_stream) {
187
-						$source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
187
+						$source_stream = "https://v.redd.it/".$matches[1]."/DASH_600_K";
188 188
 					}
189 189
 
190 190
 					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 
543 543
 			// do not try to embed posts linking back to other reddit posts
544 544
 			// readability.php requires PHP 5.6
545
-			if ($url &&	strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) {
545
+			if ($url && strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) {
546 546
 
547 547
 				/* link may lead to a huge video file or whatever, we need to check content type before trying to
548 548
 				parse it which p much requires curl */
Please login to merge, or discard this patch.
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 	}
23 23
 
24 24
 	public function hook_prefs_tab($args) {
25
-		if ($args != "prefFeeds") return;
25
+		if ($args != "prefFeeds") {
26
+		    return;
27
+		}
26 28
 
27 29
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
28 30
 			title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">";
@@ -173,8 +175,7 @@  discard block
 block discarded – undo
173 175
 									if ($child["data"]["url"] == $matches[0]) {
174 176
 										try {
175 177
 											$source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
-										}
177
-										catch (Exception $e) {
178
+										} catch (Exception $e) {
178 179
 										}
179 180
 										break 2;
180 181
 									}
@@ -230,8 +231,9 @@  discard block
 block discarded – undo
230 231
 
231 232
 					$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
232 233
 
233
-					if (strpos($source_stream, "imgur.com") !== false)
234
-						$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
234
+					if (strpos($source_stream, "imgur.com") !== false) {
235
+											$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
236
+					}
235 237
 
236 238
 					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
237 239
 
@@ -426,7 +428,9 @@  discard block
 block discarded – undo
426 428
 					if ($row = $sth->fetch()) {
427 429
 						$num_found = $row['cid'];
428 430
 
429
-						if ($num_found > 0) $article["force_catchup"] = true;
431
+						if ($num_found > 0) {
432
+						    $article["force_catchup"] = true;
433
+						}
430 434
 					}
431 435
 				}
432 436
 			}
@@ -458,7 +462,9 @@  discard block
 block discarded – undo
458 462
 		$video->setAttribute("controls", "1");
459 463
 		$video->setAttribute("loop", "1");
460 464
 
461
-		if ($poster_url) $video->setAttribute("poster", $poster_url);
465
+		if ($poster_url) {
466
+		    $video->setAttribute("poster", $poster_url);
467
+		}
462 468
 
463 469
 		$source = $doc->createElement('source');
464 470
 		$source->setAttribute("src", $source_stream);
Please login to merge, or discard this patch.
lib/accept-to-gettext.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -72,43 +72,43 @@  discard block
 block discarded – undo
72 72
 function find_match($curlscore,$curcscore,$curgtlang,$langval,$charval,
73 73
                     $gtlang)
74 74
 {
75
-  if($curlscore < $langval) {
75
+    if($curlscore < $langval) {
76 76
     $curlscore=$langval;
77 77
     $curcscore=$charval;
78 78
     $curgtlang=$gtlang;
79
-  } else if ($curlscore == $langval) {
79
+    } else if ($curlscore == $langval) {
80 80
     if($curcscore < $charval) {
81
-      $curcscore=$charval;
82
-      $curgtlang=$gtlang;
81
+        $curcscore=$charval;
82
+        $curgtlang=$gtlang;
83 83
     }
84
-  }
85
-  return array($curlscore, $curcscore, $curgtlang);
84
+    }
85
+    return array($curlscore, $curcscore, $curgtlang);
86 86
 }
87 87
 
88 88
 function al2gt($gettextlangs, $mime) {
89
-  /* default to "everything is acceptable", as RFC2616 specifies */
90
-  $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' :
89
+    /* default to "everything is acceptable", as RFC2616 specifies */
90
+    $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' :
91 91
       $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
92
-  $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' :
92
+    $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' :
93 93
       $_SERVER["HTTP_ACCEPT_CHARSET"]);
94
-  $alparts=@preg_split("/,/",$acceptLang);
95
-  $acparts=@preg_split("/,/",$acceptChar);
94
+    $alparts=@preg_split("/,/",$acceptLang);
95
+    $acparts=@preg_split("/,/",$acceptChar);
96 96
   
97
-  /* Parse the contents of the Accept-Language header.*/
98
-  foreach($alparts as $part) {
97
+    /* Parse the contents of the Accept-Language header.*/
98
+    foreach($alparts as $part) {
99 99
     $part=trim($part);
100 100
     if(preg_match("/;/", $part)) {
101
-      $lang=@preg_split("/;/",$part);
102
-      $score=@preg_split("/=/",$lang[1]);
103
-      $alscores[$lang[0]]=$score[1];
101
+        $lang=@preg_split("/;/",$part);
102
+        $score=@preg_split("/=/",$lang[1]);
103
+        $alscores[$lang[0]]=$score[1];
104 104
     } else {
105
-      $alscores[$part]=1;
105
+        $alscores[$part]=1;
106
+    }
106 107
     }
107
-  }
108 108
 
109
-  /* Do the same for the Accept-Charset header. */
109
+    /* Do the same for the Accept-Charset header. */
110 110
 
111
-  /* RFC2616: ``If no "*" is present in an Accept-Charset field, then
111
+    /* RFC2616: ``If no "*" is present in an Accept-Charset field, then
112 112
    * all character sets not explicitly mentioned get a quality value of
113 113
    * 0, except for ISO-8859-1, which gets a quality value of 1 if not
114 114
    * explicitly mentioned.''
@@ -116,31 +116,31 @@  discard block
 block discarded – undo
116 116
    * Making it 2 for the time being, so that we
117 117
    * can distinguish between "not specified" and "specified as 1" later
118 118
    * on. */
119
-  $acscores["ISO-8859-1"]=2;
119
+    $acscores["ISO-8859-1"]=2;
120 120
 
121
-  foreach($acparts as $part) {
121
+    foreach($acparts as $part) {
122 122
     $part=trim($part);
123 123
     if(preg_match("/;/", $part)) {
124
-      $cs=@preg_split("/;/",$part);
125
-      $score=@preg_split("/=/",$cs[1]);
126
-      $acscores[strtoupper($cs[0])]=$score[1];
124
+        $cs=@preg_split("/;/",$part);
125
+        $score=@preg_split("/=/",$cs[1]);
126
+        $acscores[strtoupper($cs[0])]=$score[1];
127 127
     } else {
128
-      $acscores[strtoupper($part)]=1;
128
+        $acscores[strtoupper($part)]=1;
129
+    }
129 130
     }
130
-  }
131
-  if($acscores["ISO-8859-1"]==2) {
131
+    if($acscores["ISO-8859-1"]==2) {
132 132
     $acscores["ISO-8859-1"]=(isset($acscores["*"])?$acscores["*"]:1);
133
-  }
133
+    }
134 134
 
135
-  /* 
135
+    /* 
136 136
    * Loop through the available languages/encodings, and pick the one
137 137
    * with the highest score, excluding the ones with a charset the user
138 138
    * did not include.
139 139
    */
140
-  $curlscore=0;
141
-  $curcscore=0;
142
-  $curgtlang=null;
143
-  foreach($gettextlangs as $gtlang) {
140
+    $curlscore=0;
141
+    $curcscore=0;
142
+    $curgtlang=null;
143
+    foreach($gettextlangs as $gtlang) {
144 144
 
145 145
     $tmp1=preg_replace("/\_/","-",$gtlang);
146 146
     $tmp2=@preg_split("/\./",$tmp1);
@@ -149,38 +149,38 @@  discard block
 block discarded – undo
149 149
     $noct=@preg_split("/-/",$allang);
150 150
 
151 151
     $testvals=array(
152
-         array(@$alscores[$allang], @$acscores[$gtcs]),
153
-     array(@$alscores[$noct[0]], @$acscores[$gtcs]),
154
-     array(@$alscores[$allang], @$acscores["*"]),
155
-     array(@$alscores[$noct[0]], @$acscores["*"]),
156
-     array(@$alscores["*"], @$acscores[$gtcs]),
157
-     array(@$alscores["*"], @$acscores["*"]));
152
+            array(@$alscores[$allang], @$acscores[$gtcs]),
153
+        array(@$alscores[$noct[0]], @$acscores[$gtcs]),
154
+        array(@$alscores[$allang], @$acscores["*"]),
155
+        array(@$alscores[$noct[0]], @$acscores["*"]),
156
+        array(@$alscores["*"], @$acscores[$gtcs]),
157
+        array(@$alscores["*"], @$acscores["*"]));
158 158
 
159 159
     $found=false;
160 160
     foreach($testvals as $tval) {
161
-      if(!$found && isset($tval[0]) && isset($tval[1])) {
161
+        if(!$found && isset($tval[0]) && isset($tval[1])) {
162 162
         $arr=find_match($curlscore, $curcscore, $curgtlang, $tval[0],
163
-              $tval[1], $gtlang);
163
+                $tval[1], $gtlang);
164 164
         $curlscore=$arr[0];
165 165
         $curcscore=$arr[1];
166 166
         $curgtlang=$arr[2];
167 167
     $found=true;
168
-      }
168
+        }
169
+    }
169 170
     }
170
-  }
171 171
 
172
-  /* We must re-parse the gettext-string now, since we may have found it
172
+    /* We must re-parse the gettext-string now, since we may have found it
173 173
    * through a "*" qualifier.*/
174 174
   
175
-  $gtparts=@preg_split("/\./",$curgtlang);
176
-  $tmp=strtolower($gtparts[0]);
177
-  $lang=preg_replace("/\_/", "-", $tmp);
178
-  $charset=$gtparts[1];
175
+    $gtparts=@preg_split("/\./",$curgtlang);
176
+    $tmp=strtolower($gtparts[0]);
177
+    $lang=preg_replace("/\_/", "-", $tmp);
178
+    $charset=$gtparts[1];
179 179
 
180
-  header("Content-Language: $lang");
181
-  header("Content-Type: $mime; charset=$charset");
180
+    header("Content-Language: $lang");
181
+    header("Content-Type: $mime; charset=$charset");
182 182
 
183
-  return $curgtlang;
183
+    return $curgtlang;
184 184
 }
185 185
 
186 186
 ?>
Please login to merge, or discard this patch.
Spacing   +51 added lines, -53 removed lines patch added patch discarded remove patch
@@ -69,17 +69,17 @@  discard block
 block discarded – undo
69 69
 
70 70
 /* not really important, this one; perhaps I could've put it inline with
71 71
  * the rest. */
72
-function find_match($curlscore,$curcscore,$curgtlang,$langval,$charval,
72
+function find_match($curlscore, $curcscore, $curgtlang, $langval, $charval,
73 73
                     $gtlang)
74 74
 {
75
-  if($curlscore < $langval) {
76
-    $curlscore=$langval;
77
-    $curcscore=$charval;
78
-    $curgtlang=$gtlang;
75
+  if ($curlscore < $langval) {
76
+    $curlscore = $langval;
77
+    $curcscore = $charval;
78
+    $curgtlang = $gtlang;
79 79
   } else if ($curlscore == $langval) {
80
-    if($curcscore < $charval) {
81
-      $curcscore=$charval;
82
-      $curgtlang=$gtlang;
80
+    if ($curcscore < $charval) {
81
+      $curcscore = $charval;
82
+      $curgtlang = $gtlang;
83 83
     }
84 84
   }
85 85
   return array($curlscore, $curcscore, $curgtlang);
@@ -87,22 +87,20 @@  discard block
 block discarded – undo
87 87
 
88 88
 function al2gt($gettextlangs, $mime) {
89 89
   /* default to "everything is acceptable", as RFC2616 specifies */
90
-  $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' :
91
-      $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
92
-  $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' :
93
-      $_SERVER["HTTP_ACCEPT_CHARSET"]);
94
-  $alparts=@preg_split("/,/",$acceptLang);
95
-  $acparts=@preg_split("/,/",$acceptChar);
90
+  $acceptLang = (($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
91
+  $acceptChar = (($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_CHARSET"]);
92
+  $alparts = @preg_split("/,/", $acceptLang);
93
+  $acparts = @preg_split("/,/", $acceptChar);
96 94
   
97 95
   /* Parse the contents of the Accept-Language header.*/
98
-  foreach($alparts as $part) {
99
-    $part=trim($part);
100
-    if(preg_match("/;/", $part)) {
101
-      $lang=@preg_split("/;/",$part);
102
-      $score=@preg_split("/=/",$lang[1]);
103
-      $alscores[$lang[0]]=$score[1];
96
+  foreach ($alparts as $part) {
97
+    $part = trim($part);
98
+    if (preg_match("/;/", $part)) {
99
+      $lang = @preg_split("/;/", $part);
100
+      $score = @preg_split("/=/", $lang[1]);
101
+      $alscores[$lang[0]] = $score[1];
104 102
     } else {
105
-      $alscores[$part]=1;
103
+      $alscores[$part] = 1;
106 104
     }
107 105
   }
108 106
 
@@ -116,20 +114,20 @@  discard block
 block discarded – undo
116 114
    * Making it 2 for the time being, so that we
117 115
    * can distinguish between "not specified" and "specified as 1" later
118 116
    * on. */
119
-  $acscores["ISO-8859-1"]=2;
117
+  $acscores["ISO-8859-1"] = 2;
120 118
 
121
-  foreach($acparts as $part) {
122
-    $part=trim($part);
123
-    if(preg_match("/;/", $part)) {
124
-      $cs=@preg_split("/;/",$part);
125
-      $score=@preg_split("/=/",$cs[1]);
126
-      $acscores[strtoupper($cs[0])]=$score[1];
119
+  foreach ($acparts as $part) {
120
+    $part = trim($part);
121
+    if (preg_match("/;/", $part)) {
122
+      $cs = @preg_split("/;/", $part);
123
+      $score = @preg_split("/=/", $cs[1]);
124
+      $acscores[strtoupper($cs[0])] = $score[1];
127 125
     } else {
128
-      $acscores[strtoupper($part)]=1;
126
+      $acscores[strtoupper($part)] = 1;
129 127
     }
130 128
   }
131
-  if($acscores["ISO-8859-1"]==2) {
132
-    $acscores["ISO-8859-1"]=(isset($acscores["*"])?$acscores["*"]:1);
129
+  if ($acscores["ISO-8859-1"] == 2) {
130
+    $acscores["ISO-8859-1"] = (isset($acscores["*"]) ? $acscores["*"] : 1);
133 131
   }
134 132
 
135 133
   /* 
@@ -137,18 +135,18 @@  discard block
 block discarded – undo
137 135
    * with the highest score, excluding the ones with a charset the user
138 136
    * did not include.
139 137
    */
140
-  $curlscore=0;
141
-  $curcscore=0;
142
-  $curgtlang=null;
143
-  foreach($gettextlangs as $gtlang) {
138
+  $curlscore = 0;
139
+  $curcscore = 0;
140
+  $curgtlang = null;
141
+  foreach ($gettextlangs as $gtlang) {
144 142
 
145
-    $tmp1=preg_replace("/\_/","-",$gtlang);
146
-    $tmp2=@preg_split("/\./",$tmp1);
147
-    $allang=strtolower($tmp2[0]);
148
-    $gtcs=strtoupper($tmp2[1]);
149
-    $noct=@preg_split("/-/",$allang);
143
+    $tmp1 = preg_replace("/\_/", "-", $gtlang);
144
+    $tmp2 = @preg_split("/\./", $tmp1);
145
+    $allang = strtolower($tmp2[0]);
146
+    $gtcs = strtoupper($tmp2[1]);
147
+    $noct = @preg_split("/-/", $allang);
150 148
 
151
-    $testvals=array(
149
+    $testvals = array(
152 150
          array(@$alscores[$allang], @$acscores[$gtcs]),
153 151
      array(@$alscores[$noct[0]], @$acscores[$gtcs]),
154 152
      array(@$alscores[$allang], @$acscores["*"]),
@@ -156,15 +154,15 @@  discard block
 block discarded – undo
156 154
      array(@$alscores["*"], @$acscores[$gtcs]),
157 155
      array(@$alscores["*"], @$acscores["*"]));
158 156
 
159
-    $found=false;
160
-    foreach($testvals as $tval) {
161
-      if(!$found && isset($tval[0]) && isset($tval[1])) {
162
-        $arr=find_match($curlscore, $curcscore, $curgtlang, $tval[0],
157
+    $found = false;
158
+    foreach ($testvals as $tval) {
159
+      if (!$found && isset($tval[0]) && isset($tval[1])) {
160
+        $arr = find_match($curlscore, $curcscore, $curgtlang, $tval[0],
163 161
               $tval[1], $gtlang);
164
-        $curlscore=$arr[0];
165
-        $curcscore=$arr[1];
166
-        $curgtlang=$arr[2];
167
-    $found=true;
162
+        $curlscore = $arr[0];
163
+        $curcscore = $arr[1];
164
+        $curgtlang = $arr[2];
165
+    $found = true;
168 166
       }
169 167
     }
170 168
   }
@@ -172,10 +170,10 @@  discard block
 block discarded – undo
172 170
   /* We must re-parse the gettext-string now, since we may have found it
173 171
    * through a "*" qualifier.*/
174 172
   
175
-  $gtparts=@preg_split("/\./",$curgtlang);
176
-  $tmp=strtolower($gtparts[0]);
177
-  $lang=preg_replace("/\_/", "-", $tmp);
178
-  $charset=$gtparts[1];
173
+  $gtparts = @preg_split("/\./", $curgtlang);
174
+  $tmp = strtolower($gtparts[0]);
175
+  $lang = preg_replace("/\_/", "-", $tmp);
176
+  $charset = $gtparts[1];
179 177
 
180 178
   header("Content-Language: $lang");
181 179
   header("Content-Type: $mime; charset=$charset");
Please login to merge, or discard this patch.