@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * @param $name |
|
| 192 | + * @param string $name |
|
| 193 | 193 | * @param string $extension |
| 194 | 194 | * @return array |
| 195 | 195 | */ |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * Return random background |
| 257 | 257 | * |
| 258 | - * @return array |
|
| 258 | + * @return string|null |
|
| 259 | 259 | */ |
| 260 | 260 | public function loadBackground() |
| 261 | 261 | { |
@@ -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'; |
@@ -5,11 +5,11 @@ discard block |
||
| 5 | 5 | * D.J. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -include dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/mainfile.php'; |
|
| 8 | +include dirname(dirname(dirname(dirname(dirname(__DIR__))))).'/mainfile.php'; |
|
| 9 | 9 | error_reporting(0); |
| 10 | 10 | $xoopsLogger->activated = false; |
| 11 | 11 | |
| 12 | -if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/^' . preg_quote(XOOPS_URL, '/') . '/', $_SERVER['HTTP_REFERER'])) { |
|
| 12 | +if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/^'.preg_quote(XOOPS_URL, '/').'/', $_SERVER['HTTP_REFERER'])) { |
|
| 13 | 13 | exit(); |
| 14 | 14 | } |
| 15 | 15 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | if ($this->mode === 'bmp') { |
| 87 | 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')); |
|
| 88 | + $this->code = mt_rand(pow(10, $this->config['num_chars'] - 1), (int) str_pad('9', $this->config['num_chars'], '9')); |
|
| 89 | 89 | } else { |
| 90 | 90 | $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']); |
| 91 | 91 | if (!$this->config['casesensitive']) { |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code; |
|
| 104 | - $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 103 | + $_SESSION['XoopsCaptcha_sessioncode'] = (string) $this->code; |
|
| 104 | + $maxAttempts = (int) (@$_SESSION['XoopsCaptcha_maxattempts']); |
|
| 105 | 105 | |
| 106 | 106 | // Increase the attempt records on refresh |
| 107 | 107 | if (!empty($maxAttempts)) { |
| 108 | - $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++; |
|
| 109 | - if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 108 | + $_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']]++; |
|
| 109 | + if ($_SESSION['XoopsCaptcha_attempt_'.$_SESSION['XoopsCaptcha_name']] > $maxAttempts) { |
|
| 110 | 110 | $this->invalid = true; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | if ($this->invalid) { |
| 122 | 122 | header('Content-type: image/gif'); |
| 123 | - readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif'); |
|
| 123 | + readfile(XOOPS_ROOT_PATH.'/images/subject/icon2.gif'); |
|
| 124 | 124 | |
| 125 | 125 | return; |
| 126 | 126 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | header('Content-type: image/jpeg'); |
| 191 | 191 | imagejpeg($this->oImage); |
| 192 | 192 | } else { |
| 193 | - imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg'); |
|
| 193 | + imagejpeg($this->oImage, XOOPS_ROOT_PATH.'/'.$this->config['imagepath'].'/'.$file.'.jpg'); |
|
| 194 | 194 | } |
| 195 | 195 | imagedestroy($this->oImage); |
| 196 | 196 | } |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | */ |
| 214 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
| 215 | - $file_path = $this->config['rootpath'] . "/{$name}"; |
|
| 214 | + require_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
| 215 | + $file_path = $this->config['rootpath']."/{$name}"; |
|
| 216 | 216 | $files = XoopsLists::getFileListAsArray($file_path); |
| 217 | 217 | foreach ($files as $item) { |
| 218 | 218 | if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | public function loadFont() |
| 230 | 230 | { |
| 231 | 231 | $fonts = $this->_getList('fonts', 'ttf'); |
| 232 | - $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)]; |
|
| 232 | + $this->font = $this->config['rootpath'].'/fonts/'.$fonts[array_rand($fonts)]; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | public function setImageSize() |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | imagedestroy($oImage); |
| 256 | 256 | |
| 257 | 257 | $this->height = $MaxCharHeight + 2; |
| 258 | - $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']); |
|
| 258 | + $this->spacing = (int) (($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']); |
|
| 259 | 259 | $this->width = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $RandBackground = null; |
| 270 | 270 | if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) { |
| 271 | - $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)]; |
|
| 271 | + $RandBackground = $this->config['rootpath'].'/backgrounds/'.$backgrounds[array_rand($backgrounds)]; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | return $RandBackground; |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | -$config = @include __DIR__ . '/../config.php'; |
|
| 441 | +$config = @include __DIR__.'/../config.php'; |
|
| 442 | 442 | $imageHandler = new XoopsCaptchaImageHandler(); |
| 443 | 443 | $imageHandler->setConfig($config); |
| 444 | 444 | $imageHandler->loadImage(); |
@@ -248,7 +248,7 @@ |
||
| 248 | 248 | /** |
| 249 | 249 | * @param $field_id |
| 250 | 250 | * @param $options |
| 251 | - * @return mixed |
|
| 251 | + * @return string |
|
| 252 | 252 | */ |
| 253 | 253 | public function auto_complete_field($field_id, $options) |
| 254 | 254 | { |
@@ -15,322 +15,322 @@ 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 | - |
|
| 90 | - public function _sortabe_element($element_id, $options) |
|
| 91 | - { |
|
| 92 | - //if (isset($options['with'])) |
|
| 93 | - { |
|
| 94 | - $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - //if (isset($option['onUpdate'])) |
|
| 98 | - { |
|
| 99 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - foreach ($options as $var => $val) { |
|
| 103 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 104 | - unset($options[$var]); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
| 109 | - |
|
| 110 | - foreach ($arr as $var) { |
|
| 111 | - if (isset($options[$var])) { |
|
| 112 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if (isset($options['containment'])) { |
|
| 117 | - $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if (isset($options['only'])) { |
|
| 121 | - $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param $element_id |
|
| 129 | - * @param $options |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public function _dragable_element_js($element_id, $options) |
|
| 133 | - { |
|
| 134 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param $element_id |
|
| 139 | - * @param $options |
|
| 140 | - * @return string |
|
| 141 | - */ |
|
| 142 | - public function _drop_receiving_element($element_id, $options) |
|
| 143 | - { |
|
| 144 | - |
|
| 145 | - //if (isset($options['with'])) |
|
| 146 | - { |
|
| 147 | - $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - //if (isset($option['onDrop'])) |
|
| 151 | - { |
|
| 152 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - if (is_array($options)) { |
|
| 156 | - foreach ($options as $var => $val) { |
|
| 157 | - if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 158 | - unset($options[$var]); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (isset($options['accept'])) { |
|
| 164 | - $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if (isset($options['hoverclass'])) { |
|
| 168 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 175 | - // Merged Javascript macro |
|
| 176 | - ///////////////////////////////////////////////////////////////////////////////////// |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @param $field_id |
|
| 180 | - * @param $options |
|
| 181 | - * @param bool $tag |
|
| 182 | - * @return string |
|
| 183 | - */ |
|
| 184 | - public function in_place_editor($field_id, $options, $tag = true) |
|
| 185 | - { |
|
| 186 | - $function = 'new Ajax.InPlaceEditor('; |
|
| 187 | - $function .= "'$field_id', "; |
|
| 188 | - $function .= "'" . $options['url'] . "'"; |
|
| 189 | - |
|
| 190 | - $js_options = array(); |
|
| 191 | - if (isset($options['cancel_text'])) { |
|
| 192 | - $js_options['cancelText'] = $options['cancel_text']; |
|
| 193 | - } |
|
| 194 | - if (isset($options['save_text'])) { |
|
| 195 | - $js_options['okText'] = $options['save_text']; |
|
| 196 | - } |
|
| 197 | - if (isset($options['loading_text'])) { |
|
| 198 | - $js_options['loadingText'] = $options['loading_text']; |
|
| 199 | - } |
|
| 200 | - if (isset($options['rows'])) { |
|
| 201 | - $js_options['rows'] = $options['rows']; |
|
| 202 | - } |
|
| 203 | - if (isset($options['cols'])) { |
|
| 204 | - $js_options['cols'] = $options['cols']; |
|
| 205 | - } |
|
| 206 | - if (isset($options['size'])) { |
|
| 207 | - $js_options['size'] = $options['size']; |
|
| 208 | - } |
|
| 209 | - if (isset($options['external_control'])) { |
|
| 210 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 211 | - } |
|
| 212 | - if (isset($options['load_text_url'])) { |
|
| 213 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 214 | - } |
|
| 215 | - if (isset($options['options'])) { |
|
| 216 | - $js_options['ajaxOptions'] = $options['options']; |
|
| 217 | - } |
|
| 218 | - if (isset($options['script'])) { |
|
| 219 | - $js_options['evalScripts'] = $options['script']; |
|
| 220 | - } |
|
| 221 | - if (isset($options['with'])) { |
|
| 222 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 226 | - if ($tag) { |
|
| 227 | - return $this->tag($function); |
|
| 228 | - } else { |
|
| 229 | - return $function; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @param $object |
|
| 235 | - * @param null $tag_options |
|
| 236 | - * @param null $in_place_editor_options |
|
| 237 | - * @return string |
|
| 238 | - */ |
|
| 239 | - public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 240 | - { |
|
| 241 | - $ret_val = ''; |
|
| 242 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 243 | - $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 244 | - |
|
| 245 | - return $ret_val; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param $field_id |
|
| 250 | - * @param $options |
|
| 251 | - * @return mixed |
|
| 252 | - */ |
|
| 253 | - public function auto_complete_field($field_id, $options) |
|
| 254 | - { |
|
| 255 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | - $function .= "'$field_id', "; |
|
| 257 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | - $function .= "'" . $options['url'] . "'"; |
|
| 259 | - |
|
| 260 | - $js_options = array(); |
|
| 261 | - if (isset($options['tokens'])) { |
|
| 262 | - $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 263 | - } |
|
| 264 | - if (isset($options['with'])) { |
|
| 265 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 266 | - } |
|
| 267 | - if (isset($options['indicator'])) { |
|
| 268 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 269 | - } |
|
| 270 | - if (isset($options['select'])) { |
|
| 271 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
| 275 | - if (isset($options[$var])) { |
|
| 276 | - $js_options['$val'] = $options['var']; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 281 | - |
|
| 282 | - return $this->tag($function); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @param $entries |
|
| 287 | - * @param $field |
|
| 288 | - * @param null $phrase |
|
| 289 | - */ |
|
| 290 | - public function auto_complete_results($entries, $field, $phrase = null) |
|
| 291 | - { |
|
| 292 | - if (!is_array($entries)) { |
|
| 293 | - return; |
|
| 294 | - } |
|
| 295 | - $ret_val = '<ul>'; |
|
| 296 | - // Complete this function |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * @param $object |
|
| 301 | - * @param null $tag_options |
|
| 302 | - * @param null $completion_options |
|
| 303 | - * @return string |
|
| 304 | - */ |
|
| 305 | - public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 306 | - { |
|
| 307 | - $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 308 | - $ret_val .= '<input autocomplete="off" id="' |
|
| 309 | - . $object |
|
| 310 | - . '" name="' |
|
| 311 | - . $object |
|
| 312 | - . '" size="' |
|
| 313 | - . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 314 | - . '" type="text" value="' |
|
| 315 | - . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 316 | - . '" ' |
|
| 317 | - . (isset($tag_options['class']) ? 'class = "' |
|
| 318 | - . $tag_options['class'] |
|
| 319 | - . '" ' : '') |
|
| 320 | - . '>'; |
|
| 321 | - |
|
| 322 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 323 | - $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 324 | - |
|
| 325 | - return $ret_val; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * @return string |
|
| 330 | - */ |
|
| 331 | - public function _auto_complete_stylesheet() |
|
| 332 | - { |
|
| 333 | - 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 | + |
|
| 90 | + public function _sortabe_element($element_id, $options) |
|
| 91 | + { |
|
| 92 | + //if (isset($options['with'])) |
|
| 93 | + { |
|
| 94 | + $options['with'] = "Sortable.serialize('$element_id')"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + //if (isset($option['onUpdate'])) |
|
| 98 | + { |
|
| 99 | + $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + foreach ($options as $var => $val) { |
|
| 103 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 104 | + unset($options[$var]); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $arr = array('tag', 'overlap', 'contraint', 'handle'); |
|
| 109 | + |
|
| 110 | + foreach ($arr as $var) { |
|
| 111 | + if (isset($options[$var])) { |
|
| 112 | + $options[$var] = "'" . $options[$var] . "'"; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if (isset($options['containment'])) { |
|
| 117 | + $options['containment'] = $this->_array_or_string_for_javascript($options['containment']); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if (isset($options['only'])) { |
|
| 121 | + $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param $element_id |
|
| 129 | + * @param $options |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public function _dragable_element_js($element_id, $options) |
|
| 133 | + { |
|
| 134 | + return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param $element_id |
|
| 139 | + * @param $options |
|
| 140 | + * @return string |
|
| 141 | + */ |
|
| 142 | + public function _drop_receiving_element($element_id, $options) |
|
| 143 | + { |
|
| 144 | + |
|
| 145 | + //if (isset($options['with'])) |
|
| 146 | + { |
|
| 147 | + $options['with'] = '\'id=\' + encodeURIComponent(element.id)'; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + //if (isset($option['onDrop'])) |
|
| 151 | + { |
|
| 152 | + $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if (is_array($options)) { |
|
| 156 | + foreach ($options as $var => $val) { |
|
| 157 | + if (in_array($var, $this->AJAX_OPTIONS)) { |
|
| 158 | + unset($options[$var]); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (isset($options['accept'])) { |
|
| 164 | + $options['accept'] = $this->_array_or_string_for_javascript($options['accept']); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if (isset($options['hoverclass'])) { |
|
| 168 | + $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 175 | + // Merged Javascript macro |
|
| 176 | + ///////////////////////////////////////////////////////////////////////////////////// |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @param $field_id |
|
| 180 | + * @param $options |
|
| 181 | + * @param bool $tag |
|
| 182 | + * @return string |
|
| 183 | + */ |
|
| 184 | + public function in_place_editor($field_id, $options, $tag = true) |
|
| 185 | + { |
|
| 186 | + $function = 'new Ajax.InPlaceEditor('; |
|
| 187 | + $function .= "'$field_id', "; |
|
| 188 | + $function .= "'" . $options['url'] . "'"; |
|
| 189 | + |
|
| 190 | + $js_options = array(); |
|
| 191 | + if (isset($options['cancel_text'])) { |
|
| 192 | + $js_options['cancelText'] = $options['cancel_text']; |
|
| 193 | + } |
|
| 194 | + if (isset($options['save_text'])) { |
|
| 195 | + $js_options['okText'] = $options['save_text']; |
|
| 196 | + } |
|
| 197 | + if (isset($options['loading_text'])) { |
|
| 198 | + $js_options['loadingText'] = $options['loading_text']; |
|
| 199 | + } |
|
| 200 | + if (isset($options['rows'])) { |
|
| 201 | + $js_options['rows'] = $options['rows']; |
|
| 202 | + } |
|
| 203 | + if (isset($options['cols'])) { |
|
| 204 | + $js_options['cols'] = $options['cols']; |
|
| 205 | + } |
|
| 206 | + if (isset($options['size'])) { |
|
| 207 | + $js_options['size'] = $options['size']; |
|
| 208 | + } |
|
| 209 | + if (isset($options['external_control'])) { |
|
| 210 | + $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 211 | + } |
|
| 212 | + if (isset($options['load_text_url'])) { |
|
| 213 | + $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 214 | + } |
|
| 215 | + if (isset($options['options'])) { |
|
| 216 | + $js_options['ajaxOptions'] = $options['options']; |
|
| 217 | + } |
|
| 218 | + if (isset($options['script'])) { |
|
| 219 | + $js_options['evalScripts'] = $options['script']; |
|
| 220 | + } |
|
| 221 | + if (isset($options['with'])) { |
|
| 222 | + $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 226 | + if ($tag) { |
|
| 227 | + return $this->tag($function); |
|
| 228 | + } else { |
|
| 229 | + return $function; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @param $object |
|
| 235 | + * @param null $tag_options |
|
| 236 | + * @param null $in_place_editor_options |
|
| 237 | + * @return string |
|
| 238 | + */ |
|
| 239 | + public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
|
| 240 | + { |
|
| 241 | + $ret_val = ''; |
|
| 242 | + $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 243 | + $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
|
| 244 | + |
|
| 245 | + return $ret_val; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param $field_id |
|
| 250 | + * @param $options |
|
| 251 | + * @return mixed |
|
| 252 | + */ |
|
| 253 | + public function auto_complete_field($field_id, $options) |
|
| 254 | + { |
|
| 255 | + $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | + $function .= "'$field_id', "; |
|
| 257 | + $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | + $function .= "'" . $options['url'] . "'"; |
|
| 259 | + |
|
| 260 | + $js_options = array(); |
|
| 261 | + if (isset($options['tokens'])) { |
|
| 262 | + $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
|
| 263 | + } |
|
| 264 | + if (isset($options['with'])) { |
|
| 265 | + $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 266 | + } |
|
| 267 | + if (isset($options['indicator'])) { |
|
| 268 | + $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 269 | + } |
|
| 270 | + if (isset($options['select'])) { |
|
| 271 | + $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
|
| 275 | + if (isset($options[$var])) { |
|
| 276 | + $js_options['$val'] = $options['var']; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 281 | + |
|
| 282 | + return $this->tag($function); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @param $entries |
|
| 287 | + * @param $field |
|
| 288 | + * @param null $phrase |
|
| 289 | + */ |
|
| 290 | + public function auto_complete_results($entries, $field, $phrase = null) |
|
| 291 | + { |
|
| 292 | + if (!is_array($entries)) { |
|
| 293 | + return; |
|
| 294 | + } |
|
| 295 | + $ret_val = '<ul>'; |
|
| 296 | + // Complete this function |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * @param $object |
|
| 301 | + * @param null $tag_options |
|
| 302 | + * @param null $completion_options |
|
| 303 | + * @return string |
|
| 304 | + */ |
|
| 305 | + public function text_field_with_auto_complete($object, $tag_options = null, $completion_options = null) |
|
| 306 | + { |
|
| 307 | + $ret_val = isset($completion_options['skip_style']) ? '' : $this->_auto_complete_stylesheet(); |
|
| 308 | + $ret_val .= '<input autocomplete="off" id="' |
|
| 309 | + . $object |
|
| 310 | + . '" name="' |
|
| 311 | + . $object |
|
| 312 | + . '" size="' |
|
| 313 | + . (isset($tag_options['size']) ? $tag_options['size'] : 30) |
|
| 314 | + . '" type="text" value="' |
|
| 315 | + . (isset($tag_options['size']) ? $tag_options['value'] : '') |
|
| 316 | + . '" ' |
|
| 317 | + . (isset($tag_options['class']) ? 'class = "' |
|
| 318 | + . $tag_options['class'] |
|
| 319 | + . '" ' : '') |
|
| 320 | + . '>'; |
|
| 321 | + |
|
| 322 | + $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 323 | + $ret_val .= $this->auto_complete_field($object, $completion_options); |
|
| 324 | + |
|
| 325 | + return $ret_val; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * @return string |
|
| 330 | + */ |
|
| 331 | + public function _auto_complete_stylesheet() |
|
| 332 | + { |
|
| 333 | + return '<style> div.auto_complete { |
|
| 334 | 334 | width: 350px; |
| 335 | 335 | background: #fff; |
| 336 | 336 | } |
@@ -354,5 +354,5 @@ discard block |
||
| 354 | 354 | padding:0; |
| 355 | 355 | } |
| 356 | 356 | </style>'; |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (in_array($name, $this->TOGGLE_EFFECTS)) { |
| 64 | - return "Effect.toggle($element,'" . str_replace('toggle_', '', $name) . "'," . $this->_options_for_javascript($js_options) . ')'; |
|
| 64 | + return "Effect.toggle($element,'".str_replace('toggle_', '', $name)."',".$this->_options_for_javascript($js_options).')'; |
|
| 65 | 65 | } else { |
| 66 | - return 'new Effect.' . ucwords($name) . "($element," . $this->_options_for_javascript($js_options) . ')'; |
|
| 66 | + return 'new Effect.'.ucwords($name)."($element,".$this->_options_for_javascript($js_options).')'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | //if (isset($option['onUpdate'])) |
| 98 | 98 | { |
| 99 | - $options['onUpdate'] = 'function(){' . $this->remote_function($options) . '}'; |
|
| 99 | + $options['onUpdate'] = 'function(){'.$this->remote_function($options).'}'; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | foreach ($options as $var => $val) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | foreach ($arr as $var) { |
| 111 | 111 | if (isset($options[$var])) { |
| 112 | - $options[$var] = "'" . $options[$var] . "'"; |
|
| 112 | + $options[$var] = "'".$options[$var]."'"; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $options['only'] = $this->_array_or_string_for_javascript($options['only']); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return "Sortable.create('$element_id'," . $this->_options_for_javascript($options) . ')'; |
|
| 124 | + return "Sortable.create('$element_id',".$this->_options_for_javascript($options).')'; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function _dragable_element_js($element_id, $options) |
| 133 | 133 | { |
| 134 | - return 'new Draggable(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 134 | + return 'new Draggable(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | //if (isset($option['onDrop'])) |
| 151 | 151 | { |
| 152 | - $options['onDrop'] = 'function(element){' . $this->remote_function($options) . '}'; |
|
| 152 | + $options['onDrop'] = 'function(element){'.$this->remote_function($options).'}'; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if (is_array($options)) { |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (isset($options['hoverclass'])) { |
| 168 | - $options['hoverclass'] = "'" . $options['hoverclass'] . "'"; |
|
| 168 | + $options['hoverclass'] = "'".$options['hoverclass']."'"; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return 'Droppables.add(\'' . $element_id . '\',' . $this->_options_for_javascript($options) . ')'; |
|
| 171 | + return 'Droppables.add(\''.$element_id.'\','.$this->_options_for_javascript($options).')'; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | ///////////////////////////////////////////////////////////////////////////////////// |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $function = 'new Ajax.InPlaceEditor('; |
| 187 | 187 | $function .= "'$field_id', "; |
| 188 | - $function .= "'" . $options['url'] . "'"; |
|
| 188 | + $function .= "'".$options['url']."'"; |
|
| 189 | 189 | |
| 190 | 190 | $js_options = array(); |
| 191 | 191 | if (isset($options['cancel_text'])) { |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | $js_options['size'] = $options['size']; |
| 208 | 208 | } |
| 209 | 209 | if (isset($options['external_control'])) { |
| 210 | - $js_options['externalControl'] = "'" . $options['external_control'] . "'"; |
|
| 210 | + $js_options['externalControl'] = "'".$options['external_control']."'"; |
|
| 211 | 211 | } |
| 212 | 212 | if (isset($options['load_text_url'])) { |
| 213 | - $js_options['loadTextURL'] = "'" . $options['load_text_url'] . "'"; |
|
| 213 | + $js_options['loadTextURL'] = "'".$options['load_text_url']."'"; |
|
| 214 | 214 | } |
| 215 | 215 | if (isset($options['options'])) { |
| 216 | 216 | $js_options['ajaxOptions'] = $options['options']; |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | $js_options['evalScripts'] = $options['script']; |
| 220 | 220 | } |
| 221 | 221 | if (isset($options['with'])) { |
| 222 | - $js_options['callback'] = 'function(form) { return ' . $options['with'] . ' }'; |
|
| 222 | + $js_options['callback'] = 'function(form) { return '.$options['with'].' }'; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 225 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 226 | 226 | if ($tag) { |
| 227 | 227 | return $this->tag($function); |
| 228 | 228 | } else { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | public function in_place_editor_field($object, $tag_options = null, $in_place_editor_options = null) |
| 240 | 240 | { |
| 241 | 241 | $ret_val = ''; |
| 242 | - $ret_val .= '<span id="' . $object . '" class="in_place_editor_field">' . (isset($tag_options['value']) ? $tag_options['value'] : '') . '</span>'; |
|
| 242 | + $ret_val .= '<span id="'.$object.'" class="in_place_editor_field">'.(isset($tag_options['value']) ? $tag_options['value'] : '').'</span>'; |
|
| 243 | 243 | $ret_val .= $this->in_place_editor($object, $in_place_editor_options); |
| 244 | 244 | |
| 245 | 245 | return $ret_val; |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function auto_complete_field($field_id, $options) |
| 254 | 254 | { |
| 255 | - $function = "var $field_id" . '_auto_completer = new Ajax.Autocompleter('; |
|
| 255 | + $function = "var $field_id".'_auto_completer = new Ajax.Autocompleter('; |
|
| 256 | 256 | $function .= "'$field_id', "; |
| 257 | - $function .= "'" . (isset($options['update']) ? $options['update'] : $field_id . '_auto_complete') . "', "; |
|
| 258 | - $function .= "'" . $options['url'] . "'"; |
|
| 257 | + $function .= "'".(isset($options['update']) ? $options['update'] : $field_id.'_auto_complete')."', "; |
|
| 258 | + $function .= "'".$options['url']."'"; |
|
| 259 | 259 | |
| 260 | 260 | $js_options = array(); |
| 261 | 261 | if (isset($options['tokens'])) { |
| 262 | 262 | $js_options['tokens'] = $this->javascript->_array_or_string_for_javascript($options['tokens']); |
| 263 | 263 | } |
| 264 | 264 | if (isset($options['with'])) { |
| 265 | - $js_options['callback'] = 'function(element, value) { return ' . $options['with'] . ' }'; |
|
| 265 | + $js_options['callback'] = 'function(element, value) { return '.$options['with'].' }'; |
|
| 266 | 266 | } |
| 267 | 267 | if (isset($options['indicator'])) { |
| 268 | - $js_options['indicator'] = "'" . $options['indicator'] . "'"; |
|
| 268 | + $js_options['indicator'] = "'".$options['indicator']."'"; |
|
| 269 | 269 | } |
| 270 | 270 | if (isset($options['select'])) { |
| 271 | - $js_options['select'] = "'" . $options['select'] . "'"; |
|
| 271 | + $js_options['select'] = "'".$options['select']."'"; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | foreach (array('on_show' => 'onShow', 'on_hide' => 'onHide', 'min_chars' => 'min_chars') as $var => $val) { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $function .= ', ' . $this->_options_for_javascript($js_options) . ' )'; |
|
| 280 | + $function .= ', '.$this->_options_for_javascript($js_options).' )'; |
|
| 281 | 281 | |
| 282 | 282 | return $this->tag($function); |
| 283 | 283 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | . '" ' : '') |
| 320 | 320 | . '>'; |
| 321 | 321 | |
| 322 | - $ret_val .= '<div id="' . $object . '_auto_complete" class="auto_complete"></div>'; |
|
| 322 | + $ret_val .= '<div id="'.$object.'_auto_complete" class="auto_complete"></div>'; |
|
| 323 | 323 | $ret_val .= $this->auto_complete_field($object, $completion_options); |
| 324 | 324 | |
| 325 | 325 | return $ret_val; |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | |
| 10 | 10 | function smartobject_plugin_smartpartner() |
| 11 | 11 | { |
| 12 | - $pluginInfo = array(); |
|
| 12 | + $pluginInfo = array(); |
|
| 13 | 13 | |
| 14 | - $pluginInfo['items']['partner']['caption'] = 'Partner'; |
|
| 15 | - $pluginInfo['items']['partner']['url'] = 'partner.php?partnerid=%u'; |
|
| 16 | - $pluginInfo['items']['partner']['request'] = 'partnerid'; |
|
| 14 | + $pluginInfo['items']['partner']['caption'] = 'Partner'; |
|
| 15 | + $pluginInfo['items']['partner']['url'] = 'partner.php?partnerid=%u'; |
|
| 16 | + $pluginInfo['items']['partner']['request'] = 'partnerid'; |
|
| 17 | 17 | |
| 18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | - $pluginInfo['items']['category']['url'] = 'index.php?view_category_id=%u'; |
|
| 20 | - $pluginInfo['items']['category']['request'] = 'view_category_id'; |
|
| 18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | + $pluginInfo['items']['category']['url'] = 'index.php?view_category_id=%u'; |
|
| 20 | + $pluginInfo['items']['category']['request'] = 'view_category_id'; |
|
| 21 | 21 | |
| 22 | - return $pluginInfo; |
|
| 22 | + return $pluginInfo; |
|
| 23 | 23 | } |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | |
| 10 | 10 | function smartobject_plugin_smartsection() |
| 11 | 11 | { |
| 12 | - $pluginInfo = array(); |
|
| 12 | + $pluginInfo = array(); |
|
| 13 | 13 | |
| 14 | - $pluginInfo['items']['item']['caption'] = 'Article'; |
|
| 15 | - $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
| 16 | - $pluginInfo['items']['item']['request'] = 'itemid'; |
|
| 14 | + $pluginInfo['items']['item']['caption'] = 'Article'; |
|
| 15 | + $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
| 16 | + $pluginInfo['items']['item']['request'] = 'itemid'; |
|
| 17 | 17 | |
| 18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | - $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
| 20 | - $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
| 18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | + $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
| 20 | + $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
| 21 | 21 | |
| 22 | - return $pluginInfo; |
|
| 22 | + return $pluginInfo; |
|
| 23 | 23 | } |
@@ -9,12 +9,12 @@ |
||
| 9 | 9 | |
| 10 | 10 | function smartobject_plugin_xcgal() |
| 11 | 11 | { |
| 12 | - global $xoopsConfig; |
|
| 12 | + global $xoopsConfig; |
|
| 13 | 13 | |
| 14 | - $pluginInfo = array(); |
|
| 15 | - $pluginInfo['items']['album']['caption'] = 'Album'; |
|
| 16 | - $pluginInfo['items']['item']['url'] = 'thumbnails.php?album=%u'; |
|
| 17 | - $pluginInfo['items']['item']['request'] = 'album'; |
|
| 14 | + $pluginInfo = array(); |
|
| 15 | + $pluginInfo['items']['album']['caption'] = 'Album'; |
|
| 16 | + $pluginInfo['items']['item']['url'] = 'thumbnails.php?album=%u'; |
|
| 17 | + $pluginInfo['items']['item']['request'] = 'album'; |
|
| 18 | 18 | |
| 19 | - return $pluginInfo; |
|
| 19 | + return $pluginInfo; |
|
| 20 | 20 | } |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | |
| 10 | 10 | function smartobject_plugin_smartshop() |
| 11 | 11 | { |
| 12 | - $pluginInfo = array(); |
|
| 12 | + $pluginInfo = array(); |
|
| 13 | 13 | |
| 14 | - $pluginInfo['items']['item']['caption'] = 'Item'; |
|
| 15 | - $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
| 16 | - $pluginInfo['items']['item']['request'] = 'itemid'; |
|
| 14 | + $pluginInfo['items']['item']['caption'] = 'Item'; |
|
| 15 | + $pluginInfo['items']['item']['url'] = 'item.php?itemid=%u'; |
|
| 16 | + $pluginInfo['items']['item']['request'] = 'itemid'; |
|
| 17 | 17 | |
| 18 | - $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | - $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
| 20 | - $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
| 18 | + $pluginInfo['items']['category']['caption'] = 'Category'; |
|
| 19 | + $pluginInfo['items']['category']['url'] = 'category.php?categoryid=%u'; |
|
| 20 | + $pluginInfo['items']['category']['request'] = 'categoryid'; |
|
| 21 | 21 | |
| 22 | - return $pluginInfo; |
|
| 22 | + return $pluginInfo; |
|
| 23 | 23 | } |
@@ -2,5 +2,5 @@ |
||
| 2 | 2 | |
| 3 | 3 | function smarthook_footer_start() |
| 4 | 4 | { |
| 5 | - // code... |
|
| 5 | + // code... |
|
| 6 | 6 | } |
@@ -14,22 +14,22 @@ |
||
| 14 | 14 | * SmartObject library path |
| 15 | 15 | */ |
| 16 | 16 | if (!defined('SMARTOBJECT_URL')) { |
| 17 | - define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 17 | + define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 18 | 18 | } |
| 19 | 19 | if (!defined('SMARTOBJECT_ROOT_PATH')) { |
| 20 | - define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 20 | + define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 21 | 21 | } |
| 22 | 22 | if (!defined('SMARTOBJECT_IMAGES_URL')) { |
| 23 | - define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 23 | + define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 24 | 24 | } |
| 25 | 25 | if (!defined('SMARTOBJECT_IMAGES_ROOT_PATH')) { |
| 26 | - define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 26 | + define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 27 | 27 | } |
| 28 | 28 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_URL')) { |
| 29 | - define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 29 | + define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 30 | 30 | } |
| 31 | 31 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH')) { |
| 32 | - define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 32 | + define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | * SmartObject library path |
| 15 | 15 | */ |
| 16 | 16 | if (!defined('SMARTOBJECT_URL')) { |
| 17 | - define('SMARTOBJECT_URL', XOOPS_URL . '/modules/smartobject/'); |
|
| 17 | + define('SMARTOBJECT_URL', XOOPS_URL.'/modules/smartobject/'); |
|
| 18 | 18 | } |
| 19 | 19 | if (!defined('SMARTOBJECT_ROOT_PATH')) { |
| 20 | - define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/smartobject/'); |
|
| 20 | + define('SMARTOBJECT_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/smartobject/'); |
|
| 21 | 21 | } |
| 22 | 22 | if (!defined('SMARTOBJECT_IMAGES_URL')) { |
| 23 | - define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL . 'assets/images/'); |
|
| 23 | + define('SMARTOBJECT_IMAGES_URL', SMARTOBJECT_URL.'assets/images/'); |
|
| 24 | 24 | } |
| 25 | 25 | if (!defined('SMARTOBJECT_IMAGES_ROOT_PATH')) { |
| 26 | - define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/'); |
|
| 26 | + define('SMARTOBJECT_IMAGES_ROOT_PATH', SMARTOBJECT_ROOT_PATH.'assets/images/'); |
|
| 27 | 27 | } |
| 28 | 28 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_URL')) { |
| 29 | - define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL . 'assets/images/actions/'); |
|
| 29 | + define('SMARTOBJECT_IMAGES_ACTIONS_URL', SMARTOBJECT_URL.'assets/images/actions/'); |
|
| 30 | 30 | } |
| 31 | 31 | if (!defined('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH')) { |
| 32 | - define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH . 'assets/images/actions/'); |
|
| 32 | + define('SMARTOBJECT_IMAGES_ACTIONS_ROOT_PATH', SMARTOBJECT_ROOT_PATH.'assets/images/actions/'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Version of the SmartObject Framework |
| 37 | 37 | */ |
| 38 | -require_once SMARTOBJECT_ROOT_PATH . 'include/version.php'; |
|
| 39 | -require_once SMARTOBJECT_ROOT_PATH . 'include/functions.php'; |
|
| 40 | -require_once SMARTOBJECT_ROOT_PATH . 'include/xoops_core_common_functions.php'; |
|
| 38 | +require_once SMARTOBJECT_ROOT_PATH.'include/version.php'; |
|
| 39 | +require_once SMARTOBJECT_ROOT_PATH.'include/functions.php'; |
|
| 40 | +require_once SMARTOBJECT_ROOT_PATH.'include/xoops_core_common_functions.php'; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Some constants used by the SmartObjects |
@@ -66,4 +66,4 @@ discard block |
||
| 66 | 66 | // get previous page |
| 67 | 67 | $smart_previous_page = smart_getenv('HTTP_REFERER'); |
| 68 | 68 | |
| 69 | -require_once SMARTOBJECT_ROOT_PATH . 'class/smartloader.php'; |
|
| 69 | +require_once SMARTOBJECT_ROOT_PATH.'class/smartloader.php'; |
|
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | $smartobjectCurrencyHandler = xoops_getModuleHandler('currency', 'smartobject'); |
| 18 | 18 | |
| 19 | 19 | if (!$smartobjectCurrenciesObj) { |
| 20 | - $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
| 20 | + $smartobjectCurrenciesObj = $smartobjectCurrencyHandler->getCurrencies(); |
|
| 21 | 21 | } |
| 22 | 22 | if (!$smartobjectCurrenciesArray) { |
| 23 | - foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
| 24 | - if ($currencyObj->getVar('default_currency', 'e')) { |
|
| 25 | - $smartobjectDefaultCurrency = $currencyObj; |
|
| 26 | - } |
|
| 27 | - $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
| 28 | - } |
|
| 23 | + foreach ($smartobjectCurrenciesObj as $currencyid => $currencyObj) { |
|
| 24 | + if ($currencyObj->getVar('default_currency', 'e')) { |
|
| 25 | + $smartobjectDefaultCurrency = $currencyObj; |
|
| 26 | + } |
|
| 27 | + $smartobjectCurrenciesArray[$currencyid] = $currencyObj->getCode(); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | smart_loadCommonLanguageFile(); |
| 12 | 12 | |
| 13 | -require_once SMARTOBJECT_ROOT_PATH . 'class/currency.php'; |
|
| 13 | +require_once SMARTOBJECT_ROOT_PATH.'class/currency.php'; |
|
| 14 | 14 | |
| 15 | 15 | static $smartobjectCurrenciesObj, $smartobjectCurrenciesArray, $smartobjectDefaultCurrency; |
| 16 | 16 | |