Completed
Push — master ( fd57b4...81f48e )
by Angus
06:22
created
application/models/Tracker/Tracker_Title_Model.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
 	/**
110 110
 	 * @param string $site_url
111 111
 	 *
112
-	 * @return object|null
112
+	 * @return string
113 113
 	 */
114 114
 	public function getSiteDataFromURL(string $site_url) {
115 115
 		$query = $this->db->select('*')
Please login to merge, or discard this patch.
application/models/Site_Model.php 1 patch
Spacing   +35 added lines, -35 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);
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 
261 261
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
262 262
 			$chapterURLSegments = explode('/', $link);
263
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
264
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
263
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
264
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
265 265
 
266 266
 			if($firstGet) {
267 267
 				$this->doCustomFollow($content['body']);
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 340
 							$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href'));
341 341
 							$chapterURLSegments = explode('/', $link);
342
-							$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
342
+							$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
343 343
 
344
-							$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
344
+							$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue));
345 345
 
346 346
 							$title_url = explode('/', $title->getAttribute('href'))[4];
347 347
 							$titleDataList[$title_url] = $titleData;
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 
433 433
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
434 434
 			$chapterURLSegments = explode('/', $link);
435
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
436
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
435
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
436
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
437 437
 		}
438 438
 
439 439
 		return (!empty($titleData) ? $titleData : NULL);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 
465 465
 		$chapter_parts = explode(':--:', $chapter);
466 466
 		return [
467
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
467
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
468 468
 			'number' => $chapter_parts[1]
469 469
 		];
470 470
 	}
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
 
500 500
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
501 501
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
502
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
502
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
503 503
 
504 504
 			$dateString = $data['nodes_latest']->nodeValue;
505 505
 			if($dateString == 'An hour ago') {
506 506
 				$dateString = '1 hour ago';
507 507
 			}
508
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
508
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
509 509
 
510 510
 			if($firstGet && $lang == 'English') {
511 511
 				//FIXME: English is forced due for now. See #78.
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 
609 609
 									$chapter = $nodes_chapter->item(0);
610 610
 									preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text);
611
-									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : ''));
611
+									$titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
612 612
 
613 613
 									$dateString = $nodes_latest->item(0)->nodeValue;
614 614
 									if($dateString == 'An hour ago') {
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		*/
658 658
 
659 659
 		$chapterData = [
660
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
660
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
661 661
 			'number' => ''
662 662
 		];
663 663
 
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
 					}
713 713
 
714 714
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
715
-					if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
715
+					if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) {
716 716
 						$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
717 717
 					} else {
718 718
 						$titleData['latest_chapter'] = $chapterURLSegments[2];
719 719
 					}
720 720
 
721
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
721
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
722 722
 				}
723 723
 				break;
724 724
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
730 730
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
731
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
731
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
732 732
 
733 733
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
734 734
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 
784 784
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
785 785
 
786
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
786
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
787 787
 		}
788 788
 
789 789
 		return (!empty($titleData) ? $titleData : NULL);
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 
827 827
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
828 828
 
829
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
829
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
830 830
 		}
831 831
 
832 832
 		return (!empty($titleData) ? $titleData : NULL);
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
886 886
 
887 887
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
888
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
889
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
888
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
889
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
890 890
 			}
891 891
 		} else {
892 892
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
 					$titleData['title'] = $nodes_title->item(0)->textContent;
958 958
 
959 959
 					$firstRow      = $nodes_row->item(0);
960
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
960
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
961 961
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
962 962
 
963 963
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
964 964
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
965
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
966
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
965
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
966
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
967 967
 				}
968 968
 			} else {
969 969
 				//TODO: Throw ERRORS;
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
988 988
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
989 989
 
990
-		if (strpos($title_url, '.') !== FALSE) {
990
+		if(strpos($title_url, '.') !== FALSE) {
991 991
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
992 992
 		} else {
993 993
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 
1023 1023
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1024 1024
 
1025
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
1025
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
1026 1026
 		}
1027 1027
 
1028 1028
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 
1067 1067
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
1068 1068
 
1069
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1069
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
1070 1070
 		}
1071 1071
 
1072 1072
 		return (!empty($titleData) ? $titleData : NULL);
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 		$chapter_parts = explode('/', $chapter);
1090 1090
 		return [
1091 1091
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
1092
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1092
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1093 1093
 		];
1094 1094
 	}
1095 1095
 
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		$chapter_parts = explode('/', $chapter);
1114 1114
 		return [
1115 1115
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
1116
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1116
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1117 1117
 		];
1118 1118
 	}
1119 1119
 
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		$chapter_parts = explode('/', $chapter);
1138 1138
 		return [
1139 1139
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
1140
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1140
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1141 1141
 		];
1142 1142
 	}
1143 1143
 
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 		$chapter_parts = explode('/', $chapter);
1162 1162
 		return [
1163 1163
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
1164
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1164
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1165 1165
 		];
1166 1166
 	}
1167 1167
 
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 		$chapter_parts = explode('/', $chapter);
1186 1186
 		return [
1187 1187
 			'url'    => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/",
1188
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1188
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
1189 1189
 		];
1190 1190
 	}
1191 1191
 
@@ -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
 
Please login to merge, or discard this patch.