Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ## Tool to bulk disable registrar "AutoRenew: True" //
- ## Everything Web CC - Used AllWorldIT's sync script and modified to suit
- # 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 Disable Registrar Auto-renew\n";
- echo "--------------------------------------\n";
- # Request balance from registrar
- if (PEAR::isError($client = _cozaepp_Client())) {
- echo "ERROR: ".$client->getMessage()."\n";
- die();
- }
- # Domain passed as argument?
- if (isset($argv, $argv[1])) {
- $queryresult = mysql_query("SELECT domain FROM tbldomains WHERE domain = '".mysql_escape_string(trim($argv[1]))."' and registrar = 'cozaepp' AND status = 'Active'");
- } else {
- # No? Let's do them all
- $queryresult = mysql_query("SELECT domain FROM tbldomains WHERE registrar = 'cozaepp' AND status = 'Active'");
- }
- # If you want to do it on domains that are cancelled - not just active - you can remove the "AND status = 'Active' above (note: both queries have it)
- 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;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment