User:MPUploadBot/Main Page bot Source

The following is automatically generated by X!'s adminbot.

Bot Hierarchy

 * bot.php
 * bot2.php
 * classes.php
 * adminpass.php
 * nickpass.php
 * Images/
 * tmp/

Source code
&lt;?php

/* Copyright (C) 2008 Soxred93 - http://en.wikipedia.org/wiki/User:X!

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.



include( &quot;./functions.php&quot; );

initialize;

checkEnable;

postSource;

purgeCache;

deleteImages;

process;

process('Main Page');

?&gt;

&lt;?php

/* Copyright (C) 2008 Soxred93 - http://en.wikipedia.org/wiki/User:X!

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.



include( &quot;./functions.php&quot; );

initialize;

checkEnable;

purgeCache;

//Get to the RC feed while(1) { $feed = fsockopen('irc.wikimedia.org',6667,$ircerrno,$ircerrstr,30); if (!$feed) { sleep(10); $feed = fsockopen('irc.wikimedia.org',6667,$ircerrno,$ircerrstr,30); if (!$feed) die($feederrstr.' ('.$feederrno.')'); } 		$feedchannel = '#en.wikipedia'; fwrite($feed,'USER SoxAdminBot &quot;1&quot; &quot;1&quot; :SoxBot Wikipedia Bot.'.&quot;\n&quot;); fwrite($feed,'NICK SoxAdminBot'.&quot;\n&quot;); while (!feof($feed)) { $rawline = fgets($feed,1024); $line = str_replace(array(&quot;\n&quot;,&quot;\r&quot;,&quot;\002&quot;),'',$rawline); $line = preg_replace('/\003(\d\d?(,\d\d?)?)?/','',$line); //echo 'FEED: '.$line.&quot;\n&quot;; if (!$line) { fclose($feed); break; } $linea= explode(' ',$line,4);

if (strtolower($linea[0]) == 'ping') { fwrite($feed,'PONG '.$linea[1].&quot;\n&quot;); } elseif (($linea[1] == '376') or ($linea[1] == '422')) { fwrite($feed,'JOIN '.$feedchannel.&quot;\n&quot;); } elseif ((strtolower($linea[1]) == 'privmsg') and (strtolower($linea[2]) == strtolower($feedchannel))) { $message = substr($linea[3],1); if (preg_match('/^\[\[((Talk|User|Wikipedia|Image|File|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?title=[^&amp;]*&amp;diff=(\d*)&amp;oldid=(\d*)|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S',$message,$m)) {				$messagereceived = microtime(1);				$change['namespace'] = $m[1];				$change['title'] = $m[5];				$change['flags'] = $m[6];				$change['url'] = $m[7];				$change['revid'] = $m[8];				$change['old_revid'] = $m[9];				$change['user'] = $m[10];				$change['length'] = $m[12];				$change['comment'] = $m[13];				//echo $change['namespace'];				if ($change['namespace'] == 'Wikipedia:' || $change['namespace'] == 'Template:') {					echo $change['title'].&quot;\n&quot;;					if ($change['title'] == 'Today\'s featured article/'.date('F j, Y') || $change['title'] == 'Did you know' || $change['title'] == 'In the news' || $change['title'] == 'Selected anniversaries'.date('F j') || $change['title'] == 'POTD protected/'.date('Y-m-d') ) {						process($change['namespace'].$change['title']);					}				}			}		}	} }

?&gt;

&lt;?php

include('./classes.php');

//Setup the classes $http 	= new http; $wpapi = new wikipediaapi; $wpq   = new wikipediaquery; $wpi   = new wikipediaindex; $user  = 'MPUploadBot'; $trialuser  = 'X!';

function initialize { global $wpapi, $user, $trialuser; include( './adminpass.php' );//Password

echo &quot;Logging in...\n&quot;;

$wpapi-&gt;login( $trialuser,$pass );//Login unset( $pass ); //Security reasons return $user; }

function checkEnable { global $wpq, $user; echo &quot;\nChecking if bot is enabled...\n&quot;; $run = $wpq-&gt;getpage( 'User:'.$user.'/Run' ); if ( !preg_match( '/(yes|enable|true)/iS',$run ) ) { irc(&quot;!admin@commons - X!'s adminbot is disabled. Please make sure all images on the Main Page are protected.&quot;, '#wikimedia-commons'); irc(&quot;!admin - X!'s adminbot is disabled. Please make sure all images on the Main Page are protected.&quot;, '#wikipedia-en-admins'); irc(&quot;!admin - X!'s adminbot is disabled. Please make sure all images on the Main Page are protected.&quot;, '#wikipedia-en-alerts'); die( &quot;Bot Disabled\n&quot; ); }	unset( $run ); return true; }

function postSource { //Post the source code global $wpi, $user; echo &quot;\nPosting source code...\n&quot;; $wpi-&gt;forcepost('User:'.$user.'/Main Page bot Source',               &quot;The following is automatically generated by User:X!'s adminbot.\n\n&quot; .                &quot;==Bot Hierarchy==\n*bot.php\n*bot2.php\n*classes.php\n*adminpass.php\n*nickpass.php\n*Images/\n*tmp/\n\n&quot; .                &quot;==Source code==\n&quot; .                &quot;\n&lt;pre&gt;&quot;.htmlentities(file_get_contents('./bot.php')).&quot;&lt;/pre&gt;\n\n&quot; .                &quot;\n&lt;pre&gt;&quot;.htmlentities(file_get_contents('./bot2.php')).&quot;&lt;/pre&gt;\n\n&quot; .                &quot;\n&lt;pre&gt;&quot;.htmlentities(file_get_contents('./functions.php')).&quot;&lt;/pre&gt;\n\n&quot; .                &quot;\n&lt;pre&gt;&quot;.htmlentities(file_get_contents('./classes.php')).&quot;&lt;/pre&gt;\n&quot;,                'Automated source upload.'); //die; }

function purgeCache { global $http; echo &quot;\nPurging cache...\n&quot;; $check = $http-&gt;get( 'http://en.wikipedia.org/w/api.php?action=purge&amp;titles=Main_Page&amp;format=php' ); $check = unserialize( $check ); print_r($check); if ( !isset( $check['purge'][0]['purged'] ) ) { die( &quot;An error occured while logging in.\n&quot; ); } }

function deleteImages { global $http, $wpapi, $wpq, $wpi; echo &quot;\nFinding images not used anymore...\n&quot;; $currlist = file_get_contents('./images.txt'); $currlist = explode(&quot;\n&quot;, $currlist); sleep(3); if ($currlist[0] != '') { echo &quot;\nImages are: &quot;.implode(', ', $currlist).&quot;\n&quot;; foreach( $currlist as $image ) { if ($image == '') { continue; } $titles = array; $continue = null; $iu = imageusage($image,$continue); foreach ($iu as $data) { $titles[] = $data['title']; } while (isset($iu[4999])) { $iu = imageusage($image,$continue); foreach ($iu as $data) { $titles[] = $data['title']; } }			print_r($titles); sleep(3); if (!in_array('Main Page', $titles) &amp;&amp; !in_array('Wikipedia:Main Page/Tomorrow', $titles)) { if ( $wpq-&gt;getpageid( $image ) === -1 ) { echo &quot;\nAlready deleted...\n&quot;; remtext($image); continue; }				$list = getTemplates($image); print_r($list); if (in_array('Template:C-uploaded', $list)) { echo &quot;\nDeleting $image...\n&quot;; $wpi-&gt;delete($image, ' - BOT EDIT: See Bots/Requests for approval/SoxBot 11: No longer on Main Page'); unlink('./Images/'.$image);//Remove the local copy, to save space sleep(3); if (delrevs($image) === true) { echo &quot;\nRestoring $image...\n&quot;; undelete($image); }					remtext($image); }			}		}	} }

function remtext($image) { $file = file('./images.txt'); echo &quot;Removing $image from images.txt.\n&quot;; print_r($file); foreach ($file as $key =&gt; $value) { if ($value == $image) { unset($file[$key]); }	}	print_r($file); foreach ($file as $line) { file_put_contents('./images.txt', $line.&quot;\n&quot;); } }

function process($title = 'Wikipedia:Main Page/Tomorrow') { global $wpq, $wpapi, $wpi, $http; $list = exclude(getImages( $title )); //print_r($list); foreach( $list as $image ) { $image = &quot;Image:&quot;.$image;

if ( $wpq-&gt;getpageid( $image ) !== -1 ) { echo &quot;\nExists locally...\n&quot;;continue; } if ( checkEdit( $image ) === false ) { echo &quot;\nEdited in last 24 hours...\n&quot;;continue; } if ( fullprotect( $image ) === true ) { echo &quot;\nProtected locally on Commons...\n&quot;;continue; } echo &quot;\nGetting url of $image...\n&quot;; $url = getUrl( $image ); echo &quot;\nDownloading $image...\n&quot;; downloadImage( $url, './Images/'.$image ); $text = $http-&gt;get( 'http://commons.wikimedia.org/w/api.php?action=query&amp;prop=revisions&amp;format=php&amp;titles='.urlencode($image).'&amp;rvprop=content' ); $text = unserialize( $text ); $text = $text['query']['pages']; foreach ($text as $key =&gt; $data) { $text2 = $data['revisions'][0]['*']; }		$text2 = str_ireplace(&quot;&quot;, &quot;[[commons:&quot;, $text2);//Replace wikilinks with interwiki links		$text = &quot;\n&lt;includeonly&gt;BOT EDIT: See [[Wikipedia:Bots/Requests for approval/SoxBot 11.&lt;/includeonly&gt;\n\n\n&quot;.$text2;		echo &quot;\nUploading $image...\n&quot;;		$image2 = explode(':', $image);		if ( in_array( $image, file( './images.txt' ) ) ) { echo &quot;\nHmm, why isn't it uploaded yet?\n&quot;; }		$wpi-&gt;upload($image2[1], './Images/'.$image, $text);		$wpi-&gt;protect($image, ' - BOT EDIT: See Bots/Requests for approval/SoxBot 11. Protecting image on Main Page.');		file_put_contents('./images.txt', file_get_contents('./images.txt').$image.&quot;\n&quot;);//Add it to the list of protected images		sleep(3);	} }

//Checks to see if it was edited in the last 10 minutes function checkEdit($image) { echo &quot;\nChecking if $image was edited in the last 24 hours...\n&quot;; if (lastedit($image) &gt; strtotime('-24 hours')) { irc(&quot;!admin@commons - Please protect $image, as it is on the Main Page.&quot;, '#wikimedia-commons'); irc(&quot;!admin - Please upload $image from Commons, as it is on the Main Page.&quot;, '#wikipedia-en-admins'); irc(&quot;!admin - Please upload $image from Commons, as it is on the Main Page.&quot;, '#wikipedia-en-alerts'); return false; }	else { return true; } }

function lastEdit($page) { echo &quot;\nFinding last edit to $page...\n&quot;; //Returns the timestamp of the last edit to $page global $http, $wpapi, $wpq; $x = $http-&gt;get('http://commons.wikimedia.org/w/api.php?action=query&amp;prop=revisions&amp;titles='.urlencode($page).'&amp;rvlimit=1&amp;rvprop=timestamp&amp;format=php'); $x = unserialize($x); $timestamp = $x['query']['pages'][$wpq-&gt;getpageid($page)]['revisions'][0]['timestamp']; return strtotime($timestamp); }

function downloadImage($url,$local) { //Downloads the image to upload $out = fopen($local, 'w'); $ch = curl_init; curl_setopt($ch, CURLOPT_FILE, $out); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); curl_close($ch); }

function getUrl($image) { //Returns the url of the Commons image global $http, $wpapi, $wpq; $x = $http-&gt;get('http://commons.wikimedia.org/w/api.php?action=query&amp;titles='.urlencode($image).'&amp;prop=imageinfo&amp;iiprop=url&amp;iilimit=1&amp;format=php'); $x = unserialize($x); $file = $x['query']['pages']; foreach ($file as $img) { $file = $img['imageinfo'][0]['url']; }	if (!$file) { die('Image not found'); }	return $file; }

function imageusage($image, &amp;$continue = null) { //Returns an array with all pages that use $image global $http, $wpapi, $wpq; echo &quot;Getting image usage...\n&quot;; if ($continue != null) { $append = '&amp;iucontinue='.urlencode($continue); } else { $append = ''; }	$x = $http-&gt;get($wpapi-&gt;apiurl.'?action=query&amp;list=imageusage&amp;iutitle='.urlencode($image).'&amp;format=php&amp;iulimit=5000'.$append); $x = unserialize($x); $continue = $x['query-continue']['imageusage']['iucontinue']; return $x['query']['imageusage']; }

function getImages($page) { //Returns an array with all the images on $page global $http, $wpapi, $wpq; $x = $http-&gt;get($wpapi-&gt;apiurl.'?action=query&amp;titles='.urlencode($page).'&amp;prop=images&amp;imlimit=500&amp;format=php'); $x = unserialize($x); $id = $wpq-&gt;getpageid($page); foreach ($x['query']['pages'][$id]['images'] as $links) { $images[] = str_replace('Image:','',$links['title']); }	return $images; }

function getTemplates($page) { //Returns an array with all the templates on $page echo &quot;Getting templates...\n&quot;; global $http, $wpapi, $wpq; $x = $http-&gt;get($wpapi-&gt;apiurl.'?action=query&amp;titles='.urlencode($page).'&amp;prop=templates&amp;tllimit=500&amp;format=php'); $x = unserialize($x); foreach ($x['query']['pages'][$wpq-&gt;getpageid($page)]['templates'] as $links) { $templates[] = $links['title']; }	return $templates; }

function irc($message,$channel) { include('nickpass.php'); $nick = 'SoxBot'; $socket = fsockopen(&quot;irc.freenode.net&quot;, 6667, $en, $es, 30); if (!$socket) { echo 'Error: '.$es.' ('.$en.')'.&quot;\n&quot;; return false; }	fwrite($socket, 'USER '.$nick.' &quot;toolserver.org&quot; &quot;Main Page&quot; :'.$nick.&quot;\n&quot;); fwrite($socket, 'NICK '.$nick.&quot;\n&quot;); fwrite($socket, 'PASS '.$nickpass.&quot;\n&quot;); while (!feof($socket)) { $data = str_replace(array(&quot;\r&quot;,&quot;\n&quot;),'',fgets($socket,512)); $darr = explode(' ',$data); if (strtolower($darr[0]) == 'ping') { fwrite($socket, 'PONG '.$darr[1].&quot;\n&quot;); } elseif (($darr[1] == '376') or ($darr[1] == '422')) { fwrite($socket, 'JOIN '.$channel.&quot;\n&quot;); } elseif ((strtolower($darr[1]) == 'mode') and ((($darr[2]{0} == ':')?substr($darr[2],1):$darr[2]) == '+v') and (strtolower(($darr[3]{0} == ':')?substr($darr[3],1):$darr[3]) == strtolower($nick))) { fwrite($socket, 'PRIVMSG '.$channel.' :'.$message.&quot;\n&quot;); fwrite($socket, 'QUIT :No longer needed.'.&quot;\n&quot;); fclose($socket); }	}	return true; }

function exclude($list) { //Returns $list excluding anything listed on the exclude list global $http, $wpapi, $wpq, $user; $x = $wpq-&gt;getpage('User:X!/Exclude List.js'); //Get the exclude list $exclude = explode(chr(10), $x); foreach ($exclude as $e) { //Parse it			if (!preg_match('/^#/',$e)) { $exclude_list[] = $e; }		}		foreach ($list as $l) { $add = true; foreach ($exclude_list as $e) { if ($e == $l) { $add = false; break; }			}			if ($add) { $cleaned_list[] = $l; }		}		return $cleaned_list; }

function fullprotect($page) { //returns true if the page is full protected global $wpapi, $http, $wpq; $x = $http-&gt;get('http://commons.wikimedia.org/w/api.php?action=query&amp;titles='.urlencode($page).'&amp;prop=info&amp;inprop=protection&amp;format=php'); $x = unserialize($x); if ($x['query']['pages'][$wpq-&gt;getpageid($page)]['protection'][0]['level'] == 'sysop') { return true; }	else { return false; }	}

function delrevs($page) { global $wpapi, $http, $wpq; $x = $http-&gt;get('http://en.wikipedia.org/w/api.php?action=query&amp;list=deletedrevs&amp;titles='.urlencode($page).'&amp;format=php'); $x = unserialize($x); if (count($x['query']['deletedrevs'][0]['revisions']) &gt; 1) { return true; }	else { return false; }	}

function undelete($page) { global $wpapi, $http, $wpq, $user, $trialuser; $x = $http-&gt;get('http://en.wikipedia.org/w/api.php?action=query&amp;list=deletedrevs&amp;drprop=token|user&amp;titles='.urlencode($page).'&amp;format=php'); $x = unserialize($x); $token = htmlspecialchars($x['query']['deletedrevs'][0]['token']); $post = array; $users = $x['query']['deletedrevs'][0]['revisions']; $timestamps = array; foreach($users as $rev) { echo $rev['user']; if ($rev['user'] != $trialuser) { $timestamps[] = $rev['timestamp']; }	}	print_r($timestamps); $post['token'] = $token; $post['reason'] = ' - BOT EDIT: Restoring Wikipedia specific edits.'; $post['timestamps'] = implode(&quot;|&quot;, $timestamps); $http-&gt;post('http://en.wikipedia.org/w/api.php?action=undelete&amp;title='.urlencode($page).'&amp;format=php',$post); }

?&gt;

&lt;?PHP class http { private $ch; private $uid; public $postfollowredirs; public $getfollowredirs;

function data_encode ($data, $keyprefix = &quot;&quot;, $keypostfix = &quot;&quot;) { assert( is_array($data) ); $vars=null; foreach($data as $key=&gt;$value) { if(is_array($value)) $vars .= $this-&gt;data_encode($value, $keyprefix.$key.$keypostfix.urlencode(&quot;[&quot;), urlencode(&quot;]&quot;)); else $vars .= $keyprefix.$key.$keypostfix.&quot;=&quot;.urlencode($value).&quot;&amp;&quot;; }                       return $vars; }

function __construct { $this-&gt;ch = curl_init; $this-&gt;uid = dechex(rand(0,99999999)); curl_setopt($this-&gt;ch,CURLOPT_COOKIEJAR,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_COOKIEFILE,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_MAXCONNECTS,100); curl_setopt($this-&gt;ch,CURLOPT_CLOSEPOLICY,CURLCLOSEPOLICY_LEAST_RECENTLY_USED); $this-&gt;postfollowredirs = 0; $this-&gt;getfollowredirs = 1; }

function post ($url,$data) { //                     echo 'POST: '.$url.&quot;\n&quot;; $time = microtime(1); curl_setopt($this-&gt;ch,CURLOPT_URL,$url); curl_setopt($this-&gt;ch,CURLOPT_COOKIEJAR,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_COOKIEFILE,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_FOLLOWLOCATION,$this-&gt;postfollowredirs); curl_setopt($this-&gt;ch,CURLOPT_MAXREDIRS,10); curl_setopt($this-&gt;ch,CURLOPT_HEADER,0); curl_setopt($this-&gt;ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($this-&gt;ch,CURLOPT_TIMEOUT,30); curl_setopt($this-&gt;ch,CURLOPT_CONNECTTIMEOUT,10); curl_setopt($this-&gt;ch,CURLOPT_POST,1); //                     curl_setopt($this-&gt;ch,CURLOPT_POSTFIELDS, substr($this-&gt;data_encode($data), 0, -1) ); curl_setopt($this-&gt;ch,CURLOPT_POSTFIELDS, $data); $data = curl_exec($this-&gt;ch); //var_dump($data); //echo 'POST: '.$url.' ('.(microtime(1) - $time).' s) ('.strlen($data).&quot; b)\n&quot;; return $data; }

function get ($url) { //echo 'GET: '.$url.&quot;\n&quot;; $time = microtime(1); curl_setopt($this-&gt;ch,CURLOPT_URL,$url); curl_setopt($this-&gt;ch,CURLOPT_COOKIEJAR,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_COOKIEFILE,'./tmp/cookies.dat'); curl_setopt($this-&gt;ch,CURLOPT_FOLLOWLOCATION,$this-&gt;getfollowredirs); curl_setopt($this-&gt;ch,CURLOPT_MAXREDIRS,10); curl_setopt($this-&gt;ch,CURLOPT_HEADER,0); curl_setopt($this-&gt;ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($this-&gt;ch,CURLOPT_TIMEOUT,30); curl_setopt($this-&gt;ch,CURLOPT_CONNECTTIMEOUT,10); curl_setopt($this-&gt;ch,CURLOPT_HTTPGET,1); $data = curl_exec($this-&gt;ch); //var_dump($data); //echo 'GET: '.$url.' ('.(microtime(1) - $time).' s) ('.strlen($data).&quot; b)\n&quot;; return $data; }

function __destruct { curl_close($this-&gt;ch); //@unlink('/tmp/cluewikibot.cookies.dat'); }       }

class wikipediaquery { private $http; private $api; public $queryurl = 'http://en.wikipedia.org/w/query.php'; //Obsolete, but kept for compatibility purposes.

function __construct { global $__wp__http; if (!isset($__wp__http)) { $__wp__http = new http; }                       $this-&gt;http = &amp;$__wp__http; $this-&gt;api = new wikipediaapi; }               private function checkurl { $this-&gt;api-&gt;apiurl = str_replace('query.php','api.php',$this-&gt;queryurl); }               function getpage ($page) { $this-&gt;checkurl; //                     $ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=content&amp;format=php&amp;titles='.urlencode($page))); //                     foreach ($ret['pages'] as $page) { //                             return $page['content']['*']; //                     }                        $ret = $this-&gt;api-&gt;revisions($page,1,'older',true,null,true,false,false,false); return $ret[0]['*']; }

function getpageid ($page) { $this-&gt;checkurl; //                     $ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=content&amp;format=php&amp;titles='.urlencode($page))); //                     foreach ($ret['pages'] as $page) { //                             return $page['id']; //                     }                        $ret = $this-&gt;api-&gt;revisions($page,1,'older',false,null,true,false,false,false); return $ret['pageid']; }

function contribcount ($user) { $this-&gt;checkurl; //                     $ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=contribcounter&amp;format=php&amp;titles=User:'.urlencode($user))); //                     foreach ($ret['pages'] as $page) { //                             return $page['contribcounter']['count']; //                     }                        $ret = $this-&gt;api-&gt;users($user,1,null,true); if ($ret !== false) return $ret[0]['editcount']; return false; }       }

class wikipediaapi { private $http; public $apiurl = 'http://en.wikipedia.org/w/api.php';

function __construct { global $__wp__http; if (!isset($__wp__http)) { $__wp__http = new http; }                       $this-&gt;http = &amp;$__wp__http; }

function login ($user,$pass) { $data = $this-&gt;http-&gt;post($this-&gt;apiurl.'?action=login&amp;format=php',array('lgname' =&gt; $user, 'lgpassword' =&gt; $pass)); print_r(unserialize($data)); //                     if ($data) echo $data.&quot;\n\n&quot;; }

function getedittoken { $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;format=php&amp;prop=info&amp;intoken=edit&amp;titles=Main%20Page'); $x = unserialize($x); foreach ($x['query']['pages'] as $y) { return $y['edittoken']; }               }

function recentchanges ($count = 10,$namespace = null,$dir = 'older',$ts = null) { $append = ''; if ($ts !== null) { $append .= '&amp;rcstart='.urlencode($ts); } $append .= '&amp;rcdir='.urlencode($dir); if ($namespace !== null) { $append .= '&amp;rcnamespace='.urlencode($namespace); } $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=recentchanges&amp;rcprop=user|comment|flags|timestamp|title|ids|sizes&amp;format=php&amp;rclimit='.$count.$append); $x = unserialize($x); return $x['query']['recentchanges']; }

function search ($search,$limit = 10,$offset = 0,$namespace = 0,$what = 'text',$redirs = false) { $append = ''; if ($limit != null) $append .= '&amp;srlimit='.urlencode($limit); if ($offset != null) $append .= '&amp;sroffset='.urlencode($offset); if ($namespace != null) $append .= '&amp;srnamespace='.urlencode($namespace); if ($what != null) $append .= '&amp;srwhat='.urlencode($what); if ($redirs == true) $append .= '&amp;srredirects=1'; else $append .= '&amp;srredirects=0'; $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=search&amp;format=php&amp;srsearch='.urlencode($search).$append); $x = unserialize($x); return $x['query']['search']; }

function logs ($user = null,$title = null,$limit = 50,$type = null,$start = null,$end = null,$dir = 'older') { $append = ''; if ($user != null) $append.= '&amp;leuser='.urlencode($user); if ($title != null) $append.= '&amp;letitle='.urlencode($title); if ($limit != null) $append.= '&amp;lelimit='.urlencode($limit); if ($type != null) $append.= '&amp;letype='.urlencode($type); if ($start != null) $append.= '&amp;lestart='.urlencode($start); if ($end != null) $append.= '&amp;leend='.urlencode($end); if ($dir != null) $append.= '&amp;ledir='.urlencode($dir); $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;format=php&amp;list=logevents&amp;leprop=ids|title|type|user|timestamp|comment|details'.$append); $x = unserialize($x); return $x['query']['logevents']; }

function usercontribs ($user,$count = 50,&amp;$continue = null,$dir = 'older') { if ($continue != null) { $append = '&amp;ucstart='.urlencode($continue); } else { $append = ''; }                       $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;format=php&amp;list=usercontribs&amp;ucuser='.urlencode($user).'&amp;uclimit='.urlencode($count).'&amp;ucdir='.urlencode($dir).$append); $x = unserialize($x); $continue = $x['query-continue']['usercontribs']['ucstart']; return $x['query']['usercontribs']; }

function revisions ($page,$count = 1,$dir = 'older',$content = false,$revid = null,$wait = true,$getrbtok = false,$dieonerror = true,$redirects = false) { $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;prop=revisions&amp;titles='.urlencode($page).'&amp;rvlimit='.urlencode($count).'&amp;rvprop=timestamp|ids|user|comment'.(($content)?'|content':).'&amp;format=php&amp;meta=userinfo&amp;rvdir='.urlencode($dir).(($revid !== null)?'&amp;rvstartid='.urlencode($revid):).(($getrbtok == true)?'&amp;rvtoken=rollback':).(($redirects == true)?'&amp;redirects':)); $x = unserialize($x); if ($revid !== null) { $found = false; if (!isset($x['query']['pages']) or !is_array($x['query']['pages'])) { if ($dieonerror == true) die('No such page.'.&quot;\n&quot;); else return false; }                               foreach ($x['query']['pages'] as $data) { if (!isset($data['revisions']) or !is_array($data['revisions'])) { if ($dieonerror == true) die('No such page.'.&quot;\n&quot;); else return false; }                                       foreach ($data['revisions'] as $data2) if ($data2['revid'] == $revid) $found = true; unset($data,$data2); break; }

if ($found == false) { if ($wait == true) { sleep(1); return $this-&gt;revisions($page,$count,$dir,$content,$revid,false,$getrbtok,$dieonerror); } else { if ($dieonerror == true) die('Revision error.'.&quot;\n&quot;); }                               }                        }                        foreach ($x['query']['pages'] as $key =&gt; $data) { $data['revisions']['ns'] = $data['ns']; $data['revisions']['title'] = $data['title']; $data['revisions']['currentuser'] = $x['query']['userinfo']['name']; //                             $data['revisions']['currentuser'] = $x['query']['userinfo']['currentuser']['name']; $data['revisions']['continue'] = $x['query-continue']['revisions']['rvstartid']; $data['revisions']['pageid'] = $key; return $data['revisions']; }               }

function users ($start = null,$limit = 1,$group = null,$reqirestart = false,&amp;$continue = null) { $append = ''; if ($start != null) $append .= '&amp;aufrom='.urlencode($start); if ($group != null) $append .= '&amp;augroup='.urlencode($group); $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=allusers&amp;format=php&amp;auprop=blockinfo|editcount|registration|groups&amp;aulimit='.urlencode($limit).$append); $x = unserialize($x); $continue = $x['query-continue']['allusers']['aufrom']; if (($requirestart == true) and ($x['query']['allusers'][0]['name'] != $start)) return false; return $x['query']['allusers']; }

function categorymembers ($category,$count = 500,&amp;$continue = null) { if ($continue != null) { $append = '&amp;cmcontinue='.urlencode($continue); } else { $append = ''; }                       $category = 'Category:'.str_ireplace('category:','',$category); $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=categorymembers&amp;cmtitle='.urlencode($category).'&amp;format=php&amp;cmlimit='.$count.$append); $x = unserialize($x); $continue = $x['query-continue']['categorymembers']['cmcontinue']; return $x['query']['categorymembers']; }

function listcategories (&amp;$start = null,$limit = 50,$dir = 'ascending',$prefix = null) { $append = ''; if ($start != null) $append .= '&amp;acfrom='.urlencode($start); if ($limit != null) $append .= '&amp;aclimit='.urlencode($limit); if ($dir != null) $append .= '&amp;acdir='.urlencode($dir); if ($prefix != null) $append .= '&amp;acprefix='.urlencode($prefix);

$x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=allcategories&amp;acprop=size&amp;format=php'.$append); $x = unserialize($x);

$start = $x['query-continue']['allcategories']['acfrom'];

return $x['query']['allcategories']; }

function backlinks ($page,$count = 500,&amp;$continue = null,$filter = null) { if ($continue != null) { $append = '&amp;blcontinue='.urlencode($continue); } else { $append = ''; }                       if ($filter != null) { $append .= '&amp;blfilterredir='.urlencode($filter); }

$x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=backlinks&amp;bltitle='.urlencode($page).'&amp;format=php&amp;bllimit='.$count.$append); $x = unserialize($x); $continue = $x['query-continue']['backlinks']['blcontinue']; return $x['query']['backlinks']; }

function embeddedin ($page,$count = 500,&amp;$continue = null) { if ($continue != null) { $append = '&amp;eicontinue='.urlencode($continue); } else { $append = ''; }                       $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=embeddedin&amp;eititle='.urlencode($page).'&amp;format=php&amp;eilimit='.$count.$append); $x = unserialize($x); $continue = $x['query-continue']['embeddedin']['eicontinue']; return $x['query']['embeddedin']; }

function listprefix ($prefix,$namespace = 0,$count = 500,&amp;$continue = null) { $append = '&amp;apnamespace='.urlencode($namespace); if ($continue != null) { $append .= '&amp;apfrom='.urlencode($continue); }                       $x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=allpages&amp;apprefix='.urlencode($prefix).'&amp;format=php&amp;aplimit='.$count.$append); $x = unserialize($x); $continue = $x['query-continue']['allpages']['apfrom']; return $x['query']['allpages']; }       }

class wikipediaindex { private $http; public $indexurl = 'http://en.wikipedia.org/w/index.php'; private $postinterval = 0; private $lastpost; private $edittoken;

function __construct { global $__wp__http; if (!isset($__wp__http)) { $__wp__http = new http; }                       $this-&gt;http = &amp;$__wp__http; }

function post ($page,$data,$summery = '',$minor = false,$rv = null,$bot = true) { global $user; global $maxlag; global $irc; global $irctechchannel; global $run; global $maxlagkeepgoing;

$wpq = new wikipediaquery; $wpq-&gt;queryurl = str_replace('index.php','query.php',$this-&gt;indexurl); $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl);

if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; if ($rv == null) $rv = $wpapi-&gt;revisions($page,1,'older',true); if (!$rv[0]['*']) $rv[0]['*'] = $wpq-&gt;getpage($page);

//Fake the edit form. $now = gmdate('YmdHis', time); $token = htmlspecialchars($this-&gt;edittoken); $tmp = date_parse($rv[0]['timestamp']); $edittime = gmdate('YmdHis', gmmktime($tmp['hour'],$tmp['minute'],$tmp['second'],$tmp['month'],$tmp['day'],$tmp['year'])); $html = &quot;&lt;input type='hidden' value=\&quot;{$now}\&quot; name=\&quot;wpStarttime\&quot; /&gt;\n&quot;; $html.= &quot;&lt;input type='hidden' value=\&quot;{$edittime}\&quot; name=\&quot;wpEdittime\&quot; /&gt;\n&quot;; $html.= &quot;&lt;input type='hidden' value=\&quot;{$token}\&quot; name=\&quot;wpEditToken\&quot; /&gt;\n&quot;; $html.= '&lt;input name=&quot;wpAutoSummary&quot; type=&quot;hidden&quot; value=&quot;'.md5('').'&quot; /&gt;'.&quot;\n&quot;;

if (preg_match('/'.preg_quote('','/').'/iS',$rv[0]['*'])) { return false; }          /* Honor the bots flags */ if (preg_match('/'.preg_quote('','/').'/iS',$rv[0]['*'])) { return false; } if (preg_match('/'.preg_quote('','/').'/iS',$rv[0]['*'])) { return false; } if (preg_match('/'.preg_quote('','/').'/iS',$rv[0]['*'],$m)) { if (in_array(explode(',',$m[1]),$user)) { return false; } } /* /Honor the bots flags */ if (!preg_match('/'.preg_quote($user,'/').'/iS',$rv['currentuser'])) { return false; } /* We need to be logged in */ //                     if (preg_match('/'.preg_quote('You have new messages','/').'/iS',$rv[0]['*'])) { return false; } /* Check talk page */ if (!preg_match('/(yes|enable|true)/iS',((isset($run))?$run:$wpq-&gt;getpage('User:'.$user.'/Run')))) { return false; } /* Check /Run page */

