Dynamic DNS

Discussion in 'Developers' Forum' started by omry, Sep 17, 2008.

  1. FFH

    FFH Member

    Hi Till, The user does exist and username and password is absolutely correct.
    I have setup a test environment for this, I am really keen to get this working. Any help greatly appreciated.
    Here is the code, you can see I have applied your update already.

    PHP:
    <?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 === falseerror(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 === falseerror(404"DNS record not found");
    $id $id['id'];
    $app->db->datalogUpdate('dns_rr'"data = '$ip'"'id'$id);

    function 
    error($code$msg)
    {
        
    header("HTTP/1.0 $code $msg");
        echo 
    $msg;
        die();
    }
    ?>
     
    Last edited: Dec 7, 2017
  2. FFH

    FFH Member

    So I am trying to update this script for the newer version of ISPConfig. I have hit a couple of roadblocks so any help will be appreciated.

    The idea of this is you can use a URL to update an A record for a particular domain: http://host.example.com:8080/tools/dyndns/update.php?domain=test&user=username&pass=password

    This is what I have right now, works sometimes but not all the time. I think it has something to do with the groupid and userid. Sorry, I am just crap at this and muddling my way through...

    PHP:
    <?php
    require_once('../../../lib/config.inc.php');
    #require_once('../../../lib/classes/db_mysql.inc.php');
    require_once('../../../lib/app.inc.php');

    $dbname 'dbispconfig';
    $dbuser 'xxxxxxxxxxxx';
    $dbpass 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
    $dbhost 'localhost';

    $user $_GET['user'];
    $pass $_GET['pass'];
    $remoteip = isset($_GET['ip']) ? isset($_GET['ip']) : $_SERVER['REMOTE_ADDR'];
    $domain = !empty($_GET['domain']) ? $_GET['domain'] : error(500"missing domain");

    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 client WHERE USERNAME = '$user' and ( PASSWORD = '".md5($pass)."' or PASSWORD = password('$pass') )";
    $app->db->show_error_messages true;
    $dbuser $app->db->queryOneRecord($sql);
    #$pas = md5($pass);
    if ($dbuser == $falseerror(403"authentication failed");
    $groups $dbuser['sys_groupid'];
    $id $app->db->queryOneRecord("SELECT id FROM dns_rr WHERE name = '$domain' AND type = 'A' AND sys_groupid = '$groups'");
    if (
    $id == $falseerror(404"DNS record not found");
    $clientid $id['id'];

    $updateresult $app->db->query("UPDATE dns_rr SET data = '$remoteip' WHERE id = '$clientid' ");
    if (
    $updateresult == $falseerror(404"DNS record not updated");

    $newip $app->db->queryOneRecord("SELECT data FROM dns_rr WHERE name = '$domain' AND type = 'A' AND sys_groupid = '$groups' ");
    $changedip $newip['data'];
    if(
    $changedip == $remoteiperror(400"DNS record updated");
    if(
    $changedip != $remoteiperror(404"DNS record not updated");
    $app->db->close();

    function 
    error($code$msg)
    {
        
    header("HTTP/1.0 $code $msg");
        echo 
    $msg;
        die();
    }
    ?>
    Any help greatly appreciated. :)
     
  3. FFH

    FFH Member

    I have managed to get an updated version of this running quite nicely.
    Cheers. :)
     

Share This Page