Completed
Push — master ( 7c5656...a50592 )
by Michael
01:55
created
view.blogs.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 include __DIR__ . '/header.php';
30 30
 
31 31
 if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
32
-    include XOOPS_ROOT_PATH . '/include/notification_update.php';
33
-    exit();
32
+	include XOOPS_ROOT_PATH . '/include/notification_update.php';
33
+	exit();
34 34
 }
35 35
 
36 36
 if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) {
37
-    $args['start'] = @$args_num[0];
38
-    $args['sort']  = @$args_str[0];
37
+	$args['start'] = @$args_num[0];
38
+	$args['sort']  = @$args_str[0];
39 39
 }
40 40
 
41 41
 /* Start */
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
 $blog_prefix = '';
83 83
 /* Specific category */
84 84
 if ($category_id > 0) {
85
-    $category_obj = $categoryHandler->get($category_id);
86
-    $criteria->add(new Criteria('bc.cat_id', $category_id));
87
-    $uid           = 0;
88
-    $blog_id       = 0;
89
-    $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')];
90
-    $query_type    = 'category';
91
-    $blog_prefix   = 'b.';
85
+	$category_obj = $categoryHandler->get($category_id);
86
+	$criteria->add(new Criteria('bc.cat_id', $category_id));
87
+	$uid           = 0;
88
+	$blog_id       = 0;
89
+	$category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')];
90
+	$query_type    = 'category';
91
+	$blog_prefix   = 'b.';
92 92
 }
93 93
 
94 94
 /* User bookmarks(favorites) */
95 95
 if ($uid > 0) {
96
-    $criteria->add(new Criteria('bm.bm_uid', $uid));
97
-    $category_id     = 0;
98
-    $blog_id         = 0;
99
-    $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
100
-    $user_data       = [
101
-        'uid'   => $uid,
102
-        'name'  => XoopsUser::getUnameFromId($uid),
103
-        'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid))
104
-    ];
105
-    $query_type      = 'bookmark';
106
-    $blog_prefix     = 'b.';
96
+	$criteria->add(new Criteria('bm.bm_uid', $uid));
97
+	$category_id     = 0;
98
+	$blog_id         = 0;
99
+	$bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
100
+	$user_data       = [
101
+		'uid'   => $uid,
102
+		'name'  => XoopsUser::getUnameFromId($uid),
103
+		'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid))
104
+	];
105
+	$query_type      = 'bookmark';
106
+	$blog_prefix     = 'b.';
107 107
 }
108 108
 
109 109
 $criteria->add(new Criteria($blog_prefix . 'blog_status', 0, '>'));
@@ -112,20 +112,20 @@  discard block
 block discarded – undo
112 112
 $order = 'DESC';
113 113
 $sort  = empty($sort) ? 'default' : $sort;
114 114
 switch ($sort) {
115
-    case 'marks':
116
-        $sortby = $blog_prefix . 'blog_marks';
117
-        break;
118
-    case 'rating':
119
-        $sortby = $blog_prefix . 'blog_rating';
120
-        break;
121
-    case 'time':
122
-        $sortby = $blog_prefix . 'blog_time';
123
-        break;
124
-    case 'default':
125
-    default:
126
-        $sort   = 'default';
127
-        $sortby = $blog_prefix . 'blog_id';
128
-        break;
115
+	case 'marks':
116
+		$sortby = $blog_prefix . 'blog_marks';
117
+		break;
118
+	case 'rating':
119
+		$sortby = $blog_prefix . 'blog_rating';
120
+		break;
121
+	case 'time':
122
+		$sortby = $blog_prefix . 'blog_time';
123
+		break;
124
+	case 'default':
125
+	default:
126
+		$sort   = 'default';
127
+		$sortby = $blog_prefix . 'blog_id';
128
+		break;
129 129
 }
130 130
 $criteria->setSort($sortby);
131 131
 $criteria->setOrder($order);
@@ -134,93 +134,93 @@  discard block
 block discarded – undo
134 134
 
135 135
 $tags = empty($list) ? '' : [$blog_prefix . 'blog_title', $blog_prefix . 'blog_time'];
136 136
 switch ($query_type) {
137
-    case 'category':
138
-        $blogs_obj  = $blogHandler->getByCategory($criteria, $tags);
139
-        $count_blog = $blogHandler->getCountByCategory($criteria);
140
-        break;
141
-    case 'bookmark':
142
-        $blogs_obj  = $blogHandler->getByBookmark($criteria, $tags);
143
-        $count_blog = $blogHandler->getCountByBookmark($criteria);
144
-        break;
145
-    default:
146
-        $blogs_obj  = $blogHandler->getAll($criteria, $tags);
147
-        $count_blog = $blogHandler->getCount($criteria);
148
-        break;
137
+	case 'category':
138
+		$blogs_obj  = $blogHandler->getByCategory($criteria, $tags);
139
+		$count_blog = $blogHandler->getCountByCategory($criteria);
140
+		break;
141
+	case 'bookmark':
142
+		$blogs_obj  = $blogHandler->getByBookmark($criteria, $tags);
143
+		$count_blog = $blogHandler->getCountByBookmark($criteria);
144
+		break;
145
+	default:
146
+		$blogs_obj  = $blogHandler->getAll($criteria, $tags);
147
+		$count_blog = $blogHandler->getCount($criteria);
148
+		break;
149 149
 }
150 150
 
151 151
 /* Objects to array */
152 152
 $blogs = [];
153 153
 foreach (array_keys($blogs_obj) as $id) {
154
-    $_blog = [
155
-        'id'    => $id,
156
-        'title' => $blogs_obj[$id]->getVar('blog_title'),
157
-        'time'  => $blogs_obj[$id]->getTime()
158
-    ];
159
-    if (empty($list)) {
160
-        $_blog = array_merge($_blog, [
161
-            'image' => $blogs_obj[$id]->getImage(),
162
-            'feed'  => $blogs_obj[$id]->getVar('blog_feed'),
163
-            'link'  => $blogs_obj[$id]->getVar('blog_link'),
164
-            'desc'  => $blogs_obj[$id]->getVar('blog_desc'),
165
-            'star'  => $blogs_obj[$id]->getStar(),
166
-            'rates' => $blogs_obj[$id]->getVar('blog_rates'),
167
-            'marks' => $blogs_obj[$id]->getVar('blog_marks')
168
-        ]);
169
-    }
170
-    $blogs[] = $_blog;
171
-    unset($_blog);
154
+	$_blog = [
155
+		'id'    => $id,
156
+		'title' => $blogs_obj[$id]->getVar('blog_title'),
157
+		'time'  => $blogs_obj[$id]->getTime()
158
+	];
159
+	if (empty($list)) {
160
+		$_blog = array_merge($_blog, [
161
+			'image' => $blogs_obj[$id]->getImage(),
162
+			'feed'  => $blogs_obj[$id]->getVar('blog_feed'),
163
+			'link'  => $blogs_obj[$id]->getVar('blog_link'),
164
+			'desc'  => $blogs_obj[$id]->getVar('blog_desc'),
165
+			'star'  => $blogs_obj[$id]->getStar(),
166
+			'rates' => $blogs_obj[$id]->getVar('blog_rates'),
167
+			'marks' => $blogs_obj[$id]->getVar('blog_marks')
168
+		]);
169
+	}
170
+	$blogs[] = $_blog;
171
+	unset($_blog);
172 172
 }
173 173
 unset($blogs_obj);
174 174
 
175 175
 if ($count_blog > $limit) {
176
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
177
-    $start_link = [];
178
-    if ($sort) {
179
-        $start_link[] = 'sort=' . $sort;
180
-    }
181
-    if ($category_id) {
182
-        $start_link[] = 'category=' . $category_id;
183
-    }
184
-    if ($list) {
185
-        $start_link[] = 'list=' . $list;
186
-    }
187
-    $nav     = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&', $start_link));
188
-    $pagenav = $nav->renderNav(4);
176
+	include XOOPS_ROOT_PATH . '/class/pagenav.php';
177
+	$start_link = [];
178
+	if ($sort) {
179
+		$start_link[] = 'sort=' . $sort;
180
+	}
181
+	if ($category_id) {
182
+		$start_link[] = 'category=' . $category_id;
183
+	}
184
+	if ($list) {
185
+		$start_link[] = 'list=' . $list;
186
+	}
187
+	$nav     = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&', $start_link));
188
+	$pagenav = $nav->renderNav(4);
189 189
 } else {
190
-    $pagenav = '';
190
+	$pagenav = '';
191 191
 }
192 192
 
193 193
 $xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']);
194 194
 $xoopsTpl->assign('link_home', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_HOME') . "\" target=\"_self\">" . planet_constant('MD_HOME') . '</a>');
195 195
 
196 196
 if ($category_id || $uid) {
197
-    $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
197
+	$xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
198 198
 
199
-    $link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>';
200
-    $xoopsTpl->assign('link_articles', $link_articles);
199
+	$link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>';
200
+	$xoopsTpl->assign('link_articles', $link_articles);
201 201
 }
202 202
 
203 203
 $link_switch = "<a href=\""
204
-               . XOOPS_URL
205
-               . '/modules/'
206
-               . $GLOBALS['moddirname']
207
-               . '/view.blogs.php'
208
-               . (empty($category_id) ? '' : '/c' . $category_id)
209
-               . (empty($uid) ? '' : '/u' . $uid)
210
-               . (empty($list) ? '/l1' : '')
211
-               . "\" title=\""
212
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
213
-               . "\">"
214
-               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
215
-               . '</a>';
204
+			   . XOOPS_URL
205
+			   . '/modules/'
206
+			   . $GLOBALS['moddirname']
207
+			   . '/view.blogs.php'
208
+			   . (empty($category_id) ? '' : '/c' . $category_id)
209
+			   . (empty($uid) ? '' : '/u' . $uid)
210
+			   . (empty($list) ? '/l1' : '')
211
+			   . "\" title=\""
212
+			   . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
213
+			   . "\">"
214
+			   . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
215
+			   . '</a>';
216 216
 $xoopsTpl->assign('link_switch', $link_switch);
217 217
 
218 218
 if (empty($uid) && is_object($xoopsUser)) {
219
-    $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
219
+	$xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
220 220
 }
221 221
 
222 222
 if ($xoopsModuleConfig['newblog_submit'] == 1 || is_object($xoopsUser)) {
223
-    $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
223
+	$xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
224 224
 }
225 225
 
226 226
 $xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_BLOGS'));
@@ -234,35 +234,35 @@  discard block
 block discarded – undo
234 234
 $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
235 235
 if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) {
236 236
 } elseif (!$list) {
237
-    $xoopsTpl->assign('canrate', 1);
237
+	$xoopsTpl->assign('canrate', 1);
238 238
 }
239 239
 
240 240
 $sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER;
241 241
 $vars      = [];
242 242
 if (!empty($category_id)) {
243
-    $vars[] = 'c' . $category_id;
243
+	$vars[] = 'c' . $category_id;
244 244
 }
245 245
 if (!empty($uid)) {
246
-    $vars[] = 'u' . $uid;
246
+	$vars[] = 'u' . $uid;
247 247
 }
248 248
 if (!empty($list)) {
249
-    $vars[] = 'li';
249
+	$vars[] = 'li';
250 250
 }
251 251
 if (!empty($vars)) {
252
-    $sort_link .= implode('/', $vars) . '/';
252
+	$sort_link .= implode('/', $vars) . '/';
253 253
 }
254 254
 $sortlinks   = [];
255 255
 $valid_sorts = [
256
-    'marks'   => planet_constant('MD_BOOKMARKS'),
257
-    'rating'  => planet_constant('MD_RATING'),
258
-    'time'    => planet_constant('MD_TIME'),
259
-    'default' => planet_constant('MD_DEFAULT')
256
+	'marks'   => planet_constant('MD_BOOKMARKS'),
257
+	'rating'  => planet_constant('MD_RATING'),
258
+	'time'    => planet_constant('MD_TIME'),
259
+	'default' => planet_constant('MD_DEFAULT')
260 260
 ];
261 261
 foreach ($valid_sorts as $val => $name) {
262
-    if ($val == $sort) {
263
-        continue;
264
-    }
265
-    $sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>';
262
+	if ($val == $sort) {
263
+		continue;
264
+	}
265
+	$sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>';
266 266
 }
267 267
 $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks));
268 268
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 use Xmf\Request;
28 28
 
29
-include __DIR__ . '/header.php';
29
+include __DIR__.'/header.php';
30 30
 
31 31
 if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
32
-    include XOOPS_ROOT_PATH . '/include/notification_update.php';
32
+    include XOOPS_ROOT_PATH.'/include/notification_update.php';
33 33
     exit();
34 34
 }
35 35
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 }
67 67
 */
68 68
 
69
-$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . planet_constant('MD_BLOGS');
69
+$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name').' - '.planet_constant('MD_BLOGS');
70 70
 $xoopsOption['template_main']   = PlanetUtility::planetGetTemplate('blogs');
71
-require_once XOOPS_ROOT_PATH . '/header.php';
72
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
71
+require_once XOOPS_ROOT_PATH.'/header.php';
72
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
73 73
 
74 74
 // Following part will not be executed after cache
75 75
 $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 $criteria    = new CriteriaCompo();
82 82
 $blog_prefix = '';
83 83
 /* Specific category */
