Passed
Push — master ( 492cc7...e5a5fc )
by Michael
45s queued 11s
created
include/functions.forum.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -17,198 +17,198 @@
 block discarded – undo
17 17
 define('NEWBB_FUNCTIONS_FORUM_LOADED', true);
18 18
 
19 19
 if (!defined('NEWBB_FUNCTIONS_FORUM')) {
20
-    define('NEWBB_FUNCTIONS_FORUM', 1);
21
-
22
-    /**
23
-     * @param  null|array $value             selected forum id
24
-     * @param  string     $permission        permission (access, all, etc.)
25
-     * @param  bool       $categoryDelimiter show delimiter between categories
26
-     * @param  bool       $see
27
-     * @return string
28
-     */
29
-    function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false)
30
-    {
31
-        global $xoopsUser;
32
-        /** @var Newbb\CategoryHandler $categoryHandler */
33
-        $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
34
-        $categories      = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
35
-
36
-        $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
37
-
38
-        $groups = [XOOPS_GROUP_ANONYMOUS];
39
-        if (is_object($xoopsUser)) {
40
-            $groups = $xoopsUser->getGroups();
41
-        }
42
-        sort($groups);
43
-        $groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups));
44
-        $forums   = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) {
45
-            /** @var Newbb\CategoryHandler $categoryHandler */
46
-            $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
47
-            $categories      = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
48
-
49
-            /** @var Newbb\ForumHandler $forumHandler */
50
-            $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
51
-            $forums       = $forumHandler->getTree(array_keys($categories), 0, 'all');
52
-
53
-            return $forums;
54
-        }, 300);
55
-
56
-        $value = is_array($value) ? $value : [$value];
57
-        //$see = is_array($see) ? $see : array($see);
58
-        $box = '';
59
-        if (count($forums) > 0) {
60
-            foreach (array_keys($categories) as $key) {
61
-                if ($categoryDelimiter) {
62
-                    $box .= "<option value=0>&nbsp;</option>\n";
63
-                }
64
-                $box .= "<option value='" . (-1 * $key) . "'>[" . $categories[$key]['cat_title'] . "]</option>\n";
65
-                if (empty($forums[$key])) {
66
-                    continue;
67
-                }
68
-                foreach ($forums[$key] as $f => $forum) {
69
-                    if ($see && in_array($f, $value)) {
70
-                        continue;
71
-                    }
72
-                    $box .= "<option value='{$f}' " . (in_array($f, $value) ? ' selected' : '') . '>' . $forum['prefix'] . $forum['forum_name'] . "</option>\n";
73
-                }
74
-            }
75
-        } else {
76
-            $box .= '<option value=0>' . _MD_NEWBB_NOFORUMINDB . "</option>\n";
77
-        }
78
-        unset($forums, $categories);
79
-
80
-        return $box;
81
-    }
82
-
83
-    /**
84
-     * @param  int $forum_id
85
-     * @return string
86
-     */
87
-    function newbbMakeJumpbox($forum_id = 0)
88
-    {
89
-        $box = '<form name="forum_jumpbox" method="get" action="' . XOOPS_URL . '/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value &lt; 1) {return false;}">';
90
-        $box .= '<select class="select" name="forum" onchange="if (this.options[this.selectedIndex].value >0) { document.forms.forum_jumpbox.submit();}">';
91
-        $box .= '<option value=0>-- ' . _MD_NEWBB_SELFORUM . ' --</option>';
92
-        $box .= newbbForumSelectBox($forum_id);
93
-        $box .= "</select> <input type='submit' class='button' value='" . _GO . "' /></form>";
94
-        unset($forums, $categories);
95
-
96
-        return $box;
97
-    }
98
-
99
-    /**
100
-     * Get structured forums
101
-     *
102
-     * This is a temporary solution
103
-     * To be substituted with a new tree handler
104
-     *
105
-     * @int integer    $pid    parent forum ID
106
-     *
107
-     * @param  int  $pid
108
-     * @param  bool $refresh
109
-     * @return array
110
-     */
111
-    function newbbGetSubForum($pid = 0, $refresh = false)
112
-    {
113
-        static $list;
114
-        if (null === $list) {
115
-            $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
116
-            $list        = $cacheHelper->read('forum_sub');
117
-        }
118
-
119
-        if (!is_array($list) || $refresh) {
120
-            $list = newbbCreateSubForumList();
121
-        }
122
-        if (0 == $pid) {
123
-            return $list;
124
-        } else {
125
-            return @$list[$pid];
126
-        }
127
-    }
128
-
129
-    /**
130
-     * @return array
131
-     */
132
-    function newbbCreateSubForumList()
133
-    {
134
-        /** @var Newbb\ForumHandler $forumHandler */
20
+	define('NEWBB_FUNCTIONS_FORUM', 1);
21
+
22
+	/**
23
+	 * @param  null|array $value             selected forum id
24
+	 * @param  string     $permission        permission (access, all, etc.)
25
+	 * @param  bool       $categoryDelimiter show delimiter between categories
26
+	 * @param  bool       $see
27
+	 * @return string
28
+	 */
29
+	function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false)
30
+	{
31
+		global $xoopsUser;
32
+		/** @var Newbb\CategoryHandler $categoryHandler */
33
+		$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
34
+		$categories      = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
35
+
36
+		$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
37
+
38
+		$groups = [XOOPS_GROUP_ANONYMOUS];
39
+		if (is_object($xoopsUser)) {
40
+			$groups = $xoopsUser->getGroups();
41
+		}
42
+		sort($groups);
43
+		$groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups));
44
+		$forums   = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) {
45
+			/** @var Newbb\CategoryHandler $categoryHandler */
46
+			$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
47
+			$categories      = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
48
+
49
+			/** @var Newbb\ForumHandler $forumHandler */
50
+			$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
51
+			$forums       = $forumHandler->getTree(array_keys($categories), 0, 'all');
52
+
53
+			return $forums;
54
+		}, 300);
55
+
56
+		$value = is_array($value) ? $value : [$value];
57
+		//$see = is_array($see) ? $see : array($see);
58
+		$box = '';
59
+		if (count($forums) > 0) {
60
+			foreach (array_keys($categories) as $key) {
61
+				if ($categoryDelimiter) {
62
+					$box .= "<option value=0>&nbsp;</option>\n";
63
+				}
64
+				$box .= "<option value='" . (-1 * $key) . "'>[" . $categories[$key]['cat_title'] . "]</option>\n";
65
+				if (empty($forums[$key])) {
66
+					continue;
67
+				}
68
+				foreach ($forums[$key] as $f => $forum) {
69
+					if ($see && in_array($f, $value)) {
70
+						continue;
71
+					}
72
+					$box .= "<option value='{$f}' " . (in_array($f, $value) ? ' selected' : '') . '>' . $forum['prefix'] . $forum['forum_name'] . "</option>\n";
73
+				}
74
+			}
75
+		} else {
76
+			$box .= '<option value=0>' . _MD_NEWBB_NOFORUMINDB . "</option>\n";
77
+		}
78
+		unset($forums, $categories);
79
+
80
+		return $box;
81
+	}
82
+
83
+	/**
84
+	 * @param  int $forum_id
85
+	 * @return string
86
+	 */
87
+	function newbbMakeJumpbox($forum_id = 0)
88
+	{
89
+		$box = '<form name="forum_jumpbox" method="get" action="' . XOOPS_URL . '/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value &lt; 1) {return false;}">';
90
+		$box .= '<select class="select" name="forum" onchange="if (this.options[this.selectedIndex].value >0) { document.forms.forum_jumpbox.submit();}">';
91
+		$box .= '<option value=0>-- ' . _MD_NEWBB_SELFORUM . ' --</option>';
92
+		$box .= newbbForumSelectBox($forum_id);
93
+		$box .= "</select> <input type='submit' class='button' value='" . _GO . "' /></form>";
94
+		unset($forums, $categories);
95
+
96
+		return $box;
97
+	}
98
+
99
+	/**
100
+	 * Get structured forums
101
+	 *
102
+	 * This is a temporary solution
103
+	 * To be substituted with a new tree handler
104
+	 *
105
+	 * @int integer    $pid    parent forum ID
106
+	 *
107
+	 * @param  int  $pid
108
+	 * @param  bool $refresh
109
+	 * @return array
110
+	 */
111
+	function newbbGetSubForum($pid = 0, $refresh = false)
112
+	{
113
+		static $list;
114
+		if (null === $list) {
115
+			$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
116
+			$list        = $cacheHelper->read('forum_sub');
117
+		}
118
+
119
+		if (!is_array($list) || $refresh) {
120
+			$list = newbbCreateSubForumList();
121
+		}
122
+		if (0 == $pid) {
123
+			return $list;
124
+		} else {
125
+			return @$list[$pid];
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * @return array
131
+	 */
132
+	function newbbCreateSubForumList()
133
+	{
134
+		/** @var Newbb\ForumHandler $forumHandler */
135 135
 //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
136
-        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
137
-        $criteria     = new \CriteriaCompo(null, 1);
138
-        $criteria->setSort('cat_id ASC, parent_forum ASC, forum_order');
139
-        $criteria->setOrder('ASC');
140
-        $forumsObject = $forumHandler->getObjects($criteria);
136
+		$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
137
+		$criteria     = new \CriteriaCompo(null, 1);
138
+		$criteria->setSort('cat_id ASC, parent_forum ASC, forum_order');
139
+		$criteria->setOrder('ASC');
140
+		$forumsObject = $forumHandler->getObjects($criteria);
141 141
 //        require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php');
142
-        $tree        = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
143
-        $forum_array = [];
144
-        foreach (array_keys($forumsObject) as $key) {
145
-            if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) {
146
-                continue;
147
-            }
148
-            $forum_array[$forumsObject[$key]->getVar('forum_id')] = $child;
149
-        }
150
-        unset($forumsObject, $tree, $criteria);
151
-
152
-        $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
153
-        $cacheHelper->write('forum_sub', $forum_array);
154
-
155
-        return $forum_array;
156
-    }
157
-
158
-    /**
159
-     * @param  int  $forum_id
160
-     * @param  bool $refresh
161
-     * @return array|mixed|null
162
-     */
163
-    function newbbGetParentForum($forum_id = 0, $refresh = false)
164
-    {
165
-        static $list = null;
166
-
167
-        if (null === $list) {
168
-            $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
169
-            $list        = $cacheHelper->read('forum_parent');
170
-        }
171
-        if (!is_array($list) || $refresh) {
172
-            $list = newbbCreateParentForumList();
173
-        }
174
-        if (0 == $forum_id) {
175
-            return $list;
176
-        } else {
177
-            return @$list[$forum_id];
178
-        }
179
-    }
180
-
181
-    /**
182
-     * @return array
183
-     */
184
-    function newbbCreateParentForumList()
185
-    {
186
-        /** @var Newbb\ForumHandler $forumHandler */
187
-        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
188
-        $criteria     = new \Criteria('1', 1);
189
-        $criteria->setSort('parent_forum');
190
-        $criteria->setOrder('ASC');
191
-        $forumsObject = $forumHandler->getObjects($criteria);
142
+		$tree        = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
143
+		$forum_array = [];
144
+		foreach (array_keys($forumsObject) as $key) {
145
+			if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) {
146
+				continue;
147
+			}
148
+			$forum_array[$forumsObject[$key]->getVar('forum_id')] = $child;
149
+		}
150
+		unset($forumsObject, $tree, $criteria);
151
+
152
+		$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
153
+		$cacheHelper->write('forum_sub', $forum_array);
154
+
155
+		return $forum_array;
156
+	}
157
+
158
+	/**
159
+	 * @param  int  $forum_id
160
+	 * @param  bool $refresh
161
+	 * @return array|mixed|null
162
+	 */
163
+	function newbbGetParentForum($forum_id = 0, $refresh = false)
164
+	{
165
+		static $list = null;
166
+
167
+		if (null === $list) {
168
+			$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
169
+			$list        = $cacheHelper->read('forum_parent');
170
+		}
171
+		if (!is_array($list) || $refresh) {
172
+			$list = newbbCreateParentForumList();
173
+		}
174
+		if (0 == $forum_id) {
175
+			return $list;
176
+		} else {
177
+			return @$list[$forum_id];
178
+		}
179
+	}
180
+
181
+	/**
182
+	 * @return array
183
+	 */
184
+	function newbbCreateParentForumList()
185
+	{
186
+		/** @var Newbb\ForumHandler $forumHandler */
187
+		$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
188
+		$criteria     = new \Criteria('1', 1);
189
+		$criteria->setSort('parent_forum');
190
+		$criteria->setOrder('ASC');
191
+		$forumsObject = $forumHandler->getObjects($criteria);
192 192
 //        require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php');
193
-        $tree        = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
194
-        $forum_array = [];
195
-        foreach (array_keys($forumsObject) as $key) {
196
-            $parent_forum = $forumsObject[$key]->getVar('parent_forum');
197
-            if (!$parent_forum) {
198
-                continue;
199
-            }
200
-            if (isset($forum_array[$parent_forum])) {
201
-                $forum_array[$forumsObject[$key]->getVar('forum_id')]   = $forum_array[$parent_forum];
202
-                $forum_array[$forumsObject[$key]->getVar('forum_id')][] = $parent_forum;
203
-            } else {
204
-                $forum_array[$forumsObject[$key]->getVar('forum_id')] = $tree->getParentForums($forumsObject[$key]->getVar('forum_id'));
205
-            }
206
-        }
207
-        unset($forumsObject, $tree, $criteria);
208
-
209
-        $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
210
-        $cacheHelper->write('forum_parent', $forum_array);
211
-
212
-        return $forum_array;
213
-    }
193
+		$tree        = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
194
+		$forum_array = [];
195
+		foreach (array_keys($forumsObject) as $key) {
196
+			$parent_forum = $forumsObject[$key]->getVar('parent_forum');
197
+			if (!$parent_forum) {
198
+				continue;
199
+			}
200
+			if (isset($forum_array[$parent_forum])) {
201
+				$forum_array[$forumsObject[$key]->getVar('forum_id')]   = $forum_array[$parent_forum];
202
+				$forum_array[$forumsObject[$key]->getVar('forum_id')][] = $parent_forum;
203
+			} else {
204
+				$forum_array[$forumsObject[$key]->getVar('forum_id')] = $tree->getParentForums($forumsObject[$key]->getVar('forum_id'));
205
+			}
206
+		}
207
+		unset($forumsObject, $tree, $criteria);
208
+
209
+		$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
210
+		$cacheHelper->write('forum_parent', $forum_array);
211
+
212
+		return $forum_array;
213
+	}
214 214
 }
