Размер файла: 2.97Kb
<?php
require_once $_SERVER['DOCUMENT_ROOT']."/includes/start.php";
if(isset($_SESSION['auth']) and $_SESSION['auth']==1){
echo $_up; echo '<div class="list">';
//$friends = mysql_query ("select count(id) as num from friends where id_user='".$usr['id']."';");
//$friends_data = mysql_fetch_array($friends);
//$cf = $friends_data["num"];
//echo '<a href="?show=friends"><b>Друзья</b></a> (<b>'.$cf.'</b>)<br>';
echo '<b><a href="?show=changePonC">Обмен</a>/ <a href="?show=present_money">Перевод</a> (поинты:кредиты)</a></b><br>';
//if($_GET['show']=='friends'){
//echo '<br>';
//$page=isset($_GET['p'])?$_GET['p']:1;
//$friends=mysql_query("SELECT * FROM `friends` WHERE `id_user`=$usr[id] ORDER BY `id_user` LIMIT ".(($page-1)*10).", 10");
//$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE id_user=$usr[id]"), 0);
//if($total==0){
//echo 'У вас нет друзей :('; exit;
//}
//while($fdata=mysql_fetch_array($friends)){
//$friend_info = mysql_fetch_assoc(mysql_query("SELECT `id`,`login`,`rtime` FROM `users` WHERE `id`='$fdata[id_friend]'")); //запрос на логин юзера
//if( time( ) - 300 < $friends_info['rtime'] ){
//$status_on_site = 'online';
//}else{
//$status_on_site = 'был в чате: '.date("d.m в H:i",$friend_info['rtime']).'<br/>';
//}
//echo '<a href="/u'.$friend_info['id'].'">'.$friend_info['login'].'</a> [ '.$status_on_site.' ]<br>';
//}
//nav($count_pres, $page, '?id='.$id.'&', 10); //навигация
//}
if($_GET['show']=='changePonC'){
echo '<br><b>Обменять поинты на кредиты:</b><br>
<form action="?go=pointsONcredits" method="post">
<table width="100%">
<tr><td width="50%" valign="top">Поинтов:</td><td valign="top"><b>'.$usr['points'].'</b></td></tr>
<tr><td width="50%" valign="top">Кредитов:</td><td valign="top"><b>'.$usr['credits'].'</b></td></tr>
<tr><td width="50%" valign="top">Курс обмена (поинтов на кредиты):</td><td valign="top"><b>1000:1</b></td></tr>
<tr><td width="50%" valign="top">Сколько получить кредитов:</td><td valign="top"><input name="credits"/></td></tr>
</table>
<input type="submit" value="Обменять"/>
</form><br>';
}
echo '<a href="presents.php?"><b>Подарки</b></a><br>';
echo '</div>'; echo $_down;
if($_GET['go']=="pointsONcredits"){
$credits=$_POST['credits'];
if(empty($credits)){
header ("Location: ?show=changePonC"); exit;
}
if(eregi("[^0-9]" , $credits)){
header ("Location: ?show=changePonC"); exit;
}
$credits_x=$credits*1000;
if($usr['points']<$credits_x){
header ("Location: ?show=changePonC"); exit;
}
mysql_query("update users set points=points-$credits_x where id='$usr[id]' limit 1");
mysql_query("update users set credits=credits+$credits where id='$usr[id]' limit 1");
header ("Location: ?show=changePonC"); exit;
}
}else{
header ("Location: ?"); exit;
}
?>