Файл: billing/_rootinc/ficora.inc.php
Строк: 697
<?
require_once($full_home_path."/_rootinc/ficora/DomainNameWS.php");
class FICORA
{
public $controller = true;
public $url=null;
public $user=null;
public $secret = null;
public $error = null;
public $fp=null;
/*
* initialization
*/
public function startup(&$controller)
{
$this->controller =& $controller;
}
/*
* initialization
*/
public function init($url,$user,$secret)
{
$this->url=$url;
$this->user=$user;
$this->secret=$secret;
}
public function regDomain($domain_name, $validity_period, $based_on_person_name, $person_name_registration_id, $domain_name_holder_person_id, $domain_name_holder_company_type, $domain_name_holder_business_id, $electronic_notification_approval, $data_publishing_approval, $ns1, $ns2, $ns3, $ns4, $type, $company, $department, $first_name, $last_name, $address, $post, $city, $phone, $email)
{
$client = new DomainNameWS($this->url);
$apply = new Apply();
$apply->webDomainRequest = new apply_request();
// domain information
$apply->webDomainRequest->name = $domain_name;
$apply->webDomainRequest->valid_applicant_confirmation = true;
$apply->webDomainRequest->based_on_person_name = $based_on_person_name;
$apply->webDomainRequest->person_name_registration_id = $person_name_registration_id;
$apply->webDomainRequest->domain_name_holder_person_id = $domain_name_holder_person_id;
$apply->webDomainRequest->domain_name_holder_company_type = $domain_name_holder_company_type;
$apply->webDomainRequest->domain_name_holder_business_id = $domain_name_holder_business_id;
$apply->webDomainRequest->electronic_notification_approval = $electronic_notification_approval;
$apply->webDomainRequest->data_publishing_approval = $data_publishing_approval;
// nameservers
$apply->webDomainRequest->nameservers[0] = new nameserver();
$apply->webDomainRequest->nameservers[0]->name = $ns1;
$apply->webDomainRequest->nameservers[0]->ipaddress = "";
$apply->webDomainRequest->nameservers[1] = new nameserver();
$apply->webDomainRequest->nameservers[1]->name = $ns2;
$apply->webDomainRequest->nameservers[1]->ipaddress = "";
if ($ns3) {
$apply->webDomainRequest->nameservers[2] = new nameserver();
$apply->webDomainRequest->nameservers[2]->name = $ns3;
$apply->webDomainRequest->nameservers[2]->ipaddress = "";
}
if ($ns4) {
$apply->webDomainRequest->nameservers[3] = new nameserver();
$apply->webDomainRequest->nameservers[3]->name = $ns4;
$apply->webDomainRequest->nameservers[3]->ipaddress = "";
}
// contact information (only domain owner, type company)
$apply->webDomainRequest->contacts[0]->type = $type;
$apply->webDomainRequest->contacts[0]->company = $company;
$apply->webDomainRequest->contacts[0]->department = $department;
$apply->webDomainRequest->contacts[0]->first_names[0] = $first_name;
$apply->webDomainRequest->contacts[0]->last_name = $last_name;
$apply->webDomainRequest->contacts[0]->postal_address = $address;
$apply->webDomainRequest->contacts[0]->postal_code = $post;
$apply->webDomainRequest->contacts[0]->postal_office = $city;
$apply->webDomainRequest->contacts[0]->phone = $phone;
$apply->webDomainRequest->contacts[0]->email = $email;
$apply->webDomainRequest->contacts[0]->language_code = "fi-FI";
//context
$apply->webDomainRequest->context = new context();
$apply->webDomainRequest->context->user_name = $this->user;
$apply->webDomainRequest->context->timestamp = $this->getTimeStamp();
$apply->webDomainRequest->domain_validity_period_in_months = $validity_period;
// mac
$macstring=
$apply->webDomainRequest->name .
$this->boolean2string($apply->webDomainRequest->valid_applicant_confirmation).
$this->boolean2string($apply->webDomainRequest->based_on_person_name) .
$apply->webDomainRequest->person_name_registration_id .
$apply->webDomainRequest->person_name_registration_number .
$apply->webDomainRequest->domain_name_holder_company_type .
$apply->webDomainRequest->domain_name_holder_business_id .
$apply->webDomainRequest->domain_name_holder_person_id .
$this->boolean2string($apply->webDomainRequest->electronic_notification_approval) .
$this->boolean2string($apply->webDomainRequest->data_publishing_approval) .
$apply->webDomainRequest->nameservers[0]->name .
$apply->webDomainRequest->nameservers[0]->ipaddress .
$apply->webDomainRequest->nameservers[1]->name .
$apply->webDomainRequest->nameservers[1]->ipaddress .
$apply->webDomainRequest->nameservers[2]->name .
$apply->webDomainRequest->nameservers[2]->ipaddress .
$apply->webDomainRequest->nameservers[3]->name .
$apply->webDomainRequest->nameservers[3]->ipaddress .
$apply->webDomainRequest->contacts[0]->type .
$apply->webDomainRequest->contacts[0]->company .
$apply->webDomainRequest->contacts[0]->department .
$apply->webDomainRequest->contacts[0]->first_names[0] .
$apply->webDomainRequest->contacts[0]->first_names[1] .
$apply->webDomainRequest->contacts[0]->last_name .
$apply->webDomainRequest->contacts[0]->postal_address .
$apply->webDomainRequest->contacts[0]->postal_code .
$apply->webDomainRequest->contacts[0]->postal_office .
$apply->webDomainRequest->contacts[0]->phone .
$apply->webDomainRequest->contacts[0]->email .
$apply->webDomainRequest->contacts[0]->language_code .
$apply->webDomainRequest->context->user_name .
$apply->webDomainRequest->context->timestamp .
$apply->webDomainRequest->domain_validity_period_in_months .
$this->secret;
$hash = hash('sha1', $macstring);
$apply->webDomainRequest->context->mac = $hash;
// Performs the Apply request
try
{
$res = $client->Apply($apply);
}
catch (SoapFault $exception)
{
$this->error = "regDomain: ".$exception;
return false;
}
// get the results
if ($res->ApplyResult->code === false) {
$this->error = "regDomain: Webdomain validation error: ".$res->ApplyResult->webdomain_validation_errors->error_message->code." ".$res->ApplyResult->webdomain_validation_errors->error_message->description." ";
$n = sizeof($res->ApplyResult->nameserver_validation_errors->error_message);
if ($n >0) {
$this->error .= "Name server validation error: ".$res->ApplyResult->nameserver_validation_errors->error_message->code." ".$res->ApplyResult->nameserver_validation_errors->error_message->description." ";
}
$n = sizeof($res->ApplyResult->contact_validation_errors->error_message);
if ($k >0) {
for ($i = 0; $i < $n; $i++){
$this->error .= "Contact validation error $i: ".$res->ApplyResult->contact_validation_errors->error_message[$i]->code." ".$res->ApplyResult->contact_validation_errors->error_message[$i]->description;
}
}
return false;
}
else {
# $n = sizeof($res->ApplyResult->nameserver_technical_errors->error_message);
# if ($n == 0) {
return true;
# }
# if ($n >0) {
# $this->error = "regDomain: ";
# for ($i = 0; $i < $n; $i++){
# $this->error = "Technical error $i: ".$res->ApplyResult->nameserver_technical_errors->error_message[$i]->code." ".$res->ApplyResult->nameserver_technical_errors->error_message[$i]->description;
# }
# return false;
# }
}
}
public function renewDomain($domain_name, $validity_period)
{
$client = new DomainNameWS($this->url);
$renew = new Renew();
$renew->renewRequest = new renew_request();
// domain information
$renew->renewRequest->webdomain_name = $domain_name;
// context
$renew->renewRequest->context = new context();
$renew->renewRequest->context->user_name = $this->user;
$renew->renewRequest->context->timestamp = $this->getTimeStamp();
$renew->renewRequest->domain_validity_period_in_months = $validity_period;
// mac
$macstring=
$renew->renewRequest->webdomain_name .
$renew->renewRequest->context->user_name .
$renew->renewRequest->context->timestamp .
$renew->renewRequest->domain_validity_period_in_months .
$this->secret;
$hash = hash('sha1', $macstring);
$renew->renewRequest->context->mac = $hash;
// performs the Renew request
try
{
$res = $client->Renew($renew);
}
catch (SoapFault $exception)
{
$this->error = "renewDomain: ".$exception;
return false;
}
// get the results
if($res->RenewResult->code === false){
$this->error = "Webdomain validation error: ".$res->RenewResult->webdomain_validation_errors->error_message->code." ".$res->RenewResult->webdomain_validation_errors->error_message->description;
return false;
}
else {
return true;
}
}
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("/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 = "getNS: $d->last_error";;
return false;
}
}
public function updateNS($domain_name, $authorization_key, $ns1, $ns2, $ns3, $ns4)
{
$client = new DomainNameWS($this->url);
$change = new ChangeNameServers();
$change->changeNameServerRequest = new change_nameservers_request();
// domain information
$change->changeNameServerRequest->webdomain_name = $domain_name;
$change->changeNameServerRequest->authorization_key = $authorization_key;
// nameservers
$change->changeNameServerRequest->nameservers[0] = new nameserver();
$change->changeNameServerRequest->nameservers[0]->name = $ns1;
$change->changeNameServerRequest->nameservers[0]->ipaddress = "";
$change->changeNameServerRequest->nameservers[1] = new nameserver();
$change->changeNameServerRequest->nameservers[1]->name = $ns2;
$change->changeNameServerRequest->nameservers[1]->ipaddress = "";
if ($ns3) {
$change->changeNameServerRequest->nameservers[2] = new nameserver();
$change->changeNameServerRequest->nameservers[2]->name = $ns3;
$change->changeNameServerRequest->nameservers[2]->ipaddress = "";
}
if ($ns4) {
$change->changeNameServerRequest->nameservers[3] = new nameserver();
$change->changeNameServerRequest->nameservers[3]->name = $ns4;
$change->changeNameServerRequest->nameservers[3]->ipaddress = "";
}
// context
$change->changeNameServerRequest->context = new context();
$change->changeNameServerRequest->context->user_name = $this->user;
$change->changeNameServerRequest->context->timestamp = $this->getTimeStamp();
// mac
$macstring=
$change->changeNameServerRequest->webdomain_name .
$change->changeNameServerRequest->authorization_key .
$change->changeNameServerRequest->nameservers[0]->name .
$change->changeNameServerRequest->nameservers[0]->ipaddress .
$change->changeNameServerRequest->nameservers[1]->name .
$change->changeNameServerRequest->nameservers[1]->ipaddress .
$change->changeNameServerRequest->nameservers[2]->name .
$change->changeNameServerRequest->nameservers[2]->ipaddress .
$change->changeNameServerRequest->nameservers[3]->name .
$change->changeNameServerRequest->nameservers[3]->ipaddress .
$change->changeNameServerRequest->context->user_name .
$change->changeNameServerRequest->context->timestamp .
$this->secret;
$macstring = utf8_encode($macstring);
$hash = hash('sha1', $macstring);
$change->changeNameServerRequest->context->mac = $hash;
// performs the ChangeNameServers request
try
{
$res = $client->ChangeNameServers($change);
}
catch (SoapFault $exception)
{
$this->error = "updateNS: ".$exception;
return false;
}
// get the results
if($res->ChangeNameServersResult->code === false) {
$this->error = "updateNS: Webdomain validation error: ".$res->ChangeNameServersResult->webdomain_validation_errors->error_message->code." ".$res->ChangeNameServersResult->webdomain_validation_errors->error_message->description." ";
$n = sizeof($res->ApplyResult->nameserver_validation_errors->error_message);
if ($n >0) {
$this->error .= "Name server validation error: ".$res->ChangeNameServersResult->nameserver_validation_errors->error_message->code." ".$res->ChangeNameServersResult->nameserver_validation_errors->error_message->description." ";
}
$n = sizeof($res->ChangeNameServersResult->contact_validation_errors->error_message);
if ($k >0) {
for ($i = 0; $i < $n; $i++){
$this->error .= "Contact validation error $i: ".$res->ChangeNameServersResult->contact_validation_errors->error_message[$i]->code." ".$res->ChangeNameServersResult->contact_validation_errors->error_message[$i]->description." ";
}
}
return false;
}
else {
# $n = sizeof($res->ChangeNameServersResult->nameserver_technical_errors->error_message);
# if ($n == 0) {
return true;
# }
# if ($n >0) {
# for ($i = 0; $i < $n; $i++){
# $this->error = "updateNS: Technical error $i: ".$res->ChangeNameServersResult->nameserver_technical_errors->error_message[$i]->code." ".$res->ChangeNameServersResult->nameserver_technical_errors->error_message[$i]->description." ";
# }
# return false;
# }
}
}
public function boolean2string($bool){
if ($bool === true)
return 'true';
else
return 'false';
}
public function getTimeStamp() {
// Time must be UTC
date_default_timezone_set("UTC");
list($fraction, $full) = explode(' ', microtime());
$fraction = substr($fraction, 2, 7);
$timestamp = date("Y-m-d")."T".date("H:i:s.").$fraction."Z";
return $timestamp;
}
}
?>