Completed
Push — master ( abab0f...58f85f )
by Angus
03:27
created
application/models/Site_Model.php 3 patches
Spacing   +27 added lines, -27 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
 class Site_Model extends CI_Model {
4 4
 	public function __construct() {
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 	public function isValidTitleURL(string $title_url) : bool {}
17 17
 	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
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 
118 118
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
119 119
 				$chapterURLSegments = explode('/', $link);
120
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
121
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
120
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
121
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
122 122
 			}
123 123
 		} else {
124 124
 			//TODO: Throw ERRORS;
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 
178 178
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
179 179
 				$chapterURLSegments = explode('/', $link);
180
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
181
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
180
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
181
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
182 182
 			}
183 183
 		} else {
184 184
 			//TODO: Throw ERRORS;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$chapter_parts = explode(':--:', $chapter);
221 221
 		return [
222
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
222
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
223 223
 			'number' => $chapter_parts[1]
224 224
 		];
225 225
 	}
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		//Bato.to is annoying and locks stuff behind auth. See: https://github.com/DakuTree/manga-tracker/issues/14#issuecomment-233830855
236 236
 		$cookies = [
237 237
 			"lang_option={$title_lang}",
238
-			"member_id=" . $this->config->item('batoto_cookie_member_id'),
239
-			"pass_hash=" . $this->config->item('batoto_cookie_pass_hash')
238
+			"member_id=".$this->config->item('batoto_cookie_member_id'),
239
+			"pass_hash=".$this->config->item('batoto_cookie_pass_hash')
240 240
 		];
241 241
 		$data = $this->get_content($title_url, implode("; ", $cookies), "", TRUE);
242 242
 		if(!$data) {
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
 					preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)):?.*/', trim($chapter_element->nodeValue), $text);
269 269
 
270 270
 					$titleData['title']          = html_entity_decode(trim($xpath->query('//h1[@class="ipsType_pagetitle"]')->item(0)->nodeValue));
271
-					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter']);
271
+					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter']);
272 272
 
273 273
 					$dateString = $updated_element->nodeValue;
274 274
 					if($dateString == 'An hour ago') {
275 275
 						$dateString = '1 hour ago';
276 276
 					}
277
-					$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
277
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
278 278
 				} else {
279 279
 					log_message('error', "Batoto: Regex missing <td> ({$title_url})");
280 280
 					return NULL;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		*/
323 323
 
324 324
 		$chapterData = [
325
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
325
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
326 326
 			'number' => ''
327 327
 		];
328 328
 
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
 
363 363
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
364 364
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
365
-			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '') . substr($matchesT[0], 3, -4);
365
+			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '').substr($matchesT[0], 3, -4);
366 366
 
367 367
 			$data = preg_replace('/^[\S\s]*(<dl class=\'chapter-list\'>[\S\s]*<\/dl>)[\S\s]*$/', '$1', $data);
368 368
 			preg_match_all('/<dd>[\s\S]+?(?=<\/dd>)<\/dd>/', $data, $matches);
369 369
 			$latest_chapter_html = array_pop($matches[0]);
370 370
 
371 371
 			preg_match('/\/chapters\/([^"]+)/', $latest_chapter_html, $matches);
372
-			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url)+1);
372
+			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url) + 1);
373 373
 			//FIXME: THIS IS A TEMP FIX, SEE https://github.com/DakuTree/manga-tracker/issues/58
374 374
 			if(!$titleData['latest_chapter']) {
375 375
 				log_message('error', 'DynastyScans::getTitleData cannot parse title properly as it contains oneshot. || URL: '.$title_url);
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
 			}
378 378
 
379 379
 			preg_match('/<small>released (.*)<\/small>/', $latest_chapter_html, $matches);
380
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
380
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
381 381
 		} elseif($title_parts[1] == '1') {
382 382
 			$data = $this->get_content('http://dynasty-scans.com/chapters/'.$title_url);
383 383
 
384 384
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
385 385
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
386
-			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
386
+			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
387 387
 
388 388
 			$titleData['latest_chapter'] = 'oneshot'; //This will never change
389 389
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
450 450
 
451 451
 				$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
452
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
452
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
453 453
 			}
454 454
 		} else {
455 455
 			//TODO: Throw ERRORS;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
508 508
 
509 509
 				$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
510
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
510
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
511 511
 			}
512 512
 		} else {
513 513
 			//TODO: Throw ERRORS;
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 				$titleData['title'] = trim((string) $xml->channel->title);
573 573
 
574 574
 				$chapterURLSegments = explode('/', ((string) $xml->channel->item[0]->link));
575
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
576
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
575
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
576
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
577 577
 			}
578 578
 		} else {
579 579
 			//TODO: Throw ERRORS;
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 
653 653
 					$link = (string) $nodes_chapter[0]->getAttribute('href');
654 654
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
655
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
656
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
655
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
656
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
657 657
 				}
