Completed
Branch master (3189d6)
by Michael
14:06 queued 10:31
created
include/captcha/scripts/img.php 1 patch
Indentation   +409 added lines, -409 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Image Creation script
4
- *
5
- * D.J.
6
- */
3
+	 * Image Creation script
4
+	 *
5
+	 * D.J.
6
+	 */
7 7
 
8 8
 include dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/mainfile.php';
9 9
 error_reporting(0);
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,185 +18,185 @@  discard block
 block discarded – undo
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('imagecreatetruecolor', 'imagecolorallocate', 'imagefilledrectangle', 'imagejpeg', 'imagedestroy', 'imageftbbox');
44
-            foreach ($required_functions as $func) {
45
-                if (!function_exists($func)) {
46
-                    $this->mode = 'bmp';
47
-                    break;
48
-                }
49
-            }
50
-        }
51
-    }
52
-
53
-    /**
54
-     * Loading configs from CAPTCHA class
55
-     * @param array $config
56
-     */
57
-    public function setConfig($config = array())
58
-    {
59
-        // Loading default preferences
60
-        $this->config = $config;
61
-    }
62
-
63
-    public function loadImage()
64
-    {
65
-        $this->createCode();
66
-        $this->setCode();
67
-        $this->createImage();
68
-    }
69
-
70
-    /**
71
-     * Create Code
72
-     */
73
-    public function createCode()
74
-    {
75
-        if ($this->invalid) {
76
-            return;
77
-        }
78
-
79
-        if ($this->mode === 'bmp') {
80
-            $this->config['num_chars'] = 4;
81
-            $this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
82
-        } else {
83
-            $this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
84
-            if (!$this->config['casesensitive']) {
85
-                $this->code = strtoupper($this->code);
86
-            }
87
-        }
88
-    }
89
-
90
-    public function setCode()
91
-    {
92
-        if ($this->invalid) {
93
-            return;
94
-        }
95
-
96
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
97
-        $maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
98
-
99
-        // Increase the attempt records on refresh
100
-        if (!empty($maxAttempts)) {
101
-            $_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
102
-            if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
103
-                $this->invalid = true;
104
-            }
105
-        }
106
-    }
107
-
108
-    /**
109
-     * @param  string $file
110
-     * @return string|void
111
-     */
112
-    public function createImage($file = '')
113
-    {
114
-        if ($this->invalid) {
115
-            header('Content-type: image/gif');
116
-            readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
117
-
118
-            return;
119
-        }
120
-
121
-        if ($this->mode === 'bmp') {
122
-            return $this->createImageBmp();
123
-        } else {
124
-            return $this->createImageGd();
125
-        }
126
-    }
127
-
128
-    /**
129
-     *  Create CAPTCHA iamge with GD
130
-     *  Originated from DuGris' SecurityImage
131
-     * @param string $file
132
-     */
133
-    //  --------------------------------------------------------------------------- //
134
-    // Class: SecurityImage 1.5                                                    //
135
-    // Author: DuGris aka L. Jen <http://www.dugris.info>                           //
136
-    // Email: [email protected]                                                    //
137
-    // Licence: GNU                                                                 //
138
-    // Project: XOOPS Project                                                   //
139
-    //  --------------------------------------------------------------------------- //
140
-    public function createImageGd($file = '')
141
-    {
142
-        $this->loadFont();
143
-        $this->setImageSize();
144
-
145
-        $this->oImage = imagecreatetruecolor($this->width, $this->height);
146
-        $background   = imagecolorallocate($this->oImage, 255, 255, 255);
147
-        imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
148
-
149
-        switch ($this->config['background_type']) {
150
-            default:
151
-            case 0:
152
-                $this->drawBars();
153
-                break;
154
-
155
-            case 1:
156
-                $this->drawCircles();
157
-                break;
158
-
159
-            case 2:
160
-                $this->drawLines();
161
-                break;
162
-
163
-            case 3:
164
-                $this->drawRectangles();
165
-                break;
166
-
167
-            case 4:
168
-                $this->drawEllipses();
169
-                break;
170
-
171
-            case 5:
172
-                $this->drawPolygons();
173
-                break;
174
-
175
-            case 100:
176
-                $this->createFromFile();
177
-                break;
178
-        }
179
-        $this->drawBorder();
180
-        $this->drawCode();
181
-
182
-        if (empty($file)) {
183
-            header('Content-type: image/jpeg');
184
-            imagejpeg($this->oImage);
185
-        } else {
186
-            imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
187
-        }
188
-        imagedestroy($this->oImage);
189
-    }
190
-
191
-    /**
192
-     * @param         $name
193
-     * @param  string $extension
194
-     * @return array
195
-     */
196
-    public function _getList($name, $extension = '')
197
-    {
198
-        $items = array();
199
-        /*
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('imagecreatetruecolor', 'imagecolorallocate', 'imagefilledrectangle', 'imagejpeg', 'imagedestroy', 'imageftbbox');
44
+			foreach ($required_functions as $func) {
45
+				if (!function_exists($func)) {
46
+					$this->mode = 'bmp';
47
+					break;
48
+				}
49
+			}
50
+		}
51
+	}
52
+
53
+	/**
54
+	 * Loading configs from CAPTCHA class
55
+	 * @param array $config
56
+	 */
57
+	public function setConfig($config = array())
58
+	{
59
+		// Loading default preferences
60
+		$this->config = $config;
61
+	}
62
+
63
+	public function loadImage()
64
+	{
65
+		$this->createCode();
66
+		$this->setCode();
67
+		$this->createImage();
68
+	}
69
+
70
+	/**
71
+	 * Create Code
72
+	 */
73
+	public function createCode()
74
+	{
75
+		if ($this->invalid) {
76
+			return;
77
+		}
78
+
79
+		if ($this->mode === 'bmp') {
80
+			$this->config['num_chars'] = 4;
81
+			$this->code                = mt_rand(pow(10, $this->config['num_chars'] - 1), (int)str_pad('9', $this->config['num_chars'], '9'));
82
+		} else {
83
+			$this->code = substr(md5(uniqid(mt_rand(), 1)), 0, $this->config['num_chars']);
84
+			if (!$this->config['casesensitive']) {
85
+				$this->code = strtoupper($this->code);
86
+			}
87
+		}
88
+	}
89
+
90
+	public function setCode()
91
+	{
92
+		if ($this->invalid) {
93
+			return;
94
+		}
95
+
96
+		$_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
97
+		$maxAttempts                          = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
98
+
99
+		// Increase the attempt records on refresh
100
+		if (!empty($maxAttempts)) {
101
+			$_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']]++;
102
+			if ($_SESSION['XoopsCaptcha_attempt_' . $_SESSION['XoopsCaptcha_name']] > $maxAttempts) {
103
+				$this->invalid = true;
104
+			}
105
+		}
106
+	}
107
+
108
+	/**
109
+	 * @param  string $file
110
+	 * @return string|void
111
+	 */
112
+	public function createImage($file = '')
113
+	{
114
+		if ($this->invalid) {
115
+			header('Content-type: image/gif');
116
+			readfile(XOOPS_ROOT_PATH . '/images/subject/icon2.gif');
117
+
118
+			return;
119
+		}
120
+
121
+		if ($this->mode === 'bmp') {
122
+			return $this->createImageBmp();
123
+		} else {
124
+			return $this->createImageGd();
125
+		}
126
+	}
127
+
128
+	/**
129
+	 *  Create CAPTCHA iamge with GD
130
+	 *  Originated from DuGris' SecurityImage
131
+	 * @param string $file
132
+	 */
133
+	//  --------------------------------------------------------------------------- //
134
+	// Class: SecurityImage 1.5                                                    //
135
+	// Author: DuGris aka L. Jen <http://www.dugris.info>                           //
136
+	// Email: [email protected]                                                    //
137
+	// Licence: GNU                                                                 //
138
+	// Project: XOOPS Project                                                   //
139
+	//  --------------------------------------------------------------------------- //
140
+	public function createImageGd($file = '')
141
+	{
142
+		$this->loadFont();
143
+		$this->setImageSize();
144
+
145
+		$this->oImage = imagecreatetruecolor($this->width, $this->height);
146
+		$background   = imagecolorallocate($this->oImage, 255, 255, 255);
147
+		imagefilledrectangle($this->oImage, 0, 0, $this->width, $this->height, $background);
148
+
149
+		switch ($this->config['background_type']) {
150
+			default:
151
+			case 0:
152
+				$this->drawBars();
153
+				break;
154
+
155
+			case 1:
156
+				$this->drawCircles();
157
+				break;
158
+
159
+			case 2:
160
+				$this->drawLines();
161
+				break;
162
+
163
+			case 3:
164
+				$this->drawRectangles();
165
+				break;
166
+
167
+			case 4:
168
+				$this->drawEllipses();
169
+				break;
170
+
171
+			case 5:
172
+				$this->drawPolygons();
173
+				break;
174
+
175
+			case 100:
176
+				$this->createFromFile();
177
+				break;
178
+		}
179
+		$this->drawBorder();
180
+		$this->drawCode();
181
+
182
+		if (empty($file)) {
183
+			header('Content-type: image/jpeg');
184
+			imagejpeg($this->oImage);
185
+		} else {
186
+			imagejpeg($this->oImage, XOOPS_ROOT_PATH . '/' . $this->config['imagepath'] . '/' . $file . '.jpg');
187
+		}
188
+		imagedestroy($this->oImage);
189
+	}
190
+
191
+	/**
192
+	 * @param         $name
193
+	 * @param  string $extension
194
+	 * @return array
195
+	 */
196
+	public function _getList($name, $extension = '')
197
+	{
198
+		$items = array();
199
+		/*
200 200
          if (@ include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.ini.php") {
201 201
          load_functions("cache");
202 202
          if ($items = mod_loadCacheFile("captcha_{$name}", "captcha")) {
@@ -204,231 +204,231 @@  discard block
 block discarded – undo
204 204
          }
205 205
          }
206 206
          */
207
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
208
-        $file_path = $this->config['rootpath'] . "/{$name}";
209
-        $files     = XoopsLists::getFileListAsArray($file_path);
210
-        foreach ($files as $item) {
211
-            if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
212
-                $items[] = $item;
213
-            }
214
-        }
215
-        if (function_exists('mod_createCacheFile')) {
216
-            mod_createCacheFile($items, "captcha_{$name}", 'captcha');
217
-        }
218
-
219
-        return $items;
220
-    }
221
-
222
-    public function loadFont()
223
-    {
224
-        $fonts      = $this->_getList('fonts', 'ttf');
225
-        $this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
226
-    }
227
-
228
-    public function setImageSize()
229
-    {
230
-        $MaxCharWidth  = 0;
231
-        $MaxCharHeight = 0;
232
-        $oImage        = imagecreatetruecolor(100, 100);
233
-        $text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
234
-        $FontSize      = $this->config['fontsize_max'];
235
-        for ($Angle = -30; $Angle <= 30; ++$Angle) {
236
-            for ($i = 65; $i <= 90; ++$i) {
237
-                $CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), array());
238
-                $_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
239
-                if ($_MaxCharWidth > $MaxCharWidth) {
240
-                    $MaxCharWidth = $_MaxCharWidth;
241
-                }
242
-                $_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
243
-                if ($_MaxCharHeight > $MaxCharHeight) {
244
-                    $MaxCharHeight = $_MaxCharHeight;
245
-                }
246
-            }
247
-        }
248
-        imagedestroy($oImage);
249
-
250
-        $this->height  = $MaxCharHeight + 2;
251
-        $this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
252
-        $this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
253
-    }
254
-
255
-    /**
256
-     * Return random background
257
-     *
258
-     * @return array
259
-     */
260
-    public function loadBackground()
261
-    {
262
-        $RandBackground = null;
263
-        if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
264
-            $RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
265
-        }
266
-
267
-        return $RandBackground;
268
-    }
269
-
270
-    /**
271
-     * Draw Image background
272
-     */
273
-    public function createFromFile()
274
-    {
275
-        if ($RandImage = $this->loadBackground()) {
276
-            $ImageType = @getimagesize($RandImage);
277
-            switch (@$ImageType[2]) {
278
-                case 1:
279
-                    $BackgroundImage = imagecreatefromgif($RandImage);
280
-                    break;
281
-
282
-                case 2:
283
-                    $BackgroundImage = imagecreatefromjpeg($RandImage);
284
-                    break;
285
-
286
-                case 3:
287
-                    $BackgroundImage = imagecreatefrompng($RandImage);
288
-                    break;
289
-            }
290
-        }
291
-        if (!empty($BackgroundImage)) {
292
-            imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
293
-            imagedestroy($BackgroundImage);
294
-        } else {
295
-            $this->drawBars();
296
-        }
297
-    }
298
-
299
-    /**
300
-     * Draw Code
301
-     */
302
-    public function drawCode()
303
-    {
304
-        for ($i = 0; $i < $this->config['num_chars']; ++$i) {
305
-            // select random greyscale colour
306
-            $text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
307
-
308
-            // write text to image
309
-            $Angle = mt_rand(10, 30);
310
-            if ($i % 2) {
311
-                $Angle = mt_rand(-10, -30);
312
-            }
313
-
314
-            // select random font size
315
-            $FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
316
-
317
-            $CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array());
318
-            $CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
319
-
320
-            // calculate character starting coordinates
321
-            $posX = ($this->spacing / 2) + ($i * $this->spacing);
322
-            $posY = 2 + ($this->height / 2) + ($CharHeight / 4);
323
-
324
-            imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array());
325
-        }
326
-    }
327
-
328
-    /**
329
-     * Draw Border
330
-     */
331
-    public function drawBorder()
332
-    {
333
-        $rgb          = mt_rand(50, 150);
334
-        $border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
335
-        imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
336
-    }
337
-
338
-    /**
339
-     * Draw Circles background
340
-     */
341
-    public function drawCircles()
342
-    {
343
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
344
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
345
-            imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
346
-        }
347
-    }
348
-
349
-    /**
350
-     * Draw Lines background
351
-     */
352
-    public function drawLines()
353
-    {
354
-        for ($i = 0; $i < $this->config['background_num']; ++$i) {
355
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
356
-            imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
357
-        }
358
-    }
359
-
360
-    /**
361
-     * Draw Rectangles background
362
-     */
363
-    public function drawRectangles()
364
-    {
365
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
366
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
367
-            imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
368
-        }
369
-    }
370
-
371
-    /**
372
-     * Draw Bars background
373
-     */
374
-    public function drawBars()
375
-    {
376
-        for ($i = 0; $i <= $this->height;) {
377
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
378
-            imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
379
-            $i = $i + 2.5;
380
-        }
381
-        for ($i = 0; $i <= $this->width;) {
382
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
383
-            imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
384
-            $i = $i + 2.5;
385
-        }
386
-    }
387
-
388
-    /**
389
-     * Draw Ellipses background
390
-     */
391
-    public function drawEllipses()
392
-    {
393
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
394
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
395
-            imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
396
-        }
397
-    }
398
-
399
-    /**
400
-     * Draw polygons background
401
-     */
402
-    public function drawPolygons()
403
-    {
404
-        for ($i = 1; $i <= $this->config['background_num']; ++$i) {
405
-            $randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
406
-            $coords      = array();
407
-            for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
408
-                $coords[] = mt_rand(0, $this->width);
409
-                $coords[] = mt_rand(0, $this->height);
410
-            }
411
-            imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
412
-        }
413
-    }
414
-
415
-    /**
416
-     *  Create CAPTCHA iamge with BMP
417
-     *  TODO
418
-     * @param  string $file
419
-     * @return string
420
-     */
421
-    public function createImageBmp($file = '')
422
-    {
423
-        $image = '';
424
-
425
-        if (empty($file)) {
426
-            header('Content-type: image/bmp');
427
-            echo $image;
428
-        } else {
429
-            return $image;
430
-        }
431
-    }
207
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
208
+		$file_path = $this->config['rootpath'] . "/{$name}";
209
+		$files     = XoopsLists::getFileListAsArray($file_path);
210
+		foreach ($files as $item) {
211
+			if (empty($extension) || preg_match("/(\.{$extension})$/i", $item)) {
212
+				$items[] = $item;
213
+			}
214
+		}
215
+		if (function_exists('mod_createCacheFile')) {
216
+			mod_createCacheFile($items, "captcha_{$name}", 'captcha');
217
+		}
218
+
219
+		return $items;
220
+	}
221
+
222
+	public function loadFont()
223
+	{
224
+		$fonts      = $this->_getList('fonts', 'ttf');
225
+		$this->font = $this->config['rootpath'] . '/fonts/' . $fonts[array_rand($fonts)];
226
+	}
227
+
228
+	public function setImageSize()
229
+	{
230
+		$MaxCharWidth  = 0;
231
+		$MaxCharHeight = 0;
232
+		$oImage        = imagecreatetruecolor(100, 100);
233
+		$text_color    = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
234
+		$FontSize      = $this->config['fontsize_max'];
235
+		for ($Angle = -30; $Angle <= 30; ++$Angle) {
236
+			for ($i = 65; $i <= 90; ++$i) {
237
+				$CharDetails   = imageftbbox($FontSize, $Angle, $this->font, chr($i), array());
238
+				$_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
239
+				if ($_MaxCharWidth > $MaxCharWidth) {
240
+					$MaxCharWidth = $_MaxCharWidth;
241
+				}
242
+				$_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
243
+				if ($_MaxCharHeight > $MaxCharHeight) {
244
+					$MaxCharHeight = $_MaxCharHeight;
245
+				}
246
+			}
247
+		}
248
+		imagedestroy($oImage);
249
+
250
+		$this->height  = $MaxCharHeight + 2;
251
+		$this->spacing = (int)(($this->config['num_chars'] * $MaxCharWidth) / $this->config['num_chars']);
252
+		$this->width   = ($this->config['num_chars'] * $MaxCharWidth) + ($this->spacing / 2);
253
+	}
254
+
255
+	/**
256
+	 * Return random background
257
+	 *
258
+	 * @return array
259
+	 */
260
+	public function loadBackground()
261
+	{
262
+		$RandBackground = null;
263
+		if ($backgrounds = $this->_getList('backgrounds', '(gif|jpg|png)')) {
264
+			$RandBackground = $this->config['rootpath'] . '/backgrounds/' . $backgrounds[array_rand($backgrounds)];
265
+		}
266
+
267
+		return $RandBackground;
268
+	}
269
+
270
+	/**
271
+	 * Draw Image background
272
+	 */
273
+	public function createFromFile()
274
+	{
275
+		if ($RandImage = $this->loadBackground()) {
276
+			$ImageType = @getimagesize($RandImage);
277
+			switch (@$ImageType[2]) {
278
+				case 1:
279
+					$BackgroundImage = imagecreatefromgif($RandImage);
280
+					break;
281
+
282
+				case 2:
283
+					$BackgroundImage = imagecreatefromjpeg($RandImage);
284
+					break;
285
+
286
+				case 3:
287
+					$BackgroundImage = imagecreatefrompng($RandImage);
288
+					break;
289
+			}
290
+		}
291
+		if (!empty($BackgroundImage)) {
292
+			imagecopyresized($this->oImage, $BackgroundImage, 0, 0, 0, 0, imagesx($this->oImage), imagesy($this->oImage), imagesx($BackgroundImage), imagesy($BackgroundImage));
293
+			imagedestroy($BackgroundImage);
294
+		} else {
295
+			$this->drawBars();
296
+		}
297
+	}
298
+
299
+	/**
300
+	 * Draw Code
301
+	 */
302
+	public function drawCode()
303
+	{
304
+		for ($i = 0; $i < $this->config['num_chars']; ++$i) {
305
+			// select random greyscale colour
306
+			$text_color = imagecolorallocate($this->oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
307
+
308
+			// write text to image
309
+			$Angle = mt_rand(10, 30);
310
+			if ($i % 2) {
311
+				$Angle = mt_rand(-10, -30);
312
+			}
313
+
314
+			// select random font size
315
+			$FontSize = mt_rand($this->config['fontsize_min'], $this->config['fontsize_max']);
316
+
317
+			$CharDetails = imageftbbox($FontSize, $Angle, $this->font, $this->code[$i], array());
318
+			$CharHeight  = abs($CharDetails[1] + $CharDetails[5]);
319
+
320
+			// calculate character starting coordinates
321
+			$posX = ($this->spacing / 2) + ($i * $this->spacing);
322
+			$posY = 2 + ($this->height / 2) + ($CharHeight / 4);
323
+
324
+			imagefttext($this->oImage, $FontSize, $Angle, $posX, $posY, $text_color, $this->font, $this->code[$i], array());
325
+		}
326
+	}
327
+
328
+	/**
329
+	 * Draw Border
330
+	 */
331
+	public function drawBorder()
332
+	{
333
+		$rgb          = mt_rand(50, 150);
334
+		$border_color = imagecolorallocate($this->oImage, $rgb, $rgb, $rgb);
335
+		imagerectangle($this->oImage, 0, 0, $this->width - 1, $this->height - 1, $border_color);
336
+	}
337
+
338
+	/**
339
+	 * Draw Circles background
340
+	 */
341
+	public function drawCircles()
342
+	{
343
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
344
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
345
+			imagefilledellipse($this->oImage, mt_rand(0, $this->width - 10), mt_rand(0, $this->height - 3), mt_rand(10, 20), mt_rand(20, 30), $randomcolor);
346
+		}
347
+	}
348
+
349
+	/**
350
+	 * Draw Lines background
351
+	 */
352
+	public function drawLines()
353
+	{
354
+		for ($i = 0; $i < $this->config['background_num']; ++$i) {
355
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
356
+			imageline($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
357
+		}
358
+	}
359
+
360
+	/**
361
+	 * Draw Rectangles background
362
+	 */
363
+	public function drawRectangles()
364
+	{
365
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
366
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
367
+			imagefilledrectangle($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
368
+		}
369
+	}
370
+
371
+	/**
372
+	 * Draw Bars background
373
+	 */
374
+	public function drawBars()
375
+	{
376
+		for ($i = 0; $i <= $this->height;) {
377
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
378
+			imageline($this->oImage, 0, $i, $this->width, $i, $randomcolor);
379
+			$i = $i + 2.5;
380
+		}
381
+		for ($i = 0; $i <= $this->width;) {
382
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
383
+			imageline($this->oImage, $i, 0, $i, $this->height, $randomcolor);
384
+			$i = $i + 2.5;
385
+		}
386
+	}
387
+
388
+	/**
389
+	 * Draw Ellipses background
390
+	 */
391
+	public function drawEllipses()
392
+	{
393
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
394
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
395
+			imageellipse($this->oImage, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $randomcolor);
396
+		}
397
+	}
398
+
399
+	/**
400
+	 * Draw polygons background
401
+	 */
402
+	public function drawPolygons()
403
+	{
404
+		for ($i = 1; $i <= $this->config['background_num']; ++$i) {
405
+			$randomcolor = imagecolorallocate($this->oImage, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
406
+			$coords      = array();
407
+			for ($j = 1; $j <= $this->config['polygon_point']; ++$j) {
408
+				$coords[] = mt_rand(0, $this->width);
409
+				$coords[] = mt_rand(0, $this->height);
410
+			}
411
+			imagefilledpolygon($this->oImage, $coords, $this->config['polygon_point'], $randomcolor);
412
+		}
413
+	}
414
+
415
+	/**
416
+	 *  Create CAPTCHA iamge with BMP
417
+	 *  TODO
418
+	 * @param  string $file
419
+	 * @return string
420
+	 */
421
+	public function createImageBmp($file = '')
422
+	{
423
+		$image = '';
424
+
425
+		if (empty($file)) {
426
+			header('Content-type: image/bmp');
427
+			echo $image;
428
+		} else {
429
+			return $image;
430
+		}
431
+	}
432 432
 }
