|
@@ -118,7 +118,7 @@ discard block |
|
|
block discarded – undo |
|
118
|
118
|
//We don't want double trailing slashes, so fix this when possible. |
|
119
|
119
|
$pageSeparator = ''; |
|
120
|
120
|
} |
|
121
|
|
- $pageURL = $chapterData['url'] . $pageSeparator . $page; |
|
|
121
|
+ $pageURL = $chapterData['url'].$pageSeparator.$page; |
|
122
|
122
|
} |
|
123
|
123
|
return $pageURL; |
|
124
|
124
|
} |
|
@@ -212,7 +212,7 @@ discard block |
|
|
block discarded – undo |
|
212
|
212
|
|
|
213
|
213
|
$ch = curl_init(); |
|
214
|
214
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
215
|
|
- curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
|
215
|
+ curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
216
|
216
|
//curl_setopt($ch, CURLOPT_VERBOSE, 1); |
|
217
|
217
|
curl_setopt($ch, CURLOPT_HEADER, 1); |
|
218
|
218
|
|
|
@@ -234,8 +234,8 @@ discard block |
|
|
block discarded – undo |
|
234
|
234
|
curl_setopt($ch, CURLOPT_URL, $url); |
|
235
|
235
|
|
|
236
|
236
|
if($isPost) { |
|
237
|
|
- curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
238
|
|
- curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
|
237
|
+ curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
|
238
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
239
|
239
|
} |
|
240
|
240
|
|
|
241
|
241
|
$response = curl_exec($ch); |
|
@@ -282,7 +282,7 @@ discard block |
|
|
block discarded – undo |
|
282
|
282
|
$result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData))); |
|
283
|
283
|
$cookieData = json_decode($result, TRUE); |
|
284
|
284
|
|
|
285
|
|
- $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
|
285
|
+ $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
286
|
286
|
log_message('debug', "Saving CloudFlare Cookies for {$this->site}"); |
|
287
|
287
|
|
|
288
|
288
|
$refresh = TRUE; |
|
@@ -340,7 +340,7 @@ discard block |
|
|
block discarded – undo |
|
340
|
340
|
|
|
341
|
341
|
$dom = new DOMDocument(); |
|
342
|
342
|
libxml_use_internal_errors(TRUE); |
|
343
|
|
- $dom->loadHTML('<?xml encoding="utf-8" ?>' . $data); |
|
|
343
|
+ $dom->loadHTML('<?xml encoding="utf-8" ?>'.$data); |
|
344
|
344
|
libxml_use_internal_errors(FALSE); |
|
345
|
345
|
|
|
346
|
346
|
$xpath = new DOMXPath($dom); |
|
@@ -349,7 +349,7 @@ discard block |
|
|
block discarded – undo |
|
349
|
349
|
if($nodes_title->length === 1) { |
|
350
|
350
|
if($nodes_row->length === 1) { |
|
351
|
351
|
$firstRow = $nodes_row->item(0); |
|
352
|
|
- $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
|
352
|
+ $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
353
|
353
|
|
|
354
|
354
|
if($node_chapter_string !== '') { |
|
355
|
355
|
$nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
|
@@ -565,7 +565,7 @@ discard block |
|
|
block discarded – undo |
|
565
|
565
|
final private function _setSiteRateLimit(?int $rateLimit = NULL) : bool { |
|
566
|
566
|
//We would just use increment(), but we can't set ttl with it... |
|
567
|
567
|
$currentRateLimit = $rateLimit ?: $this->_getSiteRateLimit(); |
|
568
|
|
- return $this->cache->save("{$this->site}_ratelimit", $currentRateLimit + 1,3600); |
|
|
568
|
+ return $this->cache->save("{$this->site}_ratelimit", $currentRateLimit + 1, 3600); |
|
569
|
569
|
} |
|
570
|
570
|
} |
|
571
|
571
|
|
|
@@ -583,7 +583,7 @@ discard block |
|
|
block discarded – undo |
|
583
|
583
|
$chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/) |
|
584
|
584
|
return [ |
|
585
|
585
|
'url' => $this->getChapterURL($title_url, $chapter), |
|
586
|
|
- 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
|
586
|
+ 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
587
|
587
|
]; |
|
588
|
588
|
} |
|
589
|
589
|
public function getChapterURL(string $title_url, string $chapter) : string { |
|
@@ -768,9 +768,9 @@ discard block |
|
|
block discarded – undo |
|
768
|
768
|
|
|
769
|
769
|
$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. |
|
770
|
770
|
if($dateString == 'T') { |
|
771
|
|
- $dateString = date("Y-m-d",now()); |
|
|
771
|
+ $dateString = date("Y-m-d", now()); |
|
772
|
772
|
} |
|
773
|
|
- $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString . ' 00:00')); |
|
|
773
|
+ $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString.' 00:00')); |
|
774
|
774
|
|
|
775
|
775
|
$titleDataList[$title_url] = $titleData; |
|
776
|
776
|
} |
|
@@ -935,11 +935,11 @@ discard block |
|
|
block discarded – undo |
|
935
|
935
|
"" |
|
936
|
936
|
); |
|
937
|
937
|
if($data) { |
|
938
|
|
- $titleData['title'] = trim(preg_replace('/ Added on .*$/','', $data['nodes_title']->textContent)); |
|
|
938
|
+ $titleData['title'] = trim(preg_replace('/ Added on .*$/', '', $data['nodes_title']->textContent)); |
|
939
|
939
|
$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
|
940
|
940
|
|
|
941
|
|
- $dateString = preg_replace('/^Added (?:on )?/', '',$data['nodes_latest']->textContent); |
|
942
|
|
- $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
|
941
|
+ $dateString = preg_replace('/^Added (?:on )?/', '', $data['nodes_latest']->textContent); |
|
|
942
|
+ $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
943
|
943
|
} |
|
944
|
944
|
return (!empty($titleData) ? $titleData : NULL); |
|
945
|
945
|
} |
|
@@ -1017,9 +1017,9 @@ discard block |
|
|
block discarded – undo |
|
1017
|
1017
|
public function getChapterData(string $title_url, string $chapter) : array { |
|
1018
|
1018
|
if(strpos($chapter, '/')) { |
|
1019
|
1019
|
$chapterArr = explode('/', $chapter); |
|
1020
|
|
- $chapterN = "v{$chapterArr[0]}/c".str_replace('chapter_','',$chapterArr[1]); |
|
1021
|
|
- } else if (ctype_digit($chapter)) { |
|
1022
|
|
- $chapterN = 'c'.str_replace('chapter_','', $chapter); |
|
|
1020
|
+ $chapterN = "v{$chapterArr[0]}/c".str_replace('chapter_', '', $chapterArr[1]); |
|
|
1021
|
+ } else if(ctype_digit($chapter)) { |
|
|
1022
|
+ $chapterN = 'c'.str_replace('chapter_', '', $chapter); |
|
1023
|
1023
|
} |
|
1024
|
1024
|
return [ |
|
1025
|
1025
|
'url' => $this->getChapterURL($title_url, $chapter), |