function widget_coza_balance($vars)
{
    require_once ROOTDIR . '/includes/registrarfunctions.php';
    require_once ROOTDIR . '/includes/classes/AfriCC/autoload.php';
    require_once ROOTDIR . '/modules/registrars/coza/Factory.php';
    $params = getRegistrarConfigOptions('coza');
    $title = 'CO.ZA Balance';
    $content = '<p align ="center" class="textblack"><strong>%s</strong></p>';
    $epp_client = \COZA\Factory::build($params);
    try {
        $epp_client->connect();
        $frame = new \AfriCC\EPP\Extension\COZA\Info\CozaContact();
        $frame->setId(!empty($params['OTE']) && $params['OTE'] === 'on' ? $params['TestUsername'] : $params['Username']);
        $frame->requestBalance();
        $response = $epp_client->request($frame);
        if (!$response instanceof \AfriCC\EPP\Frame\Response) {
            unset($epp_client);
            return ['title' => $title, 'content' => sprintf($content, 'ERROR: no response')];
        }
        if (!$response->success()) {
            unset($epp_client);
            return ['title' => $title, 'content' => sprintf($content, sprintf('ERROR (%d): %s', $response->code(), $response->message()))];
        }
        $data = $response->data();
        if (empty($data) || !is_array($data) || empty($data['infData']['balance'])) {
            unset($epp_client);
            return ['title' => $title, 'content' => sprintf($content, 'ERROR: empty response')];
        }
        unset($epp_client);
        return ['title' => $title, 'content' => sprintf($content, 'Current registrar balance is R ' . $data['infData']['balance'])];
    } catch (Exception $e) {
        unset($epp_client);
        return ['title' => $title, 'content' => sprintf($content, 'ERROR: ' . $e->getMessage())];
    }
}
Example #2
0
function RegBuildParams($params)
{
    $reg = $params['registrar'];
    if (!$reg) {
        return false;
    }
    if (!loadRegistrarModule($reg)) {
        return false;
    }
    $regconfigs = getRegistrarConfigOptions($reg);
    $params = array_merge($params, $regconfigs);
    return $params;
}
/**
 * @link http://docs.whmcs.com/Hooks:ClientEdit
 * @param array $vars
 */
