/** * Returns one item (Nucleus version) */ function _getItem($itemid, $username, $password) { global $manager; // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!$manager->existsItem($itemid, 1, 1)) { return _error(6, "No such item ({$itemid})"); } $blogid = getBlogIDFromItemID($itemid); if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // 3. return the item // Structure returned has dateCreated, userid, blogid and content $item =& $manager->getItem($itemid, 1, 1); // (also allow drafts and future items) $blog = new BLOG($blogid); if ($blog->convertBreaks()) { $item['body'] = removeBreaks($item['body']); } $newstruct = new xmlrpcval(array("publishDate" => new xmlrpcval(iso8601_encode($item['timestamp']), "dateTime.iso8601"), "userid" => new xmlrpcval($item['authorid'], "string"), "blogid" => new xmlrpcval($blogid, "string"), "title" => new xmlrpcval($item['title'], "string"), "body" => new xmlrpcval($item['body'], "string"), "more" => new xmlrpcval($item['more'], "string"), "draft" => new xmlrpcval($item['draft'], "boolean"), "closed" => new xmlrpcval($item['closed'], "boolean")), 'struct'); return new xmlrpcresp($newstruct); }
/** * Returns one item (Blogger version) */ function _getItemBlogger($itemid, $username, $password) { global $manager; // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!$manager->existsItem($itemid, 1, 1)) { return _error(6, "No such item ({$itemid})"); } $blogid = getBlogIDFromItemID($itemid); if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // 3. return the item // Structure returned has dateCreated, userid, blogid and content $item =& $manager->getItem($itemid, 1, 1); // (also allow drafts and future items) $blog = new BLOG($blogid); // get category $item['category'] = $blog->getCategoryName($item['catid']); // remove linebreaks if needed if ($blog->convertBreaks()) { $item['body'] = removeBreaks($item['body']); } $content = blogger_specialTags($item) . $item['body']; $newstruct = new xmlrpcval(array("dateCreated" => new xmlrpcval(iso8601_encode($item['timestamp']), "dateTime.iso8601"), "userid" => new xmlrpcval($item['authorid'], "string"), "blogid" => new xmlrpcval($blogid, "string"), "content" => new xmlrpcval($content, "string")), 'struct'); return new xmlrpcresp($newstruct); }
function _setSkinPart($blogid, $username, $password, $content, $type) { // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!BLOG::existsID($blogid)) { return _error(2, "No such blog ({$blogid})"); } if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // 3. update skin part $blog = new BLOG($blogid); $skin = new SKIN($blog->getDefaultSkin()); $skin->update($type, $content); return new xmlrpcresp(new xmlrpcval(1, 'boolean')); }
case 32: $CONF['secureCookieKeyIP'] = serverVar('REMOTE_ADDR'); break; default: $CONF['secureCookieKeyIP'] = ''; } // login/logout when required or renew cookies if ($action == 'login') { // Form Authentication $login = postVar('login'); $pw = postVar('password'); $shared = intPostVar('shared'); // shared computer or not $pw = substr($pw, 0, 40); // avoid md5 collision by using a long key if ($member->login($login, $pw)) { $member->newCookieKey(); $member->setCookies($shared); if ($CONF['secureCookieKey'] !== 'none') { // secure cookie key $member->setCookieKey(md5($member->getCookieKey() . $CONF['secureCookieKeyIP'])); $member->write(); } // allows direct access to parts of the admin area after logging in if ($nextaction) { $action = $nextaction; } $manager->notify('LoginSuccess', array('member' => &$member, 'username' => $login)); $errormessage = ''; ACTIONLOG::add(INFO, "Login successful for {$login} (sharedpc={$shared})"); } else {
function _mt_getRecentPostTitles($blogid, $username, $password, $iAmount) { $blogid = intval($blogid); $iAmount = intval($iAmount); // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!BLOG::existsID($blogid)) { return _error(2, "No such blog ({$blogid})"); } if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } $iAmount = intval($iAmount); if ($iAmount < 1) { return _error(5, "Amount parameter must be positive"); } // 3. create and return list of recent items // Struct returned has dateCreated, userid, postid and title $blog = new BLOG($blogid); $structarray = array(); // the array in which the structs will be stored $query = "SELECT inumber, ititle as title, itime, iauthor" . ' FROM ' . sql_table('item') . " WHERE iblog={$blogid}" . " ORDER BY itime DESC" . " LIMIT {$iAmount}"; $r = sql_query($query); while ($row = sql_fetch_assoc($r)) { $newstruct = new xmlrpcval(array("dateCreated" => new xmlrpcval(iso8601_encode(strtotime($row['itime'])), "dateTime.iso8601"), "postid" => new xmlrpcval($row['inumber'], "string"), "title" => new xmlrpcval($row['title'], "string"), "userid" => new xmlrpcval($row['iauthor'], "string")), 'struct'); array_push($structarray, $newstruct); } return new xmlrpcresp(new xmlrpcval($structarray, "array")); }
function _mw_getPost($itemid, $username, $password) { global $manager; // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!$manager->existsItem($itemid, 1, 1)) { return _error(6, "No such item ({$itemid})"); } $blogid = getBlogIDFromItemID($itemid); if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // 3. return the item $item =& $manager->getItem($itemid, 1, 1); // (also allow drafts and future items) $b = new BLOG($blogid); if ($b->convertBreaks()) { $item['body'] = removeBreaks($item['body']); $item['more'] = removeBreaks($item['more']); } $categoryname = $b->getCategoryName($item['catid']); $newstruct = new xmlrpcval(array("dateCreated" => new xmlrpcval(iso8601_encode($item['timestamp']), "dateTime.iso8601"), "userid" => new xmlrpcval($item['authorid'], "string"), "blogid" => new xmlrpcval($blogid, "string"), "postid" => new xmlrpcval($itemid, "string"), "description" => new xmlrpcval($item['body'], "string"), "title" => new xmlrpcval($item['title'], "string"), "categories" => new xmlrpcval(array(new xmlrpcval($categoryname, "string")), "array"), "mt_text_more" => new xmlrpcval($item['more'], "string"), "mt_allow_comments" => new xmlrpcval($item['closed'] ? 0 : 1, "int"), "mt_allow_pings" => new xmlrpcval(1, "int")), 'struct'); //TODO: add "String link" to struct? //TODO: add "String permaLink" to struct? return new xmlrpcresp($newstruct); }