Файл: billing/_rootinc/naunet.inc.php
Строк: 354
<?
class NAUNET
{
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 connect($api_path)
{
$api_path = iconv("utf-8","koi8-r",htmlDecode($api_path));
$this->fp = curl_init();
curl_setopt($this->fp, CURLOPT_URL, $this->url);
# curl_setopt($this->fp, CURLOPT_URL, "https://test.naunet.ru/c/registrar"); # Demo url
curl_setopt($this->fp, CURL_HTTP_VERSION_1_1, 1);
curl_setopt($this->fp, CURLOPT_POST, 1);
curl_setopt($this->fp, CURLOPT_POSTFIELDS, $api_path);
curl_setopt($this->fp, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->fp, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->fp, CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->fp, CURLOPT_TIMEOUT, 120);
$result = curl_exec($this->fp);
$result = preg_replace("/<html><body>/ui","",$result);
$result = preg_replace("/</body></html>/ui","",$result);
return $result;
}
public function disconnect()
{
curl_close($this->fp);
}
public function parseResult($result) {
$result_arr = mb_split(" ",$result);
return $result_arr;
}
public function regDomainNewPerson($domain,$ns1,$ns2,$ns3,$ns4,$person,$person_r,$passport,$birth_date,$address_r,$p_addr,$phone,$fax,$email,$code,$private_person_flag)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$nserver = "nserver=$ns1&nserver=$ns2";
if ($ns3) { $nserver = $nserver."&nserver=$ns3"; }
if ($ns4) { $nserver = $nserver."&nserver=$ns4"; }
$result = $this->connect("action=NEW&login=".$this->user."&password=".$this->password."&domain=$domain&$nserver&person=$person&person-r=$person_r&passport=$passport&birth-date=$birth_date&address-r=$address_r&p-addr=$p_addr&phone=".urlencode($phone)."&fax-no=".urlencode($fax)."&e-mail=$email&contact-login=$email&private-whois=$private_person_flag&code=$code");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "dns_check" or $result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
public function regDomainExistsPerson($domain,$ns1,$ns2,$ns3,$ns4,$sslogin,$private_person_flag)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$nserver = "nserver=$ns1&nserver=$ns2";
if ($ns3) { $nserver = $nserver."&nserver=$ns3"; }
if ($ns4) { $nserver = $nserver."&nserver=$ns4"; }
$result = $this->connect("action=NEW&login=".$this->user."&password=".$this->password."&domain=$domain&$nserver&contact-login=$sslogin&private-whois=$private_person_flag");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "dns_check" or $result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
public function regDomainNewOrg($domain,$ns1,$ns2,$ns3,$ns4,$org,$org_r,$code,$adress_r,$p_addr,$phone,$fax,$email)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$nserver = "nserver=$ns1&nserver=$ns2";
if ($ns3) { $nserver = $nserver."&nserver=$ns3"; }
if ($ns4) { $nserver = $nserver."&nserver=$ns4"; }
$result = $this->connect("action=NEW&login=".$this->user."&password=".$this->password."&domain=$domain&$nserver&org=$org&org-r=$org_r&code=$code&address-r=$adress_r&p-addr=$p_addr&phone=".urlencode($phone)."&fax-no=".urlencode($fax)."&e-mail=$email&contact-login=$email");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "dns_check" or $result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
public function regDomainExistsOrg($domain,$ns1,$ns2,$ns3,$ns4,$sslogin)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$nserver = "nserver=$ns1&nserver=$ns2";
if ($ns3) { $nserver = $nserver."&nserver=$ns3"; }
if ($ns4) { $nserver = $nserver."&nserver=$ns4"; }
$result = $this->connect("action=NEW&login=".$this->user."&password=".$this->password."&domain=$domain&$nserver&contact-login=$sslogin");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "dns_check" or $result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
public function renewDomain($domain)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$result = $this->connect("action=PROLONG&login=".$this->user."&password=".$this->password."&domain=$domain");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
public function getNS($domain)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$result = $this->connect("action=GET&login=".$this->user."&password=".$this->password."&domain=$domain");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "done") {
$result1 = mb_split("n", $result);
while (list($index,$res) = each($result1)) {
if (preg_match("/nserver/ui",$res)) {
preg_match("/nserver:s+(.*)/iu",$res,$arr);
$resultarray[]=$arr[1];
} else if (preg_match("/Name Server/ui",$res)) {
preg_match("/Name Server:s+(.*)/iu",$res,$arr);
$resultarray[]=$arr[1];
}
}
return $resultarray;
} else {
$this->error = $result;
return false;
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4)
{
if (preg_match("/[а-яёЁ]/ui",$domain)) {
$idna = new idna_convert();
$domain = $idna->encode($domain);
}
$nserver = "nserver=$ns1&nserver=$ns2";
if ($ns3) { $nserver = $nserver."&nserver=$ns3"; }
if ($ns4) { $nserver = $nserver."&nserver=$ns4"; }
$result = $this->connect("action=UPDATE&login=".$this->user."&password=".$this->password."&domain=$domain&$nserver");
if($result == '') {
$this->error='No output.';
return false;
}
$this->disconnect();
$result_arr = $this->parseResult($result);
if ($result_arr[2] == "dns_check" or $result_arr[2] == "done") {
return true;
} else {
$this->error = $result;
return false;
}
}
}
?>