Completed
Push — master ( 79d43d...8be713 )
by Angus
03:47
created
application/models/Site_Model.php 3 patches
Spacing   +33 added lines, -33 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
 abstract class Site_Model extends CI_Model {
4 4
 	public function __construct() {
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 	abstract public function isValidTitleURL(string $title_url) : bool;
17 17
 	abstract public function isValidChapter(string $chapter) : bool;
18 18
 
19
-	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE){
19
+	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE) {
20 20
 		$ch = curl_init();
21 21
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
22
-		curl_setopt($ch, CURLOPT_ENCODING , "gzip");
22
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
23 23
 
24 24
 		if($follow_redirect)        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
25 25
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
123 123
 				$chapterURLSegments = explode('/', $link);
124
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
125
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
124
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
125
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
126 126
 			}
127 127
 		} else {
128 128
 			//TODO: Throw ERRORS;
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 
182 182
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
183 183
 				$chapterURLSegments = explode('/', $link);
184
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
185
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
184
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
185
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
186 186
 			}
187 187
 		} else {
188 188
 			//TODO: Throw ERRORS;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		$chapter_parts = explode(':--:', $chapter);
225 225
 		return [
226
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
226
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
227 227
 			'number' => $chapter_parts[1]
228 228
 		];
229 229
 	}
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 		//Bato.to is annoying and locks stuff behind auth. See: https://github.com/DakuTree/manga-tracker/issues/14#issuecomment-233830855
240 240
 		$cookies = [
241 241
 			"lang_option={$title_lang}",
242
-			"member_id=" . $this->config->item('batoto_cookie_member_id'),
243
-			"pass_hash=" . $this->config->item('batoto_cookie_pass_hash')
242
+			"member_id=".$this->config->item('batoto_cookie_member_id'),
243
+			"pass_hash=".$this->config->item('batoto_cookie_pass_hash')
244 244
 		];
245 245
 		$data = $this->get_content($title_url, implode("; ", $cookies), "", TRUE);
246 246
 		if(!$data) {
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
 					preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)):?.*/', trim($chapter_element->nodeValue), $text);
273 273
 
274 274
 					$titleData['title']          = html_entity_decode(trim($xpath->query('//h1[@class="ipsType_pagetitle"]')->item(0)->nodeValue));
275
-					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter']);
275
+					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter']);
276 276
 
277 277
 					$dateString = $updated_element->nodeValue;
278 278
 					if($dateString == 'An hour ago') {
279 279
 						$dateString = '1 hour ago';
280 280
 					}
281
-					$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
281
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
282 282
 				} else {
283 283
 					log_message('error', "Batoto: Regex missing <td> ({$title_url})");
284 284
 					return NULL;
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		*/
327 327
 
328 328
 		$chapterData = [
329
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
329
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
330 330
 			'number' => ''
331 331
 		];
332 332
 
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 
367 367
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
368 368
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
369
-			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '') . substr($matchesT[0], 3, -4);
369
+			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '').substr($matchesT[0], 3, -4);
370 370
 
371 371
 			$data = preg_replace('/^[\S\s]*(<dl class=\'chapter-list\'>[\S\s]*<\/dl>)[\S\s]*$/', '$1', $data);
372 372
 			preg_match_all('/<dd>[\s\S]+?(?=<\/dd>)<\/dd>/', $data, $matches);
373 373
 			$latest_chapter_html = array_pop($matches[0]);
374 374
 
375 375
 			preg_match('/\/chapters\/([^"]+)/', $latest_chapter_html, $matches);
376
-			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url)+1);
376
+			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url) + 1);
377 377
 			//FIXME: THIS IS A TEMP FIX, SEE https://github.com/DakuTree/manga-tracker/issues/58
378 378
 			if(!$titleData['latest_chapter']) {
379 379
 				log_message('error', 'DynastyScans::getTitleData cannot parse title properly as it contains oneshot. || URL: '.$title_url);
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 			}
382 382
 
383 383
 			preg_match('/<small>released (.*)<\/small>/', $latest_chapter_html, $matches);
384
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
384
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
385 385
 		} elseif($title_parts[1] == '1') {
386 386
 			$data = $this->get_content('http://dynasty-scans.com/chapters/'.$title_url);
387 387
 
388 388
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
389 389
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
390
-			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
390
+			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
391 391
 
392 392
 			$titleData['latest_chapter'] = 'oneshot'; //This will never change
393 393
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
454 454
 
455 455
 				$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
456
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
456
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
457 457
 			}
