michaelmr

WHMCS CozaEPP registrar contact update

Feb 22nd, 2013
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.82 KB | None | 0 0
  1. <?php
  2. ## Tool to update registrar contact details (details sent in update emails etc)
  3. ## Everything Web CC - Used AllWorldIT's sync script and modified to suit
  4.  
  5. ## Edit this file with the new details you'd like
  6. ## Format must be as per the RAR guidelines @ https://www.registry.net.za/content.php?wiki=1&contentid=28&title=Contact%20Constraints
  7. $new_details = array(
  8.     'name' => 'Domain Administrator',
  9.     'city' => 'Cape Town',
  10.     'country_code' => 'ZA',
  11.     'telephone' => '+27.123456789',
  12.     'fax' => '+27.123456789',
  13.     'email' => '[email protected]',
  14. );
  15.  
  16. # This file brings in a few constants we need
  17. require_once dirname(__FILE__) . '/../../../dbconnect.php';
  18.  
  19. # Setup include dir
  20. $include_path = ROOTDIR . '/modules/registrars/cozaepp';
  21. set_include_path($include_path . PATH_SEPARATOR . get_include_path());
  22.  
  23. # Include EPP stuff we need
  24. require_once 'cozaepp.php';
  25.  
  26. # Additional functions we need
  27. require_once ROOTDIR . '/includes/functions.php';
  28.  
  29. # Include registrar functions aswell
  30. require_once ROOTDIR . '/includes/registrarfunctions.php';
  31.  
  32. # We need pear for the error handling
  33. require_once "PEAR.php";
  34.  
  35. # Grab module parameters
  36. $params = getregistrarconfigoptions('cozaepp');
  37.  
  38. echo("COZA-EPP Update Registrar Contact Details\n");
  39. echo("------------------------------------------\n");
  40.  
  41. # Request balance from registrar
  42. if (PEAR::isError($client = _cozaepp_Client())) {
  43.     echo("ERROR: ".$client->getMessage()."\n");
  44.     exit;
  45. }
  46.  
  47. $xml = '<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  48.             <epp:command>
  49.               <epp:update>
  50.                 <contact:update>
  51.                   <contact:id>'.$params['Username'].'</contact:id>
  52.                   <contact:chg>
  53.                     <contact:postalInfo type="loc">
  54.                       <contact:name>'.$new_details['name'].'</contact:name>
  55.                       <contact:addr>
  56.                         <contact:city>'.$new_details['city'].'</contact:city>
  57.                         <contact:cc>'.$new_details['country_code'].'</contact:cc>
  58.                       </contact:addr>
  59.                     </contact:postalInfo>
  60.                     <contact:voice>'.$new_details['telephone'].'</contact:voice>
  61.                     <contact:fax>'.$new_details['fax'].'</contact:fax>
  62.                     <contact:email>'.$new_details['email'].'</contact:email>
  63.                   </contact:chg>
  64.                 </contact:update>
  65.               </epp:update>
  66.             </epp:command>
  67.           </epp:epp>';
  68.  
  69. # Query domain
  70. $output = $client->request($xml);
  71.  
  72. $doc= new DOMDocument();
  73. $doc->loadXML($output);
  74. $coderes = $doc->getElementsByTagName('result')->item(0)->getAttribute('code');
  75.  
  76. if ($coderes == '1000') {
  77.     if($doc->getElementsByTagName('msg')) {
  78.         if($doc->getElementsByTagName('msg')->item(0)) {
  79.             echo "- Results: ".$doc->getElementsByTagName('msg')->item(0)->nodeValue."\n";
  80.         } else {
  81.             echo "There was an error! - ".print_r($doc)."\n";
  82.         }
  83.     }
  84. } else {
  85.     echo "Contact Update Error: "._cozaepp_message($coderes)." - ".print_r($doc)."\n";
  86. }
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment