Example #1
0
function zbs_ShowUserPayments($login)
{
    $usConfig = zbs_LoadConfig();
    if ($usConfig['PAYMENTS_ENABLED']) {
        $allpayments = zbs_CashGetUserPayments($login);
        $cells = la_TableCell(__('Date'));
        $cells .= la_TableCell(__('Payment'));
        $cells .= la_TableCell(__('Balance'));
        $rows = la_TableRow($cells, 'row1');
        if (!empty($allpayments)) {
            foreach ($allpayments as $io => $eachpayment) {
                if ($usConfig['PAYMENTSTIMEHIDE']) {
                    $timestamp = strtotime($eachpayment['date']);
                    $cleanDate = date("Y-m-d", $timestamp);
                    $dateCells = $cleanDate;
                } else {
                    $dateCells = $eachpayment['date'];
                }
                $cells = la_TableCell($dateCells);
                $cells .= la_TableCell($eachpayment['summ']);
                $cells .= la_TableCell($eachpayment['balance']);
                $rows .= la_TableRow($cells, 'row2');
            }
        }
        $result = la_TableBody($rows, '100%', 0);
        show_window(__('Last payments'), $result);
    } else {
        $result = __('This module is disabled');
        show_window(__('Sorry'), $result);
    }
}
Example #2
0
/**
 * Returns XML-agent user data
 * 
 * @param string $login
 */
