Пример #1
0
 /**
  * Returns array of entries from given categories
  *
  * @param xmlrpcmsg $msg
  * @return xmlrpcresp
  */
 public function retrieve()
 {
     $db =& JFactory::getDBO();
     $query = "SELECT c.id AS id, c.sectionid AS sectionid, c.catid AS catid, c.state AS state, c.created_by_alias AS created_by_alias, " . "\nc.created_by AS created_by, UNIX_TIMESTAMP(c.created) AS created, UNIX_TIMESTAMP(c.publish_up) AS publish_up, c.version AS version, c.metakey AS metakey, c.metadesc AS metadesc, " . "\nUNIX_TIMESTAMP(c.publish_down) AS publish_down, c.access AS access, UNIX_TIMESTAMP(c.modified) AS modified, c.title AS title, c.attribs AS attribs, " . "\nc.title_alias AS title_alias, c.introtext AS introtext, c.fulltext AS `fulltext`, c.hits AS hits, f.content_id as frontpage " . "\nFROM #__content AS c " . "\nLEFT OUTER JOIN #__content_frontpage AS f on c.id = f.content_id " . "\nWHERE state != -2 " . "\nORDER BY title ASC";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $structArray = array();
     foreach ($rows as $row) {
         if (strlen($row->fulltext) > 0) {
             $content = $row->introtext . "<hr id=\"system-readmore\" />" . $row->fulltext;
         } else {
             $content = $row->introtext;
         }
         $structArray[] = array('id' => (int) $row->id, 'sectionid' => (int) $row->sectionid, 'catid' => (int) $row->catid, 'access' => (int) $row->access, 'state' => (int) $row->state, 'created_by' => (int) $row->created_by, 'created_by_alias' => $row->created_by_alias, 'created' => iso8601_encode($row->created), 'publish_up' => iso8601_encode($row->publish_up), 'publish_down' => iso8601_encode($row->publish_down), 'modified' => iso8601_encode($row->modified), 'title' => $row->title, 'name' => $row->title_alias, 'text' => $content, 'description' => "Content Item " . $row->id, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => (int) $row->hits, 'revised' => (int) $row->version, 'attribs' => $row->attribs, 'frontpage' => (bool) $row->frontpage);
     }
     return $structArray;
 }
Пример #2
0
 public function getRssAttributes($oJournalPage = null, $bIsForRpc = false)
 {
     $aResult = array();
     $aResult['title'] = $this->getTitle();
     $aJournalPageLink = $this->getLink($oJournalPage);
     $aResult['link'] = LinkUtil::absoluteLink(LinkUtil::link($aJournalPageLink, 'FrontendManager'), null, LinkUtil::isSSL());
     if ($bIsForRpc) {
         $aResult['description'] = RichtextUtil::parseStorageForBackendOutput($this->getText())->render();
     } else {
         $aResult['description'] = RichtextUtil::parseStorageForFrontendOutput($this->getText())->render();
     }
     $aResult['author'] = $this->getUserRelatedByCreatedBy()->getEmail() . ' (' . $this->getUserRelatedByCreatedBy()->getFullName() . ')';
     $aTags = TagPeer::tagInstancesForObject($this);
     $aCategories = array();
     foreach ($aTags as $oTag) {
         $aCategories[] = $oTag->getTagName();
     }
     $aResult[$bIsForRpc ? 'categories' : 'category'] = $aCategories;
     if ($aJournalPageLink) {
         $aResult['guid'] = $aResult['link'];
     } else {
         $aResult['guid'] = array('isPermaLink' => 'false', '__content' => $this->getId() . "-" . $this->getJournal()->getId());
     }
     $aResult['pubDate'] = date(DATE_RSS, (int) $this->getCreatedAtTimestamp());
     if ($bIsForRpc) {
         $aResult['dateCreated'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp()), 'dateTime.iso8601');
         $aResult['date_created_gmt'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp(), 1), 'dateTime.iso8601');
         $aResult['postid'] = $this->getId();
     } else {
         $aEnclosures = array();
         foreach ($this->getImages() as $oImage) {
             $oDocument = $oImage->getDocument();
             $aEnclosures[] = array('length' => $oDocument->getDataSize(), 'type' => $oDocument->getMimetype(), 'url' => LinkUtil::absoluteLink($oDocument->getLink(), null, LinkUtil::isSSL()));
         }
         $aResult['enclosure'] = $aEnclosures;
     }
     return $aResult;
 }