84
-if ($category_id > 0) {
84
+if ($category_id>0) {
85 85
     $category_obj = $categoryHandler->get($category_id);
86 86
     $criteria->add(new Criteria('bc.cat_id', $category_id));
87 87
     $uid           = 0;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 }
93 93
 
94 94
 /* User bookmarks(favorites) */
95
-if ($uid > 0) {
95
+if ($uid>0) {
96 96
     $criteria->add(new Criteria('bm.bm_uid', $uid));
97 97
     $category_id     = 0;
98 98
     $blog_id         = 0;
@@ -106,25 +106,25 @@  discard block
 block discarded – undo
106 106
     $blog_prefix     = 'b.';
107 107
 }
108 108
 
109
-$criteria->add(new Criteria($blog_prefix . 'blog_status', 0, '>'));
109
+$criteria->add(new Criteria($blog_prefix.'blog_status', 0, '>'));
110 110
 
111 111
 /* Sort */
112 112
 $order = 'DESC';
113 113
 $sort  = empty($sort) ? 'default' : $sort;
114 114
 switch ($sort) {
115 115
     case 'marks':
116
-        $sortby = $blog_prefix . 'blog_marks';
116
+        $sortby = $blog_prefix.'blog_marks';
117 117
         break;
118 118
     case 'rating':
119
-        $sortby = $blog_prefix . 'blog_rating';
119
+        $sortby = $blog_prefix.'blog_rating';
120 120
         break;
121 121
     case 'time':
122
-        $sortby = $blog_prefix . 'blog_time';
122
+        $sortby = $blog_prefix.'blog_time';
123 123
         break;
124 124
     case 'default':
125 125
     default:
126 126
         $sort   = 'default';
127
-        $sortby = $blog_prefix . 'blog_id';
127
+        $sortby = $blog_prefix.'blog_id';
128 128
         break;
129 129
 }
130 130
 $criteria->setSort($sortby);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 $criteria->setStart($start);
133 133
 $criteria->setLimit($limit);
134 134
 
135
-$tags = empty($list) ? '' : [$blog_prefix . 'blog_title', $blog_prefix . 'blog_time'];
135
+$tags = empty($list) ? '' : [$blog_prefix.'blog_title', $blog_prefix.'blog_time'];
136 136
 switch ($query_type) {
137 137
     case 'category':
138 138
         $blogs_obj  = $blogHandler->getByCategory($criteria, $tags);
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 }
173 173
 unset($blogs_obj);
174 174
 
175
-if ($count_blog > $limit) {
176
-    include XOOPS_ROOT_PATH . '/class/pagenav.php';
175
+if ($count_blog>$limit) {
176
+    include XOOPS_ROOT_PATH.'/class/pagenav.php';
177 177
     $start_link = [];
178 178
     if ($sort) {
179
-        $start_link[] = 'sort=' . $sort;
179
+        $start_link[] = 'sort='.$sort;
180 180
     }
181 181
     if ($category_id) {
182
-        $start_link[] = 'category=' . $category_id;
182
+        $start_link[] = 'category='.$category_id;
183 183
     }
184 184
     if ($list) {
185
-        $start_link[] = 'list=' . $list;
185
+        $start_link[] = 'list='.$list;
186 186
     }
187 187
     $nav     = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&amp;', $start_link));
188 188
     $pagenav = $nav->renderNav(4);
189
-} else {
189
+}else {
190 190
     $pagenav = '';
191 191
 }
192 192
 
193 193
 $xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']);
194
-$xoopsTpl->assign('link_home', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_HOME') . "\" target=\"_self\">" . planet_constant('MD_HOME') . '</a>');
194
+$xoopsTpl->assign('link_home', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/index.php\" title=\"".planet_constant('MD_HOME')."\" target=\"_self\">".planet_constant('MD_HOME').'</a>');
195 195
 
196 196
 if ($category_id || $uid) {
197
-    $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>');
197
+    $xoopsTpl->assign('link_index', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/view.blogs.php\" title=\"".planet_constant('MD_INDEX')."\" target=\"_self\">".planet_constant('MD_INDEX').'</a>');
198 198
 
199
-    $link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>';
199
+    $link_articles = "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.(empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid)."\" title=\"".planet_constant('MD_ARTICLES')."\">".planet_constant('MD_ARTICLES').'</a>';
200 200
     $xoopsTpl->assign('link_articles', $link_articles);
201 201
 }
202 202
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
                . '/modules/'
206 206
                . $GLOBALS['moddirname']
207 207
                . '/view.blogs.php'
208
-               . (empty($category_id) ? '' : '/c' . $category_id)
209
-               . (empty($uid) ? '' : '/u' . $uid)
208
+               . (empty($category_id) ? '' : '/c'.$category_id)
209
+               . (empty($uid) ? '' : '/u'.$uid)
210 210
                . (empty($list) ? '/l1' : '')
211 211
                . "\" title=\""
212 212
                . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
 $xoopsTpl->assign('link_switch', $link_switch);
217 217
 
218 218
 if (empty($uid) && is_object($xoopsUser)) {
219
-    $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>');
219
+    $xoopsTpl->assign('link_bookmark', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'.URL_DELIMITER.'u'.$xoopsUser->getVar('uid')."\" title=\"".planet_constant('MD_BOOKMARKS')."\" target=\"_self\">".planet_constant('MD_BOOKMARKS').'</a>');
220 220
 }
221 221
 
222 222
 if ($xoopsModuleConfig['newblog_submit'] == 1 || is_object($xoopsUser)) {
223
-    $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>');
223
+    $xoopsTpl->assign('link_submit', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/action.blog.php\" title=\""._SUBMIT."\" target=\"_blank\">"._SUBMIT.'</a>');
224 224
 }
225 225
 
226
-$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_BLOGS'));
226
+$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name').'::'.planet_constant('MD_BLOGS'));
227 227
 $xoopsTpl->assign('category', @$category_data);
228 228
 $xoopsTpl->assign('user', @$user_data);
229 229
 $xoopsTpl->assign('blogs', $blogs);
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
     $xoopsTpl->assign('canrate', 1);
238 238
 }
239 239
 
240
-$sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER;
240
+$sort_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'.URL_DELIMITER;
241 241
 $vars      = [];
242 242
 if (!empty($category_id)) {
243
-    $vars[] = 'c' . $category_id;
243
+    $vars[] = 'c'.$category_id;
244 244
 }
245 245
 if (!empty($uid)) {
246
-    $vars[] = 'u' . $uid;
246
+    $vars[] = 'u'.$uid;
247 247
 }
248 248
 if (!empty($list)) {
249 249
     $vars[] = 'li';
250 250
 }
251 251
 if (!empty($vars)) {
252
-    $sort_link .= implode('/', $vars) . '/';
252
+    $sort_link .= implode('/', $vars).'/';
253 253
 }
254 254
 $sortlinks   = [];
255 255
 $valid_sorts = [
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
     if ($val == $sort) {
263 263
         continue;
264 264
     }
265
-    $sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>';
265
+    $sortlinks[] = "<a href=\"".$sort_link.$val."\">".$name.'</a>';
266 266
 }
267 267
 $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks));
268 268
 
269
-require_once __DIR__ . '/footer.php';
269
+require_once __DIR__.'/footer.php';
Please login to merge, or discard this patch.
search.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 $configHandler     = xoops_getHandler('config');
33 33
 $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH);
34 34
 if (empty($xoopsConfigSearch['enable_search'])) {
35
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS'));
35
+	redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS'));
36 36
 }
37 37
 
38 38
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0;
@@ -50,93 +50,93 @@  discard block
 block discarded – undo
50 50
 $blog     = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST');//(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null));
51 51
 $uid      = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST');//(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null));
52 52
 $searchin = Request::getArray(
53
-    'searchin',
54
-    0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [],
55
-                              'POST'
53
+	'searchin',
54
+	0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [],
55
+							  'POST'
56 56
 ); //isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? explode('|', $_GET['searchin']) : array());
57 57
 $sortby   = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST');//isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null);
58 58
 $term     = Request::getString('term', Request::getString('term', '', 'GET'), 'POST');//isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : '');
59 59
 
60 60
 $andor  = in_array(strtoupper($andor), ['OR', 'AND', 'EXACT']) ? strtoupper($andor) : 'OR';
61 61
 $sortby = in_array(strtolower($sortby), [
62
-    'a.art_id desc',
63
-    'a.art_time desc',
64
-    'a.art_title',
65
-    'a.blog_id',
66
-    'b.blog_id',
67
-    'b.blog_feed',
68
-    'b.blog_title',
69
-    'b.blog_time'
62
+	'a.art_id desc',
63
+	'a.art_time desc',
64
+	'a.art_title',
65
+	'a.blog_id',
66
+	'b.blog_id',
67
+	'b.blog_feed',
68
+	'b.blog_title',
69
+	'b.blog_time'
70 70
 ]) ? strtolower($sortby) : '';
71 71
 
72 72
 if (!(empty(Request::getString('submit', '', 'POST')) && empty(Request::getString('term', '', 'GET')))) {
73
-    $next_search['category'] = $category;
74
-    $next_search['blog']     = $blog;
75
-    $next_search['uid']      = $uid;
76
-    $next_search['andor']    = $andor;
73
+	$next_search['category'] = $category;
74
+	$next_search['blog']     = $blog;
75
+	$next_search['uid']      = $uid;
76
+	$next_search['andor']    = $andor;
77 77
 
78
-    $next_search['term'] = $term;
79
-    $query               = trim($term);
78
+	$next_search['term'] = $term;
79
+	$query               = trim($term);
80 80
 
81
-    if ($andor !== 'EXACT') {
82
-        $ignored_queries = []; // holds kewords that are shorter than allowed minmum length
83
-        $temp_queries    = preg_split("/[\s,]+/", $query);
84
-        foreach ($temp_queries as $q) {
85
-            $q = trim($q);
86
-            if (strlen($q) >= $xoopsConfigSearch['keyword_min']) {
87
-                $queries[] = $myts->addSlashes($q);
88
-            } else {
89
-                $ignored_queries[] = $myts->addSlashes($q);
90
-            }
91
-        }
92
-        if (count($queries) == 0) {
93
-            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
94
-        }
95
-    } else {
96
-        if (strlen($query) < $xoopsConfigSearch['keyword_min']) {
97
-            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
98
-        }
99
-        $queries = [$myts->addSlashes($query)];
100
-    }
81
+	if ($andor !== 'EXACT') {
82
+		$ignored_queries = []; // holds kewords that are shorter than allowed minmum length
83
+		$temp_queries    = preg_split("/[\s,]+/", $query);
84
+		foreach ($temp_queries as $q) {
85
+			$q = trim($q);
86
+			if (strlen($q) >= $xoopsConfigSearch['keyword_min']) {
87
+				$queries[] = $myts->addSlashes($q);
88
+			} else {
89
+				$ignored_queries[] = $myts->addSlashes($q);
90
+			}
91
+		}
92
+		if (count($queries) == 0) {
93
+			redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
94
+		}
95
+	} else {
96
+		if (strlen($query) < $xoopsConfigSearch['keyword_min']) {
97
+			redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
98
+		}
99
+		$queries = [$myts->addSlashes($query)];
100
+	}
101 101
 
102
-    $next_search['sortby']   = $sortby;
103
-    $next_search['searchin'] = implode('|', $searchin);
102
+	$next_search['sortby']   = $sortby;
103
+	$next_search['searchin'] = implode('|', $searchin);
104 104
 
105
-    /* To be added: year-month
105
+	/* To be added: year-month
106 106
      * see view.archive.php
107 107
      */
108
-    if (!empty($time)) {
109
-        $extra = '';
110
-    } else {
111
-        $extra = '';
112
-    }
108
+	if (!empty($time)) {
109
+		$extra = '';
110
+	} else {
111
+		$extra = '';
112
+	}
113 113
 
114
-    $results = planet_search($queries, $andor, $limit, $start, $uid, $category, $blog, $sortby, $searchin, $extra);
114
+	$results = planet_search($queries, $andor, $limit, $start, $uid, $category, $blog, $sortby, $searchin, $extra);
115 115
 
116
-    /*
116
+	/*
117 117
     if ( count($results) < 1 ) {
118 118
         redirect_header("javascript:history.go(-1);", 2, _SR_NOMATCH);
119 119
     } else
120 120
     */
121
-    {
122
-        $xoopsTpl->assign('results', $results);
121
+	{
122
+		$xoopsTpl->assign('results', $results);
123 123
 
124
-        if (count($next_search) > 0) {
125
-            $items = [];
126
-            foreach ($next_search as $para => $val) {
127
-                if (!empty($val)) {
128
-                    $items[] = "$para=$val";
129
-                }
130
-            }
131
-            if (count($items) > 0) {
132
-                $paras = implode('&', $items);
133
-            }
134
-            unset($next_search);
135
-            unset($items);
136
-        }
137
-        $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras;
124
+		if (count($next_search) > 0) {
125
+			$items = [];
126
+			foreach ($next_search as $para => $val) {
127
+				if (!empty($val)) {
128
+					$items[] = "$para=$val";
129
+				}
130
+			}
131
+			if (count($items) > 0) {
132
+				$paras = implode('&', $items);
133
+			}
134
+			unset($next_search);
135
+			unset($items);
136
+		}
137
+		$search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras;
138 138
 
139
-        /*
139
+		/*
140 140
          $next_results =& planet_search($queries, $andor, 1, $start + $limit, $uid, $category, $sortby, $searchin, $extra);
141 141
       $next_count = count($next_results);
142 142
       $has_next = false;
@@ -145,41 +145,41 @@  discard block
 block discarded – undo
145 145
       }
146 146
       if (false != $has_next)
147 147
       */
148
-        if (count($results)) {
149
-            $next            = $start + $limit;
150
-            $queries         = implode(',', $queries);
151
-            $search_url_next = $search_url . "&start=$next";
152
-            $search_next     = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>';
153
-            $xoopsTpl->assign('search_next', $search_next);
154
-        }
155
-        if ($start > 0) {
156
-            $prev            = $start - $limit;
157
-            $search_url_prev = $search_url . "&start=$prev";
158
-            $search_prev     = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>';
159
-            $xoopsTpl->assign('search_prev', $search_prev);
160
-        }
161
-    }
148
+		if (count($results)) {
149
+			$next            = $start + $limit;
150
+			$queries         = implode(',', $queries);
151
+			$search_url_next = $search_url . "&start=$next";
152
+			$search_next     = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>';
153
+			$xoopsTpl->assign('search_next', $search_next);
154
+		}
155
+		if ($start > 0) {
156
+			$prev            = $start - $limit;
157
+			$search_url_prev = $search_url . "&start=$prev";
158
+			$search_prev     = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>';
159
+			$xoopsTpl->assign('search_prev', $search_prev);
160
+		}
161
+	}
162 162
 
163
-    unset($results);
164
-    $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term);
165
-    $xoopsTpl->assign('search_info', $search_info);
163
+	unset($results);
164
+	$search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term);
165
+	$xoopsTpl->assign('search_info', $search_info);
166 166
 }
167 167
 
168 168
 /* type */
169 169
 $type_select = "<select name=\"andor\">";
170 170
 $type_select .= "<option value=\"OR\"";
171 171
 if ('OR' === $andor) {
172
-    $type_select .= " selected=\"selected\"";
172
+	$type_select .= " selected=\"selected\"";
173 173
 }
174 174
 $type_select .= '>' . _SR_ANY . '</option>';
175 175
 $type_select .= "<option value=\"AND\"";
176 176
 if ('AND' === $andor) {
177
-    $type_select .= " selected=\"selected\"";
177
+	$type_select .= " selected=\"selected\"";
178 178
 }
179 179
 $type_select .= '>' . _SR_ALL . '</option>';
180 180
 $type_select .= "<option value=\"EXACT\"";
181 181
 if ('exact' === $andor) {
182
-    $type_select .= " selected=\"selected\"";
182
+	$type_select .= " selected=\"selected\"";
183 183
 }
184 184
 $type_select .= '>' . _SR_EXACT . '</option>';
185 185
 $type_select .= '</select>';
@@ -188,32 +188,32 @@  discard block
 block discarded – undo
188 188
 $searchin_select = '';
189 189
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\"";
190 190
 if (in_array('title', $searchin)) {
191
-    $searchin_select .= ' checked';
191
+	$searchin_select .= ' checked';
192 192
 }
193 193
 $searchin_select .= '>' . planet_constant('MD_TITLE') . '&nbsp;&nbsp;';
194 194
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\"";
195 195
 if (in_array('text', $searchin)) {
196
-    $searchin_select .= ' checked';
196
+	$searchin_select .= ' checked';
197 197
 }
198 198
 $searchin_select .= '>' . planet_constant('MD_BODY') . '&nbsp;&nbsp;||&nbsp;&nbsp;';
199 199
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"blog\"";
200 200
 if (in_array('blog', $searchin)) {
201
-    $searchin_select .= ' checked';
201
+	$searchin_select .= ' checked';
202 202
 }
203 203
 $searchin_select .= '>' . planet_constant('MD_BLOG') . '&nbsp;&nbsp;';
204 204
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"feed\"";
205 205
 if (in_array('feed', $searchin)) {
206
-    $searchin_select .= ' checked';
206
+	$searchin_select .= ' checked';
207 207
 }
208 208
 $searchin_select .= '>' . planet_constant('MD_FEED') . '&nbsp;&nbsp;';
209 209
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"desc\"";
210 210
 if (in_array('desc', $searchin)) {
211
-    $searchin_select .= ' checked';
211
+	$searchin_select .= ' checked';
212 212
 }
213 213
 $searchin_select .= '>' . planet_constant('MD_DESC') . '&nbsp;&nbsp;';
214 214
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\"";
215 215
 if (empty($searchin)) {
216
-    $searchin_select .= ' checked';
216
+	$searchin_select .= ' checked';
217 217
 }
218 218
 $searchin_select .= '>' . _ALL . '&nbsp;&nbsp;';
219 219
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 $sortby_select = "<select name=\"sortby\">";
222 222
 $sortby_select .= "<option value=\"\"";
223 223
 if (empty($sortby)) {
224
-    $sortby_select .= " selected=\"selected\"";
224
+	$sortby_select .= " selected=\"selected\"";
225 225
 }
226 226
 $sortby_select .= '>' . _NONE . '</option>';
227 227
 $sortby_select .= "<option value=\"a.art_time\"";
228 228
 if ('a.art_time' === $sortby) {
229
-    $sortby_select .= " selected=\"selected\"";
229
+	$sortby_select .= " selected=\"selected\"";
230 230
 }
231 231
 $sortby_select .= '>' . planet_constant('MD_TIME') . '</option>';
232 232
 $sortby_select .= "<option value=\"a.art_title\"";
233 233
 if ('a.art_title' === $sortby) {
234
-    $sortby_select .= " selected=\"selected\"";
234
+	$sortby_select .= " selected=\"selected\"";
235 235
 }
236 236
 $sortby_select .= '>' . planet_constant('MD_TITLE') . '</option>';
237 237
 $sortby_select .= "<option value=\"\">&nbsp;&nbsp;----&nbsp;&nbsp;</option>";
238 238
 $sortby_select .= "<option value=\"a.blog_title\"";
239 239
 if ('a.blog_title' === $sortby) {
240
-    $sortby_select .= " selected=\"selected\"";
240
+	$sortby_select .= " selected=\"selected\"";
241 241
 }
242 242
 $sortby_select .= '>' . planet_constant('MD_BLOG') . '</option>';
243 243
 $sortby_select .= "<option value=\"a.blog_time\"";
244 244
 if ('b.blog_time' === $sortby) {
245
-    $sortby_select .= " selected=\"selected\"";
245
+	$sortby_select .= " selected=\"selected\"";
246 246
 }
247 247
 $sortby_select .= '>' . planet_constant('MD_UPDATE') . '</option>';
248 248
 $sortby_select .= '</select>';
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 $xoopsTpl->assign('uid', $uid);
260 260
 
261 261
 if ($xoopsConfigSearch['keyword_min'] > 0) {
262
-    $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min']));
262
+	$xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min']));
263 263
 }
264 264
 
265 265
 include XOOPS_ROOT_PATH . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,35 +27,35 @@  discard block
 block discarded – undo
27 27
 use Xmf\Request;
28 28
 
29 29
 $xoopsOption['pagetype'] = 'search';
30
-include __DIR__ . '/header.php';
30
+include __DIR__.'/header.php';
31 31
 $xoopsModule->loadLanguage('main');
32 32
 $configHandler     = xoops_getHandler('config');
33 33
 $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH);
34 34
 if (empty($xoopsConfigSearch['enable_search'])) {
35
-    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS'));
35
+    redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php', 2, planet_constant('MD_NOACCESS'));
36 36
 }
37 37
 
38 38
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0;
39 39
 $xoopsOption['template_main']                             = PlanetUtility::planetGetTemplate('search');
40
-include XOOPS_ROOT_PATH . '/header.php';
41
-include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
40
+include XOOPS_ROOT_PATH.'/header.php';
41
+include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php';
42 42
 
43
-require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/search.inc.php';
43
+require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/search.inc.php';
44 44
 $limit = $xoopsModuleConfig['articles_perpage'];
45 45
 
46 46
 $queries  = [];
47
-$andor    = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST');//isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : '');
48
-$start    = Request::getInt('start', 0, 'GET');//isset($_GET['start']) ? $_GET['start'] : 0;
47
+$andor    = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST'); //isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : '');
48
+$start    = Request::getInt('start', 0, 'GET'); //isset($_GET['start']) ? $_GET['start'] : 0;
49 49
 $category = Request::getInt('category', Request::getInt('category', 0, 'GET'), 'POST'); //(int)(isset($_POST['category']) ? $_POST['category'] : (isset($_GET['category']) ? $_GET['category'] : null));
50
-$blog     = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST');//(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null));
51
-$uid      = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST');//(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null));
50
+$blog     = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST'); //(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null));
51
+$uid      = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST'); //(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null));
52 52
 $searchin = Request::getArray(
53 53
     'searchin',
54 54
     0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [],
55 55
                               'POST'
56 56
 ); //isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? explode('|', $_GET['searchin']) : array());
57
-$sortby   = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST');//isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null);
58
-$term     = Request::getString('term', Request::getString('term', '', 'GET'), 'POST');//isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : '');
57
+$sortby   = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST'); //isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null);
58
+$term     = Request::getString('term', Request::getString('term', '', 'GET'), 'POST'); //isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : '');
59 59
 
60 60
 $andor  = in_array(strtoupper($andor), ['OR', 'AND', 'EXACT']) ? strtoupper($andor) : 'OR';