function zbs_UserShowXmlAgentData($login)
{
    $us_config = zbs_LoadConfig();
    if (isset($_GET['payments'])) {
        if ($us_config['PAYMENTS_ENABLED']) {
            $allpayments = zbs_CashGetUserPayments($login);
            $payments = '<?xml version="1.0" encoding="utf-8"?>
<data>' . "\n";
            if (!empty($allpayments)) {
                foreach ($allpayments as $io => $eachpayment) {
                    $payments .= '<payment>' . "\n";
                    $payments .= "\t" . '<date>' . $eachpayment['date'] . '</date>' . "\n";
                    $payments .= "\t" . '<summ>' . $eachpayment['summ'] . '</summ>' . "\n";
                    $payments .= "\t" . '<balance>' . $eachpayment['balance'] . '</balance>' . "\n";
                    $payments .= '</payment>' . "\n";
                }
            }
            $payments .= '</data>' . "\n";
        } else {
            $payments = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<data>' . "\n" . '</data>' . "\n";
        }
        header('Last-Modified: ' . gmdate('r'));
        header('Content-Type: text/html; charset=utf-8');
        header("Cache-Control: no-store, no-cache, must-revalidate");
        // HTTP/1.1
        header("Pragma: no-cache");
        header('Access-Control-Allow-Origin: *');
        die($payments);
    }
    if (isset($_GET['announcements'])) {
        if ($us_config['AN_ENABLED']) {
            $announcements_query = "SELECT * from `zbsannouncements` WHERE `public`='1' ORDER by `id` DESC";
            $allAnnouncements = simple_queryall($announcements_query);
            $announcements = '<?xml version="1.0" encoding="utf-8"?>
<data>' . "\n";
            if (!empty($allAnnouncements)) {
                foreach ($allAnnouncements as $ian => $eachAnnouncement) {
                    $annText = strip_tags($eachAnnouncement['text']);
                    $allTitle = strip_tags($eachAnnouncement['title']);
                    $announcements .= '<message unic="' . $eachAnnouncement['id'] . '" title="' . $allTitle . '">' . $annText . '</message>' . "\n";
                }
            }
            $announcements .= '</data>' . "\n";
        } else {
            $announcements = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<data>' . "\n" . '</data>' . "\n";
        }
        header('Last-Modified: ' . gmdate('r'));
        header('Content-Type: text/html; charset=utf-8');
        header("Cache-Control: no-store, no-cache, must-revalidate");
        // HTTP/1.1
        header("Pragma: no-cache");
        header('Access-Control-Allow-Origin: *');
        die($announcements);
    }
    $us_currency = $us_config['currency'];
    $userdata = zbs_UserGetStargazerData($login);
    $alladdress = zbs_AddressGetFulladdresslist();
    $allrealnames = zbs_UserGetAllRealnames();
    $contract = zbs_UserGetContract($login);
    $email = zbs_UserGetEmail($login);
    $mobile = zbs_UserGetMobile($login);
    $phone = zbs_UserGetPhone($login);
    $apiVer = '1';
    $passive = $userdata['Passive'];
    $down = $userdata['Down'];
    //payment id handling
    if ($us_config['OPENPAYZ_REALID']) {
        $paymentid = zbs_PaymentIDGet($login);
    } else {
        $paymentid = ip2int($userdata['IP']);
    }
    if ($userdata['CreditExpire'] != 0) {
        $credexpire = date("d-m-Y", $userdata['CreditExpire']);
    } else {
        $credexpire = 'No';
    }
    if ($userdata['TariffChange']) {
        $tariffNm = $userdata['TariffChange'];
    } else {
        $tariffNm = 'No';
    }
    $traffdown = 0;
    $traffup = 0;
    $traffdgb = 0;
    $traffugb = 0;
    for ($i = 0; $i <= 9; $i++) {
        $traffdown = $traffdown + $userdata['D' . $i];
        $traffup = $traffup + $userdata['U' . $i];
    }
    $traffdgb = round($traffdown / 1073741824);
    $traffugb = round($traffup / 1073741824);
    if ($traffdgb == 0) {
        $traffdgb = 1;
    }
    if ($traffugb == 0) {
        $traffugb = 1;
    }
    // pasive state check
    if ($passive) {
        $passive_state = 'frozen';
    } else {
        $passive_state = 'active';
    }
    //down state check
    if ($down) {
        $down_state = ' + disabled';
    } else {
        $down_state = '';
    }
    // START OF ONLINELEFT COUNTING <<
    if ($us_config['ONLINELEFT_COUNT'] != 0) {
        // DEFINE VARS:
        $userBalance = $userdata['Cash'];
        if ($userBalance >= 0) {
            $balanceExpire = zbs_GetOnlineLeftCount($login, $userBalance, $userdata['Tariff'], true);
        } else {
            $balanceExpire = 'debt';
        }
    } else {
        $balanceExpire = 'No';
    }
    // >> END OF ONLINELEFT COUNTING
    $result = '<?xml version="1.0" encoding="utf-8"?>
<userdata>' . "\n";
    $result .= "\t" . '<address>' . @$alladdress[$login] . '</address>' . "\n";
    $result .= "\t" . '<realname>' . @$allrealnames[$login] . '</realname>' . "\n";
    $result .= "\t" . '<login>' . $login . '</login>' . "\n";
    $result .= "\t" . '<cash>' . @round($userdata['Cash'], 2) . '</cash>' . "\n";
    $result .= "\t" . '<ip>' . @$userdata['IP'] . '</ip>' . "\n";
    $result .= "\t" . '<phone>' . $phone . '</phone>' . "\n";
    $result .= "\t" . '<mobile>' . $mobile . '</mobile>' . "\n";
    $result .= "\t" . '<email>' . $email . '</email>' . "\n";
    $result .= "\t" . '<credit>' . @$userdata['Credit'] . '</credit>' . "\n";
    $result .= "\t" . '<creditexpire>' . $credexpire . '</creditexpire>' . "\n";
    $result .= "\t" . '<payid>' . $paymentid . '</payid>' . "\n";
    $result .= "\t" . '<contract>' . $contract . '</contract>' . "\n";
    $result .= "\t" . '<tariff>' . $userdata['Tariff'] . '</tariff>' . "\n";
    $result .= "\t" . '<tariffnm>' . $tariffNm . '</tariffnm>' . "\n";
    $result .= "\t" . '<traffdownload>' . zbs_convert_size($traffdown) . '</traffdownload>' . "\n";
    $result .= "\t" . '<traffupload>' . zbs_convert_size($traffup) . '</traffupload>' . "\n";
    $result .= "\t" . '<trafftotal>' . zbs_convert_size($traffdown + $traffup) . '</trafftotal>' . "\n";
    $result .= "\t" . '<accountstate>' . $passive_state . $down_state . '</accountstate>' . "\n";
    $result .= "\t" . '<accountexpire>' . $balanceExpire . '</accountexpire>' . "\n";
    $result .= "\t" . '<currency>' . $us_currency . '</currency>' . "\n";
    $result .= "\t" . '<version>' . $apiVer . '</version>' . "\n";
    $result .= '</userdata>' . "\n";
    header('Last-Modified: ' . gmdate('r'));
    header('Content-Type: text/html; charset=utf-8');
    header("Cache-Control: no-store, no-cache, must-revalidate");
    // HTTP/1.1
    header("Pragma: no-cache");
    header('Access-Control-Allow-Origin: *');
    die($result);
}