<?
$usid = $_SESSION["user_id"];
$usname = $_SESSION["user"];
$db->Query("SELECT * FROM ".$pref."_users_b WHERE id = '$usid' LIMIT 1");
$user_data = $db->FetchArray();
?>
<style>
#good {
border-color: #489E12;
}
#error {
border-color: #EC5E0B;
}
.alert {
color: #650202;
margin: 5px 0;
padding: 8px 35px 8px 14px;
text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5);
background-color: #F5CE9D;
border: 2px solid #3Aa73D;
border-radius: 2px;
}
</style>
<!--Powered By WmRush.name -->
<td valign="top">
<div class="r_block">
<h1>Пин - коды</h1>
<div class="silver-bk"><div class="clr"></div>
<?
if(isset($_POST['pin'])) {
$pin = $db->RealEscape(htmlspecialchars($_POST['pin'], ENT_QUOTES, 'windows-1251'));
$db->Query("SELECT * FROM ".$pref."_pin WHERE pin = '$pin'");
$kol = $db->NumRows();
$pin = $db->FetchArray();
$id_pin = $pin['id'];
$sum = $pin['summa'];
if($kol != 0) {
if($pin['status'] == 0) {
//$db->Query("UPDATE db_users_b SET money_b = money_b + '$sum' WHERE id = '$usid'");
# Настройки
$db->Query("SELECT * FROM ".$pref."_config WHERE id = '1' LIMIT 1");
$sonfig_site = $db->FetchArray();
$user_id = $usid;
$db->Query("SELECT user, referer_id FROM ".$pref."_users_a WHERE id = '$usid' LIMIT 1");
$user_ardata = $db->FetchArray();
$user_name = $user_ardata["user"];
$refid = $user_ardata["referer_id"];
# Зачисляем баланс
$serebro = sprintf("%.4f", floatval($sonfig_site["ser_per_wmr"] * $sum) );
$db->Query("SELECT insert_sum FROM ".$pref."_users_b WHERE id = '$usid' LIMIT 1");
$ins_sum = $db->FetchRow();
$serebro = intval($ins_sum <= 101) ? ($serebro + ($serebro * 0.0) ) : $serebro;
$add_tree = ( $sum >= 0.0) ? 0 : 0;
$lsb = time();
$to_referer = ($serebro * 0.0);
$db->Query("UPDATE ".$pref."_users_b SET money_b = money_b + '$serebro', e_t = e_t + '$add_tree', to_referer = to_referer + '$to_referer', last_sbor = '$lsb', insert_sum = insert_sum + '$sum' WHERE id = '$usid'");
# Зачисляем средства рефереру и дерево
$add_tree_referer = ($ins_sum <= 0.01) ? ", a_t = a_t + 0" : "";
$db->Query("UPDATE ".$pref."_users_b SET money_b = money_b + $to_referer, from_referals = from_referals + '$to_referer' {$add_tree_referer} WHERE id = '$refid'");
# Статистика пополнений
$da = time();
$dd = $da + 60*60*24*15;
$db->Query("INSERT INTO ".$pref."_insert_money (user, user_id, money, serebro, date_add, date_del)
VALUES ('$user_name','$user_id','$sum','$serebro','$da','$dd')");
# Конкурс
$competition = new competition($db);
$competition->UpdatePoints($user_id, $sum);
#--------
/* $wmset = new wmset();
$marray = $wmset->GetSet($sum);
$a_t = intval($marray["t_a"]);
$b_t = intval($marray["t_b"]);
$c_t = intval($marray["t_c"]);
$d_t = intval($marray["t_d"]);
$e_t = intval($marray["t_e"]);
$db->Query("UPDATE ".$pref."_users_b SET a_t = a_t + '$a_t', b_t = b_t + '$b_t', c_t = c_t + '$c_t', d_t = d_t + '$d_t', e_t = e_t + '$e_t',
last_sbor = '$lsb' WHERE id = '$usid'"); */
# Обновление статистики сайта
$db->Query("UPDATE ".$pref."_stats SET all_insert = all_insert + '$sum' WHERE id = '1'");
$db->Query("UPDATE wmrush_pin SET status = 1 WHERE id = '$id_pin'");
echo '<center><div class="alert" id="good">Пинкод активирован! Вы получили '.$serebro.' серебра</div></center><BR />';
}else echo '<center><div class="alert" id="error">Пинкод уже активирован!</div></center><BR />';
}else echo '<center><div class="alert" id="error">Пин кода не существует</div></center><BR />';
}
?>
<form action="" method="post">
<table width="99%" border="0" align="center">
<tr>
<td>Введите Пинкод : </td>
<td><input type="text" name="pin" size="15"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="swap" value="Активировать Пин код" style="height: 30px; margin-top:10px;" /></td>
</tr>
</table>
</form>
<!--Powered By WmRush.name -->
</div>
<div class="clr"></div>
вот код