$x = $this-&gt;forcepost($page,$data,$summery,$minor,$html,$maxlag,$maxlagkeepgoing,$bot); /* Go ahead and post. */                       $this-&gt;lastpost = time; return $x; }

function forcepost ($page,$data,$summery = '',$minor = false,$edithtml = null,$maxlag = null,$mlkg = null,$bot = true) { $post['wpSection'] = ''; $post['wpScrolltop'] = ''; if ($minor == true) { $post['wpMinoredit'] = 1; } $post['wpTextbox1'] = $data; $post['wpSummary'] = $summery; if ($edithtml == null) { $html = $this-&gt;http-&gt;get($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=edit'); } else { $html = $edithtml; }                       preg_match('|\&lt;input type\=\\\'hidden\\\' value\=\&quot;(.*)\&quot; name\=\&quot;wpStarttime\&quot; /\&gt;|U',$html,$m); $post['wpStarttime'] = $m[1]; preg_match('|\&lt;input type\=\\\'hidden\\\' value\=\&quot;(.*)\&quot; name\=\&quot;wpEdittime\&quot; /\&gt;|U',$html,$m); $post['wpEdittime'] = $m[1]; preg_match('|\&lt;input type\=\\\'hidden\\\' value\=\&quot;(.*)\&quot; name\=\&quot;wpEditToken\&quot; /\&gt;|U',$html,$m); $post['wpEditToken'] = $m[1]; preg_match('|\&lt;input name\=\&quot;wpAutoSummary\&quot; type\=\&quot;hidden\&quot; value\=\&quot;(.*)\&quot; /\&gt;|U',$html,$m); $post['wpAutoSummary'] = $m[1]; if ($maxlag != null) { $x = $this-&gt;http-&gt;post($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=submit&amp;maxlag='.urlencode($maxlag).'&amp;bot='.(($bot == true)?'1':'0'),$post); if (preg_match('/Waiting for ([^ ]*): ([0-9.-]+) seconds lagged/S',$x,$lagged)) { global $irc; if (is_resource($irc)) { global $irctechchannel; foreach(explode(',',$irctechchannel) as $y) { fwrite($irc,'PRIVMSG '.$y.' :'.$lagged[1].' is lagged out by '.$lagged[2].' seconds. ('.$lagged[0].')'.&quot;\n&quot;); }                                       }                                        sleep(10); if ($mlkg != true) { return false; } else { $x = $this-&gt;http-&gt;post($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=submit&amp;bot='.(($bot == true)?'1':'0'),$post); } }                               return $x; } else { return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=submit&amp;bot='.(($bot == true)?'1':'0'),$post); }               }

function diff ($title,$oldid,$id,$wait = true) { $deleted = ''; $added = '';

$html = $this-&gt;http-&gt;get($this-&gt;indexurl.'?title='.urlencode($title).'&amp;action=render&amp;diff='.urlencode($id).'&amp;oldid='.urlencode($oldid).'&amp;diffonly=1');

if (preg_match_all('/\&amp;amp\;(oldid\=|undo=)(\d*)\\\'\&gt;(Revision as of|undo)/USs', $html, $m, PREG_SET_ORDER)) { //print_r($m); if ((($oldid != $m[0][2]) and (is_numeric($oldid))) or (($id != $m[1][2]) and (is_numeric($id)))) { if ($wait == true) { sleep(1); return $this-&gt;diff($title,$oldid,$id,false); } else { die('Revision error.'.&quot;\n&quot;); }                               }                        }                        if (preg_match_all('/\&lt;td class\=(\&quot;|\\\')diff-addedline\1\&gt;\&lt;div\&gt;(.*)\&lt;\/div\&gt;\&lt;\/td\&gt;/USs', $html, $m, PREG_SET_ORDER)) { //print_r($m); foreach ($m as $x) { $added .= htmlspecialchars_decode(strip_tags($x[2])).&quot;\n&quot;; }                       }

if (preg_match_all('/\&lt;td class\=(\&quot;|\\\')diff-deletedline\1\&gt;\&lt;div\&gt;(.*)\&lt;\/div\&gt;\&lt;\/td\&gt;/USs', $html, $m, PREG_SET_ORDER)) { //print_r($m); foreach ($m as $x) { $deleted .= htmlspecialchars_decode(strip_tags($x[2])).&quot;\n&quot;; }                       }

//echo $added.&quot;\n&quot;.$deleted.&quot;\n&quot;;

if (preg_match('/action\=rollback\&amp;amp\;from\=.*\&amp;amp\;token\=(.*)\&quot;/US', $html, $m)) { $rbtoken = $m[1]; $rbtoken = urldecode($rbtoken); //                             echo 'rbtoken: '.$rbtoken.' -- '; print_r($m); echo &quot;\n\n&quot;; return array($added,$deleted,$rbtoken); }

return array($added,$deleted); }

function rollback ($title,$user,$reason = null,$token = null,$bot = true) { if (($token == null) or (!$token)) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); $token = $wpapi-&gt;revisions($title,1,'older',false,null,true,true); if ($token[0]['user'] == $user) { echo 'Token: '; print_r($token); echo &quot;\n\n&quot;; $token = $token[0]['rollbacktoken']; } else { return false; }                       }                        $x = $this-&gt;http-&gt;get($this-&gt;indexurl.'?title='.urlencode($title).'&amp;action=rollback&amp;from='.urlencode($user).'&amp;token='.urlencode($token).(($reason != null)?'&amp;summary='.urlencode($reason):'').'&amp;bot='.(($bot == true)?'1':'0')); echo 'Rollback return: '.$x.&quot;\n&quot;; if (!preg_match('/action complete/iS',$x)) return false; return $x; }

function move ($old,$new,$reason) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken;

$token = htmlspecialchars($this-&gt;edittoken);

$post = array (                                       'wpOldTitle'    =&gt; $old,                                        'wpNewTitle'    =&gt; $new,                                        'wpReason'      =&gt; $reason,                                        'wpWatch'       =&gt; '0',                                        'wpEditToken'   =&gt; $token,                                        'wpMove'        =&gt; 'Move page'                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title=Special:Movepage&amp;action=submit',$post); }

function upload ($page,$file,$desc) { $post = array (                                       'wpUploadFile'          =&gt; '@'.$file,                                        'wpSourceType'          =&gt; 'file',                                        'wpDestFile'            =&gt; $page,                                        'wpUploadDescription'   =&gt; $desc,                                        'wpLicense'             =&gt; '',                                        'wpWatchthis'           =&gt; '0',                                        'wpIgnoreWarning'       =&gt; '1',                                        'wpUpload'              =&gt; 'Upload file'                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title=Special:Upload&amp;action=submit',$post); }

function hasemail ($user) { $tmp = $this-&gt;http-&gt;get($this-&gt;indexurl.'?title=Special:EmailUser&amp;target='.urlencode($user)); if (stripos($tmp,&quot;No e-mail address&quot;) !== false) return false; return true; }               function email ($user,$subject,$body) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken;

$post = array (                                       'wpSubject'     =&gt; $subject,                                        'wpText'        =&gt; $body,                                        'wpCCMe'        =&gt; 0,                                        'wpSend'        =&gt; 'Send',                                        'wpEditToken'   =&gt; $this-&gt;edittoken                                );

return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title=Special:EmailUser&amp;target='.urlencode($user).'&amp;action=submit',$post); }               function delete ($page,$reason=null) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; $token = htmlspecialchars($this-&gt;edittoken); $post = array('title' =&gt; $page,'token' =&gt; $token,'reason' =&gt; $reason);

$x = $this-&gt;http-&gt;post( $wpapi-&gt;apiurl.'?action=delete&amp;format=php',$post ); print_r( $x ); }               function protect ($page,$reason=null,$edit='sysop',$move='sysop',$editexpire='infinite',$moveexpire='infinite') { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; $token = htmlspecialchars($this-&gt;edittoken); $post = array (                                       'mwProtect-reason'      =&gt; $reason,                                        'mwProtectWatch'        =&gt; '0',                                        'mwProtect-cascade'     =&gt; '0',                                        'mwProtect-expiry-edit' =&gt; $editexpire,                                        'mwProtect-expiry-move' =&gt; $moveexpire,                                        'mw-Protect-submit'     =&gt; 'Confirm',                                        'wpEditToken'           =&gt; $token,                                        'mwProtect-level-edit'  =&gt; $edit,                                        'mwProtect-level-move'  =&gt; $move                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=protect',$post); }               function salt ($page,$reason=null,$create='sysop',$expire='infinite') { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; $token = htmlspecialchars($this-&gt;edittoken); $post = array (                                       'mwProtect-reason'      =&gt; $reason,                                        'mwProtectWatch'        =&gt; '0',                                        'mwProtect-expiry'      =&gt; $expire,                                        'mw-Protect-submit'     =&gt; 'Confirm',                                        'wpEditToken'           =&gt; $token,                                        'mwProtect-level-create'  =&gt; $create                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title='.urlencode($page).'&amp;action=protect',$post); }               function block ($user,$expire='infinite',$reason='Vandalism',$anon=1,$account=1,$autoblock=1,$emailban=0) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; $token = htmlspecialchars($this-&gt;edittoken); $post = array (                                       'wpBlockAddress'       =&gt; $user,                                        'wpBlockReason'         =&gt; $reason,                                        'wpAnonOnly'            =&gt; $anon,                                        'wpBlockOther'         =&gt; $expire,                                        'wpBlock'              =&gt; 'Block',                                        'wpEditToken'           =&gt; $token,                                        'wpCreateAccount'      =&gt; $account,                                        'wpEnableAutoblock'    =&gt; $autoblock,                                        'wpEmailBan'           =&gt; $emailban,                                        'wpWatchUser'          =&gt; 0,                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title=Special:BlockIP&amp;action=submit',$post); }               function unblock ($user,$reason=null) { $wpapi = new wikipediaapi; $wpapi-&gt;apiurl = str_replace('index.php','api.php',$this-&gt;indexurl); if ((!$this-&gt;edittoken) or ($this-&gt;edittoken == '')) $this-&gt;edittoken = $wpapi-&gt;getedittoken; $token = htmlspecialchars($this-&gt;edittoken); $post = array (                                       'wpUnblockAddress'     =&gt; $user,                                        'wpUnblockReason'      =&gt; $reason,                                        'wpBlock'              =&gt; 'Unblock',                                        'wpEditToken'           =&gt; $token                                ); return $this-&gt;http-&gt;post($this-&gt;indexurl.'?title=Special:IPBlockList&amp;action=submit',$post); }       } ?&gt;