Example #1
0
function readPage($username = NULL, $password = NULL, $id = NULL, $loginToken = NULL, $editToken = NULL, $title = NULL, $revisionID = NULL)
{
    $__pcpServer = new PCPServer();
    $__userCredentials = new PCPUserCredentials($username, $password, $id, $loginToken, $editToken);
    $_REQUEST = array();
    $__pcpServer->login($__userCredentials);
    //	var_dump($__userCredentials,$title, $revisionID);
    //	die;
    return simplexml_load_string(PCPUtil::createXMLResponse($__pcpServer->readPage($__userCredentials, $title, $revisionID)->toXML()), 'SimpleXMLElement', LIBXML_NOCDATA);
}
Example #2
0
 public function movePage(PCPUserCredentials $uc = NULL, $fromTitle = NULL, $toTitle = NULL, $movetalk = false, $noredirect = false)
 {
     // check if new user credentials are set
     if ($userCredentials != NULL && $this->usedUC->un != $userCredentials->un) {
         $this->usedUC = $userCredentials;
         $this->login();
     }
     if (!isset($fromTitle) || !isset($toTitle)) {
         return false;
     }
     // get the edit token for the page
     $this->getEditToken(NULL, urldecode($fromTitle));
     // if movetalk is not set, do not use it
     if ($movetalk) {
         $this->queryMovePage = array_merge($this->queryMovePage, array('movetalk'));
     }
     if ($noredirect) {
         $this->queryMovePage = array_merge($this->queryMovePage, array('noredirect'));
     }
     foreach (PCPUtil::replaceInHash($this->queryMovePage, array(urlencode($fromTitle), urlencode($toTitle), urlencode($this->usedUC->editToken))) as $__parameter => $__parameterValue) {
         $__parameters .= $__parameter . '=' . $__parameterValue . '&';
     }
     $__request = $this->targetWiki->url . '/' . $this->targetWiki->api . '?' . $__parameters . $this->_returnFormat;
     // sets the return format
     $__curlHandler = curl_init();
     curl_setopt($__curlHandler, CURLOPT_URL, $__request);
     if ($this->targetWiki->proxyAddr != "") {
         curl_setopt($__curlHandler, CURLOPT_PROXY, $this->targetWiki->proxyAddr);
     }
     curl_setopt($__curlHandler, CURLOPT_HEADER, false);
     // don't return the header in teh result
     curl_setopt($__curlHandler, CURLOPT_COOKIEJAR, $this->cookieFile);
     curl_setopt($__curlHandler, CURLOPT_COOKIEFILE, $this->cookieFile);
     // set the file where cookies from which cookies are being read
     curl_setopt($__curlHandler, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($__curlHandler, CURLOPT_POST, 1);
     // use the POST method
     #curl_setopt($__curlHandler, CURLOPT_POSTFIELDS, "wpName=".$this->usedUC->un."&wpLoginToken=".$this->usedUC->lgToken);
     $__serializedResult = curl_exec($__curlHandler);
     curl_close($__curlHandler);
     $__result = unserialize($__serializedResult);
     return $__result;
 }
Example #3
0
 public function movePage(PCPUserCredentials $userCredentials = NULL, $fromTitle = NULL, $toTitle = NULL, $movetalk = false, $noredirect = false)
 {
     if ($fromTitle == NULL || $toTitle == NULL) {
         // trigger an error?
         return false;
     }
     $this->getEditToken($userCredentials, $fromTitle);
     // if movetalk is not set, do not use it
     if ($movetalk) {
         $this->queryMovePage = array_merge($this->queryMovePage, array('movetalk'));
     }
     if ($noredirect) {
         $this->queryMovePage = array_merge($this->queryMovePage, array('noredirect'));
     }
     $__request = new FauxRequest(PCPUtil::replaceInHash($this->queryMovePage, array($fromTitle, $toTitle, $this->usedUC->editToken)));
     $__api = new ApiMain($__request, true);
     $__api->execute();
     //		$__result =& $__api->GetResultData();
     //		return true;
     return $__api->GetResultData();
 }