Misplaced Pages

User:ClueBot/Source: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:ClueBot Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 15:05, 2 August 2008 view sourceYad2ayadayada (talk | contribs)9 editsNo edit summary← Previous edit Revision as of 15:06, 2 August 2008 view source Xeno (talk | contribs)Autopatrolled, Bureaucrats, Administrators103,386 editsm Reverted edits by Yad2ayadayada (talk) to last version by ClueBotNext edit →
Line 1: Line 1:
The following is automatically generated by ].
{{Talkarchive}}


==Request==
Please add ] to the various cluebots. Thanks! Browsing existing bots aby function is currently a little difficult, and this is being rectified.--] 17:22, 29 October 2007 (UTC)


A lot of its so called "vandilism" removal is not actually vadalism <small>—Preceding ] comment added by ] (]) 01:15, 1 November 2007 (UTC)</small><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
==Bot Broken==


==Classes (wikibot.classes.php)==
Bot is screwed up!


<pre>&lt;?PHP
I just got a warning on my discussion page for adding "useless junk" to the ] page. Sorry, but wasnt me! Don't accuse me Mr Bot, or I'll have to rewire you! Never even heard of Marsha Hunt! How very rooooooooood! ] 09:42, 31 October 2007 (UTC)
class http {
private $ch;
private $uid;
public $postfollowredirs;
public $getfollowredirs;


function data_encode ($data, $keyprefix = &quot;&quot;, $keypostfix = &quot;&quot;) {
Oh i didnt know i could get in trouble for that, i thought you could do anything on this gay ass website <small>—Preceding ] comment added by ] (]) 21:07, 2 November 2007 (UTC)</small><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
assert( is_array($data) );
== Just thought you should know. ==
$vars=null;
foreach($data as $key=&gt;$value) {
if(is_array($value)) $vars .= $this-&gt;data_encode($value, $keyprefix.$key.$keypostfix.urlencode(&quot;&quot;));
else $vars .= $keyprefix.$key.$keypostfix.&quot;=&quot;.urlencode($value).&quot;&amp;&quot;;
}
return $vars;
}


function __construct () {
I was searching through my watchlist and noticed that Cluebot had reverted some vandalism on The Legend of Zelda game article. I was curious about what the vandals had done, so I checked it out. In the process, I discovered a weakness in his programming; this particular vandal had done a series of edits, each more offensive than the last, and Cluebot only reverted the most recent of them. I went ahead and reverted further for it (by the way, it was my first full-fledged revert; hope I didn't screw anything up), but I thought you should know, in the off-chance that you may know a way to fix it. If not, oh well. By the way, you should probably delete this once you read it; the last thing we need is vandals getting ideas. ] 06:06, 3 November 2007 (UTC)
$this-&gt;ch = curl_init();
== user Asd0011 ==
$this-&gt;uid = dechex(rand(0,99999999));
curl_setopt($this-&gt;ch,CURLOPT_COOKIEJAR,'/tmp/cluewikibot.cookies.'.$this-&gt;uid.'.dat');
curl_setopt($this-&gt;ch,CURLOPT_COOKIEFILE,'/tmp/cluewikibot.cookies.'.$this-&gt;uid.'.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) {
Hi!
// echo 'POST: '.$url.&quot;\n&quot;;
I think he is a bit notorious at the moment. Wouldn't it be better to send him out of the house for a while?? --] 02:26, 4 November 2007 (UTC)
$time = microtime(1);
:Elaborate. How would you plan on doing that? I am not an administrator and neither is ClueBot. Bug ] or another admin. :P -- ]<sup>(]|]|]|])</sup> 05:09, 4 November 2007 (UTC)
curl_setopt($this-&gt;ch,CURLOPT_URL,$url);
== Source - repeated word ==
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) {
'/wanker/i' => -15,
//echo 'GET: '.$url.&quot;\n&quot;;
'/motherfucker/i' => -20,
$time = microtime(1);
'/wanker/i' => -20,
curl_setopt($this-&gt;ch,CURLOPT_URL,$url);
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 () {
"Wanker" has both -15 and -20; just thought you might like to trim your source by 1 line. You may have already done it and not updated the source at ClueBot's user page, but I thought I may as well let you know, just in case. (Respond on my talk page, please.) — ] (]) 19:06, 4 November 2007 (UTC)
curl_close($this-&gt;ch);
== Thanks for the revert ==
@unlink('/tmp/cluewikibot.cookies.'.$this-&gt;uid.'.dat');
}
}


class wikipediaquery {
Thanks for the revert of the ] article from vandalism. I really appreciate it. Please advise your owner of this. ] 19:20, 4 November 2007 (UTC)
private $http;
== Bot doesn't recognize uw-bv? ==
public $queryurl = 'http://en.wikipedia.org/w/query.php';


function __construct () {
I recently warned a vandal using {{tl|uw-bv}}. A few minutes later, Cluebot reverted the same vandal and added a level one warning to the talk page, which I'm guessing means it doesn't recognize this warning template. From uw-bv, it should go to a level 4 warning or directly to reporting the vandal (I generally do the former, but I know others do the latter). ] ] 08:01, 3 November 2007 (UTC)
global $__wp__http;
:{{tl|uw-bv}} is a very old template that no one uses anymore. It uses a special tag that the bot doesn't understand because the bot is new, and it wouldn't browse for templates that no one is expected to use. Try {{tl|uw-vandalism4im}} instead. &mdash;]]<sup>]</sup><small>{{User:Ceres3/Status}}</small> 00:24, 6 November 2007 (UTC)
if (!isset($__wp__http)) {
::On the contrary, it is a standard tag today. It was imported into the new set of warnings (note the uw- prefix) and is included in Twinkle. I still see it used regularly on RC patrol, and I certainly have no intention to stop using it. It is not the same as uw-vandalism4im. ] ] 00:32, 6 November 2007 (UTC)
$__wp__http = new http;
}
$this-&gt;http = &amp;$__wp__http;
}
function getpage ($page) {
$ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=content&amp;format=php&amp;titles='.urlencode($page)));
foreach ($ret as $page) {
return $page;
}
}


function getpageid ($page) {
== Bot stopped working ==
$ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=content&amp;format=php&amp;titles='.urlencode($page)));
foreach ($ret as $page) {
return $page;
}
}


function contribcount ($user) {
ClueBot seems to have stopped working at 10:49 today, and boy do we need it now! ] 18:59, 5 November 2007 (UTC)
$ret = unserialize($this-&gt;http-&gt;get($this-&gt;queryurl.'?what=contribcounter&amp;format=php&amp;titles=User:'.urlencode($user)));
:Someone changed ] ... I would suggest watchlisting it. -- ]<sup>(]|]|]|])</sup> 01:08, 6 November 2007 (UTC)
foreach ($ret as $page) {
== Great bot ==
return $page;
}
}
}


class wikipediaapi {
I always find it catching vandalism before I can get to it. Thanks for creating it.--] 18:42, 7 November 2007 (UTC)
private $http;
== What that user did was not vandalism. ==
public $apiurl = 'http://en.wikipedia.org/w/api.php';


function __construct () {
] wrote in ] "south park rocks!!!". I have issues with calling that vandalism. He/she might not have actually tried to hurt the page, they were just voicing their opinion. And their opinion on South Park was positive, therefore it is not vandalism, it is just "inappropriate appraisal". Please be gentler with your statements in future. ] 22:27, 9 November 2007 (UTC)
global $__wp__http;
==Just what are BOTs and how do they work==
if (!isset($__wp__http)) {
Just took a Linux admin class. Just what are these wiki bots and how do they work? I can see them all the place removing the "F" word, for example from articles. Feel free to remove this question soon if it compromises something or just reply on my page and not here. Thanks. Meanwhile I've found the how to create a bot at http://en.wikipedia.org/Wikipedia:Creating_a_bot
$__wp__http = new http;
] 02:06, 10 November 2007 (UTC)
}
:In a nutshell, a wikibot is a computer program, programmed in programming language, that can make requests to Misplaced Pages. Bots do this the same way your browser would do it, with an HTTP request. There are a few pages which provide information more suited for a bot, but making an edit still has to be done using the same page you would use. The bots do not have to actually display the page on the screen, but they still have to load it. Bots are used for repetitive or tedious tasks. The bot ClueBot, for example, is programmed in PHP and you can see its source ]. -- ]<sup>(]|]|]|])</sup> 02:14, 10 November 2007 (UTC)
$this-&gt;http = &amp;$__wp__http;
}


function login ($user,$pass) {
::OK, understand that they are programs, automated processes. I see there is also an approval process to prevent these programs from running amuck. I am NOT a programmer, but I do work in IT, and much more comfortable talking history, so forgive my inane questions. After 2 weeks of Linux training at my company, I came away really impressed with the features and power within Linux, and based on that I have to ask, just how are these bots introduced into the entire Linux underlying system and how do you guys prevent totally unintended consequences, looping, etc? In other words, is there much in the way of any formal change control on all this stuff? Originally amazed at the sheer volumn of info in wikipedia, I'm now almost MORE AMAZED at the sophistication of the underlying technologies - and the degree of dedication on the parts of a VAST world-wide network of not just the contributors, but the admins, the programmers. And to think of the ZILLIONS of un-compensated hours spent in contributing and system maintenance. Although there must also be a group of actually paid wiki employees, I imagine. The normal joe looking around[REDACTED] has to ask, "when do you people sleep? Do you have a life?"
$data = $this-&gt;http-&gt;post($this-&gt;apiurl.'?action=login',array('lgname' =&gt; $user, 'lgpassword' =&gt; $pass));
// if ($data) echo $data.&quot;\n\n&quot;;
}


function getedittoken () {
::All you hear about in the media is BS like "so many articles" and "anyone can claim to be a subject-matter expert in[REDACTED] and go unchallenged." Re. Academia is increasingly threatened by the proliferation of wiki "information" with no "academic" peer review that they demand for so-called reliability. But then THINK of the junk that is published in so-called "professional publications!" My kid's same teachers who mouth the words, "Don't rely on wikipedia," are constantly checking stuff on wiki, themselves. Also writers and editors. Case in point. I have contributed a ton of stuff to articles on ] and his family. In Time Magazine last year, I found a few "re-worked" paragraphs from[REDACTED] shamelessly woven into the article. I knew my own stuff just by reading it on the Time series on TR. I actually read the magazine with absolutely NO thought of the stuff I had added in wikipedia, until I came to some sections and pushed my chair back and said, "Hey - I've SEEN this stuff beFORE - yeah, before alright - right here in wikipedia. I told my wife, "Looks like editors of Time Magazine have managed to pay us wikipedians a rather backhanded compliment this time! Thanks. ] 02:38, 10 November 2007 (UTC)
$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 as $y) {
return $y;
}
}


function recentchanges ($count = 10,$namespace = null,$dir = 'older',$ts = null) {
:::Basically the bots run like any other program in Linux. They do not run on the Wikimedia servers, except perhaps the ones on Wikimedia's shell server (the toolserver). They do not have special privileges. The bot flag is really just to help obscure the edits by a bot. The edits by bots aren't shown in ] and minor edits by bots to users' talk pages do not make that ugly orange bar come up. For example, ClueBot runs on a box here at my house. To answer your question about sleep, ClueBot does not sleep :P On a more serious note, there are just so many Wikipedians and Recent Change Patrollers that at least someone is on all the time. -- ]<sup>(]|]|]|])</sup> 03:29, 10 November 2007 (UTC)
$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;
}


function search ($search,$limit = 10,$offset = 0,$namespace = 0,$what = 'text',$redirs = false) {
:: Thanks for the information. I'm not normally a "golly-gee" type of person, but[REDACTED] is truely an international cooperation success story and says a lot about the maturation of most decent elements in the human race if you think about the massive amount of collaboration that has to work around this planet for this to work and more importantly to stay up and not crash. I'll do some more research and try to attend one of those wikepedia conventions. I'm in the USA Pacific Northwest, so maybe in Seattle or Portland. Thanks again. PS, I also noted your information on ClueNet and some of these other forms of Open-Source collaboration. For the future, until I really delve into Linux, scripting, etc., I'm going to stick with history because at least I can speak with some degree of authority in THAT particular information realm. ] 04:16, 10 November 2007 (UTC)
$append = '';
== Welcome ==
if ($limit != null) $append .= '&amp;srlimit='.urlencode($limit);
<!-- Template from Template:Welcomeg -->{| style="background-color:#F5FFFA; padding:0;" cellpadding="0"
if ($offset != null) $append .= '&amp;sroffset='.urlencode($offset);
|class="MainPageBG" style="border:1px solid lightgrey; background-color:lightgrey; vertical-align:top; color:#000000; font-size:85%"|
if ($namespace != null) $append .= '&amp;srnamespace='.urlencode($namespace);
{| width="100%" cellpadding="0" cellspacing="5" style="vertical-align:top; background-color:lavender; padding:0;"
if ($what != null) $append .= '&amp;srwhat='.urlencode($what);
! <div style="margin:0; background-color:white; font-family:sans-serif; font-size:120%; font-weight:normal; border:1px solid lightgrey; text-align:left; padding-left:0.4em; padding-top:0.2em; padding-bottom:0.2em;">Hello, '''ClueBot Commons'''! ] to Misplaced Pages! Thank you for ]. You may benefit from following some of the links below, which will help you get the most out of Misplaced Pages. If you have any questions you can ask me on my talk page, or place '''<tt>{&#123;helpme&#125;}</tt>''' on your ] and ask your question there. Please remember to ] on talk pages by clicking ] or by typing four tildes "~&#126;~~"; this will automatically produce your name and the date. If you are already loving Misplaced Pages you might want to consider being "]" by a more experienced editor or joining a ] to collaborate with others in creating and improving articles of your interest. Click ] for a directory of all the WikiProjects. Finally, please do your best to '''always fill in the ] field'''. Happy editing! ] ]/] 03:39, 18 November 2007 (UTC)
if ($redirs == true) $append .= '&amp;srredirects=1';
|}
else $append .= '&amp;srredirects=0';
{| width="100%" style="background-color:white;"
$x = $this-&gt;http-&gt;get($this-&gt;apiurl.'?action=query&amp;list=search&amp;format=php&amp;srsearch='.urlencode($search).$append);
|class="MainPageBG" style="width: 55%; border:1px solid white; background-color:lightgrey; vertical-align:top"|
$x = unserialize($x);
{| width="100%" cellpadding="0" cellspacing="5" style="vertical-align:top; background-color:Lavender"
return $x;
! <div style="margin: 0; background-color:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Getting Started</div>
}
|-
|style="color:#000"|
* ] • ]
* How to: ] • ]
|-
! <div style="margin: 0; background:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Getting Help</div>
|-
| style="color:#000"|
* ]
* ]
* ]
|-
! <div style="margin: 0; background:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Policies and Guidelines</div>
|-
| style="color:#000"|
* ] • ]
* ] • ] • ]
* ] • ]
<hr />
* ] • ] • ]
* ] • ] • ]
* ] • ] • ]
* ] • ] • ]
|-
|}
|class="MainPageBG" style="width: 55%; border:1px solid lightgrey; background-color:Seashell; vertical-align:top"|
{| width="100%" cellpadding="0" cellspacing="5" style="vertical-align:top; background-color:Seashell"
! <div style="margin: 0; background-color:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">The Community</div>
|-
|style="color:#000"|
* ] • ]
* ] • ] • ]
* ] • ]
* ] • ]
* ] • ] • ]
|-
! <div style="margin: 0; background-color:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Things to do</div>
|-
|style="color:#000"|
* ] • ]
* ] • ]
* ] • ]
* Cleaning up: ] • ] • ]
|-
! <div style="margin: 0; background-color:white; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid lightgrey; text-align:left; color:grey; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Miscellaneous</div>
|-
|style="color:#000"|
* ] • ] • ]
* ] • ]
* ] • ] • ]
|}
|}
|}<!--Template:Welcomeg-->
== GTFO ==


