@@ -14,16 +14,16 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | if (!class_exists('Projax')) { |
| 17 | - include __DIR__ . '/classes/JavaScript.php'; |
|
| 18 | - include __DIR__ . '/classes/Prototype.php'; |
|
| 19 | - include __DIR__ . '/classes/Scriptaculous.php'; |
|
| 17 | + include __DIR__ . '/classes/JavaScript.php'; |
|
| 18 | + include __DIR__ . '/classes/Prototype.php'; |
|
| 19 | + include __DIR__ . '/classes/Scriptaculous.php'; |
|
| 20 | 20 | |
| 21 | - // For $projax = new Projax(); |
|
| 21 | + // For $projax = new Projax(); |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Class projax |
|
| 25 | - */ |
|
| 26 | - class projax extends Scriptaculous |
|
| 27 | - { |
|
| 28 | - } |
|
| 23 | + /** |
|
| 24 | + * Class projax |
|
| 25 | + */ |
|
| 26 | + class projax extends Scriptaculous |
|
| 27 | + { |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -13,253 +13,253 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class XoopsCaptcha |
| 15 | 15 | { |
| 16 | - public $active = true; |
|
| 17 | - public $mode = 'text'; // potential values: image, text |
|
| 18 | - public $config = array(); |
|
| 19 | - |
|
| 20 | - public $message = array(); // Logging error messages |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * XoopsCaptcha constructor. |
|
| 24 | - */ |
|
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - // Loading default preferences |
|
| 28 | - $this->config = @include __DIR__ . '/config.php'; |
|
| 29 | - |
|
| 30 | - $this->setMode($this->config['mode']); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return XoopsCaptcha |
|
| 35 | - */ |
|
| 36 | - public static function getInstance() |
|
| 37 | - { |
|
| 38 | - static $instance; |
|
| 39 | - if (null === $instance) { |
|
| 40 | - $instance = new static(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - return $instance; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @param $name |
|
| 48 | - * @param $val |
|
| 49 | - * @return bool |
|
| 50 | - */ |
|
| 51 | - public function setConfig($name, $val) |
|
| 52 | - { |
|
| 53 | - if ($name === 'mode') { |
|
| 54 | - $this->setMode($val); |
|
| 55 | - } elseif (isset($this->$name)) { |
|
| 56 | - $this->$name = $val; |
|
| 57 | - } else { |
|
| 58 | - $this->config[$name] = $val; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return true; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Set CAPTCHA mode |
|
| 66 | - * |
|
| 67 | - * For future possible modes, right now force to use text or image |
|
| 68 | - * |
|
| 69 | - * @param string $mode if no mode is set, just verify current mode |
|
| 70 | - */ |
|
| 71 | - public function setMode($mode = null) |
|
| 72 | - { |
|
| 73 | - if (!empty($mode) && in_array($mode, array('text', 'image'))) { |
|
| 74 | - $this->mode = $mode; |
|
| 75 | - |
|
| 76 | - if ($this->mode !== 'image') { |
|
| 77 | - return; |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - // Disable image mode |
|
| 82 | - if (!extension_loaded('gd')) { |
|
| 83 | - $this->mode = 'text'; |
|
| 84 | - } else { |
|
| 85 | - $required_functions = array( |
|
| 86 | - 'imagecreatetruecolor', |
|
| 87 | - 'imagecolorallocate', |
|
| 88 | - 'imagefilledrectangle', |
|
| 89 | - 'imagejpeg', |
|
| 90 | - 'imagedestroy', |
|
| 91 | - 'imageftbbox' |
|
| 92 | - ); |
|
| 93 | - foreach ($required_functions as $func) { |
|
| 94 | - if (!function_exists($func)) { |
|
| 95 | - $this->mode = 'text'; |
|
| 96 | - break; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Initializing the CAPTCHA class |
|
| 104 | - * @param string $name |
|
| 105 | - * @param null $skipmember |
|
| 106 | - * @param null $num_chars |
|
| 107 | - * @param null $fontsize_min |
|
| 108 | - * @param null $fontsize_max |
|
| 109 | - * @param null $background_type |
|
| 110 | - * @param null $background_num |
|
| 111 | - */ |
|
| 112 | - public function init( |
|
| 113 | - $name = 'xoopscaptcha', |
|
| 114 | - $skipmember = null, |
|
| 115 | - $num_chars = null, |
|
| 116 | - $fontsize_min = null, |
|
| 117 | - $fontsize_max = null, |
|
| 118 | - $background_type = null, |
|
| 119 | - $background_num = null |
|
| 120 | - ) { |
|
| 121 | - // Loading RUN-TIME settings |
|
| 122 | - foreach (array_keys($this->config) as $key) { |
|
| 123 | - if (isset(${$key}) && ${$key} !== null) { |
|
| 124 | - $this->config[$key] = ${$key}; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - $this->config['name'] = $name; |
|
| 128 | - |
|
| 129 | - // Skip CAPTCHA for member if set |
|
| 130 | - if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) { |
|
| 131 | - $this->active = false; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Verify user submission |
|
| 137 | - * @param null $skipMember |
|
| 138 | - * @return bool |
|
| 139 | - */ |
|
| 140 | - public function verify($skipMember = null) |
|
| 141 | - { |
|
| 142 | - $sessionName = @$_SESSION['XoopsCaptcha_name']; |
|
| 143 | - $skipMember = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember; |
|
| 144 | - $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 145 | - |
|
| 146 | - $is_valid = false; |
|
| 147 | - |
|
| 148 | - // Skip CAPTCHA for member if set |
|
| 149 | - if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) { |
|
| 150 | - $is_valid = true; |
|
| 151 | - // Kill too many attempts |
|
| 152 | - } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) { |
|
| 153 | - $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 154 | - |
|
| 155 | - // Verify the code |
|
| 156 | - } elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) { |
|
| 157 | - $func = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp'; |
|
| 158 | - $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if (!empty($maxAttempts)) { |
|
| 162 | - if (!$is_valid) { |
|
| 163 | - // Increase the attempt records on failure |
|
| 164 | - $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++; |
|
| 165 | - // Log the error message |
|
| 166 | - $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
|
| 167 | - } else { |
|
| 168 | - |
|
| 169 | - // reset attempt records on success |
|
| 170 | - $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - $this->destroyGarbage(true); |
|
| 174 | - |
|
| 175 | - return $is_valid; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @return mixed|string |
|
| 180 | - */ |
|
| 181 | - public function getCaption() |
|
| 182 | - { |
|
| 183 | - return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : ''; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @return string |
|
| 188 | - */ |
|
| 189 | - public function getMessage() |
|
| 190 | - { |
|
| 191 | - return implode('<br>', $this->message); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Destory historical stuff |
|
| 196 | - * @param bool $clearSession |
|
| 197 | - * @return bool |
|
| 198 | - */ |
|
| 199 | - public function destroyGarbage($clearSession = false) |
|
| 200 | - { |
|
| 201 | - require_once __DIR__ . '/' . $this->mode . '.php'; |
|
| 202 | - $class = 'XoopsCaptcha' . ucfirst($this->mode); |
|
| 203 | - $captchaHandler = new $class(); |
|
| 204 | - if (method_exists($captchaHandler, 'destroyGarbage')) { |
|
| 205 | - $captchaHandler->loadConfig($this->config); |
|
| 206 | - $captchaHandler->destroyGarbage(); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if ($clearSession) { |
|
| 210 | - $_SESSION['XoopsCaptcha_name'] = null; |
|
| 211 | - $_SESSION['XoopsCaptcha_skipmember'] = null; |
|
| 212 | - $_SESSION['XoopsCaptcha_sessioncode'] = null; |
|
| 213 | - $_SESSION['XoopsCaptcha_maxattempts'] = null; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - return true; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * @return mixed|string |
|
| 221 | - */ |
|
| 222 | - public function render() |
|
| 223 | - { |
|
| 224 | - $form = ''; |
|
| 225 | - |
|
| 226 | - if (!$this->active || empty($this->config['name'])) { |
|
| 227 | - return $form; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - $_SESSION['XoopsCaptcha_name'] = $this->config['name']; |
|
| 231 | - $_SESSION['XoopsCaptcha_skipmember'] = $this->config['skipmember']; |
|
| 232 | - $maxAttempts = $this->config['maxattempt']; |
|
| 233 | - $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts; |
|
| 234 | - /* |
|
| 16 | + public $active = true; |
|
| 17 | + public $mode = 'text'; // potential values: image, text |
|
| 18 | + public $config = array(); |
|
| 19 | + |
|
| 20 | + public $message = array(); // Logging error messages |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * XoopsCaptcha constructor. |
|
| 24 | + */ |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + // Loading default preferences |
|
| 28 | + $this->config = @include __DIR__ . '/config.php'; |
|
| 29 | + |
|
| 30 | + $this->setMode($this->config['mode']); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return XoopsCaptcha |
|
| 35 | + */ |
|
| 36 | + public static function getInstance() |
|
| 37 | + { |
|
| 38 | + static $instance; |
|
| 39 | + if (null === $instance) { |
|
| 40 | + $instance = new static(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + return $instance; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param $name |
|
| 48 | + * @param $val |
|
| 49 | + * @return bool |
|
| 50 | + */ |
|
| 51 | + public function setConfig($name, $val) |
|
| 52 | + { |
|
| 53 | + if ($name === 'mode') { |
|
| 54 | + $this->setMode($val); |
|
| 55 | + } elseif (isset($this->$name)) { |
|
| 56 | + $this->$name = $val; |
|
| 57 | + } else { |
|
| 58 | + $this->config[$name] = $val; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return true; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Set CAPTCHA mode |
|
| 66 | + * |
|
| 67 | + * For future possible modes, right now force to use text or image |
|
| 68 | + * |
|
| 69 | + * @param string $mode if no mode is set, just verify current mode |
|
| 70 | + */ |
|
| 71 | + public function setMode($mode = null) |
|
| 72 | + { |
|
| 73 | + if (!empty($mode) && in_array($mode, array('text', 'image'))) { |
|
| 74 | + $this->mode = $mode; |
|
| 75 | + |
|
| 76 | + if ($this->mode !== 'image') { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + // Disable image mode |
|
| 82 | + if (!extension_loaded('gd')) { |
|
| 83 | + $this->mode = 'text'; |
|
| 84 | + } else { |
|
| 85 | + $required_functions = array( |
|
| 86 | + 'imagecreatetruecolor', |
|
| 87 | + 'imagecolorallocate', |
|
| 88 | + 'imagefilledrectangle', |
|
| 89 | + 'imagejpeg', |
|
| 90 | + 'imagedestroy', |
|
| 91 | + 'imageftbbox' |
|
| 92 | + ); |
|
| 93 | + foreach ($required_functions as $func) { |
|
| 94 | + if (!function_exists($func)) { |
|
| 95 | + $this->mode = 'text'; |
|
| 96 | + break; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Initializing the CAPTCHA class |
|
| 104 | + * @param string $name |
|
| 105 | + * @param null $skipmember |
|
| 106 | + * @param null $num_chars |
|
| 107 | + * @param null $fontsize_min |
|
| 108 | + * @param null $fontsize_max |
|
| 109 | + * @param null $background_type |
|
| 110 | + * @param null $background_num |
|
| 111 | + */ |
|
| 112 | + public function init( |
|
| 113 | + $name = 'xoopscaptcha', |
|
| 114 | + $skipmember = null, |
|
| 115 | + $num_chars = null, |
|
| 116 | + $fontsize_min = null, |
|
| 117 | + $fontsize_max = null, |
|
| 118 | + $background_type = null, |
|
| 119 | + $background_num = null |
|
| 120 | + ) { |
|
| 121 | + // Loading RUN-TIME settings |
|
| 122 | + foreach (array_keys($this->config) as $key) { |
|
| 123 | + if (isset(${$key}) && ${$key} !== null) { |
|
| 124 | + $this->config[$key] = ${$key}; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + $this->config['name'] = $name; |
|
| 128 | + |
|
| 129 | + // Skip CAPTCHA for member if set |
|
| 130 | + if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) { |
|
| 131 | + $this->active = false; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Verify user submission |
|
| 137 | + * @param null $skipMember |
|
| 138 | + * @return bool |
|
| 139 | + */ |
|
| 140 | + public function verify($skipMember = null) |
|
| 141 | + { |
|
| 142 | + $sessionName = @$_SESSION['XoopsCaptcha_name']; |
|
| 143 | + $skipMember = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember; |
|
| 144 | + $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 145 | + |
|
| 146 | + $is_valid = false; |
|
| 147 | + |
|
| 148 | + // Skip CAPTCHA for member if set |
|
| 149 | + if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) { |
|
| 150 | + $is_valid = true; |
|
| 151 | + // Kill too many attempts |
|
| 152 | + } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) { |
|
| 153 | + $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 154 | + |
|
| 155 | + // Verify the code |
|
| 156 | + } elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) { |
|
| 157 | + $func = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp'; |
|
| 158 | + $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if (!empty($maxAttempts)) { |
|
| 162 | + if (!$is_valid) { |
|
| 163 | + // Increase the attempt records on failure |
|
| 164 | + $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++; |
|
| 165 | + // Log the error message |
|
| 166 | + $this->message[] = XOOPS_CAPTCHA_INVALID_CODE; |
|
| 167 | + } else { |
|
| 168 | + |
|
| 169 | + // reset attempt records on success |
|
| 170 | + $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + $this->destroyGarbage(true); |
|
| 174 | + |
|
| 175 | + return $is_valid; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @return mixed|string |
|
| 180 | + */ |
|
| 181 | + public function getCaption() |
|
| 182 | + { |
|
| 183 | + return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : ''; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @return string |
|
| 188 | + */ |
|
| 189 | + public function getMessage() |
|
| 190 | + { |
|
| 191 | + return implode('<br>', $this->message); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Destory historical stuff |
|
| 196 | + * @param bool $clearSession |
|
| 197 | + * @return bool |
|
| 198 | + */ |
|
| 199 | + public function destroyGarbage($clearSession = false) |
|
| 200 | + { |
|
| 201 | + require_once __DIR__ . '/' . $this->mode . '.php'; |
|
| 202 | + $class = 'XoopsCaptcha' . ucfirst($this->mode); |
|
| 203 | + $captchaHandler = new $class(); |
|
| 204 | + if (method_exists($captchaHandler, 'destroyGarbage')) { |
|
| 205 | + $captchaHandler->loadConfig($this->config); |
|
| 206 | + $captchaHandler->destroyGarbage(); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if ($clearSession) { |
|
| 210 | + $_SESSION['XoopsCaptcha_name'] = null; |
|
| 211 | + $_SESSION['XoopsCaptcha_skipmember'] = null; |
|
| 212 | + $_SESSION['XoopsCaptcha_sessioncode'] = null; |
|
| 213 | + $_SESSION['XoopsCaptcha_maxattempts'] = null; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + return true; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * @return mixed|string |
|
| 221 | + */ |
|
| 222 | + public function render() |
|
| 223 | + { |
|
| 224 | + $form = ''; |
|
| 225 | + |
|
| 226 | + if (!$this->active || empty($this->config['name'])) { |
|
| 227 | + return $form; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + $_SESSION['XoopsCaptcha_name'] = $this->config['name']; |
|
| 231 | + $_SESSION['XoopsCaptcha_skipmember'] = $this->config['skipmember']; |
|
| 232 | + $maxAttempts = $this->config['maxattempt']; |
|
| 233 | + $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts; |
|
| 234 | + /* |
|
| 235 | 235 | if (!empty($maxAttempts)) { |
| 236 | 236 | $_SESSION['XoopsCaptcha_maxattempts_'.$_SESSION['XoopsCaptcha_name']] = $maxAttempts; |
| 237 | 237 | } |
| 238 | 238 | */ |
| 239 | 239 | |
| 240 | - // Fail on too many attempts |
|
| 241 | - if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) { |
|
| 242 | - $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 243 | - // Load the form element |
|
| 244 | - } else { |
|
| 245 | - $form = $this->loadForm(); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - return $form; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * @return mixed |
|
| 253 | - */ |
|
| 254 | - public function loadForm() |
|
| 255 | - { |
|
| 256 | - require_once __DIR__ . '/' . $this->mode . '.php'; |
|
| 257 | - $class = 'XoopsCaptcha' . ucfirst($this->mode); |
|
| 258 | - $captchaHandler = new $class(); |
|
| 259 | - $captchaHandler->loadConfig($this->config); |
|
| 260 | - |
|
| 261 | - $form = $captchaHandler->render(); |
|
| 262 | - |
|
| 263 | - return $form; |
|
| 264 | - } |
|
| 240 | + // Fail on too many attempts |
|
| 241 | + if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) { |
|
| 242 | + $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS; |
|
| 243 | + // Load the form element |
|
| 244 | + } else { |
|
| 245 | + $form = $this->loadForm(); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + return $form; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * @return mixed |
|
| 253 | + */ |
|
| 254 | + public function loadForm() |
|
| 255 | + { |
|
| 256 | + require_once __DIR__ . '/' . $this->mode . '.php'; |
|
| 257 | + $class = 'XoopsCaptcha' . ucfirst($this->mode); |
|
| 258 | + $captchaHandler = new $class(); |
|
| 259 | + $captchaHandler->loadConfig($this->config); |
|
| 260 | + |
|
| 261 | + $form = $captchaHandler->render(); |
|
| 262 | + |
|
| 263 | + return $form; |
|
| 264 | + } |
|
| 265 | 265 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $xoopsLogger->activated = false; |
| 11 | 11 | |
| 12 | 12 | if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/^' . preg_quote(XOOPS_URL, '/') . '/', $_SERVER['HTTP_REFERER'])) { |
| 13 | - exit(); |
|
| 13 | + exit(); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -18,192 +18,192 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class XoopsCaptchaImageHandler |
| 20 | 20 | { |
| 21 | - public $config = array(); |
|
| 22 | - //var $mode = "gd"; // GD or bmp |
|
| 23 | - public $code; |
|
| 24 | - public $invalid = false; |
|
| 25 | - |
|
| 26 | - public $font; |
|
| 27 | - public $spacing; |
|
| 28 | - public $width; |
|
| 29 | - public $height; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * XoopsCaptchaImageHandler constructor. |
|
| 33 | - */ |
|
| 34 | - public function __construct() |
|
| 35 | - { |
|
| 36 | - if (empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 37 | - $this->invalid = true; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if (!extension_loaded('gd')) { |
|
| 41 | - $this->mode = 'bmp'; |
|
| 42 | - } else { |
|
| 43 | - $required_functions = array( |
|
| 44 | - 'imagecreatetruecolor', |
|
| 45 | - 'imagecolorallocate', |
|
| 46 | - 'imagefilledrectangle', |
|
| 47 | - 'imagejpeg', |
|
| 48 | - 'imagedestroy', |
|
| 49 | - 'imageftbbox' |
|
| 50 | - ); |
|
| 51 | - foreach ($required_functions as $func) { |
|
| 52 | - if (!function_exists($func)) { |
|
| 53 | - $this->mode = 'bmp'; |
|
| 54 | - break; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Loading configs from CAPTCHA class |
|
| 62 | - * @param array $config |
|
| 63 | - */ |
|
| 64 | - public function setConfig($config = array()) |
|
| 65 | - { |
|
| 66 | - // Loading default preferences |
|
| 67 | - $this->config = $config; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function loadImage() |
|
| 71 | - { |
|
| 72 | - $this->createCode(); |
|
| 73 | - $this->setCode(); |
|
| 74 | - $this->createImage(); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Create Code |
|
| 79 | - */ |
|
| 80 | - public function createCode() |
|
| 81 | - { |
|
| 82 | - if ($this->invalid) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if ($this->mode === 'bmp') { |
|
| 87 | - $this->config['num_chars'] = 4; |
|
| 88 | - $this->code = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9')); |
|
| 89 | - } else { |
|
| 90 | - $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']); |
|
| 91 | - if (!$this->config['casesensitive']) { |
|
| 92 | - $this->code = strtoupper($this->code); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function setCode() |
|
| 98 | - { |
|
| 99 | - if ($this->invalid) { |
|
| 100 | - return; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code; |
|
| 104 | - $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 105 | - |
|
| 106 | - // Increase the attempt records on refresh |
|
| 107 | - if (!empty($maxAttempts)) { |
|
| 108 | - $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++; |
|
| 109 | - if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 110 | - $this->invalid = true; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @param string $file |
|
| 117 | - * @return string|void |
|
| 118 | - */ |
|
| 119 | - public function createImage($file = '') |
|
| 120 | - { |
|
| 121 | - if ($this->invalid) { |
|
| 122 | - header('Content-type: image/gif'); |
|
| 123 | - readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif'); |
|
| 124 | - |
|
| 125 | - return; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ($this->mode === 'bmp') { |
|
| 129 | - return $this->createImageBmp(); |
|
| 130 | - } else { |
|
| 131 | - return $this->createImageGd(); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Create CAPTCHA iamge with GD |
|
| 137 | - * Originated from DuGris' SecurityImage |
|
| 138 | - * @param string $file |
|
| 139 | - */ |
|
| 140 | - // --------------------------------------------------------------------------- // |
|
| 141 | - // Class: SecurityImage 1.5 // |
|
| 142 | - // Author: DuGris aka L. Jen <http://www.dugris.info> // |
|
| 143 | - // Email: [email protected] // |
|
| 144 | - // Licence: GNU // |
|
| 145 | - // Project: XOOPS Project // |
|
| 146 | - // --------------------------------------------------------------------------- // |
|
| 147 | - public function createImageGd($file = '') |
|
| 148 | - { |
|
| 149 | - $this->loadFont(); |
|
| 150 | - $this->setImageSize(); |
|
| 151 | - |
|
| 152 | - $this->oImage = imagecreatetruecolor($this->width, $this->height); |
|
| 153 | - $background = imagecolorallocate($this->oImage, 255, 255, 255); |
|
| 154 | - imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background); |
|
| 155 | - |
|
| 156 | - switch ($this->config['background_type']) { |
|
| 157 | - default: |
|
| 158 | - case 0: |
|
| 159 | - $this->drawBars(); |
|
| 160 | - break; |
|
| 161 | - |
|
| 162 | - case 1: |
|
| 163 | - $this->drawCircles(); |
|
| 164 | - break; |
|
| 165 | - |
|
| 166 | - case 2: |
|
| 167 | - $this->drawLines(); |
|
| 168 | - break; |
|
| 169 | - |
|
| 170 | - case 3: |
|
| 171 | - $this->drawRectangles(); |
|
| 172 | - break; |
|
| 173 | - |
|
| 174 | - case 4: |
|
| 175 | - $this->drawEllipses(); |
|
| 176 | - break; |
|
| 177 | - |
|
| 178 | - case 5: |
|
| 179 | - $this->drawPolygons(); |
|
| 180 | - break; |
|
| 181 | - |
|
| 182 | - case 100: |
|
| 183 | - $this->createFromFile(); |
|
| 184 | - break; |
|
| 185 | - } |
|
| 186 | - $this->drawBorder(); |
|
| 187 | - $this->drawCode(); |
|
| 188 | - |
|
| 189 | - if (empty($file)) { |
|
| 190 | - header('Content-type: image/jpeg'); |
|
| 191 | - imagejpeg($this->oImage); |
|
| 192 | - } else { |
|
| 193 | - imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg'); |
|
| 194 | - } |
|
| 195 | - imagedestroy($this->oImage); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @param $name |
|
| 200 | - * @param string $extension |
|
| 201 | - * @return array |
|
| 202 | - */ |
|
| 203 | - public function _getList($name, $extension = '') |
|
| 204 | - { |
|
| 205 | - $items = array(); |
|
| 206 | - /* |
|
| 21 | + public $config = array(); |
|
| 22 | + //var $mode = "gd"; // GD or bmp |
|
| 23 | + public $code; |
|
| 24 | + public $invalid = false; |
|
| 25 | + |
|
| 26 | + public $font; |
|
| 27 | + public $spacing; |
|
| 28 | + public $width; |
|
| 29 | + public $height; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * XoopsCaptchaImageHandler constructor. |
|
| 33 | + */ |
|
| 34 | + public function __construct() |
|
| 35 | + { |
|
| 36 | + if (empty($_SESSION['XoopsCaptcha_name'])) { |
|
| 37 | + $this->invalid = true; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if (!extension_loaded('gd')) { |
|
| 41 | + $this->mode = 'bmp'; |
|
| 42 | + } else { |
|
| 43 | + $required_functions = array( |
|
| 44 | + 'imagecreatetruecolor', |
|
| 45 | + 'imagecolorallocate', |
|
| 46 | + 'imagefilledrectangle', |
|
| 47 | + 'imagejpeg', |
|
| 48 | + 'imagedestroy', |
|
| 49 | + 'imageftbbox' |
|
| 50 | + ); |
|
| 51 | + foreach ($required_functions as $func) { |
|
| 52 | + if (!function_exists($func)) { |
|
| 53 | + $this->mode = 'bmp'; |
|
| 54 | + break; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Loading configs from CAPTCHA class |
|
| 62 | + * @param array $config |
|
| 63 | + */ |
|
| 64 | + public function setConfig($config = array()) |
|
| 65 | + { |
|
| 66 | + // Loading default preferences |
|
| 67 | + $this->config = $config; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function loadImage() |
|
| 71 | + { |
|
| 72 | + $this->createCode(); |
|
| 73 | + $this->setCode(); |
|
| 74 | + $this->createImage(); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Create Code |
|
| 79 | + */ |
|
| 80 | + public function createCode() |
|
| 81 | + { |
|
| 82 | + if ($this->invalid) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if ($this->mode === 'bmp') { |
|
| 87 | + $this->config['num_chars'] = 4; |
|
| 88 | + $this->code = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9')); |
|
| 89 | + } else { |
|
| 90 | + $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']); |
|
| 91 | + if (!$this->config['casesensitive']) { |
|
| 92 | + $this->code = strtoupper($this->code); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function setCode() |
|
| 98 | + { |
|
| 99 | + if ($this->invalid) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code; |
|
| 104 | + $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 105 | + |
|
| 106 | + // Increase the attempt records on refresh |
|
| 107 | + if (!empty($maxAttempts)) { |
|
| 108 | + $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++; |
|
| 109 | + if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 110 | + $this->invalid = true; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @param string $file |
|
| 117 | + * @return string|void |
|
| 118 | + */ |
|
| 119 | + public function createImage($file = '') |
|
| 120 | + { |
|
| 121 | + if ($this->invalid) { |
|
| 122 | + header('Content-type: image/gif'); |
|
| 123 | + readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif'); |
|
| 124 | + |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ($this->mode === 'bmp') { |
|
| 129 | + return $this->createImageBmp(); |
|
| 130 | + } else { |
|
| 131 | + return $this->createImageGd(); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Create CAPTCHA iamge with GD |
|
| 137 | + * Originated from DuGris' SecurityImage |
|
| 138 | + * @param string $file |
|
| 139 | + */ |
|
| 140 | + // --------------------------------------------------------------------------- // |
|
| 141 | + // Class: SecurityImage 1.5 // |
|
| 142 | + // Author: DuGris aka L. Jen <http://www.dugris.info> // |
|
| 143 | + // Email: [email protected] // |
|
| 144 | + // Licence: GNU // |
|
| 145 | + // Project: XOOPS Project // |
|
| 146 | + // --------------------------------------------------------------------------- // |
|
| 147 | + public function createImageGd($file = '') |
|
| 148 | + { |
|
| 149 | + $this->loadFont(); |
|
| 150 | + $this->setImageSize(); |
|
| 151 | + |
|
| 152 | + $this->oImage = imagecreatetruecolor($this->width, $this->height); |
|
| 153 | + $background = imagecolorallocate($this->oImage, 255, 255, 255); |
|
| 154 | + imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background); |
|
| 155 | + |
|
| 156 | + switch ($this->config['background_type']) { |
|
| 157 | + default: |
|
| 158 | + case 0: |
|
| 159 | + $this->drawBars(); |
|
| 160 | + break; |
|
| 161 | + |
|
| 162 | + case 1: |
|
| 163 | + $this->drawCircles(); |
|
| 164 | + break; |
|
| 165 | + |
|
| 166 | + case 2: |
|
| 167 | + $this->drawLines(); |
|
| 168 | + break; |
|
| 169 | + |
|
| 170 | + case 3: |
|
| 171 | + $this->drawRectangles(); |
|
| 172 | + break; |
|
| 173 | + |
|
| 174 | + case 4: |
|
| 175 | + $this->drawEllipses(); |
|
| 176 | + break; |
|
| 177 | + |
|
| 178 | + case 5: |
|
| 179 | + $this->drawPolygons(); |
|
| 180 | + break; |
|
| 181 | + |
|
| 182 | + case 100: |
|
| 183 | + $this->createFromFile(); |
|
| 184 | + break; |
|
| 185 | + } |
|
| 186 | + $this->drawBorder(); |
|
| 187 | + $this->drawCode(); |
|
| 188 | + |
|
| 189 | + if (empty($file)) { |
|
| 190 | + header('Content-type: image/jpeg'); |
|
| 191 | + imagejpeg($this->oImage); |
|
| 192 | + } else { |
|
| 193 | + imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg'); |
|
| 194 | + } |
|
| 195 | + imagedestroy($this->oImage); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @param $name |
|
| 200 | + * @param string $extension |
|
| 201 | + * @return array |
|
| 202 | + */ |
|
| 203 | + public function _getList($name, $extension = '') |
|
| 204 | + { |
|
| 205 | + $items = array(); |
|
| 206 | + /* |
|
| 207 | 207 | if (@ require_once XOOPS_ROOT_PATH."/Frameworks/art/functions.ini.php") { |
| 208 | 208 | load_functions("cache"); |
| 209 | 209 | if ($items = mod_loadCacheFile("captcha_{$name}", "captcha")) { |
@@ -211,231 +211,231 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | */ |
| 214 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 215 | - $file_path = $this->config['rootpath'] . "/{$name}"; |
|
| 216 | - $files = XoopsLists::getFileListAsArray($file_path); |
|
| 217 | - foreach ($files as $item) { |
|
| 218 | - if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) { |
|
| 219 | - $items[] = $item; |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - if (function_exists('mod_createCacheFile')) { |
|
| 223 | - mod_createCacheFile($items, "captcha_{$name}", 'captcha'); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - return $items; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - public function loadFont() |
|
| 230 | - { |
|
| 231 | - $fonts = $this->_getList('fonts', 'ttf'); |
|
| 232 | - $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)]; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - public function setImageSize() |
|
| 236 | - { |
|
| 237 | - $MaxCharWidth = 0; |
|
| 238 | - $MaxCharHeight = 0; |
|
| 239 | - $oImage = imagecreatetruecolor(100, 100); |
|
| 240 | - $text_color = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 241 | - $FontSize = $this->config['fontsize_max']; |
|
| 242 | - for ($Angle = -30; $Angle <= 30; ++$Angle) { |
|
| 243 | - for ($i = 65; $i <= 90; ++$i) { |
|
| 244 | - $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array()); |
|
| 245 | - $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 246 | - if ($_MaxCharWidth > $MaxCharWidth) { |
|
| 247 | - $MaxCharWidth = $_MaxCharWidth; |
|
| 248 | - } |
|
| 249 | - $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 250 | - if ($_MaxCharHeight > $MaxCharHeight) { |
|
| 251 | - $MaxCharHeight = $_MaxCharHeight; |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - imagedestroy($oImage); |
|
| 256 | - |
|
| 257 | - $this->height = $MaxCharHeight + 2; |
|
| 258 | - $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']); |
|
| 259 | - $this->width = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * Return random background |
|
| 264 | - * |
|
| 265 | - * @return array |
|
| 266 | - */ |
|
| 267 | - public function loadBackground() |
|
| 268 | - { |
|
| 269 | - $RandBackground = null; |
|
| 270 | - if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) { |
|
| 271 | - $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)]; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - return $RandBackground; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Draw Image background |
|
| 279 | - */ |
|
| 280 | - public function createFromFile() |
|
| 281 | - { |
|
| 282 | - if ($RandImage = $this->loadBackground()) { |
|
| 283 | - $ImageType = @getimagesize($RandImage); |
|
| 284 | - switch (@$ImageType[2]) { |
|
| 285 | - case 1: |
|
| 286 | - $BackgroundImage = imagecreatefromgif($RandImage); |
|
| 287 | - break; |
|
| 288 | - |
|
| 289 | - case 2: |
|
| 290 | - $BackgroundImage = imagecreatefromjpeg($RandImage); |
|
| 291 | - break; |
|
| 292 | - |
|
| 293 | - case 3: |
|
| 294 | - $BackgroundImage = imagecreatefrompng($RandImage); |
|
| 295 | - break; |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - if (!empty($BackgroundImage)) { |
|
| 299 | - imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage)); |
|
| 300 | - imagedestroy($BackgroundImage); |
|
| 301 | - } else { |
|
| 302 | - $this->drawBars(); |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Draw Code |
|
| 308 | - */ |
|
| 309 | - public function drawCode() |
|
| 310 | - { |
|
| 311 | - for ($i = 0; $i < $this->config['num_chars']; ++$i) { |
|
| 312 | - // select random greyscale colour |
|
| 313 | - $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 314 | - |
|
| 315 | - // write text to image |
|
| 316 | - $Angle = mt_rand(10, 30); |
|
| 317 | - if ($i % 2) { |
|
| 318 | - $Angle = mt_rand(-10, -30); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - // select random font size |
|
| 322 | - $FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']); |
|
| 323 | - |
|
| 324 | - $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array()); |
|
| 325 | - $CharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 326 | - |
|
| 327 | - // calculate character starting coordinates |
|
| 328 | - $posX = ($this->spacing / 2) + ($i * $this->spacing); |
|
| 329 | - $posY = 2 + ($this->height / 2) + ($CharHeight / 4); |
|
| 330 | - |
|
| 331 | - imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array()); |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Draw Border |
|
| 337 | - */ |
|
| 338 | - public function drawBorder() |
|
| 339 | - { |
|
| 340 | - $rgb = mt_rand(50, 150); |
|
| 341 | - $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb); |
|
| 342 | - imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * Draw Circles background |
|
| 347 | - */ |
|
| 348 | - public function drawCircles() |
|
| 349 | - { |
|
| 350 | - for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 351 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 352 | - imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor); |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Draw Lines background |
|
| 358 | - */ |
|
| 359 | - public function drawLines() |
|
| 360 | - { |
|
| 361 | - for ($i = 0; $i < $this->config['background_num']; ++$i) { |
|
| 362 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 363 | - imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Draw Rectangles background |
|
| 369 | - */ |
|
| 370 | - public function drawRectangles() |
|
| 371 | - { |
|
| 372 | - for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 373 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 374 | - imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * Draw Bars background |
|
| 380 | - */ |
|
| 381 | - public function drawBars() |
|
| 382 | - { |
|
| 383 | - for ($i = 0; $i <= $this->height;) { |
|
| 384 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 385 | - imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor); |
|
| 386 | - $i += 2.5; |
|
| 387 | - } |
|
| 388 | - for ($i = 0; $i <= $this->width;) { |
|
| 389 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 390 | - imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor); |
|
| 391 | - $i += 2.5; |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Draw Ellipses background |
|
| 397 | - */ |
|
| 398 | - public function drawEllipses() |
|
| 399 | - { |
|
| 400 | - for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 401 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 402 | - imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Draw polygons background |
|
| 408 | - */ |
|
| 409 | - public function drawPolygons() |
|
| 410 | - { |
|
| 411 | - for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 412 | - $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 413 | - $coords = array(); |
|
| 414 | - for ($j = 1; $j <= $this->config['polygon_point']; ++$j) { |
|
| 415 | - $coords[] = mt_rand(0, $this->width); |
|
| 416 | - $coords[] = mt_rand(0, $this->height); |
|
| 417 | - } |
|
| 418 | - imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor); |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * Create CAPTCHA iamge with BMP |
|
| 424 | - * TODO |
|
| 425 | - * @param string $file |
|
| 426 | - * @return string |
|
| 427 | - */ |
|
| 428 | - public function createImageBmp($file = '') |
|
| 429 | - { |
|
| 430 | - $image = ''; |
|
| 431 | - |
|
| 432 | - if (empty($file)) { |
|
| 433 | - header('Content-type: image/bmp'); |
|
| 434 | - echo $image; |
|
| 435 | - } else { |
|
| 436 | - return $image; |
|
| 437 | - } |
|
| 438 | - } |
|
| 214 | + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 215 | + $file_path = $this->config['rootpath'] . "/{$name}"; |
|
| 216 | + $files = XoopsLists::getFileListAsArray($file_path); |
|
| 217 | + foreach ($files as $item) { |
|
| 218 | + if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) { |
|
| 219 | + $items[] = $item; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + if (function_exists('mod_createCacheFile')) { |
|
| 223 | + mod_createCacheFile($items, "captcha_{$name}", 'captcha'); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + return $items; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + public function loadFont() |
|
| 230 | + { |
|
| 231 | + $fonts = $this->_getList('fonts', 'ttf'); |
|
| 232 | + $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)]; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + public function setImageSize() |
|
| 236 | + { |
|
| 237 | + $MaxCharWidth = 0; |
|
| 238 | + $MaxCharHeight = 0; |
|
| 239 | + $oImage = imagecreatetruecolor(100, 100); |
|
| 240 | + $text_color = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 241 | + $FontSize = $this->config['fontsize_max']; |
|
| 242 | + for ($Angle = -30; $Angle <= 30; ++$Angle) { |
|
| 243 | + for ($i = 65; $i <= 90; ++$i) { |
|
| 244 | + $CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array()); |
|
| 245 | + $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]); |
|
| 246 | + if ($_MaxCharWidth > $MaxCharWidth) { |
|
| 247 | + $MaxCharWidth = $_MaxCharWidth; |
|
| 248 | + } |
|
| 249 | + $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 250 | + if ($_MaxCharHeight > $MaxCharHeight) { |
|
| 251 | + $MaxCharHeight = $_MaxCharHeight; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + imagedestroy($oImage); |
|
| 256 | + |
|
| 257 | + $this->height = $MaxCharHeight + 2; |
|
| 258 | + $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']); |
|
| 259 | + $this->width = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * Return random background |
|
| 264 | + * |
|
| 265 | + * @return array |
|
| 266 | + */ |
|
| 267 | + public function loadBackground() |
|
| 268 | + { |
|
| 269 | + $RandBackground = null; |
|
| 270 | + if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) { |
|
| 271 | + $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)]; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + return $RandBackground; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Draw Image background |
|
| 279 | + */ |
|
| 280 | + public function createFromFile() |
|
| 281 | + { |
|
| 282 | + if ($RandImage = $this->loadBackground()) { |
|
| 283 | + $ImageType = @getimagesize($RandImage); |
|
| 284 | + switch (@$ImageType[2]) { |
|
| 285 | + case 1: |
|
| 286 | + $BackgroundImage = imagecreatefromgif($RandImage); |
|
| 287 | + break; |
|
| 288 | + |
|
| 289 | + case 2: |
|
| 290 | + $BackgroundImage = imagecreatefromjpeg($RandImage); |
|
| 291 | + break; |
|
| 292 | + |
|
| 293 | + case 3: |
|
| 294 | + $BackgroundImage = imagecreatefrompng($RandImage); |
|
| 295 | + break; |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + if (!empty($BackgroundImage)) { |
|
| 299 | + imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage)); |
|
| 300 | + imagedestroy($BackgroundImage); |
|
| 301 | + } else { |
|
| 302 | + $this->drawBars(); |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Draw Code |
|
| 308 | + */ |
|
| 309 | + public function drawCode() |
|
| 310 | + { |
|
| 311 | + for ($i = 0; $i < $this->config['num_chars']; ++$i) { |
|
| 312 | + // select random greyscale colour |
|
| 313 | + $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); |
|
| 314 | + |
|
| 315 | + // write text to image |
|
| 316 | + $Angle = mt_rand(10, 30); |
|
| 317 | + if ($i % 2) { |
|
| 318 | + $Angle = mt_rand(-10, -30); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + // select random font size |
|
| 322 | + $FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']); |
|
| 323 | + |
|
| 324 | + $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array()); |
|
| 325 | + $CharHeight = abs($CharDetails[1] + $CharDetails[5]); |
|
| 326 | + |
|
| 327 | + // calculate character starting coordinates |
|
| 328 | + $posX = ($this->spacing / 2) + ($i * $this->spacing); |
|
| 329 | + $posY = 2 + ($this->height / 2) + ($CharHeight / 4); |
|
| 330 | + |
|
| 331 | + imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array()); |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Draw Border |
|
| 337 | + */ |
|
| 338 | + public function drawBorder() |
|
| 339 | + { |
|
| 340 | + $rgb = mt_rand(50, 150); |
|
| 341 | + $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb); |
|
| 342 | + imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * Draw Circles background |
|
| 347 | + */ |
|
| 348 | + public function drawCircles() |
|
| 349 | + { |
|
| 350 | + for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 351 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 352 | + imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor); |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Draw Lines background |
|
| 358 | + */ |
|
| 359 | + public function drawLines() |
|
| 360 | + { |
|
| 361 | + for ($i = 0; $i < $this->config['background_num']; ++$i) { |
|
| 362 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 363 | + imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Draw Rectangles background |
|
| 369 | + */ |
|
| 370 | + public function drawRectangles() |
|
| 371 | + { |
|
| 372 | + for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 373 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 374 | + imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Draw Bars background |
|
| 380 | + */ |
|
| 381 | + public function drawBars() |
|
| 382 | + { |
|
| 383 | + for ($i = 0; $i <= $this->height;) { |
|
| 384 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 385 | + imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor); |
|
| 386 | + $i += 2.5; |
|
| 387 | + } |
|
| 388 | + for ($i = 0; $i <= $this->width;) { |
|
| 389 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 390 | + imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor); |
|
| 391 | + $i += 2.5; |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Draw Ellipses background |
|
| 397 | + */ |
|
| 398 | + public function drawEllipses() |
|
| 399 | + { |
|
| 400 | + for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 401 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 402 | + imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor); |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Draw polygons background |
|
| 408 | + */ |
|
| 409 | + public function drawPolygons() |
|
| 410 | + { |
|
| 411 | + for ($i = 1; $i <= $this->config['background_num']; ++$i) { |
|
| 412 | + $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255)); |
|
| 413 | + $coords = array(); |
|
| 414 | + for ($j = 1; $j <= $this->config['polygon_point']; ++$j) { |
|
| 415 | + $coords[] = mt_rand(0, $this->width); |
|
| 416 | + $coords[] = mt_rand(0, $this->height); |
|
| 417 | + } |
|
| 418 | + imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor); |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * Create CAPTCHA iamge with BMP |
|
| 424 | + * TODO |
|
| 425 | + * @param string $file |
|
| 426 | + * @return string |
|
| 427 | + */ |
|
| 428 | + public function createImageBmp($file = '') |
|
| 429 | + { |
|
| 430 | + $image = ''; |
|
| 431 | + |
|
| 432 | + if (empty($file)) { |
|
| 433 | + header('Content-type: image/bmp'); |
|
| 434 | + echo $image; |
|
| 435 | + } else { |
|
| 436 | + return $image; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $config = @include __DIR__ . '/../config.php'; |
@@ -38,60 +38,60 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class XoopsFormCaptcha extends XoopsFormElement |
| 40 | 40 | { |
| 41 | - public $_captchaHandler; |
|
| 41 | + public $_captchaHandler; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $caption Caption of the form element, default value is defined in captcha/language/ |
|
| 45 | - * @param string $name Name for the input box |
|
| 46 | - * @param boolean $skipmember Skip CAPTCHA check for members |
|
| 47 | - * @param int $numchar Number of characters in image mode, and input box size for text mode |
|
| 48 | - * @param int $minfontsize Minimum font-size of characters in image mode |
|
| 49 | - * @param int $maxfontsize Maximum font-size of characters in image mode |
|
| 50 | - * @param int $backgroundtype Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files |
|
| 51 | - * @param int $backgroundnum Number of background images in image mode |
|
| 52 | - * |
|
| 53 | - */ |
|
| 54 | - public function __construct( |
|
| 55 | - $caption = '', |
|
| 56 | - $name = 'xoopscaptcha', |
|
| 57 | - $skipmember = null, |
|
| 58 | - $numchar = null, |
|
| 59 | - $minfontsize = null, |
|
| 60 | - $maxfontsize = null, |
|
| 61 | - $backgroundtype = null, |
|
| 62 | - $backgroundnum = null |
|
| 63 | - ) { |
|
| 64 | - if (!class_exists('XoopsCaptcaha')) { |
|
| 65 | - require_once SMARTOBJECT_ROOT_PATH . '/include/captcha/captcha.php'; |
|
| 66 | - } |
|
| 43 | + /** |
|
| 44 | + * @param string $caption Caption of the form element, default value is defined in captcha/language/ |
|
| 45 | + * @param string $name Name for the input box |
|
| 46 | + * @param boolean $skipmember Skip CAPTCHA check for members |
|
| 47 | + * @param int $numchar Number of characters in image mode, and input box size for text mode |
|
| 48 | + * @param int $minfontsize Minimum font-size of characters in image mode |
|
| 49 | + * @param int $maxfontsize Maximum font-size of characters in image mode |
|
| 50 | + * @param int $backgroundtype Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files |
|
| 51 | + * @param int $backgroundnum Number of background images in image mode |
|
| 52 | + * |
|
| 53 | + */ |
|
| 54 | + public function __construct( |
|
| 55 | + $caption = '', |
|
| 56 | + $name = 'xoopscaptcha', |
|
| 57 | + $skipmember = null, |
|
| 58 | + $numchar = null, |
|
| 59 | + $minfontsize = null, |
|
| 60 | + $maxfontsize = null, |
|
| 61 | + $backgroundtype = null, |
|
| 62 | + $backgroundnum = null |
|
| 63 | + ) { |
|
| 64 | + if (!class_exists('XoopsCaptcaha')) { |
|
| 65 | + require_once SMARTOBJECT_ROOT_PATH . '/include/captcha/captcha.php'; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $this->_captchaHandler = XoopsCaptcha::getInstance(); |
|
| 69 | - $this->_captchaHandler->init($name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum); |
|
| 70 | - if (!$this->_captchaHandler->active) { |
|
| 71 | - $this->setHidden(); |
|
| 72 | - } else { |
|
| 73 | - $caption = !empty($caption) ? $caption : $this->_captchaHandler->getCaption(); |
|
| 74 | - $this->setCaption($caption); |
|
| 75 | - } |
|
| 76 | - } |
|
| 68 | + $this->_captchaHandler = XoopsCaptcha::getInstance(); |
|
| 69 | + $this->_captchaHandler->init($name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum); |
|
| 70 | + if (!$this->_captchaHandler->active) { |
|
| 71 | + $this->setHidden(); |
|
| 72 | + } else { |
|
| 73 | + $caption = !empty($caption) ? $caption : $this->_captchaHandler->getCaption(); |
|
| 74 | + $this->setCaption($caption); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param $name |
|
| 80 | - * @param $val |
|
| 81 | - * @return bool |
|
| 82 | - */ |
|
| 83 | - public function setConfig($name, $val) |
|
| 84 | - { |
|
| 85 | - return $this->_captchaHandler->setConfig($name, $val); |
|
| 86 | - } |
|
| 78 | + /** |
|
| 79 | + * @param $name |
|
| 80 | + * @param $val |
|
| 81 | + * @return bool |
|
| 82 | + */ |
|
| 83 | + public function setConfig($name, $val) |
|
| 84 | + { |
|
| 85 | + return $this->_captchaHandler->setConfig($name, $val); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @return mixed|string |
|
| 90 | - */ |
|
| 91 | - public function render() |
|
| 92 | - { |
|
| 93 | - if (!$this->isHidden()) { |
|
| 94 | - return $this->_captchaHandler->render(); |
|
| 95 | - } |
|
| 96 | - } |
|
| 88 | + /** |
|
| 89 | + * @return mixed|string |
|
| 90 | + */ |
|
| 91 | + public function render() |
|
| 92 | + { |
|
| 93 | + if (!$this->isHidden()) { |
|
| 94 | + return $this->_captchaHandler->render(); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -7,75 +7,75 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class XoopsCaptchaText |
| 9 | 9 | { |
| 10 | - public $config = array(); |
|
| 11 | - public $code; |
|
| 10 | + public $config = array(); |
|
| 11 | + public $code; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * XoopsCaptchaText constructor. |
|
| 15 | - */ |
|
| 16 | - public function __construct() |
|
| 17 | - { |
|
| 18 | - } |
|
| 13 | + /** |
|
| 14 | + * XoopsCaptchaText constructor. |
|
| 15 | + */ |
|
| 16 | + public function __construct() |
|
| 17 | + { |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return XoopsCaptchaText |
|
| 22 | - */ |
|
| 23 | - public static function getInstance() |
|
| 24 | - { |
|
| 25 | - static $instance; |
|
| 26 | - if (null === $instance) { |
|
| 27 | - $instance = new static(); |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * @return XoopsCaptchaText |
|
| 22 | + */ |
|
| 23 | + public static function getInstance() |
|
| 24 | + { |
|
| 25 | + static $instance; |
|
| 26 | + if (null === $instance) { |
|
| 27 | + $instance = new static(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - return $instance; |
|
| 31 | - } |
|
| 30 | + return $instance; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Loading configs from CAPTCHA class |
|
| 35 | - * @param array $config |
|
| 36 | - */ |
|
| 37 | - public function loadConfig($config = array()) |
|
| 38 | - { |
|
| 39 | - // Loading default preferences |
|
| 40 | - $this->config = $config; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * Loading configs from CAPTCHA class |
|
| 35 | + * @param array $config |
|
| 36 | + */ |
|
| 37 | + public function loadConfig($config = array()) |
|
| 38 | + { |
|
| 39 | + // Loading default preferences |
|
| 40 | + $this->config = $config; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function setCode() |
|
| 44 | - { |
|
| 45 | - $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code; |
|
| 46 | - } |
|
| 43 | + public function setCode() |
|
| 44 | + { |
|
| 45 | + $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public function render() |
|
| 52 | - { |
|
| 53 | - $form = $this->loadText() . " <input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''>"; |
|
| 54 | - $rule = constant('XOOPS_CAPTCHA_RULE_TEXT'); |
|
| 55 | - if (!empty($rule)) { |
|
| 56 | - $form .= " <small>{$rule}</small>"; |
|
| 57 | - } |
|
| 48 | + /** |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public function render() |
|
| 52 | + { |
|
| 53 | + $form = $this->loadText() . " <input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''>"; |
|
| 54 | + $rule = constant('XOOPS_CAPTCHA_RULE_TEXT'); |
|
| 55 | + if (!empty($rule)) { |
|
| 56 | + $form .= " <small>{$rule}</small>"; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $this->setCode(); |
|
| 59 | + $this->setCode(); |
|
| 60 | 60 | |
| 61 | - return $form; |
|
| 62 | - } |
|
| 61 | + return $form; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 67 | - public function loadText() |
|
| 68 | - { |
|
| 69 | - $val_a = mt_rand(0, 9); |
|
| 70 | - $val_b = mt_rand(0, 9); |
|
| 71 | - if ($val_a > $val_b) { |
|
| 72 | - $expression = "{$val_a} - {$val_b} = ?"; |
|
| 73 | - $this->code = $val_a - $val_b; |
|
| 74 | - } else { |
|
| 75 | - $expression = "{$val_a} + {$val_b} = ?"; |
|
| 76 | - $this->code = $val_a + $val_b; |
|
| 77 | - } |
|
| 64 | + /** |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | + public function loadText() |
|
| 68 | + { |
|
| 69 | + $val_a = mt_rand(0, 9); |
|
| 70 | + $val_b = mt_rand(0, 9); |
|
| 71 | + if ($val_a > $val_b) { |
|
| 72 | + $expression = "{$val_a} - {$val_b} = ?"; |
|
| 73 | + $this->code = $val_a - $val_b; |
|
| 74 | + } else { |
|
| 75 | + $expression = "{$val_a} + {$val_b} = ?"; |
|
| 76 | + $this->code = $val_a + $val_b; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>"; |
|
| 80 | - } |
|
| 79 | + return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>"; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -7,62 +7,62 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class XoopsCaptchaImage |
| 9 | 9 | { |
| 10 | - public $config = array(); |
|
| 10 | + public $config = array(); |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * XoopsCaptchaImage constructor. |
|
| 14 | - */ |
|
| 15 | - public function __construct() |
|
| 16 | - { |
|
| 17 | - //$this->name = md5( session_id() ); |
|
| 18 | - } |
|
| 12 | + /** |
|
| 13 | + * XoopsCaptchaImage constructor. |
|
| 14 | + */ |
|
| 15 | + public function __construct() |
|
| 16 | + { |
|
| 17 | + //$this->name = md5( session_id() ); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return XoopsCaptchaImage |
|
| 22 | - */ |
|
| 23 | - public static function getInstance() |
|
| 24 | - { |
|
| 25 | - static $instance; |
|
| 26 | - if (null === $instance) { |
|
| 27 | - $instance = new static(); |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * @return XoopsCaptchaImage |
|
| 22 | + */ |
|
| 23 | + public static function getInstance() |
|
| 24 | + { |
|
| 25 | + static $instance; |
|
| 26 | + if (null === $instance) { |
|
| 27 | + $instance = new static(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - return $instance; |
|
| 31 | - } |
|
| 30 | + return $instance; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Loading configs from CAPTCHA class |
|
| 35 | - * @param array $config |
|
| 36 | - */ |
|
| 37 | - public function loadConfig($config = array()) |
|
| 38 | - { |
|
| 39 | - // Loading default preferences |
|
| 40 | - $this->config = $config; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * Loading configs from CAPTCHA class |
|
| 35 | + * @param array $config |
|
| 36 | + */ |
|
| 37 | + public function loadConfig($config = array()) |
|
| 38 | + { |
|
| 39 | + // Loading default preferences |
|
| 40 | + $this->config = $config; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 46 | - public function render() |
|
| 47 | - { |
|
| 48 | - $form = "<input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''> " . $this->loadImage(); |
|
| 49 | - $rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES); |
|
| 50 | - if ($this->config['maxattempt']) { |
|
| 51 | - $rule .= ' | ' . sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']); |
|
| 52 | - } |
|
| 53 | - $form .= " <small>{$rule}</small>"; |
|
| 43 | + /** |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | + public function render() |
|
| 47 | + { |
|
| 48 | + $form = "<input type='text' name='" . $this->config['name'] . "' id='" . $this->config['name'] . "' size='" . $this->config['num_chars'] . "' maxlength='" . $this->config['num_chars'] . "' value=''> " . $this->loadImage(); |
|
| 49 | + $rule = htmlspecialchars(XOOPS_CAPTCHA_REFRESH, ENT_QUOTES); |
|
| 50 | + if ($this->config['maxattempt']) { |
|
| 51 | + $rule .= ' | ' . sprintf(constant('XOOPS_CAPTCHA_MAXATTEMPTS'), $this->config['maxattempt']); |
|
| 52 | + } |
|
| 53 | + $form .= " <small>{$rule}</small>"; |
|
| 54 | 54 | |
| 55 | - return $form; |
|
| 56 | - } |
|
| 55 | + return $form; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function loadImage() |
|
| 62 | - { |
|
| 63 | - $rule = $this->config['casesensitive'] ? constant('XOOPS_CAPTCHA_RULE_CASESENSITIVE') : constant('XOOPS_CAPTCHA_RULE_CASEINSENSITIVE'); |
|
| 64 | - $ret = "<img id='captcha' src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "' onclick=\"this.src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "?refresh='+Math.random()" . "\" align='absmiddle' style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "'>"; |
|
| 58 | + /** |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function loadImage() |
|
| 62 | + { |
|
| 63 | + $rule = $this->config['casesensitive'] ? constant('XOOPS_CAPTCHA_RULE_CASESENSITIVE') : constant('XOOPS_CAPTCHA_RULE_CASEINSENSITIVE'); |
|
| 64 | + $ret = "<img id='captcha' src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "' onclick=\"this.src='" . XOOPS_URL . '/' . $this->config['imageurl'] . "?refresh='+Math.random()" . "\" align='absmiddle' style='cursor: pointer;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "'>"; |
|
| 65 | 65 | |
| 66 | - return $ret; |
|
| 67 | - } |
|
| 66 | + return $ret; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -12,40 +12,40 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | $config = array( |
| 15 | - 'mode' => 'image', |
|
| 16 | - 'name' => 'xoopscaptcha', |
|
| 17 | - 'skipmember' => true, |
|
| 18 | - // Skip CAPTCHA check for members |
|
| 19 | - 'maxattempt' => 100, |
|
| 20 | - // Maximum attempts for each session |
|
| 15 | + 'mode' => 'image', |
|
| 16 | + 'name' => 'xoopscaptcha', |
|
| 17 | + 'skipmember' => true, |
|
| 18 | + // Skip CAPTCHA check for members |
|
| 19 | + 'maxattempt' => 100, |
|
| 20 | + // Maximum attempts for each session |
|
| 21 | 21 | |
| 22 | - 'num_chars' => 4, |
|
| 23 | - // Maximum characters |
|
| 22 | + 'num_chars' => 4, |
|
| 23 | + // Maximum characters |
|
| 24 | 24 | |
| 25 | - // For image mode, based on DuGris' SecurityImage |
|
| 26 | - 'rootpath' => __DIR__, |
|
| 27 | - // __Absolute__ Path to the root of fonts and backgrounds |
|
| 28 | - 'imagepath' => 'uploads/captcha', |
|
| 29 | - // Path to temporary image files, __relative__ to XOOPS_ROOT_PATH |
|
| 30 | - 'imageurl' => 'modules/smartobject/include/captcha/scripts/img.php', |
|
| 31 | - // Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH |
|
| 32 | - 'casesensitive' => false, |
|
| 33 | - // Characters in image mode is case-sensitive |
|
| 34 | - 'fontsize_min' => 12, |
|
| 35 | - // Minimum font-size |
|
| 36 | - 'fontsize_max' => 12, |
|
| 37 | - // Maximum font-size |
|
| 38 | - 'background_type' => 0, |
|
| 39 | - // Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files |
|
| 40 | - 'background_num' => 50, |
|
| 41 | - // Number of background images to generate |
|
| 42 | - 'polygon_point' => 3 |
|
| 25 | + // For image mode, based on DuGris' SecurityImage |
|
| 26 | + 'rootpath' => __DIR__, |
|
| 27 | + // __Absolute__ Path to the root of fonts and backgrounds |
|
| 28 | + 'imagepath' => 'uploads/captcha', |
|
| 29 | + // Path to temporary image files, __relative__ to XOOPS_ROOT_PATH |
|
| 30 | + 'imageurl' => 'modules/smartobject/include/captcha/scripts/img.php', |
|
| 31 | + // Path to the script for creating image, __relative__ to XOOPS_ROOT_PATH |
|
| 32 | + 'casesensitive' => false, |
|
| 33 | + // Characters in image mode is case-sensitive |
|
| 34 | + 'fontsize_min' => 12, |
|
| 35 | + // Minimum font-size |
|
| 36 | + 'fontsize_max' => 12, |
|
| 37 | + // Maximum font-size |
|
| 38 | + 'background_type' => 0, |
|
| 39 | + // Background type in image mode: 0 - bar; 1 - circle; 2 - line; 3 - rectangle; 4 - ellipse; 5 - polygon; 100 - generated from files |
|
| 40 | + 'background_num' => 50, |
|
| 41 | + // Number of background images to generate |
|
| 42 | + 'polygon_point' => 3 |
|
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | $language = preg_replace("/[^a-z0-9_\-]/i", '', $GLOBALS['xoopsConfig']['language']); |
| 46 | 46 | |
| 47 | 47 | if (!@require_once __DIR__ . "/language/{$language}.php") { |
| 48 | - require_once __DIR__ . '/language/english.php'; |
|
| 48 | + require_once __DIR__ . '/language/english.php'; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $config; |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function smart_get_css_link($cssfile) |
| 13 | 13 | { |
| 14 | - $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 14 | + $ret = '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">'; |
|
| 15 | 15 | |
| 16 | - return $ret; |
|
| 16 | + return $ret; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function smart_get_page_before_form() |
| 23 | 23 | { |
| 24 | - global $smart_previous_page; |
|
| 24 | + global $smart_previous_page; |
|
| 25 | 25 | |
| 26 | - return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 26 | + return isset($_POST['smart_page_before_form']) ? $_POST['smart_page_before_form'] : $smart_previous_page; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -34,29 +34,29 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function smart_userIsAdmin($module = false) |
| 36 | 36 | { |
| 37 | - global $xoopsUser; |
|
| 38 | - static $smart_isAdmin; |
|
| 39 | - if (!$module) { |
|
| 40 | - global $xoopsModule; |
|
| 41 | - $module = $xoopsModule->getVar('dirname'); |
|
| 42 | - } |
|
| 43 | - if (isset($smart_isAdmin[$module])) { |
|
| 44 | - return $smart_isAdmin[$module]; |
|
| 45 | - } |
|
| 46 | - if (!$xoopsUser) { |
|
| 47 | - $smart_isAdmin[$module] = false; |
|
| 48 | - |
|
| 49 | - return $smart_isAdmin[$module]; |
|
| 50 | - } |
|
| 51 | - $smart_isAdmin[$module] = false; |
|
| 52 | - $smartModule = smart_getModuleInfo($module); |
|
| 53 | - if (!is_object($smartModule)) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - $module_id = $smartModule->getVar('mid'); |
|
| 57 | - $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 58 | - |
|
| 59 | - return $smart_isAdmin[$module]; |
|
| 37 | + global $xoopsUser; |
|
| 38 | + static $smart_isAdmin; |
|
| 39 | + if (!$module) { |
|
| 40 | + global $xoopsModule; |
|
| 41 | + $module = $xoopsModule->getVar('dirname'); |
|
| 42 | + } |
|
| 43 | + if (isset($smart_isAdmin[$module])) { |
|
| 44 | + return $smart_isAdmin[$module]; |
|
| 45 | + } |
|
| 46 | + if (!$xoopsUser) { |
|
| 47 | + $smart_isAdmin[$module] = false; |
|
| 48 | + |
|
| 49 | + return $smart_isAdmin[$module]; |
|
| 50 | + } |
|
| 51 | + $smart_isAdmin[$module] = false; |
|
| 52 | + $smartModule = smart_getModuleInfo($module); |
|
| 53 | + if (!is_object($smartModule)) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + $module_id = $smartModule->getVar('mid'); |
|
| 57 | + $smart_isAdmin[$module] = $xoopsUser->isAdmin($module_id); |
|
| 58 | + |
|
| 59 | + return $smart_isAdmin[$module]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function smart_isXoops22() |
| 66 | 66 | { |
| 67 | - $xoops22 = false; |
|
| 68 | - $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 69 | - if (substr($xv, 2, 1) == '2') { |
|
| 70 | - $xoops22 = true; |
|
| 71 | - } |
|
| 67 | + $xoops22 = false; |
|
| 68 | + $xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
|
| 69 | + if (substr($xv, 2, 1) == '2') { |
|
| 70 | + $xoops22 = true; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $xoops22; |
|
| 73 | + return $xoops22; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -81,36 +81,36 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function smart_getModuleName($withLink = true, $forBreadCrumb = false, $moduleName = false) |
| 83 | 83 | { |
| 84 | - if (!$moduleName) { |
|
| 85 | - global $xoopsModule; |
|
| 86 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 87 | - } |
|
| 88 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 89 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 90 | - if (!isset($smartModule)) { |
|
| 91 | - return ''; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if ($forBreadCrumb |
|
| 95 | - && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 96 | - && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!$withLink) { |
|
| 100 | - return $smartModule->getVar('name'); |
|
| 101 | - } else { |
|
| 102 | - $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 103 | - if ($seoMode === 'rewrite') { |
|
| 104 | - $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 105 | - $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 106 | - } elseif ($seoMode === 'pathinfo') { |
|
| 107 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 108 | - } else { |
|
| 109 | - $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 113 | - } |
|
| 84 | + if (!$moduleName) { |
|
| 85 | + global $xoopsModule; |
|
| 86 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 87 | + } |
|
| 88 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 89 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 90 | + if (!isset($smartModule)) { |
|
| 91 | + return ''; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if ($forBreadCrumb |
|
| 95 | + && (isset($smartModuleConfig['show_mod_name_breadcrumb']) |
|
| 96 | + && !$smartModuleConfig['show_mod_name_breadcrumb'])) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!$withLink) { |
|
| 100 | + return $smartModule->getVar('name'); |
|
| 101 | + } else { |
|
| 102 | + $seoMode = smart_getModuleModeSEO($moduleName); |
|
| 103 | + if ($seoMode === 'rewrite') { |
|
| 104 | + $seoModuleName = smart_getModuleNameForSEO($moduleName); |
|
| 105 | + $ret = XOOPS_URL . '/' . $seoModuleName . '/'; |
|
| 106 | + } elseif ($seoMode === 'pathinfo') { |
|
| 107 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/'; |
|
| 108 | + } else { |
|
| 109 | + $ret = XOOPS_URL . '/modules/' . $moduleName . '/'; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>'; |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function smart_getModuleNameForSEO($moduleName = false) |
| 121 | 121 | { |
| 122 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 123 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 124 | - if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 125 | - return $smartModuleConfig['seo_module_name']; |
|
| 126 | - } |
|
| 127 | - $ret = smart_getModuleName(false, false, $moduleName); |
|
| 128 | - |
|
| 129 | - return strtolower($ret); |
|
| 122 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 123 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 124 | + if (isset($smartModuleConfig['seo_module_name'])) { |
|
| 125 | + return $smartModuleConfig['seo_module_name']; |
|
| 126 | + } |
|
| 127 | + $ret = smart_getModuleName(false, false, $moduleName); |
|
| 128 | + |
|
| 129 | + return strtolower($ret); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | function smart_getModuleModeSEO($moduleName = false) |
| 137 | 137 | { |
| 138 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 139 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 138 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 139 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 140 | 140 | |
| 141 | - return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 141 | + return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function smart_getModuleIncludeIdSEO($moduleName = false) |
| 149 | 149 | { |
| 150 | - $smartModule = smart_getModuleInfo($moduleName); |
|
| 151 | - $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 150 | + $smartModule = smart_getModuleInfo($moduleName); |
|
| 151 | + $smartModuleConfig = smart_getModuleConfig($moduleName); |
|
| 152 | 152 | |
| 153 | - return !empty($smartModuleConfig['seo_inc_id']); |
|
| 153 | + return !empty($smartModuleConfig['seo_inc_id']); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -159,25 +159,25 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function smart_getenv($key) |
| 161 | 161 | { |
| 162 | - $ret = ''; |
|
| 163 | - $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 162 | + $ret = ''; |
|
| 163 | + $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : ''); |
|
| 164 | 164 | |
| 165 | - return $ret; |
|
| 165 | + return $ret; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | function smart_xoops_cp_header() |
| 169 | 169 | { |
| 170 | - xoops_cp_header(); |
|
| 171 | - global $xoopsModule, $xoopsConfig; |
|
| 172 | - /** |
|
| 173 | - * include SmartObject admin language file |
|
| 174 | - */ |
|
| 175 | - $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 176 | - if (file_exists($fileName)) { |
|
| 177 | - require_once $fileName; |
|
| 178 | - } else { |
|
| 179 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 180 | - } ?> |
|
| 170 | + xoops_cp_header(); |
|
| 171 | + global $xoopsModule, $xoopsConfig; |
|
| 172 | + /** |
|
| 173 | + * include SmartObject admin language file |
|
| 174 | + */ |
|
| 175 | + $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 176 | + if (file_exists($fileName)) { |
|
| 177 | + require_once $fileName; |
|
| 178 | + } else { |
|
| 179 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 180 | + } ?> |
|
| 181 | 181 | <script type='text/javascript'> |
| 182 | 182 | <!-- |
| 183 | 183 | var smart_url = '<?php echo SMARTOBJECT_URL ?>'; |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script> |
| 191 | 191 | <?php |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Include the admin language constants for the SmartObject Framework |
|
| 195 | - */ |
|
| 196 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 197 | - if (!file_exists($admin_file)) { |
|
| 198 | - $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
| 199 | - } |
|
| 200 | - require_once $admin_file; |
|
| 193 | + /** |
|
| 194 | + * Include the admin language constants for the SmartObject Framework |
|
| 195 | + */ |
|
| 196 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 197 | + if (!file_exists($admin_file)) { |
|
| 198 | + $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php'; |
|
| 199 | + } |
|
| 200 | + require_once $admin_file; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function smart_TableExists($table) |
| 213 | 213 | { |
| 214 | - $bRetVal = false; |
|
| 215 | - //Verifies that a MySQL table exists |
|
| 216 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 217 | - $realname = $xoopsDB->prefix($table); |
|
| 218 | - $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 219 | - $ret = $xoopsDB->queryF($sql); |
|
| 220 | - while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 221 | - if ($m_table == $realname) { |
|
| 222 | - $bRetVal = true; |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - $xoopsDB->freeRecordSet($ret); |
|
| 227 | - |
|
| 228 | - return $bRetVal; |
|
| 214 | + $bRetVal = false; |
|
| 215 | + //Verifies that a MySQL table exists |
|
| 216 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 217 | + $realname = $xoopsDB->prefix($table); |
|
| 218 | + $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
|
| 219 | + $ret = $xoopsDB->queryF($sql); |
|
| 220 | + while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
|
| 221 | + if ($m_table == $realname) { |
|
| 222 | + $bRetVal = true; |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + $xoopsDB->freeRecordSet($ret); |
|
| 227 | + |
|
| 228 | + return $bRetVal; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -240,19 +240,19 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | function smart_GetMeta($key, $moduleName = false) |
| 242 | 242 | { |
| 243 | - if (!$moduleName) { |
|
| 244 | - $moduleName = smart_getCurrentModuleName(); |
|
| 245 | - } |
|
| 246 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 247 | - $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 248 | - $ret = $xoopsDB->query($sql); |
|
| 249 | - if (!$ret) { |
|
| 250 | - $value = false; |
|
| 251 | - } else { |
|
| 252 | - list($value) = $xoopsDB->fetchRow($ret); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $value; |
|
| 243 | + if (!$moduleName) { |
|
| 244 | + $moduleName = smart_getCurrentModuleName(); |
|
| 245 | + } |
|
| 246 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 247 | + $sql = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key)); |
|
| 248 | + $ret = $xoopsDB->query($sql); |
|
| 249 | + if (!$ret) { |
|
| 250 | + $value = false; |
|
| 251 | + } else { |
|
| 252 | + list($value) = $xoopsDB->fetchRow($ret); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $value; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | function smart_getCurrentModuleName() |
| 262 | 262 | { |
| 263 | - global $xoopsModule; |
|
| 264 | - if (is_object($xoopsModule)) { |
|
| 265 | - return $xoopsModule->getVar('dirname'); |
|
| 266 | - } else { |
|
| 267 | - return false; |
|
| 268 | - } |
|
| 263 | + global $xoopsModule; |
|
| 264 | + if (is_object($xoopsModule)) { |
|
| 265 | + return $xoopsModule->getVar('dirname'); |
|
| 266 | + } else { |
|
| 267 | + return false; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -281,22 +281,22 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function smart_SetMeta($key, $value, $moduleName = false) |
| 283 | 283 | { |
| 284 | - if (!$moduleName) { |
|
| 285 | - $moduleName = smart_getCurrentModuleName(); |
|
| 286 | - } |
|
| 287 | - $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 288 | - $ret = smart_GetMeta($key, $moduleName); |
|
| 289 | - if ($ret === '0' || $ret > 0) { |
|
| 290 | - $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 291 | - } else { |
|
| 292 | - $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 293 | - } |
|
| 294 | - $ret = $xoopsDB->queryF($sql); |
|
| 295 | - if (!$ret) { |
|
| 296 | - return false; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - return true; |
|
| 284 | + if (!$moduleName) { |
|
| 285 | + $moduleName = smart_getCurrentModuleName(); |
|
| 286 | + } |
|
| 287 | + $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 288 | + $ret = smart_GetMeta($key, $moduleName); |
|
| 289 | + if ($ret === '0' || $ret > 0) { |
|
| 290 | + $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); |
|
| 291 | + } else { |
|
| 292 | + $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); |
|
| 293 | + } |
|
| 294 | + $ret = $xoopsDB->queryF($sql); |
|
| 295 | + if (!$ret) { |
|
| 296 | + return false; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + return true; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Thanks to Mithrandir:-) |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | function smart_substr($str, $start, $length, $trimmarker = '...') |
| 311 | 311 | { |
| 312 | - // if the string is empty, let's get out ;-) |
|
| 313 | - if ($str === '') { |
|
| 314 | - return $str; |
|
| 315 | - } |
|
| 316 | - // reverse a string that is shortened with '' as trimmarker |
|
| 317 | - $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 318 | - // find first space in reversed string |
|
| 319 | - $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 320 | - // truncate the original string to a length of $length |
|
| 321 | - // minus the position of the last space |
|
| 322 | - // plus the length of the $trimmarker |
|
| 323 | - $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 324 | - |
|
| 325 | - return $truncated_string; |
|
| 312 | + // if the string is empty, let's get out ;-) |
|
| 313 | + if ($str === '') { |
|
| 314 | + return $str; |
|
| 315 | + } |
|
| 316 | + // reverse a string that is shortened with '' as trimmarker |
|
| 317 | + $reversed_string = strrev(xoops_substr($str, $start, $length, '')); |
|
| 318 | + // find first space in reversed string |
|
| 319 | + $position_of_space = strpos($reversed_string, ' ', 0); |
|
| 320 | + // truncate the original string to a length of $length |
|
| 321 | + // minus the position of the last space |
|
| 322 | + // plus the length of the $trimmarker |
|
| 323 | + $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker); |
|
| 324 | + |
|
| 325 | + return $truncated_string; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -333,19 +333,19 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined') |
| 335 | 335 | { |
| 336 | - if (!$moduleName) { |
|
| 337 | - $moduleName = smart_getCurrentModuleName(); |
|
| 338 | - } |
|
| 339 | - $configs = smart_getModuleConfig($moduleName); |
|
| 340 | - if (isset($configs[$key])) { |
|
| 341 | - return $configs[$key]; |
|
| 342 | - } else { |
|
| 343 | - if ($default === 'default_is_undefined') { |
|
| 344 | - return null; |
|
| 345 | - } else { |
|
| 346 | - return $default; |
|
| 347 | - } |
|
| 348 | - } |
|
| 336 | + if (!$moduleName) { |
|
| 337 | + $moduleName = smart_getCurrentModuleName(); |
|
| 338 | + } |
|
| 339 | + $configs = smart_getModuleConfig($moduleName); |
|
| 340 | + if (isset($configs[$key])) { |
|
| 341 | + return $configs[$key]; |
|
| 342 | + } else { |
|
| 343 | + if ($default === 'default_is_undefined') { |
|
| 344 | + return null; |
|
| 345 | + } else { |
|
| 346 | + return $default; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -358,32 +358,32 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function smart_copyr($source, $dest) |
| 360 | 360 | { |
| 361 | - // Simple copy for a file |
|
| 362 | - if (is_file($source)) { |
|
| 363 | - return copy($source, $dest); |
|
| 364 | - } |
|
| 365 | - // Make destination directory |
|
| 366 | - if (!is_dir($dest)) { |
|
| 367 | - mkdir($dest); |
|
| 368 | - } |
|
| 369 | - // Loop through the folder |
|
| 370 | - $dir = dir($source); |
|
| 371 | - while (false !== $entry = $dir->read()) { |
|
| 372 | - // Skip pointers |
|
| 373 | - if ($entry === '.' || $entry === '..') { |
|
| 374 | - continue; |
|
| 375 | - } |
|
| 376 | - // Deep copy directories |
|
| 377 | - if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 378 | - copyr("$source/$entry", "$dest/$entry"); |
|
| 379 | - } else { |
|
| 380 | - copy("$source/$entry", "$dest/$entry"); |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - // Clean up |
|
| 384 | - $dir->close(); |
|
| 385 | - |
|
| 386 | - return true; |
|
| 361 | + // Simple copy for a file |
|
| 362 | + if (is_file($source)) { |
|
| 363 | + return copy($source, $dest); |
|
| 364 | + } |
|
| 365 | + // Make destination directory |
|
| 366 | + if (!is_dir($dest)) { |
|
| 367 | + mkdir($dest); |
|
| 368 | + } |
|
| 369 | + // Loop through the folder |
|
| 370 | + $dir = dir($source); |
|
| 371 | + while (false !== $entry = $dir->read()) { |
|
| 372 | + // Skip pointers |
|
| 373 | + if ($entry === '.' || $entry === '..') { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 376 | + // Deep copy directories |
|
| 377 | + if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) { |
|
| 378 | + copyr("$source/$entry", "$dest/$entry"); |
|
| 379 | + } else { |
|
| 380 | + copy("$source/$entry", "$dest/$entry"); |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + // Clean up |
|
| 384 | + $dir->close(); |
|
| 385 | + |
|
| 386 | + return true; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,26 +393,26 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function smart_admin_mkdir($target) |
| 395 | 395 | { |
| 396 | - // http://www.php.net/manual/en/function.mkdir.php |
|
| 397 | - // saint at corenova.com |
|
| 398 | - // bart at cdasites dot com |
|
| 399 | - if (is_dir($target) || empty($target)) { |
|
| 400 | - return true; // best case check first |
|
| 401 | - } |
|
| 402 | - if (file_exists($target) && !is_dir($target)) { |
|
| 403 | - return false; |
|
| 404 | - } |
|
| 405 | - if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 406 | - if (!file_exists($target)) { |
|
| 407 | - $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 408 | - smart_admin_chmod($target); |
|
| 409 | - |
|
| 410 | - return $res; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - $res = is_dir($target); |
|
| 414 | - |
|
| 415 | - return $res; |
|
| 396 | + // http://www.php.net/manual/en/function.mkdir.php |
|
| 397 | + // saint at corenova.com |
|
| 398 | + // bart at cdasites dot com |
|
| 399 | + if (is_dir($target) || empty($target)) { |
|
| 400 | + return true; // best case check first |
|
| 401 | + } |
|
| 402 | + if (file_exists($target) && !is_dir($target)) { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 405 | + if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) { |
|
| 406 | + if (!file_exists($target)) { |
|
| 407 | + $res = mkdir($target, 0777); // crawl back up & create dir tree |
|
| 408 | + smart_admin_chmod($target); |
|
| 409 | + |
|
| 410 | + return $res; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + $res = is_dir($target); |
|
| 414 | + |
|
| 415 | + return $res; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | function smart_admin_chmod($target, $mode = 0777) |
| 425 | 425 | { |
| 426 | - return @ chmod($target, $mode); |
|
| 426 | + return @ chmod($target, $mode); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -434,31 +434,31 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | function smart_imageResize($src, $maxWidth, $maxHeight) |
| 436 | 436 | { |
| 437 | - $width = ''; |
|
| 438 | - $height = ''; |
|
| 439 | - $type = ''; |
|
| 440 | - $attr = ''; |
|
| 441 | - if (file_exists($src)) { |
|
| 442 | - list($width, $height, $type, $attr) = getimagesize($src); |
|
| 443 | - if ($width > $maxWidth) { |
|
| 444 | - $originalWidth = $width; |
|
| 445 | - $width = $maxWidth; |
|
| 446 | - $height = $width * $height / $originalWidth; |
|
| 447 | - } |
|
| 448 | - if ($height > $maxHeight) { |
|
| 449 | - $originalHeight = $height; |
|
| 450 | - $height = $maxHeight; |
|
| 451 | - $width = $height * $width / $originalHeight; |
|
| 452 | - } |
|
| 453 | - $attr = " width='$width' height='$height'"; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - return array( |
|
| 457 | - $width, |
|
| 458 | - $height, |
|
| 459 | - $type, |
|
| 460 | - $attr |
|
| 461 | - ); |
|
| 437 | + $width = ''; |
|
| 438 | + $height = ''; |
|
| 439 | + $type = ''; |
|
| 440 | + $attr = ''; |
|
| 441 | + if (file_exists($src)) { |
|
| 442 | + list($width, $height, $type, $attr) = getimagesize($src); |
|
| 443 | + if ($width > $maxWidth) { |
|
| 444 | + $originalWidth = $width; |
|
| 445 | + $width = $maxWidth; |
|
| 446 | + $height = $width * $height / $originalWidth; |
|
| 447 | + } |
|
| 448 | + if ($height > $maxHeight) { |
|
| 449 | + $originalHeight = $height; |
|
| 450 | + $height = $maxHeight; |
|
| 451 | + $width = $height * $width / $originalHeight; |
|
| 452 | + } |
|
| 453 | + $attr = " width='$width' height='$height'"; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + return array( |
|
| 457 | + $width, |
|
| 458 | + $height, |
|
| 459 | + $type, |
|
| 460 | + $attr |
|
| 461 | + ); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -467,34 +467,34 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | function smart_getModuleInfo($moduleName = false) |
| 469 | 469 | { |
| 470 | - static $smartModules; |
|
| 471 | - if (isset($smartModules[$moduleName])) { |
|
| 472 | - $ret =& $smartModules[$moduleName]; |
|
| 473 | - |
|
| 474 | - return $ret; |
|
| 475 | - } |
|
| 476 | - global $xoopsModule; |
|
| 477 | - if (!$moduleName) { |
|
| 478 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 479 | - $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 480 | - |
|
| 481 | - return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 482 | - } |
|
| 483 | - } |
|
| 484 | - if (!isset($smartModules[$moduleName])) { |
|
| 485 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 486 | - $smartModules[$moduleName] = $xoopsModule; |
|
| 487 | - } else { |
|
| 488 | - $hModule = xoops_getHandler('module'); |
|
| 489 | - if ($moduleName !== 'xoops') { |
|
| 490 | - $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 491 | - } else { |
|
| 492 | - $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 493 | - } |
|
| 494 | - } |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - return $smartModules[$moduleName]; |
|
| 470 | + static $smartModules; |
|
| 471 | + if (isset($smartModules[$moduleName])) { |
|
| 472 | + $ret =& $smartModules[$moduleName]; |
|
| 473 | + |
|
| 474 | + return $ret; |
|
| 475 | + } |
|
| 476 | + global $xoopsModule; |
|
| 477 | + if (!$moduleName) { |
|
| 478 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 479 | + $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule; |
|
| 480 | + |
|
| 481 | + return $smartModules[$xoopsModule->getVar('dirname')]; |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | + if (!isset($smartModules[$moduleName])) { |
|
| 485 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 486 | + $smartModules[$moduleName] = $xoopsModule; |
|
| 487 | + } else { |
|
| 488 | + $hModule = xoops_getHandler('module'); |
|
| 489 | + if ($moduleName !== 'xoops') { |
|
| 490 | + $smartModules[$moduleName] = $hModule->getByDirname($moduleName); |
|
| 491 | + } else { |
|
| 492 | + $smartModules[$moduleName] = $hModule->getByDirname('system'); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return $smartModules[$moduleName]; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -503,40 +503,40 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | function smart_getModuleConfig($moduleName = false) |
| 505 | 505 | { |
| 506 | - static $smartConfigs; |
|
| 507 | - if (isset($smartConfigs[$moduleName])) { |
|
| 508 | - $ret =& $smartConfigs[$moduleName]; |
|
| 509 | - |
|
| 510 | - return $ret; |
|
| 511 | - } |
|
| 512 | - global $xoopsModule, $xoopsModuleConfig; |
|
| 513 | - if (!$moduleName) { |
|
| 514 | - if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 515 | - $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 516 | - |
|
| 517 | - return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - // if we still did not found the xoopsModule, this is because there is none |
|
| 521 | - if (!$moduleName) { |
|
| 522 | - $ret = false; |
|
| 523 | - |
|
| 524 | - return $ret; |
|
| 525 | - } |
|
| 526 | - if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 527 | - $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 528 | - } else { |
|
| 529 | - $module = smart_getModuleInfo($moduleName); |
|
| 530 | - if (!is_object($module)) { |
|
| 531 | - $ret = false; |
|
| 532 | - |
|
| 533 | - return $ret; |
|
| 534 | - } |
|
| 535 | - $hModConfig = xoops_getHandler('config'); |
|
| 536 | - $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - return $smartConfigs[$moduleName]; |
|
| 506 | + static $smartConfigs; |
|
| 507 | + if (isset($smartConfigs[$moduleName])) { |
|
| 508 | + $ret =& $smartConfigs[$moduleName]; |
|
| 509 | + |
|
| 510 | + return $ret; |
|
| 511 | + } |
|
| 512 | + global $xoopsModule, $xoopsModuleConfig; |
|
| 513 | + if (!$moduleName) { |
|
| 514 | + if (isset($xoopsModule) && is_object($xoopsModule)) { |
|
| 515 | + $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig; |
|
| 516 | + |
|
| 517 | + return $smartConfigs[$xoopsModule->getVar('dirname')]; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + // if we still did not found the xoopsModule, this is because there is none |
|
| 521 | + if (!$moduleName) { |
|
| 522 | + $ret = false; |
|
| 523 | + |
|
| 524 | + return $ret; |
|
| 525 | + } |
|
| 526 | + if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) { |
|
| 527 | + $smartConfigs[$moduleName] = $xoopsModuleConfig; |
|
| 528 | + } else { |
|
| 529 | + $module = smart_getModuleInfo($moduleName); |
|
| 530 | + if (!is_object($module)) { |
|
| 531 | + $ret = false; |
|
| 532 | + |
|
| 533 | + return $ret; |
|
| 534 | + } |
|
| 535 | + $hModConfig = xoops_getHandler('config'); |
|
| 536 | + $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + return $smartConfigs[$moduleName]; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -545,10 +545,10 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | function smart_deleteFile($dirname) |
| 547 | 547 | { |
| 548 | - // Simple delete for a file |
|
| 549 | - if (is_file($dirname)) { |
|
| 550 | - return unlink($dirname); |
|
| 551 | - } |
|
| 548 | + // Simple delete for a file |
|
| 549 | + if (is_file($dirname)) { |
|
| 550 | + return unlink($dirname); |
|
| 551 | + } |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -557,12 +557,12 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | function smart_formatErrors($errors = array()) |
| 559 | 559 | { |
| 560 | - $ret = ''; |
|
| 561 | - foreach ($errors as $key => $value) { |
|
| 562 | - $ret .= '<br> - ' . $value; |
|
| 563 | - } |
|
| 560 | + $ret = ''; |
|
| 561 | + foreach ($errors as $key => $value) { |
|
| 562 | + $ret .= '<br> - ' . $value; |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - return $ret; |
|
| 565 | + return $ret; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -576,46 +576,46 @@ discard block |
||
| 576 | 576 | */ |
| 577 | 577 | function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false) |
| 578 | 578 | { |
| 579 | - if (!is_numeric($userid)) { |
|
| 580 | - return $userid; |
|
| 581 | - } |
|
| 582 | - $userid = (int)$userid; |
|
| 583 | - if ($userid > 0) { |
|
| 584 | - if ($users == array()) { |
|
| 585 | - //fetching users |
|
| 586 | - $memberHandler = xoops_getHandler('member'); |
|
| 587 | - $user =& $memberHandler->getUser($userid); |
|
| 588 | - } else { |
|
| 589 | - if (!isset($users[$userid])) { |
|
| 590 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 591 | - } |
|
| 592 | - $user =& $users[$userid]; |
|
| 593 | - } |
|
| 594 | - if (is_object($user)) { |
|
| 595 | - $ts = MyTextSanitizer:: getInstance(); |
|
| 596 | - $username = $user->getVar('uname'); |
|
| 597 | - $fullname = ''; |
|
| 598 | - $fullname2 = $user->getVar('name'); |
|
| 599 | - if ($name && !empty($fullname2)) { |
|
| 600 | - $fullname = $user->getVar('name'); |
|
| 601 | - } |
|
| 602 | - if (!empty($fullname)) { |
|
| 603 | - $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 604 | - } else { |
|
| 605 | - $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 606 | - } |
|
| 607 | - // add contact info: email + PM |
|
| 608 | - if ($withContact) { |
|
| 609 | - $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"></a>'; |
|
| 610 | - $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 611 | - $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"></a>'; |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - return $linkeduser; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 579 | + if (!is_numeric($userid)) { |
|
| 580 | + return $userid; |
|
| 581 | + } |
|
| 582 | + $userid = (int)$userid; |
|
| 583 | + if ($userid > 0) { |
|
| 584 | + if ($users == array()) { |
|
| 585 | + //fetching users |
|
| 586 | + $memberHandler = xoops_getHandler('member'); |
|
| 587 | + $user =& $memberHandler->getUser($userid); |
|
| 588 | + } else { |
|
| 589 | + if (!isset($users[$userid])) { |
|
| 590 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 591 | + } |
|
| 592 | + $user =& $users[$userid]; |
|
| 593 | + } |
|
| 594 | + if (is_object($user)) { |
|
| 595 | + $ts = MyTextSanitizer:: getInstance(); |
|
| 596 | + $username = $user->getVar('uname'); |
|
| 597 | + $fullname = ''; |
|
| 598 | + $fullname2 = $user->getVar('name'); |
|
| 599 | + if ($name && !empty($fullname2)) { |
|
| 600 | + $fullname = $user->getVar('name'); |
|
| 601 | + } |
|
| 602 | + if (!empty($fullname)) { |
|
| 603 | + $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
|
| 604 | + } else { |
|
| 605 | + $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>'; |
|
| 606 | + } |
|
| 607 | + // add contact info: email + PM |
|
| 608 | + if ($withContact) { |
|
| 609 | + $linkeduser .= ' <a href="mailto:' . $user->getVar('email') . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/email.gif' . '" alt="' . _CO_SOBJECT_SEND_EMAIL . '" title="' . _CO_SOBJECT_SEND_EMAIL . '"></a>'; |
|
| 610 | + $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);"; |
|
| 611 | + $linkeduser .= ' <a href="' . $js . '"><img style="vertical-align: middle;" src="' . XOOPS_URL . '/images/icons/pm.gif' . '" alt="' . _CO_SOBJECT_SEND_PM . '" title="' . _CO_SOBJECT_SEND_PM . '"></a>'; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + return $linkeduser; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + return $GLOBALS['xoopsConfig']['anonymous']; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -626,33 +626,33 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1) |
| 628 | 628 | { |
| 629 | - global $xoopsModule, $xoopsConfig; |
|
| 630 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 631 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 632 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 633 | - } else { |
|
| 634 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 635 | - } |
|
| 636 | - if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 637 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 638 | - } else { |
|
| 639 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 640 | - } |
|
| 641 | - $headermenu = array(); |
|
| 642 | - $adminObject = array(); |
|
| 643 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 644 | - $tpl = new XoopsTpl(); |
|
| 645 | - $tpl->assign(array( |
|
| 646 | - 'headermenu' => $headermenu, |
|
| 647 | - 'adminmenu' => $adminObject, |
|
| 648 | - 'current' => $currentoption, |
|
| 649 | - 'breadcrumb' => $breadcrumb, |
|
| 650 | - 'headermenucount' => count($headermenu), |
|
| 651 | - 'submenus' => $submenus, |
|
| 652 | - 'currentsub' => $currentsub, |
|
| 653 | - 'submenuscount' => count($submenus) |
|
| 654 | - )); |
|
| 655 | - $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 629 | + global $xoopsModule, $xoopsConfig; |
|
| 630 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 631 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
| 632 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
|
| 633 | + } else { |
|
| 634 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php'; |
|
| 635 | + } |
|
| 636 | + if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
| 637 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
| 638 | + } else { |
|
| 639 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php'; |
|
| 640 | + } |
|
| 641 | + $headermenu = array(); |
|
| 642 | + $adminObject = array(); |
|
| 643 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php'; |
|
| 644 | + $tpl = new XoopsTpl(); |
|
| 645 | + $tpl->assign(array( |
|
| 646 | + 'headermenu' => $headermenu, |
|
| 647 | + 'adminmenu' => $adminObject, |
|
| 648 | + 'current' => $currentoption, |
|
| 649 | + 'breadcrumb' => $breadcrumb, |
|
| 650 | + 'headermenucount' => count($headermenu), |
|
| 651 | + 'submenus' => $submenus, |
|
| 652 | + 'currentsub' => $currentsub, |
|
| 653 | + 'submenuscount' => count($submenus) |
|
| 654 | + )); |
|
| 655 | + $tpl->display('db:smartobject_admin_menu.tpl'); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | function smart_collapsableBar($id = '', $title = '', $dsc = '') |
| 664 | 664 | { |
| 665 | - global $xoopsModule; |
|
| 666 | - echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 667 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 668 | - echo "<div id='" . $id . "'>"; |
|
| 669 | - if ($dsc !== '') { |
|
| 670 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 671 | - } |
|
| 665 | + global $xoopsModule; |
|
| 666 | + echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"togglecollapse('" . $id . "'); toggleIcon('" . $id . "_icon')\";>"; |
|
| 667 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 668 | + echo "<div id='" . $id . "'>"; |
|
| 669 | + if ($dsc !== '') { |
|
| 670 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 671 | + } |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -678,15 +678,15 @@ discard block |
||
| 678 | 678 | */ |
| 679 | 679 | function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '') |
| 680 | 680 | { |
| 681 | - global $xoopsModule; |
|
| 682 | - $onClick = "ajaxtogglecollapse('$id')"; |
|
| 683 | - //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 684 | - echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 685 | - echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 686 | - echo "<div id='" . $id . "'>"; |
|
| 687 | - if ($dsc !== '') { |
|
| 688 | - echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 689 | - } |
|
| 681 | + global $xoopsModule; |
|
| 682 | + $onClick = "ajaxtogglecollapse('$id')"; |
|
| 683 | + //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')"; |
|
| 684 | + echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">'; |
|
| 685 | + echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt=''></a> " . $title . '</h3>'; |
|
| 686 | + echo "<div id='" . $id . "'>"; |
|
| 687 | + if ($dsc !== '') { |
|
| 688 | + echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>'; |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -713,20 +713,20 @@ discard block |
||
| 713 | 713 | */ |
| 714 | 714 | function smart_openclose_collapsable($name) |
| 715 | 715 | { |
| 716 | - $urls = smart_getCurrentUrls(); |
|
| 717 | - $path = $urls['phpself']; |
|
| 718 | - $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 719 | - $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 720 | - $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 721 | - if ($cookie === 'none') { |
|
| 722 | - echo ' |
|
| 716 | + $urls = smart_getCurrentUrls(); |
|
| 717 | + $path = $urls['phpself']; |
|
| 718 | + $cookie_name = $path . '_smart_collaps_' . $name; |
|
| 719 | + $cookie_name = str_replace('.', '_', $cookie_name); |
|
| 720 | + $cookie = smart_getCookieVar($cookie_name, ''); |
|
| 721 | + if ($cookie === 'none') { |
|
| 722 | + echo ' |
|
| 723 | 723 | <script type="text/javascript"><!-- |
| 724 | 724 | togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); |
| 725 | 725 | //--> |
| 726 | 726 | </script> |
| 727 | 727 | '; |
| 728 | - } |
|
| 729 | - /* if ($cookie == 'none') { |
|
| 728 | + } |
|
| 729 | + /* if ($cookie == 'none') { |
|
| 730 | 730 | echo ' |
| 731 | 731 | <script type="text/javascript"><!-- |
| 732 | 732 | hideElement("' . $name . '"); |
@@ -742,9 +742,9 @@ discard block |
||
| 742 | 742 | */ |
| 743 | 743 | function smart_close_collapsable($name) |
| 744 | 744 | { |
| 745 | - echo '</div>'; |
|
| 746 | - smart_openclose_collapsable($name); |
|
| 747 | - echo '<br>'; |
|
| 745 | + echo '</div>'; |
|
| 746 | + smart_openclose_collapsable($name); |
|
| 747 | + echo '<br>'; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | */ |
| 755 | 755 | function smart_setCookieVar($name, $value, $time = 0) |
| 756 | 756 | { |
| 757 | - if ($time == 0) { |
|
| 758 | - $time = time() + 3600 * 24 * 365; |
|
| 759 | - //$time = ''; |
|
| 760 | - } |
|
| 761 | - setcookie($name, $value, $time, '/'); |
|
| 757 | + if ($time == 0) { |
|
| 758 | + $time = time() + 3600 * 24 * 365; |
|
| 759 | + //$time = ''; |
|
| 760 | + } |
|
| 761 | + setcookie($name, $value, $time, '/'); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | /** |
@@ -768,12 +768,12 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | function smart_getCookieVar($name, $default = '') |
| 770 | 770 | { |
| 771 | - $name = str_replace('.', '_', $name); |
|
| 772 | - if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 773 | - return $_COOKIE[$name]; |
|
| 774 | - } else { |
|
| 775 | - return $default; |
|
| 776 | - } |
|
| 771 | + $name = str_replace('.', '_', $name); |
|
| 772 | + if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
|
| 773 | + return $_COOKIE[$name]; |
|
| 774 | + } else { |
|
| 775 | + return $default; |
|
| 776 | + } |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
@@ -781,25 +781,25 @@ discard block |
||
| 781 | 781 | */ |
| 782 | 782 | function smart_getCurrentUrls() |
| 783 | 783 | { |
| 784 | - $urls = array(); |
|
| 785 | - $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
| 786 | - $phpself = $_SERVER['PHP_SELF']; |
|
| 787 | - $httphost = $_SERVER['HTTP_HOST']; |
|
| 788 | - $querystring = $_SERVER['QUERY_STRING']; |
|
| 789 | - if ($querystring !== '') { |
|
| 790 | - $querystring = '?' . $querystring; |
|
| 791 | - } |
|
| 792 | - $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 793 | - $urls = array(); |
|
| 794 | - $urls['http'] = $http; |
|
| 795 | - $urls['httphost'] = $httphost; |
|
| 796 | - $urls['phpself'] = $phpself; |
|
| 797 | - $urls['querystring'] = $querystring; |
|
| 798 | - $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 799 | - $urls['full'] = $currenturl; |
|
| 800 | - $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 801 | - |
|
| 802 | - return $urls; |
|
| 784 | + $urls = array(); |
|
| 785 | + $http = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://'; |
|
| 786 | + $phpself = $_SERVER['PHP_SELF']; |
|
| 787 | + $httphost = $_SERVER['HTTP_HOST']; |
|
| 788 | + $querystring = $_SERVER['QUERY_STRING']; |
|
| 789 | + if ($querystring !== '') { |
|
| 790 | + $querystring = '?' . $querystring; |
|
| 791 | + } |
|
| 792 | + $currenturl = $http . $httphost . $phpself . $querystring; |
|
| 793 | + $urls = array(); |
|
| 794 | + $urls['http'] = $http; |
|
| 795 | + $urls['httphost'] = $httphost; |
|
| 796 | + $urls['phpself'] = $phpself; |
|
| 797 | + $urls['querystring'] = $querystring; |
|
| 798 | + $urls['full_phpself'] = $http . $httphost . $phpself; |
|
| 799 | + $urls['full'] = $currenturl; |
|
| 800 | + $urls['isHomePage'] = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself); |
|
| 801 | + |
|
| 802 | + return $urls; |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | /** |
@@ -807,9 +807,9 @@ discard block |
||
| 807 | 807 | */ |
| 808 | 808 | function smart_getCurrentPage() |
| 809 | 809 | { |
| 810 | - $urls = smart_getCurrentUrls(); |
|
| 810 | + $urls = smart_getCurrentUrls(); |
|
| 811 | 811 | |
| 812 | - return $urls['full']; |
|
| 812 | + return $urls['full']; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -872,29 +872,29 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | function smart_modFooter() |
| 874 | 874 | { |
| 875 | - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 876 | - |
|
| 877 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 878 | - $tpl = new XoopsTpl(); |
|
| 879 | - |
|
| 880 | - $hModule = xoops_getHandler('module'); |
|
| 881 | - $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | - $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 883 | - $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'></a>"; |
|
| 884 | - $tpl->assign('modfooter', $modfooter); |
|
| 885 | - |
|
| 886 | - if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 887 | - define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 888 | - } |
|
| 889 | - $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 890 | - $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 891 | - $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 875 | + global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
| 876 | + |
|
| 877 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
| 878 | + $tpl = new XoopsTpl(); |
|
| 879 | + |
|
| 880 | + $hModule = xoops_getHandler('module'); |
|
| 881 | + $versioninfo =& $hModule->get($xoopsModule->getVar('mid')); |
|
| 882 | + $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . ''; |
|
| 883 | + $modfooter = "<a href='" . $versioninfo->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/cssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'></a>"; |
|
| 884 | + $tpl->assign('modfooter', $modfooter); |
|
| 885 | + |
|
| 886 | + if (!defined('_AM_SOBJECT_XOOPS_PRO')) { |
|
| 887 | + define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?'); |
|
| 888 | + } |
|
| 889 | + $smartobjectConfig = smart_getModuleConfig('smartobject'); |
|
| 890 | + $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']); |
|
| 891 | + $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.tpl'); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | function smart_xoops_cp_footer() |
| 895 | 895 | { |
| 896 | - smart_modFooter(); |
|
| 897 | - xoops_cp_footer(); |
|
| 896 | + smart_modFooter(); |
|
| 897 | + xoops_cp_footer(); |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | /** |
@@ -903,11 +903,11 @@ discard block |
||
| 903 | 903 | */ |
| 904 | 904 | function smart_sanitizeForCommonTags($text) |
| 905 | 905 | { |
| 906 | - global $xoopsConfig; |
|
| 907 | - $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 908 | - $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 906 | + global $xoopsConfig; |
|
| 907 | + $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text); |
|
| 908 | + $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text); |
|
| 909 | 909 | |
| 910 | - return $text; |
|
| 910 | + return $text; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | function smart_addScript($src) |
| 917 | 917 | { |
| 918 | - echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 918 | + echo '<script src="' . $src . '" type="text/javascript"></script>'; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | */ |
| 924 | 924 | function smart_addStyle($src) |
| 925 | 925 | { |
| 926 | - if ($src === 'smartobject') { |
|
| 927 | - $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 928 | - } |
|
| 929 | - echo smart_get_css_link($src); |
|
| 926 | + if ($src === 'smartobject') { |
|
| 927 | + $src = SMARTOBJECT_URL . 'assets/css/module.css'; |
|
| 928 | + } |
|
| 929 | + echo smart_get_css_link($src); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | function smart_addAdminAjaxSupport() |
| 933 | 933 | { |
| 934 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 935 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | - smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 934 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js'); |
|
| 935 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js'); |
|
| 936 | + smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js'); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | /** |
@@ -942,11 +942,11 @@ discard block |
||
| 942 | 942 | */ |
| 943 | 943 | function smart_sanitizeForSmartpopupLink($text) |
| 944 | 944 | { |
| 945 | - $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 946 | - $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 947 | - $ret = preg_replace($patterns, $replacements, $text); |
|
| 945 | + $patterns[] = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU"; |
|
| 946 | + $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>"; |
|
| 947 | + $ret = preg_replace($patterns, $replacements, $text); |
|
| 948 | 948 | |
| 949 | - return $ret; |
|
| 949 | + return $ret; |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | /** |
@@ -961,25 +961,25 @@ discard block |
||
| 961 | 961 | */ |
| 962 | 962 | function smart_getImageSize($url, & $width, & $height) |
| 963 | 963 | { |
| 964 | - if (empty($width) || empty($height)) { |
|
| 965 | - if (!$dimension = @ getimagesize($url)) { |
|
| 966 | - return false; |
|
| 967 | - } |
|
| 968 | - if (!empty($width)) { |
|
| 969 | - $height = $dimension[1] * $width / $dimension[0]; |
|
| 970 | - } elseif (!empty($height)) { |
|
| 971 | - $width = $dimension[0] * $height / $dimension[1]; |
|
| 972 | - } else { |
|
| 973 | - list($width, $height) = array( |
|
| 974 | - $dimension[0], |
|
| 975 | - $dimension[1] |
|
| 976 | - ); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - return true; |
|
| 980 | - } else { |
|
| 981 | - return true; |
|
| 982 | - } |
|
| 964 | + if (empty($width) || empty($height)) { |
|
| 965 | + if (!$dimension = @ getimagesize($url)) { |
|
| 966 | + return false; |
|
| 967 | + } |
|
| 968 | + if (!empty($width)) { |
|
| 969 | + $height = $dimension[1] * $width / $dimension[0]; |
|
| 970 | + } elseif (!empty($height)) { |
|
| 971 | + $width = $dimension[0] * $height / $dimension[1]; |
|
| 972 | + } else { |
|
| 973 | + list($width, $height) = array( |
|
| 974 | + $dimension[0], |
|
| 975 | + $dimension[1] |
|
| 976 | + ); |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + return true; |
|
| 980 | + } else { |
|
| 981 | + return true; |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -992,10 +992,10 @@ discard block |
||
| 992 | 992 | */ |
| 993 | 993 | function smart_htmlnumericentities($str) |
| 994 | 994 | { |
| 995 | - // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 996 | - return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 997 | - return '&#' . ord($m[0]) . chr(59); |
|
| 998 | - }, $str); |
|
| 995 | + // return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); |
|
| 996 | + return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { |
|
| 997 | + return '&#' . ord($m[0]) . chr(59); |
|
| 998 | + }, $str); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
@@ -1005,24 +1005,24 @@ discard block |
||
| 1005 | 1005 | */ |
| 1006 | 1006 | function smart_getcorehandler($name, $optional = false) |
| 1007 | 1007 | { |
| 1008 | - static $handlers; |
|
| 1009 | - $name = strtolower(trim($name)); |
|
| 1010 | - if (!isset($handlers[$name])) { |
|
| 1011 | - if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1012 | - require_once $hnd_file; |
|
| 1013 | - } |
|
| 1014 | - $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1015 | - if (class_exists($class)) { |
|
| 1016 | - $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1019 | - if (!isset($handlers[$name]) && !$optional) { |
|
| 1020 | - trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1021 | - } |
|
| 1022 | - if (isset($handlers[$name])) { |
|
| 1023 | - return $handlers[$name]; |
|
| 1024 | - } |
|
| 1025 | - $inst = false; |
|
| 1008 | + static $handlers; |
|
| 1009 | + $name = strtolower(trim($name)); |
|
| 1010 | + if (!isset($handlers[$name])) { |
|
| 1011 | + if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) { |
|
| 1012 | + require_once $hnd_file; |
|
| 1013 | + } |
|
| 1014 | + $class = 'Xoops' . ucfirst($name) . 'Handler'; |
|
| 1015 | + if (class_exists($class)) { |
|
| 1016 | + $handlers[$name] = new $class($GLOBALS['xoopsDB'], 'xoops'); |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | + if (!isset($handlers[$name]) && !$optional) { |
|
| 1020 | + trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR); |
|
| 1021 | + } |
|
| 1022 | + if (isset($handlers[$name])) { |
|
| 1023 | + return $handlers[$name]; |
|
| 1024 | + } |
|
| 1025 | + $inst = false; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1031,15 +1031,15 @@ discard block |
||
| 1031 | 1031 | */ |
| 1032 | 1032 | function smart_sanitizeAdsenses_callback($matches) |
| 1033 | 1033 | { |
| 1034 | - global $smartobjectAdsenseHandler; |
|
| 1035 | - if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1036 | - $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1037 | - $ret = $adsenseObj->render(); |
|
| 1038 | - |
|
| 1039 | - return $ret; |
|
| 1040 | - } else { |
|
| 1041 | - return ''; |
|
| 1042 | - } |
|
| 1034 | + global $smartobjectAdsenseHandler; |
|
| 1035 | + if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) { |
|
| 1036 | + $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]]; |
|
| 1037 | + $ret = $adsenseObj->render(); |
|
| 1038 | + |
|
| 1039 | + return $ret; |
|
| 1040 | + } else { |
|
| 1041 | + return ''; |
|
| 1042 | + } |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
@@ -1048,13 +1048,13 @@ discard block |
||
| 1048 | 1048 | */ |
| 1049 | 1049 | function smart_sanitizeAdsenses($text) |
| 1050 | 1050 | { |
| 1051 | - $patterns = array(); |
|
| 1052 | - $replacements = array(); |
|
| 1051 | + $patterns = array(); |
|
| 1052 | + $replacements = array(); |
|
| 1053 | 1053 | |
| 1054 | - $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1055 | - $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1054 | + $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU"; |
|
| 1055 | + $text = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text); |
|
| 1056 | 1056 | |
| 1057 | - return $text; |
|
| 1057 | + return $text; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /** |
@@ -1063,15 +1063,15 @@ discard block |
||
| 1063 | 1063 | */ |
| 1064 | 1064 | function smart_sanitizeCustomtags_callback($matches) |
| 1065 | 1065 | { |
| 1066 | - global $smartobjectCustomtagHandler; |
|
| 1067 | - if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1068 | - $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1069 | - $ret = $customObj->renderWithPhp(); |
|
| 1070 | - |
|
| 1071 | - return $ret; |
|
| 1072 | - } else { |
|
| 1073 | - return ''; |
|
| 1074 | - } |
|
| 1066 | + global $smartobjectCustomtagHandler; |
|
| 1067 | + if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) { |
|
| 1068 | + $customObj = $smartobjectCustomtagHandler->objects[$matches[1]]; |
|
| 1069 | + $ret = $customObj->renderWithPhp(); |
|
| 1070 | + |
|
| 1071 | + return $ret; |
|
| 1072 | + } else { |
|
| 1073 | + return ''; |
|
| 1074 | + } |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1080,13 +1080,13 @@ discard block |
||
| 1080 | 1080 | */ |
| 1081 | 1081 | function smart_sanitizeCustomtags($text) |
| 1082 | 1082 | { |
| 1083 | - $patterns = array(); |
|
| 1084 | - $replacements = array(); |
|
| 1083 | + $patterns = array(); |
|
| 1084 | + $replacements = array(); |
|
| 1085 | 1085 | |
| 1086 | - $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1087 | - $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1086 | + $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU"; |
|
| 1087 | + $text = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text); |
|
| 1088 | 1088 | |
| 1089 | - return $text; |
|
| 1089 | + return $text; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
@@ -1095,20 +1095,20 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | function smart_loadLanguageFile($module, $file) |
| 1097 | 1097 | { |
| 1098 | - global $xoopsConfig; |
|
| 1099 | - |
|
| 1100 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1101 | - if (!file_exists($filename)) { |
|
| 1102 | - $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1103 | - } |
|
| 1104 | - if (file_exists($filename)) { |
|
| 1105 | - require_once $filename; |
|
| 1106 | - } |
|
| 1098 | + global $xoopsConfig; |
|
| 1099 | + |
|
| 1100 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php'; |
|
| 1101 | + if (!file_exists($filename)) { |
|
| 1102 | + $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php'; |
|
| 1103 | + } |
|
| 1104 | + if (file_exists($filename)) { |
|
| 1105 | + require_once $filename; |
|
| 1106 | + } |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | function smart_loadCommonLanguageFile() |
| 1110 | 1110 | { |
| 1111 | - smart_loadLanguageFile('smartobject', 'common'); |
|
| 1111 | + smart_loadLanguageFile('smartobject', 'common'); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1118,35 +1118,35 @@ discard block |
||
| 1118 | 1118 | */ |
| 1119 | 1119 | function smart_purifyText($text, $keyword = false) |
| 1120 | 1120 | { |
| 1121 | - global $myts; |
|
| 1122 | - $text = str_replace(' ', ' ', $text); |
|
| 1123 | - $text = str_replace('<br>', ' ', $text); |
|
| 1124 | - $text = str_replace('<br>', ' ', $text); |
|
| 1125 | - $text = str_replace('<br', ' ', $text); |
|
| 1126 | - $text = strip_tags($text); |
|
| 1127 | - $text = html_entity_decode($text); |
|
| 1128 | - $text = $myts->undoHtmlSpecialChars($text); |
|
| 1129 | - $text = str_replace(')', ' ', $text); |
|
| 1130 | - $text = str_replace('(', ' ', $text); |
|
| 1131 | - $text = str_replace(':', ' ', $text); |
|
| 1132 | - $text = str_replace('&euro', ' euro ', $text); |
|
| 1133 | - $text = str_replace('&hellip', '...', $text); |
|
| 1134 | - $text = str_replace('&rsquo', ' ', $text); |
|
| 1135 | - $text = str_replace('!', ' ', $text); |
|
| 1136 | - $text = str_replace('?', ' ', $text); |
|
| 1137 | - $text = str_replace('"', ' ', $text); |
|
| 1138 | - $text = str_replace('-', ' ', $text); |
|
| 1139 | - $text = str_replace('\n', ' ', $text); |
|
| 1140 | - $text = str_replace('―', ' ', $text); |
|
| 1141 | - |
|
| 1142 | - if ($keyword) { |
|
| 1143 | - $text = str_replace('.', ' ', $text); |
|
| 1144 | - $text = str_replace(',', ' ', $text); |
|
| 1145 | - $text = str_replace('\'', ' ', $text); |
|
| 1146 | - } |
|
| 1147 | - $text = str_replace(';', ' ', $text); |
|
| 1148 | - |
|
| 1149 | - return $text; |
|
| 1121 | + global $myts; |
|
| 1122 | + $text = str_replace(' ', ' ', $text); |
|
| 1123 | + $text = str_replace('<br>', ' ', $text); |
|
| 1124 | + $text = str_replace('<br>', ' ', $text); |
|
| 1125 | + $text = str_replace('<br', ' ', $text); |
|
| 1126 | + $text = strip_tags($text); |
|
| 1127 | + $text = html_entity_decode($text); |
|
| 1128 | + $text = $myts->undoHtmlSpecialChars($text); |
|
| 1129 | + $text = str_replace(')', ' ', $text); |
|
| 1130 | + $text = str_replace('(', ' ', $text); |
|
| 1131 | + $text = str_replace(':', ' ', $text); |
|
| 1132 | + $text = str_replace('&euro', ' euro ', $text); |
|
| 1133 | + $text = str_replace('&hellip', '...', $text); |
|
| 1134 | + $text = str_replace('&rsquo', ' ', $text); |
|
| 1135 | + $text = str_replace('!', ' ', $text); |
|
| 1136 | + $text = str_replace('?', ' ', $text); |
|
| 1137 | + $text = str_replace('"', ' ', $text); |
|
| 1138 | + $text = str_replace('-', ' ', $text); |
|
| 1139 | + $text = str_replace('\n', ' ', $text); |
|
| 1140 | + $text = str_replace('―', ' ', $text); |
|
| 1141 | + |
|
| 1142 | + if ($keyword) { |
|
| 1143 | + $text = str_replace('.', ' ', $text); |
|
| 1144 | + $text = str_replace(',', ' ', $text); |
|
| 1145 | + $text = str_replace('\'', ' ', $text); |
|
| 1146 | + } |
|
| 1147 | + $text = str_replace(';', ' ', $text); |
|
| 1148 | + |
|
| 1149 | + return $text; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
@@ -1155,51 +1155,51 @@ discard block |
||
| 1155 | 1155 | */ |
| 1156 | 1156 | function smart_html2text($document) |
| 1157 | 1157 | { |
| 1158 | - // PHP Manual:: function preg_replace |
|
| 1159 | - // $document should contain an HTML document. |
|
| 1160 | - // This will remove HTML tags, javascript sections |
|
| 1161 | - // and white space. It will also convert some |
|
| 1162 | - // common HTML entities to their text equivalent. |
|
| 1163 | - // Credits: newbb2 |
|
| 1164 | - $search = array( |
|
| 1165 | - "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1166 | - "'<img.*?>'si", // Strip out img tags |
|
| 1167 | - "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1168 | - "'([\r\n])[\s]+'", // Strip out white space |
|
| 1169 | - "'&(quot|#34);'i", // Replace HTML entities |
|
| 1170 | - "'&(amp|#38);'i", |
|
| 1171 | - "'&(lt|#60);'i", |
|
| 1172 | - "'&(gt|#62);'i", |
|
| 1173 | - "'&(nbsp|#160);'i", |
|
| 1174 | - "'&(iexcl|#161);'i", |
|
| 1175 | - "'&(cent|#162);'i", |
|
| 1176 | - "'&(pound|#163);'i", |
|
| 1177 | - "'&(copy|#169);'i" |
|
| 1178 | - ); // evaluate as php |
|
| 1179 | - |
|
| 1180 | - $replace = array( |
|
| 1181 | - '', |
|
| 1182 | - '', |
|
| 1183 | - '', |
|
| 1184 | - "\\1", |
|
| 1185 | - "\"", |
|
| 1186 | - '&', |
|
| 1187 | - '<', |
|
| 1188 | - '>', |
|
| 1189 | - ' ', |
|
| 1190 | - chr(161), |
|
| 1191 | - chr(162), |
|
| 1192 | - chr(163), |
|
| 1193 | - chr(169), |
|
| 1194 | - ); |
|
| 1195 | - |
|
| 1196 | - $text = preg_replace($search, $replace, $document); |
|
| 1197 | - |
|
| 1198 | - preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1199 | - return chr($matches[1]); |
|
| 1200 | - }, $document); |
|
| 1201 | - |
|
| 1202 | - return $text; |
|
| 1158 | + // PHP Manual:: function preg_replace |
|
| 1159 | + // $document should contain an HTML document. |
|
| 1160 | + // This will remove HTML tags, javascript sections |
|
| 1161 | + // and white space. It will also convert some |
|
| 1162 | + // common HTML entities to their text equivalent. |
|
| 1163 | + // Credits: newbb2 |
|
| 1164 | + $search = array( |
|
| 1165 | + "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 1166 | + "'<img.*?>'si", // Strip out img tags |
|
| 1167 | + "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 1168 | + "'([\r\n])[\s]+'", // Strip out white space |
|
| 1169 | + "'&(quot|#34);'i", // Replace HTML entities |
|
| 1170 | + "'&(amp|#38);'i", |
|
| 1171 | + "'&(lt|#60);'i", |
|
| 1172 | + "'&(gt|#62);'i", |
|
| 1173 | + "'&(nbsp|#160);'i", |
|
| 1174 | + "'&(iexcl|#161);'i", |
|
| 1175 | + "'&(cent|#162);'i", |
|
| 1176 | + "'&(pound|#163);'i", |
|
| 1177 | + "'&(copy|#169);'i" |
|
| 1178 | + ); // evaluate as php |
|
| 1179 | + |
|
| 1180 | + $replace = array( |
|
| 1181 | + '', |
|
| 1182 | + '', |
|
| 1183 | + '', |
|
| 1184 | + "\\1", |
|
| 1185 | + "\"", |
|
| 1186 | + '&', |
|
| 1187 | + '<', |
|
| 1188 | + '>', |
|
| 1189 | + ' ', |
|
| 1190 | + chr(161), |
|
| 1191 | + chr(162), |
|
| 1192 | + chr(163), |
|
| 1193 | + chr(169), |
|
| 1194 | + ); |
|
| 1195 | + |
|
| 1196 | + $text = preg_replace($search, $replace, $document); |
|
| 1197 | + |
|
| 1198 | + preg_replace_callback('/&#(\d+);/', function ($matches) { |
|
| 1199 | + return chr($matches[1]); |
|
| 1200 | + }, $document); |
|
| 1201 | + |
|
| 1202 | + return $text; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /** |
@@ -1213,32 +1213,32 @@ discard block |
||
| 1213 | 1213 | */ |
| 1214 | 1214 | function smart_getfloat($str, $set = false) |
| 1215 | 1215 | { |
| 1216 | - if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1217 | - // Found number in $str, so set $str that number |
|
| 1218 | - $str = $match[0]; |
|
| 1219 | - if (false !== strpos($str, ',')) { |
|
| 1220 | - // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1221 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | - $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1223 | - |
|
| 1224 | - return (float)$str; |
|
| 1225 | - } else { |
|
| 1226 | - // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1227 | - if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) === true && $set['single_dot_as_decimal'] === true) { |
|
| 1228 | - // Treat single dot as decimal separator |
|
| 1229 | - return (float)$str; |
|
| 1230 | - } else { |
|
| 1231 | - //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1232 | - // Else, treat all dots as thousand seps |
|
| 1233 | - $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1234 | - |
|
| 1235 | - return (float)$str; |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - } else { |
|
| 1239 | - // No number found, return zero |
|
| 1240 | - return 0; |
|
| 1241 | - } |
|
| 1216 | + if (preg_match("/([0-9\.,-]+)/", $str, $match)) { |
|
| 1217 | + // Found number in $str, so set $str that number |
|
| 1218 | + $str = $match[0]; |
|
| 1219 | + if (false !== strpos($str, ',')) { |
|
| 1220 | + // A comma exists, that makes it easy, cos we assume it separates the decimal part. |
|
| 1221 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1222 | + $str = str_replace(',', '.', $str); // Convert , to . for floatval command |
|
| 1223 | + |
|
| 1224 | + return (float)$str; |
|
| 1225 | + } else { |
|
| 1226 | + // No comma exists, so we have to decide, how a single dot shall be treated |
|
| 1227 | + if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) === true && $set['single_dot_as_decimal'] === true) { |
|
| 1228 | + // Treat single dot as decimal separator |
|
| 1229 | + return (float)$str; |
|
| 1230 | + } else { |
|
| 1231 | + //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> "; |
|
| 1232 | + // Else, treat all dots as thousand seps |
|
| 1233 | + $str = str_replace('.', '', $str); // Erase thousand seps |
|
| 1234 | + |
|
| 1235 | + return (float)$str; |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + } else { |
|
| 1239 | + // No number found, return zero |
|
| 1240 | + return 0; |
|
| 1241 | + } |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | /** |
@@ -1248,26 +1248,26 @@ discard block |
||
| 1248 | 1248 | */ |
| 1249 | 1249 | function smart_currency($var, $currencyObj = false) |
| 1250 | 1250 | { |
| 1251 | - $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
| 1252 | - $ret = round($ret, 2); |
|
| 1253 | - // make sur we have at least .00 in the $var |
|
| 1254 | - $decimal_section_original = strstr($ret, '.'); |
|
| 1255 | - $decimal_section = $decimal_section_original; |
|
| 1256 | - if ($decimal_section) { |
|
| 1257 | - if (strlen($decimal_section) == 1) { |
|
| 1258 | - $decimal_section = '.00'; |
|
| 1259 | - } elseif (strlen($decimal_section) == 2) { |
|
| 1260 | - $decimal_section .= '0'; |
|
| 1261 | - } |
|
| 1262 | - $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1263 | - } else { |
|
| 1264 | - $ret .= '.00'; |
|
| 1265 | - } |
|
| 1266 | - if ($currencyObj) { |
|
| 1267 | - $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - return $ret; |
|
| 1251 | + $ret = smart_getfloat($var, array('single_dot_as_decimal' => true)); |
|
| 1252 | + $ret = round($ret, 2); |
|
| 1253 | + // make sur we have at least .00 in the $var |
|
| 1254 | + $decimal_section_original = strstr($ret, '.'); |
|
| 1255 | + $decimal_section = $decimal_section_original; |
|
| 1256 | + if ($decimal_section) { |
|
| 1257 | + if (strlen($decimal_section) == 1) { |
|
| 1258 | + $decimal_section = '.00'; |
|
| 1259 | + } elseif (strlen($decimal_section) == 2) { |
|
| 1260 | + $decimal_section .= '0'; |
|
| 1261 | + } |
|
| 1262 | + $ret = str_replace($decimal_section_original, $decimal_section, $ret); |
|
| 1263 | + } else { |
|
| 1264 | + $ret .= '.00'; |
|
| 1265 | + } |
|
| 1266 | + if ($currencyObj) { |
|
| 1267 | + $ret = $ret . ' ' . $currencyObj->getCode(); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + return $ret; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | */ |
| 1277 | 1277 | function smart_float($var) |
| 1278 | 1278 | { |
| 1279 | - return smart_currency($var); |
|
| 1279 | + return smart_currency($var); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
@@ -1285,16 +1285,16 @@ discard block |
||
| 1285 | 1285 | */ |
| 1286 | 1286 | function smart_getModuleAdminLink($moduleName = false) |
| 1287 | 1287 | { |
| 1288 | - global $xoopsModule; |
|
| 1289 | - if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1290 | - $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1291 | - } |
|
| 1292 | - $ret = ''; |
|
| 1293 | - if ($moduleName) { |
|
| 1294 | - $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - return $ret; |
|
| 1288 | + global $xoopsModule; |
|
| 1289 | + if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) { |
|
| 1290 | + $moduleName = $xoopsModule->getVar('dirname'); |
|
| 1291 | + } |
|
| 1292 | + $ret = ''; |
|
| 1293 | + if ($moduleName) { |
|
| 1294 | + $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>'; |
|
| 1295 | + } |
|
| 1296 | + |
|
| 1297 | + return $ret; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | 1300 | /** |
@@ -1302,19 +1302,19 @@ discard block |
||
| 1302 | 1302 | */ |
| 1303 | 1303 | function smart_getEditors() |
| 1304 | 1304 | { |
| 1305 | - $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1306 | - if (!file_exists($filename)) { |
|
| 1307 | - return false; |
|
| 1308 | - } |
|
| 1309 | - require_once $filename; |
|
| 1310 | - $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1311 | - $aList = $xoopseditorHandler->getList(); |
|
| 1312 | - $ret = array(); |
|
| 1313 | - foreach ($aList as $k => $v) { |
|
| 1314 | - $ret[$v] = $k; |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - return $ret; |
|
| 1305 | + $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php'; |
|
| 1306 | + if (!file_exists($filename)) { |
|
| 1307 | + return false; |
|
| 1308 | + } |
|
| 1309 | + require_once $filename; |
|
| 1310 | + $xoopseditorHandler = XoopsEditorHandler::getInstance(); |
|
| 1311 | + $aList = $xoopseditorHandler->getList(); |
|
| 1312 | + $ret = array(); |
|
| 1313 | + foreach ($aList as $k => $v) { |
|
| 1314 | + $ret[$v] = $k; |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + return $ret; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | /** |
@@ -1324,11 +1324,11 @@ discard block |
||
| 1324 | 1324 | */ |
| 1325 | 1325 | function smart_getTablesArray($moduleName, $items) |
| 1326 | 1326 | { |
| 1327 | - $ret = array(); |
|
| 1328 | - foreach ($items as $item) { |
|
| 1329 | - $ret[] = $moduleName . '_' . $item; |
|
| 1330 | - } |
|
| 1331 | - $ret[] = $moduleName . '_meta'; |
|
| 1327 | + $ret = array(); |
|
| 1328 | + foreach ($items as $item) { |
|
| 1329 | + $ret[] = $moduleName . '_' . $item; |
|
| 1330 | + } |
|
| 1331 | + $ret[] = $moduleName . '_meta'; |
|
| 1332 | 1332 | |
| 1333 | - return $ret; |
|
| 1333 | + return $ret; |
|
| 1334 | 1334 | } |
@@ -15,319 +15,319 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Scriptaculous extends Prototype |
| 17 | 17 | { |
| 18 | - public $TOGGLE_EFFECTS = array('toggle_appear', 'toggle_slide', 'toggle_blind'); |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Scriptaculous constructor. |
|
| 22 | - */ |
|
| 23 | - public function __construct() |
|
| 24 | - { |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param $element_id |
|
| 29 | - * @param null $options |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function dragable_element($element_id, $options = null) |
|
| 33 | - { |
|
| 34 | - return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param $element_id |
|
| 39 | - * @param null $options |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function drop_receiving_element($element_id, $options = null) |
|
| 43 | - { |
|
| 44 | - return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param $name |
|
| 49 | - * @param bool $element_id |
|
| 50 | - * @param null $js_options |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | - { |
|
| 55 | - $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | - |
|
| 57 | - $js_queue = ''; |
|
| 58 | - if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | - } elseif (isset($js_options)) { |
|
| 60 | - $js_queue = "'$js_options'"; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | - } else { |
|
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param $element_id |
|
| 72 | - * @param null $options |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function sortabe_element($element_id, $options = null) |
|
| 76 | - { |
|
| 77 | - return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | - // Private functions |
|
| 82 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @param $element_id |
|
| 86 | - * @param $options |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function _sortabe_element($element_id, $options) |
|
| 90 | - { |
|
| 91 | - //if (isset($options['with'])) { |
|
| 92 | - $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 93 | - // } |
|
| 94 | - |
|
| 95 | - //if (isset($option['onUpdate'])) { |
|
| 96 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 97 | - //} |
|
| 98 | - |
|
| 99 | - foreach ($options as $var => $val) { |
|
| 100 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 101 | - unset($options[$var]); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
| 106 | - |
|
| 107 | - foreach ($arr as $var) { |
|
| 108 | - if (isset($options[$var])) { |
|
| 109 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - if (isset($options['containment'])) { |
|
| 114 | - $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if (isset($options['only'])) { |
|
| 118 | - $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @param $element_id |
|
| 126 | - * @param $options |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function _dragable_element_js($element_id, $options) |
|
| 130 | - { |
|
| 131 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @param $element_id |
|
| 136 | - * @param $options |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function _drop_receiving_element($element_id, $options) |
|
| 140 | - { |
|
| 141 | - |
|
| 142 | - //if (isset($options['with'])) { |
|
| 143 | - $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 144 | - // } |
|
| 145 | - |
|
| 146 | - //if (isset($option['onDrop'])) |
|
| 147 | - |
|
| 148 | - { |
|
| 149 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (is_array($options)) { |
|
| 153 | - foreach ($options as $var => $val) { |
|
| 154 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 155 | - unset($options[$var]); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if (isset($options['accept'])) { |
|
| 161 | - $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if (isset($options['hoverclass'])) { |
|
| 165 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 172 | - // Merged Javascript macro |
|
| 173 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @param $field_id |
|
| 177 | - * @param $options |
|
| 178 | - * @param bool $tag |
|
| 179 | - * @return string |
|
| 180 | - */ |
|
| 181 | - public function in_place_editor($field_id, $options, $tag = true) |
|
| 182 | - { |
|
| 183 | - $function = 'new Ajax.InPlaceEditor('; |
|
| 184 | - $function .= "'$field_id', "; |
|
| 185 | - $function .= "'" . $options['url'] . "'"; |
|
| 186 | - |
|
| 187 | - $js_options = array(); |
|
| 188 | - if (isset($options['cancel_text'])) { |
|
| 189 | - $js_options['cancelText'] = $options['cancel_text']; |
|
| 190 | - } |
|
| 191 | - if (isset($options['save_text'])) { |
|
| 192 | - $js_options['okText'] = $options['save_text']; |
|
| 193 | - } |
|
| 194 | - if (isset($options['loading_text'])) { |
|
| 195 | - $js_options['loadingText'] = $options['loading_text']; |
|
| 196 | - } |
|
| 197 | - if (isset($options['rows'])) { |
|
| 198 | - $js_options['rows'] = $options['rows']; |
|
| 199 | - } |
|
| 200 | - if (isset($options['cols'])) { |
|
| 201 | - $js_options['cols'] = $options['cols']; |
|
| 202 | - } |
|
| 203 | - if (isset($options['size'])) { |
|
| 204 | - $js_options['size'] = $options['size']; |
|
| 205 | - } |
|
| 206 | - if (isset($options['external_control'])) { |
|
| 207 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 208 | - } |
|
| 209 | - if (isset($options['load_text_url'])) { |
|
| 210 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 211 | - } |
|
| 212 | - if (isset($options['options'])) { |
|
| 213 | - $js_options['ajaxOptions'] = $options['options']; |
|
| 214 | - } |
|
| 215 | - if (isset($options['script'])) { |
|
| 216 | - $js_options['evalScripts'] = $options['script']; |
|
| 217 | - } |
|
| 218 | - if (isset($options['with'])) { |
|
| 219 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 223 | - if ($tag) { |
|
| 224 | - return $this->tag($function); |
|
| 225 | - } else { |
|
| 226 | - return $function; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param $object |
|
| 232 | - * @param null $tag_options |
|
| 233 | - * @param null $in_place_editor_options |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 237 | - { |
|
| 238 | - $ret_val = ''; |
|
| 239 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 240 | - $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 241 | - |
|
| 242 | - return $ret_val; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param $field_id |
|
| 247 | - * @param $options |
|
| 248 | - * @return mixed |
|
| 249 | - */ |
|
| 250 | - public function auto_complete_field($field_id, $options) |
|
| 251 | - { |
|
| 252 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 253 | - $function .= "'$field_id', "; |
|
| 254 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 255 | - $function .= "'" . $options['url'] . "'"; |
|
| 256 | - |
|
| 257 | - $js_options = array(); |
|
| 258 | - if (isset($options['tokens'])) { |
|
| 259 | - $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 260 | - } |
|
| 261 | - if (isset($options['with'])) { |
|
| 262 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 263 | - } |
|
| 264 | - if (isset($options['indicator'])) { |
|
| 265 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 266 | - } |
|
| 267 | - if (isset($options['select'])) { |
|
| 268 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
| 272 | - if (isset($options[$var])) { |
|
| 273 | - $js_options['$val'] = $options['var']; |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 278 | - |
|
| 279 | - return $this->tag($function); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * @param $entries |
|
| 284 | - * @param $field |
|
| 285 | - * @param null $phrase |
|
| 286 | - */ |
|
| 287 | - public function auto_complete_results($entries, $field, $phrase = null) |
|
| 288 | - { |
|
| 289 | - if (!is_array($entries)) { |
|
| 290 | - return; |
|
| 291 | - } |
|
| 292 | - $ret_val = '<ul>'; |
|
| 293 | - // Complete this function |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @param $object |
|
| 298 | - * @param null $tag_options |
|
| 299 | - * @param null $completion_options |
|
| 300 | - * @return string |
|
| 301 | - */ |
|
| 302 | - public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 303 | - { |
|
| 304 | - $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 305 | - $ret_val .= '<input autocomplete="off" id="' |
|
| 306 | - . $object |
|
| 307 | - . '" name="' |
|
| 308 | - . $object |
|
| 309 | - . '" size="' |
|
| 310 | - . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 311 | - . '" type="text" value="' |
|
| 312 | - . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 313 | - . '" ' |
|
| 314 | - . (isset($tag_options['class']) ? 'class = "' |
|
| 315 | - . $tag_options['class'] |
|
| 316 | - . '" ' : '') |
|
| 317 | - . '>'; |
|
| 318 | - |
|
| 319 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 320 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 321 | - |
|
| 322 | - return $ret_val; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * @return string |
|
| 327 | - */ |
|
| 328 | - public function _auto_complete_stylesheet() |
|
| 329 | - { |
|
| 330 | - return '<style> div.auto_complete { |
|
| 18 | + public $TOGGLE_EFFECTS = array('toggle_appear', 'toggle_slide', 'toggle_blind'); |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Scriptaculous constructor. |
|
| 22 | + */ |
|
| 23 | + public function __construct() |
|
| 24 | + { |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param $element_id |
|
| 29 | + * @param null $options |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function dragable_element($element_id, $options = null) |
|
| 33 | + { |
|
| 34 | + return $this->tag($this->_dragable_element_js($element_id, $options)); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param $element_id |
|
| 39 | + * @param null $options |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function drop_receiving_element($element_id, $options = null) |
|
| 43 | + { |
|
| 44 | + return $this->tag($this->_drop_receiving_element($element_id, $options)); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param $name |
|
| 49 | + * @param bool $element_id |
|
| 50 | + * @param null $js_options |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public function visual_effect($name, $element_id = false, $js_options = null) |
|
| 54 | + { |
|
| 55 | + $element = $element_id ? "'$element_id'" : 'element'; |
|
| 56 | + |
|
| 57 | + $js_queue = ''; |
|
| 58 | + if (isset($js_options) && is_array($js_options['queue'])) { |
|
| 59 | + } elseif (isset($js_options)) { |
|
| 60 | + $js_queue = "'$js_options'"; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (in_array($name, $this->TOGGLE_EFFECTS)) { |
|
| 64 | + return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 65 | + } else { |
|
| 66 | + return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param $element_id |
|
| 72 | + * @param null $options |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function sortabe_element($element_id, $options = null) |
|
| 76 | + { |
|
| 77 | + return $this->tag($this->_sortabe_element($element_id, $options)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 81 | + // Private functions |
|
| 82 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param $element_id |
|
| 86 | + * @param $options |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function _sortabe_element($element_id, $options) |
|
| 90 | + { |
|
| 91 | + //if (isset($options['with'])) { |
|
| 92 | + $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 93 | + // } |
|
| 94 | + |
|
| 95 | + //if (isset($option['onUpdate'])) { |
|
| 96 | + $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 97 | + //} |
|
| 98 | + |
|
| 99 | + foreach ($options as $var => $val) { |
|
| 100 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 101 | + unset($options[$var]); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
| 106 | + |
|
| 107 | + foreach ($arr as $var) { |
|
| 108 | + if (isset($options[$var])) { |
|
| 109 | + $options[$var] = "'" . $options[$var] . "'"; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + if (isset($options['containment'])) { |
|
| 114 | + $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if (isset($options['only'])) { |
|
| 118 | + $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @param $element_id |
|
| 126 | + * @param $options |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function _dragable_element_js($element_id, $options) |
|
| 130 | + { |
|
| 131 | + return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @param $element_id |
|
| 136 | + * @param $options |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function _drop_receiving_element($element_id, $options) |
|
| 140 | + { |
|
| 141 | + |
|
| 142 | + //if (isset($options['with'])) { |
|
| 143 | + $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 144 | + // } |
|
| 145 | + |
|
| 146 | + //if (isset($option['onDrop'])) |
|
| 147 | + |
|
| 148 | + { |
|
| 149 | + $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (is_array($options)) { |
|
| 153 | + foreach ($options as $var => $val) { |
|
| 154 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 155 | + unset($options[$var]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if (isset($options['accept'])) { |
|
| 161 | + $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if (isset($options['hoverclass'])) { |
|
| 165 | + $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 172 | + // Merged Javascript macro |
|
| 173 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param $field_id |
|
| 177 | + * @param $options |
|
| 178 | + * @param bool $tag |
|
| 179 | + * @return string |
|
| 180 | + */ |
|
| 181 | + public function in_place_editor($field_id, $options, $tag = true) |
|
| 182 | + { |
|
| 183 | + $function = 'new Ajax.InPlaceEditor('; |
|
| 184 | + $function .= "'$field_id', "; |
|
| 185 | + $function .= "'" . $options['url'] . "'"; |
|
| 186 | + |
|
| 187 | + $js_options = array(); |
|
| 188 | + if (isset($options['cancel_text'])) { |
|
| 189 | + $js_options['cancelText'] = $options['cancel_text']; |
|
| 190 | + } |
|
| 191 | + if (isset($options['save_text'])) { |
|
| 192 | + $js_options['okText'] = $options['save_text']; |
|
| 193 | + } |
|
| 194 | + if (isset($options['loading_text'])) { |
|
| 195 | + $js_options['loadingText'] = $options['loading_text']; |
|
| 196 | + } |
|
| 197 | + if (isset($options['rows'])) { |
|
| 198 | + $js_options['rows'] = $options['rows']; |
|
| 199 | + } |
|
| 200 | + if (isset($options['cols'])) { |
|
| 201 | + $js_options['cols'] = $options['cols']; |
|
| 202 | + } |
|
| 203 | + if (isset($options['size'])) { |
|
| 204 | + $js_options['size'] = $options['size']; |
|
| 205 | + } |
|
| 206 | + if (isset($options['external_control'])) { |
|
| 207 | + $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 208 | + } |
|
| 209 | + if (isset($options['load_text_url'])) { |
|
| 210 | + $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 211 | + } |
|
| 212 | + if (isset($options['options'])) { |
|
| 213 | + $js_options['ajaxOptions'] = $options['options']; |
|
| 214 | + } |
|
| 215 | + if (isset($options['script'])) { |
|
| 216 | + $js_options['evalScripts'] = $options['script']; |
|
| 217 | + } |
|
| 218 | + if (isset($options['with'])) { |
|
| 219 | + $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 223 | + if ($tag) { |
|
| 224 | + return $this->tag($function); |
|
| 225 | + } else { |
|
| 226 | + return $function; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param $object |
|
| 232 | + * @param null $tag_options |
|
| 233 | + * @param null $in_place_editor_options |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 237 | + { |
|
| 238 | + $ret_val = ''; |
|
| 239 | + $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 240 | + $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 241 | + |
|
| 242 | + return $ret_val; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param $field_id |
|
| 247 | + * @param $options |
|
| 248 | + * @return mixed |
|
| 249 | + */ |
|
| 250 | + public function auto_complete_field($field_id, $options) |
|
| 251 | + { |
|
| 252 | + $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 253 | + $function .= "'$field_id', "; |
|
| 254 | + $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 255 | + $function .= "'" . $options['url'] . "'"; |
|
| 256 | + |
|
| 257 | + $js_options = array(); |
|
| 258 | + if (isset($options['tokens'])) { |
|
| 259 | + $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 260 | + } |
|
| 261 | + if (isset($options['with'])) { |
|
| 262 | + $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 263 | + } |
|
| 264 | + if (isset($options['indicator'])) { |
|
| 265 | + $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 266 | + } |
|
| 267 | + if (isset($options['select'])) { |
|
| 268 | + $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
| 272 | + if (isset($options[$var])) { |
|
| 273 | + $js_options['$val'] = $options['var']; |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 278 | + |
|
| 279 | + return $this->tag($function); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * @param $entries |
|
| 284 | + * @param $field |
|
| 285 | + * @param null $phrase |
|
| 286 | + */ |
|
| 287 | + public function auto_complete_results($entries, $field, $phrase = null) |
|
| 288 | + { |
|
| 289 | + if (!is_array($entries)) { |
|
| 290 | + return; |
|
| 291 | + } |
|
| 292 | + $ret_val = '<ul>'; |
|
| 293 | + // Complete this function |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @param $object |
|
| 298 | + * @param null $tag_options |
|
| 299 | + * @param null $completion_options |
|
| 300 | + * @return string |
|
| 301 | + */ |
|
| 302 | + public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 303 | + { |
|
| 304 | + $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 305 | + $ret_val .= '<input autocomplete="off" id="' |
|
| 306 | + . $object |
|
| 307 | + . '" name="' |
|
| 308 | + . $object |
|
| 309 | + . '" size="' |
|
| 310 | + . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 311 | + . '" type="text" value="' |
|
| 312 | + . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 313 | + . '" ' |
|
| 314 | + . (isset($tag_options['class']) ? 'class = "' |
|
| 315 | + . $tag_options['class'] |
|
| 316 | + . '" ' : '') |
|
| 317 | + . '>'; |
|
| 318 | + |
|
| 319 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 320 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 321 | + |
|
| 322 | + return $ret_val; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * @return string |
|
| 327 | + */ |
|
| 328 | + public function _auto_complete_stylesheet() |
|
| 329 | + { |
|
| 330 | + return '<style> div.auto_complete { |
|
| 331 | 331 | width: 350px; |
| 332 | 332 | background: #fff; |
| 333 | 333 | } |
@@ -351,5 +351,5 @@ discard block |
||
| 351 | 351 | padding:0; |
| 352 | 352 | } |
| 353 | 353 | </style>'; |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | } |