Merge branch 'develop' into qlo-remove-mysql2

This commit is contained in:
Rohit Jain
2021-10-26 19:43:18 +05:30
committed by GitHub
1799 changed files with 53075 additions and 352 deletions

View File

@@ -96,15 +96,11 @@ function rewriteSettingsFile($base_urls = null, $theme = null, $array_db = null)
$defines['_DB_PASSWD_'] = (($array_db && isset($array_db['_DB_PASSWD_'])) ? $array_db['_DB_PASSWD_'] : _DB_PASSWD_);
$defines['_COOKIE_KEY_'] = addslashes(_COOKIE_KEY_);
$defines['_COOKIE_IV_'] = addslashes(_COOKIE_IV_);
$defines['_NEW_COOKIE_KEY_'] = addslashes(_NEW_COOKIE_KEY_);
$defines['_PS_CREATION_DATE_'] = addslashes(_PS_CREATION_DATE_);
if (defined('_RIJNDAEL_KEY_')) {
$defines['_RIJNDAEL_KEY_'] = addslashes(_RIJNDAEL_KEY_);
}
if (defined('_RIJNDAEL_IV_')) {
$defines['_RIJNDAEL_IV_'] = addslashes(_RIJNDAEL_IV_);
}
$defines['_PS_VERSION_'] = addslashes(_PS_VERSION_);
$defines['_QLOAPPS_VERSION_'] = addslashes(_QLOAPPS_VERSION_);
$content = "<?php\n\n";
foreach ($defines as $k => $value) {
if ($k == '_PS_VERSION_') {

View File

@@ -41,10 +41,10 @@
</select>
</td>
<td class="center col-sm-6">
<a class="btn btn-default deactiveDatesModal" data-toggle="modal" data-target="#deactiveDatesModal" {if $info['id_status'] != 3 }style="display: none;"{/if}>{if $info['id_status'] != 3 }{l s='Add Dates'}{else}{l s='View Dates'}{/if}
<a class="btn btn-default deactiveDatesModal" data-toggle="modal" data-target="#deactiveDatesModal" {if $info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }style="display: none;"{/if}>{if $info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }{l s='Add Dates'}{else}{l s='View Dates'}{/if}
</a>
<input type="text" class="form-control room_comment" value="{$info['comment']}" name="room_comment[]" {if $info['id_status'] == 3 }style="display: none;"{/if}>
<input type="hidden" class="form-control disableDatesJSON" name="disableDatesJSON[]" {if $info['id_status'] == 3}value="{$info['disabled_dates_json']|escape:'html':'UTF-8'}"{/if}>
<input type="text" class="form-control room_comment" value="{$info['comment']}" name="room_comment[]" {if $info['id_status'] == $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }style="display: none;"{/if}>
<input type="hidden" class="form-control disableDatesJSON" name="disableDatesJSON[]" {if $info['id_status'] == $rm_status['STATUS_TEMPORARY_INACTIVE']['id']}value="{$info['disabled_dates_json']|escape:'html':'UTF-8'}"{/if}>
</td>
<td class="center col-sm-1">
<a href="#" class="rm_htl_room btn btn-default" data-id-htl-info="{$info['id']}"><i class="icon-trash"></i></a>
@@ -337,7 +337,7 @@
// on changing the room status as disabled for some date range.....
$(document).on("change", ".room_status", function(){
var status_val = $(this).val();
if (status_val == 3) {
if (status_val == rm_status.STATUS_TEMPORARY_INACTIVE.id) {
$(this).closest('.room_data_values').find('.room_comment, .deactiveDatesModal').toggle();
} else {
$(this).closest('.room_data_values').find('.room_comment').show();

View File

@@ -87,6 +87,7 @@ class ConfigurationTestCore
'config_dir' => 'config',
'files' => false,
'mails_dir' => 'mails',
'openssl' => false,
'curl' => false,
'soap' => false,
'simplexml' => false,
@@ -113,7 +114,6 @@ class ConfigurationTestCore
'new_phpversion' => false,
'register_globals' => false,
'gz' => false,
'mcrypt' => false,
'mbstring' => false,
'magicquotes' => false,
'dom' => false,
@@ -145,12 +145,12 @@ class ConfigurationTestCore
public static function test_phpversion()
{
return version_compare(substr(phpversion(), 0, 5), '5.4.0', '>=');
return version_compare(substr(phpversion(), 0, 5), '5.6.0', '>=');
}
public static function test_new_phpversion()
{
return version_compare(substr(phpversion(), 0, 5), '5.4.0', '>=');
return version_compare(substr(phpversion(), 0, 5), '5.6.0', '>=');
}
public static function test_mysql_support()
@@ -400,9 +400,9 @@ class ConfigurationTestCore
return function_exists('mb_strtolower');
}
public static function test_mcrypt()
public static function test_openssl()
{
return function_exists('mcrypt_encrypt');
return function_exists('openssl_encrypt');
}
public static function test_sessions()

View File

@@ -76,7 +76,7 @@ class CookieCore
$this->_name = 'PrestaShop-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);
$this->_allow_writing = true;
$this->_salt = $this->_standalone ? str_pad('', 8, md5('ps'.__FILE__)) : _COOKIE_IV_;
$this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
$this->_cipherTool = new PhpEncryption(_NEW_COOKIE_KEY_);
$this->_secure = (bool)$secure;
$this->update();
@@ -324,6 +324,11 @@ class CookieCore
*/
protected function _setcookie($cookie = null)
{
$length = (ini_get('mbstring.func_overload') & 2) ? mb_strlen($cookie, ini_get('default_charset')) : strlen($cookie);
if ($length >= 1048576) {
return false;
}
if ($cookie) {
$content = $this->_cipherTool->encrypt($cookie);
$time = $this->_expire;

122
classes/PhpEncryption.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
/**
* Class PhpEncryptionCore for openSSL 1.0.1+.
*/
class PhpEncryptionCore
{
const ENGINE = 'PhpEncryptionEngine';
const LEGACY_ENGINE = 'PhpEncryptionLegacyEngine';
private static $engine;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$engineClass = self::resolveEngineToUse();
self::$engine = new $engineClass($hexString);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
return self::$engine->encrypt($plaintext);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
return self::$engine->decrypt($cipherText);
}
/**
* @param $header
* @param $bytes
*
* @return string
*
* @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
*/
public static function saveBytesToChecksummedAsciiSafeString($header, $bytes)
{
$engine = self::resolveEngineToUse();
return $engine::saveBytesToChecksummedAsciiSafeString($header, $bytes);
}
/**
* @return string
*
* @throws Exception
*/
public static function createNewRandomKey()
{
$engine = self::resolveEngineToUse();
try {
$randomKey = $engine::createNewRandomKey();
} catch (EnvironmentIsBrokenException $exception) {
$buf = $engine::randomCompat();
$randomKey = $engine::saveToAsciiSafeString($buf);
}
return $randomKey;
}
/**
* Choose which engine use regarding the OpenSSL cipher methods available.
*/
public static function resolveEngineToUse()
{
if (false === in_array(\Defuse\Crypto\Core::CIPHER_METHOD, openssl_get_cipher_methods())) {
return self::LEGACY_ENGINE;
}
return self::ENGINE;
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Encoding;
use Defuse\Crypto\Key;
/**
* Class PhpEncryption engine for openSSL 1.0.1+.
*/
class PhpEncryptionEngineCore
{
protected $key;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$this->key = self::loadFromAsciiSafeString($hexString);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
return Crypto::encrypt($plaintext, $this->key);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
try {
$plaintext = Crypto::decrypt($cipherText, $this->key);
} catch (Exception $e) {
if ($e instanceof \Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException) {
return false;
}
throw $e;
}
return $plaintext;
}
/**
* @param $header
* @param $bytes
*
* @return string
*
* @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
*/
public static function saveBytesToChecksummedAsciiSafeString($header, $bytes)
{
return Encoding::saveBytesToChecksummedAsciiSafeString($header, $bytes);
}
/**
* @return string
*/
public static function createNewRandomKey()
{
$key = Key::createNewRandomKey();
return $key->saveToAsciiSafeString();
}
/**
* @param $hexString
*
* @return Key
*/
public static function loadFromAsciiSafeString($hexString)
{
return Key::loadFromAsciiSafeString($hexString);
}
/**
* @return string
*
* @throws Exception
*
* @see https://github.com/paragonie/random_compat/blob/v1.4.1/lib/random_bytes_openssl.php
* @see https://github.com/paragonie/random_compat/blob/v1.4.1/lib/random_bytes_mcrypt.php
*/
public static function randomCompat()
{
$bytes = Key::KEY_BYTE_SIZE;
$secure = true;
$buf = openssl_random_pseudo_bytes($bytes, $secure);
if (
$buf !== false
&&
$secure
&&
RandomCompat_strlen($buf) === $bytes
) {
return $buf;
}
$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
if (
$buf !== false
&&
RandomCompat_strlen($buf) === $bytes
) {
return $buf;
}
throw new Exception(
'Could not gather sufficient random data'
);
}
/**
* @param $buf
*
* @return string
*/
public static function saveToAsciiSafeString($buf)
{
return Encoding::saveBytesToChecksummedAsciiSafeString(
Key::KEY_CURRENT_VERSION,
$buf
);
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Class PhpEncryption engine for openSSL < 0.9.8.
*
* @doc http://php.net/manual/fr/function.mcrypt-encrypt.php#refsect1-function.mcrypt-encrypt-examples
*
* This class will be deprecated when web hosting providers will update their version of OpenSSL.
*/
class PhpEncryptionLegacyEngineCore extends PhpEncryptionEngine
{
protected $key;
protected $hmacIv;
protected $iv;
protected $ivSize;
protected $mode = MCRYPT_MODE_CBC;
protected $cipher = MCRYPT_RIJNDAEL_128;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$this->key = substr($hexString, 0, 32);
$this->ivSize = mcrypt_get_iv_size($this->cipher, $this->mode);
$this->iv = mcrypt_create_iv($this->ivSize, MCRYPT_RAND);
$this->hmacIv = substr(sha1(_COOKIE_KEY_), 0, $this->ivSize);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
$blockSize = mcrypt_get_block_size($this->cipher, $this->mode);
$pad = $blockSize - (strlen($plaintext) % $blockSize);
$cipherText = mcrypt_encrypt(
$this->cipher,
$this->key,
$plaintext . str_repeat(chr($pad), $pad),
$this->mode,
$this->iv
);
$cipherText = $this->iv . $cipherText;
return $this->generateHmac($cipherText) . ':' . base64_encode($cipherText);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
$data = explode(':', $cipherText);
if (count($data) != 2) {
return false;
}
list($hmac, $encrypted) = $data;
$encrypted = base64_decode($encrypted);
$newHmac = $this->generateHmac($encrypted);
if ($hmac !== $newHmac) {
return false;
}
$ivDec = substr($encrypted, 0, $this->ivSize);
$cipherText = substr($encrypted, $this->ivSize);
$data = mcrypt_decrypt(
$this->cipher,
$this->key,
$cipherText,
$this->mode,
$ivDec
);
$pad = ord($data[strlen($data) - 1]);
return substr($data, 0, -$pad);
}
/**
* Generate Hmac.
*
* @param string $encrypted
*
* @return string
*/
protected function generateHmac($encrypted)
{
$macKey = $this->generateKeygenS2k('sha256', $this->key, $this->hmacIv, 32);
return hash_hmac(
'sha256',
$this->hmacIv . $this->cipher . $encrypted,
$macKey
);
}
/**
* Alternative to mhash_keygen_s2k for security reason
* and php compatibilities.
*
* @param string $hash
* @param string $password
* @param string $salt
* @param int $bytes
*
* @return string
*/
protected function generateKeygenS2k($hash, $password, $salt, $bytes)
{
$result = '';
foreach (range(0, ceil($bytes / strlen(hash($hash, null, true))) - 1) as $i) {
$result .= hash(
$hash,
str_repeat("\0", $i) . str_pad(substr($salt, 0, 8), 8, "\0", STR_PAD_RIGHT) . $password,
true
);
}
return substr(
$result,
0,
intval($bytes)
);
}
}

View File

@@ -1,157 +0,0 @@
<?php
/*
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class RijndaelCore
{
protected $_key;
protected $_iv;
public function __construct($key, $iv)
{
$this->_key = $key;
$this->_iv = base64_decode($iv);
}
/**
* Base64 is not required, but it is be more compact than urlencode
*
* @param string $plaintext
* @return bool|string
*/
public function encrypt($plaintext)
{
if (strlen($plaintext) >= 1048576) {
return false;
}
$cipherText = null;
if (function_exists('openssl_encrypt') && version_compare(phpversion(), '5.3.3', '>=')) {
$cipherText = openssl_encrypt($plaintext, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA, $this->_iv);
} elseif (function_exists('mcrypt_encrypt')) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
$blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$pad = $blockSize - (strlen($plaintext) % $blockSize);
$cipherText = mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
$this->_key,
$plaintext . str_repeat(chr($pad), $pad),
MCRYPT_MODE_CBC,
$iv
);
$cipherText = $iv.$cipherText;
} else {
throw new RuntimeException('Either Mcrypt or OpenSSL extension is required to run Prestashop');
}
return $this->generateHmac($cipherText) . ':' . base64_encode($cipherText);
}
public function decrypt($cipherText)
{
$data = explode(':', $cipherText);
if (count($data) != 2) {
return false;
}
list($hmac, $encrypted) = $data;
$encrypted = base64_decode($encrypted);
$newHmac = $this->generateHmac($encrypted);
if ($hmac !== $newHmac) {
return false;
}
$output = null;
if (function_exists('openssl_decrypt') && version_compare(phpversion(), '5.3.3', '>=')) {
$output = openssl_decrypt($encrypted, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA, $this->_iv);
} elseif (function_exists('mcrypt_decrypt')) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$ivDec = substr($encrypted, 0, $ivSize);
$encrypted = substr($encrypted, $ivSize);
$output = mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
$this->_key,
$encrypted,
MCRYPT_MODE_CBC,
$ivDec
);
$pad = ord($output[strlen($output) - 1]);
$output = substr($output, 0, -$pad);
} else {
throw new RuntimeException('Either Mcrypt or OpenSSL extension is required to run Prestashop');
}
return $output;
}
/**
* Generate Hmac
*
* @param string $encrypted
*
* @return string
*/
protected function generateHmac($encrypted)
{
$macKey = $this->generateKeygenS2k('sha256', $this->_key, $this->_iv, 32);
return hash_hmac(
'sha256',
$this->_iv . MCRYPT_RIJNDAEL_128 . $encrypted,
$macKey
);
}
/**
* Alternative to mhash_keygen_s2k for security reason
* and php compatibilities.
*
* @param string $hash
* @param string $password
* @param string $salt
* @param integer $bytes
*
* @return string
*/
protected function generateKeygenS2k($hash, $password, $salt, $bytes)
{
$result = '';
foreach (range(0, ceil($bytes / strlen(hash($hash, null, true))) - 1) as $i) {
$result .= hash(
$hash,
str_repeat("\0", $i) . str_pad(substr($salt, 0, 8), 8, "\0", STR_PAD_RIGHT) . $password,
true
);
}
return substr(
$result,
0,
intval($bytes)
);
}
}

View File

@@ -23,6 +23,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once (_PS_TOOL_DIR_.'defuse/php-encryption/defuse-crypto.phar');
// Include some alias functions
require_once(_PS_CONFIG_DIR_.'alias.php');

View File

@@ -107,7 +107,6 @@ if (!defined('_PS_GEOIP_DIR_')) {
if (!defined('_PS_GEOIP_CITY_FILE_')) {
define('_PS_GEOIP_CITY_FILE_', 'GeoLiteCity.dat');
}
define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/');
define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/');
define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/');
define('_PS_TCPDF_PATH_', _PS_TOOL_DIR_.'tcpdf/');

View File

@@ -127,9 +127,10 @@ class AdminInformationControllerCore extends AdminController
'fopen' => $this->l('Allow the PHP fopen() function on your server.'),
'register_globals' => $this->l('Set PHP "register_globals" option to "Off".'),
'gz' => $this->l('Enable GZIP compression on your server.'),
'files' => $this->l('Some PrestaShop files are missing from your server.'),
'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by PrestaShop will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion()),
'files' => $this->l('Some QloApps files are missing from your server.'),
'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by QloApps will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion()),
'pdo_mysql' => $this->l('PDO MySQL extension is not loaded')
'openssl' => $this->l('PHP OpenSSL extension is not loaded'),
);
// Functions list to test with 'test_system'

View File

@@ -460,49 +460,6 @@ class AdminPerformanceControllerCore extends AdminController
$this->fields_value['_MEDIA_SERVER_3_'] = Configuration::get('PS_MEDIA_SERVER_3');
}
public function initFieldsetCiphering()
{
$phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
$php_lang = in_array($this->context->language->iso_code, $phpdoc_langs) ? $this->context->language->iso_code : 'en';
$warning_mcrypt = ' '.$this->l('(you must install the [a]Mcrypt extension[/a])');
$warning_mcrypt = str_replace('[a]', '<a href="http://www.php.net/manual/'.substr($php_lang, 0, 2).'/book.mcrypt.php" target="_blank">', $warning_mcrypt);
$warning_mcrypt = str_replace('[/a]', '</a>', $warning_mcrypt);
if (defined('_RIJNDAEL_KEY_') && defined('_RIJNDAEL_IV_')) {
$this->fields_form[5]['form'] = array(
'legend' => array(
'title' => $this->l('Ciphering'),
'icon' => 'icon-desktop'
),
'input' => array(
array(
'type' => 'hidden',
'name' => 'ciphering_up'
),
array(
'type' => 'radio',
'label' => $this->l('Algorithm'),
'name' => 'PS_CIPHER_ALGORITHM',
'values' => array(
array(
'id' => 'PS_CIPHER_ALGORITHM_1',
'value' => 1,
'label' => $this->l('Use Rijndael with mcrypt lib.').(function_exists('mcrypt_encrypt') ? '' : $warning_mcrypt)
),
)
)
),
'submit' => array(
'title' => $this->l('Save')
)
);
}
$this->fields_value['PS_CIPHER_ALGORITHM'] = Configuration::get('PS_CIPHER_ALGORITHM');
}
public function initFieldsetCaching()
{
$phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
@@ -618,7 +575,6 @@ class AdminPerformanceControllerCore extends AdminController
if (!defined('_PS_HOST_MODE_')) {
$this->initFieldsetMediaServer();
$this->initFieldsetCiphering();
$this->initFieldsetCaching();
}
@@ -840,51 +796,6 @@ class AdminPerformanceControllerCore extends AdminController
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool)Tools::getValue('ciphering_up') && Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM')) {
if ($this->tabAccess['edit'] === '1') {
$algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM');
$prev_settings = file_get_contents(_PS_ROOT_DIR_.'/config/settings.inc.php');
$new_settings = $prev_settings;
if ($algo) {
if (!function_exists('mcrypt_encrypt')) {
$this->errors[] = Tools::displayError('The "Mcrypt" PHP extension is not activated on this server.');
} else {
if (!strstr($new_settings, '_RIJNDAEL_KEY_')) {
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$key = Tools::passwdGen($key_size);
$new_settings = preg_replace(
'/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i',
'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');',
$new_settings
);
}
if (!strstr($new_settings, '_RIJNDAEL_IV_')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
$new_settings = preg_replace(
'/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i',
'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');',
$new_settings
);
}
}
}
if (!count($this->errors)) {
// If there is not settings file modification or if the backup and replacement of the settings file worked
if ($new_settings == $prev_settings || (
copy(_PS_ROOT_DIR_.'/config/settings.inc.php', _PS_ROOT_DIR_.'/config/settings.old.php')
&& (bool)file_put_contents(_PS_ROOT_DIR_.'/config/settings.inc.php', $new_settings)
)) {
Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo);
$redirectAdmin = true;
} else {
$this->errors[] = Tools::displayError('The settings file cannot be overwritten.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool)Tools::getValue('cache_up')) {
if ($this->tabAccess['edit'] === '1') {

View File

@@ -3324,8 +3324,8 @@ class AdminProductsControllerCore extends AdminController
$objHotelInfo = new HotelBranchInformation();
$hotelInfo = $objHotelInfo->hotelsNameAndId();
if ($hotelInfo) {
$objRoomStatus = new HotelRoomStatus();
$roomStatus = $objRoomStatus->getAllRoomStatus();
$objRoomInfo = new HotelRoomInformation();
$roomStatus = $objRoomInfo->getAllRoomStatus();
$objRoomType = new HotelRoomType();
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) {
@@ -3334,12 +3334,11 @@ class AdminProductsControllerCore extends AdminController
$hotelFullInfo = $objHotelInfo->hotelBranchInfoById($hotelRoomType['id_hotel']);
$data->assign('htl_full_info', $hotelFullInfo);
$objRoomInfo = new HotelRoomInformation();
$objRoomDisableDates = new HotelRoomDisableDates();
$hotelRoomInfo = $objRoomInfo->getHotelRoomInfo($obj->id, $hotelRoomType['id_hotel']);
if ($hotelRoomInfo) {
foreach ($hotelRoomInfo as &$room) {
if ($room['id_status'] == 3) {
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
$room['disabled_dates_json'] = json_encode($disabledDates);
}
@@ -3493,7 +3492,7 @@ class AdminProductsControllerCore extends AdminController
//validate room status
$disableDtsArr = array();
foreach ($room_status as $key => $status) {
if ($status == 3) {
if ($status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDtsArr[$key] = json_decode($disable_dates[$key], true);
$this->validateDisableDateRanges($disableDtsArr[$key]);
}
@@ -3529,7 +3528,7 @@ class AdminProductsControllerCore extends AdminController
$objRoomInfo->floor = $room_floor[$key];
$objRoomInfo->comment = $room_comment[$key];
if ($objRoomInfo->save()) {
if ($room_status[$key] == 3) {
if ($room_status[$key] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$objDisDts = new HotelRoomDisableDates();
$objDisDts->deleteRoomDisableDates($objRoomInfo->id);
if (isset($disableDtsArr[$key]) && $disableDtsArr[$key]) {

View File

@@ -24,6 +24,8 @@
* International Registered Trademark & Property of PrestaShop SA
*/
require_once (_PS_TOOL_DIR_.'defuse/php-encryption/defuse-crypto.phar');
class InstallModelInstall extends InstallAbstractModel
{
const SETTINGS_FILE = 'config/settings.inc.php';
@@ -69,6 +71,7 @@ class InstallModelInstall extends InstallAbstractModel
$this->setError($this->language->l('%s folder is not writable (check permissions)', dirname(self::SETTINGS_FILE)));
return false;
}
$key = \Defuse\Crypto\Key::createNewRandomKey();
// Generate settings content and write file
$settings_constants = array(
@@ -82,17 +85,12 @@ class InstallModelInstall extends InstallAbstractModel
'_PS_CACHE_ENABLED_' => '0',
'_COOKIE_KEY_' => Tools::passwdGen(56),
'_COOKIE_IV_' => Tools::passwdGen(8),
'_NEW_COOKIE_KEY_' => $key->saveToAsciiSafeString(),
'_PS_CREATION_DATE_' => date('Y-m-d'),
'_PS_VERSION_' => _PS_INSTALL_VERSION_,
'_QLOAPPS_VERSION_' => _QLO_INSTALL_VERSION_,
);
// If mcrypt is activated, add Rijndael 128 configuration
if (function_exists('mcrypt_encrypt')) {
$settings_constants['_RIJNDAEL_KEY_'] = Tools::passwdGen(mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
$settings_constants['_RIJNDAEL_IV_'] = base64_encode(mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND));
}
$settings_content = "<?php\n";
foreach ($settings_constants as $constant => $value) {

View File

@@ -27,8 +27,9 @@
if (!defined('_PS_VERSION_'))
exit;
include_once(_PS_CLASS_DIR_.'../tools/pear/PEAR.php');
include_once(_PS_PEAR_XML_PARSER_PATH_.'Parser.php');
include_once _PS_CLASS_DIR_.'../tools/pear/PEAR.php';
require_once dirname(__FILE__).'/vendor/autoload.php';
class Blockrss extends Module
{

7
modules/blockrss/vendor/autoload.php vendored Normal file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit573edf418ff486f71fdaa7e03e5841ca::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,10 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php',
);

View File

@@ -0,0 +1,11 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'XML' => array($vendorDir . '/pear/xml_feed_parser'),
'Log' => array($vendorDir . '/pear/log'),
);

View File

@@ -0,0 +1,9 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@@ -0,0 +1,56 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit573edf418ff486f71fdaa7e03e5841ca
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit573edf418ff486f71fdaa7e03e5841ca', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit573edf418ff486f71fdaa7e03e5841ca', 'loadClassLoader'));
$includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit573edf418ff486f71fdaa7e03e5841ca::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

View File

@@ -0,0 +1,38 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit573edf418ff486f71fdaa7e03e5841ca
{
public static $prefixesPsr0 = array (
'X' =>
array (
'XML' =>
array (
0 => __DIR__ . '/..' . '/pear/xml_feed_parser',
),
),
'L' =>
array (
'Log' =>
array (
0 => __DIR__ . '/..' . '/pear/log',
),
),
);
public static $classMap = array (
'PEAR_Exception' => __DIR__ . '/..' . '/pear/pear_exception/PEAR/Exception.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixesPsr0 = ComposerStaticInit573edf418ff486f71fdaa7e03e5841ca::$prefixesPsr0;
$loader->classMap = ComposerStaticInit573edf418ff486f71fdaa7e03e5841ca::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1,12 @@
<?php
// include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/pear/log',
$vendorDir . '/pear/pear_exception',
$vendorDir . '/pear/xml_feed_parser',
);

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,166 @@
[
{
"name": "pear/log",
"version": "1.13.3",
"version_normalized": "1.13.3.0",
"source": {
"type": "git",
"url": "https://github.com/pear/Log.git",
"reference": "21af0be11669194d72d88b5ee9d5f176dc75d9a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Log/zipball/21af0be11669194d72d88b5ee9d5f176dc75d9a3",
"reference": "21af0be11669194d72d88b5ee9d5f176dc75d9a3",
"shasum": ""
},
"require": {
"pear/pear_exception": "1.0.1 || 1.0.2",
"php": ">5.2"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"pear/db": "Install optionally via your project's composer.json"
},
"time": "2021-05-04T23:51:30+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Log": "./"
},
"exclude-from-classmap": [
"/examples/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"MIT"
],
"authors": [
{
"name": "Jon Parise",
"email": "jon@php.net",
"homepage": "http://www.indelible.org",
"role": "Developer"
}
],
"description": "PEAR Logging Framework",
"homepage": "http://pear.github.io/Log/",
"keywords": [
"log",
"logging"
]
},
{
"name": "pear/pear_exception",
"version": "v1.0.2",
"version_normalized": "1.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/pear/PEAR_Exception.git",
"reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/b14fbe2ddb0b9f94f5b24cf08783d599f776fff0",
"reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "<9"
},
"time": "2021-03-21T15:43:46+00:00",
"type": "class",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"classmap": [
"PEAR/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"."
],
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Helgi Thormar",
"email": "dufuz@php.net"
},
{
"name": "Greg Beaver",
"email": "cellog@php.net"
}
],
"description": "The PEAR Exception base class.",
"homepage": "https://github.com/pear/PEAR_Exception",
"keywords": [
"exception"
]
},
{
"name": "pear/xml_feed_parser",
"version": "v1.0.5",
"version_normalized": "1.0.5.0",
"source": {
"type": "git",
"url": "https://github.com/pear/XML_Feed_Parser.git",
"reference": "d8ad454742acba786738b39cbcc7c10f7b57adbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/XML_Feed_Parser/zipball/d8ad454742acba786738b39cbcc7c10f7b57adbe",
"reference": "d8ad454742acba786738b39cbcc7c10f7b57adbe",
"shasum": ""
},
"require": {
"pear/log": "*",
"pear/pear_exception": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"ext-tidy": "May require the tidy PHP extension"
},
"time": "2019-02-11T14:09:14+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"XML": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"./"
],
"license": [
"LGPL"
],
"authors": [
{
"name": "James Stewart",
"email": "james@jystewart.net",
"role": "Lead"
}
],
"description": "More info available on: http://pear.php.net/package/XML_Feed_Parser"
}
]

29
modules/blockrss/vendor/index.php vendored Normal file
View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

29
modules/blockrss/vendor/pear/index.php vendored Normal file
View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,29 @@
---
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
steps:
- uses: actions/checkout@v2
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: sqlite
ini-values: include_path=.:/usr/share/php
- name: Run tests
run: |
pear run-tests -d tests/

View File

@@ -0,0 +1,18 @@
# /
/*.tgz
# /docs/
/docs/api
# /tests/
/tests/*.diff
/tests/*.exp
/tests/*.log
/tests/*.out
/tests/sqlite-log.db
# composer related
composer.lock
composer.phar
vendor

View File

@@ -0,0 +1,19 @@
Copyright (c) 2001-2016 Jon Parise, Chuck Hagenbuch, and Jan Schneider.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

872
modules/blockrss/vendor/pear/log/Log.php vendored Normal file
View File

@@ -0,0 +1,872 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $
*
* @version $Revision$
* @package Log
*/
define('PEAR_LOG_EMERG', 0); /* System is unusable */
define('PEAR_LOG_ALERT', 1); /* Immediate action required */
define('PEAR_LOG_CRIT', 2); /* Critical conditions */
define('PEAR_LOG_ERR', 3); /* Error conditions */
define('PEAR_LOG_WARNING', 4); /* Warning conditions */
define('PEAR_LOG_NOTICE', 5); /* Normal but significant */
define('PEAR_LOG_INFO', 6); /* Informational */
define('PEAR_LOG_DEBUG', 7); /* Debug-level messages */
define('PEAR_LOG_ALL', 0xffffffff); /* All messages */
define('PEAR_LOG_NONE', 0x00000000); /* No message */
/* Log types for PHP's native error_log() function. */
define('PEAR_LOG_TYPE_SYSTEM', 0); /* Use PHP's system logger */
define('PEAR_LOG_TYPE_MAIL', 1); /* Use PHP's mail() function */
define('PEAR_LOG_TYPE_DEBUG', 2); /* Use PHP's debugging connection */
define('PEAR_LOG_TYPE_FILE', 3); /* Append to a file */
define('PEAR_LOG_TYPE_SAPI', 4); /* Use the SAPI logging handler */
/**
* The Log:: class implements both an abstraction for various logging
* mechanisms and the Subject end of a Subject-Observer pattern.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
* @since Horde 1.3
* @package Log
*/
class Log
{
/**
* Indicates whether or not the log can been opened / connected.
*
* @var boolean
* @access protected
*/
var $_opened = false;
/**
* Instance-specific unique identification number.
*
* @var integer
* @access protected
*/
var $_id = 0;
/**
* The label that uniquely identifies this set of log messages.
*
* @var string
* @access protected
*/
var $_ident = '';
/**
* The default priority to use when logging an event.
*
* @var integer
* @access protected
*/
var $_priority = PEAR_LOG_INFO;
/**
* The bitmask of allowed log levels.
*
* @var integer
* @access protected
*/
var $_mask = PEAR_LOG_ALL;
/**
* Holds all Log_observer objects that wish to be notified of new messages.
*
* @var array
* @access protected
*/
var $_listeners = array();
/**
* Starting depth to use when walking a backtrace in search of the
* function that invoked the log system.
*
* @var integer
* @access protected
*/
var $_backtrace_depth = 0;
/**
* Maps canonical format keys to position arguments for use in building
* "line format" strings.
*
* @var array
* @access protected
*/
var $_formatMap = array('%{timestamp}' => '%1$s',
'%{ident}' => '%2$s',
'%{priority}' => '%3$s',
'%{message}' => '%4$s',
'%{file}' => '%5$s',
'%{line}' => '%6$s',
'%{function}' => '%7$s',
'%{class}' => '%8$s',
'%\{' => '%%{');
public function __construct()
{
}
/**
* Attempts to return a concrete Log instance of type $handler.
*
* @param string $handler The type of concrete Log subclass to return.
* Attempt to dynamically include the code for
* this subclass. Currently, valid values are
* 'console', 'syslog', 'sql', 'file', and 'mcal'.
*
* @param string $name The name of the actually log file, table, or
* other specific store to use. Defaults to an
* empty string, with which the subclass will
* attempt to do something intelligent.
*
* @param string $ident The identity reported to the log system.
*
* @param array $conf A hash containing any additional configuration
* information that a subclass might need.
*
* @param int $level Log messages up to and including this level.
*
* @return object Log The newly created concrete Log instance, or
* null on an error.
* @access public
* @since Log 1.0
*/
public static function factory($handler, $name = '', $ident = '',
$conf = array(), $level = PEAR_LOG_DEBUG)
{
$handler = strtolower($handler);
$class = 'Log_' . $handler;
$classfile = 'Log/' . $handler . '.php';
/*
* Attempt to include our version of the named class, but don't treat
* a failure as fatal. The caller may have already included their own
* version of the named class.
*/
if (!class_exists($class, false)) {
include_once $classfile;
}
/* If the class exists, return a new instance of it. */
if (class_exists($class, false)) {
$obj = new $class($name, $ident, $conf, $level);
return $obj;
}
$null = null;
return $null;
}
/**
* Attempts to return a reference to a concrete Log instance of type
* $handler, only creating a new instance if no log instance with the same
* parameters currently exists.
*
* You should use this if there are multiple places you might create a
* logger, you don't want to create multiple loggers, and you don't want to
* check for the existance of one each time. The singleton pattern does all
* the checking work for you.
*
* <b>You MUST call this method with the $var = &Log::singleton() syntax.
* Without the ampersand (&) in front of the method name, you will not get
* a reference, you will get a copy.</b>
*
* @param string $handler The type of concrete Log subclass to return.
* Attempt to dynamically include the code for
* this subclass. Currently, valid values are
* 'console', 'syslog', 'sql', 'file', and 'mcal'.
*
* @param string $name The name of the actually log file, table, or
* other specific store to use. Defaults to an
* empty string, with which the subclass will
* attempt to do something intelligent.
*
* @param string $ident The identity reported to the log system.
*
* @param array $conf A hash containing any additional configuration
* information that a subclass might need.
*
* @param int $level Log messages up to and including this level.
*
* @return object Log The newly created concrete Log instance, or
* null on an error.
* @access public
* @since Log 1.0
*/
public static function singleton($handler, $name = '', $ident = '',
$conf = array(), $level = PEAR_LOG_DEBUG)
{
static $instances;
if (!isset($instances)) $instances = array();
$signature = serialize(array($handler, $name, $ident, $conf, $level));
if (!isset($instances[$signature])) {
$instances[$signature] = Log::factory($handler, $name, $ident,
$conf, $level);
}
return $instances[$signature];
}
/**
* Abstract implementation of the open() method.
* @since Log 1.0
*/
function open()
{
return false;
}
/**
* Abstract implementation of the close() method.
* @since Log 1.0
*/
function close()
{
return false;
}
/**
* Abstract implementation of the flush() method.
* @since Log 1.8.2
*/
function flush()
{
return false;
}
/**
* Abstract implementation of the log() method.
* @since Log 1.0
*/
function log($message, $priority = null)
{
return false;
}
/**
* A convenience function for logging a emergency event. It will log a
* message at the PEAR_LOG_EMERG log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function emerg($message)
{
return $this->log($message, PEAR_LOG_EMERG);
}
/**
* A convenience function for logging an alert event. It will log a
* message at the PEAR_LOG_ALERT log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function alert($message)
{
return $this->log($message, PEAR_LOG_ALERT);
}
/**
* A convenience function for logging a critical event. It will log a
* message at the PEAR_LOG_CRIT log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function crit($message)
{
return $this->log($message, PEAR_LOG_CRIT);
}
/**
* A convenience function for logging a error event. It will log a
* message at the PEAR_LOG_ERR log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function err($message)
{
return $this->log($message, PEAR_LOG_ERR);
}
/**
* A convenience function for logging a warning event. It will log a
* message at the PEAR_LOG_WARNING log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function warning($message)
{
return $this->log($message, PEAR_LOG_WARNING);
}
/**
* A convenience function for logging a notice event. It will log a
* message at the PEAR_LOG_NOTICE log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function notice($message)
{
return $this->log($message, PEAR_LOG_NOTICE);
}
/**
* A convenience function for logging a information event. It will log a
* message at the PEAR_LOG_INFO log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function info($message)
{
return $this->log($message, PEAR_LOG_INFO);
}
/**
* A convenience function for logging a debug event. It will log a
* message at the PEAR_LOG_DEBUG log level.
*
* @param mixed $message String or object containing the message
* to log.
*
* @return boolean True if the message was successfully logged.
*
* @access public
* @since Log 1.7.0
*/
function debug($message)
{
return $this->log($message, PEAR_LOG_DEBUG);
}
/**
* Returns the string representation of the message data.
*
* If $message is an object, _extractMessage() will attempt to extract
* the message text using a known method (such as a PEAR_Error object's
* getMessage() method). If a known method, cannot be found, the
* serialized representation of the object will be returned.
*
* If the message data is already a string, it will be returned unchanged.
*
* @param mixed $message The original message data. This may be a
* string or any object.
*
* @return string The string representation of the message.
*
* @access protected
*/
function _extractMessage($message)
{
/*
* If we've been given an object, attempt to extract the message using
* a known method. If we can't find such a method, default to the
* "human-readable" version of the object.
*
* We also use the human-readable format for arrays.
*/
if (is_object($message)) {
if (method_exists($message, 'getmessage')) {
$message = $message->getMessage();
} else if (method_exists($message, 'tostring')) {
$message = $message->toString();
} else if (method_exists($message, '__tostring')) {
$message = (string)$message;
} else {
$message = var_export($message, true);
}
} else if (is_array($message)) {
if (isset($message['message'])) {
if (is_scalar($message['message'])) {
$message = $message['message'];
} else {
$message = var_export($message['message'], true);
}
} else {
$message = var_export($message, true);
}
} else if (is_bool($message) || $message === NULL) {
$message = var_export($message, true);
}
/* Otherwise, we assume the message is a string. */
return $message;
}
/**
* Using debug_backtrace(), returns the file, line, and enclosing function
* name of the source code context from which log() was invoked.
*
* @param int $depth The initial number of frames we should step
* back into the trace.
*
* @return array Array containing four strings: the filename, the line,
* the function name, and the class name from which log()
* was called.
*
* @access private
* @since Log 1.9.4
*/
function _getBacktraceVars($depth)
{
/* Start by generating a backtrace from the current call (here). */
$bt = debug_backtrace();
/* Store some handy shortcuts to our previous frames. */
$bt0 = isset($bt[$depth]) ? $bt[$depth] : null;
$bt1 = isset($bt[$depth + 1]) ? $bt[$depth + 1] : null;
/*
* If we were ultimately invoked by the composite handler, we need to
* increase our depth one additional level to compensate.
*/
$class = isset($bt1['class']) ? $bt1['class'] : null;
if ($class !== null && strcasecmp($class, 'Log_composite') == 0) {
$depth++;
$bt0 = isset($bt[$depth]) ? $bt[$depth] : null;
$bt1 = isset($bt[$depth + 1]) ? $bt[$depth + 1] : null;
$class = isset($bt1['class']) ? $bt1['class'] : null;
}
/*
* We're interested in the frame which invoked the log() function, so
* we need to walk back some number of frames into the backtrace. The
* $depth parameter tells us where to start looking. We go one step
* further back to find the name of the encapsulating function from
* which log() was called.
*/
$file = isset($bt0) ? $bt0['file'] : null;
$line = isset($bt0) ? $bt0['line'] : 0;
$func = isset($bt1) ? $bt1['function'] : null;
/*
* However, if log() was called from one of our "shortcut" functions,
* we're going to need to go back an additional step.
*/
if (in_array($func, array('emerg', 'alert', 'crit', 'err', 'warning',
'notice', 'info', 'debug'))) {
$bt2 = isset($bt[$depth + 2]) ? $bt[$depth + 2] : null;
$file = is_array($bt1) ? $bt1['file'] : null;
$line = is_array($bt1) ? $bt1['line'] : 0;
$func = is_array($bt2) ? $bt2['function'] : null;
$class = isset($bt2['class']) ? $bt2['class'] : null;
}
/*
* If we couldn't extract a function name (perhaps because we were
* executed from the "main" context), provide a default value.
*/
if ($func === null) {
$func = '(none)';
}
/* Return a 4-tuple containing (file, line, function, class). */
return array($file, $line, $func, $class);
}
/**
* Sets the starting depth to use when walking a backtrace in search of
* the function that invoked the log system. This is used on conjunction
* with the 'file', 'line', 'function', and 'class' formatters.
*
* @param int $depth The new backtrace depth.
*
* @access public
* @since Log 1.12.7
*/
public function setBacktraceDepth($depth)
{
$this->_backtrace_depth = $depth;
}
/**
* Produces a formatted log line based on a format string and a set of
* variables representing the current log record and state.
*
* @return string Formatted log string.
*
* @access protected
* @since Log 1.9.4
*/
function _format($format, $timestamp, $priority, $message)
{
/*
* If the format string references any of the backtrace-driven
* variables (%5 %6,%7,%8), generate the backtrace and fetch them.
*/
if (preg_match('/%[5678]/', $format)) {
/* Plus 2 to account for our internal function calls. */
$d = $this->_backtrace_depth + 2;
list($file, $line, $func, $class) = $this->_getBacktraceVars($d);
}
/*
* Build the formatted string. We use the sprintf() function's
* "argument swapping" capability to dynamically select and position
* the variables which will ultimately appear in the log string.
*/
return sprintf($format,
$timestamp,
$this->_ident,
$this->priorityToString($priority),
$message,
isset($file) ? $file : '',
isset($line) ? $line : '',
isset($func) ? $func : '',
isset($class) ? $class : '');
}
/**
* Returns the string representation of a PEAR_LOG_* integer constant.
*
* @param int $priority A PEAR_LOG_* integer constant.
*
* @return string The string representation of $level.
*
* @access public
* @since Log 1.0
*/
function priorityToString($priority)
{
$levels = array(
PEAR_LOG_EMERG => 'emergency',
PEAR_LOG_ALERT => 'alert',
PEAR_LOG_CRIT => 'critical',
PEAR_LOG_ERR => 'error',
PEAR_LOG_WARNING => 'warning',
PEAR_LOG_NOTICE => 'notice',
PEAR_LOG_INFO => 'info',
PEAR_LOG_DEBUG => 'debug'
);
return $levels[$priority];
}
/**
* Returns the the PEAR_LOG_* integer constant for the given string
* representation of a priority name. This function performs a
* case-insensitive search.
*
* @param string $name String containing a priority name.
*
* @return string The PEAR_LOG_* integer contstant corresponding
* the the specified priority name.
*
* @access public
* @since Log 1.9.0
*/
function stringToPriority($name)
{
$levels = array(
'emergency' => PEAR_LOG_EMERG,
'alert' => PEAR_LOG_ALERT,
'critical' => PEAR_LOG_CRIT,
'error' => PEAR_LOG_ERR,
'warning' => PEAR_LOG_WARNING,
'notice' => PEAR_LOG_NOTICE,
'info' => PEAR_LOG_INFO,
'debug' => PEAR_LOG_DEBUG
);
return $levels[strtolower($name)];
}
/**
* Calculate the log mask for the given priority.
*
* This method may be called statically.
*
* @param integer $priority The priority whose mask will be calculated.
*
* @return integer The calculated log mask.
*
* @access public
* @since Log 1.7.0
*/
public static function MASK($priority)
{
return (1 << $priority);
}
/**
* Calculate the log mask for all priorities up to the given priority.
*
* This method may be called statically.
*
* @param integer $priority The maximum priority covered by this mask.
*
* @return integer The resulting log mask.
*
* @access public
* @since Log 1.7.0
*
* @deprecated deprecated since Log 1.9.4; use Log::MAX() instead
*/
public static function UPTO($priority)
{
return Log::MAX($priority);
}
/**
* Calculate the log mask for all priorities greater than or equal to the
* given priority. In other words, $priority will be the lowest priority
* matched by the resulting mask.
*
* This method may be called statically.
*
* @param integer $priority The minimum priority covered by this mask.
*
* @return integer The resulting log mask.
*
* @access public
* @since Log 1.9.4
*/
public static function MIN($priority)
{
return PEAR_LOG_ALL ^ ((1 << $priority) - 1);
}
/**
* Calculate the log mask for all priorities less than or equal to the
* given priority. In other words, $priority will be the highests priority
* matched by the resulting mask.
*
* This method may be called statically.
*
* @param integer $priority The maximum priority covered by this mask.
*
* @return integer The resulting log mask.
*
* @access public
* @since Log 1.9.4
*/
public static function MAX($priority)
{
return ((1 << ($priority + 1)) - 1);
}
/**
* Set and return the level mask for the current Log instance.
*
* @param integer $mask A bitwise mask of log levels.
*
* @return integer The current level mask.
*
* @access public
* @since Log 1.7.0
*/
function setMask($mask)
{
$this->_mask = $mask;
return $this->_mask;
}
/**
* Returns the current level mask.
*
* @return integer The current level mask.
*
* @access public
* @since Log 1.7.0
*/
function getMask()
{
return $this->_mask;
}
/**
* Check if the given priority is included in the current level mask.
*
* @param integer $priority The priority to check.
*
* @return boolean True if the given priority is included in the current
* log mask.
*
* @access protected
* @since Log 1.7.0
*/
function _isMasked($priority)
{
return (Log::MASK($priority) & $this->_mask);
}
/**
* Returns the current default priority.
*
* @return integer The current default priority.
*
* @access public
* @since Log 1.8.4
*/
function getPriority()
{
return $this->_priority;
}
/**
* Sets the default priority to the specified value.
*
* @param integer $priority The new default priority.
*
* @access public
* @since Log 1.8.4
*/
function setPriority($priority)
{
$this->_priority = $priority;
}
/**
* Adds a Log_observer instance to the list of observers that are listening
* for messages emitted by this Log instance.
*
* @param object $observer The Log_observer instance to attach as a
* listener.
*
* @return boolean True if the observer is successfully attached.
*
* @access public
* @since Log 1.0
*/
function attach(&$observer)
{
if (!is_a($observer, 'Log_observer')) {
return false;
}
$this->_listeners[$observer->_id] = &$observer;
return true;
}
/**
* Removes a Log_observer instance from the list of observers.
*
* @param object $observer The Log_observer instance to detach from
* the list of listeners.
*
* @return boolean True if the observer is successfully detached.
*
* @access public
* @since Log 1.0
*/
function detach($observer)
{
if (!is_a($observer, 'Log_observer') ||
!isset($this->_listeners[$observer->_id])) {
return false;
}
unset($this->_listeners[$observer->_id]);
return true;
}
/**
* Informs each registered observer instance that a new message has been
* logged.
*
* @param array $event A hash describing the log event.
*
* @access protected
*/
function _announce($event)
{
foreach ($this->_listeners as $id => $listener) {
if ($event['priority'] <= $this->_listeners[$id]->_priority) {
$this->_listeners[$id]->notify($event);
}
}
}
/**
* Indicates whether this is a composite class.
*
* @return boolean True if this is a composite class.
*
* @access public
* @since Log 1.0
*/
function isComposite()
{
return false;
}
/**
* Sets this Log instance's identification string.
*
* @param string $ident The new identification string.
*
* @access public
* @since Log 1.6.3
*/
function setIdent($ident)
{
$this->_ident = $ident;
}
/**
* Returns the current identification string.
*
* @return string The current Log instance's identification string.
*
* @access public
* @since Log 1.6.3
*/
function getIdent()
{
return $this->_ident;
}
}

View File

@@ -0,0 +1,274 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log/composite.php,v 1.2 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision$
* @package Log
*/
/**
* The Log_composite:: class implements a Composite pattern which
* allows multiple Log implementations to receive the same events.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
*
* @since Horde 1.3
* @since Log 1.0
* @package Log
*
* @example composite.php Using the composite handler.
*/
class Log_composite extends Log
{
/**
* Array holding all of the Log instances to which log events should be
* sent.
*
* @var array
* @access private
*/
var $_children = array();
/**
* Constructs a new composite Log object.
*
* @param string $name This parameter is ignored.
* @param string $ident This parameter is ignored.
* @param array $conf This parameter is ignored.
* @param int $level This parameter is ignored.
*
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_ident = $ident;
}
/**
* Opens all of the child instances.
*
* @return True if all of the child instances were successfully opened.
*
* @access public
*/
function open()
{
/* Attempt to open each of our children. */
$this->_opened = true;
foreach ($this->_children as $child) {
$this->_opened &= $child->open();
}
/* If all children were opened, return success. */
return $this->_opened;
}
/**
* Closes all open child instances.
*
* @return True if all of the opened child instances were successfully
* closed.
*
* @access public
*/
function close()
{
/* If we haven't been opened, there's nothing more to do. */
if (!$this->_opened) {
return true;
}
/* Attempt to close each of our children. */
$closed = true;
foreach ($this->_children as $child) {
if ($child->_opened) {
$closed &= $child->close();
}
}
/* Clear the opened state for consistency. */
$this->_opened = false;
/* If all children were closed, return success. */
return $closed;
}
/**
* Flushes all child instances. It is assumed that all of the children
* have been successfully opened.
*
* @return True if all of the child instances were successfully flushed.
*
* @access public
* @since Log 1.8.2
*/
function flush()
{
/* Attempt to flush each of our children. */
$flushed = true;
foreach ($this->_children as $child) {
$flushed &= $child->flush();
}
/* If all children were flushed, return success. */
return $flushed;
}
/**
* Sends $message and $priority to each child of this composite. If the
* appropriate children aren't already open, they will be opened here.
*
* @param mixed $message String or object containing the message
* to log.
* @param string $priority (optional) The priority of the message.
* Valid values are: PEAR_LOG_EMERG,
* PEAR_LOG_ALERT, PEAR_LOG_CRIT,
* PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and
* PEAR_LOG_DEBUG.
*
* @return boolean True if the entry is successfully logged.
*
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/*
* Abort early if the priority is above the composite handler's
* maximum logging level.
*
* XXX: Consider whether or not introducing this change would break
* backwards compatibility. Some users may be expecting composite
* handlers to pass on all events to their children regardless of
* their own priority.
*/
#if (!$this->_isMasked($priority)) {
# return false;
#}
/*
* Iterate over all of our children. If a unopened child will respond
* to this log event, we attempt to open it immediately. The composite
* handler's opened state will be enabled as soon as the first child
* handler is successfully opened.
*
* We track an overall success state that indicates whether or not all
* of the relevant child handlers were opened and successfully logged
* the event. If one handler fails, we still attempt any remaining
* children, but we consider the overall result a failure.
*/
$success = true;
foreach ($this->_children as $child) {
/* If this child won't respond to this event, skip it. */
if (!$child->_isMasked($priority)) {
continue;
}
/* If this child has yet to be opened, attempt to do so now. */
if (!$child->_opened) {
$success &= $child->open();
/*
* If we've successfully opened our first handler, the
* composite handler itself is considered to be opened.
*/
if (!$this->_opened && $success) {
$this->_opened = true;
}
}
/* Finally, attempt to log the message to the child handler. */
if ($child->_opened) {
$success &= $child->log($message, $priority);
}
}
/* Notify the observers. */
$this->_announce(array('priority' => $priority, 'message' => $message));
/* Return success if all of the open children logged the event. */
return $success;
}
/**
* Returns true if this is a composite.
*
* @return boolean True if this is a composite class.
*
* @access public
*/
function isComposite()
{
return true;
}
/**
* Sets this identification string for all of this composite's children.
*
* @param string $ident The new identification string.
*
* @access public
* @since Log 1.6.7
*/
function setIdent($ident)
{
/* Call our base class's setIdent() method. */
parent::setIdent($ident);
/* ... and then call setIdent() on all of our children. */
foreach ($this->_children as $child) {
$child->setIdent($ident);
}
}
/**
* Adds a Log instance to the list of children.
*
* @param object $child The Log instance to add.
*
* @return boolean True if the Log instance was successfully added.
*
* @access public
*/
function addChild(&$child)
{
/* Make sure this is a Log instance. */
if (!is_a($child, 'Log')) {
return false;
}
$this->_children[$child->_id] = $child;
return true;
}
/**
* Removes a Log instance from the list of children.
*
* @param object $child The Log instance to remove.
*
* @return boolean True if the Log instance was successfully removed.
*
* @access public
*/
function removeChild($child)
{
if (!is_a($child, 'Log') || !isset($this->_children[$child->_id])) {
return false;
}
unset($this->_children[$child->_id]);
return true;
}
}

View File

@@ -0,0 +1,222 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_console class is a concrete implementation of the Log::
* abstract class which writes message to the text console.
*
* @author Jon Parise <jon@php.net>
* @since Log 1.1
* @package Log
*
* @example console.php Using the console handler.
*/
class Log_console extends Log
{
/**
* Handle to the current output stream.
* @var resource
* @access private
*/
var $_stream = null;
/**
* Is this object responsible for closing the stream resource?
* @var bool
* @access private
*/
var $_closeResource = false;
/**
* Should the output be buffered or displayed immediately?
* @var string
* @access private
*/
var $_buffering = false;
/**
* String holding the buffered output.
* @var string
* @access private
*/
var $_buffer = '';
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '%1$s %2$s [%3$s] %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* Constructs a new Log_console object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (!empty($conf['stream'])) {
$this->_stream = $conf['stream'];
} elseif (defined('STDOUT')) {
$this->_stream = STDOUT;
} else {
$this->_stream = fopen('php://output', 'a');
$this->_closeResource = true;
}
if (isset($conf['buffering'])) {
$this->_buffering = $conf['buffering'];
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
/*
* If output buffering has been requested, we need to register a
* shutdown function that will dump the buffer upon termination.
*/
if ($this->_buffering) {
register_shutdown_function(array(&$this, '_Log_console'));
}
}
/**
* Destructor
*/
function _Log_console()
{
$this->close();
}
/**
* Open the output stream.
*
* @access public
* @since Log 1.9.7
*/
function open()
{
$this->_opened = true;
return true;
}
/**
* Closes the output stream.
*
* This results in a call to flush().
*
* @access public
* @since Log 1.9.0
*/
function close()
{
$this->flush();
$this->_opened = false;
if ($this->_closeResource === true && is_resource($this->_stream)) {
fclose($this->_stream);
}
return true;
}
/**
* Flushes all pending ("buffered") data to the output stream.
*
* @access public
* @since Log 1.8.2
*/
function flush()
{
/*
* If output buffering is enabled, dump the contents of the buffer to
* the output stream.
*/
if ($this->_buffering && (strlen($this->_buffer) > 0)) {
fwrite($this->_stream, $this->_buffer);
$this->_buffer = '';
}
if (is_resource($this->_stream)) {
return fflush($this->_stream);
}
return false;
}
/**
* Writes $message to the text console. Also, passes the message
* along to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build the string containing the complete log line. */
$line = $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message) . "\n";
/*
* If buffering is enabled, append this line to the output buffer.
* Otherwise, print the line to the output stream immediately.
*/
if ($this->_buffering) {
$this->_buffer .= $line;
} else {
fwrite($this->_stream, $line);
}
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,234 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_daemon class is a concrete implementation of the Log::
* abstract class which sends messages to syslog daemon on UNIX-like machines.
* This class uses the syslog protocol: http://www.ietf.org/rfc/rfc3164.txt
*
* @author Bart van der Schans <schans@dds.nl>
* @version $Revision$
* @package Log
*/
class Log_daemon extends Log
{
/**
* Integer holding the log facility to use.
* @var string
*/
var $_name = LOG_DAEMON;
/**
* Var holding the resource pointer to the socket
* @var resource
*/
var $_socket;
/**
* The ip address or servername
* @see http://www.php.net/manual/en/transports.php
* @var string
*/
var $_ip = '127.0.0.1';
/**
* Protocol to use (tcp, udp, etc.)
* @see http://www.php.net/manual/en/transports.php
* @var string
*/
var $_proto = 'udp';
/**
* Port to connect to
* @var int
*/
var $_port = 514;
/**
* Maximum message length in bytes
* @var int
*/
var $_maxsize = 4096;
/**
* Socket timeout in seconds
* @var int
*/
var $_timeout = 1;
/**
* Constructs a new syslog object.
*
* @param string $name The syslog facility.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Maximum level at which to log.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
/* Ensure we have a valid integer value for $name. */
if (empty($name) || !is_int($name)) {
$name = LOG_SYSLOG;
}
$this->_id = md5(microtime().rand());
$this->_name = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['ip'])) {
$this->_ip = $conf['ip'];
}
if (isset($conf['proto'])) {
$this->_proto = $conf['proto'];
}
if (isset($conf['port'])) {
$this->_port = $conf['port'];
}
if (isset($conf['maxsize'])) {
$this->_maxsize = $conf['maxsize'];
}
if (isset($conf['timeout'])) {
$this->_timeout = $conf['timeout'];
}
$this->_proto = $this->_proto . '://';
register_shutdown_function(array(&$this, '_Log_daemon'));
}
/**
* Destructor.
*
* @access private
*/
function _Log_daemon()
{
$this->close();
}
/**
* Opens a connection to the system logger, if it has not already
* been opened. This is implicitly called by log(), if necessary.
* @access public
*/
function open()
{
if (!$this->_opened) {
$this->_opened = (bool)($this->_socket = @fsockopen(
$this->_proto . $this->_ip,
$this->_port,
$errno,
$errstr,
$this->_timeout));
}
return $this->_opened;
}
/**
* Closes the connection to the system logger, if it is open.
* @access public
*/
function close()
{
if ($this->_opened) {
$this->_opened = false;
return fclose($this->_socket);
}
return true;
}
/**
* Sends $message to the currently open syslog connection. Calls
* open() if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
*
* @param string $message The textual message to be logged.
* @param int $priority (optional) The priority of the message. Valid
* values are: LOG_EMERG, LOG_ALERT, LOG_CRIT,
* LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO,
* and LOG_DEBUG. The default is LOG_INFO.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Set the facility level. */
$facility_level = intval($this->_name) +
intval($this->_toSyslog($priority));
/* Prepend ident info. */
if (!empty($this->_ident)) {
$message = $this->_ident . ' ' . $message;
}
/* Check for message length. */
if (strlen($message) > $this->_maxsize) {
$message = substr($message, 0, ($this->_maxsize) - 10) . ' [...]';
}
/* Write to socket. */
fwrite($this->_socket, '<' . $facility_level . '>' . $message . "\n");
$this->_announce(array('priority' => $priority, 'message' => $message));
}
/**
* Converts a PEAR_LOG_* constant into a syslog LOG_* constant.
*
* This function exists because, under Windows, not all of the LOG_*
* constants have unique values. Instead, the PEAR_LOG_* were introduced
* for global use, with the conversion to the LOG_* constants kept local to
* to the syslog driver.
*
* @param int $priority PEAR_LOG_* value to convert to LOG_* value.
*
* @return The LOG_* representation of $priority.
*
* @access private
*/
function _toSyslog($priority)
{
static $priorities = array(
PEAR_LOG_EMERG => LOG_EMERG,
PEAR_LOG_ALERT => LOG_ALERT,
PEAR_LOG_CRIT => LOG_CRIT,
PEAR_LOG_ERR => LOG_ERR,
PEAR_LOG_WARNING => LOG_WARNING,
PEAR_LOG_NOTICE => LOG_NOTICE,
PEAR_LOG_INFO => LOG_INFO,
PEAR_LOG_DEBUG => LOG_DEBUG
);
/* If we're passed an unknown priority, default to LOG_INFO. */
if (!is_int($priority) || !in_array($priority, $priorities)) {
return LOG_INFO;
}
return $priorities[$priority];
}
}

View File

@@ -0,0 +1,181 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_display class is a concrete implementation of the Log::
* abstract class which writes message into browser in usual PHP maner.
* This may be useful because when you use PEAR::setErrorHandling in
* PEAR_ERROR_CALLBACK mode error messages are not displayed by
* PHP error handler.
*
* @author Paul Yanchenko <pusher@inaco.ru>
* @since Log 1.8.0
* @package Log
*
* @example display.php Using the display handler.
*/
class Log_display extends Log
{
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '<b>%3$s</b>: %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* Flag indicating whether raw message text should be passed directly to
* the log system. Otherwise, the text will be converted to an HTML-safe
* representation.
* @var boolean
* @access private
*/
var $_rawText = false;
/**
* Constructs a new Log_display object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name = '', $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
/* Start by configuring the line format. */
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
/* We may need to prepend a string to our line format. */
$prepend = null;
if (isset($conf['error_prepend'])) {
$prepend = $conf['error_prepend'];
} else {
$prepend = ini_get('error_prepend_string');
}
if (!empty($prepend)) {
$this->_lineFormat = $prepend . $this->_lineFormat;
}
/* We may also need to append a string to our line format. */
$append = null;
if (isset($conf['error_append'])) {
$append = $conf['error_append'];
} else {
$append = ini_get('error_append_string');
}
if (!empty($append)) {
$this->_lineFormat .= $append;
}
/* Lastly, the line ending sequence is also configurable. */
if (isset($conf['linebreak'])) {
$this->_lineFormat .= $conf['linebreak'];
} else {
$this->_lineFormat .= "<br />\n";
}
/* The user can also change the time format. */
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
/* Message text conversion can be disabled. */
if (isset($conf['rawText'])) {
$this->_rawText = $conf['rawText'];
}
}
/**
* Opens the display handler.
*
* @access public
* @since Log 1.9.6
*/
function open()
{
$this->_opened = true;
return true;
}
/**
* Closes the display handler.
*
* @access public
* @since Log 1.9.6
*/
function close()
{
$this->_opened = false;
return true;
}
/**
* Writes $message to the text browser. Also, passes the message
* along to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Convert the message to an HTML-friendly represention unless raw
* text has been requested. */
if ($this->_rawText === false) {
$message = nl2br(htmlspecialchars($message));
}
/* Build and output the complete log line. */
echo $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority,
$message);
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_error_log class is a concrete implementation of the Log abstract
* class that logs messages using PHP's error_log() function.
*
* @author Jon Parise <jon@php.net>
* @since Log 1.7.0
* @package Log
*
* @example error_log.php Using the error_log handler.
*/
class Log_error_log extends Log
{
/**
* The error_log() log type.
* @var integer
* @access private
*/
var $_type = PEAR_LOG_TYPE_SYSTEM;
/**
* The type-specific destination value.
* @var string
* @access private
*/
var $_destination = '';
/**
* Additional headers to pass to the mail() function when the
* PEAR_LOG_TYPE_MAIL type is used.
* @var string
* @access private
*/
var $_extra_headers = '';
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '%2$s: %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* Constructs a new Log_error_log object.
*
* @param string $name One of the PEAR_LOG_TYPE_* constants.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_type = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (!empty($conf['destination'])) {
$this->_destination = $conf['destination'];
}
if (!empty($conf['extra_headers'])) {
$this->_extra_headers = $conf['extra_headers'];
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
}
/**
* Opens the handler.
*
* @access public
* @since Log 1.9.6
*/
function open()
{
$this->_opened = true;
return true;
}
/**
* Closes the handler.
*
* @access public
* @since Log 1.9.6
*/
function close()
{
$this->_opened = false;
return true;
}
/**
* Logs $message using PHP's error_log() function. The message is also
* passed along to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build the string containing the complete log line. */
$line = $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message);
/* Pass the log line and parameters to the error_log() function. */
$success = error_log($line, $this->_type, $this->_destination,
$this->_extra_headers);
$this->_announce(array('priority' => $priority, 'message' => $message));
return $success;
}
}

