Файл: setk/adm_panel/present.php
Строк: 137
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
user_access('adm_set_sys',null,'index.php?'.SID);
adm_check();
$width = ($webbrowser == 'web' ? '200' : '70'); // Размер подарков при выводе в браузер
$suite = 'http://'.$_SERVER['HTTP_HOST']; // Сайт
if(isset($_GET['female']) && $_GET['female']<=2 && $_GET['female']>='0')
{
$female=intval($_GET['female']);
$set['title']='Рассылка подарков'.($_GET['female']=='0'?'-девушки':NULL).($_GET['female']=='1'?'-парни':NULL).($_GET['female']=='2'?'-всем':NULL);
include_once '../sys/inc/thead.php';
title();
aut();
if (isset($_GET['gift']) && isset($_GET['category']) && isset($_GET['female']) && $_GET['female']<=2 && $_GET['female']>='0')
{
// Категория
$category = mysql_fetch_assoc(mysql_query("SELECT * FROM `gift_categories` WHERE `id` = '" . intval($_GET['category']) . "' LIMIT 1"));
// Подарок
$gift = mysql_fetch_assoc(mysql_query("SELECT * FROM `gift_list` WHERE `id` = '" . intval($_GET['gift']) . "' LIMIT 1"));
if (!$gift)
{
$_SESSION['message'] = 'Нет такого подарка';
header("Location: ?female=".$_GET['female']."");
exit;
}
if (isset($_GET['ok']) )
{
$gift_msg = my_esc($_POST['msg']);
if(strlen2($gift_msg)>50)$err='Не больше 50 сиволов ';
if(!isset($err)){
if($female=='0') {
$q=mysql_query("SELECT * FROM `user` WHERE `pol`='0' AND `id`!='$user[id]'");
while($row = mysql_fetch_assoc($q)) {
mysql_query("INSERT INTO `gifts_user` (`id_user`, `id_ank`, `id_gift`, `coment`, `time`) values('$row[id]', '1', '$gift[id]', '$gift_msg', '$time')");
$uid=mysql_insert_id();
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$row['id']."', 'Вам подарок от администрации от ".$suite." [url=".$suite."/user/gift/gift.php?id=".$uid."]Посмотреть[/url]', '".$time."')");
}
}
/////////////////////////////////////////////
if($female=='1') {
$q=mysql_query("SELECT * FROM `user` WHERE `pol`='1' AND `id`!='$user[id]'");
while($row = mysql_fetch_assoc($q)) {
mysql_query("INSERT INTO `gifts_user` (`id_user`, `id_ank`, `id_gift`, `coment`, `time`) values('$row[id]', '1', '$gift[id]', '$gift_msg', '$time')");
$uid=mysql_insert_id();
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$row['id']."', 'Вам подарок от администрации от ".$suite." [url=".$suite."/user/gift/gift.php?id=".$uid."]Посмотреть[/url]', '".$time."')");
}
}
/////////////////////////////////////////
if($female=='2') {
$q=mysql_query("SELECT * FROM `user` WHERE `id`!='$user[id]'");
while($row = mysql_fetch_assoc($q)) {
mysql_query("INSERT INTO `gifts_user` (`id_user`, `id_ank`, `id_gift`, `coment`, `time`) values('$row[id]', '1', '$gift[id]', '$gift_msg', '$time')");
$uid=mysql_insert_id();
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$row['id']."', 'Вам подарок от администрации от ".$suite." [url=".$suite."/user/gift/gift.php?id=".$uid."]Посмотреть[/url]', '".$time."')");
}
}
////////////////////////////////////////////
$_SESSION['message'] = 'Подарки отправлены!';
header("Location: present.php");
exit;
}
}
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="present.php?female='.$_GET['female'].'">Категории</a> | <a href="present.php?female='.$_GET['female'].'&category=' . $category['id'] . '">' . htmlspecialchars($category['name']) . '</a> | <b>' . htmlspecialchars($gift['name']) . '</b><br />';
echo '</div>';
echo '<form action="present.php?female='.$_GET['female'].'&present&category=' . $category['id'] . '&gift=' . $gift['id'] . '&ok" method="post">';
echo '<div class="mess">';
err();
echo '<b>Вы выбрали этот подарок</b> </br> <img src="/sys/gift/' . $gift['id'] . '.png" style="max-width:' . $width . 'px;" alt="*" /> ';
echo '<br />';
echo '</div>';
echo '<div class="mess">';
echo $tPanel . '<textarea type="text" name="msg" value=""/></textarea><br />';
echo '<input class="submit" type="submit" value="Разослать" /> ';
echo '</br><small>* Необязательно для заполнения</small></div>';
echo "</form>";
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="present.php?female='.$_GET['female'].'">Категории</a> | <a href="present.php?female='.$_GET['female'].'&category=' . $category['id'] . '">' . htmlspecialchars($category['name']) . '</a> | <b>' . htmlspecialchars($gift['name']) . '</b><br />';
echo '</div>';
}
else
/*
==================================
Вывод подарков
==================================
*/
if (isset($_GET['category']))
{
// Категория
$category = mysql_fetch_assoc(mysql_query("SELECT * FROM `gift_categories` WHERE `id` = '" . intval($_GET['category']) . "' LIMIT 1"));
if (!$category)
{
$_SESSION['message'] = 'Нет такой категории';
header("Location: ?female=".$_GET['female']."");
exit;
}
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="present.php?female='.$_GET['female'].'">Категории</a> | <b>' . htmlspecialchars($category['name']) . '</b><br />';
echo '</div>';
// Список подарков
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `gift_list` WHERE `id_category` = '$category[id]'"),0);
if ($k_post == 0)
{
echo '<div class="mess">';
echo 'Нет подарков';
echo '</div>';
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT name,id,money FROM `gift_list` WHERE `id_category` = '$category[id]' ORDER BY `id` LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
/*-----------зебра-----------*/
if ($num==0){
echo '<div class="nav1">';
$num=1;
}
elseif ($num==1){
echo '<div class="nav2">';
$num=0;
}
/*---------------------------*/
echo '<img src="/sys/gift/' . $post['id'] . '.png" style="max-width:' . $width . 'px;" alt="*" /><br />';
echo '<a href="present.php?female='.$_GET['female'].'&category=' . $category['id'] . '&gift=' . $post['id'] . '"><b>' . htmlspecialchars($post['name']) . '</b></a> ';
echo '</div>';
}
if ($k_page>1)str('present.php?female='.$_GET['female'].'&category=' . intval($_GET['category']) . '&',$k_page,$page); // Вывод страниц
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="present.php?female='.$_GET['female'].'"> Категории </a> | <b>' . htmlspecialchars($category['name']) . '</b><br />';
echo '</div>';
}
else
/*
==================================
Вывод категорий
==================================
*/
{
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <b>Категории</b>';
echo '</div>';
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `gift_categories`"),0);
if ($k_post == 0)
{
echo '<div class="mess">';
echo 'Нет категорий';
echo '</div>';
}
$q = mysql_query("SELECT name,id FROM `gift_categories` ORDER BY `id`");
while ($post = mysql_fetch_assoc($q))
{
/*-----------зебра-----------*/
if ($num==0){
echo '<div class="nav1">';
$num=1;
}
elseif ($num==1){
echo '<div class="nav2">';
$num=0;
}
/*---------------------------*/
echo '<img src="/style/themes/default/loads/14/dir.png" alt="*" /> <a href="present.php?female='.$_GET['female'].'&category=' . $post['id'] . '">' . htmlspecialchars($post['name']) . '</a> ';
echo '(' . mysql_result(mysql_query("SELECT COUNT(id) FROM `gift_list` WHERE `id_category` = '$post[id]'"),0) . ')';
echo '</div>';
}
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <b>Категории</b>';
echo '</div>';
}
echo "<div class='foot'>n";
if (user_access('adm_panel_show'))
echo "«<a href='/adm_panel/present.php'>Назад</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
$set['title']='Рассылка подарков';
include_once '../sys/inc/thead.php';
title();
aut();
echo '<div class="mess"><b>Рассылка :</b></div>
<div class="nav1"><img src="/style/icons/man.png" alt=""/> <a href="?female=1">Парни</a></br>
<img src="/style/icons/woman.png" alt=""/> <a href="?female=0">Девушки</a></br>
<img src="/style/icons/activ.gif" alt=""/> <a href="?female=2">Всем</a></br>
</div>';
echo "<div class='foot'>n";
if (user_access('adm_panel_show'))
echo "«<a href='/adm_panel/'>В админку</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
?>