Completed
Push — master ( bad5d9...4e991e )
by Angus
03:11
created
application/models/Site_Model.php 3 patches
Spacing   +26 added lines, -26 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 = ""){
19
+	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "") {
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(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
25 25
 		if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
115 115
 				$chapterURLSegments = explode('/', $link);
116
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
117
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
116
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
117
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
118 118
 			}
119 119
 		} else {
120 120
 			//TODO: Throw ERRORS;
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
 				$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
175 175
 				$chapterURLSegments = explode('/', $link);
176
-				$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
177
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
176
+				$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
177
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
178 178
 			}
179 179
 		} else {
180 180
 			//TODO: Throw ERRORS;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 		$chapter_parts = explode(':--:', $chapter);
216 216
 		return [
217
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
217
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
218 218
 			'number' => $chapter_parts[1]
219 219
 		];
220 220
 	}
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 		//Bato.to is annoying and locks stuff behind auth. See: https://github.com/DakuTree/manga-tracker/issues/14#issuecomment-233830855
231 231
 		$cookies = [
232 232
 			"lang_option={$title_lang}",
233
-		    "member_id=" . $this->config->item('batoto_cookie_member_id'),
234
-		    "pass_hash=" . $this->config->item('batoto_cookie_pass_hash')
233
+		    "member_id=".$this->config->item('batoto_cookie_member_id'),
234
+		    "pass_hash=".$this->config->item('batoto_cookie_pass_hash')
235 235
 		];
236 236
 		$data = $this->get_content($title_url, implode("; ", $cookies));
237 237
 		if(!$data) {
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 					preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)):?.*/', trim($chapter_element->nodeValue), $text);
264 264
 
265 265
 					$titleData['title']          = html_entity_decode(trim($xpath->query('//h1[@class="ipsType_pagetitle"]')->item(0)->nodeValue));
266
-					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter']);
266
+					$titleData['latest_chapter'] = substr($chapter_element->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter']);
267 267
 
268 268
 					$dateString = $updated_element->nodeValue;
269 269
 					if($dateString == 'An hour ago') {
270 270
 						$dateString = '1 hour ago';
271 271
 					}
272
-					$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
272
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
273 273
 				} else {
274 274
 					log_message('error', "Batoto: Regex missing <td> ({$title_url})");
275 275
 					return NULL;
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		*/
318 318
 
319 319
 		$chapterData = [
320
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
320
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
321 321
 			'number' => ''
322 322
 		];
323 323
 
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 
358 358
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
359 359
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
360
-			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '') . substr($matchesT[0], 3, -4);
360
+			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '').substr($matchesT[0], 3, -4);
361 361
 
362 362
 			$data = preg_replace('/^[\S\s]*(<dl class=\'chapter-list\'>[\S\s]*<\/dl>)[\S\s]*$/', '$1', $data);
363 363
 			preg_match_all('/<dd>[\s\S]+?(?=<\/dd>)<\/dd>/', $data, $matches);
364 364
 			$latest_chapter_html = array_pop($matches[0]);
365 365
 
366 366
 			preg_match('/\/chapters\/([^"]+)/', $latest_chapter_html, $matches);
367
-			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url)+1);
367
+			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url) + 1);
368 368
 			//FIXME: THIS IS A TEMP FIX, SEE https://github.com/DakuTree/manga-tracker/issues/58
369 369
 			if(!$titleData['latest_chapter']) {
370 370
 				log_message('error', 'DynastyScans::getTitleData cannot parse title properly as it contains oneshot. || URL: '.$title_url);
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 			}
373 373
 
374 374
 			preg_match('/<small>released (.*)<\/small>/', $latest_chapter_html, $matches);
375
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
375
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
376 376
 		} elseif($title_parts[1] == '1') {
377 377
 			$data = $this->get_content('http://dynasty-scans.com/chapters/'.$title_url);
378 378
 
379 379
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
380 380
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
381
-			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
381
+			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
382 382
 
383 383
 			$titleData['latest_chapter'] = 'oneshot'; //This will never change
384 384
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
445 445
 
446 446
 				$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
447
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
447
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
448 448
 			}
449 449
 		} else {
450 450
 			//TODO: Throw ERRORS;
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 				$nodes_chapter = $xpath->query("td[1]/a", $nodes_row[0]);
503 503
 
504 504
 				$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $nodes_chapter[0]->getAttribute('href'));
505
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
505
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->nodeValue));
506 506
 			}
507 507
 		} else {
508 508
 			//TODO: Throw ERRORS;
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 				$titleData['title'] = trim((string) $xml->channel->title);
568 568
 
569 569
 				$chapterURLSegments = explode('/', ((string) $xml->channel->item[0]->link));
570
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
571
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
570
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
571
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->channel->item[0]->pubDate));
572 572
 			}