61 61
 $sortby = in_array(strtolower($sortby), [
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
         $temp_queries    = preg_split("/[\s,]+/", $query);
84 84
         foreach ($temp_queries as $q) {
85 85
             $q = trim($q);
86
-            if (strlen($q) >= $xoopsConfigSearch['keyword_min']) {
86
+            if (strlen($q)>=$xoopsConfigSearch['keyword_min']) {
87 87
                 $queries[] = $myts->addSlashes($q);
88
-            } else {
88
+            }else {
89 89
                 $ignored_queries[] = $myts->addSlashes($q);
90 90
             }
91 91
         }
92 92
         if (count($queries) == 0) {
93
-            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
93
+            redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
94 94
         }
95
-    } else {
96
-        if (strlen($query) < $xoopsConfigSearch['keyword_min']) {
97
-            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
95
+    }else {
96
+        if (strlen($query)<$xoopsConfigSearch['keyword_min']) {
97
+            redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
98 98
         }
99 99
         $queries = [$myts->addSlashes($query)];
100 100
     }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     if (!empty($time)) {
109 109
         $extra = '';
110
-    } else {
110
+    }else {
111 111
         $extra = '';
112 112
     }
113 113
 
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $xoopsTpl->assign('results', $results);
123 123
 
124
-        if (count($next_search) > 0) {
124
+        if (count($next_search)>0) {
125 125
             $items = [];
126 126
             foreach ($next_search as $para => $val) {
127 127
                 if (!empty($val)) {
128 128
                     $items[] = "$para=$val";
129 129
                 }
130 130
             }
131
-            if (count($items) > 0) {
131
+            if (count($items)>0) {
132 132
                 $paras = implode('&', $items);
133 133
             }
134 134
             unset($next_search);
135 135
             unset($items);
136 136
         }
137
-        $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras;
137
+        $search_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php?'.$paras;
138 138
 
139 139
         /*
140 140
          $next_results =& planet_search($queries, $andor, 1, $start + $limit, $uid, $category, $sortby, $searchin, $extra);
@@ -146,22 +146,22 @@  discard block
 block discarded – undo
146 146
       if (false != $has_next)
147 147
       */
148 148
         if (count($results)) {
149
-            $next            = $start + $limit;
149
+            $next            = $start+$limit;
150 150
             $queries         = implode(',', $queries);
151
-            $search_url_next = $search_url . "&start=$next";
152
-            $search_next     = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>';
151
+            $search_url_next = $search_url."&start=$next";
152
+            $search_next     = "<a href=\"".htmlspecialchars($search_url_next)."\">"._SR_NEXT.'</a>';
153 153
             $xoopsTpl->assign('search_next', $search_next);
154 154
         }
155
-        if ($start > 0) {
156
-            $prev            = $start - $limit;
157
-            $search_url_prev = $search_url . "&start=$prev";
158
-            $search_prev     = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>';
155
+        if ($start>0) {
156
+            $prev            = $start-$limit;
157
+            $search_url_prev = $search_url."&start=$prev";
158
+            $search_prev     = "<a href=\"".htmlspecialchars($search_url_prev)."\">"._SR_PREVIOUS.'</a>';
159 159
             $xoopsTpl->assign('search_prev', $search_prev);
160 160
         }
161 161
     }
162 162
 
163 163
     unset($results);
164
-    $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term);
164
+    $search_info = _SR_KEYWORDS.': '.$myts->htmlSpecialChars($term);
165 165
     $xoopsTpl->assign('search_info', $search_info);
166 166
 }
167 167
 
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
 if ('OR' === $andor) {
172 172
     $type_select .= " selected=\"selected\"";
173 173
 }
174
-$type_select .= '>' . _SR_ANY . '</option>';
174
+$type_select .= '>'._SR_ANY.'</option>';
175 175
 $type_select .= "<option value=\"AND\"";
176 176
 if ('AND' === $andor) {
177 177
     $type_select .= " selected=\"selected\"";
178 178
 }
179
-$type_select .= '>' . _SR_ALL . '</option>';
179
+$type_select .= '>'._SR_ALL.'</option>';
180 180
 $type_select .= "<option value=\"EXACT\"";
181 181
 if ('exact' === $andor) {
182 182
     $type_select .= " selected=\"selected\"";
183 183
 }
184
-$type_select .= '>' . _SR_EXACT . '</option>';
184
+$type_select .= '>'._SR_EXACT.'</option>';
185 185
 $type_select .= '</select>';
186 186
 
187 187
 /* scope */
@@ -190,32 +190,32 @@  discard block
 block discarded – undo
190 190
 if (in_array('title', $searchin)) {
191 191
     $searchin_select .= ' checked';
192 192
 }
193
-$searchin_select .= '>' . planet_constant('MD_TITLE') . '&nbsp;&nbsp;';
193
+$searchin_select .= '>'.planet_constant('MD_TITLE').'&nbsp;&nbsp;';
194 194
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\"";
195 195
 if (in_array('text', $searchin)) {
196 196
     $searchin_select .= ' checked';
197 197
 }
198
-$searchin_select .= '>' . planet_constant('MD_BODY') . '&nbsp;&nbsp;||&nbsp;&nbsp;';
198
+$searchin_select .= '>'.planet_constant('MD_BODY').'&nbsp;&nbsp;||&nbsp;&nbsp;';
199 199
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"blog\"";
200 200
 if (in_array('blog', $searchin)) {
201 201
     $searchin_select .= ' checked';
202 202
 }
203
-$searchin_select .= '>' . planet_constant('MD_BLOG') . '&nbsp;&nbsp;';
203
+$searchin_select .= '>'.planet_constant('MD_BLOG').'&nbsp;&nbsp;';
204 204
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"feed\"";
205 205
 if (in_array('feed', $searchin)) {
206 206
     $searchin_select .= ' checked';
207 207
 }
208
-$searchin_select .= '>' . planet_constant('MD_FEED') . '&nbsp;&nbsp;';
208
+$searchin_select .= '>'.planet_constant('MD_FEED').'&nbsp;&nbsp;';
209 209
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"desc\"";
210 210
 if (in_array('desc', $searchin)) {
211 211
     $searchin_select .= ' checked';
212 212
 }
213
-$searchin_select .= '>' . planet_constant('MD_DESC') . '&nbsp;&nbsp;';
213
+$searchin_select .= '>'.planet_constant('MD_DESC').'&nbsp;&nbsp;';
214 214
 $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\"";
215 215
 if (empty($searchin)) {
216 216
     $searchin_select .= ' checked';
217 217
 }
218
-$searchin_select .= '>' . _ALL . '&nbsp;&nbsp;';
218
+$searchin_select .= '>'._ALL.'&nbsp;&nbsp;';
219 219
 
220 220
 /* sortby */
221 221
 $sortby_select = "<select name=\"sortby\">";
@@ -223,28 +223,28 @@  discard block
 block discarded – undo
223 223
 if (empty($sortby)) {
224 224
     $sortby_select .= " selected=\"selected\"";
225 225
 }
226
-$sortby_select .= '>' . _NONE . '</option>';
226
+$sortby_select .= '>'._NONE.'</option>';
227 227
 $sortby_select .= "<option value=\"a.art_time\"";
228 228
 if ('a.art_time' === $sortby) {
229 229
     $sortby_select .= " selected=\"selected\"";
230 230
 }
231
-$sortby_select .= '>' . planet_constant('MD_TIME') . '</option>';
231
+$sortby_select .= '>'.planet_constant('MD_TIME').'</option>';
232 232
 $sortby_select .= "<option value=\"a.art_title\"";
233 233
 if ('a.art_title' === $sortby) {
234 234
     $sortby_select .= " selected=\"selected\"";
235 235
 }
236
-$sortby_select .= '>' . planet_constant('MD_TITLE') . '</option>';
236
+$sortby_select .= '>'.planet_constant('MD_TITLE').'</option>';
237 237
 $sortby_select .= "<option value=\"\">&nbsp;&nbsp;----&nbsp;&nbsp;</option>";
238 238
 $sortby_select .= "<option value=\"a.blog_title\"";
239 239
 if ('a.blog_title' === $sortby) {
240 240
     $sortby_select .= " selected=\"selected\"";
241 241
 }
242
-$sortby_select .= '>' . planet_constant('MD_BLOG') . '</option>';
242
+$sortby_select .= '>'.planet_constant('MD_BLOG').'</option>';
243 243
 $sortby_select .= "<option value=\"a.blog_time\"";
244 244
 if ('b.blog_time' === $sortby) {
245 245
     $sortby_select .= " selected=\"selected\"";
246 246
 }
247
-$sortby_select .= '>' . planet_constant('MD_UPDATE') . '</option>';
247
+$sortby_select .= '>'.planet_constant('MD_UPDATE').'</option>';
248 248
 $sortby_select .= '</select>';
249 249
 
250 250
 $xoopsTpl->assign('type_select', $type_select);
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 $xoopsTpl->assign('blog', $blog);
259 259
 $xoopsTpl->assign('uid', $uid);
260 260
 
261
-if ($xoopsConfigSearch['keyword_min'] > 0) {
261
+if ($xoopsConfigSearch['keyword_min']>0) {
262 262
     $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min']));
263 263
 }
264 264
 
265
-include XOOPS_ROOT_PATH . '/footer.php';
265
+include XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.
class/category.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
  */
31 31
 
32 32
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
33
-require_once __DIR__ . '/../include/vars.php';
33
+require_once __DIR__.'/../include/vars.php';
34 34
 //mod_loadFunctions('', $GLOBALS['moddirname']);
35 35
 
36 36
 /**
Please login to merge, or discard this patch.
class/xmlpc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 
28 28
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
29
-require_once __DIR__ . '/../include/vars.php';
29
+require_once __DIR__.'/../include/vars.php';
30 30
 //mod_loadFunctions('', $GLOBALS['moddirname']);
31 31
 
32 32
 if (!class_exists('Xmlrpc_client')) {
Please login to merge, or discard this patch.
class/xml.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 
28 28
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
29
-require_once __DIR__ . '/../include/vars.php';
29
+require_once __DIR__.'/../include/vars.php';
30 30
 //mod_loadFunctions('', $GLOBALS['moddirname']);
31 31
 
32 32
 /*** GENERAL USAGE *********************************************************
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
  */
65 65
 
66 66
 // your local timezone, set to "" to disable or for GMT
67
-$server_TZ = abs((int)($GLOBALS['xoopsConfig']['server_TZ'] * 3600.0));
68
-$prefix    = ($GLOBALS['xoopsConfig']['server_TZ'] < 0) ? '-' : '+';
69
-$TIME_ZONE = $prefix . date('H:i', $server_TZ);
67
+$server_TZ = abs((int) ($GLOBALS['xoopsConfig']['server_TZ']*3600.0));
68
+$prefix    = ($GLOBALS['xoopsConfig']['server_TZ']<0) ? '-' : '+';
69
+$TIME_ZONE = $prefix.date('H:i', $server_TZ);
70 70
 define('TIME_ZONE', $TIME_ZONE);
71 71
 // Version string.
72 72
 define('FEEDCREATOR_VERSION', 'ARTICLE @ XOOPS powered by FeedCreator');
73 73
 
74
-require_once __DIR__ . '/feedcreator.class.php';
74
+require_once __DIR__.'/feedcreator.class.php';
75 75
 
76 76
 /**
77 77
  * Description
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
          */
96 96
         public function __construct($version)
97 97
         {
98
-            $this->filename = XOOPS_CACHE_PATH . '/feed.xml';
98
+            $this->filename = XOOPS_CACHE_PATH.'/feed.xml';
99 99
             $this->version  = $version;
100 100
         }
101 101
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 foreach (array_keys($val) as $key) {
123 123
                     $val[$key] = $this->convert_encoding($val[$key]);
124 124
                 }
125
-            } else {
125
+            }else {
126 126
                 $val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET);
127 127
             }
128 128
 
Please login to merge, or discard this patch.
class/class-IXR.php 2 patches
Indentation   +993 added lines, -993 removed lines patch added patch discarded remove patch
@@ -14,136 +14,136 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class IXR_Value
16 16
 {
17
-    public $data;
18
-    public $type;
19
-
20
-    /**
21
-     * IXR_Value constructor.
22
-     * @param      $data
23
-     * @param bool $type
24
-     */
25
-    public function __construct($data, $type = false)
26
-    {
27
-        $this->data = $data;
28
-        if (!$type) {
29
-            $type = $this->calculateType();
30
-        }
31
-        $this->type = $type;
32
-        if ($type === 'struct') {
33
-            /* Turn all the values in the array in to new IXR_Value objects */
34
-            foreach ($this->data as $key => $value) {
35
-                $this->data[$key] = new IXR_Value($value);
36
-            }
37
-        }
38
-        if ($type === 'array') {
39
-            for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
40
-                $this->data[$i] = new IXR_Value($this->data[$i]);
41
-            }
42
-        }
43
-    }
44
-
45
-    /**
46
-     * @return string
47
-     */
48
-    public function calculateType()
49
-    {
50
-        if ($this->data === true || $this->data === false) {
51
-            return 'boolean';
52
-        }
53
-        if (is_int($this->data)) {
54
-            return 'int';
55
-        }
56
-        if (is_float($this->data)) {
57
-            return 'double';
58
-        }
59
-        // Deal with IXR object types base64 and date
60
-        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
61
-            return 'date';
62
-        }
63
-        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
64
-            return 'base64';
65
-        }
66
-        // If it is a normal PHP object convert it in to a struct
67
-        if (is_object($this->data)) {
68
-            $this->data = get_object_vars($this->data);
69
-
70
-            return 'struct';
71
-        }
72
-        if (!is_array($this->data)) {
73
-            return 'string';
74
-        }
75
-        /* We have an array - is it an array or a struct ? */
76
-        if ($this->isStruct($this->data)) {
77
-            return 'struct';
78
-        } else {
79
-            return 'array';
80
-        }
81
-    }
82
-
83
-    /**
84
-     * @return bool|string
85
-     */
86
-    public function getXml()
87
-    {
88
-        /* Return XML for this value */
89
-        switch ($this->type) {
90
-            case 'boolean':
91
-                return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
92
-                break;
93
-            case 'int':
94
-                return '<int>' . $this->data . '</int>';
95
-                break;
96
-            case 'double':
97
-                return '<double>' . $this->data . '</double>';
98
-                break;
99
-            case 'string':
100
-                return '<string>' . htmlspecialchars($this->data) . '</string>';
101
-                break;
102
-            case 'array':
103
-                $return = '<array><data>' . "\n";
104
-                foreach ($this->data as $item) {
105
-                    $return .= '  <value>' . $item->getXml() . "</value>\n";
106
-                }
107
-                $return .= '</data></array>';
108
-
109
-                return $return;
110
-                break;
111
-            case 'struct':
112
-                $return = '<struct>' . "\n";
113
-                foreach ($this->data as $name => $value) {
114
-                    $return .= "  <member><name>$name</name><value>";
115
-                    $return .= $value->getXml() . "</value></member>\n";
116
-                }
117
-                $return .= '</struct>';
118
-
119
-                return $return;
120
-                break;
121
-            case 'date':
122
-            case 'base64':
123
-                return $this->data->getXml();
124
-                break;
125
-        }
126
-
127
-        return false;
128
-    }
129
-
130
-    /**
131
-     * @param $array
132
-     * @return bool
133
-     */
134
-    public function isStruct($array)
135
-    {
136
-        /* Nasty function to check if an array is a struct or not */
137
-        $expected = 0;
138
-        foreach ($array as $key => $value) {
139
-            if ((string)$key != (string)$expected) {
140
-                return true;
141
-            }
142
-            ++$expected;
143
-        }
144
-
145
-        return false;
146
-    }
17
+	public $data;
18
+	public $type;
19
+
20
+	/**
21
+	 * IXR_Value constructor.
22
+	 * @param      $data
23
+	 * @param bool $type
24
+	 */
25
+	public function __construct($data, $type = false)
26
+	{
27
+		$this->data = $data;
28
+		if (!$type) {
29
+			$type = $this->calculateType();
30
+		}
31
+		$this->type = $type;
32
+		if ($type === 'struct') {
33
+			/* Turn all the values in the array in to new IXR_Value objects */
34
+			foreach ($this->data as $key => $value) {
35
+				$this->data[$key] = new IXR_Value($value);
36
+			}
37
+		}
38
+		if ($type === 'array') {
39
+			for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
40
+				$this->data[$i] = new IXR_Value($this->data[$i]);
41
+			}
42
+		}
43
+	}
44
+
45
+	/**
46
+	 * @return string
47
+	 */
48
+	public function calculateType()
49
+	{
50
+		if ($this->data === true || $this->data === false) {
51
+			return 'boolean';
52
+		}
53
+		if (is_int($this->data)) {
54
+			return 'int';
55
+		}
56
+		if (is_float($this->data)) {
57
+			return 'double';
58
+		}
59
+		// Deal with IXR object types base64 and date
60
+		if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
61
+			return 'date';
62
+		}
63
+		if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
64
+			return 'base64';
65
+		}
66
+		// If it is a normal PHP object convert it in to a struct
67
+		if (is_object($this->data)) {
68
+			$this->data = get_object_vars($this->data);
69
+
70
+			return 'struct';
71
+		}
72
+		if (!is_array($this->data)) {
73
+			return 'string';
74
+		}
75
+		/* We have an array - is it an array or a struct ? */
76
+		if ($this->isStruct($this->data)) {
77
+			return 'struct';
78
+		} else {
79
+			return 'array';
80
+		}
81
+	}
82
+
83
+	/**
84
+	 * @return bool|string
85
+	 */
86
+	public function getXml()
87
+	{
88
+		/* Return XML for this value */
89
+		switch ($this->type) {
90
+			case 'boolean':
91
+				return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
92
+				break;
93
+			case 'int':
94
+				return '<int>' . $this->data . '</int>';
95
+				break;
96
+			case 'double':
97
+				return '<double>' . $this->data . '</double>';
98
+				break;
99
+			case 'string':
100
+				return '<string>' . htmlspecialchars($this->data) . '</string>';
101
+				break;
102
+			case 'array':
103
+				$return = '<array><data>' . "\n";
104
+				foreach ($this->data as $item) {
105
+					$return .= '  <value>' . $item->getXml() . "</value>\n";
106
+				}
107
+				$return .= '</data></array>';
108
+
109
+				return $return;
110
+				break;
111
+			case 'struct':
112
+				$return = '<struct>' . "\n";
113
+				foreach ($this->data as $name => $value) {
114
+					$return .= "  <member><name>$name</name><value>";
115
+					$return .= $value->getXml() . "</value></member>\n";
116
+				}
117
+				$return .= '</struct>';
118
+
119
+				return $return;
120
+				break;
121
+			case 'date':
122
+			case 'base64':
123
+				return $this->data->getXml();
124
+				break;
125
+		}
126
+
127
+		return false;
128
+	}
129
+
130
+	/**
131
+	 * @param $array
132
+	 * @return bool
133
+	 */
134
+	public function isStruct($array)
135
+	{
136
+		/* Nasty function to check if an array is a struct or not */
137
+		$expected = 0;
138
+		foreach ($array as $key => $value) {
139
+			if ((string)$key != (string)$expected) {
140
+				return true;
141
+			}
142
+			++$expected;
143
+		}
144
+
145
+		return false;
146
+	}
147 147
 }
148 148
 
149 149
 /**
@@ -151,189 +151,189 @@  discard block
 block discarded – undo
151 151
  */
152 152
 class IXR_Message
