@@ -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 | |
@@ -82,7 +84,9 @@ discard block |
||
| 82 | 84 | $baseFile = file_get_contents('./public/userscripts/manga-tracker.user.js'); |
| 83 | 85 | |
| 84 | 86 | $parse = parse_url($this->baseURL); |
| 85 | - if(strpos($baseFile, $parse['host']) !== false) die("Domain already exists in userscript?"); |
|
| 87 | + if(strpos($baseFile, $parse['host']) !== false) { |
|
| 88 | + die("Domain already exists in userscript?"); |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | preg_match('/\@updated ([0-9\-]+)\r.*?\@version ([0-9\.]+)/s', $baseFile, $matches); |
| 88 | 92 | |
@@ -179,7 +183,9 @@ discard block |
||
| 179 | 183 | } |
| 180 | 184 | } |
| 181 | 185 | |
| 182 | - if(empty($titleArr)) die("API isn't returning any titles?"); |
|
| 186 | + if(empty($titleArr)) { |
|
| 187 | + die("API isn't returning any titles?"); |
|
| 188 | + } |
|
| 183 | 189 | return $titleArr; |
| 184 | 190 | } |
| 185 | 191 | } |
@@ -53,7 +53,8 @@ |
||
| 53 | 53 | $this->session->keep_flashdata('referred_from'); |
| 54 | 54 | if($prevURL = $this->session->flashdata('referred_from')) { |
| 55 | 55 | redirect($prevURL); |
| 56 | - } else { //@codeCoverageIgnore |
|
| 56 | + } else { |
|
| 57 | +//@codeCoverageIgnore |
|
| 57 | 58 | redirect('/'); //TODO (CHECK): Should this be refresh? |
| 58 | 59 | } //@codeCoverageIgnore |
| 59 | 60 | } else { |
@@ -114,11 +114,15 @@ |
||
| 114 | 114 | |
| 115 | 115 | if($sortOrder == 'asc') { |
| 116 | 116 | $unreadSort = ($a_text <=> $b_text); |
| 117 | - if($unreadSort) return $unreadSort; |
|
| 117 | + if($unreadSort) { |
|
| 118 | + return $unreadSort; |
|
| 119 | + } |
|
| 118 | 120 | return $a_text2 <=> $b_text2; |
| 119 | 121 | } else { |
| 120 | 122 | $unreadSort = ($a_text <=> $b_text); |
| 121 | - if($unreadSort) return $unreadSort; |
|
| 123 | + if($unreadSort) { |
|
| 124 | + return $unreadSort; |
|
| 125 | + } |
|
| 122 | 126 | return $b_text2 <=> $a_text2; |
| 123 | 127 | } |
| 124 | 128 | }); |
@@ -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); |
@@ -23,7 +23,9 @@ |
||
| 23 | 23 | $this->body_data['totalPages'] = $historyData['totalPages']; |
| 24 | 24 | $this->body_data['titleID'] = (int) $titleID; |
| 25 | 25 | |
| 26 | - if($page > $this->body_data['totalPages'] && $page > 1) redirect("/history/{$titleID}/1"); |
|
| 26 | + if($page > $this->body_data['totalPages'] && $page > 1) { |
|
| 27 | + redirect("/history/{$titleID}/1"); |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $this->_render_page("TitleHistory"); |
| 29 | 31 | |