Completed
Push — master ( a09810...4911d3 )
by Michael
02:35
created
class/smarthighlighter.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -19,96 +19,96 @@
 block discarded – undo
19 19
  */
20 20
 class SmartHighlighter
21 21
 {
22
-    /**
23
-     * @access private
24
-     */
25
-    public $preg_keywords = '';
26
-    /**
27
-     * @access private
28
-     */
29
-    public $keywords = '';
30
-    /**
31
-     * @access private
32
-     */
33
-    public $singlewords = false;
34
-    /**
35
-     * @access private
36
-     */
37
-    public $replace_callback = null;
22
+	/**
23
+	 * @access private
24
+	 */
25
+	public $preg_keywords = '';
26
+	/**
27
+	 * @access private
28
+	 */
29
+	public $keywords = '';
30
+	/**
31
+	 * @access private
32
+	 */
33
+	public $singlewords = false;
34
+	/**
35
+	 * @access private
36
+	 */
37
+	public $replace_callback = null;
38 38
 
39
-    public $content;
39
+	public $content;
40 40
 
41
-    /**
42
-     * Main constructor
43
-     *
44
-     * This is the main constructor of keyhighlighter class. <br>
45
-     * It's the only public method of the class.
46
-     * @param string   $keywords         the keywords you want to highlight
47
-     * @param boolean  $singlewords      specify if it has to highlight also the single words.
48
-     * @param callback $replace_callback a custom callback for keyword highlight.
49
-     *                                   <code>
50
-     *                                   <?php
51
-     *                                   require ('keyhighlighter.class.php');
52
-     *
53
-     * function my_highlighter ($matches) {
54
-     *  return '<span style="font-weight: bolder; color: #FF0000;">' . $matches[0] . '</span>';
55
-     * }
56
-     *
57
-     * new keyhighlighter ('W3C', false, 'my_highlighter');
58
-     * readfile ('http://www.w3c.org/');
59
-     * ?>
60
-     * </code>
61
-     */
62
-    // public function __construct ()
63
-    public function __construct($keywords, $singlewords = false, $replace_callback = null)
64
-    {
65
-        $this->keywords         = $keywords;
66
-        $this->singlewords      = $singlewords;
67
-        $this->replace_callback = $replace_callback;
68
-    }
41
+	/**
42
+	 * Main constructor
43
+	 *
44
+	 * This is the main constructor of keyhighlighter class. <br>
45
+	 * It's the only public method of the class.
46
+	 * @param string   $keywords         the keywords you want to highlight
47
+	 * @param boolean  $singlewords      specify if it has to highlight also the single words.
48
+	 * @param callback $replace_callback a custom callback for keyword highlight.
49
+	 *                                   <code>
50
+	 *                                   <?php
51
+	 *                                   require ('keyhighlighter.class.php');
52
+	 *
53
+	 * function my_highlighter ($matches) {
54
+	 *  return '<span style="font-weight: bolder; color: #FF0000;">' . $matches[0] . '</span>';
55
+	 * }
56
+	 *
57
+	 * new keyhighlighter ('W3C', false, 'my_highlighter');
58
+	 * readfile ('http://www.w3c.org/');
59
+	 * ?>
60
+	 * </code>
61
+	 */
62
+	// public function __construct ()
63
+	public function __construct($keywords, $singlewords = false, $replace_callback = null)
64
+	{
65
+		$this->keywords         = $keywords;
66
+		$this->singlewords      = $singlewords;
67
+		$this->replace_callback = $replace_callback;
68
+	}
69 69
 
70
-    /**
71
-     * @access private
72
-     * @param $replace_matches
73
-     * @return mixed
74
-     */
75
-    public function replace($replace_matches)
76
-    {
77
-        $patterns = array();
78
-        if ($this->singlewords) {
79
-            $keywords = explode(' ', $this->preg_keywords);
80
-            foreach ($keywords as $keyword) {
81
-                $patterns[] = '/(?' . '>' . $keyword . '+)/si';
82
-            }
83
-        } else {
84
-            $patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si';
85
-        }
70
+	/**
71
+	 * @access private
72
+	 * @param $replace_matches
73
+	 * @return mixed
74
+	 */
75
+	public function replace($replace_matches)
76
+	{
77
+		$patterns = array();
78
+		if ($this->singlewords) {
79
+			$keywords = explode(' ', $this->preg_keywords);
80
+			foreach ($keywords as $keyword) {
81
+				$patterns[] = '/(?' . '>' . $keyword . '+)/si';
82
+			}
83
+		} else {
84
+			$patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si';
85
+		}
86 86
 
87
-        $result = $replace_matches[0];
87
+		$result = $replace_matches[0];
88 88
 
89
-        foreach ($patterns as $pattern) {
90
-            if (null !== $this->replace_callback) {
91
-                $result = preg_replace_callback($pattern, $this->replace_callback, $result);
92
-            } else {
93
-                $result = preg_replace($pattern, '<span class="highlightedkey">\\0</span>', $result);
94
-            }
95
-        }
89
+		foreach ($patterns as $pattern) {
90
+			if (null !== $this->replace_callback) {
91
+				$result = preg_replace_callback($pattern, $this->replace_callback, $result);
92
+			} else {
93
+				$result = preg_replace($pattern, '<span class="highlightedkey">\\0</span>', $result);
94
+			}
95
+		}
96 96
 
97
-        return $result;
98
-    }
97
+		return $result;
98
+	}
99 99
 
100
-    /**
101
-     * @access private
102
-     * @param $buffer
103
-     * @return mixed|string
104
-     */
105
-    public function highlight($buffer)
106
-    {
107
-        $buffer              = '>' . $buffer . '<';
108
-        $this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords);
109
-        $buffer              = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer);
110
-        $buffer              = substr($buffer, 1, -1);
100
+	/**
101
+	 * @access private
102
+	 * @param $buffer
103
+	 * @return mixed|string
104
+	 */
105
+	public function highlight($buffer)
106
+	{
107
+		$buffer              = '>' . $buffer . '<';
108
+		$this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords);
109
+		$buffer              = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer);
110
+		$buffer              = substr($buffer, 1, -1);
111 111
 
