Completed
Push — master ( 01b1a5...81f493 )
by Michael
04:03
created
class/form/elements/smartformcheckelement.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,41 +7,41 @@  discard block
 block discarded – undo
7 7
  */
8 8
 class SmartFormCheckElement extends XoopsFormCheckBox
9 9
 {
10
-    /**
11
-     *
12
-     * /**
13
-     * prepare HTML for output
14
-     *
15
-     * @return string
16
-     */
17
-    public function render()
18
-    {
19
-        $ret = '';
20
-        if (count($this->getOptions()) > 1 && substr($this->getName(), -2, 2) !== '[]') {
21
-            $newname = $this->getName() . '[]';
22
-            $this->setName($newname);
23
-        }
24
-        foreach ($this->getOptions() as $value => $name) {
25
-            $ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'";
26
-            if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) {
27
-                $ret .= " checked='checked'";
28
-            }
29
-            $ret .= $this->getExtra() . ' />' . $name . '<br>';
30
-        }
10
+	/**
11
+	 *
12
+	 * /**
13
+	 * prepare HTML for output
14
+	 *
15
+	 * @return string
16
+	 */
17
+	public function render()
18
+	{
19
+		$ret = '';
20
+		if (count($this->getOptions()) > 1 && substr($this->getName(), -2, 2) !== '[]') {
21
+			$newname = $this->getName() . '[]';
22
+			$this->setName($newname);
23
+		}
24
+		foreach ($this->getOptions() as $value => $name) {
25
+			$ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'";
26
+			if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) {
27
+				$ret .= " checked='checked'";
28
+			}
29
+			$ret .= $this->getExtra() . ' />' . $name . '<br>';
30
+		}
31 31
 
32
-        return $ret;
33
-    }
32
+		return $ret;
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     */
38
-    public function renderValidationJS()
39
-    {
40
-        $js .= 'var hasSelections = false;';
41
-        //sometimes, there is an implicit '[]', sometimes not
42
-        $eltname = $this->getName();
43
-        if (strpos($eltname, '[') === false) {
44
-            $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function renderValidationJS()
39
+	{
40
+		$js .= 'var hasSelections = false;';
41
+		//sometimes, there is an implicit '[]', sometimes not
42
+		$eltname = $this->getName();
43
+		if (strpos($eltname, '[') === false) {
44
+			$js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
45 45
                 if (myform['{$eltname}[]'][i].checked) {
46 46
                     hasSelections = true;
47 47
                 }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             }
50 50
             if (hasSelections == false) {
51 51
                 window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n";
52
-        } else {
53
-            $js .= "for (var i = 0; i < myform['" . $eltname . "'].length; i++) {
52
+		} else {
53
+			$js .= "for (var i = 0; i < myform['" . $eltname . "'].length; i++) {
54 54
                 if (myform['{$eltname}'][i].checked) {
55 55
                     hasSelections = true;
56 56
                 }
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
             }
59 59
             if (hasSelections == false) {
60 60
                 window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n";
61
-        }
61
+		}
62 62
 
63
-        return $js;
64
-    }
63
+		return $js;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
class/form/elements/smartformfileelement.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -5,38 +5,38 @@
 block discarded – undo
5 5
  */
6 6
 class SmartFormFileElement extends XoopsFormFile
7 7
 {
8
-    public $object;
9
-    public $key;
8
+	public $object;
9
+	public $key;
10 10
 
11
-    /**
12
-     * SmartFormFileElement constructor.
13
-     * @param string $object
14
-     * @param string $key
15
-     */
16
-    public function __construct($object, $key)
17
-    {
18
-        $this->object = $object;
19
-        $this->key    = $key;
20
-        parent::__construct($object->vars[$key]['form_caption'], $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0);
21
-        $this->setExtra(' size=50');
22
-    }
11
+	/**
12
+	 * SmartFormFileElement constructor.
13
+	 * @param string $object
14
+	 * @param string $key
15
+	 */
16
+	public function __construct($object, $key)
17
+	{
18
+		$this->object = $object;
19
+		$this->key    = $key;
20
+		parent::__construct($object->vars[$key]['form_caption'], $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0);
21
+		$this->setExtra(' size=50');
22
+	}
23 23
 
24
-    /**
25
-     * prepare HTML for output
26
-     *
27
-     * @return string HTML
28
-     */
29
-    public function render()
30
-    {
31
-        $ret = '';
32
-        if ($this->object->getVar($this->key) !== '') {
33
-            $ret .= '<div>' . _CO_SOBJECT_CURRENT_FILE . $this->object->getVar($this->key) . '</div>';
34
-        }
24
+	/**
25
+	 * prepare HTML for output
26
+	 *
27
+	 * @return string HTML
28
+	 */
29
+	public function render()
30
+	{
31
+		$ret = '';
32
+		if ($this->object->getVar($this->key) !== '') {
33
+			$ret .= '<div>' . _CO_SOBJECT_CURRENT_FILE . $this->object->getVar($this->key) . '</div>';
34
+		}
35 35
 
36
-        $ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "' />
36
+		$ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "' />
37 37
                 <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . " />
38 38
                 <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName() . "' /></div>";
39 39
 
40
-        return $ret;
41
-    }
40
+		return $ret;
41
+	}
42 42
 }
Please login to merge, or discard this patch.
class/form/elements/smartautocompleteelement.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@
 block discarded – undo
11 11
  */
12 12
 class SmartAutocompleteElement extends XoopsFormText
13 13
 {
14
-    public $_include_file;
14
+	public $_include_file;
15 15
 
16
-    /**
17
-     * SmartAutocompleteElement constructor.
18
-     * @param string $caption
19
-     * @param string $name
20
-     * @param int    $include_file
21
-     * @param int    $size
22
-     * @param string $maxlength
23
-     * @param string $value
24
-     */
25
-    public function __construct($caption, $name, $include_file, $size, $maxlength, $value = '')
26
-    {
27
-        $this->_include_file = $include_file;
28
-        parent::__construct($caption, $name, $size, $maxlength, $value);
29
-    }
16
+	/**
17
+	 * SmartAutocompleteElement constructor.
18
+	 * @param string $caption
19
+	 * @param string $name
20
+	 * @param int    $include_file
21
+	 * @param int    $size
22
+	 * @param string $maxlength
23
+	 * @param string $value
24
+	 */
25
+	public function __construct($caption, $name, $include_file, $size, $maxlength, $value = '')
26
+	{
27
+		$this->_include_file = $include_file;
28
+		parent::__construct($caption, $name, $size, $maxlength, $value);
29
+	}
30 30
 
31
-    /**
32
-     * Prepare HTML for output
33
-     *
34
-     * @return string HTML
35
-     */
36
-    public function render()
37
-    {
38
-        $ret = "<input type='text' name='" .
39
-               $this->getName() .
40
-               "' id='" .
41
-               $this->getName() .
42
-               "' size='" .
43
-               $this->getSize() .
44
-               "' maxlength='" .
45
-               $this->getMaxlength() .
46
-               "' value='" .
47
-               $this->getValue() .
48
-               "'" .
49
-               $this->getExtra() .
50
-               ' />';
31
+	/**
32
+	 * Prepare HTML for output
33
+	 *
34
+	 * @return string HTML
35
+	 */
36
+	public function render()
37
+	{
38
+		$ret = "<input type='text' name='" .
39
+			   $this->getName() .
40
+			   "' id='" .
41
+			   $this->getName() .
42
+			   "' size='" .
43
+			   $this->getSize() .
44
+			   "' maxlength='" .
45
+			   $this->getMaxlength() .
46
+			   "' value='" .
47
+			   $this->getValue() .
48
+			   "'" .
49
+			   $this->getExtra() .
50
+			   ' />';
51 51
 
52
-        $ret .= '   <div class="smartobject_autocomplete_hint" id="smartobject_autocomplete_hint' . $this->getName() . '"></div>
52
+		$ret .= '   <div class="smartobject_autocomplete_hint" id="smartobject_autocomplete_hint' . $this->getName() . '"></div>
53 53
 
54 54
     <script type="text/javascript">
55 55
         new Ajax.Autocompleter("' . $this->getName() . '","smartobject_autocomplete_hint' . $this->getName() . '","' . $this->_include_file . '?key=' . $this->getName() . '");
56 56
     </script>';
57 57
 
58
-        return $ret;
59
-    }
58
+		return $ret;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
class/form/elements/smartformimageelement.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormImageElement extends XoopsFormElementTray
13 13
 {
14
-    /**
15
-     * SmartFormImageElement constructor.
16
-     * @param string $object
17
-     * @param string $key
18
-     */
19
-    public function __construct($object, $key)
20
-    {
21
-        $var             = $object->vars[$key];
22
-        $object_imageurl = $object->getImageDir();
23
-        parent::__construct($var['form_caption'], ' ');
14
+	/**
15
+	 * SmartFormImageElement constructor.
16
+	 * @param string $object
17
+	 * @param string $key
18
+	 */
19
+	public function __construct($object, $key)
20
+	{
21
+		$var             = $object->vars[$key];
22
+		$object_imageurl = $object->getImageDir();
23
+		parent::__construct($var['form_caption'], ' ');
24 24
 
25
-        $objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']);
25
+		$objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']);
26 26
 
27
-        if ($object->getVar($key) !== '' && (0 === strpos($object->getVar($key), 'http') || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) {
28
-            $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt='' /><br><br>"));
29
-        } elseif ($object->getVar($key) !== '') {
30
-            $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt='' /><br><br>"));
31
-        }
27
+		if ($object->getVar($key) !== '' && (0 === strpos($object->getVar($key), 'http') || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) {
28
+			$this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt='' /><br><br>"));
29
+		} elseif ($object->getVar($key) !== '') {
30
+			$this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt='' /><br><br>"));
31
+		}
32 32
 
33
-        include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php';
34
-        $this->addElement(new SmartFormFileUploadElement($object, $key));
33
+		include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php';
34
+		$this->addElement(new SmartFormFileUploadElement($object, $key));
35 35
 
36
-        $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', ''));
37
-        include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php';
38
-        include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php';
36
+		$this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', ''));
37
+		include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php';
38
+		include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php';
39 39
 
40
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE));
41
-        $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
42
-        $this->addElement(new XoopsFormLabel('', '<br><br>'));
43
-        $delete_check = new SmartFormCheckElement('', 'delete_' . $key);
44
-        $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>');
45
-        $this->addElement($delete_check);
46
-    }
40
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE));
41
+		$this->addElement(new SmartFormTextElement($object, 'url_' . $key));
42
+		$this->addElement(new XoopsFormLabel('', '<br><br>'));
43
+		$delete_check = new SmartFormCheckElement('', 'delete_' . $key);
44
+		$delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>');
45
+		$this->addElement($delete_check);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
class/form/elements/smartformset_passwordelement.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@
 block discarded – undo
12 12
 
13 13
 class SmartFormSet_passwordElement extends XoopsFormElementTray
14 14
 {
15
-    /**
16
-     * Size of the field.
17
-     * @var int
18
-     * @access  private
19
-     */
20
-    public $_size;
15
+	/**
16
+	 * Size of the field.
17
+	 * @var int
18
+	 * @access  private
19
+	 */
20
+	public $_size;
21 21
 
22
-    /**
23
-     * Maximum length of the text
24
-     * @var int
25
-     * @access  private
26
-     */
27
-    public $_maxlength;
22
+	/**
23
+	 * Maximum length of the text
24
+	 * @var int
25
+	 * @access  private
26
+	 */
27
+	public $_maxlength;
28 28
 
29
-    /**
30
-     * Initial content of the field.
31
-     * @var string
32
-     * @access  private
33
-     */
34
-    public $_value;
29
+	/**
30
+	 * Initial content of the field.
31
+	 * @var string
32
+	 * @access  private
33
+	 */
34
+	public $_value;
35 35
 
36
-    /**
37
-     * Constructor
38
-     *
39
-     * @param string $object
40
-     * @param string $key
41
-     * @internal param string $caption Caption
42
-     * @internal param string $name "name" attribute
43
-     * @internal param int $size Size of the field
44
-     * @internal param int $maxlength Maximum length of the text
45
-     * @internal param int $value Initial value of the field.
46
-     *                          <b>Warning:</b> this is readable in cleartext in the page's source!
47
-     */
48
-    public function __construct($object, $key)
49
-    {
50
-        $var     = $object->vars[$key];
51
-        $control = $object->controls[$key];
36
+	/**
37
+	 * Constructor
38
+	 *
39
+	 * @param string $object
40
+	 * @param string $key
41
+	 * @internal param string $caption Caption
42
+	 * @internal param string $name "name" attribute
43
+	 * @internal param int $size Size of the field
44
+	 * @internal param int $maxlength Maximum length of the text
45
+	 * @internal param int $value Initial value of the field.
46
+	 *                          <b>Warning:</b> this is readable in cleartext in the page's source!
47
+	 */
48
+	public function __construct($object, $key)
49
+	{
50
+		$var     = $object->vars[$key];
51
+		$control = $object->controls[$key];
52 52
 
53
-        parent::__construct($var['form_caption'] . '<br>' . _US_TYPEPASSTWICE, ' ', $key . '_password_tray');
53
+		parent::__construct($var['form_caption'] . '<br>' . _US_TYPEPASSTWICE, ' ', $key . '_password_tray');
54 54
 
55
-        $password_box1 = new XoopsFormPassword('', $key . '1', 10, 32);
56
-        $this->addElement($password_box1);
55
+		$password_box1 = new XoopsFormPassword('', $key . '1', 10, 32);
56
+		$this->addElement($password_box1);
57 57
 
58
-        $password_box2 = new XoopsFormPassword('', $key . '2', 10, 32);
59
-        $this->addElement($password_box2);
60
-    }
58
+		$password_box2 = new XoopsFormPassword('', $key . '2', 10, 32);
59
+		$this->addElement($password_box2);
60
+	}
61 61
 }
Please login to merge, or discard this patch.
include/functions.php 1 patch
Indentation   +733 added lines, -733 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,64 +575,64 @@  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:' .
609
-                               $user->getVar('email') .
610
-                               '"><img style="vertical-align: middle;" src="' .
611
-                               XOOPS_URL .
612
-                               '/images/icons/email.gif' .
613
-                               '" alt="' .
614
-                               _CO_SOBJECT_SEND_EMAIL .
615
-                               '" title="' .
616
-                               _CO_SOBJECT_SEND_EMAIL .
617
-                               '"/></a>';
618
-                $js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
619
-                $linkeduser .= ' <a href="' .
620
-                               $js .
621
-                               '"><img style="vertical-align: middle;" src="' .
622
-                               XOOPS_URL .
623
-                               '/images/icons/pm.gif' .
624
-                               '" alt="' .
625
-                               _CO_SOBJECT_SEND_PM .
626
-                               '" title="' .
627
-                               _CO_SOBJECT_SEND_PM .
628
-                               '"/></a>';
629
-            }
630
-
631
-            return $linkeduser;
632
-        }
633
-    }
634
-
635
-    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:' .
609
+							   $user->getVar('email') .
610
+							   '"><img style="vertical-align: middle;" src="' .
611
+							   XOOPS_URL .
612
+							   '/images/icons/email.gif' .
613
+							   '" alt="' .
614
+							   _CO_SOBJECT_SEND_EMAIL .
615
+							   '" title="' .
616
+							   _CO_SOBJECT_SEND_EMAIL .
617
+							   '"/></a>';
618
+				$js = "javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userid . "', 'pmlite',450,370);";
619
+				$linkeduser .= ' <a href="' .
620
+							   $js .
621
+							   '"><img style="vertical-align: middle;" src="' .
622
+							   XOOPS_URL .
623
+							   '/images/icons/pm.gif' .
624
+							   '" alt="' .
625
+							   _CO_SOBJECT_SEND_PM .
626
+							   '" title="' .
627
+							   _CO_SOBJECT_SEND_PM .
628
+							   '"/></a>';
629
+			}
630
+
631
+			return $linkeduser;
632
+		}
633
+	}
634
+
635
+	return $GLOBALS['xoopsConfig']['anonymous'];
636 636
 }
