/
uploadtool.php
44 lines (38 loc) · 1.18 KB
/
uploadtool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php include ("navbar.php"); ?>
<?php
/**
Landing page for OAuth authorization
*/
include 'OAuthFunctions.php';
// Fetch the access token if this is the callback from requesting authorization
if (isset($_GET['oauth_verifier']) && $_GET['oauth_verifier']) {
fetchAccessToken();
}
$res = doApiQuery(array(
'format' => 'json',
'action' => 'query',
'meta' => 'userinfo',
), $ch, "");
if (isset($res->error->code) && $res->error->code === 'mwoauth-invalid-authorization') {
// We're not authorized!
header("Location: upload.php");
}
if (isset($res->query->userinfo)) {
$wikiUsername = $res->query->userinfo->name;
}
if (isset($res->query->userinfo->anon)) {
header("HTTP/1.1 $errorCode Internal Server Error");
echo 'Not logged in. (How did that happen?)';
exit(0);
}
?>
<div class="main">
<div class="container" style="width:1000px">
<br>
<font size="-1">You are now logged in as <b><?php print_r($wikiUsername); ?></b>.<br>
To revoke access go to settings in your Wikimedia account.<br>
You can close this tab and continue uploading images.
</div>
</div>
</div><!-- #wrapper closes -->
<?php include ("footer.php"); ?>