433 433
 
434 434
 $config        = @include '../config.php';
Please login to merge, or discard this patch.
include/captcha/text.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -7,75 +7,75 @@
 block discarded – undo
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 function &instance()
24
-    {
25
-        static $instance;
26
-        if (!isset($instance)) {
27
-            $instance = new XoopsCaptchaText();
28
-        }
20
+	/**
21
+	 * @return XoopsCaptchaText
22
+	 */
23
+	public function &instance()
24
+	{
25
+		static $instance;
26
+		if (!isset($instance)) {
27
+			$instance = new XoopsCaptchaText();
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() . "&nbsp;&nbsp; <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 .= "&nbsp;&nbsp;<small>{$rule}</small>";
57
-        }
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function render()
52
+	{
53
+		$form = $this->loadText() . "&nbsp;&nbsp; <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 .= "&nbsp;&nbsp;<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
 }
Please login to merge, or discard this patch.
include/captcha/image.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,62 +7,62 @@
 block discarded – undo
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 function &instance()
24
-    {
25
-        static $instance;
26
-        if (!isset($instance)) {
27
-            $instance = new XoopsCaptchaImage();
28
-        }
20
+	/**
21
+	 * @return XoopsCaptchaImage
22
+	 */
23
+	public function &instance()
24
+	{
25
+		static $instance;
26
+		if (!isset($instance)) {
27
+			$instance = new XoopsCaptchaImage();
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='' /> &nbsp; " . $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 .= "&nbsp;&nbsp;<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='' /> &nbsp; " . $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 .= "&nbsp;&nbsp;<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
 }
Please login to merge, or discard this patch.
include/captcha/captcha.php 1 patch
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -13,239 +13,239 @@
 block discarded – undo
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 instance()
37
-    {
38
-        static $instance;
39
-        if (!isset($instance)) {
40
-            $instance = new XoopsCaptcha();
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('imagecreatetruecolor', 'imagecolorallocate', 'imagefilledrectangle', 'imagejpeg', 'imagedestroy', 'imageftbbox');
86
-            foreach ($required_functions as $func) {
87
-                if (!function_exists($func)) {
88
-                    $this->mode = 'text';
89
-                    break;
90
-                }
91
-            }
92
-        }
93
-    }
94
-
95
-    /**
96
-     * Initializing the CAPTCHA class
97
-     * @param string $name
98
-     * @param null   $skipmember
99
-     * @param null   $num_chars
100
-     * @param null   $fontsize_min
101
-     * @param null   $fontsize_max
102
-     * @param null   $background_type
103
-     * @param null   $background_num
104
-     */
105
-    public function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null)
106
-    {
107
-        // Loading RUN-TIME settings
108
-        foreach (array_keys($this->config) as $key) {
109
-            if (isset(${$key}) && ${$key} !== null) {
110
-                $this->config[$key] = ${$key};
111
-            }
112
-        }
113
-        $this->config['name'] = $name;
114
-
115
-        // Skip CAPTCHA for member if set
116
-        if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
117
-            $this->active = false;
118
-        }
119
-    }
120
-
121
-    /**
122
-     * Verify user submission
123
-     * @param  null $skipMember
124
-     * @return bool
125
-     */
126
-    public function verify($skipMember = null)
127
-    {
128
-        $sessionName = @$_SESSION['XoopsCaptcha_name'];
129
-        $skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
130
-        $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
131
-
132
-        $is_valid = false;
133
-
134
-        // Skip CAPTCHA for member if set
135
-        if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
136
-            $is_valid = true;
137
-            // Kill too many attempts
138
-        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
139
-            $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
140
-
141
-            // Verify the code
142
-        } elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
143
-            $func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
144
-            $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
145
-        }
146
-
147
-        if (!empty($maxAttempts)) {
148
-            if (!$is_valid) {
149
-                // Increase the attempt records on failure
150
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
151
-                // Log the error message
152
-                $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
153
-            } else {
154
-
155
-                // reset attempt records on success
156
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
157
-            }
158
-        }
159
-        $this->destroyGarbage(true);
160
-
161
-        return $is_valid;
162
-    }
163
-
164
-    /**
165
-     * @return mixed|string
166
-     */
167
-    public function getCaption()
168
-    {
169
-        return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
170
-    }
171
-
172
-    /**
173
-     * @return string
174
-     */
175
-    public function getMessage()
176
-    {
177
-        return implode('<br />', $this->message);
178
-    }
179
-
180
-    /**
181
-     * Destory historical stuff
182
-     * @param  bool $clearSession
183
-     * @return bool
184
-     */
185
-    public function destroyGarbage($clearSession = false)
186
-    {
187
-        require_once __DIR__ . '/' . $this->mode . '.php';
188
-        $class           = 'XoopsCaptcha' . ucfirst($this->mode);
189
-        $captchaHandler = new $class();
190
-        if (method_exists($captchaHandler, 'destroyGarbage')) {
191
-            $captchaHandler->loadConfig($this->config);
192
-            $captchaHandler->destroyGarbage();
193
-        }
194
-
195
-        if ($clearSession) {
196
-            $_SESSION['XoopsCaptcha_name']        = null;
197
-            $_SESSION['XoopsCaptcha_skipmember']  = null;
198
-            $_SESSION['XoopsCaptcha_sessioncode'] = null;
199
-            $_SESSION['XoopsCaptcha_maxattempts'] = null;
200
-        }
201
-
202
-        return true;
203
-    }
204
-
205
-    /**
206
-     * @return mixed|string
207
-     */
208
-    public function render()
209
-    {
210
-        $form = '';
211
-
212
-        if (!$this->active || empty($this->config['name'])) {
213
-            return $form;
214
-        }
215
-
216
-        $_SESSION['XoopsCaptcha_name']        = $this->config['name'];
217
-        $_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
218
-        $maxAttempts                          = $this->config['maxattempt'];
219
-        $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
220
-        /*
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 instance()
37
+	{
38
+		static $instance;
39
+		if (!isset($instance)) {
40
+			$instance = new XoopsCaptcha();
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('imagecreatetruecolor', 'imagecolorallocate', 'imagefilledrectangle', 'imagejpeg', 'imagedestroy', 'imageftbbox');
86
+			foreach ($required_functions as $func) {
87
+				if (!function_exists($func)) {
88
+					$this->mode = 'text';
89
+					break;
90
+				}
91
+			}
92
+		}
93
+	}
94
+
95
+	/**
96
+	 * Initializing the CAPTCHA class
97
+	 * @param string $name
98
+	 * @param null   $skipmember
99
+	 * @param null   $num_chars
100
+	 * @param null   $fontsize_min
101
+	 * @param null   $fontsize_max
102
+	 * @param null   $background_type
103
+	 * @param null   $background_num
104
+	 */
105
+	public function init($name = 'xoopscaptcha', $skipmember = null, $num_chars = null, $fontsize_min = null, $fontsize_max = null, $background_type = null, $background_num = null)
106
+	{
107
+		// Loading RUN-TIME settings
108
+		foreach (array_keys($this->config) as $key) {
109
+			if (isset(${$key}) && ${$key} !== null) {
110
+				$this->config[$key] = ${$key};
111
+			}
112
+		}
113
+		$this->config['name'] = $name;
114
+
115
+		// Skip CAPTCHA for member if set
116
+		if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
117
+			$this->active = false;
118
+		}
119
+	}
120
+
121
+	/**
122
+	 * Verify user submission
123
+	 * @param  null $skipMember
124
+	 * @return bool
125
+	 */
126
+	public function verify($skipMember = null)
127
+	{
128
+		$sessionName = @$_SESSION['XoopsCaptcha_name'];
129
+		$skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
130
+		$maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
131
+
132
+		$is_valid = false;
133
+
134
+		// Skip CAPTCHA for member if set
135
+		if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
136
+			$is_valid = true;
137
+			// Kill too many attempts
138
+		} elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
139
+			$this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
140
+
141
+			// Verify the code
142
+		} elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
143
+			$func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
144
+			$is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
145
+		}
146
+
147
+		if (!empty($maxAttempts)) {
148
+			if (!$is_valid) {
149
+				// Increase the attempt records on failure
150
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
151
+				// Log the error message
152
+				$this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
153
+			} else {
154
+
155
+				// reset attempt records on success
156
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
157
+			}
158
+		}
159
+		$this->destroyGarbage(true);
160
+
161
+		return $is_valid;
162
+	}
163
+
164
+	/**
165
+	 * @return mixed|string
166
+	 */
167
+	public function getCaption()
168
+	{
169
+		return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
170
+	}
171
+
172
+	/**
173
+	 * @return string
174
+	 */
175
+	public function getMessage()
176
+	{
177
+		return implode('<br />', $this->message);
178
+	}
179
+
180
+	/**
181
+	 * Destory historical stuff
182
+	 * @param  bool $clearSession
183
+	 * @return bool
184
+	 */
185
+	public function destroyGarbage($clearSession = false)
186
+	{
187
+		require_once __DIR__ . '/' . $this->mode . '.php';
188
+		$class           = 'XoopsCaptcha' . ucfirst($this->mode);
189
+		$captchaHandler = new $class();
190
+		if (method_exists($captchaHandler, 'destroyGarbage')) {
191
+			$captchaHandler->loadConfig($this->config);
192
+			$captchaHandler->destroyGarbage();
193
+		}
194
+
195
+		if ($clearSession) {
196
+			$_SESSION['XoopsCaptcha_name']        = null;
197
+			$_SESSION['XoopsCaptcha_skipmember']  = null;
198
+			$_SESSION['XoopsCaptcha_sessioncode'] = null;
199
+			$_SESSION['XoopsCaptcha_maxattempts'] = null;
200
+		}
201
+
202
+		return true;
203
+	}
204
+
205
+	/**
206
+	 * @return mixed|string
207
+	 */
208
+	public function render()
209
+	{
210
+		$form = '';
211
+
212
+		if (!$this->active || empty($this->config['name'])) {
213
+			return $form;
214
+		}
215
+
216
+		$_SESSION['XoopsCaptcha_name']        = $this->config['name'];
217
+		$_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
218
+		$maxAttempts                          = $this->config['maxattempt'];
219
+		$_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
220
+		/*
221 221
          if (!empty($maxAttempts)) {
222 222
          $_SESSION['XoopsCaptcha_maxattempts_'.$_SESSION['XoopsCaptcha_name']] = $maxAttempts;
223 223
          }
224 224
          */
225 225
 
226
-        // Fail on too many attempts
227
-        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
228
-            $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
229
-            // Load the form element
230
-        } else {
231
-            $form = $this->loadForm();
232
-        }
233
-
234
-        return $form;
235
-    }
236
-
237
-    /**
238
-     * @return mixed
239
-     */
240
-    public function loadForm()
241
-    {
242
-        require_once __DIR__ . '/' . $this->mode . '.php';
243
-        $class           = 'XoopsCaptcha' . ucfirst($this->mode);
244
-        $captchaHandler = new $class();
245
-        $captchaHandler->loadConfig($this->config);
246
-
247
-        $form = $captchaHandler->render();
248
-
249
-        return $form;
250
-    }
226
+		// Fail on too many attempts
227
+		if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
228
+			$form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
229
+			// Load the form element
230
+		} else {
231
+			$form = $this->loadForm();
232
+		}
233
+
234
+		return $form;
235
+	}
236
+
237
+	/**
238
+	 * @return mixed
239
+	 */
240
+	public function loadForm()
241
+	{
242
+		require_once __DIR__ . '/' . $this->mode . '.php';
243
+		$class           = 'XoopsCaptcha' . ucfirst($this->mode);
244
+		$captchaHandler = new $class();
245
+		$captchaHandler->loadConfig($this->config);
246
+
247
+		$form = $captchaHandler->render();
248
+
249
+		return $form;
250
+	}
251 251
 }