153 153
 {
154
-    public $message;
155
-    public $messageType;  // methodCall / methodResponse / fault
156
-    public $faultCode;
157
-    public $faultString;
158
-    public $methodName;
159
-    public $params;
160
-    // Current variable stacks
161
-    public $_arraystructs      = [];   // The stack used to keep track of the current array/struct
162
-    public $_arraystructstypes = []; // Stack keeping track of if things are structs or array
163
-    public $_currentStructName = [];  // A stack as well
164
-    public $_param;
165
-    public $_value;
166
-    public $_currentTag;
167
-    public $_currentTagContents;
168
-    // The XML parser
169
-    public $_parser;
170
-
171
-    /**
172
-     * IXR_Message constructor.
173
-     * @param $message
174
-     */
175
-    public function __construct($message)
176
-    {
177
-        $this->message = $message;
178
-    }
179
-
180
-    /**
181
-     * @return bool
182
-     */
183
-    public function parse()
184
-    {
185
-        // first remove the XML declaration
186
-        $this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
187
-        if (trim($this->message) == '') {
188
-            return false;
189
-        }
190
-        $this->_parser = xml_parser_create();
191
-        // Set XML parser to take the case of tags in to account
192
-        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
193
-        // Set XML parser callback functions
194
-        xml_set_object($this->_parser, $this);
195
-        xml_set_elementHandler($this->_parser, 'tag_open', 'tag_close');
196
-        xml_set_character_dataHandler($this->_parser, 'cdata');
197
-        if (!xml_parse($this->_parser, $this->message)) {
198
-            /* die(sprintf('XML error: %s at line %d',
154
+	public $message;
155
+	public $messageType;  // methodCall / methodResponse / fault
156
+	public $faultCode;
157
+	public $faultString;
158
+	public $methodName;
159
+	public $params;
160
+	// Current variable stacks
161
+	public $_arraystructs      = [];   // The stack used to keep track of the current array/struct
162
+	public $_arraystructstypes = []; // Stack keeping track of if things are structs or array
163
+	public $_currentStructName = [];  // A stack as well
164
+	public $_param;
165
+	public $_value;
166
+	public $_currentTag;
167
+	public $_currentTagContents;
168
+	// The XML parser
169
+	public $_parser;
170
+
171
+	/**
172
+	 * IXR_Message constructor.
173
+	 * @param $message
174
+	 */
175
+	public function __construct($message)
176
+	{
177
+		$this->message = $message;
178
+	}
179
+
180
+	/**
181
+	 * @return bool
182
+	 */
183
+	public function parse()
184
+	{
185
+		// first remove the XML declaration
186
+		$this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
187
+		if (trim($this->message) == '') {
188
+			return false;
189
+		}
190
+		$this->_parser = xml_parser_create();
191
+		// Set XML parser to take the case of tags in to account
192
+		xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
193
+		// Set XML parser callback functions
194
+		xml_set_object($this->_parser, $this);
195
+		xml_set_elementHandler($this->_parser, 'tag_open', 'tag_close');
196
+		xml_set_character_dataHandler($this->_parser, 'cdata');
197
+		if (!xml_parse($this->_parser, $this->message)) {
198
+			/* die(sprintf('XML error: %s at line %d',
199 199
                 xml_error_string(xml_get_error_code($this->_parser)),
200 200
                 xml_get_current_line_number($this->_parser))); */
201 201
 
202
-            return false;
203
-        }
204
-        xml_parser_free($this->_parser);
205
-        // Grab the error messages, if any
206
-        if ($this->messageType === 'fault') {
207
-            $this->faultCode   = $this->params[0]['faultCode'];
208
-            $this->faultString = $this->params[0]['faultString'];
209
-        }
210
-
211
-        return true;
212
-    }
213
-
214
-    /**
215
-     * @param $parser
216
-     * @param $tag
217
-     * @param $attr
218
-     */
219
-    public function tag_open($parser, $tag, $attr)
220
-    {
221
-        $this->currentTag = $tag;
222
-        switch ($tag) {
223
-            case 'methodCall':
224
-            case 'methodResponse':
225
-            case 'fault':
226
-                $this->messageType = $tag;
227
-                break;
228
-            /* Deal with stacks of arrays and structs */
229
-            case 'data':    // data is to all intents and puposes more interesting than array
230
-                $this->_arraystructstypes[] = 'array';
231
-                $this->_arraystructs[]      = [];
232
-                break;
233
-            case 'struct':
234
-                $this->_arraystructstypes[] = 'struct';
235
-                $this->_arraystructs[]      = [];
236
-                break;
237
-        }
238
-    }
239
-
240
-    /**
241
-     * @param $parser
242
-     * @param $cdata
243
-     */
244
-    public function cdata($parser, $cdata)
245
-    {
246
-        $this->_currentTagContents .= $cdata;
247
-    }
248
-
249
-    /**
250
-     * @param $parser
251
-     * @param $tag
252
-     */
253
-    public function tag_close($parser, $tag)
254
-    {
255
-        $valueFlag = false;
256
-        switch ($tag) {
257
-            case 'int':
258
-            case 'i4':
259
-                $value                     = (int)trim($this->_currentTagContents);
260
-                $this->_currentTagContents = '';
261
-                $valueFlag                 = true;
262
-                break;
263
-            case 'double':
264
-                $value                     = (double)trim($this->_currentTagContents);
265
-                $this->_currentTagContents = '';
266
-                $valueFlag                 = true;
267
-                break;
268
-            case 'string':
269
-                $value                     = (string)trim($this->_currentTagContents);
270
-                $this->_currentTagContents = '';
271
-                $valueFlag                 = true;
272
-                break;
273
-            case 'dateTime.iso8601':
274
-                $value = new IXR_Date(trim($this->_currentTagContents));
275
-                // $value = $iso->getTimestamp();
276
-                $this->_currentTagContents = '';
277
-                $valueFlag                 = true;
278
-                break;
279
-            case 'value':
280
-                // "If no type is indicated, the type is string."
281
-                if (trim($this->_currentTagContents) != '') {
282
-                    $value                     = (string)$this->_currentTagContents;
283
-                    $this->_currentTagContents = '';
284
-                    $valueFlag                 = true;
285
-                }
286
-                break;
287
-            case 'boolean':
288
-                $value                     = (boolean)trim($this->_currentTagContents);
289
-                $this->_currentTagContents = '';
290
-                $valueFlag                 = true;
291
-                break;
292
-            case 'base64':
293
-                $value                     = base64_decode(trim($this->_currentTagContents));
294
-                $this->_currentTagContents = '';
295
-                $valueFlag                 = true;
296
-                break;
297
-            /* Deal with stacks of arrays and structs */
298
-            case 'data':
299
-            case 'struct':
300
-                $value = array_pop($this->_arraystructs);
301
-                array_pop($this->_arraystructstypes);
302
-                $valueFlag = true;
303
-                break;
304
-            case 'member':
305
-                array_pop($this->_currentStructName);
306
-                break;
307
-            case 'name':
308
-                $this->_currentStructName[] = trim($this->_currentTagContents);
309
-                $this->_currentTagContents  = '';
310
-                break;
311
-            case 'methodName':
312
-                $this->methodName          = trim($this->_currentTagContents);
313
-                $this->_currentTagContents = '';
314
-                break;
315
-        }
316
-        if ($valueFlag) {
317
-            /*
202
+			return false;
203
+		}
204
+		xml_parser_free($this->_parser);
205
+		// Grab the error messages, if any
206
+		if ($this->messageType === 'fault') {
207
+			$this->faultCode   = $this->params[0]['faultCode'];
208
+			$this->faultString = $this->params[0]['faultString'];
209
+		}
210
+
211
+		return true;
212
+	}
213
+
214
+	/**
215
+	 * @param $parser
216
+	 * @param $tag
217
+	 * @param $attr
218
+	 */
219
+	public function tag_open($parser, $tag, $attr)
220
+	{
221
+		$this->currentTag = $tag;
222
+		switch ($tag) {
223
+			case 'methodCall':
224
+			case 'methodResponse':
225
+			case 'fault':
226
+				$this->messageType = $tag;
227
+				break;
228
+			/* Deal with stacks of arrays and structs */
229
+			case 'data':    // data is to all intents and puposes more interesting than array
230
+				$this->_arraystructstypes[] = 'array';
231
+				$this->_arraystructs[]      = [];
232
+				break;
233
+			case 'struct':
234
+				$this->_arraystructstypes[] = 'struct';
235
+				$this->_arraystructs[]      = [];
236
+				break;
237
+		}
238
+	}
239
+
240
+	/**
241
+	 * @param $parser
242
+	 * @param $cdata
243
+	 */
244
+	public function cdata($parser, $cdata)
245
+	{
246
+		$this->_currentTagContents .= $cdata;
247
+	}
248
+
249
+	/**
250
+	 * @param $parser
251
+	 * @param $tag
252
+	 */
253
+	public function tag_close($parser, $tag)
254
+	{
255
+		$valueFlag = false;
256
+		switch ($tag) {
257
+			case 'int':
258
+			case 'i4':
259
+				$value                     = (int)trim($this->_currentTagContents);
260
+				$this->_currentTagContents = '';
261
+				$valueFlag                 = true;
262
+				break;
263
+			case 'double':
264
+				$value                     = (double)trim($this->_currentTagContents);
265
+				$this->_currentTagContents = '';
266
+				$valueFlag                 = true;
267
+				break;
268
+			case 'string':
269
+				$value                     = (string)trim($this->_currentTagContents);
270
+				$this->_currentTagContents = '';
271
+				$valueFlag                 = true;
272
+				break;
273
+			case 'dateTime.iso8601':
274
+				$value = new IXR_Date(trim($this->_currentTagContents));
275
+				// $value = $iso->getTimestamp();
276
+				$this->_currentTagContents = '';
277
+				$valueFlag                 = true;
278
+				break;
279
+			case 'value':
280
+				// "If no type is indicated, the type is string."
281
+				if (trim($this->_currentTagContents) != '') {
282
+					$value                     = (string)$this->_currentTagContents;
283
+					$this->_currentTagContents = '';
284
+					$valueFlag                 = true;
285
+				}
286
+				break;
287
+			case 'boolean':
288
+				$value                     = (boolean)trim($this->_currentTagContents);
289
+				$this->_currentTagContents = '';
290
+				$valueFlag                 = true;
291
+				break;
292
+			case 'base64':
293
+				$value                     = base64_decode(trim($this->_currentTagContents));
294
+				$this->_currentTagContents = '';
295
+				$valueFlag                 = true;
296
+				break;
297
+			/* Deal with stacks of arrays and structs */
298
+			case 'data':
299
+			case 'struct':
300
+				$value = array_pop($this->_arraystructs);
301
+				array_pop($this->_arraystructstypes);
302
+				$valueFlag = true;
303
+				break;
304
+			case 'member':
305
+				array_pop($this->_currentStructName);
306
+				break;
307
+			case 'name':
308
+				$this->_currentStructName[] = trim($this->_currentTagContents);
309
+				$this->_currentTagContents  = '';
310
+				break;
311
+			case 'methodName':
312
+				$this->methodName          = trim($this->_currentTagContents);
313
+				$this->_currentTagContents = '';
314
+				break;
315
+		}
316
+		if ($valueFlag) {
317
+			/*
318 318
             if (!is_array($value) && !is_object($value)) {
319 319
                 $value = trim($value);
320 320
             }
321 321
             */
322
-            if (count($this->_arraystructs) > 0) {
323
-                // Add value to struct or array
324
-                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
325
-                    // Add to struct
326
-                    $this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
327
-                } else {
328
-                    // Add to array
329
-                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
330
-                }
331
-            } else {
332
-                // Just add as a paramater
333
-                $this->params[] = $value;
334
-            }
335
-        }
336
-    }
322
+			if (count($this->_arraystructs) > 0) {
323
+				// Add value to struct or array
324
+				if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
325
+					// Add to struct
326
+					$this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
327
+				} else {
328
+					// Add to array
329
+					$this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
330
+				}
331
+			} else {
332
+				// Just add as a paramater
333
+				$this->params[] = $value;
334
+			}
335
+		}
336
+	}
337 337
 }
338 338
 
339 339
 /**
@@ -341,55 +341,55 @@  discard block
 block discarded – undo
341 341
  */
342 342
 class IXR_Server
343 343
 {
344
-    public $data;
345
-    public $callbacks = [];
346
-    public $message;
347
-    public $capabilities;
348
-
349
-    /**
350
-     * IXR_Server constructor.
351
-     * @param bool $callbacks
352
-     * @param bool $data
353
-     */
354
-    public function __construct($callbacks = false, $data = false)
355
-    {
356
-        $this->setCapabilities();
357
-        if ($callbacks) {
358
-            $this->callbacks = $callbacks;
359
-        }
360
-        $this->setCallbacks();
361
-        $this->serve($data);
362
-    }
363
-
364
-    /**
365
-     * @param bool $data
366
-     */
367
-    public function serve($data = false)
368
-    {
369
-        if (!$data) {
370
-            $http_raw_post_data = file_get_contents('php://input');
371
-            if (!$http_raw_post_data) {
372
-                die('XML-RPC server accepts POST requests only.');
373
-            }
374
-            $data = $http_raw_post_data;
375
-        }
376
-        $this->message = new IXR_Message($data);
377
-        if (!$this->message->parse()) {
378
-            $this->error(-32700, 'parse error. not well formed');
379
-        }
380
-        if ($this->message->messageType !== 'methodCall') {
381
-            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
382
-        }
383
-        $result = $this->call($this->message->methodName, $this->message->params);
384
-        // Is the result an error?
385
-        if (is_a($result, 'IXR_Error')) {
386
-            $this->error($result);
387
-        }
388
-        // Encode the result
389
-        $r         = new IXR_Value($result);
390
-        $resultxml = $r->getXml();
391
-        // Create the XML
392
-        $xml = <<<EOD
344
+	public $data;
345
+	public $callbacks = [];
346
+	public $message;
347
+	public $capabilities;
348
+
349
+	/**
350
+	 * IXR_Server constructor.
351
+	 * @param bool $callbacks
352
+	 * @param bool $data
353
+	 */
354
+	public function __construct($callbacks = false, $data = false)
355
+	{
356
+		$this->setCapabilities();
357
+		if ($callbacks) {
358
+			$this->callbacks = $callbacks;
359
+		}
360
+		$this->setCallbacks();
361
+		$this->serve($data);
362
+	}
363
+
364
+	/**
365
+	 * @param bool $data
366
+	 */
367
+	public function serve($data = false)
368
+	{
369
+		if (!$data) {
370
+			$http_raw_post_data = file_get_contents('php://input');
371
+			if (!$http_raw_post_data) {
372
+				die('XML-RPC server accepts POST requests only.');
373
+			}
374
+			$data = $http_raw_post_data;
375
+		}
376
+		$this->message = new IXR_Message($data);
377
+		if (!$this->message->parse()) {
378
+			$this->error(-32700, 'parse error. not well formed');
379
+		}
380
+		if ($this->message->messageType !== 'methodCall') {
381
+			$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
382
+		}
383
+		$result = $this->call($this->message->methodName, $this->message->params);
384
+		// Is the result an error?
385
+		if (is_a($result, 'IXR_Error')) {
386
+			$this->error($result);
387
+		}
388
+		// Encode the result
389
+		$r         = new IXR_Value($result);
390
+		$resultxml = $r->getXml();
391
+		// Create the XML
392
+		$xml = <<<EOD
393 393
 <methodResponse>
394 394
   <params>
395 395
     <param>
@@ -401,162 +401,162 @@  discard block
 block discarded – undo
401 401
 </methodResponse>
402 402
 
403 403
 EOD;
404
-        // Send it
405
-        $this->output($xml);
406
-    }
407
-
408
-    /**
409
-     * @param $methodname
410
-     * @param $args
411
-     * @return IXR_Error|mixed
412
-     */
413
-    public function call($methodname, $args)
414
-    {
415
-        if (!$this->hasMethod($methodname)) {
416
-            return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
417
-        }
418
-        $method = $this->callbacks[$methodname];
419
-        // Perform the callback and send the response
420
-        if (count($args) == 1) {
421
-            // If only one paramater just send that instead of the whole array
422
-            $args = $args[0];
423
-        }
424
-        // Are we dealing with a function or a method?
425
-        if (substr($method, 0, 5) === 'this:') {
426
-            // It's a class method - check it exists
427
-            $method = substr($method, 5);
428
-            if (!method_exists($this, $method)) {
429
-                return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
430
-            }
431
-            // Call the method
432
-            $result = $this->$method($args);
433
-        } else {
434
-            // It's a function - does it exist?
435
-            if (is_array($method)) {
436
-                if (!method_exists($method[0], $method[1])) {
437
-                    return new IXR_Error(-32601, 'server error. requested object method "' . $method[1] . '" does not exist.');
438
-                }
439
-            } elseif (!function_exists($method)) {
440
-                return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
441
-            }
442
-            // Call the function
443
-            $result = call_user_func($method, $args);
444
-        }
445
-
446
-        return $result;
447
-    }
448
-
449
-    /**
450
-     * @param      $error
451
-     * @param bool $message
452
-     */
453
-    public function error($error, $message = false)
454
-    {
455
-        // Accepts either an error object or an error code and message
456
-        if ($message && !is_object($error)) {
457
-            $error = new IXR_Error($error, $message);
458
-        }
459
-        $this->output($error->getXml());
460
-    }
461
-
462
-    /**
463
-     * @param $xml
464
-     */
465
-    public function output($xml)
466
-    {
467
-        $xml    = '<?xml version="1.0"?>' . "\n" . $xml;
468
-        $length = strlen($xml);
469
-        header('Connection: close');
470
-        header('Content-Length: ' . $length);
471
-        header('Content-Type: text/xml');
472
-        header('Date: ' . date('r'));
473
-        echo $xml;
474
-        exit;
475
-    }
476
-
477
-    /**
478
-     * @param $method
479
-     * @return bool
480
-     */
481
-    public function hasMethod($method)
482
-    {
483
-        return in_array($method, array_keys($this->callbacks));
484
-    }
485
-
486
-    public function setCapabilities()
487
-    {
488
-        // Initialises capabilities array
489
-        $this->capabilities = [
490
-            'xmlrpc'           => [
491
-                'specUrl'     => 'http://www.xmlrpc.com/spec',
492
-                'specVersion' => 1
493
-            ],
494
-            'faults_interop'   => [
495
-                'specUrl'     => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
496
-                'specVersion' => 20010516
497
-            ],
498
-            'system.multicall' => [
499
-                'specUrl'     => 'http://www.xmlrpc.com/discuss/msgReader$1208',
500
-                'specVersion' => 1
501
-            ]
502
-        ];
503
-    }
504
-
505
-    /**
506
-     * @param $args
507
-     * @return mixed
508
-     */
509
-    public function getCapabilities($args)
510
-    {
511
-        return $this->capabilities;
512
-    }
513
-
514
-    public function setCallbacks()
515
-    {
516
-        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
517
-        $this->callbacks['system.listMethods']     = 'this:listMethods';
518
-        $this->callbacks['system.multicall']       = 'this:multiCall';
519
-    }
520
-
521
-    /**
522
-     * @param $args
523
-     * @return array
524
-     */
525
-    public function listMethods($args)
526
-    {
527
-        // Returns a list of methods - uses array_reverse to ensure user defined
528
-        // methods are listed before server defined methods
529
-        return array_reverse(array_keys($this->callbacks));
530
-    }
531
-
532
-    /**
533
-     * @param $methodcalls
534
-     * @return array
535
-     */
536
-    public function multiCall($methodcalls)
537
-    {
538
-        // See http://www.xmlrpc.com/discuss/msgReader$1208
539
-        $return = [];
540
-        foreach ($methodcalls as $call) {
541
-            $method = $call['methodName'];
542
-            $params = $call['params'];
543
-            if ($method === 'system.multicall') {
544
-                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
545
-            } else {
546
-                $result = $this->call($method, $params);
547
-            }
548
-            if (is_a($result, 'IXR_Error')) {
549
-                $return[] = [
550
-                    'faultCode'   => $result->code,
551
-                    'faultString' => $result->message
552
-                ];
553
-            } else {
554
-                $return[] = [$result];
555
-            }
556
-        }
557
-
558
-        return $return;
559
-    }
404
+		// Send it
405
+		$this->output($xml);
406
+	}
407
+
408
+	/**
409
+	 * @param $methodname
410
+	 * @param $args
411
+	 * @return IXR_Error|mixed
412
+	 */
413
+	public function call($methodname, $args)
414
+	{
415
+		if (!$this->hasMethod($methodname)) {
416
+			return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
417
+		}
418
+		$method = $this->callbacks[$methodname];
419
+		// Perform the callback and send the response
420
+		if (count($args) == 1) {
421
+			// If only one paramater just send that instead of the whole array
422
+			$args = $args[0];
423
+		}
424
+		// Are we dealing with a function or a method?
425
+		if (substr($method, 0, 5) === 'this:') {
426
+			// It's a class method - check it exists
427
+			$method = substr($method, 5);
428
+			if (!method_exists($this, $method)) {
429
+				return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
430
+			}
431
+			// Call the method
432
+			$result = $this->$method($args);
433
+		} else {
434
+			// It's a function - does it exist?
435
+			if (is_array($method)) {
436
+				if (!method_exists($method[0], $method[1])) {
437
+					return new IXR_Error(-32601, 'server error. requested object method "' . $method[1] . '" does not exist.');
438
+				}
439
+			} elseif (!function_exists($method)) {
440
+				return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
441
+			}
442
+			// Call the function
443
+			$result = call_user_func($method, $args);
444
+		}
445
+
446
+		return $result;
447
+	}
448
+
449
+	/**
450
+	 * @param      $error
451
+	 * @param bool $message
452
+	 */
453
+	public function error($error, $message = false)
454
+	{
455
+		// Accepts either an error object or an error code and message
456
+		if ($message && !is_object($error)) {
457
+			$error = new IXR_Error($error, $message);
458
+		}
459
+		$this->output($error->getXml());
460
+	}
461
+
462
+	/**
463
+	 * @param $xml
464
+	 */
465
+	public function output($xml)
466
+	{
467
+		$xml    = '<?xml version="1.0"?>' . "\n" . $xml;
468
+		$length = strlen($xml);
469
+		header('Connection: close');
470
+		header('Content-Length: ' . $length);
471
+		header('Content-Type: text/xml');
472
+		header('Date: ' . date('r'));
473
+		echo $xml;
474
+		exit;
475
+	}
476
+
477
+	/**
478
+	 * @param $method
479
+	 * @return bool
480
+	 */
481
+	public function hasMethod($method)
482
+	{
483
+		return in_array($method, array_keys($this->callbacks));
484
+	}
485
+
486
+	public function setCapabilities()
487
+	{
488
+		// Initialises capabilities array
489
+		$this->capabilities = [
490
+			'xmlrpc'           => [
491
+				'specUrl'     => 'http://www.xmlrpc.com/spec',
492
+				'specVersion' => 1
493
+			],
494
+			'faults_interop'   => [
495
+				'specUrl'     => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
496
+				'specVersion' => 20010516
497
+			],
498
+			'system.multicall' => [
499
+				'specUrl'     => 'http://www.xmlrpc.com/discuss/msgReader$1208',
500
+				'specVersion' => 1
501
+			]
502
+		];
503
+	}
504
+
505
+	/**
506
+	 * @param $args
507
+	 * @return mixed
508
+	 */
509
+	public function getCapabilities($args)
510
+	{
511
+		return $this->capabilities;
512
+	}
513
+
514
+	public function setCallbacks()
515
+	{
516
+		$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
517
+		$this->callbacks['system.listMethods']     = 'this:listMethods';
518
+		$this->callbacks['system.multicall']       = 'this:multiCall';
519
+	}
520
+
521
+	/**
522
+	 * @param $args
523
+	 * @return array
524
+	 */
525
+	public function listMethods($args)
526
+	{
527
+		// Returns a list of methods - uses array_reverse to ensure user defined
528
+		// methods are listed before server defined methods
529
+		return array_reverse(array_keys($this->callbacks));
530
+	}
531
+
532
+	/**
533
+	 * @param $methodcalls
534
+	 * @return array
535
+	 */
536
+	public function multiCall($methodcalls)
537
+	{
538
+		// See http://www.xmlrpc.com/discuss/msgReader$1208
539
+		$return = [];
540
+		foreach ($methodcalls as $call) {
541
+			$method = $call['methodName'];
542
+			$params = $call['params'];
543
+			if ($method === 'system.multicall') {
544
+				$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
545
+			} else {
546
+				$result = $this->call($method, $params);
547
+			}
548
+			if (is_a($result, 'IXR_Error')) {
549
+				$return[] = [
550
+					'faultCode'   => $result->code,
551
+					'faultString' => $result->message
552
+				];
553
+			} else {
554
+				$return[] = [$result];
555
+			}
556
+		}
557
+
558
+		return $return;
559
+	}
560 560
 }
561 561
 
562 562
 /**
@@ -564,50 +564,50 @@  discard block
 block discarded – undo
564 564
  */
565 565
 class IXR_Request
566 566
 {
567
-    public $method;
568
-    public $args;
569
-    public $xml;
570
-
571
-    /**
572
-     * IXR_Request constructor.
573
-     * @param $method
574
-     * @param $args
575
-     */
576
-    public function __construct($method, $args)
577
-    {
578
-        $this->method = $method;
579
-        $this->args   = $args;
580
-        $this->xml    = <<<EOD
567
+	public $method;
568
+	public $args;
569
+	public $xml;
570
+
571
+	/**
572
+	 * IXR_Request constructor.
573
+	 * @param $method
574
+	 * @param $args
575
+	 */
576
+	public function __construct($method, $args)
577
+	{
578
+		$this->method = $method;
579
+		$this->args   = $args;
580
+		$this->xml    = <<<EOD
581 581
 <?xml version="1.0"?>
582 582
 <methodCall>
583 583
 <methodName>{$this->method}</methodName>
584 584
 <params>
585 585
 
586 586
 EOD;
587
-        foreach ($this->args as $arg) {
588
-            $this->xml .= '<param><value>';
589
-            $v         = new IXR_Value($arg);
590
-            $this->xml .= $v->getXml();
591
-            $this->xml .= "</value></param>\n";
592
-        }
593
-        $this->xml .= '</params></methodCall>';
594
-    }
595
-
596
-    /**
597
-     * @return int
598
-     */
599
-    public function getLength()
600
-    {
601
-        return strlen($this->xml);
602
-    }
603
-
604
-    /**
605
-     * @return string
606
-     */
607
-    public function getXml()
608
-    {
609
-        return $this->xml;
610
-    }
587
+		foreach ($this->args as $arg) {
588
+			$this->xml .= '<param><value>';
589
+			$v         = new IXR_Value($arg);
590
+			$this->xml .= $v->getXml();
591
+			$this->xml .= "</value></param>\n";
592
+		}
593
+		$this->xml .= '</params></methodCall>';
594
+	}
595
+
596
+	/**
597
+	 * @return int
598
+	 */
599
+	public function getLength()
600
+	{
601
+		return strlen($this->xml);
602
+	}
603
+
604
+	/**
605
+	 * @return string
606
+	 */
607
+	public function getXml()
608
+	{
609
+		return $this->xml;
610
+	}
611 611
 }
