@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if(!defined('__XE__')) |
|
4 | +if (!defined('__XE__')) |
|
5 | 5 | exit(); |
6 | 6 | |
7 | 7 | /** |
@@ -13,27 +13,27 @@ discard block |
||
13 | 13 | * It should be called before executing the module(before_module_proc). If not, it is forced to shut down. |
14 | 14 | * */ |
15 | 15 | // Insert a rsd tag when called_position is after_module_proc |
16 | -if($called_position == 'after_module_proc') |
|
16 | +if ($called_position == 'after_module_proc') |
|
17 | 17 | { |
18 | 18 | // Create rsd address of the current module |
19 | 19 | $site_module_info = Context::get('site_module_info'); |
20 | 20 | $rsd_url = getFullSiteUrl($site_module_info->domain, '', 'mid', $this->module_info->mid, 'act', 'api'); |
21 | 21 | // Insert rsd tag into the header |
22 | - Context::addHtmlHeader(" " . '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsd_url . '" />'); |
|
22 | + Context::addHtmlHeader(" ".'<link rel="EditURI" type="application/rsd+xml" title="RSD" href="'.$rsd_url.'" />'); |
|
23 | 23 | } |
24 | 24 | // If act isnot api, just return |
25 | -if($_REQUEST['act'] != 'api') |
|
25 | +if ($_REQUEST['act'] != 'api') |
|
26 | 26 | { |
27 | 27 | return; |
28 | 28 | } |
29 | 29 | |
30 | 30 | // Read func file |
31 | -require_once(_XE_PATH_ . 'addons/blogapi/blogapi.func.php'); |
|
31 | +require_once(_XE_PATH_.'addons/blogapi/blogapi.func.php'); |
|
32 | 32 | |
33 | 33 | $xml = $GLOBALS['HTTP_RAW_POST_DATA']; |
34 | 34 | |
35 | 35 | // If HTTP_RAW_POST_DATA is NULL, Print error message |
36 | -if(!$xml) |
|
36 | +if (!$xml) |
|
37 | 37 | { |
38 | 38 | $content = getXmlRpcFailure(1, 'Invalid Method Call'); |
39 | 39 | printContent($content); |
@@ -41,38 +41,38 @@ discard block |
||
41 | 41 | |
42 | 42 | // xmlprc parsing |
43 | 43 | // Parse the requested xmlrpc |
44 | -if(Security::detectingXEE($xml)) |
|
44 | +if (Security::detectingXEE($xml)) |
|
45 | 45 | { |
46 | 46 | header("HTTP/1.0 400 Bad Request"); |
47 | 47 | exit; |
48 | 48 | } |
49 | 49 | |
50 | -if(version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true); |
|
50 | +if (version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true); |
|
51 | 51 | $xml = new SimpleXMLElement($xml, LIBXML_NONET | LIBXML_NOENT); |
52 | 52 | |
53 | -$method_name = (string)$xml->methodName; |
|
53 | +$method_name = (string) $xml->methodName; |
|
54 | 54 | $params = $xml->params->param; |
55 | 55 | |
56 | 56 | // Compatible with some of methodname |
57 | -if(in_array($method_name, array('metaWeblog.deletePost', 'metaWeblog.getUsersBlogs', 'metaWeblog.getUserInfo'))) |
|
57 | +if (in_array($method_name, array('metaWeblog.deletePost', 'metaWeblog.getUsersBlogs', 'metaWeblog.getUserInfo'))) |
|
58 | 58 | { |
59 | 59 | $method_name = str_replace('metaWeblog.', 'blogger.', $method_name); |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Get user_id, password and attempt log-in |
63 | -$user_id = trim((string)$params[1]->value->string); |
|
64 | -$password = trim((string)$params[2]->value->string); |
|
63 | +$user_id = trim((string) $params[1]->value->string); |
|
64 | +$password = trim((string) $params[2]->value->string); |
|
65 | 65 | |
66 | 66 | // Before executing the module, authentication is processed. |
67 | -if($called_position == 'before_module_init') |
|
67 | +if ($called_position == 'before_module_init') |
|
68 | 68 | { |
69 | 69 | // Attempt log-in by using member controller |
70 | - if($user_id && $password) |
|
70 | + if ($user_id && $password) |
|
71 | 71 | { |
72 | 72 | $oMemberController = getController('member'); |
73 | 73 | $output = $oMemberController->doLogin($user_id, $password); |
74 | 74 | // If login fails, an error message appears |
75 | - if(!$output->toBool()) |
|
75 | + if (!$output->toBool()) |
|
76 | 76 | { |
77 | 77 | $content = getXmlRpcFailure(1, $output->getMessage()); |
78 | 78 | printContent($content); |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | // Before module processing, handle requests from blogapi tool and then terminate. |
89 | -if($called_position == 'before_module_proc') |
|
89 | +if ($called_position == 'before_module_proc') |
|
90 | 90 | { |
91 | 91 | // Check writing permission |
92 | - if(!$this->grant->write_document) |
|
92 | + if (!$this->grant->write_document) |
|
93 | 93 | { |
94 | 94 | printContent(getXmlRpcFailure(1, 'no permission')); |
95 | 95 | } |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | // Specifies a temporary file storage |
102 | 102 | $logged_info = Context::get('logged_info'); |
103 | 103 | $mediaPath = sprintf('files/cache/blogapi/%s/%s/', $this->mid, $logged_info->member_srl); |
104 | - $mediaAbsPath = _XE_PATH_ . $mediaPath; |
|
105 | - $mediaUrlPath = Context::getRequestUri() . $mediaPath; |
|
104 | + $mediaAbsPath = _XE_PATH_.$mediaPath; |
|
105 | + $mediaUrlPath = Context::getRequestUri().$mediaPath; |
|
106 | 106 | |
107 | - switch($method_name) |
|
107 | + switch ($method_name) |
|
108 | 108 | { |
109 | 109 | // Blog information |
110 | 110 | case 'blogger.getUsersBlogs' : |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | // Return a list of categories |
122 | 122 | case 'metaWeblog.getCategories' : |
123 | 123 | $category_obj_list = array(); |
124 | - if($category_list) |
|
124 | + if ($category_list) |
|
125 | 125 | { |
126 | - foreach($category_list as $category_srl => $category_info) |
|
126 | + foreach ($category_list as $category_srl => $category_info) |
|
127 | 127 | { |
128 | 128 | $obj = new stdClass(); |
129 | 129 | $obj->description = $category_info->title; |
@@ -144,50 +144,50 @@ discard block |
||
144 | 144 | // Check a file upload permission |
145 | 145 | $oFileModel = getModel('file'); |
146 | 146 | $file_module_config = $oFileModel->getFileModuleConfig($this->module_srl); |
147 | - if(is_array($file_module_config->download_grant) && count($file_module_config->download_grant) > 0) |
|
147 | + if (is_array($file_module_config->download_grant) && count($file_module_config->download_grant) > 0) |
|
148 | 148 | { |
149 | 149 | $logged_info = Context::get('logged_info'); |
150 | - if($logged_info->is_admin != 'Y') |
|
150 | + if ($logged_info->is_admin != 'Y') |
|
151 | 151 | { |
152 | 152 | $is_permitted = false; |
153 | - for($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
153 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
154 | 154 | { |
155 | 155 | $group_srl = $file_module_config->download_grant[$i]; |
156 | - if($logged_info->group_list[$group_srl]) |
|
156 | + if ($logged_info->group_list[$group_srl]) |
|
157 | 157 | { |
158 | 158 | $is_permitted = true; |
159 | 159 | break; |
160 | 160 | } |
161 | 161 | } |
162 | - if(!$is_permitted){ |
|
162 | + if (!$is_permitted) { |
|
163 | 163 | printContent(getXmlRpcFailure(1, 'no permission')); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | $fileinfo = $params[3]->value->struct->member; |
169 | - foreach($fileinfo as $key => $val) |
|
169 | + foreach ($fileinfo as $key => $val) |
|
170 | 170 | { |
171 | - $nodename = (string)$val->name; |
|
172 | - if($nodename === 'bits') |
|
171 | + $nodename = (string) $val->name; |
|
172 | + if ($nodename === 'bits') |
|
173 | 173 | { |
174 | - $filedata = base64_decode((string)$val->value->base64); |
|
174 | + $filedata = base64_decode((string) $val->value->base64); |
|
175 | 175 | } |
176 | - else if($nodename === 'name') |
|
176 | + else if ($nodename === 'name') |
|
177 | 177 | { |
178 | - $filename = pathinfo((string)$val->value->string, PATHINFO_BASENAME); |
|
178 | + $filename = pathinfo((string) $val->value->string, PATHINFO_BASENAME); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - if($logged_info->is_admin != 'Y') |
|
182 | + if ($logged_info->is_admin != 'Y') |
|
183 | 183 | { |
184 | 184 | // check file type |
185 | - if(isset($file_module_config->allowed_filetypes) && $file_module_config->allowed_filetypes !== '*.*') |
|
185 | + if (isset($file_module_config->allowed_filetypes) && $file_module_config->allowed_filetypes !== '*.*') |
|
186 | 186 | { |
187 | 187 | $filetypes = explode(';', $file_module_config->allowed_filetypes); |
188 | 188 | $ext = array(); |
189 | 189 | |
190 | - foreach($filetypes as $item) |
|
190 | + foreach ($filetypes as $item) |
|
191 | 191 | { |
192 | 192 | $item = explode('.', $item); |
193 | 193 | $ext[] = strtolower(array_pop($item)); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $uploaded_ext = explode('.', $filename); |
197 | 197 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
198 | 198 | |
199 | - if(!in_array($uploaded_ext, $ext)) |
|
199 | + if (!in_array($uploaded_ext, $ext)) |
|
200 | 200 | { |
201 | 201 | printContent(getXmlRpcFailure(1, 'Not allowed file type')); |
202 | 202 | break; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | $allowed_filesize = $file_module_config->allowed_filesize * 1024 * 1024; |
207 | - if($allowed_filesize < strlen($filedata)) |
|
207 | + if ($allowed_filesize < strlen($filedata)) |
|
208 | 208 | { |
209 | 209 | printContent(getXmlRpcFailure(1, 'This file exceeds the attachment limit')); |
210 | 210 | break; |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | $target_filename = sprintf('%s%s', $mediaAbsPath, $temp_filename); |
216 | 216 | FileHandler::makeDir($mediaAbsPath); |
217 | 217 | FileHandler::writeFile($target_filename, $filedata); |
218 | - FileHandler::writeFile($target_filename . '_source_filename', $filename); |
|
218 | + FileHandler::writeFile($target_filename.'_source_filename', $filename); |
|
219 | 219 | |
220 | 220 | $obj = new stdClass(); |
221 | - $obj->url = Context::getRequestUri() . $mediaPath . $temp_filename; |
|
221 | + $obj->url = Context::getRequestUri().$mediaPath.$temp_filename; |
|
222 | 222 | $content = getXmlRpcResponse($obj); |
223 | 223 | printContent($content); |
224 | 224 | break; |
225 | 225 | // Get posts |
226 | 226 | case 'metaWeblog.getPost' : |
227 | - $document_srl = (string)$params[0]->value->string; |
|
228 | - if(!$document_srl) |
|
227 | + $document_srl = (string) $params[0]->value->string; |
|
228 | + if (!$document_srl) |
|
229 | 229 | { |
230 | 230 | printContent(getXmlRpcFailure(1, 'no permission')); |
231 | 231 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | $oDocumentModel = getModel('document'); |
235 | 235 | $oDocument = $oDocumentModel->getDocument($document_srl); |
236 | - if(!$oDocument->isExists() || !$oDocument->isGranted()) |
|
236 | + if (!$oDocument->isExists() || !$oDocument->isGranted()) |
|
237 | 237 | { |
238 | 238 | printContent(getXmlRpcFailure(1, 'no permission')); |
239 | 239 | } |
@@ -241,37 +241,37 @@ discard block |
||
241 | 241 | { |
242 | 242 | // Get a list of categories and set Context |
243 | 243 | $category = ""; |
244 | - if($oDocument->get('category_srl')) |
|
244 | + if ($oDocument->get('category_srl')) |
|
245 | 245 | { |
246 | 246 | $oDocumentModel = getModel('document'); |
247 | 247 | $category_list = $oDocumentModel->getCategoryList($oDocument->get('module_srl')); |
248 | - if($category_list[$oDocument->get('category_srl')]) |
|
248 | + if ($category_list[$oDocument->get('category_srl')]) |
|
249 | 249 | { |
250 | 250 | $category = $category_list[$oDocument->get('category_srl')]->title; |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | $content = sprintf( |
255 | - '<?xml version="1.0" encoding="utf-8"?>' . |
|
256 | - '<methodResponse>' . |
|
257 | - '<params>' . |
|
258 | - '<param>' . |
|
259 | - '<value>' . |
|
260 | - '<struct>' . |
|
261 | - '<member><name>categories</name><value><array><data><value><![CDATA[%s]]></value></data></array></value></member>' . |
|
262 | - '<member><name>dateCreated</name><value><dateTime.iso8601>%s</dateTime.iso8601></value></member>' . |
|
263 | - '<member><name>description</name><value><![CDATA[%s]]></value></member>' . |
|
264 | - '<member><name>link</name><value>%s</value></member>' . |
|
265 | - '<member><name>postid</name><value><string>%s</string></value></member>' . |
|
266 | - '<member><name>title</name><value><![CDATA[%s]]></value></member>' . |
|
267 | - '<member><name>publish</name><value><boolean>1</boolean></value></member>' . |
|
268 | - '</struct>' . |
|
269 | - '</value>' . |
|
270 | - '</param>' . |
|
271 | - '</params>' . |
|
255 | + '<?xml version="1.0" encoding="utf-8"?>'. |
|
256 | + '<methodResponse>'. |
|
257 | + '<params>'. |
|
258 | + '<param>'. |
|
259 | + '<value>'. |
|
260 | + '<struct>'. |
|
261 | + '<member><name>categories</name><value><array><data><value><![CDATA[%s]]></value></data></array></value></member>'. |
|
262 | + '<member><name>dateCreated</name><value><dateTime.iso8601>%s</dateTime.iso8601></value></member>'. |
|
263 | + '<member><name>description</name><value><![CDATA[%s]]></value></member>'. |
|
264 | + '<member><name>link</name><value>%s</value></member>'. |
|
265 | + '<member><name>postid</name><value><string>%s</string></value></member>'. |
|
266 | + '<member><name>title</name><value><![CDATA[%s]]></value></member>'. |
|
267 | + '<member><name>publish</name><value><boolean>1</boolean></value></member>'. |
|
268 | + '</struct>'. |
|
269 | + '</value>'. |
|
270 | + '</param>'. |
|
271 | + '</params>'. |
|
272 | 272 | '</methodResponse>', |
273 | 273 | $category, |
274 | - date("Ymd", $oDocument->getRegdateTime()) . 'T' . date("H:i:s", $oDocument->getRegdateTime()), |
|
274 | + date("Ymd", $oDocument->getRegdateTime()).'T'.date("H:i:s", $oDocument->getRegdateTime()), |
|
275 | 275 | $oDocument->getContent(false, false, true, false), |
276 | 276 | getFullUrl('', 'document_srl', $oDocument->document_srl), |
277 | 277 | $oDocument->document_srl, |
@@ -287,35 +287,35 @@ discard block |
||
287 | 287 | $obj = new stdClass(); |
288 | 288 | $info = $params[3]; |
289 | 289 | // Get information of post, title, and category |
290 | - foreach($info->value->struct->member as $val) |
|
290 | + foreach ($info->value->struct->member as $val) |
|
291 | 291 | { |
292 | - switch((string)$val->name) |
|
292 | + switch ((string) $val->name) |
|
293 | 293 | { |
294 | 294 | case 'title' : |
295 | - $obj->title = (string)$val->value->string; |
|
295 | + $obj->title = (string) $val->value->string; |
|
296 | 296 | break; |
297 | 297 | case 'description' : |
298 | - $obj->content = (string)$val->value->string; |
|
298 | + $obj->content = (string) $val->value->string; |
|
299 | 299 | break; |
300 | 300 | case 'categories' : |
301 | 301 | $categories = $val->value->array->data->value; |
302 | - $category = (string)$categories[0]->string; |
|
303 | - if($category && $category_list) |
|
302 | + $category = (string) $categories[0]->string; |
|
303 | + if ($category && $category_list) |
|
304 | 304 | { |
305 | - foreach($category_list as $category_srl => $category_info) |
|
305 | + foreach ($category_list as $category_srl => $category_info) |
|
306 | 306 | { |
307 | - if($category_info->title == $category) |
|
307 | + if ($category_info->title == $category) |
|
308 | 308 | $obj->category_srl = $category_srl; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | case 'tagwords' : |
313 | 313 | $tags = $val->value->array->data->value; |
314 | - foreach($tags as $tag) |
|
314 | + foreach ($tags as $tag) |
|
315 | 315 | { |
316 | - $tag_list[] = (string)$tag->string; |
|
316 | + $tag_list[] = (string) $tag->string; |
|
317 | 317 | } |
318 | - if(count($tag_list)) |
|
318 | + if (count($tag_list)) |
|
319 | 319 | $obj->tags = implode(',', $tag_list); |
320 | 320 | break; |
321 | 321 | } |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | $obj->module_srl = $this->module_srl; |
328 | 328 | |
329 | 329 | // Attachment |
330 | - if(is_dir($mediaAbsPath)) |
|
330 | + if (is_dir($mediaAbsPath)) |
|
331 | 331 | { |
332 | 332 | $file_list = FileHandler::readDir($mediaAbsPath, '/(_source_filename)$/is'); |
333 | 333 | $file_count = count($file_list); |
334 | - if($file_count) |
|
334 | + if ($file_count) |
|
335 | 335 | { |
336 | 336 | $oFileController = getController('file'); |
337 | 337 | $oFileModel = getModel('file'); |
338 | - foreach($file_list as $file) |
|
338 | + foreach ($file_list as $file) |
|
339 | 339 | { |
340 | - $filename = FileHandler::readFile($mediaAbsPath . $file); |
|
340 | + $filename = FileHandler::readFile($mediaAbsPath.$file); |
|
341 | 341 | $temp_filename = str_replace('_source_filename', '', $file); |
342 | 342 | |
343 | 343 | $file_info = array(); |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | $file_info['name'] = $filename; |
346 | 346 | $fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true); |
347 | 347 | |
348 | - if($fileOutput->get('direct_download') === 'N') |
|
348 | + if ($fileOutput->get('direct_download') === 'N') |
|
349 | 349 | { |
350 | - $replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
|
350 | + $replace_url = Context::getRequestUri().$oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
|
351 | 351 | } |
352 | 352 | else |
353 | 353 | { |
354 | - $replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename'); |
|
354 | + $replace_url = Context::getRequestUri().$fileOutput->get('uploaded_filename'); |
|
355 | 355 | } |
356 | 356 | |
357 | - $obj->content = str_replace($mediaUrlPath . $temp_filename, $replace_url, $obj->content); |
|
357 | + $obj->content = str_replace($mediaUrlPath.$temp_filename, $replace_url, $obj->content); |
|
358 | 358 | } |
359 | 359 | $obj->uploaded_count = $file_count; |
360 | 360 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $obj->homepage = $logged_info->homepage; |
374 | 374 | $output = $oDocumentController->insertDocument($obj, TRUE); |
375 | 375 | |
376 | - if(!$output->toBool()) |
|
376 | + if (!$output->toBool()) |
|
377 | 377 | { |
378 | 378 | $content = getXmlRpcFailure(1, $output->getMessage()); |
379 | 379 | } |
@@ -388,17 +388,17 @@ discard block |
||
388 | 388 | |
389 | 389 | // Edit post |
390 | 390 | case 'metaWeblog.editPost' : |
391 | - $tmp_val = (string)$params[0]->value->string; |
|
392 | - if(!$tmp_val) |
|
393 | - $tmp_val = (string)$params[0]->value->i4; |
|
394 | - if(!$tmp_val) |
|
391 | + $tmp_val = (string) $params[0]->value->string; |
|
392 | + if (!$tmp_val) |
|
393 | + $tmp_val = (string) $params[0]->value->i4; |
|
394 | + if (!$tmp_val) |
|
395 | 395 | { |
396 | 396 | $content = getXmlRpcFailure(1, 'no permission'); |
397 | 397 | break; |
398 | 398 | } |
399 | 399 | $tmp_arr = explode('/', $tmp_val); |
400 | 400 | $document_srl = array_pop($tmp_arr); |
401 | - if(!$document_srl) |
|
401 | + if (!$document_srl) |
|
402 | 402 | { |
403 | 403 | $content = getXmlRpcFailure(1, 'no permission'); |
404 | 404 | break; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $oDocumentModel = getModel('document'); |
408 | 408 | $oDocument = $oDocumentModel->getDocument($document_srl); |
409 | 409 | // Check if a permission to modify a document is granted |
410 | - if(!$oDocument->isGranted()) |
|
410 | + if (!$oDocument->isGranted()) |
|
411 | 411 | { |
412 | 412 | $content = getXmlRpcFailure(1, 'no permission'); |
413 | 413 | break; |
@@ -417,35 +417,35 @@ discard block |
||
417 | 417 | |
418 | 418 | $info = $params[3]; |
419 | 419 | // Get information of post, title, and category |
420 | - foreach($info->value->struct->member as $val) |
|
420 | + foreach ($info->value->struct->member as $val) |
|
421 | 421 | { |
422 | - switch((string)$val->name) |
|
422 | + switch ((string) $val->name) |
|
423 | 423 | { |
424 | 424 | case 'title' : |
425 | - $obj->title = (string)$val->value->string; |
|
425 | + $obj->title = (string) $val->value->string; |
|
426 | 426 | break; |
427 | 427 | case 'description' : |
428 | - $obj->content = (string)$val->value->string; |
|
428 | + $obj->content = (string) $val->value->string; |
|
429 | 429 | break; |
430 | 430 | case 'categories' : |
431 | 431 | $categories = $val->value->array->data->value; |
432 | - $category = (string)$categories[0]->string; |
|
433 | - if($category && $category_list) |
|
432 | + $category = (string) $categories[0]->string; |
|
433 | + if ($category && $category_list) |
|
434 | 434 | { |
435 | - foreach($category_list as $category_srl => $category_info) |
|
435 | + foreach ($category_list as $category_srl => $category_info) |
|
436 | 436 | { |
437 | - if($category_info->title == $category) |
|
437 | + if ($category_info->title == $category) |
|
438 | 438 | $obj->category_srl = $category_srl; |
439 | 439 | } |
440 | 440 | } |
441 | 441 | break; |
442 | 442 | case 'tagwords' : |
443 | 443 | $tags = $val->value->array->data->value; |
444 | - foreach($tags as $tag) |
|
444 | + foreach ($tags as $tag) |
|
445 | 445 | { |
446 | - $tag_list[] = (string)$tag->string; |
|
446 | + $tag_list[] = (string) $tag->string; |
|
447 | 447 | } |
448 | - if(count($tag_list)) |
|
448 | + if (count($tag_list)) |
|
449 | 449 | $obj->tags = implode(',', $tag_list); |
450 | 450 | break; |
451 | 451 | } |
@@ -455,17 +455,17 @@ discard block |
||
455 | 455 | $obj->module_srl = $this->module_srl; |
456 | 456 | |
457 | 457 | // Attachment |
458 | - if(is_dir($mediaAbsPath)) |
|
458 | + if (is_dir($mediaAbsPath)) |
|
459 | 459 | { |
460 | 460 | $file_list = FileHandler::readDir($mediaAbsPath, '/(_source_filename)$/is'); |
461 | 461 | $file_count = count($file_list); |
462 | - if($file_count) |
|
462 | + if ($file_count) |
|
463 | 463 | { |
464 | 464 | $oFileController = getController('file'); |
465 | 465 | $oFileModel = getModel('file'); |
466 | - foreach($file_list as $file) |
|
466 | + foreach ($file_list as $file) |
|
467 | 467 | { |
468 | - $filename = FileHandler::readFile($mediaAbsPath . $file); |
|
468 | + $filename = FileHandler::readFile($mediaAbsPath.$file); |
|
469 | 469 | $temp_filename = str_replace('_source_filename', '', $file); |
470 | 470 | |
471 | 471 | $file_info = array(); |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | $file_info['name'] = $filename; |
474 | 474 | $fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true); |
475 | 475 | |
476 | - if($fileOutput->get('direct_download') === 'N') |
|
476 | + if ($fileOutput->get('direct_download') === 'N') |
|
477 | 477 | { |
478 | - $replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
|
478 | + $replace_url = Context::getRequestUri().$oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
|
479 | 479 | } |
480 | 480 | else |
481 | 481 | { |
482 | - $replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename'); |
|
482 | + $replace_url = Context::getRequestUri().$fileOutput->get('uploaded_filename'); |
|
483 | 483 | } |
484 | 484 | |
485 | - $obj->content = str_replace($mediaUrlPath . $temp_filename, $replace_url, $obj->content); |
|
485 | + $obj->content = str_replace($mediaUrlPath.$temp_filename, $replace_url, $obj->content); |
|
486 | 486 | } |
487 | 487 | $obj->uploaded_count += $file_count; |
488 | 488 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | $oDocumentController = getController('document'); |
492 | 492 | $output = $oDocumentController->updateDocument($oDocument, $obj, TRUE); |
493 | 493 | |
494 | - if(!$output->toBool()) |
|
494 | + if (!$output->toBool()) |
|
495 | 495 | { |
496 | 496 | $content = getXmlRpcFailure(1, $output->getMessage()); |
497 | 497 | } |
@@ -505,19 +505,19 @@ discard block |
||
505 | 505 | break; |
506 | 506 | // Delete the post |
507 | 507 | case 'blogger.deletePost' : |
508 | - $tmp_val = (string)$params[1]->value->string; |
|
508 | + $tmp_val = (string) $params[1]->value->string; |
|
509 | 509 | $tmp_arr = explode('/', $tmp_val); |
510 | 510 | $document_srl = array_pop($tmp_arr); |
511 | 511 | // Get a document |
512 | 512 | $oDocumentModel = getModel('document'); |
513 | 513 | $oDocument = $oDocumentModel->getDocument($document_srl); |
514 | 514 | // If the document exists |
515 | - if(!$oDocument->isExists()) |
|
515 | + if (!$oDocument->isExists()) |
|
516 | 516 | { |
517 | 517 | $content = getXmlRpcFailure(1, 'not exists'); |
518 | 518 | // Check if a permission to delete a document is granted |
519 | 519 | } |
520 | - elseif(!$oDocument->isGranted()) |
|
520 | + elseif (!$oDocument->isGranted()) |
|
521 | 521 | { |
522 | 522 | $content = getXmlRpcFailure(1, 'no permission'); |
523 | 523 | break; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | { |
528 | 528 | $oDocumentController = getController('document'); |
529 | 529 | $output = $oDocumentController->deleteDocument($document_srl); |
530 | - if(!$output->toBool()) |
|
530 | + if (!$output->toBool()) |
|
531 | 531 | $content = getXmlRpcFailure(1, $output->getMessage()); |
532 | 532 | else |
533 | 533 | $content = getXmlRpcResponse(true); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $args->search_target = 'member_srl'; |
548 | 548 | $args->search_keyword = $logged_info->member_srl; |
549 | 549 | $output = $oDocumentModel->getDocumentList($args); |
550 | - if(!$output->toBool() || !$output->data) |
|
550 | + if (!$output->toBool() || !$output->data) |
|
551 | 551 | { |
552 | 552 | $content = getXmlRpcFailure(1, 'post not founded'); |
553 | 553 | } |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | $oEditorController = getController('editor'); |
557 | 557 | |
558 | 558 | $posts = array(); |
559 | - foreach($output->data as $key => $oDocument) |
|
559 | + foreach ($output->data as $key => $oDocument) |
|
560 | 560 | { |
561 | 561 | $post = new stdClass(); |
562 | 562 | $post->categories = array(); |
563 | - $post->dateCreated = date("Ymd", $oDocument->getRegdateTime()) . 'T' . date("H:i:s", $oDocument->getRegdateTime()); |
|
564 | - $post->description = sprintf('<![CDATA[%s]]>',$oEditorController->transComponent($oDocument->getContent(false, false, true, false))); |
|
563 | + $post->dateCreated = date("Ymd", $oDocument->getRegdateTime()).'T'.date("H:i:s", $oDocument->getRegdateTime()); |
|
564 | + $post->description = sprintf('<![CDATA[%s]]>', $oEditorController->transComponent($oDocument->getContent(false, false, true, false))); |
|
565 | 565 | $post->link = $post->permaLink = getFullUrl('', 'document_srl', $oDocument->document_srl); |
566 | 566 | $post->postid = $oDocument->document_srl; |
567 | 567 | $post->title = htmlspecialchars($oDocument->get('title'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
@@ -1,8 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if(!defined('__XE__')) |
|
4 | +if(!defined('__XE__')) { |
|
5 | 5 | exit(); |
6 | +} |
|
6 | 7 | |
7 | 8 | /** |
8 | 9 | * @file blogapicounter.addon.php |
@@ -47,7 +48,9 @@ discard block |
||
47 | 48 | exit; |
48 | 49 | } |
49 | 50 | |
50 | -if(version_compare(PHP_VERSION, '5.2.11', '<=')) libxml_disable_entity_loader(true); |
|
51 | +if(version_compare(PHP_VERSION, '5.2.11', '<=')) { |
|
52 | + libxml_disable_entity_loader(true); |
|
53 | +} |
|
51 | 54 | $xml = new SimpleXMLElement($xml, LIBXML_NONET | LIBXML_NOENT); |
52 | 55 | |
53 | 56 | $method_name = (string)$xml->methodName; |
@@ -77,8 +80,7 @@ discard block |
||
77 | 80 | $content = getXmlRpcFailure(1, $output->getMessage()); |
78 | 81 | printContent($content); |
79 | 82 | } |
80 | - } |
|
81 | - else |
|
83 | + } else |
|
82 | 84 | { |
83 | 85 | $content = getXmlRpcFailure(1, 'not logged'); |
84 | 86 | printContent($content); |
@@ -172,8 +174,7 @@ discard block |
||
172 | 174 | if($nodename === 'bits') |
173 | 175 | { |
174 | 176 | $filedata = base64_decode((string)$val->value->base64); |
175 | - } |
|
176 | - else if($nodename === 'name') |
|
177 | + } else if($nodename === 'name') |
|
177 | 178 | { |
178 | 179 | $filename = pathinfo((string)$val->value->string, PATHINFO_BASENAME); |
179 | 180 | } |
@@ -228,16 +229,14 @@ discard block |
||
228 | 229 | if(!$document_srl) |
229 | 230 | { |
230 | 231 | printContent(getXmlRpcFailure(1, 'no permission')); |
231 | - } |
|
232 | - else |
|
232 | + } else |
|
233 | 233 | { |
234 | 234 | $oDocumentModel = getModel('document'); |
235 | 235 | $oDocument = $oDocumentModel->getDocument($document_srl); |
236 | 236 | if(!$oDocument->isExists() || !$oDocument->isGranted()) |
237 | 237 | { |
238 | 238 | printContent(getXmlRpcFailure(1, 'no permission')); |
239 | - } |
|
240 | - else |
|
239 | + } else |
|
241 | 240 | { |
242 | 241 | // Get a list of categories and set Context |
243 | 242 | $category = ""; |
@@ -304,8 +303,9 @@ discard block |
||
304 | 303 | { |
305 | 304 | foreach($category_list as $category_srl => $category_info) |
306 | 305 | { |
307 | - if($category_info->title == $category) |
|
308 | - $obj->category_srl = $category_srl; |
|
306 | + if($category_info->title == $category) { |
|
307 | + $obj->category_srl = $category_srl; |
|
308 | + } |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | break; |
@@ -315,8 +315,9 @@ discard block |
||
315 | 315 | { |
316 | 316 | $tag_list[] = (string)$tag->string; |
317 | 317 | } |
318 | - if(count($tag_list)) |
|
319 | - $obj->tags = implode(',', $tag_list); |
|
318 | + if(count($tag_list)) { |
|
319 | + $obj->tags = implode(',', $tag_list); |
|
320 | + } |
|
320 | 321 | break; |
321 | 322 | } |
322 | 323 | } |
@@ -348,8 +349,7 @@ discard block |
||
348 | 349 | if($fileOutput->get('direct_download') === 'N') |
349 | 350 | { |
350 | 351 | $replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
351 | - } |
|
352 | - else |
|
352 | + } else |
|
353 | 353 | { |
354 | 354 | $replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename'); |
355 | 355 | } |
@@ -376,8 +376,7 @@ discard block |
||
376 | 376 | if(!$output->toBool()) |
377 | 377 | { |
378 | 378 | $content = getXmlRpcFailure(1, $output->getMessage()); |
379 | - } |
|
380 | - else |
|
379 | + } else |
|
381 | 380 | { |
382 | 381 | $content = getXmlRpcResponse(strval($document_srl)); |
383 | 382 | } |
@@ -389,8 +388,9 @@ discard block |
||
389 | 388 | // Edit post |
390 | 389 | case 'metaWeblog.editPost' : |
391 | 390 | $tmp_val = (string)$params[0]->value->string; |
392 | - if(!$tmp_val) |
|
393 | - $tmp_val = (string)$params[0]->value->i4; |
|
391 | + if(!$tmp_val) { |
|
392 | + $tmp_val = (string)$params[0]->value->i4; |
|
393 | + } |
|
394 | 394 | if(!$tmp_val) |
395 | 395 | { |
396 | 396 | $content = getXmlRpcFailure(1, 'no permission'); |
@@ -434,8 +434,9 @@ discard block |
||
434 | 434 | { |
435 | 435 | foreach($category_list as $category_srl => $category_info) |
436 | 436 | { |
437 | - if($category_info->title == $category) |
|
438 | - $obj->category_srl = $category_srl; |
|
437 | + if($category_info->title == $category) { |
|
438 | + $obj->category_srl = $category_srl; |
|
439 | + } |
|
439 | 440 | } |
440 | 441 | } |
441 | 442 | break; |
@@ -445,8 +446,9 @@ discard block |
||
445 | 446 | { |
446 | 447 | $tag_list[] = (string)$tag->string; |
447 | 448 | } |
448 | - if(count($tag_list)) |
|
449 | - $obj->tags = implode(',', $tag_list); |
|
449 | + if(count($tag_list)) { |
|
450 | + $obj->tags = implode(',', $tag_list); |
|
451 | + } |
|
450 | 452 | break; |
451 | 453 | } |
452 | 454 | } |
@@ -476,8 +478,7 @@ discard block |
||
476 | 478 | if($fileOutput->get('direct_download') === 'N') |
477 | 479 | { |
478 | 480 | $replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl); |
479 | - } |
|
480 | - else |
|
481 | + } else |
|
481 | 482 | { |
482 | 483 | $replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename'); |
483 | 484 | } |
@@ -494,8 +495,7 @@ discard block |
||
494 | 495 | if(!$output->toBool()) |
495 | 496 | { |
496 | 497 | $content = getXmlRpcFailure(1, $output->getMessage()); |
497 | - } |
|
498 | - else |
|
498 | + } else |
|
499 | 499 | { |
500 | 500 | $content = getXmlRpcResponse(true); |
501 | 501 | FileHandler::removeDir($mediaAbsPath); |
@@ -516,21 +516,20 @@ discard block |
||
516 | 516 | { |
517 | 517 | $content = getXmlRpcFailure(1, 'not exists'); |
518 | 518 | // Check if a permission to delete a document is granted |
519 | - } |
|
520 | - elseif(!$oDocument->isGranted()) |
|
519 | + } elseif(!$oDocument->isGranted()) |
|
521 | 520 | { |
522 | 521 | $content = getXmlRpcFailure(1, 'no permission'); |
523 | 522 | break; |
524 | 523 | // Delete |
525 | - } |
|
526 | - else |
|
524 | + } else |
|
527 | 525 | { |
528 | 526 | $oDocumentController = getController('document'); |
529 | 527 | $output = $oDocumentController->deleteDocument($document_srl); |
530 | - if(!$output->toBool()) |
|
531 | - $content = getXmlRpcFailure(1, $output->getMessage()); |
|
532 | - else |
|
533 | - $content = getXmlRpcResponse(true); |
|
528 | + if(!$output->toBool()) { |
|
529 | + $content = getXmlRpcFailure(1, $output->getMessage()); |
|
530 | + } else { |
|
531 | + $content = getXmlRpcResponse(true); |
|
532 | + } |
|
534 | 533 | } |
535 | 534 | |
536 | 535 | printContent($content); |
@@ -550,8 +549,7 @@ discard block |
||
550 | 549 | if(!$output->toBool() || !$output->data) |
551 | 550 | { |
552 | 551 | $content = getXmlRpcFailure(1, 'post not founded'); |
553 | - } |
|
554 | - else |
|
552 | + } else |
|
555 | 553 | { |
556 | 554 | $oEditorController = getController('editor'); |
557 | 555 |