Skip to content
Snippets Groups Projects
Commit 6f5080d3 authored by Liam's avatar Liam
Browse files

The module requires consistant account passwords

parent 36e6c5f0
No related branches found
No related tags found
1 merge request!30The module requires that account passwords be consistent across all SLD servers
#!/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__) . '/../dbconnect.php';
# Internals
$_help = <<<EOD
usage: {$argv[0]} [--help|-h] <command> [<args>]
Available commands are:
changepassword Change ZACR account password.
EOD;
$_setup = <<<EOD
This script requires you to specify the path to the dbconnect.php file in your WHMCS installation.
Open the file and change the variable \$dbconnpath to suit your environment.
{$_help}
EOD;
// Validate dbconnpath
if (!file_exists($dbconnpath)) {
die($_setup);
}
// 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';
if (!function_exists('_cozaepp_Client')) {
die($_setup);
}
// Additional functions we need
require_once ROOTDIR . '/includes/functions.php';
// Include registrar functions aswell
require_once ROOTDIR . '/includes/registrarfunctions.php';
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':
case '--help':
case 'help':
default:
echo $_help;
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);
}
\ No newline at end of file
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