great.
here is the code, if anyone is interested.
I put it in:
/usr/local/ispconfig/interface/web/tools/dyndns
PHP Code:
<?php
$user = $_GET['user'];
$pass = $_GET['pass'];
$ip = isset($_GET['ip']) ? isset($_GET['ip']) : $_SERVER['REMOTE_ADDR'];
$domain = !empty($_GET['domain']) ? $_GET['domain'] : error(500, "missing domain");
require_once('../../../lib/config.inc.php');
require_once('../../../lib/classes/auth.inc.php');
require_once('../../../lib/app.inc.php');
global $app;
$ip = $app->db->quote($ip);
$user = $app->db->quote($user);
$pass = $app->db->quote($pass);
$domain = $app->db->quote($domain);
$sql = "SELECT * FROM sys_user WHERE USERNAME = '$user' and ( PASSWORT = '".md5($pass)."' or PASSWORT = password('$pass') )";
$app->db->show_error_messages = true;
$dbuser = $app->db->queryOneRecord($sql);
if ($dbuser === false) error(403, "authentication failed");
$groups = $dbuser['groups'];
$id = $app->db->queryOneRecord("SELECT id FROM dns_rr WHERE name = '$domain' AND type = 'A' AND sys_groupid IN ($groups)");
if ($id === false) error(404, "DNS record not found");
$id = $id['id'];
$app->db->query("UPDATE dns_rr SET data = '$ip' WHERE id = $id");
function error($code, $msg)
{
header("HTTP/1.0 $code $msg");
echo $msg;
die();
}
?>
Client code example:
#! /bin/sh
# this code should run from cron.houry of the machine that need to update the dns
USER=username
PASS=password
DOMAINS=(domain1.com. domain2.com.)
for DOMAIN in ${DOMAINS[@]}
do
URL="http://YOUR_ISPCONFIG_SERVER:8080/tools/dyndns/update.php"
response=$(HEAD -m GET "$URL?user=$USER&pass=$PASS&domain=$DOMAIN") || echo $response
done
Note that the domains should be exactly as mentioned in the dns_rr table (including trailing dot).
Recent comments
17 hours 13 min ago
23 hours 54 min ago
1 day 3 hours ago
1 day 5 hours ago
1 day 13 hours ago
1 day 23 hours ago
2 days 6 min ago
2 days 3 hours ago
2 days 8 hours ago
2 days 8 hours ago