658 658
 			} else {
659 659
 				//TODO: Throw ERRORS;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 		$chapter_parts = explode('/', $chapter);
689 689
 		return [
690 690
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}",
691
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
691
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
692 692
 		];
693 693
 	}
694 694
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 
720 720
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
721 721
 				$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link);
722
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
722
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
723 723
 			}
724 724
 		} else {
725 725
 			//TODO: Throw ERRORS;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 
778 778
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
779 779
 				$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', $link);
780
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
780
+				$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
781 781
 			} else {
782 782
 				log_message('error', "GameOfScanlation: Unable to find nodes.");
783 783
 				return NULL;
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 
837 837
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
838 838
 				$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', $link);
839
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($nodes_latest[0]->getAttribute('title'), 13)));
839
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($nodes_latest[0]->getAttribute('title'), 13)));
840 840
 			} else {
841 841
 				log_message('error', "MangaCow: Unable to find nodes.");
842 842
 				return NULL;
Please login to merge, or discard this patch.
Braces   +76 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,15 +16,21 @@  discard block
 block discarded – undo
16 16
 	public function isValidTitleURL(string $title_url) : bool {}
17 17
 	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');
@@ -74,12 +80,16 @@  discard block
 block discarded – undo
74 80
 
75 81
 	public function isValidTitleURL(string $title_url) : bool {
76 82
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
77
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
83
+		if(!$success) {
84
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
85
+		}
78 86
 		return $success;
79 87
 	}
80 88
 	public function isValidChapter(string $chapter) : bool {
81 89
 		$success = (bool) preg_match('/^(?:v[0-9a-zA-Z]+\/)?c[0-9\.]+$/', $chapter);
82
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
90
+		if(!$success) {
91
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
92
+		}
83 93
 		return $success;
84 94
 	}
85 95
 
@@ -135,12 +145,16 @@  discard block
 block discarded – undo
135 145
 
136 146
 	public function isValidTitleURL(string $title_url) : bool {
137 147
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
138
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
148
+		if(!$success) {
149
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
150
+		}
139 151
 		return $success;
140 152
 	}
141 153
 	public function isValidChapter(string $chapter) : bool {
142 154
 		$success = (bool) preg_match('/^(?:v[0-9]+\/)?c[0-9]+(?:\.[0-9]+)?$/', $chapter);
143
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
155
+		if(!$success) {
156
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
157
+		}
144 158
 		return $success;
145 159
 	}
146 160
 
@@ -202,7 +216,9 @@  discard block
 block discarded – undo
202 216
 
203 217
 	public function isValidTitleURL(string $title_url) : bool {
204 218
 		$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);
205
-		if(!$success) log_message('error', "Invalid Title URL (Batoto): {$title_url}");
219
+		if(!$success) {
220
+			log_message('error', "Invalid Title URL (Batoto): {$title_url}");
221
+		}
206 222
 		return $success;
207 223
 	}
208 224
 	public function isValidChapter(string $chapter) : bool {
@@ -210,7 +226,9 @@  discard block
 block discarded – undo
210 226
 		//       Preferably we'd just use /^[0-9a-z]+:--:(v[0-9]+\/)?c[0-9]+(\.[0-9]+)?$/
211 227
 
212 228
 		$success = (bool) preg_match('/^[0-9a-z]+:--:.+$/', $chapter);
213
-		if(!$success) log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
229
+		if(!$success) {
230
+			log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
231
+		}
214 232
 		return $success;
215 233
 	}
216 234
 
@@ -303,12 +321,16 @@  discard block
 block discarded – undo
303 321
 
304 322
 	public function isValidTitleURL(string $title_url) : bool {
305 323
 		$success = (bool) preg_match('/^[a-z0-9_]+:--:(?:0|1)$/', $title_url);
306
-		if(!$success) log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
324
+		if(!$success) {
325
+			log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
326
+		}
307 327
 		return $success;
308 328
 	}
309 329
 	public function isValidChapter(string $chapter) : bool {
310 330
 		$success = (bool) preg_match('/^[0-9a-z_]+$/', $chapter);
311
-		if(!$success) log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
331
+		if(!$success) {
332
+			log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
333
+		}
312 334
 		return $success;
313 335
 	}
314 336
 
@@ -414,12 +436,16 @@  discard block
 block discarded – undo
414 436
 
415 437
 	public function isValidTitleURL(string $title_url) : bool {
416 438
 		$success = (bool) preg_match('/^[a-z0-9-]+$/', $title_url);
417
-		if(!$success) log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
439
+		if(!$success) {
440
+			log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
441
+		}
418 442
 		return $success;
419 443
 	}