Please login to merge, or discard this patch.
include/search.inc.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -28,119 +28,119 @@
 block discarded – undo
28 28
  * @return array
29 29
  */
30 30
 function newbb_search(
31
-    $queryarray,
32
-    $andor,
33
-    $limit,
34
-    $offset,
35
-    $userid,
36
-    $forums = 0,
37
-    $sortby = 0,
38
-    $searchin = 'both',
39
-    CriteriaCompo $criteriaExtra = null
31
+	$queryarray,
32
+	$andor,
33
+	$limit,
34
+	$offset,
35
+	$userid,
36
+	$forums = 0,
37
+	$sortby = 0,
38
+	$searchin = 'both',
39
+	CriteriaCompo $criteriaExtra = null
40 40
 ) {
41
-    global $myts, $xoopsDB;
42
-    // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
43
-    if (!isset($GLOBALS['xoopsModuleConfig'])) {
44
-        $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig();
45
-    }
46
-    // irmtfan - in XOOPSCORE/search.php $xoopsModule is not set
47
-    if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module'])
48
-        && 'newbb' === $GLOBALS['module']->getVar('dirname')) {
49
-        $GLOBALS['xoopsModule'] = $GLOBALS['module'];
50
-    }
51
-    /** @var Newbb\ForumHandler $forumHandler */
52
-    $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
53
-    $validForums  = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
41
+	global $myts, $xoopsDB;
42
+	// irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
43
+	if (!isset($GLOBALS['xoopsModuleConfig'])) {
44
+		$GLOBALS['xoopsModuleConfig'] = newbbLoadConfig();
45
+	}
46
+	// irmtfan - in XOOPSCORE/search.php $xoopsModule is not set
47
+	if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module'])
48
+		&& 'newbb' === $GLOBALS['module']->getVar('dirname')) {
49
+		$GLOBALS['xoopsModule'] = $GLOBALS['module'];
50
+	}
51
+	/** @var Newbb\ForumHandler $forumHandler */
52
+	$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
53
+	$validForums  = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
54 54
 
