示例#1
0
/**
 * Add some cash to user login in stargazer, and creates payment record in registry
 * 
 * @global object $billing   Pre-initialized low-level stargazer handlers
 * @param string  $login     Existing users login
 * @param float   $cash      Amount of money to put/set on user login
 * @param string  $operation Operation  type: add, correct,set,mock
 * @param int     $cashtype  Existing cashtype ID for payment registry
 * @param string  $note      Payment notes
 * 
 * @return void
 */
function zb_CashAdd($login, $cash, $operation, $cashtype, $note)
{
    global $billing;
    $login = mysql_real_escape_string($login);
    $cash = mysql_real_escape_string($cash);
    $cash = preg_replace("#[^0-9\\-\\.]#Uis", '', $cash);
    $cash = trim($cash);
    $cashtype = vf($cashtype);
    $note = mysql_real_escape_string($note);
    $date = curdatetime();
    $balance = zb_CashGetUserBalance($login);
    $admin = whoami();
    $noteprefix = '';
    /**
     * They wanna f**k you for free and explode ya
     * I gonna waiting no time let me show ya
     * You gonna be kidding Couse nothing is happening
     * You wanna be happy So follow me
     */
    switch ($operation) {
        case 'add':
            $targettable = 'payments';
            $billing->addcash($login, $cash);
            log_register('BALANCEADD (' . $login . ') ON ' . $cash);
            break;
        case 'correct':
            $targettable = 'paymentscorr';
            $billing->addcash($login, $cash);
            log_register('BALANCECORRECT (' . $login . ') ON ' . $cash);
            break;
        case 'set':
            $targettable = 'payments';
            $billing->setcash($login, $cash);
            log_register("BALANCESET (" . $login . ') ON ' . $cash);
            $noteprefix = 'BALANCESET:';
            break;
        case 'mock':
            $targettable = 'payments';
            log_register("BALANCEMOCK (" . $login . ') ON ' . $cash);
            $noteprefix = 'MOCK:';
            break;
    }
    //push dat payment to payments registry
    $query = "INSERT INTO `" . $targettable . "` (\n                    `id` ,\n                    `login` ,\n                    `date` ,\n                    `admin` ,\n                    `balance` ,\n                    `summ` ,\n                    `cashtypeid` ,\n                    `note`\n                    )\n                    VALUES (\n                    NULL , '" . $login . "', '" . $date . "', '" . $admin . "', '" . $balance . "', '" . $cash . "', '" . $cashtype . "', '" . ($noteprefix . $note) . "'\n                    );";
    nr_query($query);
}
示例#2
0
/**
 * Adds some money to user account
 * 
 * @param string $login
 * @param float $cash
 * @param string $note
 * 
 * @return void
 */
function zbs_CashAdd($login, $cash, $note)
{
    $login = vf($login);
    $cash = mysql_real_escape_string($cash);
    $cashtype = 0;
    $note = mysql_real_escape_string($note);
    $date = curdatetime();
    $balance = zb_CashGetUserBalance($login);
    billing_addcash($login, $cash);
    $query = "INSERT INTO `payments` ( `id` , `login` , `date` , `balance` , `summ` , `cashtypeid` , `note` )\n                VALUES (NULL , '" . $login . "', '" . $date . "', '" . $balance . "', '" . $cash . "', '" . $cashtype . "', '" . $note . ");";
    nr_query($query);
    log_register("BALANCECHANGE (" . $login . ') ON ' . $cash);
}