Completed
Push — master ( d30a44...39481e )
by Angus
03:37
created
application/models/Site_Model.php 1 patch
Spacing   +36 added lines, -36 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']);
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 
315 315
 							$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href'));
316 316
 							$chapterURLSegments = explode('/', $link);
317
-							$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
317
+							$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
318 318
 
319
-							$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
319
+							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
320 320
 
321 321
 							$title_url = explode('/', $title->getAttribute('href'))[4];
322 322
 							$titleDataList[$title_url] = $titleData;
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 
407 407
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
408 408
 			$chapterURLSegments = explode('/', $link);
409
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
410
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
409
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
410
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
411 411
 		}
412 412
 
413 413
 		return (!empty($titleData) ? $titleData : NULL);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
 		$chapter_parts = explode(':--:', $chapter);
439 439
 		return [
440
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
440
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
441 441
 			'number' => $chapter_parts[1]
442 442
 		];
443 443
 	}
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
 
473 473
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
474 474
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
475
-			$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
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
476 476
 
477 477
 			$dateString = $data['nodes_latest']->nodeValue;
478 478
 			if($dateString == 'An hour ago') {
479 479
 				$dateString = '1 hour ago';
480 480
 			}
481
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
481
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
482 482
 
483 483
 			if($firstGet && $lang == 'English') {
484 484
 				//FIXME: English is forced due for now. See #78.
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 
582 582
 									$chapter = $nodes_chapter->item(0);
583 583
 									preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text);
584
-									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : ''));
584
+									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
585 585
 
586 586
 									$dateString = $nodes_latest->item(0)->nodeValue;
587 587
 									if($dateString == 'An hour ago') {
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 		*/
630 630
 
631 631
 		$chapterData = [
632
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
632
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
633 633
 			'number' => ''
634 634
 		];
635 635
 
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
 					}
685 685
 
686 686
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
687
-					if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
687
+					if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
688 688
 						$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
689 689
 					} else {
690 690
 						$titleData['latest_chapter'] = $chapterURLSegments[2];
691 691
 					}
692 692
 
693
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
693
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
694 694
 				}
695 695
 				break;
696 696
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 
701 701
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
702 702
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
703
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
703
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
704 704
 
705 705
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
706 706
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 
755 755
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
756 756
 
757
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
757
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
758 758
 		}
759 759
 
760 760
 		return (!empty($titleData) ? $titleData : NULL);
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
798 798
 
799
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
799
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
800 800
 		}
801 801
 
802 802
 		return (!empty($titleData) ? $titleData : NULL);
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
855 855
 
856 856
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
857
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
858
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
857
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
858
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
859 859
 			}
860 860
 		} else {
861 861
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -925,13 +925,13 @@  discard block
 block discarded – undo
925 925
 					$titleData['title'] = $nodes_title->item(0)->textContent;
926 926
 
927 927
 					$firstRow      = $nodes_row->item(0);
928
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
928
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
929 929
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
930 930
 
931 931
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
932 932
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
933
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
934
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
933
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
934
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
935 935
 				}
936 936
 			} else {
937 937
 				//TODO: Throw ERRORS;
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
955 955
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
956 956
 
957
-		if (strpos($title_url, '.') !== FALSE) {
957
+		if(strpos($title_url, '.') !== FALSE) {
958 958
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
959 959
 		} else {
960 960
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 
990 990
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
991 991
 
992
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
992
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
993 993
 		}
994 994
 
995 995
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1034 1034
 
1035
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1035
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1036 1036
 		}
1037 1037
 
1038 1038
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 		$chapter_parts = explode('/', $chapter);
1055 1055
 		return [
1056 1056
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
1057
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1057
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1058 1058
 		];
1059 1059
 	}
1060 1060
 
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		$chapter_parts = explode('/', $chapter);
1078 1078
 		return [
1079 1079
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
1080
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1080
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1081 1081
 		];
1082 1082
 	}
1083 1083
 
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		$chapter_parts = explode('/', $chapter);
1101 1101
 		return [
1102 1102
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
1103
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1103
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1104 1104
 		];
1105 1105
 	}
1106 1106
 
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 		$chapter_parts = explode('/', $chapter);
1124 1124
 		return [
1125 1125
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
1126
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1126
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1127 1127
 		];
1128 1128
 	}
1129 1129
 
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 		$chapter_parts = explode('/', $chapter);
1147 1147
 		return [
1148 1148
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
1149
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1149
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1150 1150
 		];
1151 1151
 	}
1152 1152
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 		$chapter_parts = explode('/', $chapter);
1170 1170
 		return [
1171 1171
 			'url'    => "https://kobato.hologfx.com/reader/read/{$title_url}/{$chapter}/",
1172
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1172
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1173 1173
 		];
1174 1174
 	}
1175 1175
 
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 		$chapter_parts = explode('/', $chapter);
1193 1193
 		return [
1194 1194
 			'url'    => "http://www.demonicscans.com/FoOlSlide/read/{$title_url}/{$chapter}/",
1195
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1195
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1196 1196
 		];
1197 1197
 	}
1198 1198
 
Please login to merge, or discard this patch.