55
-    $criteriaPost = new \CriteriaCompo();
56
-    $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
55
+	$criteriaPost = new \CriteriaCompo();
56
+	$criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
57 57
 
58
-    $forum_list = [];// get forum lists just for forum names
59
-    if (count($validForums) > 0) {
60
-        $criteriaPermissions = new \CriteriaCompo();
61
-        $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
-        $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
63
-    }
58
+	$forum_list = [];// get forum lists just for forum names
59
+	if (count($validForums) > 0) {
60
+		$criteriaPermissions = new \CriteriaCompo();
61
+		$criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
+		$forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
63
+	}
64 64
 
65
-    if (is_numeric($userid) && 0 !== $userid) {
66
-        $criteriaUser = new \CriteriaCompo();
67
-        $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
68
-    } elseif (is_array($userid) && count($userid) > 0) {
69
-        $userid       = array_map('intval', $userid);
70
-        $criteriaUser = new \CriteriaCompo();
71
-        $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
72
-    }
65
+	if (is_numeric($userid) && 0 !== $userid) {
66
+		$criteriaUser = new \CriteriaCompo();
67
+		$criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
68
+	} elseif (is_array($userid) && count($userid) > 0) {
69
+		$userid       = array_map('intval', $userid);
70
+		$criteriaUser = new \CriteriaCompo();
71
+		$criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
72
+	}
73 73
 
