User:ClueBot VI/Source

The following is automatically generated by ClueBot VI.


 * wikibot.classes.php is here.

Source to ClueBot VI
&lt;?PHP function addtobottom(&amp;$data,$add) { global $cmt; $cmt++;

$tmp = explode('===',$data); $tmp[0] = rtrim($tmp[0]).&quot;\n&quot;.$add.&quot;&lt;!-- If removing the CUU/Clerk note template, keep this comment so ClueBot VI won't readd the template. --&gt;\n\n&quot;; $tmp = implode('===',$tmp); $data = $tmp; }

include '../wikibot.classes.php'; include 'cluebot6.config.php';

$wpq = new wikipediaquery; $wpapi = new wikipediaapi; $wpi = new wikipediaindex;

$wpapi-&gt;login($user,$pass);

$wpapi-&gt;edit('User:'.$user.'/Source',		'The following is automatically generated by '.$user.&quot;.\n\n\n\n&quot; .		'* wikibot.classes.php is here.' .		&quot;\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;,		'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */

//	$i = 22; while (1) { $crats = array; $cratsd = $wpapi-&gt;users(null,500,&quot;bureaucrat&quot;); foreach ($cratsd as $crat) $crats[] = preg_quote($crat['name'],'/'); $crats = implode('|',$crats); $origdata = $wpq-&gt;getpage('Wikipedia:Changing username/Usurpations'); $data = preg_replace('/\=\=\=\s*(January|February|March|April|May|June|July|August|September|October|November|December)\s*\d{1,2},\s*\d{4}\s*\=\=\=/',,preg_replace('/\'\'Requests left here will be filled no earlier than (January|February|March|April|May|June|July|August|September|October|November|December)\s*\d{1,2},\s*\d{4}\.\'\'/',,preg_replace('/\=\=\=\s*Unknown\s*\=\=\=/','',$origdata))); $header = explode('====',$data,2); $data = '===='.$header[1]; $header = $header[0]; $datatopost = $header; preg_match_all('/\=\=\=\=\s*(\S.*)\s*\=\=\=\=(.*)(?=\=\=\=\=\s*\S.*\s*\=\=\=\=(.*)|$)/Us',$data,$m,PREG_SET_ORDER); $footer = explode($m[count($m)-1][2],$data); $footer = $footer[1]; $cmt = 0; //		echo $footer.&quot;\n\n&quot;; //		print_r($m); echo $crats.&quot;\n&quot;; foreach ($m as $k =&gt; &amp;$request) { if (preg_match('/\{\{Done\}\}.*(\d{2}):(\d{2}), (\d+) ([a-zA-Z]+) (\d{4}) \(UTC\)/i',$request[2],$match)) { if (preg_match('/User:('.$crats.')/i',$request[2])) { $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 ((time - gmmktime($match[1],$match[2],0,$month[$match[4]],$match[3],$match[5])) &gt; 3*24*60*60) { $darchive[] = $request; unset($m[$k]); }				}				continue; }			if (preg_match('/\{\{Not ?done\}\}.*(\d{2}):(\d{2}), (\d+) ([a-zA-Z]+) (\d{4}) \(UTC\)/i',$request[2],$match)) { if (preg_match('/User:('.$crats.')/i',$request[2])) { $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 ((time - gmmktime($match[1],$match[2],0,$month[$match[4]],$match[3],$match[5])) &gt; 48*60*60) { $narchive[] = $request; unset($m[$k]); }				}				continue; }			if (preg_match('/\{\{CUU.*/i',$request[2])) continue; if (preg_match('/\{\{Clerk note\}\}/i',$request[2])) continue; if (preg_match('/\{\{\[\[Image:.*/i',$request[2])) continue; if (preg_match('/ClueBot VI/i',$request[2])) continue; $to = explode('&acirc;��',trim($request[1])); if (!isset($to[1])) { addtobottom(&amp;$request[2],': Parse error: I had a problem parsing this request. Please ensure that the header is in the correct format.  Thanks.  ~'); continue; }			$from = trim($to[0]); $to = trim($to[1]);

$to = strtoupper($to{0}).substr($to,1); $from = strtoupper($from{0}).substr($from,1);

$params = array;

$totaledits = $wpq-&gt;contribcount($to); $visibleedits = 0; $cont = null; while (($count = count($wpapi-&gt;usercontribs($to,500,&amp;$cont))) == 500) $visibleedits += $count; $visibleedits += $count; $deletededits = $totaledits - $visibleedits;

if ($visibleedits &gt; 0) $params['contribs'] = 'yes'; else $params['contribs'] = 'no'; if ($deletededits &gt; 0) $params['dcontribs'] = 'yes'; else $params['dcontribs'] = 'no';

if (count($wpapi-&gt;logs($to)) &gt; 1) $params['logs'] = 'yes'; else $params['logs'] = 'no';

$info = $wpapi-&gt;users($to);

if ($info[0]['name'] != $to) { addtobottom(&amp;$request[2],': User &quot;'.$to.'&quot; is not registered. Please see WP:CHU/S instead.  ~'); continue; }

preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/',$info[0]['registration'],$regdate); if (((time - gmmktime($regdate[4],$regdate[5],$regdate[6],$regdate[2],$regdate[3],$regdate[1])) &gt; 6*30*24*60*60) or ((time - gmmktime($regdate[4],$regdate[5],$regdate[6],$regdate[2],$regdate[3],$regdate[1])) &lt; 3600)) { $params['new'] = 'no'; } else { $params['new'] = 'yes'; }

if (stripos($wpq-&gt;getpage('User talk:'.$to),$from) !== false) $params['notified'] = 'yes'; else $params['notified'] = 'no';

if ($wpi-&gt;hasemail($to)) $params['email'] = 'yes'; else $params['email'] = 'no'; $fromec = $wpq-&gt;contribcount($from);

$note = 'User has '.$visibleedits.' undeleted edits, '.$deletededits.' deleted edits, and '.$totaledits.' total edits. ';			$note.= 'Requesting user has '.(isset($fromec)?$fromec:'no').' edits.';

$params['note'] = $note;

$cuutemplate = ': ~';

//			echo $cuutemplate.&quot;\n\n&quot;;

addtobottom(&amp;$request[2],$cuutemplate); }

$newdata = trim($header).&quot;\n\n&quot;; $cdate = ''; unset($m2,$unk); foreach ($m as $k =&gt; $req) { if (preg_match('/(\d{2}):(\d{2}), (\d+) ([a-zA-Z]+) (\d{4}) \(UTC\)/iU',$req[2],$match)) { $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				); $m2[$k] = gmmktime($match[1],$match[2],0,$month[$match[4]],$match[3],$match[5]); } else { $unk[$k] = 'Unknown'; }		}		asort($m2);

