|
@@ -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
|
/** |
|
4
|
4
|
* Class Tracker_Sites_Model |
|
@@ -181,7 +181,7 @@ discard block |
|
|
block discarded – undo |
|
181
|
181
|
|
|
182
|
182
|
$ch = curl_init(); |
|
183
|
183
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
184
|
|
- curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
|
184
|
+ curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
185
|
185
|
//curl_setopt($ch, CURLOPT_VERBOSE, 1); |
|
186
|
186
|
curl_setopt($ch, CURLOPT_HEADER, 1); |
|
187
|
187
|
|
|
@@ -203,8 +203,8 @@ discard block |
|
|
block discarded – undo |
|
203
|
203
|
curl_setopt($ch, CURLOPT_URL, $url); |
|
204
|
204
|
|
|
205
|
205
|
if($isPost) { |
|
206
|
|
- curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
207
|
|
- curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
|
206
|
+ curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
|
207
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
208
|
208
|
} |
|
209
|
209
|
|
|
210
|
210
|
$response = curl_exec($ch); |
|
@@ -251,7 +251,7 @@ discard block |
|
|
block discarded – undo |
|
251
|
251
|
$result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData))); |
|
252
|
252
|
$cookieData = json_decode($result, TRUE); |
|
253
|
253
|
|
|
254
|
|
- $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
|
254
|
+ $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
255
|
255
|
log_message('debug', "Saving CloudFlare Cookies for {$this->site}"); |
|
256
|
256
|
|
|
257
|
257
|
$refresh = TRUE; |
|
@@ -309,7 +309,7 @@ discard block |
|
|
block discarded – undo |
|
309
|
309
|
|
|
310
|
310
|
$dom = new DOMDocument(); |
|
311
|
311
|
libxml_use_internal_errors(TRUE); |
|
312
|
|
- $dom->loadHTML('<?xml encoding="utf-8" ?>' . $data); |
|
|
312
|
+ $dom->loadHTML('<?xml encoding="utf-8" ?>'.$data); |
|
313
|
313
|
libxml_use_internal_errors(FALSE); |
|
314
|
314
|
|
|
315
|
315
|
$xpath = new DOMXPath($dom); |
|
@@ -318,7 +318,7 @@ discard block |
|
|
block discarded – undo |
|
318
|
318
|
if($nodes_title->length === 1) { |
|
319
|
319
|
if($nodes_row->length === 1) { |
|
320
|
320
|
$firstRow = $nodes_row->item(0); |
|
321
|
|
- $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
|
321
|
+ $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
322
|
322
|
|
|
323
|
323
|
if($node_chapter_string !== '') { |
|
324
|
324
|
$nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
|
@@ -534,7 +534,7 @@ discard block |
|
|
block discarded – undo |
|
534
|
534
|
final private function _setSiteRateLimit(?int $rateLimit = NULL) : bool { |
|
535
|
535
|
//We would just use increment(), but we can't set ttl with it... |
|
536
|
536
|
$currentRateLimit = $rateLimit ?: $this->_getSiteRateLimit(); |
|
537
|
|
- return $this->cache->save("{$this->site}_ratelimit", $currentRateLimit + 1,3600); |
|
|
537
|
+ return $this->cache->save("{$this->site}_ratelimit", $currentRateLimit + 1, 3600); |
|
538
|
538
|
} |
|
539
|
539
|
} |
|
540
|
540
|
|
|
@@ -551,7 +551,7 @@ discard block |
|
|
block discarded – undo |
|
551
|
551
|
$chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/) |
|
552
|
552
|
return [ |
|
553
|
553
|
'url' => $this->getChapterURL($title_url, $chapter), |
|
554
|
|
- 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
|
554
|
+ 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
555
|
555
|
]; |
|
556
|
556
|
} |
|
557
|
557
|
public function getChapterURL(string $title_url, string $chapter) : string { |
|
@@ -735,9 +735,9 @@ discard block |
|
|
block discarded – undo |
|
735
|
735
|
|
|
736
|
736
|
$dateString = str_replace('/', '-', trim($nodes_latest->item(0)->nodeValue)); //NOTE: We replace slashes here as it stops strtotime interpreting the date as US date format. |
|
737
|
737
|
if($dateString == 'T') { |
|
738
|
|
- $dateString = date("Y-m-d",now()); |
|
|
738
|
+ $dateString = date("Y-m-d", now()); |
|
739
|
739
|
} |
|
740
|
|
- $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString . ' 00:00')); |
|
|
740
|
+ $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString.' 00:00')); |
|
741
|
741
|
|
|
742
|
742
|
$titleDataList[$title_url] = $titleData; |
|
743
|
743
|
} |
|
@@ -795,7 +795,7 @@ discard block |
|
|
block discarded – undo |
|
795
|
795
|
//For whatever reason, DOMDocument breaks the <link> element we need to grab the chapter, so we have to grab it elsewhere. |
|
796
|
796
|
$titleData['latest_chapter'] = preg_replace('/^.*? - ([0-9\.]+) - .*?$/', '$1', trim($data['nodes_chapter']->textContent)); |
|
797
|
797
|
|
|
798
|
|
- $titleData['last_updated'] = date('Y-m-d H:i:s', strtotime((string) $data['nodes_latest']->textContent)); |
|
|
798
|
+ $titleData['last_updated'] = date('Y-m-d H:i:s', strtotime((string) $data['nodes_latest']->textContent)); |
|
799
|
799
|
} |
|
800
|
800
|
|
|
801
|
801
|
return (!empty($titleData) ? $titleData : NULL); |
|
@@ -901,11 +901,11 @@ discard block |
|
|
block discarded – undo |
|
901
|
901
|
"" |
|
902
|
902
|
); |
|
903
|
903
|
if($data) { |
|
904
|
|
- $titleData['title'] = trim(preg_replace('/ Added on .*$/','', $data['nodes_title']->textContent)); |
|
|
904
|
+ $titleData['title'] = trim(preg_replace('/ Added on .*$/', '', $data['nodes_title']->textContent)); |
|
905
|
905
|
$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
|
906
|
906
|
|
|
907
|
|
- $dateString = preg_replace('/^Added (?:on )?/', '',$data['nodes_latest']->textContent); |
|
908
|
|
- $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
|
907
|
+ $dateString = preg_replace('/^Added (?:on )?/', '', $data['nodes_latest']->textContent); |
|
|
908
|
+ $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
909
|
909
|
} |
|
910
|
910
|
return (!empty($titleData) ? $titleData : NULL); |
|
911
|
911
|
} |