612 612
 
613 613
 /**
@@ -615,150 +615,150 @@  discard block
 block discarded – undo
615 615
  */
616 616
 class IXR_Client
617 617
 {
618
-    public $server;
619
-    public $port;
620
-    public $path;
621
-    public $useragent;
622
-    public $response;
623
-    public $timeout;
624
-    public $vendor  = '';
625
-    public $message = false;
626
-    public $debug   = false;
627
-    // Storage place for an error message
628
-    public $error = false;
629
-
630
-    /**
631
-     * IXR_Client constructor.
632
-     * @param        $server
633
-     * @param bool   $path
634
-     * @param int    $port
635
-     * @param int    $timeout
636
-     * @param string $vendor
637
-     */
638
-    public function __construct($server, $path = false, $port = 80, $timeout = 30, $vendor = '')
639
-    {
640
-        if (!$path) {
641
-            // Assume we have been given a URL instead
642
-            $bits         = parse_url($server);
643
-            $this->server = $bits['host'];
644
-            $this->port   = isset($bits['port']) ? $bits['port'] : 80;
645
-            $this->path   = isset($bits['path']) ? $bits['path'] : '/';
646
-            // Make absolutely sure we have a path
647
-            if (!$this->path) {
648
-                $this->path = '/';
649
-            }
650
-        } else {
651
-            $this->server  = $server;
652
-            $this->path    = $path;
653
-            $this->port    = $port;
654
-            $this->timeout = $timeout;
655
-        }
656
-        $this->useragent = 'The Incutio XML-RPC PHP Library';
657
-    }
658
-
659
-    /**
660
-     * @return bool
661
-     */
662
-    public function query()
663
-    {
664
-        $args    = func_get_args();
665
-        $method  = array_shift($args);
666
-        $request = new IXR_Request($method, $args);
667
-        $length  = $request->getLength();
668
-        $xml     = $request->getXml();
669
-        $r       = "\r\n";
670
-        $request = "POST {$this->path} HTTP/1.0$r";
671
-        $request .= "Host: {$this->server}$r";
672
-        $request .= "Content-Type: text/xml$r";
673
-        $request .= "User-Agent: {$this->useragent}$r";
674
-        $request .= "Content-length: {$length}$r$r";
675
-        $request .= $xml;
676
-        // Now send the request
677
-        if ($this->debug) {
678
-            echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
679
-        }
680
-        $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
681
-        if (!$fp) {
682
-            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
683
-
684
-            return false;
685
-        }
686
-        fwrite($fp, $request);
687
-        $contents       = '';
688
-        $gotFirstLine   = false;
689
-        $gettingHeaders = true;
690
-        while (!feof($fp)) {
691
-            $line = fgets($fp, 4096);
692
-            if (!$gotFirstLine) {
693
-                // Check line for '200'
694
-                if (false === strpos($line, '200')) {
695
-                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
696
-
697
-                    return false;
698
-                }
699
-                $gotFirstLine = true;
700
-            }
701
-            if (trim($line) == '') {
702
-                $gettingHeaders = false;
703
-            }
704
-            if (!$gettingHeaders) {
705
-                $contents .= trim($line) . "\n";
706
-            }
707
-        }
708
-        if ($this->debug) {
709
-            echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
710
-        }
711
-        // Now parse what we've got back
712
-        $this->message = new IXR_Message($contents);
713
-        if (!$this->message->parse()) {
714
-            // XML error
715
-            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
716
-
717
-            return false;
718
-        }
719
-        // Is the message a fault?
720
-        if ($this->message->messageType === 'fault') {
721
-            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
722
-
723
-            return false;
724
-        }
725
-
726
-        // Message must be OK
727
-        return true;
728
-    }
729
-
730
-    /**
731
-     * @return mixed
732
-     */
733
-    public function getResponse()
734
-    {
735
-        // methodResponses can only have one param - return that
736
-        return $this->message->params[0];
737
-    }
738
-
739
-    /**
740
-     * @return bool
741
-     */
742
-    public function isError()
743
-    {
744
-        return is_object($this->error);
745
-    }
746
-
747
-    /**
748
-     * @return mixed
749
-     */
750
-    public function getErrorCode()
751
-    {
752
-        return $this->error->code;
753
-    }
754
-
755
-    /**
756
-     * @return mixed
757
-     */
758
-    public function getErrorMessage()
759
-    {
760
-        return $this->error->message;
761
-    }
618
+	public $server;
619
+	public $port;
620
+	public $path;
621
+	public $useragent;
622
+	public $response;
623
+	public $timeout;
624
+	public $vendor  = '';
625
+	public $message = false;
626
+	public $debug   = false;
627
+	// Storage place for an error message
628
+	public $error = false;
629
+
630
+	/**
631
+	 * IXR_Client constructor.
632
+	 * @param        $server
633
+	 * @param bool   $path
634
+	 * @param int    $port
635
+	 * @param int    $timeout
636
+	 * @param string $vendor
637
+	 */
638
+	public function __construct($server, $path = false, $port = 80, $timeout = 30, $vendor = '')
639
+	{
640
+		if (!$path) {
641
+			// Assume we have been given a URL instead
642
+			$bits         = parse_url($server);
643
+			$this->server = $bits['host'];
644
+			$this->port   = isset($bits['port']) ? $bits['port'] : 80;
645
+			$this->path   = isset($bits['path']) ? $bits['path'] : '/';
646
+			// Make absolutely sure we have a path
647
+			if (!$this->path) {
648
+				$this->path = '/';
649
+			}
650
+		} else {
651
+			$this->server  = $server;
652
+			$this->path    = $path;
653
+			$this->port    = $port;
654
+			$this->timeout = $timeout;
655
+		}
656
+		$this->useragent = 'The Incutio XML-RPC PHP Library';
657
+	}
658
+
659
+	/**
660
+	 * @return bool
661
+	 */
662
+	public function query()
663
+	{
664
+		$args    = func_get_args();
665
+		$method  = array_shift($args);
666
+		$request = new IXR_Request($method, $args);
667
+		$length  = $request->getLength();
668
+		$xml     = $request->getXml();
669
+		$r       = "\r\n";
670
+		$request = "POST {$this->path} HTTP/1.0$r";
671
+		$request .= "Host: {$this->server}$r";
672
+		$request .= "Content-Type: text/xml$r";
673
+		$request .= "User-Agent: {$this->useragent}$r";
674
+		$request .= "Content-length: {$length}$r$r";
675
+		$request .= $xml;
676
+		// Now send the request
677
+		if ($this->debug) {
678
+			echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
679
+		}
680
+		$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
681
+		if (!$fp) {
682
+			$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
683
+
684
+			return false;
685
+		}
686
+		fwrite($fp, $request);
687
+		$contents       = '';
688
+		$gotFirstLine   = false;
689
+		$gettingHeaders = true;
690
+		while (!feof($fp)) {
691
+			$line = fgets($fp, 4096);
692
+			if (!$gotFirstLine) {
693
+				// Check line for '200'
694
+				if (false === strpos($line, '200')) {
695
+					$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
696
+
697
+					return false;
698
+				}
699
+				$gotFirstLine = true;
700
+			}
701
+			if (trim($line) == '') {
702
+				$gettingHeaders = false;
703
+			}
704
+			if (!$gettingHeaders) {
705
+				$contents .= trim($line) . "\n";
706
+			}
707
+		}
708
+		if ($this->debug) {
709
+			echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
710
+		}
711
+		// Now parse what we've got back
712
+		$this->message = new IXR_Message($contents);
713
+		if (!$this->message->parse()) {
714
+			// XML error
715
+			$this->error = new IXR_Error(-32700, 'parse error. not well formed');
716
+
717
+			return false;
718
+		}
719
+		// Is the message a fault?
720
+		if ($this->message->messageType === 'fault') {
721
+			$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
722
+
723
+			return false;
724
+		}
725
+
726
+		// Message must be OK
727
+		return true;
728
+	}
729
+
730
+	/**
731
+	 * @return mixed
732
+	 */
733
+	public function getResponse()
734
+	{
735
+		// methodResponses can only have one param - return that
736
+		return $this->message->params[0];
737
+	}
738
+
739
+	/**
740
+	 * @return bool
741
+	 */
742
+	public function isError()
743
+	{
744
+		return is_object($this->error);
745
+	}
746
+
747
+	/**
748
+	 * @return mixed
749
+	 */
750
+	public function getErrorCode()
751
+	{
752
+		return $this->error->code;
753
+	}
754
+
755
+	/**
756
+	 * @return mixed
757
+	 */
758
+	public function getErrorMessage()
759
+	{
760
+		return $this->error->message;
761
+	}
762 762
 }
763 763
 
764 764
 /**
@@ -766,26 +766,26 @@  discard block
 block discarded – undo
766 766
  */
767 767
 class IXR_Error
768 768
 {
769
-    public $code;
770
-    public $message;
771
-
772
-    /**
773
-     * IXR_Error constructor.
774
-     * @param $code
775
-     * @param $message
776
-     */
777
-    public function __construct($code, $message)
778
-    {
779
-        $this->code    = $code;
780
-        $this->message = $message;
781
-    }
782
-
783
-    /**
784
-     * @return string
785
-     */
786
-    public function getXml()
787
-    {
788
-        $xml = <<<EOD
769
+	public $code;
770
+	public $message;
771
+
772
+	/**
773
+	 * IXR_Error constructor.
774
+	 * @param $code
775
+	 * @param $message
776
+	 */
777
+	public function __construct($code, $message)
778
+	{
779
+		$this->code    = $code;
780
+		$this->message = $message;
781
+	}
782
+
783
+	/**
784
+	 * @return string
785
+	 */
786
+	public function getXml()
787
+	{
788
+		$xml = <<<EOD
789 789
 <methodResponse>
790 790
   <fault>
791 791
     <value>
@@ -805,8 +805,8 @@  discard block
 block discarded – undo
805 805
 
806 806
 EOD;
807 807
 
808
-        return $xml;
809
-    }
808
+		return $xml;
809
+	}
810 810
 }
811 811
 
812 812
 /**
@@ -814,78 +814,78 @@  discard block
 block discarded – undo
814 814
  */
815 815
 class IXR_Date
816 816
 {
817
-    public $year;
818
-    public $month;
819
-    public $day;
820
-    public $hour;
821
-    public $minute;
822
-    public $second;
823
-    public $timezone;
824
-
825
-    /**
826
-     * IXR_Date constructor.
827
-     * @param $time
828
-     */
829
-    public function __construct($time)
830
-    {
831
-        // $time can be a PHP timestamp or an ISO one
832
-        if (is_numeric($time)) {
833
-            $this->parseTimestamp($time);
834
-        } else {
835
-            $this->parseIso($time);
836
-        }
837
-    }
838
-
839
-    /**
840
-     * @param $timestamp
841
-     */
842
-    public function parseTimestamp($timestamp)
843
-    {
844
-        $this->year   = date('Y', $timestamp);
845
-        $this->month  = date('Y', $timestamp);
846
-        $this->day    = date('Y', $timestamp);
847
-        $this->hour   = date('H', $timestamp);
848
-        $this->minute = date('i', $timestamp);
849
-        $this->second = date('s', $timestamp);
850
-    }
851
-
852
-    /**
853
-     * @param $iso
854
-     */
855
-    public function parseIso($iso)
856
-    {
857
-        $this->year     = substr($iso, 0, 4);
858
-        $this->month    = substr($iso, 4, 2);
859
-        $this->day      = substr($iso, 6, 2);
860
-        $this->hour     = substr($iso, 9, 2);
861
-        $this->minute   = substr($iso, 12, 2);
862
-        $this->second   = substr($iso, 15, 2);
863
-        $this->timezone = substr($iso, 17);
864
-    }
865
-
866
-    /**
867
-     * @return string
868
-     */
869
-    public function getIso()
870
-    {
871
-        return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second . $this->timezone;
872
-    }
873
-
874
-    /**
875
-     * @return string
876
-     */
877
-    public function getXml()
878
-    {
879
-        return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
880
-    }
881
-
882
-    /**
883
-     * @return int
884
-     */
885
-    public function getTimestamp()
886
-    {
887
-        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
888
-    }
817
+	public $year;
818
+	public $month;
819
+	public $day;
820
+	public $hour;
821
+	public $minute;
822
+	public $second;
823
+	public $timezone;
824
+
825
+	/**
826
+	 * IXR_Date constructor.
827
+	 * @param $time
828
+	 */
829
+	public function __construct($time)
830
+	{
831
+		// $time can be a PHP timestamp or an ISO one
832
+		if (is_numeric($time)) {
833
+			$this->parseTimestamp($time);
834
+		} else {
835
+			$this->parseIso($time);
836
+		}
837
+	}
838
+
839
+	/**
840
+	 * @param $timestamp
841
+	 */
842
+	public function parseTimestamp($timestamp)
843
+	{
844
+		$this->year   = date('Y', $timestamp);
845
+		$this->month  = date('Y', $timestamp);
846
+		$this->day    = date('Y', $timestamp);
847
+		$this->hour   = date('H', $timestamp);
848
+		$this->minute = date('i', $timestamp);
849
+		$this->second = date('s', $timestamp);
850
+	}
851
+
852
+	/**
853
+	 * @param $iso
854
+	 */
855
+	public function parseIso($iso)
856
+	{
857
+		$this->year     = substr($iso, 0, 4);
858
+		$this->month    = substr($iso, 4, 2);
859
+		$this->day      = substr($iso, 6, 2);
860
+		$this->hour     = substr($iso, 9, 2);
861
+		$this->minute   = substr($iso, 12, 2);
862
+		$this->second   = substr($iso, 15, 2);
863
+		$this->timezone = substr($iso, 17);
864
+	}
865
+
866
+	/**
867
+	 * @return string
868
+	 */
869
+	public function getIso()
870
+	{
871
+		return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second . $this->timezone;
872
+	}
873
+
874
+	/**
875
+	 * @return string
876
+	 */
877
+	public function getXml()
878
+	{
879
+		return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
880
+	}
881
+
882
+	/**
883
+	 * @return int
884
+	 */
885
+	public function getTimestamp()
886
+	{
887
+		return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
888
+	}
889 889
 }
890 890
 
891 891
 /**
@@ -893,24 +893,24 @@  discard block
 block discarded – undo
893 893
  */
894 894
 class IXR_Base64
895 895
 {
896
-    public $data;
897
-
898
-    /**
899
-     * IXR_Base64 constructor.
900
-     * @param $data
901
-     */
902
-    public function __construct($data)
903
-    {
904
-        $this->data = $data;
905
-    }
906
-
907
-    /**
908
-     * @return string
909
-     */
910
-    public function getXml()
911
-    {
912
-        return '<base64>' . base64_encode($this->data) . '</base64>';
913
-    }
896
+	public $data;
897
+
898
+	/**
899
+	 * IXR_Base64 constructor.
900
+	 * @param $data
901
+	 */
902
+	public function __construct($data)
903
+	{
904
+		$this->data = $data;
905
+	}
906
+
907
+	/**
908
+	 * @return string
909
+	 */
910
+	public function getXml()
911
+	{
912
+		return '<base64>' . base64_encode($this->data) . '</base64>';
913
+	}
914 914
 }
915 915
 
916 916
 /**
@@ -918,161 +918,161 @@  discard block
 block discarded – undo
918 918
  */
919 919
 class IXR_IntrospectionServer extends IXR_Server
