Completed
Push — master ( 1dfd21...36ade4 )
by Angus
03:51
created
application/models/Site_Model.php 1 patch
Spacing   +34 added lines, -34 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, bool $isPost = FALSE, array $postFields = []) {
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
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 		curl_setopt($ch, CURLOPT_URL, $url);
51 51
 
52 52
 		if($isPost) {
53
-			curl_setopt($ch,CURLOPT_POST, count($postFields));
54
-			curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields));
53
+			curl_setopt($ch, CURLOPT_POST, count($postFields));
54
+			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
55 55
 		}
56 56
 
57 57
 		$response = curl_exec($ch);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				$nodes_row   = $xpath->query($node_row_string);
119 119
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
120 120
 					$firstRow      = $nodes_row->item(0);
121
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
121
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
122 122
 
123 123
 					if($node_chapter_string !== '') {
124 124
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 
255 255
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
256 256
 			$chapterURLSegments = explode('/', $link);
257
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
258
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
257
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
258
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
259 259
 
260 260
 			if($firstGet) {
261 261
 				$this->doCustomFollow($content['body']);
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 
334 334
 							$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href'));
335 335
 							$chapterURLSegments = explode('/', $link);
336
-							$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
336
+							$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
337 337
 
338
-							$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
338
+							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
339 339
 
340 340
 							$title_url = explode('/', $title->getAttribute('href'))[4];
341 341
 							$titleDataList[$title_url] = $titleData;
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 
427 427
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
428 428
 			$chapterURLSegments = explode('/', $link);
429
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
430
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
429
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
430
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
431 431
 		}
432 432
 
433 433
 		return (!empty($titleData) ? $titleData : NULL);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
 		$chapter_parts = explode(':--:', $chapter);
460 460
 		return [
461
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
461
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
462 462
 			'number' => $chapter_parts[1]
463 463
 		];
464 464
 	}
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
 
494 494
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
495 495
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
496
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
496
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
497 497
 
498 498
 			$dateString = $data['nodes_latest']->nodeValue;
499 499
 			if($dateString == 'An hour ago') {
500 500
 				$dateString = '1 hour ago';
501 501
 			}
502
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
502
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
503 503
 
504 504
 			if($firstGet && $lang == 'English') {
505 505
 				//FIXME: English is forced due for now. See #78.
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
 									$chapter = $nodes_chapter->item(0);
604 604
 									preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text);
605
-									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : ''));
605
+									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
606 606
 
607 607
 									$dateString = $nodes_latest->item(0)->nodeValue;
608 608
 									if($dateString == 'An hour ago') {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 		*/
652 652
 
653 653
 		$chapterData = [
654
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
654
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
655 655
 			'number' => ''
656 656
 		];
657 657
 
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
 					}
707 707
 
708 708
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
709
-					if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
709
+					if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
710 710
 						$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
711 711
 					} else {
712 712
 						$titleData['latest_chapter'] = $chapterURLSegments[2];
713 713
 					}
714 714
 
715
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
715
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
716 716
 				}
717 717
 				break;
718 718
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 
723 723
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
724 724
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
725
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
725
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
726 726
 
727 727
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
728 728
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 
778 778
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
779 779
 
780
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
780
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
781 781
 		}
782 782
 
783 783
 		return (!empty($titleData) ? $titleData : NULL);
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 
821 821
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
822 822
 
823
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
823
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
824 824
 		}
825 825
 
826 826
 		return (!empty($titleData) ? $titleData : NULL);
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
880 880
 
881 881
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
882
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
883
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
882
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
883
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
884 884
 			}
885 885
 		} else {
886 886
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -951,13 +951,13 @@  discard block
 block discarded – undo
951 951
 					$titleData['title'] = $nodes_title->item(0)->textContent;
952 952
 
953 953
 					$firstRow      = $nodes_row->item(0);
954
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
954
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
955 955
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
956 956
 
957 957
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
958 958
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
959
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
960
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
959
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
960
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
961 961
 				}
962 962
 			} else {
963 963
 				//TODO: Throw ERRORS;
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
982 982
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
983 983
 
984
-		if (strpos($title_url, '.') !== FALSE) {
984
+		if(strpos($title_url, '.') !== FALSE) {
985 985
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
986 986
 		} else {
987 987
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1018 1018
 
1019
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
1019
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
1020 1020
 		}
1021 1021
 
1022 1022
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 
1061 1061
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1062 1062
 
1063
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1063
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1064 1064
 		}
1065 1065
 
1066 1066
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 		$chapter_parts = explode('/', $chapter);
1084 1084
 		return [
1085 1085
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
1086
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1086
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1087 1087
 		];
1088 1088
 	}
1089 1089
 
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 		$chapter_parts = explode('/', $chapter);
1108 1108
 		return [
1109 1109
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
1110
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1110
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1111 1111
 		];
1112 1112
 	}
1113 1113
 
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 		$chapter_parts = explode('/', $chapter);
1132 1132
 		return [
1133 1133
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
1134
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1134
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1135 1135
 		];
1136 1136
 	}
1137 1137
 
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 		$chapter_parts = explode('/', $chapter);
1156 1156
 		return [
1157 1157
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
1158
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1158
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1159 1159
 		];
1160 1160
 	}
1161 1161
 
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 		$chapter_parts = explode('/', $chapter);
1180 1180
 		return [
1181 1181
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
1182
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1182
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1183 1183
 		];
1184 1184
 	}
1185 1185
 
Please login to merge, or discard this patch.