forked from oleics/php-webhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.php
42 lines (38 loc) · 1.11 KB
/
link.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
<?php
require_once('inc.php');
$config = require('config.php');
if (file_exists('key.php'))
{
$key = require('key.php');
if ($key['current'] !== $_SERVER['QUERY_STRING'])
{
if ($key['previous'] === $_SERVER['QUERY_STRING'])
{
header('Location: ?' . $key['current']);
}
else if (!isset($_POST['passwd']))
{
echo '<form method="post"><input type="password" name="passwd" /></form>';
}
else if ($_POST['passwd'] !== $config['passwd'])
{
echo 'Wrong';
}
else
{
header('Location: ?' . $key['current']);
}
exit;
}
}
else
{
}
mt_srand(microtime(true) * 1000);
$new = sha1(crypt(microtime(true) . mt_rand() . time() . mt_rand()));
file_put_contents('key.php', '<?php return ' . var_export(array(
'current' => $new,
'previous' => isset($key) ? $key['current'] : '',
), true) . ';');
echo '<label for="webhook">Webhook:</label> <input id="webhook" size="80" type="text" value="' . dirname($_SERVER['SCRIPT_URI']) . '/hook.php?' . $new . '" />';
//print_r($_SERVER);