Skip to content
Snippets Groups Projects
Commit 5196079f authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added script to sync renewal dates with COZA

parent cf5a00cd
No related branches found
No related tags found
No related merge requests found
<?
# 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' AND status <> 'Pending Transfer'");
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
$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";
}
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment