コード例 #1
0
ファイル: wikibot.classes.php プロジェクト: Riamse/cluebotng
 /**
  * Rollback an edit.
  * @param $title Page title to rollback.
  * @param $user Username of last edit to the page to rollback.
  * @param $reason Reason to rollback.  If null, default is generated.  (Default null)
  * @param $token Rollback token to use.  If null, it is fetched.  (Default null)
  * @param $bot Whether or not to mark as bot.  (Default true)
  * @return HTML or false if failure.
  * @deprecated
  * @see wikipediaapi::rollback
  **/
 function rollback($title, $user, $reason = null, $token = null, $bot = true)
 {
     if ($token == null or !$token) {
         $wpapi = new wikipediaapi();
         $wpapi->apiurl = str_replace('index.php', 'api.php', $this->indexurl);
         $token = $wpapi->revisions($title, 1, 'older', false, null, true, true);
         if ($token[0]['user'] == $user) {
             //					echo 'Token: '; print_r($token); echo "\n\n";
             $token = $token[0]['rollbacktoken'];
         } else {
             return false;
         }
     }
     $x = $this->http->get($this->indexurl . '?title=' . urlencode($title) . '&action=rollback&from=' . urlencode($user) . '&token=' . urlencode($token) . ($reason != null ? '&summary=' . urlencode($reason) : '') . '&bot=' . ($bot == true ? '1' : '0'));
     if (!preg_match('/action complete/iS', $x)) {
         return false;
     }
     return $x;
 }