get['s'])) { $this->get['s'] = null; } switch($this->get['s']) { default: $content = $this->list_supermasters(); break; case 'add': return $this->add_supermaster(); case 'delete': return $this->delete_supermaster(); } return eval($this->template('ADMIN_SUPERMASTERS')); } /** * Display a listing of existing supermaster records * * @author Roger Libiez [Samson] http://www.iguanadons.net * @since 1.1.5 **/ function list_supermasters() { $count = 0; $content = ''; $masters = $this->db->query( 'SELECT * FROM supermasters' ); while( $master = $this->db->nqfetch( $masters ) ) { $count++; $ip = $this->format( $master['ip'], FORMAT_HTMLCHARS ); $ns = $this->format( $master['nameserver'], FORMAT_HTMLCHARS ); $account = $this->format( $master['account'], FORMAT_HTMLCHARS ); $content .= eval($this->template('ADMIN_SUPERMASTER_ENTRY')); } if( $count == 0 ) $content = $this->lang->supermasters_none; return $content; } /** * Create a supermaster record for PDNS * * IP address should always be the PDNS server this code is running on. * Nameserver is a domain name to look for in the notification from the master server. * The account value is not used for anything that I can see, so it's set to "Internal" * * @author Roger Libiez [Samson] http://www.iguanadons.net * @since 1.1.5 **/ function add_supermaster() { if(!isset($this->post['submit'])) { return eval($this->template('ADMIN_SUPERMASTER_ADD')); } $ip = $this->post['ip']; $ns = $this->post['ns']; // If the 2 pieces of useful input match, then we can't insert the data. $exists = $this->db->fetch( "SELECT * FROM supermasters WHERE ip='%s' AND nameserver='%s'", $ip, $ns ); if( $exists ) return $this->message( $this->lang->supermaster_add, $this->lang->supermaster_exists ); $type = 'A'; if( strpos( $ip, '.' ) === false ) $type = 'AAAA'; if( !$this->is_valid_ip($ip, $type) ) return $this->message( $this->lang->supermaster_add, $this->lang->supermaster_ip_invalid ); if( !$this->is_valid_domain($ns) ) return $this->message( $this->lang->supermaster_add, $this->lang->supermaster_ns_invalid ); $this->db->query( "INSERT INTO supermasters (ip,nameserver,account) VALUES( '%s', '%s', 'Internal' )", $ip, $ns ); return $this->message( $this->lang->supermaster_add, $this->lang->supermaster_added ); } /** * Delete an existing supermaster record * * @author Roger Libiez [Samson] http://www.iguanadons.net * @since 1.1.5 **/ function delete_supermaster() { $ip = isset($this->get['ip']) ? $this->get['ip'] : '*BOGUS*'; $ns = isset($this->get['ns']) ? $this->get['ns'] : '*BOGUS*'; $exists = $this->db->fetch( "SELECT ip,nameserver FROM supermasters WHERE ip='%s' AND nameserver='%s'", $ip, $ns ); if( !$exists ) return $this->message( $this->lang->supermaster_delete, $this->lang->supermaster_ns_unknown ); if( !isset($this->get['confirm'])) return $this->message( $this->lang->supermaster_delete, $this->lang->supermaster_confirm_delete . ' ' . $ns . '?', "{$this->lang->delete}" ); $this->db->query( "DELETE FROM supermasters WHERE ip='%s' AND nameserver='%s'", $ip, $ns ); return $this->message( $this->lang->supermaster_delete, $this->lang->supermaster_deleted ); } } ?>