637 637
 
638 638
 /**
@@ -643,33 +643,33 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function smart_adminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1)
645 645
 {
646
-    global $xoopsModule, $xoopsConfig;
647
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
648
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
649
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
650
-    } else {
651
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
652
-    }
653
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
654
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
655
-    } else {
656
-        include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
657
-    }
658
-    $headermenu = array();
659
-    $adminmenu  = array();
660
-    include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
661
-    $tpl = new XoopsTpl();
662
-    $tpl->assign(array(
663
-                     'headermenu'      => $headermenu,
664
-                     'adminmenu'       => $adminmenu,
665
-                     'current'         => $currentoption,
666
-                     'breadcrumb'      => $breadcrumb,
667
-                     'headermenucount' => count($headermenu),
668
-                     'submenus'        => $submenus,
669
-                     'currentsub'      => $currentsub,
670
-                     'submenuscount'   => count($submenus)
671
-                 ));
672
-    $tpl->display('db:smartobject_admin_menu.tpl');
646
+	global $xoopsModule, $xoopsConfig;
647
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
648
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
649
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
650
+	} else {
651
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/modinfo.php';
652
+	}
653
+	if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php')) {
654
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/admin.php';
655
+	} else {
656
+		include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/admin.php';
657
+	}
658
+	$headermenu = array();
659
+	$adminmenu  = array();
660
+	include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/menu.php';
661
+	$tpl = new XoopsTpl();
662
+	$tpl->assign(array(
663
+					 'headermenu'      => $headermenu,
664
+					 'adminmenu'       => $adminmenu,
665
+					 'current'         => $currentoption,
666
+					 'breadcrumb'      => $breadcrumb,
667
+					 'headermenucount' => count($headermenu),
668
+					 'submenus'        => $submenus,
669
+					 'currentsub'      => $currentsub,
670
+					 'submenuscount'   => count($submenus)
671
+				 ));
672
+	$tpl->display('db:smartobject_admin_menu.tpl');
673 673
 }
674 674
 
675 675
 /**
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function smart_collapsableBar($id = '', $title = '', $dsc = '')
681 681
 {
682
-    global $xoopsModule;
683
-    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')\";>";
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
-    }
682
+	global $xoopsModule;
683
+	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')\";>";
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
 /**
@@ -695,15 +695,15 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function smart_ajaxCollapsableBar($id = '', $title = '', $dsc = '')
697 697
 {
698
-    global $xoopsModule;
699
-    $onClick = "ajaxtogglecollapse('$id')";
700
-    //$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
701
-    echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
702
-    echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
703
-    echo "<div id='" . $id . "'>";
704
-    if ($dsc !== '') {
705
-        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
706
-    }
698
+	global $xoopsModule;
699
+	$onClick = "ajaxtogglecollapse('$id')";
700
+	//$onClick = "togglecollapse('$id'); toggleIcon('" . $id . "_icon')";
701
+	echo '<h3 style="border: 1px solid; color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; " onclick="' . $onClick . '">';
702
+	echo "<img id='" . $id . "_icon' src=" . SMARTOBJECT_URL . "assets/images/close12.gif alt='' /></a>&nbsp;" . $title . '</h3>';
703
+	echo "<div id='" . $id . "'>";
704
+	if ($dsc !== '') {
705
+		echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $dsc . '</span>';
706
+	}
707 707
 }
708 708
 
709 709
 /**
@@ -730,20 +730,20 @@  discard block
 block discarded – undo
730 730
  */
