Файл: billing/_rootinc/todaynic.inc.php
Строк: 250
<?
require_once($full_home_path."/_rootinc/todaynic/xmlbase.inc.php");
require_once($full_home_path."/_rootinc/todaynic/agentxmlclient.inc.php");
require_once($full_home_path."/_rootinc/todaynic/Domain_class.inc.php");
class TODAYNIC
{
public $controller = true;
public $url=null;
public $user=null;
public $password = null;
public $error = null;
public $fp=null;
/*
* initialization
*/
public function startup(&$controller)
{
$this->controller =& $controller;
}
/*
* initialization
*/
public function init($url,$user,$password)
{
$this->url=$url;
$this->user=$user;
$this->password=$password;
}
public function registerDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$name,$org,$country,$state,$post,$city,$street,$phone,$fax,$mobile,$email)
{
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$Domain['domainname']=$domain;
$Domain['domainperiod']=$period;
$Domain['ns1']=$ns1;
$Domain['ns2']=$ns2;
if ($ns3) { $Domain['ns3']=$ns3; }
if ($ns4) { $Domain['ns4']=$ns4; }
if (!$state) { $state = "NA"; }
if (!$fax) { $fax = $phone; }
$Regist['name']=$name;
$Regist['cnname']="null";
$Regist['org']=$org;
$Regist['cnorg']="null";
$Regist['cc']=$country;
$Regist['sp']=$state;
$Regist['pc']=$post;
$Regist['city']=$city;
$Regist['street']=$street;
$Regist['street1']="";
$Regist['voice']=$phone;
$Regist['fax']=$fax;
$Regist['email']=$email;
$Regist['mob']=$mobile;
$Admin=$Regist;
$Tech=$Regist;
$Billing=$Regist;
$respxml=$newclient->createDomain($Domain,$Regist,$Admin,$Tech,$Billing);
if($respxml == '') {
$this->error='No output (registerDomain)';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function renewDomain($domain,$period)
{
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$respxml=$newclient->infoDomain($domain);
if($respxml == '') {
$this->error='No output (renewDomain:infoDomain)';
return false;
} else {
$respArr=$newclient->toArray();
$expdate = $respArr["domain:dtExpired"][0];
if ($expdate) {
$domainI['domainname']=$domain;
$domainI['curexpired']=$expdate;
$domainI['domainperiod']=$period;
$respxml='';
$respxml=$newclient->renewDomain($domainI);
if($respxml == '') {
$this->error='No output (renewDomain)';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "Code $code: ".$newclient->getMessage();
return false;
}
}
} else {
$this->error = "Can't get expiration date for domain (Code ".$newclient->getCode().": ".$newclient->getMessage().")";
return false;
}
}
}
public function getNS($domain)
{
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$respxml=$newclient->infoDomain($domain);
if($respxml == '') {
$this->error='No output (getNS)';
return false;
} else {
$respArr=$newclient->toArray();
if ($respArr["domain:ns"][0] and $respArr["domain:ns"][1]) {
$ns[] = $respArr["domain:ns"][0];
$ns[] = $respArr["domain:ns"][1];
}
if ($respArr["domain:ns"][2]) { $ns[] = $respArr["domain:ns"][2]; }
if ($respArr["domain:ns"][3]) { $ns[] = $respArr["domain:ns"][3]; }
if (is_array($ns)) {
return $ns;
} else {
$this->error = "Can't get NS for domain (Code ".$newclient->getCode().": ".$newclient->getMessage().")";
return false;
}
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4)
{
$domainI['domainname'] = $domain;
$domainI['newns1'] = $ns1;
$domainI['newns2'] = $ns2;
if ($ns3) { $domainI['newns3'] = $ns3; }
if ($ns4) { $domainI['newns4'] = $ns4; }
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$respxml=$newclient->modifyDomain($domainI);
# print "rnrn".$newclient->sendXML."rnrn".$respxml."rnrn";
if($respxml == '') {
$this->error='No output (updateNS)';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "Code $code: ".$newclient->getMessage();
return false;
}
}
}
}
?>