Hi Friends
For the php page
What is the database I get to work?
<?php
define('_IN_JOHNCMS', 1);
$rootpath = '';
$textl = 'ارسال هدیه';
require('incfiles/core.php');
$loc = "giftg";
require('incfiles/head.php');
if ($_GET['id'] && $user_id) {
$uh = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$_GET['id']."' "));
echo '<div class="mainbox"><div class="mainblok"><div class="nfooter"><h1>'.$uh['name'].' ارسال هدیه به </h1></div>';
echo '<div class="gmenu rrr"><font color="gray">تعداد را وارد کنید</font>
<form action="/send_gift.php?id='.$_GET['id'].'" method="post">ارسال گل
<input type="checkbox" name="gift" checked="checked" />4 <br/>
<br/><input type="submit" name="submit" value=" ارسال "></form>
<br/>توجه : شما در هر هدیه پنجاه امتیاز از دست خواهید داد
</div>';
echo '
<a href="/help/index.php?id=14"><div class="list2 rrr">هدیه جيست؟</div></a></div></div>
';
}
if(isset($_POST['submit']) && $_GET['id']) {
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$_GET['id']."' "));
$uzl = mysql_num_rows(mysql_query("SELECT * FROM `prof_like` WHERE `id_liked` = '" . $user['id'] . "'"));
$user['likes'] = $uzl;
$dd = mysql_query("SELECT * FROM `hzr` WHERE `id` = '" . $user['id'] . "'");
$user['hazer'] = mysql_num_rows($dd);
$hs = mysql_query("SELECT * FROM `gift` WHERE `from` = '" . $user['id'] . "'");
$user['hs'] = mysql_num_rows($hs);
$hr = mysql_query("SELECT * FROM `gift` WHERE `to` = '" . $user['id'] . "'");
$user['hr'] = mysql_num_rows($hr);
$user['emtiyaz'] = $user['blogs'] + $user['postchat'] + $user['postforum'] + $user['thanked'] + $user['hazer'] + $user['likes'] + $user['cre'];
$user['emtiyaz'] = $user['emtiyaz'] - ($user['hs'] * 50) + ($user['hr'] * 10) ;
$f = fmod($user['emtiyaz'],50);
$user['emtiyaz'] = ( $user['emtiyaz'] - $f ) / 50;
if ($user['emtiyaz'] > 1)
$xx = $user['emtiyaz'] ;
if((!empty($_POST['gift'])) && (1 < $xx || 1 == $xx) && $_GET['id'] != $user_id) {
$_POST['gift'] = 1;
$accept = "هدیه با موفقیت ارسال شد";
mysql_query("INSERT INTO `gift` SET `time` = '".time()."', `from` = '$user_id', `to` = '".$uh['id']."', `gift` = '".$_POST['gift']."' ");
mysql_query("INSERT INTO `giftn` SET `time` = '".time()."', `uz` = '".$uh['id']."', `tip` = '1' ");
} else {
if ($_POST['gift'] > $xx)
$error = "شما حداکثر $xx هدیه میتوانید بفرستید";
if ($_GET['id'] == $user_id)
$error = "شما نمیتوانید به خودتان هدیه بفرستید";
}
}
if ($error)
echo'<div class="rmenu ccc" style="margin:5px">'.$error.'</div>';
if ($accept)
echo'<div class="gmenu ccc" style="margin:5px">'.$accept.'</div>';
require('incfiles/end.php');
?>
<?php
define('_IN_JOHNCMS', 1);
$rootpath = '';
$textl = 'هدیه ها';
require('incfiles/core.php');
$loc = "gifg";
require('incfiles/head.php');
if ($_GET['to'] && $_GET['from']) {
} else {
if ($_GET['to'])
$uh = mysql_fetch_assoc(mysql_query("SELECT * FROM `gift` WHERE `to` = '".$_GET['to']."' ORDER BY `time` DESC LIMIT 1"));
if ($_GET['from'])
$uh = mysql_fetch_assoc(mysql_query("SELECT * FROM `gift` WHERE `from` = '".$_GET['from']."' ORDER BY `time` DESC LIMIT 1"));
if ($_GET['to']) {
$uu = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$_GET['to']."' "));
echo '<div class="mainbox"><div class="mainblok"><div class="nfooter"><h1>'.$uu['name'].' اخرين هدیه های دریافتی </h1></div>';
$pg = mysql_num_rows(mysql_query("SELECT * FROM `gift` WHERE `to` = '".$uh['to']."'"));
if ($_GET['to'] == $user_id) {
$hrr = mysql_query("SELECT * FROM `giftn` WHERE `uz` = '$user_id' AND `tip` = '1' ORDER BY `time` DESC LIMIT 100000");
$xdp = mysql_num_rows($hrr);
while ($giftn = mysql_fetch_assoc($hrr)) {
mysql_query("UPDATE `giftn` SET `tip` = '2' WHERE `uz` = '$user_id' AND `time` = '".$giftn['time']."'");
}
}
if ($pg > $kmess) {
echo ' <div class="topmenu" dir="rtl">';
echo functions::display_pagination('/gift.php?to='.$_GET['to'].'&', $start, $pg, $kmess);
echo '</div>';
}
echo '<center/><table width="98%" align="cernter" dir="rtl">';
$i = 0;
$pg = mysql_query("SELECT * FROM `gift` WHERE `to` = '".$uh['to']."' ORDER BY `time` DESC LIMIT $start,$kmess");
$i = $start;
while ($gift = mysql_fetch_array($pg)) {
$i = $i + 1;
$uu = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$gift['from']."' "));
echo $i % 2 ? '<tr><td width="1%"><div class="list2 rrr" dir="rtl">'.$i.'</div></td><td ><div class="list2 ccc" dir="rtl"><a href="/users/'.$uu['name'].'"><span style="color:'.$uu['color'].';">'.$uu['name'].'</span></a></div></td><td ><div class="list2 ccc" dir="rtl">'.jdate("y/m/d H:i",$gift['time']).'</div></td></tr>' : '<tr><td width="1%"><div class="list1 rrr" dir="rtl">'.$i.'</div></td><td ><div class="list2 ccc" dir="rtl"><a href="/users/'.$uu['name'].'"><span style="color:'.$uu['color'].';">'.$uu['name'].'</span></a></div></td><td ><div class="list2 ccc" dir="rtl">'.jdate("y/m/d H:i",$gift['time']).'</div></td></tr>';
}
}
if ($_GET['from'])
{
$uu = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$_GET['from']."' "));
echo '<div class="mainbox"><div class="mainblok"><div class="nfooter"><h1>'.$uu['name'].' اخرين هدیه های ارسالی </h1></div>';
$pg = mysql_num_rows(mysql_query("SELECT * FROM `gift` WHERE `from` = '".$uh['from']."'"));
if ($pg > $kmess) {
echo ' <div class="topmenu" dir="rtl">';
echo functions::display_pagination('/gift.php?from='.$_GET['from'].'&', $start, $pg, $kmess);
echo '</div>';
}
echo '<center/><table width="98%" align="cernter" dir="rtl">';
$i = 0;
$pg = mysql_query("SELECT * FROM `gift` WHERE `from` = '".$uh['from']."' ORDER BY `time` DESC LIMIT $start,$kmess");
$i = $start;
while ($gift = mysql_fetch_array($pg)) {
$i = $i + 1;
$uu = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$gift['to']."' "));
echo $i % 2 ? '<tr><td width="1%"><div class="list2 rrr" dir="rtl">'.$i.'</div></td><td ><div class="list2 ccc" dir="rtl"><a href="/users/'.$uu['name'].'"><span style="color:'.$uu['color'].';">'.$uu['name'].'</span></a></div></td><td ><div class="list2 ccc" dir="rtl">'.jdate("y/m/d H:i",$gift['time']).'</div></td></tr>' : '<tr><td width="1%"><div class="list1 rrr" dir="rtl">'.$i.'</div></td><td ><div class="list2 ccc" dir="rtl"><a href="/users/'.$uu['name'].'"><span style="color:'.$uu['color'].';">'.$uu['name'].'</span></a></div></td><td ><div class="list2 ccc" dir="rtl">'.jdate("y/m/d H:i",$gift['time']).'</div></td></tr>';
}
}
echo '</table></div></div>';
}
require('incfiles/end.php');
?>