731 731
 function smart_openclose_collapsable($name)
732 732
 {
733
-    $urls        = smart_getCurrentUrls();
734
-    $path        = $urls['phpself'];
735
-    $cookie_name = $path . '_smart_collaps_' . $name;
736
-    $cookie_name = str_replace('.', '_', $cookie_name);
737
-    $cookie      = smart_getCookieVar($cookie_name, '');
738
-    if ($cookie === 'none') {
739
-        echo '
733
+	$urls        = smart_getCurrentUrls();
734
+	$path        = $urls['phpself'];
735
+	$cookie_name = $path . '_smart_collaps_' . $name;
736
+	$cookie_name = str_replace('.', '_', $cookie_name);
737
+	$cookie      = smart_getCookieVar($cookie_name, '');
738
+	if ($cookie === 'none') {
739
+		echo '
740 740
                 <script type="text/javascript"><!--
741 741
                 togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon");
742 742
                     //-->
743 743
                 </script>
744 744
                 ';
745
-    }
746
-    /*  if ($cookie == 'none') {
745
+	}
746
+	/*  if ($cookie == 'none') {
747 747
      echo '
748 748
      <script type="text/javascript"><!--
749 749
      hideElement("' . $name . '");
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
  */
760 760
 function smart_close_collapsable($name)
761 761
 {
762
-    echo '</div>';
763
-    smart_openclose_collapsable($name);
764
-    echo '<br>';
762
+	echo '</div>';
763
+	smart_openclose_collapsable($name);
764
+	echo '<br>';
765 765
 }
766 766
 
767 767
 /**
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
  */
772 772
 function smart_setCookieVar($name, $value, $time = 0)
773 773
 {
774
-    if ($time == 0) {
775
-        $time = time() + 3600 * 24 * 365;
776
-        //$time = '';
777
-    }
778
-    setcookie($name, $value, $time, '/');
774
+	if ($time == 0) {
775
+		$time = time() + 3600 * 24 * 365;
776
+		//$time = '';
777
+	}
778
+	setcookie($name, $value, $time, '/');
779 779
 }
780 780
 
781 781
 /**
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
  */
786 786
 function smart_getCookieVar($name, $default = '')
787 787
 {
788
-    $name = str_replace('.', '_', $name);
789
-    if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
790
-        return $_COOKIE[$name];
791
-    } else {
792
-        return $default;
793
-    }
788
+	$name = str_replace('.', '_', $name);
789
+	if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) {
790
+		return $_COOKIE[$name];
791
+	} else {
792
+		return $default;
793
+	}
794 794
 }
795 795
 
796 796
 /**
@@ -798,25 +798,25 @@  discard block
 block discarded – undo
798 798
  */
799 799
 function smart_getCurrentUrls()
800 800
 {
801
-    $urls        = array();
802
-    $http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
803
-    $phpself     = $_SERVER['PHP_SELF'];
804
-    $httphost    = $_SERVER['HTTP_HOST'];
805
-    $querystring = $_SERVER['QUERY_STRING'];
806
-    if ($querystring !== '') {
807
-        $querystring = '?' . $querystring;
808
-    }
809
-    $currenturl           = $http . $httphost . $phpself . $querystring;
810
-    $urls                 = array();
811
-    $urls['http']         = $http;
812
-    $urls['httphost']     = $httphost;
813
-    $urls['phpself']      = $phpself;
814
-    $urls['querystring']  = $querystring;
815
-    $urls['full_phpself'] = $http . $httphost . $phpself;
816
-    $urls['full']         = $currenturl;
817
-    $urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
818
-
819
-    return $urls;
801
+	$urls        = array();
802
+	$http        = (strpos(XOOPS_URL, 'https://') === false) ? 'http://' : 'https://';
803
+	$phpself     = $_SERVER['PHP_SELF'];
804
+	$httphost    = $_SERVER['HTTP_HOST'];
805
+	$querystring = $_SERVER['QUERY_STRING'];
806
+	if ($querystring !== '') {
807
+		$querystring = '?' . $querystring;
808
+	}
809
+	$currenturl           = $http . $httphost . $phpself . $querystring;
810
+	$urls                 = array();
811
+	$urls['http']         = $http;
812
+	$urls['httphost']     = $httphost;
813
+	$urls['phpself']      = $phpself;
814
+	$urls['querystring']  = $querystring;
815
+	$urls['full_phpself'] = $http . $httphost . $phpself;
816
+	$urls['full']         = $currenturl;
817
+	$urls['isHomePage']   = (XOOPS_URL . '/index.php') == ($http . $httphost . $phpself);
818
+
819
+	return $urls;
820 820
 }
821 821
 
822 822
 /**
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
  */
825 825
 function smart_getCurrentPage()
826 826
 {
827
-    $urls = smart_getCurrentUrls();
827
+	$urls = smart_getCurrentUrls();
828 828
 
829
-    return $urls['full'];
829
+	return $urls['full'];
830 830
 }
831 831
 
832 832
 /**
@@ -889,39 +889,39 @@  discard block
 block discarded – undo
889 889
  */
890 890
 function smart_modFooter()
891 891
 {
892
-    global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
893
-
894
-    include_once XOOPS_ROOT_PATH . '/class/template.php';
895
-    $tpl = new XoopsTpl();
896
-
897
-    $hModule      = xoops_getHandler('module');
898
-    $versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
899
-    $modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
900
-    $modfooter    = "<a href='" .
901
-                    $versioninfo->getInfo('support_site_url') .
902
-                    "' target='_blank'><img src='" .
903
-                    XOOPS_URL .
904
-                    '/modules/' .
905
-                    $xoopsModule->getVar('dirname') .
906
-                    "/assets/images/cssbutton.gif' title='" .
907
-                    $modfootertxt .
908
-                    "' alt='" .
909
-                    $modfootertxt .
910
-                    "'/></a>";
911
-    $tpl->assign('modfooter', $modfooter);
912
-
913
-    if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
914
-        define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?');
915
-    }
916
-    $smartobjectConfig = smart_getModuleConfig('smartobject');
917
-    $tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
918
-    $tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
892
+	global $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
893
+
894
+	include_once XOOPS_ROOT_PATH . '/class/template.php';
895
+	$tpl = new XoopsTpl();
896
+
897
+	$hModule      = xoops_getHandler('module');
898
+	$versioninfo  =& $hModule->get($xoopsModule->getVar('mid'));
899
+	$modfootertxt = 'Module ' . $versioninfo->getInfo('name') . ' - Version ' . $versioninfo->getInfo('version') . '';
900
+	$modfooter    = "<a href='" .
901
+					$versioninfo->getInfo('support_site_url') .
902
+					"' target='_blank'><img src='" .
903
+					XOOPS_URL .
904
+					'/modules/' .
905
+					$xoopsModule->getVar('dirname') .
906
+					"/assets/images/cssbutton.gif' title='" .
907
+					$modfootertxt .
908
+					"' alt='" .
909
+					$modfootertxt .
910
+					"'/></a>";
911
+	$tpl->assign('modfooter', $modfooter);
912
+
913
+	if (!defined('_AM_SOBJECT_XOOPS_PRO')) {
914
+		define('_AM_SOBJECT_XOOPS_PRO', 'Do you need help with this module ?<br>Do you need new features not yet available?');
915
+	}
916
+	$smartobjectConfig = smart_getModuleConfig('smartobject');
917
+	$tpl->assign('smartobject_enable_admin_footer', $smartobjectConfig['enable_admin_footer']);
918
+	$tpl->display(SMARTOBJECT_ROOT_PATH . 'templates/smartobject_admin_footer.html');
919 919
 }