74
-    $count = 0;
75
-    if (is_array($queryarray)) {
76
-        $count = count($queryarray);
77
-    }
78
-    $highlightKey = '';
79
-    if ($count > 0) {
80
-        $criteriaKeywords = new \CriteriaCompo();
81
-        foreach ($queryarray as $queryTerm) {
82
-            $termCriteria  = new \CriteriaCompo();
83
-            $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
84
-            if ('title' === $searchin || 'both' === $searchin) {
85
-                $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86
-            }
87
-            if ('text' === $searchin || 'both' === $searchin) {
88
-                $termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR');
89
-            }
90
-            $criteriaKeywords->add($termCriteria, $andor);
91
-        }
92
-        // add highlight keywords to post links
93
-        $highlightKey = '&amp;keywords=' . implode(' ', $queryarray);
94
-        $highlightKey = str_replace(' ', '+', $highlightKey);
95
-    }
96
-    $criteria = new \CriteriaCompo();
97
-    $criteria->add($criteriaPost, 'AND');
98
-    if (null !== $criteriaPermissions) {
99
-        $criteria->add($criteriaPermissions, 'AND');
100
-    }
101
-    if (isset($criteriaUser)) {
102
-        $criteria->add($criteriaUser, 'AND');
103
-    }
104
-    if (isset($criteriaKeywords)) {
105
-        $criteria->add($criteriaKeywords, 'AND');
106
-    }
107
-    if (isset($criteriaExtra)) {
108
-        $criteria->add($criteriaExtra, 'AND');
109
-    }
110
-    //$criteria->setLimit($limit); // no need for this
111
-    //$criteria->setStart($offset); // no need for this
74
+	$count = 0;
75
+	if (is_array($queryarray)) {
76
+		$count = count($queryarray);
77
+	}
78
+	$highlightKey = '';
79
+	if ($count > 0) {
80
+		$criteriaKeywords = new \CriteriaCompo();
81
+		foreach ($queryarray as $queryTerm) {
82
+			$termCriteria  = new \CriteriaCompo();
83
+			$queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
84
+			if ('title' === $searchin || 'both' === $searchin) {
85
+				$termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86
+			}
87
+			if ('text' === $searchin || 'both' === $searchin) {
88
+				$termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR');
89
+			}
90
+			$criteriaKeywords->add($termCriteria, $andor);
91
+		}
92
+		// add highlight keywords to post links
93
+		$highlightKey = '&amp;keywords=' . implode(' ', $queryarray);
94
+		$highlightKey = str_replace(' ', '+', $highlightKey);
95
+	}
96
+	$criteria = new \CriteriaCompo();
97
+	$criteria->add($criteriaPost, 'AND');
98
+	if (null !== $criteriaPermissions) {
99
+		$criteria->add($criteriaPermissions, 'AND');
100
+	}
101
+	if (isset($criteriaUser)) {
102
+		$criteria->add($criteriaUser, 'AND');
103
+	}
104
+	if (isset($criteriaKeywords)) {
105
+		$criteria->add($criteriaKeywords, 'AND');
106
+	}
107
+	if (isset($criteriaExtra)) {
108
+		$criteria->add($criteriaExtra, 'AND');
109
+	}
110
+	//$criteria->setLimit($limit); // no need for this
111
+	//$criteria->setStart($offset); // no need for this
112 112
 
113
-    if (empty($sortby)) {
114
-        $sortby = 'p.post_time';
115
-    }
116
-    $criteria->setSort($sortby);
117
-    $order = 'ASC';
118
-    if ('p.post_time' === $sortby) {
119
-        $order = 'DESC';
120
-    }
121
-    $criteria->setOrder($order);
113
+	if (empty($sortby)) {
114
+		$sortby = 'p.post_time';
115
+	}
116
+	$criteria->setSort($sortby);
117
+	$order = 'ASC';
118
+	if ('p.post_time' === $sortby) {
119
+		$order = 'DESC';
120
+	}
121
+	$criteria->setOrder($order);
122 122
 
123
-    /** @var Newbb\PostHandler $postHandler */
124
-    $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
125
-    $posts       = $postHandler->getPostsByLimit($criteria, $limit, $offset);
123
+	/** @var Newbb\PostHandler $postHandler */
124
+	$postHandler = Newbb\Helper::getInstance()->getHandler('Post');
125
+	$posts       = $postHandler->getPostsByLimit($criteria, $limit, $offset);
126 126
 
127
-    $ret = [];
128
-    $i   = 0;
129
-    foreach (array_keys($posts) as $id) {
130
-        /** @var Newbb\Post $post */
131
-        $post                  = $posts[$id];
132
-        $post_data             = $post->getPostBody();
133
-        $ret[$i]['topic_id']   = $post->getVar('topic_id');
134
-        $ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
135
-        $ret[$i]['title']      = $post_data['subject'];
136
-        $ret[$i]['time']       = $post_data['date'];
137
-        $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
-        $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
139
-        $ret[$i]['post_text']  = $post_data['text'];
140
-        $ret[$i]['uid']        = $post->getVar('uid');
141
-        $ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
142
-        ++$i;
143
-    }
127
+	$ret = [];
128
+	$i   = 0;
129
+	foreach (array_keys($posts) as $id) {
130
+		/** @var Newbb\Post $post */
131
+		$post                  = $posts[$id];
132
+		$post_data             = $post->getPostBody();
133
+		$ret[$i]['topic_id']   = $post->getVar('topic_id');
134
+		$ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
135
+		$ret[$i]['title']      = $post_data['subject'];
136
+		$ret[$i]['time']       = $post_data['date'];
137
+		$ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
+		$ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
139
+		$ret[$i]['post_text']  = $post_data['text'];
140
+		$ret[$i]['uid']        = $post->getVar('uid');
141
+		$ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
142
+		++$i;
143
+	}
144 144
 