Please login to merge, or discard this patch.
include/captcha/formcaptcha.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Adding CAPTCHA
4
- *
5
- * Currently there are two types of CAPTCHA forms, text and image
6
- * The default mode is "text", it can be changed in the priority:
7
- * 1 If mode is set through XoopsFormCaptcha::setMode(), take it
8
- * 2 Elseif mode is set though captcha/config.php, take it
9
- * 3 Else, take "text"
10
- *
11
- * D.J.
12
- */
3
+	 * Adding CAPTCHA
4
+	 *
5
+	 * Currently there are two types of CAPTCHA forms, text and image
6
+	 * The default mode is "text", it can be changed in the priority:
7
+	 * 1 If mode is set through XoopsFormCaptcha::setMode(), take it
8
+	 * 2 Elseif mode is set though captcha/config.php, take it
9
+	 * 3 Else, take "text"
10
+	 *
11
+	 * D.J.
12
+	 */
13 13
 
14 14
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
15 15
 
@@ -38,52 +38,52 @@  discard block
 block discarded – undo
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($caption = '', $name = 'xoopscaptcha', $skipmember = null, $numchar = null, $minfontsize = null, $maxfontsize = null, $backgroundtype = null, $backgroundnum = null)
55
-    {
56
-        if (!class_exists('XoopsCaptcaha')) {
57
-            require_once SMARTOBJECT_ROOT_PATH . '/include/captcha/captcha.php';
58
-        }
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($caption = '', $name = 'xoopscaptcha', $skipmember = null, $numchar = null, $minfontsize = null, $maxfontsize = null, $backgroundtype = null, $backgroundnum = null)
55
+	{
56
+		if (!class_exists('XoopsCaptcaha')) {
57
+			require_once SMARTOBJECT_ROOT_PATH . '/include/captcha/captcha.php';
58
+		}
59 59
 
60
-        $this->_captchaHandler = XoopsCaptcha::instance();
61
-        $this->_captchaHandler->init($name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum);
62
-        if (!$this->_captchaHandler->active) {
63
-            $this->setHidden();
64
-        } else {
65
-            $caption = !empty($caption) ? $caption : $this->_captchaHandler->getCaption();
66
-            $this->setCaption($caption);
67
-        }
68
-    }
60
+		$this->_captchaHandler = XoopsCaptcha::instance();
61
+		$this->_captchaHandler->init($name, $skipmember, $numchar, $minfontsize, $maxfontsize, $backgroundtype, $backgroundnum);
62
+		if (!$this->_captchaHandler->active) {
63
+			$this->setHidden();
64
+		} else {
65
+			$caption = !empty($caption) ? $caption : $this->_captchaHandler->getCaption();
66
+			$this->setCaption($caption);
67
+		}
68
+	}
69 69
 
70
-    /**
71
-     * @param $name
72
-     * @param $val
73
-     * @return bool
74
-     */
75
-    public function setConfig($name, $val)
76
-    {
77
-        return $this->_captchaHandler->setConfig($name, $val);
78
-    }
70
+	/**
71
+	 * @param $name
72
+	 * @param $val
73
+	 * @return bool
74
+	 */
75
+	public function setConfig($name, $val)
76
+	{
77
+		return $this->_captchaHandler->setConfig($name, $val);
78
+	}
79 79
 
80
-    /**
81
-     * @return mixed|string
82
-     */
83
-    public function render()
84
-    {
85
-        if (!$this->isHidden()) {
86
-            return $this->_captchaHandler->render();
87
-        }
88
-    }
80
+	/**
81
+	 * @return mixed|string
82
+	 */
83
+	public function render()
84
+	{
85
+		if (!$this->isHidden()) {
86
+			return $this->_captchaHandler->render();
87
+		}
88
+	}
89 89
 }
Please login to merge, or discard this patch.
include/functions.php 1 patch
Indentation   +705 added lines, -705 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,34 +81,34 @@  discard block
 block discarded – undo
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 && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) {
95
-        return '';
96
-    }
97
-    if (!$withLink) {
98
-        return $smartModule->getVar('name');
99
-    } else {
100
-        $seoMode = smart_getModuleModeSEO($moduleName);
101
-        if ($seoMode === 'rewrite') {
102
-            $seoModuleName = smart_getModuleNameForSEO($moduleName);
103
-            $ret           = XOOPS_URL . '/' . $seoModuleName . '/';
104
-        } elseif ($seoMode === 'pathinfo') {
105
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/';
106
-        } else {
107
-            $ret = XOOPS_URL . '/modules/' . $moduleName . '/';
108
-        }
109
-
110
-        return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>';
111
-    }
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 && (isset($smartModuleConfig['show_mod_name_breadcrumb']) && !$smartModuleConfig['show_mod_name_breadcrumb'])) {
95
+		return '';
96
+	}
97
+	if (!$withLink) {
98
+		return $smartModule->getVar('name');
99
+	} else {
100
+		$seoMode = smart_getModuleModeSEO($moduleName);
101
+		if ($seoMode === 'rewrite') {
102
+			$seoModuleName = smart_getModuleNameForSEO($moduleName);
103
+			$ret           = XOOPS_URL . '/' . $seoModuleName . '/';
104
+		} elseif ($seoMode === 'pathinfo') {
105
+			$ret = XOOPS_URL . '/modules/' . $moduleName . '/seo.php/' . $seoModuleName . '/';
106
+		} else {
107
+			$ret = XOOPS_URL . '/modules/' . $moduleName . '/';
108
+		}
109
+
110
+		return '<a href="' . $ret . '">' . $smartModule->getVar('name') . '</a>';
111
+	}
112 112
 }
113 113
 
114 114
 /**
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function smart_getModuleNameForSEO($moduleName = false)
119 119
 {
120
-    $smartModule       = smart_getModuleInfo($moduleName);
121
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
122
-    if (isset($smartModuleConfig['seo_module_name'])) {
123
-        return $smartModuleConfig['seo_module_name'];
124
-    }
125
-    $ret = smart_getModuleName(false, false, $moduleName);
126
-
127
-    return strtolower($ret);
120
+	$smartModule       = smart_getModuleInfo($moduleName);
121
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
122
+	if (isset($smartModuleConfig['seo_module_name'])) {
123
+		return $smartModuleConfig['seo_module_name'];
124
+	}
125
+	$ret = smart_getModuleName(false, false, $moduleName);
126
+
127
+	return strtolower($ret);
128 128
 }
129 129
 
130 130
 /**
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
  */
134 134
 function smart_getModuleModeSEO($moduleName = false)
135 135
 {
136
-    $smartModule       = smart_getModuleInfo($moduleName);
137
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
136
+	$smartModule       = smart_getModuleInfo($moduleName);
137
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
138 138
 
139
-    return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false;
139
+	return isset($smartModuleConfig['seo_mode']) ? $smartModuleConfig['seo_mode'] : false;
140 140
 }
141 141
 
142 142
 /**
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function smart_getModuleIncludeIdSEO($moduleName = false)
147 147
 {
148
-    $smartModule       = smart_getModuleInfo($moduleName);
149
-    $smartModuleConfig = smart_getModuleConfig($moduleName);
148
+	$smartModule       = smart_getModuleInfo($moduleName);
149
+	$smartModuleConfig = smart_getModuleConfig($moduleName);
150 150
 
151
-    return !empty($smartModuleConfig['seo_inc_id']);
151
+	return !empty($smartModuleConfig['seo_inc_id']);
152 152
 }
153 153
 
154 154
 /**
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function smart_getenv($key)
159 159
 {
160
-    $ret = '';
161
-    $ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : '');
160
+	$ret = '';
161
+	$ret = isset($_SERVER[$key]) ? $_SERVER[$key] : (isset($_ENV[$key]) ? $_ENV[$key] : '');
162 162
 
163
-    return $ret;
163
+	return $ret;
164 164
 }
165 165
 
166 166
 function smart_xoops_cp_header()
167 167
 {
168
-    xoops_cp_header();
169
-    global $xoopsModule, $xoopsConfig;
170
-    /**
171
-     * include SmartObject admin language file
172
-     */
173
-    $fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
174
-    if (file_exists($fileName)) {
175
-        include_once $fileName;
176
-    } else {
177
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
178
-    }
179
-    ?>
168
+	xoops_cp_header();
169
+	global $xoopsModule, $xoopsConfig;
170
+	/**
171
+	 * include SmartObject admin language file
172
+	 */
173
+	$fileName = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
174
+	if (file_exists($fileName)) {
175
+		include_once $fileName;
176
+	} else {
177
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
178
+	}
179
+	?>
180 180
     <script type='text/javascript'>
181 181
         <!--
182 182
         var smart_url = '<?php echo SMARTOBJECT_URL ?>';
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
         src='<?php echo SMARTOBJECT_URL ?>include/smart.js'></script>
190 190
     <?php
191 191
 
192
-    /**
193
-     * Include the admin language constants for the SmartObject Framework
194
-     */
195
-    $admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php';
196
-    if (!file_exists($admin_file)) {
197
-        $admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php';
198
-    }
199
-    include_once($admin_file);
192
+	/**
193
+	 * Include the admin language constants for the SmartObject Framework
194
+	 */
195
+	$admin_file = SMARTOBJECT_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php';
196
+	if (!file_exists($admin_file)) {
197
+		$admin_file = SMARTOBJECT_ROOT_PATH . 'language/english/admin.php';
198
+	}
199
+	include_once($admin_file);
200 200
 }
201 201
 
202 202
 /**
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function smart_TableExists($table)
212 212
 {
213
-    $bRetVal = false;
214
-    //Verifies that a MySQL table exists
215
-    $xoopsDB  = XoopsDatabaseFactory::getDatabaseConnection();
216
-    $realname = $xoopsDB->prefix($table);
217
-    $sql      = 'SHOW TABLES FROM ' . XOOPS_DB_NAME;
218
-    $ret      = $xoopsDB->queryF($sql);
219
-    while (list($m_table) = $xoopsDB->fetchRow($ret)) {
220
-        if ($m_table == $realname) {
221
-            $bRetVal = true;
222
-            break;
223
-        }
224
-    }
225
-    $xoopsDB->freeRecordSet($ret);
226
-
227
-    return $bRetVal;
213
+	$bRetVal = false;
214
+	//Verifies that a MySQL table exists
215
+	$xoopsDB  = XoopsDatabaseFactory::getDatabaseConnection();
216
+	$realname = $xoopsDB->prefix($table);
217
+	$sql      = 'SHOW TABLES FROM ' . XOOPS_DB_NAME;
218
+	$ret      = $xoopsDB->queryF($sql);
219
+	while (list($m_table) = $xoopsDB->fetchRow($ret)) {
220
+		if ($m_table == $realname) {
221
+			$bRetVal = true;
222
+			break;
223
+		}
224
+	}
225
+	$xoopsDB->freeRecordSet($ret);
226
+
227
+	return $bRetVal;
228 228
 }
229 229
 
230 230
 /**
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
  */
