示例#1
0
include '../../servers/whmcsreseller/functions.php';
include '../../../configuration.php';
$db = mysql_connect($db_host, $db_username, $db_password) or die("Error connecting to database.");
mysql_select_db($db_name, $db) or die("Couldn't select the database.");
$data = mysql_query("SELECT * FROM whmcsresellerconf");
while ($r = mysql_fetch_array($data)) {
    switch ($r['name']) {
        case "email":
            $whmcs_email = $r['value'];
            break;
        case "password":
            $whmcs_pass = base64_decode($r['value']);
            break;
    }
}
$ch = curl_init();
$content = wr_dologin($ch, $whmcs_email, $whmcs_pass);
if (!$content) {
    $data = mysql_query("SELECT * FROM whmcsresellerlicenses");
    while ($r = mysql_fetch_array($data)) {
        $lic_id = $r['license_id'];
        $lic_info = wr_get_lic_info($ch, $lic_id);
        $lic_status = $lic_info['status'];
        $lic_domains = $lic_info['domains'];
        $lic_ips = $lic_info['ips'];
        $lic_path = $lic_info['directory'];
        $lic_type = $lic_info['type'];
        mysql_query("UPDATE whmcsresellerlicenses SET status='{$lic_status}', domains='{$lic_domains}', ips='{$lic_ips}', path='{$lic_path}', type='{$lic_type}' WHERE license_id='{$lic_id}'");
    }
}
curl_close($ch);
			<!-- Import Licenses -->
			<div id="tab1box" class="tabbox"><div id="tab_content">
			<h3>Import Licenses</h3>
			<p align="center">Click the import button below to import licenses from your WHMCS client area</p>
			<form method="post" action="' . $modulelink . '&a=import" name="configfrm">
			<p align="center"><input type="submit" value="Import" class="button"></p>
			<input type="hidden" name="tab" id="tab" value="" /></form><br />';
    if ($_REQUEST['a'] == "import") {
        print '<p align="center"><strong>Number of licenses imported: ' . $imp_count . '</strong></p>';
    }
    print '<h3>All Licenses</h3>
			<div class="tablebg"><table class="datatable" cellspacing="1" cellpadding="3">
			<tr><th>Delete</th><th>Reissue</th><th>License</th><th>Type</th><th>Client</th><th>License Status</th><th>Domains</th></tr>';
    $ch = curl_init();
    $data = wr_dologin($ch, $myemail, $mypass);
    foreach ($licenses as $k => $v) {
        $lic_id = $v['license_id'];
        $lic_str = $v['license'];
        $lic_userid = $v['user_id'];
        $lic_status = $v['status'];
        $lic_domains = $v['domains'];
        $lic_ips = $v['ips'];
        $lic_path = $v['path'];
        $lic_type = $v['type'];
        print '<tr><td align="center"><a href="' . $modulelink . '&a=del&lic_id=' . $lic_id . '"><img src="images/icons/delete.png" /></a></td>
				<td align="center"><a href="' . $modulelink . '&a=reissue&lic_id=' . $lic_id . '"><img src="images/icons/cleanup.png" /></a></td>
				<td align="center">' . $lic_str . '</td>
				<td align="center">' . $lic_type . '</td>';
        if ($lic_userid) {
            print '<td align="center"><a href="clientssummary.php?userid=' . $lic_userid . '">' . $lic_userid . '</a></td>';
function whmcsreseller_ClientArea($params)
{
    include 'functions.php';
    $userid = $params['clientsdetails']['userid'];
    $serviceid = $params['serviceid'];
    $lic_id = wr_get_lic_id_byuser($userid, $serviceid);
    $data = select_query("whmcsresellerconf", "name, value", array());
    while ($r = mysql_fetch_array($data)) {
        switch ($r['name']) {
            case "email":
                $myemail = $r['value'];
                break;
            case "password":
                $mypass = base64_decode($r['value']);
                break;
        }
    }
    if (isset($_REQUEST['_a'])) {
        if (!isset($_POST['lic_id']) && !isset($_POST['id']) && !isset($_POST['user_id'])) {
            print '<div class="errorbox" align="center" width="60%">Unauthorized Access Attempt.</div>';
        } else {
            $mylic_id = $_POST['lic_id'];
            $myservice_id = $_POST['id'];
            $myuser_id = $_POST['user_id'];
            $d = select_query("whmcsresellerlicenses", "*", array("license_id" => $mylic_id, "user_id" => $myuser_id, "prod_id" => $myservice_id));
            if (!mysql_num_rows($data)) {
                print '<div class="errorbox" align="center" width="60%">Unauthorized Access Attempt.</div>';
            } else {
                $data = select_query("whmcsresellerconf", "*");
                while ($r = mysql_fetch_array($data)) {
                    switch ($r['name']) {
                        case "email":
                            $whmcs_email = $r['value'];
                            break;
                        case "password":
                            $whmcs_pass = base64_decode($r['value']);
                            break;
                    }
                }
                $ch = curl_init();
                $data = wr_dologin($ch, $whmcs_email, $whmcs_pass);
                if (!$data) {
                    $lic_info = wr_get_lic_info($ch, $lic_id);
                    $lic_status = $lic_info['status'];
                    if ($lic_status != "Reissued") {
                        wr_reissue_lic($ch, $lic_id);
                    }
                }
                curl_close($ch);
            }
        }
    }
    $prod_data = select_query("tblhosting", "domainstatus", array("id" => $serviceid, "domainstatus" => "Active"));
    $isactive = mysql_num_rows($prod_data);
    $ch = curl_init();
    $data = wr_dologin($ch, $myemail, $mypass);
    if (!$data) {
        $lic_info = wr_get_lic_info($ch, $lic_id);
    }
    curl_close($ch);
    $lic_status = $lic_info['status'];
    if ($lic_status == "Reissued") {
        $lic_domains = "";
        $lic_ips = "";
        $lic_path = "";
        $lic_key = $lic_info['license'];
        $code = '<br /><div class="errorbox">The Valid Domains, IPs and Directory will be detected & saved the next time the license is verified.</div><br />';
    } else {
        $lic_domains = $lic_info['domains'];
        $lic_ips = $lic_info['ips'];
        $lic_path = $lic_info['directory'];
        $lic_key = $lic_info['license'];
        switch ($lic_info['type']) {
            case "nobranding":
                $type = "No Branding";
                break;
            case "branding":
                $type = "Branding";
                break;
        }
        $code = '<br />';
    }
    $code = $code . '<table cellspacing="1" cellpadding="0" class="frame"><tr><td>
			<table width="100%" cellpadding="2">
			<tr><td class="fieldarea">License Key:</td><td><input id="tbstyle" type="text" size="40" value="' . $lic_key . '" readonly=true></td></tr>
			<tr><td class="fieldarea">Valid Domains:</td><td><textarea id="tastyle" cols="40" readonly=true>' . $lic_domains . '</textarea></td></tr>
			<tr><td class="fieldarea">Valid IPs:</td><td><textarea id="tastyle" cols="40" readonly=true>' . $lic_ips . '</textarea></td></tr>
			<tr><td class="fieldarea">Valid Directory:</td><td><textarea id="tastyle" cols="40" readonly=true>' . $lic_path . '</textarea></td></tr>
			<tr><td class="fieldarea">License Type:</td><td>' . $type . '</td></tr>
			<tr><td class="fieldarea">Status:</td><td>' . $lic_status . '</td></tr></table></td></tr>';
    if ($lic_status == "Reissued") {
        $code = $code . '<tr><td align="center">&nbsp;</td></tr>';
    } else {
        $code = $code . '<tr><td align="center">
						<form method="POST" action="' . $_SERVER['PHP_SELF'] . '?action=productdetails&_a=reissue">
						<input type="hidden" name="id" value="' . $params['serviceid'] . '" />
						<input type="hidden" name="lic_id" value="' . $lic_id . '" />
						<input type="hidden" name="user_id" value="' . $userid . '" />
						<input type="submit" value="Reissue License" class="button" />
						</td></tr>';
    }
    $code = $code . '</table>';
    if (!$lic_key || !$isactive) {
        return '<br /><div class="errorbox">No license is currently assigned.</div>';
    } else {
        return $code;
    }
}