Файл: _rootinc/epag.inc.php
Строк: 557
<?
class EPAG
{
public $url = null;
public $port = null;
public $user = null;
public $password = null;
public $customerid = null;
public $error = null;
public $fp = null;
public $isConnected = false;
public function init($url,$port,$user,$password,$customerid)
{
$this->user = $user;
$this->url = $url;
$this->port = $port;
$this->password = $password;
$this->customerid = $customerid;
}
public function connect()
{
$socket = fsockopen("ssl://".$this->url, $this->port, $errno, $errstr, 30);
if (!$socket) {
$this->error = "connect: Error connecting to ssl://".$this->url.":".$this->port.": $errstr (code $errno)";
return false;
} else {
$this->fp=$socket;
$xml = "__start_message
action: login
username: $this->user
password: $this->password
__stop_message
";
if(!$this->send($xml)) {
$this->error='connect: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[Result] == "SUCCESS") {
$this->isConnected = true;
return true;
} else {
$this->error = "connect: ".$result[Result]." ".$result[NRC]." (".$result[Reason].")";
return false;
}
} else if (!$this->error) {
$this->error = "connect: Unable to get result.";
return false;
} else {
$this->error = "connect: ".$this->error;
return false;
}
}
}
}
public function disconnect()
{
if ($this->isConnected) {
$xml = "__start_message
action: logout
__stop_message
";
$this->send($xml);
$this->isConnected = false;
}
@fclose($this->fp);
}
public function get($print = 0)
{
if (@feof($this->fp)) {
$this->error = "get: Connection appears to have closed.";
return false;
}
$response = "";
$result_array = array();
$cnt=0;
do {
$cnt++;
$get_string = fgets($this->fp, 1024);
$response .= $get_string;
}
while (trim($get_string) != "__stop_message");
if ($print) { print "n$responsen"; }
$result_lines = @mb_split("n",$response);
while (list($index,$result_line) = @each($result_lines)) {
if (preg_match("/^([^:]+):(.*)/iu",$result_line,$arr)) {
$arrIndex = trim($arr[1]);
$arrValue = trim($arr[2]);
$result_array[$arrIndex] = $arrValue;
}
}
if ($print) { print "n"; print_r($result_array); print "n"; }
return $result_array;
}
public function send($write)
{
# print "nn$writenn";
return @fwrite($this->fp,$write);
}
public function createContact($type,$name,$org,$street,$city,$oblast,$post,$country,$phone,$fax,$email)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 2.4 CONTACT (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a. Requested Action ........... : REG
0c. CustomerRemarks............. :
a . EPNIC-Handle ............... :
b . Person Name ................ : $name
c . Organisation ............... : $org
e . Street ..................... : $street
f . Postal Code ................ : $post
g . City ....................... : $city
h . State/Province ............. : $oblast
i . Country Code ............... : $country
j . Phone No. .................. : $phone
k . Fax No. .................... : $fax
l . E-mail Address ............. : $email
tp. Contact Type (Org|Person) .. : $type
r0. Remark ..................... :
r1. Remark ..................... :
m0. .asia Identification Number :
m1. .asia Form of Identity ..... :
m2. .asia Type of Entity ....... :
n0. .aero ENS ID ............... :
n1. .aero ENS Password ......... :
p0. ID Card Number ............. :
p1. ID Card Issue Date ......... :
p2. ID Card Authority .......... :
t0. Date of Birth .............. :
t1. Place of Birth ............. :
t2. Country of Birth ........... :
t3. State of Birth ............. :
s . VAT ID Number .............. :
x . Tax Number ................. :
y . Registration Number ........ :
z0. Trademark Number ........... :
z1. Trademark Locality ......... :
__stop_message
";
if(!$this->send($xml)) {
$this->error='createContact: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[Result] == "SUCCESS") {
return $result[Handle];
} else {
$this->error = "createContact: ".$result[Result]." ".$result[NRC]." (".$result[Reason].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "createContact: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "createContact: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function updateContact($handle,$type,$name,$org,$street,$city,$oblast,$post,$country,$phone,$fax,$email)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 2.4 CONTACT (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a. Requested Action ........... : UPDATE
0c. CustomerRemarks............. :
a . EPNIC-Handle ............... : $handle
e . Street ..................... : $street
f . Postal Code ................ : $post
g . City ....................... : $city
h . State/Province ............. : $oblast
i . Country Code ............... : $country
j . Phone No. .................. : $phone
k . Fax No. .................... : $fax
l . E-mail Address ............. : $email
tp. Contact Type (Org|Person) .. : $type
r0. Remark ..................... :
r1. Remark ..................... :
m0. .asia Identification Number :
m1. .asia Form of Identity ..... :
m2. .asia Type of Entity ....... :
n0. .aero ENS ID ............... :
n1. .aero ENS Password ......... :
p0. ID Card Number ............. :
p1. ID Card Issue Date ......... :
p2. ID Card Authority .......... :
t0. Date of Birth .............. :
t1. Place of Birth ............. :
t2. Country of Birth ........... :
t3. State of Birth ............. :
s . VAT ID Number .............. :
x . Tax Number ................. :
y . Registration Number ........ :
z0. Trademark Number ........... :
z1. Trademark Locality ......... :
__stop_message
";
if(!$this->send($xml)) {
$this->error='updateContact: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[Result] == "SUCCESS") {
$this->disconnect();
return true;
} else {
$this->error = "updateContact: ".$result[Result]." ".$result[NRC]." (".$result[Reason].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateContact: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "updateContact: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function registerDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$handle)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 6.4 DOMAIN (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a . Requested Action .......... : REG
0b . Language .................. : EN
0c . CustomerRemarks............ :
1a . Domainname ................ : $domain
1c . AuthCode .................. :
1d . Registration Period (Years) : $period
1e . Domain-Status ............. :
2a . Owner EPNIC-Handle ........ : $handle
3a . Admin-C EPNIC-Handle ...... : $handle
4a . Tech-C EPNIC-Handle ....... : $handle
5a . Zone-C EPNIC-Handle ....... : $handle
6a . Billing-C EPNIC-Handle .... : $handle
7a . Hidden-Primary DNS ........ :
7a0. 1. Domainnameserver ....... : $ns1
7a1. 1. DNS IP ................. : $ns1ip
7b0. 2. Domainnameserver ....... : $ns2
7b1. 2. DNS IP ................. : $ns2ip
7c0. 3. Domainnameserver ....... : $ns3
7c1. 3. DNS IP ................. : $ns3ip
7d0. 4. Domainnameserver ....... : $ns4
7d1. 4. DNS IP ................. : $ns4ip
8i . Use Trustee Service........ :
__stop_message
";
if(!$this->send($xml)) {
$this->error='registerDomain: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result["Result"] == "SUCCESS" or $result["Result"] == "SUCCESS WITH RESERVATIONS" or $result["Result"] == "WARNING" or $result["Result"] == "PENDING") {
$this->disconnect();
if ($result["Result"] != "SUCCESS") {
$this->error = "registerDomain: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
}
return true;
} else {
$this->error = "registerDomain: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "registerDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "registerDomain: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function transferDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$handle,$auth)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 6.4 DOMAIN (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a . Requested Action .......... : TRANSFER
0b . Language .................. : EN
0c . CustomerRemarks............ :
1a . Domainname ................ : $domain
1c . AuthCode .................. : $auth
1d . Registration Period (Years) : $period
1e . Domain-Status ............. :
2a . Owner EPNIC-Handle ........ : $handle
3a . Admin-C EPNIC-Handle ...... : $handle
4a . Tech-C EPNIC-Handle ....... : $handle
5a . Zone-C EPNIC-Handle ....... : $handle
6a . Billing-C EPNIC-Handle .... : $handle
7a . Hidden-Primary DNS ........ :
7a0. 1. Domainnameserver ....... : $ns1
7a1. 1. DNS IP ................. : $ns1ip
7b0. 2. Domainnameserver ....... : $ns2
7b1. 2. DNS IP ................. : $ns2ip
7c0. 3. Domainnameserver ....... : $ns3
7c1. 3. DNS IP ................. : $ns3ip
7d0. 4. Domainnameserver ....... : $ns4
7d1. 4. DNS IP ................. : $ns4ip
8i . Use Trustee Service........ :
__stop_message
";
if(!$this->send($xml)) {
$this->error='transferDomain: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result["Result"] == "SUCCESS" or $result["Result"] == "SUCCESS WITH RESERVATIONS" or $result["Result"] == "WARNING" or $result["Result"] == "PENDING") {
$this->disconnect();
if ($result["Result"] != "SUCCESS" and $result["Result"] != "PENDING") {
$this->error = "transferDomain: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
}
return true;
} else {
$this->error = "transferDomain: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "transferDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "transferDomain: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function getNS($domain)
{
$d = new domain($domain);
$result = $d->info();
if (!$d->last_error) {
$result1 = mb_split("n", $result);
while (list($index,$res) = each($result1)) {
if (preg_match("/Name Server/ui",$res)) {
preg_match("/Name Server:s*(.*)/iu",$res,$arr);
$resultarray[]=$arr[1];
}
}
return $resultarray;
} else {
$this->error = "getNS: $d->last_error";;
return false;
}
}
public function updateNS($domain,$handle,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 6.4 DOMAIN (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a . Requested Action .......... : UPDATE
0b . Language .................. : EN
0c . CustomerRemarks............ :
1a . Domainname ................ : $domain
1c . AuthCode .................. :
1d . Registration Period (Years) :
1e . Domain-Status ............. :
2a . Owner EPNIC-Handle ........ : $handle
3a . Admin-C EPNIC-Handle ...... : $handle
4a . Tech-C EPNIC-Handle ....... : $handle
5a . Zone-C EPNIC-Handle ....... : $handle
6a . Billing-C EPNIC-Handle .... : $handle
7a . Hidden-Primary DNS ........ :
7a0. 1. Domainnameserver ....... : $ns1
7a1. 1. DNS IP ................. : $ns1ip
7b0. 2. Domainnameserver ....... : $ns2
7b1. 2. DNS IP ................. : $ns2ip
7c0. 3. Domainnameserver ....... : $ns3
7c1. 3. DNS IP ................. : $ns3ip
7d0. 4. Domainnameserver ....... : $ns4
7d1. 4. DNS IP ................. : $ns4ip
8i . Use Trustee Service........ :
__stop_message
";
if(!$this->send($xml)) {
$this->error='updateNS: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result["Result"] == "SUCCESS" or $result["Result"] == "WARNING" or $result["Result"] == "PENDING") {
$this->disconnect();
if ($result["Result"] != "SUCCESS") {
$this->error = "updateNS: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
}
return true;
} else {
$this->error = "updateNS: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateNS: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "updateNS: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function expire($domain,$handle)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 6.4 DOMAIN (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a . Requested Action .......... : EXPIRE
0b . Language .................. : EN
0c . CustomerRemarks............ :
1a . Domainname ................ : $domain
1c . AuthCode .................. :
1d . Registration Period (Years) :
1e . Domain-Status ............. :
2a . Owner EPNIC-Handle ........ : $handle
3a . Admin-C EPNIC-Handle ...... : $handle
4a . Tech-C EPNIC-Handle ....... : $handle
5a . Zone-C EPNIC-Handle ....... : $handle
6a . Billing-C EPNIC-Handle .... : $handle
__stop_message
";
if(!$this->send($xml)) {
$this->error='expire: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result["Result"] == "SUCCESS" or $result["Result"] == "WARNING" or $result["Result"] == "PENDING") {
$this->disconnect();
if ($result["Result"] != "SUCCESS") {
$this->error = "expire: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
}
return true;
} else {
$this->error = "expire: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "expire: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "expire: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
public function unExpire($domain,$handle)
{
if ($this->isConnected or $this->connect()) {
$xml = "__start_message
## VERSION 6.4 DOMAIN (2008-04-18) DO NOT REMOVE OR CHANGE!
0 . EPNIC-Customer-ID .......... : $this->customerid
0a . Requested Action .......... : UNEXPIRE
0b . Language .................. : EN
0c . CustomerRemarks............ :
1a . Domainname ................ : $domain
1c . AuthCode .................. :
1d . Registration Period (Years) :
1e . Domain-Status ............. :
2a . Owner EPNIC-Handle ........ : $handle
3a . Admin-C EPNIC-Handle ...... : $handle
4a . Tech-C EPNIC-Handle ....... : $handle
5a . Zone-C EPNIC-Handle ....... : $handle
6a . Billing-C EPNIC-Handle .... : $handle
__stop_message
";
if(!$this->send($xml)) {
$this->error='unExpire: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result["Result"] == "SUCCESS" or $result["Result"] == "WARNING" or $result["Result"] == "PENDING") {
$this->disconnect();
if ($result["Result"] != "SUCCESS") {
$this->error = "unExpire: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
}
return true;
} else {
$this->error = "unExpire: ".$result["Result"]." ".$result["NRC"]." (".$result["Reason"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "unExpire: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "unExpire: ".$this->error;
$this->disconnect();
return false;
}
}
}
}
}
?>