Completed
Push — master ( 12fde4...ab9e87 )
by Angus
09:08
created
application/models/Site_Model.php 1 patch
Spacing   +37 added lines, -37 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          = '';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	final protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE, bool $isPost = FALSE, array $postFields = []) {
35 35
 		$ch = curl_init();
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
37
-		curl_setopt($ch, CURLOPT_ENCODING , "gzip");
37
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
38 38
 		//curl_setopt($ch, CURLOPT_VERBOSE, 1);
39 39
 		curl_setopt($ch, CURLOPT_HEADER, 1);
40 40
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 		curl_setopt($ch, CURLOPT_URL, $url);
53 53
 
54 54
 		if($isPost) {
55
-			curl_setopt($ch,CURLOPT_POST, count($postFields));
56
-			curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields));
55
+			curl_setopt($ch, CURLOPT_POST, count($postFields));
56
+			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
57 57
 		}
58 58
 
59 59
 		$response = curl_exec($ch);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				$nodes_row   = $xpath->query($node_row_string);
121 121
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
122 122
 					$firstRow      = $nodes_row->item(0);
123
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
123
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
124 124
 
125 125
 					if($node_chapter_string !== '') {
126 126
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
237 237
 			$chapterURLSegments = explode('/', $link);
238
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
239
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
238
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
239
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
240 240
 
241 241
 			if($firstGet) {
242 242
 				$this->doCustomFollow($content['body']);
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 
314 314
 							$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href'));
315 315
 							$chapterURLSegments = explode('/', $link);
316
-							$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
316
+							$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
317 317
 
318
-							$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
318
+							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
319 319
 
320 320
 							$title_url = explode('/', $title->getAttribute('href'))[4];
321 321
 							$titleDataList[$title_url] = $titleData;
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 
406 406
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
407 407
 			$chapterURLSegments = explode('/', $link);
408
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
409
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
408
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
409
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
410 410
 		}
411 411
 
412 412
 		return (!empty($titleData) ? $titleData : NULL);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 
437 437
 		$chapter_parts = explode(':--:', $chapter);
438 438
 		return [
439
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
439
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
440 440
 			'number' => $chapter_parts[1]
441 441
 		];
442 442
 	}
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 
472 472
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
473 473
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
474
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
474
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
475 475
 
476 476
 			$dateString = $data['nodes_latest']->nodeValue;
477 477
 			if($dateString == 'An hour ago') {
478 478
 				$dateString = '1 hour ago';
479 479
 			}
480
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
480
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
481 481
 
482 482
 			if($firstGet && $lang == 'English') {
483 483
 				//FIXME: English is forced due for now. See #78.
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
 									$chapter = $nodes_chapter->item(0);
580 580
 									preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text);
581
-									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : ''));
581
+									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
582 582
 
583 583
 									$dateString = $nodes_latest->item(0)->nodeValue;
584 584
 									if($dateString == 'An hour ago') {
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		*/
665 665
 
666 666
 		$chapterData = [
667
-			'url'    => 'https://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
667
+			'url'    => 'https://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
668 668
 			'number' => ''
669 669
 		];
670 670
 
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 					}
720 720
 
721 721
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
722
-					if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
722
+					if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
723 723
 						$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
724 724
 					} else {
725 725
 						$titleData['latest_chapter'] = $chapterURLSegments[2];
726 726
 					}
727 727
 
728
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
728
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
729 729
 				}
730 730
 				break;
731 731
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 
736 736
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
737 737
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
738
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
738
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
739 739
 
740 740
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
741 741
 
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 
790 790
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
791 791
 
792
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
792
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
793 793
 		}
794 794
 
795 795
 		return (!empty($titleData) ? $titleData : NULL);
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 
832 832
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
833 833
 
834
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
834
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
835 835
 		}
836 836
 
837 837
 		return (!empty($titleData) ? $titleData : NULL);
@@ -889,8 +889,8 @@  discard block
 block discarded – undo
889 889
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
890 890
 
891 891
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
892
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
893
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
892
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
893
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
894 894
 			}
895 895
 		} else {
896 896
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -960,13 +960,13 @@  discard block
 block discarded – undo
960 960
 					$titleData['title'] = $nodes_title->item(0)->textContent;
961 961
 
962 962
 					$firstRow      = $nodes_row->item(0);
963
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
963
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
964 964
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
965 965
 
966 966
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
967 967
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
968
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
969
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
968
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
969
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
970 970
 				}
971 971
 			} else {
972 972
 				//TODO: Throw ERRORS;
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
990 990
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
991 991
 
992
-		if (strpos($title_url, '.') !== FALSE) {
992
+		if(strpos($title_url, '.') !== FALSE) {
993 993
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
994 994
 		} else {
995 995
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1026 1026
 
1027
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
1027
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
1028 1028
 		}
1029 1029
 
1030 1030
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1069 1069
 
1070
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1070
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1071 1071
 		}
1072 1072
 
1073 1073
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		$chapter_parts = explode('/', $chapter);
1131 1131
 		return [
1132 1132
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
1133
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1133
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1134 1134
 		];
1135 1135
 	}
1136 1136
 
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 		$chapter_parts = explode('/', $chapter);
1154 1154
 		return [
1155 1155
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
1156
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1156
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1157 1157
 		];
1158 1158
 	}
1159 1159
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		$chapter_parts = explode('/', $chapter);
1177 1177
 		return [
1178 1178
 			'url'    => "http://helveticascans.com/r/read/{$title_url}/{$chapter}/",
1179
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1179
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1180 1180
 		];
1181 1181
 	}
1182 1182
 
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		$chapter_parts = explode('/', $chapter);
1200 1200
 		return [
1201 1201
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
1202
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1202
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1203 1203
 		];
1204 1204
 	}
1205 1205
 
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 		$chapter_parts = explode('/', $chapter);
1223 1223
 		return [
1224 1224
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
1225
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1225
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1226 1226
 		];
1227 1227
 	}
1228 1228
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$chapter_parts = explode('/', $chapter);
1246 1246
 		return [
1247 1247
 			'url'    => "https://kobato.hologfx.com/reader/read/{$title_url}/{$chapter}/",
1248
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1248
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1249 1249
 		];
1250 1250
 	}
1251 1251
 
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 		$chapter_parts = explode('/', $chapter);
1269 1269
 		return [
1270 1270
 			'url'    => "http://www.demonicscans.com/FoOlSlide/read/{$title_url}/{$chapter}/",
1271
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1271
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1272 1272
 		];
1273 1273
 	}
1274 1274
 
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 		$chapter_parts = explode('/', $chapter);
1292 1292
 		return [
1293 1293
 			'url'    => "https://reader.deathtollscans.net/read/{$title_url}/{$chapter}/",
1294
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1294
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1295 1295
 		];
1296 1296
 	}
1297 1297
 
Please login to merge, or discard this patch.