View file user/gift/gift.php

File size: 3.55Kb
<?php
require( '../../sys/inc/core.php' );
only_reg();
$width = ( $webbrowser == 'web' ? '100' : '70' );
$post  = db::fetch("SELECT id,status,coment,id_gift,id_ank,id_user,time FROM `gifts_user` WHERE `id` = '" . intval( $_GET['id'] ) . "' LIMIT 1", ARRAY_A);
if ( !$post['id'] ) {
    header( "Location: /index.php?" );
}
$gift   = db::fetch("SELECT id,name FROM `gift_list` WHERE `id` = '" . $post['id_gift'] . "' LIMIT 1", ARRAY_A);
$ank    = get_user( $post['id_user'] );
$anketa = get_user( $post['id_ank'] );
if ( $post['status'] == 0 && isset( $_GET['ok'] ) && $user['id'] == $ank['id'] ) {
    db::query("UPDATE `gifts_user` SET `status` = '1' WHERE `id` = '$post[id]' LIMIT 1");
    db::query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`) VALUES ('$user[id]', '$anketa[id]', '$gift[id]', 'ok_gift', '$time')");
    $_SESSION['message'] = 'Подарок от ' . $anketa['nick'] . ' принят';
    header( "Location: gift.php?id=$post[id]" );
    exit;
}
if ( $post['status'] == 0 && isset( $_GET['no'] ) && $user['id'] == $ank['id'] ) {
    db::query("DELETE FROM `gifts_user` WHERE `id` = '$post[id]' LIMIT 1");
    db::query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`) VALUES ('$user[id]', '$anketa[id]', '$gift[id]', 'no_gift', '$time')");
    $_SESSION['message'] = 'Подарок от ' . $anketa['nick'] . ' отклонен';
    header( "Location: ?new" );
    exit;
}
if ( isset( $_GET['delete'] ) && ( $ank['id'] == $user['id'] || $user['level'] > 2 ) ) {
    db::query("DELETE FROM `gifts_user` WHERE `id` = '$post[id]' LIMIT 1");
    $_SESSION['message'] = 'Подарок от ' . $anketa['nick'] . ' удален';
    header( "Location: index.php" );
    exit;
}
$set['title'] = 'Подарок ' . $ank['nick'] . ' ' . htmlspecialchars( $gift['name'] );
include_once '../../sys/inc/thead.php';
title();
aut();
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a> | <a href="/user/gift/index.php?id=' . $ank['id'] . '">Подарки</a> | <b>' . htmlspecialchars( $gift['name'] ) . '</b>';
echo '</div>';
echo '<div class="nav2">';
echo '<img src="/sys/gift/' . $gift['id'] . '.png" style="max-width:' . $width . 'px;" alt="*" /><br />';
echo htmlspecialchars( $gift['name'] ) . ' :: ' . vremja( $post['time'] ) . '<br />';
echo '</div>';
echo '<div class="nav1">';
echo status( $anketa['id'] ), group( $anketa['id'] ), '<a href="/info.php?id=' . $anketa['id'] . '">' . $anketa['nick'] . '</a>', medal( $anketa['id'] ), online( $anketa['id'] ) . '<br />';
if ( $post['coment'] )
    echo 'Комментарий: <br />' . output_text( $post['coment'] );
echo '</div>';
if ( $ank['id'] == $user['id'] ) {
    echo '<div class="nav2">';
    if ( $post['status'] == 0 ) {
        echo '<center><img src="/style/icons/ok.gif" alt="*" /> <a href="?id=' . $post['id'] . '&amp;ok">Принять</a> ';
        echo '<img src="/style/icons/delete.gif" alt="*" /> <a href="?id=' . $post['id'] . '&amp;no">Отказаться</a></center>';
    } else {
        echo '<img src="/style/icons/delete.gif" alt="*" /> <a href="/user/gift/gift.php?id=' . $post['id'] . '&amp;delete">Удалить</a>';
    }
    echo '</div>';
}
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a> | <a href="/user/gift/index.php?id=' . $ank['id'] . '">Подарки</a> | <b>' . htmlspecialchars( $gift['name'] ) . '</b>';
echo '</div>';
include_once '../../sys/inc/tfoot.php';
?>