920 920
 {
921
-    public $signatures;
922
-    public $help;
923
-
924
-    /**
925
-     * IXR_IntrospectionServer constructor.
926
-     */
927
-    public function __construct()
928
-    {
929
-        $this->setCallbacks();
930
-        $this->setCapabilities();
931
-        $this->capabilities['introspection'] = [
932
-            'specUrl'     => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
933
-            'specVersion' => 1
934
-        ];
935
-        $this->addCallback('system.methodSignature', 'this:methodSignature', ['array', 'string'], 'Returns an array describing the return type and required parameters of a method');
936
-        $this->addCallback('system.getCapabilities', 'this:getCapabilities', ['struct'], 'Returns a struct describing the XML-RPC specifications supported by this server');
937
-        $this->addCallback('system.listMethods', 'this:listMethods', ['array'], 'Returns an array of available methods on this server');
938
-        $this->addCallback('system.methodHelp', 'this:methodHelp', ['string', 'string'], 'Returns a documentation string for the specified method');
939
-    }
940
-
941
-    /**
942
-     * @param $method
943
-     * @param $callback
944
-     * @param $args
945
-     * @param $help
946
-     */
947
-    public function addCallback($method, $callback, $args, $help)
948
-    {
949
-        $this->callbacks[$method]  = $callback;
950
-        $this->signatures[$method] = $args;
951
-        $this->help[$method]       = $help;
952
-    }
953
-
954
-    /**
955
-     * @param $methodname
956
-     * @param $args
957
-     * @return IXR_Error|mixed
958
-     */
959
-    public function call($methodname, $args)
960
-    {
961
-        // Make sure it's in an array
962
-        if ($args && !is_array($args)) {
963
-            $args = [$args];
964
-        }
965
-        // Over-rides default call method, adds signature check
966
-        if (!$this->hasMethod($methodname)) {
967
-            return new IXR_Error(-32601, 'server error. requested method "' . $this->message->methodName . '" not specified.');
968
-        }
969
-        $method     = $this->callbacks[$methodname];
970
-        $signature  = $this->signatures[$methodname];
971
-        $returnType = array_shift($signature);
972
-        // Check the number of arguments
973
-        if (count($args) != count($signature)) {
974
-            // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
975
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
976
-        }
977
-        // Check the argument types
978
-        $ok         = true;
979
-        $argsbackup = $args;
980
-        for ($i = 0, $j = count($args); $i < $j; ++$i) {
981
-            $arg  = array_shift($args);
982
-            $type = array_shift($signature);
983
-            switch ($type) {
984
-                case 'int':
985
-                case 'i4':
986
-                    if (is_array($arg) || !is_int($arg)) {
987
-                        $ok = false;
988
-                    }
989
-                    break;
990
-                case 'base64':
991
-                case 'string':
992
-                    if (!is_string($arg)) {
993
-                        $ok = false;
994
-                    }
995
-                    break;
996
-                case 'boolean':
997
-                    if ($arg !== false && $arg !== true) {
998
-                        $ok = false;
999
-                    }
1000
-                    break;
1001
-                case 'float':
1002
-                case 'double':
1003
-                    if (!is_float($arg)) {
1004
-                        $ok = false;
1005
-                    }
1006
-                    break;
1007
-                case 'date':
1008
-                case 'dateTime.iso8601':
1009
-                    if (!is_a($arg, 'IXR_Date')) {
1010
-                        $ok = false;
1011
-                    }
1012
-                    break;
1013
-            }
1014
-            if (!$ok) {
1015
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
1016
-            }
1017
-        }
1018
-
1019
-        // It passed the test - run the "real" method call
1020
-        return parent::call($methodname, $argsbackup);
1021
-    }
1022
-
1023
-    /**
1024
-     * @param $method
1025
-     * @return array|IXR_Error
1026
-     */
1027
-    public function methodSignature($method)
1028
-    {
1029
-        if (!$this->hasMethod($method)) {
1030
-            return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
1031
-        }
1032
-        // We should be returning an array of types
1033
-        $types  = $this->signatures[$method];
1034
-        $return = [];
1035
-        foreach ($types as $type) {
1036
-            switch ($type) {
1037
-                case 'string':
1038
-                    $return[] = 'string';
1039
-                    break;
1040
-                case 'int':
1041
-                case 'i4':
1042
-                    $return[] = 42;
1043
-                    break;
1044
-                case 'double':
1045
-                    $return[] = 3.1415;
1046
-                    break;
1047
-                case 'dateTime.iso8601':
1048
-                    $return[] = new IXR_Date(time());
1049
-                    break;
1050
-                case 'boolean':
1051
-                    $return[] = true;
1052
-                    break;
1053
-                case 'base64':
1054
-                    $return[] = new IXR_Base64('base64');
1055
-                    break;
1056
-                case 'array':
1057
-                    $return[] = ['array'];
1058
-                    break;
1059
-                case 'struct':
1060
-                    $return[] = ['struct' => 'struct'];
1061
-                    break;
1062
-            }
1063
-        }
1064
-
1065
-        return $return;
1066
-    }
1067
-
1068
-    /**
1069
-     * @param $method
1070
-     * @return mixed
1071
-     */
1072
-    public function methodHelp($method)
1073
-    {
1074
-        return $this->help[$method];
1075
-    }
921
+	public $signatures;
922
+	public $help;
923
+
924
+	/**
925
+	 * IXR_IntrospectionServer constructor.
926
+	 */
927
+	public function __construct()
928
+	{
929
+		$this->setCallbacks();
930
+		$this->setCapabilities();
931
+		$this->capabilities['introspection'] = [
932
+			'specUrl'     => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
933
+			'specVersion' => 1
934
+		];
935
+		$this->addCallback('system.methodSignature', 'this:methodSignature', ['array', 'string'], 'Returns an array describing the return type and required parameters of a method');
936
+		$this->addCallback('system.getCapabilities', 'this:getCapabilities', ['struct'], 'Returns a struct describing the XML-RPC specifications supported by this server');
937
+		$this->addCallback('system.listMethods', 'this:listMethods', ['array'], 'Returns an array of available methods on this server');
938
+		$this->addCallback('system.methodHelp', 'this:methodHelp', ['string', 'string'], 'Returns a documentation string for the specified method');
939
+	}
940
+
941
+	/**
942
+	 * @param $method
943
+	 * @param $callback
944
+	 * @param $args
945
+	 * @param $help
946
+	 */
947
+	public function addCallback($method, $callback, $args, $help)
948
+	{
949
+		$this->callbacks[$method]  = $callback;
950
+		$this->signatures[$method] = $args;
951
+		$this->help[$method]       = $help;
952
+	}
953
+
954
+	/**
955
+	 * @param $methodname
956
+	 * @param $args
957
+	 * @return IXR_Error|mixed
958
+	 */
959
+	public function call($methodname, $args)
960
+	{
961
+		// Make sure it's in an array
962
+		if ($args && !is_array($args)) {
963
+			$args = [$args];
964
+		}
965
+		// Over-rides default call method, adds signature check
966
+		if (!$this->hasMethod($methodname)) {
967
+			return new IXR_Error(-32601, 'server error. requested method "' . $this->message->methodName . '" not specified.');
968
+		}
969
+		$method     = $this->callbacks[$methodname];
970
+		$signature  = $this->signatures[$methodname];
971
+		$returnType = array_shift($signature);
972
+		// Check the number of arguments
973
+		if (count($args) != count($signature)) {
974
+			// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
975
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
976
+		}
977
+		// Check the argument types
978
+		$ok         = true;
979
+		$argsbackup = $args;
980
+		for ($i = 0, $j = count($args); $i < $j; ++$i) {
981
+			$arg  = array_shift($args);
982
+			$type = array_shift($signature);
983
+			switch ($type) {
984
+				case 'int':
985
+				case 'i4':
986
+					if (is_array($arg) || !is_int($arg)) {
987
+						$ok = false;
988
+					}
989
+					break;
990
+				case 'base64':
991
+				case 'string':
992
+					if (!is_string($arg)) {
993
+						$ok = false;
994
+					}
995
+					break;
996
+				case 'boolean':
997
+					if ($arg !== false && $arg !== true) {
998
+						$ok = false;
999
+					}
1000
+					break;
1001
+				case 'float':
1002
+				case 'double':
1003
+					if (!is_float($arg)) {
1004
+						$ok = false;
1005
+					}
1006
+					break;
1007
+				case 'date':
1008
+				case 'dateTime.iso8601':
1009
+					if (!is_a($arg, 'IXR_Date')) {
1010
+						$ok = false;
1011
+					}
1012
+					break;
1013
+			}
1014
+			if (!$ok) {
1015
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
1016
+			}
1017
+		}
1018
+
1019
+		// It passed the test - run the "real" method call
1020
+		return parent::call($methodname, $argsbackup);
1021
+	}
1022
+
1023
+	/**
1024
+	 * @param $method
1025
+	 * @return array|IXR_Error
1026
+	 */
1027
+	public function methodSignature($method)
1028
+	{
1029
+		if (!$this->hasMethod($method)) {
1030
+			return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
1031
+		}
1032
+		// We should be returning an array of types
1033
+		$types  = $this->signatures[$method];
1034
+		$return = [];
1035
+		foreach ($types as $type) {
1036
+			switch ($type) {
1037
+				case 'string':
1038
+					$return[] = 'string';
1039
+					break;
1040
+				case 'int':
1041
+				case 'i4':
1042
+					$return[] = 42;
1043
+					break;
1044
+				case 'double':
1045
+					$return[] = 3.1415;
1046
+					break;
1047
+				case 'dateTime.iso8601':
1048
+					$return[] = new IXR_Date(time());
1049
+					break;
1050
+				case 'boolean':
1051
+					$return[] = true;
1052
+					break;
1053
+				case 'base64':
1054
+					$return[] = new IXR_Base64('base64');
1055
+					break;
1056
+				case 'array':
1057
+					$return[] = ['array'];
1058
+					break;
1059
+				case 'struct':
1060
+					$return[] = ['struct' => 'struct'];
1061
+					break;
1062
+			}
1063
+		}
1064
+
1065
+		return $return;
1066
+	}
1067
+
1068
+	/**
1069
+	 * @param $method
1070
+	 * @return mixed
1071
+	 */
1072
+	public function methodHelp($method)
1073
+	{
1074
+		return $this->help[$method];
1075
+	}
1076 1076
 }
1077 1077
 
1078 1078
 /**
@@ -1080,37 +1080,37 @@  discard block
 block discarded – undo
1080 1080
  */
1081 1081
 class IXR_ClientMulticall extends IXR_Client
1082 1082
 {
1083
-    public $calls = [];
1084
-
1085
-    /**
1086
-     * IXR_ClientMulticall constructor.
1087
-     * @param      $server
1088
-     * @param bool $path
1089
-     * @param int  $port
1090
-     */
1091
-    public function __construct($server, $path = false, $port = 80)
1092
-    {
1093
-        parent::IXR_Client($server, $path, $port);
1094
-        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1095
-    }
1096
-
1097
-    public function addCall()
1098
-    {
1099
-        $args          = func_get_args();
1100
-        $methodName    = array_shift($args);
1101
-        $struct        = [
1102
-            'methodName' => $methodName,
1103
-            'params'     => $args
1104
-        ];
1105
-        $this->calls[] = $struct;
1106
-    }
1107
-
1108
-    /**
1109
-     * @return bool
1110
-     */
1111
-    public function query()
1112
-    {
1113
-        // Prepare multicall, then call the parent::query() method
1114
-        return parent::query('system.multicall', $this->calls);
1115
-    }
1083
+	public $calls = [];
1084
+
1085
+	/**
1086
+	 * IXR_ClientMulticall constructor.
1087
+	 * @param      $server
1088
+	 * @param bool $path
1089
+	 * @param int  $port
1090
+	 */
1091
+	public function __construct($server, $path = false, $port = 80)
1092
+	{
1093
+		parent::IXR_Client($server, $path, $port);
1094
+		$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1095
+	}
1096
+
1097
+	public function addCall()
1098
+	{
1099
+		$args          = func_get_args();
1100
+		$methodName    = array_shift($args);
1101
+		$struct        = [
1102
+			'methodName' => $methodName,
1103
+			'params'     => $args
1104
+		];
1105
+		$this->calls[] = $struct;
1106
+	}
1107
+
1108
+	/**
1109
+	 * @return bool
1110
+	 */
1111
+	public function query()
1112
+	{
1113
+		// Prepare multicall, then call the parent::query() method
1114
+		return parent::query('system.multicall', $this->calls);
1115
+	}
1116 1116
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             }
37 37
         }
38 38
         if ($type === 'array') {
39
-            for ($i = 0, $j = count($this->data); $i < $j; ++$i) {
39
+            for ($i = 0, $j = count($this->data); $i<$j; ++$i) {
40 40
                 $this->data[$i] = new IXR_Value($this->data[$i]);
41 41
             }
42 42
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         /* We have an array - is it an array or a struct ? */
76 76
         if ($this->isStruct($this->data)) {
77 77
             return 'struct';
78
-        } else {
78
+        }else {
79 79
             return 'array';
80 80
         }
81 81
     }
@@ -88,31 +88,31 @@  discard block
 block discarded – undo
88 88
         /* Return XML for this value */
89 89
         switch ($this->type) {
90 90
             case 'boolean':
91
-                return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
91
+                return '<boolean>'.($this->data ? '1' : '0').'</boolean>';
92 92
                 break;
93 93
             case 'int':
94
-                return '<int>' . $this->data . '</int>';
94
+                return '<int>'.$this->data.'</int>';
95 95
                 break;
96 96
             case 'double':
97
-                return '<double>' . $this->data . '</double>';
97
+                return '<double>'.$this->data.'</double>';
98 98
                 break;
99 99
             case 'string':
100
-                return '<string>' . htmlspecialchars($this->data) . '</string>';
100
+                return '<string>'.htmlspecialchars($this->data).'</string>';
101 101
                 break;
102 102
             case 'array':
103
-                $return = '<array><data>' . "\n";
103
+                $return = '<array><data>'."\n";
104 104
                 foreach ($this->data as $item) {
105
-                    $return .= '  <value>' . $item->getXml() . "</value>\n";
105
+                    $return .= '  <value>'.$item->getXml()."</value>\n";
106 106
                 }
107 107
                 $return .= '</data></array>';
108 108
 
109 109
                 return $return;
110 110
                 break;
111 111
             case 'struct':
112
-                $return = '<struct>' . "\n";
112
+                $return = '<struct>'."\n";
113 113
                 foreach ($this->data as $name => $value) {
114 114
                     $return .= "  <member><name>$name</name><value>";
115
-                    $return .= $value->getXml() . "</value></member>\n";
115
+                    $return .= $value->getXml()."</value></member>\n";
116 116
                 }
117 117
                 $return .= '</struct>';
118 118
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         /* Nasty function to check if an array is a struct or not */
137 137
         $expected = 0;
138 138
         foreach ($array as $key => $value) {
139
-            if ((string)$key != (string)$expected) {
139
+            if ((string) $key != (string) $expected) {
140 140
                 return true;
141 141
             }
142 142
             ++$expected;
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 class IXR_Message
153 153
 {
154 154
     public $message;
155
-    public $messageType;  // methodCall / methodResponse / fault
155
+    public $messageType; // methodCall / methodResponse / fault
156 156
     public $faultCode;
157 157
     public $faultString;
158 158
     public $methodName;
159 159
     public $params;
160 160
     // Current variable stacks
161
-    public $_arraystructs      = [];   // The stack used to keep track of the current array/struct
161
+    public $_arraystructs      = []; // The stack used to keep track of the current array/struct
162 162
     public $_arraystructstypes = []; // Stack keeping track of if things are structs or array
163
-    public $_currentStructName = [];  // A stack as well
163
+    public $_currentStructName = []; // A stack as well
164 164
     public $_param;
165 165
     public $_value;
166 166
     public $_currentTag;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     public function parse()
184 184
     {
185 185
         // first remove the XML declaration
186
-        $this->message = preg_replace('/<\?xml(.*)?\?' . '>/', '', $this->message);
186
+        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
187 187
         if (trim($this->message) == '') {
188 188
             return false;
189 189
         }
@@ -256,17 +256,17 @@  discard block
 block discarded – undo
256 256
         switch ($tag) {
257 257
             case 'int':
258 258
             case 'i4':
259
-                $value                     = (int)trim($this->_currentTagContents);
259
+                $value                     = (int) trim($this->_currentTagContents);
260 260
                 $this->_currentTagContents = '';
261 261
                 $valueFlag                 = true;
262 262
                 break;
263 263
             case 'double':
264
-                $value                     = (double)trim($this->_currentTagContents);
264
+                $value                     = (double) trim($this->_currentTagContents);
265 265
                 $this->_currentTagContents = '';
266 266
                 $valueFlag                 = true;
267 267
                 break;
268 268
             case 'string':
269
-                $value                     = (string)trim($this->_currentTagContents);
269
+                $value                     = (string) trim($this->_currentTagContents);
270 270
                 $this->_currentTagContents = '';
271 271
                 $valueFlag                 = true;
272 272
                 break;
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
             case 'value':
280 280
                 // "If no type is indicated, the type is string."
281 281
                 if (trim($this->_currentTagContents) != '') {
282
-                    $value                     = (string)$this->_currentTagContents;
282
+                    $value                     = (string) $this->_currentTagContents;
283 283
                     $this->_currentTagContents = '';
284 284
                     $valueFlag                 = true;
285 285
                 }
286 286
                 break;
287 287
             case 'boolean':
288
-                $value                     = (boolean)trim($this->_currentTagContents);
288
+                $value                     = (boolean) trim($this->_currentTagContents);
289 289
                 $this->_currentTagContents = '';
290 290
                 $valueFlag                 = true;
291 291
                 break;
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
                 $value = trim($value);
320 320
             }
321 321
             */
322
-            if (count($this->_arraystructs) > 0) {
322
+            if (count($this->_arraystructs)>0) {
323 323
                 // Add value to struct or array
324
-                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] === 'struct') {
324
+                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] === 'struct') {
325 325
                     // Add to struct
326
-                    $this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
327
-                } else {
326
+                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
327
+                }else {
328 328
                     // Add to array
329
-                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
329
+                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
330 330
                 }
331
-            } else {
331
+            }else {
332 332
                 // Just add as a paramater
333 333
                 $this->params[] = $value;
334 334
             }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     public function call($methodname, $args)
414 414
     {
415 415
         if (!$this->hasMethod($methodname)) {
416
-            return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
416
+            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
417 417
         }
418 418
         $method = $this->callbacks[$methodname];
419 419
         // Perform the callback and send the response
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
             // It's a class method - check it exists
427 427
             $method = substr($method, 5);
428 428
             if (!method_exists($this, $method)) {
429
-                return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
429
+                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
430 430
             }
431 431
             // Call the method
432 432
             $result = $this->$method($args);
433
-        } else {
433
+        }else {
434 434
             // It's a function - does it exist?
435 435
             if (is_array($method)) {
436 436
                 if (!method_exists($method[0], $method[1])) {
437
-                    return new IXR_Error(-32601, 'server error. requested object method "' . $method[1] . '" does not exist.');
437
+                    return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
438 438
                 }
439 439
             } elseif (!function_exists($method)) {
440
-                return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
440
+                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
441 441
             }
442 442
             // Call the function
443 443
             $result = call_user_func($method, $args);
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function output($xml)
466 466
     {
467
-        $xml    = '<?xml version="1.0"?>' . "\n" . $xml;
467
+        $xml    = '<?xml version="1.0"?>'."\n".$xml;
468 468
         $length = strlen($xml);
469 469
         header('Connection: close');
470
-        header('Content-Length: ' . $length);
470
+        header('Content-Length: '.$length);
471 471
         header('Content-Type: text/xml');
472
-        header('Date: ' . date('r'));
472
+        header('Date: '.date('r'));
473 473
         echo $xml;
474 474
         exit;
475 475
     }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
             $params = $call['params'];
543 543
             if ($method === 'system.multicall') {
544 544
                 $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
545
-            } else {
545
+            }else {
546 546
                 $result = $this->call($method, $params);
547 547
             }
548 548
             if (is_a($result, 'IXR_Error')) {
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                     'faultCode'   => $result->code,
551 551
                     'faultString' => $result->message
552 552
                 ];
553
-            } else {
553
+            }else {
554 554
                 $return[] = [$result];
555 555
             }
556 556
         }
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 EOD;
587 587
         foreach ($this->args as $arg) {
588 588
             $this->xml .= '<param><value>';
589
-            $v         = new IXR_Value($arg);
589
+            $v = new IXR_Value($arg);
590 590
             $this->xml .= $v->getXml();
591 591
             $this->xml .= "</value></param>\n";
592 592
         }
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
             if (!$this->path) {
648 648
                 $this->path = '/';
649 649
             }
650
-        } else {
650
+        }else {
651 651
             $this->server  = $server;
652 652
             $this->path    = $path;
653 653
             $this->port    = $port;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
         $request .= $xml;
676 676
         // Now send the request
677 677
         if ($this->debug) {
678
-            echo '<pre>' . htmlspecialchars($request) . "\n</pre>\n\n";
678
+            echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
679 679
         }
680 680
         $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
681 681
         if (!$fp) {
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
                 $gettingHeaders = false;
703 703
             }
704 704
             if (!$gettingHeaders) {
705
-                $contents .= trim($line) . "\n";
705
+                $contents .= trim($line)."\n";
706 706
             }
707 707
         }
708 708
         if ($this->debug) {
709
-            echo '<pre>' . htmlspecialchars($contents) . "\n</pre>\n\n";
709
+            echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
710 710
         }
711 711
         // Now parse what we've got back
712 712
         $this->message = new IXR_Message($contents);
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         // $time can be a PHP timestamp or an ISO one
832 832
         if (is_numeric($time)) {
833 833
             $this->parseTimestamp($time);
834
-        } else {
834
+        }else {
835 835
             $this->parseIso($time);
836 836
         }
837 837
     }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
      */
869 869
     public function getIso()
870 870
     {
871
-        return $this->year . $this->month . $this->day . 'T' . $this->hour . ':' . $this->minute . ':' . $this->second . $this->timezone;
871
+        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
872 872
     }
873 873
 
874 874
     /**
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
      */
877 877
     public function getXml()
878 878
     {
879
-        return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
879
+        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
880 880
     }
881 881
 
882 882
     /**
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
      */
910 910
     public function getXml()
911 911
     {
912
-        return '<base64>' . base64_encode($this->data) . '</base64>';
912
+        return '<base64>'.base64_encode($this->data).'</base64>';
913 913
     }
914 914
 }
915 915
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
         }
965 965
         // Over-rides default call method, adds signature check
966 966
         if (!$this->hasMethod($methodname)) {
967
-            return new IXR_Error(-32601, 'server error. requested method "' . $this->message->methodName . '" not specified.');
967
+            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
968 968
         }
969 969
         $method     = $this->callbacks[$methodname];
970 970
         $signature  = $this->signatures[$methodname];
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
         // Check the argument types
978 978
         $ok         = true;
979 979
         $argsbackup = $args;
