Newer
Older
# Copyright (c) 2012-2013, AllWorldIT
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Official Website:
# http://devlabs.linuxassist.net/projects/whmcs-coza-epp
# Nigel Kukard <nkukard@lbsd.net>
# ! ! P L E A S E N O T E ! !
# * If you make changes to this file, please consider contributing
# anything useful back to the community. Don't be a sour prick.
# * If you find this module useful please consider making a
# donation to support modules like this.
# WHMCS hosting, theming, module development, payment gateway
# integration, customizations and consulting all available from
// Make sure we not being accssed directly
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
# Configuration array
function cozaepp_getConfigArray() {
$configarray = array(
"Username" => array( "Type" => "text", "Size" => "20", "Description" => "Enter your username here" ),
"Password" => array( "Type" => "password", "Size" => "20", "Description" => "Enter your password here" ),
"Server" => array( "Type" => "text", "Size" => "20", "Description" => "Enter EPP Server Address" ),
"Port" => array( "Type" => "text", "Size" => "20", "Description" => "Enter EPP Server Port" ),
"SSL" => array( "Type" => "yesno" ),
"Certificate" => array( "Type" => "text", "Description" => "Path of certificate .pem" )
);
return $configarray;
}
function cozaepp_AdminCustomButtonArray() {
$buttonarray = array(
"Approve Transfer" => "ApproveTransfer",
"Cancel Transfer Request" => "CancelTransferRequest",
"Reject Transfer" => "RejectTransfer",
"Recreate Contact" => "RecreateContact",
);
return $buttonarray;
# Function to return current nameservers
function cozaepp_GetNameservers($params) {
$domain = strtolower("$sld.$tld");
try {
$client = _cozaepp_Client();
# Get list of nameservers for domain
$result = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc = new DOMDocument();
$doc->loadXML($result);
logModuleCall('Cozaepp', 'GetNameservers', $xml, $result);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check the result is ok
if($coderes != '1000') {
$values["error"] = "GetNameservers/domain-info($domain): Code ($coderes) $msg";
return $values;
}
# Grab hostname array
$ns = $doc->getElementsByTagName('hostName');
# Extract nameservers & build return result
$i = 1; $values = array();
foreach ($ns as $nn) {
$values["ns{$i}"] = $nn->nodeValue;
$i++;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'GetNameservers/EPP: '.$e->getMessage();
return $values;
return $values;
}
# Function to save set of nameservers
function cozaepp_SaveNameservers($params) {
# Grab variables
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
if ($nameserver1 = $params["ns1"]) {
<domain:hostAttr>
<domain:hostName>'.$nameserver1.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver2 = $params["ns2"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver2.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver3 = $params["ns3"]) {
<domain:hostAttr>
<domain:hostName>'.$nameserver3.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver4 = $params["ns4"]) {
<domain:hostAttr>
<domain:hostName>'.$nameserver4.'</domain:hostName>
</domain:hostAttr>';
}
if ($nameserver5 = $params["ns5"]) {
<domain:hostAttr>
<domain:hostName>'.$nameserver5.'</domain:hostName>
</domain:hostAttr>';
}
try {
$client = _cozaepp_Client();
# Grab list of current nameservers
$request = $client->request( $xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'SaveNameservers', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check if result is ok
if($coderes != '1000') {
$values["error"] = "SaveNameservers/domain-info($domain): Code ($coderes) $msg";
$values["status"] = $msg;
# Generate list of nameservers to remove
$hostlist = $doc->getElementsByTagName('hostName');
foreach ($hostlist as $host) {
$rem_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$host->nodeValue.'</domain:hostName>
</domain:hostAttr>
# Build request
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns:cozadomain="http://co.za/epp/extensions/cozadomain-1-0"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:update>
<domain:update>
<domain:name>'.$domain.'</domain:name>
<domain:add>
<domain:ns>'.$add_hosts.' </domain:ns>
<domain:rem>
<domain:ns>'.$rem_hosts.'</domain:ns>
</domain:rem>
</domain:update>
</epp:update>
<epp:extension>
<cozadomain:update xsi:schemaLocation="http://co.za/epp/extensions/cozadomain-1-0 coza-domain-1.0.xsd">
<cozadomain:chg><cozadomain:autorenew>false</cozadomain:autorenew></cozadomain:chg></cozadomain:update>
</epp:extension>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'SaveNameservers', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check if result is ok
if($coderes != '1001') {
$values["error"] = "SaveNameservers/domain-update($domain): Code ($coderes) $msg";
$values['status'] = "Domain update Pending. Based on .co.za policy, the estimated time taken is around 5 days.";
} catch (Exception $e) {
$values["error"] = 'SaveNameservers/EPP: '.$e->getMessage();
}
return $values;
}
# NOT IMPLEMENTED
function cozaepp_GetRegistrarLock($params) {
# Grab variables
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
if ($lock=="1") {
$lockstatus="locked";
} else {
$lockstatus="unlocked";
}
return $lockstatus;
}
# NOT IMPLEMENTED
function cozaepp_SaveRegistrarLock($params) {
$values["error"] = "SaveRegistrarLock: Current co.za policy does not allow for the addition of client-side statuses on domains.";
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# Function to retrieve an available contact id
function _cozaepp_CheckContact($prehash) {
$prehash = $prehash . time() . rand(0, 1000000);
$contactid = substr(md5($prehash), 0,15);
# Get client instance and check for available contact id
try {
$client = _cozaepp_Client();
$contactAvailable = 0;
$count = 0;
while ($contactAvailable == 0) {
# Check if contact exists
$request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>'.$contactid.'</contact:id>
</contact:check>
</check>
</command>
</epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RegisterDomain:CheckContact', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$contactAvailable = $doc->getElementsByTagName('id')->item(0)->getAttribute('avail');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes == '1000') {
$values['contact'] = 'Contact Created';
} else if($coderes == '2302') {
$values['contact'] = 'Contact Already exists';
} else if($coderes == '2201') {
$values['contact'] = 'Contact Already exists and is not owned by you';
} else {
$values["error"] = "RegisterDomain/contact-check($contactid): Code ($coderes) $msg";
return $values;
}
$values["status"] = $msg;
# If contact still isn't available attempt to add a random time again rehash and return
if ($contactAvailable == 0) {
$contactAvailable = substr(md5($prehash . time() . rand(0, 1000000) . $count), 0,15);
}
if ($count >= 10) {
break;
}
$count++;
}
return $contactid;
} catch (Exception $e) {
$values["error"] = 'RegisterDomain/EPP: '.$e->getMessage();
return $values;
}
}
# Function to register domain
function cozaepp_RegisterDomain($params) {
# Grab varaibles
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$regperiod = $params["regperiod"];
# Get registrant details
$RegistrantFirstName = $params["firstname"];
$RegistrantLastName = $params["lastname"];
$RegistrantAddress1 = $params["address1"];
$RegistrantAddress2 = $params["address2"];
$RegistrantCity = $params["city"];
$RegistrantStateProvince = $params["state"];
$RegistrantPostalCode = $params["postcode"];
$RegistrantCountry = $params["country"];
$RegistrantEmailAddress = $params["email"];
$RegistrantPhone = $params["fullphonenumber"];
$AdminFirstName = $params["adminfirstname"];
$AdminLastName = $params["adminlastname"];
$AdminAddress1 = $params["adminaddress1"];
$AdminAddress2 = $params["adminaddress2"];
$AdminCity = $params["admincity"];
$AdminStateProvince = $params["adminstate"];
$AdminPostalCode = $params["adminpostcode"];
$AdminCountry = $params["admincountry"];
$AdminEmailAddress = $params["adminemail"];
$AdminPhone = $params["adminphonenumber"];
$contactid = substr(md5($domain), 0,15);
if ($nameserver1 = $params["ns1"]) {
$add_hosts = '
<domain:hostAttr>
<domain:hostName>'.$nameserver1.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver2 = $params["ns2"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver2.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver3 = $params["ns3"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver3.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver4 = $params["ns4"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver4.'</domain:hostName>
</domain:hostAttr>
';
if ($nameserver5 = $params["ns5"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver5.'</domain:hostName>
</domain:hostAttr>
';
try {
$client = _cozaepp_Client();
# Send registration
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:create>
<contact:create xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>'.$contactid.'</contact:id>
<contact:postalInfo type="loc">
<contact:name>'.$RegistrantFirstName.' '.$RegistrantLastName.'</contact:name>
<contact:addr>
<contact:street>'.$RegistrantAddress1.'</contact:street>
<contact:street>'.$RegistrantAddress2.'</contact:street>
<contact:city>'.$RegistrantCity.'</contact:city>
<contact:sp>'.$RegistrantStateProvince.'</contact:sp>
<contact:pc>'.$RegistrantPostalCode.'</contact:pc>
<contact:cc>'.$RegistrantCountry.'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$RegistrantPhone.'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$RegistrantEmailAddress.'</contact:email>
<contact:authInfo>
<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
</contact:authInfo>
</contact:create>
</epp:create>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RegisterDomain', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes == '1000') {
$values['contact'] = 'Contact Created';
} else if($coderes == '2302') {
$values['contact'] = 'Contact Already exists';
} else {
$values["error"] = "RegisterDomain/contact-create($contactid): Code ($coderes) $msg";
return $values;
}
$values["status"] = $msg;
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns:cozadomain="http://co.za/epp/extensions/cozadomain-1-0"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:create>
<domain:create xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>'.$domain.'</domain:name>
<domain:registrant>'.$contactid.'</domain:registrant>
<domain:authInfo>
<domain:pw>coza</domain:pw>
</domain:authInfo>
</domain:create>
<epp:extension>
<cozadomain:create>
<cozadomain:autorenew>false</cozadomain:autorenew>
</cozadomain:create>
</epp:extension>
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RegisterDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "RegisterDomain/domain-create($domain): Code ($coderes) $msg";
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'RegisterDomain/EPP: '.$e->getMessage();
}
return $values;
}
# Function to transfer a domain
function cozaepp_TransferDomain($params) {
# Grab variables
$testmode = $params["TestMode"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$regperiod = $params["regperiod"];
$transfersecret = $params["transfersecret"];
$nameserver1 = $params["ns1"];
$nameserver2 = $params["ns2"];
# Registrant Details
$RegistrantFirstName = $params["firstname"];
$RegistrantLastName = $params["lastname"];
$RegistrantAddress1 = $params["address1"];
$RegistrantAddress2 = $params["address2"];
$RegistrantCity = $params["city"];
$RegistrantStateProvince = $params["state"];
$RegistrantPostalCode = $params["postcode"];
$RegistrantCountry = $params["country"];
$RegistrantEmailAddress = $params["email"];
$RegistrantPhone = $params["fullphonenumber"];
$AdminFirstName = $params["adminfirstname"];
$AdminLastName = $params["adminlastname"];
$AdminAddress1 = $params["adminaddress1"];
$AdminAddress2 = $params["adminaddress2"];
$AdminCity = $params["admincity"];
$AdminStateProvince = $params["adminstate"];
$AdminPostalCode = $params["adminpostcode"];
$AdminCountry = $params["admincountry"];
$AdminEmailAddress = $params["adminemail"];
$AdminPhone = $params["adminphonenumber"];
$contactid = substr(md5($domain), 0,15);
try {
$client = _cozaepp_Client();
# Initiate transfer
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:transfer op="request">
<domain:transfer>
<domain:name>'.$domain.'</domain:name>
</domain:transfer>
</epp:transfer>
</epp:command>
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'TransferDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# We should get a 1001 back
if($coderes != '1001') {
$values["error"] = "TransferDomain/domain-transfer($domain): Code ($coderes) $msg";
$values["status"] = $msg;
# Create contact details
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:create>
<contact:create xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>'.$contactid.'</contact:id>
<contact:postalInfo type="loc">
<contact:name>'.$RegistrantFirstName.' '.$RegistrantLastName.'</contact:name>
<contact:addr>
<contact:street>'.$RegistrantAddress1.'</contact:street>
<contact:street>'.$RegistrantAddress2.'</contact:street>
<contact:city>'.$RegistrantCity.'</contact:city>
<contact:sp>'.$RegistrantStateProvince.'</contact:sp>
<contact:pc>'.$RegistrantPostalCode.'</contact:pc>
<contact:cc>'.$RegistrantCountry.'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$RegistrantPhone.'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$RegistrantEmailAddress.'</contact:email>
<contact:authInfo>
<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
</contact:authInfo>
</contact:create>
</epp:create>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'TransferDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes == '1000') {
$values['contact'] = 'Contact Created';
} else if($coderes == '2302') {
$values['contact'] = 'Contact Already exists';
} else {
$values["error"] = "TransferDomain/contact-create($contactid): Code ($coderes) $msg";
return $values;
}
} catch (Exception $e) {
$values["error"] = 'TransferDomain/EPP: '.$e->getMessage();
return $values;
}
# Function to renew domain
function cozaepp_RenewDomain($params) {
# Grab variables
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
try {
$client = _cozaepp_Client();
# Send renewal request
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RenewDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "RenewDomain/domain-info($domain)): Code ($coderes) $msg";
$values["status"] = $msg;
# Sanitize expiry date
$expdate = substr($doc->getElementsByTagName('exDate')->item(0)->nodeValue,0,10);
if (empty($expdate)) {
$values["error"] = "RenewDomain/domain-info($domain): Domain info not available";
return $values;
}
# Send request to renew
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:renew>
<domain:renew>
<domain:name>'.$domain.'</domain:name>
<domain:curExpDate>'.$expdate.'</domain:curExpDate>
</domain:renew>
</epp:renew>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RenewDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "RenewDomain/domain-renew($domain,$expdate): Code (".$coderes.") ".$msg;
return $values;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'RenewDomain/EPP: '.$e->getMessage();
}
# If error, return the error message in the value below
return $values;
}
function _getContactDetails($domain, $client = null) {
if (!isset($client)) {
$client = _cozaepp_Client();
}
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', '_GetContactDetails', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values["error"] = "_GetContactDetails/domain-info($domain): Code (".$coderes.") ".$msg;
# Grab contact info
$registrant = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
if (empty($registrant)) {
$values["error"] = "_GetContactDetails/domain-info($domain): Registrant info not available";
# Grab contact info
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<epp:command>
<epp:info>
<contact:info>
<contact:id>'.$registrant.'</contact:id>
</contact:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', '_GetContactDetails', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values["error"] = "_GetContactDetails/contact-info($registrant): Code (".$coderes.") ".$msg;
$nodes = $doc->getElementsByTagName('postalInfo');
for ($i = 0; ($i < $nodes->length); $i++) {
if ($nodes->item($i)->getAttributeNode('type')->nodeValue == 'loc') {
$childNodes = $nodes->item($i);
$results["Registrant"]["Contact Name"] = $childNodes->getElementsByTagName('name')->item(0)->nodeValue;
$results["Registrant"]["Organisation"] = $childNodes->getElementsByTagName('org')->item(0)->nodeValue;
$results["Registrant"]["Address line 1"] = $childNodes->getElementsByTagName('street')->item(0)->nodeValue;
$results["Registrant"]["Address line 2"] = $childNodes->getElementsByTagName('street')->item(1)->nodeValue;
$results["Registrant"]["TownCity"] = $childNodes->getElementsByTagName('city')->item(0)->nodeValue;
$results["Registrant"]["State"] = $childNodes->getElementsByTagName('sp')->item(0)->nodeValue;
$results["Registrant"]["Zip code"] = $childNodes->getElementsByTagName('pc')->item(0)->nodeValue;
$results["Registrant"]["Country Code"] = $childNodes->getElementsByTagName('cc')->item(0)->nodeValue;
$results["Registrant"]["Phone"] = $doc->getElementsByTagName('voice')->item(0)->nodeValue;
$results["Registrant"]["Email"] = $doc->getElementsByTagName('email')->item(0)->nodeValue;
} catch (Exception $e) {
$values["error"] = 'GetContactDetails/EPP: '.$e->getMessage();
}
# Function to grab contact details
function cozaepp_GetContactDetails($params) {
# Grab variables
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
$results = _getContactDetails($domain);
# If there was an error return it
if (isset($results["error"])) {
return $results;
}
# What we going to do here is make sure all the attirbutes we return back are set
# If we don't do this WHMCS won't display the options for editing
foreach (
array("Contact Name","Organisation","Address line 1","Address line 2","TownCity","State","Zip code","Country Code","Phone","Email")
as $item
) {
# Check if the item is set
if ($results["Registrant"][$item] == "") {
# Just set it to -
$values["Registrant"][$item] = "-";
} else {
# We setting this here so we maintain the right order, else we get the set
# things first and all the unsets second, which looks crap
$values["Registrant"][$item] = $results["Registrant"][$item];
}
}
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
/**
* Catching all the different variations of params as encountered by clients
* This has only been reported to have occured in WHMCS 5.2 and 5.3.7
* References to the occurences of this particular issue can be found at the followinf urls:
* https://gitlab.devlabs.linuxassist.net/awit-whmcs/whmcs-coza-epp/issues/11#note_630
* http://lists.linuxassist.net/pipermail/whmcs-coza-epp_lists.linuxassist.net/2013-April/000319.html
*/
function _getContactDetailsFromParams($params) {
$results = array();
$results["Contact Name"] = $params["contactdetails"]["Registrant"]["Contact Name"];
// Catching different variations of Organisation
if (isset($params["contactdetails"]["Registrant"]["Organisation"])) {
$results["Organisation"] = $params["contactdetails"]["Registrant"]["Organisation"];
} else if (isset($params["contactdetails"]["Registrant"]["Company Name"])) {
$results["Organisation"] = $params["contactdetails"]["Registrant"]["Company Name"];
} else {
$results["Organisation"] = "";
}
// Catching different variations of Address line 1
if (isset($params["contactdetails"]["Registrant"]["Address line 1"])) {
$results["Address line 1"] = $params["contactdetails"]["Registrant"]["Address line 1"];
} else if (isset($params["contactdetails"]["Registrant"]["Address 1"])) {
$results["Address line 1"] = $params["contactdetails"]["Registrant"]["Address 1"];
} else {
$results["Address line 1"] = "";
}
// Catching different variations of Address line 2
if (isset($params["contactdetails"]["Registrant"]["Address line 2"])) {
$results["Address line 2"] = $params["contactdetails"]["Registrant"]["Address line 2"];
} else if (isset($params["contactdetails"]["Registrant"]["Address 2"])) {
$results["Address line 2"] = $params["contactdetails"]["Registrant"]["Address 2"];
} else {
$results["Address line 2"] = "";
}
// Catching different variations of TownCity
if (isset($params["contactdetails"]["Registrant"]["TownCity"])) {
$results["TownCity"] = $params["contactdetails"]["Registrant"]["TownCity"];
} else if (isset($params["contactdetails"]["Registrant"]["City"])) {
$results["TownCity"] = $params["contactdetails"]["Registrant"]["City"];
} else {
$results["TownCity"] = "";
}
$results["State"] = $params["contactdetails"]["Registrant"]["State"];
// Catching different variations of Postal Code
if (isset($params["contactdetails"]["Registrant"]["Zip code"])) {
$results["Zip code"] = $params["contactdetails"]["Registrant"]["Zip code"];
} else if (isset($params["contactdetails"]["Registrant"]["ZIP Code"])) {
$results["Zip code"] = $params["contactdetails"]["Registrant"]["ZIP Code"];
} else if (isset($params["contactdetails"]["Registrant"]["Postcode"])) {
$results["Zip code"] = $params["contactdetails"]["Registrant"]["Postcode"];
} else {
$results["Zip code"] = "";
}
// Catching different variations of Country Code
if (isset($params["contactdetails"]["Registrant"]["Country Code"])) {
$results["Country Code"] = $params["contactdetails"]["Registrant"]["Country Code"];
} else if (isset($params["contactdetails"]["Registrant"]["Country"])) {
$results["Country Code"] = $params["contactdetails"]["Registrant"]["Country"];
} else {
$results["Country Code"] = "";
}
$results["Phone"] = $params["contactdetails"]["Registrant"]["Phone"];
$results["Email"] = $params["contactdetails"]["Registrant"]["Email"];
return $results;
}
# Function to save contact details
function cozaepp_SaveContactDetails($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$contactDetails = _getContactDetailsFromParams($params);
$registrant_name = $contactDetails["Contact Name"];
$registrant_org = $contactDetails["Organisation"];
$registrant_address1 = $contactDetails["Address line 1"];
$registrant_address2 = $contactDetails["Address line 2"];
$registrant_town = $contactDetails["TownCity"];
$registrant_state = $contactDetails["State"];
$registrant_zipcode = $contactDetails["Zip code"];
$registrant_countrycode = $contactDetails["Country Code"];
$registrant_phone = $contactDetails["Phone"];
$registrant_email = $contactDetails["Email"];
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'SaveContactDetails', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "SaveContactDetails/domain-info($domain): Code (".$coderes.") ".$msg;
$values["status"] = $msg;
# Time to do the update
$registrant = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
# Save contact details
$request = $client->request($xml = '
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<epp:command>
<epp:update>
<contact:update>
<contact:id>'.$registrant.'</contact:id>
<contact:chg>
<contact:postalInfo type="loc">
<contact:name>'.$registrant_name.'</contact:name>
<contact:org>'.$registrant_org.'</contact:org>
<contact:addr>
<contact:street>'.$registrant_address1.'</contact:street>
<contact:street>'.$registrant_address2.'</contact:street>
<contact:city>'.$registrant_town.'</contact:city>
<contact:sp>'.$registrant_state.'</contact:sp>
<contact:pc>'.$registrant_zipcode.'</contact:pc>
<contact:cc>'.$registrant_countrycode.'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$registrant_phone.'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$registrant_email.'</contact:email>
</contact:chg>
</contact:update>
</epp:update>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'SaveContactDetails', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1001') {
$values["error"] = "SaveContactDetails/contact-update($registrant): Code ($coderes) $msg";
return $values;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'SaveContactDetails/EPP: '.$e->getMessage();
}
return $values;
}
# NOT IMPLEMENTED
function cozaepp_GetEPPCode($params) {
# Grab variables
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
# If error, return the error message in the value below
//$values["error"] = 'error';
return $values;
# Function to register nameserver
function cozaepp_RegisterNameserver($params) {
# Grab varaibles
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
$ipaddress = $params["ipaddress"];
# Grab client instance
try {
$client = _cozaepp_Client();
# Register nameserver
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:update>
<domain:update>
<domain:name>'.$domain.'</domain:name>
<domain:add>
<domain:ns>
<domain:hostAttr>
<domain:hostName>'.$nameserver.'</domain:hostName>
<domain:hostAddr ip="v4">'.$ipaddress.'</domain:hostAddr>
</domain:hostAttr>
</domain:ns>
</domain:add>
</domain:update>
</epp:update>
</epp:command>
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RegisterNameserver', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check if result is ok
if($coderes != '1001') {
$values["error"] = "RegisterNameserver/domain-update($domain): Code ($coderes) $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'SaveNameservers/EPP: '.$e->getMessage();
return $values;
}
function cozaepp_ModifyNameserver($params) {
# Grab variables
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
$currentipaddress = $params["currentipaddress"];
$newipaddress = $params["newipaddress"];
# Grab client instance
try {
$client = _cozaepp_Client();
# Modify nameserver
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>'.$domain.'</domain:name>
<domain:add>
<domain:ns>
<domain:hostAttr>
<domain:hostName>'.$nameserver.'</domain:hostName>
<domain:hostAddr ip="v4">'.$newipaddress.'</domain:hostAddr>
</domain:hostAttr>
</domain:ns>
</domain:add>
</domain:update>
</epp:update>
</epp:command>
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'ModifyNameserver', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check if result is ok
if($coderes != '1001') {
$values["error"] = "ModifyNameserver/domain-update($domain): Code ($coderes) $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'SaveNameservers/EPP: '.$e->getMessage();
return $values;
}
function cozaepp_DeleteNameserver($params) {
# Grab variables
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
# Grab client instance
try {
$client = _cozaepp_Client();
# If we were given hostname. blow away all of the stuff behind it and allow us to remove hostname
$nameserver = preg_replace('/\.\.\S+/','',$nameserver);
# Delete nameserver
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>'.$domain.'</domain:name>
<domain:rem>
<domain:ns>
<domain:hostAttr>
<domain:hostName>'.$nameserver.'</domain:hostName>
</domain:hostAttr>
</domain:ns>
</domain:rem>
</domain:update>
</epp:update>
</epp:command>
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'DeleteNameserver', $xml, $request);
# Pull off status
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check if result is ok
if($coderes != '1001') {
$values["error"] = "DeleteNameserver/domain-update($domain): Code ($coderes) $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'SaveNameservers/EPP: '.$e->getMessage();
return $values;
}
# Function to return meaningful message from response code
function _cozaepp_message($code) {
return "Code $code";
}
# Ack a POLL message
function _cozaepp_ackpoll($client,$msgid) {
# Ack poll message
$request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<poll op="ack" msgID="'.$msgid.'"/>
</command>
</epp>
');
# Decipher XML
$doc = new DOMDocument();
logModuleCall('Cozaepp', 'ackpoll', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1301' && $coderes != '1300' && $coderes != 1000) {
throw new Exception("ackpoll/poll-ack($id): Code ($coderes) $msg");
# Function to create internal COZA EPP request
function _cozaepp_Client() {
# Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
require_once 'Net/EPP/Client.php';
require_once 'Net/EPP/Protocol.php';
# Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
# Check if module parameters are sane
if (empty($params['Username']) || empty($params['Password'])) {
throw new Exception('System configuration error(1), please contact your provider');
}
if ($params['Server'] != 'regphase3.dnservices.co.za' && $params['Server'] != 'epp.coza.net.za') {
throw new Exception('System configuration error(2), please contact your provider');
}
# Create SSL context
$context = stream_context_create();
if (!empty($params['SSL']) && $params['SSL'] == 'on') {
$use_ssl = true;
}
# Set certificate if we have one
if ($use_ssl && !empty($params['Certificate'])) {
if (!file_exists($params['Certificate'])) {
throw new Exception("System configuration error(3), please contact your provider");
# Set client side certificate
stream_context_set_option($context, 'ssl', 'local_cert', $params['Certificate']);
}
# Create EPP client
$client = new Net_EPP_Client();
$res = $client->connect($params['Server'], $params['Port'], 10, $use_ssl, $context);
$request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<login>
<clID>'.$params['Username'].'</clID>
<pw>'.$params['Password'].'</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
</svcs>
</login>
</command>
</epp>
');
logModuleCall('Cozaepp', 'Connect', $xml, $request);
function cozaepp_TransferSync($params) {
$domainid = $params['domainid'];
$domain = $params['domain'];
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
$registrar = $params['registrar'];
$regperiod = $params['regperiod'];
$status = $params['status'];
$dnsmanagement = $params['dnsmanagement'];
$emailforwarding = $params['emailforwarding'];
$idprotection = $params['idprotection'];
# Other parameters used in your _getConfigArray() function would also be available for use in this function
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'TransferSync', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if ($coderes == '2303') {
$values['error'] = "TransferSync/domain-info($domain): Domain not found";
return $values;
} else if ($coderes != '1000') {
$values['error'] = "TransferSync/domain-info($domain): Code("._cozaepp_message($coderes).") $msg";
return $values;
# Check if we can get a status back
if ($doc->getElementsByTagName('status')->item(0)) {
$statusres = $doc->getElementsByTagName('status')->item(0)->getAttribute('s');
$createdate = substr($doc->getElementsByTagName('crDate')->item(0)->nodeValue,0,10);
$nextduedate = substr($doc->getElementsByTagName('exDate')->item(0)->nodeValue,0,10);
} else {
$values['error'] = "TransferSync/domain-info($domain): Domain not found";
return $values;
}
$values['status'] = $msg;
# Check status and update
if ($statusres == "ok") {
$values['completed'] = true;
} else {
$values['error'] = "TransferSync/domain-info($domain): Unknown status code '$statusres' (File a bug report here: http://gitlab.devlabs.linuxassist.net/awit-whmcs/whmcs-coza-epp/issues/new)";
}
$values['expirydate'] = $nextduedate;
} catch (Exception $e) {
$values["error"] = 'TransferSync/EPP: '.$e->getMessage();
return $values;
}
return $values;
}
function cozaepp_RecreateContact($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
# Get client instance
try {
$client = _cozaepp_Client();
# Fetching contact details
$contact = _getContactDetails($domain, $client);
# If there was an error return it
if (isset($contact["error"])) {
return $contact;
}
# Check for available contact id
$registrant = _cozaepp_CheckContact($domain);
# Recreate contact
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
<epp:command>
<epp:create>
<contact:create xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>'.$registrant.'</contact:id>
<contact:postalInfo type="loc">
<contact:name>'.$contact["Registrant"]["Contact Name"].'</contact:name>
<contact:org>'.$contact["Registrant"]["Organisation"].'</contact:org>
<contact:addr>
<contact:street>'.$contact["Registrant"]["Address line 1"].'</contact:street>
<contact:street>'.$contact["Registrant"]["Address line 2"].'</contact:street>
<contact:city>'.$contact["Registrant"]["TownCity"].'</contact:city>
<contact:sp>'.$contact["Registrant"]["State"].'</contact:sp>
<contact:pc>'.$contact["Registrant"]["Zip code"].'</contact:pc>
<contact:cc>'.$contact["Registrant"]["Country Code"].'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$contact["Registrant"]["Phone"].'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$contact["Registrant"]["Email"].'</contact:email>
<contact:authInfo>
<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
</contact:authInfo>
</contact:create>
</epp:create>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RecreateContact', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "RecreateContact/contact-create($registrant): Code ($coderes) $msg";
return $values;
}
$values["status"] = $msg;
# Update domain registrant
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:update>
<domain:update>
<domain:name>'.$domain.'</domain:name>
<domain:chg>
<domain:registrant>'.$registrant.'</domain:registrant>
</domain:chg>
</domain:update>
</epp:update>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RecreateContact', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1001') {
$values["error"] = "RecreateContact/domain-info($domain): Code (".$coderes.") ".$msg;
return $values;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'RecreateContact/EPP: '.$e->getMessage();
return $values;
}
return $values;
}
function cozaepp_Sync($params) {
$domainid = $params['domainid'];
$domain = $params['domain'];
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
$registrar = $params['registrar'];
$regperiod = $params['regperiod'];
$status = $params['status'];
$dnsmanagement = $params['dnsmanagement'];
$emailforwarding = $params['emailforwarding'];
$idprotection = $params['idprotection'];
# Other parameters used in your _getConfigArray() function would also be available for use in this function
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:info>
<domain:info xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
$doc= new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'Sync', $xml, $request);
# Initialize the owningRegistrar which will contain the owning registrar
# The <domain:clID> element contains the unique identifier of the registrar that owns the domain.
$owningRegistrar = NULL;
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if ($coderes == '2303') {
# Code 2303, domain not found
$values['error'] = "TransferSync/domain-info($domain): Domain not found";
return $values;
} else if ($coderes == '1000') {
if (
$doc->getElementsByTagName('infData') &&
$doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('ns')->item(0) &&
$doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('clID')
) {
$owningRegistrar = $doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('clID')->item(0)->nodeValue;
}
} else {
$values['error'] = "Sync/domain-info($domain): Code("._cozaepp_message($coderes).") $msg";
return $values;
}
# Check if we can get a status back
if ($doc->getElementsByTagName('status')->item(0)) {
$statusres = $doc->getElementsByTagName('status')->item(0)->getAttribute('s');
$createdate = substr($doc->getElementsByTagName('crDate')->item(0)->nodeValue,0,10);
$nextduedate = substr($doc->getElementsByTagName('exDate')->item(0)->nodeValue,0,10);
} else if (!empty($owningRegistrar) && $owningRegistrar != $username) {
# If we got an owningRegistrar back and we're not the owning registrar, return error
$values['error'] = "Sync/domain-info($domain): Domain belongs to a different registrar, (owning registrar: $owningRegistrar, your registrar: $username)";
return $values;
} else {
$values['error'] = "Sync/domain-info($domain): Domain not found";
return $values;
}
$values['status'] = $msg;
# Check status and update
if ($statusres == "ok") {
$values['active'] = true;
} elseif ($statusres == "pendingUpdate") {
} elseif ($statusres == "serverHold") {
} elseif ($statusres == "expired" || $statusres == "pendingDelete" || $statusres == "inactive") {
$values['expired'] = true;
} else {
$values['error'] = "Sync/domain-info($domain): Unknown status code '$statusres' (File a bug report here: http://gitlab.devlabs.linuxassist.net/awit-whmcs/whmcs-coza-epp/issues/new)";
}
$values['expirydate'] = $nextduedate;
} catch (Exception $e) {
$values["error"] = 'Sync/EPP: '.$e->getMessage();
return $values;
}
function cozaepp_RequestDelete($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<epp:command>
<epp:delete>
<domain:delete xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>'.$domain.'</domain:name>
</domain:delete>
</epp:delete>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc = new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RequestDelete', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1001') {
$values['error'] = 'RequestDelete/domain-info('.$domain.'): Code('._cozaepp_message($coderes).") $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'RequestDelete/EPP: '.$e->getMessage();
return $values;
}
function cozaepp_ApproveTransfer($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:transfer op="approve">
<domain:transfer>
<domain:name>'.$domain.'</domain:name>
</domain:transfer>
</epp:transfer>
</epp:command>
# Parse XML result
$doc = new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'ApproveTransfer', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values['error'] = 'ApproveTransfer/domain-info('.$domain.'): Code('._cozaepp_message($coderes).") $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'ApproveTransfer/EPP: '.$e->getMessage();
return $values;
}
return $values;
}
function cozaepp_CancelTransferRequest($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:transfer op="cancel">
<domain:transfer>
<domain:name>'.$domain.'</domain:name>
</domain:transfer>
</epp:transfer>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc = new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'CancelTransferRequest', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values['error'] = 'CancelTransferRequest/domain-info('.$domain.'): Code('._cozaepp_message($coderes).") $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'CancelTransferRequest/EPP: '.$e->getMessage();
return $values;
return $values;
}
function cozaepp_RejectTransfer($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client();
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<epp:command>
<epp:transfer op="reject">
<domain:transfer>
<domain:name>'.$domain.'</domain:name>
</domain:transfer>
</epp:transfer>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc = new DOMDocument();
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RejectTransfer', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values['error'] = 'RejectTransfer/domain-info('.$domain.'): Code('._cozaepp_message($coderes).") $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'RejectTransfer/EPP: '.$e->getMessage();
return $values;
}