458 458
 		} else {
459 459
 			//TODO: Throw ERRORS;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
512 512
 
513 513
 				$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
514
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
514
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
515 515
 			}
516 516
 		} else {
517 517
 			//TODO: Throw ERRORS;
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
 				$titleData['title'] = trim((string) $xml->channel->title);
577 577
 
578 578
 				$chapterURLSegments = explode('/', ((string) $xml->channel->item[0]->link));
579
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
580
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
579
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
580
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
581 581
 			}
582 582
 		} else {
583 583
 			//TODO: Throw ERRORS;
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
 
657 657
 					$link = (string) $nodes_chapter[0]->getAttribute('href');
658 658
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
659
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
660
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
659
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
660
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
661 661
 				}
662 662
 			} else {
663 663
 				//TODO: Throw ERRORS;
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 		$chapter_parts = explode('/', $chapter);
693 693
 		return [
694 694
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}",
695
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
695
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
696 696
 		];
697 697
 	}
698 698
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 
724 724
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
725 725
 				$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link);
726
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
726
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
727 727
 			}
728 728
 		} else {
729 729
 			//TODO: Throw ERRORS;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
783 783
 				$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', $link);
784
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
784
+				$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
785 785
 			} else {
786 786
 				log_message('error', "GameOfScanlation: Unable to find nodes.");
787 787
 				return NULL;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
842 842
 				$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', $link);
843
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($nodes_latest[0]->getAttribute('title'), 13)));
843
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($nodes_latest[0]->getAttribute('title'), 13)));
844 844
 			} else {
845 845
 				log_message('error', "MangaCow: Unable to find nodes.");
846 846
 				return NULL;
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		$chapter_parts = explode('/', $chapter);
875 875
 		return [
876 876
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}",
877
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
877
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
878 878
 		];
879 879
 	}
880 880
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 			//SOO sometimes uses volume groups which are above recent chapters (if they haven't been grouped yet), so make sure we check for both.
900 900
 			$nodes_row   = $xpath->query("//div[@class='list']/div[@class='group']/div[@class='title' and text() = 'Chapters']/following-sibling::div[@class='element'][1]");
901 901
 			if($nodes_row->length !== 1) {
902
-				$nodes_row   = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]");
902
+				$nodes_row = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]");
903 903
 			}
904 904
 			if($nodes_title->length === 1 && $nodes_row->length === 1) {
905 905
 				$titleData['title'] = trim($nodes_title[0]->textContent);
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 
911 911
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
912 912
 				$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link);
913
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
913
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
914 914
 			}
915 915
 		} else {
916 916
 			//TODO: Throw ERRORS;
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 		$chapter_parts = explode('/', $chapter);
942 942
 		return [
943 943
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}",
944
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
944
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
945 945
 		];
946 946
 	}
947 947
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			$nodes_title = $xpath->query("//div[@class='large comic']/h1[@class='title']");
965 965
 			$nodes_row   = $xpath->query("//div[@class='list']/div[@class='group']/div[@class='title' and text() = 'Chapters']/following-sibling::div[@class='element'][1]");
966 966
 			if($nodes_row->length !== 1) {
967
-				$nodes_row   = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]");
967
+				$nodes_row = $xpath->query("//div[@class='list']/div[@class='group'][1]/div[@class='element'][1]");
968 968
 			}
969 969
 			if($nodes_title->length === 1 && $nodes_row->length === 1) {
970 970
 				$titleData['title'] = trim($nodes_title[0]->textContent);
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 
976 976
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
977 977
 				$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link);
978
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
978
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
979 979
 			}
