PHP class for communicating with DA

dryas

Verified User
Joined
Nov 6, 2003
Messages
14
Location
Germany / Rheine
Hello,

there is a big problem with the new html safe characters feature in version 1.203.

The "parse_str" PHP Function will not work together with the unicode html characters.... :-(

Benny

---
Linuworx.de
 
Last edited:

dryas

Verified User
Joined
Nov 6, 2003
Messages
14
Location
Germany / Rheine
Hi,

sorry, but this feature is terrible. :( Nothing against html safe characters, but it blocks any php or perl script.

If you use &#[NUMBER], PHP didn't work, because it misinterprets the GET Variables. If you use %[NUMBER] Perl will make problems...

The %[NUMBER] works with PHP, but this is not HTML safe, isn't it? I must search and replace all the characters all the time...

Out of the frying pan into the fire... :(

Benny
 
Last edited:

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
Just escape = and & somehow, with some character sequence, or something. Nothing else is needed.

= -> |EQL|
& -> |AMP|

or something. :)

With the class I can easily convert these back to = and &.
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
Ah, yes. For some reason I was under the impression this still wasn't fixed. Sorry :)
 

lidios

Verified User
Joined
Oct 20, 2003
Messages
9
ERROR

Hi,

Every time I try to use this, it tells me:

Could not excute your request



Details
You do not own that domain

Would anyone know why that is?
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
Check and make sure you're using the admin|{username} // {admin_password} login format
 

lidios

Verified User
Joined
Oct 20, 2003
Messages
9
I found what was wrong!

In the examples, it showed the domain name to be inside {}, apparently, the {} are not needed. After I took those out, it worked fine.

This is what I'm talking about:


<?php

include 'httpsocket.php';

$sock = new HTTPSocket;

$sock->connect('comain.com',2222);
$sock->set_login('username,'************');

$sock->set_method('POST');

$sock->query('/CMD_EMAIL_POP',
array(
'action' => 'create',
'domain' => 'domain.com', //NOT '{domain.com}'
'user' => 'start',
'passwd' => 'pass',
'passwd2' => 'pass',
'create' => 'Create'
));
$result = $sock->fetch_body();

echo $result;

?>
 

lidios

Verified User
Joined
Oct 20, 2003
Messages
9
QUESTION

I have a Question though...

How can you set it so that after, lets say, the POP account has been created, the default header (Log Out, Change Password, Help, buttons, and on the left, the DA Logo, and the tree) don't show up?

The links are broken anyways, which I guess is good cuz noone wants visitors to be able to do anything after creating their Email account...
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
lidios said:
In the examples, it showed the domain name to be inside {}, apparently, the {} are not needed. After I took those out, it worked fine.
Yeah, sorry, I use them to show you need to insert something. Maybe using $whatever inplace of {whatever} would be better.
lidios said:
How can you set it so that after, lets say, the POP account has been created, the default header (Log Out, Change Password, Help, buttons, and on the left, the DA Logo, and the tree) don't show up?
You're going to have to regex the body result and cut out anything you don't want.

Remember, any CMD_API* token will return a pretty result that this php class can parse. It's the other tokens that end up returning their in-DA HTML values.
 
Last edited:

Marckus_e

Verified User
Joined
Feb 18, 2004
Messages
36
Location
Sweden
I have just tried to use the finished example of the CMD_DOMAIN script from l0rdphi1.

I change the login and password, servername and what the domain it should create.

Run the script and end up on the login page, nothing seems to be runned.

No errors?

Creating a user works fine but i want to be able to create a second domain with CMD_DOMAIN (which isn't in the API list).

/Best Regards
Marcus
 

Marckus_e

Verified User
Joined
Feb 18, 2004
Messages
36
Location
Sweden
PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('ssl://ipadress',2222);

$sock->set_login("admin|web270","notforyou!");

$sock->set_method('POST');

$sock->query('/CMD_DOMAIN',
    array(
        'action' => 'create',
        'domain' => 'kalletestar.se',
        'ubandwidth' => 'unlimited',
        'uquota' => 'unlimited',
        'ssl' => 'OFF',
        'cgi' => 'ON',
        'php' => 'ON',
        'create' => 'Create'
    ));
$result = $sock->fetch_body();

echo $result;

?>
There it is!
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
Hmmmm. You are using your 'admin' user password, correct? Besides the SSL connection (which people have been having trouble with), that looks like it should work without any problems. Are you sure your PHP configuration is set up to handle ssl:// includes in PHP? (I'd guess it is, though)
 

Marckus_e

Verified User
Joined
Feb 18, 2004
Messages
36
Location
Sweden
Solved!

Used the wrong password.

One shall not work on mondays!

/Marcus
 
Last edited:

guido

Verified User
Joined
Mar 20, 2004
Messages
23
Question

OKe,

I'm new with this so bare with me :D

Oke I have a reseller account with a certain hostingcompany... Created a new user with a own domain, where I want to automatically, with the help of PHP, create new subdomains and emailaccounts.

for example:

'mydomain.com' is the account, with 'test' as username and 'rain' as password
And I want to create the next examples:

test.mydomain.com

and

test@mydomain.com


Well the email part worked with me, by using the virtual email commands : /CMD_API_POP

The username + password I used for that command were the username and password of the 'mydomain.com' account (created under 'Your Reseller').

But the listing and creation of subdomains, doesn't work with me. I will c&p an example where I was trying to print a list of already existing subdomains:

PHP:
$sock = new HTTPSocket;  
$sock->connect("<my IP>",<my Port>); 
$sock->set_login("test","rain");$sock->query('/CMD_API_SUBDOMAINS', array('domain' => 'mydomain.com'));    

$result = $sock->fetch_parsed_body();  
print_r($result);

What am I doing wrong :D
 

guido

Verified User
Joined
Mar 20, 2004
Messages
23
Aaaahhh

A little bit of reading explains a LOT :)

oke they are running 1.21.0 and the commands I try to use are implements in 1.21.2 -> figures...

So I'll just bug those guys, if the want to upgrade...

I'll be back :D
 

guido

Verified User
Joined
Mar 20, 2004
Messages
23
Next Question ;)

Oke next question... I can do almost everything:

create subdomains
create databases
create emailboxes

and get lists of all the options above.

BUT is it also possible to create FTP accounts (under the subdomain)? I can't find anything about it in the API, but I've to admit, I'm a really bad reader as well as a writer :D

So is FTP control something I overlooked or just not present... and where can I request such a API extention ;) Because if I'm getting it right "l0rdphi1" is the PHP code master, but not the DA developer, that's John isn't it?

Greetz
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,905
Hello,

Anything you can do via webbrowser can be done via the API. The only difference is that you might not get a parseable result, but the command will be executed. Just load the desired page in your web browser, go "view source" and retrieve all form values for the command you want and apply them to your script.

John
 
Top