User:SoxBot VI/Source

From Wikipedia, the free encyclopedia

The following is automatically generated by SoxBot VI.


  • wikibot.classes.php is here.


[edit] Source to SoxBot VI

<?PHP
                                include '../Cluebot2/wikibot.classes.php';
                                include '../Cluebot2/cluebot6.config.php';
                                
                                $wpq = new wikipediaquery;
                                $wpapi = new wikipediaapi;
                                $wpi = new wikipediaindex;
                                $http = new http;

                                $wpapi->login($user,$pass);
                
                                function lcfirst( $str ) {
                                                $str = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
                                                $str = strtolower($str[0]);
                                                return $str;
                                }
                                $wpi->forcepost('User:'.$user.'/Source',"The following is automatically generated by [[User:".$user."|]].\n\n\n\n* wikibot.classes.php is [[User:ClueBot/Source|here]].\n\n\n\n==Source to ".$user."==\n\n<pre>".htmlentities(file_get_contents(__FILE__))."</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. */
                                $text = $wpq->getpage('Wikipedia:Changing username');
                                $m = preg_split('/^\=\=\=\s*(.*)\s+\xe2\x86\x92\s+(.*)\s*\=\=\=$/m', $text, -1, PREG_SPLIT_NO_EMPTY);
                                unset($m[0]);
                                foreach ($m as $u) {
                                                if (preg_match('/(\{\{done\}\}|\{\{not\s?done\}\}|\{\{crat\s?note|\{\{[Cc]lerk[-]?\s?[Nn]ote|\{\{CHU\||\{\{User\:SoxBot VI\/CHU)/', $u)) {
                                                                echo "Request has been taken care of already, skipping.\n\n";
                                                }
                                                else {
                                                                preg_match('/\{\{renameuser2\|1\=(.*)\n?\|2\=(.*)\n?\}\}\n\* Reason\: ((.*)\n?\(UTC\))/', $u, $r);
                                                                unset($r[0]);
                                                                $error = null;
                                                                $problem = null;
                                                                $old = trim($r[1]);
                                                                $old = str_replace('_',' ',$old);
                                                                $new = trim($r[2]);
                                                                $reason = trim($r[3]); 
                                                                $ei = $wpapi->users($new);
                                                                $eu = $wpapi->users($old);
                                                                $cb = $http->get("http://en.wikipedia.org/w/api.php?action=query&list=blocks&bkusers=$old&format=php");
                                                                $cb = unserialize($cb);
                                                                $cb = $cb['query']['blocks'];
                                                                $rl = $http->get("http://en.wikipedia.org/w/api.php?action=query&list=logevents&letype=renameuser&format=php&letitle=User:$old");
                                                                $rl = unserialize($rl);
                                                                $rl = $el['query']['logevents'];
                                                                $towrite = null;
                                                                preg_match('/\n?\s?\[\[(User:|User talk:)(.*)\]\]/', $reason, $requser);
                                                                if (preg_match('/\n?\s?\[\[Special:Contributions\/(.*)\|(.*)\]\] \(\[\[User talk\:(.*)\|talk\]\]\)/', $reason, $ip)) {
                                                                                echo "Request made by $ip.\n";
                                                                                $error = "{{User:SoxBot VI/CHU|ip|$ip[1]}} ";
                                                                }
                                                                /*elseif (!preg_match('/\n?\s?\[\[(User:|User talk:)(.*)(\|(.*))?\]\]/', $reason)) {
                                                                                echo "No signature";
                                                                                $towrite .= ":* {{User:SoxBot VI/CHU|sign}}\n";
                                                                                $error = "true";
                                                                }*/
                                                                /*elseif ($requser != $old) {
                                                                                echo "Requested is not the old username.\n";
                                                                                $towrite .= ":* {{User:SoxBot VI/CHU|du}}\n";
                                                                                $error = "true";
                                                                }
                                                                else {
                                                                                echo "Request made by user. \n";
                                                                }*/
                                                                if (count($cb) != '0') {
                                                                                echo "Old username is blocked.\n";
                                                                                $error .= "{{User:SoxBot VI/CHU|block}} ";
                                                                }
                                                                if (strlen($new) > '40') {
                                                                                echo "Requested username is longer than 40 characters.\n";
                                                                                $error .= "{{User:SoxBot VI/CHU|len}} ";
                                                                }
                                                                if (strpos($reason, 'Reason for requested renaming.') !== FALSE) {
                                                                                echo "Request appears to be the default reason.\n";
                                                                                $error .= "{{User:SoxBot VI/CHU|df}} ";
                                                                }
                                                                /*foreach ($eu as $data1) {
                                                                                $apiname1 = trim($data1['name']);
                                                                                if (urlencode($apiname1) != urlencode($old)) {
                                                                                                echo "Old user does not exist, as closest name is ".$apiname1.". Invalid.\n";
                                                                                                $error .= "{{User:SoxBot VI/CHU|no}} ";
                                                                                }
                                                                }*/
                                                                foreach ($ei as $data) {
                                                                                $apiname = trim($data['name']);
                                                                                if ($new == lcFirst($old)) {
                                                                                                echo "Requested name is the same name, but lowercase.\n";
                                                                                                $error .= "{{User:SoxBot VI/CHU|lc}} ";
                                                                                }       
                                                                                elseif ($apiname != $new) {
                                                                                        $ga = $http->get('http://en.wikipedia.org/w/ca.php');
                                                                                        $pos = strpos($new, $ga);
                                                                                        if ($pos === false) {
                                                                                                echo "Requested user does not exist, as closest name is ".$apiname.". Valid.\n";
                                                                                                /*if ($error == "true") {
                                                                                                                $towrite .= ":* {{User:SoxBot VI/CHU|ne}}\n";
                                                                                                }*/
                                                                                        }
                                                                                        else {
                                                                                                echo "Global usernames should not be renamed.\n";
                                                                                                $error .= "{{User:SoxBot VI/CHU|g}} ";
                                                                                        }
                                                                                }
                                                                                else {
                                                                                                echo $new." exists, checking for usurpability\n";
                                                                                                if ($eu[0]['editcount'] <= '200') {
                                                                                                                echo $eu[0]['name']." has less than 200 edits, not pointing to USURP.\n";
                                                                                                                $error .= "{{User:SoxBot VI/CHU|e}} ";
                                                                                                }
                                                                                                else {
                                                                                                                if (trim($data['editcount']) != '0') {
                                                                                                                                echo $new." has edits, not possible.\n";
                                                                                                                                $error .= "{{User:SoxBot VI/CHU|e}} ";
                                                                                                                }
                                                                                                                else {
                                                                                                                                echo "Usurp possible.\n";
                                                                                                                                $error .= "{{User:SoxBot VI/CHU|usurp}} ";
                                                                                                                }
                                                                                                }
                                                                                }
                                                                }
                                                                if ($error) {
                                                                                $towrite .= ":{{User:SoxBot VI/CHU|error|2=$error}} ~~~~\n";
                                                                }
                                                                else {
                                                                                $towrite .= ":{{User:SoxBot VI/CHU|noerror}} ~~~~\n";
                                                                }
                                                                $write = str_replace($reason, $reason."\n".$towrite, $wpq->getpage('Wikipedia:Changing username'));
                                                                $wpi->post('Wikipedia:Changing username', $write, 'Adding analysis for '.$old.' to '.$new.' (BOT EDIT)');
                                                                echo $towrite."\n\n";
                                                                
                                                }
                                }
?>


91.198.174.194 (talk)