980 980
 		} else {
981 981
 			//TODO: Throw ERRORS;
Please login to merge, or discard this patch.
Braces   +88 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,15 +16,21 @@  discard block
 block discarded – undo
16 16
 	abstract public function isValidTitleURL(string $title_url) : bool;
17 17
 	abstract public function isValidChapter(string $chapter) : bool;
18 18
 
19
-	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE){
19
+	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE) {
20 20
 		$ch = curl_init();
21 21
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
22 22
 		curl_setopt($ch, CURLOPT_ENCODING , "gzip");
23 23
 
24
-		if($follow_redirect)        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
24
+		if($follow_redirect) {
25
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
26
+		}
25 27
 
26
-		if(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
27
-		if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
28
+		if(!empty($cookie_string)) {
29
+			curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
30
+		}
31
+		if(!empty($cookiejar_path)) {
32
+			curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
33
+		}
28 34
 
29 35
 		//Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff.
30 36
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2824.0 Safari/537.36');
@@ -78,12 +84,16 @@  discard block
 block discarded – undo
78 84
 
79 85
 	public function isValidTitleURL(string $title_url) : bool {
80 86
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
81
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
87
+		if(!$success) {
88
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
89
+		}
82 90
 		return $success;
83 91
 	}
84 92
 	public function isValidChapter(string $chapter) : bool {
85 93
 		$success = (bool) preg_match('/^(?:v[0-9a-zA-Z]+\/)?c[0-9\.]+$/', $chapter);
86
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
94
+		if(!$success) {
95
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
96
+		}
87 97
 		return $success;
88 98
 	}
89 99
 
@@ -139,12 +149,16 @@  discard block
 block discarded – undo
139 149
 
140 150
 	public function isValidTitleURL(string $title_url) : bool {
141 151
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
142
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
152
+		if(!$success) {
153
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
154
+		}
143 155
 		return $success;
144 156
 	}
145 157
 	public function isValidChapter(string $chapter) : bool {
146 158
 		$success = (bool) preg_match('/^(?:v[0-9]+\/)?c[0-9]+(?:\.[0-9]+)?$/', $chapter);
147
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
159
+		if(!$success) {
160
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
161
+		}
148 162
 		return $success;
149 163
 	}
150 164
 
@@ -206,7 +220,9 @@  discard block
 block discarded – undo
206 220
 
207 221
 	public function isValidTitleURL(string $title_url) : bool {
208 222
 		$success = (bool) preg_match('/^[0-9]+:--:(?:English|Spanish|French|German|Portuguese|Turkish|Indonesian|Greek|Filipino|Italian|Polish|Thai|Malay|Hungarian|Romanian|Arabic|Hebrew|Russian|Vietnamese|Dutch)$/', $title_url);
209
-		if(!$success) log_message('error', "Invalid Title URL (Batoto): {$title_url}");
223
+		if(!$success) {
224
+			log_message('error', "Invalid Title URL (Batoto): {$title_url}");
225
+		}
210 226
 		return $success;
211 227
 	}
212 228
 	public function isValidChapter(string $chapter) : bool {
@@ -214,7 +230,9 @@  discard block
 block discarded – undo
214 230
 		//       Preferably we'd just use /^[0-9a-z]+:--:(v[0-9]+\/)?c[0-9]+(\.[0-9]+)?$/
215 231
 
216 232
 		$success = (bool) preg_match('/^[0-9a-z]+:--:.+$/', $chapter);
217
-		if(!$success) log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
233
+		if(!$success) {
234
+			log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
235
+		}
218 236
 		return $success;
219 237
 	}
220 238
 
@@ -307,12 +325,16 @@  discard block
 block discarded – undo
307 325
 
308 326
 	public function isValidTitleURL(string $title_url) : bool {
309 327
 		$success = (bool) preg_match('/^[a-z0-9_]+:--:(?:0|1)$/', $title_url);
310
-		if(!$success) log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
328
+		if(!$success) {
329
+			log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
330
+		}
311 331
 		return $success;
312 332
 	}
313 333
 	public function isValidChapter(string $chapter) : bool {
314 334
 		$success = (bool) preg_match('/^[0-9a-z_]+$/', $chapter);
315
-		if(!$success) log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
335
+		if(!$success) {
336
+			log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
337
+		}
316 338
 		return $success;
317 339
 	}
318 340
 
@@ -418,12 +440,16 @@  discard block
 block discarded – undo
418 440
 
419 441
 	public function isValidTitleURL(string $title_url) : bool {
420 442
 		$success = (bool) preg_match('/^[a-z0-9-]+$/', $title_url);
421
-		if(!$success) log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
443
+		if(!$success) {
444
+			log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
445
+		}
422 446
 		return $success;
423 447
 	}
424 448
 	public function isValidChapter(string $chapter) : bool {
425 449
 		$success = (bool) preg_match('/^[0-9]+$/', $chapter);
426
-		if(!$success) log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
450
+		if(!$success) {
451
+			log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
452
+		}
427 453
 		return $success;
428 454
 	}
429 455
 
@@ -470,12 +496,16 @@  discard block
 block discarded – undo
470 496
 
471 497
 	public function isValidTitleURL(string $title_url) : bool {
472 498
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
473
-		if(!$success) log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
499
+		if(!$success) {
500
+			log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
501
+		}
474 502
 		return $success;
475 503
 	}
476 504
 	public function isValidChapter(string $chapter) : bool {
477 505
 		$success = (bool) preg_match('/^(.*?)\/[0-9]+$/', $chapter);
478
-		if(!$success) log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
506
+		if(!$success) {
507
+			log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
508
+		}
479 509
 		return $success;
480 510
 	}
481 511
 
@@ -544,12 +574,16 @@  discard block
 block discarded – undo
544 574
 
545 575
 	public function isValidTitleURL(string $title_url) : bool {
546 576
 		$success = (bool) preg_match('/^[0-9]+:--:(?:en|zh-hant|zh-hans|th|id):--:[a-z0-9-]+:--:(?:drama|fantasy|comedy|action|slice-of-life|romance|superhero|thriller|sports|sci-fi)$/', $title_url);
547
-		if(!$success) log_message('error', "Invalid Title URL (WebToons): {$title_url}");
577
+		if(!$success) {
578
+			log_message('error', "Invalid Title URL (WebToons): {$title_url}");
579
+		}
548 580
 		return $success;
549 581
 	}
550 582
 	public function isValidChapter(string $chapter) : bool {
551 583
 		$success = (bool) preg_match('/^[0-9]+:--:.*$/', $chapter);
552
-		if(!$success) log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
584
+		if(!$success) {
585
+			log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
586
+		}
553 587
 		return $success;
554 588
 	}
555 589
 
@@ -606,12 +640,16 @@  discard block
 block discarded – undo
606 640
 
607 641
 	public function isValidTitleURL(string $title_url) : bool {
608 642
 		$success = (bool) preg_match('/^[A-Za-z0-9-]+/', $title_url);
609
-		if(!$success) log_message('error', "Invalid Title URL (KissManga): {$title_url}");
643
+		if(!$success) {
644
+			log_message('error', "Invalid Title URL (KissManga): {$title_url}");
645
+		}
610 646
 		return $success;
611 647
 	}
612 648
 	public function isValidChapter(string $chapter) : bool {
613 649
 		$success = (bool) preg_match('/^.*?:--:[0-9]+$/', $chapter);
614
-		if(!$success) log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
650
+		if(!$success) {
651
+			log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
652
+		}
615 653
 		return $success;
616 654
 	}
617 655
 
@@ -678,12 +716,16 @@  discard block
 block discarded – undo
678 716
 
679 717
 	public function isValidTitleURL(string $title_url) : bool {
680 718
 		$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url);
681
-		if(!$success) log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
719
+		if(!$success) {
720
+			log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
721
+		}
682 722
 		return $success;
683 723
 	}
684 724
 	public function isValidChapter(string $chapter) : bool {
685 725
 		$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter);
686
-		if(!$success) log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
726
+		if(!$success) {
727
+			log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
728
+		}
687 729
 		return $success;
688 730
 	}
