dns api delete

VinceSTM

Verified User
Joined
Oct 29, 2006
Messages
21
I am trying to develop a script that connects to the api of DA (DNS-only).

The insertion works perfectly, the exist works too, but the delete doesn't work. My code:
$action = $_GET["action"];
else if($action == "delete")
{
$domain = $_GET["select0"];
//delete
}

any idea?
 
It goes further:

The request the directadmin does after a domain deletion is the following:

Contents of $_GET:

Contents of $_POST:

Contents of $_COOKIE:

Contents of $_REQUEST:

Contents of $_SERVER:
CONTENT_LENGTH = 42
DOCUMENT_ROOT = /var/www/html
PATH = /usr/bin:/bin
REDIRECT_STATUS = 200
REDIRECT_URL = /CMD_API_DNS_ADMIN
REMOTE_ADDR = *.*.*.*
REMOTE_PORT = 58536
SCRIPT_FILENAME = /var/www/html/da_api.php
SERVER_ADDR = *.*.*.*
SERVER_ADMIN = webmaster@****
SERVER_NAME = localhost
SERVER_PORT = 80
SERVER_SIGNATURE = <ADDRESS>Apache/1.3.39 Server at localhost Port 80</ADDRESS>

SERVER_SOFTWARE = Apache/1.3.39 (Unix) mod_ssl/2.8.30 OpenSSL/0.9.8e PHP/4.4.4 FrontPage/5.0.2.2510
GATEWAY_INTERFACE = CGI/1.1
SERVER_PROTOCOL = HTTP/1.0
REQUEST_METHOD = POST
QUERY_STRING =
REQUEST_URI = /CMD_API_DNS_ADMIN
SCRIPT_NAME = /da_api.php
PATH_TRANSLATED = /var/www/html/da_api.php
PHP_SELF = /da_api.php
PHP_AUTH_USER = user
PHP_AUTH_PW = test
argv = Array
argc = 0


The Directadmin doesn't give an action or domain....
 
Hello,

I believe we're also checking this via email as well.. in any case, if you have another DA server, try starting it up in logging debug mode to see what's being passed:
Code:
cd /usr/local/directadmin
killall -9 directadmin
./directadmin b800
on the remote server (call it B)... then issue a delete request on server A to see if it makes it through.

Another suggestion... if possible, create a cgi-bin file to accept the raw data from DA.. check the headers that way. DA-to-DA works fine, but I'll admit that DA is not apache, nor does it use the same parsers... if there are any slight variances with headers that apache may be choking on, only the raw form would be able to point it out for us.

So in your cgi-bin, create something that takes all stdinput and dumps it to the screen, after the usual httpd headers, or just to a file, so we can see exactly the full request.

The action=rawsave function is next to exactly the same as the action=delete version, hence it's strange how one works, but theo the other doesn't, while they all work DA-to-DA just fine.

John
 
Accepting Connections on port 2222
0: Authorization: Basic ***********
1: Content-Length: 43
Post string: action=delete&select0=aapjes.nl&cluster=yes

This works (da to da)

Do you have any idea how I should make such a cgi script?
 
Here is a sample perl script that could kind of do it:
http://www.troubleshooters.com/codecorn/littperl/perlcgi.htm

Modified a bit:
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n output to file";
open (LOGOUT, ">/home/[B]username[/B]/output.txt");
while(<STDIN>)
{
      chomp($_);
      print LOGOUT "$_\n";
}
close(LOGOUT);
chmod it to 700, chown is to username:username

I didn't test this for any syntax errors.

John
 
i get a 403 forbidden..

(put it in public_html/cgi-bin/help.cgi)
chown -> user:user (where user is my user)
chmod -> 700

edit: i didn't had any rights on cgi-bin

now:
500: Internal Server Error
 
Last edited:
Try running it manually, eg:
Code:
cd /home/username/domains/domain.com/cgi-bin
./help.cgi
and see what that generates.
Type something in by hand like "test test", and press ctrl-d to close the stdin pipe to see if it's writing to the file or not.

This is the general guide for debuggin cgi-bin files:
http://help.directadmin.com/item.php?id=6

John
 
So your cgi received the whole request correctly? Can you paste out the entire set of httpd headers and the request (hide any authentication bits or anything that should be hidden).

Worst case, just use a cgi-bin script to do the processing if you know that it can see the request correctly.. but it's probably something with the mod_rewrite.. but I honestly can't say for sure.

John
 
hey, it works with:

$del = $HTTP_RAW_POST_DATA;
if(substr($del,0,14) == "action=delete&")
{
 
Back
Top