@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | class MY_Config extends CI_Config { |
| 4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
| 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 |
@@ -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); |
@@ -531,6 +531,10 @@ |
||
| 531 | 531 | final private function _getSiteRateLimit() : int { |
| 532 | 532 | return (int) ($this->cache->get("{$this->site}_ratelimit") ?: 0); |
| 533 | 533 | } |
| 534 | + |
|
| 535 | + /** |
|
| 536 | + * @param integer $rateLimit |
|
| 537 | + */ |
|
| 534 | 538 | final private function _setSiteRateLimit(?int $rateLimit = NULL) : bool { |
| 535 | 539 | //We would just use increment(), but we can't set ttl with it... |
| 536 | 540 | $currentRateLimit = $rateLimit ?: $this->_getSiteRateLimit(); |
@@ -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 |
@@ -181,7 +181,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -1,11 +1,11 @@ |
||
| 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 | //Because we can't autoload the cache driver with params - https://forum.codeigniter.com/thread-62217-post-319687.html#pid319687 |
| 4 | 4 | class Cacher { |
| 5 | 5 | protected $CI; |
| 6 | 6 | |
| 7 | 7 | public function __construct() { |
| 8 | - $this->CI =& get_instance(); //grab an instance of CI |
|
| 8 | + $this->CI = & get_instance(); //grab an instance of CI |
|
| 9 | 9 | $this->initiate_cache(); |
| 10 | 10 | } |
| 11 | 11 | |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | |
| 12 | 12 | //This is pretty barebones issue reporting, and honestly not a great way to do it, but it works for now (until the Github is public). |
| 13 | 13 | $body = "". |
| 14 | - (!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : ""). |
|
| 15 | - "Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n". |
|
| 16 | - "<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000)); |
|
| 14 | + (!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : ""). |
|
| 15 | + "Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n". |
|
| 16 | + "<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000)); |
|
| 17 | 17 | |
| 18 | 18 | $success = TRUE; |
| 19 | 19 | $this->email->from('[email protected]', $this->config->item('site_title', 'ion_auth')); |
@@ -1,4 +1,4 @@ |
||
| 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 | class Tracker_Issue_Model extends Tracker_Base_Model { |
| 4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
| 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 | class Tracker_Issue_Model extends Tracker_Base_Model { |
| 4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | class ReportIssue extends MY_Controller { |
| 4 | 4 | public function __construct() { |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $this->header_data['page'] = "report-issue"; |
| 13 | 13 | |
| 14 | 14 | $this->form_validation->set_rules('issue_description', 'Description', 'required|max_length[255]'); |
| 15 | - $this->form_validation->set_rules('issue_url', 'URL', 'valid_url'); |
|
| 15 | + $this->form_validation->set_rules('issue_url', 'URL', 'valid_url'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | $this->body_data['issue_submitted'] = FALSE; |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | if(!empty($this->input->post('website'))) { |
| 23 | 23 | $this->body_data['issue_submitted'] = FALSE; |
| 24 | - log_message('error',"Bot attempting to spam report issue form: \"".$this->input->post('issue_description')."\""); |
|
| 24 | + log_message('error', "Bot attempting to spam report issue form: \"".$this->input->post('issue_description')."\""); |
|
| 25 | 25 | } else { |
| 26 | - $this->body_data['issue_submitted'] = $this->Tracker->issue->report("USERID:" . $this->User->id . " ||| " . $this->input->post('issue_description'), NULL, $this->input->post('issue_url')); |
|
| 26 | + $this->body_data['issue_submitted'] = $this->Tracker->issue->report("USERID:".$this->User->id." ||| ".$this->input->post('issue_description'), NULL, $this->input->post('issue_url')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | |
| 3 | 3 | if(!extension_loaded('gd')) die('GD ext is required to run this!'); |
| 4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | private $className; |
| 10 | 10 | |
| 11 | 11 | public function __construct() { |
| 12 | - if(isset($_SERVER['argv']) && count($_SERVER['argv']) === 3){ |
|
| 12 | + if(isset($_SERVER['argv']) && count($_SERVER['argv']) === 3) { |
|
| 13 | 13 | $this->baseURL = rtrim($_SERVER['argv'][1], '/'); |
| 14 | 14 | $this->className = $_SERVER['argv'][2]; |
| 15 | 15 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $this->updateDocs(); |
| 31 | 31 | |
| 32 | - $domain = preg_replace('#^https?://(.*?)(?:/.*?)?$#', '$1', $this->baseURL); |
|
| 32 | + $domain = preg_replace('#^https?://(.*?)(?:/.*?)?$#', '$1', $this->baseURL); |
|
| 33 | 33 | say("\nAdmin SQL:"); |
| 34 | 34 | say("INSERT INTO `mangatracker_development`.`tracker_sites` (`id`, `site`, `site_class`, `status`, `use_custom`) VALUES (NULL, '{$domain}', '{$this->className}', 'enabled', 'Y');"); |
| 35 | 35 | say("INSERT INTO `mangatracker_production`.`tracker_sites` (`id`, `site`, `site_class`, `status`, `use_custom`) VALUES (NULL, '{$domain}', '{$this->className}', 'enabled', 'Y');"); |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | //Update @updated |
| 99 | 99 | $currentDate = date("Y-m-d", time()); |
| 100 | - $baseFile = str_replace("@updated {$matches[1]}","@updated {$currentDate}", $baseFile); |
|
| 100 | + $baseFile = str_replace("@updated {$matches[1]}", "@updated {$currentDate}", $baseFile); |
|
| 101 | 101 | |
| 102 | 102 | //Update @version |
| 103 | 103 | $currentVersion = explode('.', $matches[2]); |
| 104 | - $newVersion = "{$currentVersion[0]}.{$currentVersion[1]}.". (((int) $currentVersion[2]) + 1); |
|
| 105 | - $baseFile = str_replace("@version {$matches[2]}","@version {$newVersion}", $baseFile); |
|
| 104 | + $newVersion = "{$currentVersion[0]}.{$currentVersion[1]}.".(((int) $currentVersion[2]) + 1); |
|
| 105 | + $baseFile = str_replace("@version {$matches[2]}", "@version {$newVersion}", $baseFile); |
|
| 106 | 106 | |
| 107 | 107 | //Add @require |
| 108 | 108 | // @resource fontAwesome |
@@ -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,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(); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $baseFile = file_get_contents($baseFileName); |
| 99 | 99 | |
| 100 | 100 | $parse = parse_url($this->baseURL); |
| 101 | - if(strpos($baseFile, $parse['host']) !== false) die("Domain already exists in userscript?"); |
|
| 101 | + if(strpos($baseFile, $parse['host']) !== FALSE) die("Domain already exists in userscript?"); |
|
| 102 | 102 | |
| 103 | 103 | preg_match('/\@updated ([0-9\-]+)[\r\n]+.*?\@version ([0-9\.]+)/s', $baseFile, $matches); |
| 104 | 104 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $require = <<<EOT |
| 121 | 121 | // @require https://{$baseDomain}/userscripts/sites/{$this->className}.1.js |
| 122 | 122 | // @resource fontAwesome |
| 123 | -EOT; |
|
| 123 | +eot; |
|
| 124 | 124 | $baseFile = str_replace('// @resource fontAwesome', $require, $baseFile); |
| 125 | 125 | |
| 126 | 126 | file_put_contents($baseFileName, $baseFile); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | }; |
| 147 | 147 | })(window.trackerSites = (window.trackerSites || {})); |
| 148 | 148 | |
| 149 | -EOT; |
|
| 149 | +eot; |
|
| 150 | 150 | |
| 151 | 151 | file_put_contents("./public/userscripts/sites/{$this->className}.js", $siteData); |
| 152 | 152 | } |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $ch = curl_init("{$this->baseURL}/api/reader/chapters/orderby/desc_created/format/json"); |
| 168 | 168 | |
| 169 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 170 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 169 | + curl_setopt($ch, CURLOPT_NOBODY, TRUE); |
|
| 170 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
| 171 | 171 | curl_exec($ch); |
| 172 | 172 | $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 173 | 173 | curl_close($ch); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | if($content = file_get_contents($jsonURL)) { |
| 182 | 182 | $json = json_decode($content, TRUE); |
| 183 | 183 | shuffle($json['comics']); |
| 184 | - $comics = array_slice($json['comics'], 0, 5, true); |
|
| 184 | + $comics = array_slice($json['comics'], 0, 5, TRUE); |
|
| 185 | 185 | |
| 186 | 186 | foreach($comics as $comic) { |
| 187 | 187 | $titleArr[$comic['stub']] = $comic['name']; |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | * Write to defined logger. Is called from CodeIgniters native log_message() |
| 138 | 138 | * |
| 139 | 139 | * @param string $level |
| 140 | - * @param $msg |
|
| 140 | + * @param string $msg |
|
| 141 | 141 | * @return bool |
| 142 | 142 | */ |
| 143 | 143 | public function write_log($level = 'error', $msg) |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | public function __construct() { |
| 49 | 49 | $file_path = APPPATH.'config/monolog.php'; |
| 50 | 50 | $found = FALSE; |
| 51 | - if (file_exists($file_path)) { |
|
| 51 | + if(file_exists($file_path)) { |
|
| 52 | 52 | $found = TRUE; |
| 53 | 53 | require($file_path); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Is the config file in the environment folder? |
| 57 | - if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/monolog.php')) { |
|
| 57 | + if(file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/monolog.php')) { |
|
| 58 | 58 | require($file_path); |
| 59 | - } elseif (!$found) { |
|
| 59 | + } elseif(!$found) { |
|
| 60 | 60 | exit('monolog.php config does not exist'); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -67,7 +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']) |
|
| 70 | + if($this->config['introspection_processor']) |
|
| 71 | 71 | { |
| 72 | 72 | // add controller and line number info to each log message |
| 73 | 73 | // 2 = depth in the stacktrace to ignore. This gives us the file |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // decide which handler(s) to use |
| 79 | - foreach ($this->config['handlers'] as $value) |
|
| 79 | + foreach($this->config['handlers'] as $value) |
|
| 80 | 80 | { |
| 81 | - switch ($value) |
|
| 81 | + switch($value) |
|
| 82 | 82 | { |
| 83 | 83 | case 'file': |
| 84 | 84 | $handler = new RotatingFileHandler($this->config['file_logfile']); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | break; |
| 124 | 124 | |
| 125 | 125 | default: |
| 126 | - exit('log handler not supported: ' . $value . "\n"); |
|
| 126 | + exit('log handler not supported: '.$value."\n"); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $this->log->pushHandler($handler); |
@@ -145,19 +145,19 @@ discard block |
||
| 145 | 145 | $level = strtoupper($level); |
| 146 | 146 | |
| 147 | 147 | // verify error level |
| 148 | - if (!isset($this->_levels[$level])) |
|
| 148 | + if(!isset($this->_levels[$level])) |
|
| 149 | 149 | { |
| 150 | - $this->log->addError('unknown error level: ' . $level); |
|
| 150 | + $this->log->addError('unknown error level: '.$level); |
|
| 151 | 151 | $level = 'ALL'; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // filter out anything in $this->config['exclusion_list'] |
| 155 | - if (!empty($this->config['exclusion_list'])) |
|
| 155 | + if(!empty($this->config['exclusion_list'])) |
|
| 156 | 156 | { |
| 157 | - foreach ($this->config['exclusion_list'] as $findme) |
|
| 157 | + foreach($this->config['exclusion_list'] as $findme) |
|
| 158 | 158 | { |
| 159 | 159 | $pos = strpos($msg, $findme); |
| 160 | - if ($pos !== false) |
|
| 160 | + if($pos !== false) |
|
| 161 | 161 | { |
| 162 | 162 | // just exit now - we don't want to log this error |
| 163 | 163 | return true; |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ($this->_levels[$level] <= $this->config['threshold']) |
|
| 168 | + if($this->_levels[$level] <= $this->config['threshold']) |
|
| 169 | 169 | { |
| 170 | - switch ($level) |
|
| 170 | + switch($level) |
|
| 171 | 171 | { |
| 172 | 172 | case 'ERROR': |
| 173 | 173 | $this->log->addError($msg); |
@@ -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; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | 4 | * CodeIgniter Monolog Plus |
@@ -82,18 +82,18 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | case 'file': |
| 84 | 84 | $handler = new RotatingFileHandler($this->config['file_logfile']); |
| 85 | - $formatter = new LineFormatter(null, null, $config['file_multiline']); |
|
| 85 | + $formatter = new LineFormatter(NULL, NULL, $config['file_multiline']); |
|
| 86 | 86 | $handler->setFormatter($formatter); |
| 87 | 87 | break; |
| 88 | 88 | |
| 89 | 89 | case 'ci_file': |
| 90 | 90 | $handler = new RotatingFileHandler($this->config['ci_file_logfile']); |
| 91 | - $formatter = new LineFormatter("%level_name% - %datetime% --> %message% %extra%\n", null, $config['ci_file_multiline']); |
|
| 91 | + $formatter = new LineFormatter("%level_name% - %datetime% --> %message% %extra%\n", NULL, $config['ci_file_multiline']); |
|
| 92 | 92 | $handler->setFormatter($formatter); |
| 93 | 93 | break; |
| 94 | 94 | |
| 95 | 95 | case 'new_relic': |
| 96 | - $handler = new NewRelicHandler(Logger::ERROR, true, $this->config['new_relic_app_name']); |
|
| 96 | + $handler = new NewRelicHandler(Logger::ERROR, TRUE, $this->config['new_relic_app_name']); |
|
| 97 | 97 | break; |
| 98 | 98 | |
| 99 | 99 | case 'hipchat': |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | case 'papertrail': |
| 114 | 114 | $handler = new SyslogUdpHandler($this->config['papertrail_host'], $this->config['papertrail_port']); |
| 115 | - $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%", null, $config['papertrail_multiline']); |
|
| 115 | + $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%", NULL, $config['papertrail_multiline']); |
|
| 116 | 116 | $handler->setFormatter($formatter); |
| 117 | 117 | break; |
| 118 | 118 | |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | foreach ($this->config['exclusion_list'] as $findme) |
| 158 | 158 | { |
| 159 | 159 | $pos = strpos($msg, $findme); |
| 160 | - if ($pos !== false) |
|
| 160 | + if ($pos !== FALSE) |
|
| 161 | 161 | { |
| 162 | 162 | // just exit now - we don't want to log this error |
| 163 | - return true; |
|
| 163 | + return TRUE; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | break; |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | - return true; |
|
| 186 | + return TRUE; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | } |
@@ -134,9 +134,9 @@ |
||
| 134 | 134 | $config['composer_autoload'] = FALSE; |
| 135 | 135 | |
| 136 | 136 | //NOTE: This doesn't work in autoload.php as it is loaded after we need it. |
| 137 | -spl_autoload_register(function ($class) { |
|
| 138 | - $fileMono = APPPATH . '../vendor/monolog/monolog/src/'.strtr($class, '\\', '/').'.php'; |
|
| 139 | - $filePsr = APPPATH . '../vendor/psr/log/'.strtr($class, '\\', '/').'.php'; |
|
| 137 | +spl_autoload_register(function($class) { |
|
| 138 | + $fileMono = APPPATH.'../vendor/monolog/monolog/src/'.strtr($class, '\\', '/').'.php'; |
|
| 139 | + $filePsr = APPPATH.'../vendor/psr/log/'.strtr($class, '\\', '/').'.php'; |
|
| 140 | 140 | if(file_exists($fileMono)) { |
| 141 | 141 | require $fileMono; |
| 142 | 142 | return TRUE; |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | 4 | |-------------------------------------------------------------------------- |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | 4 | |-------------------------------------------------------------------------- |