Файл: user/gift.php
Строк: 406
<?php
require_once '../incfiles/core.php';
require_once '../incfiles/func.php';
require_once '../incfiles/auth.php';
require_once '../incfiles/user.php';
if (empty($user_id)) {go(URL.'/');}
if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
$id = abs(intval($_GET['id']));
$result = mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true) $arr_user = mysql_fetch_array($result);
else go(URL);
}
else go(URL);
$act = htmlentities(trim($_GET['act']));
if ($window == true)echo '<div class="title"><div class="for_pc right"><a href="" onclick="Window.Close(); return false"><img src="'.URL.'/design/img/del.png"/></a></div><a class="title_a_hover" href="'.URL.'/?id='.$id.'" onclick="Page.Go(this.href); return false">'.$arr_user['name'].' '.$arr_user['surname'].'</a></div>';
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
$price =40;
if($user['money']<$price)
{
echo'<div class="block">';
echo''.lang('У вас не достаточно средств нужно <b>'.$price.'</b> монет, у вас <b>'.$user['money'].'</b> монет','У вас достатньо монет,потрібно <b>'.$price.'</b> у вас зараз <b>'.$user['money'].'</b>').'';
echo'</div>';
require_once '../incfiles/foot.php';
}
if($act !=info && $act !=info_user && $act !=action)
{
echo '<div class="for_pc"><div class="title">
<a '. ($act == ''?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&" onclick="Window.Open(this.href); return false">Дружба</a>
<a '. ($act == love?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=love" onclick="Window.Open(this.href); return false">Романтика</a>
<a '. ($act == birthday?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=birthday" onclick="Window.Open(this.href); return false">'.lang('День Рождения','День народження').'</a>
<a '. ($act == car?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=car" onclick="Window.Open(this.href); return false">'.lang('Машини','Машини').'</a>
<a '. ($act == monster?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=monster" onclick="Window.Open(this.href); return false">'.lang('Монстры','Монстри').'</a>
<a '. ($act == pasha?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=pasha" onclick="Window.Open(this.href); return false">'.lang('Пасха','Пасха').'</a>
<a '. ($act == girl?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=girl" onclick="Window.Open(this.href); return false">'.lang('Девушки','Дівчата').'</a>
</div></div>';
echo '<div class="for_mobile"><div class="title">
<a '. ($act == ''?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&" onclick="Page.Go(this.href); return false;">Дружба</a>
<a '. ($act == love?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=love" onclick="Page.Go(this.href); return false;">Романтика</a>
<a '. ($act == birthday?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=birthday" onclick="Page.Go(this.href); return false;">'.lang('День Рождения','День народження').'</a>
<a '. ($act == car?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=car" onclick="Page.Go(this.href); return false;">'.lang('Машини','Машини').'</a>
<a '. ($act == monster?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=monster" onclick="Page.Go(this.href); return false;">'.lang('Монстры','Монстри').'</a>
<a '. ($act == pasha?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=pasha" onclick="Page.Go(this.href); return false;">'.lang('Пасха','Пасха').'</a>
<a '. ($act == girl?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&act=girl" onclick="Page.Go(this.href); return false;">'.lang('Девушки','Дівчата').'</a>
</div></div>';
}
switch($act)
{
default:
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/friends'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=friends" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/friends/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'love':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/love'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=love" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/love/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'birthday':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/birthday'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=birthday" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/birthday/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'car':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/car'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=car" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/car/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'monster':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/monster'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=monster" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/monster/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'pasha':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/pasha'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=pasha" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/pasha/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'girl':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
if ($handle = opendir(HOME.'/design/gifts/girl'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
$COUNT_FILES_ON_PAGE = 140;
$COUNT_FIELES = count($files);
$COUNT_PAGES = intval($COUNT_FIELES / $COUNT_FILES_ON_PAGE);
if (empty($_GET['p']) || $_GET['p'] < 0 || $_GET['p'] > $COUNT_PAGES || !intval($_GET['p']))
$_GET['p'] = 0;
for($i = 0; $i <= $COUNT_PAGES; ++$i)
{
}
$START = intval($_GET['p']) * $COUNT_FILES_ON_PAGE;
$END = $START + $COUNT_FILES_ON_PAGE;
$z = 1;
echo '<table style="width:100%;" cellpadding="0" cellspacing="0"><tr>';
for($i = $START; $i < $END; ++$i)
{
if (key_exists($i, $files))
{
$name = mb_substr($files[$i], 0, -4, 'UTF-8');
echo'<td style="width:50px;"><a href="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$name.'&act=action&folder=girl" onclick="Window.Open(this.href); return false"><img src="'.URL.'/resize.php?img=design/gifts/girl/'.$files[$i].'&width=50&height=0" alt="img" title="1 Coins"/> </a> '. ($z++ % 6 == 0 ? '</tr><tr>' : '');
}
}
echo '</tr></table>';
break;
case 'action':
if (!empty($_GET['g']) && is_numeric($_GET['g']))
{
$g = abs(intval($_GET['g']));
}
else go(URL);
if (!empty($_GET['folder']))
{
$folder = check($_GET['folder']);
if (file_exists(HOME.'/design/gifts/'.$folder.'/' . $g . '.jpg'))
{
$folder = check($_GET['folder']);
$format='.jpg';
}elseif (file_exists(HOME.'/design/gifts/'.$folder.'/' . $g . '.png'))
{
$folder = check($_GET['folder']);
$format='.png';
}else go(URL);
}else go(URL);
if (!empty($g) && $id != $user_id)
{
require_once 'handler/new_gift.php';
echo'<center><img src="'.URL.'/resize.php?img=design/gifts/'.$folder.'/'.$g.''.$format.'&width=150&height=0" alt="img" title="'.$price.'"/> </a></center>';
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
$('#form_content').html('');
Page.Loading('start');
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
$('.content').html(response);
Page.Loading('stop');
}
}
});
});
});
</script>
<?
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
echo user_access_page($arr_user);
// echo '<div class="title"><a '. ($act == true?'class="title_a_hover"':'') .' href="'.URL.'/user/gift.php?id='.$id.'&" onclick="Window.Open(this.href); return false">Назад</a></div></div>';
echo '<div class="block">
<form id="form" action="'.URL.'/user/gift.php?id='.$arr_user['id'].'&g='.$g.'&act=action&folder='.$folder.'" method="post">
<input id="textarea" name="ask" class="input" maxlength="500" value=""/>
<a id="checkbox_on" href="" onclick="Form.Checkbox_off(); return false"><img style="margin:3px;" src="'.URL.'/design/img/checkbox_on.gif"/> '.lang('Анонимно','Анонімно').'</a>
<a id="checkbox_off" href="" style="display:none;" onclick="Form.Checkbox_on('anonim'); return false"><img style="margin:3px;" src="'.URL.'/design/img/checkbox_off.gif"/> '.lang('Анонимно','Анонімно').'</a>
<div id="checkbox"><input type="hidden" name="anonim" value="1"/></div>
<div class="button2"><input class="button" type="submit" value="'.lang('Подарить','Подaрувати').'" /></div> ';
echo '</form></div>';
}else {
echo'<center><div class="block">'.lang('Вы не можете дарить себе подарки','Ви не можете дарувати собі подарунки').'</div></center>';
}
break;
case 'info':
if (!empty($_GET['g']) && is_numeric($_GET['g']))
{
$g = abs(intval($_GET['g']));
}else go(URL);
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
echo '<div class="block">';
$ctrl = mysql_query("SELECT * FROM presents WHERE whom = '$id' AND id = '$g' LIMIT 1");
if (mysql_num_rows($ctrl) == false)
{
header('location: /' . $id);
}
else
{
$is = mysql_fetch_assoc($ctrl);
echo '<center><img src="resize.php?img='.$is['path'].'&width=100&height=0" alt="."/></center><br/>';
echo (!empty($is['msg'])) ? '<div class="status">'.text_view($is['msg']) . '</div>' : '';
if (!empty($is['who']))
{
$result = mysql_query("SELECT * FROM `users` WHERE `id` = '".$is['who']."' LIMIT 1");
if (mysql_num_rows($result) == true) $r_user = mysql_fetch_array($result);
$nome = $r_user['name']. $r_user['surname'];
echo ''.user_name($r_user['id']).'</br>';
}
else echo '' . lang('Анонимный подарок','Анонімний подарунок') . '<br/>';
echo '<div class="for_pc right">'.vtime($is['time']).'</div></br>';
if ($id == $user['id'])
{
echo '<a class="button3" href="'.URL.'/user/gift.php?id='.$id.'&g='.$is['id'].'&act=delete" onclick="Window.Open(this.href); return false">' . lang('Удалить','Видалити') . '</a>';
}
}
echo '</div>';
break;
case 'info_user':
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Подарки','Подарунки');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `presents` WHERE `whom` = '".$id."'"),0);
if ($all == true)
{
$cp = ceil($all/90);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*10-10;
$res = mysql_query("SELECT * FROM `presents` WHERE `whom` = '".$id."' ORDER by `time` DESC LIMIT $start,10");
while ($is = mysql_fetch_array($res))
{
echo '<a class="block" href="'.URL.'/user/gift.php?id='.$id.'&g='.$is['id'].'&act=info" onclick="Window.Open(this.href); return false">' . showgift($is['path'], 45 ,45) . '</a></div>';
}
navi_window($p,$cp,''.URL.'/user/gift.php?id='.$id.'&g='.$is['id'].'&act=info_user');
}
break;
case 'delete':
if (!empty($_GET['g']) && is_numeric($_GET['g']))
{
$g = abs(intval($_GET['g']));
}else go(URL);
if ($id == $user['id'])
{
mysql_query("DELETE FROM `presents` WHERE `id` = '".$g."'");
go(URL);
}
break;
}
require_once '../incfiles/foot.php';
?>