573 573
 		} else {
574 574
 			//TODO: Throw ERRORS;
@@ -647,8 +647,8 @@  discard block
 block discarded – undo
647 647
 
648 648
 					$link = (string) $nodes_chapter[0]->getAttribute('href');
649 649
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
650
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
651
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
650
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
651
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest[0]->textContent));
652 652
 				}
653 653
 			} else {
654 654
 				//TODO: Throw ERRORS;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 		$chapter_parts = explode('/', $chapter);
684 684
 		return [
685 685
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}",
686
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
686
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
687 687
 		];
688 688
 	}
689 689
 
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 
715 715
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
716 716
 				$titleData['latest_chapter'] = preg_replace('/.*\/read\/.*?\/(.*?)\/$/', '$1', $link);
717
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
717
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) str_replace('.', '', explode(',', $nodes_latest[0]->textContent)[1])));
718 718
 			}
719 719
 		} else {
720 720
 			//TODO: Throw ERRORS;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 
773 773
 				$link = (string) $nodes_chapter[0]->getAttribute('href');
774 774
 				$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', $link);
775
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
775
+				$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $nodes_latest[0]->getAttribute('data-time'));
776 776
 			} else {
777 777
 				log_message('error', "GameOfScanlation: Unable to find nodes.");
778 778
 				return NULL;
Please login to merge, or discard this patch.
Braces   +67 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,13 +16,17 @@  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 = ""){
19
+	protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "") {
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(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
25
-		if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
24
+		if(!empty($cookie_string)) {
25
+			curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
26
+		}
27
+		if(!empty($cookiejar_path)) {
28
+			curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
29
+		}
26 30
 
27 31
 		//Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff.
28 32
 		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');
@@ -70,12 +74,16 @@  discard block
 block discarded – undo
70 74
 
71 75
 	public function isValidTitleURL(string $title_url) : bool {
72 76
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
73
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
77
+		if(!$success) {
78
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
79
+		}
74 80
 		return $success;
75 81
 	}
76 82
 	public function isValidChapter(string $chapter) : bool {
77 83
 		$success = (bool) preg_match('/^(?:v[0-9a-zA-Z]+\/)?c[0-9\.]+$/', $chapter);
78
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
84
+		if(!$success) {
85
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
86
+		}
79 87
 		return $success;
80 88
 	}
81 89
 
@@ -131,12 +139,16 @@  discard block
 block discarded – undo
131 139
 
132 140
 	public function isValidTitleURL(string $title_url) : bool {
133 141
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
134
-		if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
142
+		if(!$success) {
143
+			log_message('error', "Invalid Title URL (MangaFox): {$title_url}");
144
+		}
135 145
 		return $success;
136 146
 	}
137 147
 	public function isValidChapter(string $chapter) : bool {
138 148
 		$success = (bool) preg_match('/^(?:v[0-9]+\/)?c[0-9]+(?:\.[0-9]+)?$/', $chapter);
139
-		if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
149
+		if(!$success) {
150
+			log_message('error', 'Invalid Chapter (MangaFox): '.$chapter);
151
+		}
140 152
 		return $success;
141 153
 	}
142 154
 
@@ -197,7 +209,9 @@  discard block
 block discarded – undo
197 209
 
198 210
 	public function isValidTitleURL(string $title_url) : bool {
199 211
 		$success = (bool) preg_match('/^[a-z0-9%-]+:--:(?:English|Spanish|French|German|Portuguese|Turkish|Indonesian|Greek|Filipino|Italian|Polish|Thai|Malay|Hungarian|Romanian|Arabic|Hebrew|Russian|Vietnamese|Dutch)$/', $title_url);
200
-		if(!$success) log_message('error', "Invalid Title URL (Batoto): {$title_url}");
212
+		if(!$success) {
213
+			log_message('error', "Invalid Title URL (Batoto): {$title_url}");
214
+		}
201 215
 		return $success;
202 216
 	}
203 217
 	public function isValidChapter(string $chapter) : bool {
@@ -205,7 +219,9 @@  discard block
 block discarded – undo
205 219
 		//       Preferably we'd just use /^[0-9a-z]+:--:(v[0-9]+\/)?c[0-9]+(\.[0-9]+)?$/
206 220
 
207 221
 		$success = (bool) preg_match('/^[0-9a-z]+:--:.+$/', $chapter);
208
-		if(!$success) log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
222
+		if(!$success) {
223
+			log_message('error', 'Invalid Chapter (Batoto): '.$chapter);
224
+		}
209 225
 		return $success;
210 226
 	}
211 227
 
@@ -298,12 +314,16 @@  discard block
 block discarded – undo
298 314
 
299 315
 	public function isValidTitleURL(string $title_url) : bool {
300 316
 		$success = (bool) preg_match('/^[a-z0-9_]+:--:(?:0|1)$/', $title_url);
301
-		if(!$success) log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
317
+		if(!$success) {
318
+			log_message('error', "Invalid Title URL (DynastyScans): {$title_url}");
319
+		}
302 320
 		return $success;
303 321
 	}
304 322
 	public function isValidChapter(string $chapter) : bool {
305 323
 		$success = (bool) preg_match('/^[0-9a-z_]+$/', $chapter);
306
-		if(!$success) log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
324
+		if(!$success) {
325
+			log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter);
326
+		}
307 327
 		return $success;
308 328
 	}
309 329
 
@@ -409,12 +429,16 @@  discard block
 block discarded – undo
409 429
 
410 430
 	public function isValidTitleURL(string $title_url) : bool {
411 431
 		$success = (bool) preg_match('/^[a-z0-9-]+$/', $title_url);
412
-		if(!$success) log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
432
+		if(!$success) {
433
+			log_message('error', "Invalid Title URL (MangaPanda): {$title_url}");
434
+		}
413 435
 		return $success;
414 436
 	}
415 437
 	public function isValidChapter(string $chapter) : bool {
416 438
 		$success = (bool) preg_match('/^[0-9]+$/', $chapter);
417
-		if(!$success) log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
439
+		if(!$success) {
440
+			log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter);
441
+		}
418 442
 		return $success;
419 443
 	}