689 731
 
@@ -740,12 +782,16 @@  discard block
 block discarded – undo
740 782
 
741 783
 	public function isValidTitleURL(string $title_url) : bool {
742 784
 		$success = (bool) preg_match('/^[a-z0-9-]+/', $title_url);
743
-		if(!$success) log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
785
+		if(!$success) {
786
+			log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
787
+		}
744 788
 		return $success;
745 789
 	}
746 790
 	public function isValidChapter(string $chapter) : bool {
747 791
 		$success = (bool) preg_match('/^[a-z0-9\.-]+$/', $chapter);
748
-		if(!$success) log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
792
+		if(!$success) {
793
+			log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
794
+		}
749 795
 		return $success;
750 796
 	}
751 797
 
@@ -801,12 +847,16 @@  discard block
 block discarded – undo
801 847
 
802 848
 	public function isValidTitleURL(string $title_url) : bool {
803 849
 		$success = (bool) preg_match('/^[a-zA-Z0-9_]+/', $title_url);
804
-		if(!$success) log_message('error', "Invalid Title URL (MangaCow): {$title_url}");
850
+		if(!$success) {
851
+			log_message('error', "Invalid Title URL (MangaCow): {$title_url}");
852
+		}
805 853
 		return $success;
806 854
 	}
807 855
 	public function isValidChapter(string $chapter) : bool {
808 856
 		$success = (bool) preg_match('/^[0-9]+$/', $chapter);
809
-		if(!$success) log_message('error', 'Invalid Chapter (MangaCow): '.$chapter);
857
+		if(!$success) {
858
+			log_message('error', 'Invalid Chapter (MangaCow): '.$chapter);
859
+		}
810 860
 		return $success;
811 861
 	}
