forked from yswery/PHP-DNS-SERVER
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.php
56 lines (43 loc) · 1.41 KB
/
update.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
<?php
error_reporting(E_ALL);
$username = filter_input(INPUT_GET, "username");
if(isset($_SERVER['PHP_AUTH_USER']))
$username = $_SERVER['PHP_AUTH_USER'];
$password = filter_input(INPUT_GET, "password");
if(isset($_SERVER['PHP_AUTH_PW']))
$password = $_SERVER['PHP_AUTH_PW'];
$domain = filter_input(INPUT_GET, "domain");
if(filter_input(INPUT_GET, "hostname"))
$domain = filter_input(INPUT_GET, "hostname");
$ip = filter_input(INPUT_GET, "ip");
if(filter_input(INPUT_GET, "myip"))
$ip = filter_input(INPUT_GET, "myip");
require "loader.php";
$config = new \yswery\DNS\MySQLConfigProvider();
$c = new mysqli($config->host, $config->user, $config->password, $config->database);
$q = $c->query("SELECT * FROM
NSUser
WHERE
NSUserName = '".$c->real_escape_string($username)."'
AND NSUserPassword = '".$c->real_escape_string(sha1($password))."'
AND NSUserDomain = '".$c->real_escape_string($domain)."'");
$t = $q->fetch_object();
if(!$t){
header("HTTP/1.0 401 Unauthorized");
die();
}
$q = $c->query("
UPDATE
NSEntry
SET
NSEntryData = '".$c->real_escape_string($ip)."',
NSEntryUpdate = '".time()."'
WHERE
NSEntryType = 'A'
AND NSEntryDomain = '".$c->real_escape_string($domain)."'");
$update = new stdClass();
$update->domain = $domain;
$update->ip = $ip;
msg_send(msg_get_queue(3456), 8, $update, true, false, $err);
msg_send(msg_get_queue(3457), 8, $update, true, false, $err);
echo "good ".$ip;