420 444
 	public function isValidChapter(string $chapter) : bool {
421 445
 		$success = (bool) preg_match('/^[0-9]+$/', $chapter);
422
-		if(!$success) log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
446
+		if(!$success) {
447
+			log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
448
+		}
423 449
 		return $success;
424 450
 	}
425 451
 
@@ -466,12 +492,16 @@  discard block
 block discarded – undo
466 492
 
467 493
 	public function isValidTitleURL(string $title_url) : bool {
468 494
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
469
-		if(!$success) log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
495
+		if(!$success) {
496
+			log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
497
+		}
470 498
 		return $success;
471 499
 	}
472 500
 	public function isValidChapter(string $chapter) : bool {
473 501
 		$success = (bool) preg_match('/^(.*?)\/[0-9]+$/', $chapter);
474
-		if(!$success) log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
502
+		if(!$success) {
503
+			log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
504
+		}
475 505
 		return $success;
476 506
 	}
477 507
 
@@ -540,12 +570,16 @@  discard block
 block discarded – undo
540 570
 
541 571
 	public function isValidTitleURL(string $title_url) : bool {
542 572
 		$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);
543
-		if(!$success) log_message('error', "Invalid Title URL (WebToons): {$title_url}");
573
+		if(!$success) {
574
+			log_message('error', "Invalid Title URL (WebToons): {$title_url}");
575
+		}
544 576
 		return $success;
545 577
 	}
546 578
 	public function isValidChapter(string $chapter) : bool {
547 579
 		$success = (bool) preg_match('/^[0-9]+:--:.*$/', $chapter);
548
-		if(!$success) log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
580
+		if(!$success) {
581
+			log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
582
+		}
549 583
 		return $success;
550 584
 	}
551 585
 
@@ -602,12 +636,16 @@  discard block
 block discarded – undo
602 636
 
603 637
 	public function isValidTitleURL(string $title_url) : bool {
604 638
 		$success = (bool) preg_match('/^[A-Za-z0-9-]+/', $title_url);
605
-		if(!$success) log_message('error', "Invalid Title URL (KissManga): {$title_url}");
639
+		if(!$success) {
640
+			log_message('error', "Invalid Title URL (KissManga): {$title_url}");
641
+		}
606 642
 		return $success;
607 643
 	}
608 644
 	public function isValidChapter(string $chapter) : bool {
609 645
 		$success = (bool) preg_match('/^.*?:--:[0-9]+$/', $chapter);
610
-		if(!$success) log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
646
+		if(!$success) {
647
+			log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
648
+		}
611 649
 		return $success;
612 650
 	}
613 651
 
@@ -674,12 +712,16 @@  discard block
 block discarded – undo
674 712
 
675 713
 	public function isValidTitleURL(string $title_url) : bool {
676 714
 		$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url);
677
-		if(!$success) log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
715
+		if(!$success) {
716
+			log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
717
+		}
678 718
 		return $success;
679 719
 	}
680 720
 	public function isValidChapter(string $chapter) : bool {
681 721
 		$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter);
682
-		if(!$success) log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
722
+		if(!$success) {
723
+			log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
724
+		}
683 725
 		return $success;
684 726
 	}
685 727
 
@@ -736,12 +778,16 @@  discard block
 block discarded – undo
736 778
 
737 779
 	public function isValidTitleURL(string $title_url) : bool {
738 780
 		$success = (bool) preg_match('/^[a-z0-9-]+/', $title_url);
739
-		if(!$success) log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
781
+		if(!$success) {
782
+			log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
783
+		}
740 784
 		return $success;
741 785
 	}
742 786
 	public function isValidChapter(string $chapter) : bool {
743 787
 		$success = (bool) preg_match('/^[a-z0-9\.-]+$/', $chapter);
744
-		if(!$success) log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
788
+		if(!$success) {
789
+			log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
790
+		}
745 791
 		return $success;
746 792
 	}
747 793
 
@@ -797,12 +843,16 @@  discard block
 block discarded – undo
797 843
 
798 844
 	public function isValidTitleURL(string $title_url) : bool {
799 845
 		$success = (bool) preg_match('/^[a-zA-Z0-9_]+/', $title_url);
800
-		if(!$success) log_message('error', "Invalid Title URL (MangaCow): {$title_url}");
846
+		if(!$success) {
847
+			log_message('error', "Invalid Title URL (MangaCow): {$title_url}");
848
+		}
801 849
 		return $success;
802 850
 	}
803 851
 	public function isValidChapter(string $chapter) : bool {
804 852
 		$success = (bool) preg_match('/^[0-9]+$/', $chapter);
805
-		if(!$success) log_message('error', 'Invalid Chapter (MangaCow): '.$chapter);
853
+		if(!$success) {
854
+			log_message('error', 'Invalid Chapter (MangaCow): '.$chapter);
855
+		}
806 856
 		return $success;
807 857
 	}