812 862
 
@@ -860,12 +910,16 @@  discard block
 block discarded – undo
860 910
 
861 911
 	public function isValidTitleURL(string $title_url) : bool {
862 912
 		$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url);
863
-		if(!$success) log_message('error', "Invalid Title URL (SeaOtterScans): {$title_url}");
913
+		if(!$success) {
914
+			log_message('error', "Invalid Title URL (SeaOtterScans): {$title_url}");
915
+		}
864 916
 		return $success;
865 917
 	}
866 918
 	public function isValidChapter(string $chapter) : bool {
867 919
 		$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter);
868
-		if(!$success) log_message('error', 'Invalid Chapter (SeaOtterScans): '.$chapter);
920
+		if(!$success) {
921
+			log_message('error', 'Invalid Chapter (SeaOtterScans): '.$chapter);
922
+		}
869 923
 		return $success;
870 924
 	}
871 925
 
@@ -927,12 +981,16 @@  discard block
 block discarded – undo
927 981
 
928 982
 	public function isValidTitleURL(string $title_url) : bool {
929 983
 		$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url);
930
-		if(!$success) log_message('error', "Invalid Title URL (HelveticaScans): {$title_url}");
984
+		if(!$success) {
985
+			log_message('error', "Invalid Title URL (HelveticaScans): {$title_url}");
986
+		}
931 987
 		return $success;
932 988
 	}
933 989
 	public function isValidChapter(string $chapter) : bool {
934 990
 		$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter);
935
-		if(!$success) log_message('error', 'Invalid Chapter (HelveticaScans): '.$chapter);
991
+		if(!$success) {
992
+			log_message('error', 'Invalid Chapter (HelveticaScans): '.$chapter);
993
+		}
936 994
 		return $success;
937 995
 	}
