Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P132
(An Untitled Masterwork)
Active
Public
Actions
Authored by
stwalkerster
on May 26 2017, 6:01 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F20615:
May 26 2017, 6:01 PM
2017-05-26 18:01:32 (UTC+0)
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
"
;
}
}
Event Timeline
stwalkerster
created this paste.
May 26 2017, 6:01 PM
2017-05-26 18:01:32 (UTC+0)
stwalkerster
created this object with visibility "Public (No Login Required)".
Log In to Comment