/
chimpunlock.php
70 lines (60 loc) · 1.82 KB
/
chimpunlock.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
include_once('MCAPI.class.php');
(isset($_COOKIE['chimpunlock']) and
list($username, $password) = explode('|', $_COOKIE['chimpunlock'])) or
(isset($_POST['username']) and $username = $_POST['username'] and
isset($_POST['pass']) and $password = $_POST['pass']) or
list($username, $password) = array(null, null);
#die(serialize(array($username, $password)));
$mc = new MCAPI($username, $password);
if (!$mc->api_key) {
setcookie('chimpunlock', null);
die((isset($_POST['username']) ? 'Couldn\'t log in: '.$mc->errorMessage : '').'
<form action="#" method="POST">
<input type="text" name="username"/>
<input type="password" name="pass"/>
<input type="submit" value="Login"/>
</form>');
}
else {
setcookie('chimpunlock', "$username|$password");
#header('Location: '.$_SERVER['PHP_SELF']) and die();
}
$mc->closeOneOhSecurityHole($username, $password) or
$mc->errorCode == 101 or
die('Security hole still open.'.$mc->errorCode.': '.$mc->errorMessage);
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'expire':
$mc->apikeyExpire($username, $password);
break;
case 'add':
$mc->apikeyAdd($username, $password, $_REQUEST['key']);
break;
}
header('Location: '.$_SERVER['PHP_SELF']) and die();
}
echo '
<table>
<thead>
<tr>
<th>key</th>
<th></th>
</tr>
</thead>
<tbody>';
foreach ($mc->apikeys($username, $password, true) as $key) {
extract($key);
echo "
<tr>
<td>$apikey</td>
<td>$created_at</td>
<td>$expired_at</td>
<td><a href='?action=expire&key=$apikey' class='cmd expire'>expire</a></td>
</tr>";
}
echo "
</tbody>
</table>";
?>
<a href="?action=add" class='cmd add'>add new</a>