Пример #3
0
/**
 * 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);
}
Пример #4
0
/**
 * metaWeblog.getRecentPosts
 *
 * @param array $params Contains blog id, username, password, and number of posts
 */
function metaweblog_getRecentPosts($params)
{
    global $xmlrpcerruser;
    $conv = $params->getParam(0);
    $blogid = $conv->scalarval();
    $conv = $params->getParam(1);
    $user = $conv->scalarval();
    $conv = $params->getParam(2);
    $pass = $conv->scalarval();
    $conv = $params->getParam(3);
    $num = $conv->scalarval();
    // Check password
    $login = pivotx_get_userid($user, $pass);
    $uid = $login['uid'];
    if ($uid != -1) {
        // Check blog permissions.
        if (pivotx_user_blog_check($uid, $blogid)) {
            $postlist = pivotx_recent($blogid, $num);
        } else {
            $err = "User {$user} does not have access to any category in blog {$blogid}";
        }
    } else {
        $err = $login['err'];
    }
    if ($err) {
        return new xmlrpcresp(0, $xmlrpcerruser + 1, $err);
    } else {
        // Encode each entry of the array.
        foreach ($postlist as $entry) {
            // convert the date
            list($yr, $mo, $da, $ho, $mi) = explode("-", $entry['date']);
            $unixtime = mktime($ho, $mi, 0, $mo, $da, $yr);
            $isoString = iso8601_encode($unixtime);
            $date = new xmlrpcval($isoString, "dateTime.iso8601");
            $userid = new xmlrpcval($entry['userid']);
            $content = new xmlrpcval($entry['content']);
            $postid = new xmlrpcval($entry['postid']);
            $title = new xmlrpcval($entry['title']);
            $description = new xmlrpcval($entry['description']);
            $link = new xmlrpcval($entry['link']);
            $permalink = new xmlrpcval($entry['permalink']);
            $cat_arr = php_xmlrpc_encode($entry['categories']);
            $encode_arr = array('dateCreated' => $date, 'userid' => $userid, 'postid' => $postid, 'title' => $title, 'description' => $description, 'link' => $link, 'permaLink' => $permalink, 'categories' => $cat_arr);
            $xmlrpcpostarr[] = new xmlrpcval($encode_arr, "struct");
            // $xmlrpcpostarr[] = php_xmlrpc_encode($encode_arr);
        }
        $myResp = new xmlrpcval($xmlrpcpostarr, "array");
        return new xmlrpcresp($myResp);
    }
}
Пример #5
0
function getPageList($xmlrpcmsg)
{
    $sql = e107::getDb();
    $blogid = $xmlrpcmsg->getParam(0)->scalarval();
    $username = $xmlrpcmsg->getParam(1)->scalarval();
    $password = $xmlrpcmsg->getParam(2)->scalarval();
    if (userLogin($username, $password, '5') == true) {
        $structArray = array();
        $query = 'SELECT 
                 p.*,
                 u.user_id,
                 u.user_name
              FROM `#page` AS p 
              LEFT JOIN `#user` AS u ON u.user_id = p.page_author
              ORDER BY p.page_datestamp DESC 
              LIMIT ' . $numpages;
        $sql->db_Select_gen($query);
        while ($row = $sql->db_Fetch()) {
            $structArray[] = new xmlrpcval(array('page_id' => new xmlrpcval($row['page_id'], 'string'), 'page_title' => new xmlrpcval($row['page_title'], 'string'), 'page_parent_title' => new xmlrpcval('', 'string'), 'date_created_gmt' => new xmlrpcval('', 'string'), 'dateCreated' => new xmlrpcval(iso8601_encode($row['page_datestamp']), 'dateTime.iso8601')), 'struct');
        }
        return new xmlrpcresp(new xmlrpcval($structArray, 'array'));
        // Return type is struct[] (array of struct)
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 1, 'Login Failed');
    }
}
Пример #6
0
 public function testDateTime()
 {
     $time = time();
     $t1 = new xmlrpcval($time, 'dateTime.iso8601');
     $t2 = new xmlrpcval(iso8601_encode($time), 'dateTime.iso8601');
     $this->assertEquals($t1->serialize(), $t2->serialize());
     if (class_exists('DateTime')) {
         $datetime = new DateTime();
         // skip this test for php 5.2. It is a bit harder there to build a DateTime from unix timestamp with proper TZ info
         if (is_callable(array($datetime, 'setTimestamp'))) {
             $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601');
             $this->assertEquals($t1->serialize(), $t3->serialize());
         }
     }
 }
