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 (91)
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;
......
This diff is collapsed.
<?
# Copyright (c) 2012-2013, 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,8 +48,6 @@ 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';
......@@ -62,58 +60,90 @@ 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;
}
$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");
}
}
} 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";
}
# Loop with message queue
while (!$last) {
# Request messages
$output= $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($output);
# 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";
}
# This is the last one
if ($coderes == 1300) {
$last = 1;
}
$msgid = $doc->getElementsByTagName('msgQ')->item(0)->getAttribute('id');
$res = _cozaepp_ackpoll($client,$msgid);
if (PEAR::isError($res)) {
echo("ERROR: ".$res->getMessage()."\n");
}
} 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 $output;
echo "\n\n";
}
}
} catch (Exception $e) {
echo("ERROR: ".$e->getMessage(). "\n");
exit;
}
?>
<?
# Copyright (c) 2012, 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
# This file brings in a few constants we need
require_once dirname(__FILE__) . '/../../../dbconnect.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';
# We need pear for the error handling
require_once "PEAR.php";
# Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
echo("COZA-EPP Domain Sync Report\n");
echo("---------------------------------------------------\n");
# Request balance from registrar
if (PEAR::isError($client = _cozaepp_Client())) {
echo("ERROR: ".$client->getMessage()."\n");
exit;
}
# 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);
# 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 {
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
$querytemplate = "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",
mysql_real_escape_string($createdate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($domain)
));
echo "Updated $domain expiry to $nextduedate\n";
} elseif ($statusres == "serverHold") {
mysql_query(sprintf($querytemplate,"Pending",
mysql_real_escape_string($createdate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($domain)
));
echo "Domain $domain is PENDING (Registration: $createdate, Expiry: $nextduedate)\n";
} elseif ($statusres == "expired") {
mysql_query(sprintf($querytemplate,"Expired",
mysql_real_escape_string($createdate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($nextduedate),
mysql_real_escape_string($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";
}
}
?>
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");
?>