145
-    return $ret;
145
+	return $ret;
146 146
 }
Please login to merge, or discard this patch.
include/functions.render.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -17,146 +17,146 @@
 block discarded – undo
17 17
 define('NEWBB_FUNCTIONS_RENDER_LOADED', true);
18 18
 
19 19
 if (!defined('NEWBB_FUNCTIONS_RENDER')) {
20
-    define('NEWBB_FUNCTIONS_RENDER', 1);
20
+	define('NEWBB_FUNCTIONS_RENDER', 1);
21 21
 
22
-    /*
22
+	/*
23 23
      * Sorry, we have to use the stupid solution unless there is an option in MyTextSanitizer:: htmlspecialchars();
24 24
      */
25
-    /**
26
-     * @param $text
27
-     * @return mixed
28
-     */
29
-    function newbbHtmlspecialchars(&$text)
30
-    {
31
-        return preg_replace(['/&amp;/i', '/&nbsp;/i'], ['&', '&amp;nbsp;'], htmlspecialchars($text, ENT_QUOTES | ENT_HTML5));
32
-    }
33
-
34
-    /**
35
-     * @param        $text
36
-     * @param  int   $html
37
-     * @param  int   $smiley
38
-     * @param  int   $xcode
39
-     * @param  int   $image
40
-     * @param  int   $br
41
-     * @return mixed
42
-     */
43
-    function &newbbDisplayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
44
-    {
45
-        global $myts;
46
-
47
-        if (1 !== $html) {
48
-            // html not allowed
49
-            $text = newbbHtmlspecialchars($text);
50
-        }
51
-        $text = $myts->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
52
-        $text = $myts->makeClickable($text);
53
-        if (0 !== $smiley) {
54
-            // process smiley
55
-            $text = $myts->smiley($text);
56
-        }
57
-        if (0 !== $xcode) {
58
-            // decode xcode
59
-            if (0 !== $image) {
60
-                // image allowed
61
-                $text = $myts->xoopsCodeDecode($text);
62
-            } else {
63
-                // image not allowed
64
-                $text = $myts->xoopsCodeDecode($text, 0);
65
-            }
66
-        }
67
-        if (0 !== $br) {
68
-            $text = $myts->nl2Br($text);
69
-        }
70
-        $text = $myts->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
71
-
72
-        return $text;
73
-    }
74
-
75
-    /**
76
-     * @param $document
77
-     * @return string
78
-     */
79
-    function newbbHtml2text($document)
80
-    {
81
-        $text = strip_tags($document);
82
-
83
-        return $text;
84
-    }
85
-
86
-    /**
87
-     * Display forrum button
88
-     *
89
-     * @param          $link
90
-     * @param          $button
91
-     * @param  string  $alt     alt message
92
-     * @param  boolean $asImage true for image mode; false for text mode
93
-     * @param  string  $extra   extra attribute for the button
94
-     * @return mixed
95
-     * @internal param string $image image/button name, without extension
96
-     */
97
-    function newbbGetButton($link, $button, $alt = '', $asImage = true, $extra = "class='forum_button'")
98
-    {
99
-        $button = "<input type='button' name='{$button}' {$extra} value='{$alt}' onclick='window.location.href={$link}' />";
100
-        if (empty($asImage)) {
101
-            $button = "<a href='{$link}' title='{$alt}' {$extra}>" . newbbDisplayImage($button, $alt, true) . '</a>';
102
-        }
103
-
104
-        return $button;
105
-    }
106
-
107
-    /**
108
-     * Display forrum images
109
-     *
110
-     * @param  string  $image   image name, without extension
111
-     * @param  string  $alt     alt message
112
-     * @param  boolean $display true for return image anchor; faulse for assign to $xoopsTpl
113
-     * @param  string  $extra   extra attribute for the image
114
-     * @return mixed
115
-     */
116
-    function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class='forum_icon'")
117
-    {
118
-        $iconHandler = newbbGetIconHandler();
119
-        // START hacked by irmtfan
120
-        // to show text links instead of buttons - func_num_args()==2 => only when $image, $alt is set and optional $display not set
121
-
122
-        if (2 == func_num_args()) {
123
-            // overall setting
124
-            if (!empty($GLOBALS['xoopsModuleConfig']['display_text_links'])) {
125
-                $display = false;
126
-            }
127
-            // if set for each link => overwrite $display
128
-            if (isset($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image])) {
129
-                $display = empty($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image]);
130
-            }
131
-        }
132
-        // END hacked by irmtfan
133
-        if (empty($display)) {
134
-            return $iconHandler->assignImage($image, $alt, $extra);
135
-        } else {
136
-            return $iconHandler->getImage($image, $alt, $extra);
137
-        }
138
-    }
139
-
140
-    /**
141
-     * @return Newbb\IconHandler
142
-     */
143
-    function newbbGetIconHandler()
144
-    {
145
-        global $xoTheme;
146
-        static $iconHandler;
147
-
148
-        if (null !== $iconHandler) {
149
-            return $iconHandler;
150
-        }
25
+	/**
26
+	 * @param $text
27
+	 * @return mixed
28
+	 */
29
+	function newbbHtmlspecialchars(&$text)
30
+	{
31
+		return preg_replace(['/&amp;/i', '/&nbsp;/i'], ['&', '&amp;nbsp;'], htmlspecialchars($text, ENT_QUOTES | ENT_HTML5));
32
+	}
33
+
34
+	/**
35
+	 * @param        $text
36
+	 * @param  int   $html
37
+	 * @param  int   $smiley
38
+	 * @param  int   $xcode
39
+	 * @param  int   $image
40
+	 * @param  int   $br
41
+	 * @return mixed
42
+	 */
43
+	function &newbbDisplayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
44
+	{
45
+		global $myts;
46
+
47
+		if (1 !== $html) {
48
+			// html not allowed
49
+			$text = newbbHtmlspecialchars($text);
50
+		}
51
+		$text = $myts->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
52
+		$text = $myts->makeClickable($text);
53
+		if (0 !== $smiley) {
54
+			// process smiley
55
+			$text = $myts->smiley($text);
56
+		}
57
+		if (0 !== $xcode) {
58
+			// decode xcode
59
+			if (0 !== $image) {
60
+				// image allowed
61
+				$text = $myts->xoopsCodeDecode($text);
62
+			} else {
63
+				// image not allowed
64
+				$text = $myts->xoopsCodeDecode($text, 0);
65
+			}
66
+		}
67
+		if (0 !== $br) {
68
+			$text = $myts->nl2Br($text);
69
+		}
70
+		$text = $myts->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
71
+
72
+		return $text;
73
+	}
74
+
75
+	/**
76
+	 * @param $document
77
+	 * @return string
78
+	 */
79
+	function newbbHtml2text($document)
80
+	{
81
+		$text = strip_tags($document);
82
+
83
+		return $text;
84
+	}
85
+
86
+	/**
87
+	 * Display forrum button
88
+	 *
89
+	 * @param          $link
90
+	 * @param          $button
91
+	 * @param  string  $alt     alt message
92
+	 * @param  boolean $asImage true for image mode; false for text mode
93
+	 * @param  string  $extra   extra attribute for the button
94
+	 * @return mixed
95
+	 * @internal param string $image image/button name, without extension
96
+	 */
97
+	function newbbGetButton($link, $button, $alt = '', $asImage = true, $extra = "class='forum_button'")
98
+	{
99
+		$button = "<input type='button' name='{$button}' {$extra} value='{$alt}' onclick='window.location.href={$link}' />";
100
+		if (empty($asImage)) {
101
+			$button = "<a href='{$link}' title='{$alt}' {$extra}>" . newbbDisplayImage($button, $alt, true) . '</a>';
102
+		}
103
+
104
+		return $button;
105
+	}
106
+
107
+	/**
108
+	 * Display forrum images
109
+	 *
110
+	 * @param  string  $image   image name, without extension
111
+	 * @param  string  $alt     alt message
112
+	 * @param  boolean $display true for return image anchor; faulse for assign to $xoopsTpl
113
+	 * @param  string  $extra   extra attribute for the image
114
+	 * @return mixed
115
+	 */
116
+	function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class='forum_icon'")
117
+	{
118
+		$iconHandler = newbbGetIconHandler();
119
+		// START hacked by irmtfan
120
+		// to show text links instead of buttons - func_num_args()==2 => only when $image, $alt is set and optional $display not set
121
+
122
+		if (2 == func_num_args()) {
123
+			// overall setting
124
+			if (!empty($GLOBALS['xoopsModuleConfig']['display_text_links'])) {
125
+				$display = false;
126
+			}
127
+			// if set for each link => overwrite $display
128
+			if (isset($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image])) {
129
+				$display = empty($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image]);
130
+			}
131
+		}
132
+		// END hacked by irmtfan
133
+		if (empty($display)) {
134
+			return $iconHandler->assignImage($image, $alt, $extra);
135
+		} else {
136
+			return $iconHandler->getImage($image, $alt, $extra);
137
+		}
138
+	}
139
+
140
+	/**
141
+	 * @return Newbb\IconHandler
142
+	 */
143
+	function newbbGetIconHandler()
144
+	{
145
+		global $xoTheme;
146
+		static $iconHandler;
147
+
148
+		if (null !== $iconHandler) {
149
+			return $iconHandler;
150
+		}
151 151
 
152 152
 //        if (!class_exists('IconHandler')) {
153 153
 //            require_once dirname(__DIR__) . '/class/icon.php';
154 154
 //        }
155 155
 
156
-        $iconHandler           = Newbb\IconHandler::getInstance();
157
-        $iconHandler->template = $xoTheme->template;
158
-        $iconHandler->init($GLOBALS['xoopsConfig']['language']);
156
+		$iconHandler           = Newbb\IconHandler::getInstance();
157
+		$iconHandler->template = $xoTheme->template;
158
+		$iconHandler->init($GLOBALS['xoopsConfig']['language']);
159 159
 
160
-        return $iconHandler;
161
-    }
160
+		return $iconHandler;
161
+	}
162 162
 }