980
-        for ($i = 0, $j = count($args); $i < $j; ++$i) {
980
+        for ($i = 0, $j = count($args); $i<$j; ++$i) {
981 981
             $arg  = array_shift($args);
982 982
             $type = array_shift($signature);
983 983
             switch ($type) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
     public function methodSignature($method)
1028 1028
     {
1029 1029
         if (!$this->hasMethod($method)) {
1030
-            return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
1030
+            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1031 1031
         }
1032 1032
         // We should be returning an array of types
1033 1033
         $types  = $this->signatures[$method];
Please login to merge, or discard this patch.
class/rate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 // ------------------------------------------------------------------------ //
27 27
 
28 28
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
29
-require_once __DIR__ . '/../include/vars.php';
29
+require_once __DIR__.'/../include/vars.php';
30 30
 //mod_loadFunctions('', $GLOBALS['moddirname']);
31 31
 
32 32
 if (!class_exists('Brate')):
Please login to merge, or discard this patch.
class/blog.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 
32 32
 // defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
33
-require_once __DIR__ . '/../include/vars.php';
33
+require_once __DIR__.'/../include/vars.php';
34 34
 //mod_loadFunctions('', $GLOBALS['moddirname']);
35 35
 
36 36
 /**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         {
134 134
             $ave = 3;
135 135
             if ($this->getVar('blog_rates')) {
136
-                $ave = number_format($this->getVar('blog_rating') / $this->getVar('blog_rates'), $decimals);
136
+                $ave = number_format($this->getVar('blog_rating')/$this->getVar('blog_rates'), $decimals);
137 137
             }
138 138
 
139 139
             return $ave;
Please login to merge, or discard this patch.
class/utility.php 2 patches
Indentation   +518 added lines, -518 removed lines patch added patch discarded remove patch
@@ -30,531 +30,531 @@
 block discarded – undo
30 30
 
31 31
 $current_path = __FILE__;
32 32
 if (DIRECTORY_SEPARATOR !== '/') {
33
-    $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
33
+	$current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
34 34
 }
35 35
 $url_arr               = explode('/', strstr($current_path, '/modules/'));
36 36
 $GLOBALS['moddirname'] = $url_arr[2];
37 37
 
38 38
 if (!defined('planet_FUNCTIONS')):
39
-    define('planet_FUNCTIONS', 1);
40
-
41
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
42
-    require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
43
-    require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
44
-
45
-    /**
46
-     * Class PlanetUtility
47
-     */
48
-    class PlanetUtility
49
-    {
50
-
51
-        /**
52
-         * Function to display messages
53
-         *
54
-         * @var mixed $messages
55
-         * @return bool
56
-         */
57
-        public static function planetDisplayMessage($message)
58
-        {
59
-            return mod_message($message);
60
-        }
61
-
62
-        /**
63
-         * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
64
-         *
65
-         * @var array $args_numeric array of numeric variable values
66
-         * @var array $args         array of indexed variables: name and value
67
-         * @var array $args_string  array of string variable values
68
-         *
69
-         * @return bool true on args parsed
70
-         */
71
-
72
-        /* known issues:
39
+	define('planet_FUNCTIONS', 1);
40
+
41
+	require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
42
+	require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
43
+	require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
44
+
45
+	/**
46
+	 * Class PlanetUtility
47
+	 */
48
+	class PlanetUtility
49
+	{
50
+
51
+		/**
52
+		 * Function to display messages
53
+		 *
54
+		 * @var mixed $messages
55
+		 * @return bool
56
+		 */
57
+		public static function planetDisplayMessage($message)
58
+		{
59
+			return mod_message($message);
60
+		}
61
+
62
+		/**
63
+		 * Function to parse arguments for a page according to $_SERVER['REQUEST_URI']
64
+		 *
65
+		 * @var array $args_numeric array of numeric variable values
66
+		 * @var array $args         array of indexed variables: name and value
67
+		 * @var array $args_string  array of string variable values
68
+		 *
69
+		 * @return bool true on args parsed
70
+		 */
71
+
72
+		/* known issues:
73 73
          * - "/" in a string
74 74
          * - "&" in a string
75 75
         */
76
-        public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
77
-        {
78
-            $args_abb     = [
79
-                'a' => 'article',
80
-                'b' => 'blog',
81
-                'c' => 'category',
82
-                'l' => 'list',
83
-                'o' => 'sort',
84
-                's' => 'start',
85
-                'u' => 'uid'
86
-            ];
87
-            $args         = [];
88
-            $args_numeric = [];
89
-            $args_string  = [];
90
-            if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
91
-                $vars = preg_split("/[\/|&]/", $matches[1]);
92
-                $vars = array_map('trim', $vars);
93
-                if (count($vars) > 0) {
94
-                    foreach ($vars as $var) {
95
-                        if (is_numeric($var)) {
96
-                            $args_numeric[] = $var;
97
-                        } elseif (false === strpos($var, '=')) {
98
-                            if (is_numeric(substr($var, 1))) {
99
-                                $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
100
-                            } else {
101
-                                $args_string[] = urldecode($var);
102
-                            }
103
-                        } else {
104
-                            parse_str($var, $args);
105
-                        }
106
-                    }
107
-                }
108
-            }
109
-
110
-            return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
111
-        }
112
-
113
-        /**
114
-         * Function to parse class prefix
115
-         *
116
-         * @var string $class_string string to be parsed
117
-         * @var mixed  $pattern
118
-         * @var mixed  $replacement
119
-         *
120
-         * @return bool true on success
121
-         */
122
-        public static function planetParseClass($class_string, $pattern = '', $replacement = '')
123
-        {
124
-            if (empty($class_string)) {
125
-                return;
126
-            }
127
-            $patterns     = ["/\[CLASS_PREFIX\]/"];
128
-            $replacements = [ucfirst(strtolower($GLOBALS['moddirname']))];
129
-            if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
130
-                $pattern     = [$pattern];
131
-                $replacement = [$replacement];
132
-            }
133
-            if (is_array($pattern) && count($pattern) > 0) {
134
-                $ii = 0;
135
-                foreach ($pattern as $pat) {
136
-                    if (!in_array($pat, $patterns)) {
137
-                        $patterns[]     = $pat;
138
-                        $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
139
-                    }
140
-                    ++$ii;
141
-                }
142
-            }
143
-            $class_string = preg_replace($patterns, $replacements, $class_string);
144
-            eval($class_string);
145
-
146
-            return true;
147
-        }
148
-
149
-        /**
150
-         * Function to parse function prefix
151
-         *
152
-         * @var string $function_string string to be parsed
153
-         * @var mixed  $pattern
154
-         * @var mixed  $replacement
155
-         *
156
-         * @return bool true on success
157
-         */
158
-        public static function planetParseFunction($function_string, $pattern = '', $replacement = '')
159
-        {
160
-            if (empty($function_string)) {
161
-                return;
162
-            }
163
-            $patterns     = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"];
164
-            $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']];
165
-            if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
166
-                $pattern     = [$pattern];
167
-                $replacement = [$replacement];
168
-            }
169
-            if (is_array($pattern) && count($pattern) > 0) {
170
-                $ii = 0;
171
-                foreach ($pattern as $pat) {
172
-                    if (!in_array($pat, $patterns)) {
173
-                        $patterns[]     = $pat;
174
-                        $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
175
-                    }
176
-                    ++$ii;
177
-                }
178
-            }
179
-            $function_string = preg_replace($patterns, $replacements, $function_string);
180
-            eval($function_string);
181
-
182
-            return true;
183
-        }
184
-
185
-        /**
186
-         * Function to convert UNIX time to formatted time string
187
-         * @param        $time
188
-         * @param string $format
189
-         * @return string
190
-         */
191
-        public static function planetFormatTimestamp($time, $format = '')
192
-        {
193
-            if (empty($time)) {
194
-                return '';
195
-            }
196
-
197
-            return formatTimestamp($time, $format);
198
-        }
199
-
200
-        /**
201
-         * Function to a list of user names associated with their user IDs
202
-         * @param int  $userid
203
-         * @param int  $usereal
204
-         * @param bool $linked
205
-         * @return array
206
-         */
207
-        public static function &planetGetUnameFromId($userid, $usereal = 0, $linked = false)
208
-        {
209
-            if (!is_array($userid)) {
210
-                $userid = [$userid];
211
-            }
212
-            $users =& mod_getUnameFromIds($userid, $usereal, $linked);
213
-
214
-            return $users;
215
-        }
216
-
217
-        /**
218
-         * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
219
-         *
220
-         * @var string $text raw content
221
-         *
222
-         * @return array associative array of link url and title
223
-         */
224
-        public static function &planetParseLinks($text)
225
-        {
226
-            $myts       = MyTextSanitizer::getInstance();
227
-            $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
228
-            $links      = [];
229
-            if (count($link_array) > 0) {
230
-                foreach ($link_array as $link) {
231
-                    @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
232
-                    if (empty($url)) {
233
-                        continue;
234
-                    }
235
-                    //if(empty($title)) $title = $url;
236
-                    $links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)];
237
-                }
238
-            }
239
-
240
-            return $links;
241
-        }
242
-
243
-        /**
244
-         * @param $pagename
245
-         * @return string
246
-         */
247
-        public static function planetGetTemplate($pagename)
248
-        {
249
-            return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
250
-        }
251
-
252
-        /**
253
-         * @param int $currentoption
254
-         */
255
-        //public static function planet_adminmenu($currentoption = -1)
256
-        //{
257
-        //    loadModuleAdminMenu($currentoption, '');
258
-        //
259
-        //    return;
260
-        //}
261
-
262
-        /**
263
-         * Function to send a trackback
264
-         *
265
-         * @param $article
266
-         * @param $comment
267
-         * @return bool
268
-         */
269
-        public static function planetSendTrackback(&$article, &$comment)
270
-        {
271
-            $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
272
-            $blog_obj    = $blogHandler->get($article->getVar('blog_id'));
273
-            if (!$pattern = $blog_obj->getVar('blog_trackback')) {
274
-                return false;
275
-            }
276
-
277
-            @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
278
-            $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
279
-
280
-            return static::planetTrackback($trackback_url, $article);
281
-        }
282
-
283
-        /**
284
-         * @param $trackback_url
285
-         * @param $article
286
-         * @return bool
287
-         */
288
-        public static function planetTrackback($trackback_url, $article)
289
-        {
290
-            global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
291
-
292
-            $title         = $article->getVar('art_title');
293
-            $excerpt       = $article->getVar('art_content');
294
-            $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
295
-            $title         = xoops_utf8_encode($title);
296
-            $excerpt       = xoops_utf8_encode($excerpt);
297
-            $blog_name     = xoops_utf8_encode($blog_name);
298
-            $charset       = 'utf-8';
299
-            $title1        = urlencode($title);
300
-            $excerpt1      = urlencode($excerpt);
301
-            $name1         = urlencode($blog_name);
302
-            $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
303
-            $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
304
-            $trackback_url = parse_url($trackback_url);
305
-
306
-            $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
307
-            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
308
-            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
309
-            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
310
-            $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
311
-            $http_request .= "\r\n\r\n";
312
-            $http_request .= $query_string;
313
-            if ('' == $trackback_url['port']) {
314
-                $trackback_url['port'] = 80;
315
-            }
316
-            $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
317
-            @fwrite($fs, $http_request);
318
-            if ($xoopsModuleConfig['do_debug']) {
319
-                $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
320
-                $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
321
-                $fr         .= "CHARSET:$charset\n";
322
-                $fr         .= "NAME:$blog_name\n";
323
-                $fr         .= 'TITLE:' . $title . "\n";
324
-                $fr         .= "EXCERPT:$excerpt\n\n";
325
-                while (!@feof($fs)) {
326
-                    $fr .= @fgets($fs, 4096);
327
-                }
328
-                $fr .= "\n\n";
329
-
330
-                if ($fp = fopen($debug_file, 'a')) {
331
-                    fwrite($fp, $fr);
332
-                    fclose($fp);
333
-                } else {
334
-                }
335
-            }
336
-            @fclose($fs);
337
-
338
-            return true;
339
-        }
340
-
341
-        /**
342
-         * Function to ping servers
343
-         * @param $server
344
-         * @param $id
345
-         */
346
-        public static function planetGetPing($server, $id)
347
-        {
348
-            if (is_array($server)) {
349
-                foreach ($server as $serv) {
350
-                    PlanetUtility::planetGetPing($serv, $id);
351
-                }
352
-            }
353
-            require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
354
-
355
-            // using a timeout of 3 seconds should be enough to cover slow servers
356
-            $client            = new IXR_Client($server, false);
357
-            $client->timeout   = 3;
358
-            $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
359
-
360
-            // when set to true, this outputs debug messages by itself
361
-            $client->debug = false;
362
-
363
-            $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
364
-            $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
365
-            $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
366
-
367
-            if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
368
-                $client->query('weblogUpdates.ping', $blogname, $home);
369
-            }
370
-        }
371
-
372
-        /**
373
-         * Function to respond to a trackback
374
-         * @param int    $error
375
-         * @param string $error_message
376
-         */
377
-        public static function planetRespondToTrackback($error = 0, $error_message = '')
378
-        {
379
-            $charset       = 'utf-8';
380
-            $error_message = xoops_utf8_encode($error_message);
381
-            header('Content-Type: text/xml; charset="' . $charset . '"');
382
-            if ($error) {
383
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
384
-                echo "<response>\n";
385
-                echo "<error>1</error>\n";
386
-                echo "<message>$error_message</message>\n";
387
-                echo '</response>';
388
-                die();
389
-            } else {
390
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
391
-                echo "<response>\n";
392
-                echo "<error>0</error>\n";
393
-                echo '</response>';
394
-            }
395
-        }
396
-
397
-        /**
398
-         * Function to set a cookie with module-specified name
399
-         *
400
-         * using customized serialization method
401
-         * @param        $name
402
-         * @param string $string
403
-         * @param int    $expire
404
-         */
405
-        public static function planetSetCookie($name, $string = '', $expire = 0)
406
-        {
407
-            if (is_array($string)) {
408
-                $value = [];
409
-                foreach ($string as $key => $val) {
410
-                    $value[] = $key . '|' . $val;
411
-                }
412
-                $string = implode(',', $value);
413
-            }
414
-            setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
415
-        }
416
-
417
-        /**
418
-         * @param      $name
419
-         * @param bool $isArray
420
-         * @return array|null
421
-         */
422
-        public static function planetGetCookie($name, $isArray = false)
423
-        {
424
-            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
425
-            if ($isArray) {
426
-                $_value = $value ? explode(',', $value) : [];
427
-                $value  = [];
428
-                if (count($_value) > 0) {
429
-                    foreach ($_value as $string) {
430
-                        $key         = substr($string, 0, strpos($string, '|'));
431
-                        $val         = substr($string, strpos($string, '|') + 1);
432
-                        $value[$key] = $val;
433
-                    }
434
-                }
435
-                unset($_value);
436
-            }
437
-
438
-            return $value;
439
-        }
440
-
441
-        /**
442
-         * Function to filter text
443
-         *
444
-         * @param $document
445
-         * @return string filtered text
446
-         */
447
-        public static function &planetHtml2text(&$document)
448
-        {
449
-            $document = strip_tags($document);
450
-
451
-            return $document;
452
-        }
453
-
454
-        // Adapted from PMA_getIp() [phpmyadmin project]
455
-
456
-        /**
457
-         * @param bool $asString
458
-         * @return mixed
459
-         */
460
-        public static function planetGetIP($asString = false)
461
-        {
462
-            return mod_getIP($asString);
463
-        }
464
-
465
-        /**
466
-         * @param $url
467
-         * @return bool|mixed|string
468
-         */
469
-        public static function planetGetRemoteContent($url)
470
-        {
471
-            if ($data = static::planetFetchSnoopy($url)) {
472
-                return $data;
473
-            }
474
-            if ($data = static::planetFetchCURL($url)) {
475
-                return $data;
476
-            }
477
-            if ($data = static::planetFetchFopen($url)) {
478
-                return $data;
479
-            }
480
-
481
-            return false;
482
-        }
483
-
484
-        /**
485
-         * @param $url
486
-         * @return string
487
-         */
488
-        public static function planetFetchSnoopy($url)
489
-        {
490
-            require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
491
-            $snoopy = new Snoopy;
492
-            $data   = '';
493
-            if (@$snoopy->fetch($url)) {
494
-                $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
495
-            }
496
-
497
-            return $data;
498
-        }
499
-
500
-        /**
501
-         * @param $url
502
-         * @return bool|mixed
503
-         */
504
-        public static function planetFetchCURL($url)
505
-        {
506
-            if (!function_exists('curl_init')) {
507
-                return false;
508
-            }
509
-            $ch = curl_init();    // initialize curl handle
510
-            curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
511
-            curl_setopt($ch, CURLOPT_FAILONERROR, 1);
512
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
513
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
514
-            curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
515
-            $data = curl_exec($ch); // run the whole process
516
-            curl_close($ch);
517
-
518
-            return $data;
519
-        }
520
-
521
-        /**
522
-         * @param $url
523
-         * @return bool|string
524
-         */
525
-        public static function planetFetchFopen($url)
526
-        {
527
-            if (!$fp = @fopen($url, 'r')) {
528
-                return false;
529
-            }
530
-            $data = '';
531
-            while (!feof($fp)) {
532
-                $data .= fgets($fp, 1024);
533
-            }
534
-            fclose($fp);
535
-
536
-            return $data;
537
-        }
538
-
539
-        /**
540
-         * @param     $haystack
541
-         * @param     $needle
542
-         * @param int $offset
543
-         * @return bool|int
544
-         */
545
-        public static function planetStrrPos($haystack, $needle, $offset = 0)
546
-        {
547
-            if (substr(PHP_VERSION, 0, 1) == 5) {
548
-                return strrpos($haystack, $needle, $offset);
549
-            }
550
-            $index = strpos(strrev($haystack), strrev($needle));
551
-            if ($index === false) {
552
-                return false;
553
-            }
554
-            $index = strlen($haystack) - strlen($needle) - $index;
555
-
556
-            return $index;
557
-        }
558
-    }
76
+		public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
77
+		{
78
+			$args_abb     = [
79
+				'a' => 'article',
80
+				'b' => 'blog',
81
+				'c' => 'category',
82
+				'l' => 'list',
83
+				'o' => 'sort',
84
+				's' => 'start',
85
+				'u' => 'uid'
86
+			];
87
+			$args         = [];
88
+			$args_numeric = [];
89
+			$args_string  = [];
90
+			if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
91
+				$vars = preg_split("/[\/|&]/", $matches[1]);
92
+				$vars = array_map('trim', $vars);
93
+				if (count($vars) > 0) {
94
+					foreach ($vars as $var) {
95
+						if (is_numeric($var)) {
96
+							$args_numeric[] = $var;
97
+						} elseif (false === strpos($var, '=')) {
98
+							if (is_numeric(substr($var, 1))) {
99
+								$args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
100
+							} else {
101
+								$args_string[] = urldecode($var);
102
+							}
103
+						} else {
104
+							parse_str($var, $args);
105
+						}
106
+					}
107
+				}
108
+			}
109
+
110
+			return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
111
+		}
112
+
113
+		/**
114
+		 * Function to parse class prefix
115
+		 *
116
+		 * @var string $class_string string to be parsed
117
+		 * @var mixed  $pattern
118
+		 * @var mixed  $replacement
119
+		 *
120
+		 * @return bool true on success
121
+		 */
122
+		public static function planetParseClass($class_string, $pattern = '', $replacement = '')
123
+		{
124
+			if (empty($class_string)) {
125
+				return;
126
+			}
127
+			$patterns     = ["/\[CLASS_PREFIX\]/"];
128
+			$replacements = [ucfirst(strtolower($GLOBALS['moddirname']))];
129
+			if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
130
+				$pattern     = [$pattern];
131
+				$replacement = [$replacement];
132
+			}
133
+			if (is_array($pattern) && count($pattern) > 0) {
134
+				$ii = 0;
135
+				foreach ($pattern as $pat) {
136
+					if (!in_array($pat, $patterns)) {
137
+						$patterns[]     = $pat;
138
+						$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
139
+					}
140
+					++$ii;
141
+				}
142
+			}
143
+			$class_string = preg_replace($patterns, $replacements, $class_string);
144
+			eval($class_string);
145
+
146
+			return true;
147
+		}
148
+
149
+		/**
150
+		 * Function to parse function prefix
151
+		 *
152
+		 * @var string $function_string string to be parsed
153
+		 * @var mixed  $pattern
154
+		 * @var mixed  $replacement
155
+		 *
156
+		 * @return bool true on success
157
+		 */
158
+		public static function planetParseFunction($function_string, $pattern = '', $replacement = '')
159
+		{
160
+			if (empty($function_string)) {
161
+				return;
162
+			}
163
+			$patterns     = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"];
164
+			$replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']];
165
+			if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) {
166
+				$pattern     = [$pattern];
167
+				$replacement = [$replacement];
168
+			}
169
+			if (is_array($pattern) && count($pattern) > 0) {
170
+				$ii = 0;
171
+				foreach ($pattern as $pat) {
172
+					if (!in_array($pat, $patterns)) {
173
+						$patterns[]     = $pat;
174
+						$replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : '';
175
+					}
176
+					++$ii;
177
+				}
178
+			}
179
+			$function_string = preg_replace($patterns, $replacements, $function_string);
180
+			eval($function_string);
181
+
182
+			return true;
183
+		}
184
+
185
+		/**
186
+		 * Function to convert UNIX time to formatted time string
187
+		 * @param        $time
188
+		 * @param string $format
189
+		 * @return string
190
+		 */
191
+		public static function planetFormatTimestamp($time, $format = '')
192
+		{
193
+			if (empty($time)) {
194
+				return '';
195
+			}
196
+
197
+			return formatTimestamp($time, $format);
198
+		}
199
+
200
+		/**
201
+		 * Function to a list of user names associated with their user IDs
202
+		 * @param int  $userid
203
+		 * @param int  $usereal
204
+		 * @param bool $linked
205
+		 * @return array
206
+		 */
207
+		public static function &planetGetUnameFromId($userid, $usereal = 0, $linked = false)
208
+		{
209
+			if (!is_array($userid)) {
210
+				$userid = [$userid];
211
+			}
212
+			$users =& mod_getUnameFromIds($userid, $usereal, $linked);
213
+
214
+			return $users;
215
+		}
216
+
217
+		/**
218
+		 * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space
219
+		 *
220
+		 * @var string $text raw content
221
+		 *
222
+		 * @return array associative array of link url and title
223
+		 */
224
+		public static function &planetParseLinks($text)
225
+		{
226
+			$myts       = MyTextSanitizer::getInstance();
227
+			$link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
228
+			$links      = [];
229
+			if (count($link_array) > 0) {
230
+				foreach ($link_array as $link) {
231
+					@list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
232
+					if (empty($url)) {
233
+						continue;
234
+					}
235
+					//if(empty($title)) $title = $url;
236
+					$links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)];
237
+				}
238
+			}
239
+
240
+			return $links;
241
+		}
242
+
243
+		/**
244
+		 * @param $pagename
245
+		 * @return string
246
+		 */
247
+		public static function planetGetTemplate($pagename)
248
+		{
249
+			return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
250
+		}
251
+
252
+		/**
253
+		 * @param int $currentoption
254
+		 */
255
+		//public static function planet_adminmenu($currentoption = -1)
256
+		//{
257
+		//    loadModuleAdminMenu($currentoption, '');
258
+		//
259
+		//    return;
260
+		//}
261
+
262
+		/**
263
+		 * Function to send a trackback
264
+		 *
265
+		 * @param $article
266
+		 * @param $comment
267
+		 * @return bool
268
+		 */
269
+		public static function planetSendTrackback(&$article, &$comment)
270
+		{
271
+			$blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
272
+			$blog_obj    = $blogHandler->get($article->getVar('blog_id'));
273
+			if (!$pattern = $blog_obj->getVar('blog_trackback')) {
274
+				return false;
275
+			}
276
+
277
+			@list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
278
+			$trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
279
+
280
+			return static::planetTrackback($trackback_url, $article);
281
+		}
282
+
283
+		/**
284
+		 * @param $trackback_url
285
+		 * @param $article
286
+		 * @return bool
287
+		 */
288
+		public static function planetTrackback($trackback_url, $article)
289
+		{
290
+			global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
291
+
292
+			$title         = $article->getVar('art_title');
293
+			$excerpt       = $article->getVar('art_content');
294
+			$blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
295
+			$title         = xoops_utf8_encode($title);
296
+			$excerpt       = xoops_utf8_encode($excerpt);
297
+			$blog_name     = xoops_utf8_encode($blog_name);
298
+			$charset       = 'utf-8';
299
+			$title1        = urlencode($title);
300
+			$excerpt1      = urlencode($excerpt);
301
+			$name1         = urlencode($blog_name);
302
+			$url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
303
+			$query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
304
+			$trackback_url = parse_url($trackback_url);
305
+
306
+			$http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
307
+			$http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
308
+			$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
309
+			$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
310
+			$http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
311
+			$http_request .= "\r\n\r\n";
312
+			$http_request .= $query_string;
313
+			if ('' == $trackback_url['port']) {
314
+				$trackback_url['port'] = 80;
315
+			}
316
+			$fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
317
+			@fwrite($fs, $http_request);
318
+			if ($xoopsModuleConfig['do_debug']) {
319
+				$debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
320
+				$fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
321
+				$fr         .= "CHARSET:$charset\n";
322
+				$fr         .= "NAME:$blog_name\n";
323
+				$fr         .= 'TITLE:' . $title . "\n";
324
+				$fr         .= "EXCERPT:$excerpt\n\n";
325
+				while (!@feof($fs)) {
326
+					$fr .= @fgets($fs, 4096);
327
+				}
328
+				$fr .= "\n\n";
329
+
330
+				if ($fp = fopen($debug_file, 'a')) {
331
+					fwrite($fp, $fr);
332
+					fclose($fp);
333
+				} else {
334
+				}
335
+			}
336
+			@fclose($fs);
337
+
338
+			return true;
339
+		}
340
+
341
+		/**
342
+		 * Function to ping servers
343
+		 * @param $server
344
+		 * @param $id
345
+		 */
346
+		public static function planetGetPing($server, $id)
347
+		{
348
+			if (is_array($server)) {
349
+				foreach ($server as $serv) {
350
+					PlanetUtility::planetGetPing($serv, $id);
351
+				}
352
+			}
353
+			require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
354
+
355
+			// using a timeout of 3 seconds should be enough to cover slow servers
356
+			$client            = new IXR_Client($server, false);
357
+			$client->timeout   = 3;
358
+			$client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
359
+
360
+			// when set to true, this outputs debug messages by itself
361
+			$client->debug = false;
362
+
363
+			$blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
364
+			$home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
365
+			$rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
366
+
367
+			if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
368
+				$client->query('weblogUpdates.ping', $blogname, $home);
369
+			}
370
+		}
371
+
372
+		/**
373
+		 * Function to respond to a trackback
374
+		 * @param int    $error
375
+		 * @param string $error_message
376
+		 */
377
+		public static function planetRespondToTrackback($error = 0, $error_message = '')
378
+		{
379
+			$charset       = 'utf-8';
380
+			$error_message = xoops_utf8_encode($error_message);
381
+			header('Content-Type: text/xml; charset="' . $charset . '"');
382
+			if ($error) {
383
+				echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
384
+				echo "<response>\n";
385
+				echo "<error>1</error>\n";
386
+				echo "<message>$error_message</message>\n";
387
+				echo '</response>';
388
+				die();
389
+			} else {
390
+				echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
391
+				echo "<response>\n";
392
+				echo "<error>0</error>\n";
393
+				echo '</response>';
394
+			}
395
+		}
396
+
397
+		/**
398
+		 * Function to set a cookie with module-specified name
399
+		 *
400
+		 * using customized serialization method
401
+		 * @param        $name
402
+		 * @param string $string
403
+		 * @param int    $expire
404
+		 */
405
+		public static function planetSetCookie($name, $string = '', $expire = 0)
406
+		{
407
+			if (is_array($string)) {
408
+				$value = [];
409
+				foreach ($string as $key => $val) {
410
+					$value[] = $key . '|' . $val;
411
+				}
412
+				$string = implode(',', $value);
413
+			}
414
+			setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
415
+		}
416
+
417
+		/**
418
+		 * @param      $name
419
+		 * @param bool $isArray
420
+		 * @return array|null
421
+		 */
422
+		public static function planetGetCookie($name, $isArray = false)
423
+		{
424
+			$value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
425
+			if ($isArray) {
426
+				$_value = $value ? explode(',', $value) : [];
427
+				$value  = [];
428
+				if (count($_value) > 0) {
429
+					foreach ($_value as $string) {
430
+						$key         = substr($string, 0, strpos($string, '|'));
431
+						$val         = substr($string, strpos($string, '|') + 1);
432
+						$value[$key] = $val;
433
+					}
434
+				}
435
+				unset($_value);
436
+			}
437
+
438
+			return $value;
439
+		}
440
+
441
+		/**
442
+		 * Function to filter text
443
+		 *
444
+		 * @param $document
445
+		 * @return string filtered text
446
+		 */
447
+		public static function &planetHtml2text(&$document)
448
+		{
449
+			$document = strip_tags($document);
450
+
451
+			return $document;
452
+		}
453
+
454
+		// Adapted from PMA_getIp() [phpmyadmin project]
455
+
456
+		/**
457
+		 * @param bool $asString
458
+		 * @return mixed
459
+		 */
460
+		public static function planetGetIP($asString = false)
461
+		{
462
+			return mod_getIP($asString);
463
+		}
464
+
465
+		/**
466
+		 * @param $url
467
+		 * @return bool|mixed|string
468
+		 */
469
+		public static function planetGetRemoteContent($url)
470
+		{
471
+			if ($data = static::planetFetchSnoopy($url)) {
472
+				return $data;
473
+			}
474
+			if ($data = static::planetFetchCURL($url)) {
475
+				return $data;
476
+			}
477
+			if ($data = static::planetFetchFopen($url)) {
478
+				return $data;
479
+			}
480
+
481
+			return false;
482
+		}
483
+
484
+		/**
485
+		 * @param $url
486
+		 * @return string
487
+		 */
488
+		public static function planetFetchSnoopy($url)
489
+		{
490
+			require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
491
+			$snoopy = new Snoopy;
492
+			$data   = '';
493
+			if (@$snoopy->fetch($url)) {
494
+				$data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results;
495
+			}
496
+
497
+			return $data;
498
+		}
499
+
500
+		/**
501
+		 * @param $url
502
+		 * @return bool|mixed
503
+		 */
504
+		public static function planetFetchCURL($url)
505
+		{
506
+			if (!function_exists('curl_init')) {
507
+				return false;
508
+			}
509
+			$ch = curl_init();    // initialize curl handle
510
+			curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
511
+			curl_setopt($ch, CURLOPT_FAILONERROR, 1);
512
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
513
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
514
+			curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
515
+			$data = curl_exec($ch); // run the whole process
516
+			curl_close($ch);
517
+
518
+			return $data;
519
+		}
520
+
521
+		/**
522
+		 * @param $url
523
+		 * @return bool|string
524
+		 */
525
+		public static function planetFetchFopen($url)
526
+		{
527
+			if (!$fp = @fopen($url, 'r')) {
528
+				return false;
529
+			}
530
+			$data = '';
531
+			while (!feof($fp)) {
532
+				$data .= fgets($fp, 1024);
533
+			}
534
+			fclose($fp);
535
+
536
+			return $data;
537
+		}
538
+
539
+		/**
540
+		 * @param     $haystack
541
+		 * @param     $needle
542
+		 * @param int $offset
543
+		 * @return bool|int
544
+		 */
545
+		public static function planetStrrPos($haystack, $needle, $offset = 0)
546
+		{
547
+			if (substr(PHP_VERSION, 0, 1) == 5) {
548
+				return strrpos($haystack, $needle, $offset);
549
+			}
550
+			$index = strpos(strrev($haystack), strrev($needle));
551
+			if ($index === false) {
552
+				return false;
553
+			}
554
+			$index = strlen($haystack) - strlen($needle) - $index;
555
+
556
+			return $index;
557
+		}
558
+	}
559 559
 
