diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php deleted file mode 100644 index f3d34c4a9cd..00000000000 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ /dev/null @@ -1,174 +0,0 @@ -isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', 'ChromePhp.class.php'); - } - - /** - * Is the module active ? - * - * @return int -1 if not active, 0 if active but lib/path not found, 1 if OK - */ - public function isActive() - { - global $conf; - try - { - if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) { - $conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/'; - } - set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH); - - $res = @include_once 'ChromePhp.php'; - if (! $res) $res=@include_once 'ChromePhp.class.php'; - - restore_include_path(); - - if ($res) - { - return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler - } - else - { - return 0; - } - } - catch(Exception $e) - { - print ''."\n"; - } - - return -1; - } - - /** - * Return array of configuration data - * - * @return array Return array of configuration data - */ - public function configure() - { - global $langs; - - return array( - array( - 'name' => $langs->trans('IncludePath', 'SYSLOG_CHROMEPHP_INCLUDEPATH'), - 'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH', - 'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/', - 'attr' => 'size="60"', - 'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/' - ) - ); - } - - /** - * Return if configuration is valid - * - * @return array Array of errors. Empty array if ok. - */ - public function checkConfiguration() - { - global $langs,$conf; - - $errors = array(); - - if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php')) - { - $conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop - if (is_object($langs)) // $langs may not be defined yet. - { - $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php'); - } - else - { - $errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php"; - } - } - - return $errors; - } - - /** - * Output log content. We also start output buffering at first log write. - * - * @param array $content Content to log - * @return null|false - */ - public function export($content) - { - global $conf; - - if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return; // Global option to disable output of this handler - - //We check the configuration to avoid showing PHP warnings - if (count($this->checkConfiguration()) > 0) return false; - - try - { - // Warning ChromePHP must be into PHP include path. It is not possible to use into require_once a constant from - // database or config file because we must be able to log data before database or config file read. - $oldinclude=get_include_path(); - set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH); - $res = @include_once 'ChromePhp.php'; - if (! $res) $res=@include_once 'ChromePhp.class.php'; - set_include_path($oldinclude); - - ob_start(); // To be sure headers are not flushed until all page is completely processed - if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']); - elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']); - elseif ($content['level'] == LOG_INFO) ChromePhp::log($content['message']); - else ChromePhp::log($content['message']); - } - catch (Exception $e) - { - // Do not use dol_syslog here to avoid infinite loop - } - } -} diff --git a/htdocs/core/modules/syslog/mod_syslog_firephp.php b/htdocs/core/modules/syslog/mod_syslog_firephp.php deleted file mode 100644 index abc341f9a30..00000000000 --- a/htdocs/core/modules/syslog/mod_syslog_firephp.php +++ /dev/null @@ -1,175 +0,0 @@ - - * Copyright (C) 2015 Raphaƫl Doursenaud - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; - -/** - * Class to manage logging to a FirePHP - */ -class mod_syslog_firephp extends LogHandler implements LogHandlerInterface -{ - public $code = 'firephp'; - private static $firephp_include_path = '/includes/firephp/firephp-core/lib/'; - private static $firephp_class_path = 'FirePHPCore/FirePHP.class.php'; - - /** - * Return name of logger - * - * @return string Name of logger - */ - public function getName() - { - return 'FirePHP'; - } - - /** - * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development') - * - * @return string - */ - public function getVersion() - { - return 'dolibarr'; - } - - /** - * Content of the info tooltip. - * - * @return false|string - */ - public function getInfo() - { - global $langs; - - return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', self::$firephp_class_path); - } - - /** - * Is the module active ? - * - * @return int - */ - public function isActive() - { - global $conf; - try - { - if (empty($conf->global->SYSLOG_FIREPHP_INCLUDEPATH)) { - $conf->global->SYSLOG_FIREPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT . self::$firephp_include_path; - } - set_include_path($conf->global->SYSLOG_FIREPHP_INCLUDEPATH); - $res = @include_once self::$firephp_class_path; - restore_include_path(); - if ($res) { - return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FIREPHP)?1:0; // Set SYSLOG_DISABLE_LOGHANDLER_FIREPHP to 1 to disable this loghandler - } else { - return 0; - } - } - catch(Exception $e) - { - print ''."\n"; - } - - return -1; - } - - /** - * Return array of configuration data - * - * @return array Return array of configuration data - */ - public function configure() - { - global $langs; - - return array( - array( - 'name' => $langs->trans('IncludePath', 'SYSLOG_FIREPHP_INCLUDEPATH'), - 'constant' => 'SYSLOG_FIREPHP_INCLUDEPATH', - 'default' => DOL_DOCUMENT_ROOT . self::$firephp_include_path, - 'attr' => 'size="60"', - 'example' => '/usr/share/php, ' . DOL_DOCUMENT_ROOT . self::$firephp_include_path - ) - ); - } - - /** - * Return if configuration is valid - * - * @return array Array of errors. Empty array if ok. - */ - public function checkConfiguration() - { - global $conf, $langs; - - $errors = array(); - - if (!file_exists($conf->global->SYSLOG_FIREPHP_INCLUDEPATH . self::$firephp_class_path)) - { - $conf->global->MAIN_SYSLOG_DISABLE_FIREPHP = 1; // avoid infinite loop - if (is_object($langs)) // $langs may not be defined yet. - { - $errors[] = $langs->trans("ErrorFailedToOpenFile", self::$firephp_class_path); - } - else - { - $errors[] = "ErrorFailedToOpenFile " . self::$firephp_class_path; - } - } - - return $errors; - } - - /** - * Output log content - * - * @param array $content Content to log - * @return null|false - */ - public function export($content) - { - global $conf; - - if (! empty($conf->global->MAIN_SYSLOG_DISABLE_FIREPHP)) return; // Global option to disable output of this handler - - //We check the configuration to avoid showing PHP warnings - if (count($this->checkConfiguration())) return false; - - try - { - // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once a constant from - // database or config file because we must be able to log data before database or config file read. - $oldinclude=get_include_path(); - set_include_path($conf->global->SYSLOG_FIREPHP_INCLUDEPATH); - include_once self::$firephp_class_path; - set_include_path($oldinclude); - ob_start(); // To be sure headers are not flushed until all page is completely processed - $firephp = FirePHP::getInstance(true); - if ($content['level'] == LOG_ERR) $firephp->error($content['message']); - elseif ($content['level'] == LOG_WARNING) $firephp->warn($content['message']); - elseif ($content['level'] == LOG_INFO) $firephp->log($content['message']); - else $firephp->log($content['message']); - } - catch (Exception $e) - { - // Do not use dol_syslog here to avoid infinite loop - return false; - } - } -} diff --git a/htdocs/includes/ccampbell/chromephp/ChromePhp.php b/htdocs/includes/ccampbell/chromephp/ChromePhp.php deleted file mode 100644 index 577b1cecb9d..00000000000 --- a/htdocs/includes/ccampbell/chromephp/ChromePhp.php +++ /dev/null @@ -1,446 +0,0 @@ - - */ -class ChromePhp -{ - /** - * @var string - */ - const VERSION = '4.1.0'; - - /** - * @var string - */ - const HEADER_NAME = 'X-ChromeLogger-Data'; - - /** - * @var string - */ - const BACKTRACE_LEVEL = 'backtrace_level'; - - /** - * @var string - */ - const LOG = 'log'; - - /** - * @var string - */ - const WARN = 'warn'; - - /** - * @var string - */ - const ERROR = 'error'; - - /** - * @var string - */ - const GROUP = 'group'; - - /** - * @var string - */ - const INFO = 'info'; - - /** - * @var string - */ - const GROUP_END = 'groupEnd'; - - /** - * @var string - */ - const GROUP_COLLAPSED = 'groupCollapsed'; - - /** - * @var string - */ - const TABLE = 'table'; - - /** - * @var string - */ - protected $_php_version; - - /** - * @var int - */ - protected $_timestamp; - - /** - * @var array - */ - protected $_json = array( - 'version' => self::VERSION, - 'columns' => array('log', 'backtrace', 'type'), - 'rows' => array() - ); - - /** - * @var array - */ - protected $_backtraces = array(); - - /** - * @var bool - */ - protected $_error_triggered = false; - - /** - * @var array - */ - protected $_settings = array( - self::BACKTRACE_LEVEL => 1 - ); - - /** - * @var ChromePhp - */ - protected static $_instance; - - /** - * Prevent recursion when working with objects referring to each other - * - * @var array - */ - protected $_processed = array(); - - /** - * constructor - */ - private function __construct() - { - $this->_php_version = phpversion(); - $this->_timestamp = $this->_php_version >= 5.1 ? $_SERVER['REQUEST_TIME'] : time(); - $this->_json['request_uri'] = $_SERVER['REQUEST_URI']; - } - - /** - * gets instance of this class - * - * @return ChromePhp - */ - public static function getInstance() - { - if (self::$_instance === null) { - self::$_instance = new self(); - } - return self::$_instance; - } - - /** - * logs a variable to the console - * - * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] - * @return void - */ - public static function log() - { - $args = func_get_args(); - return self::_log('', $args); - } - - /** - * logs a warning to the console - * - * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] - * @return void - */ - public static function warn() - { - $args = func_get_args(); - return self::_log(self::WARN, $args); - } - - /** - * logs an error to the console - * - * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] - * @return void - */ - public static function error() - { - $args = func_get_args(); - return self::_log(self::ERROR, $args); - } - - /** - * sends a group log - * - * @param string value - */ - public static function group() - { - $args = func_get_args(); - return self::_log(self::GROUP, $args); - } - - /** - * sends an info log - * - * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] - * @return void - */ - public static function info() - { - $args = func_get_args(); - return self::_log(self::INFO, $args); - } - - /** - * sends a collapsed group log - * - * @param string value - */ - public static function groupCollapsed() - { - $args = func_get_args(); - return self::_log(self::GROUP_COLLAPSED, $args); - } - - /** - * ends a group log - * - * @param string value - */ - public static function groupEnd() - { - $args = func_get_args(); - return self::_log(self::GROUP_END, $args); - } - - /** - * sends a table log - * - * @param string value - */ - public static function table() - { - $args = func_get_args(); - return self::_log(self::TABLE, $args); - } - - /** - * internal logging call - * - * @param string $type - * @return void - */ - protected static function _log($type, array $args) - { - // nothing passed in, don't do anything - if (count($args) == 0 && $type != self::GROUP_END) { - return; - } - - $logger = self::getInstance(); - - $logger->_processed = array(); - - $logs = array(); - foreach ($args as $arg) { - $logs[] = $logger->_convert($arg); - } - - $backtrace = debug_backtrace(false); - $level = $logger->getSetting(self::BACKTRACE_LEVEL); - - $backtrace_message = 'unknown'; - if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) { - $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line']; - } - - $logger->_addRow($logs, $backtrace_message, $type); - } - - /** - * converts an object to a better format for logging - * - * @param Object - * @return array - */ - protected function _convert($object) - { - // if this isn't an object then just return it - if (!is_object($object)) { - return $object; - } - - //Mark this object as processed so we don't convert it twice and it - //Also avoid recursion when objects refer to each other - $this->_processed[] = $object; - - $object_as_array = array(); - - // first add the class name - $object_as_array['___class_name'] = get_class($object); - - // loop through object vars - $object_vars = get_object_vars($object); - foreach ($object_vars as $key => $value) { - - // same instance as parent object - if ($value === $object || in_array($value, $this->_processed, true)) { - $value = 'recursion - parent object [' . get_class($value) . ']'; - } - $object_as_array[$key] = $this->_convert($value); - } - - $reflection = new ReflectionClass($object); - - // loop through the properties and add those - foreach ($reflection->getProperties() as $property) { - - // if one of these properties was already added above then ignore it - if (array_key_exists($property->getName(), $object_vars)) { - continue; - } - $type = $this->_getPropertyKey($property); - - if ($this->_php_version >= 5.3) { - $property->setAccessible(true); - } - - try { - $value = $property->getValue($object); - } catch (ReflectionException $e) { - $value = 'only PHP 5.3 can access private/protected properties'; - } - - // same instance as parent object - if ($value === $object || in_array($value, $this->_processed, true)) { - $value = 'recursion - parent object [' . get_class($value) . ']'; - } - - $object_as_array[$type] = $this->_convert($value); - } - return $object_as_array; - } - - /** - * takes a reflection property and returns a nicely formatted key of the property name - * - * @param ReflectionProperty - * @return string - */ - protected function _getPropertyKey(ReflectionProperty $property) - { - $static = $property->isStatic() ? ' static' : ''; - if ($property->isPublic()) { - return 'public' . $static . ' ' . $property->getName(); - } - - if ($property->isProtected()) { - return 'protected' . $static . ' ' . $property->getName(); - } - - if ($property->isPrivate()) { - return 'private' . $static . ' ' . $property->getName(); - } - } - - /** - * adds a value to the data array - * - * @var mixed - * @return void - */ - protected function _addRow(array $logs, $backtrace, $type) - { - // if this is logged on the same line for example in a loop, set it to null to save space - if (in_array($backtrace, $this->_backtraces)) { - $backtrace = null; - } - - // for group, groupEnd, and groupCollapsed - // take out the backtrace since it is not useful - if ($type == self::GROUP || $type == self::GROUP_END || $type == self::GROUP_COLLAPSED) { - $backtrace = null; - } - - if ($backtrace !== null) { - $this->_backtraces[] = $backtrace; - } - - $row = array($logs, $backtrace, $type); - - $this->_json['rows'][] = $row; - $this->_writeHeader($this->_json); - } - - protected function _writeHeader($data) - { - header(self::HEADER_NAME . ': ' . $this->_encode($data)); - } - - /** - * encodes the data to be sent along with the request - * - * @param array $data - * @return string - */ - protected function _encode($data) - { - return base64_encode(utf8_encode(json_encode($data))); - } - - /** - * adds a setting - * - * @param string key - * @param mixed value - * @return void - */ - public function addSetting($key, $value) - { - $this->_settings[$key] = $value; - } - - /** - * add ability to set multiple settings in one call - * - * @param array $settings - * @return void - */ - public function addSettings(array $settings) - { - foreach ($settings as $key => $value) { - $this->addSetting($key, $value); - } - } - - /** - * gets a setting - * - * @param string key - * @return mixed - */ - public function getSetting($key) - { - if (!isset($this->_settings[$key])) { - return null; - } - return $this->_settings[$key]; - } -} diff --git a/htdocs/includes/ccampbell/chromephp/README.md b/htdocs/includes/ccampbell/chromephp/README.md deleted file mode 100644 index 3dd7dbe19dd..00000000000 --- a/htdocs/includes/ccampbell/chromephp/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## Overview -ChromePhp is a PHP library for the Chrome Logger Google Chrome extension. - -This library allows you to log variables to the Chrome console. - -## Requirements -- PHP 5 or later - -## Installation -1. Install the Chrome extension from: https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd -2. Click the extension icon in the browser to enable it for the current tab's domain -3. Put ChromePhp.php somewhere in your PHP include path -4. Log some data - - ```php - include 'ChromePhp.php'; - ChromePhp::log('Hello console!'); - ChromePhp::log($_SERVER); - ChromePhp::warn('something went wrong!'); - ``` - -More information can be found here: -http://www.chromelogger.com diff --git a/htdocs/includes/ccampbell/chromephp/composer.json b/htdocs/includes/ccampbell/chromephp/composer.json deleted file mode 100644 index dc16853d3ec..00000000000 --- a/htdocs/includes/ccampbell/chromephp/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "ccampbell/chromephp", - "type": "library", - "description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).", - "keywords": ["log","logging"], - "homepage": "http://github.com/ccampbell/chromephp", - "license": "Apache-2.0", - "authors": [ - { - "name": "Craig Campbell", - "email": "iamcraigcampbell@gmail.com", - "homepage": "http://craig.is", - "role": "Developer" - } - ], - "require": { - "php": ">=5.0.0" - }, - "autoload": { - "psr-0": { - "ChromePhp": "" - } - } -}