Completed
Push — master ( 4a50a3...305ec5 )
by Angus
09:08
created
application/models/Site_Model.php 2 patches
Spacing   +29 added lines, -29 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
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			$nodes_row   = $xpath->query($node_row_string);
112 112
 			if($nodes_title->length === 1 && $nodes_row->length === 1) {
113 113
 				$firstRow      = $nodes_row->item(0);
114
-				$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
114
+				$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
115 115
 
116 116
 				if($node_chapter_string !== '') {
117 117
 					$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 
240 240
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
241 241
 			$chapterURLSegments = explode('/', $link);
242
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
243
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
242
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
243
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
244 244
 		}
245 245
 
246 246
 		return (!empty($titleData) ? $titleData : NULL);
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 
285 285
 			$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
286 286
 			$chapterURLSegments = explode('/', $link);
287
-			$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
288
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
287
+			$titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : "");
288
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
289 289
 		}
290 290
 
291 291
 		return (!empty($titleData) ? $titleData : NULL);
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
 		$chapter_parts = explode(':--:', $chapter);
318 318
 		return [
319
-			'url'    => "http://bato.to/reader#" . $chapter_parts[0],
319
+			'url'    => "http://bato.to/reader#".$chapter_parts[0],
320 320
 			'number' => $chapter_parts[1]
321 321
 		];
322 322
 	}
@@ -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
 
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 
439 439
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
440 440
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
441
-			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '') . substr($matchesT[0], 3, -4);
441
+			$titleData['title'] = (!empty($matchesD) ? (substr($matchesD[1], 0, -7) !== 'Original' ? substr($matchesD[1], 0, -7).' - ' : '') : '').substr($matchesT[0], 3, -4);
442 442
 
443 443
 			$data = preg_replace('/^[\S\s]*(<dl class=\'chapter-list\'>[\S\s]*<\/dl>)[\S\s]*$/', '$1', $data);
444 444
 			preg_match_all('/<dd>[\s\S]+?(?=<\/dd>)<\/dd>/', $data, $matches);
445 445
 			$latest_chapter_html = array_pop($matches[0]);
446 446
 
447 447
 			preg_match('/\/chapters\/([^"]+)/', $latest_chapter_html, $matches);
448
-			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url)+1);
448
+			$titleData['latest_chapter'] = substr($matches[1], strlen($title_url) + 1);
449 449
 			//FIXME: THIS IS A TEMP FIX, SEE https://github.com/DakuTree/manga-tracker/issues/58
450 450
 			if(!$titleData['latest_chapter']) {
451 451
 				log_message('error', 'DynastyScans::getTitleData cannot parse title properly as it contains oneshot. || URL: '.$title_url);
@@ -453,14 +453,14 @@  discard block
 block discarded – undo
453 453
 			}
454 454
 
455 455
 			preg_match('/<small>released (.*)<\/small>/', $latest_chapter_html, $matches);
456
-			$titleData['last_updated']   = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
456
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace('\'', '', $matches[1])));
457 457
 		} elseif($title_parts[1] == '1') {
458 458
 			$content = $this->get_content('http://dynasty-scans.com/chapters/'.$title_url);
459 459
 			$data = $content['body'];
460 460
 
461 461
 			preg_match('/<b>.*<\/b>/', $data, $matchesT);
462 462
 			preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD);
463
-			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4);
463
+			$titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4);
464 464
 
465 465
 			$titleData['latest_chapter'] = 'oneshot'; //This will never change
466 466
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
516 516
 
517
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
517
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
518 518
 		}
519 519
 
520 520
 		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);
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 				$titleData['title'] = trim((string) $xml->{'channel'}->title);
615 615
 
616 616
 				$chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link));
617
-				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6];
618
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
617
+				$titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6];
618
+				$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate));
619 619
 			}
620 620
 		} else {
621 621
 			log_message('error', "Series missing? (WebToons): {$title_url}");
@@ -686,13 +686,13 @@  discard block
 block discarded – undo
686 686
 					$titleData['title'] = $nodes_title->item(0)->textContent;
687 687
 
688 688
 					$firstRow      = $nodes_row->item(0);
689
-					$nodes_latest  = $xpath->query("td[2]",   $firstRow);
689
+					$nodes_latest  = $xpath->query("td[2]", $firstRow);
690 690
 					$nodes_chapter = $xpath->query("td[1]/a", $firstRow);
691 691
 
692 692
 					$link = (string) $nodes_chapter->item(0)->getAttribute('href');
693 693
 					$chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link));
694
-					$titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link);
695
-					$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
694
+					$titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link);
695
+					$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent));
696 696
 				}
697 697
 			} else {
698 698
 				//TODO: Throw ERRORS;
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
 
747 747
 				$firstRow      = $nodes_row->item(0);
748 748
 				$nodes_latest  = $xpath->query("p[@class='author']/span|p[@class='author']/abbr", $firstRow);
749
-				$nodes_chapter = $xpath->query("p[@class='text_work']/a",                         $firstRow);
749
+				$nodes_chapter = $xpath->query("p[@class='text_work']/a", $firstRow);
750 750
 
751 751
 				$link = (string) $nodes_chapter->item(0)->getAttribute('href');
752 752
 				$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', $link);
753
-				$titleData['last_updated'] =  date("Y-m-d H:i:s", (int) $nodes_latest->item(0)->getAttribute('data-time'));
753
+				$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $nodes_latest->item(0)->getAttribute('data-time'));
754 754
 			} else {
755 755
 				log_message('error', "GameOfScanlation: Unable to find nodes.");
756 756
 				return NULL;
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 
802 802
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
803 803
 
804
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
804
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
805 805
 		}
806 806
 
807 807
 		return (!empty($titleData) ? $titleData : NULL);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		$chapter_parts = explode('/', $chapter);
823 823
 		return [
824 824
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
825
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
825
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
826 826
 		];
827 827
 	}
828 828
 
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 		$chapter_parts = explode('/', $chapter);
847 847
 		return [
848 848
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
849
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
849
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
850 850
 		];
851 851
 	}
852 852
 
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 		$chapter_parts = explode('/', $chapter);
871 871
 		return [
872 872
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
873
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
873
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
874 874
 		];
875 875
 	}
876 876
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 		$chapter_parts = explode('/', $chapter);
895 895
 		return [
896 896
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
897
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
897
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
898 898
 		];
899 899
 	}
900 900
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 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          = '';
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 				$data = preg_replace('/^[\S\s]*(<div id="leftside">[\S\s]*)<div id="rightside">[\S\s]*$/', '$1', $data);
675 675
 
676 676
 				$dom = new DOMDocument();
677
-				libxml_use_internal_errors(true);
677
+				libxml_use_internal_errors(TRUE);
678 678
 				$dom->loadHTML($data);
679
-				libxml_use_internal_errors(false);
679
+				libxml_use_internal_errors(FALSE);
680 680
 
681 681
 				$xpath = new DOMXPath($dom);
682 682
 
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
 			//$data = preg_replace('/^[\S\s]*(<ol[\S\s]*)<\/ol>[\S\s]*$/', '$1', $data);
734 734
 
735 735
 			$dom = new DOMDocument();
736
-			libxml_use_internal_errors(true);
736
+			libxml_use_internal_errors(TRUE);
737 737
 			$dom->loadHTML($data);
738
-			libxml_use_internal_errors(false);
738
+			libxml_use_internal_errors(FALSE);
739 739
 
740 740
 			$xpath = new DOMXPath($dom);
741 741
 
Please login to merge, or discard this patch.