Completed
Push — master ( d6ef10...270242 )
by Angus
03:27
created
application/models/Site_Model.php 1 patch
Spacing   +28 added lines, -28 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) {
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
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			$nodes_row   = $xpath->query($node_row_string);
111 111
 			if($nodes_title->length === 1 && $nodes_row->length === 1) {
112 112
 				$firstRow      = $nodes_row->item(0);
113
-				$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
113
+				$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
114 114
 
115 115
 				if($node_chapter_string !== '') {
116 116
 					$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 
237 237
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
238 238
 			$chapterURLSegments = explode('/', $link);
239
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
240
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
239
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
240
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
241 241
 		}
242 242
 
243 243
 		return (!empty($titleData) ? $titleData : NULL);
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 
281 281
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
282 282
 			$chapterURLSegments = explode('/', $link);
283
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
284
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
283
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
284
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
285 285
 		}
286 286
 
287 287
 		return (!empty($titleData) ? $titleData : NULL);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 		$chapter_parts = explode(':--:', $chapter);
314 314
 		return [
315
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
315
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
316 316
 			'number' => $chapter_parts[1]
317 317
 		];
318 318
 	}
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 
348 348
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
349 349
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
350
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
350
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
351 351
 
352 352
 			$dateString = $data['nodes_latest']->nodeValue;
353 353
 			if($dateString == 'An hour ago') {
354 354
 				$dateString = '1 hour ago';
355 355
 			}
356
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
356
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
357 357
 		}
358 358
 
359 359
 		return (!empty($titleData) ? $titleData : NULL);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 		*/
393 393
 
394 394
 		$chapterData = [
395
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
395
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
396 396
 			'number' => ''
397 397
 		];
398 398
 
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 					}
448 448
 
449 449
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
450
-					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0])+1);
450
+					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
451 451
 
452
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
452
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
453 453
 				}
454 454
 				break;
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
461 461
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
462
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
462
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
463 463
 
464 464
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
465 465
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 
516 516
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
517 517
 
518
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
518
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
519 519
 		}
520 520
 
521 521
 		return (!empty($titleData) ? $titleData : NULL);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
560 560
 
561
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
561
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
562 562
 		}
563 563
 
564 564
 		return (!empty($titleData) ? $titleData : NULL);
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
618 618
 
619 619
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
620
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
621
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
620
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
621
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
622 622
 			}
623 623
 		} else {
624 624
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
 					$titleData['title'] = $nodes_title->item(0)->textContent;
690 690
 
691 691
 					$firstRow      = $nodes_row->item(0);
692
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
692
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
693 693
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
694 694
 
695 695
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
696 696
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
697
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
698
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
697
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
698
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
699 699
 				}
700 700
 			} else {
701 701
 				//TODO: Throw ERRORS;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
720 720
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
721 721
 
722
-		if (strpos($title_url, '.') !== FALSE) {
722
+		if(strpos($title_url, '.') !== FALSE) {
723 723
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
724 724
 		} else {
725 725
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 
755 755
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
756 756
 
757
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
757
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
758 758
 		}
759 759
 
760 760
 		return (!empty($titleData) ? $titleData : NULL);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 
799 799
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
800 800
 
801
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
801
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
802 802
 		}
803 803
 
804 804
 		return (!empty($titleData) ? $titleData : NULL);
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		$chapter_parts = explode('/', $chapter);
820 820
 		return [
821 821
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
822
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
822
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
823 823
 		];
824 824
 	}
825 825
 
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 		$chapter_parts = explode('/', $chapter);
844 844
 		return [
845 845
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
846
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
846
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
847 847
 		];
848 848
 	}
849 849
 
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 		$chapter_parts = explode('/', $chapter);
868 868
 		return [
869 869
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
870
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
870
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
871 871
 		];
872 872
 	}
873 873
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		$chapter_parts = explode('/', $chapter);
892 892
 		return [
893 893
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
894
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
894
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
895 895
 		];
896 896
 	}
897 897
 
Please login to merge, or discard this patch.