User:ClueBot VI/Source
Appearance
The following is automatically generated by ClueBot VI.
- wikibot.classes.php is here.
Source to ClueBot VI
[edit]<?PHP function addtobottom(&$data,$add) { global $cmt; $cmt++; $tmp = explode('===',$data); $tmp[0] = rtrim($tmp[0])."\n".$add."<!-- If removing the CUU/Clerk note template, keep this comment so ClueBot VI won't readd the template. -->\n\n"; $tmp = implode('===',$tmp); $data = $tmp; } include '../wikibot.classes.php'; include 'cluebot6.config.php'; $wpq = new wikipediaquery; $wpapi = new wikipediaapi; $wpi = new wikipediaindex; $wpapi->login($user,$pass); $wpapi->edit('User:'.$user.'/Source', 'The following is automatically generated by [[User:'.$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. */ // $i = 22; while (1) { $crats = array(); $cratsd = $wpapi->users(null,500,"bureaucrat"); foreach ($cratsd as $crat) $crats[] = preg_quote($crat['name'],'/'); $crats = implode('|',$crats); $origdata = $wpq->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."\n\n"; // print_r($m); echo $crats."\n"; foreach ($m as $k => &$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' => 1, 'February' => 2, 'March' => 3, 'April' => 4, 'May' => 5, 'June' => 6, 'July' => 7, 'August' => 8, 'September' => 9, 'October' => 10, 'November' => 11, 'December' => 12 ); if ((time() - gmmktime($match[1],$match[2],0,$month[$match[4]],$match[3],$match[5])) > 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' => 1, 'February' => 2, 'March' => 3, 'April' => 4, 'May' => 5, 'June' => 6, 'July' => 7, 'August' => 8, 'September' => 9, 'October' => 10, 'November' => 11, 'December' => 12 ); if ((time() - gmmktime($match[1],$match[2],0,$month[$match[4]],$match[3],$match[5])) > 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('�',trim($request[1])); if (!isset($to[1])) { addtobottom(&$request[2],':{{Clerk note}} 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->contribcount($to); $visibleedits = 0; $cont = null; while (($count = count($wpapi->usercontribs($to,500,&$cont))) == 500) $visibleedits += $count; $visibleedits += $count; $deletededits = $totaledits - $visibleedits; if ($visibleedits > 0) $params['contribs'] = 'yes'; else $params['contribs'] = 'no'; if ($deletededits > 0) $params['dcontribs'] = 'yes'; else $params['dcontribs'] = 'no'; if (count($wpapi->logs($to)) > 1) $params['logs'] = 'yes'; else $params['logs'] = 'no'; $info = $wpapi->users($to); if ($info[0]['name'] != $to) { addtobottom(&$request[2],':{{Clerk note}} User "'.$to.'" 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])) > 6*30*24*60*60) or ((time() - gmmktime($regdate[4],$regdate[5],$regdate[6],$regdate[2],$regdate[3],$regdate[1])) < 3600)) { $params['new'] = 'no'; } else { $params['new'] = 'yes'; } if (stripos($wpq->getpage('User talk:'.$to),$from) !== false) $params['notified'] = 'yes'; else $params['notified'] = 'no'; if ($wpi->hasemail($to)) $params['email'] = 'yes'; else $params['email'] = 'no'; $fromec = $wpq->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 = ':{{CUU'; foreach ($params as $k => $v) $cuutemplate.='|'.$k.'='.$v; $cuutemplate.= '}} ~~~~'; // echo $cuutemplate."\n\n"; addtobottom(&$request[2],$cuutemplate); } $newdata = trim($header)."\n\n"; $cdate = ''; unset($m2,$unk); foreach ($m as $k => $req) { if (preg_match('/(\d{2}):(\d{2}), (\d+) ([a-zA-Z]+) (\d{4}) \(UTC\)/iU',$req[2],$match)) { $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 ); $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 => $t) { $req = $m[$k]; if ($cdate != gmdate('F j, Y', $t)) { $cdate = gmdate('F j, Y', $t); $newdata.= '=== '.$cdate.' ==='."\n"; $newdata.= '\'\'Requests left here will be filled no earlier than '.gmdate('F j, Y', ($t + (8*86400))).'.\'\''."\n\n"; } $newdata.= '===='.$req[1].'===='."\n\n".trim($req[2])."\n\n"; } if (count($unk) > 0) { $newdata.= '=== Unknown ==='."\n"; foreach ($unk as $k => $t) { $req = $m[$k]; $newdata.= '===='.$req[1].'===='."\n\n".trim($req[2])."\n\n"; } } $newdata.= $footer; if (trim($newdata) != trim($origdata)) { $summary = 'Clerking: Formatting'; if ($cmt > 0) $summary.= ', adding '.$cmt.' clerk notice'.(($cmt > 1)?'s':''); if (count($darchive) > 0) $summary.= ', archiving '.count($darchive).' done request'.((count($darchive) > 1)?'s':''); if (count($narchive) > 0) $summary.= ', archiving '.count($narchive).' rejected request'.((count($narchive) > 1)?'s':''); $summary.= '. (BOT)'; $wpapi->edit('Wikipedia:Changing username/Usurpations',$newdata,$summary); } if (count($darchive) > 0) { $i = 1; while (strlen($archdata = $wpq->getpage('Wikipedia:Changing username/Usurpations/Completed/'.$i)) > 100000) $i++; foreach ($darchive as $req) $archdata.= "\n".'===='.$req[1].'===='."\n\n".trim($req[2])."\n\n"; $wpapi->edit('Wikipedia:Changing username/Usurpations/Completed/'.$i,$archdata,'Archiving '.count($darchive).' request'.((count($darchive) > 1)?'s':'').' from [[WP:CHUU]]. (BOT)'); } if (count($narchive) > 0) { $i = 1; while (strlen($archdata = $wpq->getpage('Wikipedia:Changing username/Usurpations/Rejected/'.$i)) > 100000) $i++; foreach ($narchive as $req) $archdata.= "\n".'===='.$req[1].'===='."\n\n".trim($req[2])."\n\n"; $wpapi->edit('Wikipedia:Changing username/Usurpations/Rejected/'.$i,$archdata,'Archiving '.count($narchive).' request'.((count($narchive) > 1)?'s':'').' from [[WP:CHUU]]. (BOT)'); } unset($darchive,$narchive); sleep(300); } ?>
ClueBot VI (talk) 18:04, 20 October 2010 (UTC)