Пример #7
0
/**
 * 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);
}
Пример #8
0
 function testDateTime()
 {
     $time = time();
     $t1 = new xmlrpcval($time, 'dateTime.iso8601');
     $t2 = new xmlrpcval(iso8601_encode($time), 'dateTime.iso8601');
     $this->assertEquals($t1->serialize(), $t2->serialize());
     if (class_exists('DateTime')) {
         $datetime = new DateTime();
         $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601');
         $this->assertEquals($t1->serialize(), $t3->serialize());
     }
 }
Пример #9
0
function getPageInfo($params)
{
    $revision = _getPageRevision($params);
    if (!$revision) {
        return NoSuchPage();
    }
    $name = short_string($revision->getPageName());
    $version = new xmlrpcval($revision->getVersion(), "int");
    $lastmodified = new xmlrpcval(iso8601_encode($revision->get('mtime'), 0), "dateTime.iso8601");
    $author = short_string($revision->get('author'));
    return new xmlrpcresp(new xmlrpcval(array('name' => $name, 'lastModified' => $lastmodified, 'version' => $version, 'author' => $author), "struct"));
}
Пример #10
0
function getUploadedFileInfo($params)
{
    // localpath is the relative part after "Upload:"
    $ParamPath = $params->getParam(0);
    $localpath = short_string_decode($ParamPath->scalarval());
    preg_replace("/^[\\ \\/ \\.]/", "", $localpath);
    // strip hacks
    $file = getUploadFilePath() . $localpath;
    if (file_exists($file)) {
        $size = filesize($file);
        $lastmodified = filemtime($file);
    } else {
        $size = 0;
        $lastmodified = 0;
    }
    return new xmlrpcresp(new xmlrpcval(array('lastModified' => new xmlrpcval(iso8601_encode($lastmodified, 1), "dateTime.iso8601"), 'size' => new xmlrpcval($size, "int")), "struct"));
}
Пример #11
0
	protected function buildStruct($row, $mt = false)
	{
		$date = iso8601_encode(strtotime($row->created), 0);

		if ($mt)
		{
			$xmlArray = array(
				'userid'  => new xmlrpcval($row->created_by, 'string'),
				'dateCreated' => new xmlrpcval($date, 'dateTime.iso8601'),
				'postid'  => new xmlrpcval($row->id, 'string'),
				'title'   => new xmlrpcval($row->title, 'string'),
			);
		}
		else
		{

			$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->id, $row->catid), false, 2);
			$xmlArray = array(
				'userid'  => new xmlrpcval($row->created_by, 'string'),
				'dateCreated' => new xmlrpcval($date, 'dateTime.iso8601'),
				'postid'  => new xmlrpcval($row->id, 'string'),
				'description' => new xmlrpcval($row->introtext, 'string'),
				'title'   => new xmlrpcval($row->title, 'string'),
				'wp_slug' => new xmlrpcval($row->alias, 'string'),
				'mt_basename' => new xmlrpcval($row->alias, 'string'),
				'categories'  => new xmlrpcval(array(new xmlrpcval($row->category_title, 'string')), 'array'),
				'link'  => new xmlrpcval($link, 'string'),
				'permaLink' => new xmlrpcval($link, 'string'),
				'mt_excerpt' => new xmlrpcval($row->metadesc, 'string'),
				'mt_text_more'  => new xmlrpcval($row->fulltext, 'string'),
				'mt_allow_comments' => new xmlrpcval('1', 'int'),
				'mt_allow_pings' => new xmlrpcval('0', 'int'),
				'mt_convert_breaks' => new xmlrpcval('', 'string'),
				'mt_keywords'   => new xmlrpcval($row->metakey, 'string')
			);
		}

		$xmlObject = new xmlrpcval($xmlArray, 'struct');
		return array(true, $xmlObject);
	}
Пример #12
0
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"));
}
Пример #13
0
 /**
  * implements <i>samurai.SessionInitiate</i>
  *
  * @param string $LocalUri as SIP-URI
  * @param string $RemoteUri as SIP-URI
  * @param string $TOS Type of service as defined in $availableTOS
  * @param string $Content depends on TOS
  * @param dateTime $schedule as unix timestamp
  *
  * @return string SessionID, if available
  *
  * @throws sipgateAPI_Server_Exception on Server responses != 200 OK
  */
 protected function samurai_SessionInitiate($LocalUri, $RemoteUri, $TOS, $Content, $Schedule = NULL)
 {
     if (isset($LocalUri)) {
         $val_a["LocalUri"] = new xmlrpcval($LocalUri);
     }
     if (isset($RemoteUri)) {
         $val_a["RemoteUri"] = new xmlrpcval($RemoteUri);
     } else {
         throw new sipgateAPI_Exception("No RemoteUri");
     }
     if (isset($TOS)) {
         $val_a["TOS"] = new xmlrpcval($TOS);
     } else {
         throw new sipgateAPI_Exception("No valid TOS");
     }
     if (isset($Content)) {
         $val_a["Content"] = new xmlrpcval($Content);
     }
     if (isset($Schedule)) {
         $val_a["Schedule"] = new xmlrpcval(iso8601_encode($Schedule), "dateTime.iso8601");
     }
     $val_s = new xmlrpcval();
     $val_s->addStruct($val_a);
     $v = array();
     $v[] = $val_s;
     // create message
     $m = new xmlrpcmsg('samurai.SessionInitiate', $v);
     // send message
     $r = $this->client->send($m);
     if (!$r->faultCode()) {
         $php_r = php_xmlrpc_decode($r->value());
         return $php_r["SessionID"];
     } else {
         throw new sipgateAPI_Server_Exception($r->faultString(), $r->faultCode());
     }
 }
