e
// client.
// Use the first line of the post as the title
//list($title,$content) = explode("\n",$content,2);
// Let's try using <title> tags....
$result = preg_match('/<title>(.+)<\/title>(.*)/is',$content,$arr);
if ($result) {
$title = $arr[1];
$body = $arr[2];
} else {
$title = '';
$body = $content;
}
$postid = mpb_new_post($uid,$blogid,$title,$body);
$postid = $blogid . ':' . $postid;
$myResp = new xmlrpcval($postid,"string");
// this is a successful value being returned
return new
xmlrpcresp($myResp);
}
}
function editPost ($params) { // ($appkey, $postid, $user, $pass, $content, $publish)
global $xmlrpcerruser;
// PHP makes us do this decode in multiple steps, with
// temp variables... It can't do something like:
// $foo = $params->getParam(0)->scalarval()
$xappkey = $params->getParam(0);
$xpostid = $params->getParam(1);
$xuser = $params->getParam(2);
$xpass = $params->getParam(3);
$xcontent = $params->getParam(4);
$xpublish = $params->getParam(5);
$appkey = $xappkey->scalarval();
$postid = $xpostid->scalarval();
$user = $xuser->scalarval();
$pass = $xpass->scalarval();
$content = $xcontent->scalarval();
$publish = $xpublish->scalarval();
// MyPHPBlog's organization is different from Blogger. We
// have to play a few tricks with postid, because it is
// not unique throughout the system, but instead is only
// unique to a particular blogid. We separate the blogid
// and postid with a colon, and pass that value to the
// client.
list($blogid,$postid) = explode(':',$postid);
// Check login
$login = mpb_get_userid($user,$pass);
$uid = $login['uid'];
// uid of -1 means user/pass didn't jive
if ($uid != -1) {
// Do some stuff
if (!mpb_user_blog_check($uid,$blogid)) {
$err = "User $user does not have post access for blogid $blogid";
}
if (!mpb_user_post_check($uid,$blogid,$postid)) {
$err = "User $user cannot edit postid $postid";
}
} else {
// Bad login
$err = $login['err'];
}
//$err = "editPost not implemented yet";
if ($err) {
// this is an error condition
return new xmlrpcresp(0, $xmlrpcerruser+1, // user error 1
$err);
} else {
// Build response packet.
// Let's try using <title> tags....
$result = preg_match('/^<title>(.+)<\/title>(.*)/is',$content,$arr);
if ($result) {
$title = $arr[1];
$body = $arr[2];
} else {
$title = '';
$body = $content;
}
mpb_update_post($uid,$blogid,$postid,$title,$body);
$myResp = new xmlrpcval(1,"boolean");
// this is a successful value being returned
return new xmlrpcresp($myResp);
}
}
function getPost ($params) { // ($appkey, $postid, $user, $pass)
// PHP makes us do this decode in multiple steps, with
// temp variables... It can't do something like:
// $foo = $params->getParam(0)->scalarval()
$xappkey = $params->getParam(0);
$xpostid = $params->getParam(1);
$xuser = $params->getParam(2);
$xpass = $params->getParam(3);
$appkey = $xappkey->scalarval();
$bpostid = $xpostid->scalarval();
$user = $xuser->scalarval();
$pass = $xpass->scalarval();
list($blogid,$postid) = explode(':',$bpostid);
// Check login
$login = mpb_get_userid($user,$pass);
$uid = $login['uid'];
// uid of -1 means user/pass didn't jive
if ($uid != -1) {
$xmlrpcpost = mpb_get_post($blogid,$postid);
} else {
// Bad login
$err = $login['err'];
}
if ($err) {
// this is an error condition
return new xmlrpcr