@@ -1,4 +1,4 @@ |
||
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 | class FallenAngelsScans extends Base_myMangaReaderCMS_Site_Model { |
4 | 4 | public $baseURL = 'https://manga.fascans.com'; |
@@ -1,4 +1,4 @@ |
||
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 | class FallenAngelsScans extends Base_myMangaReaderCMS_Site_Model { |
4 | 4 | public $baseURL = 'https://manga.fascans.com'; |
@@ -1,11 +1,11 @@ |
||
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 | //Because we can't autoload the cache driver with params - https://forum.codeigniter.com/thread-62217-post-319687.html#pid319687 |
4 | 4 | class Cacher { |
5 | 5 | protected $CI; |
6 | 6 | |
7 | 7 | public function __construct() { |
8 | - $this->CI =& get_instance(); //grab an instance of CI |
|
8 | + $this->CI = & get_instance(); //grab an instance of CI |
|
9 | 9 | $this->initiate_cache(); |
10 | 10 | } |
11 | 11 |
@@ -1,4 +1,4 @@ discard block |
||
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 | /** |
4 | 4 | * Class Tracker_Sites_Model |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param bool $firstGet |
103 | 103 | * @return array|null [title,latest_chapter,last_updated,followed?] |
104 | 104 | */ |
105 | - abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array; |
|
105 | + abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Validates given $title_url against titleFormat. |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | $ch = curl_init(); |
155 | 155 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
156 | - curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
156 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
157 | 157 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
158 | 158 | curl_setopt($ch, CURLOPT_HEADER, 1); |
159 | 159 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | curl_setopt($ch, CURLOPT_URL, $url); |
176 | 176 | |
177 | 177 | if($isPost) { |
178 | - curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
179 | - curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
178 | + curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
179 | + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $response = curl_exec($ch); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData))); |
221 | 221 | $cookieData = json_decode($result, TRUE); |
222 | 222 | |
223 | - $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
223 | + $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
224 | 224 | log_message('debug', "Saving CloudFlare Cookies for {$this->site}"); |
225 | 225 | |
226 | 226 | $refresh = TRUE; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | $dom = new DOMDocument(); |
273 | 273 | libxml_use_internal_errors(TRUE); |
274 | - $dom->loadHTML('<?xml encoding="utf-8" ?>' . $data); |
|
274 | + $dom->loadHTML('<?xml encoding="utf-8" ?>'.$data); |
|
275 | 275 | libxml_use_internal_errors(FALSE); |
276 | 276 | |
277 | 277 | $xpath = new DOMXPath($dom); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $nodes_row = $xpath->query($node_row_string); |
280 | 280 | if($nodes_title->length === 1 && $nodes_row->length === 1) { |
281 | 281 | $firstRow = $nodes_row->item(0); |
282 | - $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
282 | + $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
283 | 283 | |
284 | 284 | if($node_chapter_string !== '') { |
285 | 285 | $nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | $chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/) |
468 | 468 | return [ |
469 | 469 | 'url' => $this->getChapterURL($title_url, $chapter), |
470 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
470 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
471 | 471 | ]; |
472 | 472 | } |
473 | 473 | public function getChapterURL(string $title_url, string $chapter) : string { |
474 | 474 | return "{$this->baseURL}/read/{$title_url}/{$chapter}/"; |
475 | 475 | } |
476 | 476 | |
477 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
477 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
478 | 478 | $titleData = []; |
479 | 479 | |
480 | 480 | $jsonURL = $this->getJSONTitleURL($title_url); |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | return $this->getFullTitleURL($title_url).'/'.$chapter; |
595 | 595 | } |
596 | 596 | |
597 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
597 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
598 | 598 | $titleData = []; |
599 | 599 | |
600 | 600 | $fullURL = $this->getFullTitleURL($title_url); |
@@ -114,7 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | final public function isValidTitleURL(string $title_url) : bool { |
116 | 116 | $success = (bool) preg_match($this->titleFormat, $title_url); |
117 | - if(!$success) log_message('error', "Invalid Title URL ({$this->site}): {$title_url}"); |
|
117 | + if(!$success) { |
|
118 | + log_message('error', "Invalid Title URL ({$this->site}): {$title_url}"); |
|
119 | + } |
|
118 | 120 | return $success; |
119 | 121 | } |
120 | 122 | |
@@ -128,7 +130,9 @@ discard block |
||
128 | 130 | */ |
129 | 131 | final public function isValidChapter(string $chapter) : bool { |
130 | 132 | $success = (bool) preg_match($this->chapterFormat, $chapter); |
131 | - if(!$success) log_message('error', "Invalid Chapter ({$this->site}): {$chapter}"); |
|
133 | + if(!$success) { |
|
134 | + log_message('error', "Invalid Chapter ({$this->site}): {$chapter}"); |
|
135 | + } |
|
132 | 136 | return $success; |
133 | 137 | } |
134 | 138 | |
@@ -157,14 +161,20 @@ discard block |
||
157 | 161 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
158 | 162 | curl_setopt($ch, CURLOPT_HEADER, 1); |
159 | 163 | |
160 | - if($follow_redirect) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
164 | + if($follow_redirect) { |
|
165 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
166 | + } |
|
161 | 167 | |
162 | 168 | if($cookies = $this->cache->get("cloudflare_{$this->site}")) { |
163 | 169 | $cookie_string .= "; {$cookies}"; |
164 | 170 | } |
165 | 171 | |
166 | - if(!empty($cookie_string)) curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
167 | - if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
172 | + if(!empty($cookie_string)) { |
|
173 | + curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
174 | + } |
|
175 | + if(!empty($cookiejar_path)) { |
|
176 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
177 | + } |
|
168 | 178 | |
169 | 179 | //Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff. |
170 | 180 | curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); |
@@ -192,7 +202,9 @@ discard block |
||
192 | 202 | $body = substr($response, $header_size); |
193 | 203 | curl_close($ch); |
194 | 204 | |
195 | - if($status_code === 503) $refresh = $this->handleCloudFlare($url, $body); |
|
205 | + if($status_code === 503) { |
|
206 | + $refresh = $this->handleCloudFlare($url, $body); |
|
207 | + } |
|
196 | 208 | } |
197 | 209 | |
198 | 210 | return [ |
@@ -405,8 +417,12 @@ discard block |
||
405 | 417 | $status = FALSE; |
406 | 418 | |
407 | 419 | //Make sure we have a volume element |
408 | - if(count($oldChapterSegments) === 1) array_unshift($oldChapterSegments, 'v0'); |
|
409 | - if(count($newChapterSegments) === 1) array_unshift($newChapterSegments, 'v0'); |
|
420 | + if(count($oldChapterSegments) === 1) { |
|
421 | + array_unshift($oldChapterSegments, 'v0'); |
|
422 | + } |
|
423 | + if(count($newChapterSegments) === 1) { |
|
424 | + array_unshift($newChapterSegments, 'v0'); |
|
425 | + } |
|
410 | 426 | |
411 | 427 | $oldCount = count($oldChapterSegments); |
412 | 428 | $newCount = count($newChapterSegments); |
@@ -419,8 +435,12 @@ discard block |
||
419 | 435 | $newVolume = substr(array_shift($newChapterSegments), 1); |
420 | 436 | |
421 | 437 | //Forcing volume to 0 as TBD might not be the latest (although it can be, but that is covered by other checks) |
422 | - if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $oldVolume = 0; |
|
423 | - if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $newVolume = 0; |
|
438 | + if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) { |
|
439 | + $oldVolume = 0; |
|
440 | + } |
|
441 | + if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) { |
|
442 | + $newVolume = 0; |
|
443 | + } |
|
424 | 444 | |
425 | 445 | $oldVolume = floatval($oldVolume); |
426 | 446 | $newVolume = floatval($newVolume); |
@@ -1,4 +1,4 @@ discard block |
||
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 | /** |
4 | 4 | * Class Tracker_Sites_Model |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | final private function handleCloudFlare(string $url, string $body) : bool { |
206 | 206 | $refresh = FALSE; |
207 | 207 | |
208 | - if(strpos($body, 'DDoS protection by Cloudflare') !== false) { |
|
208 | + if(strpos($body, 'DDoS protection by Cloudflare') !== FALSE) { |
|
209 | 209 | //print "Cloudflare detected? Grabbing Cookies.\n"; |
210 | 210 | if(!$this->hasCloudFlare) { |
211 | 211 | //TODO: Site appears to have enabled CloudFlare, disable it and contact admin. |