420 444
 
@@ -461,12 +485,16 @@  discard block
 block discarded – undo
461 485
 
462 486
 	public function isValidTitleURL(string $title_url) : bool {
463 487
 		$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url);
464
-		if(!$success) log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
488
+		if(!$success) {
489
+			log_message('error', "Invalid Title URL (MangaStream): {$title_url}");
490
+		}
465 491
 		return $success;
466 492
 	}
467 493
 	public function isValidChapter(string $chapter) : bool {
468 494
 		$success = (bool) preg_match('/^(.*?)\/[0-9]+$/', $chapter);
469
-		if(!$success) log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
495
+		if(!$success) {
496
+			log_message('error', 'Invalid Chapter (MangaStream): '.$chapter);
497
+		}
470 498
 		return $success;
471 499
 	}
472 500
 
@@ -535,12 +563,16 @@  discard block
 block discarded – undo
535 563
 
536 564
 	public function isValidTitleURL(string $title_url) : bool {
537 565
 		$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);
538
-		if(!$success) log_message('error', "Invalid Title URL (WebToons): {$title_url}");
566
+		if(!$success) {
567
+			log_message('error', "Invalid Title URL (WebToons): {$title_url}");
568
+		}
539 569
 		return $success;
540 570
 	}
541 571
 	public function isValidChapter(string $chapter) : bool {
542 572
 		$success = (bool) preg_match('/^[0-9]+:--:.*$/', $chapter);
543
-		if(!$success) log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
573
+		if(!$success) {
574
+			log_message('error', 'Invalid Chapter (WebToons): '.$chapter);
575
+		}
544 576
 		return $success;
545 577
 	}
546 578
 
@@ -597,12 +629,16 @@  discard block
 block discarded – undo
597 629
 
598 630
 	public function isValidTitleURL(string $title_url) : bool {
599 631
 		$success = (bool) preg_match('/^[A-Za-z0-9-]+/', $title_url);
600
-		if(!$success) log_message('error', "Invalid Title URL (KissManga): {$title_url}");
632
+		if(!$success) {
633
+			log_message('error', "Invalid Title URL (KissManga): {$title_url}");
634
+		}
601 635
 		return $success;
602 636
 	}
603 637
 	public function isValidChapter(string $chapter) : bool {
604 638
 		$success = (bool) preg_match('/^.*?:--:[0-9]+$/', $chapter);
605
-		if(!$success) log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
639
+		if(!$success) {
640
+			log_message('error', 'Invalid Chapter (KissManga): '.$chapter);
641
+		}
606 642
 		return $success;
607 643
 	}
608 644
 
@@ -669,12 +705,16 @@  discard block
 block discarded – undo
669 705
 
670 706
 	public function isValidTitleURL(string $title_url) : bool {
671 707
 		$success = (bool) preg_match('/^[a-z0-9_]+/', $title_url);
672
-		if(!$success) log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
708
+		if(!$success) {
709
+			log_message('error', "Invalid Title URL (KireiCake): {$title_url}");
710
+		}
673 711
 		return $success;
674 712
 	}
675 713
 	public function isValidChapter(string $chapter) : bool {
676 714
 		$success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter);
677
-		if(!$success) log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
715
+		if(!$success) {
716
+			log_message('error', 'Invalid Chapter (KireiCake): '.$chapter);
717
+		}
678 718
 		return $success;
