|
From: <du...@us...> - 2012-10-12 00:38:15
|
Revision: 10214
http://sourceforge.net/p/xoops/svn/10214
Author: dugris
Date: 2012-10-12 00:38:13 +0000 (Fri, 12 Oct 2012)
Log Message:
-----------
Read/Write config files in xoops_data/configs folder
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php
Property Changed:
----------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php 2012-10-12 00:32:32 UTC (rev 10213)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php 2012-10-12 00:38:13 UTC (rev 10214)
@@ -1,482 +1,537 @@
-<?php
-/*
- 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.
-*/
-
-/**
- * CAPTCHA configurations for Image mode
- *
- * Based on DuGris' SecurityImage
- *
- * @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 class
- * @subpackage captcha
- * @since 2.3.0
- * @author Taiwen Jiang <ph...@us...>
- * @version $Id$
- */
-
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-class XoopsCaptcha
-{
- /**
- * @var bool
- */
- public $active;
-
- /**
- * @var XoopsCaptchaMethod
- */
- public $handler;
-
- /**
- * @var string
- */
- public $path_basic;
-
- /**
- * @var string
- */
- public $path_plugin;
-
- /**
- * @var string
- */
- public $name;
-
- /**
- * @var array
- */
- public $config = array();
-
- /**
- * @var array
- */
- public $message = array();
-
- /**
- * construct
- */
- public function __construct()
- {
- $xoops = Xoops::getInstance();
- $xoops->loadLanguage('captcha');
- // Load static configurations
- $this->path_basic = XOOPS_ROOT_PATH . '/class/captcha';
- $this->path_plugin = XOOPS_ROOT_PATH . '/Frameworks/captcha';
- $this->config = $this->loadConfig();
- $this->name = $this->config['name'];
- }
-
- /**
- * Get Instance
- *
- * @return XoopsCaptcha
- */
- static function getInstance()
- {
- static $instance;
- if (!isset($instance)) {
- $class = __CLASS__;
- $instance = new $class();
- }
- return $instance;
- }
-
- /**
- * XoopsCaptcha::loadConfig()
- *
- * @param string $filename
- * @return array
- */
- public function loadConfig($filename = null)
- {
- $basic_config = array();
- $plugin_config = array();
- $filename = empty($filename) ? 'config.php' : 'config.' . $filename . '.php';
- if (file_exists($file = $this->path_basic . '/' . $filename)) {
- $basic_config = include $file;
- }
- if (file_exists($file = $this->path_plugin . '/' . $filename)) {
- $plugin_config = include $file;
- }
-
- $config = array_merge($basic_config, $plugin_config);
- foreach ($config as $key => $val) {
- $config[$key] = $val;
- }
- return $config;
- }
-
- /**
- * XoopsCaptcha::isActive()
- *
- * @return bool
- */
- public function isActive()
- {
- $xoops = Xoops::getInstance();
-
- if (isset($this->active)) {
- return $this->active;
- }
- if (!empty($this->config['disabled'])) {
- $this->active = false;
- return $this->active;
- }
- if (!empty($this->config['skipmember']) && $xoops->isUser()) {
- $this->active = false;
- return $this->active;
- }
- if (!isset($this->handler)) {
- $this->loadHandler();
- }
- $this->active = isset($this->handler);
- return $this->active;
- }
-
- /**
- * XoopsCaptcha::loadHandler()
- *
- * @param string $name
- * @return XoopsCatchaMethod
- */
- public function loadHandler($name = null)
- {
- $name = !empty($name) ? $name : (empty($this->config['mode']) ? 'text' : $this->config['mode']);
- $class = 'XoopsCaptcha' . ucfirst($name);
- if (!empty($this->handler) && get_class($this->handler) == $class) {
- return $this->handler;
- }
- $this->handler = null;
- if (file_exists($file = $this->path_basic . '/' . $name . '.php')) {
- require_once $file;
- } else {
- if (file_exists($file = $this->path_plugin . '/' . $name . '.php')) {
- require_once $file;
- }
- }
-
- if (!class_exists($class)) {
- $class = 'XoopsCaptchaText';
- require_once $this->path_basic . '/text.php';
- }
- /* @var $handler XoopsCaptchaMethod */
- $handler = new $class($this);
- if ($handler->isActive()) {
- $this->handler = $handler;
- $this->handler->loadConfig($name);
- }
- return $this->handler;
- }
-
- /**
- * XoopsCaptcha::setConfigs()
- *
- * @param mixed $configs
- * @return bool
- */
- public function setConfigs($configs)
- {
- foreach ($configs as $key => $val) {
- $this->setConfig($key, $val);
- }
- return true;
- }
-
- /**
- * XoopsCaptcha::setConfig()
- *
- * @param mixed $name
- * @param mixed $val
- * @return bool
- */
- public function setConfig($name, $val)
- {
- if (isset($this->$name)) {
- $this->$name = $val;
- } else {
- $this->config[$name] = $val;
- }
- return true;
- }
-
- /**
- * XoopsCaptcha::verify()
- *
- * Verify user submission
- *
- * @param bool $skipMember
- * @param string $name
- * @return bool
- */
- public function verify($skipMember = null, $name = null)
- {
- $xoops = Xoops::getInstance();
- $sessionName = empty($name) ? $this->name : $name;
- $skipMember = ($skipMember === null) ? $_SESSION["{$sessionName}_skipmember"] : $skipMember;
- $maxAttempts = $_SESSION["{$sessionName}_maxattempts"];
- $attempt = $_SESSION["{$sessionName}_attempt"];
- $is_valid = false;
- // Skip CAPTCHA verification if disabled
- if (!$this->isActive()) {
- $is_valid = true;
- // Skip CAPTCHA for member if set
- } else {
- if ($xoops->isUser() && !empty($skipMember)) {
- $is_valid = true;
- // Kill too many attempts
- } else {
- if (!empty($maxAttempts) && $attempt > $maxAttempts) {
- $this->message[] = _CAPTCHA_TOOMANYATTEMPTS;
- // Verify the code
- } else {
- $is_valid = $this->handler->verify($sessionName);
- }
- }
- }
-
- if (!$is_valid) {
- // Increase the attempt records on failure
- $_SESSION["{$sessionName}_attempt"]++;
- // Log the error message
- $this->message[] = _CAPTCHA_INVALID_CODE;
- } else {
- // reset attempt records on success
- $_SESSION["{$sessionName}_attempt"] = null;
- }
- $this->destroyGarbage(true);
- return $is_valid;
- }
-
- /**
- * XoopsCaptcha::getCaption()
- *
- * @return string
- */
- public function getCaption()
- {
- return defined('_CAPTCHA_CAPTION') ? constant('_CAPTCHA_CAPTION') : '';
- }
-
- /**
- * XoopsCaptcha::getMessage()
- *
- * @return sdtring
- */
- public function getMessage()
- {
- return implode('<br />', $this->message);
- }
-
- /**
- * Destory historical stuff
- *
- * @param bool $clearSession
- * @return bool
- */
- public function destroyGarbage($clearSession = false)
- {
- $this->loadHandler();
- $this->handler->destroyGarbage();
-
- if ($clearSession) {
- $_SESSION[$this->name . '_name'] = null;
- $_SESSION[$this->name . '_skipmember'] = null;
- $_SESSION[$this->name . '_code'] = null;
- $_SESSION[$this->name . '_maxattempts'] = null;
- }
-
- return true;
- }
-
- /**
- * XoopsCaptcha::render()
- *
- * @return string
- */
- public function render()
- {
- $_SESSION[$this->name . '_name'] = $this->name;
- $_SESSION[$this->name . '_skipmember'] = $this->config['skipmember'];
- $form = '';
- if (!$this->active || empty($this->config['name'])) {
- return $form;
- }
-
- $maxAttempts = $this->config['maxattempts'];
- $_SESSION[$this->name . '_maxattempts'] = $maxAttempts;
- $attempt = isset($_SESSION[$this->name . '_attempt']) ? $_SESSION[$this->name . '_attempt'] : 0;
- $_SESSION[$this->name . '_attempt'] = $attempt;
-
- // Failure on too many attempts
- if (!empty($maxAttempts) && $attempt > $maxAttempts) {
- $form = _CAPTCHA_TOOMANYATTEMPTS;
- // Load the form element
- } else {
- $form = $this->loadForm();
- }
- return $form;
- }
-
- /**
- * XoopsCaptcha::renderValidationJS()
- *
- * @return string
- */
- public function renderValidationJS()
- {
- if (!$this->active || empty($this->config['name'])) {
- return '';
- }
- return $this->handler->renderValidationJS();
- }
-
- /**
- * XoopsCaptcha::setCode()
- *
- * @param mixed $code
- * @return bool
- */
- public function setCode($code = null)
- {
- $code = ($code === null) ? $this->handler->getCode() : $code;
- if (!empty($code)) {
- $_SESSION[$this->name . '_code'] = $code;
- return true;
- }
- return false;
- }
-
- /**
- * XoopsCaptcha::loadForm()
- *
- * @return string
- */
- public function loadForm()
- {
- $form = $this->handler->render();
- $this->setCode();
- return $form;
- }
-}
-
-/**
- * Abstract class for CAPTCHA method
- *
- * Currently there are two types of CAPTCHA forms, text and image
- * The default mode is "text", it can be changed in the priority:
- * 1 If mode is set through XoopsFormCaptcha::setConfig("mode", $mode), take it
- * 2 Elseif mode is set though captcha/config.php, take it
- * 3 Else, take "text"
- */
-class XoopsCaptchaMethod
-{
- /**
- * @var XoopsCaptcha
- */
- public $handler;
-
- /**
- * @var array
- */
- public $config;
-
- /**
- * @var string
- */
- public $code;
-
- /**
- * XoopsCaptchaMethod::__construct()
- *
- * @param mixed $handler
- */
- public function __construct($handler = null)
- {
- $this->handler = $handler;
- }
-
- /**
- * XoopsCaptchaMethod::isActive()
- *
- * @return bool
- */
- public function isActive()
- {
- return true;
- }
-
- /**
- * XoopsCaptchaMethod::loadConfig()
- *
- * @param string $name
- * @return array
- */
- public function loadConfig($name = '')
- {
- $this->config = empty($name) ? $this->handler->config
- : array_merge($this->handler->config, $this->handler->loadConfig($name));
- }
-
- /**
- * XoopsCaptchaMethod::getCode()
- *
- * @return string
- */
- public function getCode()
- {
- return strval($this->code);
- }
-
- /**
- * XoopsCaptchaMethod::render()
- *
- * @return string
- */
- public function render()
- {
- return '';
- }
-
- /**
- * @return string
- */
- public function renderValidationJS()
- {
- return '';
- }
-
- /**
- * XoopsCaptchaMethod::verify()
- *
- * @param mixed $sessionName
- * @return bool
- */
- public function verify($sessionName = null)
- {
- $is_valid = false;
- if (!empty($_SESSION["{$sessionName}_code"])) {
- $func = !empty($this->config['casesensitive']) ? 'strcmp' : 'strcasecmp';
- $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION["{$sessionName}_code"]);
- }
- return $is_valid;
- }
-
- /**
- * @return bool
- */
- public function destroyGarbage()
- {
- return true;
- }
-
+<?php
+/*
+ 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.
+*/
+
+/**
+ * CAPTCHA configurations for Image mode
+ *
+ * Based on DuGris' SecurityImage
+ *
+ * @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 class
+ * @subpackage captcha
+ * @since 2.3.0
+ * @author Taiwen Jiang <ph...@us...>
+ * @version $Id$
+ */
+
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+class XoopsCaptcha
+{
+ /**
+ * @var bool
+ */
+ public $active;
+
+ /**
+ * @var XoopsCaptchaMethod
+ */
+ public $handler;
+
+ /**
+ * @var string
+ */
+ public $path_basic;
+
+ /**
+ * @var string
+ */
+ public $path_plugin;
+
+ /**
+ * @var string
+ */
+ public $configPath;
+
+ /**
+ * @var string
+ */
+ public $name;
+
+ /**
+ * @var array
+ */
+ public $config = array();
+
+ /**
+ * @var array
+ */
+ public $message = array();
+
+ /**
+ * construct
+ */
+ public function __construct()
+ {
+ $xoops = Xoops::getInstance();
+ $xoops->loadLanguage('captcha');
+ // Load static configurations
+ $this->path_basic = XOOPS_ROOT_PATH . '/class/captcha';
+ $this->path_plugin = XOOPS_ROOT_PATH . '/Frameworks/captcha';
+ $this->configPath = XOOPS_VAR_PATH . '/configs/';
+ $this->config = $this->loadConfig();
+ $this->name = $this->config['name'];
+ }
+
+ /**
+ * Get Instance
+ *
+ * @return XoopsCaptcha
+ */
+ static function getInstance()
+ {
+ static $instance;
+ if (!isset($instance)) {
+ $class = __CLASS__;
+ $instance = new $class();
+ }
+ return $instance;
+ }
+
+ /**
+ * XoopsCaptcha::loadConfig()
+ *
+ * @param string $filename
+ * @return array
+ */
+ function loadConfig( $name = 'config') {
+ if ( $name == 'config' ) {
+ $filename = 'captcha.config';
+ } else {
+ $filename = 'captcha.config.' . $name;
+ }
+ if ( !$config = $this->readConfig($filename) ) {
+ $config = $this->loadBasicConfig( $name );
+ $this->writeConfig($filename, $config );
+ }
+ return $config;
+ }
+
+ /**
+ * XoopsCaptcha::loadBasicConfig()
+ *
+ * @param string $filename
+ * @return array
+ */
+ function loadBasicConfig($filename = null)
+ {
+ $basic_config = array();
+ $plugin_config = array();
+ $filename = ($filename == 'config') ? 'config.php' : 'config.' . $filename . '.php';
+ if (file_exists($file = $this->path_basic . '/' . $filename)) {
+ $basic_config = include $file;
+ }
+ if (file_exists($file = $this->path_plugin . '/' . $filename)) {
+ $plugin_config = include $file;
+ }
+
+ $config = array_merge($basic_config, $plugin_config);
+ foreach ($config as $key => $val) {
+ $config[$key] = $val;
+ }
+ return $config;
+ }
+
+ /**
+ * XoopsCaptcha::readConfig()
+ *
+ * @param string $filename
+ * @return array
+ */
+ function readConfig( $filename = 'config')
+ {
+ $path_file = $this->configPath . $filename . '.php';
+ XoopsLoad::load('XoopsFile');
+ $file = XoopsFile::getHandler('file', $path_file);
+ return eval(@$file->read());
+ }
+
+ /**
+ * XoopsCaptcha::writeConfig()
+ *
+ * @param string $filename
+ * @param array $config
+ * @return array
+ */
+ function writeConfig($filename = 'config', $config)
+ {
+ $path_file = $this->configPath . $filename . '.php';
+ XoopsLoad::load('XoopsFile');
+ $file = XoopsFile::getHandler('file', $path_file);
+ return $file->write( 'return ' . var_export($config, true) . ';');
+ }
+
+ /**
+ * XoopsCaptcha::isActive()
+ *
+ * @return bool
+ */
+ public function isActive()
+ {
+ $xoops = Xoops::getInstance();
+
+ if (isset($this->active)) {
+ return $this->active;
+ }
+ if (!empty($this->config['disabled'])) {
+ $this->active = false;
+ return $this->active;
+ }
+ if (!empty($this->config['skipmember']) && $xoops->isUser()) {
+ $this->active = false;
+ return $this->active;
+ }
+ if (!isset($this->handler)) {
+ $this->loadHandler();
+ }
+ $this->active = isset($this->handler);
+ return $this->active;
+ }
+
+ /**
+ * XoopsCaptcha::loadHandler()
+ *
+ * @param string $name
+ * @return XoopsCatchaMethod
+ */
+ public function loadHandler($name = null)
+ {
+ $name = !empty($name) ? $name : (empty($this->config['mode']) ? 'text' : $this->config['mode']);
+ $class = 'XoopsCaptcha' . ucfirst($name);
+ if (!empty($this->handler) && get_class($this->handler) == $class) {
+ return $this->handler;
+ }
+ $this->handler = null;
+ if (file_exists($file = $this->path_basic . '/' . $name . '.php')) {
+ require_once $file;
+ } else {
+ if (file_exists($file = $this->path_plugin . '/' . $name . '.php')) {
+ require_once $file;
+ }
+ }
+
+ if (!class_exists($class)) {
+ $class = 'XoopsCaptchaText';
+ require_once $this->path_basic . '/text.php';
+ }
+ /* @var $handler XoopsCaptchaMethod */
+ $handler = new $class($this);
+ if ($handler->isActive()) {
+ $this->handler = $handler;
+ $this->handler->loadConfig($name);
+ }
+ return $this->handler;
+ }
+
+ /**
+ * XoopsCaptcha::setConfigs()
+ *
+ * @param mixed $configs
+ * @return bool
+ */
+ public function setConfigs($configs)
+ {
+ foreach ($configs as $key => $val) {
+ $this->setConfig($key, $val);
+ }
+ return true;
+ }
+
+ /**
+ * XoopsCaptcha::setConfig()
+ *
+ * @param mixed $name
+ * @param mixed $val
+ * @return bool
+ */
+ public function setConfig($name, $val)
+ {
+ if (isset($this->$name)) {
+ $this->$name = $val;
+ } else {
+ $this->config[$name] = $val;
+ }
+ return true;
+ }
+
+ /**
+ * XoopsCaptcha::verify()
+ *
+ * Verify user submission
+ *
+ * @param bool $skipMember
+ * @param string $name
+ * @return bool
+ */
+ public function verify($skipMember = null, $name = null)
+ {
+ $xoops = Xoops::getInstance();
+ $sessionName = empty($name) ? $this->name : $name;
+ $skipMember = ($skipMember === null) ? $_SESSION["{$sessionName}_skipmember"] : $skipMember;
+ $maxAttempts = $_SESSION["{$sessionName}_maxattempts"];
+ $attempt = $_SESSION["{$sessionName}_attempt"];
+ $is_valid = false;
+ // Skip CAPTCHA verification if disabled
+ if (!$this->isActive()) {
+ $is_valid = true;
+ // Skip CAPTCHA for member if set
+ } else {
+ if ($xoops->isUser() && !empty($skipMember)) {
+ $is_valid = true;
+ // Kill too many attempts
+ } else {
+ if (!empty($maxAttempts) && $attempt > $maxAttempts) {
+ $this->message[] = _CAPTCHA_TOOMANYATTEMPTS;
+ // Verify the code
+ } else {
+ $is_valid = $this->handler->verify($sessionName);
+ }
+ }
+ }
+
+ if (!$is_valid) {
+ // Increase the attempt records on failure
+ $_SESSION["{$sessionName}_attempt"]++;
+ // Log the error message
+ $this->message[] = _CAPTCHA_INVALID_CODE;
+ } else {
+ // reset attempt records on success
+ $_SESSION["{$sessionName}_attempt"] = null;
+ }
+ $this->destroyGarbage(true);
+ return $is_valid;
+ }
+
+ /**
+ * XoopsCaptcha::getCaption()
+ *
+ * @return string
+ */
+ public function getCaption()
+ {
+ return defined('_CAPTCHA_CAPTION') ? constant('_CAPTCHA_CAPTION') : '';
+ }
+
+ /**
+ * XoopsCaptcha::getMessage()
+ *
+ * @return sdtring
+ */
+ public function getMessage()
+ {
+ return implode('<br />', $this->message);
+ }
+
+ /**
+ * Destory historical stuff
+ *
+ * @param bool $clearSession
+ * @return bool
+ */
+ public function destroyGarbage($clearSession = false)
+ {
+ $this->loadHandler();
+ $this->handler->destroyGarbage();
+
+ if ($clearSession) {
+ foreach ($this->config as $k => $config ) {
+ $_SESSION[$this->name . '_' . $k] = null;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * XoopsCaptcha::render()
+ *
+ * @return string
+ */
+ public function render()
+ {
+ $sessionName = $this->config['name'];
+ $_SESSION[$sessionName . '_name'] = $sessionName;
+ foreach ($this->config as $k => $config ) {
+ $_SESSION[$sessionName . '_' . $k] = $config;
+ }
+ $form = '';
+ if (!$this->active || empty($this->config['name'])) {
+ return $form;
+ }
+
+ $maxAttempts = $this->config['maxattempts'];
+ $attempt = isset($_SESSION[$sessionName . '_attempt']) ? $_SESSION[$sessionName . '_attempt'] : 0;
+ $_SESSION[$sessionName . '_attempt'] = $attempt;
+
+ // Failure on too many attempts
+ if (!empty($maxAttempts) && $attempt > $maxAttempts) {
+ $form = _CAPTCHA_TOOMANYATTEMPTS;
+ // Load the form element
+ } else {
+ $form = $this->loadForm();
+ }
+ return $form;
+ }
+
+ /**
+ * XoopsCaptcha::renderValidationJS()
+ *
+ * @return string
+ */
+ public function renderValidationJS()
+ {
+ if (!$this->active || empty($this->config['name'])) {
+ return '';
+ }
+ return $this->handler->renderValidationJS();
+ }
+
+ /**
+ * XoopsCaptcha::setCode()
+ *
+ * @param mixed $code
+ * @return bool
+ */
+ public function setCode($code = null)
+ {
+ $code = ($code === null) ? $this->handler->getCode() : $code;
+ if (!empty($code)) {
+ $_SESSION[$this->name . '_code'] = $code;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * XoopsCaptcha::loadForm()
+ *
+ * @return string
+ */
+ public function loadForm()
+ {
+ $form = $this->handler->render();
+ $this->setCode();
+ return $form;
+ }
+}
+
+/**
+ * Abstract class for CAPTCHA method
+ *
+ * Currently there are two types of CAPTCHA forms, text and image
+ * The default mode is "text", it can be changed in the priority:
+ * 1 If mode is set through XoopsFormCaptcha::setConfig("mode", $mode), take it
+ * 2 Elseif mode is set though captcha/config.php, take it
+ * 3 Else, take "text"
+ */
+class XoopsCaptchaMethod
+{
+ /**
+ * @var XoopsCaptcha
+ */
+ public $handler;
+
+ /**
+ * @var array
+ */
+ public $config;
+
+ /**
+ * @var string
+ */
+ public $code;
+
+ /**
+ * XoopsCaptchaMethod::__construct()
+ *
+ * @param mixed $handler
+ */
+ public function __construct($handler = null)
+ {
+ $this->handler = $handler;
+ }
+
+ /**
+ * XoopsCaptchaMethod::isActive()
+ *
+ * @return bool
+ */
+ public function isActive()
+ {
+ return true;
+ }
+
+ /**
+ * XoopsCaptchaMethod::loadConfig()
+ *
+ * @param string $name
+ * @return array
+ */
+ public function loadConfig($name = '')
+ {
+ $this->config = empty($name) ? $this->handler->config
+ : array_merge($this->handler->config, $this->handler->loadConfig($name));
+
+ }
+
+ /**
+ * XoopsCaptchaMethod::getCode()
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return strval($this->code);
+ }
+
+ /**
+ * XoopsCaptchaMethod::render()
+ *
+ * @return string
+ */
+ public function render()
+ {
+ return '';
+ }
+
+ /**
+ * @return string
+ */
+ public function renderValidationJS()
+ {
+ return '';
+ }
+
+ /**
+ * XoopsCaptchaMethod::verify()
+ *
+ * @param mixed $sessionName
+ * @return bool
+ */
+ public function verify($sessionName = null)
+ {
+ $is_valid = false;
+ if (!empty($_SESSION["{$sessionName}_code"])) {
+ $func = !empty($this->config['casesensitive']) ? 'strcmp' : 'strcasecmp';
+ $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION["{$sessionName}_code"]);
+ }
+ return $is_valid;
+ }
+
+ /**
+ * @return bool
+ */
+ public function destroyGarbage()
+ {
+ return true;
+ }
+
}
\ No newline at end of file
Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/captcha/xoopscaptcha.php
___________________________________________________________________
Deleted: svn:eol-style
- native
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php 2012-10-12 00:32:32 UTC (rev 10213)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php 2012-10-12 00:38:13 UTC (rev 10214)
@@ -58,6 +58,7 @@
$this->captchaHandler = XoopsCaptcha::getInstance();
$configs['name'] = $name;
$configs['skipmember'] = $skipmember;
+ $configs = $this->captchaHandler->loadConfig();
$this->captchaHandler->setConfigs($configs);
if (! $this->captchaHandler->isActive()) {
$this->setHidden();
|
|
From: <du...@us...> - 2012-11-29 13:39:29
|
Revision: 10287
http://sourceforge.net/p/xoops/svn/10287
Author: dugris
Date: 2012-11-29 13:39:27 +0000 (Thu, 29 Nov 2012)
Log Message:
-----------
BUG Fix : model/class/stats function getcount & getcounts
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php 2012-11-29 13:36:07 UTC (rev 10286)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php 2012-11-29 13:39:27 UTC (rev 10287)
@@ -163,6 +163,14 @@
{
return $this->groupby ? " GROUP BY {$this->groupby}" : "";
}
+
+ /**
+ * @return string
+ */
+ public function getGroupbyField()
+ {
+ return $this->groupby ? $this->groupby : "";
+ }
}
/**
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2012-11-29 13:36:07 UTC (rev 10286)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2012-11-29 13:39:27 UTC (rev 10287)
@@ -44,9 +44,9 @@
$field = '';
$groupby = false;
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
- if ($criteria->getGroupby() != '') {
+ if ($criteria->getGroupbyField() != '') {
$groupby = true;
- $field = $criteria->getGroupby() . ", ";
+ $field = $criteria->getGroupbyField() . ", ";
}
}
$sql = "SELECT {$field} COUNT(*) FROM `{$this->handler->table}`";
@@ -87,7 +87,7 @@
$sql_where = $criteria->renderWhere();
$limit = $criteria->getLimit();
$start = $criteria->getStart();
- if ($groupby = $criteria->getGroupby()) {
+ if ($groupby = $criteria->getGroupbyField()) {
$groupby_key = $groupby;
}
}
|
|
From: <du...@us...> - 2012-12-04 20:09:00
|
Revision: 10318
http://sourceforge.net/p/xoops/svn/10318
Author: dugris
Date: 2012-12-04 20:08:57 +0000 (Tue, 04 Dec 2012)
Log Message:
-----------
Fix groupby in criteria & model
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php 2012-12-03 23:33:54 UTC (rev 10317)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/criteria.php 2012-12-04 20:08:57 UTC (rev 10318)
@@ -161,16 +161,8 @@
*/
public function getGroupby()
{
- return $this->groupby ? " GROUP BY {$this->groupby}" : "";
+ return isset($this->groupby) ? $this->groupby : "";
}
-
- /**
- * @return string
- */
- public function getGroupbyField()
- {
- return $this->groupby ? $this->groupby : "";
- }
}
/**
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php 2012-12-03 23:33:54 UTC (rev 10317)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php 2012-12-04 20:08:57 UTC (rev 10318)
@@ -98,6 +98,9 @@
$sql .= " ORDER BY {$sort} " . $criteria->getOrder();
$orderSet = true;
}
+ if ($criteria->getGroupby() != '') {
+ $sql .= ' GROUP BY (' . $criteria->getGroupby() . ')';
+ }
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
@@ -139,6 +142,9 @@
$sql = " SELECT COUNT(DISTINCT {$this->handler->keyName}) AS count" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}";
if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) {
$sql .= " " . $criteria->renderWhere();
+ if ($criteria->getGroupby() != '') {
+ $sql .= ' GROUP BY (' . $criteria->getGroupby() . ')';
+ }
}
if (!$result = $this->handler->db->query($sql)) {
return false;
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php 2012-12-03 23:33:54 UTC (rev 10317)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php 2012-12-04 20:08:57 UTC (rev 10318)
@@ -57,7 +57,7 @@
if (isset($criteria)) {
$sql .= " " . $criteria->renderWhere();
if ($groupby = $criteria->getGroupby()) {
- $sql .= $groupby;
+ $sql .= ' GROUP BY (' . $groupby . ')';
}
if ($sort = $criteria->getSort()) {
$sql .= " ORDER BY {$sort} " . $criteria->getOrder();
@@ -138,6 +138,9 @@
if ($sort = $criteria->getSort()) {
$sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder();
}
+ if ($groupby = $criteria->getGroupby()) {
+ $sql .= ' GROUP BY (' . $groupby . ')';
+ }
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2012-12-03 23:33:54 UTC (rev 10317)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2012-12-04 20:08:57 UTC (rev 10318)
@@ -44,15 +44,17 @@
$field = '';
$groupby = false;
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
- if ($criteria->getGroupbyField() != '') {
+ if ($criteria->getGroupby() != '') {
$groupby = true;
- $field = $criteria->getGroupbyField() . ", ";
+ $field = $criteria->getGroupby() . ", ";
}
}
$sql = "SELECT {$field} COUNT(*) FROM `{$this->handler->table}`";
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$sql .= ' ' . $criteria->renderWhere();
- $sql .= $criteria->getGroupby();
+ if ($criteria->getGroupby() != '') {
+ $sql .= ' GROUP BY (' . $criteria->getGroupby() . ')';
+ }
}
$result = $this->handler->db->query($sql);
if (!$result) {
@@ -87,7 +89,7 @@
$sql_where = $criteria->renderWhere();
$limit = $criteria->getLimit();
$start = $criteria->getStart();
- if ($groupby = $criteria->getGroupbyField()) {
+ if ($groupby = $criteria->getGroupby()) {
$groupby_key = $groupby;
}
}
|
|
From: <tr...@us...> - 2012-12-12 00:09:48
|
Revision: 10366
http://sourceforge.net/p/xoops/svn/10366
Author: trabis
Date: 2012-12-12 00:09:45 +0000 (Wed, 12 Dec 2012)
Log Message:
-----------
Fixing small bugs
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/userutility.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopslocal.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/userutility.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/userutility.php 2012-12-11 23:01:05 UTC (rev 10365)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/userutility.php 2012-12-12 00:09:45 UTC (rev 10366)
@@ -254,25 +254,25 @@
/**
* XoopsUserUtility::getUnameFromIds()
*
- * @param int $uid
- * @param bool $usereal
- * @param bool $linked
+ * @param array $uids
+ * @param bool $usereal
+ * @param bool $linked
*
* @return array
*/
- static function getUnameFromIds($uid, $usereal = false, $linked = false)
+ static function getUnameFromIds($uids, $usereal = false, $linked = false)
{
$xoops = Xoops::getInstance();
- if (!is_array($uid)) {
- $uid = array($uid);
+ if (!is_array($uids)) {
+ $uids = array($uids);
}
- $userid = array_map('intval', array_filter($uid));
+ $userids = array_map('intval', array_filter($uids));
$myts = MyTextSanitizer::getInstance();
$users = array();
- if (count($userid) > 0) {
+ if (count($userids) > 0) {
$criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
- $criteria->add(new Criteria('uid', "('" . implode(',', array_unique($userid)) . "')", 'IN'));
+ $criteria->add(new Criteria('uid', "('" . implode(',', array_unique($userids)) . "')", 'IN'));
$user_handler = $xoops->getHandlerUser();
if (!$rows = $user_handler->getAll($criteria, array('uid', 'uname', 'name'), false, true)) {
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-11 23:01:05 UTC (rev 10365)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-12 00:09:45 UTC (rev 10366)
@@ -333,7 +333,7 @@
'xoopsmembershiphandler' => XOOPS_ROOT_PATH . '/kernel/membership.php',
'xoopsmodelfactory' => XOOPS_ROOT_PATH . '/class/model/xoopsmodel.php',
'xoopsmoduleadmin' => XOOPS_ROOT_PATH . '/class/moduleadmin.php',
- 'xoopsmodules' => XOOPS_ROOT_PATH . '/kernel/module.php',
+ 'xoopsmodule' => XOOPS_ROOT_PATH . '/kernel/module.php',
'xoopsmodulehandler' => XOOPS_ROOT_PATH . '/kernel/module.php',
'xoopsmultimailer' => XOOPS_ROOT_PATH . '/class/mail/xoopsmultimailer.php',
'xoopsnotification' => XOOPS_ROOT_PATH . '/kernel/notification.php',
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopslocal.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopslocal.php 2012-12-11 23:01:05 UTC (rev 10365)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopslocal.php 2012-12-12 00:09:45 UTC (rev 10366)
@@ -260,9 +260,7 @@
*/
public function __call($name, $args)
{
- exit($name);
if (function_exists($name)) {
- exit($name);
return call_user_func_array($name, $args);
}
return null;
|
|
From: <tr...@us...> - 2012-12-26 18:44:07
|
Revision: 10563
http://sourceforge.net/p/xoops/svn/10563
Author: trabis
Date: 2012-12-26 18:43:49 +0000 (Wed, 26 Dec 2012)
Log Message:
-----------
Adding a simple block form to use in blocks forms. Needs some extra work. Help is appreciated.
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php
Added Paths:
-----------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/blockform.php
Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/blockform.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/blockform.php (rev 0)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/blockform.php 2012-12-26 18:43:49 UTC (rev 10563)
@@ -0,0 +1,56 @@
+<?php
+/*
+ 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.
+*/
+
+/**
+ * XOOPS Block Form
+ *
+ * @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 class
+ * @subpackage xoopsform
+ * @since 2.6.0
+ * @author trabis <lus...@gm...>
+ * @version $Id$
+ */
+
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+
+/**
+ * Form that will output formatted as a HTML table
+ *
+ * No styles and no JavaScript to check for required fields.
+ */
+class XoopsBlockForm extends XoopsForm
+{
+ public function __construct()
+ {
+ parent::__construct('', '', '');
+ }
+
+ /**
+ * @return string
+ */
+ public function render()
+ {
+ $ret = '';
+ /* @var $ele XoopsFormElement */
+ foreach ($this->getElements() as $ele) {
+ if (!$ele->isHidden()) {
+ $ret .= "<strong>" . $ele->getCaption()."</strong>";
+ $ret .= " " . $ele->render() . "";
+ $ret .= " <i>" . $ele->getDescription() . "</i><br /><br />";
+ }
+ }
+ $ret .= '';
+ return $ret;
+ }
+}
\ No newline at end of file
Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/blockform.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-26 18:41:43 UTC (rev 10562)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-26 18:43:49 UTC (rev 10563)
@@ -240,6 +240,7 @@
'xoopsavataruserlink' => XOOPS_ROOT_PATH . '/kernel/avataruserlink.php',
'xoopsavataruserlinkhandler' => XOOPS_ROOT_PATH . '/kernel/avataruserlink.php',
'xoopsblock' => XOOPS_ROOT_PATH . '/kernel/block.php',
+ 'xoopsblockform' => XOOPS_ROOT_PATH . '/class/xoopsform/blockform.php',
'xoopsblockhandler' => XOOPS_ROOT_PATH . '/kernel/block.php',
'xoopsblockmodulelink' => XOOPS_ROOT_PATH . '/kernel/blockmodulelink.php',
'xoopsblockmodulelinkhandler' => XOOPS_ROOT_PATH . '/kernel/blockmodulelink.php',
|
|
From: <be...@us...> - 2013-08-17 00:10:27
|
Revision: 11934
http://sourceforge.net/p/xoops/svn/11934
Author: beckmi
Date: 2013-08-17 00:10:20 +0000 (Sat, 17 Aug 2013)
Log Message:
-----------
Fixing preg_replace /e in textsanitizer for PHP 5.5.x
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/flash/flash.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/mp3/mp3.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/wiki/wiki.php
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/youtube/youtube.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php 2013-08-16 23:03:01 UTC (rev 11933)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php 2013-08-17 00:10:20 UTC (rev 11934)
@@ -136,7 +136,7 @@
* @param string $height
* @return string
*/
- public function decode($url, $width, $height)
+ public static function decode($url, $width, $height)
{
return '';
}
@@ -181,6 +181,11 @@
*/
public $replacements = array();
+//mb------------------------------
+ public $callbackPatterns = array();
+ public $callbacks = array();
+//mb------------------------------
+
/**
* @var string
*/
@@ -280,6 +285,29 @@
return $message;
}
+
+
+ function makeClickableCallback01($match)
+ {
+ return $match[1]."<a href=\"$match[2]://$match[3]\" title=\"$match[2]://$match[3]\" rel=\"external\">$match[2]://".$this->truncate( $match[3] ).'</a>';
+ }
+
+ function makeClickableCallback02($match)
+ {
+ return $match[1] ."<a href=\"http://www.$match[2]$match[6]\" title=\"www.$match[2]$match[6]\" rel=\"external\">" .$this->truncate('www.'.$match[2].$match[6]) .'</a>';
+ }
+
+ function makeClickableCallback03($match)
+ {
+ return $match[1]."<a href=\"ftp://ftp.$match[2].$match[3]\" title=\"ftp.$match[2].$match[3]\" rel=\"external\">" . $this->truncate('ftp.'.$match[2].$match[3]) .'</a>';
+ }
+
+ function makeClickableCallback04($match)
+ {
+ return $match[1]. "<a href=\"mailto:$match[2]@$match[3]\" title=\"$match[2]@$match[3]\">" .$this->truncate($match[2]."@".$match[3]) .'</a>';
+ }
+
+
/**
* Make links in the text clickable
*
@@ -290,22 +318,40 @@
$valid_chars = "a-z0-9\/\-_+=.~!%@?#&;:$\|";
$end_chars = "a-z0-9\/\-_+=~!%@?#&;:$\|";
- $patterns = array();
- $replacements = array();
+// $patterns = array();
+// $replacements = array();
+//
+// $patterns[] = "/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([{$valid_chars}]+[{$end_chars}])/ei";
+// $replacements[] = "'\\1<a href=\"\\2://\\3\" title=\"\\2://\\3\" rel=\"external\">\\2://'.MyTextSanitizer::truncate( '\\3' ).'</a>'";
+//
+//
+// $patterns[] = "/(^|[^]_a-z0-9-=\"'\/:\.])www\.((([a-zA-Z0-9\-]*\.){1,}){1}([a-zA-Z]{2,6}){1})((\/([a-zA-Z0-9\-\._\?\,\'\/\\+&%\$#\=~])*)*)/ei";
+// $replacements[] = "'\\1<a href=\"http://www.\\2\\6\" title=\"www.\\2\\6\" rel=\"external\">'.MyTextSanitizer::truncate( 'www.\\2\\6' ).'</a>'";
+//
+// $patterns[] = "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([{$valid_chars}]+[{$end_chars}])/ei";
+// $replacements[] = "'\\1<a href=\"ftp://ftp.\\2.\\3\" title=\"ftp.\\2.\\3\" rel=\"external\">'.MyTextSanitizer::truncate( 'ftp.\\2.\\3' ).'</a>'";
+//
+// $patterns[] = "/(^|[^]_a-z0-9-=\"'\/:\.])([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+)@((?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?)/ei";
+// $replacements[] = "'\\1<a href=\"mailto:\\2@\\3\" title=\"\\2@\\3\">'.MyTextSanitizer::truncate( '\\2@\\3' ).'</a>'";
+//
+// $text = preg_replace($patterns, $replacements, $text);
+//
+//----------------------------------------------------------------------------------
- $patterns[] = "/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([{$valid_chars}]+[{$end_chars}])/ei";
- $replacements[] = "'\\1<a href=\"\\2://\\3\" title=\"\\2://\\3\" rel=\"external\">\\2://'.MyTextSanitizer::truncate( '\\3' ).'</a>'";
- $patterns[] = "/(^|[^]_a-z0-9-=\"'\/:\.])www\.((([a-zA-Z0-9\-]*\.){1,}){1}([a-zA-Z]{2,6}){1})((\/([a-zA-Z0-9\-\._\?\,\'\/\\+&%\$#\=~])*)*)/ei";
- $replacements[] = "'\\1<a href=\"http://www.\\2\\6\" title=\"www.\\2\\6\" rel=\"external\">'.MyTextSanitizer::truncate( 'www.\\2\\6' ).'</a>'";
+ $pattern = "/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([{$valid_chars}]+[{$end_chars}])/i";
+ $text = preg_replace_callback($pattern, 'self::makeClickableCallback01', $text);
- $patterns[] = "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([{$valid_chars}]+[{$end_chars}])/ei";
- $replacements[] = "'\\1<a href=\"ftp://ftp.\\2.\\3\" title=\"ftp.\\2.\\3\" rel=\"external\">'.MyTextSanitizer::truncate( 'ftp.\\2.\\3' ).'</a>'";
+ $pattern = "/(^|[^]_a-z0-9-=\"'\/:\.])www\.((([a-zA-Z0-9\-]*\.){1,}){1}([a-zA-Z]{2,6}){1})((\/([a-zA-Z0-9\-\._\?\,\'\/\\+&%\$#\=~])*)*)/i";
+ $text = preg_replace_callback($pattern, 'self::makeClickableCallback02', $text);
- $patterns[] = "/(^|[^]_a-z0-9-=\"'\/:\.])([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+)@((?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?)/ei";
- $replacements[] = "'\\1<a href=\"mailto:\\2@\\3\" title=\"\\2@\\3\">'.MyTextSanitizer::truncate( '\\2@\\3' ).'</a>'";
- $text = preg_replace($patterns, $replacements, $text);
+ $pattern = "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([{$valid_chars}]+[{$end_chars}])/i";
+ $text = preg_replace_callback($pattern, 'self::makeClickableCallback03', $text);
+
+ $pattern = "/(^|[^]_a-z0-9-=\"'\/:\.])([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+)@((?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?)/i";
+ $text = preg_replace_callback($pattern, 'self::makeClickableCallback04', $text);
+
return $text;
}
@@ -378,6 +424,13 @@
$this->executeExtensions();
$text = preg_replace($this->patterns, $this->replacements, $this->text);
+//-------------------------------------------------------------------------------
+ $count = sizeof($this->callbackPatterns);
+
+ for ($i = 0; $i < $count; $i++) {
+ $text = preg_replace_callback($this->callbackPatterns[$i], $this->callbacks[$i] , $text);
+ }
+//------------------------------------------------------------------------------
$text = $this->quoteConv($text);
return $text;
}
@@ -582,13 +635,21 @@
public function codePreConv($text, $xcode = 1)
{
if ($xcode != 0) {
- $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/esU";
- $replacements = "'[code\\1]'.base64_encode('\\2').'[/code]'";
- $text = preg_replace($patterns, $replacements, $text);
+// $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/esU";
+// $replacements = "'[code\\1]'.base64_encode('\\2').'[/code]'";
+ $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/sU";
+ $text = preg_replace_callback($patterns, create_function('$matches',"return '[code'.\$matches[1].']' . base64_encode(\$matches[2]). '[/code]';"),$text);
}
return $text;
}
+
+function codeConvCallback($match)
+ {
+ return '<div class=\"xoopsCode\">'. $this->executeExtension('syntaxhighlight', str_replace('\\\"', '\"', base64_decode($match[2])), $match[1]).'</div>';
+ }
+
+
/**
* MyTextSanitizer::codeConv()
*
@@ -601,9 +662,10 @@
if (empty($xcode)) {
return $text;
}
- $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/esU";
- $replacements = "'<div class=\"xoopsCode\">'.\$this->executeExtension('syntaxhighlight', str_replace('\\\"', '\"', base64_decode('$2')), '$1').'</div>'";
- $text = preg_replace($patterns, $replacements, $text);
+ $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/sU";
+// $replacements = "'<div class=\"xoopsCode\">'.\$this->executeExtension('syntaxhighlight', str_replace('\\\"', '\"', base64_decode('$2')), '$1').'</div>'";
+ $text = preg_replace_callback($patterns, array($this,'codeConvCallback'), $text);
+
return $text;
}
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/flash/flash.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/flash/flash.php 2013-08-16 23:03:01 UTC (rev 11933)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/flash/flash.php 2013-08-17 00:10:20 UTC (rev 11934)
@@ -57,6 +57,9 @@
$code, $javascript
);
}
+ static function myCallback($match) {
+ return self::decode( $match[5], $match[3], $match[4] );
+ }
/**
* @param MyTextSanitizer $ts
@@ -64,9 +67,14 @@
*/
public function load(MyTextSanitizer &$ts)
{
- $ts->patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
- $ts->replacements[] = __CLASS__ . "::decode( '\\5', '\\3', '\\4' )";
+// $ts->patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
+// $ts->replacements[] = __CLASS__ . "::decode( '\\5', '\\3', '\\4' )";
+//mb------------------------------
+ $ts->callbackPatterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/sU";
+ $ts->callbacks[] = __CLASS__ . "::myCallback";
+//mb------------------------------
+
return true;
}
@@ -76,7 +84,7 @@
* @param int $height
* @return string
*/
- public function decode($url, $width, $height)
+ public static function decode($url, $width, $height)
{
$config = parent::loadConfig(dirname(__FILE__));
if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) {
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/mp3/mp3.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/mp3/mp3.php 2013-08-16 23:03:01 UTC (rev 11933)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/mp3/mp3.php 2013-08-17 00:10:20 UTC (rev 11934)
@@ -55,10 +55,18 @@
);
}
+ static function myCallback($match) {
+ return self::decode($match[1]);
+ }
+
public function load(MyTextSanitizer &$ts)
{
- $ts->patterns[] = "/\[mp3\](.*?)\[\/mp3\]/es";
- $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
+// $ts->patterns[] = "/\[mp3\](.*?)\[\/mp3\]/es";
+// $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
+//mb------------------------------
+ $ts->callbackPatterns[] = "/\[mp3\](.*?)\[\/mp3\]/s";
+ $ts->callbacks[] = __CLASS__ . "::myCallback";
+//mb------------------------------
return true;
}
@@ -67,7 +75,7 @@
* @param string $url
* @return string
*/
- public function decode($url)
+ public static function decode ($url)
{
$rp = "<embed flashvars=\"playerID=1&bg=0xf8f8f8&leftbg=0x3786b3&lefticon=0x78bee3&rightbg=0x3786b3&rightbghover=0x78bee3&righticon=0x78bee3&righticonhover=0x3786b3&text=0x666666&slider=0x3786b3&track=0xcccccc&border=0x666666&loader=0x78bee3&loop=no&soundFile={$url}\" quality='high' menu='false' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" . XOOPS_URL . "/images/form/player.swf' width=290 height=24 type='application/x-shockwave-flash'></embed>";
return $rp;
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/wiki/wiki.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/wiki/wiki.php 2013-08-16 23:03:01 UTC (rev 11933)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/wiki/wiki.php 2013-08-17 00:10:20 UTC (rev 11934)
@@ -56,21 +56,28 @@
);
}
+ static function myCallback($match) {
+ return self::decode( $match[1] );
+ }
/**
* @param MyTextSanitizer $ts
* @return void
*/
public function load(MyTextSanitizer &$ts)
{
- $ts->patterns[] = "/\[\[([^\]]*)\]\]/esU";
- $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
+// $ts->patterns[] = "/\[\[([^\]]*)\]\]/esU";
+// $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
+//mb------------------------------
+ $ts->callbackPatterns[] = "/\[\[([^\]]*)\]\]/sU";
+ $ts->callbacks[] = __CLASS__ . "::myCallback";
+//mb------------------------------
}
/**
* @param string $text
* @return string
*/
- public function decode($text)
+ public static function decode($text)
{
$config = parent::loadConfig(dirname(__FILE__));
if (empty($text) || empty($config['link'])) {
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/youtube/youtube.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/youtube/youtube.php 2013-08-16 23:03:01 UTC (rev 11933)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/textsanitizer/youtube/youtube.php 2013-08-17 00:10:20 UTC (rev 11934)
@@ -55,14 +55,24 @@
return array($code, $javascript);
}
+static function myCallback($match) {
+ return self::decode( $match[4], $match[2], $match[3] );
+}
+
/**
* @param MyTextSanitizer $ts
* @return void
*/
public function load(MyTextSanitizer &$ts)
{
- $ts->patterns[] = "/\[youtube=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/youtube\]/esU";
- $ts->replacements[] = __CLASS__ . "::decode( '\\4', '\\2', '\\3' )";
+// $ts->patterns[] = "/\[youtube=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/youtube\]/esU";
+// $ts->replacements[] = __CLASS__ . "::decode( '\\4', '\\2', '\\3' )";
+
+//mb------------------------------
+ $ts->callbackPatterns[] = "/\[youtube=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/youtube\]/sU";
+ $ts->callbacks[] = __CLASS__ . "::myCallback";
+//mb------------------------------
+
}
/**
@@ -71,7 +81,7 @@
* @param string $height
* @return string
*/
- public function decode($url, $width, $height)
+ public static function decode($url, $width, $height)
{
if (!preg_match("/^http:\/\/(www\.)?youtube\.com\/watch\?v=(.*)/i", $url, $matches)) {
trigger_error("Not matched: {$url} {$width} {$height}", E_USER_WARNING);
|