mimic
Verified User
Bump.
Please help me with the post above this one.
Please help me with the post above this one.
// instance connection
if ($this->bind_host)
{
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($socket,$this->bind_host);
if (!@socket_connect($socket,$this->remote_host,$this->remote_port))
{
$OK = FALSE;
}
}
else
{
$socket = @fsockopen( $this->remote_host, $this->remote_port, $sock_errno, $sock_errstr, 10 );
}
if ( !$socket || !$OK )
{
$this->error[] = "Can't create socket connection to $this->remote_host:$this->remote_port.";
return 0;
}
// instance connection
if ($this->bind_host)
{
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket)
{
$OK = false;
$this->error[] = socket_strerror(socket_last_error());
}
else if (!socket_bind($socket,$this->bind_host))
{
$OK = false;
$this->error[] = socket_strerror(socket_last_error());
}
else if (!@socket_connect($socket,$this->remote_host,$this->remote_port))
{
$OK = false;
$this->error[] = socket_strerror(socket_last_error());
}
}
else
{
$socket = @fsockopen( $this->remote_host, $this->remote_port, $sock_errno, $sock_errstr, 10 );
$this->error[] = $sock_errstr;
}
if ( !$OK || !$socket )
{
$this->error[] = "Can't create socket connection to $this->remote_host:$this->remote_port.";
return false;
}
I'm pretty new when it comes to this....but is there a way to store server, username and ip so that you don't have to enter it manually into every fuction do you.
What I would do, is have a .php file somewhere on your site - call it maybe da.php.. Its contents could have something like..
<?
$daip = "xxx.xxx.xxx.xxx"; // Server IP Address
$dauser = "username"; // username
$dapass = "password"; // password
?>
Then all you need to do, is "include" the file and that way you always have those variables with the values...
<? include("da.php"); ?>
Tis that simple
Then try using an array
$dauser['server1'] = "XXXXXXX";
$dapass['server1'] = "YYYYYYYYY";
$daip['server1'] = "xxx.xxx.xxx.xxx";
Then you just call up the specific $dauser['Whichever']...
Would that do the job?
$sock->query("/CMD_API_SHOW_USER_CONFIG?name=client1");
$result = $sock->fetch_parsed_body();
...
echo $result['package'];
Hey.
This is a small PHP class put together to help communicate with DirectAdmin. It is simple enough, and most anyone can make good use of it.
You cannot execute that command
Details
The request you've made cannot be executed because it does not exist in your authority level
Uhm I`ve uploaded the same script to my server and used "localhost" as hostname, the result is the same, DA says I don`t have the authority level. Heeeeeellllllpppppp!!!!I ran the script (show_all_users.php script) on a remote webserver (apache on my laptop) using my resellers username and password and my server gives me the following error:
You cannot execute that command
----------------------------------
Details
The request you\'ve made cannot be executed because it does not exist in your authority level
I`ve used my reseller username and password, also tried a client's account user and password. Could it be that DA would only accept requests from localhost? And reject any http request that comes from another IP / host? Are my options getting slimmer? Is there a command in the api that shows me the authority level I have and the commands I can execute?
$socket = new HTTPSocket;
$socket->connect('****.nl',2222);
$socket->set_login('*****', '******');
$socket->query('/CMD_CRON_JOBS');
$result = $socket->fetch_body();
echo $result;
php
include 'httpsocket.php';
$passwd = $_POST[passwd];
$domain ='*****';
$user = $_POST[user];
$sock = new HTTPSocket;
$sock->connect('*********',2222);
$sock->set_login("******","********");
$sock->set_method('POST');
$sock->query('CMD_API_POP',
array(
'action' => 'create',
'domain' => '$domain',
'user' => '$user',
'passwd' => '$passwd',
'quota' => '10'
));
$result = $sock->fetch_body();
echo $result;
?>
<form action="da_create_mail.php" method="post" name="form_mail_accounts" id="form_mail_accounts">
<div align="center"></div>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><div align="center"><span class="style1">add</span></div></td>
</tr>
<tr>
<td width="55%">user<input name="user" type="text" id="user" size="25" maxlength="12"></td>
<td width="55%">pass<input name="passwd" type="text" id="passwd" size="25" maxlength="12"></td>
</tr>
</table>
<div align="center"></div>
<p align="center">
<input type="submit" name="Submit" value="add">
<input type="reset" name="Submit2" value="Reset Form">
</p>
</form>
[PHP]
$sock->query('/CMD_API_POP','domain=$domain"a='.$_POST['quota'].'&action=create&user='.$_POST['user'].'&passwd='.$_POST['passwd'].'');
///echo $sock->result;
if(eregi('error=0', $sock->result)){
echo '<p>Email<br />
username: '.$_POST['user'].'@$domain<br />
password: '.$_POST['passwd'].'<br />
Quota: '.$_POST['quota'].'<br />
POP3 server: mail.$domain<br />
SMTP server: mail.$domain*</p>';
}
if(eregi('error=1', $sock->result)){
echo 'error';
}