Completed
Push — master ( 0f9479...65c76e )
by Angus
02:49
created
application/core/MY_Controller.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 	protected $footer_data = array();
7 7
 	public    $global_data = array();
8 8
 
9
-	public function __construct(){
9
+	public function __construct() {
10 10
 		parent::__construct();
11 11
 
12 12
 		//FIXME: This is pretty much a phpUnit hack. Without it phpUnit fails here. We need a proper way to fake user/admin testing.
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
80 80
 	public function __construct() {
81 81
 		parent::__construct();
82 82
 
83
-		if($this->ion_auth->logged_in()) redirect('/');
83
+		if($this->ion_auth->logged_in()) {
84
+			redirect('/');
85
+		}
84 86
 	}
85 87
 }
86 88
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 	protected $footer_data = array();
7 7
 	public    $global_data = array();
8 8
 
9
-	public function __construct(){
9
+	public function __construct() {
10 10
 		parent::__construct();
11 11
 
12 12
 		//FIXME: This is pretty much a phpUnit hack. Without it phpUnit fails here. We need a proper way to fake user/admin testing.
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 
19 19
 		$this->global_data['theme'] = $this->User_Options->get('theme');
20 20
 		$css_path = "css/main.{$this->User_Options->get('theme')}";
21
-		$this->global_data['complied_css_path'] = asset_url()."{$css_path}.".filemtime(APPPATH . "../public/assets/{$css_path}.css").".css";
21
+		$this->global_data['complied_css_path'] = asset_url()."{$css_path}.".filemtime(APPPATH."../public/assets/{$css_path}.css").".css";
22 22
 
23 23
 		$js_path = 'js/compiled.min';
24
-		$this->global_data['complied_js_path']  = asset_url()."{$js_path}.".filemtime(APPPATH . "../public/assets/{$js_path}.js").".js";
24
+		$this->global_data['complied_js_path']  = asset_url()."{$js_path}.".filemtime(APPPATH."../public/assets/{$js_path}.js").".js";
25 25
 	}
26 26
 
27 27
 	public function _render_page(/*(array) $paths*/) : void {
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$json = is_array($json_input) ? json_encode($json_input) : $json_input;
46 46
 
47 47
 		$this->output->set_content_type('application/json', 'utf-8');
48
-		$this->_render_content($json,'json', $download, $filenamePrefix);
48
+		$this->_render_content($json, 'json', $download, $filenamePrefix);
49 49
 	}
50 50
 	public function _render_content(string $content, string $filenameExt, bool $download = FALSE, string $filenamePrefix = 'tracker') : void {
51 51
 		if($download) {
Please login to merge, or discard this patch.
application/libraries/Cacher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') or exit('No direct script access allowed');
2 2
 
3 3
 //Because we can't autoload the cache driver with params - https://forum.codeigniter.com/thread-62217-post-319687.html#pid319687
4 4
 class Cacher {
5 5
 	protected $CI;
6 6
 
7 7
 	public function __construct() {
8
-		$this->CI =& get_instance(); //grab an instance of CI
8
+		$this->CI = & get_instance(); //grab an instance of CI
9 9
 		$this->initiate_cache();
10 10
 	}
11 11
 
Please login to merge, or discard this patch.
application/models/Tracker/Tracker_Sites_Model.php 3 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 /**
4 4
  * Class Tracker_Sites_Model
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param bool   $firstGet
103 103
 	 * @return array|null [title,latest_chapter,last_updated,followed?]
104 104
 	 */
105
-	abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array;
105
+	abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array;
106 106
 
107 107
 	/**
108 108
 	 * Validates given $title_url against titleFormat.
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 			$ch = curl_init();
153 153
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
154
-			curl_setopt($ch, CURLOPT_ENCODING , "gzip");
154
+			curl_setopt($ch, CURLOPT_ENCODING, "gzip");
155 155
 			//curl_setopt($ch, CURLOPT_VERBOSE, 1);
156 156
 			curl_setopt($ch, CURLOPT_HEADER, 1);
157 157
 
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 			curl_setopt($ch, CURLOPT_URL, $url);
174 174
 
175 175
 			if($isPost) {
176
-				curl_setopt($ch,CURLOPT_POST, count($postFields));
177
-				curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields));
176
+				curl_setopt($ch, CURLOPT_POST, count($postFields));
177
+				curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
178 178
 			}
179 179
 
180 180
 			$response = curl_exec($ch);
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData)));
218 218
 			$cookieData = json_decode($result, TRUE);
219 219
 
220
-			$this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'],  31536000 /* 1 year, or until we renew it */);
220
+			$this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */);
221 221
 			$refresh = TRUE;
222 222
 		} else {
223 223
 			//Either site doesn't have CloudFlare or we have bypassed it. Either is good!
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
 				$dom = new DOMDocument();
268 268
 				libxml_use_internal_errors(TRUE);
269
-				$dom->loadHTML('<?xml encoding="utf-8" ?>' . $data);
269
+				$dom->loadHTML('<?xml encoding="utf-8" ?>'.$data);
270 270
 				libxml_use_internal_errors(FALSE);
271 271
 
272 272
 				$xpath = new DOMXPath($dom);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				$nodes_row   = $xpath->query($node_row_string);
275 275
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
276 276
 					$firstRow      = $nodes_row->item(0);
277
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
277
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
278 278
 
279 279
 					if($node_chapter_string !== '') {
280 280
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
 		$chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/)
463 463
 		return [
464 464
 			'url'    => $this->getChapterURL($title_url, $chapter),
465
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
465
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
466 466
 		];
467 467
 	}
468 468
 	public function getChapterURL(string $title_url, string $chapter) : string {
469 469
 		return "{$this->baseURL}/read/{$title_url}/{$chapter}/";
470 470
 	}
471 471
 
472
-	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array {
472
+	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array {
473 473
 		$titleData = [];
474 474
 
475 475
 		$jsonURL = $this->getJSONTitleURL($title_url);
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		return $this->getFullTitleURL($title_url).'/'.$chapter;
590 590
 	}
591 591
 
592
-	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array {
592
+	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array {
593 593
 		$titleData = [];
594 594
 
595 595
 		$fullURL = $this->getFullTitleURL($title_url);
Please login to merge, or discard this patch.
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -114,7 +114,9 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	final public function isValidTitleURL(string $title_url) : bool {
116 116
 		$success = (bool) preg_match($this->titleFormat, $title_url);
117
-		if(!$success) log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
117
+		if(!$success) {
118
+			log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
119
+		}
118 120
 		return $success;
119 121
 	}
120 122
 
@@ -128,7 +130,9 @@  discard block
 block discarded – undo
128 130
 	 */
129 131
 	final public function isValidChapter(string $chapter) : bool {
130 132
 		$success = (bool) preg_match($this->chapterFormat, $chapter);
131
-		if(!$success) log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
133
+		if(!$success) {
134
+			log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
135
+		}
132 136
 		return $success;
133 137
 	}
134 138
 
@@ -155,14 +159,20 @@  discard block
 block discarded – undo
155 159
 			//curl_setopt($ch, CURLOPT_VERBOSE, 1);
156 160
 			curl_setopt($ch, CURLOPT_HEADER, 1);
157 161
 
158
-			if($follow_redirect)        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
162
+			if($follow_redirect) {
163
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
164
+			}
159 165
 
160 166
 			if(($cookies = $this->cache->get("cloudflare_{$this->site}"))) {
161 167
 				$cookie_string .= "; {$cookies}";
162 168
 			}
163 169
 
164
-			if(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
165
-			if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
170
+			if(!empty($cookie_string)) {
171
+				curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
172
+			}
173
+			if(!empty($cookiejar_path)) {
174
+				curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
175
+			}
166 176
 
167 177
 			//Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff.
168 178
 			curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -190,7 +200,9 @@  discard block
 block discarded – undo
190 200
 			$body        = substr($response, $header_size);
191 201
 			curl_close($ch);
192 202
 
193
-			if($status_code === 503) $refresh = $this->handleCloudFlare($url, $body);
203
+			if($status_code === 503) {
204
+				$refresh = $this->handleCloudFlare($url, $body);
205
+			}
194 206
 		}
195 207
 
196 208
 		return [
@@ -400,8 +412,12 @@  discard block
 block discarded – undo
400 412
 		$status = FALSE;
401 413
 
402 414
 		//Make sure we have a volume element
403
-		if(count($oldChapterSegments) === 1) array_unshift($oldChapterSegments, 'v0');
404
-		if(count($newChapterSegments) === 1) array_unshift($newChapterSegments, 'v0');
415
+		if(count($oldChapterSegments) === 1) {
416
+			array_unshift($oldChapterSegments, 'v0');
417
+		}
418
+		if(count($newChapterSegments) === 1) {
419
+			array_unshift($newChapterSegments, 'v0');
420
+		}
405 421
 
406 422
 		$oldCount = count($oldChapterSegments);
407 423
 		$newCount = count($newChapterSegments);
@@ -414,8 +430,12 @@  discard block
 block discarded – undo
414 430
 				$newVolume = substr(array_shift($newChapterSegments), 1);
415 431
 
416 432
 				//Forcing volume to 0 as TBD might not be the latest (although it can be, but that is covered by other checks)
417
-				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $oldVolume = 0;
418
-				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $newVolume = 0;
433
+				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
434
+					$oldVolume = 0;
435
+				}
436
+				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
437
+					$newVolume = 0;
438
+				}
419 439
 
420 440
 				$oldVolume = floatval($oldVolume);
421 441
 				$newVolume = floatval($newVolume);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed');
2 2
 
3 3
 /**
4 4
  * Class Tracker_Sites_Model
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	final private function handleCloudFlare(string $url, string $body) : bool {
204 204
 		$refresh = FALSE;
205 205
 
206
-		if(strpos($body, 'DDoS protection by Cloudflare') !== false) {
206
+		if(strpos($body, 'DDoS protection by Cloudflare') !== FALSE) {
207 207
 			if(!$this->hasCloudFlare) {
208 208
 				//TODO: Site appears to have enabled CloudFlare, disable it and contact admin.
209 209
 				//      We'll continue to bypass CloudFlare as this may occur in a loop.
Please login to merge, or discard this patch.
application/models/Tracker/Sites/LHTranslation.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 class LHTranslation extends Base_Site_Model {
4 4
 	public $titleFormat   = '/^[a-zA-Z0-9_\-.]+$/';
5 5
 	public $chapterFormat = '/^[0-9\.]+$/';
6 6
 
7 7
 	public function getFullTitleURL(string $title_url) : string {
8
-		$title_url = str_replace('.','', $title_url);
8
+		$title_url = str_replace('.', '', $title_url);
9 9
 		return "http://lhtranslation.com/{$title_url}";
10 10
 	}
11 11
 
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
 		];
18 18
 	}
19 19
 
20
-	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array {
20
+	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array {
21 21
 		$titleData = [];
22 22
 
23
-		$title_url = str_replace('.','', $title_url);
23
+		$title_url = str_replace('.', '', $title_url);
24 24
 		$title_url = $this->_fixTitle($title_url);
25 25
 		$fullURL = "http://lhtranslation.com/{$title_url}/feed/";
26 26
 		$content = $this->get_content($fullURL);
27 27
 
28 28
 		$data = $content['body'];
29 29
 		$xml = simplexml_load_string($data) or die("Error: Cannot create object");
30
-		if(((string) $xml->{'channel'}->title) !== 'Comments on: '){
30
+		if(((string) $xml->{'channel'}->title) !== 'Comments on: ') {
31 31
 			if(isset($xml->{'channel'}->item[0])) {
32 32
 				if($title = (string) $xml->{'channel'}->item[0]->category) {
33 33
 					$titleData['title'] = trim($title);
Please login to merge, or discard this patch.