more cleanup

This commit is contained in:
Darko Luketic 2021-11-29 12:04:01 +01:00
parent d02db09056
commit 759ac10971
6 changed files with 87 additions and 102 deletions

View File

@ -1275,13 +1275,6 @@ class Human {
Turkish (<a href="http://hakanertr.wordpress.com" target="_blank">Hakan</a>),
Ukrainian (<a href="http://getvoip.com/blog" target="_blank">Michael Yunat</a>)';
$links = '
<a id="docs-icon" class="small-icon" title="Documentation" href="' . $CRAYON_WEBSITE . '" target="_blank"></a>
<a id="git-icon" class="small-icon" title="GitHub" href="' . $CRAYON_GIT . '" target="_blank"></a>
<a id="wp-icon" class="small-icon" title="Plugin Page" href="' . $CRAYON_PLUGIN_WP . '" target="_blank"></a>
<a id="twitter-icon" class="small-icon" title="Twitter" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
<a id="gmail-icon" class="small-icon" title="Email" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>';
echo '
<table id="crayon-info" border="0">
<tr>
@ -1292,9 +1285,6 @@ class Human {
</tr>
<tr>
<td>' . $translators . '</td>
</tr>
<tr>
<td colspan="2">' . $links . '</td>
</tr>
</table>';
}

View File

@ -95,11 +95,9 @@ const CRAYON_STYLE_ADMIN = CRAYON_CSS_SRC_DIR . 'admin_style.css';
const CRAYON_STYLE_GLOBAL = CRAYON_CSS_SRC_DIR . 'global_style.css';
const CRAYON_STYLE_MIN = CRAYON_CSS_MIN_DIR . 'crayon.min.css';
const CRAYON_LOGO = CRAYON_CSS_DIR . 'images/crayon_logo.png';
const CRAYON_DONATE_BUTTON = CRAYON_CSS_DIR . 'images/donate.png';
const CRAYON_THEME_EDITOR_PHP = CRAYON_THEME_EDITOR_PATH . 'theme_editor.php';
const CRAYON_THEME_EDITOR_JS = CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js';
const CRAYON_THEME_EDITOR_STYLE = CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css';
const CRAYON_THEME_EDITOR_BUTTON = CRAYON_CSS_DIR . 'images/theme_editor.png';
// PHP Files
const CRAYON_FORMATTER_PHP = CRAYON_ROOT_PATH . 'crayon_formatter.class.php';

View File

@ -1,13 +1,4 @@
=== Crayon Syntax Highlighter ===
Contributors: akarmenia
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=AW99EMEPQ4CFE&lc=AU&item_name=Crayon%20Syntax%20Highlighter%20Donation&item_number=crayon%2ddonate&currency_code=AUD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
License: GPLv2 or later
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter, bbpress
Requires at least: 3.0
Tested up to: 4.2.0
Stable tag: trunk
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, or post text.
== Description ==

View File

@ -1,94 +1,103 @@
<?php
require_once (CRAYON_ROOT_PATH . 'crayon_settings.class.php');
require_once(CRAYON_ROOT_PATH . 'crayon_settings.class.php');
/* Manages logging variable values to the log file. */
class CrayonLog {
private static $file = NULL;
// Logs a variable value to a log file
class CrayonLog
{
private static $file = NULL;
public static function log($var = NULL, $title = '', $trim_url = TRUE) {
if ($var === NULL) {
// Return log
// Logs a variable value to a log file
if (($log = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
return $log;
} else {
return '';
}
} else {
try {
if (self::$file == NULL) {
self::$file = @fopen(CRAYON_LOG_FILE, 'a+');
public static function log($var = NULL, $title = '', $trim_url = TRUE)
{
if ($var === NULL) {
// Return log
if (self::$file) {
$header = /*CRAYON_DASH .*/ CRAYON_NL . '[Crayon Syntax Highlighter Log Entry - ' . date('g:i:s A - d M Y') . ']' . CRAYON_NL .
/*CRAYON_DASH .*/ CRAYON_NL;
fwrite(self::$file, $header);
} else {
return;
}
}
// Capture variable dump
if (($log = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
return $log;
} else {
return '';
}
} else {
try {
if (self::$file == NULL) {
self::$file = @fopen(CRAYON_LOG_FILE, 'a+');
if (self::$file) {
$header = /*CRAYON_DASH .*/
CRAYON_NL . '[Crayon Syntax Highlighter Log Entry - ' . date('g:i:s A - d M Y') . ']' . CRAYON_NL .
/*CRAYON_DASH .*/
CRAYON_NL;
fwrite(self::$file, $header);
} else {
return;
}
}
// Capture variable dump
$buffer = trim(strip_tags(var_export($var, true)));
$title = (!empty($title) ? " [$title]" : '');
$title = (!empty($title) ? " [$title]" : '');
// Remove absolute path to plugin directory from buffer
if ($trim_url) {
$buffer = CrayonUtil::path_rel($buffer);
}
$write = $title . ' ' . $buffer . CRAYON_NL /* . CRAYON_LINE . CRAYON_NL*/;
// If we exceed max file size, truncate file first
if (filesize(CRAYON_LOG_FILE) + strlen($write) > CRAYON_LOG_MAX_SIZE) {
ftruncate(self::$file, 0);
fwrite(self::$file, 'The log has been truncated since it exceeded ' . CRAYON_LOG_MAX_SIZE .
' bytes.' . CRAYON_NL . /*CRAYON_LINE .*/ CRAYON_NL);
}
clearstatcache();
fwrite(self::$file, $write, CRAYON_LOG_MAX_SIZE);
} catch (Exception $e) {
// Ignore fatal errors during logging
}
}
}
// Remove absolute path to plugin directory from buffer
if ($trim_url) {
$buffer = CrayonUtil::path_rel($buffer);
}
$write = $title . ' ' . $buffer . CRAYON_NL /* . CRAYON_LINE . CRAYON_NL*/
;
// Logs system-wide only if global settings permit
// If we exceed max file size, truncate file first
if (filesize(CRAYON_LOG_FILE) + strlen($write) > CRAYON_LOG_MAX_SIZE) {
ftruncate(self::$file, 0);
fwrite(self::$file, 'The log has been truncated since it exceeded ' . CRAYON_LOG_MAX_SIZE .
' bytes.' . CRAYON_NL . /*CRAYON_LINE .*/ CRAYON_NL);
}
clearstatcache();
fwrite(self::$file, $write, CRAYON_LOG_MAX_SIZE);
} catch (Exception $e) {
// Ignore fatal errors during logging
}
}
}
public static function syslog($var = NULL, $title = '', $trim_url = TRUE) {
if (CrayonGlobalSettings::val(CrayonSettings::ERROR_LOG_SYS)) {
$title = (empty($title)) ? 'SYSTEM LOG' : $title;
self::log($var, $title, $trim_url);
}
}
public static function debug($var = NULL, $title = '', $trim_url = TRUE) {
if (CRAYON_DEBUG) {
$title = (empty($title)) ? 'DEBUG' : $title;
self::log($var, $title, $trim_url);
}
}
// Logs system-wide only if global settings permit
public static function clear() {
if (!@unlink(CRAYON_LOG_FILE)) {
// Will result in nothing if we can't log
public static function syslog($var = NULL, $title = '', $trim_url = TRUE)
{
if (CrayonGlobalSettings::val(CrayonSettings::ERROR_LOG_SYS)) {
$title = (empty($title)) ? 'SYSTEM LOG' : $title;
self::log($var, $title, $trim_url);
}
}
self::log('The log could not be cleared', 'Log Clear');
}
self::$file = NULL; // Remove file handle
public static function debug($var = NULL, $title = '', $trim_url = TRUE)
{
if (CRAYON_DEBUG) {
$title = (empty($title)) ? 'DEBUG' : $title;
self::log($var, $title, $trim_url);
}
}
}
public static function clear()
{
if (!@unlink(CRAYON_LOG_FILE)) {
// Will result in nothing if we can't log
public static function email($to, $from = NULL) {
if (($log_contents = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
$headers = $from ? 'From: ' . $from : '';
$result = @mail($to, 'Crayon Syntax Highlighter Log', $log_contents, $headers);
self::log('The log was emailed to the admin.', 'Log Email');
} else {
// Will result in nothing if we can't email
self::log('The log could not be cleared', 'Log Clear');
}
self::$file = NULL; // Remove file handle
self::log("The log could not be emailed to $to.", 'Log Email');
}
}
}
public static function email($to, $from = NULL)
{
if (($log_contents = CrayonUtil::file(CRAYON_LOG_FILE)) !== FALSE) {
$headers = $from ? 'From: ' . $from : '';
$result = @mail($to, 'Crayon Syntax Highlighter Log', $log_contents, $headers);
self::log('The log was emailed to the admin.', 'Log Email');
} else {
// Will result in nothing if we can't email
self::log("The log could not be emailed to $to.", 'Log Email');
}
}
}
?>

View File

@ -20,5 +20,4 @@ class CrayonTimer {
return 0;
}
}
}
?>
}

View File

@ -53,5 +53,3 @@ function crayon_resources() {
crayon_print_script('crayon-js', $plugin_url.CRAYON_JS, $CRAYON_VERSION);
crayon_print_script('crayon-jquery-popup', $plugin_url.CRAYON_JQUERY_POPUP, $CRAYON_VERSION);
}
?>