240 240
 function smart_GetMeta($key, $moduleName = false)
241 241
 {
242
-    if (!$moduleName) {
243
-        $moduleName = smart_getCurrentModuleName();
244
-    }
245
-    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
246
-    $sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key));
247
-    $ret     = $xoopsDB->query($sql);
248
-    if (!$ret) {
249
-        $value = false;
250
-    } else {
251
-        list($value) = $xoopsDB->fetchRow($ret);
252
-    }
253
-
254
-    return $value;
242
+	if (!$moduleName) {
243
+		$moduleName = smart_getCurrentModuleName();
244
+	}
245
+	$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
246
+	$sql     = sprintf('SELECT metavalue FROM %s WHERE metakey=%s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key));
247
+	$ret     = $xoopsDB->query($sql);
248
+	if (!$ret) {
249
+		$value = false;
250
+	} else {
251
+		list($value) = $xoopsDB->fetchRow($ret);
252
+	}
253
+
254
+	return $value;
255 255
 }
256 256
 
257 257
 /**
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function smart_getCurrentModuleName()
261 261
 {
262
-    global $xoopsModule;
263
-    if (is_object($xoopsModule)) {
264
-        return $xoopsModule->getVar('dirname');
265
-    } else {
266
-        return false;
267
-    }
262
+	global $xoopsModule;
263
+	if (is_object($xoopsModule)) {
264
+		return $xoopsModule->getVar('dirname');
265
+	} else {
266
+		return false;
267
+	}
268 268
 }
269 269
 
270 270
 /**
@@ -280,22 +280,22 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function smart_SetMeta($key, $value, $moduleName = false)
282 282
 {
283
-    if (!$moduleName) {
284
-        $moduleName = smart_getCurrentModuleName();
285
-    }
286
-    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
287
-    $ret     = smart_GetMeta($key, $moduleName);
288
-    if ($ret === '0' || $ret > 0) {
289
-        $sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
290
-    } else {
291
-        $sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
292
-    }
293
-    $ret = $xoopsDB->queryF($sql);
294
-    if (!$ret) {
295
-        return false;
296
-    }
297
-
298
-    return true;
283
+	if (!$moduleName) {
284
+		$moduleName = smart_getCurrentModuleName();
285
+	}
286
+	$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
287
+	$ret     = smart_GetMeta($key, $moduleName);
288
+	if ($ret === '0' || $ret > 0) {
289
+		$sql = sprintf('UPDATE %s SET metavalue = %s WHERE metakey = %s', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key));
290
+	} else {
291
+		$sql = sprintf('INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)', $xoopsDB->prefix($moduleName . '_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value));
292
+	}
293
+	$ret = $xoopsDB->queryF($sql);
294
+	if (!$ret) {
295
+		return false;
296
+	}
297
+
298
+	return true;
299 299
 }
300 300
 
301 301
 // Thanks to Mithrandir:-)
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
  */
309 309
 function smart_substr($str, $start, $length, $trimmarker = '...')
310 310
 {
311
-    // if the string is empty, let's get out ;-)
312
-    if ($str == '') {
313
-        return $str;
314
-    }
315
-    // reverse a string that is shortened with '' as trimmarker
316
-    $reversed_string = strrev(xoops_substr($str, $start, $length, ''));
317
-    // find first space in reversed string
318
-    $position_of_space = strpos($reversed_string, ' ', 0);
319
-    // truncate the original string to a length of $length
320
-    // minus the position of the last space
321
-    // plus the length of the $trimmarker
322
-    $truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
323
-
324
-    return $truncated_string;
311
+	// if the string is empty, let's get out ;-)
312
+	if ($str == '') {
313
+		return $str;
314
+	}
315
+	// reverse a string that is shortened with '' as trimmarker
316
+	$reversed_string = strrev(xoops_substr($str, $start, $length, ''));
317
+	// find first space in reversed string
318
+	$position_of_space = strpos($reversed_string, ' ', 0);
319
+	// truncate the original string to a length of $length
320
+	// minus the position of the last space
321
+	// plus the length of the $trimmarker
322
+	$truncated_string = xoops_substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
323
+
324
+	return $truncated_string;
325 325
 }
326 326
 
327 327
 /**
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
  */
333 333
 function smart_getConfig($key, $moduleName = false, $default = 'default_is_undefined')
334 334
 {
335
-    if (!$moduleName) {
336
-        $moduleName = smart_getCurrentModuleName();
337
-    }
338
-    $configs = smart_getModuleConfig($moduleName);
339
-    if (isset($configs[$key])) {
340
-        return $configs[$key];
341
-    } else {
342
-        if ($default === 'default_is_undefined') {
343
-            return null;
344
-        } else {
345
-            return $default;
346
-        }
347
-    }
335
+	if (!$moduleName) {
336
+		$moduleName = smart_getCurrentModuleName();
337
+	}
338
+	$configs = smart_getModuleConfig($moduleName);
339
+	if (isset($configs[$key])) {
340
+		return $configs[$key];
341
+	} else {
342
+		if ($default === 'default_is_undefined') {
343
+			return null;
344
+		} else {
345
+			return $default;
346
+		}
347
+	}
348 348
 }
349 349
 
350 350
 /**
@@ -357,32 +357,32 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function smart_copyr($source, $dest)
359 359
 {
360
-    // Simple copy for a file
361
-    if (is_file($source)) {
362
-        return copy($source, $dest);
363
-    }
364
-    // Make destination directory
365
-    if (!is_dir($dest)) {
366
-        mkdir($dest);
367
-    }
368
-    // Loop through the folder
369
-    $dir = dir($source);
370
-    while (false !== $entry = $dir->read()) {
371
-        // Skip pointers
372
-        if ($entry === '.' || $entry === '..') {
373
-            continue;
374
-        }
375
-        // Deep copy directories
376
-        if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) {
377
-            copyr("$source/$entry", "$dest/$entry");
378
-        } else {
379
-            copy("$source/$entry", "$dest/$entry");
380
-        }
381
-    }
382
-    // Clean up
383
-    $dir->close();
384
-
385
-    return true;
360
+	// Simple copy for a file
361
+	if (is_file($source)) {
362
+		return copy($source, $dest);
363
+	}
364
+	// Make destination directory
365
+	if (!is_dir($dest)) {
366
+		mkdir($dest);
367
+	}
368
+	// Loop through the folder
369
+	$dir = dir($source);
370
+	while (false !== $entry = $dir->read()) {
371
+		// Skip pointers
372
+		if ($entry === '.' || $entry === '..') {
373
+			continue;
374
+		}
375
+		// Deep copy directories
376
+		if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) {
377
+			copyr("$source/$entry", "$dest/$entry");
378
+		} else {
379
+			copy("$source/$entry", "$dest/$entry");
380
+		}
381
+	}
382
+	// Clean up
383
+	$dir->close();
384
+
385
+	return true;
386 386
 }
387 387
 
388 388
 /**
@@ -392,26 +392,26 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function smart_admin_mkdir($target)
394 394
 {
395
-    // http://www.php.net/manual/en/function.mkdir.php
396
-    // saint at corenova.com
397
-    // bart at cdasites dot com
398
-    if (is_dir($target) || empty($target)) {
399
-        return true; // best case check first
400
-    }
401
-    if (file_exists($target) && !is_dir($target)) {
402
-        return false;
403
-    }
404
-    if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) {
405
-        if (!file_exists($target)) {
406
-            $res = mkdir($target, 0777); // crawl back up & create dir tree
407
-            smart_admin_chmod($target);
408
-
409
-            return $res;
410
-        }
411
-    }
412
-    $res = is_dir($target);
413
-
414
-    return $res;
395
+	// http://www.php.net/manual/en/function.mkdir.php
396
+	// saint at corenova.com
397
+	// bart at cdasites dot com
398
+	if (is_dir($target) || empty($target)) {
399
+		return true; // best case check first
400
+	}
401
+	if (file_exists($target) && !is_dir($target)) {
402
+		return false;
403
+	}
404
+	if (smart_admin_mkdir(substr($target, 0, strrpos($target, '/')))) {
405
+		if (!file_exists($target)) {
406
+			$res = mkdir($target, 0777); // crawl back up & create dir tree
407
+			smart_admin_chmod($target);
408
+
409
+			return $res;
410
+		}
411
+	}
412
+	$res = is_dir($target);
413
+
414
+	return $res;
415 415
 }
416 416
 
417 417
 /**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  */
423 423
 function smart_admin_chmod($target, $mode = 0777)
424 424
 {
425
-    return @ chmod($target, $mode);
425
+	return @ chmod($target, $mode);
426 426
 }
427 427
 
428 428
 /**
@@ -433,31 +433,31 @@  discard block
 block discarded – undo
433 433
  */
434 434
 function smart_imageResize($src, $maxWidth, $maxHeight)
435 435
 {
436
-    $width  = '';
437
-    $height = '';
438
-    $type   = '';
439
-    $attr   = '';
440
-    if (file_exists($src)) {
441
-        list($width, $height, $type, $attr) = getimagesize($src);
442
-        if ($width > $maxWidth) {
443
-            $originalWidth = $width;
444
-            $width         = $maxWidth;
445
-            $height        = $width * $height / $originalWidth;
446
-        }
447
-        if ($height > $maxHeight) {
448
-            $originalHeight = $height;
449
-            $height         = $maxHeight;
450
-            $width          = $height * $width / $originalHeight;
451
-        }
452
-        $attr = " width='$width' height='$height'";
453
-    }
454
-
455
-    return array(
456
-        $width,
457
-        $height,
458
-        $type,
459
-        $attr
460
-    );
436
+	$width  = '';
437
+	$height = '';
438
+	$type   = '';
439
+	$attr   = '';
440
+	if (file_exists($src)) {
441
+		list($width, $height, $type, $attr) = getimagesize($src);
442
+		if ($width > $maxWidth) {
443
+			$originalWidth = $width;
444
+			$width         = $maxWidth;
445
+			$height        = $width * $height / $originalWidth;
446
+		}
447
+		if ($height > $maxHeight) {
448
+			$originalHeight = $height;
449
+			$height         = $maxHeight;
450
+			$width          = $height * $width / $originalHeight;
451
+		}
452
+		$attr = " width='$width' height='$height'";
453
+	}
454
+
455
+	return array(
456
+		$width,
457
+		$height,
458
+		$type,
459
+		$attr
460
+	);
461 461
 }
462 462
 
463 463
 /**
@@ -466,34 +466,34 @@  discard block
 block discarded – undo
466 466
  */
467 467
 function smart_getModuleInfo($moduleName = false)
468 468
 {
469
-    static $smartModules;
470
-    if (isset($smartModules[$moduleName])) {
471
-        $ret =& $smartModules[$moduleName];
472
-
473
-        return $ret;
474
-    }
475
-    global $xoopsModule;
476
-    if (!$moduleName) {
477
-        if (isset($xoopsModule) && is_object($xoopsModule)) {
478
-            $smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule;
479
-
480
-            return $smartModules[$xoopsModule->getVar('dirname')];
481
-        }
482
-    }
483
-    if (!isset($smartModules[$moduleName])) {
484
-        if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
485
-            $smartModules[$moduleName] = $xoopsModule;
486
-        } else {
487
-            $hModule = xoops_getHandler('module');
488
-            if ($moduleName !== 'xoops') {
489
-                $smartModules[$moduleName] = $hModule->getByDirname($moduleName);
490
-            } else {
491
-                $smartModules[$moduleName] = $hModule->getByDirname('system');
492
-            }
493
-        }
494
-    }
495
-
496
-    return $smartModules[$moduleName];
469
+	static $smartModules;
470
+	if (isset($smartModules[$moduleName])) {
471
+		$ret =& $smartModules[$moduleName];
472
+
473
+		return $ret;
474
+	}
475
+	global $xoopsModule;
476
+	if (!$moduleName) {
477
+		if (isset($xoopsModule) && is_object($xoopsModule)) {
478
+			$smartModules[$xoopsModule->getVar('dirname')] = $xoopsModule;
479
+
480
+			return $smartModules[$xoopsModule->getVar('dirname')];
481
+		}
482
+	}
483
+	if (!isset($smartModules[$moduleName])) {
484
+		if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
485
+			$smartModules[$moduleName] = $xoopsModule;
486
+		} else {
487
+			$hModule = xoops_getHandler('module');
488
+			if ($moduleName !== 'xoops') {
489
+				$smartModules[$moduleName] = $hModule->getByDirname($moduleName);
490
+			} else {
491
+				$smartModules[$moduleName] = $hModule->getByDirname('system');
492
+			}
493
+		}
494
+	}
495
+
496
+	return $smartModules[$moduleName];
497 497
 }
498 498
 
499 499
 /**
@@ -502,40 +502,40 @@  discard block
 block discarded – undo
502 502
  */
503 503
 function smart_getModuleConfig($moduleName = false)
504 504
 {
505
-    static $smartConfigs;
506
-    if (isset($smartConfigs[$moduleName])) {
507
-        $ret =& $smartConfigs[$moduleName];
508
-
509
-        return $ret;
510
-    }
511
-    global $xoopsModule, $xoopsModuleConfig;
512
-    if (!$moduleName) {
513
-        if (isset($xoopsModule) && is_object($xoopsModule)) {
514
-            $smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig;
515
-
516
-            return $smartConfigs[$xoopsModule->getVar('dirname')];
517
-        }
518
-    }
519
-    // if we still did not found the xoopsModule, this is because there is none
520
-    if (!$moduleName) {
521
-        $ret = false;
522
-
523
-        return $ret;
524
-    }
525
-    if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
526
-        $smartConfigs[$moduleName] = $xoopsModuleConfig;
527
-    } else {
528
-        $module = smart_getModuleInfo($moduleName);
529
-        if (!is_object($module)) {
530
-            $ret = false;
531
-
532
-            return $ret;
533
-        }
534
-        $hModConfig                = xoops_getHandler('config');
535
-        $smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
536
-    }
537
-
538
-    return $smartConfigs[$moduleName];
505
+	static $smartConfigs;
506
+	if (isset($smartConfigs[$moduleName])) {
507
+		$ret =& $smartConfigs[$moduleName];
508
+
509
+		return $ret;
510
+	}
511
+	global $xoopsModule, $xoopsModuleConfig;
512
+	if (!$moduleName) {
513
+		if (isset($xoopsModule) && is_object($xoopsModule)) {
514
+			$smartConfigs[$xoopsModule->getVar('dirname')] = $xoopsModuleConfig;
515
+
516
+			return $smartConfigs[$xoopsModule->getVar('dirname')];
517
+		}
518
+	}
519
+	// if we still did not found the xoopsModule, this is because there is none
520
+	if (!$moduleName) {
521
+		$ret = false;
522
+
523
+		return $ret;
524
+	}
525
+	if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $moduleName) {
526
+		$smartConfigs[$moduleName] = $xoopsModuleConfig;
527
+	} else {
528
+		$module = smart_getModuleInfo($moduleName);
529
+		if (!is_object($module)) {
530
+			$ret = false;
531
+
532
+			return $ret;
533
+		}
534
+		$hModConfig                = xoops_getHandler('config');
535
+		$smartConfigs[$moduleName] =& $hModConfig->getConfigsByCat(0, $module->getVar('mid'));
536
+	}
537
+
538
+	return $smartConfigs[$moduleName];
539 539
 }
