Completed
Push — master ( 309124...31e2f4 )
by Angus
04:05
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
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 				$nodes_row   = $xpath->query($node_row_string);
113 113
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
114 114
 					$firstRow      = $nodes_row->item(0);
115
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
115
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
116 116
 
117 117
 					if($node_chapter_string !== '') {
118 118
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 
242 242
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
243 243
 			$chapterURLSegments = explode('/', $link);
244
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
245
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
244
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
245
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
246 246
 		}
247 247
 
248 248
 		return (!empty($titleData) ? $titleData : NULL);
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 
286 286
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
287 287
 			$chapterURLSegments = explode('/', $link);
288
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
289
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
288
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
289
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
290 290
 		}
291 291
 
292 292
 		return (!empty($titleData) ? $titleData : NULL);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 		$chapter_parts = explode(':--:', $chapter);
319 319
 		return [
320
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
320
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
321 321
 			'number' => $chapter_parts[1]
322 322
 		];
323 323
 	}
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
 
353 353
 			///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/
354 354
 			preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text);
355
-			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : ''));
355
+			$titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : ''));
356 356
 
357 357
 			$dateString = $data['nodes_latest']->nodeValue;
358 358
 			if($dateString == 'An hour ago') {
359 359
 				$dateString = '1 hour ago';
360 360
 			}
361
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
361
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString)));
362 362
 		}
363 363
 
364 364
 		return (!empty($titleData) ? $titleData : NULL);
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 		*/
398 398
 
399 399
 		$chapterData = [
400
-			'url'    => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter,
400
+			'url'    => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter,
401 401
 			'number' => ''
402 402
 		];
403 403
 
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
 					}
453 453
 
454 454
 					$chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href'));
455
-					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0])+1);
455
+					$titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1);
456 456
 
457
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
457
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9))));
458 458
 				}
459 459
 				break;
460 460
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 
465 465
 				preg_match('/<b>.*<\/b>/', $data, $matchesT);
466 466
 				preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
467
-				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
467
+				$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
468 468
 
469 469
 				$titleData['latest_chapter'] = 'oneshot'; //This will never change
470 470
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
522 522
 
523
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
523
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
524 524
 		}
525 525
 
526 526
 		return (!empty($titleData) ? $titleData : NULL);
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
 			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
565 565
 
566
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
566
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
567 567
 		}
568 568
 
569 569
 		return (!empty($titleData) ? $titleData : NULL);
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
623 623
 
624 624
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
625
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
626
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
625
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
626
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
627 627
 			}
628 628
 		} else {
629 629
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 					$titleData['title'] = $nodes_title->item(0)->textContent;
695 695
 
696 696
 					$firstRow      = $nodes_row->item(0);
697
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
697
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
698 698
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
699 699
 
700 700
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
701 701
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
702
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
703
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
702
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
703
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
704 704
 				}
705 705
 			} else {
706 706
 				//TODO: Throw ERRORS;
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 		         The bad thing is these are interchangeable, despite them showing the exact same listing page.
725 725
 		         Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */
726 726
 
727
-		if (strpos($title_url, '.') !== FALSE) {
727
+		if(strpos($title_url, '.') !== FALSE) {
728 728
 			$format = "https://gameofscanlation.moe/forums/{$title_url}/";
729 729
 		} else {
730 730
 			$format = "https://gameofscanlation.moe/projects/{$title_url}/";
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 
760 760
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
761 761
 
762
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
762
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
763 763
 		}
764 764
 
765 765
 		return (!empty($titleData) ? $titleData : NULL);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 
804 804
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
805 805
 
806
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
806
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
807 807
 		}
808 808
 
809 809
 		return (!empty($titleData) ? $titleData : NULL);
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		$chapter_parts = explode('/', $chapter);
825 825
 		return [
826 826
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
827
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
827
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
828 828
 		];
829 829
 	}
830 830
 
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 		$chapter_parts = explode('/', $chapter);
849 849
 		return [
850 850
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
851
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
851
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
852 852
 		];
853 853
 	}
854 854
 
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 		$chapter_parts = explode('/', $chapter);
873 873
 		return [
874 874
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
875
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
875
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
876 876
 		];
877 877
 	}
878 878
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 		$chapter_parts = explode('/', $chapter);
897 897
 		return [
898 898
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
899
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
899
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
900 900
 		];
901 901
 	}
902 902
 
Please login to merge, or discard this patch.