@@ -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 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | //Make sure last_checked is always updated on successful run. |
153 | 153 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
154 | 154 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
155 | - ->where('id', $row->title_id) |
|
156 | - ->update('tracker_titles'); |
|
155 | + ->where('id', $row->title_id) |
|
156 | + ->update('tracker_titles'); |
|
157 | 157 | |
158 | 158 | print " - ({$titleData['latest_chapter']})\n"; |
159 | 159 | } else { |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | //Make sure last_checked is always updated on successful run. |
168 | 168 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
169 | 169 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
170 | - ->where('id', $row->title_id) |
|
171 | - ->update('tracker_titles'); |
|
170 | + ->where('id', $row->title_id) |
|
171 | + ->update('tracker_titles'); |
|
172 | 172 | |
173 | 173 | print " - (No chapters found?)\n"; |
174 | 174 | } else { |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function updateCustom() { |
193 | 193 | $query = $this->db->select('*') |
194 | - ->from('tracker_sites') |
|
195 | - ->where('status', 'enabled') |
|
196 | - ->where('tracker_sites.use_custom', 'Y') |
|
197 | - ->get(); |
|
194 | + ->from('tracker_sites') |
|
195 | + ->where('status', 'enabled') |
|
196 | + ->where('tracker_sites.use_custom', 'Y') |
|
197 | + ->get(); |
|
198 | 198 | |
199 | 199 | $sites = $query->result_array(); |
200 | 200 | foreach ($sites as $site) { |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | //Make sure last_checked is always updated on successful run. |
212 | 212 | //CHECK: Is there a reason we aren't just doing this in updateByID? |
213 | 213 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
214 | - ->where('id', $titleID) |
|
215 | - ->update('tracker_titles'); |
|
214 | + ->where('id', $titleID) |
|
215 | + ->update('tracker_titles'); |
|
216 | 216 | |
217 | 217 | print " - ({$titleData['latest_chapter']})\n"; |
218 | 218 | } else { |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | |
242 | 242 | public function refollowCustom() { |
243 | 243 | $query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class') |
244 | - ->from('tracker_titles') |
|
245 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
246 | - ->where('tracker_titles.followed','N') |
|
247 | - ->where('tracker_titles !=', '255') |
|
248 | - ->where('tracker_sites.status', 'enabled') |
|
249 | - ->where('tracker_sites.use_custom', 'Y') |
|
250 | - ->get(); |
|
244 | + ->from('tracker_titles') |
|
245 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
246 | + ->where('tracker_titles.followed','N') |
|
247 | + ->where('tracker_titles !=', '255') |
|
248 | + ->where('tracker_sites.status', 'enabled') |
|
249 | + ->where('tracker_sites.use_custom', 'Y') |
|
250 | + ->get(); |
|
251 | 251 | |
252 | 252 | if($query->num_rows() > 0) { |
253 | 253 | foreach($query->result() as $row) { |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | |
259 | 259 | if(!empty($titleData)) { |
260 | 260 | $this->db->set($titleData) |
261 | - ->where('id', $row->id) |
|
262 | - ->update('tracker_titles'); |
|
261 | + ->where('id', $row->id) |
|
262 | + ->update('tracker_titles'); |
|
263 | 263 | |
264 | 264 | print "> {$row->site_class}:{$row->id}:{$row->title_url} FOLLOWED\n"; |
265 | 265 | } else { |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
308 | 308 | if($titleData['title'] !== $row->title) { |
309 | 309 | $this->db->set('title', $titleData['title']) |
310 | - ->where('id', $row->id) |
|
311 | - ->update('tracker_titles'); |
|
310 | + ->where('id', $row->id) |
|
311 | + ->update('tracker_titles'); |
|
312 | 312 | //TODO: Add to history somehow? |
313 | 313 | print " - NEW TITLE ({$titleData['title']})\n"; |
314 | 314 | } else { |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | //We might as well try to update as well. |
319 | 319 | if($this->Tracker->title->updateByID((int) $row->id, $titleData['latest_chapter'])) { |
320 | 320 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
321 | - ->where('id', $row->id) |
|
322 | - ->update('tracker_titles'); |
|
321 | + ->where('id', $row->id) |
|
322 | + ->update('tracker_titles'); |
|
323 | 323 | } |
324 | 324 | } else { |
325 | 325 | log_message('error', "{$row->title} failed to update title successfully"); |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | $date = $temp_now->format('Y-m-d'); |
336 | 336 | |
337 | 337 | $query = $this->db->select('1') |
338 | - ->from('site_stats') |
|
339 | - ->where('date', $date) |
|
340 | - ->get(); |
|
338 | + ->from('site_stats') |
|
339 | + ->where('date', $date) |
|
340 | + ->get(); |
|
341 | 341 | |
342 | 342 | if($query->num_rows() > 0) { |
343 | 343 | $this->db->set('total_requests', 'total_requests+1', FALSE) |
344 | - ->where('date', $date) |
|
345 | - ->update('site_stats'); |
|
344 | + ->where('date', $date) |
|
345 | + ->update('site_stats'); |
|
346 | 346 | } else { |
347 | 347 | $this->db->insert('site_stats', [ |
348 | 348 | 'date' => $date, |
@@ -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 | class Tracker_Admin_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $query = $query->get(); |
77 | 77 | |
78 | 78 | if($query->num_rows() > 0) { |
79 | - foreach ($query->result() as $row) { |
|
79 | + foreach($query->result() as $row) { |
|
80 | 80 | $this->handleUpdate($row); |
81 | 81 | } |
82 | 82 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $query = $query->get(); |
134 | 134 | |
135 | 135 | if($query->num_rows() > 0) { |
136 | - foreach ($query->result() as $row) { |
|
136 | + foreach($query->result() as $row) { |
|
137 | 137 | $this->handleUpdate($row); |
138 | 138 | } |
139 | 139 | } |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | ->get(); |
198 | 198 | |
199 | 199 | $sites = $query->result_array(); |
200 | - foreach ($sites as $site) { |
|
200 | + foreach($sites as $site) { |
|
201 | 201 | $siteClass = $this->sites->{$site['site_class']}; |
202 | 202 | if($titleDataList = $siteClass->doCustomUpdate()) { |
203 | - foreach ($titleDataList as $titleURL => $titleData) { |
|
203 | + foreach($titleDataList as $titleURL => $titleData) { |
|
204 | 204 | $titleURL = (string) $titleURL; //Number only keys get converted to int for some reason, so we need to fix that. |
205 | 205 | print "> {$titleData['title']} <{$site['site_class']}>"; //Print this prior to doing anything so we can more easily find out if something went wrong |
206 | 206 | if(is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $query = $this->db->select('tracker_titles.id, tracker_titles.title_url, tracker_sites.site_class') |
244 | 244 | ->from('tracker_titles') |
245 | 245 | ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
246 | - ->where('tracker_titles.followed','N') |
|
246 | + ->where('tracker_titles.followed', 'N') |
|
247 | 247 | ->where('tracker_titles !=', '255') |
248 | 248 | ->where('tracker_sites.status', 'enabled') |
249 | 249 | ->where('tracker_sites.use_custom', 'Y') |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | // @formatter:on |
302 | 302 | |
303 | 303 | if($query->num_rows() > 0) { |
304 | - foreach ($query->result() as $row) { |
|
304 | + foreach($query->result() as $row) { |
|
305 | 305 | print "> {$row->title} <{$row->site_class}>"; //Print this prior to doing anything so we can more easily find out if something went wrong |
306 | 306 | $titleData = $this->sites->{$row->site_class}->getTitleData($row->title_url); |
307 | 307 | if($titleData['title'] && is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
@@ -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 | |-------------------------------------------------------------------------- |
@@ -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', 'cli'); // valid handlers are ci_file | file | new_relic | hipchat | stderr | papertrail |