@@ -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 |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $ch = curl_init(); |
| 164 | 164 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 165 | - curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
| 165 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
| 166 | 166 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
| 167 | 167 | curl_setopt($ch, CURLOPT_HEADER, 1); |
| 168 | 168 | |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | curl_setopt($ch, CURLOPT_URL, $url); |
| 185 | 185 | |
| 186 | 186 | if($isPost) { |
| 187 | - curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
| 188 | - curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
| 187 | + curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
| 188 | + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $response = curl_exec($ch); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData))); |
| 233 | 233 | $cookieData = json_decode($result, TRUE); |
| 234 | 234 | |
| 235 | - $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
| 235 | + $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
| 236 | 236 | log_message('debug', "Saving CloudFlare Cookies for {$this->site}"); |
| 237 | 237 | |
| 238 | 238 | $refresh = TRUE; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $dom = new DOMDocument(); |
| 285 | 285 | libxml_use_internal_errors(TRUE); |
| 286 | - $dom->loadHTML('<?xml encoding="utf-8" ?>' . $data); |
|
| 286 | + $dom->loadHTML('<?xml encoding="utf-8" ?>'.$data); |
|
| 287 | 287 | libxml_use_internal_errors(FALSE); |
| 288 | 288 | |
| 289 | 289 | $xpath = new DOMXPath($dom); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | $nodes_row = $xpath->query($node_row_string); |
| 292 | 292 | if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 293 | 293 | $firstRow = $nodes_row->item(0); |
| 294 | - $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
| 294 | + $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
| 295 | 295 | |
| 296 | 296 | if($node_chapter_string !== '') { |
| 297 | 297 | $nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | $chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/) |
| 486 | 486 | return [ |
| 487 | 487 | 'url' => $this->getChapterURL($title_url, $chapter), |
| 488 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 488 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 489 | 489 | ]; |
| 490 | 490 | } |
| 491 | 491 | public function getChapterURL(string $title_url, string $chapter) : string { |
@@ -680,9 +680,9 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | $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. |
| 682 | 682 | if($dateString == 'T') { |
| 683 | - $dateString = date("Y-m-d",now()); |
|
| 683 | + $dateString = date("Y-m-d", now()); |
|
| 684 | 684 | } |
| 685 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString . ' 00:00')); |
|
| 685 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString.' 00:00')); |
|
| 686 | 686 | |
| 687 | 687 | $titleDataList[$title_url] = $titleData; |
| 688 | 688 | } |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | //For whatever reason, DOMDocument breaks the <link> element we need to grab the chapter, so we have to grab it elsewhere. |
| 738 | 738 | $titleData['latest_chapter'] = preg_replace('/^.*? - ([0-9\.]+) - .*?$/', '$1', trim($data['nodes_chapter']->textContent)); |
| 739 | 739 | |
| 740 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->textContent)); |
|
| 740 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->textContent)); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | return (!empty($titleData) ? $titleData : NULL); |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | "" |
| 840 | 840 | ); |
| 841 | 841 | if($data) { |
| 842 | - $titleData['title'] = trim(preg_replace('/ Added on .*$/','', $data['nodes_title']->textContent)); |
|
| 842 | + $titleData['title'] = trim(preg_replace('/ Added on .*$/', '', $data['nodes_title']->textContent)); |
|
| 843 | 843 | $titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 844 | 844 | |
| 845 | - $dateString = preg_replace('/^Added (?:on )?/', '',$data['nodes_latest']->textContent); |
|
| 846 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
| 845 | + $dateString = preg_replace('/^Added (?:on )?/', '', $data['nodes_latest']->textContent); |
|
| 846 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime($dateString)); |
|
| 847 | 847 | } |
| 848 | 848 | return (!empty($titleData) ? $titleData : NULL); |
| 849 | 849 | } |
@@ -1,6 +1,8 @@ discard block |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | 2 | |
| 3 | -if(!extension_loaded('gd')) die('GD ext is required to run this!'); |
|
| 3 | +if(!extension_loaded('gd')) { |
|
| 4 | + die('GD ext is required to run this!'); |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | chdir(dirname(__FILE__).'/../'); //Just to make things easier, change dir to project root. |
| 6 | 8 | |
@@ -9,7 +11,7 @@ discard block |
||
| 9 | 11 | private $className; |
| 10 | 12 | |
| 11 | 13 | public function __construct() { |
| 12 | - if(isset($_SERVER['argv']) && count($_SERVER['argv']) === 3){ |
|
| 14 | + if(isset($_SERVER['argv']) && count($_SERVER['argv']) === 3) { |
|
| 13 | 15 | $this->baseURL = rtrim($_SERVER['argv'][1], '/'); |
| 14 | 16 | $this->className = $_SERVER['argv'][2]; |
| 15 | 17 | |
@@ -91,7 +93,9 @@ discard block |
||
| 91 | 93 | $baseFile = file_get_contents('./public/userscripts/manga-tracker.user.js'); |
| 92 | 94 | |
| 93 | 95 | $parse = parse_url($this->baseURL); |
| 94 | - if(strpos($baseFile, $parse['host']) !== false) die("Domain already exists in userscript?"); |
|
| 96 | + if(strpos($baseFile, $parse['host']) !== false) { |
|
| 97 | + die("Domain already exists in userscript?"); |
|
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | preg_match('/\@updated ([0-9\-]+)[\r\n]+.*?\@version ([0-9\.]+)/s', $baseFile, $matches); |
| 97 | 101 | |
@@ -181,7 +185,9 @@ discard block |
||
| 181 | 185 | } |
| 182 | 186 | } |
| 183 | 187 | |
| 184 | - if(empty($titleArr)) die("API isn't returning any titles?"); |
|
| 188 | + if(empty($titleArr)) { |
|
| 189 | + die("API isn't returning any titles?"); |
|
| 190 | + } |
|
| 185 | 191 | return $titleArr; |
| 186 | 192 | } |
| 187 | 193 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | //Replace class names |
| 69 | 69 | $baseFile = str_replace('class HelveticaScans', "class {$this->className}", $baseFile); |
| 70 | - $baseFile = str_replace('coversDefaultClass HelveticaScans', "coversDefaultClass {$this->className}", $baseFile); |
|
| 70 | + $baseFile = str_replace('coversDefaultClass HelveticaScans', "coversdefaultclass {$this->className}", $baseFile); |
|
| 71 | 71 | |
| 72 | 72 | //Replace tests |
| 73 | 73 | $titleList = $this->getTitles(); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $baseFile = file_get_contents('./public/userscripts/manga-tracker.user.js'); |
| 92 | 92 | |
| 93 | 93 | $parse = parse_url($this->baseURL); |
| 94 | - if(strpos($baseFile, $parse['host']) !== false) die("Domain already exists in userscript?"); |
|
| 94 | + if(strpos($baseFile, $parse['host']) !== FALSE) die("Domain already exists in userscript?"); |
|
| 95 | 95 | |
| 96 | 96 | preg_match('/\@updated ([0-9\-]+)[\r\n]+.*?\@version ([0-9\.]+)/s', $baseFile, $matches); |
| 97 | 97 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $require = <<<EOT |
| 114 | 114 | // @require https://trackr.moe/userscripts/sites/{$this->className}.1.js |
| 115 | 115 | // @resource fontAwesome |
| 116 | -EOT; |
|
| 116 | +eot; |
|
| 117 | 117 | $baseFile = str_replace('// @resource fontAwesome', $require, $baseFile); |
| 118 | 118 | |
| 119 | 119 | file_put_contents('./public/userscripts/manga-tracker.user.js', $baseFile); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | }; |
| 140 | 140 | })(window.trackerSites = (window.trackerSites || {})); |
| 141 | 141 | |
| 142 | -EOT; |
|
| 142 | +eot; |
|
| 143 | 143 | |
| 144 | 144 | file_put_contents("./public/userscripts/sites/{$this->className}.js", $siteData); |
| 145 | 145 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $ch = curl_init("{$this->baseURL}/api/reader/chapters/orderby/desc_created/format/json"); |
| 161 | 161 | |
| 162 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 163 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 162 | + curl_setopt($ch, CURLOPT_NOBODY, TRUE); |
|
| 163 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
| 164 | 164 | curl_exec($ch); |
| 165 | 165 | $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 166 | 166 | curl_close($ch); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | if($content = file_get_contents($jsonURL)) { |
| 175 | 175 | $json = json_decode($content, TRUE); |
| 176 | 176 | shuffle($json['comics']); |
| 177 | - $comics = array_slice($json['comics'], 0, 5, true); |
|
| 177 | + $comics = array_slice($json['comics'], 0, 5, TRUE); |
|
| 178 | 178 | |
| 179 | 179 | foreach($comics as $comic) { |
| 180 | 180 | $titleArr[$comic['stub']] = $comic['name']; |