View File

@@ -0,0 +1,316 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_file class is a concrete implementation of the Log abstract
* class that logs messages to a text file.
*
* @author Jon Parise <jon@php.net>
* @author Roman Neuhauser <neuhauser@bellavista.cz>
* @since Log 1.0
* @package Log
*
* @example file.php Using the file handler.
*/
class Log_file extends Log
{
/**
* String containing the name of the log file.
* @var string
* @access private
*/
var $_filename = 'php.log';
/**
* Handle to the log file.
* @var resource
* @access private
*/
var $_fp = false;
/**
* Should new log entries be append to an existing log file, or should the
* a new log file overwrite an existing one?
* @var boolean
* @access private
*/
var $_append = true;
/**
* Should advisory file locking (i.e., flock()) be used?
* @var boolean
* @access private
*/
var $_locking = false;
/**
* Integer (in octal) containing the log file's permissions mode.
* @var integer
* @access private
*/
var $_mode = 0644;
/**
* Integer (in octal) specifying the file permission mode that will be
* used when creating directories that do not already exist.
* @var integer
* @access private
*/
var $_dirmode = 0755;
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '%1$s %2$s [%3$s] %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* String containing the end-on-line character sequence.
* @var string
* @access private
*/
var $_eol = "\n";
/**
* Constructs a new Log_file object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_filename = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['append'])) {
$this->_append = $conf['append'];
}
if (isset($conf['locking'])) {
$this->_locking = $conf['locking'];
}
if (!empty($conf['mode'])) {
if (is_string($conf['mode'])) {
$this->_mode = octdec($conf['mode']);
} else {
$this->_mode = $conf['mode'];
}
}
if (!empty($conf['dirmode'])) {
if (is_string($conf['dirmode'])) {
$this->_dirmode = octdec($conf['dirmode']);
} else {
$this->_dirmode = $conf['dirmode'];
}
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
if (!empty($conf['eol'])) {
$this->_eol = $conf['eol'];
} else {
$this->_eol = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n";
}
register_shutdown_function(array(&$this, '_Log_file'));
}
/**
* Destructor
*/
function _Log_file()
{
if ($this->_opened) {
$this->close();
}
}
/**
* Creates the given directory path. If the parent directories don't
* already exist, they will be created, too.
*
* This implementation is inspired by Python's os.makedirs function.
*
* @param string $path The full directory path to create.
* @param integer $mode The permissions mode with which the
* directories will be created.
*
* @return True if the full path is successfully created or already
* exists.
*
* @access private
*/
function _mkpath($path, $mode = 0700)
{
/* Separate the last pathname component from the rest of the path. */
$head = dirname($path);
$tail = basename($path);
/* Make sure we've split the path into two complete components. */
if (empty($tail)) {
$head = dirname($path);
$tail = basename($path);
}
/* Recurse up the path if our current segment does not exist. */
if (!empty($head) && !empty($tail) && !is_dir($head)) {
$this->_mkpath($head, $mode);
}
/* Create this segment of the path. */
return @mkdir($head, $mode);
}
/**
* Opens the log file for output. If the specified log file does not
* already exist, it will be created. By default, new log entries are
* appended to the end of the log file.
*
* This is implicitly called by log(), if necessary.
*
* @access public
*/
function open()
{
if (!$this->_opened) {
/* If the log file's directory doesn't exist, create it. */
if (!is_dir(dirname($this->_filename))) {
$this->_mkpath($this->_filename, $this->_dirmode);
}
/* Determine whether the log file needs to be created. */
$creating = !file_exists($this->_filename);
/* Obtain a handle to the log file. */
$this->_fp = fopen($this->_filename, ($this->_append) ? 'a' : 'w');
/* We consider the file "opened" if we have a valid file pointer. */
$this->_opened = ($this->_fp !== false);
/* Attempt to set the file's permissions if we just created it. */
if ($creating && $this->_opened) {
chmod($this->_filename, $this->_mode);
}
}
return $this->_opened;
}
/**
* Closes the log file if it is open.
*
* @access public
*/
function close()
{
/* If the log file is open, close it. */
if ($this->_opened && fclose($this->_fp)) {
$this->_opened = false;
}
return ($this->_opened === false);
}
/**
* Flushes all pending data to the file handle.
*
* @access public
* @since Log 1.8.2
*/
function flush()
{
if (is_resource($this->_fp)) {
return fflush($this->_fp);
}
return false;
}
/**
* Logs $message to the output window. The message is also passed along
* to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the log file isn't already open, open it now. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build the string containing the complete log line. */
$line = $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message) . $this->_eol;
/* If locking is enabled, acquire an exclusive lock on the file. */
if ($this->_locking) {
flock($this->_fp, LOCK_EX);
}
/* Write the log line to the log file. */
$success = (fwrite($this->_fp, $line) !== false);
/* Unlock the file now that we're finished writing to it. */
if ($this->_locking) {
flock($this->_fp, LOCK_UN);
}
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return $success;
}
}

