Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • awit-whmcs/whmcs-coza-epp
  • weheartwebsites/whmcs-coza-epp
  • qbitza/whmcs-coza-epp
  • wyrie/whmcs-coza-epp
  • Woklet/whmcs-coza-epp
  • jaymcc/whmcs-coza-epp
  • cmcawood/whmcs-coza-epp
7 results
Show changes
Commits on Source (99)
See http://devlabs.linuxassist.net/projects/whmcs-coza-epp
See http://gitlab.devlabs.linuxassist.net/awit-whmcs/whmcs-coza-epp/wikis/home
v.0.1.x to v1.0.0:
- Support added for .web.za, .org.za and .net.za
v0.1.0 to v0.1.1:
- Remove cronjob for modules/registrars/cozaepp/cozaeppsync.php, this is done by WHMCS automagically
#!/usr/bin/env php
<?php
# 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
# Lead developer:
# 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
# http://allworldit.com
# ! ! CONFIGURATION REQUIRED ! !
# Set the path below to the dbconnect.php file of your WHMCS installation.
$dbconnpath = dirname(__FILE__) . '/../init.php';
// Function that displays help
function _displayHelp() {
echo "usage: {$argv[0]} [--help|-h] <command> [<args>]\n\nAvailable commands are:\n\n changepassword Change ZACR account password.";
}
// This file brings in a few constants we need
require_once $dbconnpath;
// Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
// Include EPP stuff we need
require_once 'cozaepp.php';
// Additional functions we need
require_once ROOTDIR . '/includes/functions.php';
// Include registrar functions aswell
require_once ROOTDIR . '/includes/registrarfunctions.php';
// Changes old password to given new password for the specified SLD
function changePassword($sld, $current_password, $new_password)
{
// Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
try {
$client = _cozaepp_Client($sld);
$result = $client->request('
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<login>
<clID>'.$params['Username'].'</clID>
<pw>'.$current_password.'</pw>
<newPW>'.$new_password.'</newPW>
<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>');
$doc= new DOMDocument();
$doc->loadXML($result);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if ($coderes != '1000') {
$values["error"] = "ChangePassword($sld): Code ($coderes) $msg";
return $values;
}
$values['status'] = $msg;
} catch (Exception $e) {
$values["error"] = 'changePassword/EPP: '.$e->getMessage();
return $values;
}
return $values;
}
$_command = strtolower($argv[1]);
switch ($_command) {
case 'changepassword':
if (empty($argv['2']) || empty($argv['3']) || empty($argv['4'])) {
echo "\033[1;31mError: changepassword expects 3 arguments.\033[1;0m\n\n";
echo "{$argv[0]} changepassword <sld> <current password> <new password>\n\n";
exit(1);
}
$res = changePassword($argv['2'], $argv['3'], $argv['4']);
break;
case '-h':
exit(0);
case '--help':
exit(0);
default:
exit(1);
_displayHelp();
break;
}
if (is_array($res)) {
if (array_key_exists('error', $res)) {
echo $res['error'];
exit(2);
} elseif (array_key_exists('status', $res)) {
echo $res['status'];
exit(0);
}
} else {
echo "\033[1;31mError: Unexpected result from command call\033[1;0m\n\n";
var_dump($res);
}
<?php
/**
* Copyright (c) 2012-2015, 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:
* https://gitlab.devlabs.linuxassist.net/awit-whmcs/whmcs-coza-epp/wikis/home
* Lead developer:
* 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
* http://allworldit.com
* Buzybuy - cozaepp Disable Auto Renew
* This script is a modification of the original cozaeppsync.php script from AllWorldIT combined with code from
* Everything Web CC script.
* This script will loop through all the coza domains in your WHMCS database.
* Each domain's auto renew will be set to false on the domain.
* This script can also be reversed and set each domain's auto renew to true by editing the flag value below.
* http://www.buzybuy.com
*/
// This file brings in a few constants we need
require_once dirname(__FILE__) . '/../../../init.php';
// Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
// Include EPP stuff we need
require_once 'cozaepp.php';
// Additional functions we need
require_once ROOTDIR . '/includes/functions.php';
// Include registrar functions aswell
require_once ROOTDIR . '/includes/registrarfunctions.php';
// Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
echo("COZA-EPP Domain Set Auto Renew To False Report\n");
echo("---------------------------------------------------\n");
// Request balance from registrar
try {
$client = _cozaepp_Client();
// Pull list of domains which are registered using this module
$queryresult = mysql_query("
SELECT
domain
FROM
tbldomains
WHERE registrar = 'cozaepp'"
);
while($data = mysql_fetch_array($queryresult)) {
$domains[] = trim(strtolower($data['domain']));
}
// Loop with each one
foreach ($domains as $domain) {
sleep(1);
// Get domain info
$output = $client->request('
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</info>
<extension>
<cozadomain:info xmlns:cozadomain="http://co.za/epp/extensions/cozadomain-1-0"
xsi:schemaLocation="http://co.za/epp/extensions/cozadomain-1-0 coza-domain-1.0.xsd">
</cozadomain:info>
</extension>
</command>
</epp>
');
$doc= new DOMDocument();
$doc->loadXML($output);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if ($coderes == '1000') {
// Is autorenew enabled?
if ($doc->getElementsByTagName('autorenew') &&
$doc->getElementsByTagName('autorenew')->item(0) &&
strtolower(trim($doc->getElementsByTagName('autorenew')->item(0)->nodeValue)) != "false"
) {
sleep(1);
// Disable autorenew via update
$output = $client->request('
<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 xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>'.$domain.'</domain:name>
</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>
</epp:command>
</epp:epp>
');
$doc= new DOMDocument();
$doc->loadXML($output);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes == '1001') {
if($doc->getElementsByTagName('msg')) {
if($doc->getElementsByTagName('msg')->item(0)) {
echo "- ".$domain." results: ".$doc->getElementsByTagName('msg')->item(0)->nodeValue."\n";
} else {
$status = "$domain response error\n";
continue;
}
}
} else {
echo "Domain renew status update on $domain not successful: "._cozaepp_message($coderes)."\n";
continue;
}
} else {
echo "- ".$domain." already has auto-renew disabled.\n";
continue;
}
} else {
echo "Domain info on $domain not successful: "._cozaepp_message($coderes)."\n";
continue;
}
}
} catch (Exception $e) {
echo("ERROR: ".$e->getMessage()."\n");
exit;
}
<?php
/**
* AWIT COZAEPP - COZA EPP Module
* Copyright (c) 2014, 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/>.
*/
// Make sure we not being accssed directly
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
// Our global supported field list
$AWIT_COZAEPP_SUPPORTED_FIELDS = array(
"max_items"
);
// Addon configuration
function awit_cozaepp_config()
{
// Configuration
$configarray = array(
"name" => "AWIT COZAEPP",
"description" => "This module is to facilitate displaying of epp messages.",
"version" => "1.2",
"author" => "AllWorldIT",
"language" => "english",
"fields" => array(
// Admin User
"max_items" => array (
"FriendlyName" => "Items Per Page",
"Description" => "Amount of items to list per page",
"Type" => "text", "Size" => "30",
"Default" => "100"
),
)
);
return $configarray;
}
function awit_cozaepp_get_config_custom_fields()
{
global $AWIT_COZAEPP_SUPPORTED_FIELDS;
// Query modules table
$table = "tbladdonmodules";
$fields = "setting,value";
$where = array( 'module' => 'awit_cozaepp' );
$result = select_query($table,$fields,$where);
// Filter out the settings we need
$custom_fields = array();
while ($row = mysql_fetch_array($result)) {
// Check in our global list
if (in_array($row['setting'],$AWIT_COZAEPP_SUPPORTED_FIELDS)) {
$custom_fields[$row['setting']] = $row['value'];
}
}
return $custom_fields;
}
function _awit_cozaepp_getMaxItems()
{
$customFields = awit_cozaepp_get_config_custom_fields();
return $customFields['max_items'];
}
// Addon activation
function awit_cozaepp_activate()
{
// Create Custom DB Table
$result = mysql_query("
CREATE TABLE `mod_awit_cozaepp_messages` (
`id` INT( 1 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`created` DATETIME NOT NULL,
`code` VARCHAR(10) NOT NULL,
`message` TEXT NOT NULL
)
");
// Return Result
if (!$result) {
return array("status" => "error", "description"=>"There was a problem activating the module.");
} else {
return array("status" => "success","description" =>"Open module configuration for configuration options.");
}
}
function awit_cozaepp_deactivate()
{
// Remove custom tables
$result1 = mysql_query("
DROP TABLE `mod_awit_cozaepp_messages`
");
if (!$result) {
return array("status"=>"error","description"=>"There was an error deactivating the module.");
} else {
return array("status"=>"success","description"=>"Module has been deactivated.");
}
}
// Addon output
function awit_cozaepp_output($vars)
{
// Check if we have to display all records
if (isset($_POST['button']) && $_POST['button'] == 'Display All') {
$whereClause = '';
} else if (!empty($_POST['date_to']) && !empty($_POST['date_from'])) {
// Default dates
try {
$dateTo = new DateTime($_POST['date_to']);
$dateTo = $dateTo->format('Y-m-d');
$dateFrom = new DateTime($_POST['date_from']);
$dateFrom = $dateFrom->format('Y-m-d');
} catch (Exception $ex) {
// Catching exception against valid date
$dateFrom = new DateTime(date("Y-m-d"));
$dateFrom = $dateFrom->format('Y-m-d');
$dateFrom->modify('+1 day');
$dateTo = $dateTo->format('Y-m-d');
}
$whereClause = "WHERE Date(created) >= Date('".mysql_real_escape_string($dateFrom)."')
AND Date(created) <= Date('".mysql_real_escape_string($dateTo)."')";
}
// Make link to use
$link = $vars['modulelink'];
// Fancy date picker
echo '
<script>
$(function() {
$( "#date_from" ).datepicker({
dateFormat: "yy-mm-dd",
constrainInput: true
});
$( "#date_to" ).datepicker({
dateFormat: "yy-mm-dd",
constrainInput: true
});
});
</script>
';
// Date search fields
echo "<p>Select a start and end date and hit search.</p>";
echo "<form action='$link' method='post'>";
echo "<input id='date_from' type='text' value='$dateFrom' name='date_from' />";
echo "<input id='date_to' type='text' value='$dateTo' name='date_to' />";
echo "<input type='submit' name='button' value='Search' />";
echo "<input type='submit' name='button' value='Display All' />";
echo "<br /><br />";
$orderClause = 'ORDER BY created DESC';
// Max amount of records to show per page
$recordMax = _awit_cozaepp_getMaxItems();
// Validation
if (!is_numeric($recordMax)) {
$recordMax = 100;
}
// Setting page number
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else if (isset($_POST['page'])) {
$page = $_POST['page'];
}
// Ensuring valid page number
if ($page < 1) {
$page = 1;
}
// Pagination button handler
if (isset($_POST['prevPage'])) {
// Prev Page
$page = ($page > 1)? ($page - 1) : 1;
} else if (isset($_POST['nextPage'])) {
// Next Page
$page = $page + 1;
}
$recordCurrent = intval(abs($recordMax * $page)) - $recordMax;
$limitClause = "LIMIT $recordCurrent, $recordMax";
// Query the database, getting the total amount of records
$result = mysql_query(sprintf("
SELECT
COUNT(*) AS cnt
FROM
mod_awit_cozaepp_messages
%s %s
",
$whereClause,
$orderClause
));
$row = mysql_fetch_array($result);
$totalRecords = $row['cnt'];
$lastPage = ceil($totalRecords / $recordMax);
// Query the database
$result = mysql_query(sprintf("
SELECT
*
FROM
mod_awit_cozaepp_messages
%s %s %s
",
$whereClause,
$orderClause,
$limitClause
));
// Loop through results and genenrate form
$includeForm = 0;
while ($row = mysql_fetch_array($result)) {
// Open form
if (!$includeForm) {
$includeForm = 1;
echo '<div class="tablebg">';
echo '<table id="epp-message-log" class="datatable" width="100%" border="0" cellspacing="1" cellpadding="3">';
echo "<tr>";
echo "<th>Timestamp</th>";
echo "<th>Code</th>";
echo "<th>Message</th>";
echo "</tr>";
}
echo "<tr>";
echo "<td>".$row['created']."</td>";
echo "<td>".$row['code']."</td>";
echo "<td>".$row['message']."</td>";
echo "</tr>";
}
// Close form
if ($includeForm) {
echo "<tr><td colspan='5'>";
if ($page >= $lastPage) {
echo "<button name='prevPage'> &lt;&lt; Previous Page </button> Page $page";
} else if ($page == 1) {
echo " Page $page <button name='nextPage'> Next Page &gt;&gt; </button>";
} else {
echo "<button name='prevPage'> &lt;&lt; Previous Page </button> Page $page";
echo "<button name='nextPage'> Next Page &gt;&gt; </button>";
}
echo "</td></tr>";
echo "</table><br>";
echo "<input type='hidden' name='page' value='$page'>";
echo "</form>";
echo "</div>";
} else {
echo "<p>No logs yet for selected period..</p>";
}
}
<?php
$_ADDONLANG['intro'] = "AWIT COZAEPP Module";
$_ADDONLANG['description'] = "This module is to facilitate displaying of epp messages.";
$_ADDONLANG['documentation'] = "Pending..";
......@@ -24,7 +24,6 @@
* @revision $Id: Client.php,v 1.13 2010/10/21 11:55:07 gavin Exp $
*/
require_once('PEAR.php');
require_once('Net/EPP/Protocol.php');
$GLOBALS['Net_EPP_Client_Version'] = '0.0.4';
......@@ -45,24 +44,26 @@
* This method establishes the connection to the server. If the connection was
* established, then this method will call getFrame() and return the EPP <greeting>
* frame which is sent by the server upon connection. If connection fails, then
* a PEAR_Error object explaining the error will be returned instead.
* an exception with a message explaining the error will be thrown and handled
* in the calling code.
* @param string $host the hostname
* @param integer $port the TCP port
* @param integer $timeout the timeout in seconds
* @param boolean $ssl whether to connect using SSL
* @param resource $context a stream resource to use when setting up the socket connection
* @return PEAR_Error|string a PEAR_Error on failure, or a string containing the server <greeting>
* @throws Exception on connection errors
* @return a string containing the server <greeting>
*/
function connect($host, $port=700, $timeout=1, $ssl=true, $context=NULL) {
$target = sprintf('%s://%s:%d', ($ssl === true ? 'tls' : 'tcp'), $host, $port);
$target = sprintf('%s://%s:%d', ($ssl === true ? 'ssl' : 'tcp'), $host, $port);
if (is_resource($context)) {
$result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
} else {
$result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT);
}
if (!$result) {
return new PEAR_Error("Error connecting to $target: $errstr (code $errno)");
if ($result === False) {
throw new Exception("Error connecting to $target: $errstr (code $errno)");
}
......@@ -71,11 +72,11 @@
// Set stream timeout
if (!stream_set_timeout($this->socket,$timeout)) {
return new PEAR_Error("Failed to set timeout on socket: $errstr (code $errno)");
throw new Exception("Failed to set timeout on socket: $errstr (code $errno)");
}
// Set blocking
if (!stream_set_blocking($this->socket,0)) {
return new PEAR_Error("Failed to set blocking on socket: $errstr (code $errno)");
throw new Exception("Failed to set blocking on socket: $errstr (code $errno)");
}
return $this->getFrame();
......@@ -85,9 +86,9 @@
* Get an EPP frame from the server.
* This retrieves a frame from the server. Since the connection is blocking, this
* method will wait until one becomes available. If the connection has been broken,
* this method will return a PEAR_Error object, otherwise it will return a string
* containing the XML from the server
* @return PEAR_Error|string a PEAR_Error on failure, or a string containing the frame
* this method will return a string containing the XML from the server
* @throws Exception on frame errors
* @return a string containing the frame
*/
function getFrame() {
return Net_EPP_Protocol::getFrame($this->socket);
......@@ -97,6 +98,7 @@
* Send an XML frame to the server.
* This method sends an EPP frame to the server.
* @param string the XML data to send
* @throws Exception when it doesn't complete the write to the socket
* @return boolean the result of the fwrite() operation
*/
function sendFrame($xml) {
......@@ -106,12 +108,11 @@
/**
* a wrapper around sendFrame() and getFrame()
* @param string $xml the frame to send to the server
* @return PEAR_Error|string the frame returned by the server, or an error object
* @throws Exception when it doesn't complete the write to the socket
* @return string the frame returned by the server, or an error object
*/
function request($xml) {
if (PEAR::isError($res = $this->sendFrame($xml))) {
return $res;
}
$res = $this->sendFrame($xml);
return $this->getFrame();
}
......
......@@ -24,8 +24,6 @@
* @revision $Id: Protocol.php,v 1.4 2011/06/28 09:48:02 gavin Exp $
*/
require_once('PEAR.php');
/**
* Low-level functions useful for both EPP clients and servers
* @package Net_EPP
......@@ -37,6 +35,8 @@ class Net_EPP_Protocol {
// Loop reading and checking info to see if we hit timeout
$info = stream_get_meta_data($socket);
$time_start = microtime(true);
while (!$info['timed_out'] && !feof($socket)) {
// Try read remaining data from socket
$buffer = @fread($socket,$length - strlen($result));
......@@ -49,36 +49,80 @@ class Net_EPP_Protocol {
}
} else {
// Sleep 0.25s
usleep(2500);
usleep(250000);
}
// Update metadata
$info = stream_get_meta_data($socket);
$time_end = microtime(true);
if (($time_end - $time_start) > 10) {
throw new exception('Timeout while reading from EPP Server');
}
}
// Check for timeout
if ($info['timed_out']) {
return new PEAR_Error('Timeout while reading data from socket');
throw new Exception('Timeout while reading data from socket');
}
return $result;
}
static function _fwrite_nb($socket,$buffer,$length) {
// Loop writing and checking info to see if we hit timeout
$info = stream_get_meta_data($socket);
$time_start = microtime(true);
$pos = 0;
while (!$info['timed_out'] && !feof($socket)) {
// Some servers don't like alot of data, so keep it small per chunk
$wlen = $length - $pos;
if ($wlen > 1024) { $wlen = 1024; }
// Try write remaining data from socket
$written = @fwrite($socket,substr($buffer,$pos),$wlen);
// If we read something, bump up the position
if ($written && $written !== false) {
$pos += $written;
// If we hit the length we looking for, break
if ($pos == $length) {
break;
}
} else {
// Sleep 0.25s
usleep(250000);
}
// Update metadata
$info = stream_get_meta_data($socket);
$time_end = microtime(true);
if (($time_end - $time_start) > 10) {
throw new exception('Timeout while writing to EPP Server');
}
}
// Check for timeout
if ($info['timed_out']) {
throw new Exception('Timeout while writing data to socket');
}
return $pos;
}
/**
* get an EPP frame from the remote peer
* @param resource $socket a socket connected to the remote peer
* @return PEAR_Error|string either an error or a string
* @throws Exception on frame errors.
* @return string the frame
*/
static function getFrame($socket) {
// Read header
if (PEAR::isError($hdr = Net_EPP_Protocol::_fread_nb($socket,4))) {
return $hdr;
$hdr = Net_EPP_Protocol::_fread_nb($socket,4);
if (strlen($hdr) < 4) {
throw new Exception(sprintf('Short read of %d bytes from peer', strlen($hdr)));
}
// Unpack first 4 bytes which is our length
$unpacked = unpack('N', $hdr);
$length = $unpacked[1];
if ($length < 5) {
return new PEAR_Error(sprintf('Got a bad frame header length of %d bytes from peer', $length));
throw new Exception(sprintf('Got a bad frame header length of %d bytes from peer', $length));
} else {
$length -= 4; // discard the length of the header itself
......@@ -91,14 +135,16 @@ class Net_EPP_Protocol {
* send an EPP frame to the remote peer
* @param resource $socket a socket connected to the remote peer
* @param string $xml the XML to send
* @throws Exception when it doesn't complete the write to the socket
* @return the amount of bytes written to the frame
*/
static function sendFrame($socket, $xml) {
// Grab XML length & add on 4 bytes for the counter
$length = strlen($xml) + 4;
$res = fwrite($socket, pack('N',$length) . $xml);
$res = Net_EPP_Protocol::_fwrite_nb($socket, pack('N',$length) . $xml,$length);
// Check our write matches
if ($length != $res) {
return new PEAR_Error("Short write when sending XML");
throw new Exception("Short write when sending XML");
}
return $res;
......
<?php
# Copyright (c) 2012, AllWorldIT
#
# Copyright (c) 2012-2018, 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/>.
......@@ -18,51 +18,64 @@
# Official Website:
# http://devlabs.linuxassist.net/projects/whmcs-coza-epp
# Lead developer:
# Lead developer:
# 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
# * 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
# * 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
# WHMCS hosting, theming, module development, payment gateway
# integration, customizations and consulting all available from
# http://allworldit.com
# 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) {
# Grab variables
$tld = $params["tld"];
# Grab variables
$sld = $params["sld"];
$domain = "{$sld}.{$tld}";
# Create new EPP client
$client = _cozaepp_Client();
$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">
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
# Get client instance
try {
$client = _cozaepp_Client($domain);
# 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">
......@@ -72,22 +85,38 @@ function cozaepp_GetNameservers($params) {
</epp:command>
</epp:epp>
');
# Check results
if(!is_array($result)) {
# Parse XML
# Parse XML result
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$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
$i =0;
$values = array();
# Extract nameservers & build return result
$i = 1; $values = array();
foreach ($ns as $nn) {
$i++;
$values["ns{$i}"] = $nn->nodeValue;
$i++;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'GetNameservers/EPP: '.$e->getMessage();
return $values;
}
return $values;
}
......@@ -96,65 +125,78 @@ function cozaepp_GetNameservers($params) {
# Function to save set of nameservers
function cozaepp_SaveNameservers($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
# Generate XML for nameservers
if ($nameserver1 = $params["ns1"]) {
if ($nameserver1 = $params["ns1"]) {
$add_hosts = '
<domain:hostAttr>
<domain:hostName>'.$nameserver1.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver2 = $params["ns2"]) {
if ($nameserver2 = $params["ns2"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver2.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver3 = $params["ns3"]) {
if ($nameserver3 = $params["ns3"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver3.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver4 = $params["ns4"]) {
if ($nameserver4 = $params["ns4"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver4.'</domain:hostName>
</domain:hostAttr>';
}
if ($nameserver5 = $params["ns5"]) {
if ($nameserver5 = $params["ns5"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver5.'</domain:hostName>
</domain:hostAttr>';
}
# Grab list of current nameservers
$client = _cozaepp_Client();
$registrarinfo = $client->request('
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
# Get client instance
try {
$client = _cozaepp_Client($domain);
# 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">'.$sld.'.'.$tld.'</domain:name>
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML
$doc= new DOMDocument();
$doc->loadXML($registrarinfo);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
# 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";
return $values;
}
$values["status"] = $msg;
# Generate list of nameservers to remove
$hostlist = $doc->getElementsByTagName('hostName');
foreach ($hostlist as $host) {
......@@ -162,42 +204,55 @@ function cozaepp_SaveNameservers($params) {
<domain:hostAttr>
<domain:hostName>'.$host->nodeValue.'</domain:hostName>
</domain:hostAttr>
';
';
}
# Build request
$domainrenew = $client->request('
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
$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>'.$sld.'.'.$tld.'</domain:name>
<domain:name>'.$domain.'</domain:name>
<domain:add>
<domain:ns>'.$add_hosts.' </domain:ns>
</domain:add>
</domain:add>
<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>
</epp:command>
</epp:epp>
');
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($domainrenew);
$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"] = "Code (".$coderes.") ".$msg;
} else {
$values['status'] = "Domain update Pending. Based on .co.za policy, the estimated time taken is around 5 days.";
$values["error"] = "SaveNameservers/domain-update($domain): Code ($coderes) $msg";
return $values;
}
$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;
}
# If error, return the error message in the value below
$values["error"] = $error;
return $values;
}
......@@ -206,10 +261,12 @@ function cozaepp_SaveNameservers($params) {
# NOT IMPLEMENTED
function cozaepp_GetRegistrarLock($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
# Get lock status
$lock = 1;
$lock = 0;
if ($lock=="1") {
$lockstatus="locked";
} else {
......@@ -222,20 +279,93 @@ function cozaepp_GetRegistrarLock($params) {
# NOT IMPLEMENTED
function cozaepp_SaveRegistrarLock($params) {
$values["error"] = "Current co.za policy does not allow for the addition of client-side statuses on domains.";
$values["error"] = "SaveRegistrarLock: Current co.za policy does not allow for the addition of client-side statuses on domains.";
return $values;
}
# Function to retrieve an available contact id
function _cozaepp_CheckContact($domain,$type) {
$prehash = $domain . time() . rand(0, 1000000) . $type;
$contactid = substr(md5($prehash), 0,15);
# Get client instance and check for available contact id
try {
$client = _cozaepp_Client($domain);
$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
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
$regperiod = $params["regperiod"];
# Get registrant details
# Get registrant details
$RegistrantFirstName = $params["firstname"];
$RegistrantLastName = $params["lastname"];
$RegistrantAddress1 = $params["address1"];
......@@ -245,8 +375,8 @@ function cozaepp_RegisterDomain($params) {
$RegistrantPostalCode = $params["postcode"];
$RegistrantCountry = $params["country"];
$RegistrantEmailAddress = $params["email"];
$RegistrantPhone = $params["phonenumber"];
# Get admin Details
$RegistrantPhone = $params["fullphonenumber"];
# Get admin details
$AdminFirstName = $params["adminfirstname"];
$AdminLastName = $params["adminlastname"];
$AdminAddress1 = $params["adminaddress1"];
......@@ -256,52 +386,66 @@ function cozaepp_RegisterDomain($params) {
$AdminPostalCode = $params["adminpostcode"];
$AdminCountry = $params["admincountry"];
$AdminEmailAddress = $params["adminemail"];
$AdminPhone = $params["adminphonenumber"];
$AdminPhone = $params["adminfullphonenumber"];
# Registrar contactid hash
$contactid = substr(md5($domain), 0,15);
# Admin/Tech/Billing contactid hash
$additional_contactid = substr(md5($AdminFirstName.$AdminLastName), 0,15);
# Generate XML for namseverss
if ($nameserver1 = $params["ns1"]) {
if ($nameserver1 = $params["ns1"]) {
$add_hosts = '
<domain:hostAttr>
<domain:hostName>'.$nameserver1.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver2 = $params["ns2"]) {
if ($nameserver2 = $params["ns2"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver2.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver3 = $params["ns3"]) {
if ($nameserver3 = $params["ns3"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver3.'</domain:hostName>
</domain:hostAttr>
';
}
if ($nameserver4 = $params["ns4"]) {
if ($nameserver4 = $params["ns4"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver4.'</domain:hostName>
</domain:hostAttr>';
</domain:hostAttr>
';
}
if ($nameserver5 = $params["ns5"]) {
if ($nameserver5 = $params["ns5"]) {
$add_hosts .= '
<domain:hostAttr>
<domain:hostName>'.$nameserver5.'</domain:hostName>
</domain:hostAttr>';
</domain:hostAttr>
';
}
# Send registration
$client = _cozaepp_Client();
$contact = $client->request('
# Get client instance
try {
$client = _cozaepp_Client($domain);
# registry.net.za expects 'coza' as the password
$pw = "coza";
# 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>'.$RegistrantFirstName.$params['userid'].'</contact:id>
<contact:id>'.$contactid.'</contact:id>
<contact:postalInfo type="loc">
<contact:name>'.$RegistrantFirstName.' '.$RegistrantLastName.'</contact:name>
<contact:addr>
......@@ -313,11 +457,11 @@ function cozaepp_RegisterDomain($params) {
<contact:cc>'.$RegistrantCountry.'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$params["phonenumber"].'</contact:voice>
<contact:voice>'.$RegistrantPhone.'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$RegistrantEmailAddress.'</contact:email>
<contact:authInfo>
<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
<contact:pw>'.$pw.'</contact:pw>
</contact:authInfo>
</contact:create>
</epp:create>
......@@ -325,48 +469,131 @@ function cozaepp_RegisterDomain($params) {
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($contact);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes == '1000') {
$contactid = $RegistrantFirstName.$params['userid'];
$values['contact'] = 'Contact Created';
} else if($coderes == '2302') {
$contactid = $RegistrantFirstName.$params['userid'];
$values['contact'] = 'Contact Already exists';
} else {
$values["error"] = "Code (".$coderes.") ".$msg;
}
# If our result is success, carry on
if ( $coderes == '1000' or $coderes =='2302' ) {
$domaincreate = $client->request('
# 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;
$domaincreate = '
<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">
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>'.$sld.'.'.$tld.'</domain:name>
<domain:name>'.$domain.'</domain:name>
<domain:ns>'.$add_hosts.'</domain:ns>
<domain:registrant>'.$contactid.'</domain:registrant>
<domain:authInfo>
<domain:pw>coza</domain:pw>
</domain:authInfo>
</domain:create>
<domain:registrant>'.$contactid.'</domain:registrant>';
# Some SLDs require the presence of admin, billing and tech contacts.
# Check if our domain has the requirement and get/create the required contact id.
$_server = _cozaepp_SldLookup($domain);
if ($_server['additional_contacts']) {
# Generate a random password to be used for the additional contact
$pw = substr(md5($domain . time() . rand(0, 1000000)), 0,15);
$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>'.$additional_contactid.'</contact:id>
<contact:postalInfo type="loc">
<contact:name>'.$AdminFirstName.' '.$AdminLastName.'</contact:name>
<contact:addr>
<contact:street>'.$AdminAddress1.'</contact:street>
<contact:street>'.$AdminAddress2.'</contact:street>
<contact:city>'.$AdminCity.'</contact:city>
<contact:sp>'.$AdminStateProvince.'</contact:sp>
<contact:pc>'.$AdminPostalCode.'</contact:pc>
<contact:cc>'.$AdminCountry.'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$AdminPhone.'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$AdminEmailAddress.'</contact:email>
<contact:authInfo>
<contact:pw>'.$pw.'</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/additional-create($additional_contactid): Code ($coderes) $msg";
return $values;
}
$domaincreate .= '
<domain:contact type="admin">'.$additional_contactid.'</domain:contact>
<domain:contact type="tech">'.$additional_contactid.'</domain:contact>
<domain:contact type="billing">'.$additional_contactid.'</domain:contact>';
}
# registry.net.za expects 'coza' as the password
$pw = "coza";
$domaincreate .= '
<domain:authInfo>
<domain:pw>'.$pw.'</domain:pw>
</domain:authInfo>
</domain:create>
</epp:create>
<epp:extension>
<cozadomain:create>
<cozadomain:autorenew>false</cozadomain:autorenew>
</cozadomain:create>
</epp:extension>
</epp:command>
</epp:epp>
';
$request = $client->request($domaincreate);
$doc= new DOMDocument();
$doc->loadXML($domaincreate);
$doc->loadXML($request);
logModuleCall('Cozaepp', 'RegisterDomain', $domaincreate, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
$values["status"] = $msg;
}
$values["error"] = "RegisterDomain/domain-create($domain): Code ($coderes) $msg";
return $values;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'RegisterDomain/EPP: '.$e->getMessage();
return $values;
}
return $values;
......@@ -378,10 +605,11 @@ function cozaepp_RegisterDomain($params) {
function cozaepp_TransferDomain($params) {
# Grab variables
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
# Domain info
# Domain info
$regperiod = $params["regperiod"];
$transfersecret = $params["transfersecret"];
$nameserver1 = $params["ns1"];
......@@ -396,8 +624,8 @@ function cozaepp_TransferDomain($params) {
$RegistrantPostalCode = $params["postcode"];
$RegistrantCountry = $params["country"];
$RegistrantEmailAddress = $params["email"];
$RegistrantPhone = $params["phonenumber"];
# Admin Details
$RegistrantPhone = $params["fullphonenumber"];
# Admin details
$AdminFirstName = $params["adminfirstname"];
$AdminLastName = $params["adminlastname"];
$AdminAddress1 = $params["adminaddress1"];
......@@ -407,77 +635,47 @@ function cozaepp_TransferDomain($params) {
$AdminPostalCode = $params["adminpostcode"];
$AdminCountry = $params["admincountry"];
$AdminEmailAddress = $params["adminemail"];
$AdminPhone = $params["adminphonenumber"];
$AdminPhone = $params["adminfullphonenumber"];
# Our details
$contactid = substr(md5($domain), 0,15);
# Grab registrar info
$client = _cozaepp_Client();
$registrarinfo = $client->request('
# Get client instance
try {
$client = _cozaepp_Client($domain);
# 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>'.$sld.'.'.$tld.'</domain:name>
<domain:name>'.$domain.'</domain:name>
</domain:transfer>
</epp:transfer>
</epp:command>
</epp:epp>');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($registrarinfo);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes != '1001') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
$values["status"] = $msg;
# Create contact details
$contact = $client->request('
<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>'.$RegistrantFirstName.$params['userid'].'</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>'.$params["phonenumber"].'</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($contact);
$doc->loadXML($request);
logModuleCall('Cozaepp', 'TransferDomain', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes == '1000') {
$contactid = $RegistrantFirstName.$params['userid'];
$values['contact'] = 'Contact Created';
} else if($coderes == '2302') {
$contactid = $RegistrantFirstName.$params['userid'];
$values['contact'] = 'Contact Already exists';
} else {
$values["error"] = "Code (".$coderes.") ".$msg;
$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";
return $values;
}
} catch (Exception $e) {
$values["error"] = 'TransferDomain/EPP: '.$e->getMessage();
return $values;
}
$values["status"] = $msg;
return $values;
}
......@@ -486,42 +684,58 @@ function cozaepp_TransferDomain($params) {
# Function to renew domain
function cozaepp_RenewDomain($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$regperiod = $params["regperiod"];
$domain = strtolower("$sld.$tld");
# Get client instance
try {
$client = _cozaepp_Client($domain);
# Put your code to renew domain here
$client = _cozaepp_Client();
$registrarinfo = $client->request('
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
# 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">'.$sld.'.'.$tld.'</domain:name>
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($registrarinfo);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
# 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";
return $values;
}
$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
$domainrenew = $client->request('
$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>'.$sld.'.'.$tld.'</domain:name>
<domain:name>'.$domain.'</domain:name>
<domain:curExpDate>'.$expdate.'</domain:curExpDate>
</domain:renew>
</epp:renew>
......@@ -529,16 +743,23 @@ function cozaepp_RenewDomain($params) {
</epp:epp>
');
# Parse XML result
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($domainrenew);
$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"] = "Code (".$coderes.") ".$msg;
} else {
$values["status"] = $msg;
$values["error"] = "RenewDomain/domain-renew($domain,$expdate): Code (".$coderes.") ".$msg;
return $values;
}
$values["status"] = $msg;
} catch (Exception $e) {
$values["error"] = 'RenewDomain/EPP: '.$e->getMessage();
return $values;
}
# If error, return the error message in the value below
......@@ -547,46 +768,20 @@ function cozaepp_RenewDomain($params) {
# Function to grab contact details
function cozaepp_GetContactDetails($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
# Grab contact details
$client = _cozaepp_Client();
$registrarinfo = $client->request('
<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">'.$sld.'.'.$tld.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($registrarinfo);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
function __getContact($contactID,$client = null) {
# Get client instance
try {
if (!isset($client)) {
$client = _cozaepp_Client($domain);
}
# Grab contact info
$registrant = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
$domaininfo = $client->request('
$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:id>'.$contactID.'</contact:id>
</contact:info>
</epp:info>
</epp:command>
......@@ -594,113 +789,535 @@ function cozaepp_GetContactDetails($params) {
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($domaininfo);
$doc->loadXML($request);
logModuleCall('Cozaepp', '__getContact', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
# Setup return values
$values["Registrant"]["Contact Name"] = $doc->getElementsByTagName('name')->item(0)->nodeValue;
$values["Registrant"]["Organisation"] = $doc->getElementsByTagName('org')->item(0)->nodeValue;
$values["Registrant"]["Address line 1"] = $doc->getElementsByTagName('street')->item(0)->nodeValue;
$values["Registrant"]["Address line 2"] = $doc->getElementsByTagName('street')->item(1)->nodeValue;
$values["Registrant"]["TownCity"] = $doc->getElementsByTagName('city')->item(0)->nodeValue;
$values["Registrant"]["State"] = $doc->getElementsByTagName('sp')->item(0)->nodeValue;
$values["Registrant"]["Zip code"] = $doc->getElementsByTagName('pc')->item(0)->nodeValue;
$values["Registrant"]["Country Code"] = $doc->getElementsByTagName('cc')->item(0)->nodeValue;
$values["Registrant"]["Phone"] = $doc->getElementsByTagName('voice')->item(0)->nodeValue;
$values["Registrant"]["Email"] = $doc->getElementsByTagName('email')->item(0)->nodeValue;
$values["error"] = "__getContact/contact-info($contactID): Code (".$coderes.") ".$msg;
return $values;
}
}
return $values;
$nodes = $doc->getElementsByTagName('postalInfo');
for ($i = 0; ($i < $nodes->length); $i++) {
if ($nodes->item($i)->getAttributeNode('type')->nodeValue == 'loc') {
$childNodes = $nodes->item($i);
$results["Contact Name"] = $childNodes->getElementsByTagName('name')->item(0)->nodeValue;
$results["Organisation"] = $childNodes->getElementsByTagName('org')->item(0)->nodeValue;
$results["Address line 1"] = $childNodes->getElementsByTagName('street')->item(0)->nodeValue;
$results["Address line 2"] = $childNodes->getElementsByTagName('street')->item(1)->nodeValue;
$results["TownCity"] = $childNodes->getElementsByTagName('city')->item(0)->nodeValue;
$results["State"] = $childNodes->getElementsByTagName('sp')->item(0)->nodeValue;
$results["Zip code"] = $childNodes->getElementsByTagName('pc')->item(0)->nodeValue;
$results["Country Code"] = $childNodes->getElementsByTagName('cc')->item(0)->nodeValue;
}
}
$results["Phone"] = $doc->getElementsByTagName('voice')->item(0)->nodeValue;
$results["Email"] = $doc->getElementsByTagName('email')->item(0)->nodeValue;
return $results;
} catch (Exception $e) {
$values["error"] = '__getContact/EPP: '.$e->getMessage();
return $values;
}
}
# Function to save contact details
function cozaepp_SaveContactDetails($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
# Registrant Details
$registrant_name = $params["contactdetails"]["Registrant"]["Contact Name"];
$registrant_org = $params["contactdetails"]["Registrant"]["Organisation"];
$registrant_address1 = $params["contactdetails"]["Registrant"]["Address line 1"];
$registrant_address2 = $params["contactdetails"]["Registrant"]["Address line 2"];
$registrant_town = $params["contactdetails"]["Registrant"]["TownCity"];
$registrant_state = $params["contactdetails"]["Registrant"]["State"];
$registrant_zipcode = $params["contactdetails"]["Registrant"]["Zip code"];
$registrant_countrycode = $params["contactdetails"]["Registrant"]["Country Code"];
$registrant_phone = $params["contactdetails"]["Registrant"]["Phone"];
#$registrant_fax = '',
$registrant_email = $params["contactdetails"]["Registrant"]["Email"];
#Grab domain info
$client = _cozaepp_Client();
$registrarinfo = $client->request('
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
function _getContactDetails($domain, $client = null) {
# Get client instance
try {
if (!isset($client)) {
$client = _cozaepp_Client($domain);
}
# 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">'.$sld.'.'.$tld.'</domain:name>
<domain:name hosts="all">'.$domain.'</domain:name>
</domain:info>
</epp:info>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($registrarinfo);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes != '1000') {
$values["error"] = "Code (".$coderes.") ".$msg;
} else {
# Time to do the update
$registrant = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
$contact = $client->request('
<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($contact);
$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;
return $values;
}
# Grab contact ID's
$registrantContactID = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
if (empty($registrantContactID)) {
$values["error"] = "_GetContactDetails/domain-info($domain): Registrant contact info not available => $request";
return $values;
}
$contactNodes = $doc->getElementsByTagName('contact');
foreach ($contactNodes as $contactNode) {
# Check if we have found the relevant contact nodes
$type = $contactNode->getAttribute('type');
if ($type == "admin") {
$adminContactID = $contactNode->nodeValue;
} elseif ($type == "tech") {
$techContactID = $contactNode->nodeValue;
} elseif ($type == "billing") {
$billingContactID = $contactNode->nodeValue;
}
}
if (empty($adminContactID)) {
$values["error"] = "_GetContactDetails/domain-info($domain): Admin contact info not available";
return $values;
}
if (empty($techContactID)) {
$values["error"] = "_GetContactDetails/domain-info($domain): Technical contact info not available";
return $values;
}
if (empty($billingContactID)) {
$values["error"] = "_GetContactDetails/domain-info($domain): Billing contact info not available";
return $values;
}
} catch (Exception $e) {
$values["error"] = '_GetContactDetails/EPP: '.$e->getMessage();
return $values;
}
# Grab contacts
$registrantContactInfo = __getContact($registrantContactID,$client);
# If there was an error return it
if (isset($registrantContactInfo["error"])) {
return $registrantContactInfo;
}
$adminContactInfo = __getContact($adminContactID,$client);
# If there was an error return it
if (isset($adminContactInfo["error"])) {
return $adminContactInfo;
}
$techContactInfo = __getContact($techContactID,$client);
# If there was an error return it
if (isset($techContactInfo["error"])) {
return $techContactInfo;
}
$billingContactInfo = __getContact($billingContactID,$client);
# If there was an error return it
if (isset($billingContactInfo["error"])) {
return $billingContactInfo;
}
$results['Registrant'] = $registrantContactInfo;
$results['Admin'] = $adminContactInfo;
$results['Technical'] = $techContactInfo;
$results['Billing'] = $billingContactInfo;
return $results;
}
# Function to grab contact details
function cozaepp_GetContactDetails($params) {
# Grab variables
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
# Fetching contact details
$contacts = _getContactDetails($domain);
# If there was an error return it
if (isset($contacts["error"])) {
return $contacts;
}
# 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("Registrant","Admin","Technical","Billing") as $type) {
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 (empty($contacts[$type][$item])) {
# Just set it to -
$values[$type][$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[$type][$item] = $contacts[$type][$item];
}
}
}
return $values;
}
/**
* 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,$type) {
$results = array();
$results["Contact Name"] = $params["contactdetails"][$type]["Contact Name"];
# Catching different variations of Organisation
if (isset($params["contactdetails"][$type]["Organisation"])) {
$results["Organisation"] = $params["contactdetails"][$type]["Organisation"];
} else if (isset($params["contactdetails"][$type]["Company Name"])) {
$results["Organisation"] = $params["contactdetails"][$type]["Company Name"];
} else {
$results["Organisation"] = "";
}
# Catching different variations of Address line 1
if (isset($params["contactdetails"][$type]["Address line 1"])) {
$results["Address line 1"] = $params["contactdetails"][$type]["Address line 1"];
} else if (isset($params["contactdetails"][$type]["Address 1"])) {
$results["Address line 1"] = $params["contactdetails"][$type]["Address 1"];
} else {
$results["Address line 1"] = "";
}
# Catching different variations of Address line 2
if (isset($params["contactdetails"][$type]["Address line 2"])) {
$results["Address line 2"] = $params["contactdetails"][$type]["Address line 2"];
} else if (isset($params["contactdetails"][$type]["Address 2"])) {
$results["Address line 2"] = $params["contactdetails"][$type]["Address 2"];
} else {
$results["Address line 2"] = "";
}
# Catching different variations of TownCity
if (isset($params["contactdetails"][$type]["TownCity"])) {
$results["TownCity"] = $params["contactdetails"][$type]["TownCity"];
} else if (isset($params["contactdetails"][$type]["City"])) {
$results["TownCity"] = $params["contactdetails"][$type]["City"];
} else {
$results["TownCity"] = "";
}
$results["State"] = $params["contactdetails"][$type]["State"];
# Catching different variations of Postal Code
if (isset($params["contactdetails"][$type]["Zip code"])) {
$results["Zip code"] = $params["contactdetails"][$type]["Zip code"];
} else if (isset($params["contactdetails"][$type]["ZIP Code"])) {
$results["Zip code"] = $params["contactdetails"][$type]["ZIP Code"];
} else if (isset($params["contactdetails"][$type]["Postcode"])) {
$results["Zip code"] = $params["contactdetails"][$type]["Postcode"];
} else {
$results["Zip code"] = "";
}
# Catching different variations of Country Code
if (isset($params["contactdetails"][$type]["Country Code"])) {
$results["Country Code"] = $params["contactdetails"][$type]["Country Code"];
} else if (isset($params["contactdetails"][$type]["Country"])) {
$results["Country Code"] = $params["contactdetails"][$type]["Country"];
} else {
$results["Country Code"] = "";
}
$results["Phone"] = $params["contactdetails"][$type]["Phone"];
$results["Email"] = $params["contactdetails"][$type]["Email"];
return $results;
}
# Function to actually do the saving of contact details
function __saveContact($contactID,$contacts,$type,$client = null) {
# Get client instance
try {
if (!isset($client)) {
$client = _cozaepp_Client($domain);
}
# Grab contact
$contact = $contacts[$type];
# Save contact details
$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:update>
<contact:update>
<contact:id>'.$contactID.'</contact:id>
<contact:chg>
<contact:postalInfo type="loc">
<contact:name>'.$contact['Contact Name'].'</contact:name>
<contact:org>'.$contact['Organization'].'</contact:org>
<contact:addr>
<contact:street>'.$contact['Address line 1'].'</contact:street>
<contact:street>'.$contact['Address line 2'].'</contact:street>
<contact:city>'.$contact['TownCity'].'</contact:city>
<contact:sp>'.$contact['State'].'</contact:sp>
<contact:pc>'.$contact['Zip code'].'</contact:pc>
<contact:cc>'.$contact['Country Code'].'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$contact['Phone'].'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$contact['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;
return $values;
} catch (Exception $e) {
$values["error"] = 'SaveContactDetails/EPP: '.$e->getMessage();
return $values;
}
}
# Function to save contact details
function cozaepp_SaveContactDetails($params) {
# Grab variables
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
# Registrant details
$registrantContactDetails = _getContactDetailsFromParams($params,"Registrant");
$adminContactDetails = _getContactDetailsFromParams($params,"Admin");
$technicalContactDetails = _getContactDetailsFromParams($params,"Technical");
$billingContactDetails = _getContactDetailsFromParams($params,"Billing");
# Get client instance
try {
$client = _cozaepp_Client($domain);
# 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', 'SaveContactDetails', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
if($coderes == '1001') {
$values['status'] = $msg;
} else {
$values["error"] = "Code (".$coderes.") ".$msg;
if($coderes != '1000') {
$values["error"] = "SaveContactDetails/domain-info($domain): Code (".$coderes.") ".$msg;
return $values;
}
# Grab contact ID's
$registrantContactID = $doc->getElementsByTagName('registrant')->item(0)->nodeValue;
if (empty($registrantContactID)) {
$values["error"] = "_SaveContactDetails/domain-info($domain): Registrant contact info not available";
return $values;
}
$contactNodes = $doc->getElementsByTagName('contact');
foreach ($contactNodes as $contactNode) {
# Check if we have found the relevant contact nodes
$type = $contactNode->getAttribute('type');
if ($type == "admin") {
$adminContactID = $contactNode->nodeValue;
} elseif ($type == "tech") {
$techContactID = $contactNode->nodeValue;
} elseif ($type == "billing") {
$billingContactID = $contactNode->nodeValue;
}
}
if (empty($adminContactID)) {
$values["error"] = "_SaveContactDetails/domain-info($domain): Admin contact info not available";
return $values;
}
if (empty($techContactID)) {
$values["error"] = "_SaveContactDetails/domain-info($domain): Technical contact info not available";
return $values;
}
if (empty($billingContactID)) {
$values["error"] = "_SaveContactDetails/domain-info($domain): Billing contact info not available";
return $values;
}
# Create contacts for use in our recreate below
$contacts['Registrant'] = $registrantContactDetails;
$contacts['Admin'] = $adminContactDetails;
$contacts['Technical'] = $technicalContactDetails;
$contacts['Billing'] = $billingContactDetails;
# We'll store the XML in here if we need to recreate contacts, this happens if admin/tech/billing are the same as
# registrant
$contactXML_chg = '';
$contactXML_rem = '';
$contactXML_add = '';
# Store errors we got
$errors = '';
# Check the contact ID's differ, if not, recreate the extra ones
if ($adminContactID == $registrantContactID || $adminContactID == $techContactID || $adminContactID == $billingContactID) {
$adminContact = __recreateContact($domain,$contacts,"Admin",$client);
# If there was an error return it
if (!isset($adminContact["error"])) {
$contactXML_rem .= '<domain:contact type="admin">'.$adminContactID.'</domain:contact>';
$adminContactID = $adminContact['contactid'];
$contactXML_add .= '<domain:contact type="admin">'.$adminContactID.'</domain:contact>';
} else {
$errors .= $adminContact["error"];
}
} else {
$values = __saveContact($adminContactID,$contacts,"Admin",$client);
# If there was an error return it
if (isset($values["error"])) {
$errors .= $values["error"];
}
}
if ($techContactID == $registrantContactID || $techContactID == $adminContactID || $techContactID == $billingContactID) {
$techContact = __recreateContact($domain,$contacts,"Technical",$client);
# If there was an error return it
if (!isset($techContact["error"])) {
$contactXML_rem .= '<domain:contact type="tech">'.$techContactID.'</domain:contact>';
$techContactID = $techContact['contactid'];
$contactXML_add .= '<domain:contact type="tech">'.$techContactID.'</domain:contact>';
} else {
$errors .= $adminContact["error"];
}
} else {
$values = __saveContact($techContactID,$contacts,"Technical",$client);
# If there was an error return it
if (isset($values["error"])) {
$errors .= $values["error"];
}
}
if ($billingContactID == $registrantContactID || $billingContactID == $adminContactID || $billingContactID == $techContactID) {
$billingContact = __recreateContact($domain,$contacts,"Billing",$client);
# If there was an error return it
if (!isset($billingContact["error"])) {
$contactXML_rem .= '<domain:contact type="billing">'.$billingContactID.'</domain:contact>';
$billingContactID = $billingContact['contactid'];
$contactXML_add .= '<domain:contact type="billing">'.$billingContactID.'</domain:contact>';
} else {
$errors .= $billingContact["error"];
}
} else {
$values = __saveContact($billingContactID,$contacts,"Billing",$client);
# If there was an error return it
if (isset($values["error"])) {
$errors .= $values["error"];
}
}
# Save registrant
$values = __saveContact($registrantContactID,$contacts,"Registrant",$client);
# If there was an error return it
if (isset($values["error"])) {
$errors .= $values["error"];
}
$contactXML_chg .= '<domain:registrant>'.$registrantContactID.'</domain:registrant>';
# Build the XML for the updates we need to do
$contactXML = "";
if (!empty($contactXML_add)) {
$contactXML .= '<domain:add>'.$contactXML_add.'</domain:add>';
}
if (!empty($contactXML_rem)) {
$contactXML .= '<domain:rem>'.$contactXML_rem.'</domain:rem>';
}
if (!empty($contactXML_chg)) {
$contactXML .= '<domain:chg>'.$contactXML_chg.'</domain:chg>';
}
# Check if we need to do a contact ID update
if (!empty($contactXML)) {
# Update domain contacts if any changed
$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>
'.$contactXML.'
</domain: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') {
$errors .= "_SaveContactDetails/domain-info($domain): Code (".$coderes.") ".$msg;
}
}
# Check what we're going to return
unset($values);
if ($errors) {
$values["error"] = $errors;
} else {
$values['msg'] = "Contact details saved.";
}
return $values;
} catch (Exception $e) {
$values["error"] = 'SaveContactDetails/EPP: '.$e->getMessage();
return $values;
}
return $values;
......@@ -714,8 +1331,9 @@ function cozaepp_GetEPPCode($params) {
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
$values["eppcode"] = '';
......@@ -726,26 +1344,71 @@ function cozaepp_GetEPPCode($params) {
# NOT IMPLEMENTED
# Function to register nameserver
function cozaepp_RegisterNameserver($params) {
# Grab varaibles
$username = $params["Username"];
$password = $params["Password"];
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$tld = $params["tld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
$ipaddress = $params["ipaddress"];
# If error, return the error message in the value below
$values["error"] = $error;
# Grab client instance
try {
$client = _cozaepp_Client($domain);
# 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>
</epp:epp>
');
# 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;
}
return $values;
}
# NOT IMPLEMENTED
# Modify nameserver
function cozaepp_ModifyNameserver($params) {
# Grab variables
$username = $params["Username"];
......@@ -753,19 +1416,62 @@ function cozaepp_ModifyNameserver($params) {
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
$currentipaddress = $params["currentipaddress"];
$newipaddress = $params["newipaddress"];
# If error, return the error message in the value below
$values["error"] = $error;
# Grab client instance
try {
$client = _cozaepp_Client($domain);
# 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">
<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">'.$newipaddress.'</domain:hostAddr>
</domain:hostAttr>
</domain:ns>
</domain:add>
</domain:update>
</epp:update>
</epp:command>
</epp:epp>
');
# 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;
}
return $values;
}
# NOT IMPLEMENTED
# Delete nameserver
function cozaepp_DeleteNameserver($params) {
# Grab variables
$username = $params["Username"];
......@@ -773,15 +1479,62 @@ function cozaepp_DeleteNameserver($params) {
$testmode = $params["TestMode"];
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
$nameserver = $params["nameserver"];
# If error, return the error message in the value below
$values["error"] = $error;
# Grab client instance
try {
$client = _cozaepp_Client($domain);
# 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">
<epp:command>
<epp:update>
<domain:update>
<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>
</epp:epp>
');
# 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;
}
return $values;
}
# Function to return meaningful message from response code
function _cozaepp_message($code) {
......@@ -790,70 +1543,120 @@ function _cozaepp_message($code) {
}
# Ack a POLL message
function _cozaepp_ackpoll($client,$msgid) {
# Ack poll message
$output = $client->request('
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
$request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<poll op="ack" msgID="'.$id.'"/>
<poll op="ack" msgID="'.$msgid.'"/>
</command>
</epp>
');
# Check for error
if (PEAR::isError($output)) {
return $output;
}
# Decipher XML
$doc = new DOMDocument();
$doc->loadXML($output);
$doc->loadXML($request);
logModuleCall('Cozaepp', 'ackpoll', $xml, $request);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
$msg = $doc->getElementsByTagName('msg')->item(0)->nodeValue;
# Check result
if($coderes != '1301') {
return new PEAR_Error("Failed to ACK message $msgid");
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());
# Helper function to centrally provide data and information about different SLDs.
function _cozaepp_SldLookup($domain) {
# TLD server data provided by ZACR
$tldservers = array(
'co.za' => array(
'fqdn' => 'epp.coza.net.za',
'port' => 3121,
'additional_contacts' => true
),
'org.za' => array(
'fqdn' => 'org-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
'web.za' => array(
'fqdn' => 'web-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
'net.za' => array(
'fqdn' => 'net-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
);
if (!is_null($domain)) {
foreach ($tldservers as $tld => $data) {
if (preg_match("/$tld$/i", $domain)) {
return $data;
}
}
throw new Exception('SLD lookup failed to find: '.$domain);
} else { # defaults to co.za server.
return $tldservers['co.za'];
}
}
# Function to create internal COZA EPP request
function _cozaepp_Client($domain=null) {
# Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
# Include EPP stuff we need
require_once 'Net/EPP/Client.php';
require_once 'Net/EPP/Protocol.php';
# Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
# Set server address and port based on parsed domain name
$_server = _cozaepp_SldLookup($domain);
# Check if module parameters are sane
if (empty($params['Username']) || empty($params['Password'])) {
throw new Exception('System configuration error(1), please contact your provider');
}
# Create SSL context
$context = stream_context_create();
# Are we using ssl?
$use_ssl = false;
if (isset($params['SSL']) && $params['SSL'] == 'on') {
if (!empty($params['SSL']) && $params['SSL'] == 'on') {
$use_ssl = true;
}
# Set certificate if we have one
if ($use_ssl && isset($params['Certificate']) && file_exists($params['Certificate'])) {
# Create SSL context
$context = stream_context_create();
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();
# Connect
$res = $client->connect($params['Server'], $params['Port'], 30, $use_ssl, $context);
# Check for error
if (PEAR::isError($res)) {
return $res;
}
$res = $client->connect($_server['fqdn'], $_server['port'], 10, $use_ssl, $context);
# Perform login
$result = $client->request('
$request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<login>
......@@ -871,10 +1674,539 @@ function _cozaepp_Client() {
</command>
</epp>
');
logModuleCall('Cozaepp', 'Connect', $xml, $request);
return $client;
}
?>
function cozaepp_TransferSync($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($domain);
# 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 __recreateContact($domain,$contacts,$type,$client = null) {
# Get client instance
try {
if (!isset($client)) {
$client = _cozaepp_Client($domain);
}
# Check for available contact id
$contactID = _cozaepp_CheckContact($domain,$type);
# Generate a random password for the contact
$pw = substr(md5($domain . time() . rand(0, 1000000)), 0,15);
# 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">
<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>'.$contacts[$type]["Contact Name"].'</contact:name>
<contact:org>'.$contacts[$type]["Organisation"].'</contact:org>
<contact:addr>
<contact:street>'.$contacts[$type]["Address line 1"].'</contact:street>
<contact:street>'.$contacts[$type]["Address line 2"].'</contact:street>
<contact:city>'.$contacts[$type]["TownCity"].'</contact:city>
<contact:sp>'.$contacts[$type]["State"].'</contact:sp>
<contact:pc>'.$contacts[$type]["Zip code"].'</contact:pc>
<contact:cc>'.$contacts[$type]["Country Code"].'</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>'.$contacts[$type]["Phone"].'</contact:voice>
<contact:fax></contact:fax>
<contact:email>'.$contacts[$type]["Email"].'</contact:email>
<contact:authInfo>
<contact:pw>'.$pw.'</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($contactID:$type): Code ($coderes) $msg";
return $values;
}
$values["contactid"] = $contactID;
return $values;
} catch (Exception $e) {
$values["error"] = '__recreateContact/EPP: '.$e->getMessage();
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($domain);
# Fetching contact details
$contacts = _getContactDetails($domain, $client);
# If there was an error return it
if (isset($contacts["error"])) {
return $contacts;
}
# Create contacts
$registrantContact = __recreateContact($domain,$contacts,"Registrant",$client);
# If there was an error return it
if (isset($registrantContact["error"])) {
return $registrantContact;
}
$registrantContactID = $registrantContact['contactid'];
$adminContact = __recreateContact($domain,$contacts,"Admin",$client);
# If there was an error return it
if (isset($adminContact["error"])) {
return $adminContact;
}
$adminContactID = $adminContact['contactid'];
$techContact = __recreateContact($domain,$contacts,"Technical",$client);
# If there was an error return it
if (isset($techContact["error"])) {
return $techContact;
}
$techContactID = $techContact['contactid'];
$billingContact = __recreateContact($domain,$contacts,"Billing",$client);
# If there was an error return it
if (isset($billingContact["error"])) {
return $billingContact;
}
$billingContactID = $billingContact['contactid'];
# 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>'.$registrantContactID.'</domain:registrant>
<domain:admin>'.$adminContactID.'</domain:admin>
<domain:tech>'.$techContactID.'</domain:tech>
<domain:billing>'.$billingContactID.'</domain:billing>
</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($domain);
# 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') {
# Code 1000, success
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;
}
return $values;
}
function cozaepp_RequestDelete($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client($domain);
# 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;
}
return $values;
}
function cozaepp_ApproveTransfer($params) {
$sld = $params['sld'];
$tld = $params['tld'];
$domain = strtolower("$sld.$tld");
# Grab domain info
try {
$client = _cozaepp_Client($domain);
# 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>
</epp:epp>
');
# 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($domain);
# 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($domain);
# 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;
}
return $values;
}
<?
# Copyright (c) 2012, AllWorldIT
#
<?php
# Copyright (c) 2012-2015, 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/>.
......@@ -18,27 +18,27 @@
# Official Website:
# http://devlabs.linuxassist.net/projects/whmcs-coza-epp
# Lead developer:
# Lead developer:
# 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
# * 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
# * 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
# WHMCS hosting, theming, module development, payment gateway
# integration, customizations and consulting all available from
# http://allworldit.com
# This file brings in a few constants we need
require_once dirname(__FILE__) . '/../../../dbconnect.php';
require_once dirname(__FILE__) . '/../../../init.php';
# Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
......@@ -48,86 +48,102 @@ require_once 'cozaepp.php';
require_once ROOTDIR . '/includes/functions.php';
# Include registrar functions aswell
require_once ROOTDIR . '/includes/registrarfunctions.php';
# We need pear for the error handling
require_once "PEAR.php";
require_once 'Net/EPP/Frame.php';
require_once 'Net/EPP/Frame/Command.php';
require_once 'Net/EPP/ObjectSpec.php';
# Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
echo("COZA-EPP Domain Sync Report\n");
echo("COZA-EPP Poll Report\n");
echo("---------------------------------------------------\n");
# Request balance from registrar
if (PEAR::isError($client = _cozaepp_Client())) {
echo("ERROR: ".$client->getMessage()."\n");
exit;
}
try {
$client = _cozaepp_Client();
# Loop with message queue
while (!$last) {
# Request messages
$request = $client->request('
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<poll op="req"/>
</command>
</epp>
');
# Decode response
$doc= new DOMDocument();
$doc->loadXML($request);
# Pull off code
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if ($coderes == 1301 || $coderes == 1300) {
$msgs = $doc->getElementsByTagName('msg');
for ($m = 0; $m < $msgs->length; $m++) {
echo "CODE: $coderes, MESSAGE: '".$msgs->item($m)->textContent."'\n";
// Messages to ignore
$ignored = array(
'Command completed successfully; ack to dequeue',
'Command completed successfully; no messages'
);
// Logging message
if (!in_array(trim($msgs->item($m)->textContent), $ignored)) {
$message = mysql_real_escape_string(trim($msgs->item($m)->textContent));
$result = mysql_query("
INSERT INTO mod_awit_cozaepp_messages
(
created,
code,
message
)
VALUES
(
now(),
'$coderes',
'$message'
)
");
if (mysql_error($result)) {
echo "ERROR: couldn't log epp message: " . mysql_error($result);
}
}
}
# This is the last one
if ($coderes == 1300) {
$last = 1;
}
# Pull list of domains which are registered using this module
$queryresult = mysql_query("SELECT domain FROM tbldomains WHERE registrar = 'cozaepp' AND status <> 'Pending Transfer'");
while($data = mysql_fetch_array($queryresult)) {
$domains[] = trim(strtolower($data['domain']));
}
$msgq = $doc->getElementsByTagName('msgQ')->item(0);
if ($msgq) {
$msgid = $doc->getElementsByTagName('msgQ')->item(0)->getAttribute('id');
try {
$res = _cozaepp_ackpoll($client,$msgid);
} catch (Exception $e) {
echo("ERROR: ".$e->getMessage()."\n");
}
}
# Loop with each one
foreach($domains as $domain) {
sleep(1);
# Query domain
$output = $client->request('
<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($output);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if($coderes == '1000') {
if( $doc->getElementsByTagName('status')) {
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 {
$status = "Domain $domain not registered!";
continue;
} else {
$msgid = $doc->getElementsByTagName('svTRID')->item(0)->textContent;
$msgs = $doc->getElementsByTagName('msg');
for ($m = 0; $m < $msgs->length; $m++) {
echo "\n";
echo "UNKNOWN CODE: $coderes, MESSAGE: '".$msgs->item($m)->textContent."', ID: $msgid\n";
echo $request;
echo "\n\n";
}
}
} else {
echo "Domain check on $domain not successful: "._cozaepp_message($coderes)." (File a bug report here: http://devlabs.linuxassist.net/projects/whmcs-coza-epp/issues/new)";
continue;
}
# This is the template we going to use below for our updates
$querytempalte = "UPDATE tbldomains SET status = %s, registrationdate = %s, expirydate = %s, nextduedate = %s, WHERE domain = %s";
# Check status and update
if ($statusres == "ok") {
mysql_query(sprintf($querytemplate,"Active",$createdate,$nextduedate,$nextduedate,$domain));
echo "Updated $domain expiry to $nextduedate\n";
} elseif ($statusres == "serverHold") {
mysql_query(sprintf($querytemplate,"Pending",$createdate,$nextduedate,$nextduedate,$domain));
echo "Domain $domain is PENDING (Registration: $createdate, Expiry: $nextduedate)\n";
} elseif ($statusres == "expired") {
mysql_query(sprintf($querytemplate,"Expired",$createdate,$nextduedate,$nextduedate,$domain));
echo "Domain $domain is EXPIRED (Registration: $createdate, Expiry: $nextduedate)\n";
} else {
echo "Domain $domain has unknown status '$statusres' (File a bug report here: http://devlabs.linuxassist.net/projects/whmcs-coza-epp/issues/new)\n";
}
} catch (Exception $e) {
echo("ERROR: ".$e->getMessage(). "\n");
exit;
}
?>
modules/registrars/cozaepp/logo.gif

5.04 KiB

<?php
# Copyright (c) 2012, AllWorldIT
#
# Copyright (c) 2012-2015, 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/>.
......@@ -18,21 +18,21 @@
# Official Website:
# http://devlabs.linuxassist.net/projects/whmcs-coza-epp
# Lead developer:
# Lead developer:
# 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
# * 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
# * 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
# WHMCS hosting, theming, module development, payment gateway
# integration, customizations and consulting all available from
# http://allworldit.com
......@@ -46,8 +46,6 @@ function widget_cozaepp_balance($vars) {
require_once 'cozaepp.php';
# Include registrar functions aswell
require_once ROOTDIR . '/includes/registrarfunctions.php';
# We need pear for the error handling
require_once "PEAR.php";
# Grab module parameters
......@@ -58,12 +56,11 @@ function widget_cozaepp_balance($vars) {
$template = '<p align = "center" class="textblack"><strong>%s</strong></p>';
# Request balance from registrar
if (PEAR::isError($client = _cozaepp_Client())) {
return array('title'=>$title,'content'=>sprintf($template,"ERROR: ".$client->getMessage()));
}
try {
$client = _cozaepp_Client();
$output = $client->request('
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
$output = $client->request('
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xmlns:cozacontact="http://co.za/epp/extensions/cozacontact-1-0">
<epp:command>
<epp:info>
......@@ -78,16 +75,20 @@ function widget_cozaepp_balance($vars) {
</epp:extension>
</epp:command>
</epp:epp>
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($output);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if ($coderes == '1000') {
$balancestr = "Current registrar balance is R ".$doc->getElementsByTagName('balance')->item(0)->nodeValue;
} else {
$balancestr = 'ERROR: Parsing';
');
# Parse XML result
$doc= new DOMDocument();
$doc->loadXML($output);
$coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
if ($coderes == '1000') {
$balancestr = "Current registrar balance is R ".$doc->getElementsByTagName('balance')->item(0)->nodeValue;
} else {
$balancestr = 'ERROR: Parsing';
}
} catch (Exception $e) {
return array('title'=>$title,'content'=>sprintf($template,"ERROR: ".$e->getMessage()));
}
return array('title'=>$title,'content'=>sprintf($template,$balancestr));
......@@ -95,4 +96,3 @@ function widget_cozaepp_balance($vars) {
add_hook("AdminHomeWidgets",1,"widget_cozaepp_balance");
?>