808 858
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 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
 class Site_Model extends CI_Model {
4 4
 	public function __construct() {
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
101 101
 
102 102
 			$dom = new DOMDocument();
103
-			libxml_use_internal_errors(true);
103
+			libxml_use_internal_errors(TRUE);
104 104
 			$dom->loadHTML($data);
105
-			libxml_use_internal_errors(false);
105
+			libxml_use_internal_errors(FALSE);
106 106
 
107 107
 			$xpath = new DOMXPath($dom);
108 108
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
162 162
 
163 163
 			$dom = new DOMDocument();
164
-			libxml_use_internal_errors(true);
164
+			libxml_use_internal_errors(TRUE);
165 165
 			$dom->loadHTML($data);
166
-			libxml_use_internal_errors(false);
166
+			libxml_use_internal_errors(FALSE);
167 167
 
168 168
 			$xpath = new DOMXPath($dom);
169 169
 			$nodes_title = $xpath->query("//meta[@property='og:title']");
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 		if(strpos($data, '>Register now<') === FALSE) {
251 251
 			//Auth was successful
252 252
 			$dom = new DOMDocument();
253
-			libxml_use_internal_errors(true);
253
+			libxml_use_internal_errors(TRUE);
254 254
 			$dom->loadHTML($data);
255
-			libxml_use_internal_errors(false);
255
+			libxml_use_internal_errors(FALSE);
256 256
 
257 257
 			$xpath = new DOMXPath($dom);
258 258
 			$nodes = $xpath->query("(//div/div)[last()]/table/tbody/tr[2]");
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
434 434
 
435 435
 			$dom = new DOMDocument();
436
-			libxml_use_internal_errors(true);
436
+			libxml_use_internal_errors(TRUE);
437 437
 			$dom->loadHTML($data);
438
-			libxml_use_internal_errors(false);
438
+			libxml_use_internal_errors(FALSE);
439 439
 
440 440
 			$xpath = new DOMXPath($dom);
441 441
 
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
493 493
 
494 494
 			$dom = new DOMDocument();
495
-			libxml_use_internal_errors(true);
495
+			libxml_use_internal_errors(TRUE);
496 496
 			$dom->loadHTML($data);
497
-			libxml_use_internal_errors(false);
497
+			libxml_use_internal_errors(FALSE);
498 498
 
499 499
 			$xpath = new DOMXPath($dom);
500 500
 
@@ -636,9 +636,9 @@  discard block
 block discarded – undo
636 636
 				$data = preg_replace('/^[\S\s]*(<div id="leftside">[\S\s]*)<div id="rightside">[\S\s]*$/', '$1', $data);
637 637
 
638 638
 				$dom = new DOMDocument();
639
-				libxml_use_internal_errors(true);
639
+				libxml_use_internal_errors(TRUE);
640 640
 				$dom->loadHTML($data);
641
-				libxml_use_internal_errors(false);
641
+				libxml_use_internal_errors(FALSE);
642 642
 
643 643
 				$xpath = new DOMXPath($dom);
644 644
 
@@ -702,9 +702,9 @@  discard block
 block discarded – undo
702 702
 			$data = preg_replace('/^[\S\s]*(<article>[\S\s]*)<\/article>[\S\s]*$/', '$1', $data);
703 703
 
704 704
 			$dom = new DOMDocument();
705
-			libxml_use_internal_errors(true);
705
+			libxml_use_internal_errors(TRUE);
706 706
 			$dom->loadHTML($data);
707
-			libxml_use_internal_errors(false);
707
+			libxml_use_internal_errors(FALSE);
708 708
 
709 709
 			$xpath = new DOMXPath($dom);
710 710
 
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
 			//$data = preg_replace('/^[\S\s]*(<ol[\S\s]*)<\/ol>[\S\s]*$/', '$1', $data);
762 762
 
763 763
 			$dom = new DOMDocument();
764
-			libxml_use_internal_errors(true);
764
+			libxml_use_internal_errors(TRUE);
765 765
 			$dom->loadHTML($data);
766
-			libxml_use_internal_errors(false);
766
+			libxml_use_internal_errors(FALSE);
767 767
 
768 768
 			$xpath = new DOMXPath($dom);
769 769
 
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
 		$data = $this->get_content($fullURL);
821 821
 		if(strpos($data, '404 Page Not Found') === FALSE) {
822 822
 			$dom = new DOMDocument();
823
-			libxml_use_internal_errors(true);
823
+			libxml_use_internal_errors(TRUE);
824 824
 			$dom->loadHTML($data);
825
-			libxml_use_internal_errors(false);
825
+			libxml_use_internal_errors(FALSE);
826 826
 
827 827
 			$xpath = new DOMXPath($dom);
828 828
 
Please login to merge, or discard this patch.