112
-        return $buffer;
113
-    }
112
+		return $buffer;
113
+	}
114 114
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
         if ($this->singlewords) {
79 79
             $keywords = explode(' ', $this->preg_keywords);
80 80
             foreach ($keywords as $keyword) {
81
-                $patterns[] = '/(?' . '>' . $keyword . '+)/si';
81
+                $patterns[] = '/(?'.'>'.$keyword.'+)/si';
82 82
             }
83 83
         } else {
84
-            $patterns[] = '/(?' . '>' . $this->preg_keywords . '+)/si';
84
+            $patterns[] = '/(?'.'>'.$this->preg_keywords.'+)/si';
85 85
         }
86 86
 
87 87
         $result = $replace_matches[0];
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function highlight($buffer)
106 106
     {
107
-        $buffer              = '>' . $buffer . '<';
107
+        $buffer              = '>'.$buffer.'<';
108 108
         $this->preg_keywords = preg_replace('/[^\w ]/si', '', $this->keywords);
109
-        $buffer              = preg_replace_callback("/(\>(((?" . ">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer);
109
+        $buffer              = preg_replace_callback("/(\>(((?".">[^><]+)|(?R))*)\<)/is", array(&$this, 'replace'), $buffer);
110 110
         $buffer              = substr($buffer, 1, -1);
111 111
 
112 112
         return $buffer;
Please login to merge, or discard this patch.
class/smartuploader.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -89,51 +89,51 @@
 block discarded – undo
89 89
  */
90 90
 class SmartUploader extends XoopsMediaUploader
91 91
 {
92
-    public $ext;
93
-    public $dimension;
92
+	public $ext;
93
+	public $dimension;
94 94
 
95
-    /**
96
-     * No admin check for uploads
97
-     */
98
-    public $noAdminSizeCheck;
95
+	/**
96
+	 * No admin check for uploads
97
+	 */
98
+	public $noAdminSizeCheck;
99 99
 
100
-    /**
101
-     * Constructor
102
-     *
103
-     * @param string    $uploadDir
104
-     * @param array|int $allowedMimeTypes
105
-     * @param int       $maxFileSize
106
-     * @param int       $maxWidth
107
-     * @param int       $maxHeight
108
-     * @internal param int $cmodvalue
109
-     */
110
-    public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0)
111
-    {
112
-        parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight);
113
-    }
100
+	/**
101
+	 * Constructor
102
+	 *
103
+	 * @param string    $uploadDir
104
+	 * @param array|int $allowedMimeTypes
105
+	 * @param int       $maxFileSize
106
+	 * @param int       $maxWidth
107
+	 * @param int       $maxHeight
108
+	 * @internal param int $cmodvalue
109
+	 */
110
+	public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize, $maxWidth = 0, $maxHeight = 0)
111
+	{
112
+		parent::__construct($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight);
113
+	}
114 114
 
115
-    /**
116
-     * @param $value
117
-     */
118
-    public function noAdminSizeCheck($value)
119
-    {
120
-        $this->noAdminSizeCheck = $value;
121
-    }
115
+	/**
116
+	 * @param $value
117
+	 */
118
+	public function noAdminSizeCheck($value)
119
+	{
120
+		$this->noAdminSizeCheck = $value;
121
+	}
122 122
 
123
-    /**
124
-     * Is the file the right size?
125
-     *
126
-     * @return bool
127
-     */
128
-    public function checkMaxFileSize()
129
-    {
130
-        if ($this->noAdminSizeCheck) {
131
-            return true;
132
-        }
133
-        if ($this->mediaSize > $this->maxFileSize) {
134
-            return false;
135
-        }
123
+	/**
124
+	 * Is the file the right size?
125
+	 *
126
+	 * @return bool
127
+	 */
128
+	public function checkMaxFileSize()
129
+	{
130
+		if ($this->noAdminSizeCheck) {
131
+			return true;
132
+		}
133
+		if ($this->mediaSize > $this->maxFileSize) {
134
+			return false;
135
+		}
136 136
 
137
-        return true;
138
-    }
137
+		return true;
138
+	}
139 139
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,9 +69,9 @@
 block discarded – undo
69 69
  * @link    http://smartfactory.ca The SmartFactory
70 70
  * @package SmartObject
71 71
  */
72
-mt_srand((double)microtime() * 1000000);
72
+mt_srand((double) microtime() * 1000000);
73 73
 
74
-require_once XOOPS_ROOT_PATH . '/class/uploader.php';
74
+require_once XOOPS_ROOT_PATH.'/class/uploader.php';
75 75
 
