@@ -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 | }); |
@@ -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 | |
@@ -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 | |
@@ -98,7 +100,9 @@ discard block |
||
| 98 | 100 | $baseFile = file_get_contents($baseFileName); |
| 99 | 101 | |
| 100 | 102 | $parse = parse_url($this->baseURL); |
| 101 | - if(strpos($baseFile, $parse['host']) !== false) die("Domain already exists in userscript?"); |
|
| 103 | + if(strpos($baseFile, $parse['host']) !== false) { |
|
| 104 | + die("Domain already exists in userscript?"); |
|
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | preg_match('/\@updated ([0-9\-]+)[\r\n]+.*?\@version ([0-9\.]+)/s', $baseFile, $matches); |
| 104 | 108 | |
@@ -188,7 +192,9 @@ discard block |
||
| 188 | 192 | } |
| 189 | 193 | } |
| 190 | 194 | |
| 191 | - if(empty($titleArr)) die("API isn't returning any titles?"); |
|
| 195 | + if(empty($titleArr)) { |
|
| 196 | + die("API isn't returning any titles?"); |
|
| 197 | + } |
|
| 192 | 198 | return $titleArr; |
| 193 | 199 | } |
| 194 | 200 | } |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | // detect and register all PHP errors in this log hence forth |
| 68 | 68 | ErrorHandler::register($this->log); |
| 69 | 69 | |
| 70 | - if ($this->config['introspection_processor']) |
|
| 71 | - { |
|
| 70 | + if ($this->config['introspection_processor']) { |
|
| 72 | 71 | // add controller and line number info to each log message |
| 73 | 72 | // 2 = depth in the stacktrace to ignore. This gives us the file |
| 74 | 73 | // making the call to log_message(); |
@@ -76,10 +75,8 @@ discard block |
||
| 76 | 75 | } |
| 77 | 76 | |
| 78 | 77 | // decide which handler(s) to use |
| 79 | - foreach ($this->config['handlers'] as $value) |
|
| 80 | - { |
|
| 81 | - switch ($value) |
|
| 82 | - { |
|
| 78 | + foreach ($this->config['handlers'] as $value) { |
|
| 79 | + switch ($value) { |
|
| 83 | 80 | case 'file': |
| 84 | 81 | $handler = new RotatingFileHandler($this->config['file_logfile']); |
| 85 | 82 | $formatter = new LineFormatter(null, null, $config['file_multiline']); |
@@ -140,35 +137,28 @@ discard block |
||
| 140 | 137 | * @param $msg |
| 141 | 138 | * @return bool |
| 142 | 139 | */ |
| 143 | - public function write_log($level = 'error', $msg) |
|
| 144 | - { |
|
| 140 | + public function write_log($level = 'error', $msg) { |
|
| 145 | 141 | $level = strtoupper($level); |
| 146 | 142 | |
| 147 | 143 | // verify error level |
| 148 | - if (!isset($this->_levels[$level])) |
|
| 149 | - { |
|
| 144 | + if (!isset($this->_levels[$level])) { |
|
| 150 | 145 | $this->log->addError('unknown error level: ' . $level); |
| 151 | 146 | $level = 'ALL'; |
| 152 | 147 | } |
| 153 | 148 | |
| 154 | 149 | // filter out anything in $this->config['exclusion_list'] |
| 155 | - if (!empty($this->config['exclusion_list'])) |
|
| 156 | - { |
|
| 157 | - foreach ($this->config['exclusion_list'] as $findme) |
|
| 158 | - { |
|
| 150 | + if (!empty($this->config['exclusion_list'])) { |
|
| 151 | + foreach ($this->config['exclusion_list'] as $findme) { |
|
| 159 | 152 | $pos = strpos($msg, $findme); |
| 160 | - if ($pos !== false) |
|
| 161 | - { |
|
| 153 | + if ($pos !== false) { |
|
| 162 | 154 | // just exit now - we don't want to log this error |
| 163 | 155 | return true; |
| 164 | 156 | } |
| 165 | 157 | } |
| 166 | 158 | } |
| 167 | 159 | |
| 168 | - if ($this->_levels[$level] <= $this->config['threshold']) |
|
| 169 | - { |
|
| 170 | - switch ($level) |
|
| 171 | - { |
|
| 160 | + if ($this->_levels[$level] <= $this->config['threshold']) { |
|
| 161 | + switch ($level) { |
|
| 172 | 162 | case 'ERROR': |
| 173 | 163 | $this->log->addError($msg); |
| 174 | 164 | break; |
@@ -125,7 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | final public function isValidTitleURL(string $title_url) : bool { |
| 127 | 127 | $success = (bool) preg_match($this->titleFormat, $title_url); |
| 128 | - if(!$success) log_message('error', "Invalid Title URL ({$this->site}): {$title_url}"); |
|
| 128 | + if(!$success) { |
|
| 129 | + log_message('error', "Invalid Title URL ({$this->site}): {$title_url}"); |
|
| 130 | + } |
|
| 129 | 131 | return $success; |
| 130 | 132 | } |
| 131 | 133 | |
@@ -139,7 +141,9 @@ discard block |
||
| 139 | 141 | */ |
| 140 | 142 | final public function isValidChapter(string $chapter) : bool { |
| 141 | 143 | $success = (bool) preg_match($this->chapterFormat, $chapter); |
| 142 | - if(!$success) log_message('error', "Invalid Chapter ({$this->site}): {$chapter}"); |
|
| 144 | + if(!$success) { |
|
| 145 | + log_message('error', "Invalid Chapter ({$this->site}): {$chapter}"); |
|
| 146 | + } |
|
| 143 | 147 | return $success; |
| 144 | 148 | } |
| 145 | 149 | |
@@ -168,14 +172,20 @@ discard block |
||
| 168 | 172 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
| 169 | 173 | curl_setopt($ch, CURLOPT_HEADER, 1); |
| 170 | 174 | |
| 171 | - if($follow_redirect) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
| 175 | + if($follow_redirect) { |
|
| 176 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
| 177 | + } |
|
| 172 | 178 | |
| 173 | 179 | if($cookies = $this->cache->get("cloudflare_{$this->site}")) { |
| 174 | 180 | $cookie_string .= "; {$cookies}"; |
| 175 | 181 | } |
| 176 | 182 | |
| 177 | - if(!empty($cookie_string)) curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
| 178 | - if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
| 183 | + if(!empty($cookie_string)) { |
|
| 184 | + curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
| 185 | + } |
|
| 186 | + if(!empty($cookiejar_path)) { |
|
| 187 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
| 188 | + } |
|
| 179 | 189 | |
| 180 | 190 | //Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff. |
| 181 | 191 | curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); |
@@ -206,7 +216,9 @@ discard block |
||
| 206 | 216 | $body = substr($response, $header_size); |
| 207 | 217 | curl_close($ch); |
| 208 | 218 | |
| 209 | - if($status_code === 503) $refresh = $this->handleCloudFlare($url, $body); |
|
| 219 | + if($status_code === 503) { |
|
| 220 | + $refresh = $this->handleCloudFlare($url, $body); |
|
| 221 | + } |
|
| 210 | 222 | } |
| 211 | 223 | |
| 212 | 224 | return [ |
@@ -312,7 +324,9 @@ discard block |
||
| 312 | 324 | 'nodes_chapter' => $nodes_chapter->item(0) |
| 313 | 325 | ]; |
| 314 | 326 | |
| 315 | - if(is_callable($extraCall)) $extraCall($xpath, $returnData); |
|
| 327 | + if(is_callable($extraCall)) { |
|
| 328 | + $extraCall($xpath, $returnData); |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | return $returnData; |
| 318 | 332 | } else { |
@@ -326,7 +340,9 @@ discard block |
||
| 326 | 340 | $noChaptersCall($data, $xpath, $returnData); |
| 327 | 341 | |
| 328 | 342 | if(is_array($returnData)) { |
| 329 | - if(is_callable($extraCall) && is_array($returnData)) $extraCall($xpath, $returnData); |
|
| 343 | + if(is_callable($extraCall) && is_array($returnData)) { |
|
| 344 | + $extraCall($xpath, $returnData); |
|
| 345 | + } |
|
| 330 | 346 | } else { |
| 331 | 347 | log_message('error', "{$this->site} : {$title_url} | canHaveNoChapters set, but doesn't match possible checks! XPath is probably broken."); |
| 332 | 348 | } |
@@ -461,8 +477,12 @@ discard block |
||
| 461 | 477 | $status = FALSE; |
| 462 | 478 | |
| 463 | 479 | //Make sure we have a volume element |
| 464 | - if(count($oldChapterSegments) === 1) array_unshift($oldChapterSegments, 'v0'); |
|
| 465 | - if(count($newChapterSegments) === 1) array_unshift($newChapterSegments, 'v0'); |
|
| 480 | + if(count($oldChapterSegments) === 1) { |
|
| 481 | + array_unshift($oldChapterSegments, 'v0'); |
|
| 482 | + } |
|
| 483 | + if(count($newChapterSegments) === 1) { |
|
| 484 | + array_unshift($newChapterSegments, 'v0'); |
|
| 485 | + } |
|
| 466 | 486 | |
| 467 | 487 | $oldCount = count($oldChapterSegments); |
| 468 | 488 | $newCount = count($newChapterSegments); |
@@ -475,8 +495,12 @@ discard block |
||
| 475 | 495 | $newVolume = substr(array_shift($newChapterSegments), 1); |
| 476 | 496 | |
| 477 | 497 | //Forcing volume to 0 as TBD might not be the latest (although it can be, but that is covered by other checks) |
| 478 | - if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $oldVolume = 0; |
|
| 479 | - if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $newVolume = 0; |
|
| 498 | + if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) { |
|
| 499 | + $oldVolume = 0; |
|
| 500 | + } |
|
| 501 | + if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) { |
|
| 502 | + $newVolume = 0; |
|
| 503 | + } |
|
| 480 | 504 | |
| 481 | 505 | $oldVolume = floatval($oldVolume); |
| 482 | 506 | $newVolume = floatval($newVolume); |
@@ -184,8 +184,7 @@ |
||
| 184 | 184 | print " - Something went wrong?\n"; |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | - } |
|
| 188 | - else { |
|
| 187 | + } else { |
|
| 189 | 188 | log_message('error', "{$row->site_class} | {$row->title} ({$row->title_url}) | Failed to update."); |
| 190 | 189 | $this->Tracker->title->updateFailedChecksByID((int) $row->title_id); |
| 191 | 190 | |