540 540
 
541 541
 /**
@@ -544,10 +544,10 @@  discard block
 block discarded – undo
544 544
  */
545 545
 function smart_deleteFile($dirname)
546 546
 {
547
-    // Simple delete for a file
548
-    if (is_file($dirname)) {
549
-        return unlink($dirname);
550
-    }
547
+	// Simple delete for a file
548
+	if (is_file($dirname)) {
549
+		return unlink($dirname);
550
+	}
551 551
 }
552 552
 
553 553
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  */
557 557
 function smart_formatErrors($errors = array())
558 558
 {
559
-    $ret = '';
560
-    foreach ($errors as $key => $value) {
561
-        $ret .= '<br /> - ' . $value;
562
-    }
559
+	$ret = '';
560
+	foreach ($errors as $key => $value) {
561
+		$ret .= '<br /> - ' . $value;
562
+	}
563 563
 
564
-    return $ret;
564
+	return $ret;
565 565
 }
566 566
 
567 567
 /**
@@ -575,46 +575,46 @@  discard block
 block discarded – undo
575 575
  */
576 576
 function smart_getLinkedUnameFromId($userid = 0, $name = 0, $users = array(), $withContact = false)
577 577
 {
578
-    if (!is_numeric($userid)) {
579
-        return $userid;
580
-    }
581
-    $userid = (int)$userid;
582
-    if ($userid > 0) {
583
-        if ($users == array()) {
584
-            //fetching users
585
-            $memberHandler = xoops_getHandler('member');
586
-            $user           =& $memberHandler->getUser($userid);
587
-        } else {
588
-            if (!isset($users[$userid])) {
589
-                return $GLOBALS['xoopsConfig']['anonymous'];
590
-            }
591
-            $user =& $users[$userid];
592
-        }
593
-        if (is_object($user)) {
594
-            $ts        = MyTextSanitizer:: getInstance();
595
-            $username  = $user->getVar('uname');
596
-            $fullname  = '';
597
-            $fullname2 = $user->getVar('name');
598
-            if ($name && !empty($fullname2)) {
599
-                $fullname = $user->getVar('name');
600
-            }
601
-            if (!empty($fullname)) {
602
-                $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
603
-            } else {
604
-                $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
605
-            }
606
-            // add contact info: email + PM
607
-            if ($withContact) {
608
-                $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>';
609
-                $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
610
-                $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>';
611
-            }
612
-
613
-            return $linkeduser;
614
-        }
615
-    }
616
-
617
-    return $GLOBALS['xoopsConfig']['anonymous'];
578
+	if (!is_numeric($userid)) {
579
+		return $userid;
580
+	}
581
+	$userid = (int)$userid;
582
+	if ($userid > 0) {
583
+		if ($users == array()) {
584
+			//fetching users
585
+			$memberHandler = xoops_getHandler('member');
586
+			$user           =& $memberHandler->getUser($userid);
587
+		} else {
588
+			if (!isset($users[$userid])) {
589
+				return $GLOBALS['xoopsConfig']['anonymous'];
590
+			}
591
+			$user =& $users[$userid];
592
+		}
593
+		if (is_object($user)) {
594
+			$ts        = MyTextSanitizer:: getInstance();
595
+			$username  = $user->getVar('uname');
596
+			$fullname  = '';
597
+			$fullname2 = $user->getVar('name');
598
+			if ($name && !empty($fullname2)) {
599
+				$fullname = $user->getVar('name');
600
+			}
601
+			if (!empty($fullname)) {
602
+				$linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
603
+			} else {
604
+				$linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
605
+			}
606
+			// add contact info: email + PM
607
+			if ($withContact) {
608
+				$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>';
609
+				$js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
610
+				$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>';
611
+			}
612
+
613
+			return $linkeduser;
614
+		}
615
+	}
616
+
617
+	return $GLOBALS['xoopsConfig']['anonymous'];
618 618
 }
619 619
 
620 620
 /**
@@ -625,33 +625,33 @@  discard block
 block discarded – undo
625 625
  */
626 626
 function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1)
627 627
 {
628
-    global $xoopsModule, $xoopsConfig;
629
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
630
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
631
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
632
-    } else {
633
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
634
-    }
635
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
636
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
637
-    } else {
638
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
639
-    }
640
-    $headermenu = array();
641
-    $adminmenu  = array();
642
-    include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
643
-    $tpl = new XoopsTpl();
644
-    $tpl->assign(array(
645
-                     'headermenu'      => $headermenu,
646
-                     'adminmenu'       => $adminmenu,
647
-                     'current'         => $currentoption,
648
-                     'breadcrumb'      => $breadcrumb,
649
-                     'headermenucount' => count($headermenu),
650
-                     'submenus'        => $submenus,
651
-                     'currentsub'      => $currentsub,
652
-                     'submenuscount'   => count($submenus)
653
-                 ));
654
-    $tpl->display('db:smartobject_admin_menu.tpl');
628
+	global $xoopsModule, $xoopsConfig;
629
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
630
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
631
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
632
+	} else {
633
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
634
+	}
635
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
636
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
637
+	} else {
638
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
639
+	}
640
+	$headermenu = array();
641
+	$adminmenu  = array();
642
+	include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
643
+	$tpl = new XoopsTpl();
644
+	$tpl->assign(array(
645
+					 'headermenu'      => $headermenu,
646
+					 'adminmenu'       => $adminmenu,
647
+					 'current'         => $currentoption,
648
+					 'breadcrumb'      => $breadcrumb,
649
+					 'headermenucount' => count($headermenu),
650
+					 'submenus'        => $submenus,
651
+					 'currentsub'      => $currentsub,
652
+					 'submenuscount'   => count($submenus)
653
+				 ));
654
+	$tpl->display('db:smartobject_admin_menu.tpl');
655 655
 }
656 656
 
657 657
 /**
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
  */
662 662
 function smart_collapsableBar($id = '', $title = '', $dsc = '')
663 663
 {
664
-    global $xoopsModule;
665
-    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')\";>";
666
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
667
-    echo "<div id='" . $id . "'>";
668
-    if ($dsc != '') {
669
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
670
-    }
664
+	global $xoopsModule;
665
+	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')\";>";
666
+	echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
667
+	echo "<div id='" . $id . "'>";
668
+	if ($dsc != '') {
669
+		echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
670
+	}
671 671
 }
672 672
 
673 673
 /**
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
  */
678 678
 function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '')
679 679
 {
680
-    global $xoopsModule;
681
-    $onClick = "ajaxtogglecollapse('$id')";
682
-    //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
683
-    echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
684
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
685
-    echo "<div id='" . $id . "'>";
686
-    if ($dsc != '') {
687
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
688
-    }
680
+	global $xoopsModule;
681
+	$onClick = "ajaxtogglecollapse('$id')";
682
+	//$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
683
+	echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
684
+	echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
685
+	echo "<div id='" . $id . "'>";
686
+	if ($dsc != '') {
687
+		echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
688
+	}
689 689
 }
690 690
 
691 691
 /**
@@ -712,20 +712,20 @@  discard block
 block discarded – undo
712 712
  */
713 713
 function smart_openclose_collapsable($name)
714 714
 {
715
-    $urls        = smart_getCurrentUrls();
716
-    $path        = $urls['phpself'];
717
-    $cookie_name = $path . '_smart_collaps_' . $name;
718
-    $cookie_name = str_replace('.', '_', $cookie_name);
719
-    $cookie      = smart_getCookieVar($cookie_name, '');
720
-    if ($cookie === 'none') {
721
-        echo '
715
+	$urls        = smart_getCurrentUrls();
716
+	$path        = $urls['phpself'];
717
+	$cookie_name = $path . '_smart_collaps_' . $name;
718
+	$cookie_name = str_replace('.', '_', $cookie_name);
719
+	$cookie      = smart_getCookieVar($cookie_name, '');
720
+	if ($cookie === 'none') {
721
+		echo '
722 722
                 <script type="text/javascript"><!--
723 723
                 togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon");
724 724
                     //-->
725 725
                 </script>
726 726
                 ';
727
-    }
728
-    /*  if ($cookie == 'none') {
727
+	}
728
+	/*  if ($cookie == 'none') {
729 729
      echo '
730 730
      <script type="text/javascript"><!--
731 731
      hideElement("' . $name . '");
@@ -741,9 +741,9 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function smart_close_collapsable($name)
743 743
 {
744
-    echo '</div>';
745
-    smart_openclose_collapsable($name);
746
-    echo '<br />';
744
+	echo '</div>';
745
+	smart_openclose_collapsable($name);
746
+	echo '<br />';
747 747
 }
748 748
 
749 749
 /**
@@ -753,11 +753,11 @@  discard block
 block discarded – undo
753 753
  */
754 754
 function smart_setCookieVar($name, $value, $time = 0)
755 755
 {
756
-    if ($time == 0) {
757
-        $time = time() + 3600 * 24 * 365;
758
-        //$time = '';
759
-    }
760
-    setcookie($name, $value, $time, '/');
756
+	if ($time == 0) {
757
+		$time = time() + 3600 * 24 * 365;
758
+		//$time = '';
759
+	}
760
+	setcookie($name, $value, $time, '/');
761 761
 }
762 762
 
763 763
 /**
@@ -767,12 +767,12 @@  discard block
 block discarded – undo
767 767
  */
768 768
 function smart_getCookieVar($name, $default = '')
769 769
 {
770
-    $name = str_replace('.', '_', $name);
771
-    if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
772
-        return $_COOKIE[$name];
773
-    } else {
774
-        return $default;
775
-    }
770
+	$name = str_replace('.', '_', $name);
771
+	if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
772
+		return $_COOKIE[$name];
773
+	} else {
774
+		return $default;
775
+	}
776 776
 }
777 777
 
778 778
 /**
@@ -780,25 +780,25 @@  discard block
 block discarded – undo
780 780
  */
781 781
 function smart_getCurrentUrls()
782 782
 {
783
-    $urls        = array();
784
-    $http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
785
-    $phpself     = $_SERVER['PHP_SELF'];
786
-    $httphost    = $_SERVER['HTTP_HOST'];
787
-    $querystring = $_SERVER['QUERY_STRING'];
788
-    if ($querystring != '') {
789
-        $querystring = '?' . $querystring;
790
-    }
791
-    $currenturl           = $http . $httphost . $phpself . $querystring;
792
-    $urls                 = array();
793
-    $urls['http']         = $http;
794
-    $urls['httphost']     = $httphost;
795
-    $urls['phpself']      = $phpself;
796
-    $urls['querystring']  = $querystring;
797
-    $urls['full_phpself'] = $http . $httphost . $phpself;
798
-    $urls['full']         = $currenturl;
799
-    $urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
800
-
801
-    return $urls;
783
+	$urls        = array();
784
+	$http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
785
+	$phpself     = $_SERVER['PHP_SELF'];
786
+	$httphost    = $_SERVER['HTTP_HOST'];
787
+	$querystring = $_SERVER['QUERY_STRING'];
788
+	if ($querystring != '') {
789
+		$querystring = '?' . $querystring;
790
+	}
791
+	$currenturl           = $http . $httphost . $phpself . $querystring;
792
+	$urls                 = array();
793
+	$urls['http']         = $http;
794
+	$urls['httphost']     = $httphost;
795
+	$urls['phpself']      = $phpself;
796
+	$urls['querystring']  = $querystring;
797
+	$urls['full_phpself'] = $http . $httphost . $phpself;
798
+	$urls['full']         = $currenturl;
799
+	$urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
800
+
801
+	return $urls;
802 802
 }
803 803
 
804 804
 /**
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
  */
807 807
 function smart_getCurrentPage()
808 808
 {
809
-    $urls = smart_getCurrentUrls();
809
+	$urls = smart_getCurrentUrls();
810 810
 
811
-    return $urls['full'];
811
+	return $urls['full'];
812 812
 }
813 813
 
814 814
 /**
@@ -855,29 +855,29 @@  discard block
 block discarded – undo
855 855
  */
856 856
 function smart_modFooter()
857 857
 {
858
-    global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
859
-
860
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
861
-    $tpl = new XoopsTpl();
862
-
863
-    $hModule      = xoops_getHandler('module');
864
-    $versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
865
-    $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
866
-    $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>";
867
-    $tpl->assign('modfooter', $modfooter);
868
-
869
-    if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
870
-        define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br />Do you need new features not yet available?');
871
-    }
872
-    $smartobjectConfig = smart_getModuleConfig('smartobject');
873
-    $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
874
-    $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
858
+	global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
859
+
860
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
861
+	$tpl = new XoopsTpl();
862
+
863
+	$hModule      = xoops_getHandler('module');
864
+	$versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
865
+	$modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
866
+	$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>";
867
+	$tpl->assign('modfooter', $modfooter);
868
+
869
+	if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
870
+		define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br />Do you need new features not yet available?');
871
+	}
872
+	$smartobjectConfig = smart_getModuleConfig('smartobject');
873
+	$tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
874
+	$tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
875 875
 }
876 876
 
877 877
 function smart_xoops_cp_footer()
878 878
 {
879
-    smart_modFooter();
880
-    xoops_cp_footer();
879
+	smart_modFooter();
880
+	xoops_cp_footer();
881 881
 }
882 882
 
883 883
 /**
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
  */
887 887
 function smart_sanitizeForCommonTags($text)
888 888
 {
889
-    global $xoopsConfig;
890
-    $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
891
-    $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
889
+	global $xoopsConfig;
890
+	$text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
891
+	$text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
892 892
 
893
-    return $text;
893
+	return $text;
894 894
 }
895 895
 
896 896
 /**
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
  */
899 899
 function smart_addScript($src)
900 900
 {
901
-    echo '<script src="' . $src . '" type="text/javascript"></script>';
901
+	echo '<script src="' . $src . '" type="text/javascript"></script>';
902 902
 }
903 903
 
904 904
 /**
@@ -906,17 +906,17 @@  discard block
 block discarded – undo
906 906
  */
907 907
 function smart_addStyle($src)
908 908
 {
909
-    if ($src === 'smartobject') {
910
-        $src = SMARTOBJECT_URL . 'assets/css/module.css';
911
-    }
912
-    echo smart_get_css_link($src);
909
+	if ($src === 'smartobject') {
910
+		$src = SMARTOBJECT_URL . 'assets/css/module.css';
911
+	}
912
+	echo smart_get_css_link($src);
913 913
 }
914 914
 
915 915
 function smart_addAdminAjaxSupport()
916 916
 {
917
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
918
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
919
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
917
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
918
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
919
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
920 920
 }
921 921
 
922 922
 /**
@@ -925,11 +925,11 @@  discard block
 block discarded – undo
925 925
  */
