Cmd_api_additional_domains

larsisgoed9

Verified User
Joined
Mar 23, 2011
Messages
10
How could I get that API call to werk?
I mean, how can I fetch the outputted data..
Right now I got this code:
Code:
require( 'inc/class/direct/class.httpsocket.php' );
				$Socket = new HTTPSocket;
				$Socket->connect( $core[ 'conf' ][ 'direct' ][ 'server' ], 2222 );
				$Socket->set_login( $core[ 'conf' ][ 'direct' ][ 'user' ], $core[ 'conf' ][ 'direct' ][ 'pass' ] );
				$Socket->set_method( 'GET' );
				$Socket->query('/CMD_API_ADDITIONAL_DOMAINS');
				$newArray = $Socket->direct2array( $Socket->fetch_body( ) );
				echo $Socket->fetch_body( );

So how could I split each domain into an for loop?
 
I've solved this problem right now, by this piece of code:
Code:
require( 'inc/class/direct/class.httpsocket.php' );
						$Socket = new HTTPSocket;
						$Socket->connect( $core[ 'conf' ][ 'direct' ][ 'server' ], 2222 );
						$Socket->set_login( $core[ 'conf' ][ 'direct' ][ 'user' ].'|'.$sel['daname'], $core[ 'conf' ][ 'direct' ][ 'pass' ] );
						$Socket->set_method( 'GET' );
						$Socket->query('/CMD_API_ADDITIONAL_DOMAINS');
						$newArray = $Socket->direct2array( $Socket->fetch_body( ) );
						//echo urldecode($Socket->fetch_body());
						$exploded = explode("=", urldecode($Socket->fetch_body()));
						$count = 0;
						$doms = array();
						while(999){
							if($count == 0){
								$domainnames = $exploded[0];
								$domain = $domainnames;
							} else{
								$domainnames = explode("&", $exploded[(0+($count*18))]);
								$domain = $domainnames[1];
							}
							if($domain == ""){
								break;
							} else{
								$doms[] = array(
									'domain'	=>	$domain
								);
								$count++;
							}
						}

Right now I want to ge the DNS records.
Therefore I use this script:
Code:
require( 'inc/class/direct/class.httpsocket.php' );
							$Socket = new HTTPSocket;
							$Socket->connect( $core[ 'conf' ][ 'direct' ][ 'server' ], 2222 );
							$Socket->set_login( $core[ 'conf' ][ 'direct' ][ 'user' ].'|'.$sel['daname'], $core[ 'conf' ][ 'direct' ][ 'pass' ] );
							$Socket->set_method( 'GET' );
							$Socket->query('/CMD_API_DNS_CONTROL', array('domain' => strip_tags(mysql_real_escape_string($_GET['domain']))));
							$result = $Socket->fetch_parsed_body();

The same way, I wanna list all records.
I found the following code at this forums:

Code:
require( 'inc/class/direct/class.httpsocket.php' );
							$Socket = new HTTPSocket;
							$Socket->connect( $core[ 'conf' ][ 'direct' ][ 'server' ], 2222 );
							$Socket->set_login( $core[ 'conf' ][ 'direct' ][ 'user' ].'|'.$sel['daname'], $core[ 'conf' ][ 'direct' ][ 'pass' ] );
							$Socket->set_method( 'GET' );
							$Socket->query('/CMD_API_DNS_CONTROL', array('domain' => strip_tags(mysql_real_escape_string($_GET['domain']))));
							$result = $Socket->fetch_parsed_body();
							
							foreach($result as $key=>$val){
								$out1=$key;
							}
							$out2=str_replace('_', '.', $out1);
							$lines=explode("\n",$out2);
							foreach($lines as $key=>$line){
								$cells[$key]=explode("\t",$line); // content was tab deliminated
								if(count($cells[$key])==5){
									if($cells[$key][3]=='A'){
										$out[$cells[$key][0]]=$cells[$key][4];
									}
								}
							}
							$result = $out;
							$dnss = array();
							foreach($result as $value){
								$dnss[] = array(
									'type'	=> 'A', 
									'key'	=>	key($result),
									'value'	=>	$value
								);
								next($result);
							}
							
							$core[ 'tpl' ]->assign( 'dnss', $dnss );

The only problem right now is, it only listed the A records, but I also want to get the NS etc. records. I've already tried to remove the if that checks the A record, but it don't works..
Anyone got an idea?
 
Back
Top