function logs ($user = null,$title = null,$limit = 50,$type = null,$start = null,$end = null,$dir = 'older') {
This here that was reverted by ClueBot seemed like a good faith edit, even though misguided. It was not vandalism as such, so I'm reporting it.--''']''' <sup>'']''</sup> <sub>''']'''</sub> 06:03, 20 November 2007 (UTC)
$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;
}


This is not a vandalism. --] (]) 10:13, 23 November 2007 (UTC)
== Bot stopped working ==


function usercontribs ($user,$count = 50,&amp;$continue = null,$dir = 'older') {
ClueBot seems to have stopped working at 20:39 last night, when ] mucked around with the Run flag, but the Run flag is True again and yet the bot's not running. ] (]) 10:21, 28 November 2007 (UTC)
if ($continue != null) {
== Bot flag ==
$append = '&amp;ucstart='.urlencode($continue);
The bot flag doesn't seem to be set for this bot. It can't be filtered from watchlists. Thanks. -- <font color="#000080">Mufka</font> ] ] ]</sup> 19:14, 28 November 2007 (UTC)
} else {
:The ] have decided not to give ClueBot the bot flag because it is an anti-vandal bot and they don't give anti-vandal bots flags. Thanks. -- ]<sup>(]|]|]|])</sup> 19:29, 28 November 2007 (UTC)
$append = '';
== Delivery ==
}
$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;
return $x;
}


function revisions ($page,$count = 1,$dir = 'older',$content = false,$revid = null,$wait = true,$getrbtok = false,$dieonerror = true,$redirects = false) {
How do you get ClueBot Commons to deliver stats like ]? &mdash;]]<sup>]]</sup><small>@11/29/2007 15:23</small>
$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) or !is_array($x)) {
if ($dieonerror == true) die('No such page.'.&quot;\n&quot;);
else return false;
}
foreach ($x as $data) {
if (!isset($data) or !is_array($data)) {
if ($dieonerror == true) die('No such page.'.&quot;\n&quot;);
else return false;
}
foreach ($data as $data2) if ($data2 == $revid) $found = true;
unset($data,$data2);
break;
}


if ($found == false) {
:I could add you if you want, but the list is hardcoded into the little program that is run at 0000 (UTC -0500) my time. If it becomes more popular, I may make the list public - but I should probably get ] approval if I do. -- ]<sup>(]|]|]|])</sup> 20:41, 29 November 2007 (UTC)
if ($wait == true) {
== No warning issued ==
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 as $data) {
$data = $data;
$data = $data;
$data = $x;
// $data = $x;
$data = $x;
return $data;
}
}


function users ($start = null,$limit = 1,$group = null,$reqirestart = false,&amp;$continue = null) {
I've just issued a revert back to a version by ClueBot (ClueBot ref: 93836), and was a little surprised that ClueBot had not warned the vandal. Just too busy? I know the feeling! ] (]) 18:05, 29 November 2007 (UTC)
$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;
if (($requirestart == true) and ($x != $start)) return false;
return $x;
}


:Probably because the database replication lag was greater than 10 seconds. ClueBot will check right before each time it tries to post something. It was probably less when it reverted the vandalism, but when it went to warn the user it was probably more so ClueBot aborted it. It does this so it doesn't load the Wikimedia servers too much. -- ]<sup>(]|]|]|])</sup> 20:37, 29 November 2007 (UTC)


function categorymembers ($category,$count = 500,&amp;$continue = null) {
::Ah! Yes, that would make sense - there was a lag at about that time. ] (]) 10:37, 30 November 2007 (UTC)
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;
return $x;
}

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;

return $x;
}

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;
return $x;
}

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;
return $x;
}

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;
return $x;
}
}

class wikipediaindex {
private $http;
public $indexurl = 'http://en.wikipedia.org/search/';
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) $rv = $wpq-&gt;getpage($page);

//Fake the edit form.
$now = gmdate('YmdHis', time());
$token = htmlspecialchars($this-&gt;edittoken);
$tmp = date_parse($rv);
$edittime = gmdate('YmdHis', gmmktime($tmp,$tmp,$tmp,$tmp,$tmp,$tmp));
$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('{{nobots}}','/').'/iS',$rv)) { return false; } /* Honor the bots flags */
if (preg_match('/'.preg_quote('{{bots|allow=none}}','/').'/iS',$rv)) { return false; }
if (preg_match('/'.preg_quote('{{bots|deny=all}}','/').'/iS',$rv)) { return false; }
if (preg_match('/'.preg_quote('{{bots|deny=','/').'(.*)'.preg_quote('}}','/').'/iS',$rv,$m)) { if (in_array(explode(',',$m),$user)) { return false; } } /* /Honor the bots flags */
if (!preg_match('/'.preg_quote($user,'/').'/iS',$rv)) { return false; } /* We need to be logged in */
// if (preg_match('/'.preg_quote('You have new messages','/').'/iS',$rv)) { 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 = '';
$post = '';
if ($minor == true) { $post = 1; }
$post = $data;
$post = $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 = $m;
preg_match('|\&lt;input type\=\\\'hidden\\\' value\=\&quot;(.*)\&quot; name\=\&quot;wpEdittime\&quot; /\&gt;|U',$html,$m);
$post = $m;
preg_match('|\&lt;input type\=\\\'hidden\\\' value\=\&quot;(.*)\&quot; name\=\&quot;wpEditToken\&quot; /\&gt;|U',$html,$m);
$post = $m;
preg_match('|\&lt;input name\=\&quot;wpAutoSummary\&quot; type\=\&quot;hidden\&quot; value\=\&quot;(.*)\&quot; /\&gt;|U',$html,$m);
$post = $m;
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 (*): (+) seconds lagged/S',$x,$lagged)) {
global $irc;
if (is_resource($irc)) {
global $irctechchannel;
foreach(explode(',',$irctechchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :'.$lagged.' is lagged out by '.$lagged.' seconds. ('.$lagged.')'.&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) and (is_numeric($oldid))) or (($id != $m) 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)).&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)).&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;
$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 == $user) {
echo 'Token: '; print_r($token); echo &quot;\n\n&quot;;
$token = $token;
} 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);
}
}
?&gt;
</pre>



==Diff function (diff.function.php)==

<pre>&lt;?PHP
function diff ($old,$new,$nret = true,$inline = false) {
// if ($inline) {
// return str_replace(array(&quot;\n&quot;,chr(92).chr(92),'\n'),array(' ',chr(92),&quot;\n&quot;),diff(implode(&quot;\n&quot;,explode(' ',str_replace(array(chr(92),&quot;\n&quot;),array(chr(92).chr(92),'\n'),$old))),implode(&quot;\n&quot;,explode(' ',str_replace(array(chr(92),&quot;\n&quot;),array(chr(92).chr(92),'\n'),$new))),$nret,false));
// }
$file1 = tempnam('/tmp','diff_');
$file2 = tempnam('/tmp','diff_');
file_put_contents($file1,$old);
file_put_contents($file2,$new);
$out = array();
if ($inline) {
// echo 'EXEC: wdiff -3'.(($nret)?'1':'2').' '.escapeshellarg($file1).' '.escapeshellarg($file2).&quot;\n&quot;;
@exec('wdiff -3'.(($nret)?'1':'2').' '.escapeshellarg($file1).' '.escapeshellarg($file2),$out);
foreach ($out as $key =&gt; $line) {
if ($line == '======================================================================') unset($out);
elseif ($nret) $out = '&gt; '.$line;
else $out = '&lt; '.$line;
}
} else {
@exec('diff -d --suppress-common-lines '.escapeshellarg($file1).' '.escapeshellarg($file2),$out);
}
$out2 = array();
foreach ($out as $line) {
if (
(
($nret)
and (preg_match('/^\&gt; .*$/',$line))
)
or (
(!$nret)
and (preg_match('/^\&lt; .*$/',$line))
)
) {
$out2 = substr($line,2);
}
}
$out = $out2;
unset($out2);
unlink($file1);
unlink($file2);
return implode(&quot;\n&quot;,$out);
}
?&gt;
</pre>



==Source to ClueBot==

<pre>&lt;?PHP
declare(ticks = 1);

function sig_handler($signo) {
switch ($signo) {
case SIGCHLD:
while (($x = pcntl_waitpid(0, $status, WNOHANG)) != -1) {
if ($x == 0) break;
$status = pcntl_wexitstatus($status);
}
break;
}
}

pcntl_signal(SIGCHLD, &quot;sig_handler&quot;);

function score ($list,$data,&amp;$matches = null) {
$ret = 0;
foreach ($list as $preg =&gt; $pts) {
if ($x = preg_match_all($preg.'S',$data,$m)) {
// echo $x.'*'.$pts.' ('.$preg.')'.&quot;\n&quot;;
$matches = $x;
$ret += $pts * $x;
}
}
// echo 'Score: '.$ret.&quot;\n&quot;;
return $ret;
}

include '../diff.function.php'; /* The diff function. */
include '../wikibot.classes.php'; /* The[REDACTED] classes. */
include 'cluebot.config.php'; /* This file is very simple, but it contains sensitive information, we just define $user, $ircserver, $ircport, $ircchannel, $pass, $owner, and $status. */
include 'cluebot.scorelist.php'; /* This file is uploaded as well as the main file. */

$wpapi = new wikipediaapi;
$wpq = new wikipediaquery;
$wpi = new wikipediaindex;
$wpapi-&gt;login($user,$pass);

$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
if (!$mysql) { die('Could not connect: ' . mysql_error()); }
if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }

$ircconfig = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBChannels.js'));
$tmp = array();
foreach($ircconfig as $tmpline) { if (substr($tmpline,0,1) != '#') { $tmpline = explode('=',$tmpline,2); $tmp)] = trim($tmpline); } }

$ircchannel = $tmp;
$ircdebugchannel = $tmp;
$ircreportchannel = $tmp;
$ircvandalismchannel = $tmp;
$ircaivchannel = $tmp;
$irctechchannel = $tmp;
$ircproxychannels = $tmp;
$ircunrevertedchannels = $tmp;
$ircbagtrialchannels = $tmp;
$ircotherchannels = $tmp;

unset($tmp,$tmpline);

$stalkbots = array();
$trialbots = explode(&quot;\n&quot;,$wpq-&gt;getpage('Misplaced Pages:Bots/Requests for approval'));
foreach ($trialbots as $trialbot) if (preg_match('/\{\{BRFA\|(.*)\|.*\|Trial\}\}/',str_replace(array(&quot;\n&quot;,&quot;\r&quot;),'',$trialbot),$m)) $stalkbots] = 1;

$irc = fsockopen($ircserver,$ircport,$ircerrno,$ircerrstr,15);
$ircpid = pcntl_fork();
if ($ircpid == 0) {
fwrite($irc,'PASS '.$ircpass.&quot;\n&quot;);
fwrite($irc,'USER '.$user.' &quot;1&quot; &quot;1&quot; :ClueBot Misplaced Pages Bot.'.&quot;\n&quot;);
fwrite($irc,'NICK '.$user.&quot;\n&quot;);
while (!feof($irc)) {
$data = str_replace(array(&quot;\n&quot;,&quot;\r&quot;),'',fgets($irc,1024));
// echo 'IRC: '.$data.&quot;\n&quot;;
$d = explode(' ',$data);
if (strtolower($d) == 'ping') {
fwrite($irc,'PONG '.$d.&quot;\n&quot;);
} elseif (($d == '376') or ($d == '422')) {
// fwrite($irc,'PRIVMSG NickServ :identify '.$pass.&quot;\n&quot;);
// sleep(2);
fwrite($irc,'JOIN '.$ircchannel.','.$ircdebugchannel.','.$ircreportchannel.','.$ircvandalismchannel.','.$ircaivchannel.','.$irctechchannel.','.$ircproxychannels.','.$ircunrevertedchannels.','.$ircbagtrialchannels.','.$ircotherchannels.&quot;\n&quot;);
foreach (explode(',',$ircchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :IRC logging enabled.'.&quot;\n&quot;);
}
} elseif (strtolower($d) == 'privmsg') {
if (substr($d,0,2) == ':!') {
if (strtolower($d) == '#wikipedia-en') { $tmp = explode('!',substr($d,1)); $cmd = 'NOTICE '.$tmp; }
elseif (strtolower($d) == strtolower($user)) { $tmp = explode('!',substr($d,1)); $cmd = 'NOTICE '.$tmp; }
else { $cmd = 'PRIVMSG '.$d; }
switch (substr(strtolower($d),2)) {
case 'edit':
if (preg_match(&quot;/\\]/&quot;,$data,$m)) {
$rv = $wpapi-&gt;revisions($m,1,'older');
fwrite($irc,$cmd.' :.']] http://en.wikipedia.org/search/?title='.urlencode($m).'&amp;diff=prev' .
'&amp;oldid='.urlencode($rv).' * '.$rv.' * '.$rv.&quot;\n&quot;);
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'stalk':
if (preg_match(&quot;/\\]/&quot;,$data,$m)) {
$uc = $wpapi-&gt;usercontribs($m,1);
fwrite($irc,$cmd.' :.']] http://en.wikipedia.org/search/?title='.urlencode($uc).'&amp;diff=prev' .
'&amp;oldid='.urlencode($uc).' * '.$m.' * '.$uc.&quot;\n&quot;);
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'beaten':
if (preg_match(&quot;/\\]/&quot;,$data,$m)) {
if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
$x = mysql_fetch_assoc(mysql_query('SELECT COUNT(`id`) AS `count` FROM `beaten` WHERE `user` = \''.mysql_real_escape_string($m).'\' GROUP BY `user`'));
$y = mysql_fetch_assoc(mysql_query('SELECT SQL_CALC_FOUND_ROWS COUNT(`id`) AS `count2` FROM `beaten` GROUP BY `user` HAVING `count2` &gt; \''.mysql_real_escape_string($x).'\' LIMIT 1'));
$z = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() as `ahead`'));
fwrite($irc,$cmd.' :.']] has beaten me '.(($x != '')?$x:'0').' times. There are '.$z.' users who have beaten me more times.'.&quot;\n&quot;);
unset($x,$y);
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'vandalcount':
if (preg_match(&quot;/\\]/&quot;,$data,$m)) {
$tmp = unserialize(file_get_contents('oftenvandalized.txt'));
if (isset($tmp])) {
fwrite($irc,$cmd.' :.']] has been vandalized '.count($tmp]).' time(s) in the last 48 hours.'.&quot;\n&quot;);
} else {
fwrite($irc,$cmd.' :.']] has not been vandalized in the last 48 hours.'.&quot;\n&quot;);
}
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'heuristics':
include 'cluebot.heuristics.config.php';
$stats = unserialize(file_get_contents('cluebot.heuristics.stats.txt'));
fwrite($irc,$cmd.' :I have the following heuristics enabled: '.implode(', ',$heuristics).&quot;.\n&quot;);
foreach ($stats as $heuristic =&gt; $count) {
fwrite($irc,$cmd.' :The '.$heuristic.' heuristic has been matched '.$count.' times.'.&quot;\n&quot;);
}
unset($count,$heuristic,$stats,$heuristics);
break;
case 'status':
$ov = unserialize(file_get_contents('oftenvandalized.txt'));
foreach ($ov as $title =&gt; $array) {
if (count($array) == 0) unset($ov);
}
file_put_contents('oftenvandalized.txt',serialize($ov));
$count = count($ov);

$titles = unserialize(file_get_contents('titles.txt'));
foreach ($titles as $title =&gt; $time) {
if ((time() - $time) &gt; (24*60*60)) {
unset($titles);
}
}
file_put_contents('titles.txt',serialize($titles));
$tcount = count($titles);

foreach ($ov as $x =&gt; $y) {
$ocount = count($y);
}
arsort($ocount);
foreach ($ocount as $x =&gt; $y) {
$mova = $x;
$movacount = $y;
break;
}

preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq-&gt;getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfa);
$tfa = $tfa;
if (!preg_match('/(yes|enable|true)/i',$wpq-&gt;getpage('User:'.$user.'/Run'))) {
$run = false;
} else {
$run = true;
}

$top5beat = array();

if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
$q = mysql_query('SELECT `user`,COUNT(`id`) AS `count` FROM `cluebot_enwiki`.`beaten` WHERE `user` != \'\' GROUP BY `user` HAVING `count` &gt; 1 ORDER BY `count` DESC LIMIT 5');
while ($x = mysql_fetch_assoc($q)) {
$top5beat = $x.' ('.$x.')';
}
unset($x,$q);
$top5beat = implode(' - ',$top5beat);

fwrite($irc,$cmd.' :I am '.$user.'. I am currently '.($run?'enabled':'disabled').'. I currently have '.$wpq-&gt;contribcount($user).' contributions.'.&quot;\n&quot;);

fwrite($irc,$cmd.' :I have attempted to revert '.$tcount.' unique article/user combinations in the last 24 hours. ' .
'I know of '.$count.' different articles that have been vandalized in the last 48 hours.'.&quot;\n&quot;
);

fwrite($irc,$cmd.' :] is the most vandalized page with a total of '.$movacount.' vandalisms in the last 48 hours. ' .
'Today\'s featured article is: ].'.&quot;\n&quot;
);

fwrite($irc,$cmd.' :The following users have beat me to the revert the most: '.$top5beat.&quot;\n&quot;);

fwrite($irc,$cmd.' :I log all information to '.$ircchannel.'. This channel is '.$d.'.'.&quot;\n&quot;);

unset($x,$y,$count,$ov,$tcount,$ocount,$mova,$movacount,$tfa,$run,$title,$titles,$time,$top5beat);
break;
case 'warninglevel':
if (preg_match(&quot;/\\]/&quot;,$data,$n)) {
$warning = 0;
if (preg_match_all('/&lt;!-- Template:(uw-*(\d)(im)?|Blatantvandal \(serious warning\)) --&gt;.*(\d{2}):(\d{2}), (\d+) (+) (\d{4}) \(UTC\)/iU',
$wpq-&gt;getpage('User talk:'.$n),
$match,PREG_SET_ORDER)
) {
foreach ($match as $m) {
$month = array('January' =&gt; 1, 'February' =&gt; 2, 'March' =&gt; 3,
'April' =&gt; 4, 'May' =&gt; 5, 'June' =&gt; 6, 'July' =&gt; 7,
'August' =&gt; 8, 'September' =&gt; 9, 'October' =&gt; 10,
'November' =&gt; 11, 'December' =&gt; 12
);
if ($m == 'Blatantvandal (serious warning)') $m = 4;
if ((time() - gmmktime($m,$m,0,$month],$m,$m)) &lt;= (2*24*60*60)) {
if ($m &gt; $warning) { $warning = $m; }
}
}
}
fwrite($irc,$cmd.' :.']] is at warning level '.$warning.&quot;.\n&quot;);
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'count':
if (preg_match(&quot;/\\]/&quot;,$data,$n)) {
fwrite($irc,$cmd.' :.']] has '.$wpq-&gt;contribcount($n).&quot; contributions.\n&quot;);
} else {
fwrite($irc,$cmd.' :Couldn\'t find link.'.&quot;\n&quot;);
}
break;
case 'help':
fwrite($irc,$cmd.' :Please see ].'.&quot;\n&quot;);
break;
case 'eval':
$tmp = explode(' ',$data,6);
$tmp1 = explode('!',substr($d,1));
if ($d == md5($thesecret.$tmp1.$tmp)) {
eval($tmp);
} else {
fwrite($irc,$cmd.' :Code incorrect.'.&quot;\n&quot;);
}
break;
case 'cbproxy':
$tmp = explode(' ',$data,6);
$tmp1 = explode('!',substr($d,1));
if ($tmp1 == 'ClueBot-Bopm') {
foreach (explode(',',$ircproxychannels) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :!admin '.$tmp.&quot;\n&quot;);
}
$data = $wpq-&gt;getpage('Misplaced Pages:WikiProject on open proxies');
if (strpos($data,$tmp) === false) {
$header = explode('{{proxyip2|127.0.0.1}} || Example',$data,2);
$header .= '{{proxyip2|127.0.0.1}} || Example ';
$footer = $header;
$header = $header;
$data = &quot;\n&quot;.'{{proxyip2|'.$tmp.'}} || '.$tmp.' ~~~~'.&quot;\n&quot;;
$data = $header.$data.$footer;
unset($header,$footer);
$wpi-&gt;post('Misplaced Pages:WikiProject on open proxies',$data,'Adding '.$tmp.'.');
unset($data);
}
}
break;
}
}
}
}
die();
}

$heuristics = &quot;==Heuristics==\n\n===Config (cluebot.heuristics.config.php)===\n\n&lt;pre&gt;&quot;.htmlentities(file_get_contents('cluebot.heuristics.config.php')).&quot;&lt;/pre&gt;\n\n&quot;;
foreach (glob('heuristics/cluebot.*.heuristic.php') as $heuristic) $heuristics .= '==='.$heuristic.&quot;===\n\n&lt;pre&gt;&quot;.htmlentities(file_get_contents($heuristic)).&quot;&lt;/pre&gt;\n\n&quot;;
unset($heuristic);

$wpi-&gt;forcepost('User:'.$user.'/Source',
'The following is automatically generated by ].\n\n\n\n==Classes (wikibot.classes.php)==\n\n&lt;pre&gt;&quot; .
htmlentities(file_get_contents('../wikibot.classes.php')).&quot;&lt;/pre&gt;\n\n\n\n==Diff function (diff.function.php)==\n\n&lt;pre&gt;&quot; .
htmlentities(file_get_contents('../diff.function.php')).&quot;&lt;/pre&gt;\n\n\n\n==Source to &quot;.$user .
&quot;==\n\n&quot;.'&lt;pre&gt;'.htmlentities(file_get_contents(__FILE__)).&quot;&lt;/pre&gt;\n\n\n\n&quot; .
$heuristics .
&quot;==Score list==\n\n&quot;.'&lt;pre&gt;'.htmlentities(file_get_contents('cluebot.scorelist.php')).&quot;&lt;/pre&gt;\n\n\n\n~~~~&quot;,
'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */

unset($heuristics);

$wpi-&gt;forcepost('User:'.$user,
&quot;{{User:ClueBot Commons/Userpage}}\n&quot;,
'Automated bot userpage set.'); /* Our page, we force post this because this is *our* page. */


$tfas = 0;
$pipe = fopen('thepipe','w');
$stdin = fopen('php://stdin','r');
$run = $wpq-&gt;getpage('User:'.$user.'/Run');
$wl = $wpq-&gt;getpage('User:'.$user.'/Whitelist');
$optin = $wpq-&gt;getpage('User:'.$user.'/Optin');
$aoptin = $wpq-&gt;getpage('User:'.$user.'/AngryOptin');

unset($tmp,$tmp2,$tmp3);

$tmp = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBAutostalk.js'));
foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk] = trim($tmp3); } }
$tmp = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBAutoedit.js'));
foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit] = trim($tmp3); } }
unset($tmp,$tmp2,$tmp3);

print_r($stalk); print_r($edit);

while (1) {
$feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30);

if (!$feed) {
sleep(10);
$feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30);
if (!$feed) die($feederrstr.' ('.$feederrno.')');
}

fwrite($feed,'USER '.$user.' &quot;1&quot; &quot;1&quot; :ClueBot Misplaced Pages Bot.'.&quot;\n&quot;);
fwrite($feed,'NICK '.$user.&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) == 'ping') {
fwrite($feed,'PONG '.$linea.&quot;\n&quot;);
} elseif (($linea == '376') or ($linea == '422')) {
fwrite($feed,'JOIN '.$feedchannel.&quot;\n&quot;);
} elseif ((strtolower($linea) == 'privmsg') and (strtolower($linea) == strtolower($feedchannel))) {
$message = substr($linea,1);
if (preg_match('/^\*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?title=*&amp;diff=(\d*)&amp;oldid=(\d*)|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* (*) \* (\((*)\))? (.*)$/S',$message,$m)) {
$messagereceived = microtime(1);
$change = $m;
$change = $m;
$change = $m;
$change = $m;
$change = $m;
$change = $m;
$change = $m;
$change = $m;
$change = $m;

// include 'cluebot.stalk.config.php';

$stalkchannel = array();
foreach ($stalk as $key =&gt; $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$value));
foreach ($stalkbots as $key =&gt; $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$ircbagtrialchannels));
foreach ($edit as $key =&gt; $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change.$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$value));
// if ($change == $owner) $stalkchannel = $ircchannel;

$stalkchannel = array_unique($stalkchannel);

foreach ($stalkchannel as $y) {
fwrite($irc,'PRIVMSG '.$y.' :New edit: .$change.']] http://en.wikipedia.org/search/?title=' .
urlencode($change.$change).'&amp;diff=prev'.'&amp;oldid='.urlencode($change).' * '.$change .
' * '.$change.&quot;\n&quot;);
}
if (($change == 'User:') or ($change == 'User talk:')) {
if (strtolower($change) == strtolower($user.'/Run')) { $run = $wpq-&gt;getpage('User:'.$user.'/Run'); }
if (strtolower($change) == strtolower($user.'/Whitelist')) { $wl = $wpq-&gt;getpage('User:'.$user.'/Whitelist'); }
if (strtolower($change) == strtolower($user.'/Optin')) { $optin = $wpq-&gt;getpage('User:'.$user.'/Optin'); }
if (strtolower($change) == strtolower($user.'/AngryOptin')) { $aoptin = $wpq-&gt;getpage('User:'.$user.'/AngryOptin'); }
if (strtolower($change) == strtolower($owner.'/CBAutostalk.js')) {
unset($stalk);
$tmp = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBAutostalk.js'));
foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk] = trim($tmp3); } }
unset($tmp,$tmp2,$tmp3);
print_r($stalk);
}
if (strtolower($change) == strtolower($owner.'/CBAutoedit.js')) {
unset($edit);
$tmp = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBAutoedit.js'));
foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit] = trim($tmp3); } }
unset($tmp,$tmp2,$tmp3);
print_r($edit);
}
if (strtolower($change) == strtolower($owner.'/CBChannels.js')) {
$ircconfig = explode(&quot;\n&quot;,$wpq-&gt;getpage('User:'.$owner.'/CBChannels.js'));
$tmp = array();
foreach($ircconfig as $tmpline) { if (substr($tmpline,0,1) != '#') { $tmpline = explode('=',$tmpline,2); $tmp)] = trim($tmpline); } }
print_r($tmp);

$tmpold = array();
$tmpnew = array();
foreach ($tmp as $tmp2) foreach (explode(',',$tmp2) as $tmp3) $tmpnew = 1;
foreach (explode(',',$ircchannel.','.$ircdebugchannel.','.$ircreportchannel.','.$ircvandalismchannel.','.$ircaivchannel.','.$irctechchannel.','.$ircproxychannels.','.$ircunrevertedchannels.','.$ircbagtrialchannels.','.$ircotherchannels) as $tmp3) $tmpold = 1;

foreach ($tmpold as $tmp2 =&gt; $tmp3) if (isset($tmpnew)) unset($tmpold,$tmpnew);
foreach ($tmpnew as $tmp2 =&gt; $tmp3) $tmpnew1 = $tmp2;
foreach ($tmpold as $tmp2 =&gt; $tmp3) $tmpold1 = $tmp2;

$tmpold = $tmpold1; $tmpnew = $tmpnew1; unset($tmpold1,$tmpnew1);

fwrite($irc,'JOIN '.implode(',',$tmpnew).&quot;\n&quot;);
fwrite($irc,'PART '.implode(',',$tmpold).&quot;\n&quot;);

$ircchannel = $tmp;
$ircdebugchannel = $tmp;
$ircreportchannel = $tmp;
$ircvandalismchannel = $tmp;
$ircaivchannel = $tmp;
$irctechchannel = $tmp;
$ircproxychannels = $tmp;
$ircunrevertedchannels = $tmp;
$ircbagtrialchannels = $tmp;
$ircotherchannels = $tmp;

unset($tmp,$tmpline,$tmpold,$tmpnew,$tmp2,$tmp3);
}
}
if ($change.$change == 'Misplaced Pages:Bots/Requests for approval') {
$stalkbots = array();
$trialbots = explode(&quot;\n&quot;,$wpq-&gt;getpage('Misplaced Pages:Bots/Requests for approval'));
foreach ($trialbots as $trialbot) if (preg_match('/\{\{BRFA\|(.*)\|.*\|Trial\}\}/',str_replace(array(&quot;\n&quot;,&quot;\r&quot;),'',$trialbot),$m)) $stalkbots] = 1;
}

if (($change != '') and ((!preg_match('/\* \.$change,'/').')\]\] \- .*/i',$optin))) and ($change != 'move') and ($change != 'Template:')) continue;

$change = $change;
$change = $change.$change;

if ($change == 'move') {
if (preg_match('/moved \\] to \\]( over redirect)?: (.*)$/',$change,$m)) {
$change = $m;
$change = $m;
$change = $change;
$change = $m;
echo &quot;\n\n\n&quot;.'Move!'.&quot;\n\n\n&quot;;
print_r($change);
echo &quot;\n\n\n&quot;.'Move!'.&quot;\n\n\n&quot;;
}
}

if (
((time() - $tfas) &gt;= 1800)
and (preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq-&gt;getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfam))
) {
$tfas = time();
$tfa = $tfam;
//echo &quot;TFA: &quot;.$tfa.&quot;\n&quot;;
}
$s = null;
$pid = @pcntl_fork();
if ($pid != 0) continue;

$hutime = microtime(1);

include 'cluebot.heuristics.config.php';
foreach ($heuristics as $heuristic) {
$heuristicret = false;
include 'heuristics/cluebot.'.$heuristic.'.heuristic.php';
if ($heuristicret == true) {
$stats = unserialize(file_get_contents('cluebot.heuristics.stats.txt'));
$stats++;
print_r($log);
file_put_contents('cluebot.heuristics.stats.txt',serialize($stats));
unset($stats);
break;
}
}

if ($heuristicret == true) { echo 'Heuristics time: '.(microtime(1) - $hutime).&quot;\n&quot;; file_put_contents('trainingdata.txt',$change.&quot;\0&quot;.$change.&quot;\0&quot;.'1'.&quot;\n&quot;,FILE_APPEND); }
else {
$tmp = explode(' ',$rawline,4); $tmp = $tmp;
$udp = fsockopen('udp://localhost',3333);
fwrite($udp,substr(str_replace(array(&quot;\n&quot;,&quot;\r&quot;),'',$tmp),1).&quot;\n&quot;);
fclose($udp);
unset($tmp,$udp);
$d = $wpi-&gt;diff($change,$change,$change);
$s = score($obscenelist,$d,$log);
$s -= score($obscenelist,$d,$log);
if ($s &gt; 15) file_put_contents('trainingdata.txt',$change.&quot;\0&quot;.$change.&quot;\0&quot;.'0'.&quot;\n&quot;,FILE_APPEND);
}
unset($hutime);

if (
($heuristicret == true)
) {
if (
(
( /* IP users with 250 contributions are fine .. */
(long2ip(ip2long($change)) == $change)
/* and ($uc = $wpapi-&gt;usercontribs($change,250))
and (!isset($uc)) */
)
or ( /* Users with 50 contributions are fine .. */
(long2ip(ip2long($change)) != $change)
and ($wpq-&gt;contribcount($change) &lt; 50)
)
)
and ( /* Whitelisted users are ok. */
/* ($wl = $wpq-&gt;getpage('User:'.$user.'/Whitelist'))
and */ (!preg_match('/^\* \,'/').')|\1\]\] \- .*/',$wl))
)
) {
// $vandalpage = $wpq-&gt;getpage('User:'.$user.'/PossibleVandalism');
// $x = explode(&quot;\n\n&quot;,$vandalpage);
// foreach ($x as $k =&gt; $y) {
// if (preg_match('/(\d+)\-(\d+)\-(\d+)T(\d+):(\d+):(\d+)/',$y,$m)) {
// if ((time() - gmmktime($m,$m,$m,$m,$m,$m)) &gt; (5*60*60)) {
// unset($x);
// }
// }
// }
// $vandalpage = implode(&quot;\n\n&quot;,$x);
$diff = 'http://en.wikipedia.org/search/' .
'?title='.urlencode($change) .
'&amp;diff='.urlencode($change) .
'&amp;oldid='.urlencode($change);

$report = '.']] was ' .
(($change != 'move')?' by ':'moved to .']] by ') .
'.'|'.$change.']] ' .
'.'|(u)]] ' .
'.'|(t)]] ' .
$reason.' on '.gmdate('c');
// $datatopost = $vandalpage.&quot;\n\n&quot;.'Possible ]: '.$report.&quot; ~~~~\n&quot;;


if ($s == null) {
// $rv = $wpapi-&gt;revisions($change,2,'older',true,$change);
// $s = score($scorelist,diff($rv,$rv));
// $s += (score($scorelist,diff($rv,$rv,false))) * -1;
$s = 'N/A';
}

$tmp = unserialize(file_get_contents('oftenvandalized.txt'));
foreach ($tmp as $key1 =&gt; $tmp2) {
foreach ($tmp2 as $key2 =&gt; $time) {
if ((time() - $time) &gt; (2*24*60*60)) { unset($tmp); }
}
}
$tmp] = time();
if (count($tmp]) &gt;= 30) {
foreach (explode(',',$ircreportchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :!admin .']] has been vandalized '.(count($tmp])).' times in the last 2 days.'.&quot;\n&quot;);
}
}
file_put_contents('oftenvandalized.txt',serialize($tmp));

if (
(
($rv1 = $wpapi-&gt;revisions($change,1,'older'))
and ($rv1 == $change)
)
or ($change == 'move')
) { /* No need to continue further if it has been reverted */
echo 'Possible vandalism: '.$change.' changed by '.$change.' '.$reason.' on '.$rv.'('.$s.&quot;).\n&quot;;
foreach (explode(',',$ircdebugchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :Possible vandalism: '.$change.' changed by '.$change.' '.$reason.' on '.$rv.'('.$s.&quot;).\n&quot;);
fwrite($irc,'PRIVMSG '.$y.' :( http://en.wikipedia.org/search/?title='.urlencode($change).'&amp;action=history | '.$change.' )'.&quot;\n&quot;);
}
fwrite($pipe,'http://en.wikipedia.org/search/?title='.urlencode($change).'&amp;action=history'.&quot;\n&quot;); /* Tell owner */

$mqtime = microtime(1);

if (is_array($log)) {
$logt = '';
foreach ($log as $k =&gt; $v) {
$logt .= '* '.$v.' * &quot;'.$k.'&quot;'.&quot;\n&quot;;
}
}

$query = 'INSERT INTO `vandalism` ' .
'(`id`,`user`,`article`,`heuristic`'.((is_array($log))?',`regex`':'').',`reason`,`diff`,`old_id`,`new_id`,`reverted`) ' .
'VALUES ' .
'(NULL,\''.mysql_real_escape_string($change).'\',' .
'\''.mysql_real_escape_string($change).'\',' .
'\''.mysql_real_escape_string($heuristic).'\',' .
((is_array($log))?'\''.mysql_real_escape_string($logt).'\',':'') .
'\''.mysql_real_escape_string($reason).'\',' .
'\''.mysql_real_escape_string($change).'\',' .
'\''.mysql_real_escape_string($change).'\',' .
'\''.mysql_real_escape_string($change).'\',0)';
//echo 'Mysql query: '.$query.&quot;\n&quot;;
if (!mysql_ping($mysql)) {
$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
if (!$mysql) { die('Could not connect: ' . mysql_error()); }
if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }
}
mysql_query($query);
//echo 'Mysql error: '.mysql_error().&quot;\n&quot;;
$mysqlid = mysql_insert_id();
echo 'MySQL time: '.(microtime(1) - $mqtime).' MySQL id: '.$mysqlid.&quot;\n&quot;;
unset($mqtime);

if (
(
(
(preg_match('/(assisted|manual)/iS',$status))
and (print('Revert ? '))
and (strtolower(substr(fgets($stdin,3),0,1)) == 'y')
)
or (
(preg_match('/(read-write|rw|go|approved|trial)/iS',$status))
)
)
and (
(
(
((time() - $tfas) &lt; 1800)
or (
(preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq-&gt;getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfam))
and ($tfas = time())
and ($tfa = $tfam)
and ((print(&quot;TFA: &quot;.$tfa.&quot;\n&quot;)) or (true))
)
)
and ($tfa == $change)
)
or (
(preg_match('/\* \,'/').')\]\] \- .*/i',$aoptin))
and ((fwrite($irc,'PRIVMSG '.$ircdebugchannel.' :Angry-reverting .']].'.&quot;\n&quot;)) or (true))
)
or (
(($tmp = unserialize(file_get_contents('titles.txt'))) !== false)
and ((!isset($tmp.$change])) or ((time() - $tmp.$change]) &gt; (24*60*60)))
and ($tmp.$change] = time())
and ((file_put_contents('titles.txt',serialize($tmp))) !== false)
)
)
) {
echo 'Reverting ...'.&quot;\n&quot;;
if ($change != 'move') {
$rev = $wpapi-&gt;revisions($change,5,'older',false,null,true,true);
$revid = 0;
$rbtok = $rev;
foreach ($rev as $revdata) {
if ($revdata != $change) {
$revid = $revdata;
break;
}
}
if (($revdata == $user) or (in_array($revdata,explode(',',$botfriends)))) { die(); /* Do not revert to us. */ }
}
// if ($revid == 0) { die(); }
foreach (explode(',',$ircdebugchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :Reverting ...'.&quot;\n&quot;);
}
// $revisiondata = $wpapi-&gt;revisions($change,1,'older',true,$revid);
// if (!$revisiondata) die();
// if (!$rv1) $rv1 = $rv;
// $wpi-&gt;post(
// $change,
// $revisiondata,
// 'Reverting possible vandalism by .'|'.$change.']] ' .
// 'to version by '.$revisiondata.'. ' .
// 'False positive? ]. '.
// 'Thanks, ]. ('.$mysqlid.') (Bot)',
// false,
// $rv1
// ); /* Revert the page */
if ($change != 'move') {
if (!$rbtok) {
$d = $wpi-&gt;diff($change,$change,$change);
$rbtok = $d;
}
$rbret = $wpi-&gt;rollback(
$change,
$change,
'Reverting possible vandalism by .'|'.$change.']] ' .
'to '.(($revid == 0)?'older version':'version by '.$revdata).'. ' .
'False positive? ]. '.
'Thanks, ]. ('.$mysqlid.') (Bot)',
$rbtok,
false
);
} else {
$rbret = $wpi-&gt;move(
$change,
$change,
'Reverting possible vandalism by .'|'.$change.']] ' .
'to '.(($revid == 0)?'older version':'version by '.$revdata).'. ' .
'False positive? ]. '.
'Thanks, ]. ('.$mysqlid.') (Bot)'
);
}
//
// $rv2 = $wpapi-&gt;revisions($change,1);
// if ($rv2 == $user) {
if ($rbret !== false) {
foreach (explode(',',$ircdebugchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :Reverted. ('.(microtime(1) - $messagereceived).' s)'.&quot;\n&quot;);
}
$warning = 0;
$tpcontent = $wpq-&gt;getpage('User talk:'.$change);
if (preg_match_all('/&lt;!-- Template:(uw-*(\d)(im)?|Blatantvandal \(serious warning\)) --&gt;.*(\d{2}):(\d{2}), (\d+) (+) (\d{4}) \(UTC\)/iU',
$tpcontent,
$match,PREG_SET_ORDER)
) {
foreach ($match as $m) {
$month = array('January' =&gt; 1, 'February' =&gt; 2, 'March' =&gt; 3,
'April' =&gt; 4, 'May' =&gt; 5, 'June' =&gt; 6, 'July' =&gt; 7,
'August' =&gt; 8, 'September' =&gt; 9, 'October' =&gt; 10,
'November' =&gt; 11, 'December' =&gt; 12
);
if ($m == 'Blatantvandal (serious warning)') $m = 4;
if ((time() - gmmktime($m,$m,0,$month],$m,$m)) &lt;= (2*24*60*60)) {
if ($m &gt; $warning) { $warning = $m; }
}
}
}
$warning++;
if ($warning == 5) { /* Report them if they have been warned 4 times. */
$aivdata = $wpq-&gt;getpage('Misplaced Pages:Administrator_intervention_against_vandalism/TB2');
if (!preg_match('/'.preg_quote($change,'/').'/i',$aivdata)) {
foreach(explode(',',$ircaivchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :!admin Reporting .']] to ]. Contributions: .']] Block: .']]'.&quot;\n&quot;);
}
foreach (explode(',',$ircvandalismchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :computer bl add '.$change.' x='.(24*$warning).' r=Vandalism to .']] (#'.$warning.&quot;).\n&quot;);
}
$wpi-&gt;post(
'Misplaced Pages:Administrator_intervention_against_vandalism/TB2',
$aivdata .
&quot;\n\n* {{&quot;.((long2ip(ip2long($change)) == $change)?'IPvandal':'Vandal').'|'.$change.'}}' .
' - '.$report.&quot; (Automated) ~~~~\n&quot;,
'Automatically reporting .']]. (bot)',
false,
null,
false
);
} else {
foreach (explode(',',$ircreportchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :!admin .']] has vandalized at least one time while being listed on ]. Contributions: .']] Block: .']]'.&quot;\n&quot;);
}
}
} elseif ($warning &lt; 5) { /* Warn them if they haven't been warned 4 times. */
foreach (explode(',',$ircvandalismchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :computer bl add '.$change.' x='.(24*$warning).' r=Vandalism to .']] (#'.$warning.').'.&quot;\n&quot;);
}
$wpi-&gt;post(
'User talk:'.$change,
$tpcontent.&quot;\n\n&quot; .
'{{subst:User:'.$user.'/Warnings/Warning|1='.$warning.'|2='.$change.'|3='.$report.' &lt;!{{subst:ns:0}}-- MySQL ID: '.$mysqlid.' --{{subst:ns:0}}&gt;}} ~~~~'.&quot;\n&quot;,
'Warning .'|'.$change.']] - #'.$warning,
false,
null,
false
); /* Warn the user */
} else { /* They have already been reported ... do nothing */

}
if (!mysql_ping($mysql)) {
$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
if (!$mysql) { die('Could not connect: ' . mysql_error()); }
if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }
}
mysql_query('UPDATE `vandalism` SET `reverted` = 1 WHERE `id` = \''.mysql_real_escape_string($mysqlid).'\'');
} else {
$rv2 = $wpapi-&gt;revisions($change,1);
if ($change != $rv2) {
echo 'Grr! Beaten by '.$rv2.&quot;.\n&quot;;
foreach(explode(',',$ircdebugchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :Grr! Beaten by '.$rv2.&quot;.\n&quot;);
}
if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($rv2).'\')');
}
}
} else {
foreach (explode(',',$ircunrevertedchannels) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :'.&quot;\002\00304Possible ignored vandalism: \002\003.&quot;\003]]\00304 changed by \003.&quot;\003]] \00303&quot;.$reason.&quot;\00304 on \00307&quot;.$rv.&quot;\003(\002\00313&quot;.$s.&quot;\003).\n&quot;);
fwrite($irc,'PRIVMSG '.$y.' :'.&quot;\002(\002\00312 http://en.wikipedia.org/search/?title=&quot;.urlencode($change).&quot;&amp;action=history \003\002|\002\00312 &quot;.$change.&quot; \003\002)\002&quot;.&quot;\n&quot;);
}
}

} else {
$rev = $wpapi-&gt;revisions($change,1);
$rev = $rev;

echo 'Possible corrected vandalism: '.$change.' changed by '.$change.' '.$reason.'('.$s.&quot;)\n\tReverted by &quot;.$rev.&quot; before I saw it.\n&quot;;
foreach (explode(',',$ircdebugchannel) as $y) {
fwrite($irc,'PRIVMSG '.$y.' :Possible corrected vandalism: '.$change.' changed by '.$change.' '.$reason.'('.$s.&quot;)\n&quot;);
fwrite($irc,'PRIVMSG '.$y.' :Reverted by '.$rev.&quot; before I saw it.\n&quot;);
}
if (($rev != $user) and ($rev != $change)) {
if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($rev).'\')');
}
}
}
}
die();
}
}
}
}
?&gt;
</pre>



==Heuristics==

===Config (cluebot.heuristics.config.php)===

<pre>&lt;?PHP
$heuristics = 'grawp';
$heuristics = 'evolution';
$heuristics = 'avrillavigne';
$heuristics = 'editsummary';
$heuristics = 'pagereplace';
$heuristics = 'pageblank';
$heuristics = 'massdelete';
$heuristics = 'massadd';
$heuristics = 'tables';
$heuristics = 'smallchange';
$heuristics = 'claimjumperpete';
$heuristics = 'redirect';
?&gt;
</pre>

===heuristics/cluebot.avrillavigne.heuristic.php===

<pre>&lt;?PHP
if ( /* The Avril Lavigne vandal */
(
(preg_match('/avril\s*lavigne\s*roc*k**\s*my\s*soc*k**/i',$change))
or (preg_match('/she\s*(is\s*)*(so\s*)*.*hot\!.*using.*TW/i',$change))
or (
($change == 'Template:')
and (preg_match('/\{\{user((\s|_)talk)?:/i',$wpq-&gt;getpage($change)))
)
)
and ($reason = 'Avril Lavigne vandal?')
) {
$heuristicret = true;
fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Avril Lavigne vandal? http://en.wikipedia.org/Special:Contributions/'.$change.&quot; .\n&quot;);
}
?&gt;
</pre>

===heuristics/cluebot.claimjumperpete.heuristic.php===

<pre>&lt;?PHP
if ( /* The ClaimJumperPete vandal */
(($change &gt;= 100) and ($change &lt;= 400))
and (
($change &lt;= 200)
or ($d = $wpi-&gt;diff($change,$change,$change))
)
and (
(fnmatch(&quot;&lt;!--*howdy y'all*--&gt;*&quot;,trim(strtolower($d))))
or (fnmatch(&quot;&lt;!--*hello der*--&gt;*&quot;,trim(strtolower($d))))
or (fnmatch(&quot;&lt;!--*happy editin' y'all*--&gt;*&quot;,trim(strtolower($d))))
)
and ($reason = 'ClaimJumperPete?')
) {
$heuristicret = true;
fwrite($irc,'PRIVMSG #cvn-wp-en :!admin ClaimJumperPete vandal? http://en.wikipedia.org/search/?title='.urlencode($change).'&amp;diff=prev'.'&amp;oldid='.urlencode($change).&quot; .\n&quot;);
}
?&gt;
</pre>

===heuristics/cluebot.editsummary.heuristic.php===

<pre>&lt;?PHP
if (
(
(fnmatch('*nimp*org*',strtolower($change)))
)
and ($reason = 'obscenities in edit summary')
) {
$heuristicret = true;
}
?&gt;
</pre>

===heuristics/cluebot.evolution.heuristic.php===

<pre>&lt;?PHP
if ( /* The Evolution vandal */
($change == 'Evolution')
and (($pagedata = $wpq-&gt;getpage($change)) or true)
and (fnmatch('*Genesis 1*The beginning*',$pagedata))
and ($reason = 'replacing article with the Bible')
) {
$heuristicret = true;
fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Evolution vandal? http://en.wikipedia.org/search/?title='.urlencode($change).'&amp;diff=prev'.'&amp;oldid='.urlencode($change).&quot; .\n&quot;);
}
?&gt;
</pre>

===heuristics/cluebot.grawp.heuristic.php===

<pre>&lt;?PHP
if ( /* The Grawp vandal */
(
(fnmatch('*epic*lulz*on*nimp*org*',strtolower($change)))
or (fnmatch('*on*nimp*org*epic*lulz*',strtolower($change)))
or (fnmatch('*punishing*wikipedia*',strtolower($change)))
or (fnmatch('*anti*avril*hate*campaign*',strtolower($change)))
or (fnmatch('*hagger*',strtolower($change)))
or (fnmatch('*h?a?g?g?e?r*',strtolower($change)))
or (fnmatch('*h??a??g??g??e??r*',strtolower($change)))
or (fnmatch('*grawp*cock*',strtolower($change)))
or (fnmatch('*massive*cock*',strtolower($change)))
or (fnmatch('*grawp*dick*',strtolower($change)))
or (fnmatch('*massive*dick*',strtolower($change)))
or (fnmatch('*h?g?g?e?r*',strtolower($change)))
or (fnmatch('*hgger*',strtolower($change)))
)
and ($reason = 'Grawp?')
) {
$heuristicret = true;
fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Grawp vandal? http://en.wikipedia.org/Special:Contributions/'.$change.&quot; .\n&quot;);
}
?&gt;
</pre>

===heuristics/cluebot.massadd.heuristic.php===

<pre>&lt;?PHP
if ( /* Massive additions */
($change &gt;= 7500)
and ($rv = $wpapi-&gt;revisions($change,2,'older',true,$change))
and ($pagedata = $wpq-&gt;getpage($change))
and ($s = score($scorelist,$rv))
and ($s += (score($scorelist,$rv)) * -1)
and ($s &lt; -1000)
and ($reason = 'score equals '.$s)
) $heuristicret = true;
?&gt;
</pre>

===heuristics/cluebot.massdelete.heuristic.php===

<pre>&lt;?PHP
if ( /* Massive deletes */
($change &lt;= -7500)
and ($pagedata = $wpq-&gt;getpage($change))
and (!fnmatch('*#REDIRECT*',strtoupper(substr($pagedata,0,9))))
and ($rv = $wpapi-&gt;revisions($change,2,'older',true,$change))
and ($s = score($scorelist,$rv))
and ($s += (score($scorelist,$rv)) * -1)
and ($s &lt; -50) /* There are times when massive deletes are ok. */
and ($reason = 'deleting '.($change * -1).' characters')
) $heuristicret = true;
?&gt;
</pre>

===heuristics/cluebot.pageblank.heuristic.php===

<pre>&lt;?PHP
if ( /* Page blanks */
(preg_match('/\,$m))
and (($pagedata = $wpq-&gt;getpage($change)) or true)
and ($fc = $wpapi-&gt;revisions($change,1,'newer'))
and ($fc != $change) /* The creator is allowed to blank the page. */
and ($reason = 'blanking the page')
) $heuristicret = true;
?&gt;
</pre>

===heuristics/cluebot.pagereplace.heuristic.php===

<pre>&lt;?PHP
if ( /* Page replaces */
(preg_match('/\\]Replaced page with (.*)$/',$change,$m))
and ($pagedata = $wpq-&gt;getpage($change))
and ($fc = $wpapi-&gt;revisions($change,1,'newer'))
and ($fc != $change) /* The creator is allowed to replace the page. */
and ($reason = 'replacing entire content with something else')
) $heuristicret = true;
?&gt;
</pre>

===heuristics/cluebot.redirect.heuristic.php===

<pre>&lt;?PHP
if ( /* The Redirect vandals */
(
($tfa == $change)
and (fnmatch('*#redirect *',strtolower($wpq-&gt;getpage($change))))
and ($reason = 'redirecting featured article to new title')
)
or (
($pagedata = $wpq-&gt;getpage($change))
and (fnmatch('*#redirect *',strtolower($pagedata)))
and (preg_match('/\\]/',$pagedata,$m))
and (!$wpq-&gt;getpage($m))
and ($reason = 'redirecting article to non-existant page')
)
) {
$heuristicret = true;
// fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Grawp vandal? http://en.wikipedia.org/Special:Contributions/'.$change.&quot; .\n&quot;);
}
?&gt;
</pre>

===heuristics/cluebot.smallchange.heuristic.php===

<pre>&lt;?PHP
unset($log,$log2);
if ( /* Small changes with obscenities. */
(($change &gt;= -200) and ($change &lt;= 200))
and (($d = $wpi-&gt;diff($change,$change,$change)) or true)
and ((($change == 'User:ClueBot/Sandbox') and print_r($rv)) or true)
and (($s = score($obscenelist,$d,$log)) or true)
and (($s -= score($obscenelist,$d,$log2)) or true)
and (
(
($s &lt; -5) /* There are times when small changes are ok. */
and (($rv = $wpapi-&gt;revisions($change,2,'older',true,$change)) or true)
and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
and (!fnmatch('*SEX*',strtoupper($rv)))
and (!fnmatch('*BDSM*',strtoupper($rv)))
and (score($obscenelist,$change) &gt;= 0)
and (score($obscenelist,$rv) &gt;= 0)
and (!preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\&lt;|\()?censored(\&gt;|\))?)(ing?|ed)?(\s|$)/iS',$rv))
and ($heuristic .= '/obscenities')
and ($reason = 'making a minor change with obscenities')
)
or (
($s &gt; 5)
and (($rv = $wpapi-&gt;revisions($change,2,'older',true,$change)) or true)
and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
and (!preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\&lt;|\()?censored(\&gt;|\))?)(ing?|ed)?(\s|$)/iS',$rv))
and (preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\&lt;|\()?censored(\&gt;|\))?)(ing?|ed)?(\s|$)/iS',$rv))
and ($heuristic .= '/censor')
and ($reason = 'making a minor change censoring content (])')
)
or (
(preg_match('/\!\!\!/S',$d))
and (($rv = $wpapi-&gt;revisions($change,2,'older',true,$change)) or true)
and (!preg_match('/\!\!\!/S',$rv))
and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
and ($heuristic .= '/exclamation')
and ($reason = 'making a minor change adding &quot;!!!&quot;')
)
)
) { $heuristicret = true; if (isset($log2) and is_array($log2)) foreach ($log2 as $k =&gt; $v) $log -= $v; if (isset($log) and is_array($log)) foreach ($log as $k =&gt; $v) if ($v == 0) unset($log); unset($log2); /* fwrite($irc,'PRIVMSG #wikipedia-BAG/ClueBot :Would revert http://en.wikipedia.org/search/?title='.urlencode($change.$change).'&amp;diff=prev'.'&amp;oldid='.urlencode($change).&quot; .\n&quot;); */ }
?&gt;
</pre>

===heuristics/cluebot.tables.heuristic.php===

<pre>&lt;?PHP
if ( /* Massive tables */
($change &gt;= 7500)
and ($rv = $wpapi-&gt;revisions($change,2,'older',true,$change))
and (substr_count(strtolower($rv),'&lt;td') &gt; 300)
and ($reason = 'adding huge, browser-crashing tables')
) $heuristicret = true;
?&gt;
</pre>

==Score list==

<pre>&lt;?PHP
/*
* This page contains bad words out of necessity.
* Here is 50 lines of whitespace before the actual list:
* (scroll down to see the list)
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* Here is the list:
*/
$obscenelist = Array
(
/* 'preg' =&gt; points, */
'/suck/i' =&gt; -5, /* Usually bad words */
'/stupid/i' =&gt; -3,
'/haha/i' =&gt; -5,
'/\bomg/i' =&gt; -3,
'/\bpimp\b/i' =&gt; -7,
'/1337/i' =&gt; -5,
'/leet/i' =&gt; -5,
'/dumb/i' =&gt; -5,
'/\bputa\b/i' =&gt; -7,
'/\bhomo\b/i' =&gt; -7,
'/\bGAY\b/' =&gt; -10,
'/\bslut/i' =&gt; -5,
'/damn/i' =&gt; -5,
'/\bass\b/i' =&gt; -10,
'/\brape\b/i' =&gt; -7,
'/\bpoop\b/i' =&gt; -10,
'/\bcock\b/i' =&gt; -10,
'/\blol\b/i' =&gt; -7,
'/\bcrap\b/i' =&gt; -5,
'/\bsex\b/i' =&gt; -5,
'/noob/i' =&gt; -5,
'/\bnazi\b/i' =&gt; -3,
'/\bneo-nazi\b/i' =&gt; +3, /* False-positive */
'/fuck/i' =&gt; -20, /* Stronger bad words */
'/\\]/' =&gt; +20, /* This one is a false positive */
'/bitch/i' =&gt; -20,
'/\bpussy\b/i' =&gt; -20,
'/penis/i' =&gt; -20,
'/vagina/i' =&gt; -20,
'/whore/i' =&gt; -15,
'/\bshit\b/i' =&gt; -20,
'/nigger/i' =&gt; -20,
'/\bnigga\b/i' =&gt; -20,
'/cocksucker/i' =&gt; -20,
'/assrape/i' =&gt; -15,
'/motherfucker/i' =&gt; -20,
'/wanker/i' =&gt; -20,
'/\bcunt\b/i' =&gt; -20,
'/faggot/i' =&gt; -20,
'/fags/i' =&gt; -20,
'/asshole/i' =&gt; -15,
'/fuck ((yo)?u|h(er|im)|them|it)/i' =&gt; -100, /* This looks like a personal attack */
'/((yo)?u|s?he|we|they|it) sucks?/i' =&gt; -100, /* This looks like a personal attack */
'/666+\b/i' =&gt; -50 /* Though this has uses, it is commonly used by vandals */
);
$grammarlist = Array
(
'/(.{1,4})\1{30}/' =&gt; -10, /* Ugg .. the same letter(s) several times in a row. */
'/\b.*\b/U' =&gt; +2, /* This looks to be a correct sentence */
'/\b{30,}\b/U' =&gt; -10, /* All capitals? Looks like vandal activity */
'/\b{1500,}\b/U' =&gt; -10, /* No capitals? Looks like vandal activity */
'/!{5,}/i' =&gt; -10, /* No[REDACTED] article needs '!!!!!' in it */
'/!!+1+(one)*/i' =&gt; -30, /* No[REDACTED] article needs '!!!11one' in it */
'/\\]/U' =&gt; +1, /* Wiki links are good. */
'/\{\{.*\}\}/U' =&gt; +5, /* Wiki transcludes are good. */
'/\{\{nfobox .*\}\}/U' =&gt; +20, /* Wiki infoboxes are good. */
'/\\]/iU' =&gt; +3 /* Wiki categories are good. */
);
$scorelist = array_merge($obscenelist,$grammarlist);
?&gt;
</pre>



] (]) 20:12, 31 July 2008 (UTC)

Revision as of 15:06, 2 August 2008

The following is automatically generated by ClueBot.


Classes (wikibot.classes.php)

<?PHP
	class http {
		private $ch;
		private $uid;
		public $postfollowredirs;
		public $getfollowredirs;
		function data_encode ($data, $keyprefix = "", $keypostfix = "") {
			assert( is_array($data) );
			$vars=null;
			foreach($data as $key=>$value) {
				if(is_array($value)) $vars .= $this->data_encode($value, $keyprefix.$key.$keypostfix.urlencode(""));
				else $vars .= $keyprefix.$key.$keypostfix."=".urlencode($value)."&";
			}
			return $vars;
		}
		function __construct () {
			$this->ch = curl_init();
			$this->uid = dechex(rand(0,99999999));
			curl_setopt($this->ch,CURLOPT_COOKIEJAR,'/tmp/cluewikibot.cookies.'.$this->uid.'.dat');
			curl_setopt($this->ch,CURLOPT_COOKIEFILE,'/tmp/cluewikibot.cookies.'.$this->uid.'.dat');
			curl_setopt($this->ch,CURLOPT_MAXCONNECTS,100);
			curl_setopt($this->ch,CURLOPT_CLOSEPOLICY,CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
			$this->postfollowredirs = 0;
			$this->getfollowredirs = 1;
		}
		function post ($url,$data) {
//			echo 'POST: '.$url."\n";
			$time = microtime(1);
			curl_setopt($this->ch,CURLOPT_URL,$url);
			curl_setopt($this->ch,CURLOPT_FOLLOWLOCATION,$this->postfollowredirs);
			curl_setopt($this->ch,CURLOPT_MAXREDIRS,10);
			curl_setopt($this->ch,CURLOPT_HEADER,0);
			curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
			curl_setopt($this->ch,CURLOPT_TIMEOUT,30);
			curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,10);
			curl_setopt($this->ch,CURLOPT_POST,1);
//			curl_setopt($this->ch,CURLOPT_POSTFIELDS, substr($this->data_encode($data), 0, -1) );
			curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data);
			$data = curl_exec($this->ch);
			//var_dump($data);
			echo 'POST: '.$url.' ('.(microtime(1) - $time).' s) ('.strlen($data)." b)\n";
			return $data;
		}
		function get ($url) {
			//echo 'GET: '.$url."\n";
			$time = microtime(1);
			curl_setopt($this->ch,CURLOPT_URL,$url);
			curl_setopt($this->ch,CURLOPT_FOLLOWLOCATION,$this->getfollowredirs);
			curl_setopt($this->ch,CURLOPT_MAXREDIRS,10);
			curl_setopt($this->ch,CURLOPT_HEADER,0);
			curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
			curl_setopt($this->ch,CURLOPT_TIMEOUT,30);
			curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,10);
			curl_setopt($this->ch,CURLOPT_HTTPGET,1);
			$data = curl_exec($this->ch);
			//var_dump($data);
			echo 'GET: '.$url.' ('.(microtime(1) - $time).' s) ('.strlen($data)." b)\n";
			return $data;
		}
		function __destruct () {
			curl_close($this->ch);
			@unlink('/tmp/cluewikibot.cookies.'.$this->uid.'.dat');
		}
	}
	class wikipediaquery {
		private $http;
		public $queryurl = 'http://en.wikipedia.org/w/query.php';
		function __construct () {
			global $__wp__http;
			if (!isset($__wp__http)) {
				$__wp__http = new http;
			}
			$this->http = &$__wp__http;
		}
		function getpage ($page) {
			$ret = unserialize($this->http->get($this->queryurl.'?what=content&format=php&titles='.urlencode($page)));
			foreach ($ret as $page) {
				return $page;
			}
		}
		function getpageid ($page) {
			$ret = unserialize($this->http->get($this->queryurl.'?what=content&format=php&titles='.urlencode($page)));
			foreach ($ret as $page) {
				return $page;
			}
		}
		function contribcount ($user) {
			$ret = unserialize($this->http->get($this->queryurl.'?what=contribcounter&format=php&titles=User:'.urlencode($user)));
			foreach ($ret as $page) {
				return $page;
			}
		}
	}
	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->http = &$__wp__http;
		}
		function login ($user,$pass) {
			$data = $this->http->post($this->apiurl.'?action=login',array('lgname' => $user, 'lgpassword' => $pass));
//			if ($data) echo $data."\n\n";
		}
		function getedittoken () {
			$x = $this->http->get($this->apiurl.'?action=query&format=php&prop=info&intoken=edit&titles=Main%20Page');
			$x = unserialize($x);
			foreach ($x as $y) {
				return $y;
			}
		}
		function recentchanges ($count = 10,$namespace = null,$dir = 'older',$ts = null) {
			$append = '';
			if ($ts !== null) { $append .= '&rcstart='.urlencode($ts); }
			$append .= '&rcdir='.urlencode($dir);
			if ($namespace !== null) { $append .= '&rcnamespace='.urlencode($namespace); }
			$x = $this->http->get($this->apiurl.'?action=query&list=recentchanges&rcprop=user|comment|flags|timestamp|title|ids|sizes&format=php&rclimit='.$count.$append);
			$x = unserialize($x);
			return $x;
		}
		function search ($search,$limit = 10,$offset = 0,$namespace = 0,$what = 'text',$redirs = false) {
			$append = '';
			if ($limit != null) $append .= '&srlimit='.urlencode($limit);
			if ($offset != null) $append .= '&sroffset='.urlencode($offset);
			if ($namespace != null) $append .= '&srnamespace='.urlencode($namespace);
			if ($what != null) $append .= '&srwhat='.urlencode($what);
			if ($redirs == true) $append .= '&srredirects=1';
			else $append .= '&srredirects=0';
			$x = $this->http->get($this->apiurl.'?action=query&list=search&format=php&srsearch='.urlencode($search).$append);
			$x = unserialize($x);
			return $x;
		}
		function logs ($user = null,$title = null,$limit = 50,$type = null,$start = null,$end = null,$dir = 'older') {
			$append = '';
			if ($user != null) $append.= '&leuser='.urlencode($user);
			if ($title != null) $append.= '&letitle='.urlencode($title);
			if ($limit != null) $append.= '&lelimit='.urlencode($limit);
			if ($type != null) $append.= '&letype='.urlencode($type);
			if ($start != null) $append.= '&lestart='.urlencode($start);
			if ($end != null) $append.= '&leend='.urlencode($end);
			if ($dir != null) $append.= '&ledir='.urlencode($dir);
			$x = $this->http->get($this->apiurl.'?action=query&format=php&list=logevents&leprop=ids|title|type|user|timestamp|comment|details'.$append);
			$x = unserialize($x);
			return $x;
		}
		function usercontribs ($user,$count = 50,&$continue = null,$dir = 'older') {
			if ($continue != null) {
				$append = '&ucstart='.urlencode($continue);
			} else {
				$append = '';
			}
			$x = $this->http->get($this->apiurl.'?action=query&format=php&list=usercontribs&ucuser='.urlencode($user).'&uclimit='.urlencode($count).'&ucdir='.urlencode($dir).$append);
			$x = unserialize($x);
			$continue = $x;
			return $x;
		}
		function revisions ($page,$count = 1,$dir = 'older',$content = false,$revid = null,$wait = true,$getrbtok = false,$dieonerror = true,$redirects = false) {
			$x = $this->http->get($this->apiurl.'?action=query&prop=revisions&titles='.urlencode($page).'&rvlimit='.urlencode($count).'&rvprop=timestamp|ids|user|comment'.(($content)?'|content':'').'&format=php&meta=userinfo&rvdir='.urlencode($dir).(($revid !== null)?'&rvstartid='.urlencode($revid):'').(($getrbtok == true)?'&rvtoken=rollback':'').(($redirects == true)?'&redirects':''));
			$x = unserialize($x);
			if ($revid !== null) {
				$found = false;
				if (!isset($x) or !is_array($x)) {
					if ($dieonerror == true) die('No such page.'."\n");
					else return false;
				}
				foreach ($x as $data) {
					if (!isset($data) or !is_array($data)) {
						if ($dieonerror == true) die('No such page.'."\n");
						else return false;
					}
					foreach ($data as $data2) if ($data2 == $revid) $found = true;
					unset($data,$data2);
					break;
				}
				if ($found == false) {
					if ($wait == true) {
						sleep(1);
						return $this->revisions($page,$count,$dir,$content,$revid,false,$getrbtok,$dieonerror);
					} else {
						if ($dieonerror == true) die('Revision error.'."\n");
					}
				}
			}
			foreach ($x as $data) {
				$data = $data;
				$data = $data;
				$data = $x;
//				$data = $x;
				$data = $x;
				return $data;
			}
		}
		function users ($start = null,$limit = 1,$group = null,$reqirestart = false,&$continue = null) {
			$append = '';
			if ($start != null) $append .= '&aufrom='.urlencode($start);
			if ($group != null) $append .= '&augroup='.urlencode($group);
			$x = $this->http->get($this->apiurl.'?action=query&list=allusers&format=php&auprop=blockinfo|editcount|registration|groups&aulimit='.urlencode($limit).$append);
			$x = unserialize($x);
			$continue = $x;
			if (($requirestart == true) and ($x != $start)) return false;
			return $x;
		}
		function categorymembers ($category,$count = 500,&$continue = null) {
			if ($continue != null) {
				$append = '&cmcontinue='.urlencode($continue);
			} else {
				$append = '';
			}
			$category = 'Category:'.str_ireplace('category:','',$category);
			$x = $this->http->get($this->apiurl.'?action=query&list=categorymembers&cmtitle='.urlencode($category).'&format=php&cmlimit='.$count.$append);
			$x = unserialize($x);
			$continue = $x;
			return $x;
		}
		function listcategories (&$start = null,$limit = 50,$dir = 'ascending',$prefix = null) {
			$append = '';
			if ($start != null) $append .= '&acfrom='.urlencode($start);
			if ($limit != null) $append .= '&aclimit='.urlencode($limit);
			if ($dir != null) $append .= '&acdir='.urlencode($dir);
			if ($prefix != null) $append .= '&acprefix='.urlencode($prefix);
			$x = $this->http->get($this->apiurl.'?action=query&list=allcategories&acprop=size&format=php'.$append);
			$x = unserialize($x);
			$start = $x;
			return $x;
		}
		function backlinks ($page,$count = 500,&$continue = null,$filter = null) {
			if ($continue != null) {
				$append = '&blcontinue='.urlencode($continue);
			} else {
				$append = '';
			}
			if ($filter != null) {
				$append .= '&blfilterredir='.urlencode($filter);
			}
			$x = $this->http->get($this->apiurl.'?action=query&list=backlinks&bltitle='.urlencode($page).'&format=php&bllimit='.$count.$append);
			$x = unserialize($x);
			$continue = $x;
			return $x;
		}
		function embeddedin ($page,$count = 500,&$continue = null) {
			if ($continue != null) {
				$append = '&eicontinue='.urlencode($continue);
			} else {
				$append = '';
			}
			$x = $this->http->get($this->apiurl.'?action=query&list=embeddedin&eititle='.urlencode($page).'&format=php&eilimit='.$count.$append);
			$x = unserialize($x);
			$continue = $x;
			return $x;
		}
		function listprefix ($prefix,$namespace = 0,$count = 500,&$continue = null) {
			$append = '&apnamespace='.urlencode($namespace);
			if ($continue != null) {
				$append .= '&apfrom='.urlencode($continue);
			}
			$x = $this->http->get($this->apiurl.'?action=query&list=allpages&apprefix='.urlencode($prefix).'&format=php&aplimit='.$count.$append);
			$x = unserialize($x);
			$continue = $x;
			return $x;
		}
	}
	class wikipediaindex {
		private $http;
		public $indexurl = 'http://en.wikipedia.org/search/';
		private $postinterval = 0;
		private $lastpost;
		private $edittoken;
		function __construct () {
			global $__wp__http;
			if (!isset($__wp__http)) {
				$__wp__http = new http;
			}
			$this->http = &$__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->queryurl = str_replace('index.php','query.php',$this->indexurl);
			$wpapi = new wikipediaapi; $wpapi->apiurl = str_replace('index.php','api.php',$this->indexurl);
			if ((!$this->edittoken) or ($this->edittoken == '')) $this->edittoken = $wpapi->getedittoken();
			if ($rv == null) $rv = $wpapi->revisions($page,1,'older',true);
			if (!$rv) $rv = $wpq->getpage($page);
			//Fake the edit form.
			$now = gmdate('YmdHis', time());
			$token = htmlspecialchars($this->edittoken);
			$tmp = date_parse($rv);
			$edittime = gmdate('YmdHis', gmmktime($tmp,$tmp,$tmp,$tmp,$tmp,$tmp));
			$html = "<input type='hidden' value=\"{$now}\" name=\"wpStarttime\" />\n";
			$html.= "<input type='hidden' value=\"{$edittime}\" name=\"wpEdittime\" />\n";
			$html.= "<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n";
			$html.= '<input name="wpAutoSummary" type="hidden" value="'.md5('').'" />'."\n";
			if (preg_match('/'.preg_quote('{{nobots}}','/').'/iS',$rv)) { return false; }		/* Honor the bots flags */
			if (preg_match('/'.preg_quote('{{bots|allow=none}}','/').'/iS',$rv)) { return false; }
			if (preg_match('/'.preg_quote('{{bots|deny=all}}','/').'/iS',$rv)) { return false; }
			if (preg_match('/'.preg_quote('{{bots|deny=','/').'(.*)'.preg_quote('}}','/').'/iS',$rv,$m)) { if (in_array(explode(',',$m),$user)) { return false; } } /* /Honor the bots flags */
			if (!preg_match('/'.preg_quote($user,'/').'/iS',$rv)) { return false; } /* We need to be logged in */
//			if (preg_match('/'.preg_quote('You have new messages','/').'/iS',$rv)) { return false; } /* Check talk page */
			if (!preg_match('/(yes|enable|true)/iS',((isset($run))?$run:$wpq->getpage('User:'.$user.'/Run')))) { return false; } /* Check /Run page */
			$x = $this->forcepost($page,$data,$summery,$minor,$html,$maxlag,$maxlagkeepgoing,$bot); /* Go ahead and post. */
			$this->lastpost = time();
			return $x;
		}
		function forcepost ($page,$data,$summery = '',$minor = false,$edithtml = null,$maxlag = null,$mlkg = null,$bot = true) {
			$post = '';
			$post = '';
			if ($minor == true) { $post = 1; }
			$post = $data;
			$post = $summery;
			if ($edithtml == null) {
				$html = $this->http->get($this->indexurl.'?title='.urlencode($page).'&action=edit');
			} else {
				$html = $edithtml;
			}
			preg_match('|\<input type\=\\\'hidden\\\' value\=\"(.*)\" name\=\"wpStarttime\" /\>|U',$html,$m);
			$post = $m;
			preg_match('|\<input type\=\\\'hidden\\\' value\=\"(.*)\" name\=\"wpEdittime\" /\>|U',$html,$m);
			$post = $m;
			preg_match('|\<input type\=\\\'hidden\\\' value\=\"(.*)\" name\=\"wpEditToken\" /\>|U',$html,$m);
			$post = $m;
			preg_match('|\<input name\=\"wpAutoSummary\" type\=\"hidden\" value\=\"(.*)\" /\>|U',$html,$m);
			$post = $m;
			if ($maxlag != null) {
				$x = $this->http->post($this->indexurl.'?title='.urlencode($page).'&action=submit&maxlag='.urlencode($maxlag).'&bot='.(($bot == true)?'1':'0'),$post);
				if (preg_match('/Waiting for (*): (+) seconds lagged/S',$x,$lagged)) {
					global $irc;
					if (is_resource($irc)) {
						global $irctechchannel;
						foreach(explode(',',$irctechchannel) as $y) {
							fwrite($irc,'PRIVMSG '.$y.' :'.$lagged.' is lagged out by '.$lagged.' seconds. ('.$lagged.')'."\n");
						}
					}
					sleep(10);
					if ($mlkg != true) { return false; }
					else { $x = $this->http->post($this->indexurl.'?title='.urlencode($page).'&action=submit&bot='.(($bot == true)?'1':'0'),$post); }
				}
				return $x;
			} else {
				return $this->http->post($this->indexurl.'?title='.urlencode($page).'&action=submit&bot='.(($bot == true)?'1':'0'),$post);
			}
		}
		function diff ($title,$oldid,$id,$wait = true) {
			$deleted = '';
			$added = '';
			$html = $this->http->get($this->indexurl.'?title='.urlencode($title).'&action=render&diff='.urlencode($id).'&oldid='.urlencode($oldid).'&diffonly=1');
			if (preg_match_all('/\&amp\;(oldid\=|undo=)(\d*)\\\'\>(Revision as of|undo)/USs', $html, $m, PREG_SET_ORDER)) {
				//print_r($m);
				if ((($oldid != $m) and (is_numeric($oldid))) or (($id != $m) and (is_numeric($id)))) {
					if ($wait == true) {
						sleep(1);
						return $this->diff($title,$oldid,$id,false);
					} else {
						die('Revision error.'."\n");
					}
				}
			}
			if (preg_match_all('/\<td class\=(\"|\\\')diff-addedline\1\>\<div\>(.*)\<\/div\>\<\/td\>/USs', $html, $m, PREG_SET_ORDER)) {
				//print_r($m);
				foreach ($m as $x) {
					$added .= htmlspecialchars_decode(strip_tags($x))."\n";
				}
			}
			if (preg_match_all('/\<td class\=(\"|\\\')diff-deletedline\1\>\<div\>(.*)\<\/div\>\<\/td\>/USs', $html, $m, PREG_SET_ORDER)) {
				//print_r($m);
				foreach ($m as $x) {
					$deleted .= htmlspecialchars_decode(strip_tags($x))."\n";
				}
			}
			//echo $added."\n".$deleted."\n";
			if (preg_match('/action\=rollback\&amp\;from\=.*\&amp\;token\=(.*)\"/US', $html, $m)) {
				$rbtoken = $m;
				$rbtoken = urldecode($rbtoken);
//				echo 'rbtoken: '.$rbtoken.' -- '; print_r($m); echo "\n\n";
				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->apiurl = str_replace('index.php','api.php',$this->indexurl);
				$token = $wpapi->revisions($title,1,'older',false,null,true,true);				
				if ($token == $user) {
					echo 'Token: '; print_r($token); echo "\n\n";
					$token = $token;
				} 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'));
			echo 'Rollback return: '.$x."\n";
			if (!preg_match('/action complete/iS',$x)) return false;
			return $x;
		}
		function move ($old,$new,$reason) {
			$wpapi = new wikipediaapi; $wpapi->apiurl = str_replace('index.php','api.php',$this->indexurl);
			if ((!$this->edittoken) or ($this->edittoken == '')) $this->edittoken = $wpapi->getedittoken();
			$token = htmlspecialchars($this->edittoken);
			$post = array
				(
					'wpOldTitle'	=> $old,
					'wpNewTitle'	=> $new,
					'wpReason'	=> $reason,
					'wpWatch'	=> '0',
					'wpEditToken'	=> $token,
					'wpMove'	=> 'Move page'
				);
			return $this->http->post($this->indexurl.'?title=Special:Movepage&action=submit',$post);
		}
		function upload ($page,$file,$desc) {
			$post = array
				(
					'wpUploadFile'		=> '@'.$file,
					'wpSourceType'		=> 'file',
					'wpDestFile'		=> $page,
					'wpUploadDescription'	=> $desc,
					'wpLicense'		=> '',
					'wpWatchthis'		=> '0',
					'wpIgnoreWarning'	=> '1',
					'wpUpload'		=> 'Upload file'
				);
			return $this->http->post($this->indexurl.'?title=Special:Upload&action=submit',$post);
		}
		function hasemail ($user) {
			$tmp = $this->http->get($this->indexurl.'?title=Special:EmailUser&target='.urlencode($user));
			if (stripos($tmp,"No e-mail address") !== false) return false;
			return true;
		}
		function email ($user,$subject,$body) {
			$wpapi = new wikipediaapi; $wpapi->apiurl = str_replace('index.php','api.php',$this->indexurl);
			if ((!$this->edittoken) or ($this->edittoken == '')) $this->edittoken = $wpapi->getedittoken();
			$post = array
				(
					'wpSubject'	=> $subject,
					'wpText'	=> $body,
					'wpCCMe'	=> 0,
					'wpSend'	=> 'Send',
					'wpEditToken'	=> $this->edittoken
				);
			return $this->http->post($this->indexurl.'?title=Special:EmailUser&target='.urlencode($user).'&action=submit',$post);
		}
	}
?>


Diff function (diff.function.php)

<?PHP
	function diff ($old,$new,$nret = true,$inline = false) {
//		if ($inline) {
//			return str_replace(array("\n",chr(92).chr(92),'\n'),array(' ',chr(92),"\n"),diff(implode("\n",explode(' ',str_replace(array(chr(92),"\n"),array(chr(92).chr(92),'\n'),$old))),implode("\n",explode(' ',str_replace(array(chr(92),"\n"),array(chr(92).chr(92),'\n'),$new))),$nret,false));
//		}
		$file1 = tempnam('/tmp','diff_');
		$file2 = tempnam('/tmp','diff_');
		file_put_contents($file1,$old);
		file_put_contents($file2,$new);
		$out = array();
		if ($inline) {
//			echo 'EXEC: wdiff -3'.(($nret)?'1':'2').' '.escapeshellarg($file1).' '.escapeshellarg($file2)."\n";
			@exec('wdiff -3'.(($nret)?'1':'2').' '.escapeshellarg($file1).' '.escapeshellarg($file2),$out);
			foreach ($out as $key => $line) {
				if ($line == '======================================================================') unset($out);
				elseif ($nret) $out = '> '.$line;
				else $out = '< '.$line;
			}
		} else {
			@exec('diff -d --suppress-common-lines '.escapeshellarg($file1).' '.escapeshellarg($file2),$out);
		}
		$out2 = array();
		foreach ($out as $line) {
			if (
				(
					($nret)
					and (preg_match('/^\> .*$/',$line))
				)
				or (
					(!$nret)
					and (preg_match('/^\< .*$/',$line))
				)
			) {
				$out2 = substr($line,2);
			}
		}
		$out = $out2;
		unset($out2);
		unlink($file1);
		unlink($file2);
		return implode("\n",$out);
	}
?>


Source to ClueBot

<?PHP
	declare(ticks = 1);
	function sig_handler($signo) {
		switch ($signo) {
			case SIGCHLD:
				while (($x = pcntl_waitpid(0, $status, WNOHANG)) != -1) {
					if ($x == 0) break;
					$status = pcntl_wexitstatus($status);
				}
				break;
		}
	}
	pcntl_signal(SIGCHLD,   "sig_handler");
	function score ($list,$data,&$matches = null) {
		$ret = 0;
		foreach ($list as $preg => $pts) {
			if ($x = preg_match_all($preg.'S',$data,$m)) {
//				echo $x.'*'.$pts.' ('.$preg.')'."\n";
				$matches = $x;
				$ret += $pts * $x;
			}
		}
//		echo 'Score: '.$ret."\n";
		return $ret;
	}
	include '../diff.function.php'; /* The diff function. */
	include '../wikibot.classes.php'; /* The[REDACTED] classes. */
	include 'cluebot.config.php'; /* This file is very simple, but it contains sensitive information, we just define $user, $ircserver, $ircport, $ircchannel, $pass, $owner, and $status. */
	include 'cluebot.scorelist.php'; /* This file is uploaded as well as the main file. */
	$wpapi	= new wikipediaapi;
	$wpq	= new wikipediaquery;
	$wpi	= new wikipediaindex;
	$wpapi->login($user,$pass);
	$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
	if (!$mysql) { die('Could not connect: ' . mysql_error()); }
	if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }
	$ircconfig = explode("\n",$wpq->getpage('User:'.$owner.'/CBChannels.js'));
	$tmp = array();
	foreach($ircconfig as $tmpline) { if (substr($tmpline,0,1) != '#') { $tmpline = explode('=',$tmpline,2); $tmp)] = trim($tmpline); } }
	$ircchannel = $tmp;
	$ircdebugchannel = $tmp;
	$ircreportchannel = $tmp;
	$ircvandalismchannel = $tmp;
	$ircaivchannel = $tmp;
	$irctechchannel = $tmp;
	$ircproxychannels = $tmp;
	$ircunrevertedchannels = $tmp;
	$ircbagtrialchannels = $tmp;
	$ircotherchannels = $tmp;
	unset($tmp,$tmpline);
	$stalkbots = array();
	$trialbots = explode("\n",$wpq->getpage('Misplaced Pages:Bots/Requests for approval'));
	foreach ($trialbots as $trialbot) if (preg_match('/\{\{BRFA\|(.*)\|.*\|Trial\}\}/',str_replace(array("\n","\r"),'',$trialbot),$m)) $stalkbots] = 1;
	$irc = fsockopen($ircserver,$ircport,$ircerrno,$ircerrstr,15);
	$ircpid = pcntl_fork();
	if ($ircpid == 0) {
		fwrite($irc,'PASS '.$ircpass."\n");
		fwrite($irc,'USER '.$user.' "1" "1" :ClueBot Misplaced Pages Bot.'."\n");
		fwrite($irc,'NICK '.$user."\n");
		while (!feof($irc)) {
			$data = str_replace(array("\n","\r"),'',fgets($irc,1024));
//			echo 'IRC: '.$data."\n";
			$d = explode(' ',$data);
			if (strtolower($d) == 'ping') {
				fwrite($irc,'PONG '.$d."\n");
			} elseif (($d == '376') or ($d == '422')) {
//				fwrite($irc,'PRIVMSG NickServ :identify '.$pass."\n");
//				sleep(2);
				fwrite($irc,'JOIN '.$ircchannel.','.$ircdebugchannel.','.$ircreportchannel.','.$ircvandalismchannel.','.$ircaivchannel.','.$irctechchannel.','.$ircproxychannels.','.$ircunrevertedchannels.','.$ircbagtrialchannels.','.$ircotherchannels."\n");
				foreach (explode(',',$ircchannel) as $y) {
					fwrite($irc,'PRIVMSG '.$y.' :IRC logging enabled.'."\n");
				}
			} elseif (strtolower($d) == 'privmsg') {
				if (substr($d,0,2) == ':!') {
					if (strtolower($d) == '#wikipedia-en') { $tmp = explode('!',substr($d,1)); $cmd = 'NOTICE '.$tmp; }
					elseif (strtolower($d) == strtolower($user)) { $tmp = explode('!',substr($d,1)); $cmd = 'NOTICE '.$tmp; }
					else { $cmd = 'PRIVMSG '.$d; }
					switch (substr(strtolower($d),2)) {
						case 'edit':
							if (preg_match("/\\]/",$data,$m)) {
								$rv = $wpapi->revisions($m,1,'older');
								fwrite($irc,$cmd.' :.']] http://en.wikipedia.org/search/?title='.urlencode($m).'&diff=prev' .
									'&oldid='.urlencode($rv).' * '.$rv.' * '.$rv."\n");
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'stalk':
							if (preg_match("/\\]/",$data,$m)) {
								$uc = $wpapi->usercontribs($m,1);
								fwrite($irc,$cmd.' :.']] http://en.wikipedia.org/search/?title='.urlencode($uc).'&diff=prev' .
									'&oldid='.urlencode($uc).' * '.$m.' * '.$uc."\n");
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'beaten':
							if (preg_match("/\\]/",$data,$m)) {
								if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
								$x = mysql_fetch_assoc(mysql_query('SELECT COUNT(`id`) AS `count` FROM `beaten` WHERE `user` = \''.mysql_real_escape_string($m).'\' GROUP BY `user`'));
								$y = mysql_fetch_assoc(mysql_query('SELECT SQL_CALC_FOUND_ROWS COUNT(`id`) AS `count2` FROM `beaten` GROUP BY `user` HAVING `count2` > \''.mysql_real_escape_string($x).'\' LIMIT 1'));
								$z = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() as `ahead`'));
								fwrite($irc,$cmd.' :.']] has beaten me '.(($x != '')?$x:'0').' times.  There are '.$z.' users who have beaten me more times.'."\n");
								unset($x,$y);
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'vandalcount':
							if (preg_match("/\\]/",$data,$m)) {
								$tmp = unserialize(file_get_contents('oftenvandalized.txt'));
								if (isset($tmp])) {
									fwrite($irc,$cmd.' :.']] has been vandalized '.count($tmp]).' time(s) in the last 48 hours.'."\n");
								} else {
									fwrite($irc,$cmd.' :.']] has not been vandalized in the last 48 hours.'."\n");
								}
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'heuristics':
							include 'cluebot.heuristics.config.php';
							$stats = unserialize(file_get_contents('cluebot.heuristics.stats.txt'));
							fwrite($irc,$cmd.' :I have the following heuristics enabled: '.implode(', ',$heuristics).".\n");
							foreach ($stats as $heuristic => $count) {
								fwrite($irc,$cmd.' :The '.$heuristic.' heuristic has been matched '.$count.' times.'."\n");
							}
							unset($count,$heuristic,$stats,$heuristics);
							break;
						case 'status':
							$ov = unserialize(file_get_contents('oftenvandalized.txt'));
							foreach ($ov as $title => $array) {
								if (count($array) == 0) unset($ov);
							}
							file_put_contents('oftenvandalized.txt',serialize($ov));
							$count = count($ov);
							$titles = unserialize(file_get_contents('titles.txt'));
							foreach ($titles as $title => $time) {
								if ((time() - $time) > (24*60*60)) {
									unset($titles);
								}
							}
							file_put_contents('titles.txt',serialize($titles));
							$tcount = count($titles);
							foreach ($ov as $x => $y) {
								$ocount = count($y);
							}
							arsort($ocount);
							foreach ($ocount as $x => $y) {
								$mova = $x;
								$movacount = $y;
								break;
							}
							preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq->getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfa);
							$tfa = $tfa;
							if (!preg_match('/(yes|enable|true)/i',$wpq->getpage('User:'.$user.'/Run'))) {
								$run = false;
							} else {
								$run = true;
							}
							$top5beat = array();
							if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
							$q = mysql_query('SELECT `user`,COUNT(`id`) AS `count` FROM `cluebot_enwiki`.`beaten` WHERE `user` != \'\' GROUP BY `user` HAVING `count` > 1 ORDER BY `count` DESC LIMIT 5');
							while ($x = mysql_fetch_assoc($q)) {
								$top5beat = $x.' ('.$x.')';
							}
							unset($x,$q);
							$top5beat = implode(' - ',$top5beat);
							fwrite($irc,$cmd.' :I am '.$user.'.  I am currently '.($run?'enabled':'disabled').'.  I currently have '.$wpq->contribcount($user).' contributions.'."\n");
							fwrite($irc,$cmd.' :I have attempted to revert '.$tcount.' unique article/user combinations in the last 24 hours.  ' .
								'I know of '.$count.' different articles that have been vandalized in the last 48 hours.'."\n"
								);
							fwrite($irc,$cmd.' :] is the most vandalized page with a total of '.$movacount.' vandalisms in the last 48 hours.  ' .
								'Today\'s featured article is: ].'."\n"
								);
							fwrite($irc,$cmd.' :The following users have beat me to the revert the most: '.$top5beat."\n");
							fwrite($irc,$cmd.' :I log all information to '.$ircchannel.'.  This channel is '.$d.'.'."\n");
							unset($x,$y,$count,$ov,$tcount,$ocount,$mova,$movacount,$tfa,$run,$title,$titles,$time,$top5beat);
							break;
						case 'warninglevel':
							if (preg_match("/\\]/",$data,$n)) {
								$warning = 0;
								if (preg_match_all('/<!-- Template:(uw-*(\d)(im)?|Blatantvandal \(serious warning\)) -->.*(\d{2}):(\d{2}), (\d+) (+) (\d{4}) \(UTC\)/iU',
									$wpq->getpage('User talk:'.$n),
									$match,PREG_SET_ORDER)
								) {
									foreach ($match as $m) {
										$month = array('January' => 1, 'February' => 2, 'March' => 3,
											'April' => 4, 'May' => 5, 'June' => 6, 'July' => 7,
											'August' => 8, 'September' => 9, 'October' => 10,
											'November' => 11, 'December' => 12
										);
										if ($m == 'Blatantvandal (serious warning)') $m = 4;
										if ((time() - gmmktime($m,$m,0,$month],$m,$m)) <= (2*24*60*60)) {
											if ($m > $warning) { $warning = $m; }
										}
									}
								}
								fwrite($irc,$cmd.' :.']] is at warning level '.$warning.".\n");
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'count':
							if (preg_match("/\\]/",$data,$n)) {
								fwrite($irc,$cmd.' :.']] has '.$wpq->contribcount($n)." contributions.\n");
							} else {
								fwrite($irc,$cmd.' :Couldn\'t find link.'."\n");
							}
							break;
						case 'help':
							fwrite($irc,$cmd.' :Please see ].'."\n");
							break;
						case 'eval':
							$tmp = explode(' ',$data,6);
							$tmp1 = explode('!',substr($d,1));
							if ($d == md5($thesecret.$tmp1.$tmp)) {
								eval($tmp);
							} else {
								fwrite($irc,$cmd.' :Code incorrect.'."\n");
							}
							break;
						case 'cbproxy':
							$tmp = explode(' ',$data,6);
							$tmp1 = explode('!',substr($d,1));
							if ($tmp1 == 'ClueBot-Bopm') {
								foreach (explode(',',$ircproxychannels) as $y) {
									fwrite($irc,'PRIVMSG '.$y.' :!admin '.$tmp."\n");
								}
								$data = $wpq->getpage('Misplaced Pages:WikiProject on open proxies');
								if (strpos($data,$tmp) === false) {
									$header = explode('{{proxyip2|127.0.0.1}} || Example',$data,2);
									$header .= '{{proxyip2|127.0.0.1}} || Example ';
									$footer = $header;
									$header = $header;
									$data = "\n".'{{proxyip2|'.$tmp.'}} || '.$tmp.' ~~~~'."\n";
									$data = $header.$data.$footer;
									unset($header,$footer);
									$wpi->post('Misplaced Pages:WikiProject on open proxies',$data,'Adding '.$tmp.'.');
									unset($data);
								}
							}
							break;
					}
				}
			}
		}
		die();
	}
	$heuristics = "==Heuristics==\n\n===Config (cluebot.heuristics.config.php)===\n\n<pre>".htmlentities(file_get_contents('cluebot.heuristics.config.php'))."</pre>\n\n";
	foreach (glob('heuristics/cluebot.*.heuristic.php') as $heuristic) $heuristics .= '==='.$heuristic."===\n\n<pre>".htmlentities(file_get_contents($heuristic))."</pre>\n\n";
	unset($heuristic);
	$wpi->forcepost('User:'.$user.'/Source',
		'The following is automatically generated by ].\n\n\n\n==Classes (wikibot.classes.php)==\n\n<pre>" .
		htmlentities(file_get_contents('../wikibot.classes.php'))."</pre>\n\n\n\n==Diff function (diff.function.php)==\n\n<pre>" .
		htmlentities(file_get_contents('../diff.function.php'))."</pre>\n\n\n\n==Source to ".$user .
		"==\n\n".'<pre>'.htmlentities(file_get_contents(__FILE__))."</pre>\n\n\n\n" .
		$heuristics .
		"==Score list==\n\n".'<pre>'.htmlentities(file_get_contents('cluebot.scorelist.php'))."</pre>\n\n\n\n~~~~",
		'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */
	unset($heuristics);
	$wpi->forcepost('User:'.$user,
		"{{User:ClueBot Commons/Userpage}}\n",
		'Automated bot userpage set.'); /* Our page, we force post this because this is *our* page. */
	$tfas = 0;
	$pipe = fopen('thepipe','w');
	$stdin = fopen('php://stdin','r');
	$run = $wpq->getpage('User:'.$user.'/Run');
	$wl = $wpq->getpage('User:'.$user.'/Whitelist');
	$optin = $wpq->getpage('User:'.$user.'/Optin');
	$aoptin = $wpq->getpage('User:'.$user.'/AngryOptin');
	unset($tmp,$tmp2,$tmp3);
	$tmp = explode("\n",$wpq->getpage('User:'.$owner.'/CBAutostalk.js'));
	foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk] = trim($tmp3); } }
	$tmp = explode("\n",$wpq->getpage('User:'.$owner.'/CBAutoedit.js'));
	foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit] = trim($tmp3); } }
	unset($tmp,$tmp2,$tmp3);
	print_r($stalk); print_r($edit);
	while (1) {
		$feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30);
		if (!$feed) {
			sleep(10);
			$feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30);
			if (!$feed) die($feederrstr.' ('.$feederrno.')');
		}
		fwrite($feed,'USER '.$user.' "1" "1" :ClueBot Misplaced Pages Bot.'."\n");
		fwrite($feed,'NICK '.$user."\n");
		while (!feof($feed)) {
			$rawline = fgets($feed,1024);
			$line = str_replace(array("\n","\r","\002"),'',$rawline);
			$line = preg_replace('/\003(\d\d?(,\d\d?)?)?/','',$line);
//			echo 'FEED: '.$line."\n";
			if (!$line) { fclose($feed); break; }
			$linea= explode(' ',$line,4);
			if (strtolower($linea) == 'ping') {
				fwrite($feed,'PONG '.$linea."\n");
			} elseif (($linea == '376') or ($linea == '422')) {
				fwrite($feed,'JOIN '.$feedchannel."\n");
			} elseif ((strtolower($linea) == 'privmsg') and (strtolower($linea) == strtolower($feedchannel))) {
				$message = substr($linea,1);
				if (preg_match('/^\*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?title=*&diff=(\d*)&oldid=(\d*)|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* (*) \* (\((*)\))? (.*)$/S',$message,$m)) {
					$messagereceived = microtime(1);
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
					$change = $m;
//					include 'cluebot.stalk.config.php';
					$stalkchannel = array();
					foreach ($stalk as $key => $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$value));
					foreach ($stalkbots as $key => $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$ircbagtrialchannels));
					foreach ($edit as $key => $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change.$change))) $stalkchannel = array_merge($stalkchannel,explode(',',$value));
//					if ($change == $owner) $stalkchannel = $ircchannel;
					$stalkchannel = array_unique($stalkchannel);
					foreach ($stalkchannel as $y) {
						fwrite($irc,'PRIVMSG '.$y.' :New edit: .$change.']] http://en.wikipedia.org/search/?title=' .
							urlencode($change.$change).'&diff=prev'.'&oldid='.urlencode($change).' * '.$change .
							' * '.$change."\n");
					}
					if (($change == 'User:') or ($change == 'User talk:')) {
						if (strtolower($change) == strtolower($user.'/Run')) { $run = $wpq->getpage('User:'.$user.'/Run'); }
						if (strtolower($change) == strtolower($user.'/Whitelist')) { $wl = $wpq->getpage('User:'.$user.'/Whitelist'); }
						if (strtolower($change) == strtolower($user.'/Optin')) { $optin = $wpq->getpage('User:'.$user.'/Optin'); }
						if (strtolower($change) == strtolower($user.'/AngryOptin')) { $aoptin = $wpq->getpage('User:'.$user.'/AngryOptin'); }
						if (strtolower($change) == strtolower($owner.'/CBAutostalk.js')) {
							unset($stalk);
							$tmp = explode("\n",$wpq->getpage('User:'.$owner.'/CBAutostalk.js'));
							foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk] = trim($tmp3); } }
							unset($tmp,$tmp2,$tmp3);
							print_r($stalk);
						}
						if (strtolower($change) == strtolower($owner.'/CBAutoedit.js')) {
							unset($edit);
							$tmp = explode("\n",$wpq->getpage('User:'.$owner.'/CBAutoedit.js'));
							foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit] = trim($tmp3); } }
							unset($tmp,$tmp2,$tmp3);
							print_r($edit);
						}
						if (strtolower($change) == strtolower($owner.'/CBChannels.js')) {
							$ircconfig = explode("\n",$wpq->getpage('User:'.$owner.'/CBChannels.js'));
							$tmp = array();
							foreach($ircconfig as $tmpline) { if (substr($tmpline,0,1) != '#') { $tmpline = explode('=',$tmpline,2); $tmp)] = trim($tmpline); } }
							print_r($tmp);
							$tmpold = array();
							$tmpnew = array();
							foreach ($tmp as $tmp2) foreach (explode(',',$tmp2) as $tmp3) $tmpnew = 1;
							foreach (explode(',',$ircchannel.','.$ircdebugchannel.','.$ircreportchannel.','.$ircvandalismchannel.','.$ircaivchannel.','.$irctechchannel.','.$ircproxychannels.','.$ircunrevertedchannels.','.$ircbagtrialchannels.','.$ircotherchannels) as $tmp3) $tmpold = 1;
							foreach ($tmpold as $tmp2 => $tmp3) if (isset($tmpnew)) unset($tmpold,$tmpnew);
							foreach ($tmpnew as $tmp2 => $tmp3) $tmpnew1 = $tmp2;
							foreach ($tmpold as $tmp2 => $tmp3) $tmpold1 = $tmp2;
							$tmpold = $tmpold1; $tmpnew = $tmpnew1; unset($tmpold1,$tmpnew1);
							fwrite($irc,'JOIN '.implode(',',$tmpnew)."\n");
							fwrite($irc,'PART '.implode(',',$tmpold)."\n");
							$ircchannel = $tmp;
							$ircdebugchannel = $tmp;
							$ircreportchannel = $tmp;
							$ircvandalismchannel = $tmp;
							$ircaivchannel = $tmp;
							$irctechchannel = $tmp;
							$ircproxychannels = $tmp;
							$ircunrevertedchannels = $tmp;
							$ircbagtrialchannels = $tmp;
							$ircotherchannels = $tmp;
							unset($tmp,$tmpline,$tmpold,$tmpnew,$tmp2,$tmp3);
						}
					}
					if ($change.$change == 'Misplaced Pages:Bots/Requests for approval') {
						$stalkbots = array();
						$trialbots = explode("\n",$wpq->getpage('Misplaced Pages:Bots/Requests for approval'));
						foreach ($trialbots as $trialbot) if (preg_match('/\{\{BRFA\|(.*)\|.*\|Trial\}\}/',str_replace(array("\n","\r"),'',$trialbot),$m)) $stalkbots] = 1;
					}
					if (($change != '') and ((!preg_match('/\* \.$change,'/').')\]\] \- .*/i',$optin))) and ($change != 'move') and ($change != 'Template:')) continue;
					$change = $change;
					$change = $change.$change;
					if ($change == 'move') {
						if (preg_match('/moved \\] to \\]( over redirect)?: (.*)$/',$change,$m)) {
							$change = $m;
							$change = $m;
							$change = $change;
							$change = $m;
							echo "\n\n\n".'Move!'."\n\n\n";
							print_r($change);
							echo "\n\n\n".'Move!'."\n\n\n";
						}
					}
					if (
						((time() - $tfas) >= 1800)
						and (preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq->getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfam))
					) {
						$tfas = time();
						$tfa = $tfam;
						//echo "TFA: ".$tfa."\n";
					}
					$s = null;
					$pid = @pcntl_fork();
					if ($pid != 0) continue;
					$hutime = microtime(1);
					include 'cluebot.heuristics.config.php';
					foreach ($heuristics as $heuristic) {
						$heuristicret = false;
						include 'heuristics/cluebot.'.$heuristic.'.heuristic.php';
						if ($heuristicret == true) {
							$stats = unserialize(file_get_contents('cluebot.heuristics.stats.txt'));
							$stats++;
							print_r($log);
							file_put_contents('cluebot.heuristics.stats.txt',serialize($stats));
							unset($stats);
							break;
						}
					}
					if ($heuristicret == true) { echo 'Heuristics time: '.(microtime(1) - $hutime)."\n"; file_put_contents('trainingdata.txt',$change."\0".$change."\0".'1'."\n",FILE_APPEND); }
					else {
						$tmp = explode(' ',$rawline,4); $tmp = $tmp;
						$udp = fsockopen('udp://localhost',3333);
						fwrite($udp,substr(str_replace(array("\n","\r"),'',$tmp),1)."\n");
						fclose($udp);
						unset($tmp,$udp);
						$d = $wpi->diff($change,$change,$change);
						$s = score($obscenelist,$d,$log);
						$s -= score($obscenelist,$d,$log);
						if ($s > 15) file_put_contents('trainingdata.txt',$change."\0".$change."\0".'0'."\n",FILE_APPEND);
					}
					unset($hutime);
					if (
						($heuristicret == true)
					) {
						if (
							(
								( /* IP users with 250 contributions are fine .. */
									(long2ip(ip2long($change)) == $change)
									/* and ($uc = $wpapi->usercontribs($change,250))
									and (!isset($uc)) */
								)
								or ( /* Users with 50 contributions are fine .. */
									(long2ip(ip2long($change)) != $change)
									and ($wpq->contribcount($change) < 50)
								)
							)
							and ( /* Whitelisted users are ok. */
								/* ($wl = $wpq->getpage('User:'.$user.'/Whitelist'))
								and */ (!preg_match('/^\* \,'/').')|\1\]\] \- .*/',$wl))
							)
						) {
//							$vandalpage = $wpq->getpage('User:'.$user.'/PossibleVandalism');
//							$x = explode("\n\n",$vandalpage);
//							foreach ($x as $k => $y) {
//								if (preg_match('/(\d+)\-(\d+)\-(\d+)T(\d+):(\d+):(\d+)/',$y,$m)) {
//									if ((time() - gmmktime($m,$m,$m,$m,$m,$m)) > (5*60*60)) {
//										unset($x);
//									}
//								}
//							}
//							$vandalpage = implode("\n\n",$x);
							$diff = 'http://en.wikipedia.org/search/' .
								'?title='.urlencode($change) .
								'&diff='.urlencode($change) .
								'&oldid='.urlencode($change);
							$report = '.']] was ' .
								(($change != 'move')?' by ':'moved to .']] by ') .
								'.'|'.$change.']] ' .
								'.'|(u)]] ' .
								'.'|(t)]] ' .
								$reason.' on '.gmdate('c');
//							$datatopost = $vandalpage."\n\n".'Possible ]: '.$report." ~~~~\n";
							if ($s == null) {
//								$rv = $wpapi->revisions($change,2,'older',true,$change);
//								$s = score($scorelist,diff($rv,$rv));
//								$s += (score($scorelist,diff($rv,$rv,false))) * -1;
								$s = 'N/A';
							}
							$tmp = unserialize(file_get_contents('oftenvandalized.txt'));
							foreach ($tmp as $key1 => $tmp2) {
								foreach ($tmp2 as $key2 => $time) {
									if ((time() - $time) > (2*24*60*60)) { unset($tmp); }
								}
							}
							$tmp] = time();
							if (count($tmp]) >= 30) {
								foreach (explode(',',$ircreportchannel) as $y) {
									fwrite($irc,'PRIVMSG '.$y.' :!admin .']] has been vandalized '.(count($tmp])).' times in the last 2 days.'."\n");
								}
							}
							file_put_contents('oftenvandalized.txt',serialize($tmp));
							if (
								(
									($rv1 = $wpapi->revisions($change,1,'older'))
									and ($rv1 == $change)
								)
								or ($change == 'move')
							) { /* No need to continue further if it has been reverted */
								echo 'Possible vandalism: '.$change.' changed by '.$change.' '.$reason.' on '.$rv.'('.$s.").\n";
								foreach (explode(',',$ircdebugchannel) as $y) {
									fwrite($irc,'PRIVMSG '.$y.' :Possible vandalism: '.$change.' changed by '.$change.' '.$reason.' on '.$rv.'('.$s.").\n");
									fwrite($irc,'PRIVMSG '.$y.' :( http://en.wikipedia.org/search/?title='.urlencode($change).'&action=history | '.$change.' )'."\n");
								}
								fwrite($pipe,'http://en.wikipedia.org/search/?title='.urlencode($change).'&action=history'."\n"); /* Tell owner */
								$mqtime = microtime(1);
								if (is_array($log)) {
									$logt = '';
									foreach ($log as $k => $v) {
										$logt .= '* '.$v.' * "'.$k.'"'."\n";
									}
								}
								$query = 'INSERT INTO `vandalism` ' .
									'(`id`,`user`,`article`,`heuristic`'.((is_array($log))?',`regex`':'').',`reason`,`diff`,`old_id`,`new_id`,`reverted`) ' .
									'VALUES ' .
									'(NULL,\''.mysql_real_escape_string($change).'\',' .
									'\''.mysql_real_escape_string($change).'\',' .
									'\''.mysql_real_escape_string($heuristic).'\',' .
									((is_array($log))?'\''.mysql_real_escape_string($logt).'\',':'') .
									'\''.mysql_real_escape_string($reason).'\',' .
									'\''.mysql_real_escape_string($change).'\',' .
									'\''.mysql_real_escape_string($change).'\',' .
									'\''.mysql_real_escape_string($change).'\',0)';
								//echo 'Mysql query: '.$query."\n";
								if (!mysql_ping($mysql)) {
									$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
									if (!$mysql) { die('Could not connect: ' . mysql_error()); }
									if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }
								}
								mysql_query($query);
								//echo 'Mysql error: '.mysql_error()."\n";
								$mysqlid = mysql_insert_id();
								echo 'MySQL time: '.(microtime(1) - $mqtime).' MySQL id: '.$mysqlid."\n";
								unset($mqtime);
								if (
									(
										(
											(preg_match('/(assisted|manual)/iS',$status))
											and (print('Revert ? '))
											and (strtolower(substr(fgets($stdin,3),0,1)) == 'y')
										)
										or (
											(preg_match('/(read-write|rw|go|approved|trial)/iS',$status))
										)
									)
									and (
										(
											(
												((time() - $tfas) < 1800)
												or (
													(preg_match('/\(\'\'\'\*)\|more...\]\]\'\'\'\)/iU',$wpq->getpage('Misplaced Pages:Today\'s featured article/'.date('F j, Y')),$tfam))
													and ($tfas = time())
													and ($tfa = $tfam)
													and ((print("TFA: ".$tfa."\n")) or (true))
												)
											)
											and ($tfa == $change)
										)
										or (
											(preg_match('/\* \,'/').')\]\] \- .*/i',$aoptin))
											and ((fwrite($irc,'PRIVMSG '.$ircdebugchannel.' :Angry-reverting .']].'."\n")) or (true))
										)
										or (
											(($tmp = unserialize(file_get_contents('titles.txt'))) !== false)
											and ((!isset($tmp.$change])) or ((time() - $tmp.$change]) > (24*60*60)))
											and ($tmp.$change] = time())
											and ((file_put_contents('titles.txt',serialize($tmp))) !== false)
										)
									)
								) {
									echo 'Reverting ...'."\n";
									if ($change != 'move') {
										$rev = $wpapi->revisions($change,5,'older',false,null,true,true);
										$revid = 0;
										$rbtok = $rev;
										foreach ($rev as $revdata) {
											if ($revdata != $change) {
												$revid = $revdata;
												break;
											}
										}
										if (($revdata == $user) or (in_array($revdata,explode(',',$botfriends)))) { die(); /* Do not revert to us. */ }
									}
//									if ($revid == 0) { die(); }
									foreach (explode(',',$ircdebugchannel) as $y) {
										fwrite($irc,'PRIVMSG '.$y.' :Reverting ...'."\n");
									}
//									$revisiondata = $wpapi->revisions($change,1,'older',true,$revid);
//									if (!$revisiondata) die();
//									if (!$rv1) $rv1 = $rv;
//									$wpi->post(
//										$change,
//										$revisiondata,
//										'Reverting possible vandalism by .'|'.$change.']] ' .
//										'to version by '.$revisiondata.'. ' .
//										'False positive? ]. '.
//										'Thanks, ]. ('.$mysqlid.') (Bot)',
//										false,
//										$rv1
//									); /* Revert the page */
									if ($change != 'move') {
										if (!$rbtok) {
											$d = $wpi->diff($change,$change,$change);
											$rbtok = $d;
										}
										$rbret = $wpi->rollback(
											$change,
											$change,
											'Reverting possible vandalism by .'|'.$change.']] ' .
											'to '.(($revid == 0)?'older version':'version by '.$revdata).'. ' .
											'False positive? ]. '.
											'Thanks, ]. ('.$mysqlid.') (Bot)',
											$rbtok,
											false
										);
									} else {
										$rbret = $wpi->move(
											$change,
											$change,
											'Reverting possible vandalism by .'|'.$change.']] ' .
											'to '.(($revid == 0)?'older version':'version by '.$revdata).'. ' .
											'False positive? ]. '.
											'Thanks, ]. ('.$mysqlid.') (Bot)'
										);
									}
//
// 									$rv2 = $wpapi->revisions($change,1);
//									if ($rv2 == $user) {
									if ($rbret !== false) {
										foreach (explode(',',$ircdebugchannel) as $y) {
											fwrite($irc,'PRIVMSG '.$y.' :Reverted. ('.(microtime(1) - $messagereceived).' s)'."\n");
										}
 										$warning = 0;
										$tpcontent = $wpq->getpage('User talk:'.$change);
										if (preg_match_all('/<!-- Template:(uw-*(\d)(im)?|Blatantvandal \(serious warning\)) -->.*(\d{2}):(\d{2}), (\d+) (+) (\d{4}) \(UTC\)/iU',
											$tpcontent,
											$match,PREG_SET_ORDER)
										) {
											foreach ($match as $m) {
												$month = array('January' => 1, 'February' => 2, 'March' => 3, 
													'April' => 4, 'May' => 5, 'June' => 6, 'July' => 7, 
													'August' => 8, 'September' => 9, 'October' => 10, 
													'November' => 11, 'December' => 12
												);
												if ($m == 'Blatantvandal (serious warning)') $m = 4;
												if ((time() - gmmktime($m,$m,0,$month],$m,$m)) <= (2*24*60*60)) {
													if ($m > $warning) { $warning = $m; }
												}
											}
										}
										$warning++;
										if ($warning == 5) { /* Report them if they have been warned 4 times. */
											$aivdata = $wpq->getpage('Misplaced Pages:Administrator_intervention_against_vandalism/TB2');
											if (!preg_match('/'.preg_quote($change,'/').'/i',$aivdata)) {
												foreach(explode(',',$ircaivchannel) as $y) {
													fwrite($irc,'PRIVMSG '.$y.' :!admin Reporting .']] to ]. Contributions: .']] Block: .']]'."\n");
												}
												foreach (explode(',',$ircvandalismchannel) as $y) {
													fwrite($irc,'PRIVMSG '.$y.' :computer bl add '.$change.' x='.(24*$warning).' r=Vandalism to .']] (#'.$warning.").\n");
												}
												$wpi->post(
													'Misplaced Pages:Administrator_intervention_against_vandalism/TB2',
													$aivdata .
													"\n\n* {{".((long2ip(ip2long($change)) == $change)?'IPvandal':'Vandal').'|'.$change.'}}' .
													' - '.$report." (Automated) ~~~~\n",
													'Automatically reporting .']]. (bot)',
													false,
													null,
													false
												);
											} else {
												foreach (explode(',',$ircreportchannel) as $y) {
													fwrite($irc,'PRIVMSG '.$y.' :!admin .']] has vandalized at least one time while being listed on ].  Contributions: .']] Block: .']]'."\n");
												}
											}
										} elseif ($warning < 5) { /* Warn them if they haven't been warned 4 times. */
											foreach (explode(',',$ircvandalismchannel) as $y) {
												fwrite($irc,'PRIVMSG '.$y.' :computer bl add '.$change.' x='.(24*$warning).' r=Vandalism to .']] (#'.$warning.').'."\n");
											}
											$wpi->post(
												'User talk:'.$change,
												$tpcontent."\n\n" .
												'{{subst:User:'.$user.'/Warnings/Warning|1='.$warning.'|2='.$change.'|3='.$report.' <!{{subst:ns:0}}-- MySQL ID: '.$mysqlid.' --{{subst:ns:0}}>}} ~~~~'."\n",
												'Warning .'|'.$change.']] - #'.$warning,
												false,
												null,
												false
											); /* Warn the user */
										} else { /* They have already been reported ... do nothing */
										}
										if (!mysql_ping($mysql)) {
											$mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass);
											if (!$mysql) { die('Could not connect: ' . mysql_error()); }
											if (!mysql_select_db($mysqldb, $mysql)) { die ('Can\'t use database : ' . mysql_error()); }
										}
										mysql_query('UPDATE `vandalism` SET `reverted` = 1 WHERE `id` = \''.mysql_real_escape_string($mysqlid).'\'');
									} else {
										$rv2 = $wpapi->revisions($change,1);
										if ($change != $rv2) {
											echo 'Grr! Beaten by '.$rv2.".\n";
											foreach(explode(',',$ircdebugchannel) as $y) {
												fwrite($irc,'PRIVMSG '.$y.' :Grr! Beaten by '.$rv2.".\n");
											}
											if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
											mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($rv2).'\')');
										}
									}
								} else {
									foreach (explode(',',$ircunrevertedchannels) as $y) {
										fwrite($irc,'PRIVMSG '.$y.' :'."\002\00304Possible ignored vandalism: \002\003."\003]]\00304 changed by \003."\003]] \00303".$reason."\00304 on \00307".$rv."\003(\002\00313".$s."\003).\n");
										fwrite($irc,'PRIVMSG '.$y.' :'."\002(\002\00312 http://en.wikipedia.org/search/?title=".urlencode($change)."&action=history \003\002|\002\00312 ".$change." \003\002)\002"."\n");
									}
								}
							} else {
								$rev = $wpapi->revisions($change,1);
								$rev = $rev;
								echo 'Possible corrected vandalism: '.$change.' changed by '.$change.' '.$reason.'('.$s.")\n\tReverted by ".$rev." before I saw it.\n";
								foreach (explode(',',$ircdebugchannel) as $y) {
									fwrite($irc,'PRIVMSG '.$y.' :Possible corrected vandalism: '.$change.' changed by '.$change.' '.$reason.'('.$s.")\n");
									fwrite($irc,'PRIVMSG '.$y.' :Reverted by '.$rev." before I saw it.\n");
								}
								if (($rev != $user) and ($rev != $change)) {
									if (!mysql_ping($mysql)) { $mysql = mysql_pconnect($mysqlhost.':'.$mysqlport,$mysqluser,$mysqlpass); mysql_select_db($mysqldb, $mysql); }
									mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($change).'\',\''.mysql_real_escape_string($rev).'\')');
								}
							}
						}
					}
					die();
				}
			}
		}
	}
?>


Heuristics

Config (cluebot.heuristics.config.php)

<?PHP
	$heuristics = 'grawp';
	$heuristics = 'evolution';
	$heuristics = 'avrillavigne';
	$heuristics = 'editsummary';
	$heuristics = 'pagereplace';
	$heuristics = 'pageblank';
	$heuristics = 'massdelete';
	$heuristics = 'massadd';
	$heuristics = 'tables';
	$heuristics = 'smallchange';
	$heuristics = 'claimjumperpete';
	$heuristics = 'redirect';
?>

heuristics/cluebot.avrillavigne.heuristic.php

<?PHP
	if ( /* The Avril Lavigne vandal */
		(
			(preg_match('/avril\s*lavigne\s*roc*k**\s*my\s*soc*k**/i',$change))
			or (preg_match('/she\s*(is\s*)*(so\s*)*.*hot\!.*using.*TW/i',$change))
			or (
				($change == 'Template:')
				and (preg_match('/\{\{user((\s|_)talk)?:/i',$wpq->getpage($change)))
			)
		)
		and ($reason = 'Avril Lavigne vandal?')
	) {
		$heuristicret = true;
		fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Avril Lavigne vandal? http://en.wikipedia.org/Special:Contributions/'.$change." .\n");
	}
?>

heuristics/cluebot.claimjumperpete.heuristic.php

<?PHP
	if ( /* The ClaimJumperPete vandal */
		(($change >= 100) and ($change <= 400))
		and (
			($change <= 200)
			or ($d = $wpi->diff($change,$change,$change))
		)
		and (
			(fnmatch("<!--*howdy y'all*-->*",trim(strtolower($d))))
			or (fnmatch("<!--*hello der*-->*",trim(strtolower($d))))
			or (fnmatch("<!--*happy editin' y'all*-->*",trim(strtolower($d))))
		)
		and ($reason = 'ClaimJumperPete?')
	) {
		$heuristicret = true;
		fwrite($irc,'PRIVMSG #cvn-wp-en :!admin ClaimJumperPete vandal? http://en.wikipedia.org/search/?title='.urlencode($change).'&diff=prev'.'&oldid='.urlencode($change)." .\n");
	}
?>

heuristics/cluebot.editsummary.heuristic.php

<?PHP
	if (
		(
			(fnmatch('*nimp*org*',strtolower($change)))
		)
		and ($reason = 'obscenities in edit summary')
	) {
		$heuristicret = true;
	}
?>

heuristics/cluebot.evolution.heuristic.php

<?PHP
	if ( /* The Evolution vandal */
		($change == 'Evolution')
		and (($pagedata = $wpq->getpage($change)) or true)
		and (fnmatch('*Genesis 1*The beginning*',$pagedata))
		and ($reason = 'replacing article with the Bible')
	) {
		$heuristicret = true;
		fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Evolution vandal? http://en.wikipedia.org/search/?title='.urlencode($change).'&diff=prev'.'&oldid='.urlencode($change)." .\n");
	}
?>

heuristics/cluebot.grawp.heuristic.php

<?PHP
	if ( /* The Grawp vandal */
		(
			(fnmatch('*epic*lulz*on*nimp*org*',strtolower($change)))
			or (fnmatch('*on*nimp*org*epic*lulz*',strtolower($change)))
			or (fnmatch('*punishing*wikipedia*',strtolower($change)))
			or (fnmatch('*anti*avril*hate*campaign*',strtolower($change)))
			or (fnmatch('*hagger*',strtolower($change)))
			or (fnmatch('*h?a?g?g?e?r*',strtolower($change)))
			or (fnmatch('*h??a??g??g??e??r*',strtolower($change)))
			or (fnmatch('*grawp*cock*',strtolower($change)))
			or (fnmatch('*massive*cock*',strtolower($change)))
			or (fnmatch('*grawp*dick*',strtolower($change)))
			or (fnmatch('*massive*dick*',strtolower($change)))
			or (fnmatch('*h?g?g?e?r*',strtolower($change)))
			or (fnmatch('*hgger*',strtolower($change)))
		)
		and ($reason = 'Grawp?')
	) {
		$heuristicret = true;
		fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Grawp vandal? http://en.wikipedia.org/Special:Contributions/'.$change." .\n");
	}
?>

heuristics/cluebot.massadd.heuristic.php

<?PHP
	if ( /* Massive additions */
		($change >= 7500)
		and ($rv = $wpapi->revisions($change,2,'older',true,$change))
		and ($pagedata = $wpq->getpage($change))
		and ($s = score($scorelist,$rv))
		and ($s += (score($scorelist,$rv)) * -1)
		and ($s < -1000)
		and ($reason = 'score equals '.$s)
	) $heuristicret = true;
?>

heuristics/cluebot.massdelete.heuristic.php

<?PHP
	if ( /* Massive deletes */
		($change <= -7500)
		and ($pagedata = $wpq->getpage($change))
		and (!fnmatch('*#REDIRECT*',strtoupper(substr($pagedata,0,9))))
		and ($rv = $wpapi->revisions($change,2,'older',true,$change))
		and ($s = score($scorelist,$rv))
		and ($s += (score($scorelist,$rv)) * -1)
		and ($s < -50) /* There are times when massive deletes are ok. */
		and ($reason = 'deleting '.($change * -1).' characters')
	) $heuristicret = true;
?>

heuristics/cluebot.pageblank.heuristic.php

<?PHP
	if ( /* Page blanks */
		(preg_match('/\,$m))
		and (($pagedata = $wpq->getpage($change)) or true)
		and ($fc = $wpapi->revisions($change,1,'newer'))
		and ($fc != $change) /* The creator is allowed to blank the page. */
		and ($reason = 'blanking the page')
	) $heuristicret = true;
?>

heuristics/cluebot.pagereplace.heuristic.php

<?PHP
	if ( /* Page replaces */
		(preg_match('/\\]Replaced page with (.*)$/',$change,$m))
		and ($pagedata = $wpq->getpage($change))
		and ($fc = $wpapi->revisions($change,1,'newer'))
		and ($fc != $change) /* The creator is allowed to replace the page. */
		and ($reason = 'replacing entire content with something else')
	) $heuristicret = true;
?>

heuristics/cluebot.redirect.heuristic.php

<?PHP
	if ( /* The Redirect vandals */
		(
			($tfa == $change)
			and (fnmatch('*#redirect *',strtolower($wpq->getpage($change))))
			and ($reason = 'redirecting featured article to new title')
		)
		or (
			($pagedata = $wpq->getpage($change))
			and (fnmatch('*#redirect *',strtolower($pagedata)))
			and (preg_match('/\\]/',$pagedata,$m))
			and (!$wpq->getpage($m))
			and ($reason = 'redirecting article to non-existant page')
		)
	) {
		$heuristicret = true;
//		fwrite($irc,'PRIVMSG #cvn-wp-en :!admin Grawp vandal? http://en.wikipedia.org/Special:Contributions/'.$change." .\n");
	}
?>

heuristics/cluebot.smallchange.heuristic.php

<?PHP
	unset($log,$log2);
	if ( /* Small changes with obscenities. */
		(($change >= -200) and ($change <= 200))
		and (($d = $wpi->diff($change,$change,$change)) or true)
		and ((($change == 'User:ClueBot/Sandbox') and print_r($rv)) or true)
		and (($s = score($obscenelist,$d,$log)) or true)
		and (($s -= score($obscenelist,$d,$log2)) or true)
		and (
			(
				($s < -5) /* There are times when small changes are ok. */
				and (($rv = $wpapi->revisions($change,2,'older',true,$change)) or true)
				and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
				and (!fnmatch('*SEX*',strtoupper($rv)))
				and (!fnmatch('*BDSM*',strtoupper($rv)))
				and (score($obscenelist,$change) >= 0)
				and (score($obscenelist,$rv) >= 0)
				and (!preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\<|\()?censored(\>|\))?)(ing?|ed)?(\s|$)/iS',$rv))
				and ($heuristic .= '/obscenities')
				and ($reason = 'making a minor change with obscenities')
			)
			or (
				($s > 5)
				and (($rv = $wpapi->revisions($change,2,'older',true,$change)) or true)
				and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
				and (!preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\<|\()?censored(\>|\))?)(ing?|ed)?(\s|$)/iS',$rv))
				and (preg_match('/(^|\s)({1,2}(\*+|\-{3,}){0,2}|\*{4}|\-{4}|(\<|\()?censored(\>|\))?)(ing?|ed)?(\s|$)/iS',$rv))
				and ($heuristic .= '/censor')
				and ($reason = 'making a minor change censoring content (])')
			)
			or (
				(preg_match('/\!\!\!/S',$d))
				and (($rv = $wpapi->revisions($change,2,'older',true,$change)) or true)
				and (!preg_match('/\!\!\!/S',$rv))
				and (!fnmatch('*#REDIRECT*',strtoupper(substr($rv,0,9))))
				and ($heuristic .= '/exclamation')
				and ($reason = 'making a minor change adding "!!!"')
			)
		)
	) { $heuristicret = true; if (isset($log2) and is_array($log2)) foreach ($log2 as $k => $v) $log -= $v; if (isset($log) and is_array($log)) foreach ($log as $k => $v) if ($v == 0) unset($log); unset($log2); /* fwrite($irc,'PRIVMSG #wikipedia-BAG/ClueBot :Would revert http://en.wikipedia.org/search/?title='.urlencode($change.$change).'&diff=prev'.'&oldid='.urlencode($change)." .\n"); */ }
?>

heuristics/cluebot.tables.heuristic.php

<?PHP
	if ( /* Massive tables */
		($change >= 7500)
		and ($rv = $wpapi->revisions($change,2,'older',true,$change))
		and (substr_count(strtolower($rv),'<td') > 300)
		and ($reason = 'adding huge, browser-crashing tables')
	) $heuristicret = true;
?>

Score list

<?PHP
	/*
	 * This page contains bad words out of necessity.
	 * Here is 50 lines of whitespace before the actual list:
	 * (scroll down to see the list)
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 *
	 * Here is the list:
	 */
	$obscenelist = Array
		(
			/* 'preg'				=> points, */
			'/suck/i'				=> -5,   /* Usually bad words */
			'/stupid/i'				=> -3,
			'/haha/i'				=> -5,
			'/\bomg/i'				=> -3,
			'/\bpimp\b/i'				=> -7,
			'/1337/i'				=> -5,
			'/leet/i'				=> -5,
			'/dumb/i'				=> -5,
			'/\bputa\b/i'				=> -7,
			'/\bhomo\b/i'				=> -7,
			'/\bGAY\b/'				=> -10,
			'/\bslut/i'				=> -5,
			'/damn/i'				=> -5,
			'/\bass\b/i'				=> -10,
			'/\brape\b/i'				=> -7,
			'/\bpoop\b/i'				=> -10,
			'/\bcock\b/i'				=> -10,
			'/\blol\b/i'				=> -7,
			'/\bcrap\b/i'				=> -5,
			'/\bsex\b/i'				=> -5,
			'/noob/i'				=> -5,
			'/\bnazi\b/i'				=> -3,
			'/\bneo-nazi\b/i'			=> +3,   /* False-positive */
			'/fuck/i'				=> -20,  /* Stronger bad words */
			'/\\]/'			=> +20,  /* This one is a false positive */
			'/bitch/i'				=> -20,
			'/\bpussy\b/i'				=> -20,
			'/penis/i'				=> -20,
			'/vagina/i'				=> -20,
			'/whore/i'				=> -15,
			'/\bshit\b/i'				=> -20,
			'/nigger/i'				=> -20,
			'/\bnigga\b/i'				=> -20,
			'/cocksucker/i'				=> -20,
			'/assrape/i'				=> -15,
			'/motherfucker/i'			=> -20,
			'/wanker/i'				=> -20,
			'/\bcunt\b/i'				=> -20,
			'/faggot/i'				=> -20,
			'/fags/i'				=> -20,
			'/asshole/i'				=> -15,
			'/fuck ((yo)?u|h(er|im)|them|it)/i'	=> -100, /* This looks like a personal attack */
			'/((yo)?u|s?he|we|they|it) sucks?/i'	=> -100, /* This looks like a personal attack */
			'/666+\b/i'				=> -50   /* Though this has uses, it is commonly used by vandals */
		);
	$grammarlist = Array
		(
			'/(.{1,4})\1{30}/'			=> -10,  /* Ugg .. the same letter(s) several times in a row. */
			'/\b.*\b/U'			=> +2,   /* This looks to be a correct sentence */
			'/\b{30,}\b/U'		=> -10,  /* All capitals? Looks like vandal activity */
			'/\b{1500,}\b/U'			=> -10,  /* No capitals? Looks like vandal activity */
			'/!{5,}/i'				=> -10,  /* No[REDACTED] article needs '!!!!!' in it */
			'/!!+1+(one)*/i'			=> -30,  /* No[REDACTED] article needs '!!!11one' in it */
			'/\\]/U'				=> +1,   /* Wiki links are good. */
			'/\{\{.*\}\}/U'				=> +5,   /* Wiki transcludes are good. */
			'/\{\{nfobox .*\}\}/U'		=> +20,  /* Wiki infoboxes are good. */
			'/\\]/iU'		=> +3    /* Wiki categories are good. */
		);
	$scorelist = array_merge($obscenelist,$grammarlist);
?>


ClueBot (talk) 20:12, 31 July 2008 (UTC)

User:ClueBot/Source: Difference between revisions Add topic