926 926
 function smart_sanitizeForSmartpopupLink($text)
927 927
 {
928
-    $patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
929
-    $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
930
-    $ret            = preg_replace($patterns, $replacements, $text);
928
+	$patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
929
+	$replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
930
+	$ret            = preg_replace($patterns, $replacements, $text);
931 931
 
932
-    return $ret;
932
+	return $ret;
933 933
 }
934 934
 
935 935
 /**
@@ -944,25 +944,25 @@  discard block
 block discarded – undo
944 944
  */
945 945
 function smart_getImageSize($url, & $width, & $height)
946 946
 {
947
-    if (empty($width) || empty($height)) {
948
-        if (!$dimension = @ getimagesize($url)) {
949
-            return false;
950
-        }
951
-        if (!empty($width)) {
952
-            $height = $dimension[1] * $width / $dimension[0];
953
-        } elseif (!empty($height)) {
954
-            $width = $dimension[0] * $height / $dimension[1];
955
-        } else {
956
-            list($width, $height) = array(
957
-                $dimension[0],
958
-                $dimension[1]
959
-            );
960
-        }
961
-
962
-        return true;
963
-    } else {
964
-        return true;
965
-    }
947
+	if (empty($width) || empty($height)) {
948
+		if (!$dimension = @ getimagesize($url)) {
949
+			return false;
950
+		}
951
+		if (!empty($width)) {
952
+			$height = $dimension[1] * $width / $dimension[0];
953
+		} elseif (!empty($height)) {
954
+			$width = $dimension[0] * $height / $dimension[1];
955
+		} else {
956
+			list($width, $height) = array(
957
+				$dimension[0],
958
+				$dimension[1]
959
+			);
960
+		}
961
+
962
+		return true;
963
+	} else {
964
+		return true;
965
+	}
966 966
 }
967 967
 
968 968
 /**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
  */
976 976
 function smart_htmlnumericentities($str)
977 977
 {
978
-    //    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
979
-    return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
978
+	//    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
979
+	return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
980 980
 }
981 981
 
982 982
 /**
@@ -986,24 +986,24 @@  discard block
 block discarded – undo
986 986
  */
987 987
 function smart_getcorehandler($name, $optional = false)
988 988
 {
989
-    static $handlers;
990
-    $name = strtolower(trim($name));
991
-    if (!isset($handlers[$name])) {
992
-        if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
993
-            require_once $hnd_file;
994
-        }
995
-        $class = 'Xoops' . ucfirst($name) . 'Handler';
996
-        if (class_exists($class)) {
997
-            $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
998
-        }
999
-    }
1000
-    if (!isset($handlers[$name]) && !$optional) {
1001
-        trigger_error('Class <b>' . $class . '</b> does not exist<br />Handler Name: ' . $name, E_USER_ERROR);
1002
-    }
1003
-    if (isset($handlers[$name])) {
1004
-        return $handlers[$name];
1005
-    }
1006
-    $inst = false;
989
+	static $handlers;
990
+	$name = strtolower(trim($name));
991
+	if (!isset($handlers[$name])) {
992
+		if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
993
+			require_once $hnd_file;
994
+		}
995
+		$class = 'Xoops' . ucfirst($name) . 'Handler';
996
+		if (class_exists($class)) {
997
+			$handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
998
+		}
999
+	}
1000
+	if (!isset($handlers[$name]) && !$optional) {
1001
+		trigger_error('Class <b>' . $class . '</b> does not exist<br />Handler Name: ' . $name, E_USER_ERROR);
1002
+	}
1003
+	if (isset($handlers[$name])) {
1004
+		return $handlers[$name];
1005
+	}
1006
+	$inst = false;
1007 1007
 }
1008 1008
 
1009 1009
 /**
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
  */
1013 1013
 function smart_sanitizeAdsenses_callback($matches)
1014 1014
 {
1015
-    global $smartobjectAdsenseHandler;
1016
-    if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1017
-        $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1018
-        $ret        = $adsenseObj->render();
1019
-
1020
-        return $ret;
1021
-    } else {
1022
-        return '';
1023
-    }
1015
+	global $smartobjectAdsenseHandler;
1016
+	if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1017
+		$adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1018
+		$ret        = $adsenseObj->render();
1019
+
1020
+		return $ret;
1021
+	} else {
1022
+		return '';
1023
+	}
1024 1024
 }
1025 1025
 
1026 1026
 /**
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
  */
1030 1030
 function smart_sanitizeAdsenses($text)
1031 1031
 {
1032
-    $patterns     = array();
1033
-    $replacements = array();
1032
+	$patterns     = array();
1033
+	$replacements = array();
1034 1034
 
1035
-    $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1036
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1035
+	$patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1036
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1037 1037
 
1038
-    return $text;
1038
+	return $text;
1039 1039
 }
1040 1040
 
1041 1041
 /**
@@ -1044,15 +1044,15 @@  discard block
 block discarded – undo
1044 1044
  */
1045 1045
 function smart_sanitizeCustomtags_callback($matches)
1046 1046
 {
1047
-    global $smartobjectCustomtagHandler;
1048
-    if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1049
-        $customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1050
-        $ret       = $customObj->renderWithPhp();
1051
-
1052
-        return $ret;
1053
-    } else {
1054
-        return '';
1055
-    }
1047
+	global $smartobjectCustomtagHandler;
1048
+	if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1049
+		$customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1050
+		$ret       = $customObj->renderWithPhp();
1051
+
1052
+		return $ret;
1053
+	} else {
1054
+		return '';
1055
+	}
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
  */
1062 1062
 function smart_sanitizeCustomtags($text)
1063 1063
 {
1064
-    $patterns     = array();
1065
-    $replacements = array();
1064
+	$patterns     = array();
1065
+	$replacements = array();
1066 1066
 
1067
-    $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1068
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1067
+	$patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1068
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1069 1069
 
1070
-    return $text;
1070
+	return $text;
1071 1071
 }
1072 1072
 
1073 1073
 /**
@@ -1076,20 +1076,20 @@  discard block
 block discarded – undo
1076 1076
  */
1077 1077
 function smart_loadLanguageFile($module, $file)
1078 1078
 {
1079
-    global $xoopsConfig;
1080
-
1081
-    $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1082
-    if (!file_exists($filename)) {
1083
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1084
-    }
1085
-    if (file_exists($filename)) {
1086
-        include_once($filename);
1087
-    }
1079
+	global $xoopsConfig;
1080
+
1081
+	$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1082
+	if (!file_exists($filename)) {
1083
+		$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1084
+	}
1085
+	if (file_exists($filename)) {
1086
+		include_once($filename);
1087
+	}
1088 1088
 }
1089 1089
 
1090 1090
 function smart_loadCommonLanguageFile()
1091 1091
 {
1092
-    smart_loadLanguageFile('smartobject', 'common');
1092
+	smart_loadLanguageFile('smartobject', 'common');
1093 1093
 }
1094 1094
 
1095 1095
 /**
@@ -1099,35 +1099,35 @@  discard block
 block discarded – undo
1099 1099
  */
1100 1100
 function smart_purifyText($text, $keyword = false)
1101 1101
 {
1102
-    global $myts;
1103
-    $text = str_replace('&nbsp;', ' ', $text);
1104
-    $text = str_replace('<br />', ' ', $text);
1105
-    $text = str_replace('<br/>', ' ', $text);
1106
-    $text = str_replace('<br', ' ', $text);
1107
-    $text = strip_tags($text);
1108
-    $text = html_entity_decode($text);
1109
-    $text = $myts->undoHtmlSpecialChars($text);
1110
-    $text = str_replace(')', ' ', $text);
1111
-    $text = str_replace('(', ' ', $text);
1112
-    $text = str_replace(':', ' ', $text);
1113
-    $text = str_replace('&euro', ' euro ', $text);
1114
-    $text = str_replace('&hellip', '...', $text);
1115
-    $text = str_replace('&rsquo', ' ', $text);
1116
-    $text = str_replace('!', ' ', $text);
1117
-    $text = str_replace('?', ' ', $text);
1118
-    $text = str_replace('"', ' ', $text);
1119
-    $text = str_replace('-', ' ', $text);
1120
-    $text = str_replace('\n', ' ', $text);
1121
-    $text = str_replace('&#8213;', ' ', $text);
1122
-
1123
-    if ($keyword) {
1124
-        $text = str_replace('.', ' ', $text);
1125
-        $text = str_replace(',', ' ', $text);
1126
-        $text = str_replace('\'', ' ', $text);
1127
-    }
1128
-    $text = str_replace(';', ' ', $text);
1129
-
1130
-    return $text;
1102
+	global $myts;
1103
+	$text = str_replace('&nbsp;', ' ', $text);
1104
+	$text = str_replace('<br />', ' ', $text);
1105
+	$text = str_replace('<br/>', ' ', $text);
1106
+	$text = str_replace('<br', ' ', $text);
1107
+	$text = strip_tags($text);
1108
+	$text = html_entity_decode($text);
1109
+	$text = $myts->undoHtmlSpecialChars($text);
1110
+	$text = str_replace(')', ' ', $text);
1111
+	$text = str_replace('(', ' ', $text);
1112
+	$text = str_replace(':', ' ', $text);
1113
+	$text = str_replace('&euro', ' euro ', $text);
1114
+	$text = str_replace('&hellip', '...', $text);
1115
+	$text = str_replace('&rsquo', ' ', $text);
1116
+	$text = str_replace('!', ' ', $text);
1117
+	$text = str_replace('?', ' ', $text);
1118
+	$text = str_replace('"', ' ', $text);
1119
+	$text = str_replace('-', ' ', $text);
1120
+	$text = str_replace('\n', ' ', $text);
1121
+	$text = str_replace('&#8213;', ' ', $text);
1122
+
1123
+	if ($keyword) {
1124
+		$text = str_replace('.', ' ', $text);
1125
+		$text = str_replace(',', ' ', $text);
1126
+		$text = str_replace('\'', ' ', $text);
1127
+	}
1128
+	$text = str_replace(';', ' ', $text);
1129
+
1130
+	return $text;
1131 1131
 }
1132 1132
 
1133 1133
 /**
@@ -1136,49 +1136,49 @@  discard block
 block discarded – undo
1136 1136
  */
1137 1137
 function smart_html2text($document)
1138 1138
 {
1139
-    // PHP Manual:: function preg_replace
1140
-    // $document should contain an HTML document.
1141
-    // This will remove HTML tags, javascript sections
1142
-    // and white space. It will also convert some
1143
-    // common HTML entities to their text equivalent.
1144
-    // Credits: newbb2
1145
-    $search = array(
1146
-        "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1147
-        "'<img.*?/>'si",       // Strip out img tags
1148
-        "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1149
-        "'([\r\n])[\s]+'",                // Strip out white space
1150
-        "'&(quot|#34);'i",                // Replace HTML entities
1151
-        "'&(amp|#38);'i",
1152
-        "'&(lt|#60);'i",
1153
-        "'&(gt|#62);'i",
1154
-        "'&(nbsp|#160);'i",
1155
-        "'&(iexcl|#161);'i",
1156
-        "'&(cent|#162);'i",
1157
-        "'&(pound|#163);'i",
1158
-        "'&(copy|#169);'i",
1159
-        "'&#(\d+);'e"
1160
-    );                    // evaluate as php
1161
-
1162
-    $replace = array(
1163
-        '',
1164
-        '',
1165
-        '',
1166
-        "\\1",
1167
-        "\"",
1168
-        '&',
1169
-        '<',
1170
-        '>',
1171
-        ' ',
1172
-        chr(161),
1173
-        chr(162),
1174
-        chr(163),
1175
-        chr(169),
1176
-        "chr(\\1)"
1177
-    );
1178
-
1179
-    $text = preg_replace($search, $replace, $document);
1180
-
1181
-    return $text;
1139
+	// PHP Manual:: function preg_replace
1140
+	// $document should contain an HTML document.
1141
+	// This will remove HTML tags, javascript sections
1142
+	// and white space. It will also convert some
1143
+	// common HTML entities to their text equivalent.
1144
+	// Credits: newbb2
1145
+	$search = array(
1146
+		"'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1147
+		"'<img.*?/>'si",       // Strip out img tags
1148
+		"'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1149
+		"'([\r\n])[\s]+'",                // Strip out white space
1150
+		"'&(quot|#34);'i",                // Replace HTML entities
1151
+		"'&(amp|#38);'i",
1152
+		"'&(lt|#60);'i",
1153
+		"'&(gt|#62);'i",
1154
+		"'&(nbsp|#160);'i",
1155
+		"'&(iexcl|#161);'i",
1156
+		"'&(cent|#162);'i",
1157
+		"'&(pound|#163);'i",
1158
+		"'&(copy|#169);'i",
1159
+		"'&#(\d+);'e"
1160
+	);                    // evaluate as php
1161
+
1162
+	$replace = array(
1163
+		'',
1164
+		'',
1165
+		'',
1166
+		"\\1",
1167
+		"\"",
1168
+		'&',
1169
+		'<',
1170
+		'>',
1171
+		' ',
1172
+		chr(161),
1173
+		chr(162),
1174
+		chr(163),
1175
+		chr(169),
1176
+		"chr(\\1)"
1177
+	);
1178
+
1179
+	$text = preg_replace($search, $replace, $document);
1180
+
1181
+	return $text;
1182 1182
 }
1183 1183
 
1184 1184
 /**
@@ -1192,32 +1192,32 @@  discard block
 block discarded – undo
1192 1192
  */
1193 1193
 function smart_getfloat($str, $set = false)
1194 1194
 {
1195
-    if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1196
-        // Found number in $str, so set $str that number
1197
-        $str = $match[0];
1198
-        if (false !== strpos($str, ',')) {
1199
-            // A comma exists, that makes it easy, cos we assume it separates the decimal part.
1200
-            $str = str_replace('.', '', $str);    // Erase thousand seps
1201
-            $str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1202
-
1203
-            return (float)$str;
1204
-        } else {
1205
-            // No comma exists, so we have to decide, how a single dot shall be treated
1206
-            if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1207
-                // Treat single dot as decimal separator
1208
-                return (float)$str;
1209
-            } else {
1210
-                //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> ";
1211
-                // Else, treat all dots as thousand seps
1212
-                $str = str_replace('.', '', $str);    // Erase thousand seps
1213
-
1214
-                return (float)$str;
1215
-            }
1216
-        }
1217
-    } else {
1218
-        // No number found, return zero
1219
-        return 0;
1220
-    }
1195
+	if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1196
+		// Found number in $str, so set $str that number
1197
+		$str = $match[0];
1198
+		if (false !== strpos($str, ',')) {
1199
+			// A comma exists, that makes it easy, cos we assume it separates the decimal part.
1200
+			$str = str_replace('.', '', $str);    // Erase thousand seps
1201
+			$str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1202
+
1203
+			return (float)$str;
1204
+		} else {
1205
+			// No comma exists, so we have to decide, how a single dot shall be treated
1206
+			if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1207
+				// Treat single dot as decimal separator
1208
+				return (float)$str;
1209
+			} else {
1210
+				//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br/><br/> ";
1211
+				// Else, treat all dots as thousand seps
1212
+				$str = str_replace('.', '', $str);    // Erase thousand seps
1213
+
1214
+				return (float)$str;
1215
+			}
1216
+		}
1217
+	} else {
1218
+		// No number found, return zero
1219
+		return 0;
1220
+	}
1221 1221
 }