function hook_coza_client_update($vars)
{
    $params = getRegistrarConfigOptions('coza');
    $contact = getClientsDetails($vars['userid'], 0);
    $epp_client = \COZA\Factory::build($params);
    try {
        $epp_client->connect();
        try {
            \COZA\Factory::updateContactIfExists($epp_client, \COZA\Factory::getContactHandle($params, (int) $vars['userid']), $contact);
        } catch (Exception $e) {
            unset($epp_client);
            logActivity($e->getMessage(), $vars['userid']);
            return;
        }
        unset($epp_client);
        return;
    } catch (Exception $e) {
        unset($epp_client);
        logActivity('COZA/ContactUpdate: ' . $e->getMessage(), $vars['userid']);
        return;
    }
}
Example #4
0
 }
 if (file_exists("../modules/registrars/" . $module . "/logo.gif")) {
     $registrarlogourl = "../modules/registrars/" . $module . "/logo.gif";
 } else {
     if (file_exists("../modules/registrars/" . $module . "/logo.jpg")) {
         $registrarlogourl = "../modules/registrars/" . $module . "/logo.jpg";
     } else {
         if (file_exists("../modules/registrars/" . $module . "/logo.png")) {
             $registrarlogourl = "../modules/registrars/" . $module . "/logo.png";
         } else {
             $registrarlogourl = "./images/spacer.gif";
         }
     }
 }
 $moduleactive = false;
 $moduleconfigdata = getRegistrarConfigOptions($module);
 if (is_array($moduleconfigdata) && !empty($moduleconfigdata)) {
     $moduleactive = true;
     $moduleaction = "<input type=\"button\" value=\"" . $aInt->lang("addonmodules", "activate") . "\" disabled=\"disabled\" class=\"btn disabled\" /> <input type=\"button\" value=\"" . $aInt->lang("addonmodules", "deactivate") . "\" onclick=\"deactivateMod('" . $module . "');return false\" class=\"btn-danger\" />  <input type=\"button\" value=\"" . $aInt->lang("addonmodules", "config") . "\" class=\"btn\" onclick=\"showConfig('" . $module . "')\" />";
 } else {
     $moduleaction = "<input type=\"button\" value=\"" . $aInt->lang("addonmodules", "activate") . "\" onclick=\"window.location='" . $_SERVER['PHP_SELF'] . "?action=activate&module=" . $module . generate_token("link") . "'\" class=\"btn-success\" /> <input type=\"button\" value=\"" . $aInt->lang("addonmodules", "deactivate") . "\" disabled=\"disabled\" class=\"btn disabled\" /> <input type=\"button\" value=\"" . $aInt->lang("addonmodules", "config") . "\" disabled=\"disabled\" class=\"btn disabled\" />";
 }
 $regpath = ROOTDIR . ("/modules/registrars/" . $module . "/" . $module . ".php");
 if (file_exists($regpath)) {
     require_once $regpath;
 }
 $configarray = call_user_func($module . "_getConfigArray", $params);
 echo "\t<tr id=\"formholder_";
 echo $module;
 echo "\" ";
 if ($moduleactive) {
Example #5
0
function resellerclub_DomainSync($registrar)
{
    $lcregistrar = strtolower($registrar);
    $cronreport = "" . $registrar . " Domain Sync Report<br>\n---------------------------------------------------<br>\n";
    $params = getRegistrarConfigOptions($lcregistrar);
    $postfields['auth-userid'] = $params['ResellerID'];
    $postfields['api-key'] = $params['APIKey'];
    $testmode = $params['TestMode'];
    $queryresult = select_query("tbldomains", "id,domain,status", "registrar='" . $lcregistrar . "' AND (status='Pending Transfer' OR status='Active')");
    while ($data = mysql_fetch_array($queryresult)) {
        $domainid = $data['id'];
        $domainname = $data['domain'];
        $status = $data['status'];
        $postfields['domain-name'] = $domainname;
        $orderid = resellerclub_getOrderID($postfields, $params);
        if (!is_numeric($orderid)) {
            $cronreport .= "Error for " . $domainname . ": " . $orderid . "<br>\n";
        }
        unset($postfields);
        $postfields['auth-userid'] = $params['ResellerID'];
        $postfields['api-key'] = $params['APIKey'];
        $postfields['order-id'] = $orderid;
        $postfields['options'] = "All";
        $result = resellerclub_SendCommand("details", "domains", $postfields, $params, "GET");
        if ($result['status'] == "ERROR") {
            $cronreport .= "Error for " . $domainname . ": " . $result['message'] . "<br>\n";
        }
        $expirytime = $currentstatus = "";
        $expirytime = $result['endtime'];
        $currentstatus = $result['currentstatus'];
        if ($expirytime) {
            $updateqry = array();
            if ($currentstatus == "Active") {
                $updateqry['status'] = "Active";
            }
            $expirydate = date("Y-m-d", $expirytime);
            $updateqry['expirydate'] = $expirydate;
            if (count($updateqry)) {
                update_query("tbldomains", $updateqry, array("id" => $domainid));
            }
            if ($status == "Pending Transfer" && $currentstatus == "Active") {
                sendMessage("Domain Transfer Completed", $domainid);
                $cronreport .= "Processed Domain Transfer Completion of " . $domainname . " - Updated expiry to " . fromMySQLDate($expirydate) . "<br>\n";
            }
            $cronreport .= "Updated " . $domainname . " expiry to " . fromMySQLDate($expirydate) . "<br>\n";
        }
        $cronreport .= "Error for " . $domainname . ": No expiry date returned<br>\n";
    }
    echo $cronreport;
    logActivity("" . $registrar . " Domain Sync Run");
    sendAdminNotification("system", "WHMCS " . $registrar . " Domain Syncronisation Report", $cronreport);
}
Example #6
0
}
$cronreport .= "Active Domain Syncs<br />\n";
$totalunsynced = get_query_val("tbldomains", "COUNT(id)", "registrar!='' AND status='Active' AND synced=0", "id", "ASC", "0,50");
if (!$totalunsynced) {
    update_query("tbldomains", array("synced" => "0"), "");
}
$result = select_query("tbldomains", "id,domain,expirydate,nextduedate,registrar,status", "registrar!='' AND status='Active' AND synced=0", "status` DESC, `id", "ASC", "0,50");
while ($data = mysql_fetch_array($result)) {
    $domainid = $data['id'];
    $domain = $data['domain'];
    $registrar = $data['registrar'];
    $expirydate = $data['expirydate'];
    $nextduedate = $data['nextduedate'];
    $status = $data['status'];
    $domainparts = explode(".", $domain, 2);
    $params = is_array($registrarconfigops[$registrar]) ? $registrarconfigops[$registrar] : ($registrarconfigops[$registrar] = getRegistrarConfigOptions($registrar));
    $params['domainid'] = $domainid;
    $params['domain'] = $domain;
    $params['sld'] = $domainparts[0];
    $params['tld'] = $domainparts[1];
    $params['registrar'] = $registrar;
    $params['status'] = $status;
    loadRegistrarModule($registrar);
    $updateqry = array();
    $updateqry['synced'] = "1";
    $response = $synceditems = array();
    if (function_exists($registrar . "_Sync") && !in_array($registrar, $curlerrorregistrars)) {
        $response = call_user_func($registrar . "_Sync", $params);
        if (!$response['error']) {
            if ($response['active'] && $status != "Active") {
                $updateqry['status'] = "Active";
// so relative paths work
chdir(__DIR__);
// get system path
require 'config.php';
$whmcspath = realpath($whmcspath);
// required libs
require_once $whmcspath . '/init.php';
require_once $whmcspath . '/includes/registrarfunctions.php';
require_once $whmcspath . '/includes/classes/AfriCC/autoload.php';
require_once $whmcspath . '/modules/registrars/coza/Factory.php';
$result = mysql_query('SELECT * FROM `mod_coza_contact_deletequeue` WHERE `deleted` = 0 AND `next_due` < NOW() LIMIT 10');
if ($result === false || mysql_num_rows($result) === 0) {
    unset($result);
    exit(0);
}
$params = getRegistrarConfigOptions('coza');
$epp_client = \COZA\Factory::build($params);
try {
    $epp_client->connect();
    while ($row = mysql_fetch_assoc($result)) {
        $frame = new \AfriCC\EPP\Frame\Command\Delete\Contact();
        $frame->setId($row['contact_handle']);
        $response = $epp_client->request($frame);
        if (!$response instanceof \AfriCC\EPP\Frame\Response) {
            unset($epp_client);
            echo date('Y-m-d H:i:s ') . 'unable to get response' . PHP_EOL;
            exit(1);
        }
        if (!$response->success()) {
            echo date('Y-m-d H:i:s ') . $response->code() . ' - ' . $response->message() . PHP_EOL;
            update_query('mod_coza_contact_deletequeue', ['next_due' => date('Y-m-d H:i:s', strtotime('+6 day'))], ['id' => (int) $row['id']]);