View File

@@ -0,0 +1,207 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_firebug class is a concrete implementation of the Log::
* abstract class which writes message into Firebug console.
*
* http://www.getfirebug.com/
*
* @author Mika Tuupola <tuupola@appelsiini.net>
* @since Log 1.9.11
* @package Log
*
* @example firebug.php Using the firebug handler.
*/
class Log_firebug extends Log
{
/**
* Should the output be buffered or displayed immediately?
* @var string
* @access private
*/
var $_buffering = false;
/**
* String holding the buffered output.
* @var string
* @access private
*/
var $_buffer = array();
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '%2$s [%3$s] %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
*
* Note! Default lineFormat of this driver does not display time.
*
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* Mapping of log priorities to Firebug methods.
* @var array
* @access private
*/
var $_methods = array(
PEAR_LOG_EMERG => 'error',
PEAR_LOG_ALERT => 'error',
PEAR_LOG_CRIT => 'error',
PEAR_LOG_ERR => 'error',
PEAR_LOG_WARNING => 'warn',
PEAR_LOG_NOTICE => 'info',
PEAR_LOG_INFO => 'info',
PEAR_LOG_DEBUG => 'debug'
);
/**
* Constructs a new Log_firebug object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name = '', $ident = 'PHP', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['buffering'])) {
$this->_buffering = $conf['buffering'];
}
if ($this->_buffering) {
register_shutdown_function(array(&$this, '_Log_firebug'));
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
}
/**
* Opens the firebug handler.
*
* @access public
*/
function open()
{
$this->_opened = true;
return true;
}
/**
* Destructor
*/
function _Log_firebug()
{
$this->close();
}
/**
* Closes the firebug handler.
*
* @access public
*/
function close()
{
$this->flush();
$this->_opened = false;
return true;
}
/**
* Flushes all pending ("buffered") data.
*
* @access public
*/
function flush() {
if (count($this->_buffer)) {
print '<script type="text/javascript">';
print "\nif ('console' in window) {\n";
foreach ($this->_buffer as $line) {
print " $line\n";
}
print "}\n";
print "</script>\n";
};
$this->_buffer = array();
}
/**
* Writes $message to Firebug console. Also, passes the message
* along to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
$method = $this->_methods[$priority];
/* normalize line breaks and escape quotes*/
$message = preg_replace("/\r?\n/", "\\n", addslashes($message));
/* Build the string containing the complete log line. */
$line = $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority,
$message);
if ($this->_buffering) {
$this->_buffer[] = sprintf('console.%s("%s");', $method, $line);
} else {
print '<script type="text/javascript">';
print "\nif ('console' in window) {\n";
/* Build and output the complete log line. */
printf(' console.%s("%s");', $method, $line);
print "\n}\n";
print "</script>\n";
}
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,294 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_mail class is a concrete implementation of the Log:: abstract class
* which sends log messages to a mailbox.
* The mail is actually sent when you close() the logger, or when the destructor
* is called (when the script is terminated).
*
* PLEASE NOTE that you must create a Log_mail object using =&, like this :
* $logger =& Log::factory("mail", "recipient@example.com", ...)
*
* This is a PEAR requirement for destructors to work properly.
* See http://pear.php.net/manual/en/class.pear.php
*
* @author Ronnie Garcia <ronnie@mk2.net>
* @author Jon Parise <jon@php.net>
* @since Log 1.3
* @package Log
*
* @example mail.php Using the mail handler.
*/
class Log_mail extends Log
{
/**
* String holding the recipients' email addresses. Multiple addresses
* should be separated with commas.
* @var string
* @access private
*/
var $_recipients = '';
/**
* String holding the sender's email address.
* @var string
* @access private
*/
var $_from = '';
/**
* String holding the email's subject.
* @var string
* @access private
*/
var $_subject = '[Log_mail] Log message';
/**
* String holding an optional preamble for the log messages.
* @var string
* @access private
*/
var $_preamble = '';
/**
* String containing the format of a log line.
* @var string
* @access private
*/
var $_lineFormat = '%1$s %2$s [%3$s] %4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* String holding the mail message body.
* @var string
* @access private
*/
var $_message = '';
/**
* Flag used to indicated that log lines have been written to the message
* body and the message should be sent on close().
* @var boolean
* @access private
*/
var $_shouldSend = false;
/**
* String holding the backend name of PEAR::Mail
* @var string
* @access private
*/
var $_mailBackend = '';
/**
* Array holding the params for PEAR::Mail
* @var array
* @access private
*/
var $_mailParams = array();
/**
* Constructs a new Log_mail object.
*
* Here is how you can customize the mail driver with the conf[] hash :
* $conf['from']: the mail's "From" header line,
* $conf['subject']: the mail's "Subject" line.
* $conf['mailBackend']: backend name of PEAR::Mail
* $conf['mailParams']: parameters for the PEAR::Mail backend
*
* @param string $name The message's recipients.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_recipients = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (!empty($conf['from'])) {
$this->_from = $conf['from'];
} else {
$this->_from = ini_get('sendmail_from');
}
if (!empty($conf['subject'])) {
$this->_subject = $conf['subject'];
}
if (!empty($conf['preamble'])) {
$this->_preamble = $conf['preamble'];
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
if (!empty($conf['mailBackend'])) {
$this->_mailBackend = $conf['mailBackend'];
}
if (!empty($conf['mailParams'])) {
$this->_mailParams = $conf['mailParams'];
}
/* register the destructor */
register_shutdown_function(array(&$this, '_Log_mail'));
}
/**
* Destructor. Calls close().
*
* @access private
*/
function _Log_mail()
{
$this->close();
}
/**
* Starts a new mail message.
* This is implicitly called by log(), if necessary.
*
* @access public
*/
function open()
{
if (!$this->_opened) {
if (!empty($this->_preamble)) {
$this->_message = $this->_preamble . "\r\n\r\n";
}
$this->_opened = true;
$_shouldSend = false;
}
return $this->_opened;
}
/**
* Closes the message, if it is open, and sends the mail.
* This is implicitly called by the destructor, if necessary.
*
* @access public
*/
function close()
{
if ($this->_opened) {
if ($this->_shouldSend && !empty($this->_message)) {
if ($this->_mailBackend === '') { // use mail()
$headers = "From: $this->_from\r\n";
$headers .= 'User-Agent: PEAR Log Package';
if (mail($this->_recipients, $this->_subject,
$this->_message, $headers) == false) {
return false;
}
} else { // use PEAR::Mail
include_once 'Mail.php';
$headers = array('From' => $this->_from,
'To' => $this->_recipients,
'User-Agent' => 'PEAR Log Package',
'Subject' => $this->_subject);
$mailer = &Mail::factory($this->_mailBackend,
$this->_mailParams);
$res = $mailer->send($this->_recipients, $headers,
$this->_message);
if (PEAR::isError($res)) {
return false;
}
}
/* Clear the message string now that the email has been sent. */
$this->_message = '';
$this->_shouldSend = false;
}
$this->_opened = false;
}
return ($this->_opened === false);
}
/**
* Flushes the log output by forcing the email message to be sent now.
* Events that are logged after flush() is called will be appended to a
* new email message.
*
* @access public
* @since Log 1.8.2
*/
function flush()
{
/*
* It's sufficient to simply call close() to flush the output.
* The next call to log() will cause the handler to be reopened.
*/
return $this->close();
}
/**
* Writes $message to the currently open mail message.
* Calls open(), if necessary.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the message isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Append the string containing the complete log line. */
$this->_message .= $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message) . "\r\n";
$this->_shouldSend = true;
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,169 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log/mcal.php,v 1.2 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision$
* @package Log
*/
/**
* The Log_mcal class is a concrete implementation of the Log::
* abstract class which sends messages to a local or remote calendar
* store accessed through MCAL.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @since Horde 1.3
* @since Log 1.0
* @package Log
*/
class Log_mcal extends Log
{
/**
* holding the calendar specification to connect to.
* @var string
* @access private
*/
var $_calendar = '{localhost/mstore}';
/**
* holding the username to use.
* @var string
* @access private
*/
var $_username = '';
/**
* holding the password to use.
* @var string
* @access private
*/
var $_password = '';
/**
* holding the options to pass to the calendar stream.
* @var integer
* @access private
*/
var $_options = 0;
/**
* ResourceID of the MCAL stream.
* @var string
* @access private
*/
var $_stream = '';
/**
* Integer holding the log facility to use.
* @var string
* @access private
*/
var $_name = LOG_SYSLOG;
/**
* Constructs a new Log_mcal object.
*
* @param string $name The category to use for our events.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_name = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
$this->_calendar = $conf['calendar'];
$this->_username = $conf['username'];
$this->_password = $conf['password'];
$this->_options = $conf['options'];
}
/**
* Opens a calendar stream, if it has not already been
* opened. This is implicitly called by log(), if necessary.
* @access public
*/
function open()
{
if (!$this->_opened) {
$this->_stream = mcal_open($this->_calendar, $this->_username,
$this->_password, $this->_options);
$this->_opened = true;
}
return $this->_opened;
}
/**
* Closes the calendar stream, if it is open.
* @access public
*/
function close()
{
if ($this->_opened) {
mcal_close($this->_stream);
$this->_opened = false;
}
return ($this->_opened === false);
}
/**
* Logs $message and associated information to the currently open
* calendar stream. Calls open() if necessary. Also passes the
* message along to any Log_observer instances that are observing
* this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
$date_str = date('Y:n:j:G:i:s');
$dates = explode(':', $date_str);
mcal_event_init($this->_stream);
mcal_event_set_title($this->_stream, $this->_ident);
mcal_event_set_category($this->_stream, $this->_name);
mcal_event_set_description($this->_stream, $message);
mcal_event_add_attribute($this->_stream, 'priority', $priority);
mcal_event_set_start($this->_stream, $dates[0], $dates[1], $dates[2],
$dates[3], $dates[4], $dates[5]);
mcal_event_set_end($this->_stream, $dates[0], $dates[1], $dates[2],
$dates[3], $dates[4], $dates[5]);
mcal_append_event($this->_stream);
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,358 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/** PEAR's MDB2 package */
require_once 'MDB2.php';
MDB2::loadFile('Date');
/**
* The Log_mdb2 class is a concrete implementation of the Log:: abstract class
* which sends messages to an SQL server. Each entry occupies a separate row
* in the database.
*
* This implementation uses PEAR's MDB2 database abstraction layer.
*
* CREATE TABLE log_table (
* id INT NOT NULL,
* logtime TIMESTAMP NOT NULL,
* ident CHAR(16) NOT NULL,
* priority INT NOT NULL,
* message VARCHAR(200),
* PRIMARY KEY (id)
* );
*
* @author Lukas Smith <smith@backendmedia.com>
* @author Jon Parise <jon@php.net>
* @since Log 1.9.0
* @package Log
*/
class Log_mdb2 extends Log
{
/**
* Variable containing the DSN information.
* @var mixed
* @access private
*/
var $_dsn = '';
/**
* Array containing our set of DB configuration options.
* @var array
* @access private
*/
var $_options = array('persistent' => true);
/**
* Object holding the database handle.
* @var object
* @access private
*/
var $_db = null;
/**
* Resource holding the prepared statement handle.
* @var resource
* @access private
*/
var $_statement = null;
/**
* Flag indicating that we're using an existing database connection.
* @var boolean
* @access private
*/
var $_existingConnection = false;
/**
* String holding the database table to use.
* @var string
* @access private
*/
var $_table = 'log_table';
/**
* String holding the name of the ID sequence.
* @var string
* @access private
*/
var $_sequence = 'log_id';
/**
* Maximum length of the $ident string. This corresponds to the size of
* the 'ident' column in the SQL table.
* @var integer
* @access private
*/
var $_identLimit = 16;
/**
* Set of field types used in the database table.
* @var array
* @access private
*/
var $_types = array(
'id' => 'integer',
'logtime' => 'timestamp',
'ident' => 'text',
'priority' => 'text',
'message' => 'clob'
);
/**
* Constructs a new sql logging object.
*
* @param string $name The target SQL table.
* @param string $ident The identification field.
* @param array $conf The connection configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_table = $name;
$this->_mask = Log::UPTO($level);
/* If an options array was provided, use it. */
if (isset($conf['options']) && is_array($conf['options'])) {
$this->_options = $conf['options'];
}
/* If a specific sequence name was provided, use it. */
if (!empty($conf['sequence'])) {
$this->_sequence = $conf['sequence'];
}
/* If a specific sequence name was provided, use it. */
if (isset($conf['identLimit'])) {
$this->_identLimit = $conf['identLimit'];
}
/* Now that the ident limit is confirmed, set the ident string. */
$this->setIdent($ident);
/* If an existing database connection was provided, use it. */
if (isset($conf['db'])) {
$this->_db = &$conf['db'];
$this->_existingConnection = true;
$this->_opened = true;
} elseif (isset($conf['singleton'])) {
$this->_db = &MDB2::singleton($conf['singleton'], $this->_options);
$this->_existingConnection = true;
$this->_opened = true;
} else {
$this->_dsn = $conf['dsn'];
}
}
/**
* Opens a connection to the database, if it has not already
* been opened. This is implicitly called by log(), if necessary.
*
* @return boolean True on success, false on failure.
* @access public
*/
function open()
{
if (!$this->_opened) {
/* Use the DSN and options to create a database connection. */
$this->_db = &MDB2::connect($this->_dsn, $this->_options);
if (PEAR::isError($this->_db)) {
return false;
}
/* Create a prepared statement for repeated use in log(). */
if (!$this->_prepareStatement()) {
return false;
}
/* We now consider out connection open. */
$this->_opened = true;
}
return $this->_opened;
}
/**
* Closes the connection to the database if it is still open and we were
* the ones that opened it. It is the caller's responsible to close an
* existing connection that was passed to us via $conf['db'].
*
* @return boolean True on success, false on failure.
* @access public
*/
function close()
{
/* If we have a statement object, free it. */
if (is_object($this->_statement)) {
$this->_statement->free();
$this->_statement = null;
}
/* If we opened the database connection, disconnect it. */
if ($this->_opened && !$this->_existingConnection) {
$this->_opened = false;
return $this->_db->disconnect();
}
return ($this->_opened === false);
}
/**
* Sets this Log instance's identification string. Note that this
* SQL-specific implementation will limit the length of the $ident string
* to sixteen (16) characters.
*
* @param string $ident The new identification string.
*
* @access public
* @since Log 1.8.5
*/
function setIdent($ident)
{
$this->_ident = substr($ident, 0, $this->_identLimit);
}
/**
* Inserts $message to the currently open database. Calls open(),
* if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* If we don't already have a statement object, create one. */
if (!is_object($this->_statement) && !$this->_prepareStatement()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build our set of values for this log entry. */
$values = array(
'id' => $this->_db->nextId($this->_sequence),
'logtime' => MDB2_Date::mdbNow(),
'ident' => $this->_ident,
'priority' => $priority,
'message' => $message
);
/* Execute the SQL query for this log entry insertion. */
$this->_db->expectError(MDB2_ERROR_NOSUCHTABLE);
$result = &$this->_statement->execute($values);
$this->_db->popExpect();
/* Attempt to handle any errors. */
if (PEAR::isError($result)) {
/* We can only handle MDB2_ERROR_NOSUCHTABLE errors. */
if ($result->getCode() != MDB2_ERROR_NOSUCHTABLE) {
return false;
}
/* Attempt to create the target table. */
if (!$this->_createTable()) {
return false;
}
/* Recreate our prepared statement resource. */
$this->_statement->free();
if (!$this->_prepareStatement()) {
return false;
}
/* Attempt to re-execute the insertion query. */
$result = $this->_statement->execute($values);
if (PEAR::isError($result)) {
return false;
}
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
/**
* Create the log table in the database.
*
* @return boolean True on success or false on failure.
* @access private
*/
function _createTable()
{
$this->_db->loadModule('Manager', null, true);
$result = $this->_db->manager->createTable(
$this->_table,
array(
'id' => array('type' => $this->_types['id']),
'logtime' => array('type' => $this->_types['logtime']),
'ident' => array('type' => $this->_types['ident']),
'priority' => array('type' => $this->_types['priority']),
'message' => array('type' => $this->_types['message'])
)
);
if (PEAR::isError($result)) {
return false;
}
$result = $this->_db->manager->createIndex(
$this->_table,
'unique_id',
array('fields' => array('id' => true), 'unique' => true)
);
if (PEAR::isError($result)) {
return false;
}
return true;
}
/**
* Prepare the SQL insertion statement.
*
* @return boolean True if the statement was successfully created.
*
* @access private
* @since Log 1.9.0
*/
function _prepareStatement()
{
$this->_statement = &$this->_db->prepare(
'INSERT INTO ' . $this->_table .
' (id, logtime, ident, priority, message)' .
' VALUES(:id, :logtime, :ident, :priority, :message)',
$this->_types, MDB2_PREPARE_MANIP);
/* Return success if we didn't generate an error. */
return (PEAR::isError($this->_statement) === false);
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_null class is a concrete implementation of the Log:: abstract
* class. It simply consumes log events.
*
* @author Jon Parise <jon@php.net>
* @since Log 1.8.2
* @package Log
*
* @example null.php Using the null handler.
*/
class Log_null extends Log
{
/**
* Constructs a new Log_null object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
}
/**
* Opens the handler.
*
* @access public
* @since Log 1.9.6
*/
function open()
{
$this->_opened = true;
return true;
}
/**
* Closes the handler.
*
* @access public
* @since Log 1.9.6
*/
function close()
{
$this->_opened = false;
return true;
}
/**
* Simply consumes the log event. The message will still be passed
* along to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1,129 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log/observer.php,v 1.5 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision$
* @package Log
*/
/**
* The Log_observer:: class implements the Observer end of a Subject-Observer
* pattern for watching log activity and taking actions on exceptional events.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @since Horde 1.3
* @since Log 1.0
* @package Log
*
* @example observer_mail.php An example Log_observer implementation.
*/
class Log_observer
{
/**
* Instance-specific unique identification number.
*
* @var integer
* @access private
*/
var $_id = 0;
/**
* The minimum priority level of message that we want to hear about.
* PEAR_LOG_EMERG is the highest priority, so we will only hear messages
* with an integer priority value less than or equal to ours. It defaults
* to PEAR_LOG_INFO, which listens to everything except PEAR_LOG_DEBUG.
*
* @var string
* @access private
*/
var $_priority = PEAR_LOG_INFO;
/**
* Creates a new basic Log_observer instance.
*
* @param integer $priority The highest priority at which to receive
* log event notifications.
*
* @access public
*/
public function __construct($priority = PEAR_LOG_INFO)
{
$this->_id = md5(microtime().rand());
$this->_priority = $priority;
}
/**
* Attempts to return a new concrete Log_observer instance of the requested
* type.
*
* @param string $type The type of concreate Log_observer subclass
* to return.
* @param integer $priority The highest priority at which to receive
* log event notifications.
* @param array $conf Optional associative array of additional
* configuration values.
*
* @return object The newly created concrete Log_observer
* instance, or null on an error.
*/
function &factory($type, $priority = PEAR_LOG_INFO, $conf = array())
{
$type = strtolower($type);
$class = 'Log_observer_' . $type;
/*
* If the desired class already exists (because the caller has supplied
* it from some custom location), simply instantiate and return a new
* instance.
*/
if (class_exists($class)) {
$object = new $class($priority, $conf);
return $object;
}
/* Support both the new-style and old-style file naming conventions. */
$newstyle = true;
$classfile = dirname(__FILE__) . '/observer_' . $type . '.php';
if (!file_exists($classfile)) {
$classfile = 'Log/' . $type . '.php';
$newstyle = false;
}
/*
* Attempt to include our version of the named class, but don't treat
* a failure as fatal. The caller may have already included their own
* version of the named class.
*/
@include_once $classfile;
/* If the class exists, return a new instance of it. */
if (class_exists($class)) {
/* Support both new-style and old-style construction. */
if ($newstyle) {
$object = new $class($priority, $conf);
} else {
$object = new $class($priority);
}
return $object;
}
$null = null;
return $null;
}
/**
* This is a stub method to make sure that Log_Observer classes do
* something when they are notified of a message. The default behavior
* is to just print the message, which is obviously not desireable in
* practically any situation - which is why you need to override this
* method. :)
*
* @param array $event A hash describing the log event.
*/
function notify($event)
{
print_r($event);
}
}

View File

@@ -0,0 +1,293 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log/sql.php,v 1.12 2000/08/16 20:27:34 chuck Exp $
*
* @version $Revision$
* @package Log
*/
/**
* We require the PEAR DB class. This is generally defined in the DB.php file,
* but it's possible that the caller may have provided the DB class, or a
* compatible wrapper (such as the one shipped with MDB2), so we first check
* for an existing 'DB' class before including 'DB.php'.
*/
if (!class_exists('DB')) {
require_once 'DB.php';
}
/**
* The Log_sql class is a concrete implementation of the Log::
* abstract class which sends messages to an SQL server. Each entry
* occupies a separate row in the database.
*
* This implementation uses PHP's PEAR database abstraction layer.
*
* CREATE TABLE log_table (
* id INT NOT NULL,
* logtime TIMESTAMP NOT NULL,
* ident CHAR(16) NOT NULL,
* priority INT NOT NULL,
* message VARCHAR(200),
* PRIMARY KEY (id)
* );
*
* @author Jon Parise <jon@php.net>
* @since Horde 1.3
* @since Log 1.0
* @package Log
*
* @example sql.php Using the SQL handler.
*/
class Log_sql extends Log
{
/**
* Variable containing the DSN information.
* @var mixed
* @access private
*/
var $_dsn = '';
/**
* String containing the SQL insertion statement.
*
* @var string
* @access private
*/
var $_sql = '';
/**
* Array containing our set of DB configuration options.
* @var array
* @access private
*/
var $_options = array('persistent' => true);
/**
* Object holding the database handle.
* @var object
* @access private
*/
var $_db = null;
/**
* Resource holding the prepared statement handle.
* @var resource
* @access private
*/
var $_statement = null;
/**
* Flag indicating that we're using an existing database connection.
* @var boolean
* @access private
*/
var $_existingConnection = false;
/**
* String holding the database table to use.
* @var string
* @access private
*/
var $_table = 'log_table';
/**
* String holding the name of the ID sequence.
* @var string
* @access private
*/
var $_sequence = 'log_id';
/**
* Maximum length of the $ident string. This corresponds to the size of
* the 'ident' column in the SQL table.
* @var integer
* @access private
*/
var $_identLimit = 16;
/**
* Constructs a new sql logging object.
*
* @param string $name The target SQL table.
* @param string $ident The identification field.
* @param array $conf The connection configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_table = $name;
$this->_mask = Log::UPTO($level);
/* Now that we have a table name, assign our SQL statement. */
if (!empty($conf['sql'])) {
$this->_sql = $conf['sql'];
} else {
$this->_sql = 'INSERT INTO ' . $this->_table .
' (id, logtime, ident, priority, message)' .
' VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?)';
}
/* If an options array was provided, use it. */
if (isset($conf['options']) && is_array($conf['options'])) {
$this->_options = $conf['options'];
}
/* If a specific sequence name was provided, use it. */
if (!empty($conf['sequence'])) {
$this->_sequence = $conf['sequence'];
}
/* If a specific sequence name was provided, use it. */
if (isset($conf['identLimit'])) {
$this->_identLimit = $conf['identLimit'];
}
/* Now that the ident limit is confirmed, set the ident string. */
$this->setIdent($ident);
/* If an existing database connection was provided, use it. */
if (isset($conf['db'])) {
$this->_db = &$conf['db'];
$this->_existingConnection = true;
$this->_opened = true;
} else {
$this->_dsn = $conf['dsn'];
}
}
/**
* Opens a connection to the database, if it has not already
* been opened. This is implicitly called by log(), if necessary.
*
* @return boolean True on success, false on failure.
* @access public
*/
function open()
{
if (!$this->_opened) {
/* Use the DSN and options to create a database connection. */
$this->_db = &DB::connect($this->_dsn, $this->_options);
if (DB::isError($this->_db)) {
return false;
}
/* Create a prepared statement for repeated use in log(). */
if (!$this->_prepareStatement()) {
return false;
}
/* We now consider out connection open. */
$this->_opened = true;
}
return $this->_opened;
}
/**
* Closes the connection to the database if it is still open and we were
* the ones that opened it. It is the caller's responsible to close an
* existing connection that was passed to us via $conf['db'].
*
* @return boolean True on success, false on failure.
* @access public
*/
function close()
{
if ($this->_opened && !$this->_existingConnection) {
$this->_opened = false;
$this->_db->freePrepared($this->_statement);
return $this->_db->disconnect();
}
return ($this->_opened === false);
}
/**
* Sets this Log instance's identification string. Note that this
* SQL-specific implementation will limit the length of the $ident string
* to sixteen (16) characters.
*
* @param string $ident The new identification string.
*
* @access public
* @since Log 1.8.5
*/
function setIdent($ident)
{
$this->_ident = substr($ident, 0, $this->_identLimit);
}
/**
* Inserts $message to the currently open database. Calls open(),
* if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* If we don't already have our statement object yet, create it. */
if (!is_object($this->_statement) && !$this->_prepareStatement()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build our set of values for this log entry. */
$id = $this->_db->nextId($this->_sequence);
$values = array($id, $this->_ident, $priority, $message);
/* Execute the SQL query for this log entry insertion. */
$result =& $this->_db->execute($this->_statement, $values);
if (DB::isError($result)) {
return false;
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
/**
* Prepare the SQL insertion statement.
*
* @return boolean True if the statement was successfully created.
*
* @access private
* @since Log 1.9.1
*/
function _prepareStatement()
{
$this->_statement = $this->_db->prepare($this->_sql);
/* Return success if we didn't generate an error. */
return (DB::isError($this->_statement) === false);
}
}

View File

@@ -0,0 +1,224 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_sqlite class is a concrete implementation of the Log::
* abstract class which sends messages to an Sqlite database.
* Each entry occupies a separate row in the database.
*
* This implementation uses PHP native Sqlite functions.
*
* CREATE TABLE log_table (
* id INTEGER PRIMARY KEY NOT NULL,
* logtime NOT NULL,
* ident CHAR(16) NOT NULL,
* priority INT NOT NULL,
* message
* );
*
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Jon Parise <jon@php.net>
* @since Log 1.8.3
* @package Log
*
* @example sqlite.php Using the Sqlite handler.
*/
class Log_sqlite extends Log
{
/**
* Array containing the connection defaults
* @var array
* @access private
*/
var $_options = array('mode' => 0666,
'persistent' => false);
/**
* Object holding the database handle.
* @var object
* @access private
*/
var $_db = null;
/**
* Flag indicating that we're using an existing database connection.
* @var boolean
* @access private
*/
var $_existingConnection = false;
/**
* String holding the database table to use.
* @var string
* @access private
*/
var $_table = 'log_table';
/**
* Constructs a new sql logging object.
*
* @param string $name The target SQL table.
* @param string $ident The identification field.
* @param mixed $conf Can be an array of configuration options used
* to open a new database connection
* or an already opened sqlite connection.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', &$conf, $level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_table = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (is_array($conf)) {
foreach ($conf as $k => $opt) {
$this->_options[$k] = $opt;
}
} else {
// If an existing database connection was provided, use it.
$this->_db =& $conf;
$this->_existingConnection = true;
}
}
/**
* Opens a connection to the database, if it has not already
* been opened. This is implicitly called by log(), if necessary.
*
* @return boolean True on success, false on failure.
* @access public
*/
function open()
{
if (is_resource($this->_db)) {
$this->_opened = true;
return $this->_createTable();
} else {
/* Set the connection function based on the 'persistent' option. */
if (empty($this->_options['persistent'])) {
$connectFunction = 'sqlite_open';
} else {
$connectFunction = 'sqlite_popen';
}
/* Attempt to connect to the database. */
if ($this->_db = $connectFunction($this->_options['filename'],
(int)$this->_options['mode'],
$error)) {
$this->_opened = true;
return $this->_createTable();
}
}
return $this->_opened;
}
/**
* Closes the connection to the database if it is still open and we were
* the ones that opened it. It is the caller's responsible to close an
* existing connection that was passed to us via $conf['db'].
*
* @return boolean True on success, false on failure.
* @access public
*/
function close()
{
/* We never close existing connections. */
if ($this->_existingConnection) {
return false;
}
if ($this->_opened) {
$this->_opened = false;
sqlite_close($this->_db);
}
return ($this->_opened === false);
}
/**
* Inserts $message to the currently open database. Calls open(),
* if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
// Extract the string representation of the message.
$message = $this->_extractMessage($message);
// Build the SQL query for this log entry insertion.
$q = sprintf('INSERT INTO [%s] (logtime, ident, priority, message) ' .
"VALUES ('%s', '%s', %d, '%s')",
$this->_table,
strftime('%Y-%m-%d %H:%M:%S', time()),
sqlite_escape_string($this->_ident),
$priority,
sqlite_escape_string($message));
if (!($res = @sqlite_unbuffered_query($this->_db, $q))) {
return false;
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
/**
* Checks whether the log table exists and creates it if necessary.
*
* @return boolean True on success or false on failure.
* @access private
*/
function _createTable()
{
$q = "SELECT name FROM sqlite_master WHERE name='" . $this->_table .
"' AND type='table'";
$res = sqlite_query($this->_db, $q);
if (sqlite_num_rows($res) == 0) {
$q = 'CREATE TABLE [' . $this->_table . '] (' .
'id INTEGER PRIMARY KEY NOT NULL, ' .
'logtime NOT NULL, ' .
'ident CHAR(16) NOT NULL, ' .
'priority INT NOT NULL, ' .
'message)';
if (!($res = sqlite_unbuffered_query($this->_db, $q))) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,238 @@
<?php
/**
* $Header$
* $Horde: horde/lib/Log/syslog.php,v 1.6 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision$
* @package Log
*/
/**
* The Log_syslog class is a concrete implementation of the Log::
* abstract class which sends messages to syslog on UNIX-like machines
* (PHP emulates this with the Event Log on Windows machines).
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net>
* @since Horde 1.3
* @since Log 1.0
* @package Log
*
* @example syslog.php Using the syslog handler.
*/
class Log_syslog extends Log
{
/**
* Integer holding the log facility to use.
* @var integer
* @access private
*/
var $_name = LOG_SYSLOG;
/**
* Should we inherit the current syslog connection for this process, or
* should we call openlog() to start a new syslog connection?
* @var boolean
* @access private
*/
var $_inherit = false;
/**
* Should we re-open the syslog connection for each log event?
* @var boolean
* @access private
*/
var $_reopen = false;
/**
* Maximum message length that will be sent to syslog(). If the handler
* receives a message longer than this length limit, it will be split into
* multiple syslog() calls.
* @var integer
* @access private
*/
var $_maxLength = 500;
/**
* String containing the format of a message.
* @var string
* @access private
*/
var $_lineFormat = '%4$s';
/**
* String containing the timestamp format. It will be passed directly to
* strftime(). Note that the timestamp string will generated using the
* current locale.
* @var string
* @access private
*/
var $_timeFormat = '%b %d %H:%M:%S';
/**
* Constructs a new syslog object.
*
* @param string $name The syslog facility.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
/* Ensure we have a valid integer value for $name. */
if (empty($name) || !is_int($name)) {
$name = LOG_SYSLOG;
}
if (isset($conf['inherit'])) {
$this->_inherit = $conf['inherit'];
$this->_opened = $this->_inherit;
}
if (isset($conf['reopen'])) {
$this->_reopen = $conf['reopen'];
}
if (isset($conf['maxLength'])) {
$this->_maxLength = $conf['maxLength'];
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
$this->_id = md5(microtime().rand());
$this->_name = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
}
/**
* Opens a connection to the system logger, if it has not already
* been opened. This is implicitly called by log(), if necessary.
* @access public
*/
function open()
{
if (!$this->_opened || $this->_reopen) {
$this->_opened = openlog($this->_ident, LOG_PID, $this->_name);
}
return $this->_opened;
}
/**
* Closes the connection to the system logger, if it is open.
* @access public
*/
function close()
{
if ($this->_opened && !$this->_inherit) {
closelog();
$this->_opened = false;
}
return true;
}
/**
* Sends $message to the currently open syslog connection. Calls
* open() if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param int $priority (optional) The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If we need to (re)open the connection and open() fails, abort. */
if ((!$this->_opened || $this->_reopen) && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Build a syslog priority value based on our current configuration. */
$syslogPriority = $this->_toSyslog($priority);
if ($this->_inherit) {
$syslogPriority |= $this->_name;
}
/* Apply the configured line format to the message string. */
$message = $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message);
/* Split the string into parts based on our maximum length setting. */
$parts = str_split($message, $this->_maxLength);
if ($parts === false) {
return false;
}
foreach ($parts as $part) {
if (!syslog($syslogPriority, $part)) {
return false;
}
}
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
/**
* Converts a PEAR_LOG_* constant into a syslog LOG_* constant.
*
* This function exists because, under Windows, not all of the LOG_*
* constants have unique values. Instead, the PEAR_LOG_* were introduced
* for global use, with the conversion to the LOG_* constants kept local to
* to the syslog driver.
*
* @param int $priority PEAR_LOG_* value to convert to LOG_* value.
*
* @return The LOG_* representation of $priority.
*
* @access private
*/
function _toSyslog($priority)
{
static $priorities = array(
PEAR_LOG_EMERG => LOG_EMERG,
PEAR_LOG_ALERT => LOG_ALERT,
PEAR_LOG_CRIT => LOG_CRIT,
PEAR_LOG_ERR => LOG_ERR,
PEAR_LOG_WARNING => LOG_WARNING,
PEAR_LOG_NOTICE => LOG_NOTICE,
PEAR_LOG_INFO => LOG_INFO,
PEAR_LOG_DEBUG => LOG_DEBUG
);
/* If we're passed an unknown priority, default to LOG_INFO. */
if (!is_int($priority) || !in_array($priority, $priorities)) {
return LOG_INFO;
}
return $priorities[$priority];
}
}

View File

@@ -0,0 +1,286 @@
<?php
/**
* $Header$
*
* @version $Revision$
* @package Log
*/
/**
* The Log_win class is a concrete implementation of the Log abstract
* class that logs messages to a separate browser window.
*
* The concept for this log handler is based on part by Craig Davis' article
* entitled "JavaScript Power PHP Debugging:
*
* http://www.zend.com/zend/tut/tutorial-DebugLib.php
*
* @author Jon Parise <jon@php.net>
* @since Log 1.7.0
* @package Log
*
* @example win.php Using the window handler.
*/
class Log_win extends Log
{
/**
* The name of the output window.
* @var string
* @access private
*/
var $_name = 'LogWindow';
/**
* The title of the output window.
* @var string
* @access private
*/
var $_title = 'Log Output Window';
/**
* Mapping of log priorities to styles.
* @var array
* @access private
*/
var $_styles = array(
PEAR_LOG_EMERG => 'color: red;',
PEAR_LOG_ALERT => 'color: orange;',
PEAR_LOG_CRIT => 'color: yellow;',
PEAR_LOG_ERR => 'color: green;',
PEAR_LOG_WARNING => 'color: blue;',
PEAR_LOG_NOTICE => 'color: indigo;',
PEAR_LOG_INFO => 'color: violet;',
PEAR_LOG_DEBUG => 'color: black;'
);
/**
* String buffer that holds line that are pending output.
* @var array
* @access private
*/
var $_buffer = array();
/**
* Constructs a new Log_win object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param int $level Log messages up to and including this level.
* @access public
*/
public function __construct($name, $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime().rand());
$this->_name = str_replace(' ', '_', $name);
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['title'])) {
$this->_title = $conf['title'];
}
if (isset($conf['styles']) && is_array($conf['styles'])) {
$this->_styles = $conf['styles'];
}
if (isset($conf['colors']) && is_array($conf['colors'])) {
foreach ($conf['colors'] as $level => $color) {
$this->_styles[$level] .= "color: $color;";
}
}
register_shutdown_function(array(&$this, '_Log_win'));
}
/**
* Destructor
*/
function _Log_win()
{
if ($this->_opened || (count($this->_buffer) > 0)) {
$this->close();
}
}
/**
* The first time open() is called, it will open a new browser window and
* prepare it for output.
*
* This is implicitly called by log(), if necessary.
*
* @access public
*/
function open()
{
if (!$this->_opened) {
$win = $this->_name;
$styles = $this->_styles;
if (!empty($this->_ident)) {
$identHeader = "$win.document.writeln('<th>Ident</th>')";
} else {
$identHeader = '';
}
echo <<< EOT
<script language="JavaScript">
$win = window.open('', '{$this->_name}', 'toolbar=no,scrollbars,width=600,height=400');
$win.document.writeln('<html>');
$win.document.writeln('<head>');
$win.document.writeln('<title>{$this->_title}</title>');
$win.document.writeln('<style type="text/css">');
$win.document.writeln('body { font-family: monospace; font-size: 8pt; }');
$win.document.writeln('td,th { font-size: 8pt; }');
$win.document.writeln('td,th { border-bottom: #999999 solid 1px; }');
$win.document.writeln('td,th { border-right: #999999 solid 1px; }');
$win.document.writeln('tr { text-align: left; vertical-align: top; }');
$win.document.writeln('td.l0 { $styles[0] }');
$win.document.writeln('td.l1 { $styles[1] }');
$win.document.writeln('td.l2 { $styles[2] }');
$win.document.writeln('td.l3 { $styles[3] }');
$win.document.writeln('td.l4 { $styles[4] }');
$win.document.writeln('td.l5 { $styles[5] }');
$win.document.writeln('td.l6 { $styles[6] }');
$win.document.writeln('td.l7 { $styles[7] }');
$win.document.writeln('</style>');
$win.document.writeln('<script type="text/javascript">');
$win.document.writeln('function scroll() {');
$win.document.writeln(' body = document.getElementById("{$this->_name}");');
$win.document.writeln(' body.scrollTop = body.scrollHeight;');
$win.document.writeln('}');
$win.document.writeln('<\/script>');
$win.document.writeln('</head>');
$win.document.writeln('<body id="{$this->_name}" onclick="scroll()">');
$win.document.writeln('<table border="0" cellpadding="2" cellspacing="0">');
$win.document.writeln('<tr><th>Time</th>');
$identHeader
$win.document.writeln('<th>Priority</th><th width="100%">Message</th></tr>');
</script>
EOT;
$this->_opened = true;
}
return $this->_opened;
}
/**
* Closes the output stream if it is open. If there are still pending
* lines in the output buffer, the output window will be opened so that
* the buffer can be drained.
*
* @access public
*/
function close()
{
/*
* If there are still lines waiting to be written, open the output
* window so that we can drain the buffer.
*/
if (!$this->_opened && (count($this->_buffer) > 0)) {
$this->open();
}
if ($this->_opened) {
$this->_writeln('</table>');
$this->_writeln('</body></html>');
$this->_drainBuffer();
$this->_opened = false;
}
return ($this->_opened === false);
}
/**
* Writes the contents of the output buffer to the output window.
*
* @access private
*/
function _drainBuffer()
{
$win = $this->_name;
foreach ($this->_buffer as $line) {
echo "<script language='JavaScript'>\n";
echo "$win.document.writeln('" . addslashes($line) . "');\n";
echo "self.focus();\n";
echo "</script>\n";
}
/* Now that the buffer has been drained, clear it. */
$this->_buffer = array();
}
/**
* Writes a single line of text to the output buffer.
*
* @param string $line The line of text to write.
*
* @access private
*/
function _writeln($line)
{
/* Add this line to our output buffer. */
$this->_buffer[] = $line;
/* Buffer the output until this page's headers have been sent. */
if (!headers_sent()) {
return;
}
/* If we haven't already opened the output window, do so now. */
if (!$this->_opened && !$this->open()) {
return;
}
/* Drain the buffer to the output window. */
$this->_drainBuffer();
}
/**
* Logs $message to the output window. The message is also passed along
* to any Log_observer instances that are observing this Log.
*
* @param mixed $message String or object containing the message to log.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = null)
{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
$message = preg_replace('/\r\n|\n|\r/', '<br />', $message);
list($usec, $sec) = explode(' ', microtime());
/* Build the output line that contains the log entry row. */
$line = '<tr>';
$line .= sprintf('<td>%s.%s</td>',
strftime('%H:%M:%S', $sec), substr($usec, 2, 2));
if (!empty($this->_ident)) {
$line .= '<td>' . $this->_ident . '</td>';
}
$line .= '<td>' . ucfirst($this->priorityToString($priority)) . '</td>';
$line .= sprintf('<td class="l%d">%s</td>', $priority, $message);
$line .= '</tr>';
$this->_writeln($line);
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}
}

View File

@@ -0,0 +1 @@
docs/guide.txt

View File

@@ -0,0 +1,42 @@
{
"name": "pear/log",
"type": "library",
"description": "PEAR Logging Framework",
"keywords": [
"log",
"logging"
],
"license": "MIT",
"require": {
"php": ">5.2",
"pear/pear_exception": "1.0.1 || 1.0.2"
},
"autoload": {
"psr-0": {
"Log": "./"
},
"exclude-from-classmap": ["/examples/"]
},
"include-path": [
""
],
"authors": [
{
"name": "Jon Parise",
"email": "jon@php.net",
"homepage": "http://www.indelible.org",
"role": "Developer"
}
],
"homepage": "http://pear.github.io/Log/",
"support": {
"issues": "https://github.com/pear/Log/issues",
"source": "https://github.com/pear/Log"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"pear/db": "Install optionally via your project's composer.json"
}
}

View File

@@ -0,0 +1,16 @@
[general]
source-link: no
no-datestamp: yes
generator: off
strip-comments: yes
toc-backlinks: no
[standalone reader]
docinfo_xform: no
[html4css1 writer]
stylesheet-path: docutils.css
embed-stylesheet: yes
field-name-limit: 20
cloak-email-addresses: yes
initial-header-level: 2

View File

@@ -0,0 +1,108 @@
body {
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 0.8em;
letter-spacing: 0.01em;
line-height: 1.5em;
text-align: justify;
margin: 0 auto;
width: 48em;
}
a:link, a:visited {
color: #00c;
padding-bottom: 0;
text-decoration: none;
border-bottom: 1px solid #dbd5c5;
}
a:hover {
padding-bottom: 0;
border-bottom: 2px solid #dbd5c5;
}
h1, h2, h3 {
font-family: Georgia, "Times New Roman", Times, serif;
font-weight: normal;
line-height: normal;
}
h1 {
font-size: 2.1em;
letter-spacing: -0.02em;
margin-top: 30px;
text-align: center;
}
h2 {
font-size: 1.6em;
font-style: italic;
margin: 30px 0 10px 0;
}
h3 {
font-size: 1.3em;
font-style: italic;
margin-top: 20px;
}
li {
line-height: 135%;
}
ul, ol {
margin: 0 0 1em 2em;
padding: 0 0 0 1em;
}
hr {
background-color: #ccc;
border: 0px none;
color: #eee;
height: 1px;
margin: 30px 0px;
}
blockquote, pre {
background-color: #f9f9f9;
border: 1px solid #eee;
border-left: 2px solid #ccc;
padding: 1em;
}
blockquote {
color: #666;
line-height: 1.3em;
}
pre {
line-height: normal;
overflow: auto;
}
pre.code-block {
padding-bottom: 0;
}
tt, pre, code, samp, kbd {
color: #333;
font-family: Consolas, 'Lucida Console', monospace;
font-size: 13px;
}
label em {
font-weight: normal;
}
form {
margin: 0;
padding: 0;
}
.code-block .err { border: 1px solid #FF0000 } /* Error */
.code-block .k,.kn { color: #369 } /* Keywords */
.code-block .c,.cm,.cp,.c1 { color: #666; font-style: italic } /* Comments */
.code-block .n { color: #000 } /* Names */
.code-block .p { color: #000 } /* Punctuation */
.code-block .nc,.nf,.nn { color: #333; font-weight: bold } /* Symbol Names */
.code-block .s { color: #933 } /* Literal.String */
.code-block .sd { color: #666 } /* Literal.String.Doc */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,12 @@
<?php
require_once 'Log.php';
$console = &Log::singleton('console', '', 'TEST');
$file = &Log::singleton('file', 'out.log', 'TEST');
$composite = &Log::singleton('composite');
$composite->addChild($console);
$composite->addChild($file);
$composite->log('This event will be logged to both handlers.');

View File

@@ -0,0 +1,8 @@
<?php
require_once 'Log.php';
$logger = &Log::singleton('console', '', 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,10 @@
<?php
require_once 'Log.php';
$conf = array('error_prepend' => '<font color="#ff0000"><tt>',
'error_append' => '</tt></font>');
$logger = &Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,8 @@
<?php
require_once 'Log.php';
$logger = &Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,9 @@
<?php
require_once 'Log.php';
$conf = array('mode' => 0600, 'timeFormat' => '%X %x');
$logger = &Log::singleton('file', 'out.log', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,12 @@
<?php
require_once 'Log.php';
$logger = &Log::singleton('firebug', '',
'PHP',
array('buffering' => true),
PEAR_LOG_DEBUG);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,9 @@
<?php
require_once 'Log.php';
$conf = array('subject' => 'Important Log Events');
$logger = &Log::singleton('mail', 'webmaster@example.com', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,8 @@
<?php
require_once 'Log.php';
$logger = &Log::singleton('null');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,30 @@
<?php
require_once 'Log/observer.php';
class Log_observer_mail extends Log_observer
{
var $_to = '';
var $_subject = '';
var $_pattern = '';
function Log_observer_mail($priority, $conf)
{
/* Call the base class constructor. */
$this->Log_observer($priority);
/* Configure the observer. */
$this->_to = $conf['to'];
$this->_subject = $conf['subject'];
$this->_pattern = $conf['pattern'];
}
function notify($event)
{
if (preg_match($this->_pattern, $event['message']) != 0) {
mail($this->_to, $this->_subject, $event['message']);
}
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
require_once 'Log.php';
function errorHandler($error)
{
global $logger;
$message = $error->getMessage();
if (!empty($error->backtrace[1]['file'])) {
$message .= ' (' . $error->backtrace[1]['file'];
if (!empty($error->backtrace[1]['line'])) {
$message .= ' at line ' . $error->backtrace[1]['line'];
}
$message .= ')';
}
$logger->log($message, $error->code);
}
$logger = &Log::singleton('console', '', 'ident');
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler');
PEAR::raiseError('This is an information log message.', PEAR_LOG_INFO);

View File

@@ -0,0 +1,34 @@
<?php
require_once 'Log.php';
function errorHandler($code, $message, $file, $line)
{
global $logger;
/* Map the PHP error to a Log priority. */
switch ($code) {
case E_WARNING:
case E_USER_WARNING:
$priority = PEAR_LOG_WARNING;
break;
case E_NOTICE:
case E_USER_NOTICE:
$priority = PEAR_LOG_NOTICE;
break;
case E_ERROR:
case E_USER_ERROR:
$priority = PEAR_LOG_ERR;
break;
default:
$priotity = PEAR_LOG_INFO;
}
$logger->log($message . ' in ' . $file . ' at line ' . $line,
$priority);
}
$logger = &Log::singleton('console', '', 'ident');
set_error_handler('errorHandler');
trigger_error('This is an information log message.', E_USER_NOTICE);

View File

@@ -0,0 +1,9 @@
<?php
require_once 'Log.php';
$conf = array('dsn' => 'pgsql://jon@localhost+unix/logs');
$logger = &Log::singleton('sql', 'log_table', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,14 @@
<?php
require_once 'Log.php';
/* Creating a new database connection. */
$conf = array('filename' => 'log.db', 'mode' => 0666, 'persistent' => true);
$logger =& Log::factory('sqlite', 'log_table', 'ident', $conf);
$logger->log('logging an event', PEAR_LOG_WARNING);
/* Using an existing database connection. */
$db = sqlite_open('log.db', 0666, $error);
$logger =& Log::factory('sqlite', 'log_table', 'ident', $db);
$logger->log('logging an event', PEAR_LOG_WARNING);
sqlite_close($db);

View File

@@ -0,0 +1,8 @@
<?php
require_once 'Log.php';
$logger = &Log::singleton('syslog', LOG_LOCAL0, 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,9 @@
<?php
require_once 'Log.php';
$conf = array('title' => 'Sample Log Output');
$logger = &Log::singleton('win', 'LogWindow', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,10 @@
-- $Id$
CREATE TABLE log_table (
id INT NOT NULL,
logtime TIMESTAMP NOT NULL,
ident CHAR(16) NOT NULL,
priority INT NOT NULL,
message VARCHAR(200),
PRIMARY KEY (id)
);

View File

@@ -0,0 +1,611 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>Log</name>
<channel>pear.php.net</channel>
<summary>Logging Framework</summary>
<description>The Log package provides an abstracted logging framework. It includes output handlers for log files, databases, syslog, email, Firebug, and the console. It also provides composite and subject-observer logging mechanisms.</description>
<lead>
<name>Jon Parise</name>
<user>jon</user>
<email>jon@php.net</email>
<active>yes</active>
</lead>
<lead>
<name>Chuck Hagenbuch</name>
<user>chagenbu</user>
<email>chuck@horde.org</email>
<active>yes</active>
</lead>
<lead>
<name>Jan Schneider</name>
<user>yunosh</user>
<email>jan@horde.org</email>
<active>yes</active>
</lead>
<date>2021-05-04</date>
<time>00:00:00</time>
<version>
<release>1.13.3</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Support versions 1.0.1 and 1.0.2 of pear/pear_exception.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
<dir name="docs">
<file name="guide.txt" role="doc" />
</dir> <!-- /docs -->
<dir name="examples">
<file name="composite.php" role="doc" />
<file name="console.php" role="doc" />
<file name="display.php" role="doc" />
<file name="error_log.php" role="doc" />
<file name="file.php" role="doc" />
<file name="firebug.php" role="doc" />
<file name="mail.php" role="doc" />
<file name="null.php" role="doc" />
<file name="observer_mail.php" role="doc" />
<file name="pear_error_handler.php" role="doc" />
<file name="php_error_handler.php" role="doc" />
<file name="sql.php" role="doc" />
<file name="sqlite.php" role="doc" />
<file name="syslog.php" role="doc" />
<file name="win.php" role="doc" />
</dir> <!-- /examples -->
<dir name="Log">
<file name="composite.php" role="php" />
<file name="console.php" role="php" />
<file name="daemon.php" role="php" />
<file name="display.php" role="php" />
<file name="error_log.php" role="php" />
<file name="file.php" role="php" />
<file name="firebug.php" role="php" />
<file name="mail.php" role="php" />
<file name="mcal.php" role="php" />
<file name="mdb2.php" role="php" />
<file name="null.php" role="php" />
<file name="observer.php" role="php" />
<file name="sql.php" role="php" />
<file name="sqlite.php" role="php" />
<file name="syslog.php" role="php" />
<file name="win.php" role="php" />
</dir> <!-- /Log -->
<dir name="misc">
<file name="log.sql" role="data" />
</dir> <!-- /misc -->
<dir name="tests">
<file name="backtrace.phpt" role="test" />
<file name="composite.phpt" role="test" />
<file name="console.phpt" role="test" />
<file name="display.phpt" role="test" />
<file name="error_log.phpt" role="test" />
<file name="extract-zend2.0.phpt" role="test" />
<file name="extract-zend2.2.phpt" role="test" />
<file name="factory.phpt" role="test" />
<file name="file.phpt" role="test" />
<file name="firebug.phpt" role="test" />
<file name="format.phpt" role="test" />
<file name="levels.phpt" role="test" />
<file name="masks.phpt" role="test" />
<file name="null.phpt" role="test" />
<file name="priority.phpt" role="test" />
<file name="singleton.phpt" role="test" />
<file name="sqlite.phpt" role="test" />
<file name="sql_ident.phpt" role="test" />
<file name="syslog.phpt" role="test" />
<file name="win-ob.phpt" role="test" />
<file name="win.phpt" role="test" />
</dir> <!-- /tests -->
<file name="Log.php" role="php" />
</dir> <!-- / -->
</contents>
<dependencies>
<required>
<php>
<min>5.0.0</min>
</php>
<pearinstaller>
<min>1.4.3</min>
</pearinstaller>
</required>
<optional>
<package>
<name>DB</name>
<channel>pear.php.net</channel>
<min>1.3</min>
</package>
<package>
<name>MDB2</name>
<channel>pear.php.net</channel>
<min>2.0.0RC1</min>
</package>
<package>
<name>Mail</name>
<channel>pear.php.net</channel>
</package>
<extension>
<name>sqlite</name>
</extension>
</optional>
</dependencies>
<phprelease />
<changelog>
<release>
<version>
<release>1.13.1</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2016-04-16</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Use rand() to make instance identifiers more unique than microtime()'s resolution.
</notes>
</release>
<release>
<version>
<release>1.13.0</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2016-04-03</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Deprecate PHP4-style constructors.
</notes>
</release>
<release>
<version>
<release>1.12.9</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-06-14</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Updating the pear/pear_exception dependency to a stable release.
</notes>
</release>
<release>
<version>
<release>1.12.8</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2014-07-14</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The syslog handler now emits PEAR_LOG_* priorities. (pear/Log#1)
</notes>
</release>
<release>
<version>
<release>1.12.7</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2011-09-18</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The &apos;firebug&apos; handler is now usable with Chrome, as well. (Request 18617)
- The &apos;observer&apos; code now longer generates deprecated return value reference notices. (Bug 18830)
</notes>
</release>
<release>
<version>
<release>1.12.6</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2011-05-25</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- Improved the console handler&apos;s stream handling. (Bug 17874)
- Added a &apos;reopen&apos; configuration parameter to the syslog handler. (Request 18185)
- The backtrace depth is now configurable via setBacktraceDepth(). (Request 18423)
</notes>
</release>
<release>
<version>
<release>1.12.5</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-12-22</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- Corrected the &quot;levels&quot; unit test on 32-bit systems. (Bug 18099)
- Corrected quote handling in Firebug console output. (Bug 18141)
</notes>
</release>
<release>
<version>
<release>1.12.4</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-12-05</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The display handler now has a &apos;rawText&apos; configuration option that disables HTML-safe message text conversion.
- Improved the way that the composite handler stores references its children.
</notes>
</release>
<release>
<version>
<release>1.12.3</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-09-27</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The unit tests now set the timezone. (Bug 17830)
- The composite handler now opens child handlers lazily (on demand). (Bug 17785)
</notes>
</release>
<release>
<version>
<release>1.12.2</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-08-28</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- Use PHP5-specific static method notation to avoid strict warnings. (Bug: 17509)
- Fixing some potential undefined backtrace references. (Bug: 17738)
- Adding `lineFormat` and `timeFormat` configuration variables to the syslog handler. (Request: 17753)
</notes>
</release>
<release>
<version>
<release>1.12.1</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-05-28</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Fixing a rare notice when extracting the class name from a backtrace involving the composite handler. (Bug 17356)
</notes>
</release>
<release>
<version>
<release>1.12.0</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-01-24</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
This release drops PHP4 compatibility (enforced by the package dependencies).
There is unfortunately no way to support both PHP4 and PHP5 in the same code base when running under E_ALL. Because it appears that the majority of Log package users have moved to PHP5, the Log package now targets that audience.
Given the fact that the Log package is now largely in maintenance mode, existing PHP4 users shouldn&apos;t feel adandoned. If necessary, important fixes, etc. can be merged back into the 1.11.* release line, which will retain PHP4 compatibility.
Also:
- Added a PEAR_LOG_TYPE_SAPI constant for use by with error_log handler.
</notes>
</release>
<release>
<version>
<release>1.12.0RC1</release>
<api>1.0.0</api>
</version>
<stability>
<release>beta</release>
<api>stable</api>
</stability>
<date>2009-12-27</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
This release drops PHP4 compatibility (enforced by the package dependencies).
There is unfortunately no way to support both PHP4 and PHP5 in the same code base when running under E_ALL. Because it appears that the majority of Log package users have moved to PHP5, the Log package now targets that audience.
Given the fact that the Log package is now largely in maintenance mode, existing PHP4 users shouldn&apos;t feel adandoned. If necessary, important fixes, etc. can be merged back into the 1.11.* release line, which will retain PHP4 compatibility.
</notes>
</release>
<release>
<version>
<release>1.11.6</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-12-26</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
The syslog handler&apos;s maximum message length is now configurable via a new &apos;maxLength&apos; configuration variable. If the handler receives a message longer than this length limit, it will be split into multiple syslog() calls.
</notes>
</release>
<release>
<version>
<release>1.11.5</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-07-23</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The class name is now reported correctly when the shortcut functions are used. (Bug #16452)
</notes>
</release>
<release>
<version>
<release>1.11.4</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-03-29</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- The window handler now works when output buffering is enabled. (Bug 15379)
- The window handler will now scroll to the bottom when clicked. (Kevin Wood)
</notes>
</release>
<release>
<version>
<release>1.11.3</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-11-18</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- It is now possible to configure the error_log handler&apos;s line and timestamp formats. (Bug #14655)
- Added _extractMessage() support for non-scalar array(&apos;message&apos; =&gt; ...) values.
- Spaces in &apos;win&apos; handler window names are now replaced with underscores.
- Added a class name format token: %8$s
</notes>
</release>
<release>
<version>
<release>1.11.2</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-09-04</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- Correcting some breakage in Log::_getBacktraceVars(). (Bug 14595)
</notes>
</release>
<release>
<version>
<release>1.11.1</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-08-05</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
- Log::_getBacktraceVars() no longer produces notices. (Bug 14398)
- Log::_extractMessage() now uses var_export() instead of print_r(). (Bug 14430)
</notes>
</release>
<release>
<version>
<release>1.11.0</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-06-14</date>
<license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
<notes>
Relicensing the Log package under the MIT license.
</notes>
</release>
<release>
<version>
<release>1.10.1</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-05-03</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The default value for the display handler&apos;s lineBreak configuration value wasn&apos;t being applied. (Bug 13436)
</notes>
</release>
<release>
<version>
<release>1.10.0</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-02-10</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The level masking test now passed on 64-bit platforms. (Bug 12933)
- The mail handler can now optionally use the PEAR Mail package. (Request 12839)
</notes>
</release>
<release>
<version>
<release>1.9.16</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-01-19</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- Corrected some PHPDoc syntax problems.
- Correcting some spelling errors in the users guide.
- Fixed the firebug unit test.
- Simplified the PEAR_LOG_ALL and PEAR_LOG_NONE constants.
</notes>
</release>
<release>
<version>
<release>1.9.15</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-01-19</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The Firebug handler now avoids more Javascript errors in IE. (Bug 12810)
</notes>
</release>
<release>
<version>
<release>1.9.14</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2008-01-01</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The sql handler wasn&apos;t honoring custom SQL insertion statements. (Bug 12734)
- The display handler now has a configurable line format. (Request 12781)
</notes>
</release>
<release>
<version>
<release>1.9.13</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2007-12-12</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The Firebug handler&apos;s unit test now passes. (Bug 12674)
- Fixed a PHP4 compatibility problem involving class_exists(). (Bug 12675)
</notes>
</release>
<release>
<version>
<release>1.9.12</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2007-12-11</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
- The Firebug handler no longer generates Javascript errors in IE. (Bug 12607)
- The users guide has been updated with information on writing custom handlers.
</notes>
</release>
<release>
<version>
<release>1.9.11</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2007-05-13</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
A Firebug log handler has been added.
</notes>
</release>
<release>
<version>
<release>1.9.10</release>
<api>1.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2007-02-04</date>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>
The syslog handler now has an &apos;inherit&apos; configuration parameter which controls whether or openlog() is called to create a new syslog environment. (Bug 9822)
fflush() is now always called with a valid resource. (Bug 9388)
The mail handler, when composited, no longer sends empty messages. (Bug 8865)
</notes>
</release>
</changelog>
</package>

View File

@@ -0,0 +1,76 @@
--TEST--
Log: Backtrace Vars
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '%6$s [%8$s::%7$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
# Top-level Logger
#
$logger->log("Top-level Logger - log()");
$logger->info("Top-level Logger - info()");
# Function Logger
#
function functionLog($logger)
{
$logger->log("Function Logger - log()");
$logger->info("Function Logger - info()");
}
functionLog($logger);
# Class Logger
#
class ClassLogger
{
function log($logger)
{
$logger->log("Class Logger - log()");
$logger->info("Class Logger - info()");
}
}
$classLogger = new ClassLogger();
$classLogger->log($logger);
# Composite Logger
#
$composite = Log::singleton('composite');
$composite->addChild($logger);
$composite->log("Composite Logger - log()");
$composite->info("Composite Logger - info()");
# Composite Logger via Class
#
$classLogger->log($composite);
# Deeper Backtrace
function deeperLog($logger)
{
$logger->log("Deeper Logger - log()");
$logger->info("Deeper Logger - info()");
}
$logger->setBacktraceDepth(1);
deeperLog($logger);
--EXPECT--
10 [::(none)] Top-level Logger - log()
11 [::(none)] Top-level Logger - info()
17 [::functionLog] Function Logger - log()
18 [::functionLog] Function Logger - info()
29 [ClassLogger::log] Class Logger - log()
30 [ClassLogger::log] Class Logger - info()
42 [::(none)] Composite Logger - log()
43 [::(none)] Composite Logger - info()
29 [ClassLogger::log] Class Logger - log()
30 [ClassLogger::log] Class Logger - info()
57 [::(none)] Deeper Logger - log()
53 [::deeperLog] Deeper Logger - info()

View File

@@ -0,0 +1,97 @@
--TEST--
Log: Composite Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
function printOpenStates($children) {
foreach ($children as $child) {
$state = ($child->_opened) ? 'OPEN' : 'CLOSED';
echo "$child->_ident : $state\n";
}
}
function printIdents($children) {
foreach ($children as $child) {
echo "$child->_ident\n";
}
}
function testPriority($composite, $priority) {
$log = new Log;
$name = $log->priorityToString($priority);
$success = $composite->log($name, $priority);
echo "$name : " . (($success) ? 'GOOD' : 'BAD') . "\n";
}
/* Create three handlers with different priority masks. */
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$children = array(
Log::factory('console', '', 'CONSOLE1', $conf),
Log::factory('console', '', 'CONSOLE2', $conf),
Log::factory('console', '', 'CONSOLE3', $conf)
);
$children[0]->setMask(Log::MASK(PEAR_LOG_DEBUG));
$children[1]->setMask(Log::MASK(PEAR_LOG_INFO));
$children[2]->setMask(Log::MASK(PEAR_LOG_ERR));
$composite = Log::singleton('composite');
$composite->addChild($children[0]);
$composite->addChild($children[1]);
$composite->addChild($children[2]);
/* Verify that all of the children are initially closed. */
printOpenStates($children);
/* Verify that the composite handler's open() opens all of the children. */
$composite->open();
printOpenStates($children);
/* Verify that the composite handler's close() closes all of the children. */
$composite->close();
printOpenStates($children);
/* Verify the log results at different priorities. */
testPriority($composite, PEAR_LOG_DEBUG);
printOpenStates($children);
testPriority($composite, PEAR_LOG_INFO);
printOpenStates($children);
testPriority($composite, PEAR_LOG_ERR);
printOpenStates($children);
/* Verify that changing the ident affects all children. */
$composite->setIdent('IDENT');
printIdents($children);
--EXPECT--
CONSOLE1 : CLOSED
CONSOLE2 : CLOSED
CONSOLE3 : CLOSED
CONSOLE1 : OPEN
CONSOLE2 : OPEN
CONSOLE3 : OPEN
CONSOLE1 : CLOSED
CONSOLE2 : CLOSED
CONSOLE3 : CLOSED
CONSOLE1 [debug] debug
debug : GOOD
CONSOLE1 : OPEN
CONSOLE2 : CLOSED
CONSOLE3 : CLOSED
CONSOLE2 [info] info
info : GOOD
CONSOLE1 : OPEN
CONSOLE2 : OPEN
CONSOLE3 : CLOSED
CONSOLE3 [error] error
error : GOOD
CONSOLE1 : OPEN
CONSOLE2 : OPEN
CONSOLE3 : OPEN
IDENT
IDENT
IDENT

View File

@@ -0,0 +1,45 @@
--TEST--
Log: Console Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
for ($i = 0; $i < 3; $i++) {
$logger->log("Log entry $i");
}
echo "\n[Buffering / Flush Test]\n";
$conf = array('lineFormat' => '%2$s [%3$s] %4$s', 'buffering' => true);
$buffered_logger = Log::singleton('console', '', 'buffered', $conf);
for ($i = 0; $i < 3; $i++) {
$buffered_logger->log("Pre-flush buffered log entry $i");
}
echo "Pre-flush\n";
$buffered_logger->flush();
echo "Post-flush\n";
for ($i = 0; $i < 3; $i++) {
$buffered_logger->log("Post-flush buffered log entry $i");
}
echo "Shutdown\n";
$buffered_logger->close();
--EXPECT--
ident [info] Log entry 0
ident [info] Log entry 1
ident [info] Log entry 2
[Buffering / Flush Test]
Pre-flush
buffered [info] Pre-flush buffered log entry 0
buffered [info] Pre-flush buffered log entry 1
buffered [info] Pre-flush buffered log entry 2
Post-flush
Shutdown
buffered [info] Post-flush buffered log entry 0
buffered [info] Post-flush buffered log entry 1
buffered [info] Post-flush buffered log entry 2

View File

@@ -0,0 +1,69 @@
--TEST--
Log: Display Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
function test($name, $conf)
{
echo "\nTesting $name Configuration\n";
echo "------------------------------------------------------\n";
$logger = Log::factory('display', '', $name, $conf);
$logger->log("Info", PEAR_LOG_INFO);
$logger->log("Error", PEAR_LOG_ERR);
$logger->log("Debug", PEAR_LOG_DEBUG);
$logger->log("Multi\nLine\nEntry", PEAR_LOG_INFO);
echo "\n";
}
test('Default', array());
test('Line Break', array('linebreak' => "\n"));
test('Format', array('lineFormat' => '<!-- %4$s -->'));
test('Prepend / Append', array('error_prepend' => '<tt>',
'error_append' => '</tt>'));
--EXPECT--
Testing Default Configuration
------------------------------------------------------
<b>info</b>: Info<br />
<b>error</b>: Error<br />
<b>debug</b>: Debug<br />
<b>info</b>: Multi<br />
Line<br />
Entry<br />
Testing Line Break Configuration
------------------------------------------------------
<b>info</b>: Info
<b>error</b>: Error
<b>debug</b>: Debug
<b>info</b>: Multi<br />
Line<br />
Entry
Testing Format Configuration
------------------------------------------------------
<!-- Info --><br />
<!-- Error --><br />
<!-- Debug --><br />
<!-- Multi<br />
Line<br />
Entry --><br />
Testing Prepend / Append Configuration
------------------------------------------------------
<tt><b>info</b>: Info</tt><br />
<tt><b>error</b>: Error</tt><br />
<tt><b>debug</b>: Debug</tt><br />
<tt><b>info</b>: Multi<br />
Line<br />
Entry</tt><br />

View File

@@ -0,0 +1,31 @@
--TEST--
Log: Error_Log Handler
--SKIPIF--
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("skip\n"); ?>
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
/* Default Configuration */
$logger1 = Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');
for ($i = 0; $i < 3; $i++) {
$logger1->log("Log entry $i");
}
/* Custom line format */
$conf = array('lineFormat' => '%2$s: [%3$s] %4$s');
$logger2 = Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident', $conf);
for ($i = 0; $i < 3; $i++) {
$logger2->log("Log entry $i");
}
--EXPECT--
ident: Log entry 0
ident: Log entry 1
ident: Log entry 2
ident: [info] Log entry 0
ident: [info] Log entry 1
ident: [info] Log entry 2

View File

@@ -0,0 +1,70 @@
--TEST--
Log: _extractMessage() [Zend Engine 2.0]
--SKIPIF--
<?php
if (version_compare(zend_version(), "2.0.0", "<") ||
version_compare(zend_version(), "2.2.0", ">=")) die('skip');
?>
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
/* Logging a regular string. */
$logger->log('String');
/* Logging a bare object. */
class BareObject {}
$logger->log(new BareObject());
/* Logging an object with a getMessage() method. */
class GetMessageObject { function getMessage() { return "getMessage"; } }
$logger->log(new GetMessageObject());
/* Logging an object with a toString() method. */
class ToStringObject { function toString() { return "toString"; } }
$logger->log(new ToStringObject());
/* Logging an object with a __toString() method using casting. */
class CastableObject { function __toString() { return "__toString"; } }
$logger->log(new CastableObject());
/* Logging a PEAR_Error object. */
require_once 'PEAR.php';
$logger->log(new PEAR_Error('PEAR_Error object', 100));
/* Logging an array. */
$logger->log(array(1, 2, 'three' => 3));
/* Logging an array with scalar 'message' keys. */
$logger->log(array('message' => 'Message Key'));
$logger->log(array('message' => 50));
/* Logging an array with a non-scalar 'message' key. */
$logger->log(array('message' => array(1, 2, 3)));
--EXPECT--
ident [info] String
ident [info] BareObject::__set_state(array(
))
ident [info] getMessage
ident [info] toString
ident [info] Object id #2
ident [info] PEAR_Error object
ident [info] array (
0 => 1,
1 => 2,
'three' => 3,
)
ident [info] Message Key
ident [info] 50
ident [info] array (
0 => 1,
1 => 2,
2 => 3,
)

View File

@@ -0,0 +1,67 @@
--TEST--
Log: _extractMessage() [Zend Engine 2.2]
--SKIPIF--
<?php if (version_compare(zend_version(), "2.2.0", "<")) die('skip'); ?>
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
/* Logging a regular string. */
$logger->log('String');
/* Logging a bare object. */
class BareObject {}
$logger->log(new BareObject());
/* Logging an object with a getMessage() method. */
class GetMessageObject { function getMessage() { return "getMessage"; } }
$logger->log(new GetMessageObject());
/* Logging an object with a toString() method. */
class ToStringObject { function toString() { return "toString"; } }
$logger->log(new ToStringObject());
/* Logging an object with a __toString() method using casting. */
class CastableObject { function __toString() { return "__toString"; } }
$logger->log(new CastableObject());
/* Logging a PEAR_Error object. */
require_once 'PEAR.php';
$logger->log(new PEAR_Error('PEAR_Error object', 100));
/* Logging an array. */
$logger->log(array(1, 2, 'three' => 3));
/* Logging an array with scalar 'message' keys. */
$logger->log(array('message' => 'Message Key'));
$logger->log(array('message' => 50));
/* Logging an array with a non-scalar 'message' key. */
$logger->log(array('message' => array(1, 2, 3)));
--EXPECT--
ident [info] String
ident [info] BareObject::__set_state(array(
))
ident [info] getMessage
ident [info] toString
ident [info] __toString
ident [info] PEAR_Error object
ident [info] array (
0 => 1,
1 => 2,
'three' => 3,
)
ident [info] Message Key
ident [info] 50
ident [info] array (
0 => 1,
1 => 2,
2 => 3,
)

View File

@@ -0,0 +1,22 @@
--TEST--
Log: Factory
--FILE--
<?php
require_once 'Log.php';
$console1 = Log::factory('console');
$console2 = Log::factory('console');
if (is_a($console1, 'Log_console') && is_a($console2, 'Log_console'))
{
echo "Two Log_console objects.\n";
}
if ($console1->_id != $console2->_id) {
echo "The objects have different IDs.\n";
}
--EXPECT--
Two Log_console objects.
The objects have different IDs.

View File

@@ -0,0 +1,31 @@
--TEST--
Log: File Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test.log';
if (file_exists($filename)) unlink($filename);
/* Write some entries to the log file. */
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$logger = Log::singleton('file', $filename, '', $conf);
for ($i = 0; $i < 3; $i++) {
$logger->log("Log entry $i");
}
$logger->close();
/* Dump the contents of the log file. */
echo file_get_contents($filename);
/* Clean up. */
if (file_exists($filename)) unlink($filename);
--EXPECT--
[info] Log entry 0
[info] Log entry 1
[info] Log entry 2

View File

@@ -0,0 +1,98 @@
--TEST--
Log: Firebug Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array();
print "** UNBUFFERED **\n";
$logger = Log::singleton('firebug', '', 'PHP', $conf);
$logger->log('Debug', PEAR_LOG_DEBUG);
$logger->log('Info', PEAR_LOG_INFO);
$logger->log('Notice', PEAR_LOG_NOTICE);
$logger->log('Warning', PEAR_LOG_WARNING);
$logger->log('Error', PEAR_LOG_ERR);
$logger->log('Critical', PEAR_LOG_CRIT);
$logger->log('Alert', PEAR_LOG_ALERT);
$logger->log('Emergency', PEAR_LOG_EMERG);
unset($logger);
print "\n** START BUFFERING **\n";
$conf = array('buffering' => true);
$logger = Log::singleton('firebug', '', 'PHP', $conf);
$logger->log('Debug', PEAR_LOG_DEBUG);
$logger->log('Info', PEAR_LOG_INFO);
$logger->log('Notice', PEAR_LOG_NOTICE);
$logger->log('Warning', PEAR_LOG_WARNING);
$logger->flush();
print "** FLUSHED **\n";
print "** REST OF BUFFERED **\n";
$logger->log('Error', PEAR_LOG_ERR);
$logger->log('Critical', PEAR_LOG_CRIT);
$logger->log('Alert', PEAR_LOG_ALERT);
$logger->log('Emergency', PEAR_LOG_EMERG);
--EXPECT--
** UNBUFFERED **
<script type="text/javascript">
if ('console' in window) {
console.debug("PHP [debug] Debug");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.info("PHP [info] Info");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.info("PHP [notice] Notice");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.warn("PHP [warning] Warning");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.error("PHP [error] Error");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.error("PHP [critical] Critical");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.error("PHP [alert] Alert");
}
</script>
<script type="text/javascript">
if ('console' in window) {
console.error("PHP [emergency] Emergency");
}
</script>
** START BUFFERING **
<script type="text/javascript">
if ('console' in window) {
console.debug("PHP [debug] Debug");
console.info("PHP [info] Info");
console.info("PHP [notice] Notice");
console.warn("PHP [warning] Warning");
}
</script>
** FLUSHED **
** REST OF BUFFERED **
<script type="text/javascript">
if ('console' in window) {
console.error("PHP [error] Error");
console.error("PHP [critical] Critical");
console.error("PHP [alert] Alert");
console.error("PHP [emergency] Emergency");
}
</script>

View File

@@ -0,0 +1,15 @@
--TEST--
Log: Line Format
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '%{timestamp} %{ident} %{priority} %{message} %{file} %{line} %{function} %{class}');
$logger = Log::singleton('console', '', 'ident', $conf);
$logger->log('Message');
--EXPECTREGEX--
^\w{3} \d+ \d{2}:\d{2}:\d{2} ident info Message .*format\.php \d+ [\(\)\w]+$

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,74 @@
--TEST--
Log: Levels
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
function verify($exp, $msg)
{
echo $msg . ': ';
echo ($exp) ? 'pass' : 'fail';
echo "\n";
}
function testLevels($mask)
{
echo "Mask: " . ($mask & 0xffff) . "\n";
for ($priority = PEAR_LOG_EMERG; $priority <= PEAR_LOG_DEBUG; $priority++) {
$masked = (Log::MASK($priority) & $mask);
echo "Priority $priority: ";
echo($masked) ? "masked\n" : "unmasked\n";
}
echo "\n";
}
testLevels(PEAR_LOG_NONE);
testLevels(PEAR_LOG_ALL);
testLevels(Log::MIN(PEAR_LOG_WARNING));
testLevels(Log::MAX(PEAR_LOG_WARNING));
--EXPECT--
Mask: 0
Priority 0: unmasked
Priority 1: unmasked
Priority 2: unmasked
Priority 3: unmasked
Priority 4: unmasked
Priority 5: unmasked
Priority 6: unmasked
Priority 7: unmasked
Mask: 65535
Priority 0: masked
Priority 1: masked
Priority 2: masked
Priority 3: masked
Priority 4: masked
Priority 5: masked
Priority 6: masked
Priority 7: masked
Mask: 65520
Priority 0: unmasked
Priority 1: unmasked
Priority 2: unmasked
Priority 3: unmasked
Priority 4: masked
Priority 5: masked
Priority 6: masked
Priority 7: masked
Mask: 31
Priority 0: masked
Priority 1: masked
Priority 2: masked
Priority 3: masked
Priority 4: masked
Priority 5: unmasked
Priority 6: unmasked
Priority 7: unmasked

View File

@@ -0,0 +1,40 @@
--TEST--
Log: Masks
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
/* Levels */
for ($level = PEAR_LOG_EMERG; $level <= PEAR_LOG_DEBUG; $level++) {
printf("Level %d: 0x%08x, 0x%08x, 0x%08x\n",
$level,
Log::MASK($level),
Log::MIN($level),
Log::MAX($level));
}
echo "\n";
/* Mask */
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
$logger->setMask(Log::MAX(PEAR_LOG_INFO));
$logger->info('Info 1');
$logger->setMask(Log::MAX(PEAR_LOG_ERR));
$logger->info('Info 2');
--EXPECT--
Level 0: 0x00000001, 0xffffffff, 0x00000001
Level 1: 0x00000002, 0xfffffffe, 0x00000003
Level 2: 0x00000004, 0xfffffffc, 0x00000007
Level 3: 0x00000008, 0xfffffff8, 0x0000000f
Level 4: 0x00000010, 0xfffffff0, 0x0000001f
Level 5: 0x00000020, 0xffffffe0, 0x0000003f
Level 6: 0x00000040, 0xffffffc0, 0x0000007f
Level 7: 0x00000080, 0xffffff80, 0x000000ff
ident [info] Info 1

View File

@@ -0,0 +1,15 @@
--TEST--
Log: Null Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$logger = Log::singleton('null');
for ($i = 0; $i < 3; $i++) {
$logger->log("Log entry $i");
}
--EXPECT--

View File

@@ -0,0 +1,32 @@
--TEST--
Log: Priorities
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('lineFormat' => '[%3$s] %4$s');
$logger = Log::singleton('console', '', 'ident', $conf);
/* Log at the default PEAR_LOG_INFO level. */
$logger->log('Log message');
/* Set the default priority to PEAR_LOG_DEBUG. */
$logger->setPriority(PEAR_LOG_DEBUG);
$logger->log('Log message');
/* Verify that the getPriority() method also things we're at PEAR_LOG_DEBUG. */
$priority = $logger->priorityToString($logger->getPriority());
echo "$priority\n";
/* Verify that stringToPriority() can convert back to a constant. */
$priority = $logger->stringToPriority($priority);
echo "$priority\n";
--EXPECT--
[info] Log message
[debug] Log message
debug
7

View File

@@ -0,0 +1,24 @@
--TEST--
Log: Singleton
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$console1 = Log::singleton('console');
$console2 = Log::singleton('console');
if (is_a($console1, 'Log_console') && is_a($console2, 'Log_console'))
{
echo "Two Log_console objects.\n";
}
if ($console1->_id == $console2->_id) {
echo "The objects have the same ID.\n";
}
--EXPECT--
Two Log_console objects.
The objects have the same ID.

View File

@@ -0,0 +1,27 @@
--TEST--
Log: SQL setIdent()
--SKIPIF--
<?php
require_once 'PEAR/Registry.php';
$registry = new PEAR_Registry();
if (!$registry->packageExists('DB')) die("skip\n");
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$ident = '12345678901234567890';
$logger = Log::singleton('sql', 'log_table', $ident, array('dsn' => ''));
echo $logger->getIdent() . "\n";
$logger->setIdent($ident);
echo $logger->getIdent() . "\n";
--EXPECT--
1234567890123456
1234567890123456

View File

@@ -0,0 +1,31 @@
--TEST--
Log: Sqlite Handler
--SKIPIF--
<?php if (!function_exists('sqlite_open')) die("skip\n"); ?>
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sqlite-log.db';
if (file_exists($filename)) unlink($filename);
$db = sqlite_open($filename, 0666, $error);
$ident = time();
$message = 'logging an event';
$logger = Log::factory('sqlite', 'log_table', $ident, $db);
$logger->log($message, PEAR_LOG_WARNING);
$q = "SELECT message FROM log_table WHERE ident='$ident'";
$res = sqlite_query($db, $q);
if (sqlite_fetch_string($res) == $message) {
echo 'ok';
}
sqlite_close($db);
if (file_exists($filename)) unlink($filename);
--EXPECT--
ok

View File

@@ -0,0 +1,15 @@
--TEST--
Log: Syslog Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$logger = Log::singleton('syslog', '', 'Test');
for ($i = 0; $i < 3; $i++) {
$logger->notice("Log entry $i");
}
--EXPECT--

View File

@@ -0,0 +1,70 @@
--TEST--
Log: Window Handler (Output Buffering)
--INI--
date.timezone=UTC
output_buffering=on
--FILE--
<?php
require_once 'Log.php';
$conf = array('title' => 'Test Output');
$logger = Log::singleton('win', 'test', 'ident', $conf);
for ($i = 0; $i < 3; $i++) {
$logger->log("Log entry $i");
}
--EXPECTF--
<script language="JavaScript">
test = window.open('', 'test', 'toolbar=no,scrollbars,width=600,height=400');
test.document.writeln('<html>');
test.document.writeln('<head>');
test.document.writeln('<title>Test Output</title>');
test.document.writeln('<style type="text/css">');
test.document.writeln('body { font-family: monospace; font-size: 8pt; }');
test.document.writeln('td,th { font-size: 8pt; }');
test.document.writeln('td,th { border-bottom: #999999 solid 1px; }');
test.document.writeln('td,th { border-right: #999999 solid 1px; }');
test.document.writeln('tr { text-align: left; vertical-align: top; }');
test.document.writeln('td.l0 { color: red; }');
test.document.writeln('td.l1 { color: orange; }');
test.document.writeln('td.l2 { color: yellow; }');
test.document.writeln('td.l3 { color: green; }');
test.document.writeln('td.l4 { color: blue; }');
test.document.writeln('td.l5 { color: indigo; }');
test.document.writeln('td.l6 { color: violet; }');
test.document.writeln('td.l7 { color: black; }');
test.document.writeln('</style>');
test.document.writeln('<script type="text/javascript">');
test.document.writeln('function scroll() {');
test.document.writeln(' body = document.getElementById("test");');
test.document.writeln(' body.scrollTop = body.scrollHeight;');
test.document.writeln('}');
test.document.writeln('<\/script>');
test.document.writeln('</head>');
test.document.writeln('<body id="test" onclick="scroll()">');
test.document.writeln('<table border="0" cellpadding="2" cellspacing="0">');
test.document.writeln('<tr><th>Time</th>');
test.document.writeln('<th>Ident</th>')
test.document.writeln('<th>Priority</th><th width="100%">Message</th></tr>');
</script><script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 0</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 1</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 2</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('</table>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('</body></html>');
self.focus();
</script>

View File

@@ -0,0 +1,69 @@
--TEST--
Log: Window Handler
--INI--
date.timezone=UTC
--FILE--
<?php
require_once 'Log.php';
$conf = array('title' => 'Test Output');
$logger = Log::singleton('win', 'test', 'ident', $conf);
for ($i = 0; $i < 3; $i++) {
$logger->log("Log entry $i");
}
--EXPECTF--
<script language="JavaScript">
test = window.open('', 'test', 'toolbar=no,scrollbars,width=600,height=400');
test.document.writeln('<html>');
test.document.writeln('<head>');
test.document.writeln('<title>Test Output</title>');
test.document.writeln('<style type="text/css">');
test.document.writeln('body { font-family: monospace; font-size: 8pt; }');
test.document.writeln('td,th { font-size: 8pt; }');
test.document.writeln('td,th { border-bottom: #999999 solid 1px; }');
test.document.writeln('td,th { border-right: #999999 solid 1px; }');
test.document.writeln('tr { text-align: left; vertical-align: top; }');
test.document.writeln('td.l0 { color: red; }');
test.document.writeln('td.l1 { color: orange; }');
test.document.writeln('td.l2 { color: yellow; }');
test.document.writeln('td.l3 { color: green; }');
test.document.writeln('td.l4 { color: blue; }');
test.document.writeln('td.l5 { color: indigo; }');
test.document.writeln('td.l6 { color: violet; }');
test.document.writeln('td.l7 { color: black; }');
test.document.writeln('</style>');
test.document.writeln('<script type="text/javascript">');
test.document.writeln('function scroll() {');
test.document.writeln(' body = document.getElementById("test");');
test.document.writeln(' body.scrollTop = body.scrollHeight;');
test.document.writeln('}');
test.document.writeln('<\/script>');
test.document.writeln('</head>');
test.document.writeln('<body id="test" onclick="scroll()">');
test.document.writeln('<table border="0" cellpadding="2" cellspacing="0">');
test.document.writeln('<tr><th>Time</th>');
test.document.writeln('<th>Ident</th>')
test.document.writeln('<th>Priority</th><th width="100%">Message</th></tr>');
</script><script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 0</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 1</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('<tr><td>%i:%i:%i.%i</td><td>ident</td><td>Info</td><td class=\"l6\">Log entry 2</td></tr>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('</table>');
self.focus();
</script>
<script language='JavaScript'>
test.document.writeln('</body></html>');
self.focus();
</script>

View File

@@ -0,0 +1,27 @@
Copyright (c) 1997-2009,
Stig Bakken <ssb@php.net>,
Gregory Beaver <cellog@php.net>,
Helgi Þormar Þorbjörnsson <helgi@php.net>,
Tomas V.V.Cox <cox@idecnet.com>,
Martin Jansen <mj@php.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,456 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
/**
* PEAR_Exception
*
* PHP version 5
*
* @category PEAR
* @package PEAR_Exception
* @author Tomas V. V. Cox <cox@idecnet.com>
* @author Hans Lellelid <hans@velum.net>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://pear.php.net/package/PEAR_Exception
* @since File available since Release 1.0.0
*/
/**
* Base PEAR_Exception Class
*
* 1) Features:
*
* - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception))
* - Definable triggers, shot when exceptions occur
* - Pretty and informative error messages
* - Added more context info available (like class, method or cause)
* - cause can be a PEAR_Exception or an array of mixed
* PEAR_Exceptions/PEAR_ErrorStack warnings
* - callbacks for specific exception classes and their children
*
* 2) Ideas:
*
* - Maybe a way to define a 'template' for the output
*
* 3) Inherited properties from PHP Exception Class:
*
* protected $message
* protected $code
* protected $line
* protected $file
* private $trace
*
* 4) Inherited methods from PHP Exception Class:
*
* __clone
* __construct
* getMessage
* getCode
* getFile
* getLine
* getTraceSafe
* getTraceSafeAsString
* __toString
*
* 5) Usage example
*
* <code>
* require_once 'PEAR/Exception.php';
*
* class Test {
* function foo() {
* throw new PEAR_Exception('Error Message', ERROR_CODE);
* }
* }
*
* function myLogger($pear_exception) {
* echo $pear_exception->getMessage();
* }
* // each time a exception is thrown the 'myLogger' will be called
* // (its use is completely optional)
* PEAR_Exception::addObserver('myLogger');
* $test = new Test;
* try {
* $test->foo();
* } catch (PEAR_Exception $e) {
* print $e;
* }
* </code>
*
* @category PEAR
* @package PEAR_Exception
* @author Tomas V.V.Cox <cox@idecnet.com>
* @author Hans Lellelid <hans@velum.net>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: @package_version@
* @link http://pear.php.net/package/PEAR_Exception
* @since Class available since Release 1.0.0
*/
class PEAR_Exception extends Exception
{
const OBSERVER_PRINT = -2;
const OBSERVER_TRIGGER = -4;
const OBSERVER_DIE = -8;
protected $cause;
private static $_observers = array();
private static $_uniqueid = 0;
private $_trace;
/**
* Supported signatures:
* - PEAR_Exception(string $message);
* - PEAR_Exception(string $message, int $code);
* - PEAR_Exception(string $message, Exception $cause);
* - PEAR_Exception(string $message, Exception $cause, int $code);
* - PEAR_Exception(string $message, PEAR_Error $cause);
* - PEAR_Exception(string $message, PEAR_Error $cause, int $code);
* - PEAR_Exception(string $message, array $causes);
* - PEAR_Exception(string $message, array $causes, int $code);
*
* @param string $message exception message
* @param int|Exception|PEAR_Error|array|null $p2 exception cause
* @param int|null $p3 exception code or null
*/
public function __construct($message, $p2 = null, $p3 = null)
{
if (is_int($p2)) {
$code = $p2;
$this->cause = null;
} elseif (is_object($p2) || is_array($p2)) {
// using is_object allows both Exception and PEAR_Error
if (is_object($p2) && !($p2 instanceof Exception)) {
if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) {
throw new PEAR_Exception(
'exception cause must be Exception, ' .
'array, or PEAR_Error'
);
}
}
$code = $p3;
if (is_array($p2) && isset($p2['message'])) {
// fix potential problem of passing in a single warning
$p2 = array($p2);
}
$this->cause = $p2;
} else {
$code = null;
$this->cause = null;
}
parent::__construct($message, (int) $code);
$this->signal();
}
/**
* Add an exception observer
*
* @param mixed $callback - A valid php callback, see php func is_callable()
* - A PEAR_Exception::OBSERVER_* constant
* - An array(const PEAR_Exception::OBSERVER_*,
* mixed $options)
* @param string $label The name of the observer. Use this if you want
* to remove it later with removeObserver()
*
* @return void
*/
public static function addObserver($callback, $label = 'default')
{
self::$_observers[$label] = $callback;
}
/**
* Remove an exception observer
*
* @param string $label Name of the observer
*
* @return void
*/
public static function removeObserver($label = 'default')
{
unset(self::$_observers[$label]);
}
/**
* Generate a unique ID for an observer
*
* @return int unique identifier for an observer
*/
public static function getUniqueId()
{
return self::$_uniqueid++;
}
/**
* Send a signal to all observers
*
* @return void
*/
protected function signal()
{
foreach (self::$_observers as $func) {
if (is_callable($func)) {
call_user_func($func, $this);
continue;
}
settype($func, 'array');
switch ($func[0]) {
case self::OBSERVER_PRINT :
$f = (isset($func[1])) ? $func[1] : '%s';
printf($f, $this->getMessage());
break;
case self::OBSERVER_TRIGGER :
$f = (isset($func[1])) ? $func[1] : E_USER_NOTICE;
trigger_error($this->getMessage(), $f);
break;
case self::OBSERVER_DIE :
$f = (isset($func[1])) ? $func[1] : '%s';
die(printf($f, $this->getMessage()));
break;
default:
trigger_error('invalid observer type', E_USER_WARNING);
}
}
}
/**
* Return specific error information that can be used for more detailed
* error messages or translation.
*
* This method may be overridden in child exception classes in order
* to add functionality not present in PEAR_Exception and is a placeholder
* to define API
*
* The returned array must be an associative array of parameter => value like so:
* <pre>
* array('name' => $name, 'context' => array(...))
* </pre>
*
* @return array
*/
public function getErrorData()
{
return array();
}
/**
* Returns the exception that caused this exception to be thrown
*
* @return Exception|array The context of the exception
*/
public function getCause()
{
return $this->cause;
}
/**
* Function must be public to call on caused exceptions
*
* @param array $causes Array that gets filled.
*
* @return void
*/
public function getCauseMessage(&$causes)
{
$trace = $this->getTraceSafe();
$cause = array('class' => get_class($this),
'message' => $this->message,
'file' => 'unknown',
'line' => 'unknown');
if (isset($trace[0])) {
if (isset($trace[0]['file'])) {
$cause['file'] = $trace[0]['file'];
$cause['line'] = $trace[0]['line'];
}
}
$causes[] = $cause;
if ($this->cause instanceof PEAR_Exception) {
$this->cause->getCauseMessage($causes);
} elseif ($this->cause instanceof Exception) {
$causes[] = array('class' => get_class($this->cause),
'message' => $this->cause->getMessage(),
'file' => $this->cause->getFile(),
'line' => $this->cause->getLine());
} elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
$causes[] = array('class' => get_class($this->cause),
'message' => $this->cause->getMessage(),
'file' => 'unknown',
'line' => 'unknown');
} elseif (is_array($this->cause)) {
foreach ($this->cause as $cause) {
if ($cause instanceof PEAR_Exception) {
$cause->getCauseMessage($causes);
} elseif ($cause instanceof Exception) {
$causes[] = array('class' => get_class($cause),
'message' => $cause->getMessage(),
'file' => $cause->getFile(),
'line' => $cause->getLine());
} elseif (class_exists('PEAR_Error')
&& $cause instanceof PEAR_Error
) {
$causes[] = array('class' => get_class($cause),
'message' => $cause->getMessage(),
'file' => 'unknown',
'line' => 'unknown');
} elseif (is_array($cause) && isset($cause['message'])) {
// PEAR_ErrorStack warning
$causes[] = array(
'class' => $cause['package'],
'message' => $cause['message'],
'file' => isset($cause['context']['file']) ?
$cause['context']['file'] :
'unknown',
'line' => isset($cause['context']['line']) ?
$cause['context']['line'] :
'unknown',
);
}
}
}
}
/**
* Build a backtrace and return it
*
* @return array Backtrace
*/
public function getTraceSafe()
{
if (!isset($this->_trace)) {
$this->_trace = $this->getTrace();
if (empty($this->_trace)) {
$backtrace = debug_backtrace();
$this->_trace = array($backtrace[count($backtrace)-1]);
}
}
return $this->_trace;
}
/**
* Gets the first class of the backtrace
*
* @return string Class name
*/
public function getErrorClass()
{
$trace = $this->getTraceSafe();
return $trace[0]['class'];
}
/**
* Gets the first method of the backtrace
*
* @return string Method/function name
*/
public function getErrorMethod()
{
$trace = $this->getTraceSafe();
return $trace[0]['function'];
}
/**
* Converts the exception to a string (HTML or plain text)
*
* @return string String representation
*
* @see toHtml()
* @see toText()
*/
public function __toString()
{
if (isset($_SERVER['REQUEST_URI'])) {
return $this->toHtml();
}
return $this->toText();
}
/**
* Generates a HTML representation of the exception
*
* @return string HTML code
*/
public function toHtml()
{
$trace = $this->getTraceSafe();
$causes = array();
$this->getCauseMessage($causes);
$html = '<table style="border: 1px" cellspacing="0">' . "\n";
foreach ($causes as $i => $cause) {
$html .= '<tr><td colspan="3" style="background: #ff9999">'
. str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: '
. htmlspecialchars($cause['message'])
. ' in <b>' . $cause['file'] . '</b> '
. 'on line <b>' . $cause['line'] . '</b>'
. "</td></tr>\n";
}
$html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n"
. '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>'
. '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>'
. '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n";
foreach ($trace as $k => $v) {
$html .= '<tr><td style="text-align: center;">' . $k . '</td>'
. '<td>';
if (!empty($v['class'])) {
$html .= $v['class'] . $v['type'];
}
$html .= $v['function'];
$args = array();
if (!empty($v['args'])) {
foreach ($v['args'] as $arg) {
if (is_null($arg)) {
$args[] = 'null';
} else if (is_array($arg)) {
$args[] = 'Array';
} else if (is_object($arg)) {
$args[] = 'Object('.get_class($arg).')';
} else if (is_bool($arg)) {
$args[] = $arg ? 'true' : 'false';
} else if (is_int($arg) || is_double($arg)) {
$args[] = $arg;
} else {
$arg = (string)$arg;
$str = htmlspecialchars(substr($arg, 0, 16));
if (strlen($arg) > 16) {
$str .= '&hellip;';
}
$args[] = "'" . $str . "'";
}
}
}
$html .= '(' . implode(', ', $args) . ')'
. '</td>'
. '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
. ':' . (isset($v['line']) ? $v['line'] : 'unknown')
. '</td></tr>' . "\n";
}
$html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>'
. '<td>{main}</td>'
. '<td>&nbsp;</td></tr>' . "\n"
. '</table>';
return $html;
}
/**
* Generates text representation of the exception and stack trace
*
* @return string
*/
public function toText()
{
$causes = array();
$this->getCauseMessage($causes);
$causeMsg = '';
foreach ($causes as $i => $cause) {
$causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': '
. $cause['message'] . ' in ' . $cause['file']
. ' on line ' . $cause['line'] . "\n";
}
return $causeMsg . $this->getTraceAsString();
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2021 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2021 Webkul IN
* @license https://store.webkul.com/license.html
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

Some files were not shown because too many files have changed in this diff Show More