Completed
Push — master ( 9109eb...d52c51 )
by Angus
09:38
created
application/models/Site_Model.php 1 patch
Spacing   +29 added lines, -29 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 $site          = '';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	final protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE) {
33 33
 		$ch = curl_init();
34 34
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
35
-		curl_setopt($ch, CURLOPT_ENCODING , "gzip");
35
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
36 36
 		//curl_setopt($ch, CURLOPT_VERBOSE, 1);
37 37
 		curl_setopt($ch, CURLOPT_HEADER, 1);
38 38
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 				$nodes_row   = $xpath->query($node_row_string);
113 113
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
114 114
 					$firstRow      = $nodes_row->item(0);
115
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
115
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
116 116
 
117 117
 					if($node_chapter_string !== '') {
118 118
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 
245 245
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
246 246
 			$chapterURLSegments = explode('/', $link);
247
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
248
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
247
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
248
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
249 249
 		}
250 250
 
251 251
 		return (!empty($titleData) ? $titleData : NULL);
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 
289 289
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
290 290
 			$chapterURLSegments = explode('/', $link);
291
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
292
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
291
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
292
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
293 293
 		}
294 294
 
295 295
 		return (!empty($titleData) ? $titleData : NULL);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
 		$chapter_parts = explode(':--:', $chapter);
322 322
 		return [
323
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
323
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
324 324
 			'number' => $chapter_parts[1]
325 325
 		];
326 326
 	}
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 
356 356
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
357 357
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
358
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
358
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
359 359
 
360 360
 			$dateString = $data['nodes_latest']->nodeValue;
361 361
 			if($dateString == 'An hour ago') {
362 362
 				$dateString = '1 hour ago';
363 363
 			}
364
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
364
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
365 365
 		}
366 366
 
367 367
 		return (!empty($titleData) ? $titleData : NULL);
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		*/
401 401
 
402 402
 		$chapterData = [
403
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
403
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
404 404
 			'number' => ''
405 405
 		];
406 406
 
@@ -455,9 +455,9 @@  discard block
 block discarded – undo
455 455
 					}
456 456
 
457 457
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
458
-					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0])+1);
458
+					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
459 459
 
460
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
460
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
461 461
 				}
462 462
 				break;
463 463
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 
468 468
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
469 469
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
470
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
470
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
471 471
 
472 472
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
473 473
 
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
524 524
 
525
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
525
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
526 526
 		}
527 527
 
528 528
 		return (!empty($titleData) ? $titleData : NULL);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 
566 566
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
567 567
 
568
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
568
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
569 569
 		}
570 570
 
571 571
 		return (!empty($titleData) ? $titleData : NULL);
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
625 625
 
626 626
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
627
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
628
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
627
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
628
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
629 629
 			}
630 630
 		} else {
631 631
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
 					$titleData['title'] = $nodes_title->item(0)->textContent;
697 697
 
698 698
 					$firstRow      = $nodes_row->item(0);
699
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
699
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
700 700
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
701 701
 
702 702
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
703 703
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
704
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
705
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
704
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
705
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
706 706
 				}
707 707
 			} else {
708 708
 				//TODO: Throw ERRORS;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
727 727
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
728 728
 
729
-		if (strpos($title_url, '.') !== FALSE) {
729
+		if(strpos($title_url, '.') !== FALSE) {
730 730
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
731 731
 		} else {
732 732
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
763 763
 
764
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
764
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
765 765
 		}
766 766
 
767 767
 		return (!empty($titleData) ? $titleData : NULL);
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 
806 806
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
807 807
 
808
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
808
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
809 809
 		}
810 810
 
811 811
 		return (!empty($titleData) ? $titleData : NULL);
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 		$chapter_parts = explode('/', $chapter);
829 829
 		return [
830 830
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
831
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
831
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
832 832
 		];
833 833
 	}
834 834
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 		$chapter_parts = explode('/', $chapter);
853 853
 		return [
854 854
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
855
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
855
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
856 856
 		];
857 857
 	}
858 858
 
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 		$chapter_parts = explode('/', $chapter);
877 877
 		return [
878 878
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
879
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
879
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
880 880
 		];
881 881
 	}
882 882
 
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 		$chapter_parts = explode('/', $chapter);
901 901
 		return [
902 902
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
903
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
903
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
904 904
 		];
905 905
 	}
906 906
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 		$chapter_parts = explode('/', $chapter);
925 925
 		return [
926 926
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
927
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
927
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
928 928
 		];
929 929
 	}
930 930
 
Please login to merge, or discard this patch.