Размер файла: 8.15Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729 */
/* Site: http://ticlove.ru */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/../_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/function.php'); ?>
<?php
if (!empty($_SESSION['auth_id']) && (intval($_POST['user_id']) == $_SESSION['auth_id']))
{
$page = isset($_GET['page']) ? $_GET['page'] : NULL;
switch($page)
{
case 'cated':
$sql = mysql_query("SELECT * FROM `q_gifts_cat` WHERE `id_gifts_cat` = '".intval($_POST['cat'])."' LIMIT 1;");
$arr_cat = mysql_fetch_array($sql);
echo '<div style="padding: 8px 0;">Категория: <strong>'.htmlspecialchars($arr_cat['name_cat'], ENT_QUOTES).'</strong></div>';
$q = mysql_query("SELECT * FROM `q_gifts_file` WHERE `id_gifts_cat` = '".intval($_POST['cat'])."';");
$i = 1;
while ($array = mysql_fetch_array($q))
{
?>
<a class="Agift" href="javascript:void(0)" onclick="javascript:GiftSend('<?php echo $array['id_gifts_file']; ?>')"><img src="/podarok/<?php echo $arr_cat['name_dir']; ?>/<?php echo $array['name_gift']; ?>.png" alt="" /></a>
<?php
if ($i == 4)
{
echo '<br/>';
$i = 0;
}
else echo ' ';
$i++;
}
break;
case 'send':
$sql = mysql_query("SELECT * FROM `q_gifts_file` WHERE `id_gifts_file` = '".intval($_POST['gift'])."' LIMIT 1;");
$arr_gift = mysql_fetch_array($sql);
$sql = mysql_query("SELECT * FROM `q_gifts_cat` WHERE `id_gifts_cat` = '".$arr_gift['id_gifts_cat']."' LIMIT 1;");
$arr_cat = mysql_fetch_array($sql);
$sql = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".intval($_POST['user_uid'])."' LIMIT 1;");
$arr_user = mysql_fetch_array($sql);
?>
<div>
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<img src="/podarok/<?php echo $arr_cat['name_dir']; ?>/<?php echo $arr_gift['name_gift']; ?>.png" alt="" />
</td>
<td>
<img src="/images/gift-send.gif" alt="" />
</td>
<td>
<?php
if (!empty($arr_user['avatar'])) {
$avatar = str_replace('_s', '_p', $arr_user['avatar']);
echo '<a href="user.php?id='.$arr_user['id_user'].'">';
echo '<img class="'.($arr_user['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor').'" src="'.DIR_PHOTOS.'/'.$arr_user['id_user'].'/'.$avatar.'" alt="" />';
}
else echo '<img class="'.($arr_user['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor').'" src="/images/no_photo_norm.png" alt="" />';
echo '</a>';
?>
</td>
</tr>
</table>
<div>Стоимость подарка <span class="red"><?php echo $arr_gift['cost']; ?></span> монет</div>
<div style="text-align: center; color: #ff0000; padding: 10px 0;" id="GiftSendGoLoad"></div>
</div>
<div>
<script type="text/javascript">
jQuery.fn.maxlength = function(options) {
var settings = jQuery.extend({
maxChars: 70, // максимальное колличество символов
leftChars: "символов" // текст в конце строки информера
}, options);
return this.each(function() {
var me = $(this);
var l = settings.maxChars;
me.bind('keydown keypress keyup',function(e) {
if(me.val().length>settings.maxChars) me.val(me.val().substr(0,settings.maxChars));
l = settings.maxChars - me.val().length;
me.next('span').html(l + ' ' + settings.leftChars);
});
me.after('Осталось <span class="maxlen">' + settings.maxChars + ' ' + settings.leftChars + '</span>');
});
};
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#text").maxlength();
});
</script>
<div style="padding-bottom: 5px;">
Текст к подарку (необязательно):<br/>
<textarea class="textarea" id="text" style="width: 98%; max-width: 98%; min-width: 98%; height: 100px; padding: 3px;"></textarea>
</div>
<div style="padding-bottom: 5px;">
<input type="submit" class="submit" onclick="javascript:GiftSendGo('<?php echo intval($_POST['gift']); ?>')" value="Отправить подарок" />
</div>
</div>
<div class="clear"></div>
<?php
break;
case 'go':
$sql = mysql_query("SELECT * FROM `q_gifts_file` WHERE `id_gifts_file` = '".intval($_POST['gift'])."' LIMIT 1;");
$arr_gift = mysql_fetch_array($sql);
$sql = mysql_query("SELECT `balans` FROM `q_users` WHERE `id_user` = '".$_SESSION['auth_id']."' LIMIT 1;");
$balans = mysql_result($sql, 0);
if ($arr_gift['cost'] > $balans) $str = 1;
else
{
$msg = trim($_POST['text']);
if (!empty($msg))
{
$msg = iconv('utf-8', 'windows-1251', $msg);
if (strlen($msg) > 70) $msg = substr($msg, 0, 70);
$msg = iconv('windows-1251', 'utf-8', $msg);
}
if (mysql_query("UPDATE `q_users` SET `balans` = `balans` - '".$arr_gift['cost']."' WHERE `id_user` = '".$_SESSION['auth_id']."';") && mysql_query("INSERT INTO `q_gifts` (`user_id`, `send_user_id`, `gift_id`, `text`, `date`) VALUES ('".$_SESSION['auth_id']."', '".intval($_POST['user_uid'])."', '".intval($_POST['gift'])."', '".function_sql($msg)."', '".time()."');")) $str = 2;
}
echo $str;
break;
default:
$sql = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".intval($_POST['user_uid'])."' LIMIT 1;");
$user_array = mysql_fetch_array($sql);
?>
<div class="box_bg" style="width: 650px;">
<div class="box_title">
<div class="left" style="padding-top: 2px; padding-left: 10px;">Подарок для <?php echo htmlspecialchars($user_array['name'], ENT_QUOTES); ?></div><div class="box_close right b-modal_close arcticmodal-close"></div>
</div>
<div class="clear"></div>
<div class="box_conetnt">
<div style="padding: 10px;">
<div id="GiftSendGoOk">
<div id="GiftSend">
<div style="width: 600px;">
<div style="margin-bottom: 10px;">Подарки – это лучший способ выразить симпатию и познакомиться. В нашей галерее есть подарки на любой вкус и настроение. Отправьте подарок и вас обязательно заметят!</div>
<div style="float: left; margin-bottom: 5px; width: 200px;">
<div style="padding: 8px 0;"><strong>Выберите категорию:</strong></div>
<?php $q = mysql_query("SELECT * FROM `q_gifts_cat` ORDER BY `id_gifts_cat`;"); ?>
<?php $i = 1; ?>
<?php while ($array = mysql_fetch_array($q)) { ?>
<div style="margin-bottom: 5px;"><?php echo $i; ?>)
<a href="javascript:void(0)" onclick="javascript:GiftsCat('<?php echo $array['id_gifts_cat']; ?>')"><?php echo htmlspecialchars($array['name_cat'], ENT_QUOTES); ?></a>
</div>
<?php $i++; ?>
<?php } ?>
</div>
<div style="float: right; margin-bottom: 5px; width: 400px;">
<div style="text-align: center;" id="GiftStatutLoad">
<script type="text/javascript">GiftsCat('1');</script>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="box_footer">
<div class="right"><button class="submit_red b-modal_close arcticmodal-close">Отмена</button></div>
</div>
<div class="clear"></div>
</div>
<?php
break;
}
}
?>