76 76
 /**
77 77
  * Class SmartUploader
Please login to merge, or discard this patch.
class/smartaddto.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function __construct($layout = 0, $method = 1)
22 22
     {
23
-        $layout = (int)$layout;
23
+        $layout = (int) $layout;
24 24
         if ($layout < 0 || $layout > 3) {
25 25
             $layout = 0;
26 26
         }
27 27
         $this->_layout = $layout;
28 28
 
29
-        $method = (int)$method;
29
+        $method = (int) $method;
30 30
         if ($method < 0 || $method > 1) {
31 31
             $method = 1;
32 32
         }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     {
42 42
         global $xoTheme, $xoopsTpl;
43 43
 
44
-        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
44
+        $xoTheme->addStylesheet(SMARTOBJECT_URL.'include/addto/addto.css');
45 45
 
46 46
         $xoopsTpl->assign('smartobject_addto_method', $this->_method);
47 47
         $xoopsTpl->assign('smartobject_addto_layout', $this->_layout);
48 48
 
49
-        $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/');
49
+        $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL.'include/addto/');
50 50
 
51 51
         if ($fetchOnly) {
52 52
             return $xoopsTpl->fetch('db:smartobject_addto.tpl');
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
     {
63 63
         global $xoTheme;
64 64
 
65
-        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
65
+        $xoTheme->addStylesheet(SMARTOBJECT_URL.'include/addto/addto.css');
66 66
 
67 67
         $block                             = array();
68 68
         $block['smartobject_addto_method'] = $this->_method;
69 69
         $block['smartobject_addto_layout'] = $this->_layout;
70
-        $block['smartobject_addto_url']    = SMARTOBJECT_URL . 'include/addto/';
70
+        $block['smartobject_addto_url']    = SMARTOBJECT_URL.'include/addto/';
71 71
 
72 72
         return $block;
73 73
     }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,66 +10,66 @@
 block discarded – undo
10 10
 
11 11
 class SmartAddTo
12 12
 {
13
-    public $_layout;
14
-    public $_method;
13
+	public $_layout;
14
+	public $_method;
15 15
 
16
-    /**
17
-     * Constructor of SmartAddTo
18
-     *
19
-     * @param int $layout 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical with icons, 3=Vertical no icons
20
-     * @param int $method 0=directpage, 1=popup
21
-     */
22
-    public function __construct($layout = 0, $method = 1)
23
-    {
24
-        $layout = (int)$layout;
25
-        if ($layout < 0 || $layout > 3) {
26
-            $layout = 0;
27
-        }
28
-        $this->_layout = $layout;
16
+	/**
17
+	 * Constructor of SmartAddTo
18
+	 *
19
+	 * @param int $layout 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical with icons, 3=Vertical no icons
20
+	 * @param int $method 0=directpage, 1=popup
21
+	 */
22
+	public function __construct($layout = 0, $method = 1)
23
+	{
24
+		$layout = (int)$layout;
25
+		if ($layout < 0 || $layout > 3) {
26
+			$layout = 0;
27
+		}
28
+		$this->_layout = $layout;
29 29
 
30
-        $method = (int)$method;
31
-        if ($method < 0 || $method > 1) {
32
-            $method = 1;
33
-        }
34
-        $this->_method = $method;
35
-    }
30
+		$method = (int)$method;
31
+		if ($method < 0 || $method > 1) {
32
+			$method = 1;
33
+		}
34
+		$this->_method = $method;
35
+	}
36 36
 
37
-    /**
38
-     * @param  bool $fetchOnly
39
-     * @return mixed|string|void
40
-     */
41
-    public function render($fetchOnly = false)
42
-    {
43
-        global $xoTheme, $xoopsTpl;
37
+	/**
38
+	 * @param  bool $fetchOnly
39
+	 * @return mixed|string|void
40
+	 */
41
+	public function render($fetchOnly = false)
42
+	{
43
+		global $xoTheme, $xoopsTpl;
44 44
 
45
-        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
45
+		$xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
46 46
 
47
-        $xoopsTpl->assign('smartobject_addto_method', $this->_method);
48
-        $xoopsTpl->assign('smartobject_addto_layout', $this->_layout);
47
+		$xoopsTpl->assign('smartobject_addto_method', $this->_method);
48
+		$xoopsTpl->assign('smartobject_addto_layout', $this->_layout);
49 49
 
50
-        $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/');
50
+		$xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/');
51 51
 
52
-        if ($fetchOnly) {
53
-            return $xoopsTpl->fetch('db:smartobject_addto.tpl');
54
-        } else {
55
-            $xoopsTpl->display('db:smartobject_addto.tpl');
56
-        }
57
-    }
52
+		if ($fetchOnly) {
53
+			return $xoopsTpl->fetch('db:smartobject_addto.tpl');
54
+		} else {
55
+			$xoopsTpl->display('db:smartobject_addto.tpl');
56
+		}
57
+	}
58 58
 
59
-    /**
60
-     * @return array
61
-     */
62
-    public function renderForBlock()
63
-    {
64
-        global $xoTheme;
59
+	/**
60
+	 * @return array
61
+	 */
62
+	public function renderForBlock()
63
+	{
64
+		global $xoTheme;
65 65
 
66
-        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
66
+		$xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
67 67
 
68
-        $block                             = array();
69
-        $block['smartobject_addto_method'] = $this->_method;
70
-        $block['smartobject_addto_layout'] = $this->_layout;
71
-        $block['smartobject_addto_url']    = SMARTOBJECT_URL . 'include/addto/';
68
+		$block                             = array();
69
+		$block['smartobject_addto_method'] = $this->_method;
70
+		$block['smartobject_addto_layout'] = $this->_layout;
71
+		$block['smartobject_addto_url']    = SMARTOBJECT_URL . 'include/addto/';
72 72
 
73
-        return $block;
74
-    }
73
+		return $block;
74
+	}
75 75
 }
Please login to merge, or discard this patch.
class/form/elements/smartformuser_sigelement.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,23 +12,23 @@
 block discarded – undo
12 12
 
13 13
 class SmartFormUser_sigElement extends XoopsFormElementTray