560 560
 endif;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 if (!defined('planet_FUNCTIONS')):
39 39
     define('planet_FUNCTIONS', 1);
40 40
 
41
-    require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php';
42
-    require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
43
-    require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php';
41
+    require XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/vars.php';
42
+    require_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
43
+    require_once XOOPS_ROOT_PATH.'/Frameworks/art/functions.php';
44 44
 
45 45
     /**
46 46
      * Class PlanetUtility
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         */
76 76
         public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
77 77
         {
78
-            $args_abb     = [
78
+            $args_abb = [
79 79
                 'a' => 'article',
80 80
                 'b' => 'blog',
81 81
                 'c' => 'category',
@@ -90,24 +90,24 @@  discard block
 block discarded – undo
90 90
             if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
91 91
                 $vars = preg_split("/[\/|&]/", $matches[1]);
92 92
                 $vars = array_map('trim', $vars);
93
-                if (count($vars) > 0) {
93
+                if (count($vars)>0) {
94 94
                     foreach ($vars as $var) {
95 95
                         if (is_numeric($var)) {
96 96
                             $args_numeric[] = $var;
97 97
                         } elseif (false === strpos($var, '=')) {
98 98
                             if (is_numeric(substr($var, 1))) {
99
-                                $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
100
-                            } else {
99
+                                $args[$args_abb[strtolower($var{0})]] = (int) substr($var, 1);
100
+                            }else {
101 101
                                 $args_string[] = urldecode($var);
102 102
                             }
103
-                        } else {
103
+                        }else {
104 104
                             parse_str($var, $args);
105 105
                         }
106 106
                     }
107 107
                 }
108 108
             }
109 109
 
110
-            return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true;
110
+            return (count($args)+count($args_numeric)+count($args_string) == 0) ? null : true;
111 111
         }
112 112
 
113 113
         /**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                 $pattern     = [$pattern];
131 131
                 $replacement = [$replacement];
132 132
             }
133
-            if (is_array($pattern) && count($pattern) > 0) {
133
+            if (is_array($pattern) && count($pattern)>0) {
134 134
                 $ii = 0;
135 135
                 foreach ($pattern as $pat) {
136 136
                     if (!in_array($pat, $patterns)) {
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 $pattern     = [$pattern];
167 167
                 $replacement = [$replacement];
168 168
             }
169
-            if (is_array($pattern) && count($pattern) > 0) {
169
+            if (is_array($pattern) && count($pattern)>0) {
170 170
                 $ii = 0;
171 171
                 foreach ($pattern as $pat) {
172 172
                     if (!in_array($pat, $patterns)) {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             if (!is_array($userid)) {
210 210
                 $userid = [$userid];
211 211
             }
212
-            $users =& mod_getUnameFromIds($userid, $usereal, $linked);
212
+            $users = & mod_getUnameFromIds($userid, $usereal, $linked);
213 213
 
214 214
             return $users;
215 215
         }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
             $myts       = MyTextSanitizer::getInstance();
227 227
             $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text);
228 228
             $links      = [];
229
-            if (count($link_array) > 0) {
229
+            if (count($link_array)>0) {
230 230
                 foreach ($link_array as $link) {
231 231
                     @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2));
232 232
                     if (empty($url)) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
          */
247 247
         public static function planetGetTemplate($pagename)
248 248
         {
249
-            return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl';
249
+            return $GLOBALS['VAR_PREFIX'].'_'.$pagename.'.tpl';
250 250
         }
251 251
 
252 252
         /**
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             }
276 276
 
277 277
             @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern));
278
-            $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link'));
278
+            $trackback_url = preg_replace('#'.$pat.'#', $rep, $article_obj->getVar('art_link'));
279 279
 
280 280
             return static::planetTrackback($trackback_url, $article);
281 281
         }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
             $title         = $article->getVar('art_title');
293 293
             $excerpt       = $article->getVar('art_content');
294
-            $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
294
+            $blog_name     = $xoopsConfig['sitename'].'-'.$xoopsModule->getVar('name');
295 295
             $title         = xoops_utf8_encode($title);
296 296
             $excerpt       = xoops_utf8_encode($excerpt);
297 297
             $blog_name     = xoops_utf8_encode($blog_name);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
             $title1        = urlencode($title);
300 300
             $excerpt1      = urlencode($excerpt);
301 301
             $name1         = urlencode($blog_name);
302
-            $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
302
+            $url           = urlencode(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article->getVar('art_id'));
303 303
             $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
304 304
             $trackback_url = parse_url($trackback_url);
305 305
 
306
-            $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
307
-            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
308
-            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
309
-            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
310
-            $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
306
+            $http_request = 'POST '.$trackback_url['path'].($trackback_url['query'] ? '?'.$trackback_url['query'] : '')." HTTP/1.0\r\n";
307
+            $http_request .= 'Host: '.$trackback_url['host']."\r\n";
308
+            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.$charset."\r\n";
309
+            $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
310
+            $http_request .= 'User-Agent: XOOPS Blogs/'.XOOPS_VERSION;
311 311
             $http_request .= "\r\n\r\n";
312 312
             $http_request .= $query_string;
313 313
             if ('' == $trackback_url['port']) {
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
             $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
317 317
             @fwrite($fs, $http_request);
318 318
             if ($xoopsModuleConfig['do_debug']) {
319
-                $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
319
+                $debug_file = XOOPS_CACHE_PATH.'/'.$GLOBALS['moddirname'].'_trackback.log';
320 320
                 $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
321 321
                 $fr         .= "CHARSET:$charset\n";
322 322
                 $fr         .= "NAME:$blog_name\n";
323
-                $fr         .= 'TITLE:' . $title . "\n";
323
+                $fr         .= 'TITLE:'.$title."\n";
324 324
                 $fr         .= "EXCERPT:$excerpt\n\n";
325 325
                 while (!@feof($fs)) {
326 326
                     $fr .= @fgets($fs, 4096);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
                 if ($fp = fopen($debug_file, 'a')) {
331 331
                     fwrite($fp, $fr);
332 332
                     fclose($fp);
333
-                } else {
333
+                }else {
334 334
                 }
335 335
             }
336 336
             @fclose($fs);
@@ -350,19 +350,19 @@  discard block
 block discarded – undo
350 350
                     PlanetUtility::planetGetPing($serv, $id);
351 351
                 }
352 352
             }
353
-            require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php';
353
+            require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class-IXR.php';
354 354
 
355 355
             // using a timeout of 3 seconds should be enough to cover slow servers
356 356
             $client            = new IXR_Client($server, false);
357 357
             $client->timeout   = 3;
358
-            $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION;
358
+            $client->useragent .= ' -- XOOPS Article/'.XOOPS_VERSION;
359 359
 
360 360
             // when set to true, this outputs debug messages by itself
361 361
             $client->debug = false;
362 362
 
363 363
             $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name'));
364
-            $home     = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/';
365
-            $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id;
364
+            $home     = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/';
365
+            $rss2_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php'.URL_DELIMITER.'rss2.0/'.$id;
366 366
 
367 367
             if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping
368 368
                 $client->query('weblogUpdates.ping', $blogname, $home);
@@ -378,16 +378,16 @@  discard block
 block discarded – undo
378 378
         {
379 379
             $charset       = 'utf-8';
380 380
             $error_message = xoops_utf8_encode($error_message);
381
-            header('Content-Type: text/xml; charset="' . $charset . '"');
381
+            header('Content-Type: text/xml; charset="'.$charset.'"');
382 382
             if ($error) {
383
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
383
+                echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
384 384
                 echo "<response>\n";
385 385
                 echo "<error>1</error>\n";
386 386
                 echo "<message>$error_message</message>\n";
387 387
                 echo '</response>';
388 388
                 die();
389
-            } else {
390
-                echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
389
+            }else {
390
+                echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n";
391 391
                 echo "<response>\n";
392 392
                 echo "<error>0</error>\n";
393 393
                 echo '</response>';
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
             if (is_array($string)) {
408 408
                 $value = [];
409 409
                 foreach ($string as $key => $val) {
410
-                    $value[] = $key . '|' . $val;
410
+                    $value[] = $key.'|'.$val;
411 411
                 }
412 412
                 $string = implode(',', $value);
413 413
             }
414
-            setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/');
414
+            setcookie($GLOBALS['VAR_PREFIX'].$name, $string, (int) $expire, '/');
415 415
         }
416 416
 
417 417
         /**
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
          */
422 422
         public static function planetGetCookie($name, $isArray = false)
423 423
         {
424
-            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null;
424
+            $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'].$name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'].$name] : null;
425 425
             if ($isArray) {
426 426
                 $_value = $value ? explode(',', $value) : [];
427 427
                 $value  = [];
428
-                if (count($_value) > 0) {
428
+                if (count($_value)>0) {
429 429
                     foreach ($_value as $string) {
430 430
                         $key         = substr($string, 0, strpos($string, '|'));
431
-                        $val         = substr($string, strpos($string, '|') + 1);
431
+                        $val         = substr($string, strpos($string, '|')+1);
432 432
                         $value[$key] = $val;
433 433
                     }
434 434
                 }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
          */
488 488
         public static function planetFetchSnoopy($url)
489 489
         {
490
-            require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
490
+            require_once XOOPS_ROOT_PATH.'/class/snoopy.php';
491 491
             $snoopy = new Snoopy;
492 492
             $data   = '';
493 493
             if (@$snoopy->fetch($url)) {
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
             if (!function_exists('curl_init')) {
507 507
                 return false;
508 508
             }
509
-            $ch = curl_init();    // initialize curl handle
509
+            $ch = curl_init(); // initialize curl handle
510 510
             curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
511 511
             curl_setopt($ch, CURLOPT_FAILONERROR, 1);
512
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
512
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
513 513
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
514 514
             curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s
515 515
             $data = curl_exec($ch); // run the whole process
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
             if ($index === false) {
552 552
                 return false;
553 553
             }
554
-            $index = strlen($haystack) - strlen($needle) - $index;
554
+            $index = strlen($haystack)-strlen($needle)-$index;
555 555
 
556 556
             return $index;
557 557
         }
Please login to merge, or discard this patch.