Please login to merge, or discard this patch.
include/config.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -33,83 +33,83 @@
 block discarded – undo
33 33
  */
34 34
 function getConfig()
35 35
 {
36
-    $moduleDirName      = basename(dirname(__DIR__));
37
-    $moduleDirNameUpper = strtoupper($moduleDirName);
38
-    return (object)[
39
-        'name'           => strtoupper($moduleDirName) . ' Module Configurator',
40
-        'paths'          => [
41
-            'dirname'    => $moduleDirName,
42
-            'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
43
-            'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
44
-            'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
45
-            'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
46
-            'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
47
-        ],
48
-        'uploadFolders'  => [
49
-            constant($moduleDirNameUpper . '_UPLOAD_PATH'),
50
-            constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs',
36
+	$moduleDirName      = basename(dirname(__DIR__));
37
+	$moduleDirNameUpper = strtoupper($moduleDirName);
38
+	return (object)[
39
+		'name'           => strtoupper($moduleDirName) . ' Module Configurator',
40
+		'paths'          => [
41
+			'dirname'    => $moduleDirName,
42
+			'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
43
+			'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
44
+			'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
45
+			'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
46
+			'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
47
+		],
48
+		'uploadFolders'  => [
49
+			constant($moduleDirNameUpper . '_UPLOAD_PATH'),
50
+			constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs',
51 51
 
52
-            //XOOPS_UPLOAD_PATH . '/flags'
53
-        ],
54
-        'copyBlankFiles' => [
55
-            constant($moduleDirNameUpper . '_UPLOAD_PATH'),
56
-            constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs',
57
-            //XOOPS_UPLOAD_PATH . '/flags'
58
-        ],
52
+			//XOOPS_UPLOAD_PATH . '/flags'
53
+		],
54
+		'copyBlankFiles' => [
55
+			constant($moduleDirNameUpper . '_UPLOAD_PATH'),
56
+			constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs',
57
+			//XOOPS_UPLOAD_PATH . '/flags'
58
+		],
59 59
 
60
-        'copyTestFolders' => [
61
-            //        constant($moduleDirNameUpper . '_UPLOAD_PATH'),
62
-            //[
63
-            //    constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
64
-            //    constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/images',
65
-            //]
66
-        ],
60
+		'copyTestFolders' => [
61
+			//        constant($moduleDirNameUpper . '_UPLOAD_PATH'),
62
+			//[
63
+			//    constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
64
+			//    constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/images',
65
+			//]
66
+		],
67 67
 
68
-        'templateFolders' => [
69
-            '/templates/',
70
-            '/templates/blocks/',
71
-            '/templates/admin/'
68
+		'templateFolders' => [
69
+			'/templates/',
70
+			'/templates/blocks/',
71
+			'/templates/admin/'
72 72
 
73
-        ],
74
-        'oldFiles'        => [
75
-            '/class/request.php',
76
-            '/class/registry.php',
77
-            '/class/utilities.php',
78
-            '/class/util.php',
79
-            // '/include/constants.php',
80
-            // '/include/functions.php',
81
-            '/ajaxrating.txt',
82
-        ],
83
-        'oldFolders'      => [
84
-            '/images',
85
-            '/css',
86
-            '/js',
87
-            '/tcpdf',
88
-            '/images',
89
-        ],
73
+		],
74
+		'oldFiles'        => [
75
+			'/class/request.php',
76
+			'/class/registry.php',
77
+			'/class/utilities.php',
78
+			'/class/util.php',
79
+			// '/include/constants.php',
80
+			// '/include/functions.php',
81
+			'/ajaxrating.txt',
82
+		],
83
+		'oldFolders'      => [
84
+			'/images',
85
+			'/css',
86
+			'/js',
87
+			'/tcpdf',
88
+			'/images',
89
+		],
90 90
 
91
-        'renameTables' => [
92
-            'bb_archive'     => 'newbb_archive',
93
-            'bb_categories'  => 'newbb_categories',
94
-            'bb_votedata'    => 'newbb_votedata',
95
-            'bb_forums'      => 'newbb_forums',
96
-            'bb_posts'       => 'newbb_posts',
97
-            'bb_posts_text'  => 'newbb_posts_text',
98
-            'bb_topics'      => 'newbb_topics',
99
-            'bb_online'      => 'newbb_online',
100
-            'bb_digest'      => 'newbb_digest',
101
-            'bb_report'      => 'newbb_report',
102
-            'bb_attachments' => 'newbb_attachments',
103
-            'bb_moderates'   => 'newbb_moderates',
104
-            'bb_reads_forum' => 'newbb_reads_forum',
105
-            'bb_reads_topic' => 'newbb_reads_topic',
106
-            'bb_type'        => 'newbb_type',
107
-            'bb_type_forum'  => 'newbb_type_forum',
108
-            'bb_stats'       => 'newbb_stats',
109
-            'bb_user_stats'  => 'newbb_user_stats',
110
-        ],
91
+		'renameTables' => [
92
+			'bb_archive'     => 'newbb_archive',
93
+			'bb_categories'  => 'newbb_categories',
94
+			'bb_votedata'    => 'newbb_votedata',
95
+			'bb_forums'      => 'newbb_forums',
96
+			'bb_posts'       => 'newbb_posts',
97
+			'bb_posts_text'  => 'newbb_posts_text',
98
+			'bb_topics'      => 'newbb_topics',
99
+			'bb_online'      => 'newbb_online',
100
+			'bb_digest'      => 'newbb_digest',
101
+			'bb_report'      => 'newbb_report',
102
+			'bb_attachments' => 'newbb_attachments',
103
+			'bb_moderates'   => 'newbb_moderates',
104
+			'bb_reads_forum' => 'newbb_reads_forum',
105
+			'bb_reads_topic' => 'newbb_reads_topic',
106
+			'bb_type'        => 'newbb_type',
107
+			'bb_type_forum'  => 'newbb_type_forum',
108
+			'bb_stats'       => 'newbb_stats',
109
+			'bb_user_stats'  => 'newbb_user_stats',
110
+		],
111 111
 
112
-        'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
112
+		'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
113 113
                      <img src='" . constant($moduleDirNameUpper . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>',
114
-    ];
114
+	];
115 115
 }