938 996
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +23 added lines, -23 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
 abstract class Site_Model extends CI_Model {
4 4
 	public function __construct() {
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
105 105
 
106 106
 			$dom = new DOMDocument();
107
-			libxml_use_internal_errors(true);
107
+			libxml_use_internal_errors(TRUE);
108 108
 			$dom->loadHTML($data);
109
-			libxml_use_internal_errors(false);
109
+			libxml_use_internal_errors(FALSE);
110 110
 
111 111
 			$xpath = new DOMXPath($dom);
112 112
 
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
166 166
 
167 167
 			$dom = new DOMDocument();
168
-			libxml_use_internal_errors(true);
168
+			libxml_use_internal_errors(TRUE);
169 169
 			$dom->loadHTML($data);
170
-			libxml_use_internal_errors(false);
170
+			libxml_use_internal_errors(FALSE);
171 171
 
172 172
 			$xpath = new DOMXPath($dom);
173 173
 			$nodes_title = $xpath->query("//meta[@property='og:title']");
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 		if(strpos($data, '>Register now<') === FALSE) {
255 255
 			//Auth was successful
256 256
 			$dom = new DOMDocument();
257
-			libxml_use_internal_errors(true);
257
+			libxml_use_internal_errors(TRUE);
258 258
 			$dom->loadHTML($data);
259
-			libxml_use_internal_errors(false);
259
+			libxml_use_internal_errors(FALSE);
260 260
 
261 261
 			$xpath = new DOMXPath($dom);
262 262
 			$nodes = $xpath->query("(//div/div)[last()]/table/tbody/tr[2]");
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
438 438
 
439 439
 			$dom = new DOMDocument();
440
-			libxml_use_internal_errors(true);
440
+			libxml_use_internal_errors(TRUE);
441 441
 			$dom->loadHTML($data);
442
-			libxml_use_internal_errors(false);
442
+			libxml_use_internal_errors(FALSE);
443 443
 
444 444
 			$xpath = new DOMXPath($dom);
445 445
 
@@ -496,9 +496,9 @@  discard block
 block discarded – undo
496 496
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
497 497
 
498 498
 			$dom = new DOMDocument();
499
-			libxml_use_internal_errors(true);
499
+			libxml_use_internal_errors(TRUE);
500 500
 			$dom->loadHTML($data);
501
-			libxml_use_internal_errors(false);
501
+			libxml_use_internal_errors(FALSE);
502 502
 
503 503
 			$xpath = new DOMXPath($dom);
504 504
 
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
 				$data = preg_replace('/^[\S\s]*(<div id="leftside">[\S\s]*)<div id="rightside">[\S\s]*$/', '$1', $data);
641 641
 
642 642
 				$dom = new DOMDocument();
643
-				libxml_use_internal_errors(true);
643
+				libxml_use_internal_errors(TRUE);
644 644
 				$dom->loadHTML($data);
645
-				libxml_use_internal_errors(false);
645
+				libxml_use_internal_errors(FALSE);
646 646
 
647 647
 				$xpath = new DOMXPath($dom);
648 648
 
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 			$data = preg_replace('/^[\S\s]*(<article>[\S\s]*)<\/article>[\S\s]*$/', '$1', $data);
707 707
 
708 708
 			$dom = new DOMDocument();
709
-			libxml_use_internal_errors(true);
709
+			libxml_use_internal_errors(TRUE);
710 710
 			$dom->loadHTML($data);
711
-			libxml_use_internal_errors(false);
711
+			libxml_use_internal_errors(FALSE);
712 712
 
713 713
 			$xpath = new DOMXPath($dom);
714 714
 
@@ -765,9 +765,9 @@  discard block
 block discarded – undo
765 765
 			//$data = preg_replace('/^[\S\s]*(<ol[\S\s]*)<\/ol>[\S\s]*$/', '$1', $data);
766 766
 
767 767
 			$dom = new DOMDocument();
768
-			libxml_use_internal_errors(true);
768
+			libxml_use_internal_errors(TRUE);
769 769
 			$dom->loadHTML($data);
770
-			libxml_use_internal_errors(false);
770
+			libxml_use_internal_errors(FALSE);
771 771
 
772 772
 			$xpath = new DOMXPath($dom);
773 773
 
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
 		$data = $this->get_content($fullURL);
825 825
 		if(strpos($data, '404 Page Not Found') === FALSE) {
826 826
 			$dom = new DOMDocument();
827
-			libxml_use_internal_errors(true);
827
+			libxml_use_internal_errors(TRUE);
828 828
 			$dom->loadHTML($data);
829
-			libxml_use_internal_errors(false);
829
+			libxml_use_internal_errors(FALSE);
830 830
 
831 831
 			$xpath = new DOMXPath($dom);
832 832
 
@@ -888,9 +888,9 @@  discard block
 block discarded – undo
888 888
 			$data = preg_replace('/^[\S\s]*(<article[\S\s]*)<\/article>[\S\s]*$/', '$1', $data);
889 889
 
890 890
 			$dom = new DOMDocument();
891
-			libxml_use_internal_errors(true);
891
+			libxml_use_internal_errors(TRUE);
892 892
 			$dom->loadHTML($data);
893
-			libxml_use_internal_errors(false);
893
+			libxml_use_internal_errors(FALSE);
894 894
 
895 895
 			$xpath = new DOMXPath($dom);
896 896
 
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 			$data = preg_replace('/^[\S\s]*(<article[\S\s]*)<\/article>[\S\s]*$/', '$1', $data);
956 956
 
957 957
 			$dom = new DOMDocument();
958
-			libxml_use_internal_errors(true);
958
+			libxml_use_internal_errors(TRUE);
959 959
 			$dom->loadHTML($data);
960
-			libxml_use_internal_errors(false);
960
+			libxml_use_internal_errors(FALSE);
961 961
 
962 962
 			$xpath = new DOMXPath($dom);
963 963
 
Please login to merge, or discard this patch.