From: <be...@us...> - 2012-03-12 12:55:50
|
Revision: 9122 http://xoops.svn.sourceforge.net/xoops/?rev=9122&view=rev Author: beckmi Date: 2012-03-12 12:55:37 +0000 (Mon, 12 Mar 2012) Log Message: ----------- Adding FirePHP Debug package Added Paths: ----------- ThirdParty/firephp/ ThirdParty/firephp/branches/ ThirdParty/firephp/releases/ ThirdParty/firephp/releases/1.7/ ThirdParty/firephp/trunk/ ThirdParty/firephp/trunk/firephp/ ThirdParty/firephp/trunk/firephp/class/ ThirdParty/firephp/trunk/firephp/class/logger/ ThirdParty/firephp/trunk/firephp/class/logger/firephp/ ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/ ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/FirePHP.class.php ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/LICENSE ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/english.php ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/fb.php ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/german.php ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/index.html ThirdParty/firephp/trunk/firephp/class/logger/firephp/logger.php ThirdParty/firephp/trunk/firephp/class/logger/legacy/ ThirdParty/firephp/trunk/firephp/class/logger/legacy/index.html ThirdParty/firephp/trunk/firephp/class/logger/legacy/logger.php ThirdParty/firephp/trunk/firephp/class/logger/legacy/render.php ThirdParty/firephp/trunk/firephp/class/logger/xoopslogger.php ThirdParty/firephp/trunk/firephp/class/smarty/ ThirdParty/firephp/trunk/firephp/class/smarty/internals/ ThirdParty/firephp/trunk/firephp/class/smarty/internals/core.display_debug_console.php ThirdParty/firephp/trunk/firephp/class/template.php ThirdParty/firephp/trunk/firephp/xoops_data/ ThirdParty/firephp/trunk/firephp/xoops_data/configs/ ThirdParty/firephp/trunk/firephp/xoops_data/configs/index.html ThirdParty/firephp/trunk/firephp/xoops_data/configs/xoopsconfig.php Added: ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/FirePHP.class.php =================================================================== --- ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/FirePHP.class.php (rev 0) +++ ThirdParty/firephp/trunk/firephp/class/logger/firephp/FirePHPCore/FirePHP.class.php 2012-03-12 12:55:37 UTC (rev 9122) @@ -0,0 +1,1828 @@ +<?php +// Authors: +// - cadorn, Christoph Dorn <chr...@ch...>, Copyright 2007, New BSD License +// - qbbr, Sokolov Innokenty <sok...@gm...>, Copyright 2011, New BSD License +// - cadorn, Christoph Dorn <chr...@ch...>, Copyright 2011, MIT License + +/** + * *** BEGIN LICENSE BLOCK ***** + * + * [MIT License](http://www.opensource.org/licenses/mit-license.php) + * + * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) + * + * 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. + * + * ***** END LICENSE BLOCK ***** + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn <chr...@ch...> + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ + +/** + * @see http://code.google.com/p/firephp/issues/detail?id=112 + */ +if (!defined('E_STRICT')) { + define('E_STRICT', 2048); +} +if (!defined('E_RECOVERABLE_ERROR')) { + define('E_RECOVERABLE_ERROR', 4096); +} +if (!defined('E_DEPRECATED')) { + define('E_DEPRECATED', 8192); +} +if (!defined('E_USER_DEPRECATED')) { + define('E_USER_DEPRECATED', 16384); +} + +/** + * Sends the given data to the FirePHP Firefox Extension. + * The data can be displayed in the Firebug Console or in the + * "Server" request tab. + * + * For more information see: http://www.firephp.org/ + * + * @copyright Copyright (C) 2007+ Christoph Dorn + * @author Christoph Dorn <chr...@ch...> + * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) + * @package FirePHPCore + */ +class FirePHP { + + /** + * FirePHP version + * + * @var string + */ + const VERSION = '1.0b1rc1'; + + /** + * Firebug LOG level + * + * Logs a message to firebug console. + * + * @var string + */ + const LOG = 'LOG'; + + /** + * Firebug INFO level + * + * Logs a message to firebug console and displays an info icon before the message. + * + * @var string + */ + const INFO = 'INFO'; + + /** + * Firebug WARN level + * + * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. + * + * @var string + */ + const WARN = 'WARN'; + + /** + * Firebug ERROR level + * + * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. + * + * @var string + */ + const ERROR = 'ERROR'; + + /** + * Dumps a variable to firebug's server panel + * + * @var string + */ + const DUMP = 'DUMP'; + + /** + * Displays a stack trace in firebug console + * + * @var string + */ + const TRACE = 'TRACE'; + + /** + * Displays an exception in firebug console + * + * Increments the firebug error count. + * + * @var string + */ + const EXCEPTION = 'EXCEPTION'; + + /** + * Displays an table in firebug console + * + * @var string + */ + const TABLE = 'TABLE'; + + /** + * Starts a group in firebug console + * + * @var string + */ + const GROUP_START = 'GROUP_START'; + + /** + * Ends a group in firebug console + * + * @var string + */ + const GROUP_END = 'GROUP_END'; + + /** + * Singleton instance of FirePHP + * + * @var FirePHP + */ + protected static $instance = null; + + /** + * Flag whether we are logging from within the exception handler + * + * @var boolean + */ + protected $inExceptionHandler = false; + + /** + * Flag whether to throw PHP errors that have been converted to ErrorExceptions + * + * @var boolean + */ + protected $throwErrorExceptions = true; + + /** + * Flag whether to convert PHP assertion errors to Exceptions + * + * @var boolean + */ + protected $convertAssertionErrorsToExceptions = true; + + /** + * Flag whether to throw PHP assertion errors that have been converted to Exceptions + * + * @var boolean + */ + protected $throwAssertionExceptions = false; + + /** + * Wildfire protocol message index + * + * @var integer + */ + protected $messageIndex = 1; + + /** + * Options for the library + * + * @var array + */ + protected $options = array('maxDepth' => 10, + 'maxObjectDepth' => 5, + 'maxArrayDepth' => 5, + 'useNativeJsonEncode' => true, + 'includeLineNumbers' => true); + + /** + * Filters used to exclude object members when encoding + * + * @var array + */ + protected $objectFilters = array( + 'firephp' => array('objectStack', 'instance', 'json_objectStack'), + 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack') + ); + + /** + * A stack of objects used to detect recursion during object encoding + * + * @var object + */ + protected $objectStack = array(); + + /** + * Flag to enable/disable logging + * + * @var boolean + */ + protected $enabled = true; + + /** + * The insight console to log to if applicable + * + * @var object + */ + protected $logToInsightConsole = null; + + /** + * When the object gets serialized only include specific object members. + * + * @return array + */ + public function __sleep() + { + return array('options', 'objectFilters', 'enabled'); + } + + /** + * Gets singleton instance of FirePHP + * + * @param boolean $autoCreate + * @return FirePHP + */ + public static function getInstance($autoCreate = false) + { + if ($autoCreate === true && !self::$instance) { + self::init(); + } + return self::$instance; + } + + /** + * Creates FirePHP object and stores it for singleton access + * + * @return FirePHP + */ + public static function init() + { + return self::setInstance(new self()); + } + + /** + * Set the instance of the FirePHP singleton + * + * @param FirePHP $instance The FirePHP object instance + * @return FirePHP + */ + public static function setInstance($instance) + { + return self::$instance = $instance; + } + + /** + * Set an Insight console to direct all logging calls to + * + * @param object $console The console object to log to + * @return void + */ + public function setLogToInsightConsole($console) + { + if (is_string($console)) { + if (get_class($this) != 'FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { + throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); + } + $this->logToInsightConsole = $this->to('request')->console($console); + } else { + $this->logToInsightConsole = $console; + } + } + + /** + * Enable and disable logging to Firebug + * + * @param boolean $enabled TRUE to enable, FALSE to disable + * @return void + */ + public function setEnabled($enabled) + { + $this->enabled = $enabled; + } + + /** + * Check if logging is enabled + * + * @return boolean TRUE if enabled + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * Specify a filter to be used when encoding an object + * + * Filters are used to exclude object members. + * + * @param string $class The class name of the object + * @param array $filter An array of members to exclude + * @return void + */ + public function setObjectFilter($class, $filter) + { + $this->objectFilters[strtolower($class)] = $filter; + } + + /** + * Set some options for the library + * + * Options: + * - maxDepth: The maximum depth to traverse (default: 10) + * - maxObjectDepth: The maximum depth to traverse objects (default: 5) + * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) + * - useNativeJsonEncode: If true will use json_encode() (default: true) + * - includeLineNumbers: If true will include line numbers and filenames (default: true) + * + * @param array $options The options to be set + * @return void + */ + public function setOptions($options) + { + $this->options = array_merge($this->options, $options); + } + + /** + * Get options from the library + * + * @return array The currently set options + */ + public function getOptions() + { + return $this->options; + } + + /** + * Set an option for the library + * + * @param string $name + * @param mixed $value + * @return void + * @throws Exception + */ + public function setOption($name, $value) + { + if (!isset($this->options[$name])) { + throw $this->newException('Unknown option: ' . $name); + } + $this->options[$name] = $value; + } + + /** + * Get an option from the library + * + * @param string $name + * @return mixed + * @throws Exception + */ + public function getOption($name) + { + if (!isset($this->options[$name])) { + throw $this->newException('Unknown option: ' . $name); + } + return $this->options[$name]; + } + + /** + * Register FirePHP as your error handler + * + * Will throw exceptions for each php error. + * + * @return mixed Returns a string containing the previously defined error handler (if any) + */ + public function registerErrorHandler($throwErrorExceptions = false) + { + //NOTE: The following errors will not be caught by this error handler: + // E_ERROR, E_PARSE, E_CORE_ERROR, + // E_CORE_WARNING, E_COMPILE_ERROR, + // E_COMPILE_WARNING, E_STRICT + + $this->throwErrorExceptions = $throwErrorExceptions; + + return set_error_handler(array($this, 'errorHandler')); + } + + /** + * FirePHP's error handler + * + * Throws exception for each php error that will occur. + * + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + * @param array $errcontext + */ + public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) + { + // Don't throw exception if error reporting is switched off + if (error_reporting() == 0) { + return; + } + // Only throw exceptions for errors we are asking for + if (error_reporting() & $errno) { + + $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); + if ($this->throwErrorExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + } + } + + /** + * Register FirePHP as your exception handler + * + * @return mixed Returns the name of the previously defined exception handler, + * or NULL on error. + * If no previous handler was defined, NULL is also returned. + */ + public function registerExceptionHandler() + { + return set_exception_handler(array($this, 'exceptionHandler')); + } + + /** + * FirePHP's exception handler + * + * Logs all exceptions to your firebug console and then stops the script. + * + * @param Exception $exception + * @throws Exception + */ + function exceptionHandler($exception) + { + $this->inExceptionHandler = true; + + header('HTTP/1.1 500 Internal Server Error'); + + try { + $this->fb($exception); + } catch (Exception $e) { + echo 'We had an exception: ' . $e; + } + + $this->inExceptionHandler = false; + } + + /** + * Register FirePHP driver as your assert callback + * + * @param boolean $convertAssertionErrorsToExceptions + * @param boolean $throwAssertionExceptions + * @return mixed Returns the original setting or FALSE on errors + */ + public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) + { + $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; + $this->throwAssertionExceptions = $throwAssertionExceptions; + + if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { + throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); + } + + return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); + } + + /** + * FirePHP's assertion handler + * + * Logs all assertions to your firebug console and then stops the script. + * + * @param string $file File source of assertion + * @param integer $line Line source of assertion + * @param mixed $code Assertion code + */ + public function assertionHandler($file, $line, $code) + { + if ($this->convertAssertionErrorsToExceptions) { + + $exception = new ErrorException('Assertion Failed - Code[ ' . $code . ' ]', 0, null, $file, $line); + + if ($this->throwAssertionExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + + } else { + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File' => $file, 'Line' => $line)); + } + } + + /** + * Start a group for following messages. + * + * Options: + * Collapsed: [true|false] + * Color: [#RRGGBB|ColorName] + * + * @param string $name + * @param array $options OPTIONAL Instructions on how to log the group + * @return true + * @throws Exception + */ + public function group($name, $options = null) + { + + if (!$name) { + throw $this->newException('You must specify a label for the group!'); + } + + if ($options) { + if (!is_array($options)) { + throw $this->newException('Options must be defined as an array!'); + } + if (array_key_exists('Collapsed', $options)) { + $options['Collapsed'] = ($options['Collapsed']) ? 'true' : 'false'; + } + } + + return $this->fb(null, $name, FirePHP::GROUP_START, $options); + } + + /** + * Ends a group you have started before + * + * @return true + * @throws Exception + */ + public function groupEnd() + { + return $this->fb(null, null, FirePHP::GROUP_END); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::LOG + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function log($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::LOG, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::INFO + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function info($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::INFO, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::WARN + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function warn($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::WARN, $options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::ERROR + * @param mixes $object + * @param string $label + * @return true + * @throws Exception + */ + public function error($object, $label = null, $options = array()) + { + return $this->fb($object, $label, FirePHP::ERROR, $options); + } + + /** + * Dumps key and variable to firebug server panel + * + * @see FirePHP::DUMP + * @param string $key + * @param mixed $variable + * @return true + * @throws Exception + */ + public function dump($key, $variable, $options = array()) + { + if (!is_string($key)) { + throw $this->newException('Key passed to dump() is not a string'); + } + if (strlen($key) > 100) { + throw $this->newException('Key passed to dump() is longer than 100 characters'); + } + if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $key, $m)) { + throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); + } + return $this->fb($variable, $key, FirePHP::DUMP, $options); + } + + /** + * Log a trace in the firebug console + * + * @see FirePHP::TRACE + * @param string $label + * @return true + * @throws Exception + */ + public function trace($label) + { + return $this->fb($label, FirePHP::TRACE); + } + + /** + * Log a table in the firebug console + * + * @see FirePHP::TABLE + * @param string $label + * @param string $table + * @return true + * @throws Exception + */ + public function table($label, $table, $options = array()) + { + return $this->fb($table, $label, FirePHP::TABLE, $options); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::to() + */ + public static function to() + { + $instance = self::getInstance(); + if (!method_exists($instance, '_to')) { + throw new Exception('FirePHP::to() implementation not loaded'); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_to'), $args); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::plugin() + */ + public static function plugin() + { + $instance = self::getInstance(); + if (!method_exists($instance, '_plugin')) { + throw new Exception('FirePHP::plugin() implementation not loaded'); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_plugin'), $args); + } + + /** + * Check if FirePHP is installed on client + * + * @return boolean + */ + public function detectClientExtension() + { + // Check if FirePHP is installed on client via User-Agent header + if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si', $this->getUserAgent(), $m) && + version_compare($m[1][0], '0.0.6', '>=')) { + return true; + } else + // Check if FirePHP is installed on client via X-FirePHP-Version header + if (@preg_match_all('/^([\.\d]*)$/si', $this->getRequestHeader('X-FirePHP-Version'), $m) && + version_compare($m[1][0], '0.0.6', '>=')) { + return true; + } + return false; + } + + /** + * Log varible to Firebug + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $object The variable to be logged + * @return boolean Return TRUE if message was added to headers, FALSE otherwise + * @throws Exception + */ + public function fb($object) + { + if ($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) { + if (!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message + $this->_logUpgradeClientMessage(); + } + } + + static $insightGroupStack = array(); + + if (!$this->getEnabled()) { + return false; + } + + if ($this->headersSent($filename, $linenum)) { + // If we are logging from within the exception handler we cannot throw another exception + if ($this->inExceptionHandler) { + // Simply echo the error out to the page + echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>' . $filename . '</b> on line <b>' . $linenum . '</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; + } else { + throw $this->newException('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); + } + } + + $type = null; + $label = null; + $options = array(); + + if (func_num_args() == 1) { + } else if (func_num_args() == 2) { + switch (func_get_arg(1)) { + case self::LOG: + case self::INFO: + case self::WARN: + case self::ERROR: + case self::DUMP: + case self::TRACE: + case self::EXCEPTION: + case self::TABLE: + case self::GROUP_START: + case self::GROUP_END: + $type = func_get_arg(1); + break; + default: + $label = func_get_arg(1); + break; + } + } else if (func_num_args() == 3) { + $type = func_get_arg(2); + $label = func_get_arg(1); + } else if (func_num_args() == 4) { + $type = func_get_arg(2); + $label = func_get_arg(1); + $options = func_get_arg(3); + } else { + throw $this->newException('Wrong number of arguments to fb() function!'); + } + + if ($this->logToInsightConsole !== null && (get_class($this) == 'FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) { + $trace = debug_backtrace(); + if (!$trace) return false; + for ($i = 0; $i < sizeof($trace); $i++) { + if (isset($trace[$i]['class'])) { + if ($trace[$i]['class'] == 'FirePHP' || $trace[$i]['class'] == 'FB') { + continue; + } + } + if (isset($trace[$i]['file'])) { + $path = $this->_standardizePath($trace[$i]['file']); + if (substr($path, -18, 18) == 'FirePHPCore/fb.php' || substr($path, -29, 29) == 'FirePHPCore/FirePHP.class.php') { + continue; + } + } + if (isset($trace[$i]['function']) && $trace[$i]['function'] == 'fb' && + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + continue; + } + if (isset($trace[$i]['class']) && $trace[$i]['class'] == 'FB' && + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + continue; + } + break; + } + // adjust trace offset + $msg = $this->logToInsightConsole->option('encoder.trace.offsetAdjustment', $i); + + if ($object instanceof Exception) { + $type = self::EXCEPTION; + } + if ($label && $type != self::TABLE && $type != self::GROUP_START) { + $msg = $msg->label($label); + } + switch ($type) { + case self::DUMP: + case self::LOG: + return $msg->log($object); + case self::INFO: + return $msg->info($object); + case self::WARN: + return $msg->warn($object); + case self::ERROR: + return $msg->error($object); + case self::TRACE: + return $msg->trace($object); + case self::EXCEPTION: + return $this->plugin('error')->handleException($object, $msg); + case self::TABLE: + if (isset($object[0]) && !is_string($object[0]) && $label) { + $object = array($label, $object); + } + return $msg->table($object[0], array_slice($object[1], 1), $object[1][0]); + case self::GROUP_START: + $insightGroupStack[] = $msg->group(md5($label))->open(); + return $msg->log($label); + case self::GROUP_END: + if (count($insightGroupStack) == 0) { + throw new Error('Too many groupEnd() as opposed to group() calls!'); + } + $group = array_pop($insightGroupStack); + return $group->close(); + default: + return $msg->log($object); + } + } + + if (!$this->detectClientExtension()) { + return false; + } + + $meta = array(); + $skipFinalObjectEncode = false; + + if ($object instanceof Exception) { + + $meta['file'] = $this->_escapeTraceFile($object->getFile()); + $meta['line'] = $object->getLine(); + + $trace = $object->getTrace(); + if ($object instanceof ErrorException + && isset($trace[0]['function']) + && $trace[0]['function'] == 'errorHandler' + && isset($trace[0]['class']) + && $trace[0]['class'] == 'FirePHP') { + + $severity = false; + switch ($object->getSeverity()) { + case E_WARNING: + $severity = 'E_WARNING'; + break; + + case E_NOTICE: + $severity = 'E_NOTICE'; + break; + + case E_USER_ERROR: + $severity = 'E_USER_ERROR'; + break; + + case E_USER_WARNING: + $severity = 'E_USER_WARNING'; + break; + + case E_USER_NOTICE: + $severity = 'E_USER_NOTICE'; + break; + + case E_STRICT: + $severity = 'E_STRICT'; + break; + + case E_RECOVERABLE_ERROR: + $severity = 'E_RECOVERABLE_ERROR'; + break; + + case E_DEPRECATED: + $severity = 'E_DEPRECATED'; + break; + + case E_USER_DEPRECATED: + $severity = 'E_USER_DEPRECATED'; + break; + } + + $object = array('Class' => get_class($object), + 'Message' => $severity . ': ' . $object->getMessage(), + 'File' => $this->_escapeTraceFile($object->getFile()), + 'Line' => $object->getLine(), + 'Type' => 'trigger', + 'Trace' => $this->_escapeTrace(array_splice($trace, 2))); + $skipFinalObjectEncode = true; + } else { + $object = array('Class' => get_class($object), + 'Message' => $object->getMessage(), + 'File' => $this->_escapeTraceFile($object->getFile()), + 'Line' => $object->getLine(), + 'Type' => 'throw', + 'Trace' => $this->_escapeTrace($trace)); + $skipFinalObjectEncode = true; + } + $type = self::EXCEPTION; + + } else if ($type == self::TRACE) { + + $trace = debug_backtrace(); + if (!$trace) return false; + for ($i = 0; $i < sizeof($trace); $i++) { + + if (isset($trace[$i]['class']) + && isset($trace[$i]['file']) + && ($trace[$i]['class'] == 'FirePHP' + || $trace[$i]['class'] == 'FB') + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i+1]['file']) + && $trace[$i]['class'] == 'FirePHP' + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if ($trace[$i]['function'] == 'fb' + || $trace[$i]['function'] == 'trace' + || $trace[$i]['function'] == 'send') { + + $object = array('Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '', + 'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '', + 'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '', + 'Message' => $trace[$i]['args'][0], + 'File' => isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '', + 'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '', + 'Args' => isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '', + 'Trace' => $this->_escapeTrace(array_splice($trace, $i + 1))); + + $skipFinalObjectEncode = true; + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; + break; + } + } + + } else + if ($type == self::TABLE) { + + if (isset($object[0]) && is_string($object[0])) { + $object[1] = $this->encodeTable($object[1]); + } else { + $object = $this->encodeTable($object); + } + + $skipFinalObjectEncode = true; + + } else if ($type == self::GROUP_START) { + + if (!$label) { + throw $this->newException('You must specify a label for the group!'); + } + + } else { + if ($type === null) { + $type = self::LOG; + } + } + + if ($this->options['includeLineNumbers']) { + if (!isset($meta['file']) || !isset($meta['line'])) { + + $trace = debug_backtrace(); + for ($i = 0; $trace && $i < sizeof($trace); $i++) { + + if (isset($trace[$i]['class']) + && isset($trace[$i]['file']) + && ($trace[$i]['class'] == 'FirePHP' + || $trace[$i]['class'] == 'FB') + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i + 1]['file']) + && $trace[$i]['class'] == 'FirePHP' + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if (isset($trace[$i]['file']) + && substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php') { + /* Skip FB::fb() */ + } else { + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; + break; + } + } + } + } else { + unset($meta['file']); + unset($meta['line']); + } + + $this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); + $this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . self::VERSION); + + $structureIndex = 1; + if ($type == self::DUMP) { + $structureIndex = 2; + $this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); + } else { + $this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); + } + + if ($type == self::DUMP) { + $msg = '{"' . $label . '":' . $this->jsonEncode($object, $skipFinalObjectEncode) . '}'; + } else { + $msgMeta = $options; + $msgMeta['Type'] = $type; + if ($label !== null) { + $msgMeta['Label'] = $label; + } + if (isset($meta['file']) && !isset($msgMeta['File'])) { + $msgMeta['File'] = $meta['file']; + } + if (isset($meta['line']) && !isset($msgMeta['Line'])) { + $msgMeta['Line'] = $meta['line']; + } + $msg = '[' . $this->jsonEncode($msgMeta) . ',' . $this->jsonEncode($object, $skipFinalObjectEncode) . ']'; + } + + $parts = explode("\n", chunk_split($msg, 5000, "\n")); + + for ($i = 0; $i < count($parts); $i++) { + + $part = $parts[$i]; + if ($part) { + + if (count($parts) > 2) { + // Message needs to be split into multiple parts + $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, + (($i == 0) ? strlen($msg) : '') + . '|' . $part . '|' + . (($i < count($parts) - 2) ? '\\' : '')); + } else { + $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, + strlen($part) . '|' . $part . '|'); + } + + $this->messageIndex++; + + if ($this->messageIndex > 99999) { + throw $this->newException('Maximum number (99,999) of messages reached!'); + } + } + } + + $this->setHeader('X-Wf-1-Index', $this->messageIndex - 1); + + return true; + } + + /** + * Standardizes path for windows systems. + * + * @param string $path + * @return string + */ + protected function _standardizePath($path) + { + return preg_replace('/\\\\+/', '/', $path); + } + + /** + * Escape trace path for windows systems + * + * @param array $trace + * @return array + */ + protected function _escapeTrace($trace) + { + if (!$trace) return $trace; + for ($i = 0; $i < sizeof($trace); $i++) { + if (isset($trace[$i]['file'])) { + $trace[$i]['file'] = $this->_escapeTraceFile($trace[$i]['file']); + } + if (isset($trace[$i]['args'])) { + $trace[$i]['args'] = $this->encodeObject($trace[$i]['args']); + } + } + return $trace; + } + + /** + * Escape file information of trace for windows systems + * + * @param string $file + * @return string + */ + protected function _escapeTraceFile($file) + { + /* Check if we have a windows filepath */ + if (strpos($file, '\\')) { + /* First strip down to single \ */ + + $file = preg_replace('/\\\\+/', '\\', $file); + + return $file; + } + return $file; + } + + /** + * Check if headers have already been sent + * + * @param string $filename + * @param integer $linenum + */ + protected function headersSent(&$filename, &$linenum) + { + return headers_sent($filename, $linenum); + } + + /** + * Send header + * + * @param string $name + * @param string $value + */ + protected function setHeader($name, $value) + { + return header($name . ': ' . $value); + } + + /** + * Get user agent + * + * @return string|false + */ + protected function getUserAgent() + { + if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; + return $_SERVER['HTTP_USER_AGENT']; + } + + /** + * Get all request headers + * + * @return array + */ + public static function getAllRequestHeaders() + { + static $_cachedHeaders = false; + if ($_cachedHeaders !== false) { + return $_cachedHeaders; + } + $headers = array(); + if (function_exists('getallheaders')) { + foreach (getallheaders() as $name => $value) { + $headers[strtolower($name)] = $value; + } + } else { + foreach ($_SERVER as $name => $value) { + if (substr($name, 0, 5) == 'HTTP_') { + $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; + } + } + } + return $_cachedHeaders = $headers; + } + + /** + * Get a request header + * + * @return string|false + */ + protected function getRequestHeader($name) + { + $headers = self::getAllRequestHeaders(); + if (isset($headers[strtolower($name)])) { + return $headers[strtolower($name)]; + } + return false; + } + + /** + * Returns a new exception + * + * @param string $message + * @return Exception + */ + protected function newException($message) + { + return new Exception($message); + } + + /** + * Encode an object into a JSON string + * + * Uses PHP's jeson_encode() if available + * + * @param object $object The object to be encoded + * @param boolean $skipObjectEncode + * @return string The JSON string + */ + public function jsonEncode($object, $skipObjectEncode = false) + { + if (!$skipObjectEncode) { + $object = $this->encodeObject($object); + } + + if (function_exists('json_encode') + && $this->options['useNativeJsonEncode'] != false) { + + return json_encode($object); + } else { + return $this->json_encode($object); + } + } + + /** + * Encodes a table by encoding each row and column with encodeObject() + * + * @param array $table The table to be encoded + * @return array + */ + protected function encodeTable($table) + { + if (!$table) return $table; + + $newTable = array(); + foreach ($table as $row) { + + if (is_array($row)) { + $newRow = array(); + + foreach ($row as $item) { + $newRow[] = $this->encodeObject($item); + } + + $newTable[] = $newRow; + } + } + + return $newTable; + } + + /** + * Encodes an object including members with + * protected and private visibility + * + * @param object $object The object to be encoded + * @param integer $Depth The current traversal depth + * @return array All members of the object + */ + protected function encodeObject($object, $objectDepth = 1, $arrayDepth = 1, $maxDepth = 1) + { + if ($maxDepth > $this->options['maxDepth']) { + return '** Max Depth (' . $this->options['maxDepth'] . ') **'; + } + + $return = array(); + + if (is_resource($object)) { + + return '** ' . (string) $object . ' **'; + + } else if (is_object($object)) { + + if ($objectDepth > $this->options['maxObjectDepth']) { + return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **'; + } + + foreach ($this->objectStack as $refVal) { + if ($refVal === $object) { + return '** Recursion (' . get_class($object) . ') **'; + } + } + array_push($this->objectStack, $object); + + $return['__className'] = $class = get_class($object); + $classLower = strtolower($class); + + $reflectionClass = new ReflectionClass($class); + $properties = array(); + foreach ($reflectionClass->getProperties() as $property) { + $properties[$property->getName()] = $property; + } + + $members = (array)$object; + + foreach ($properties as $plainName => $property) { + + $name = $rawName = $plainName; + if ($property->isStatic()) { + $name = 'static:' . $name; + } + if ($property->isPublic()) { + $name = 'public:' . $name; + } else if ($property->isPrivate()) { + $name = 'private:' . $name; + $rawName = "\0" . $class . "\0" . $rawName; + } else if ($property->isProtected()) { + $name = 'protected:' . $name; + $rawName = "\0" . '*' . "\0" . $rawName; + } + + if (!(isset($this->objectFilters[$classLower]) + && is_array($this->objectFilters[$classLower]) + && in_array($plainName, $this->objectFilters[$classLower]))) { + + if (array_key_exists($rawName, $members) && !$property->isStatic()) { + $return[$name] = $this->encodeObject($members[$rawName], $objectDepth + 1, 1, $maxDepth + 1); + } else { + if (method_exists($property, 'setAccessible')) { + $property->setAccessible(true); + $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); + } else + if ($property->isPublic()) { + $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); + } else { + $return[$name] = '** Need PHP 5.3 to get value **'; + } + } + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + + // Include all members that are not defined in the class + // but exist in the object + foreach ($members as $rawName => $value) { + + $name = $rawName; + + if ($name{0} == "\0") { + $parts = explode("\0", $name); + $name = $parts[2]; + } + + $plainName = $name; + + if (!isset($properties[$name])) { + $name = 'undeclared:' . $name; + + if (!(isset($this->objectFilters[$classLower]) + && is_array($this->objectFilters[$classLower]) + && in_array($plainName, $this->objectFilters[$classLower]))) { + + $return[$name] = $this->encodeObject($value, $objectDepth + 1, 1, $maxDepth + 1); + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + } + + array_pop($this->objectStack); + + } elseif (is_array($object)) { + + if ($arrayDepth > $this->options['maxArrayDepth']) { + return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **'; + } + + foreach ($object as $key => $val) { + + // Encoding the $GLOBALS PHP array causes an infinite loop + // if the recursion is not reset here as it contains + // a reference to itself. This is the only way I have come up + // with to stop infinite recursion in this case. + if ($key == 'GLOBALS' + && is_array($val) + && array_key_exists('GLOBALS', $val)) { + $val['GLOBALS'] = '** Recursion (GLOBALS) **'; + } + + if (!$this->is_utf8($key)) { + $key = utf8_encode($key); + } + + $return[$key] = $this->encodeObject($val, 1, $arrayDepth + 1, $maxDepth + 1); + } + } else { + if ($this->is_utf8($object)) { + return $object; + } else { + return utf8_encode($object); + } + } + return $return; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + protected function is_utf8($str) + { + if (function_exists('mb_detect_encoding')) { + return ( + mb_detect_encoding($str, 'UTF-8', true) == 'UTF-8' && + ($str === null || $this->jsonEncode($str, true) !== 'null') + ); + } + $c = 0; + $b = 0; + $bits = 0; + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $c = ord($str[$i]); + if ($c > 128) { + if (($c >= 254)) return false; + elseif ($c >= 252) $bits = 6; + elseif ($c >= 248) $bits = 5; + elseif ($c >= 240) $bits = 4; + elseif ($c >= 224) $bits = 3; + elseif ($c >= 192) $bits = 2; + else return false; + if (($i + $bits) > $len) return false; + while($bits > 1) { + $i++; + $b = ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bits--; + } + } + } + return ($str === null || $this->jsonEncode($str, true) !== 'null'); + } + + /** + * Converts to and from JSON format. + * + * JSON (JavaScript Object Notation) is a lightweight data-interchange + * format. It is easy for humans to read and write. It is easy for machines + * to parse and generate. It is based on a subset of the JavaScript + * Programming Language, Standard ECMA-262 3rd Edition - December 1999. + * This feature can also be found in Python. JSON is a text format that is + * completely language independent but uses conventions that are familiar + * to programmers of the C-family of languages, including C, C++, C#, Java, + * JavaScript, Perl, TCL, and many others. These properties make JSON an + * ideal data-interchange language. + * + * This package provides a simple encoder and decoder for JSON notation. It + * is intended for use with client-side Javascript applications that make + * use of HTTPRequest to perform server communication functions - data can + * be encoded into JSON notation for use in a client-side javascript, or + * decoded from incoming Javascript requests. JSON format is native to + * Javascript, and can be directly eval()'ed with no further parsing + * overhead + * + * All strings should be in ASCII or UTF-8 format! + * + * LICENSE: 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 ``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 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. + * + * @category + * @package Services_JSON + * @author Michal Migurski <mik...@te...> + * @author Matt Knapp <mdknapp[at]gmail[dot]com> + * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com> + * @author Christoph Dorn <chr...@ch...> + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + + + /** + * Keep a list of objects as we descend into the array so we can detect recursion. + */ + private $json_objectStack = array(); + + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + private function json_utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch (strlen($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + private function json_encode($var) + { + if (is_object($var)) { + if (in_array($var, $this->json_objectStack)) { + return '"** Recursion **"'; + } + } + + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = strlen($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\' . $var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_v... [truncated message content] |
From: <red...@us...> - 2012-06-22 21:28:06
|
Revision: 9688 http://xoops.svn.sourceforge.net/xoops/?rev=9688&view=rev Author: redheadedrod Date: 2012-06-22 21:28:00 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Added Paths: ----------- ThirdParty/mysqli/ ThirdParty/mysqli/README ThirdParty/mysqli/mysqlidatabase.php Added: ThirdParty/mysqli/README =================================================================== --- ThirdParty/mysqli/README (rev 0) +++ ThirdParty/mysqli/README 2012-06-22 21:28:00 UTC (rev 9688) @@ -0,0 +1,4 @@ +Put the mysqlidatabase.php file in your class/database folder +and change the XOOPS_DB_TYPE to mysqli. + +This database is NOT supported by the core team at this time. \ No newline at end of file Added: ThirdParty/mysqli/mysqlidatabase.php =================================================================== --- ThirdParty/mysqli/mysqlidatabase.php (rev 0) +++ ThirdParty/mysqli/mysqlidatabase.php 2012-06-22 21:28:00 UTC (rev 9688) @@ -0,0 +1,405 @@ +<?php +/** + * MySQL access + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @subpackage database + * @since 1.0.0 + * @author Kazumi Ono <on...@xo...> + * @author Rodney Fulk <red...@ho...> + * @version $Id: mysqlidatabase.php 8066 2012-06-22 05:09:33Z redheadedrod $ + */ +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * + * @package kernel + * @subpackage database + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + */ + +/** + * base class + */ +include_once XOOPS_ROOT_PATH . '/class/database/database.php'; +// xoops_load( 'xoopsdatabase' ); +/** + * connection to a mysql database + * + * @abstract + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + * @package kernel + * @subpackage database + */ +class XoopsMySQLiDatabase extends XoopsDatabase +{ + /** + * Database connection + * + * @var resource + */ + var $conn; + + /** + * connect to the database + * + * @param bool $selectdb select the database now? + * @return bool successful? + */ + function connect($selectdb = true) + { + static $db_charset_set; + if (!extension_loaded('mysqli')) { + trigger_error('notrace:mysqli extension not loaded', E_USER_ERROR); + return false; + } + + $this->allowWebChanges = ($_SERVER['REQUEST_METHOD'] != 'GET'); + + if (XOOPS_DB_PCONNECT == 1) { + $this->conn = @($GLOBALS["___mysqli_ston"] = mysqli_connect("p:".XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS)); + } else { + $this->conn = @($GLOBALS["___mysqli_ston"] = mysqli_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS)); + } + + if (!$this->conn) { + $this->logger->addQuery('', $this->error(), $this->errno()); + return false; + } + if ($selectdb != false) { + if (!((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . constant('XOOPS_DB_NAME')))) { + $this->logger->addQuery('', $this->error(), $this->errno()); + return false; + } + } + if (!isset($db_charset_set) && defined('XOOPS_DB_CHARSET') && XOOPS_DB_CHARSET) { + $this->queryF("SET NAMES '" . XOOPS_DB_CHARSET . "'"); + } + $db_charset_set = 1; + $this->queryF("SET SQL_BIG_SELECTS = 1"); + return true; + } + + /** + * generate an ID for a new row + * + * This is for compatibility only. Will always return 0, because MySQL supports + * autoincrement for primary keys. + * + * @param string $sequence name of the sequence from which to get the next ID + * @return int always 0, because mysql has support for autoincrement + */ + function genId($sequence) + { + return 0; // will use auto_increment + } + + /** + * Get a result row as an enumerated array + * + * @param resource $result + * @return array + */ + function fetchRow($result) + { + return @mysqli_fetch_row($result); + } + + /** + * Fetch a result row as an associative array + * + * @return array + */ + function fetchArray($result) + { + return @mysqli_fetch_assoc($result); + } + + /** + * Fetch a result row as an associative array + * + * @return array + */ + function fetchBoth($result) + { + return @mysqli_fetch_array($result, MYSQLI_BOTH); + } + + /** + * XoopsMySQLDatabase::fetchObjected() + * + * @param mixed $result + * @return + */ + function fetchObject($result) + { + return @mysqli_fetch_object($result); + } + + /** + * Get the ID generated from the previous INSERT operation + * + * @return int + */ + function getInsertId() + { + return ((is_null($___mysqli_res = mysqli_insert_id($this->conn))) ? false : $___mysqli_res); + } + + /** + * Get number of rows in result + * + * @param resource $ query result + * @return int + */ + function getRowsNum($result) + { + return @mysqli_num_rows($result); + } + + /** + * Get number of affected rows + * + * @return int + */ + function getAffectedRows() + { + return mysqli_affected_rows($this->conn); + } + + /** + * Close MySQL connection + */ + function close() + { + ((is_null($___mysqli_res = mysqli_close($this->conn))) ? false : $___mysqli_res); + } + + /** + * will free all memory associated with the result identifier result. + * + * @param resource $ query result + * @return bool TRUE on success or FALSE on failure. + */ + function freeRecordSet($result) + { + return ((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false); + } + + /** + * Returns the text of the error message from previous MySQL operation + * + * @return bool Returns the error text from the last MySQL function, or '' (the empty string) if no error occurred. + */ + function error() + { + return @((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)); + } + + /** + * Returns the numerical value of the error message from previous MySQL operation + * + * @return int Returns the error number from the last MySQL function, or 0 (zero) if no error occurred. + */ + function errno() + { + return @((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)); + } + + /** + * Returns escaped string text with single quotes around it to be safely stored in database + * + * @param string $str unescaped string text + * @return string escaped string text with single quotes around + */ + function quoteString($str) + { + return $this->quote($str); + } + + /** + * Quotes a string for use in a query. + */ + function quote($string) + { + return "'" . str_replace("\\\"", '"', str_replace("\\"", '"', mysqli_real_escape_string( $this->conn, $string))) . "'"; + } + + /** + * perform a query on the database + * + * @param string $sql a valid MySQL query + * @param int $limit number of records to return + * @param int $start offset of first record to return + * @return resource query result or FALSE if successful + * or TRUE if successful and no result + */ + function queryF($sql, $limit = 0, $start = 0) + { + if (!empty($limit)) { + if (empty($start)) { + $start = 0; + } + $sql = $sql . ' LIMIT ' . (int) $start . ', ' . (int) $limit; + } + $this->logger->startTime('query_time'); + $result = mysqli_query( $this->conn, $sql); + $this->logger->stopTime('query_time'); + $query_time = $this->logger->dumpTime('query_time', true); + if ($result) { + $this->logger->addQuery($sql, null, null, $query_time); + return $result; + } else { + $this->logger->addQuery($sql, $this->error(), $this->errno(), $query_time); + return false; + } + } + + /** + * perform a query + * + * This method is empty and does nothing! It should therefore only be + * used if nothing is exactly what you want done! ;-) + * + * @param string $sql a valid MySQL query + * @param int $limit number of records to return + * @param int $start offset of first record to return + * @abstract + */ + function query($sql, $limit = 0, $start = 0) + { + } + + /** + * perform queries from SQL dump file in a batch + * + * @param string $file file path to an SQL dump file + * @return bool FALSE if failed reading SQL file or TRUE if the file has been read and queries executed + */ + function queryFromFile($file) + { + if (false !== ($fp = fopen($file, 'r'))) { + include_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php'; + $sql_queries = trim(fread($fp, filesize($file))); + SqlUtility::splitMySqlFile($pieces, $sql_queries); + foreach ($pieces as $query) { + // [0] contains the prefixed query + // [4] contains unprefixed table name + $prefixed_query = SqlUtility::prefixQuery(trim($query), $this->prefix()); + if ($prefixed_query != false) { + $this->query($prefixed_query[0]); + } + } + return true; + } + return false; + } + + /** + * Get field name + * + * @param resource $result query result + * @param int $ numerical field index + * @return string + */ + function getFieldName($result, $offset) + { + return ((($___mysqli_tmp = mysqli_fetch_field_direct($result, 0)->name) && (!is_null($___mysqli_tmp))) ? $___mysqli_tmp : false); + } + + /** + * Get field type + * + * @param resource $result query result + * @param int $offset numerical field index + * @return string + */ + function getFieldType($result, $offset) + { + return ((is_object($___mysqli_tmp = mysqli_fetch_field_direct($result, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type)) ? ((($___mysqli_tmp = (string)(substr(( (($___mysqli_tmp == MYSQLI_TYPE_STRING) || ($___mysqli_tmp == MYSQLI_TYPE_VAR_STRING) ) ? "string " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24))) ? "int " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, ((defined("MYSQLI_TYPE_NEWDECIMAL")) ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)))) ? "real " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP) ? "timestamp " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_YEAR) ? "year " : "" ) . ( (($___mysqli_tmp == MYSQLI_TYPE_DATE) || ($___mysqli_tmp == MYSQLI_TYPE_NEWDATE) ) ? "date " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_TIME) ? "time " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_SET) ? "set " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_ENUM) ? "enum " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY) ? "geometry " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_DATETIME) ? "datetime " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB))) ? "blob " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_NULL) ? "null " : "" ), 0, -1))) == "") ? "unknown" : $___mysqli_tmp) : false); + } + + /** + * Get number of fields in result + * + * @param resource $result query result + * @return int + */ + function getFieldsNum($result) + { + return (($___mysqli_tmp = mysqli_num_fields($result)) ? $___mysqli_tmp : false); + } +} + +/** + * Safe Connection to a MySQL database. + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + * @package kernel + * @subpackage database + */ +class XoopsMySQLiDatabaseSafe extends XoopsMySQLiDatabase +{ + /** + * perform a query on the database + * + * @param string $sql a valid MySQL query + * @param int $limit number of records to return + * @param int $start offset of first record to return + * @return resource query result or FALSE if successful + * or TRUE if successful and no result + */ + function query($sql, $limit = 0, $start = 0) + { + return $this->queryF($sql, $limit, $start); + } +} + +/** + * Read-Only connection to a MySQL database. + * + * This class allows only SELECT queries to be performed through its + * {@link query()} method for security reasons. + * + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 XOOPS.org + * @package kernel + * @subpackage database + */ +class XoopsMySQLiDatabaseProxy extends XoopsMySQLiDatabase +{ + /** + * perform a query on the database + * + * this method allows only SELECT queries for safety. + * + * @param string $sql a valid MySQL query + * @param int $limit number of records to return + * @param int $start offset of first record to return + * @return resource query result or FALSE if unsuccessful + */ + function query($sql, $limit = 0, $start = 0) + { + $sql = ltrim($sql); + if (!$this->allowWebChanges && strtolower(substr($sql, 0, 6)) != 'select') { + trigger_error('Database updates are not allowed during processing of a GET request', E_USER_WARNING); + return false; + } + + return $this->queryF($sql, $limit, $start); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wis...@us...> - 2012-09-08 00:48:06
|
Revision: 10153 http://xoops.svn.sourceforge.net/xoops/?rev=10153&view=rev Author: wishcraft Date: 2012-09-08 00:47:59 +0000 (Sat, 08 Sep 2012) Log Message: ----------- XOOPS CRC - Symposium Replacement for MD5 only has collision for symaltyping reversible at length 12< Added Paths: ----------- ThirdParty/checksums/ ThirdParty/checksums/xoopscrc/ ThirdParty/checksums/xoopscrc/XOOPSCRC-Logo.png ThirdParty/checksums/xoopscrc/XOOPSCRC-background.png ThirdParty/checksums/xoopscrc/class/ ThirdParty/checksums/xoopscrc/class/xoops.crc.base.php ThirdParty/checksums/xoopscrc/class/xoops.crc.class.php ThirdParty/checksums/xoopscrc/class/xoops.crc.enumerator.php ThirdParty/checksums/xoopscrc/class/xoops.crc.leaver.php ThirdParty/checksums/xoopscrc/debug_base.php ThirdParty/checksums/xoopscrc/debug_enumerator.php ThirdParty/checksums/xoopscrc/debug_leaver.php ThirdParty/checksums/xoopscrc/index.php Added: ThirdParty/checksums/xoopscrc/XOOPSCRC-Logo.png =================================================================== (Binary files differ) Property changes on: ThirdParty/checksums/xoopscrc/XOOPSCRC-Logo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: ThirdParty/checksums/xoopscrc/XOOPSCRC-background.png =================================================================== (Binary files differ) Property changes on: ThirdParty/checksums/xoopscrc/XOOPSCRC-background.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: ThirdParty/checksums/xoopscrc/class/xoops.crc.base.php =================================================================== --- ThirdParty/checksums/xoopscrc/class/xoops.crc.base.php (rev 0) +++ ThirdParty/checksums/xoopscrc/class/xoops.crc.base.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,553 @@ +<?php +// $Id: xoops.crc.base.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // + +if (!class_exists('xoops_crc_base')) +{ + error_reporting(0); + + class xoops_crc_base extends xoops_crc + { + + var $base; + var $seed; + var $mode; + var $roll; + var $num_evr; + + function __construct ($seed = 127) + { + if ($seed<1) + { + $this->seed = 1; + } elseif ($seed>255) { + $this->seed = 256; + } else { + $this->seed = $seed; + } + $base = $this->_set_base(); + return $this->get_base(); + } + + private function _set_base() + { + + if ($this->seed < 65) + { + $case=true; + } else { + $case=false; + } + + $this->roll = ($this->seed / (3+(1/6))); + $this->num_evr = floor((34.32 / ($this->roll/$this->seed))/($this->seed*($this->roll/17.8))); + + if ($this->roll<16) + { + $this->mode = '1'; + } elseif ($this->roll >15 && $this->roll<32) { + $this->mode = '2'; + } elseif ($this->roll >32 && $this->roll<48) { + $this->mode = '3'; + } elseif ($this->roll >48 ) { + $this->mode = '4'; + } + + if ($this->num_evr==0) + { + $this->num_evr = floor((($this->seed/$this->mode)/($this->mode*3.015))); + } elseif ($this->num_evr>8) { + $this->num_evr = $this->num_evr - floor($this->mode*1.35); + } + + + + $this->base = array(); + switch ($this->mode){ + case 1: + $ii = 0; + $num = 0; + $letter = "a"; + for ($qcb=1;$qcb<32;$qcb++) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=64;$qcb>31;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + break; + case 2: + $ii = 0; + $num = 0; + $letter = "a"; + for ($qcb=32;$qcb>0;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=32;$qcb<65;$qcb++) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + break; + case 3: + $ii = 0; + $num = 0; + $letter = "a"; + for ($qcb=1;$qcb<17;$qcb++) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=64;$qcb>47;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=32;$qcb>16;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + + for ($qcb=32;$qcb<48;$qcb++) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + break; + case 4: + $ii = 0; + $num = 0; + $letter = "a"; + + for ($qcb=17;$qcb>0;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=17;$qcb<49;$qcb++) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + + for ($qcb=64;$qcb>48;$qcb--) + { + $ii++; + $done = false; + if ($sofar == $this->num_evr) + { + if ($num < 9) + { + $this->base[$qcb] = $num; + $num++; + $sofar = 0; + $done = true; + } + } else { + $sofar++; + } + + if ($done == false) + { + if (floor($qcb / ($this->roll/$this->num_evr))>$this->mode) + { + switch ($case) + { + case true: + $this->base[$qcb] = $letter; + break; + case false: + $this->base[$qcb] = strtoupper($letter); + break; + } + } else { + $this->base[$qcb] = $letter; + } + $letter++; + if (strlen($letter++)>1) { $letter="a"; } + } + } + break; + } + } + + function get_base() + { + return $this->base; + + } + + function debug_base() + { + $base = array(); + foreach ($this->base as $key => $data) + { + $base[$key] = array("char" => $data, + "ord" => ord($data), + "bin" => decbin(ord($data))); + } + + return array("mode" => $this->mode, "roll" => $this->roll, + "seed" => $this->seed, "mode" => $this->mode, + "num_evr" => $this->num_evr, "base" => $this->base, + "debug" => $base); + } + } +} + +?> \ No newline at end of file Added: ThirdParty/checksums/xoopscrc/class/xoops.crc.class.php =================================================================== --- ThirdParty/checksums/xoopscrc/class/xoops.crc.class.php (rev 0) +++ ThirdParty/checksums/xoopscrc/class/xoops.crc.class.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,75 @@ +<?php +// $Id: xoops.crc.class.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // + +if (!class_exists('xoops_crc')) +{ + + error_reporting(E_ERROR); + + class xoops_crc + { + var $base; + var $enum; + var $seed; + var $crc; + + function __construct($data, $seed, $len=29) + { + $this->seed = $seed; + $this->length = $len; + $this->base = new xoops_crc_base((int)$seed); + $this->enum = new xoops_crc_enumerator($this->base); + + if (!empty($data)) + { + for ($i=1; $i<strlen($data); $i++) + { + $enum_calc = $this->enum->enum_calc(substr($data,$i,1),$enum_calc); + } + $xoops_crc_crc = new xoops_crc_leaver($enum_calc, $this->base, $this->length); + $this->crc = $xoops_crc_crc->crc; + } + + } + + function calc($data) + { + for ($i=1; $i<strlen($data); $i++) + { + $enum_calc = $this->enum->enum_calc(substr($data,$i,1),$enum_calc); + } + $xoops_crc_crc = new xoops_crc_leaver($enum_calc, $this->base, $this->length); + return $xoops_crc_crc->crc; + } + } +} + +require ('xoops.crc.base.php'); +require ('xoops.crc.enumerator.php'); +require ('xoops.crc.leaver.php'); + + Added: ThirdParty/checksums/xoopscrc/class/xoops.crc.enumerator.php =================================================================== --- ThirdParty/checksums/xoopscrc/class/xoops.crc.enumerator.php (rev 0) +++ ThirdParty/checksums/xoopscrc/class/xoops.crc.enumerator.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,325 @@ +<?php +// $Id: xoops.crc.enumerator.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // + +if (!class_exists('xoops_crc_enumerator')) +{ + error_reporting(0); + + class xoops_crc_enumerator extends xoops_crc + { + + var $elekey; + var $base; + var $len; + + function __construct ($base, $len) + { + @$this->len = $len; + @$this->setElements($base); + } + + private function setElements($base) + { + @$this->base = $base; + @$this->elekey = array(); + + foreach ($base->base as $key => $data) + { + if (strlen((string)$data)==1) + { + if (strlen(bindec(ord($data)))==5) + { + $offset = array("ice" => (int)substr(decbin(ord($data)),5,1), + "icd" => (int)substr(decbin(ord($data)),4,1), + "icc" => (int)substr(decbin(ord($data)),3,1), + "icb" => (int)substr(decbin(ord($data)),2,1), + "ica" => (int)substr(decbin(ord($data)),1,1)); + if (substr(decbin(ord($data)),5,1)==1) + { + $offset['icf'] = 1; + } else { + $offset['icf'] = 0; + } + } elseif (strlen(decbin(ord($data)))==6) + { + $offset = array("icf" => (int)substr(decbin(ord($data)),6,1), + "ice" => (int)substr(decbin(ord($data)),5,1), + "icd" => (int)substr(decbin(ord($data)),4,1), + "icc" => (int)substr(decbin(ord($data)),3,1), + "icb" => (int)substr(decbin(ord($data)),2,1), + "ica" => (int)substr(decbin(ord($data)),1,1)); + } elseif (strlen(decbin(ord($data)))==7) + { + $offset = array("ica" => (int)substr(decbin(ord($data)),6,1), + "icb" => (int)substr(decbin(ord($data)),5,1), + "icc" => (int)substr(decbin(ord($data)),4,1), + "icd" => (int)substr(decbin(ord($data)),3,1), + "ice" => (int)substr(decbin(ord($data)),2,1), + "icf" => (int)substr(decbin(ord($data)),1,1)); + } + } else { + $offset = array("ica" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),6,1), + "icb" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),5,1), + "icc" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),4,1), + "icd" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),2,1), + "ice" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),1,1), + "icf" => (int)substr(decbin(ord(substr($key,strlen($key)-1,1))),0,1)); + + } + + if (strlen(decbin(ord($data)))==7) + { + if (strlen($data)==1) + { + $cycle = array("icf", "ice", "icd", "icc", "icb", "ica"); + foreach ($cycle as $element) + { + if ($done==false) + { + if ($offset[$element]=='0') + { + if ($prev_ele!='') + { + if ($offset[$prev_ele] == '1') + { + $offset[$prev_ele] = '0'; + } else { + $offset[$prev_ele] = '1'; + } + } + $offset[$element]= '1'; + $done=true; + } + } + } + + } else { + $cycle = array("ica", "icb", "icc", "icd", "ice", "icf"); + foreach ($cycle as $element) + { + if ($done==false) + { + if ($offset[$element]=='0') + { + if ($prev_ele!='') + { + if ($offset[$prev_ele] == '0') + { + $offset[$prev_ele] = '1'; + } else { + $offset[$prev_ele] = '0'; + } + } + $offset[$element]= '1'; + $done=true; + } + } + } + } + } + $done=false; + if (strlen($data)==1) + { + @$this->elekey[$key] = array("key" => $data, + "bin" => decbin(ord($data)), + "offset" => $offset, + "flip" => 0); + } else { + @$this->elekey[$key] = array("key" => $data, + "bin" => decbin(ord($data)), + "offset" => $offset, + "flip" => 1); + } + } + + } + + private function getBytePos($char) + { + return floor((ord($char)+1)/4); + } + + function enum_calc ($char, $enum_calc, $debug=false) + { + static $flip; + + foreach ($enum_calc as $key => $value) + { + ${$key} = $value; + } + + static $charnum; + $charnum++; + if ($charnum>3) + { + $charnum=1; + } + + $nx_key.= $char; + + if ($this->len>15) + { + if (strlen($nx_key)>$this->len) + { + $nx_key = substr($nx_key, strlen($nx_key)/($charnum+1), strlen($nx_key) - (strlen($nx_key)/($charnum+1))).substr($nx_key, 1, strlen($nx_key)-(strlen($nx_key) - (strlen($nx_key)/($charnum+1)))); + } + } else { + if (strlen($nx_key)>32) + { + $nx_key = substr($nx_key, strlen($nx_key)/($charnum+1), strlen($nx_key) - (strlen($nx_key)/($charnum+1))).substr($nx_key, 1, strlen($nx_key)-(strlen($nx_key) - (strlen($nx_key)/($charnum+1)))); + } + } + + if ($this->elekey[$this->getBytePos($char)]['flip']==0) + { + $ica = $this->elekey[$this->getBytePos($char)]['offset']['ica']; + $icb = $this->elekey[$this->getBytePos($char)]['offset']['icb']; + $icc = $this->elekey[$this->getBytePos($char)]['offset']['icc']; + $icd = $this->elekey[$this->getBytePos($char)]['offset']['icd']; + $ice = $this->elekey[$this->getBytePos($char)]['offset']['ice']; + $icf = $this->elekey[$this->getBytePos($char)]['offset']['icf']; + } else { + if ($charnum==1) + { + $icf = $this->elekey[$this->getBytePos($char)]['offset']['ica']; + $ice = $this->elekey[$this->getBytePos($char)]['offset']['icb']; + $icd = $this->elekey[$this->getBytePos($char)]['offset']['icc']; + $icc = $this->elekey[$this->getBytePos($char)]['offset']['icd']; + $icb = $this->elekey[$this->getBytePos($char)]['offset']['ice']; + $ica = $this->elekey[$this->getBytePos($char)]['offset']['icf']; + } elseif ($charnum==2) + { + $icf = $this->elekey[$this->getBytePos($char)]['offset']['ica']; + $ice = $this->elekey[$this->getBytePos($char)]['offset']['icb']; + $icd = $this->elekey[$this->getBytePos($char)]['offset']['icc']; + $icc = $this->elekey[$this->getBytePos($char)]['offset']['icf']; + $icb = $this->elekey[$this->getBytePos($char)]['offset']['ice']; + $ica = $this->elekey[$this->getBytePos($char)]['offset']['icd']; + } else + { + $icf = $this->elekey[$this->getBytePos($char)]['offset']['icc']; + $ice = $this->elekey[$this->getBytePos($char)]['offset']['icb']; + $icd = $this->elekey[$this->getBytePos($char)]['offset']['ica']; + $icc = $this->elekey[$this->getBytePos($char)]['offset']['icd']; + $icb = $this->elekey[$this->getBytePos($char)]['offset']['ice']; + $ica = $this->elekey[$this->getBytePos($char)]['offset']['icf']; + } + } + for ($icount=1; $icount<65; $icount++) + { + if ($this->elekey[$icount]['offset']['ica'] == $icb && $this->elekey[$icount]['offset']['icb'] == $icc && $this->elekey[$icount]['offset']['icc'] == $icd) { + $nuclear .= '10'; + if ($icb = $this->elekey[$icount]['flip']) { + $nuclear .= '1'; + } else { + $nuclear .= '0'; + } + if ($icc = $this->elekey[$icount]['flip']) { + $nuclear .= '1'; + } else { + $nuclear .= '0'; + } + if ($icd = $this->elekey[$icount]['flip']) { + $nuclear .= '0'; + } else { + $nuclear .= '1'; + } + } + + if ($this->elekey[$icount]['offset']['ica'] == $icc && $this->elekey[$icount]['offset']['icb'] == $icd && $this->elekey[$icount]['offset']['icc'] == $ice) { + $nuclear .= '01'; + if ($icb = $this->elekey[$icount]['flip']) { + $nuclear .= '0'; + } else { + $nuclear .= '1'; + } + if ($icc = $this->elekey[$icount]['flip']) { + $nuclear .= '1'; + } else { + $nuclear .= '0'; + } + if ($icd = $this->elekey[$icount]['flip']) { + $nuclear .= '1'; + } else { + $nuclear .= '0'; + } + } + } + + // Change in version 1.6.4 + if (strlen($nuclear)>32768) + $nuclear = substr($nuclear,strlen($nuclear)-32768,32768); + + $result = $result + $ica; + $prince = $prince + $icb; + $karma = $karma + $icc; + $motivation = $motivation + $icd; + $official = $official + $ice; + $outsidecause = $outsidecause + $icf; + + if ($ica == '0') {$yang = $yang + 1;} else {$yin = $yin + 1;} + if ($icb == '0') {$yang = yang + 1;} else {$yin = $yin + 1;} + if ($icc == '0') {$yang = $yang+ 1;} else {$yin = $yin + 1;} + if ($icd == '0') {$yang = $yang + 1;} else {$yin = $yin + 1;} + if ($ice == '0') {$yang = yang + 1;} else {$yin = $yin + 1;} + if ($icf == '0') {$yang = $yang+ 1;} else {$yin = $yin + 1;} + + if ($debug==true) + { + + $data[sizeof($data)+1] = array("pos" => $this->getBytePos($char), + "elements" => $this->elekey); + + $result = array("result" => $result, + "prince" => $prince, + "karma" => $karma, + "motivation" => $motivation, + "official" => $official, + "outsidecause" => $outsidecause, + "nuclear" => $nuclear, + "yin" => $yin, + "yang" => $yang, + "nx_key" => $nx_key, + "data"=> $data); + } else { + $result = array("result" => $result, + "prince" => $prince, + "karma" => $karma, + "motivation" => $motivation, + "official" => $official, + "outsidecause" => $outsidecause, + "nuclear" => $nuclear, + "yin" => $yin, + "yang" => $yang, + "nx_key" => $nx_key); + + } + + return $result; + } + } +} \ No newline at end of file Added: ThirdParty/checksums/xoopscrc/class/xoops.crc.leaver.php =================================================================== --- ThirdParty/checksums/xoopscrc/class/xoops.crc.leaver.php (rev 0) +++ ThirdParty/checksums/xoopscrc/class/xoops.crc.leaver.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,162 @@ +<?php +// $Id: xoops.crc.leaver.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // + +if (!class_exists('xoops_crc_leaver')) +{ + error_reporting(E_ERROR); + + class xoops_crc_leaver extends xoops_crc + { + var $crc; + + function __construct($enum_calc, $base, $len=29) + { + @$this->crc = $this->calc_crc($enum_calc, $base, $len); + } + + function calc_crc ($enum_calc, $base, $len) + { + for ($qi=0; $qi<$len+1; $qi++) + { + $da = floor(9*($qi/$len)); + $pos = $this->GetPosition($enum_calc, $len, $qi); + $pos = ceil($pos / ($len/ ($qi-1))); + for($v=-$qi;$v<$pos;$v++) + { + if ($c>64) + $c=0; + + $c++; + } + if (strlen($base->base[$c])>1) + { + $crc .= $da; + } else { + $crc .= $base->base[$c]; + } + + + if ($qi<ceil($len/3)) + { + $crc = $this->nux_cycle($crc, $enum_calc['result'], $len); + $crc = $this->nux_cycle($crc, $enum_calc['prince'], $len); + } elseif ($qi<(ceil($len/3)*2)) { + $crc = $this->nux_cycle($crc, $enum_calc['karma'], $len); + $crc = $this->nux_cycle($crc, $enum_calc['motivation'], $len); + } else { + $crc = $this->nux_cycle($crc, $enum_calc['official'], $len); + $crc = $this->nux_cycle($crc, $enum_calc['outsidecause'], $len); + } + + $crc = $this->nux_cycle($crc, $enum_calc['yang'], $len); + } + + $crc = $this->nux_cycle($crc, $enum_calc['yin'], $len); + + $crc = $this->nux_xor($crc, $enum_calc['nx_key']); + + for ($qi=0; $qi<$len+1; $qi++) + { + $da = $len-floor(9*($qi/$len)); + $pos = ceil(ord($crc{$qi}) / 4); + for($v=-$qi;$v<$pos;$v++) + { + if ($c>64) + $c=0; + + $c++; + } + if (strlen($base->base[$c])>1) + { + $final_crc .= $da; + } else { + $final_crc .= $base->base[$c]; + } + } + return $final_crc; + } + + private function GetPosition($enum_calc, $len, $qi) + { + if ($enum_calc['yin']>$enum_calc['yang']) + { + $cycle = floor((256*($enum_calc['yin']/$enum_calc['yang']))/(256*($enum_calc['yang']/$enum_calc['yin'])))+($len - $qi); + } else { + $cycle = ceil((256*($enum_calc['yang']/$enum_calc['yin']))/(256*($enum_calc['yin']/$enum_calc['yang'])))+($len - $qi); + } + + $result = $this->nuc_step($enum_calc['nuclear'], $enum_calc['result'], $cycle+$qi); + $prince = $this->nuc_step($enum_calc['nuclear'], $enum_calc['prince'], $cycle+$qi); + $karma = $this->nuc_step($enum_calc['nuclear'], $enum_calc['karma'], $cycle+$qi); + $motivation = $this->nuc_step($enum_calc['nuclear'], $enum_calc['motivation'], $cycle+$qi); + $official = $this->nuc_step($enum_calc['nuclear'], $enum_calc['official'], $cycle+$qi); + $outsidecause = $this->nuc_step($enum_calc['nuclear'], $enum_calc['outsidecause'], $cycle+$qi); + + $char = decbin($result.$prince.$karma.$motivation.$official.$outsidecause); + + return (ord($char)); + } + + private function nuc_step($nuclear, $var, $cycle) + { + $c=1; + for($v=0;$v<($var+$cycle);$v++) + { + if ($c>strlen($nuclear)) + $c=0; + + $c++; + } + return substr($nuclear,$c,1); + } + + private function nux_cycle($crc, $var, $len) + { + for($v=0;$v<($var+1);$v++) + { + for($y=1;$y<$len;$y++) + { + $crc = substr($crc, $y, $len - $y).substr($crc, 0, $len-($len - $y)); + } + } + return $crc; + } + + private function nux_xor($text_crc, $key) + { + for($i=0;$i<strlen($text_crc);) // Dont need to increment here + { + for($j=0;$j<strlen($key);$j++,$i++) + { + $crc .= $text_crc{$i} ^ $key{$j}; + } + } + return $crc; + } + + } +} \ No newline at end of file Added: ThirdParty/checksums/xoopscrc/debug_base.php =================================================================== --- ThirdParty/checksums/xoopscrc/debug_base.php (rev 0) +++ ThirdParty/checksums/xoopscrc/debug_base.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,103 @@ +<?php +// $Id: debug_base.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // +$mt=time()+microtime(); +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>XOOPSCRC Base Debug Test</title> +<style type="text/css"> +<!-- +body,td,th { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #006699; +} +body { + background-color: #FFFFCC; + background-image: url(XOOPSCRC-background.png); + background-repeat: repeat; + margin-left: 35px; + margin-top: 45px; + margin-right: 35px; + margin-bottom: 80px; +} +--> +</style></head> + +<body> +<div style="float:left; "><a style="border:hidden;" href="http://www.chronolabs.org.au/articles/Source-Code/XOOPSCRC-Variable-Checksum/"><img src="XOOPSCRC-Logo.png" /></a></div> + +<?php if (!isset($_POST['seed'])) { ?> +<form id="form1" name="form1" method="post" action=""> + <label>Seed (0-255) + <input name="seed" type="text" id="seed" value="128" size="5" maxlength="3" /> + </label> + <label> + <input type="submit" name="Submit" id="Submit" value="Submit" /> + </label> +</form> +<?php } ?> +<div style="clear:both"> </div> +<h2>Debug Examples:</h2> +<ol> + <li> + Test Enumerator (<a href="debug_enumerator.php">debug_enumerator.php</a>) + </li> + <li> + Test Leaver (<a href="debug_leaver.php">debug_leaver.php</a>)<br /> + + </li> + <li> + Index (<a href="index.php">index.php</a>) + </li> +</ol> + +<pre> + +<?php + if (isset($_POST['seed'])) + { + error_reporting(0); + class xoops_crc + { + + } + + require ('class/xoops.crc.base.php'); + + $obj_base = new xoops_crc_base((int)$_POST['seed']); + echo "Milliseconds: ".(abs((time()+microtime())-$mt)*1000)."\n"; + print_r($obj_base->debug_base()); + } +?> + +</pre> + +</body> +</html> Added: ThirdParty/checksums/xoopscrc/debug_enumerator.php =================================================================== --- ThirdParty/checksums/xoopscrc/debug_enumerator.php (rev 0) +++ ThirdParty/checksums/xoopscrc/debug_enumerator.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,114 @@ +<?php +// $Id: debug_enumerator.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // +$mt=time()+microtime(); +?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>XOOPSCRC Enumerator Debug Test</title> +<style type="text/css"> +<!-- +body,td,th { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #006699; +} +body { + background-color: #FFFFCC; + background-image: url(XOOPSCRC-background.png); + background-repeat: repeat; + margin-left: 35px; + margin-top: 45px; + margin-right: 35px; + margin-bottom: 80px; +} +--> +</style></head> + +<body> +<div style="float:left; "><a style="border:hidden;" href="http://www.chronolabs.org.au/articles/Source-Code/XOOPSCRC-Variable-Checksum/"><img src="XOOPSCRC-Logo.png" /></a></div> + +<?php if (!isset($_POST['charstring'])&&!isset($_POST['seed'])&&!isset($_POST['length'])) { ?> +<form id="form1" name="form1" method="post" action="" target="_blank"> + <label>Seed (0-255) + <input name="seed" type="text" id="seed" value="128" size="5" maxlength="3" /> + </label> + <label>Length + <input name="length" type="text" id="length" value="28" size="5" maxlength="3" /> + </label> + <label>Characters to test + <input name="charstring" type="text" id="charstring" value="" size="45" maxlength="2600" /> + </label> + <label> + <input type="submit" name="Submit" id="Submit" value="Submit" /> + </label> +</form> +<?php } ?> +<div style="clear:both"> </div> +<h2>Debug Examples:</h2> +<ol> + <li> + Test Base (<a href="debug_base.php">debug_base.php</a>) + </li> + <li> + Test Leaver (<a href="debug_leaver.php">debug_leaver.php</a>)<br /> + </li> + <li> + Index (<a href="index.php">index.php</a>) + </li> + +</ol> +<pre> + +<?php + if (isset($_POST['charstring'])&&isset($_POST['seed'])&&isset($_POST['length'])) + { + error_reporting(E_ERROR); + class xoops_crc + { + + } + + require ('class/xoops.crc.base.php'); + require ('class/xoops.crc.enumerator.php'); + + $xoops_crc_base = new xoops_crc_base((int)$_POST['seed']); + $enumerator = new xoops_crc_enumerator($xoops_crc_base, $_POST['length']); + + for ($i=1; $i<strlen($_POST['charstring']); $i++) + { + $enum_calc = $enumerator->enum_calc(substr($_POST['charstring'],$i,1),$enum_calc,true); + } + echo "Milliseconds: ".(abs((time()+microtime())-$mt)*1000)."\n"; + print_r($enum_calc); + } +?> + +</pre> + +</body> +</html> Added: ThirdParty/checksums/xoopscrc/debug_leaver.php =================================================================== --- ThirdParty/checksums/xoopscrc/debug_leaver.php (rev 0) +++ ThirdParty/checksums/xoopscrc/debug_leaver.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,118 @@ +<?php +// $Id: debug_leaver.php 1.1.0 - XOOPSCRC 2008-08-15 9:22:20 wishcraft $ +// ------------------------------------------------------------------------ // +// CLORA - Chronolabs Australia // +// Copyright (c) 2008 // +// <http://www.chronolabs.org.au/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the SDPL Source Directive Public Licence // +// as published by Chronolabs Australia; either version 2 of the License, // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Chronolab Australia // +// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia // +// ------------------------------------------------------------------------ // +$mt=time()+microtime(); +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>XOOPSCRC Leaver Debug</title> +<style type="text/css"> +<!-- +body,td,th { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #006699; +} +body { + background-color: #FFFFCC; + background-image: url(XOOPSCRC-background.png); + background-repeat: repeat; + margin-left: 35px; + margin-top: 45px; + margin-right: 35px; + margin-bottom: 80px; +} +--> +</style></head> + +<body> +<div style="float:left; "><a style="border:hidden;" href="http://www.chronolabs.org.au/articles/Source-Code/XOOPSCRC-Variable-Checksum/"><img src="XOOPSCRC-Logo.png" /></a></div> +<?php if (!isset($_POST['charstring'])&&!isset($_POST['seed'])&&!isset($_POST['length'])) { ?> +<form id="form1" name="form1" method="post" action="" target="_blank"> + <label>Seed (0-255) + <input name="seed" type="text" id="seed" value="128" size="5" maxlength="3" /> + </label> + <label>Length + <input name="length" type="text" id="length" value="28" size="5" maxlength="3" /> + </label> + <label>Characters to test + <input name="charstring" type="text" id="charstring" value="" size="15" maxlength="11" /> + </label> + <label> + <input type="submit" name="Submit" id="Submit" value="Submit" /> + </label> +</form> +<?php } ?> +<div style="clear:both"> </div> +<h2>Debug Examples:</h2> +<ol> + <li> + Test Base (<a href="debug_base.php">debug_base.php</a>) + </li> + <li> + Test Enumerator (<a href="debug_enumerator.php">debug_enumerator.php</a>) + </li> + <li> + Index (<a href="index.php">index.php</a>)<br /> + </li> +</ol> +<pre> + +<?php + if (isset($_POST['charstring'])&&isset($_POST['seed'])&&isset($_POST['length'])) + { + error_reporting(0); + class xoops_crc + { + + } + + require ('class/xoops.crc.base.php'); + require ('class/xoops.crc.enumerator.php'); + require ('class/xoops.crc.leaver.php'); + + $xoops_crc_base = new xoops_crc_base((int)$_POST['seed']); + $enumerator = new xoops_crc_enumerator($xoops_crc_base); + + for ($i=1; $i<strlen($_POST['charstring']); $i++) + { + $enum_calc = $enumerator->enum_calc(substr($_POST['charstring'],$i,1),$enum_calc); + } + + error_reporting(0); + + $crc = new xoops_crc_leaver($enum_calc, $xoops_crc_base, $_POST['length']); + echo "Milliseconds: ".(abs((time()+microtime())-$mt)*1000)."\n"; + print_r($crc); + } +?> + +</pre> + +</body> +</html> Added: ThirdParty/checksums/xoopscrc/index.php =================================================================== --- ThirdParty/checksums/xoopscrc/index.php (rev 0) +++ ThirdParty/checksums/xoopscrc/index.php 2012-09-08 00:47:59 UTC (rev 10153) @@ -0,0 +1,98 @@ +<?php +$mt=time()+microtime(); +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>XOOPSCRC Variable None Reversible Checksum</title> +<style type="text/css"> +<!-- +body,td,th { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #006699; +} +body { + background-color: #FFFFCC; + background-image: url(XOOPSCRC-background.png); + background-repeat: repeat; + margin-left: 35px; + margin-top: 45px; + margin-right: 35px; + margin-bottom: 80px; +} +--> +</style></head> + +<body> +<h1>Symposium Checksum with Complexity Divinations</h1> +<p>At lengths of 10 or less this forumula is good for passwords as it has collisions at low lengths meaning the result of the checksum can have multiple outcomes and be none reversed. At lengths of 28 characters or more there are no collisions!</p> +<?php if (!isset($_POST['charstring'])&&!isset($_POST['seed'])&&!isset($_POST['length'])) { ?> +<form id="form1" name="form1" method="post" action="" target="_blank"> + <label>Seed (0-255) + <input name="seed" type="text" id="seed" value="128" size="5" maxlength="3" /> + </label> + <label>Length + <input name="length" type="text" id="length" value="28" size="8" maxlength="7" /> + </label> + <label>Characters to test + <input name="charstring" type="text" id="charstring" value="" size="21" maxlength="32" /> + </label> + <label> + <input type="submit" name="Submit" id="Submit" value="Submit" /> + </label> + <label> + <input name="debug" type="checkbox" id="debug" value="1" /> + Show Debug</label> +</form> +<?php } ?> +<div style="clear:both"> </div> +<h2>Debug Examples:</h2> +<ol> + <li> + Test Base (<a href="debug_base.php">debug_base.php</a>) + </li> + <li> + Test Enumerator (<a href="debug_enumerator.php">debug_enumerator.php</a>) + </li> + <li> + Test Leaver (<a href="debug_leaver.php">debug_leaver.php</a>)<br /> + </li> + <li> + Index (<a href="index.php">index.php</a>) + </li> +</ol> + +<pre> + +<?php + if (isset($_POST['charstring'])&&isset($_POST['seed'])&&isset($_POST['length'])) + { + error_reporting(0); + require ('class/xoops.crc.class.php'); + set_time_limit(120); + $crc = new xoops_crc($_POST['charstring'], $_POST['seed'], $_POST['length']); + + echo "Seed: ".$crc->seed."\n"; + echo "Lenght: ".$crc->length."\n"; + echo "Milliseconds: ".(abs((time()+microtime())-$mt)*1000)."\n\n"; + echo "Data sha1: ".sha1($_POST['charstring'])."\n"; + echo "Data md5: ".md5($_POST['charstring'])."\n"; + echo "XOOPSCRC sha1: ".sha1($crc->crc)."\n"; + echo "XOOPSCRC md5: ".md5($crc->crc)."\n"; + + echo '</pre>'."\n\n".'<h2>XOOPSCRC Checksum</h2>'."\n".'<p> <textarea name="textarea" id="textarea" cols="120" rows="24">'.$crc->crc.'</textarea></p>'; + if ($_POST['debug']==1) + { + echo "<h3>Debug</h3><pre>"; + print_r($crc); + } + } +?> + +</pre> +<div style="float:right; clear:none;"><a style="border:hidden;" href="http://xoops.org"><img src="XOOPSCRC-Logo.png" /></a></div> + +</body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |