error.php
85 lines
| 2.7 KiB
| text/x-php
|
PhpLexer
/ include / error.php
| r1 | <?php | |||
| define('MTS_LOGIN', 1); // User login | ||||
| define('MTS_USER', 2); // Changes to user information | ||||
| define('MTS_PAGE', 3); // Modifying static pages | ||||
| define('MTS_RANT', 4); // Modifying rants | ||||
| define('MTS_SCRATCH', 5); // Additions to the scratchpad | ||||
| define('MTS_STRIP', 6); // Modifying strips | ||||
| define('MTS_TWITTER', 9); // Modifications to Twitter presets | ||||
| define('MTS_TYPE', 7); // Changes in the type manager | ||||
| define('MTS_TYPE_META', 8); // Changes in the metatype manager | ||||
| define('MTS_TUMBLR', 10); | ||||
| r25 | define('MTA_ADD', 'create'); // Creation action | |||
| r1 | define('MTA_INSERT', 'create'); // Creation action | |||
| define('MTA_DELETE', 'delete'); // Deletion action | ||||
| define('MTA_REMOVE', 'delete'); // Deletion action | ||||
| define('MTA_MODIFY', 'update'); // Modification action | ||||
| define('MTA_UPDATE', 'update'); // Modification action | ||||
| define('MTA_CHANGE', 'update'); // Modification action | ||||
| function adminlog($msg, $section, $action, $level=E_USER_NOTICE, $email=false) | ||||
| { | ||||
| r25 | global $dbConnection, $currentuser; | |||
| r4 | ||||
| r25 | $sql = 'INSERT INTO admin_log (contributor, section, action, level, message) VALUES (?, ?, ?, ?, ?)'; | |||
| $stmt = $dbConnection->prepare($sql); | ||||
| r50 | $stmt->bindValue(1, is_numeric($currentuser->id) ? $currentuser->id : NULL); | |||
| r25 | $stmt->bindValue(2, $section); | |||
| $stmt->bindValue(3, $action); | ||||
| $stmt->bindValue(4, $level); | ||||
| $stmt->bindValue(5, $msg); | ||||
| $stmt->execute() or die($sql . '<br>' . $stmt->errorCode() . '<br>' . var_export(debug_backtrace())); | ||||
| r1 | ||||
| // Log all important sorts of messages in the Apache log | ||||
| r25 | if( $level & (E_USER_WARNING | E_USER_ERROR) ) | |||
| { | ||||
| r1 | error_log($msg, 0); | |||
| } | ||||
| // Email critical messages and those for which email is requested | ||||
| r25 | if($email || E_USER_ERROR == $level || E_ERROR == $level) | |||
| { | ||||
| r1 | // Pretty printing | |||
| r25 | switch($level) | |||
| { | ||||
| r1 | case E_USER_NOTICE: | |||
| case E_NOTICE: | ||||
| $importance = 'Notice'; | ||||
| break; | ||||
| case E_USER_WARNING: | ||||
| case E_WARNING: | ||||
| $importance = 'Warning'; | ||||
| break; | ||||
| case E_USER_ERROR: | ||||
| case E_ERROR: | ||||
| $importance = 'Error'; | ||||
| break; | ||||
| default: | ||||
| $importance = "Other - $level"; | ||||
| break; | ||||
| } | ||||
| r25 | switch($section) | |||
| { | ||||
| r1 | case MTS_LOGIN: $area = 'User login'; break; | |||
| case MTS_USER: $area = 'Modify user'; break; | ||||
| case MTS_PAGE: $area = 'Modify page'; break; | ||||
| case MTS_RANT: $area = 'Modify rant'; break; | ||||
| case MTS_SCRATCH: $area = 'Modify scratchpd'; break; | ||||
| case MTS_STRIP: $area = 'Modify strips'; break; | ||||
| case MTS_TYPE: $area = 'Modify strip types'; break; | ||||
| case MTS_TYPE_META: $area = 'Modify strip metatypes'; break; | ||||
| case MTS_TWITTER: $area = 'Modify Twitter'; break; | ||||
| default: | ||||
| $area = 'Undefined Area'; break; | ||||
| } | ||||
| error_log("Megatokyo Administrative Notice\r\nPriority level: $importance\r\nReported by: ".$currentuser->name."\r\nSection: $area\r\n$msg", 1, SITE_CONTACT); | ||||
| } | ||||
| } | ||||
| ?> | ||||