1222 1222
 
1223 1223
 /**
@@ -1227,26 +1227,26 @@  discard block
 block discarded – undo
1227 1227
  */
1228 1228
 function smart_currency($var, $currencyObj = false)
1229 1229
 {
1230
-    $ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1231
-    $ret = round($ret, 2);
1232
-    // make sur we have at least .00 in the $var
1233
-    $decimal_section_original = strstr($ret, '.');
1234
-    $decimal_section          = $decimal_section_original;
1235
-    if ($decimal_section) {
1236
-        if (strlen($decimal_section) == 1) {
1237
-            $decimal_section = '.00';
1238
-        } elseif (strlen($decimal_section) == 2) {
1239
-            $decimal_section = $decimal_section . '0';
1240
-        }
1241
-        $ret = str_replace($decimal_section_original, $decimal_section, $ret);
1242
-    } else {
1243
-        $ret = $ret . '.00';
1244
-    }
1245
-    if ($currencyObj) {
1246
-        $ret = $ret . ' ' . $currencyObj->getCode();
1247
-    }
1248
-
1249
-    return $ret;
1230
+	$ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1231
+	$ret = round($ret, 2);
1232
+	// make sur we have at least .00 in the $var
1233
+	$decimal_section_original = strstr($ret, '.');
1234
+	$decimal_section          = $decimal_section_original;
1235
+	if ($decimal_section) {
1236
+		if (strlen($decimal_section) == 1) {
1237
+			$decimal_section = '.00';
1238
+		} elseif (strlen($decimal_section) == 2) {
1239
+			$decimal_section = $decimal_section . '0';
1240
+		}
1241
+		$ret = str_replace($decimal_section_original, $decimal_section, $ret);
1242
+	} else {
1243
+		$ret = $ret . '.00';
1244
+	}
1245
+	if ($currencyObj) {
1246
+		$ret = $ret . ' ' . $currencyObj->getCode();
1247
+	}
1248
+
1249
+	return $ret;
1250 1250
 }
1251 1251
 
1252 1252
 /**
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
  */
1256 1256
 function smart_float($var)
1257 1257
 {
1258
-    return smart_currency($var);
1258
+	return smart_currency($var);
1259 1259
 }
1260 1260
 
1261 1261
 /**
@@ -1264,16 +1264,16 @@  discard block
 block discarded – undo
1264 1264
  */
1265 1265
 function smart_getModuleAdminLink($moduleName = false)
1266 1266
 {
1267
-    global $xoopsModule;
1268
-    if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1269
-        $moduleName = $xoopsModule->getVar('dirname');
1270
-    }
1271
-    $ret = '';
1272
-    if ($moduleName) {
1273
-        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1274
-    }
1275
-
1276
-    return $ret;
1267
+	global $xoopsModule;
1268
+	if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1269
+		$moduleName = $xoopsModule->getVar('dirname');
1270
+	}
1271
+	$ret = '';
1272
+	if ($moduleName) {
1273
+		$ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1274
+	}
1275
+
1276
+	return $ret;
1277 1277
 }
1278 1278
 
1279 1279
 /**
@@ -1281,19 +1281,19 @@  discard block
 block discarded – undo
1281 1281
  */
1282 1282
 function smart_getEditors()
1283 1283
 {
1284
-    $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1285
-    if (!file_exists($filename)) {
1286
-        return false;
1287
-    }
1288
-    include_once $filename;
1289
-    $xoopseditorHandler = XoopsEditorHandler::getInstance();
1290
-    $aList               = $xoopseditorHandler->getList();
1291
-    $ret                 = array();
1292
-    foreach ($aList as $k => $v) {
1293
-        $ret[$v] = $k;
1294
-    }
1295
-
1296
-    return $ret;
1284
+	$filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1285
+	if (!file_exists($filename)) {
1286
+		return false;
1287
+	}
1288
+	include_once $filename;
1289
+	$xoopseditorHandler = XoopsEditorHandler::getInstance();
1290
+	$aList               = $xoopseditorHandler->getList();
1291
+	$ret                 = array();
1292
+	foreach ($aList as $k => $v) {
1293
+		$ret[$v] = $k;
1294
+	}
1295
+
1296
+	return $ret;
1297 1297
 }
1298 1298
 
1299 1299
 /**
@@ -1303,11 +1303,11 @@  discard block
 block discarded – undo
1303 1303
  */
1304 1304
 function smart_getTablesArray($moduleName, $items)
1305 1305
 {
1306
-    $ret = array();
1307
-    foreach ($items as $item) {
1308
-        $ret[] = $moduleName . '_' . $item;
1309
-    }
1310
-    $ret[] = $moduleName . '_meta';
1306
+	$ret = array();
1307
+	foreach ($items as $item) {
1308
+		$ret[] = $moduleName . '_' . $item;
1309
+	}
1310
+	$ret[] = $moduleName . '_meta';
1311 1311
 
1312
-    return $ret;
1312
+	return $ret;
1313 1313
 }
Please login to merge, or discard this patch.
admin/rating.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
 
12 12
 function editclass($showmenu = false, $ratingid = 0)
13 13
 {
14
-    global $smartobjectRatingHandler;
15
-
16
-    $ratingObj = $smartobjectRatingHandler->get($ratingid);
17
-
18
-    if (!$ratingObj->isNew()) {
19
-        if ($showmenu) {
20
-            //smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _AM_SOBJECT_EDITING);
21
-        }
22
-        smart_collapsableBar('ratingedit', _AM_SOBJECT_RATINGS_EDIT, _AM_SOBJECT_RATINGS_EDIT_INFO);
23
-
24
-        $sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_EDIT, 'addrating');
25
-        $sform->display();
26
-        smart_close_collapsable('ratingedit');
27
-    } else {
28
-        $ratingObj->hideFieldFromForm(array('item', 'itemid', 'uid', 'date', 'rate'));
29
-
30
-        if (isset($_POST['op'])) {
31
-            $controller = new SmartObjectController($smartobjectRatingHandler);
32
-            $controller->postDataToObject($ratingObj);
33
-
34
-            if ($_POST['op'] === 'changedField') {
35
-                switch ($_POST['changedField']) {
36
-                    case 'dirname':
37
-                        $ratingObj->showFieldOnForm(array('item', 'itemid', 'uid', 'date', 'rate'));
38
-                        break;
39
-                }
40
-            }
41
-        }
42
-
43
-        if ($showmenu) {
44
-            //smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _CO_SOBJECT_CREATINGNEW);
45
-        }
46
-
47
-        smart_collapsableBar('ratingcreate', _AM_SOBJECT_RATINGS_CREATE, _AM_SOBJECT_RATINGS_CREATE_INFO);
48
-        $sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_CREATE, 'addrating');
49
-        $sform->display();
50
-        smart_close_collapsable('ratingcreate');
51
-    }
14
+	global $smartobjectRatingHandler;
15
+
16
+	$ratingObj = $smartobjectRatingHandler->get($ratingid);
17
+
18
+	if (!$ratingObj->isNew()) {
19
+		if ($showmenu) {
20
+			//smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _AM_SOBJECT_EDITING);
21
+		}
22
+		smart_collapsableBar('ratingedit', _AM_SOBJECT_RATINGS_EDIT, _AM_SOBJECT_RATINGS_EDIT_INFO);
23
+
24
+		$sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_EDIT, 'addrating');
25
+		$sform->display();
26
+		smart_close_collapsable('ratingedit');
27
+	} else {
28
+		$ratingObj->hideFieldFromForm(array('item', 'itemid', 'uid', 'date', 'rate'));
29
+
30
+		if (isset($_POST['op'])) {
31
+			$controller = new SmartObjectController($smartobjectRatingHandler);
32
+			$controller->postDataToObject($ratingObj);
33
+
34
+			if ($_POST['op'] === 'changedField') {
35
+				switch ($_POST['changedField']) {
36
+					case 'dirname':
37
+						$ratingObj->showFieldOnForm(array('item', 'itemid', 'uid', 'date', 'rate'));
38
+						break;
39
+				}
40
+			}
41
+		}
42
+
43
+		if ($showmenu) {
44
+			//smart_adminMenu(4, _AM_SOBJECT_RATINGS . " > " . _CO_SOBJECT_CREATINGNEW);
45
+		}
46
+
47
+		smart_collapsableBar('ratingcreate', _AM_SOBJECT_RATINGS_CREATE, _AM_SOBJECT_RATINGS_CREATE_INFO);
48
+		$sform = $ratingObj->getForm(_AM_SOBJECT_RATINGS_CREATE, 'addrating');
49
+		$sform->display();
50
+		smart_close_collapsable('ratingcreate');
51
+	}
52 52
 }
53 53
 
54 54
 include_once __DIR__ . '/admin_header.php';
@@ -60,60 +60,60 @@  discard block
 block discarded – undo
60 60
 $op = '';
61 61
 
62 62
 if (isset($_GET['op'])) {
63
-    $op = $_GET['op'];
63
+	$op = $_GET['op'];
64 64
 }
65 65
 if (isset($_POST['op'])) {
66
-    $op = $_POST['op'];
66
+	$op = $_POST['op'];
67 67
 }
68 68
 
69 69
 switch ($op) {
70
-    case 'mod':
71
-    case 'changedField';
70
+	case 'mod':
71
+	case 'changedField';
72 72
 
73
-        $ratingid = isset($_GET['ratingid']) ? (int)$_GET['ratingid'] : 0;
73
+		$ratingid = isset($_GET['ratingid']) ? (int)$_GET['ratingid'] : 0;
74 74
 
75
-        smart_xoops_cp_header();
76
-        echo $indexAdmin->addNavigation(basename(__FILE__));
75
+		smart_xoops_cp_header();
76
+		echo $indexAdmin->addNavigation(basename(__FILE__));
77 77
 
78
-        editclass(true, $ratingid);
79
-        break;
78
+		editclass(true, $ratingid);
79
+		break;
80 80
 
81
-    case 'addrating':
82
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
83
-        $controller = new SmartObjectController($smartobjectRatingHandler);
84
-        $controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php');
81
+	case 'addrating':
82
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
83
+		$controller = new SmartObjectController($smartobjectRatingHandler);
84
+		$controller->storeFromDefaultForm(_AM_SOBJECT_RATINGS_CREATED, _AM_SOBJECT_RATINGS_MODIFIED, SMARTOBJECT_URL . 'admin/rating.php');
85 85
 
86
-        break;
86
+		break;
87 87
 
88
-    case 'del':
89
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
90
-        $controller = new SmartObjectController($smartobjectRatingHandler);
91
-        $controller->handleObjectDeletion();
88
+	case 'del':
89
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
90
+		$controller = new SmartObjectController($smartobjectRatingHandler);
91
+		$controller->handleObjectDeletion();
92 92
 
93
-        break;
93
+		break;
94 94
 
95
-    default:
95
+	default:
96 96
 
97
-        smart_xoops_cp_header();
98
-        echo $indexAdmin->addNavigation(basename(__FILE__));
97
+		smart_xoops_cp_header();
98
+		echo $indexAdmin->addNavigation(basename(__FILE__));
99 99
 
100
-        //smart_adminMenu(4, _AM_SOBJECT_RATINGS);
100
+		//smart_adminMenu(4, _AM_SOBJECT_RATINGS);
101 101
 
102
-        smart_collapsableBar('createdratings', _AM_SOBJECT_RATINGS, _AM_SOBJECT_RATINGS_DSC);
102
+		smart_collapsableBar('createdratings', _AM_SOBJECT_RATINGS, _AM_SOBJECT_RATINGS_DSC);
103 103
 
104
-        include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
105
-        $objectTable = new SmartObjectTable($smartobjectRatingHandler);
106
-        $objectTable->addColumn(new SmartObjectColumn('name', 'left'));
107
-        $objectTable->addColumn(new SmartObjectColumn('dirname', 'left'));
108
-        $objectTable->addColumn(new SmartObjectColumn('item', 'left', false, 'getItemValue'));
109
-        $objectTable->addColumn(new SmartObjectColumn('date', 'center', 150));
110
-        $objectTable->addColumn(new SmartObjectColumn('rate', 'center', 40, 'getRateValue'));
104
+		include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
105
+		$objectTable = new SmartObjectTable($smartobjectRatingHandler);
106
+		$objectTable->addColumn(new SmartObjectColumn('name', 'left'));
107
+		$objectTable->addColumn(new SmartObjectColumn('dirname', 'left'));
108
+		$objectTable->addColumn(new SmartObjectColumn('item', 'left', false, 'getItemValue'));
109
+		$objectTable->addColumn(new SmartObjectColumn('date', 'center', 150));
110
+		$objectTable->addColumn(new SmartObjectColumn('rate', 'center', 40, 'getRateValue'));
111 111
 
112
-        //      $objectTable->addCustomAction('getCreateItemLink');
113
-        //      $objectTable->addCustomAction('getCreateAttributLink');
112
+		//      $objectTable->addCustomAction('getCreateItemLink');
113
+		//      $objectTable->addCustomAction('getCreateAttributLink');
114 114
 
115
-        $objectTable->addIntroButton('addrating', 'rating.php?op=mod', _AM_SOBJECT_RATINGS_CREATE);
116
-        /*
115
+		$objectTable->addIntroButton('addrating', 'rating.php?op=mod', _AM_SOBJECT_RATINGS_CREATE);
116
+		/*
117 117
                 $criteria_upcoming = new CriteriaCompo();
118 118
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
119 119
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
                 ));
139 139
         */
140 140
 
141
-        $objectTable->render();
141
+		$objectTable->render();
142 142
 
143
-        echo '<br />';
144
-        smart_close_collapsable('createdratings');
145
-        echo '<br>';
143
+		echo '<br />';
144
+		smart_close_collapsable('createdratings');
145
+		echo '<br>';
146 146
 
147
-        break;
147
+		break;
148 148
 }
149 149
 
150 150
 //smart_modFooter();
Please login to merge, or discard this patch.
admin/adsense.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@  discard block
 block discarded – undo
12 12
 
13 13
 function editclass($showmenu = false, $adsenseid = 0, $clone = false)
14 14
 {
15
-    global $smartobjectAdsenseHandler;
16
-
17
-    $adsenseObj = $smartobjectAdsenseHandler->get($adsenseid);
18
-
19
-    if (!$clone && !$adsenseObj->isNew()) {
20
-        if ($showmenu) {
21
-            //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING);
22
-        }
23
-        smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO);
24
-
25
-        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense');
26
-        $sform->display();
27
-        smart_close_collapsable('adsenseedit');
28
-    } else {
29
-        $adsenseObj->setVar('adsenseid', 0);
30
-        $adsenseObj->setVar('tag', '');
31
-
32
-        if ($showmenu) {
33
-            //smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW);
34
-        }
35
-
36
-        smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO);
37
-        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true);
38
-        $sform->display();
39
-        smart_close_collapsable('adsensecreate');
40
-    }
15
+	global $smartobjectAdsenseHandler;
16
+
17
+	$adsenseObj = $smartobjectAdsenseHandler->get($adsenseid);
18
+
19
+	if (!$clone && !$adsenseObj->isNew()) {
20
+		if ($showmenu) {
21
+			//smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING);
22
+		}
23
+		smart_collapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO);
24
+
25
+		$sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense');
26
+		$sform->display();
27
+		smart_close_collapsable('adsenseedit');
28
+	} else {
29
+		$adsenseObj->setVar('adsenseid', 0);
30
+		$adsenseObj->setVar('tag', '');
31
+
32
+		if ($showmenu) {
33
+			//smart_adminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW);
34
+		}
35
+
36
+		smart_collapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO);
37
+		$sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true);
38
+		$sform->display();
39
+		smart_close_collapsable('adsensecreate');
40
+	}
41 41
 }