920 920
 
921 921
 function smart_xoops_cp_footer()
922 922
 {
923
-    smart_modFooter();
924
-    xoops_cp_footer();
923
+	smart_modFooter();
924
+	xoops_cp_footer();
925 925
 }
926 926
 
927 927
 /**
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
  */
931 931
 function smart_sanitizeForCommonTags($text)
932 932
 {
933
-    global $xoopsConfig;
934
-    $text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
935
-    $text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
933
+	global $xoopsConfig;
934
+	$text = str_replace('{X_SITENAME}', $xoopsConfig['sitename'], $text);
935
+	$text = str_replace('{X_ADMINMAIL}', $xoopsConfig['adminmail'], $text);
936 936
 
937
-    return $text;
937
+	return $text;
938 938
 }
939 939
 
940 940
 /**
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
  */
943 943
 function smart_addScript($src)
944 944
 {
945
-    echo '<script src="' . $src . '" type="text/javascript"></script>';
945
+	echo '<script src="' . $src . '" type="text/javascript"></script>';
946 946
 }
947 947
 
948 948
 /**
@@ -950,17 +950,17 @@  discard block
 block discarded – undo
950 950
  */
951 951
 function smart_addStyle($src)
952 952
 {
953
-    if ($src === 'smartobject') {
954
-        $src = SMARTOBJECT_URL . 'assets/css/module.css';
955
-    }
956
-    echo smart_get_css_link($src);
953
+	if ($src === 'smartobject') {
954
+		$src = SMARTOBJECT_URL . 'assets/css/module.css';
955
+	}
956
+	echo smart_get_css_link($src);
957 957
 }
958 958
 
959 959
 function smart_addAdminAjaxSupport()
960 960
 {
961
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
962
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
963
-    smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
961
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/lib/prototype.js');
962
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/scriptaculous.js');
963
+	smart_addScript(SMARTOBJECT_URL . 'include/scriptaculous/src/smart.js');
964 964
 }
965 965
 
966 966
 /**
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
  */
970 970
 function smart_sanitizeForSmartpopupLink($text)
971 971
 {
972
-    $patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
973
-    $replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
974
-    $ret            = preg_replace($patterns, $replacements, $text);
972
+	$patterns[]     = "/\[smartpopup=(['\"]?)([^\"'<>]*)\\1](.*)\[\/smartpopup\]/sU";
973
+	$replacements[] = "<a href=\"javascript:openWithSelfMain('\\2', 'smartpopup', 700, 519);\">\\3</a>";
974
+	$ret            = preg_replace($patterns, $replacements, $text);
975 975
 
976
-    return $ret;
976
+	return $ret;
977 977
 }
978 978
 
979 979
 /**
@@ -988,25 +988,25 @@  discard block
 block discarded – undo
988 988
  */
989 989
 function smart_getImageSize($url, & $width, & $height)
990 990
 {
991
-    if (empty($width) || empty($height)) {
992
-        if (!$dimension = @ getimagesize($url)) {
993
-            return false;
994
-        }
995
-        if (!empty($width)) {
996
-            $height = $dimension[1] * $width / $dimension[0];
997
-        } elseif (!empty($height)) {
998
-            $width = $dimension[0] * $height / $dimension[1];
999
-        } else {
1000
-            list($width, $height) = array(
1001
-                $dimension[0],
1002
-                $dimension[1]
1003
-            );
1004
-        }
1005
-
1006
-        return true;
1007
-    } else {
1008
-        return true;
1009
-    }
991
+	if (empty($width) || empty($height)) {
992
+		if (!$dimension = @ getimagesize($url)) {
993
+			return false;
994
+		}
995
+		if (!empty($width)) {
996
+			$height = $dimension[1] * $width / $dimension[0];
997
+		} elseif (!empty($height)) {
998
+			$width = $dimension[0] * $height / $dimension[1];
999
+		} else {
1000
+			list($width, $height) = array(
1001
+				$dimension[0],
1002
+				$dimension[1]
1003
+			);
1004
+		}
1005
+
1006
+		return true;
1007
+	} else {
1008
+		return true;
1009
+	}
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
  */
1020 1020
 function smart_htmlnumericentities($str)
1021 1021
 {
1022
-    //    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
1023
-    return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
1022
+	//    return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str);
1023
+	return preg_replace_callback('/[^!-%\x27-;=?-~ ]/', function ($m) { return '&#' . ord($m[0]) . chr(59); }, $str);
1024 1024
 }
1025 1025
 
1026 1026
 /**
@@ -1030,24 +1030,24 @@  discard block
 block discarded – undo
1030 1030
  */
1031 1031
 function smart_getcorehandler($name, $optional = false)
1032 1032
 {
1033
-    static $handlers;
1034
-    $name = strtolower(trim($name));
1035
-    if (!isset($handlers[$name])) {
1036
-        if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
1037
-            require_once $hnd_file;
1038
-        }
1039
-        $class = 'Xoops' . ucfirst($name) . 'Handler';
1040
-        if (class_exists($class)) {
1041
-            $handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
1042
-        }
1043
-    }
1044
-    if (!isset($handlers[$name]) && !$optional) {
1045
-        trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
1046
-    }
1047
-    if (isset($handlers[$name])) {
1048
-        return $handlers[$name];
1049
-    }
1050
-    $inst = false;
1033
+	static $handlers;
1034
+	$name = strtolower(trim($name));
1035
+	if (!isset($handlers[$name])) {
1036
+		if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/kernel/' . $name . '.php')) {
1037
+			require_once $hnd_file;
1038
+		}
1039
+		$class = 'Xoops' . ucfirst($name) . 'Handler';
1040
+		if (class_exists($class)) {
1041
+			$handlers[$name] = new $class ($GLOBALS['xoopsDB'], 'xoops');
1042
+		}
1043
+	}
1044
+	if (!isset($handlers[$name]) && !$optional) {
1045
+		trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
1046
+	}
1047
+	if (isset($handlers[$name])) {
1048
+		return $handlers[$name];
1049
+	}
1050
+	$inst = false;
1051 1051
 }
1052 1052
 
1053 1053
 /**
@@ -1056,15 +1056,15 @@  discard block
 block discarded – undo
1056 1056
  */
1057 1057
 function smart_sanitizeAdsenses_callback($matches)
1058 1058
 {
1059
-    global $smartobjectAdsenseHandler;
1060
-    if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1061
-        $adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1062
-        $ret        = $adsenseObj->render();
1063
-
1064
-        return $ret;
1065
-    } else {
1066
-        return '';
1067
-    }
1059
+	global $smartobjectAdsenseHandler;
1060
+	if (isset($smartobjectAdsenseHandler->objects[$matches[1]])) {
1061
+		$adsenseObj = $smartobjectAdsenseHandler->objects[$matches[1]];
1062
+		$ret        = $adsenseObj->render();
1063
+
1064
+		return $ret;
1065
+	} else {
1066
+		return '';
1067
+	}
1068 1068
 }
1069 1069
 
1070 1070
 /**
@@ -1073,13 +1073,13 @@  discard block
 block discarded – undo
1073 1073
  */
1074 1074
 function smart_sanitizeAdsenses($text)
1075 1075
 {
1076
-    $patterns     = array();
1077
-    $replacements = array();
1076
+	$patterns     = array();
1077
+	$replacements = array();
1078 1078
 
1079
-    $patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1080
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1079
+	$patterns[] = "/\[adsense](.*)\[\/adsense\]/sU";
1080
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeAdsenses_callback', $text);
1081 1081
 
1082
-    return $text;
1082
+	return $text;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1088,15 +1088,15 @@  discard block
 block discarded – undo
1088 1088
  */
1089 1089
 function smart_sanitizeCustomtags_callback($matches)
1090 1090
 {
1091
-    global $smartobjectCustomtagHandler;
1092
-    if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1093
-        $customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1094
-        $ret       = $customObj->renderWithPhp();
1095
-
1096
-        return $ret;
1097
-    } else {
1098
-        return '';
1099
-    }
1091
+	global $smartobjectCustomtagHandler;
1092
+	if (isset($smartobjectCustomtagHandler->objects[$matches[1]])) {
1093
+		$customObj = $smartobjectCustomtagHandler->objects[$matches[1]];
1094
+		$ret       = $customObj->renderWithPhp();
1095
+
1096
+		return $ret;
1097
+	} else {
1098
+		return '';
1099
+	}
1100 1100
 }
1101 1101
 
1102 1102
 /**
@@ -1105,13 +1105,13 @@  discard block
 block discarded – undo
1105 1105
  */
