#!/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); }