42 42
 
43 43
 include_once __DIR__ . '/admin_header.php';
@@ -50,73 +50,73 @@  discard block
 block discarded – undo
50 50
 $op = '';
51 51
 
52 52
 if (isset($_GET['op'])) {
53
-    $op = $_GET['op'];
53
+	$op = $_GET['op'];
54 54
 }
55 55
 if (isset($_POST['op'])) {
56
-    $op = $_POST['op'];
56
+	$op = $_POST['op'];
57 57
 }
58 58
 
59 59
 switch ($op) {
60
-    case 'mod':
60
+	case 'mod':
61 61
 
62
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
62
+		$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
63 63
 
64
-        smart_xoops_cp_header();
65
-        echo $indexAdmin->addNavigation(basename(__FILE__));
64
+		smart_xoops_cp_header();
65
+		echo $indexAdmin->addNavigation(basename(__FILE__));
66 66
 
67
-        editclass(true, $adsenseid);
68
-        break;
67
+		editclass(true, $adsenseid);
68
+		break;
69 69
 
70
-    case 'clone':
70
+	case 'clone':
71 71
 
72
-        $adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
72
+		$adsenseid = isset($_GET['adsenseid']) ? (int)$_GET['adsenseid'] : 0;
73 73
 
74
-        smart_xoops_cp_header();
75
-        echo $indexAdmin->addNavigation(basename(__FILE__));
74
+		smart_xoops_cp_header();
75
+		echo $indexAdmin->addNavigation(basename(__FILE__));
76 76
 
77
-        editclass(true, $adsenseid, true);
78
-        break;
77
+		editclass(true, $adsenseid, true);
78
+		break;
79 79
 
80
-    case 'addadsense':
81
-        if (@include_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
-            $xoopsCaptcha = XoopsCaptcha::instance();
83
-            if (!$xoopsCaptcha->verify()) {
84
-                redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
-                exit;
86
-            }
87
-        }
88
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
89
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
90
-        $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
91
-        break;
80
+	case 'addadsense':
81
+		if (@include_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
82
+			$xoopsCaptcha = XoopsCaptcha::instance();
83
+			if (!$xoopsCaptcha->verify()) {
84
+				redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
85
+				exit;
86
+			}
87
+		}
88
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
89
+		$controller = new SmartObjectController($smartobjectAdsenseHandler);
90
+		$controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
91
+		break;
92 92
 
93
-    case 'del':
93
+	case 'del':
94 94
 
95
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
96
-        $controller = new SmartObjectController($smartobjectAdsenseHandler);
97
-        $controller->handleObjectDeletion();
95
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
96
+		$controller = new SmartObjectController($smartobjectAdsenseHandler);
97
+		$controller->handleObjectDeletion();
98 98
 
99
-        break;
99
+		break;
100 100
 
101
-    default:
101
+	default:
102 102
 
103
-        smart_xoops_cp_header();
104
-        echo $indexAdmin->addNavigation(basename(__FILE__));
103
+		smart_xoops_cp_header();
104
+		echo $indexAdmin->addNavigation(basename(__FILE__));
105 105
 
106
-        //smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
106
+		//smart_adminMenu(3, _AM_SOBJECT_ADSENSES);
107 107
 
108
-        smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
108
+		smart_collapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
109 109
 
110
-        include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
111
-        $objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
112
-        $objectTable->addColumn(new SmartObjectColumn('description', 'left'));
113
-        $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
110
+		include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
111
+		$objectTable = new SmartObjectTable($smartobjectAdsenseHandler);
112
+		$objectTable->addColumn(new SmartObjectColumn('description', 'left'));
113
+		$objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
114 114
 
115
-        //      $objectTable->addCustomAction('getCreateItemLink');
116
-        //      $objectTable->addCustomAction('getCreateAttributLink');
115
+		//      $objectTable->addCustomAction('getCreateItemLink');
116
+		//      $objectTable->addCustomAction('getCreateAttributLink');
117 117
 
118
-        $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
119
-        /*
118
+		$objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
119
+		/*
120 120
                 $criteria_upcoming = new CriteriaCompo();
121 121
                 $criteria_upcoming->add(new Criteria('start_date', time(), '>'));
122 122
                 $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
                                             'criteria' => $criteria_last30days
141 141
                 ));
142 142
         */
143
-        $objectTable->addQuickSearch(array('title', 'summary', 'description'));
144
-        $objectTable->addCustomAction('getCloneLink');
143
+		$objectTable->addQuickSearch(array('title', 'summary', 'description'));
144
+		$objectTable->addCustomAction('getCloneLink');
145 145
 
146
-        $objectTable->render();
146
+		$objectTable->render();
147 147
 
148
-        echo '<br />';
149
-        smart_close_collapsable('createdadsenses');
150
-        echo '<br>';
148
+		echo '<br />';
149
+		smart_close_collapsable('createdadsenses');
150
+		echo '<br>';
151 151
 
152
-        break;
152
+		break;
153 153
 }
154 154
 
155 155
 //smart_modFooter();
Please login to merge, or discard this patch.
admin/tag.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,45 +12,45 @@  discard block
 block discarded – undo
12 12
 
13 13
 function edittag($tagid = 0, $language = false, $fct = false)
14 14
 {
15
-    global $smartobjectTagHandler;
16
-
17
-    $tagObj = $smartobjectTagHandler->get($tagid);
18
-
19
-    if ($tagObj->isNew()) {
20
-        $breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_TAG_CREATE;
21
-        $title                 = _AM_SOBJECT_TAG_CREATE;
22
-        $info                  = _AM_SOBJECT_TAG_CREATE_INFO;
23
-        $collaps_name          = 'tagcreate';
24
-        $form_name             = _AM_SOBJECT_TAG_CREATE;
25
-        $submit_button_caption = null;
26
-        //$tagObj->stripMultilanguageFields();
27
-    } else {
28
-        if ($language) {
29
-            $breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_TAG_EDITING_LANGUAGE;
30
-            $title                 = _AM_SOBJECT_TAG_EDIT_LANGUAGE;
31
-            $info                  = _AM_SOBJECT_TAG_EDIT_LANGUAGE_INFO;
32
-            $collaps_name          = 'tageditlanguage';
33
-            $form_name             = _AM_SOBJECT_TAG_EDIT_LANGUAGE;
34
-            $submit_button_caption = null;
35
-            $tagObj->makeNonMLFieldReadOnly();
36
-        } else {
37
-            $breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_EDITING;
38
-            $title                 = _AM_SOBJECT_TAG_EDIT;
39
-            $info                  = _AM_SOBJECT_TAG_EDIT_INFO;
40
-            $collaps_name          = 'tagedit';
41
-            $form_name             = _AM_SOBJECT_TAG_EDIT;
42
-            $submit_button_caption = null;
43
-            $tagObj->stripMultilanguageFields();
44
-        }
45
-    }
46
-
47
-    //smart_adminMenu(2, $breadcrumb);
48
-
49
-    smart_collapsableBar($collaps_name, $title, $info);
50
-
51
-    $sform = $tagObj->getForm($form_name, 'addtag', false, $submit_button_caption);
52
-    $sform->display();
53
-    smart_close_collapsable($collaps_name);
15
+	global $smartobjectTagHandler;
16
+
17
+	$tagObj = $smartobjectTagHandler->get($tagid);
18
+
19
+	if ($tagObj->isNew()) {
20
+		$breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_TAG_CREATE;
21
+		$title                 = _AM_SOBJECT_TAG_CREATE;
22
+		$info                  = _AM_SOBJECT_TAG_CREATE_INFO;
23
+		$collaps_name          = 'tagcreate';
24
+		$form_name             = _AM_SOBJECT_TAG_CREATE;
25
+		$submit_button_caption = null;
26
+		//$tagObj->stripMultilanguageFields();
27
+	} else {
28
+		if ($language) {
29
+			$breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_TAG_EDITING_LANGUAGE;
30
+			$title                 = _AM_SOBJECT_TAG_EDIT_LANGUAGE;
31
+			$info                  = _AM_SOBJECT_TAG_EDIT_LANGUAGE_INFO;
32
+			$collaps_name          = 'tageditlanguage';
33
+			$form_name             = _AM_SOBJECT_TAG_EDIT_LANGUAGE;
34
+			$submit_button_caption = null;
35
+			$tagObj->makeNonMLFieldReadOnly();
36
+		} else {
37
+			$breadcrumb            = _AM_SOBJECT_TAGS . ' > ' . _AM_SOBJECT_EDITING;
38
+			$title                 = _AM_SOBJECT_TAG_EDIT;
39
+			$info                  = _AM_SOBJECT_TAG_EDIT_INFO;
40
+			$collaps_name          = 'tagedit';
41
+			$form_name             = _AM_SOBJECT_TAG_EDIT;
42
+			$submit_button_caption = null;
43
+			$tagObj->stripMultilanguageFields();
44
+		}
45
+	}
46
+
47
+	//smart_adminMenu(2, $breadcrumb);
48
+
49
+	smart_collapsableBar($collaps_name, $title, $info);
50
+
51
+	$sform = $tagObj->getForm($form_name, 'addtag', false, $submit_button_caption);
52
+	$sform->display();
53
+	smart_close_collapsable($collaps_name);
54 54
 }
55 55
 
56 56
 include_once __DIR__ . '/admin_header.php';
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 $op = '';
63 63
 
64 64
 if (isset($_GET['op'])) {
65
-    $op = $_GET['op'];
65
+	$op = $_GET['op'];
66 66
 }
67 67
 if (isset($_POST['op'])) {
68
-    $op = $_POST['op'];
68
+	$op = $_POST['op'];
69 69
 }
70 70
 
71 71
 $tagid    = isset($_GET['tagid']) ? $_GET['tagid'] : 0;
@@ -74,66 +74,66 @@  discard block
 block discarded – undo
74 74
 
75 75
 switch ($op) {
76 76
 
77
-    case 'del':
78
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
79
-        $controller = new SmartObjectController($smartobjectTagHandler);
80
-        $controller->handleObjectDeletion(_AM_SOBJECT_TAG_DELETE_CONFIRM);
77
+	case 'del':
78
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
79
+		$controller = new SmartObjectController($smartobjectTagHandler);
80
+		$controller->handleObjectDeletion(_AM_SOBJECT_TAG_DELETE_CONFIRM);
81 81
 
82
-        break;
82
+		break;
83 83
 
84
-    case 'addtag':
85
-        include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
86
-        $controller = new SmartObjectController($smartobjectTagHandler);
87
-        $tagObj     = $controller->storeSmartObject();
88
-        if ($tagObj->hasError()) {
89
-            redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $tagObj->getHtmlErrors());
90
-            exit;
91
-        }
84
+	case 'addtag':
85
+		include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
86
+		$controller = new SmartObjectController($smartobjectTagHandler);
87
+		$tagObj     = $controller->storeSmartObject();
88
+		if ($tagObj->hasError()) {
89
+			redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $tagObj->getHtmlErrors());
90
+			exit;
91
+		}
92 92
 
93
-        if ($tagObj->hasError()) {
94
-            redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $tagObj->getHtmlErrors());
95
-        } else {
96
-            redirect_header(smart_get_page_before_form(), 3, _CO_SOBJECT_SAVE_SUCCESS);
97
-        }
98
-        exit;
99
-        break;
93
+		if ($tagObj->hasError()) {
94
+			redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $tagObj->getHtmlErrors());
95
+		} else {
96
+			redirect_header(smart_get_page_before_form(), 3, _CO_SOBJECT_SAVE_SUCCESS);
97
+		}
98
+		exit;
99
+		break;
100 100
 
101
-    case 'mod':
102
-        smart_xoops_cp_header();
103
-        edittag($tagid, $language, $fct);
104
-        break;
101
+	case 'mod':
102
+		smart_xoops_cp_header();
103
+		edittag($tagid, $language, $fct);
104
+		break;
105 105
 
106
-    default:
106
+	default:
107 107
 
108
-        smart_xoops_cp_header();
108
+		smart_xoops_cp_header();
109 109
 
110
-        //smart_adminMenu(2, _AM_SOBJECT_TAGS);
110
+		//smart_adminMenu(2, _AM_SOBJECT_TAGS);
111 111
 
112
-        smart_collapsableBar('tags', _AM_SOBJECT_TAGS, _AM_SOBJECT_TAGS_INFO);
112
+		smart_collapsableBar('tags', _AM_SOBJECT_TAGS, _AM_SOBJECT_TAGS_INFO);
113 113
 
114
-        include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
115
-        $objectTable = new SmartObjectTable($smartobjectTagHandler, false, array('delete'));
116
-        $objectTable->addColumn(new SmartObjectColumn('name'));
117
-        $objectTable->addColumn(new SmartObjectColumn('language'));
118
-        $objectTable->addColumn(new SmartObjectColumn('value'));
119
-        //      $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_TAGS_FROM, $align='left', $width=false, 'getFromInfo'));
114
+		include_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
115
+		$objectTable = new SmartObjectTable($smartobjectTagHandler, false, array('delete'));
116
+		$objectTable->addColumn(new SmartObjectColumn('name'));
117
+		$objectTable->addColumn(new SmartObjectColumn('language'));
118
+		$objectTable->addColumn(new SmartObjectColumn('value'));
119
+		//      $objectTable->addColumn(new SmartObjectColumn(_AM_SOBJECT_SENT_TAGS_FROM, $align='left', $width=false, 'getFromInfo'));
120 120
 
121
-        $objectTable->addFilter('language', 'getLanguages');
121
+		$objectTable->addFilter('language', 'getLanguages');
122 122
 
123
-        $objectTable->addCustomAction('getEditLanguageLink');
124
-        $objectTable->addCustomAction('getEditItemLink');
123
+		$objectTable->addCustomAction('getEditLanguageLink');
124
+		$objectTable->addCustomAction('getEditItemLink');
125 125
 
126
-        $objectTable->setDefaultSort('tagid');
126
+		$objectTable->setDefaultSort('tagid');
127 127
 
128
-        $objectTable->addIntroButton('addtag', 'tag.php?op=mod', _AM_SOBJECT_TAG_CREATE);
128
+		$objectTable->addIntroButton('addtag', 'tag.php?op=mod', _AM_SOBJECT_TAG_CREATE);
129 129
 
130
-        $objectTable->render();
130
+		$objectTable->render();
131 131
 
132
-        echo '<br />';
133
-        smart_close_collapsable('tags');
134
-        echo '<br>';
132
+		echo '<br />';
133
+		smart_close_collapsable('tags');
134
+		echo '<br>';
135 135
 
136
-        break;
136
+		break;
137 137
 }
138 138
 
139 139
 //smart_modFooter();
Please login to merge, or discard this patch.