@@ -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(); |
@@ -118,7 +118,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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), |
@@ -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 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[1000]'); |
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,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']; |
@@ -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');"); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | //Update @updated |
110 | 110 | $currentDate = date("Y-m-d", time()); |
111 | - $baseFile = str_replace("@updated {$matches[1]}","@updated {$currentDate}", $baseFile); |
|
111 | + $baseFile = str_replace("@updated {$matches[1]}", "@updated {$currentDate}", $baseFile); |
|
112 | 112 | |
113 | 113 | //Update @version |
114 | 114 | $currentVersion = explode('.', $matches[2]); |
115 | - $newVersion = "{$currentVersion[0]}.{$currentVersion[1]}.". (((int) $currentVersion[2]) + 1); |
|
116 | - $baseFile = str_replace("@version {$matches[2]}","@version {$newVersion}", $baseFile); |
|
115 | + $newVersion = "{$currentVersion[0]}.{$currentVersion[1]}.".(((int) $currentVersion[2]) + 1); |
|
116 | + $baseFile = str_replace("@version {$matches[2]}", "@version {$newVersion}", $baseFile); |
|
117 | 117 | |
118 | 118 | //Add @require |
119 | 119 | // @resource fontAwesome |
@@ -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) |
@@ -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; |
@@ -48,22 +48,22 @@ 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 | |
63 | 63 | // Is the config file in the _secure folder? |
64 | - if (file_exists($file_path = APPPATH.'config/_secure/monolog.php')) { |
|
64 | + if(file_exists($file_path = APPPATH.'config/_secure/monolog.php')) { |
|
65 | 65 | require($file_path); |
66 | - } elseif (!$found) { |
|
66 | + } elseif(!$found) { |
|
67 | 67 | exit('monolog.php config does not exist'); |
68 | 68 | } |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // detect and register all PHP errors in this log hence forth |
75 | 75 | ErrorHandler::register($this->log); |
76 | 76 | |
77 | - if ($this->config['introspection_processor']) |
|
77 | + if($this->config['introspection_processor']) |
|
78 | 78 | { |
79 | 79 | // add controller and line number info to each log message |
80 | 80 | // 2 = depth in the stacktrace to ignore. This gives us the file |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // decide which handler(s) to use |
86 | - foreach ($this->config['handlers'] as $value) |
|
86 | + foreach($this->config['handlers'] as $value) |
|
87 | 87 | { |
88 | - switch ($value) |
|
88 | + switch($value) |
|
89 | 89 | { |
90 | 90 | case 'file': |
91 | 91 | $handler = new RotatingFileHandler($this->config['file_logfile']); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | break; |
131 | 131 | |
132 | 132 | default: |
133 | - exit('log handler not supported: ' . $value . "\n"); |
|
133 | + exit('log handler not supported: '.$value."\n"); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | $this->log->pushHandler($handler); |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | $level = strtoupper($level); |
153 | 153 | |
154 | 154 | // verify error level |
155 | - if (!isset($this->_levels[$level])) |
|
155 | + if(!isset($this->_levels[$level])) |
|
156 | 156 | { |
157 | - $this->log->addError('unknown error level: ' . $level); |
|
157 | + $this->log->addError('unknown error level: '.$level); |
|
158 | 158 | $level = 'ALL'; |
159 | 159 | } |
160 | 160 | |
161 | 161 | // filter out anything in $this->config['exclusion_list'] |
162 | - if (!empty($this->config['exclusion_list'])) |
|
162 | + if(!empty($this->config['exclusion_list'])) |
|
163 | 163 | { |
164 | - foreach ($this->config['exclusion_list'] as $findme) |
|
164 | + foreach($this->config['exclusion_list'] as $findme) |
|
165 | 165 | { |
166 | 166 | $pos = strpos($msg, $findme); |
167 | - if ($pos !== false) |
|
167 | + if($pos !== false) |
|
168 | 168 | { |
169 | 169 | // just exit now - we don't want to log this error |
170 | 170 | return true; |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | - if ($this->_levels[$level] <= $this->config['threshold']) |
|
175 | + if($this->_levels[$level] <= $this->config['threshold']) |
|
176 | 176 | { |
177 | - switch ($level) |
|
177 | + switch($level) |
|
178 | 178 | { |
179 | 179 | case 'ERROR': |
180 | 180 | $this->log->addError($msg); |
@@ -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 |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | { |
90 | 90 | case 'file': |
91 | 91 | $handler = new RotatingFileHandler($this->config['file_logfile']); |
92 | - $formatter = new LineFormatter(null, null, $config['file_multiline']); |
|
92 | + $formatter = new LineFormatter(NULL, NULL, $config['file_multiline']); |
|
93 | 93 | $handler->setFormatter($formatter); |
94 | 94 | break; |
95 | 95 | |
96 | 96 | case 'ci_file': |
97 | 97 | $handler = new RotatingFileHandler($this->config['ci_file_logfile']); |
98 | - $formatter = new LineFormatter("%level_name% - %datetime% --> %message% %extra%\n", null, $config['ci_file_multiline']); |
|
98 | + $formatter = new LineFormatter("%level_name% - %datetime% --> %message% %extra%\n", NULL, $config['ci_file_multiline']); |
|
99 | 99 | $handler->setFormatter($formatter); |
100 | 100 | break; |
101 | 101 | |
102 | 102 | case 'new_relic': |
103 | - $handler = new NewRelicHandler(Logger::ERROR, true, $this->config['new_relic_app_name']); |
|
103 | + $handler = new NewRelicHandler(Logger::ERROR, TRUE, $this->config['new_relic_app_name']); |
|
104 | 104 | break; |
105 | 105 | |
106 | 106 | case 'hipchat': |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | case 'papertrail': |
121 | 121 | $handler = new SyslogUdpHandler($this->config['papertrail_host'], $this->config['papertrail_port']); |
122 | - $formatter = new LineFormatter('%channel%.%level_name%: %message% %extra%', null, $config['papertrail_multiline']); |
|
122 | + $formatter = new LineFormatter('%channel%.%level_name%: %message% %extra%', NULL, $config['papertrail_multiline']); |
|
123 | 123 | $handler->setFormatter($formatter); |
124 | 124 | break; |
125 | 125 | |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | foreach ($this->config['exclusion_list'] as $findme) |
165 | 165 | { |
166 | 166 | $pos = strpos($msg, $findme); |
167 | - if ($pos !== false) |
|
167 | + if ($pos !== FALSE) |
|
168 | 168 | { |
169 | 169 | // just exit now - we don't want to log this error |
170 | - return true; |
|
170 | + return TRUE; |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | break; |
191 | 191 | } |
192 | 192 | } |
193 | - return true; |
|
193 | + return TRUE; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
@@ -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 | |-------------------------------------------------------------------------- |
@@ -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/'. str_replace('\\', '/', $class) .'.php'; |
|
139 | - $filePsr = APPPATH . '../vendor/psr/log/'. str_replace('\\', '/', $class) .'.php'; |
|
137 | +spl_autoload_register(function($class) { |
|
138 | + $fileMono = APPPATH.'../vendor/monolog/monolog/src/'.str_replace('\\', '/', $class).'.php'; |
|
139 | + $filePsr = APPPATH.'../vendor/psr/log/'.str_replace('\\', '/', $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 | |-------------------------------------------------------------------------- |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $config['file_multiline'] = TRUE; //add newlines to the output |
32 | 32 | |
33 | 33 | /* NEW RELIC OPTIONS */ |
34 | -$config['new_relic_app_name'] = 'APP NAME - ' . ENVIRONMENT; |
|
34 | +$config['new_relic_app_name'] = 'APP NAME - '.ENVIRONMENT; |
|
35 | 35 | |
36 | 36 | /* HIPCHAT OPTIONS */ |
37 | 37 | $config['hipchat_app_token'] = ''; //HipChat API Token |
@@ -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 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $config['hipchat_app_token'] = ''; //HipChat API Token |
38 | 38 | $config['hipchat_app_room_id'] = ''; //The room that should be alerted of the message (Id or Name) |
39 | 39 | $config['hipchat_app_notification_name'] = 'Monolog'; //Name used in the "from" field |
40 | -$config['hipchat_app_notify'] = false; //Trigger a notification in clients or not |
|
40 | +$config['hipchat_app_notify'] = FALSE; //Trigger a notification in clients or not |
|
41 | 41 | $config['hipchat_app_loglevel'] = 'WARNING'; //The minimum logging level at which this handler will be triggered |
42 | 42 | |
43 | 43 | /* PAPER TRAIL OPTIONS */ |
@@ -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 | /* GENERAL OPTIONS */ |
4 | 4 | $config['handlers'] = array('file', 'papertrail'); // valid handlers are ci_file | file | new_relic | hipchat | stderr | papertrail |