From 759ac109717e939841c58cba9052da17534b6509 Mon Sep 17 00:00:00 2001 From: Darko Luketic Date: Mon, 29 Nov 2021 12:04:01 +0100 Subject: [PATCH] more cleanup --- crayon_settings_wp.class.php | 10 --- global.php | 2 - readme.txt | 9 -- util/crayon_log.class.php | 163 ++++++++++++++++++----------------- util/crayon_timer.class.php | 3 +- util/external_use.php | 2 - 6 files changed, 87 insertions(+), 102 deletions(-) diff --git a/crayon_settings_wp.class.php b/crayon_settings_wp.class.php index baf332b..6432a95 100644 --- a/crayon_settings_wp.class.php +++ b/crayon_settings_wp.class.php @@ -1275,13 +1275,6 @@ class Human { Turkish (Hakan), Ukrainian (Michael Yunat)'; - $links = ' - - - - - '; - echo ' @@ -1292,9 +1285,6 @@ class Human { - - -
' . $translators . '
' . $links . '
'; } diff --git a/global.php b/global.php index 0a16148..189b679 100644 --- a/global.php +++ b/global.php @@ -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'; diff --git a/readme.txt b/readme.txt index 1afdc04..15bc788 100644 --- a/readme.txt +++ b/readme.txt @@ -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¤cy_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 == diff --git a/util/crayon_log.class.php b/util/crayon_log.class.php index be1178e..5a0e11d 100644 --- a/util/crayon_log.class.php +++ b/util/crayon_log.class.php @@ -1,94 +1,103 @@ 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'); + } + } } -?> \ No newline at end of file diff --git a/util/crayon_timer.class.php b/util/crayon_timer.class.php index 79af3f5..3ee70e7 100644 --- a/util/crayon_timer.class.php +++ b/util/crayon_timer.class.php @@ -20,5 +20,4 @@ class CrayonTimer { return 0; } } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/util/external_use.php b/util/external_use.php index b264232..51ab616 100644 --- a/util/external_use.php +++ b/util/external_use.php @@ -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); } - -?> \ No newline at end of file