14 14
 {
15
-    /**
16
-     * SmartFormUser_sigElement constructor.
17
-     * @param string $object
18
-     * @param string $key
19
-     */
20
-    public function __construct($object, $key)
21
-    {
22
-        $var     = $object->vars[$key];
23
-        $control = $object->controls[$key];
15
+	/**
16
+	 * SmartFormUser_sigElement constructor.
17
+	 * @param string $object
18
+	 * @param string $key
19
+	 */
20
+	public function __construct($object, $key)
21
+	{
22
+		$var     = $object->vars[$key];
23
+		$control = $object->controls[$key];
24 24
 
25
-        parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
25
+		parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
26 26
 
27
-        $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28
-        $this->addElement($signature_textarea);
27
+		$signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28
+		$this->addElement($signature_textarea);
29 29
 
30
-        $attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e'));
31
-        $attach_checkbox->addOption(1, _US_SHOWSIG);
32
-        $this->addElement($attach_checkbox);
33
-    }
30
+		$attach_checkbox = new XoopsFormCheckBox('', 'attachsig', $object->getVar('attachsig', 'e'));
31
+		$attach_checkbox->addOption(1, _US_SHOWSIG);
32
+		$this->addElement($attach_checkbox);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         $var     = $object->vars[$key];
23 23
         $control = $object->controls[$key];
24 24
 
25
-        parent::__construct($var['form_caption'], '<br><br>', $key . '_signature_tray');
25
+        parent::__construct($var['form_caption'], '<br><br>', $key.'_signature_tray');
26 26
 
27 27
         $signature_textarea = new XoopsFormDhtmlTextArea('', $key, $object->getVar($key, 'e'));
28 28
         $this->addElement($signature_textarea);
Please login to merge, or discard this patch.
class/form/elements/smartformurllinkelement.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormUrlLinkElement extends XoopsFormElementTray
13 13
 {
14
-    /**
15
-     * SmartFormUrlLinkElement constructor.
16
-     * @param string $form_caption
17
-     * @param string $key
18
-     * @param string $object
19
-     */
20
-    public function __construct($form_caption, $key, $object)
21
-    {
22
-        parent::__construct($form_caption, '&nbsp;');
14
+	/**
15
+	 * SmartFormUrlLinkElement constructor.
16
+	 * @param string $form_caption
17
+	 * @param string $key
18
+	 * @param string $object
19
+	 */
20
+	public function __construct($form_caption, $key, $object)
21
+	{
22
+		parent::__construct($form_caption, '&nbsp;');
23 23
 
24
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
-        $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
24
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
+		$this->addElement(new SmartFormTextElement($object, 'url_' . $key));
26 26
 
27
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
-        $this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
27
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
+		$this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
29 29
 
30
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
-        $this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
30
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
+		$this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
32 32
 
33
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
34
-        $targ_val    = $object->getVar('target');
35
-        $targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
36
-        $control     = $object->getControl('target');
37
-        $targetRadio->addOptionArray($control['options']);
33
+		$this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
34
+		$targ_val    = $object->getVar('target');
35
+		$targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
36
+		$control     = $object->getControl('target');
37
+		$targetRadio->addOptionArray($control['options']);
38 38
 
39
-        $this->addElement($targetRadio);
40
-    }
39
+		$this->addElement($targetRadio);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@
 block discarded – undo
21 21
     {
22 22
         parent::__construct($form_caption, '&nbsp;');
23 23
 
24
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_URL));
25
-        $this->addElement(new SmartFormTextElement($object, 'url_' . $key));
24
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_URL));
25
+        $this->addElement(new SmartFormTextElement($object, 'url_'.$key));
26 26
 
27
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_CAPTION));
28
-        $this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
27
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_CAPTION));
28
+        $this->addElement(new SmartFormTextElement($object, 'caption_'.$key));
29 29
 
30
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_DESC . '<br>'));
31
-        $this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
30
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_DESC.'<br>'));
31
+        $this->addElement(new XoopsFormTextArea('', 'desc_'.$key, $object->getVar('description')));
32 32
 
33
-        $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URLLINK_TARGET));
33
+        $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_URLLINK_TARGET));
34 34
         $targ_val    = $object->getVar('target');
35
-        $targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val !== '' ? $targ_val : '_blank');
35
+        $targetRadio = new XoopsFormRadio('', 'target_'.$key, $targ_val !== '' ? $targ_val : '_blank');
36 36
         $control     = $object->getControl('target');
37 37
         $targetRadio->addOptionArray($control['options']);
38 38
 