1106 1106
 function smart_sanitizeCustomtags($text)
1107 1107
 {
1108
-    $patterns     = array();
1109
-    $replacements = array();
1108
+	$patterns     = array();
1109
+	$replacements = array();
1110 1110
 
1111
-    $patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1112
-    $text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1111
+	$patterns[] = "/\[customtag](.*)\[\/customtag\]/sU";
1112
+	$text       = preg_replace_callback($patterns, 'smart_sanitizeCustomtags_callback', $text);
1113 1113
 
1114
-    return $text;
1114
+	return $text;
1115 1115
 }
1116 1116
 
1117 1117
 /**
@@ -1120,20 +1120,20 @@  discard block
 block discarded – undo
1120 1120
  */
1121 1121
 function smart_loadLanguageFile($module, $file)
1122 1122
 {
1123
-    global $xoopsConfig;
1124
-
1125
-    $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1126
-    if (!file_exists($filename)) {
1127
-        $filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1128
-    }
1129
-    if (file_exists($filename)) {
1130
-        include_once($filename);
1131
-    }
1123
+	global $xoopsConfig;
1124
+
1125
+	$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/' . $xoopsConfig['language'] . '/' . $file . '.php';
1126
+	if (!file_exists($filename)) {
1127
+		$filename = XOOPS_ROOT_PATH . '/modules/' . $module . '/language/english/' . $file . '.php';
1128
+	}
1129
+	if (file_exists($filename)) {
1130
+		include_once($filename);
1131
+	}
1132 1132
 }
1133 1133
 
1134 1134
 function smart_loadCommonLanguageFile()
1135 1135
 {
1136
-    smart_loadLanguageFile('smartobject', 'common');
1136
+	smart_loadLanguageFile('smartobject', 'common');
1137 1137
 }
1138 1138
 
1139 1139
 /**
@@ -1143,35 +1143,35 @@  discard block
 block discarded – undo
1143 1143
  */
1144 1144
 function smart_purifyText($text, $keyword = false)
1145 1145
 {
1146
-    global $myts;
1147
-    $text = str_replace('&nbsp;', ' ', $text);
1148
-    $text = str_replace('<br>', ' ', $text);
1149
-    $text = str_replace('<br>', ' ', $text);
1150
-    $text = str_replace('<br', ' ', $text);
1151
-    $text = strip_tags($text);
1152
-    $text = html_entity_decode($text);
1153
-    $text = $myts->undoHtmlSpecialChars($text);
1154
-    $text = str_replace(')', ' ', $text);
1155
-    $text = str_replace('(', ' ', $text);
1156
-    $text = str_replace(':', ' ', $text);
1157
-    $text = str_replace('&euro', ' euro ', $text);
1158
-    $text = str_replace('&hellip', '...', $text);
1159
-    $text = str_replace('&rsquo', ' ', $text);
1160
-    $text = str_replace('!', ' ', $text);
1161
-    $text = str_replace('?', ' ', $text);
1162
-    $text = str_replace('"', ' ', $text);
1163
-    $text = str_replace('-', ' ', $text);
1164
-    $text = str_replace('\n', ' ', $text);
1165
-    $text = str_replace('&#8213;', ' ', $text);
1166
-
1167
-    if ($keyword) {
1168
-        $text = str_replace('.', ' ', $text);
1169
-        $text = str_replace(',', ' ', $text);
1170
-        $text = str_replace('\'', ' ', $text);
1171
-    }
1172
-    $text = str_replace(';', ' ', $text);
1173
-
1174
-    return $text;
1146
+	global $myts;
1147
+	$text = str_replace('&nbsp;', ' ', $text);
1148
+	$text = str_replace('<br>', ' ', $text);
1149
+	$text = str_replace('<br>', ' ', $text);
1150
+	$text = str_replace('<br', ' ', $text);
1151
+	$text = strip_tags($text);
1152
+	$text = html_entity_decode($text);
1153
+	$text = $myts->undoHtmlSpecialChars($text);
1154
+	$text = str_replace(')', ' ', $text);
1155
+	$text = str_replace('(', ' ', $text);
1156
+	$text = str_replace(':', ' ', $text);
1157
+	$text = str_replace('&euro', ' euro ', $text);
1158
+	$text = str_replace('&hellip', '...', $text);
1159
+	$text = str_replace('&rsquo', ' ', $text);
1160
+	$text = str_replace('!', ' ', $text);
1161
+	$text = str_replace('?', ' ', $text);
1162
+	$text = str_replace('"', ' ', $text);
1163
+	$text = str_replace('-', ' ', $text);
1164
+	$text = str_replace('\n', ' ', $text);
1165
+	$text = str_replace('&#8213;', ' ', $text);
1166
+
1167
+	if ($keyword) {
1168
+		$text = str_replace('.', ' ', $text);
1169
+		$text = str_replace(',', ' ', $text);
1170
+		$text = str_replace('\'', ' ', $text);
1171
+	}
1172
+	$text = str_replace(';', ' ', $text);
1173
+
1174
+	return $text;
1175 1175
 }
1176 1176
 
1177 1177
 /**
@@ -1180,49 +1180,49 @@  discard block
 block discarded – undo
1180 1180
  */
1181 1181
 function smart_html2text($document)
1182 1182
 {
1183
-    // PHP Manual:: function preg_replace
1184
-    // $document should contain an HTML document.
1185
-    // This will remove HTML tags, javascript sections
1186
-    // and white space. It will also convert some
1187
-    // common HTML entities to their text equivalent.
1188
-    // Credits: newbb2
1189
-    $search = array(
1190
-        "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1191
-        "'<img.*?/>'si",       // Strip out img tags
1192
-        "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1193
-        "'([\r\n])[\s]+'",                // Strip out white space
1194
-        "'&(quot|#34);'i",                // Replace HTML entities
1195
-        "'&(amp|#38);'i",
1196
-        "'&(lt|#60);'i",
1197
-        "'&(gt|#62);'i",
1198
-        "'&(nbsp|#160);'i",
1199
-        "'&(iexcl|#161);'i",
1200
-        "'&(cent|#162);'i",
1201
-        "'&(pound|#163);'i",
1202
-        "'&(copy|#169);'i",
1203
-        "'&#(\d+);'e"
1204
-    );                    // evaluate as php
1205
-
1206
-    $replace = array(
1207
-        '',
1208
-        '',
1209
-        '',
1210
-        "\\1",
1211
-        "\"",
1212
-        '&',
1213
-        '<',
1214
-        '>',
1215
-        ' ',
1216
-        chr(161),
1217
-        chr(162),
1218
-        chr(163),
1219
-        chr(169),
1220
-        "chr(\\1)"
1221
-    );
1222
-
1223
-    $text = preg_replace($search, $replace, $document);
1224
-
1225
-    return $text;
1183
+	// PHP Manual:: function preg_replace
1184
+	// $document should contain an HTML document.
1185
+	// This will remove HTML tags, javascript sections
1186
+	// and white space. It will also convert some
1187
+	// common HTML entities to their text equivalent.
1188
+	// Credits: newbb2
1189
+	$search = array(
1190
+		"'<script[^>]*?>.*?</script>'si",  // Strip out javascript
1191
+		"'<img.*?/>'si",       // Strip out img tags
1192
+		"'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
1193
+		"'([\r\n])[\s]+'",                // Strip out white space
1194
+		"'&(quot|#34);'i",                // Replace HTML entities
1195
+		"'&(amp|#38);'i",
1196
+		"'&(lt|#60);'i",
1197
+		"'&(gt|#62);'i",
1198
+		"'&(nbsp|#160);'i",
1199
+		"'&(iexcl|#161);'i",
1200
+		"'&(cent|#162);'i",
1201
+		"'&(pound|#163);'i",
1202
+		"'&(copy|#169);'i",
1203
+		"'&#(\d+);'e"
1204
+	);                    // evaluate as php
1205
+
1206
+	$replace = array(
1207
+		'',
1208
+		'',
1209
+		'',
1210
+		"\\1",
1211
+		"\"",
1212
+		'&',
1213
+		'<',
1214
+		'>',
1215
+		' ',
1216
+		chr(161),
1217
+		chr(162),
1218
+		chr(163),
1219
+		chr(169),
1220
+		"chr(\\1)"
1221
+	);
1222
+
1223
+	$text = preg_replace($search, $replace, $document);
1224
+
1225
+	return $text;
1226 1226
 }
1227 1227
 
1228 1228
 /**
@@ -1236,32 +1236,32 @@  discard block
 block discarded – undo
1236 1236
  */
1237 1237
 function smart_getfloat($str, $set = false)