Please login to merge, or discard this patch.
admin/index.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function newbb_admin_mkdir($target, $mode = 0777)
51 51
 {
52
-    $target = str_replace('..', '', $target);
52
+	$target = str_replace('..', '', $target);
53 53
 
54
-    // http://www.php.net/manual/en/function.mkdir.php
55
-    return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && (!mkdir($target, $mode) && !is_dir($target)));
54
+	// http://www.php.net/manual/en/function.mkdir.php
55
+	return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && (!mkdir($target, $mode) && !is_dir($target)));
56 56
 }
57 57
 
58 58
 /**
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function newbb_admin_chmod($target, $mode = 0777)
64 64
 {
65
-    $target = str_replace('..', '', $target);
65
+	$target = str_replace('..', '', $target);
66 66
 
67
-    return @chmod($target, $mode);
67
+	return @chmod($target, $mode);
68 68
 }
69 69
 
70 70
 /**
@@ -72,32 +72,32 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function newbb_getImageLibs()
74 74
 {
75
-    $imageLibs = [];
76
-    unset($output, $status);
77
-    if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
78
-        $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
79
-        @exec($path . 'convert -version', $output, $status);
80
-        if (empty($status) && !empty($output) && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
81
-            $imageLibs['imagemagick'] = $matches[0];
82
-        }
83
-
84
-        unset($output, $status);
85
-    }
86
-    if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
87
-        $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
88
-        @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
89
-        if (empty($status) && !empty($output) && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
90
-            $imageLibs['netpbm'] = $matches[0];
91
-        }
92
-        unset($output, $status);
93
-    }
94
-
95
-    if (function_exists('gd_info')) {
96
-        $tmpInfo         = gd_info();
97
-        $imageLibs['gd'] = $tmpInfo['GD Version'];
98
-    }
99
-
100
-    return $imageLibs;
75
+	$imageLibs = [];
76
+	unset($output, $status);
77
+	if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
78
+		$path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
79
+		@exec($path . 'convert -version', $output, $status);
80
+		if (empty($status) && !empty($output) && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
81
+			$imageLibs['imagemagick'] = $matches[0];
82
+		}
83
+
84
+		unset($output, $status);
85
+	}
86
+	if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
87
+		$path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
88
+		@exec($path . 'jpegtopnm -version 2>&1', $output, $status);
89
+		if (empty($status) && !empty($output) && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
90
+			$imageLibs['netpbm'] = $matches[0];
91
+		}
92
+		unset($output, $status);
93
+	}
94
+
95
+	if (function_exists('gd_info')) {
96
+		$tmpInfo         = gd_info();
97
+		$imageLibs['gd'] = $tmpInfo['GD Version'];
98
+	}
99
+
100
+	return $imageLibs;
101 101
 }
102 102
 
103 103
 xoops_cp_header();
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 //XOOPS_POLL
114 114
 $xoopspoll = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
115 115
 if (is_object($xoopspoll)) {
116
-    $isOK = $xoopspoll->getVar('isactive');
116
+	$isOK = $xoopspoll->getVar('isactive');
117 117
 }
118 118
 // END irmtfan add a poll_module config
119 119
 
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 $postmaxsize_iniphp = return_bytes(@ini_get('post_max_size'));
122 122
 $uploadlimit        = _AM_NEWBB_MEMLIMITTOLARGE;
123 123
 if ($postmaxsize_iniphp < $memlimit_iniphp) {
124
-    $uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, return_bytes($postmaxsize_iniphp, true));
124
+	$uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, return_bytes($postmaxsize_iniphp, true));
125 125
 }
126 126
 
127 127
 $adminObject->addInfoBox(_AM_NEWBB_PREFERENCES);
128 128
 // START irmtfan better poll module display link and version - check if xoops poll module is available
129 129
 if ($isOK) {
130
-    $pollLink = _AM_NEWBB_AVAILABLE . ': ';
131
-    $pollLink .= '<a href="' . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . '/admin/index.php"';
132
-    $pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
133
-    $pollLink .= ' title="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
134
-    $pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
130
+	$pollLink = _AM_NEWBB_AVAILABLE . ': ';
131
+	$pollLink .= '<a href="' . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . '/admin/index.php"';
132
+	$pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
133
+	$pollLink .= ' title="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
134
+	$pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
135 135
 } else {
136
-    $pollLink = _AM_NEWBB_NOTAVAILABLE;
136
+	$pollLink = _AM_NEWBB_NOTAVAILABLE;
137 137
 }
138 138
 $adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_POLLMODULE . ': %s', $pollLink));
139 139
 // END irmtfan better poll module display link and version - check if xoops poll module is available
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
 $_ufolders = $newbb_config->uploadFolders;
156 156
 foreach ($_ufolders as $wert) { 
157
-    Newbb\Utility::prepareFolder($wert);
158
-    $adminObject->addConfigBoxLine($wert, 'folder');
157
+	Newbb\Utility::prepareFolder($wert);
158
+	$adminObject->addConfigBoxLine($wert, 'folder');
159 159
 }
160 160
 
161 161
 
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function return_bytes($sizeAsString, $b = false)
178 178
 {
179
-    if (false === $b) {
180
-        switch (substr($sizeAsString, -1)) {
181
-            case 'M':
182
-            case 'm':
183
-                return (int)$sizeAsString * 1048576;
184
-            case 'K':
185
-            case 'k':
186
-                return (int)$sizeAsString * 1024;
187
-            case 'G':
188
-            case 'g':
189
-                return (int)$sizeAsString * 1073741824;
190
-            default:
191
-                return $sizeAsString;
192
-        }
193
-    } else {
194
-        $base   = log($sizeAsString) / log(1024);
195
-        $suffix = ['', 'KB', 'MB', 'GB', 'TB'];
196
-
197
-        return round(1024 ** ($base - floor($base))) . ' ' . $suffix[(int)floor($base)];
198
-    }
179
+	if (false === $b) {
180
+		switch (substr($sizeAsString, -1)) {
181
+			case 'M':
182
+			case 'm':
183
+				return (int)$sizeAsString * 1048576;
184
+			case 'K':
185
+			case 'k':
186
+				return (int)$sizeAsString * 1024;
187
+			case 'G':
188
+			case 'g':
189
+				return (int)$sizeAsString * 1073741824;
190
+			default:
191
+				return $sizeAsString;
192
+		}
193
+	} else {
194
+		$base   = log($sizeAsString) / log(1024);
195
+		$suffix = ['', 'KB', 'MB', 'GB', 'TB'];
196
+
197
+		return round(1024 ** ($base - floor($base))) . ' ' . $suffix[(int)floor($base)];
198
+	}
199 199
 }
Please login to merge, or discard this patch.