Close Connection when there is no connection value.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@13161 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
misol 2013-09-25 15:29:32 +00:00
parent 034a5c0288
commit f70ce644ce
1410 changed files with 7188 additions and 53541 deletions

View file

@ -16,7 +16,7 @@ if($called_position == 'after_module_proc')
{
// Create rsd address of the current module
$site_module_info = Context::get('site_module_info');
$rsd_url = getFullSiteUrl($site_module_info->domain, '', 'mid', $site_module_info->mid, 'act', 'api');
$rsd_url = getFullSiteUrl($site_module_info->domain, '', 'mid', $this->module_info->mid, 'act', 'api');
// Insert rsd tag into the header
Context::addHtmlHeader(" " . '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsd_url . '" />');
}
@ -28,32 +28,24 @@ if($_REQUEST['act'] != 'api')
// Read func file
require_once('./addons/blogapi/blogapi.func.php');
// xmlprc parsing
// Parse the requested xmlrpc
$oXmlParser = new XmlParser();
$xmlDoc = $oXmlParser->parse();
$xml = new SimpleXMLElement($GLOBALS['HTTP_RAW_POST_DATA']);
$method_name = $xmlDoc->methodcall->methodname->body;
$params = $xmlDoc->methodcall->params->param;
if($params && !is_array($params))
{
$params = array($params);
}
$method_name = (string)$xml->methodName;
$params = $xml->params->param;
// Compatible with some of methodname
if(in_array($method_name, array('metaWeblog.deletePost', 'metaWeblog.getUsersBlogs', 'metaWeblog.getUserInfo')))
{
$method_name = str_replace('metaWeblog.', 'blogger.', $method_name);
}
// Delete the first argument if it is blogger.deletePost
if($method_name == 'blogger.deletePost')
{
array_shift($params);
}
// Get user_id, password and attempt log-in
$user_id = trim($params[1]->value->string->body);
$password = trim($params[2]->value->string->body);
$user_id = trim((string)$params[1]->value->string);
$password = trim((string)$params[2]->value->string);
// Before executing the module, authentication is processed.
if($called_position == 'before_module_init')
{
@ -84,9 +76,11 @@ if($called_position == 'before_module_proc')
{
printContent(getXmlRpcFailure(1, 'no permission'));
}
// Get information of the categories
$oDocumentModel = getModel('document');
$category_list = $oDocumentModel->getCategoryList($this->module_srl);
// Specifies a temporary file storage
$tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id);
$uploaded_target_path = sprintf('/files/cache/blogapi/%s/%s/', $this->mid, $user_id);
@ -104,6 +98,7 @@ if($called_position == 'before_module_proc')
$content = getXmlRpcResponse($blog_list);
printContent($content);
break;
// Return a list of categories
case 'metaWeblog.getCategories' :
$category_obj_list = array();
@ -124,6 +119,7 @@ if($called_position == 'before_module_proc')
$content = getXmlRpcResponse($category_obj_list);
printContent($content);
break;
// Upload file
case 'metaWeblog.newMediaObject' :
// Check a file upload permission
@ -144,19 +140,20 @@ if($called_position == 'before_module_proc')
break;
}
}
if(!$is_permitted)
if(!$is_permitted){
printContent(getXmlRpcFailure(1, 'no permission'));
}
}
}
$fileinfo = $params[3]->value->struct->member;
foreach($fileinfo as $key => $val)
{
$nodename = $val->name->body;
$nodename = (string)$val->name;
if($nodename == 'bits')
$filedata = base64_decode($val->value->base64->body);
$filedata = base64_decode((string)$val->value->base64);
elseif($nodename == 'name')
$filename = $val->value->string->body;
$filename = (string)$val->value->string;
}
$tmp_arr = explode('/', $filename);
@ -177,7 +174,7 @@ if($called_position == 'before_module_proc')
break;
// Get posts
case 'metaWeblog.getPost' :
$document_srl = $params[0]->value->string->body;
$document_srl = (string)$params[0]->value->string;
if(!$document_srl)
{
printContent(getXmlRpcFailure(1, 'no permission'));
@ -234,27 +231,25 @@ if($called_position == 'before_module_proc')
}
}
break;
// Write a new post
case 'metaWeblog.newPost' :
$obj = new stdClass();
$info = $params[3];
// Get information of post, title, and category
for($i = 0; $i < count($info->value->struct->member); $i++)
foreach($info->value->struct->member as $val)
{
$val = $info->value->struct->member[$i];
switch($val->name->body)
switch((string)$val->name)
{
case 'title' :
$obj->title = $val->value->string->body;
$obj->title = (string)$val->value->string;
break;
case 'description' :
$obj->content = $val->value->string->body;
$obj->content = (string)$val->value->string;
break;
case 'categories' :
$categories = $val->value->array->data->value;
if(!is_array($categories))
$categories = array($categories);
$category = $categories[0]->string->body;
$category = (string)$categories[0]->string;
if($category && $category_list)
{
foreach($category_list as $category_srl => $category_info)
@ -266,21 +261,21 @@ if($called_position == 'before_module_proc')
break;
case 'tagwords' :
$tags = $val->value->array->data->value;
if(!is_array($tags))
$tags = array($tags);
for($j = 0; $j < count($tags); $j++)
foreach($tags as $tag)
{
$tag_list[] = $tags[$j]->string->body;
$tag_list[] = (string)$tag->string;
}
if(count($tag_list))
$obj->tags = implode(',', $tag_list);
break;
}
}
// Set document srl
$document_srl = getNextSequence();
$obj->document_srl = $document_srl;
$obj->module_srl = $this->module_srl;
// Attachment
if(is_dir($tmp_uploaded_path))
{
@ -302,11 +297,18 @@ if($called_position == 'before_module_proc')
}
}
$oDocumentController = &getController('document');
$oDocumentController = getController('document');
$obj->commentStatus = 'ALLOW';
$obj->allow_trackback = 'Y';
$output = $oDocumentController->insertDocument($obj);
$logged_info = Context::get('logged_info');
$obj->member_srl = $logged_info->member_srl;
$obj->user_id = $logged_info->user_id;
$obj->user_name = $logged_info->user_name;
$obj->nick_name = $logged_info->nick_name;
$obj->email_address = $logged_info->email_address;
$obj->homepage = $logged_info->homepage;
$output = $oDocumentController->insertDocument($obj, TRUE);
if(!$output->toBool())
{
@ -320,11 +322,12 @@ if($called_position == 'before_module_proc')
printContent($content);
break;
// Edit post
case 'metaWeblog.editPost' :
$tmp_val = $params[0]->value->string->body;
$tmp_val = (string)$params[0]->value->string;
if(!$tmp_val)
$tmp_val = $params[0]->value->i4->body;
$tmp_val = (string)$params[0]->value->i4;
if(!$tmp_val)
{
$content = getXmlRpcFailure(1, 'no permission');
@ -351,22 +354,19 @@ if($called_position == 'before_module_proc')
$info = $params[3];
// Get information of post, title, and category
for($i = 0; $i < count($info->value->struct->member); $i++)
foreach($info->value->struct->member as $val)
{
$val = $info->value->struct->member[$i];
switch($val->name->body)
switch((string)$val->name)
{
case 'title' :
$obj->title = $val->value->string->body;
$obj->title = (string)$val->value->string;
break;
case 'description' :
$obj->content = $val->value->string->body;
$obj->content = (string)$val->value->string;
break;
case 'categories' :
$categories = $val->value->array->data->value;
if(!is_array($categories))
$categories = array($categories);
$category = $categories[0]->string->body;
$category = (string)$categories[0]->string;
if($category && $category_list)
{
foreach($category_list as $category_srl => $category_info)
@ -378,11 +378,9 @@ if($called_position == 'before_module_proc')
break;
case 'tagwords' :
$tags = $val->value->array->data->value;
if(!is_array($tags))
$tags = array($tags);
for($j = 0; $j < count($tags); $j++)
foreach($tags as $tag)
{
$tag_list[] = $tags[$j]->string->body;
$tag_list[] = (string)$tag->string;
}
if(count($tag_list))
$obj->tags = implode(',', $tag_list);
@ -419,7 +417,7 @@ if($called_position == 'before_module_proc')
}
$oDocumentController = &getController('document');
$output = $oDocumentController->updateDocument($oDocument, $obj);
$output = $oDocumentController->updateDocument($oDocument, $obj, TRUE);
if(!$output->toBool())
{
@ -435,7 +433,7 @@ if($called_position == 'before_module_proc')
break;
// Delete the post
case 'blogger.deletePost' :
$tmp_val = $params[0]->value->string->body;
$tmp_val = (string)$params[1]->value->string;
$tmp_arr = explode('/', $tmp_val);
$document_srl = array_pop($tmp_arr);
// Get a document
@ -480,7 +478,6 @@ if($called_position == 'before_module_proc')
if(!$output->toBool() || !$output->data)
{
$content = getXmlRpcFailure(1, 'post not founded');
printContent($content);
}
else
{
@ -506,6 +503,7 @@ if($called_position == 'before_module_proc')
printContent($content);
}
break;
// Display RSD if there is no request
default :
$homepagelink = getUrl('', 'mid', $this->mid);