1238 1238
 {
1239
-    if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1240
-        // Found number in $str, so set $str that number
1241
-        $str = $match[0];
1242
-        if (false !== strpos($str, ',')) {
1243
-            // A comma exists, that makes it easy, cos we assume it separates the decimal part.
1244
-            $str = str_replace('.', '', $str);    // Erase thousand seps
1245
-            $str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1246
-
1247
-            return (float)$str;
1248
-        } else {
1249
-            // No comma exists, so we have to decide, how a single dot shall be treated
1250
-            if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1251
-                // Treat single dot as decimal separator
1252
-                return (float)$str;
1253
-            } else {
1254
-                //echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> ";
1255
-                // Else, treat all dots as thousand seps
1256
-                $str = str_replace('.', '', $str);    // Erase thousand seps
1257
-
1258
-                return (float)$str;
1259
-            }
1260
-        }
1261
-    } else {
1262
-        // No number found, return zero
1263
-        return 0;
1264
-    }
1239
+	if (preg_match("/([0-9\.,-]+)/", $str, $match)) {
1240
+		// Found number in $str, so set $str that number
1241
+		$str = $match[0];
1242
+		if (false !== strpos($str, ',')) {
1243
+			// A comma exists, that makes it easy, cos we assume it separates the decimal part.
1244
+			$str = str_replace('.', '', $str);    // Erase thousand seps
1245
+			$str = str_replace(',', '.', $str);    // Convert , to . for floatval command
1246
+
1247
+			return (float)$str;
1248
+		} else {
1249
+			// No comma exists, so we have to decide, how a single dot shall be treated
1250
+			if (preg_match("/^[0-9\-]*[\.]{1}[0-9-]+$/", $str) == true && $set['single_dot_as_decimal'] == true) {
1251
+				// Treat single dot as decimal separator
1252
+				return (float)$str;
1253
+			} else {
1254
+				//echo "str: ".$str; echo "ret: ".str_replace('.', '', $str); echo "<br><br> ";
1255
+				// Else, treat all dots as thousand seps
1256
+				$str = str_replace('.', '', $str);    // Erase thousand seps
1257
+
1258
+				return (float)$str;
1259
+			}
1260
+		}
1261
+	} else {
1262
+		// No number found, return zero
1263
+		return 0;
1264
+	}
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1271,26 +1271,26 @@  discard block
 block discarded – undo
1271 1271
  */
1272 1272
 function smart_currency($var, $currencyObj = false)
1273 1273
 {
1274
-    $ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1275
-    $ret = round($ret, 2);
1276
-    // make sur we have at least .00 in the $var
1277
-    $decimal_section_original = strstr($ret, '.');
1278
-    $decimal_section          = $decimal_section_original;
1279
-    if ($decimal_section) {
1280
-        if (strlen($decimal_section) == 1) {
1281
-            $decimal_section = '.00';
1282
-        } elseif (strlen($decimal_section) == 2) {
1283
-            $decimal_section .= '0';
1284
-        }
1285
-        $ret = str_replace($decimal_section_original, $decimal_section, $ret);
1286
-    } else {
1287
-        $ret .= '.00';
1288
-    }
1289
-    if ($currencyObj) {
1290
-        $ret = $ret . ' ' . $currencyObj->getCode();
1291
-    }
1292
-
1293
-    return $ret;
1274
+	$ret = smart_getfloat($var, array('single_dot_as_decimal' => true));
1275
+	$ret = round($ret, 2);
1276
+	// make sur we have at least .00 in the $var
1277
+	$decimal_section_original = strstr($ret, '.');
1278
+	$decimal_section          = $decimal_section_original;
1279
+	if ($decimal_section) {
1280
+		if (strlen($decimal_section) == 1) {
1281
+			$decimal_section = '.00';
1282
+		} elseif (strlen($decimal_section) == 2) {
1283
+			$decimal_section .= '0';
1284
+		}
1285
+		$ret = str_replace($decimal_section_original, $decimal_section, $ret);
1286
+	} else {
1287
+		$ret .= '.00';
1288
+	}
1289
+	if ($currencyObj) {
1290
+		$ret = $ret . ' ' . $currencyObj->getCode();
1291
+	}
1292
+
1293
+	return $ret;
1294 1294
 }
1295 1295
 
1296 1296
 /**
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
  */
1300 1300
 function smart_float($var)
1301 1301
 {
1302
-    return smart_currency($var);
1302
+	return smart_currency($var);
1303 1303
 }
1304 1304
 
1305 1305
 /**
@@ -1308,16 +1308,16 @@  discard block
 block discarded – undo
1308 1308
  */
1309 1309
 function smart_getModuleAdminLink($moduleName = false)
1310 1310
 {
1311
-    global $xoopsModule;
1312
-    if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1313
-        $moduleName = $xoopsModule->getVar('dirname');
1314
-    }
1315
-    $ret = '';
1316
-    if ($moduleName) {
1317
-        $ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1318
-    }
1319
-
1320
-    return $ret;
1311
+	global $xoopsModule;
1312
+	if (!$moduleName && (isset($xoopsModule) && is_object($xoopsModule))) {
1313
+		$moduleName = $xoopsModule->getVar('dirname');
1314
+	}
1315
+	$ret = '';
1316
+	if ($moduleName) {
1317
+		$ret = "<a href='" . XOOPS_URL . "/modules/$moduleName/admin/index.php'>" . _CO_SOBJECT_ADMIN_PAGE . '</a>';
1318
+	}
1319
+
1320
+	return $ret;
1321 1321
 }
1322 1322
 
1323 1323
 /**
@@ -1325,19 +1325,19 @@  discard block
 block discarded – undo
1325 1325
  */
1326 1326
 function smart_getEditors()
1327 1327
 {
1328
-    $filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1329
-    if (!file_exists($filename)) {
1330
-        return false;
1331
-    }
1332
-    include_once $filename;
1333
-    $xoopseditorHandler = XoopsEditorHandler::getInstance();
1334
-    $aList              = $xoopseditorHandler->getList();
1335
-    $ret                = array();
1336
-    foreach ($aList as $k => $v) {
1337
-        $ret[$v] = $k;
1338
-    }
1339
-
1340
-    return $ret;
1328
+	$filename = XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php';
1329
+	if (!file_exists($filename)) {
1330
+		return false;
1331
+	}
1332
+	include_once $filename;
1333
+	$xoopseditorHandler = XoopsEditorHandler::getInstance();
1334
+	$aList              = $xoopseditorHandler->getList();
1335
+	$ret                = array();
1336
+	foreach ($aList as $k => $v) {
1337
+		$ret[$v] = $k;
1338
+	}
1339
+
1340
+	return $ret;
1341 1341
 }
1342 1342
 
1343 1343
 /**
@@ -1347,11 +1347,11 @@  discard block
 block discarded – undo
1347 1347
  */
1348 1348
 function smart_getTablesArray($moduleName, $items)
1349 1349
 {
1350
-    $ret = array();
1351
-    foreach ($items as $item) {
1352
-        $ret[] = $moduleName . '_' . $item;
1353
-    }
1354
-    $ret[] = $moduleName . '_meta';
1350
+	$ret = array();
1351
+	foreach ($items as $item) {
1352
+		$ret[] = $moduleName . '_' . $item;
1353
+	}
1354
+	$ret[] = $moduleName . '_meta';
1355 1355
 
1356
-    return $ret;
1356
+	return $ret;
1357 1357
 }
