Page MenuHomePhabricator
Authored By
stwalkerster
May 26 2017, 6:01 PM
Size
1 KB
Referenced Files
None
Subscribers
None
<?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";
}
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18901
Default Alt Text
(1 KB)

Event Timeline