Comunicating with Direct Admin....

2oo4

New member
Joined
Jul 7, 2004
Messages
4
Hey,

I am using the class posted in this forum section but it just doesn't works if I want to get the information out of an array,
I am using PHP. The script:

PHP:
include ('da_config.php');

    $query = "SELECT * FROM config";   
    $result = mysql_query($query) or die (mysql_error(''));   
    while($obj = mysql_fetch_assoc($result)) { 

if($obj['config_naam'] == "da_domeinnaam")    {
$da_domein = $obj['config_waarde'];
}elseif($obj['config_naam'] == "da_poort")    {
$da_poort = $obj['config_waarde']; 
}elseif($obj['config_naam'] == "da_username") {
$uname = $obj['config_waarde']; 
}elseif($obj['config_naam'] == "da_pass") {
$passwd = $obj['config_waarde']; 
}elseif($obj['config_naam'] == "da_ip") {
$da_ip = $obj['config_waarde']; }
}

$sock = new HTTPSocket;
$sock->connect($da_domein,$da_poort);

$sock->set_login($uname,$passwd);

$sock->set_method('POST');

include('password.php');
foreach($_POST['domein'] as $domain){
foreach ($_POST[''.str_replace(".", "_", $domain).'_plan'] as $da_plan){

$sql = "SELECT * FROM plan";
$resultaat = mysql_query($sql) or die(mysql_error());
$aantal = mysql_num_rows($resultaat);
while ($record = mysql_fetch_object($resultaat)) {

	  if ($da_plan == $record->planid) {
		$da_plan2 = $record->da_plannaam; }
		}
$username = substr ("$domain", -8, 8);
$pass = genlatpas(9); 

$array = array(
    'action' => 'create',
	'add' => 'Submit',
	'username' => $username,
	'email' => $email,
	'passwd' => $pass,
	'passwd2' => $pass,
    'domain' => $domain,
    'package' => $da_plan2,
    'ip' => $da_ip,
    'notify' => 'no',
    );

$sock->query('/CMD_ACCOUNT_USER',$array);
$result = $sock->fetch_body(); 
echo $username;
echo $email;
echo $pass;
echo $domain;
echo $da_plan2;
echo $da_ip;
}}}

Can someone see the bug?

At the end he shows the username, e-mail pass domain plan and the ip adress but it wont make the account :confused:
 
Hello,

Try
PHP:
echo $result
right after your call sock->fetch_body(); It should tell you if there are any errors.

John
 
OK! THANKS!

It was the dot in the username that was the problem. Da doesn't support a dot in the username :)

But thanks to the Direct Admin Support and this little line of code it works now :D
PHP:
$username = str_replace(".", "", $username);

Thnx!!!
 
I would also suggest that other than changing invalid charaters to something else to abort and notify the user of invalid characters so that they can choose a new username, so as not to cause problems when they can't login, that is if this if for production use.
 
jmstacey said:
I would also suggest that other than changing invalid charaters to something else to abort and notify the user of invalid characters so that they can choose a new username, so as not to cause problems when they can't login, that is if this if for production use.

The username is based on the domain.

If a user orders a package the system generates his password etc and afther all that it will e-mail it all to the user.
 
Back
Top