@@ -11,42 +11,42 @@ |
||
11 | 11 | */ |
12 | 12 | class KarmaHandler |
13 | 13 | { |
14 | - /** |
|
15 | - * @param null $user |
|
16 | - * @return int |
|
17 | - */ |
|
18 | - public function getUserKarma($user = null) |
|
19 | - { |
|
20 | - $user = (null === $user) ? $GLOBALS['xoopsUser'] : $user; |
|
14 | + /** |
|
15 | + * @param null $user |
|
16 | + * @return int |
|
17 | + */ |
|
18 | + public function getUserKarma($user = null) |
|
19 | + { |
|
20 | + $user = (null === $user) ? $GLOBALS['xoopsUser'] : $user; |
|
21 | 21 | |
22 | - return $this->calculateUserKarma($user); |
|
23 | - } |
|
22 | + return $this->calculateUserKarma($user); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Placeholder for calculating user karma |
|
27 | - * @param \XoopsUser $user |
|
28 | - * @return int |
|
29 | - */ |
|
30 | - public function calculateUserKarma($user) |
|
31 | - { |
|
32 | - if (!is_object($user)) { |
|
33 | - $user_karma = 0; |
|
34 | - } else { |
|
35 | - $user_karma = $user->getVar('posts') * 50; |
|
36 | - } |
|
25 | + /** |
|
26 | + * Placeholder for calculating user karma |
|
27 | + * @param \XoopsUser $user |
|
28 | + * @return int |
|
29 | + */ |
|
30 | + public function calculateUserKarma($user) |
|
31 | + { |
|
32 | + if (!is_object($user)) { |
|
33 | + $user_karma = 0; |
|
34 | + } else { |
|
35 | + $user_karma = $user->getVar('posts') * 50; |
|
36 | + } |
|
37 | 37 | |
38 | - return $user_karma; |
|
39 | - } |
|
38 | + return $user_karma; |
|
39 | + } |
|
40 | 40 | |
41 | - public function updateUserKarma() |
|
42 | - { |
|
43 | - } |
|
41 | + public function updateUserKarma() |
|
42 | + { |
|
43 | + } |
|
44 | 44 | |
45 | - public function writeUserKarma() |
|
46 | - { |
|
47 | - } |
|
45 | + public function writeUserKarma() |
|
46 | + { |
|
47 | + } |
|
48 | 48 | |
49 | - public function readUserKarma() |
|
50 | - { |
|
51 | - } |
|
49 | + public function readUserKarma() |
|
50 | + { |
|
51 | + } |
|
52 | 52 | } |
@@ -26,72 +26,72 @@ |
||
26 | 26 | */ |
27 | 27 | class Helper extends \Xmf\Module\Helper |
28 | 28 | { |
29 | - public $debug; |
|
29 | + public $debug; |
|
30 | 30 | |
31 | - /** |
|
32 | - * |
|
33 | - * @param bool $debug |
|
34 | - */ |
|
35 | - public function __construct($debug = false) |
|
36 | - { |
|
37 | - $this->debug = $debug; |
|
38 | - $moduleDirName = basename(dirname(__DIR__)); |
|
39 | - parent::__construct($moduleDirName); |
|
40 | - } |
|
31 | + /** |
|
32 | + * |
|
33 | + * @param bool $debug |
|
34 | + */ |
|
35 | + public function __construct($debug = false) |
|
36 | + { |
|
37 | + $this->debug = $debug; |
|
38 | + $moduleDirName = basename(dirname(__DIR__)); |
|
39 | + parent::__construct($moduleDirName); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param bool $debug |
|
44 | - * |
|
45 | - * @return \XoopsModules\Newbb\Helper |
|
46 | - */ |
|
47 | - public static function getInstance($debug = false) |
|
48 | - { |
|
49 | - static $instance; |
|
50 | - if (null === $instance) { |
|
51 | - $instance = new static($debug); |
|
52 | - } |
|
42 | + /** |
|
43 | + * @param bool $debug |
|
44 | + * |
|
45 | + * @return \XoopsModules\Newbb\Helper |
|
46 | + */ |
|
47 | + public static function getInstance($debug = false) |
|
48 | + { |
|
49 | + static $instance; |
|
50 | + if (null === $instance) { |
|
51 | + $instance = new static($debug); |
|
52 | + } |
|
53 | 53 | |
54 | - return $instance; |
|
55 | - } |
|
54 | + return $instance; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param null|string $name |
|
59 | - * @param null|string $value |
|
60 | - * |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - public function setConfig($name = null, $value = null) |
|
64 | - { |
|
65 | - if (null === $this->configs) { |
|
66 | - $this->initConfig(); |
|
67 | - } |
|
68 | - $this->configs[$name] = $value; |
|
69 | - $this->addLog("Setting config '{$name}' : " . $this->configs[$name]); |
|
57 | + /** |
|
58 | + * @param null|string $name |
|
59 | + * @param null|string $value |
|
60 | + * |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + public function setConfig($name = null, $value = null) |
|
64 | + { |
|
65 | + if (null === $this->configs) { |
|
66 | + $this->initConfig(); |
|
67 | + } |
|
68 | + $this->configs[$name] = $value; |
|
69 | + $this->addLog("Setting config '{$name}' : " . $this->configs[$name]); |
|
70 | 70 | |
71 | - return $this->configs[$name]; |
|
72 | - } |
|
71 | + return $this->configs[$name]; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getDirname() |
|
78 | - { |
|
79 | - return $this->dirname; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getDirname() |
|
78 | + { |
|
79 | + return $this->dirname; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Get an Object Handler |
|
84 | - * |
|
85 | - * @param string $name name of handler to load |
|
86 | - * |
|
87 | - * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
88 | - */ |
|
89 | - public function getHandler($name) |
|
90 | - { |
|
91 | - $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
92 | - $class = '\\XoopsModules\\' . ucfirst(strtolower(basename(dirname(__DIR__)))) . '\\' . $name . 'Handler'; |
|
93 | - $ret = new $class($db); |
|
82 | + /** |
|
83 | + * Get an Object Handler |
|
84 | + * |
|
85 | + * @param string $name name of handler to load |
|
86 | + * |
|
87 | + * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
88 | + */ |
|
89 | + public function getHandler($name) |
|
90 | + { |
|
91 | + $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
92 | + $class = '\\XoopsModules\\' . ucfirst(strtolower(basename(dirname(__DIR__)))) . '\\' . $name . 'Handler'; |
|
93 | + $ret = new $class($db); |
|
94 | 94 | |
95 | - return $ret; |
|
96 | - } |
|
95 | + return $ret; |
|
96 | + } |
|
97 | 97 | } |
@@ -30,208 +30,208 @@ discard block |
||
30 | 30 | require_once $GLOBALS['xoops']->path('class/tree.php'); |
31 | 31 | |
32 | 32 | if (!class_exists('ObjectTree')) { |
33 | - /** |
|
34 | - * Class ObjectTree |
|
35 | - */ |
|
36 | - class ObjectTree extends \XoopsObjectTree |
|
37 | - { |
|
38 | - /** |
|
39 | - * @param $objectArr |
|
40 | - * @param null $rootId |
|
41 | - */ |
|
42 | - public function __construct(&$objectArr, $rootId = null) |
|
43 | - { |
|
44 | - parent::__construct($objectArr, 'forum_id', 'parent_forum', $rootId); |
|
45 | - } |
|
33 | + /** |
|
34 | + * Class ObjectTree |
|
35 | + */ |
|
36 | + class ObjectTree extends \XoopsObjectTree |
|
37 | + { |
|
38 | + /** |
|
39 | + * @param $objectArr |
|
40 | + * @param null $rootId |
|
41 | + */ |
|
42 | + public function __construct(&$objectArr, $rootId = null) |
|
43 | + { |
|
44 | + parent::__construct($objectArr, 'forum_id', 'parent_forum', $rootId); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Make options for a select box from |
|
49 | - * |
|
50 | - * @param int $key ID of the object to display as the root of select options |
|
51 | - * @param string $ret (reference to a string when called from outside) Result from previous recursions |
|
52 | - * @param string $prefix_orig String to indent items at deeper levels |
|
53 | - * @param string $prefix_curr String to indent the current item |
|
54 | - * @param null|array $tags |
|
55 | - * @internal param string $fieldName Name of the member variable from the |
|
56 | - * node objects that should be used as the title for the options. |
|
57 | - * @internal param string $selected Value to display as selected |
|
58 | - * @access private |
|
59 | - */ |
|
60 | - protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $tags = null) |
|
61 | - { |
|
62 | - if ($key > 0) { |
|
63 | - if (count($tags) > 0) { |
|
64 | - foreach ($tags as $tag) { |
|
65 | - $ret[$key][$tag] = $this->tree[$key]['obj']->getVar($tag); |
|
66 | - } |
|
67 | - } else { |
|
68 | - $ret[$key]['forum_name'] = $this->tree[$key]['obj']->getVar('forum_name'); |
|
69 | - } |
|
70 | - $ret[$key]['prefix'] = $prefix_curr; |
|
71 | - $prefix_curr .= $prefix_orig; |
|
72 | - } |
|
73 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
74 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
75 | - $this->makeTreeItems($childkey, $ret, $prefix_orig, $prefix_curr, $tags); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
47 | + /** |
|
48 | + * Make options for a select box from |
|
49 | + * |
|
50 | + * @param int $key ID of the object to display as the root of select options |
|
51 | + * @param string $ret (reference to a string when called from outside) Result from previous recursions |
|
52 | + * @param string $prefix_orig String to indent items at deeper levels |
|
53 | + * @param string $prefix_curr String to indent the current item |
|
54 | + * @param null|array $tags |
|
55 | + * @internal param string $fieldName Name of the member variable from the |
|
56 | + * node objects that should be used as the title for the options. |
|
57 | + * @internal param string $selected Value to display as selected |
|
58 | + * @access private |
|
59 | + */ |
|
60 | + protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $tags = null) |
|
61 | + { |
|
62 | + if ($key > 0) { |
|
63 | + if (count($tags) > 0) { |
|
64 | + foreach ($tags as $tag) { |
|
65 | + $ret[$key][$tag] = $this->tree[$key]['obj']->getVar($tag); |
|
66 | + } |
|
67 | + } else { |
|
68 | + $ret[$key]['forum_name'] = $this->tree[$key]['obj']->getVar('forum_name'); |
|
69 | + } |
|
70 | + $ret[$key]['prefix'] = $prefix_curr; |
|
71 | + $prefix_curr .= $prefix_orig; |
|
72 | + } |
|
73 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
74 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
75 | + $this->makeTreeItems($childkey, $ret, $prefix_orig, $prefix_curr, $tags); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Make a select box with options from the tree |
|
82 | - * |
|
83 | - * @param string $prefix String to indent deeper levels |
|
84 | - * @param integer $key ID of the object to display as the root of select options |
|
85 | - * @param null $tags |
|
86 | - * @return array|string HTML select box |
|
87 | - * @internal param string $name Name of the select box |
|
88 | - * @internal param string $fieldName Name of the member variable from the |
|
89 | - * node objects that should be used as the title for the options. |
|
90 | - * @internal param string $selected Value to display as selected |
|
91 | - * @internal param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy |
|
92 | - */ |
|
93 | - public function &makeTree($prefix = '-', $key = 0, $tags = null) |
|
94 | - { |
|
95 | - $ret = []; |
|
96 | - $this->makeTreeItems($key, $ret, $prefix, '', $tags); |
|
80 | + /** |
|
81 | + * Make a select box with options from the tree |
|
82 | + * |
|
83 | + * @param string $prefix String to indent deeper levels |
|
84 | + * @param integer $key ID of the object to display as the root of select options |
|
85 | + * @param null $tags |
|
86 | + * @return array|string HTML select box |
|
87 | + * @internal param string $name Name of the select box |
|
88 | + * @internal param string $fieldName Name of the member variable from the |
|
89 | + * node objects that should be used as the title for the options. |
|
90 | + * @internal param string $selected Value to display as selected |
|
91 | + * @internal param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy |
|
92 | + */ |
|
93 | + public function &makeTree($prefix = '-', $key = 0, $tags = null) |
|
94 | + { |
|
95 | + $ret = []; |
|
96 | + $this->makeTreeItems($key, $ret, $prefix, '', $tags); |
|
97 | 97 | |
98 | - return $ret; |
|
99 | - } |
|
98 | + return $ret; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Make a select box with options from the tree |
|
103 | - * |
|
104 | - * @param string $name Name of the select box |
|
105 | - * @param string $fieldName Name of the member variable from the |
|
106 | - * node objects that should be used as the title for the options. |
|
107 | - * @param string $prefix String to indent deeper levels |
|
108 | - * @param string $selected Value to display as selected |
|
109 | - * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy |
|
110 | - * @param integer $key ID of the object to display as the root of select options |
|
111 | - * @param string $extra |
|
112 | - * @return string HTML select box |
|
113 | - * |
|
114 | - * @deprecated since 2.5.9, please use makeSelectElement() |
|
115 | - */ |
|
116 | - public function makeSelBox( |
|
117 | - $name, |
|
118 | - $fieldName, |
|
119 | - $prefix = '-', |
|
120 | - $selected = '', |
|
121 | - $addEmptyOption = false, |
|
122 | - $key = 0, |
|
123 | - $extra = '' |
|
124 | - ) //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0) |
|
125 | - { |
|
126 | - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
|
127 | - trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},"); |
|
101 | + /** |
|
102 | + * Make a select box with options from the tree |
|
103 | + * |
|
104 | + * @param string $name Name of the select box |
|
105 | + * @param string $fieldName Name of the member variable from the |
|
106 | + * node objects that should be used as the title for the options. |
|
107 | + * @param string $prefix String to indent deeper levels |
|
108 | + * @param string $selected Value to display as selected |
|
109 | + * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy |
|
110 | + * @param integer $key ID of the object to display as the root of select options |
|
111 | + * @param string $extra |
|
112 | + * @return string HTML select box |
|
113 | + * |
|
114 | + * @deprecated since 2.5.9, please use makeSelectElement() |
|
115 | + */ |
|
116 | + public function makeSelBox( |
|
117 | + $name, |
|
118 | + $fieldName, |
|
119 | + $prefix = '-', |
|
120 | + $selected = '', |
|
121 | + $addEmptyOption = false, |
|
122 | + $key = 0, |
|
123 | + $extra = '' |
|
124 | + ) //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0) |
|
125 | + { |
|
126 | + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
|
127 | + trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},"); |
|
128 | 128 | |
129 | - $ret = '<select name=' . $name . '>'; |
|
130 | - if (!empty($addEmptyOption)) { |
|
131 | - $ret .= '<option value="0">' . (is_string($EmptyOption) ? $EmptyOption : '') . '</option>'; |
|
132 | - } |
|
133 | - $this->_makeSelBoxOptions('forum_name', $selected, $key, $ret, $prefix); |
|
134 | - $ret .= '</select>'; |
|
129 | + $ret = '<select name=' . $name . '>'; |
|
130 | + if (!empty($addEmptyOption)) { |
|
131 | + $ret .= '<option value="0">' . (is_string($EmptyOption) ? $EmptyOption : '') . '</option>'; |
|
132 | + } |
|
133 | + $this->_makeSelBoxOptions('forum_name', $selected, $key, $ret, $prefix); |
|
134 | + $ret .= '</select>'; |
|
135 | 135 | |
136 | - return $ret; |
|
137 | - } |
|
136 | + return $ret; |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Make a tree for the array of a given category |
|
141 | - * |
|
142 | - * @param string $key top key of the tree |
|
143 | - * @param array $ret the tree |
|
144 | - * @param integer $depth level of subcategories |
|
145 | - * @return void |
|
146 | - * @internal param array $tags fields to be used |
|
147 | - */ |
|
148 | - public function getAllChildObject($key, &$ret, $depth = 0) |
|
149 | - { |
|
150 | - if (0 == --$depth) { |
|
151 | - return; |
|
152 | - } |
|
139 | + /** |
|
140 | + * Make a tree for the array of a given category |
|
141 | + * |
|
142 | + * @param string $key top key of the tree |
|
143 | + * @param array $ret the tree |
|
144 | + * @param integer $depth level of subcategories |
|
145 | + * @return void |
|
146 | + * @internal param array $tags fields to be used |
|
147 | + */ |
|
148 | + public function getAllChildObject($key, &$ret, $depth = 0) |
|
149 | + { |
|
150 | + if (0 == --$depth) { |
|
151 | + return; |
|
152 | + } |
|
153 | 153 | |
154 | - if (isset($this->tree[$key]['child'])) { |
|
155 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
156 | - if (isset($this->tree[$childkey]['obj'])) { |
|
157 | - $ret['child'][$childkey] = $this->tree[$childkey]['obj']; |
|
158 | - } |
|
159 | - $this->getAllChild_object($childkey, $ret['child'][$childkey], $depth); |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
154 | + if (isset($this->tree[$key]['child'])) { |
|
155 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
156 | + if (isset($this->tree[$childkey]['obj'])) { |
|
157 | + $ret['child'][$childkey] = $this->tree[$childkey]['obj']; |
|
158 | + } |
|
159 | + $this->getAllChild_object($childkey, $ret['child'][$childkey], $depth); |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
165 | - * Make a tree for the array |
|
166 | - * |
|
167 | - * @param int|string $key top key of the tree |
|
168 | - * @param integer $depth level of subcategories |
|
169 | - * @return array |
|
170 | - * @internal param array $tags fields to be used |
|
171 | - */ |
|
172 | - public function &makeObjectTree($key = 0, $depth = 0) |
|
173 | - { |
|
174 | - $ret = []; |
|
175 | - if ($depth > 0) { |
|
176 | - ++$depth; |
|
177 | - } |
|
178 | - $this->getAllChild_object($key, $ret, $depth); |
|
164 | + /** |
|
165 | + * Make a tree for the array |
|
166 | + * |
|
167 | + * @param int|string $key top key of the tree |
|
168 | + * @param integer $depth level of subcategories |
|
169 | + * @return array |
|
170 | + * @internal param array $tags fields to be used |
|
171 | + */ |
|
172 | + public function &makeObjectTree($key = 0, $depth = 0) |
|
173 | + { |
|
174 | + $ret = []; |
|
175 | + if ($depth > 0) { |
|
176 | + ++$depth; |
|
177 | + } |
|
178 | + $this->getAllChild_object($key, $ret, $depth); |
|
179 | 179 | |
180 | - return $ret; |
|
181 | - } |
|
180 | + return $ret; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Make a tree for the array of a given category |
|
185 | - * |
|
186 | - * @param string $key top key of the tree |
|
187 | - * @param array $ret the tree |
|
188 | - * @param array $tags fields to be used |
|
189 | - * @param integer $depth level of subcategories |
|
190 | - * @return void |
|
191 | - */ |
|
192 | - public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0) |
|
193 | - { |
|
194 | - if (0 == --$depth) { |
|
195 | - return; |
|
196 | - } |
|
183 | + /** |
|
184 | + * Make a tree for the array of a given category |
|
185 | + * |
|
186 | + * @param string $key top key of the tree |
|
187 | + * @param array $ret the tree |
|
188 | + * @param array $tags fields to be used |
|
189 | + * @param integer $depth level of subcategories |
|
190 | + * @return void |
|
191 | + */ |
|
192 | + public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0) |
|
193 | + { |
|
194 | + if (0 == --$depth) { |
|
195 | + return; |
|
196 | + } |
|
197 | 197 | |
198 | - if (isset($this->tree[$key]['child'])) { |
|
199 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
200 | - if (isset($this->tree[$childkey]['obj'])) { |
|
201 | - if (count($tags) > 0) { |
|
202 | - foreach ($tags as $tag) { |
|
203 | - $ret['child'][$childkey][$tag] = $this->tree[$childkey]['obj']->getVar($tag); |
|
204 | - } |
|
205 | - } else { |
|
206 | - $ret['child'][$childkey]['forum_name'] = $this->tree[$childkey]['obj']->getVar('forum_name'); |
|
207 | - } |
|
208 | - } |
|
198 | + if (isset($this->tree[$key]['child'])) { |
|
199 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
200 | + if (isset($this->tree[$childkey]['obj'])) { |
|
201 | + if (count($tags) > 0) { |
|
202 | + foreach ($tags as $tag) { |
|
203 | + $ret['child'][$childkey][$tag] = $this->tree[$childkey]['obj']->getVar($tag); |
|
204 | + } |
|
205 | + } else { |
|
206 | + $ret['child'][$childkey]['forum_name'] = $this->tree[$childkey]['obj']->getVar('forum_name'); |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - $this->getAllChildArray($childkey, $ret['child'][$childkey], $tags, $depth); |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
210 | + $this->getAllChildArray($childkey, $ret['child'][$childkey], $tags, $depth); |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Make a tree for the array |
|
217 | - * |
|
218 | - * @param int|string $key top key of the tree |
|
219 | - * @param array $tags fields to be used |
|
220 | - * @param integer $depth level of subcategories |
|
221 | - * @return array |
|
222 | - */ |
|
223 | - public function &makeArrayTree($key = 0, $tags = null, $depth = 0) |
|
224 | - { |
|
225 | - $ret = []; |
|
226 | - if ($depth > 0) { |
|
227 | - ++$depth; |
|
228 | - } |
|
229 | - $this->getAllChildArray($key, $ret, $tags, $depth); |
|
215 | + /** |
|
216 | + * Make a tree for the array |
|
217 | + * |
|
218 | + * @param int|string $key top key of the tree |
|
219 | + * @param array $tags fields to be used |
|
220 | + * @param integer $depth level of subcategories |
|
221 | + * @return array |
|
222 | + */ |
|
223 | + public function &makeArrayTree($key = 0, $tags = null, $depth = 0) |
|
224 | + { |
|
225 | + $ret = []; |
|
226 | + if ($depth > 0) { |
|
227 | + ++$depth; |
|
228 | + } |
|
229 | + $this->getAllChildArray($key, $ret, $tags, $depth); |
|
230 | 230 | |
231 | - return $ret; |
|
232 | - } |
|
231 | + return $ret; |
|
232 | + } |
|
233 | 233 | |
234 | - /**#@+ |
|
234 | + /**#@+ |
|
235 | 235 | * get all parent forums |
236 | 236 | * |
237 | 237 | * @param string $key ID of the child object |
@@ -239,49 +239,49 @@ discard block |
||
239 | 239 | * @param int $uplevel (empty when called from outside) level of recursion |
240 | 240 | * @return array Array of parent nodes. |
241 | 241 | */ |
242 | - public function &myGetParentForums($key, array $ret = [], $uplevel = 0) |
|
243 | - { |
|
244 | - if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { |
|
245 | - $ret[$uplevel] = $this->tree[$this->tree[$key]['parent']]['obj']; |
|
246 | - if ($this->tree[$key]['parent'] !== $key) { |
|
247 | - //$parents = $this->getParentForums($this->tree[$key]['parent'], $ret, $uplevel+1); |
|
248 | - $parents = $this->getParentForums($this->tree[$key]['parent']); |
|
249 | - foreach (array_keys($parents) as $newkey) { |
|
250 | - $ret[$newkey] = $parents[$newkey]; |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
242 | + public function &myGetParentForums($key, array $ret = [], $uplevel = 0) |
|
243 | + { |
|
244 | + if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { |
|
245 | + $ret[$uplevel] = $this->tree[$this->tree[$key]['parent']]['obj']; |
|
246 | + if ($this->tree[$key]['parent'] !== $key) { |
|
247 | + //$parents = $this->getParentForums($this->tree[$key]['parent'], $ret, $uplevel+1); |
|
248 | + $parents = $this->getParentForums($this->tree[$key]['parent']); |
|
249 | + foreach (array_keys($parents) as $newkey) { |
|
250 | + $ret[$newkey] = $parents[$newkey]; |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - return $ret; |
|
256 | - } |
|
255 | + return $ret; |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * @param $key |
|
260 | - * @param bool $reverse |
|
261 | - * @return array |
|
262 | - */ |
|
263 | - public function &getParentForums($key, $reverse = true) |
|
264 | - { |
|
265 | - $ret = []; |
|
266 | - $pids = []; |
|
267 | - if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { |
|
268 | - $pids[] = $this->tree[$this->tree[$key]['parent']]['obj']->getVar($this->myId); |
|
269 | - $parents = $this->myGetParentForums($this->tree[$key]['parent'], $ret); |
|
270 | - foreach (array_keys($parents) as $newkey) { |
|
271 | - if (!is_object($newkey)) { |
|
272 | - continue; |
|
273 | - } |
|
274 | - $ret[] = $parents[$newkey]->getVar($this->myId); |
|
275 | - } |
|
276 | - } |
|
277 | - if ($reverse) { |
|
278 | - $pids = array_reverse($ret) + $pids; |
|
279 | - } else { |
|
280 | - $pids += $ret; |
|
281 | - } |
|
258 | + /** |
|
259 | + * @param $key |
|
260 | + * @param bool $reverse |
|
261 | + * @return array |
|
262 | + */ |
|
263 | + public function &getParentForums($key, $reverse = true) |
|
264 | + { |
|
265 | + $ret = []; |
|
266 | + $pids = []; |
|
267 | + if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { |
|
268 | + $pids[] = $this->tree[$this->tree[$key]['parent']]['obj']->getVar($this->myId); |
|
269 | + $parents = $this->myGetParentForums($this->tree[$key]['parent'], $ret); |
|
270 | + foreach (array_keys($parents) as $newkey) { |
|
271 | + if (!is_object($newkey)) { |
|
272 | + continue; |
|
273 | + } |
|
274 | + $ret[] = $parents[$newkey]->getVar($this->myId); |
|
275 | + } |
|
276 | + } |
|
277 | + if ($reverse) { |
|
278 | + $pids = array_reverse($ret) + $pids; |
|
279 | + } else { |
|
280 | + $pids += $ret; |
|
281 | + } |
|
282 | 282 | |
283 | - return $pids; |
|
284 | - } |
|
285 | - /**#@-*/ |
|
286 | - } |
|
283 | + return $pids; |
|
284 | + } |
|
285 | + /**#@-*/ |
|
286 | + } |
|
287 | 287 | } |
@@ -24,105 +24,105 @@ |
||
24 | 24 | */ |
25 | 25 | class Xmlrss |
26 | 26 | { |
27 | - public $xml_version; |
|
28 | - public $rss_version; |
|
29 | - public $xml_encoding; |
|
27 | + public $xml_version; |
|
28 | + public $rss_version; |
|
29 | + public $xml_encoding; |
|
30 | 30 | |
31 | - public $channel_title; |
|
32 | - public $channel_link; |
|
33 | - public $channel_desc; |
|
34 | - public $channel_lastbuild; |
|
35 | - public $channel_webmaster; |
|
36 | - public $channel_editor; |
|
37 | - public $channel_category; |
|
38 | - public $channel_generator; |
|
39 | - public $channel_language; |
|
31 | + public $channel_title; |
|
32 | + public $channel_link; |
|
33 | + public $channel_desc; |
|
34 | + public $channel_lastbuild; |
|
35 | + public $channel_webmaster; |
|
36 | + public $channel_editor; |
|
37 | + public $channel_category; |
|
38 | + public $channel_generator; |
|
39 | + public $channel_language; |
|
40 | 40 | |
41 | - public $image_title; |
|
42 | - public $image_url; |
|
43 | - public $image_link; |
|
44 | - public $image_description; |
|
45 | - public $image_height; |
|
46 | - public $image_width; |
|
41 | + public $image_title; |
|
42 | + public $image_url; |
|
43 | + public $image_link; |
|
44 | + public $image_description; |
|
45 | + public $image_height; |
|
46 | + public $image_width; |
|
47 | 47 | |
48 | - public $max_items; |
|
49 | - public $max_item_description; |
|
50 | - public $items = []; |
|
48 | + public $max_items; |
|
49 | + public $max_item_description; |
|
50 | + public $items = []; |
|
51 | 51 | |
52 | - /** |
|
53 | - * |
|
54 | - */ |
|
55 | - public function __construct() |
|
56 | - { |
|
57 | - $this->xml_version = '1.0'; |
|
58 | - $this->xml_encoding = empty($GLOBALS['xoopsModuleConfig']['rss_utf8']) ? _CHARSET : 'UTF-8'; |
|
59 | - $this->rss_version = '2.0'; |
|
60 | - $this->image_height = 31; |
|
61 | - $this->image_width = 88; |
|
62 | - $this->max_items = 10; |
|
63 | - $this->max_item_description = 0; |
|
64 | - $this->items = []; |
|
65 | - } |
|
52 | + /** |
|
53 | + * |
|
54 | + */ |
|
55 | + public function __construct() |
|
56 | + { |
|
57 | + $this->xml_version = '1.0'; |
|
58 | + $this->xml_encoding = empty($GLOBALS['xoopsModuleConfig']['rss_utf8']) ? _CHARSET : 'UTF-8'; |
|
59 | + $this->rss_version = '2.0'; |
|
60 | + $this->image_height = 31; |
|
61 | + $this->image_width = 88; |
|
62 | + $this->max_items = 10; |
|
63 | + $this->max_item_description = 0; |
|
64 | + $this->items = []; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param $var |
|
69 | - * @param $val |
|
70 | - */ |
|
71 | - public function setVarRss($var, $val) |
|
72 | - { |
|
73 | - $this->$var = $this->cleanup($val); |
|
74 | - } |
|
67 | + /** |
|
68 | + * @param $var |
|
69 | + * @param $val |
|
70 | + */ |
|
71 | + public function setVarRss($var, $val) |
|
72 | + { |
|
73 | + $this->$var = $this->cleanup($val); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param $title |
|
78 | - * @param $link |
|
79 | - * @param string $description |
|
80 | - * @param string $label |
|
81 | - * @param int|string $pubdate |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - public function addItem($title, $link, $description = '', $label = '', $pubdate = 0) |
|
85 | - { |
|
86 | - if (count($this->items) < $this->max_items) { |
|
87 | - if (!empty($label)) { |
|
88 | - $label = '[' . $this->cleanup($label) . ']'; |
|
89 | - } |
|
90 | - if (!empty($description)) { |
|
91 | - $description = $this->cleanup($description, $this->max_item_description); |
|
92 | - //$description .= ' ' . $label; |
|
93 | - } else { |
|
94 | - //$description = $label; |
|
95 | - } |
|
76 | + /** |
|
77 | + * @param $title |
|
78 | + * @param $link |
|
79 | + * @param string $description |
|
80 | + * @param string $label |
|
81 | + * @param int|string $pubdate |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + public function addItem($title, $link, $description = '', $label = '', $pubdate = 0) |
|
85 | + { |
|
86 | + if (count($this->items) < $this->max_items) { |
|
87 | + if (!empty($label)) { |
|
88 | + $label = '[' . $this->cleanup($label) . ']'; |
|
89 | + } |
|
90 | + if (!empty($description)) { |
|
91 | + $description = $this->cleanup($description, $this->max_item_description); |
|
92 | + //$description .= ' ' . $label; |
|
93 | + } else { |
|
94 | + //$description = $label; |
|
95 | + } |
|
96 | 96 | |
97 | - $title = $this->cleanup($title) . ' ' . $label; |
|
98 | - $pubdate = $this->cleanup($pubdate); |
|
99 | - $this->items[] = [ |
|
100 | - 'title' => $title, |
|
101 | - 'link' => $link, |
|
102 | - 'guid' => $link, |
|
103 | - 'description' => $description, |
|
104 | - 'pubdate' => $pubdate |
|
105 | - ]; |
|
106 | - } |
|
97 | + $title = $this->cleanup($title) . ' ' . $label; |
|
98 | + $pubdate = $this->cleanup($pubdate); |
|
99 | + $this->items[] = [ |
|
100 | + 'title' => $title, |
|
101 | + 'link' => $link, |
|
102 | + 'guid' => $link, |
|
103 | + 'description' => $description, |
|
104 | + 'pubdate' => $pubdate |
|
105 | + ]; |
|
106 | + } |
|
107 | 107 | |
108 | - return true; |
|
109 | - } |
|
108 | + return true; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @param $text |
|
113 | - * @param int $trim |
|
114 | - * @return mixed|string |
|
115 | - */ |
|
116 | - public function cleanup($text, $trim = 0) |
|
117 | - { |
|
118 | - if ('utf-8' === strtolower($this->xml_encoding) && strncasecmp(_CHARSET, $this->xml_encoding, 5)) { |
|
119 | - $text = \XoopsLocal::convert_encoding($text, 'utf-8'); |
|
120 | - } |
|
121 | - if (!empty($trim)) { |
|
122 | - $text = xoops_substr($text, 0, (int)$trim); |
|
123 | - } |
|
124 | - $text = htmlspecialchars($text, ENT_QUOTES); |
|
111 | + /** |
|
112 | + * @param $text |
|
113 | + * @param int $trim |
|
114 | + * @return mixed|string |
|
115 | + */ |
|
116 | + public function cleanup($text, $trim = 0) |
|
117 | + { |
|
118 | + if ('utf-8' === strtolower($this->xml_encoding) && strncasecmp(_CHARSET, $this->xml_encoding, 5)) { |
|
119 | + $text = \XoopsLocal::convert_encoding($text, 'utf-8'); |
|
120 | + } |
|
121 | + if (!empty($trim)) { |
|
122 | + $text = xoops_substr($text, 0, (int)$trim); |
|
123 | + } |
|
124 | + $text = htmlspecialchars($text, ENT_QUOTES); |
|
125 | 125 | |
126 | - return $text; |
|
127 | - } |
|
126 | + return $text; |
|
127 | + } |
|
128 | 128 | } |
@@ -8,127 +8,127 @@ |
||
8 | 8 | */ |
9 | 9 | class Utility |
10 | 10 | { |
11 | - use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
|
12 | - |
|
13 | - use Common\ServerStats; // getServerStats Trait |
|
14 | - |
|
15 | - use Common\FilesManagement; // Files Management Trait |
|
16 | - |
|
17 | - //--------------- Custom module methods ----------------------------- |
|
18 | - |
|
19 | - /** |
|
20 | - * Verify that a mysql table exists |
|
21 | - * |
|
22 | - * @package News |
|
23 | - * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
24 | - * @copyright (c) Hervé Thouzard |
|
25 | - * @param $tablename |
|
26 | - * @return bool |
|
27 | - */ |
|
28 | - public function tableExists($tablename) |
|
29 | - { |
|
30 | - global $xoopsDB; |
|
31 | - /** @var \XoopsMySQLDatabase $xoopsDB */ |
|
32 | - $result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'"); |
|
33 | - |
|
34 | - return ($xoopsDB->getRowsNum($result) > 0); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Verify that a field exists inside a mysql table |
|
39 | - * |
|
40 | - * @package News |
|
41 | - * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
42 | - * @copyright (c) Hervé Thouzard |
|
43 | - * @param $fieldname |
|
44 | - * @param $table |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public function fieldExists($fieldname, $table) |
|
48 | - { |
|
49 | - global $xoopsDB; |
|
50 | - $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
|
51 | - |
|
52 | - return ($xoopsDB->getRowsNum($result) > 0); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Add a field to a mysql table |
|
57 | - * |
|
58 | - * @package News |
|
59 | - * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
60 | - * @copyright (c) Hervé Thouzard |
|
61 | - * @param $field |
|
62 | - * @param $table |
|
63 | - * @return bool|\mysqli_result |
|
64 | - */ |
|
65 | - public function addField($field, $table) |
|
66 | - { |
|
67 | - global $xoopsDB; |
|
68 | - $result = $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field"); |
|
69 | - |
|
70 | - return $result; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
75 | - * |
|
76 | - * @param string $folder Le chemin complet du répertoire à vérifier |
|
77 | - * |
|
78 | - * @return void |
|
79 | - */ |
|
80 | - public static function prepareFolder($folder) |
|
81 | - { |
|
82 | - try { |
|
83 | - if (!@mkdir($folder) && !is_dir($folder)) { |
|
84 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
85 | - } else { |
|
86 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
87 | - } |
|
88 | - } catch (\Exception $e) { |
|
89 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - public static function cleanCache() |
|
94 | - { |
|
95 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
96 | - if (method_exists($cacheHelper, 'clear')) { |
|
97 | - $cacheHelper->clear(); |
|
98 | - return; |
|
99 | - } |
|
100 | - // for 2.5 systems, clear everything |
|
101 | - require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php'; |
|
102 | - $maintenance = new \SystemMaintenance(); |
|
103 | - $cacheList = [ |
|
104 | - 3, // xoops_cache |
|
105 | - ]; |
|
106 | - $maintenance->CleanCache($cacheList); |
|
107 | - xoops_setActiveModules(); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Checks if a user is admin of NewBB |
|
112 | - * |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - public static function userIsAdmin() |
|
116 | - { |
|
117 | - /** @var Newbb\Helper $helper */ |
|
118 | - $helper = Newbb\Helper::getInstance(); |
|
119 | - |
|
120 | - static $newbbIsAdmin; |
|
121 | - |
|
122 | - if (isset($newbbIsAdmin)) { |
|
123 | - return $newbbIsAdmin; |
|
124 | - } |
|
125 | - |
|
126 | - if (!$GLOBALS['xoopsUser']) { |
|
127 | - $newbbIsAdmin = false; |
|
128 | - } else { |
|
129 | - $newbbIsAdmin = $GLOBALS['xoopsUser']->isAdmin($helper->getModule()->getVar('mid')); |
|
130 | - } |
|
131 | - |
|
132 | - return $newbbIsAdmin; |
|
133 | - } |
|
11 | + use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
|
12 | + |
|
13 | + use Common\ServerStats; // getServerStats Trait |
|
14 | + |
|
15 | + use Common\FilesManagement; // Files Management Trait |
|
16 | + |
|
17 | + //--------------- Custom module methods ----------------------------- |
|
18 | + |
|
19 | + /** |
|
20 | + * Verify that a mysql table exists |
|
21 | + * |
|
22 | + * @package News |
|
23 | + * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
24 | + * @copyright (c) Hervé Thouzard |
|
25 | + * @param $tablename |
|
26 | + * @return bool |
|
27 | + */ |
|
28 | + public function tableExists($tablename) |
|
29 | + { |
|
30 | + global $xoopsDB; |
|
31 | + /** @var \XoopsMySQLDatabase $xoopsDB */ |
|
32 | + $result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'"); |
|
33 | + |
|
34 | + return ($xoopsDB->getRowsNum($result) > 0); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Verify that a field exists inside a mysql table |
|
39 | + * |
|
40 | + * @package News |
|
41 | + * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
42 | + * @copyright (c) Hervé Thouzard |
|
43 | + * @param $fieldname |
|
44 | + * @param $table |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public function fieldExists($fieldname, $table) |
|
48 | + { |
|
49 | + global $xoopsDB; |
|
50 | + $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
|
51 | + |
|
52 | + return ($xoopsDB->getRowsNum($result) > 0); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Add a field to a mysql table |
|
57 | + * |
|
58 | + * @package News |
|
59 | + * @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
60 | + * @copyright (c) Hervé Thouzard |
|
61 | + * @param $field |
|
62 | + * @param $table |
|
63 | + * @return bool|\mysqli_result |
|
64 | + */ |
|
65 | + public function addField($field, $table) |
|
66 | + { |
|
67 | + global $xoopsDB; |
|
68 | + $result = $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field"); |
|
69 | + |
|
70 | + return $result; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
75 | + * |
|
76 | + * @param string $folder Le chemin complet du répertoire à vérifier |
|
77 | + * |
|
78 | + * @return void |
|
79 | + */ |
|
80 | + public static function prepareFolder($folder) |
|
81 | + { |
|
82 | + try { |
|
83 | + if (!@mkdir($folder) && !is_dir($folder)) { |
|
84 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
85 | + } else { |
|
86 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
87 | + } |
|
88 | + } catch (\Exception $e) { |
|
89 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + public static function cleanCache() |
|
94 | + { |
|
95 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
96 | + if (method_exists($cacheHelper, 'clear')) { |
|
97 | + $cacheHelper->clear(); |
|
98 | + return; |
|
99 | + } |
|
100 | + // for 2.5 systems, clear everything |
|
101 | + require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php'; |
|
102 | + $maintenance = new \SystemMaintenance(); |
|
103 | + $cacheList = [ |
|
104 | + 3, // xoops_cache |
|
105 | + ]; |
|
106 | + $maintenance->CleanCache($cacheList); |
|
107 | + xoops_setActiveModules(); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Checks if a user is admin of NewBB |
|
112 | + * |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + public static function userIsAdmin() |
|
116 | + { |
|
117 | + /** @var Newbb\Helper $helper */ |
|
118 | + $helper = Newbb\Helper::getInstance(); |
|
119 | + |
|
120 | + static $newbbIsAdmin; |
|
121 | + |
|
122 | + if (isset($newbbIsAdmin)) { |
|
123 | + return $newbbIsAdmin; |
|
124 | + } |
|
125 | + |
|
126 | + if (!$GLOBALS['xoopsUser']) { |
|
127 | + $newbbIsAdmin = false; |
|
128 | + } else { |
|
129 | + $newbbIsAdmin = $GLOBALS['xoopsUser']->isAdmin($helper->getModule()->getVar('mid')); |
|
130 | + } |
|
131 | + |
|
132 | + return $newbbIsAdmin; |
|
133 | + } |
|
134 | 134 | } |
@@ -21,15 +21,15 @@ |
||
21 | 21 | **/ |
22 | 22 | class Type extends \XoopsObject |
23 | 23 | { |
24 | - /** |
|
25 | - * |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - parent::__construct(); |
|
30 | - $this->initVar('type_id', XOBJ_DTYPE_INT); |
|
31 | - $this->initVar('type_name', XOBJ_DTYPE_TXTBOX, ''); |
|
32 | - $this->initVar('type_color', XOBJ_DTYPE_SOURCE, ''); |
|
33 | - $this->initVar('type_description', XOBJ_DTYPE_TXTBOX, ''); |
|
34 | - } |
|
24 | + /** |
|
25 | + * |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + parent::__construct(); |
|
30 | + $this->initVar('type_id', XOBJ_DTYPE_INT); |
|
31 | + $this->initVar('type_name', XOBJ_DTYPE_TXTBOX, ''); |
|
32 | + $this->initVar('type_color', XOBJ_DTYPE_SOURCE, ''); |
|
33 | + $this->initVar('type_description', XOBJ_DTYPE_TXTBOX, ''); |
|
34 | + } |
|
35 | 35 | } |
@@ -7,73 +7,73 @@ |
||
7 | 7 | */ |
8 | 8 | class IpCheck |
9 | 9 | { |
10 | - /** @var string */ |
|
11 | - private $ipin; |
|
10 | + /** @var string */ |
|
11 | + private $ipin; |
|
12 | 12 | |
13 | - /** @var string */ |
|
14 | - private $ipout; |
|
13 | + /** @var string */ |
|
14 | + private $ipout; |
|
15 | 15 | |
16 | - /** @var int */ |
|
17 | - private $ipver; |
|
16 | + /** @var int */ |
|
17 | + private $ipver; |
|
18 | 18 | |
19 | - // Return IP type. 4 for IPv4, 6 for IPv6, 0 for bad IP. |
|
19 | + // Return IP type. 4 for IPv4, 6 for IPv6, 0 for bad IP. |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param $ipValue |
|
23 | - */ |
|
24 | - public function addressType($ipValue) |
|
25 | - { |
|
26 | - $this->ipin = $ipValue; |
|
27 | - $this->ipver = 0; |
|
21 | + /** |
|
22 | + * @param $ipValue |
|
23 | + */ |
|
24 | + public function addressType($ipValue) |
|
25 | + { |
|
26 | + $this->ipin = $ipValue; |
|
27 | + $this->ipver = 0; |
|
28 | 28 | |
29 | - // IPv4 addresses are easy-peasy |
|
30 | - if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
31 | - $this->ipver = 4; |
|
32 | - $this->ipout = $this->ipin; |
|
33 | - } |
|
29 | + // IPv4 addresses are easy-peasy |
|
30 | + if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
31 | + $this->ipver = 4; |
|
32 | + $this->ipout = $this->ipin; |
|
33 | + } |
|
34 | 34 | |
35 | - // IPv6 is at least a little more complex. |
|
36 | - if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
|
35 | + // IPv6 is at least a little more complex. |
|
36 | + if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
|
37 | 37 | |
38 | - // Look for embedded IPv4 in an embedded IPv6 address, where FFFF is appended. |
|
39 | - if (0 === strncmp($this->ipin, '::FFFF:', 7)) { |
|
40 | - $ipv4addr = substr($this->ipin, 7); |
|
41 | - if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
42 | - $this->ipver = 4; |
|
43 | - $this->ipout = $ipv4addr; |
|
44 | - } |
|
38 | + // Look for embedded IPv4 in an embedded IPv6 address, where FFFF is appended. |
|
39 | + if (0 === strncmp($this->ipin, '::FFFF:', 7)) { |
|
40 | + $ipv4addr = substr($this->ipin, 7); |
|
41 | + if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
42 | + $this->ipver = 4; |
|
43 | + $this->ipout = $ipv4addr; |
|
44 | + } |
|
45 | 45 | |
46 | - // Look for an IPv4 address embedded as ::x.x.x.x |
|
47 | - } elseif (0 === strpos($this->ipin, '::')) { |
|
48 | - $ipv4addr = substr($this->ipin, 2); |
|
49 | - if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
50 | - $this->ipver = 4; |
|
51 | - $this->ipout = $ipv4addr; |
|
52 | - } |
|
46 | + // Look for an IPv4 address embedded as ::x.x.x.x |
|
47 | + } elseif (0 === strpos($this->ipin, '::')) { |
|
48 | + $ipv4addr = substr($this->ipin, 2); |
|
49 | + if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
50 | + $this->ipver = 4; |
|
51 | + $this->ipout = $ipv4addr; |
|
52 | + } |
|
53 | 53 | |
54 | - // Otherwise, assume this an IPv6 address. |
|
55 | - } else { |
|
56 | - $this->ipver = 6; |
|
57 | - $this->ipout = $this->ipin; |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
54 | + // Otherwise, assume this an IPv6 address. |
|
55 | + } else { |
|
56 | + $this->ipver = 6; |
|
57 | + $this->ipout = $this->ipin; |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** Check whether the given address is an IP address |
|
63 | - * |
|
64 | - * @param string $ip Given IP address |
|
65 | - * |
|
66 | - * @return string A if IPv4, AAAA if IPv6 or 0 if invalid |
|
67 | - */ |
|
68 | - public function isValidIpAddress($ip) |
|
69 | - { |
|
70 | - $value = 0; |
|
71 | - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
72 | - $value = 'A'; |
|
73 | - } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
|
74 | - $value = 'AAAA'; |
|
75 | - } |
|
62 | + /** Check whether the given address is an IP address |
|
63 | + * |
|
64 | + * @param string $ip Given IP address |
|
65 | + * |
|
66 | + * @return string A if IPv4, AAAA if IPv6 or 0 if invalid |
|
67 | + */ |
|
68 | + public function isValidIpAddress($ip) |
|
69 | + { |
|
70 | + $value = 0; |
|
71 | + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
72 | + $value = 'A'; |
|
73 | + } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
|
74 | + $value = 'AAAA'; |
|
75 | + } |
|
76 | 76 | |
77 | - return $value; |
|
78 | - } |
|
77 | + return $value; |
|
78 | + } |
|
79 | 79 | } |
@@ -24,12 +24,12 @@ |
||
24 | 24 | */ |
25 | 25 | class Constants |
26 | 26 | { |
27 | - /**#@+ |
|
27 | + /**#@+ |
|
28 | 28 | * Constant definition |
29 | 29 | */ |
30 | 30 | |
31 | - const DISALLOW = 0; |
|
31 | + const DISALLOW = 0; |
|
32 | 32 | |
33 | - /**#@-*/ |
|
33 | + /**#@-*/ |
|
34 | 34 | } |
35 | 35 |
@@ -44,17 +44,17 @@ |
||
44 | 44 | */ |
45 | 45 | class Read extends \XoopsObject |
46 | 46 | { |
47 | - /** |
|
48 | - * @internal param $type |
|
49 | - */ |
|
50 | - public function __construct() |
|
51 | - { |
|
52 | - // parent::__construct("newbb_reads_" . $type); |
|
53 | - parent::__construct(); |
|
54 | - $this->initVar('read_id', XOBJ_DTYPE_INT); |
|
55 | - $this->initVar('uid', XOBJ_DTYPE_INT); |
|
56 | - $this->initVar('read_item', XOBJ_DTYPE_INT); |
|
57 | - $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
58 | - $this->initVar('read_time', XOBJ_DTYPE_INT); |
|
59 | - } |
|
47 | + /** |
|
48 | + * @internal param $type |
|
49 | + */ |
|
50 | + public function __construct() |
|
51 | + { |
|
52 | + // parent::__construct("newbb_reads_" . $type); |
|
53 | + parent::__construct(); |
|
54 | + $this->initVar('read_id', XOBJ_DTYPE_INT); |
|
55 | + $this->initVar('uid', XOBJ_DTYPE_INT); |
|
56 | + $this->initVar('read_item', XOBJ_DTYPE_INT); |
|
57 | + $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
58 | + $this->initVar('read_time', XOBJ_DTYPE_INT); |
|
59 | + } |
|
60 | 60 | } |