getOptions(); return (@$options['debug_mode'] == true); } /** Send a message to the error_log if debug mode is on. * This goes to a file and is used by every other class so it goes here. * @param type $message */ function debugMessage($message) { if ($this->isDebug()) { $prefix = "ABJ-404-SOLUTION (DEBUG): "; $timestamp = date('Y-m-d H:i:s') . ' (DEBUG): '; error_log($prefix . $message); $this->writeLineToDebugFile($timestamp . $message); } } /** Always send a message to the error_log. * This goes to a file and is used by every other class so it goes here. * @param type $message * @param type $sendTo404Page if false then we don't echo the 404 page. default is true iff the user is an admin or * is on an admin page. */ function errorMessage($message) { $e = new Exception; $stacktrace = $e->getTraceAsString(); $prefix = "ABJ-404-SOLUTION (ERROR): "; $timestamp = date('Y-m-d H:i:s') . ' (ERROR): '; error_log($prefix . $message); $this->writeLineToDebugFile($timestamp . $message . ", \nTrace: " . $stacktrace); // display a 404 page if the user is NOT an admin and is not on an admin page. if (!is_admin() && !current_user_can('administrator')) { // send the user to a 404 page. otherwise the user might just get a blank page. status_header(404); nocache_headers(); include(get_query_template('404')); exit(); } } /** Write the line to the debug file. * @param type $line */ function writeLineToDebugFile($line) { file_put_contents($this->getDebugFilePath(), $line . "\n", FILE_APPEND); } /** * @return type */ function getDebugFilePath() { return ABJ404_PATH . 'abj404_debug.txt'; } /** * @return type true if the file was deleted. */ function deleteDebugFile() { if (!file_exists($this->getDebugFilePath())) { return true; } return unlink($this->getDebugFilePath()); } /** * @return int file size in bytes */ function getDebugFileSize() { if (!file_exists($this->getDebugFilePath())) { return 0; } return filesize($this->getDebugFilePath()); } }