Completed
Push — master ( 833a82...6524bd )
by Angus
03:13
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.
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 
581 581
 									$chapter = $nodes_chapter->item(0);
582 582
 									preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text);
583
-									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : ''));
583
+									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
584 584
 
585 585
 									$dateString = $nodes_latest->item(0)->nodeValue;
586 586
 									if($dateString == 'An hour ago') {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 		*/
629 629
 
630 630
 		$chapterData = [
631
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
631
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
632 632
 			'number' => ''
633 633
 		];
634 634
 
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
 					}
684 684
 
685 685
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
686
-					if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
686
+					if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
687 687
 						$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
688 688
 					} else {
689 689
 						$titleData['latest_chapter'] = $chapterURLSegments[2];
690 690
 					}
691 691
 
692
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
692
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
693 693
 				}
694 694
 				break;
695 695
 
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 
700 700
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
701 701
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
702
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
702
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
703 703
 
704 704
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
705 705
 
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 
754 754
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
755 755
 
756
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
756
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
757 757
 		}
758 758
 
759 759
 		return (!empty($titleData) ? $titleData : NULL);
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 
796 796
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
797 797
 
798
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
798
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
799 799
 		}
800 800
 
801 801
 		return (!empty($titleData) ? $titleData : NULL);
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
854 854
 
855 855
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
856
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
857
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
856
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
857
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
858 858
 			}
859 859
 		} else {
860 860
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -924,13 +924,13 @@  discard block
 block discarded – undo
924 924
 					$titleData['title'] = $nodes_title->item(0)->textContent;
925 925
 
926 926
 					$firstRow      = $nodes_row->item(0);
927
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
927
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
928 928
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
929 929
 
930 930
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
931 931
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
932
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
933
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
932
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
933
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
934 934
 				}
935 935
 			} else {
936 936
 				//TODO: Throw ERRORS;
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
954 954
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
955 955
 
956
-		if (strpos($title_url, '.') !== FALSE) {
956
+		if(strpos($title_url, '.') !== FALSE) {
957 957
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
958 958
 		} else {
959 959
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 
989 989
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
990 990
 
991
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
991
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
992 992
 		}
993 993
 
994 994
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1033 1033
 
1034
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1034
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1035 1035
 		}
1036 1036
 
1037 1037
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 		$chapter_parts = explode('/', $chapter);
1095 1095
 		return [
1096 1096
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
1097
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1097
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1098 1098
 		];
1099 1099
 	}
1100 1100
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 		$chapter_parts = explode('/', $chapter);
1118 1118
 		return [
1119 1119
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
1120
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1120
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1121 1121
 		];
1122 1122
 	}
1123 1123
 
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		$chapter_parts = explode('/', $chapter);
1141 1141
 		return [
1142 1142
 			'url'    => "http://helveticascans.com/r/read/{$title_url}/{$chapter}/",
1143
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1143
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1144 1144
 		];
1145 1145
 	}
1146 1146
 
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 		$chapter_parts = explode('/', $chapter);
1164 1164
 		return [
1165 1165
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
1166
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1166
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1167 1167
 		];
1168 1168
 	}
1169 1169
 
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		$chapter_parts = explode('/', $chapter);
1187 1187
 		return [
1188 1188
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
1189
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1189
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1190 1190
 		];
1191 1191
 	}
1192 1192
 
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 		$chapter_parts = explode('/', $chapter);
1210 1210
 		return [
1211 1211
 			'url'    => "https://kobato.hologfx.com/reader/read/{$title_url}/{$chapter}/",
1212
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1212
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1213 1213
 		];
1214 1214
 	}
1215 1215
 
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 		$chapter_parts = explode('/', $chapter);
1233 1233
 		return [
1234 1234
 			'url'    => "http://www.demonicscans.com/FoOlSlide/read/{$title_url}/{$chapter}/",
1235
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1235
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1236 1236
 		];
1237 1237
 	}
1238 1238
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		$chapter_parts = explode('/', $chapter);
1256 1256
 		return [
1257 1257
 			'url'    => "https://reader.deathtollscans.net/read/{$title_url}/{$chapter}/",
1258
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1258
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1259 1259
 		];
1260 1260
 	}
1261 1261
 
Please login to merge, or discard this patch.