Файл: _rootinc/todaynic.inc.php
Строк: 590
<?
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 $url=null;
public $user=null;
public $password = null;
public $error = null;
public $fp=null;
/*
* 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);
$xmlArray = xml2array($respxml);
if($respxml == '') {
$this->error='registerDomain: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact1"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact2"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact3"];
return $resArray;
} else {
$this->error = "registerDomain: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function transferDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$name,$org,$country,$state,$post,$city,$street,$phone,$fax,$mobile,$email,$auth)
{
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$Domain['domainname']=$domain;
$Domain['domainperiod']=$period;
$Domain['password'] = $auth;
$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->transferDomain($Domain,$Regist,$Admin,$Tech,$Billing);
$xmlArray = xml2array($respxml);
if($respxml == '') {
$this->error='transferDomain: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact1"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact2"];
$resArray[] = $xmlArray[scp][0][response][0][resdata][0]["domain:contact3"];
return $resArray;
} else {
$this->error = "transferDomain: 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='renewDomain:infoDomain: No output';
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='renewDomain: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "renewDomain: Code $code: ".$newclient->getMessage();
return false;
}
}
} else {
$this->error = "renewDomain: Can't get expiration date for domain (Code ".$newclient->getCode().": ".$newclient->getMessage().")";
return false;
}
}
}
public function updateContact($contactId,$contactType,$domain,$name,$org,$country,$state,$post,$city,$street,$phone,$fax,$mobile,$email)
{
$newclient=new TodaynicDomain($this->url,$this->user,$this->password);
$contactI['domainname']=$domain;
$contactI['id']=$contactId;
$contactI['type']=$contactType;
if (!$state) { $state = "NA"; }
if (!$fax) { $fax = $phone; }
$contactI['name']=$name;
$contactI['cnname']="null";
$contactI['org']=$org;
$contactI['cnorg']="null";
$contactI['cc']=$country;
$contactI['sp']=$state;
$contactI['pc']=$post;
$contactI['city']=$city;
$contactI['street']=$street;
$contactI['street1']="";
$contactI['voice']=$phone;
$contactI['fax']=$fax;
$contactI['email']=$email;
$contactI['mob']=$mobile;
$respxml=$newclient->updateContact($contactI);
if($respxml == '') {
$this->error='updateContact: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "updateContact: Code $code: ".$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='getNS:infoDomain: No output';
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 = "getNS: Can't get NS for domain (Code ".$newclient->getCode().": ".$newclient->getMessage().")";
return false;
}
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip)
{
if ($ns1 and $ns1ip) {
$res = $this->checkNS($domain, $ns1); if (!$res) { return false; }
if ($res == "avail") { if (!$this->createNS($domain, $ns1, $ns1ip)) {return false;} }
else if ($res == "exists") {
$old1ip = $this->infoNS($domain,$ns1); if (!$old1ip) { return false; }
if ($ns1ip != $old1ip) { if (!$this->modifyNS($domain,$ns1,$ns1,$old1ip,$ns1ip)) { return false; } }
}
}
if ($ns2 and $ns2ip) {
$res = $this->checkNS($domain, $ns2); if (!$res) { return false; }
if ($res == "avail") { if (!$this->createNS($domain, $ns2, $ns2ip)) {return false;} }
else if ($res == "exists") {
$old2ip = $this->infoNS($domain,$ns2); if (!$old2ip) { return false; }
if ($ns2ip != $old2ip) { if (!$this->modifyNS($domain,$ns2,$ns2,$old2ip,$ns2ip)) { return false; } }
}
}
if ($ns3 and $ns3ip) {
$res = $this->checkNS($domain, $ns3); if (!$res) { return false; }
if ($res == "avail") { if (!$this->createNS($domain, $ns3, $ns3ip)) {return false;} }
else if ($res == "exists") {
$old3ip = $this->infoNS($domain,$ns3); if (!$old3ip) { return false; }
if ($ns3ip != $old3ip) { if (!$this->modifyNS($domain,$ns3,$ns3,$old3ip,$ns3ip)) { return false; } }
}
}
if ($ns4 and $ns4ip) {
$res = $this->checkNS($domain, $ns4); if (!$res) { return false; }
if ($res == "avail") { if (!$this->createNS($domain, $ns4, $ns4ip)) {return false;} }
else if ($res == "exists") {
$old4ip = $this->infoNS($domain,$ns4); if (!$old4ip) { return false; }
if ($ns4ip != $old4ip) { if (!$this->modifyNS($domain,$ns4,$ns4,$old4ip,$ns4ip)) { return false; } }
}
}
$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);
if($respxml == '') {
$this->error='updateNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "updateNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function checkNS($domain, $ns)
{
$newclient=new TodaynicDomain($this->url, $this->user, $this->password);
$respxml = $newclient->checkNS($domain, $ns);
if($respxml == '') {
$this->error='checkNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
$respArr=$newclient->toArray();
$result = @mb_split(": ",$respArr[name][0]);
$result = $result[1];
if ($result == "true") {
return "avail";
} else {
return "exists";
}
} else {
$this->error = "checkNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function createNS($domain, $ns, $ip)
{
$newclient=new TodaynicDomain($this->url, $this->user, $this->password);
$respxml = $newclient->createNS($domain, $ns, $ip);
if($respxml == '') {
$this->error='createNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "createNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function modifyNS($domain,$oldNS,$newNS,$oldIP,$newIP)
{
$newclient=new TodaynicDomain($this->url, $this->user, $this->password);
$respxml = $newclient->updateNS($domain,$oldNS,$newNS,$oldIP,$newIP);
if($respxml == '') {
$this->error='modifyNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "modifyNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function deleteNS($domain, $ns)
{
$newclient=new TodaynicDomain($this->url, $this->user, $this->password);
$respxml = $newclient->deleteNS($domain, $ns);
if($respxml == '') {
$this->error='deleteNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
return true;
} else {
$this->error = "deleteNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
public function infoNS($domain, $ns)
{
$newclient=new TodaynicDomain($this->url, $this->user, $this->password);
$respxml = $newclient->infoNS($domain, $ns);
if($respxml == '') {
$this->error='infoNS: No output';
return false;
} else {
$code=$newclient->getCode();
if ($code == "2000") {
$respArr=$newclient->toArray();
$ip = $respArr[address][0];
if ($ip) {
return $ip;
} else {
$this->error = "infoNS: Result true but IP not present.";
return false;
}
} else {
$this->error = "infoNS: Code $code: ".$newclient->getMessage();
return false;
}
}
}
}
?>