Page MenuHomePhabricator
Paste P132

(An Untitled Masterwork)
ActivePublic

Authored by stwalkerster on May 26 2017, 6:01 PM.
<?php
$database = new PDO('mysql:host=localhost;dbname=production', 'stwalkerster', 'lolnope');
$stmt = $database->query("select id, name, date from request where status = 'Open' and emailconfirm = 'Confirmed'");
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$api = 'http://en.wikipedia.org/w/api.php?action=query&format=json&list=users&meta=&titles=&usprop=registration&usattachedwiki=&ususers=';
foreach($result as $req) {
$url = $api . urlencode($req['name']);
$data = file_get_contents($url);
$obj = json_decode($data);
if(!isset($obj->query->users[0]->missing)) {
$regDate = new DateTime(($obj->query->users[0]->registration));
$reqDate = new DateTime($req['date']);
$reason = 'Unknown';
if( $regDate < $reqDate ) {
$reason = 'Taken';
}
if( $reqDate < $regDate ) {
$reason = 'Self-create';
}
echo $req['id'] . "|" . $req['name'] . "|" . ($obj->query->users[0]->registration) . "|" . $req['date'] . "|" . $reason . "\n";
}
}

Event Timeline

stwalkerster created this object with visibility "Public (No Login Required)".