Completed
Push — master ( eac71e...264733 )
by Angus
07:03
created
application/models/Site_Model.php 2 patches
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
 
@@ -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);
@@ -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;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 
747 747
 			$titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
748 748
 
749
-			$titleData['last_updated'] =  date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title'));
749
+			$titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title'));
750 750
 		}
751 751
 
752 752
 		return (!empty($titleData) ? $titleData : NULL);
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
 			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
793 793
 
794
-			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
794
+			$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13)));
795 795
 		}
796 796
 
797 797
 		return (!empty($titleData) ? $titleData : NULL);
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 		$chapter_parts = explode('/', $chapter);
813 813
 		return [
814 814
 			'url'    => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/",
815
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
815
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
816 816
 		];
817 817
 	}
818 818
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		$chapter_parts = explode('/', $chapter);
837 837
 		return [
838 838
 			'url'    => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/",
839
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
839
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
840 840
 		];
841 841
 	}
842 842
 
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 		$chapter_parts = explode('/', $chapter);
861 861
 		return [
862 862
 			'url'    => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/",
863
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
863
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
864 864
 		];
865 865
 	}
866 866
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 		$chapter_parts = explode('/', $chapter);
885 885
 		return [
886 886
 			'url'    => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/",
887
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
887
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
888 888
 		];
889 889
 	}
890 890
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 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          = '';
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 				$data = preg_replace('/^[\S\s]*(<div id="leftside">[\S\s]*)<div id="rightside">[\S\s]*$/', '$1', $data);
678 678
 
679 679
 				$dom = new DOMDocument();
680
-				libxml_use_internal_errors(true);
680
+				libxml_use_internal_errors(TRUE);
681 681
 				$dom->loadHTML($data);
682
-				libxml_use_internal_errors(false);
682
+				libxml_use_internal_errors(FALSE);
683 683
 
684 684
 				$xpath = new DOMXPath($dom);
685 685
 
Please login to merge, or discard this patch.