Giter VIP home page Giter VIP logo

Comments (3)

loewexy avatar loewexy commented on June 30, 2024 1

This seems to be a good idea. I will think on this and how to implement if I have enough time. There are some minor conceptual changes in the way the api works.
Is there any official documentation on the dyndns2 protocol?

from pdnsmanager.

jaapjolman avatar jaapjolman commented on June 30, 2024

not really i can send you some code i wrote to make it work, i used codeigniter for it, it was pretty strait forward let me upload the code i have

from pdnsmanager.

jaapjolman avatar jaapjolman commented on June 30, 2024

`<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Nic extends CI_Controller
{
public function index()
{
$this->checkip();
}

public function checkip()
{
    header("Content-Type: text/plain");
    print $_SERVER['REMOTE_ADDR'];
}

public function update()
{
    if (!isset($_SERVER['PHP_AUTH_USER']))
    {
        header('WWW-Authenticate: Basic realm="DYNDNS"');
        header('HTTP/1.0 401 Unauthorized');
        exit;
    }
    $data           = new stdClass();
    $data->username = $_SERVER['PHP_AUTH_USER'];
    $data->password = $_SERVER['PHP_AUTH_PW'];
    $data->hostname = explode(',', $this->input->get('hostname'));
    $data->ip       = ( $this->input->get('myip') !== null ) ? $this->input->get('myip') : $this->input->ip_address() ;

    $user_data      = $this->db->select('user_id')
                               ->where('username', $data->username)
                               ->where('password', $data->password)
                               ->get('remote_users');

    if($user = $user_data->row())
    {
        foreach($data->hostname as $hostname)
        {
            $check_record   = $this->db->select('record_id')
                                       ->from('records')
                                       ->join('xref_users_records',             'records.id = xref_users_records.record_id')
                                       ->where('records.name',                  $hostname)
                                       ->where('xref_users_records.user_id',    $user->user_id)
                                       ->get();

            if($record_data = $check_record->row())
            {
                $record             = new stdClass();
                $record->content    = $data->ip;

                $this->db->where('id', $record_data->record_id);
                $this->db->update('records', $record);

                $log                = new stdClass();
                $log->user          = $data->username;
                $log->record        = $hostname;
                $log->ip_address    = $data->ip;
                $log->timestamp     = date('Y-m-d H:i:s');

                $this->db->insert('xref_logs', $log);

                print "good " . $data->ip;
            }
            else
            {

                print "nohost";
                exit();
            }
        }
    }
    else
    {
        print "badauth";
        exit();
    }
}

}
`

from pdnsmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.