Please login to merge, or discard this patch.
class/form/elements/smartformtimeelement.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormTimeElement extends XoopsFormSelect
13 13
 {
14
-    /**
15
-     * SmartFormTimeElement constructor.
16
-     * @param string $object
17
-     * @param string $key
18
-     */
19
-    public function __construct($object, $key)
20
-    {
21
-        $var       = $object->vars[$key];
22
-        $timearray = array();
23
-        for ($i = 0; $i < 24; ++$i) {
24
-            for ($j = 0; $j < 60; $j += 10) {
25
-                $key_t             = ($i * 3600) + ($j * 60);
26
-                $timearray[$key_t] = ($j != 0) ? $i . ':' . $j : $i . ':0' . $j;
27
-            }
28
-        }
29
-        ksort($timearray);
30
-        parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'));
31
-        $this->addOptionArray($timearray);
32
-    }
14
+	/**
15
+	 * SmartFormTimeElement constructor.
16
+	 * @param string $object
17
+	 * @param string $key
18
+	 */
19
+	public function __construct($object, $key)
20
+	{
21
+		$var       = $object->vars[$key];
22
+		$timearray = array();
23
+		for ($i = 0; $i < 24; ++$i) {
24
+			for ($j = 0; $j < 60; $j += 10) {
25
+				$key_t             = ($i * 3600) + ($j * 60);
26
+				$timearray[$key_t] = ($j != 0) ? $i . ':' . $j : $i . ':0' . $j;
27
+			}
28
+		}
29
+		ksort($timearray);
30
+		parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'));
31
+		$this->addOptionArray($timearray);
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         for ($i = 0; $i < 24; ++$i) {
24 24
             for ($j = 0; $j < 60; $j += 10) {
25 25
                 $key_t             = ($i * 3600) + ($j * 60);
26
-                $timearray[$key_t] = ($j != 0) ? $i . ':' . $j : $i . ':0' . $j;
26
+                $timearray[$key_t] = ($j != 0) ? $i.':'.$j : $i.':0'.$j;
27 27
             }
28 28
         }
29 29
         ksort($timearray);
Please login to merge, or discard this patch.
class/form/elements/smartformset_passwordelement.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@
 block discarded – undo
50 50
         $var     = $object->vars[$key];
51 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);
55
+        $password_box1 = new XoopsFormPassword('', $key.'1', 10, 32);
56 56
         $this->addElement($password_box1);
57 57
 
58
-        $password_box2 = new XoopsFormPassword('', $key . '2', 10, 32);
58
+        $password_box2 = new XoopsFormPassword('', $key.'2', 10, 32);
59 59
         $this->addElement($password_box2);
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
13 13
 
14 14
 class SmartFormSet_passwordElement extends XoopsFormElementTray
15 15
 {
16
-    /**
17
-     * Size of the field.
18
-     * @var int
19
-     * @access  private
20
-     */
21
-    public $_size;
22
-
23
-    /**
24
-     * Maximum length of the text
25
-     * @var int
26
-     * @access  private
27
-     */
28
-    public $_maxlength;
29
-
30
-    /**
31
-     * Initial content of the field.
32
-     * @var string
33
-     * @access  private
34
-     */
35
-    public $_value;
36
-
37
-    /**
38
-     * Constructor
39
-     *
40
-     * @param string $object
41
-     * @param string $key
42
-     * @internal param string $caption Caption
43
-     * @internal param string $name "name" attribute
44
-     * @internal param int $size Size of the field
45
-     * @internal param int $maxlength Maximum length of the text
46
-     * @internal param int $value Initial value of the field.
47
-     *                          <b>Warning:</b> this is readable in cleartext in the page's source!
48
-     */
49
-    public function __construct($object, $key)
50
-    {
51
-        $var     = $object->vars[$key];
52
-        $control = $object->controls[$key];
53
-
54
-        parent::__construct($var['form_caption'] . '<br>' . _US_TYPEPASSTWICE, ' ', $key . '_password_tray');
55
-
56
-        $password_box1 = new XoopsFormPassword('', $key . '1', 10, 32);
57
-        $this->addElement($password_box1);
58
-
59
-        $password_box2 = new XoopsFormPassword('', $key . '2', 10, 32);
60
-        $this->addElement($password_box2);
61
-    }
16
+	/**
17
+	 * Size of the field.
18
+	 * @var int
19
+	 * @access  private
20
+	 */
21
+	public $_size;
22
+
23
+	/**
24
+	 * Maximum length of the text
25
+	 * @var int
26
+	 * @access  private
27
+	 */
28
+	public $_maxlength;
29
+
30
+	/**
31
+	 * Initial content of the field.
32
+	 * @var string
33
+	 * @access  private
34
+	 */
35
+	public $_value;
36
+
37
+	/**
38
+	 * Constructor
39
+	 *
40
+	 * @param string $object
41
+	 * @param string $key
42
+	 * @internal param string $caption Caption
43
+	 * @internal param string $name "name" attribute
44
+	 * @internal param int $size Size of the field
45
+	 * @internal param int $maxlength Maximum length of the text
46
+	 * @internal param int $value Initial value of the field.
47
+	 *                          <b>Warning:</b> this is readable in cleartext in the page's source!
48
+	 */
49
+	public function __construct($object, $key)
50
+	{
51
+		$var     = $object->vars[$key];
52
+		$control = $object->controls[$key];
53
+
54
+		parent::__construct($var['form_caption'] . '<br>' . _US_TYPEPASSTWICE, ' ', $key . '_password_tray');
55
+
56
+		$password_box1 = new XoopsFormPassword('', $key . '1', 10, 32);
57
+		$this->addElement($password_box1);
58
+
59
+		$password_box2 = new XoopsFormPassword('', $key . '2', 10, 32);
60
+		$this->addElement($password_box2);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
include/captcha/captcha.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 class XoopsCaptcha
15 15
 {
16 16
     public $active = true;
17
-    public $mode   = 'text';    // potential values: image, text
17
+    public $mode   = 'text'; // potential values: image, text
18 18
     public $config = array();
19 19
 
20 20
     public $message = array(); // Logging error messages
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function __construct()
26 26
     {
27 27
         // Loading default preferences
28
-        $this->config = @include __DIR__ . '/config.php';
28
+        $this->config = @include __DIR__.'/config.php';
29 29
 
30 30
         $this->setMode($this->config['mode']);
31 31
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $sessionName = @$_SESSION['XoopsCaptcha_name'];
129 129
         $skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
130
-        $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
130
+        $maxAttempts = (int) (@$_SESSION['XoopsCaptcha_maxattempts']);
131 131
 
132 132
         $is_valid = false;
133 133
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
136 136
             $is_valid = true;
137 137
             // Kill too many attempts
138
-        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
138
+        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_'.$sessionName] > $maxAttempts) {
139 139
             $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
140 140
 
141 141
             // Verify the code
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
         if (!empty($maxAttempts)) {
148 148
             if (!$is_valid) {
149 149
                 // Increase the attempt records on failure
150
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
150
+                $_SESSION['XoopsCaptcha_attempt_'.$sessionName]++;
151 151
                 // Log the error message
152 152
                 $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
153 153
             } else {
154 154
 
155 155
                 // reset attempt records on success
156
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
156
+                $_SESSION['XoopsCaptcha_attempt_'.$sessionName] = null;
157 157
             }
158 158
         }
159 159
         $this->destroyGarbage(true);
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function destroyGarbage($clearSession = false)
186 186
     {
187
-        require_once __DIR__ . '/' . $this->mode . '.php';
188
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
187
+        require_once __DIR__.'/'.$this->mode.'.php';
188
+        $class          = 'XoopsCaptcha'.ucfirst($this->mode);
189 189
         $captchaHandler = new $class();
190 190
         if (method_exists($captchaHandler, 'destroyGarbage')) {
191 191
             $captchaHandler->loadConfig($this->config);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
          */
225 225
 
226 226
         // Fail on too many attempts
227
-        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
227
+        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_'.$this->config['name']] > $maxAttempts) {
228 228
             $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
229 229
             // Load the form element
230 230
         } else {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function loadForm()
241 241
     {
242
-        require_once __DIR__ . '/' . $this->mode . '.php';
243
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
242
+        require_once __DIR__.'/'.$this->mode.'.php';
243
+        $class          = 'XoopsCaptcha'.ucfirst($this->mode);
244 244
         $captchaHandler = new $class();
245 245
         $captchaHandler->loadConfig($this->config);
246 246
 
Please login to merge, or discard this patch.
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -13,253 +13,253 @@
 block discarded – undo
13 13
  */
14 14
 class XoopsCaptcha
15 15
 {
16
-    public $active = true;
17
-    public $mode   = 'text';    // potential values: image, text
18
-    public $config = array();
19
-
20
-    public $message = array(); // Logging error messages
21
-
22
-    /**
23
-     * XoopsCaptcha constructor.
24
-     */
25
-    public function __construct()
26
-    {
27
-        // Loading default preferences
28
-        $this->config = @include __DIR__ . '/config.php';
29
-
30
-        $this->setMode($this->config['mode']);
31
-    }
32
-
33
-    /**
34
-     * @return XoopsCaptcha
35
-     */
36
-    public static function getInstance()
37
-    {
38
-        static $instance;
39
-        if (null === $instance) {
40
-            $instance = new static();
41
-        }
42
-
43
-        return $instance;
44
-    }
45
-
46
-    /**
47
-     * @param $name
48
-     * @param $val
49
-     * @return bool
50
-     */
51
-    public function setConfig($name, $val)
52
-    {
53
-        if ($name === 'mode') {
54
-            $this->setMode($val);
55
-        } elseif (isset($this->$name)) {
56
-            $this->$name = $val;
57
-        } else {
58
-            $this->config[$name] = $val;
59
-        }
60
-
61
-        return true;
62
-    }
63
-
64
-    /**
65
-     * Set CAPTCHA mode
66
-     *
67
-     * For future possible modes, right now force to use text or image
68
-     *
69
-     * @param string $mode if no mode is set, just verify current mode
70
-     */
71
-    public function setMode($mode = null)
72
-    {
73
-        if (!empty($mode) && in_array($mode, array('text', 'image'))) {
74
-            $this->mode = $mode;
75
-
76
-            if ($this->mode !== 'image') {
77
-                return;
78
-            }
79
-        }
80
-
81
-        // Disable image mode
82
-        if (!extension_loaded('gd')) {
83
-            $this->mode = 'text';
84
-        } else {
85
-            $required_functions = array(
86
-                'imagecreatetruecolor',
87
-                'imagecolorallocate',
88
-                'imagefilledrectangle',
89
-                'imagejpeg',
90
-                'imagedestroy',
91
-                'imageftbbox'
92
-            );
93
-            foreach ($required_functions as $func) {
94
-                if (!function_exists($func)) {
95
-                    $this->mode = 'text';
96
-                    break;
97
-                }
98
-            }
99
-        }
100
-    }
101
-
102
-    /**
103
-     * Initializing the CAPTCHA class
104
-     * @param string $name
105
-     * @param null   $skipmember
106
-     * @param null   $num_chars
107
-     * @param null   $fontsize_min
108
-     * @param null   $fontsize_max
109
-     * @param null   $background_type
110
-     * @param null   $background_num
111
-     */
112
-    public function init(
113
-        $name = 'xoopscaptcha',
114
-        $skipmember = null,
115
-        $num_chars = null,
116
-        $fontsize_min = null,
117
-        $fontsize_max = null,
118
-        $background_type = null,
119
-        $background_num = null
120
-    ) {
121
-        // Loading RUN-TIME settings
122
-        foreach (array_keys($this->config) as $key) {
123
-            if (isset(${$key}) && ${$key} !== null) {
124
-                $this->config[$key] = ${$key};
125
-            }
126
-        }
127
-        $this->config['name'] = $name;
128
-
129
-        // Skip CAPTCHA for member if set
130
-        if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
131
-            $this->active = false;
132
-        }
133
-    }
134
-
135
-    /**
136
-     * Verify user submission
137
-     * @param  null $skipMember
138
-     * @return bool
139
-     */
140
-    public function verify($skipMember = null)
141
-    {
142
-        $sessionName = @$_SESSION['XoopsCaptcha_name'];
143
-        $skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
144
-        $maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
145
-
146
-        $is_valid = false;
147
-
148
-        // Skip CAPTCHA for member if set
149
-        if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
150
-            $is_valid = true;
151
-            // Kill too many attempts
152
-        } elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
153
-            $this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
154
-
155
-            // Verify the code
156
-        } elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
157
-            $func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
158
-            $is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
159
-        }
160
-
161
-        if (!empty($maxAttempts)) {
162
-            if (!$is_valid) {
163
-                // Increase the attempt records on failure
164
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
165
-                // Log the error message
166
-                $this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
167
-            } else {
168
-
169
-                // reset attempt records on success
170
-                $_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
171
-            }
172
-        }
173
-        $this->destroyGarbage(true);
174
-
175
-        return $is_valid;
176
-    }
177
-
178
-    /**
179
-     * @return mixed|string
180
-     */
181
-    public function getCaption()
182
-    {
183
-        return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
184
-    }
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function getMessage()
190
-    {
191
-        return implode('<br>', $this->message);
192
-    }
193
-
194
-    /**
195
-     * Destory historical stuff
196
-     * @param  bool $clearSession
197
-     * @return bool
198
-     */
199
-    public function destroyGarbage($clearSession = false)
200
-    {
201
-        require_once __DIR__ . '/' . $this->mode . '.php';
202
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
203
-        $captchaHandler = new $class();
204
-        if (method_exists($captchaHandler, 'destroyGarbage')) {
205
-            $captchaHandler->loadConfig($this->config);
206
-            $captchaHandler->destroyGarbage();
207
-        }
208
-
209
-        if ($clearSession) {
210
-            $_SESSION['XoopsCaptcha_name']        = null;
211
-            $_SESSION['XoopsCaptcha_skipmember']  = null;
212
-            $_SESSION['XoopsCaptcha_sessioncode'] = null;
213
-            $_SESSION['XoopsCaptcha_maxattempts'] = null;
214
-        }
215
-
216
-        return true;
217
-    }
218
-
219
-    /**
220
-     * @return mixed|string
221
-     */
222
-    public function render()
223
-    {
224
-        $form = '';
225
-
226
-        if (!$this->active || empty($this->config['name'])) {
227
-            return $form;
228
-        }
229
-
230
-        $_SESSION['XoopsCaptcha_name']        = $this->config['name'];
231
-        $_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
232
-        $maxAttempts                          = $this->config['maxattempt'];
233
-        $_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
234
-        /*
16
+	public $active = true;
17
+	public $mode   = 'text';    // potential values: image, text
18
+	public $config = array();
19
+
20
+	public $message = array(); // Logging error messages
21
+
22
+	/**
23
+	 * XoopsCaptcha constructor.
24
+	 */
25
+	public function __construct()
26
+	{
27
+		// Loading default preferences
28
+		$this->config = @include __DIR__ . '/config.php';
29
+
30
+		$this->setMode($this->config['mode']);
31
+	}
32
+
33
+	/**
34
+	 * @return XoopsCaptcha
35
+	 */
36
+	public static function getInstance()
37
+	{
38
+		static $instance;
39
+		if (null === $instance) {
40
+			$instance = new static();
41
+		}
42
+
43
+		return $instance;
44
+	}
45
+
46
+	/**
47
+	 * @param $name
48
+	 * @param $val
49
+	 * @return bool
50
+	 */
51
+	public function setConfig($name, $val)
52
+	{
53
+		if ($name === 'mode') {
54
+			$this->setMode($val);
55
+		} elseif (isset($this->$name)) {
56
+			$this->$name = $val;
57
+		} else {
58
+			$this->config[$name] = $val;
59
+		}
60
+
61
+		return true;
62
+	}
63
+
64
+	/**
65
+	 * Set CAPTCHA mode
66
+	 *
67
+	 * For future possible modes, right now force to use text or image
68
+	 *
69
+	 * @param string $mode if no mode is set, just verify current mode
70
+	 */
71
+	public function setMode($mode = null)
72
+	{
73
+		if (!empty($mode) && in_array($mode, array('text', 'image'))) {
74
+			$this->mode = $mode;
75
+
76
+			if ($this->mode !== 'image') {
77
+				return;
78
+			}
79
+		}
80
+
81
+		// Disable image mode
82
+		if (!extension_loaded('gd')) {
83
+			$this->mode = 'text';
84
+		} else {
85
+			$required_functions = array(
86
+				'imagecreatetruecolor',
87
+				'imagecolorallocate',
88
+				'imagefilledrectangle',
89
+				'imagejpeg',
90
+				'imagedestroy',
91
+				'imageftbbox'
92
+			);
93
+			foreach ($required_functions as $func) {
94
+				if (!function_exists($func)) {
95
+					$this->mode = 'text';
96
+					break;
97
+				}
98
+			}
99
+		}
100
+	}
101
+
102
+	/**
103
+	 * Initializing the CAPTCHA class
104
+	 * @param string $name
105
+	 * @param null   $skipmember
106
+	 * @param null   $num_chars
107
+	 * @param null   $fontsize_min
108
+	 * @param null   $fontsize_max
109
+	 * @param null   $background_type
110
+	 * @param null   $background_num
111
+	 */
112
+	public function init(
113
+		$name = 'xoopscaptcha',
114
+		$skipmember = null,
115
+		$num_chars = null,
116
+		$fontsize_min = null,
117
+		$fontsize_max = null,
118
+		$background_type = null,
119
+		$background_num = null
120
+	) {
121
+		// Loading RUN-TIME settings
122
+		foreach (array_keys($this->config) as $key) {
123
+			if (isset(${$key}) && ${$key} !== null) {
124
+				$this->config[$key] = ${$key};
125
+			}
126
+		}
127
+		$this->config['name'] = $name;
128
+
129
+		// Skip CAPTCHA for member if set
130
+		if ($this->config['skipmember'] && is_object($GLOBALS['xoopsUser'])) {
131
+			$this->active = false;
132
+		}
133
+	}
134
+
135
+	/**
136
+	 * Verify user submission
137
+	 * @param  null $skipMember
138
+	 * @return bool
139
+	 */
140
+	public function verify($skipMember = null)
141
+	{
142
+		$sessionName = @$_SESSION['XoopsCaptcha_name'];
143
+		$skipMember  = ($skipMember === null) ? @$_SESSION['XoopsCaptcha_skipmember'] : $skipMember;
144
+		$maxAttempts = (int)(@$_SESSION['XoopsCaptcha_maxattempts']);
145
+
146
+		$is_valid = false;
147
+
148
+		// Skip CAPTCHA for member if set
149
+		if (is_object($GLOBALS['xoopsUser']) && !empty($skipMember)) {
150
+			$is_valid = true;
151
+			// Kill too many attempts
152
+		} elseif (!empty($maxAttempts) && $_SESSION['XoopsCaptcha_attempt_' . $sessionName] > $maxAttempts) {
153
+			$this->message[] = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
154
+
155
+			// Verify the code
156
+		} elseif (!empty($_SESSION['XoopsCaptcha_sessioncode'])) {
157
+			$func     = $this->config['casesensitive'] ? 'strcmp' : 'strcasecmp';
158
+			$is_valid = !$func(trim(@$_POST[$sessionName]), $_SESSION['XoopsCaptcha_sessioncode']);
159
+		}
160
+
161
+		if (!empty($maxAttempts)) {
162
+			if (!$is_valid) {
163
+				// Increase the attempt records on failure
164
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName]++;
165
+				// Log the error message
166
+				$this->message[] = XOOPS_CAPTCHA_INVALID_CODE;
167
+			} else {
168
+
169
+				// reset attempt records on success
170
+				$_SESSION['XoopsCaptcha_attempt_' . $sessionName] = null;
171
+			}
172
+		}
173
+		$this->destroyGarbage(true);
174
+
175
+		return $is_valid;
176
+	}
177
+
178
+	/**
179
+	 * @return mixed|string
180
+	 */
181
+	public function getCaption()
182
+	{
183
+		return defined('XOOPS_CAPTCHA_CAPTION') ? constant('XOOPS_CAPTCHA_CAPTION') : '';
184
+	}
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function getMessage()
190
+	{
191
+		return implode('<br>', $this->message);
192
+	}
193
+
194
+	/**
195
+	 * Destory historical stuff
196
+	 * @param  bool $clearSession
197
+	 * @return bool
198
+	 */
199
+	public function destroyGarbage($clearSession = false)
200
+	{
201
+		require_once __DIR__ . '/' . $this->mode . '.php';
202
+		$class          = 'XoopsCaptcha' . ucfirst($this->mode);
203
+		$captchaHandler = new $class();
204
+		if (method_exists($captchaHandler, 'destroyGarbage')) {
205
+			$captchaHandler->loadConfig($this->config);
206
+			$captchaHandler->destroyGarbage();
207
+		}
208
+
209
+		if ($clearSession) {
210
+			$_SESSION['XoopsCaptcha_name']        = null;
211
+			$_SESSION['XoopsCaptcha_skipmember']  = null;
212
+			$_SESSION['XoopsCaptcha_sessioncode'] = null;
213
+			$_SESSION['XoopsCaptcha_maxattempts'] = null;
214
+		}
215
+
216
+		return true;
217
+	}
218
+
219
+	/**
220
+	 * @return mixed|string
221
+	 */
222
+	public function render()
223
+	{
224
+		$form = '';
225
+
226
+		if (!$this->active || empty($this->config['name'])) {
227
+			return $form;
228
+		}
229
+
230
+		$_SESSION['XoopsCaptcha_name']        = $this->config['name'];
231
+		$_SESSION['XoopsCaptcha_skipmember']  = $this->config['skipmember'];
232
+		$maxAttempts                          = $this->config['maxattempt'];
233
+		$_SESSION['XoopsCaptcha_maxattempts'] = $maxAttempts;
234
+		/*
235 235
          if (!empty($maxAttempts)) {
236 236
          $_SESSION['XoopsCaptcha_maxattempts_'.$_SESSION['XoopsCaptcha_name']] = $maxAttempts;
237 237
          }
238 238
          */
239 239
 
240
-        // Fail on too many attempts
241
-        if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
242
-            $form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
243
-            // Load the form element
244
-        } else {
245
-            $form = $this->loadForm();
246
-        }
247
-
248
-        return $form;
249
-    }
250
-
251
-    /**
252
-     * @return mixed
253
-     */
254
-    public function loadForm()
255
-    {
256
-        require_once __DIR__ . '/' . $this->mode . '.php';
257
-        $class          = 'XoopsCaptcha' . ucfirst($this->mode);
258
-        $captchaHandler = new $class();
259
-        $captchaHandler->loadConfig($this->config);
260
-
261
-        $form = $captchaHandler->render();
262
-
263
-        return $form;
264
-    }
240
+		// Fail on too many attempts
241
+		if (!empty($maxAttempts) && @$_SESSION['XoopsCaptcha_attempt_' . $this->config['name']] > $maxAttempts) {
242
+			$form = XOOPS_CAPTCHA_TOOMANYATTEMPTS;
243
+			// Load the form element
244
+		} else {
245
+			$form = $this->loadForm();
246
+		}
247
+
248
+		return $form;
249
+	}
250
+
251
+	/**
252
+	 * @return mixed
253
+	 */
254
+	public function loadForm()
255
+	{
256
+		require_once __DIR__ . '/' . $this->mode . '.php';
257
+		$class          = 'XoopsCaptcha' . ucfirst($this->mode);
258
+		$captchaHandler = new $class();
259
+		$captchaHandler->loadConfig($this->config);
260
+
261
+		$form = $captchaHandler->render();
262
+
263
+		return $form;
264
+	}
265 265
 }
Please login to merge, or discard this patch.
include/xoops_core_common_functions.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function xoops_debug_dumbQuery($msg = '')
16 16
 {
17
-    global $xoopsDB;
18
-    $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2');
17
+	global $xoopsDB;
18
+	$xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2');
19 19
 }
20 20
 
21 21
 function xoops_debug_initiateQueryCount()
22 22
 {
23
-    global $smartfactory_query_count_activated, $smartfactory_query_count;
24
-    $smartfactory_query_count_activated = true;
25
-    $smartfactory_query_count           = 0;
23
+	global $smartfactory_query_count_activated, $smartfactory_query_count;
24
+	$smartfactory_query_count_activated = true;
25
+	$smartfactory_query_count           = 0;
26 26
 }
27 27
 
28 28
 /**
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function xoops_debug_getQueryCount($msg = '')
32 32
 {
33
-    global $smartfactory_query_count;
33
+	global $smartfactory_query_count;
34 34
 
35
-    return xoops_debug("xoops debug Query count ($msg): $smartfactory_query_count");
35
+	return xoops_debug("xoops debug Query count ($msg): $smartfactory_query_count");
36 36
 }
37 37
 
38 38
 /**
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function xoops_debug($msg, $exit = false)
43 43
 {
44
-    echo "<div style='padding: 5px; color: red; font-weight: bold;'>debug:: $msg</div>";
45
-    if ($exit) {
46
-        die();
47
-    }
44
+	echo "<div style='padding: 5px; color: red; font-weight: bold;'>debug:: $msg</div>";
45
+	if ($exit) {
46
+		die();
47
+	}
48 48
 }
49 49
 
50 50
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function xoops_comment($msg)
54 54
 {
55
-    echo "<div style='padding: 5px; color: green; font-weight: bold;'>=> $msg</div>";
55
+	echo "<div style='padding: 5px; color: green; font-weight: bold;'>=> $msg</div>";
56 56
 }
57 57
 
58 58
 /**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function xoops_debug_vardump($var)
62 62
 {
63
-    if (class_exists('MyTextSanitizer')) {
64
-        $myts = MyTextSanitizer::getInstance();
65
-        xoops_debug($myts->displayTarea(var_export($var, true)));
66
-    } else {
67
-        xoops_debug(var_export($var, true));
68
-    }
63
+	if (class_exists('MyTextSanitizer')) {
64
+		$myts = MyTextSanitizer::getInstance();
65
+		xoops_debug($myts->displayTarea(var_export($var, true)));
66
+	} else {
67
+		xoops_debug(var_export($var, true));
68
+	}
69 69
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 function xoops_debug_dumbQuery($msg = '')
16 16
 {
17 17
     global $xoopsDB;
18
-    $xoopsDB->query('SELECT * ' . $msg . ' FROM dudewhereismycar2');
18
+    $xoopsDB->query('SELECT * '.$msg.' FROM dudewhereismycar2');
19 19
 }
20 20
 
21 21
 function xoops_debug_initiateQueryCount()
Please login to merge, or discard this patch.