function web_VserviceCashForm($login) { $currentvcash = zb_VserviceCashGet($login); $alladdr = zb_AddressGetFulladdresslist(); $allrealnames = zb_UserGetAllRealnames(); $form = ' <form action="" method="POST"> <table width="50%" border="0"> <tr> <td class="row2">' . __('Login') . '</td> <td class="row3">' . $login . '</td> </tr> <tr> <td class="row2">' . __('Address') . '</td> <td class="row3">' . @$alladdr[$login] . '</td> </tr> <tr> <td class="row2">' . __('Real Name') . '</td> <td class="row3">' . @$allrealnames[$login] . '</td> </tr> <tr> <td class="row2">' . __('Current Cash state') . '</td> <td class="row3">' . $currentvcash . '</td> </tr> <tr> <td class="row2">' . __('New cash') . '</td> <td class="row3"><input name="newcash" size="5" type="text"></td> </tr> <tr> <td class="row2">' . __('Actions') . '</td> <td class="row3"> <input name="operation" value="add" checked="checked" type="radio"> ' . __('Add cash') . ' <input name="operation" value="set" type="radio"> ' . __('Set cash') . ' </td> </tr> <tr> <td class="row2">' . __('Payment type') . '</td> <td class="row3">' . web_CashTypeSelector() . '</td> </tr> <tr> <td class="row2">' . __('Virtual services') . '</td> <td class="row3">' . web_VservicesSelector() . '</td> </tr> </table> <input type="submit" value="' . __('Change') . '"> </form>'; return $form; }
/** * Performs an virtual services payments processing * * @param int $debug * @param bool $log_payment * @param bool $charge_frozen * * @return void */ function zb_VservicesProcessAll($debug = 0, $log_payment = true, $charge_frozen = true) { $frozenUsers = array(); $query_services = "SELECT * from `vservices` ORDER by `priority` DESC"; if ($debug) { print ">>" . curdatetime() . "\n"; print ">>Searching virtual services\n"; print $query_services . "\n"; } $allservices = simple_queryall($query_services); if (!empty($allservices)) { if ($debug) { print ">>Virtual services found!\n"; print_r($allservices); } if ($charge_frozen) { if ($debug) { print '>>Charge fee from frozen users too' . "\n"; } } else { if ($debug) { print '>>Frozen users will be skipped' . "\n"; } $frozen_query = "SELECT `login` from `users` WHERE `Passive`='1';"; if ($debug) { print $frozen_query . "\n"; } $allFrozen = simple_queryall($frozen_query); if (!empty($allFrozen)) { foreach ($allFrozen as $ioFrozen => $eachFrozen) { $frozenUsers[$eachFrozen['login']] = $eachFrozen['login']; } if ($debug) { print_r($frozenUsers); } } } foreach ($allservices as $io => $eachservice) { $users_query = "SELECT `login` from `tags` WHERE `tagid`='" . $eachservice['tagid'] . "'"; if ($debug) { print ">>Searching users with this services\n"; print $users_query . "\n"; } $allusers = simple_queryall($users_query); if (!empty($allusers)) { if ($debug) { print ">>Users found!\n"; print_r($allusers); } foreach ($allusers as $io2 => $eachuser) { if ($debug) { print ">>Processing user:"******"\n"; } if ($debug) { print ">>service:" . $eachservice['id'] . "\n"; print ">>price:" . $eachservice['price'] . "\n"; print ">>processing cashtype:" . $eachservice['cashtype'] . "\n"; } if ($eachservice['cashtype'] == 'virtual') { if ($debug) { $current_cash = zb_VserviceCashGet($eachuser['login']); print ">>current cash:" . $current_cash . "\n"; } if ($debug != 2) { zb_VserviceCashFee($eachuser['login'], $eachservice['price'], $eachservice['id']); } } if ($eachservice['cashtype'] == 'stargazer') { if ($debug) { $current_cash = zb_UserGetStargazerData($eachuser['login']); $current_cash = $current_cash['Cash']; print ">>current cash:" . $current_cash . "\n"; } if ($debug != 2) { $fee = "-" . $eachservice['price']; if ($log_payment) { $method = 'add'; } else { $method = 'correct'; } if ($charge_frozen) { zb_CashAdd($eachuser['login'], $fee, $method, '1', 'Service:' . $eachservice['id']); } else { if (isset($frozenUsers[$eachuser['login']])) { if ($debug) { print '>>user frozen - skipping him' . "\n"; } } else { zb_CashAdd($eachuser['login'], $fee, $method, '1', 'Service:' . $eachservice['id']); } } } } } } } } }