Пример #14
0
 function _do_syncwiki(&$request, $args)
 {
     global $charset;
     longer_timeout(240);
     if (!function_exists('wiki_xmlrpc_post')) {
         include_once "lib/XmlRpcClient.php";
     }
     $userid = $request->_user->_userid;
     $dbh = $request->getDbh();
     $merge_point = $dbh->get('mergepoint');
     if (empty($merge_point)) {
         $page = $dbh->getPage("ReleaseNotes");
         // this is usually the latest official page
         $last = $page->getCurrentRevision(false);
         $merge_point = $last->get("mtime");
         // for testing: 1160396075
         $dbh->set('mergepoint', $merge_point);
     }
     //TODO: remote auth, set session cookie
     $pagelist = wiki_xmlrpc_post('wiki.getRecentChanges', iso8601_encode($merge_point, 1), $args['url'], $args);
     $html = HTML();
     //$html->pushContent(HTML::div(HTML::em("check RPC2 interface...")));
     if (gettype($pagelist) === "array") {
         //$request->_deferredPageChangeNotification = array();
         $request->discardOutput();
         StartLoadDump($request, _("Syncing this PhpWiki"));
         PrintXML(HTML::strong(fmt("Download all externally changed sources.")));
         echo "<br />\n";
         PrintXML(fmt("Retrieving from external url %s wiki.getRecentChanges(%s)...", $args['url'], iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         $ouriter = $dbh->mostRecent(array('since' => $merge_point));
         //$ol = HTML::ol();
         $done = array();
         foreach ($pagelist as $ext) {
             $reaction = _("<unknown>");
             // compare existance and dates with local page
             $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
             // TODO: urldecode ???
             $name = utf8_decode($ext['name']);
             $our = $dbh->getPage($name);
             $done[$name] = 1;
             $ourrev = $our->getCurrentRevision(false);
             $rel = '<=>';
             if (!$our->exists()) {
                 // we might have deleted or moved it on purpose?
                 // check date of latest revision if there's one, and > mergepoint
                 if ($ourrev->getVersion() > 1 and $ourrev->get('mtime') > $merge_point) {
                     // our was deleted after sync, and changed after last sync.
                     $this->_addConflict('delete', $args, $our, $extdate);
                     $reaction = _(" skipped") . " (" . "locally deleted or moved" . ")";
                 } else {
                     $reaction = $this->_import($args, $our, $extdate);
                 }
             } else {
                 $ourdate = $ourrev->get('mtime');
                 if ($extdate > $ourdate and $ourdate < $merge_point) {
                     $rel = '>';
                     $reaction = $this->_import($args, $our, $extdate);
                 } elseif ($extdate > $ourdate and $ourdate >= $merge_point) {
                     $rel = '>';
                     // our is older then external but newer than last sync
                     $reaction = $this->_addConflict('import', $args, $our, $extdate);
                 } elseif ($extdate < $ourdate and $extdate < $merge_point) {
                     $rel = '>';
                     $reaction = $this->_export($args, $our);
                 } elseif ($extdate < $ourdate and $extdate >= $merge_point) {
                     $rel = '>';
                     // our is newer and external is also newer
                     $reaction = $this->_addConflict('export', $args, $our, $extdate);
                 } else {
                     $rel = '==';
                     $reaction = _("same date");
                 }
             }
             /*$ol->pushContent(HTML::li(HTML::strong($name)," ",
               $extdate,"<=>",$ourdate," ",
               HTML::strong($reaction))); */
             PrintXML(HTML::strong($name), " ", $extdate, " {$rel} ", $ourdate, " ", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
         //$html->pushContent($ol);
     } else {
         $html->pushContent("xmlrpc error:  wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist);
         trigger_error("xmlrpc error:  wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist, E_USER_WARNING);
         EndLoadDump($request);
         return $this->error($html);
     }
     if (empty($args['noexport'])) {
         PrintXML(HTML::strong(fmt("Now upload all locally newer pages.")));
         echo "<br />\n";
         PrintXML(fmt("Checking all local pages newer than %s...", iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         while ($our = $ouriter->next()) {
             $name = $our->getName();
             if ($done[$name]) {
                 continue;
             }
             $reaction = _(" skipped");
             $ext = wiki_xmlrpc_post('wiki.getPageInfo', $name, $args['url']);
             if (is_array($ext)) {
                 $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
                 $ourdate = $our->get('mtime');
                 if ($extdate < $ourdate and $extdate < $merge_point) {
                     $reaction = $this->_export($args, $our);
                 } elseif ($extdate < $ourdate and $extdate >= $merge_point) {
                     // our newer and external newer
                     $reaction = $this->_addConflict($args, $our, $extdate);
                 }
             } else {
                 $reaction = 'xmlrpc error';
             }
             PrintXML(HTML::strong($name), " ", $extdate, " < ", $ourdate, " ", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
         PrintXML(HTML::strong(fmt("Now upload all locally newer uploads.")));
         echo "<br />\n";
         PrintXML(fmt("Checking all local uploads newer than %s...", iso8601_encode($merge_point, 1)));
         echo "<br />\n";
         $this->_fileList = array();
         $prefix = getUploadFilePath();
         $this->_dir($prefix);
         $len = strlen($prefix);
         foreach ($this->_fileList as $path) {
             // strip prefix
             $file = substr($path, $len);
             $ourdate = filemtime($path);
             $oursize = filesize($path);
             $reaction = _(" skipped");
             $ext = wiki_xmlrpc_post('wiki.getUploadedFileInfo', $file, $args['url']);
             if (is_array($ext)) {
                 $extdate = iso8601_decode($ext['lastModified']->scalar, 1);
                 $extsize = $ext['size'];
                 if (empty($extsize) or $extdate < $ourdate) {
                     $timeout = $oursize * 0.0002;
                     // assume 50kb/sec upload speed
                     $reaction = $this->_upload($args, $path, $timeout);
                 }
             } else {
                 $reaction = 'xmlrpc error wiki.getUploadedFileInfo not supported';
             }
             PrintXML(HTML::strong($name), " ", "{$extdate} ({$extsize}) < {$ourdate} ({$oursize})", HTML::strong($reaction), HTML::br());
             $request->chunkOutput();
         }
     }
     $dbh->set('mergepoint', time());
     EndLoadDump($request);
     return '';
     //$html;
 }
Пример #15
0
function run_stress_tests($server, $debug = 0, $output = null)
{
    global $wiki_dmap;
    run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported");
    // of the last day:
    run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time() - 86400, 1));
    /* ... */
}
Пример #16
0
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$v = new xmlrpcval(array(new xmlrpcval("ABCDEFHIJ"), new xmlrpcval(1234, 'int'), new xmlrpcval(1, 'boolean')), "array");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$v = new xmlrpcval(array("thearray" => new xmlrpcval(array(new xmlrpcval("ABCDEFHIJ"), new xmlrpcval(1234, 'int'), new xmlrpcval(1, 'boolean'), new xmlrpcval(0, 'boolean'), new xmlrpcval(true, 'boolean'), new xmlrpcval(false, 'boolean')), "array"), "theint" => new xmlrpcval(23, 'int'), "thestring" => new xmlrpcval("foobarwhizz"), "thestruct" => new xmlrpcval(array("one" => new xmlrpcval(1, 'int'), "two" => new xmlrpcval(2, 'int')), "struct")), "struct");
print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
$w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
$w = new xmlrpcval("Mary had a little lamb,\nWhose fleece was white as snow,\nAnd everywhere that Mary went\nthe lamb was sure to go.\n\nMary had a little lamb\nShe tied it to a pylon\nTen thousand volts went down its back\nAnd turned it into nylon", "base64");
print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
$f->method('');
$f->addParam(new xmlrpcval("41", "int"));
print "<h3>Testing request serialization</h3>\n";
$op = $f->serialize();
print "<PRE>" . htmlentities($op) . "</PRE>";
print "<h3>Testing ISO date format</h3><pre>\n";
$t = time();
$date = iso8601_encode($t);
print "Now is {$t} --> {$date}\n";
print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
$tb = iso8601_decode($date);
print "That is to say {$date} --> {$tb}\n";
print "Which comes out at " . iso8601_encode($tb) . "\n";
print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
print "</pre>\n";
?>
<hr/>
<em>$Id: vardemo.php,v 1.4 2006/12/28 16:10:42 milosch Exp $</em>
</body>
</html>
Пример #17
0
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);
}