foreach ($m2 as $k =&gt; $t) { $req = $m[$k]; if ($cdate != gmdate('F j, Y', $t)) { $cdate = gmdate('F j, Y', $t); $newdata.= '=== '.$cdate.' ==='.&quot;\n&quot;; $newdata.= '\'\'Requests left here will be filled no earlier than '.gmdate('F j, Y', ($t + (8*86400))).'.\'\''.&quot;\n\n&quot;; }			$newdata.= '===='.$req[1].'===='.&quot;\n\n&quot;.trim($req[2]).&quot;\n\n&quot;; }

if (count($unk) &gt; 0) { $newdata.= '=== Unknown ==='.&quot;\n&quot;; foreach ($unk as $k =&gt; $t) { $req = $m[$k]; $newdata.= '===='.$req[1].'===='.&quot;\n\n&quot;.trim($req[2]).&quot;\n\n&quot;; }		}		$newdata.= $footer;

if (trim($newdata) != trim($origdata)) { $summary = 'Clerking: Formatting'; if ($cmt &gt; 0) $summary.= ', adding '.$cmt.' clerk notice'.(($cmt &gt; 1)?'s':''); if (count($darchive) &gt; 0) $summary.= ', archiving '.count($darchive).' done request'.((count($darchive) &gt; 1)?'s':''); if (count($narchive) &gt; 0) $summary.= ', archiving '.count($narchive).' rejected request'.((count($narchive) &gt; 1)?'s':''); $summary.= '. (BOT)'; $wpapi-&gt;edit('Wikipedia:Changing username/Usurpations',$newdata,$summary); }

if (count($darchive) &gt; 0) { $i = 1;

while (strlen($archdata = $wpq-&gt;getpage('Wikipedia:Changing username/Usurpations/Completed/'.$i)) &gt; 100000) $i++;

foreach ($darchive as $req) $archdata.= &quot;\n&quot;.'===='.$req[1].'===='.&quot;\n\n&quot;.trim($req[2]).&quot;\n\n&quot;;

$wpapi-&gt;edit('Wikipedia:Changing username/Usurpations/Completed/'.$i,$archdata,'Archiving '.count($darchive).' request'.((count($darchive) &gt; 1)?'s':'').' from WP:CHUU. (BOT)'); }

if (count($narchive) &gt; 0) { $i = 1;

while (strlen($archdata = $wpq-&gt;getpage('Wikipedia:Changing username/Usurpations/Rejected/'.$i)) &gt; 100000) $i++;

foreach ($narchive as $req) $archdata.= &quot;\n&quot;.'===='.$req[1].'===='.&quot;\n\n&quot;.trim($req[2]).&quot;\n\n&quot;;

$wpapi-&gt;edit('Wikipedia:Changing username/Usurpations/Rejected/'.$i,$archdata,'Archiving '.count($narchive).' request'.((count($narchive) &gt; 1)?'s':'').' from WP:CHUU. (BOT)'); }

unset($darchive,$narchive);

sleep(300); } ?&gt;

ClueBot VI (talk) 18:04, 20 October 2010 (UTC)