Please login to merge, or discard this patch.
include/update.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function xoops_module_update_smartobject($module)
37 37
 {
38
-    ob_start();
38
+	ob_start();
39 39
 
40
-    $dbVersion = smart_GetMeta('version', 'smartobject');
41
-    if (!$dbVersion) {
42
-        $dbVersion = 0;
43
-    }
40
+	$dbVersion = smart_GetMeta('version', 'smartobject');
41
+	if (!$dbVersion) {
42
+		$dbVersion = 0;
43
+	}
44 44
 
45
-    $dbupdater = new SmartobjectDbupdater();
45
+	$dbupdater = new SmartobjectDbupdater();
46 46
 
47
-    echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br>';
47
+	echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br>';
48 48
 
49
-    // db migrate version = 1
50
-    $newDbVersion = 1;
51
-    if ($dbVersion < $newDbVersion) {
52
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
49
+	// db migrate version = 1
50
+	$newDbVersion = 1;
51
+	if ($dbVersion < $newDbVersion) {
52
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
53 53
 
54
-        // Create table smartobject_link
55
-        $table = new SmartDbTable('smartobject_link');
56
-        if (!$table->exists()) {
57
-            $table->setStructure("CREATE TABLE %s (
54
+		// Create table smartobject_link
55
+		$table = new SmartDbTable('smartobject_link');
56
+		if (!$table->exists()) {
57
+			$table->setStructure("CREATE TABLE %s (
58 58
               `linkid` int(11) NOT NULL auto_increment,
59 59
               `from_uid` int(11) NOT NULL default '0',
60 60
               `from_email` varchar(255) NOT NULL default '',
@@ -71,63 +71,63 @@  discard block
 block discarded – undo
71 71
               PRIMARY KEY  (`linkid`)
72 72
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
73 73
 
74
-            if (!$dbupdater->updateTable($table)) {
75
-                /**
76
-                 * @todo trap the errors
77
-                 */
78
-            }
79
-        }
80
-        unset($table);
81
-        // Create table smartobject_link
82
-        $table = new SmartDbTable('smartobject_link');
83
-        if (!$table->fieldExists('date')) {
84
-            $table->addNewField('date', "int(11) NOT NULL default '0'");
85
-            if (!$dbupdater->updateTable($table)) {
86
-                /**
87
-                 * @todo trap the errors
88
-                 */
89
-            }
90
-        }
91
-        unset($table);
92
-
93
-        // Create table smartobject_tag
94
-        $table = new SmartDbTable('smartobject_tag');
95
-        if (!$table->exists()) {
96
-            $table->setStructure("CREATE TABLE %s (
74
+			if (!$dbupdater->updateTable($table)) {
75
+				/**
76
+				 * @todo trap the errors
77
+				 */
78
+			}
79
+		}
80
+		unset($table);
81
+		// Create table smartobject_link
82
+		$table = new SmartDbTable('smartobject_link');
83
+		if (!$table->fieldExists('date')) {
84
+			$table->addNewField('date', "int(11) NOT NULL default '0'");
85
+			if (!$dbupdater->updateTable($table)) {
86
+				/**
87
+				 * @todo trap the errors
88
+				 */
89
+			}
90
+		}
91
+		unset($table);
92
+
93
+		// Create table smartobject_tag
94
+		$table = new SmartDbTable('smartobject_tag');
95
+		if (!$table->exists()) {
96
+			$table->setStructure("CREATE TABLE %s (
97 97
               `tagid` int(11) NOT NULL auto_increment,
98 98
               `name` varchar(255) NOT NULL default '',
99 99
               `description` TEXT NOT NULL,
100 100
               PRIMARY KEY  (`id`)
101 101
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
102 102
 
103
-            if (!$dbupdater->updateTable($table)) {
104
-                /**
105
-                 * @todo trap the errors
106
-                 */
107
-            }
108
-        }
109
-
110
-        // Create table smartobject_tag_text
111
-        $table = new SmartDbTable('smartobject_tag_text');
112
-        if (!$table->exists()) {
113
-            $table->setStructure("CREATE TABLE %s (
103
+			if (!$dbupdater->updateTable($table)) {
104
+				/**
105
+				 * @todo trap the errors
106
+				 */
107
+			}
108
+		}
109
+
110
+		// Create table smartobject_tag_text
111
+		$table = new SmartDbTable('smartobject_tag_text');
112
+		if (!$table->exists()) {
113
+			$table->setStructure("CREATE TABLE %s (
114 114
               `tagid` int(11) NOT NULL default 0,
115 115
               `language` varchar(255) NOT NULL default '',
116 116
               `value` TEXT NOT NULL,
117 117
               PRIMARY KEY  (`id`, `language`)
118 118
             ) ENGINE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;");
119 119
 
120
-            if (!$dbupdater->updateTable($table)) {
121
-                /**
122
-                 * @todo trap the errors
123
-                 */
124
-            }
125
-        }
126
-
127
-        // Create table smartobject_adsense
128
-        $table = new SmartDbTable('smartobject_adsense');
129
-        if (!$table->exists()) {
130
-            $table->setStructure("
120
+			if (!$dbupdater->updateTable($table)) {
121
+				/**
122
+				 * @todo trap the errors
123
+				 */
124
+			}
125
+		}
126
+
127
+		// Create table smartobject_adsense
128
+		$table = new SmartDbTable('smartobject_adsense');
129
+		if (!$table->exists()) {
130
+			$table->setStructure("
131 131
   `adsenseid` int(11) NOT NULL auto_increment,
132 132
   `format` VARCHAR(100) NOT NULL,
133 133
   `description` TEXT NOT NULL,
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
   `tag` varchar(50) NOT NULL default '',
142 142
   PRIMARY KEY  (`adsenseid`)
143 143
             ");
144
-        }
145
-
146
-        if (!$dbupdater->updateTable($table)) {
147
-            /**
148
-             * @todo trap the errors
149
-             */
150
-        }
151
-    }
152
-    // db migrate version = 2
153
-    $newDbVersion = 2;
154
-    if ($dbVersion < $newDbVersion) {
155
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
156
-
157
-        // Create table smartobject_rating
158
-        $table = new SmartDbTable('smartobject_rating');
159
-        if (!$table->exists()) {
160
-            $table->setStructure('
144
+		}
145
+
146
+		if (!$dbupdater->updateTable($table)) {
147
+			/**
148
+			 * @todo trap the errors
149
+			 */
150
+		}
151
+	}
152
+	// db migrate version = 2
153
+	$newDbVersion = 2;
154
+	if ($dbVersion < $newDbVersion) {
155
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
156
+
157
+		// Create table smartobject_rating
158
+		$table = new SmartDbTable('smartobject_rating');
159
+		if (!$table->exists()) {
160
+			$table->setStructure('
161 161
   `ratingid` int(11) NOT NULL auto_increment,
162 162
   `dirname` VARCHAR(255) NOT NULL,
163 163
   `item` VARCHAR(255) NOT NULL,
@@ -168,36 +168,36 @@  discard block
 block discarded – undo
168 168
   PRIMARY KEY  (`ratingid`),
169 169
   UNIQUE (`dirname`, `item`, `itemid`, `uid`)
170 170
             ');
171
-        }
172
-
173
-        if (!$dbupdater->updateTable($table)) {
174
-            /**
175
-             * @todo trap the errors
176
-             */
177
-        }
178
-
179
-        // Create table smartobject_currency
180
-        $table = new SmartDbTable('smartobject_currency');
181
-        $table->setData("2, 'EUR', 'Euro', '�', 0.65, 0");
182
-        $table->setData("3, 'USD', 'American dollar', '$', 0.9, 0");
183
-        $table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1");
184
-
185
-        if (!$dbupdater->updateTable($table)) {
186
-            /**
187
-             * @todo trap the errors
188
-             */
189
-        }
190
-    }
191
-
192
-    // db migrate version = 3
193
-    $newDbVersion = 3;
194
-    if ($dbVersion < $newDbVersion) {
195
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
196
-
197
-        // Create table smartobject_customtag
198
-        $table = new SmartDbTable('smartobject_customtag');
199
-        if (!$table->exists()) {
200
-            $table->setStructure('
171
+		}
172
+
173
+		if (!$dbupdater->updateTable($table)) {
174
+			/**
175
+			 * @todo trap the errors
176
+			 */
177
+		}
178
+
179
+		// Create table smartobject_currency
180
+		$table = new SmartDbTable('smartobject_currency');
181
+		$table->setData("2, 'EUR', 'Euro', '�', 0.65, 0");
182
+		$table->setData("3, 'USD', 'American dollar', '$', 0.9, 0");
183
+		$table->setData("1, 'CAD', 'Canadian dollar', '$', 1, 1");
184
+
185
+		if (!$dbupdater->updateTable($table)) {
186
+			/**
187
+			 * @todo trap the errors
188
+			 */
189
+		}
190
+	}
191
+
192
+	// db migrate version = 3
193
+	$newDbVersion = 3;
194
+	if ($dbVersion < $newDbVersion) {
195
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
196
+
197
+		// Create table smartobject_customtag
198
+		$table = new SmartDbTable('smartobject_customtag');
199
+		if (!$table->exists()) {
200
+			$table->setStructure('
201 201
               `customtagid` int(11) NOT NULL auto_increment,
202 202
               `name` VARCHAR(255) NOT NULL,
203 203
               `description` TEXT NOT NULL,
@@ -205,24 +205,24 @@  discard block
 block discarded – undo
205 205
               `language` TEXT NOT NULL,
206 206
               PRIMARY KEY  (`customtagid`)
207 207
             ');
208
-        }
209
-
210
-        if (!$dbupdater->updateTable($table)) {
211
-            /**
212
-             * @todo trap the errors
213
-             */
214
-        }
215
-    }
216
-
217
-    // db migrate version = 4
218
-    $newDbVersion = 4;
219
-    if ($dbVersion < $newDbVersion) {
220
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
221
-
222
-        // Create table smartobject_currency
223
-        $table = new SmartDbTable('smartobject_currency');
224
-        if (!$table->exists()) {
225
-            $table->setStructure('
208
+		}
209
+
210
+		if (!$dbupdater->updateTable($table)) {
211
+			/**
212
+			 * @todo trap the errors
213
+			 */
214
+		}
215
+	}
216
+
217
+	// db migrate version = 4
218
+	$newDbVersion = 4;
219
+	if ($dbVersion < $newDbVersion) {
220
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
221
+
222
+		// Create table smartobject_currency
223
+		$table = new SmartDbTable('smartobject_currency');
224
+		if (!$table->exists()) {
225
+			$table->setStructure('
226 226
               `currencyid` int(11) NOT NULL auto_increment,
227 227
               `iso4217` VARCHAR(5) NOT NULL,
228 228
               `name` VARCHAR(255) NOT NULL,
@@ -231,46 +231,46 @@  discard block
 block discarded – undo
231 231
               `default_currency` int(1) NOT NULL,
232 232
               PRIMARY KEY  (`currencyid`)
233 233
             ');
234
-        }
235
-
236
-        if (!$dbupdater->updateTable($table)) {
237
-            /**
238
-             * @todo trap the errors
239
-             */
240
-        }
241
-    }
242
-
243
-    // db migrate version = 6
244
-    $newDbVersion = 6;
245
-    if ($dbVersion < $newDbVersion) {
246
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
247
-    }
248
-
249
-    $newDbVersion = 7;
250
-    if ($dbVersion < $newDbVersion) {
251
-        echo 'Database migrate to version ' . $newDbVersion . '<br>';
252
-
253
-        // Create table smartobject_file
254
-        $table = new SmartDbTable('smartobject_file');
255
-        if (!$table->exists()) {
256
-            $table->setStructure('
234
+		}
235
+
236
+		if (!$dbupdater->updateTable($table)) {
237
+			/**
238
+			 * @todo trap the errors
239
+			 */
240
+		}
241
+	}
242
+
243
+	// db migrate version = 6
244
+	$newDbVersion = 6;
245
+	if ($dbVersion < $newDbVersion) {
246
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
247
+	}
248
+
249
+	$newDbVersion = 7;
250
+	if ($dbVersion < $newDbVersion) {
251
+		echo 'Database migrate to version ' . $newDbVersion . '<br>';
252
+
253
+		// Create table smartobject_file
254
+		$table = new SmartDbTable('smartobject_file');
255
+		if (!$table->exists()) {
256
+			$table->setStructure('
257 257
               `fileid` int(11) NOT NULL auto_increment,
258 258
               `caption` varchar(255) collate latin1_general_ci NOT NULL,
259 259
               `url` varchar(255) collate latin1_general_ci NOT NULL,
260 260
               `description` text collate latin1_general_ci NOT NULL,
261 261
                PRIMARY KEY  (`fileid`)
262 262
             ');
263
-            if (!$dbupdater->updateTable($table)) {
264
-                /**
265
-                 * @todo trap the errors
266
-                 */
267
-            }
268
-        }
269
-        unset($table);
270
-        // Create table smartobject_urllink
271
-        $table = new SmartDbTable('smartobject_urllink');
272
-        if (!$table->exists()) {
273
-            $table->setStructure('
263
+			if (!$dbupdater->updateTable($table)) {
264
+				/**
265
+				 * @todo trap the errors
266
+				 */
267
+			}
268
+		}
269
+		unset($table);
270
+		// Create table smartobject_urllink
271
+		$table = new SmartDbTable('smartobject_urllink');
272
+		if (!$table->exists()) {
273
+			$table->setStructure('
274 274
               `urllinkid` int(11) NOT NULL auto_increment,
275 275
               `caption` varchar(255) collate latin1_general_ci NOT NULL,
276 276
               `url` varchar(255) collate latin1_general_ci NOT NULL,
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
               `target` varchar(10) collate latin1_general_ci NOT NULL,
279 279
                 PRIMARY KEY  (`urllinkid`)
280 280
             ');
281
-            if (!$dbupdater->updateTable($table)) {
282
-                /**
283
-                 * @todo trap the errors
284
-                 */
285
-            }
286
-        }
287
-        unset($table);
288
-    }
289
-    echo '</code>';
290
-
291
-    $feedback = ob_get_clean();
292
-    if (method_exists($module, 'setMessage')) {
293
-        $module->setMessage($feedback);
294
-    } else {
295
-        echo $feedback;
296
-    }
297
-    smart_SetMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current
298
-
299
-    return true;
281
+			if (!$dbupdater->updateTable($table)) {
282
+				/**
283
+				 * @todo trap the errors
284
+				 */
285
+			}
286
+		}
287
+		unset($table);
288
+	}
289
+	echo '</code>';
290
+
291
+	$feedback = ob_get_clean();
292
+	if (method_exists($module, 'setMessage')) {
293
+		$module->setMessage($feedback);
294
+	} else {
295
+		echo $feedback;
296
+	}
297
+	smart_SetMeta('version', $newDbVersion, 'smartobject'); //Set meta version to current
298
+
299
+	return true;
300 300
 }
301 301
 
302 302
 /**
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
  */
306 306
 function xoops_module_install_smartobject($module)
307 307
 {
308
-    ob_start();
308
+	ob_start();
309 309
 
310
-    echo 'Using the ImpressCMS onInstall event';
311
-    $feedback = ob_get_clean();
310
+	echo 'Using the ImpressCMS onInstall event';
311
+	$feedback = ob_get_clean();
312 312
 
313
-    return $feedback;
313
+	return $feedback;
314 314
 }
Please login to merge, or discard this patch.
include/captcha/text.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -7,84 +7,84 @@
 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 static function getInstance()
24
-    {
25
-        static $instance;
26
-        if (null === $instance) {
27
-            $instance = new static();
28
-        }
20
+	/**
21
+	 * @return XoopsCaptchaText
22
+	 */
23
+	public static function getInstance()
24
+	{
25
+		static $instance;
26
+		if (null === $instance) {
27
+			$instance = new static();
28
+		}
29 29
 
30
-        return $instance;
31
-    }
30
+		return $instance;
31
+	}
32 32
 
33
-    /**
34
-     * Loading configs from CAPTCHA class
35
-     * @param array $config
36
-     */
37
-    public function loadConfig($config = array())
38
-    {
39
-        // Loading default preferences
40
-        $this->config = $config;
41
-    }
33
+	/**
34
+	 * Loading configs from CAPTCHA class
35
+	 * @param array $config
36
+	 */
37
+	public function loadConfig($config = array())
38
+	{
39
+		// Loading default preferences
40
+		$this->config = $config;
41
+	}
42 42
 
43
-    public function setCode()
44
-    {
45
-        $_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
46
-    }
43
+	public function setCode()
44
+	{
45
+		$_SESSION['XoopsCaptcha_sessioncode'] = (string)$this->code;
46
+	}
47 47
 
48
-    /**
49
-     * @return string
50
-     */
51
-    public function render()
52
-    {
53
-        $form = $this->loadText() .
54
-                "&nbsp;&nbsp; <input type='text' name='" .
55
-                $this->config['name'] .
56
-                "' id='" .
57
-                $this->config['name'] .
58
-                "' size='" .
59
-                $this->config['num_chars'] .
60
-                "' maxlength='" .
61
-                $this->config['num_chars'] .
62
-                "' value='' />";
63
-        $rule = constant('XOOPS_CAPTCHA_RULE_TEXT');
64
-        if (!empty($rule)) {
65
-            $form .= "&nbsp;&nbsp;<small>{$rule}</small>";
66
-        }
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function render()
52
+	{
53
+		$form = $this->loadText() .
54
+				"&nbsp;&nbsp; <input type='text' name='" .
55
+				$this->config['name'] .
56
+				"' id='" .
57
+				$this->config['name'] .
58
+				"' size='" .
59
+				$this->config['num_chars'] .
60
+				"' maxlength='" .
61
+				$this->config['num_chars'] .
62
+				"' value='' />";
63
+		$rule = constant('XOOPS_CAPTCHA_RULE_TEXT');
64
+		if (!empty($rule)) {
65
+			$form .= "&nbsp;&nbsp;<small>{$rule}</small>";
66
+		}
67 67
 
68
-        $this->setCode();
68
+		$this->setCode();
69 69
 
70
-        return $form;
71
-    }
70
+		return $form;
71
+	}
72 72
 
73
-    /**
74
-     * @return string
75
-     */
76
-    public function loadText()
77
-    {
78
-        $val_a = mt_rand(0, 9);
79
-        $val_b = mt_rand(0, 9);
80
-        if ($val_a > $val_b) {
81
-            $expression = "{$val_a} - {$val_b} = ?";
82
-            $this->code = $val_a - $val_b;
83
-        } else {
84
-            $expression = "{$val_a} + {$val_b} = ?";
85
-            $this->code = $val_a + $val_b;
86
-        }
73
+	/**
74
+	 * @return string
75
+	 */
76
+	public function loadText()
77
+	{
78
+		$val_a = mt_rand(0, 9);
79
+		$val_b = mt_rand(0, 9);
80
+		if ($val_a > $val_b) {
81
+			$expression = "{$val_a} - {$val_b} = ?";
82
+			$this->code = $val_a - $val_b;
83
+		} else {
84
+			$expression = "{$val_a} + {$val_b} = ?";
85
+			$this->code = $val_a + $val_b;
86
+		}
87 87
 
88
-        return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>";
89
-    }
88
+		return "<span style='font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;'>{$expression}</span>";
89
+	}
90 90
 }
Please login to merge, or discard this patch.
include/captcha/scripts/img.php 1 patch
Indentation   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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 += 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 += 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 += 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 += 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 dirname(__DIR__) . '/config.php';
Please login to merge, or discard this patch.