679 719
 	}
680 720
 
@@ -731,12 +771,16 @@  discard block
 block discarded – undo
731 771
 
732 772
 	public function isValidTitleURL(string $title_url) : bool {
733 773
 		$success = (bool) preg_match('/^[a-z0-9-]+/', $title_url);
734
-		if(!$success) log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
774
+		if(!$success) {
775
+			log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}");
776
+		}
735 777
 		return $success;
736 778
 	}
737 779
 	public function isValidChapter(string $chapter) : bool {
738 780
 		$success = (bool) preg_match('/^[a-z0-9\.-]+$/', $chapter);
739
-		if(!$success) log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
781
+		if(!$success) {
782
+			log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter);
783
+		}
740 784
 		return $success;
741 785
 	}
742 786
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 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() {
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
97 97
 
98 98
 			$dom = new DOMDocument();
99
-			libxml_use_internal_errors(true);
99
+			libxml_use_internal_errors(TRUE);
100 100
 			$dom->loadHTML($data);
101
-			libxml_use_internal_errors(false);
101
+			libxml_use_internal_errors(FALSE);
102 102
 
103 103
 			$xpath = new DOMXPath($dom);
104 104
 
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
158 158
 
159 159
 			$dom = new DOMDocument();
160
-			libxml_use_internal_errors(true);
160
+			libxml_use_internal_errors(TRUE);
161 161
 			$dom->loadHTML($data);
162
-			libxml_use_internal_errors(false);
162
+			libxml_use_internal_errors(FALSE);
163 163
 
164 164
 			$xpath = new DOMXPath($dom);
165 165
 			$nodes_title = $xpath->query("//meta[@property='og:title']");
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 		if(strpos($data, '>Register now<') === FALSE) {
246 246
 			//Auth was successful
247 247
 			$dom = new DOMDocument();
248
-			libxml_use_internal_errors(true);
248
+			libxml_use_internal_errors(TRUE);
249 249
 			$dom->loadHTML($data);
250
-			libxml_use_internal_errors(false);
250
+			libxml_use_internal_errors(FALSE);
251 251
 
252 252
 			$xpath = new DOMXPath($dom);
253 253
 			$nodes = $xpath->query("(//div/div)[last()]/table/tbody/tr[2]");
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
429 429
 
430 430
 			$dom = new DOMDocument();
431
-			libxml_use_internal_errors(true);
431
+			libxml_use_internal_errors(TRUE);
432 432
 			$dom->loadHTML($data);
433
-			libxml_use_internal_errors(false);
433
+			libxml_use_internal_errors(FALSE);
434 434
 
435 435
 			$xpath = new DOMXPath($dom);
436 436
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 			//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data);
488 488
 
489 489
 			$dom = new DOMDocument();
490
-			libxml_use_internal_errors(true);
490
+			libxml_use_internal_errors(TRUE);
491 491
 			$dom->loadHTML($data);
492
-			libxml_use_internal_errors(false);
492
+			libxml_use_internal_errors(FALSE);
493 493
 
494 494
 			$xpath = new DOMXPath($dom);
495 495
 
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 				$data = preg_replace('/^[\S\s]*(<div id="leftside">[\S\s]*)<div id="rightside">[\S\s]*$/', '$1', $data);
632 632
 
633 633
 				$dom = new DOMDocument();
634
-				libxml_use_internal_errors(true);
634
+				libxml_use_internal_errors(TRUE);
635 635
 				$dom->loadHTML($data);
636
-				libxml_use_internal_errors(false);
636
+				libxml_use_internal_errors(FALSE);
637 637
 
638 638
 				$xpath = new DOMXPath($dom);
639 639
 
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
 			$data = preg_replace('/^[\S\s]*(<article>[\S\s]*)<\/article>[\S\s]*$/', '$1', $data);
698 698
 
699 699
 			$dom = new DOMDocument();
700
-			libxml_use_internal_errors(true);
700
+			libxml_use_internal_errors(TRUE);
701 701
 			$dom->loadHTML($data);
702
-			libxml_use_internal_errors(false);
702
+			libxml_use_internal_errors(FALSE);
703 703
 
704 704
 			$xpath = new DOMXPath($dom);
705 705
 
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
 			//$data = preg_replace('/^[\S\s]*(<ol[\S\s]*)<\/ol>[\S\s]*$/', '$1', $data);
757 757
 
758 758
 			$dom = new DOMDocument();
759
-			libxml_use_internal_errors(true);
759
+			libxml_use_internal_errors(TRUE);
760 760
 			$dom->loadHTML($data);
761
-			libxml_use_internal_errors(false);
761
+			libxml_use_internal_errors(FALSE);
762 762
 
763 763
 			$xpath = new DOMXPath($dom);
764 764
 
Please login to merge, or discard this patch.