<?php
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/user.php';
only_reg();
err();
$set['title']='Граффити на стену';
include_once '../../sys/inc/thead.php';
title();
aut();

if (!isset($_POST['uid']) || !is_numeric($_POST['uid']))
{
header("Location: select.php");
exit;
}

$x = intval($_POST['x']);
$y = intval($_POST['y']);
$fon = htmlspecialchars(trim($_POST['fon']));
$font = htmlspecialchars(trim($_POST['font']));
$fsize = intval($_POST['fsize']);
$rgbr = intval($_POST['rgbr']);
$rgbg = intval($_POST['rgbg']);
$rgbb = intval($_POST['rgbb']);
$textx = intval($_POST['textx']);
$texty = intval($_POST['texty']);
$arrg = intval($_POST['arrg']);
$text = htmlspecialchars(trim($_POST['text']));
$pp = htmlspecialchars(trim($_POST['pp']));
$uid = intval($_POST['uid']);
$ank = get_user($uid);
$sh = intval($_POST['sh']);
$timgf = htmlspecialchars($_POST['timg']);
$timg = md5($timgf);

if (isset($_POST['confirm_ok']))
{

$timg = htmlspecialchars($_POST['timg']);

$image = "/apps/graffity/get/$timg.png";

if (isset($_POST['msgotp']))
{
$msgotp = "".my_esc($_POST['msgotp'])."";
}
else
{
$msgotp = "";
}

$msgadd = "[grafimg]".$image."[/grafimg] [br] ".$msgotp."";

$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$user[id]'");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));

if ($user['pol']==1)
{
$ost = "разместил";
}
else
{
$ost = "разместила";
}

$msg_lenta="Ваш друг[b] $user[nick] [/b] ".$ost." граффити на [url=http://xlofes.ru/wall/?id=$ank[id]] стену [/url] пользователя [b]$ank[nick][/b]";

mysql_query("INSERT INTO `lenta` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$msg_lenta', '$time')"); 
}

if (isset($user) && $user['id']!=$ank['id']){

if ($user['pol']==1)
{
$ost = "разместил";
}
else
{
$ost = "разместила";
}

$msg2="[b]$user[nick][/b] ".$ost." граффити на Вашей [url=http://xlofes.ru/wall/index.php?id=$ank[id]]стене[/url]";
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msg2', '$time')");
}

mysql_query("INSERT INTO `us_wall` (id_user, id_user_adm, time, msg, type) values('$user[id]', '$ank[id]', '".time()."', '".$msgadd."', 'graffity')");

msg("Граффити успешно отправлено");
echo "<div class='p_t'>&raquo; <a href='/info.php?id=$ank[id]'>На страницу $ank[nick]</a></div>";
include_once '../../sys/inc/tfoot.php';
exit;
}

if (isset($_POST['confirm_no']))
{
header("Location: select.php");
exit;
}

if (isset($_GET['confirm']))
{
if (isset($_POST['msgwithgraffity']))
{
$msg = $_POST['msgwithgraffity'];
}

echo "<div class='mdlc2'>
<span>Проверка безопасности</span>
<br /></div><div class='menu'> 
<table class='post'><tr><td rowspan='2' style='width:48px'><img src='icon.png' alt='' width='48' height='48' /></td><td>
Приложение Граффити на стену запрашивает отправку записи на стену ";
echo GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
echo "</td></tr><tr><td>
Разрешить отправку?</td></tr></table>";

echo '<div class="rowup">';
$timg = htmlspecialchars($_POST['timg']);

echo '<img src="/apps/graffity/get/'.$timg.'.png" alt="" />';
if (isset($_POST['msgwithgraffity']))
{
echo "<br /><span style='color:$user[color]'>".esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($msg))))))))."</span>";
}
echo "</div>";

echo '<form action="add.php?'.$passgen.'" method="post">
<input type="hidden" name="x" value="'.$x.'">
<input type="hidden" name="y" value="'.$y.'">
<input type="hidden" name="fon" value="'.$fon.'">
<input type="hidden" name="font" value="'.$font.'">
<input type="hidden" name="fsize" value="'.$fsize.'">
<input type="hidden" name="rgbr" value="'.$rgbr.'">
<input type="hidden" name="rgbg" value="'.$rgbg.'">
<input type="hidden" name="rgbb" value="'.$rgbb.'">
<input type="hidden" name="textx" value="'.$textx.'">
<input type="hidden" name="texty" value="'.$texty.'">
<input type="hidden" name="arrg" value="'.$arrg.'">
<input type="hidden" name="text" value="'.$text.'">
<input type="hidden" name="pp" value="'.$pp.'">
<input type="hidden" name="uid" value="'.$ank['id'].'">
<input type="hidden" name="timg" value="'.$timg.'" />
<input type="hidden" name="sh" value="'.intval($_POST['sh']).'" />';
if (isset($_POST['msgwithgraffity']))
{

$msgp = htmlspecialchars($_POST['msgwithgraffity']);

echo '<input type="hidden" name="msgotp" value="'.$msgp.'" />';

}
echo '<input type="submit" name="confirm_ok" value="Подтвердить" /> 
<input type="submit" name="confirm_no" value="Отклонить" />
</form>';

echo "</div><div class='p_t'>&raquo; <a href='/info.php?id=$ank[id]'>На страницу $ank[nick]</a></div>";

echo "</div>";
include_once '../../sys/inc/tfoot.php';
exit();
}
echo '<div class="mdlc2">
<span>Граффити на стену</span>
<br /></div><div class="menu">
&raquo; Граффити готово! <br />
&raquo; Получатель: ';
echo GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
echo ' <a href="select.php">[изм]</a><br />
<center><img src="/apps/graffity/get/'.$timg.'.png" alt="" /></center><br />

<form action="add.php?confirm" method="post">
<input type="hidden" name="x" value="'.$x.'">
<input type="hidden" name="y" value="'.$y.'">
<input type="hidden" name="fon" value="'.$fon.'">
<input type="hidden" name="font" value="'.$font.'">
<input type="hidden" name="fsize" value="'.$fsize.'">
<input type="hidden" name="rgbr" value="'.$rgbr.'">
<input type="hidden" name="rgbg" value="'.$rgbg.'">
<input type="hidden" name="rgbb" value="'.$rgbb.'">
<input type="hidden" name="textx" value="'.$textx.'">
<input type="hidden" name="texty" value="'.$texty.'">
<input type="hidden" name="arrg" value="'.$arrg.'">
<input type="hidden" name="text" value="'.$text.'">
<input type="hidden" name="pp" value="'.$pp.'">
<input type="hidden" name="uid" value="'.$ank['id'].'">
<input type="hidden" name="sh" value="'.intval($_POST['sh']).'" />
<input type="hidden" name="timg" value="'.$timg.'" />
&raquo; Сообщение к граффити:<br/>
<input type="text" value="" name="msgwithgraffity" />
<input type="submit" value="Отправить">
</form>

&raquo; <a href="index.php">Нарисовать ещё граффити</a>
';

/*
$open = @opendir('get/');
while($r = @readdir($open)){
if(@is_file('get/'.$r)) {
if((@filemtime('get/'.$r)+3600) <= time()) {
@unlink('get/'.$r);
}
}
}
@closedir($open);
*/

echo "</div><div class='p_t'>&raquo; <a href='/info.php?id=$ank[id]'>На страницу $ank[nick]</a></div>";
include_once '../../sys/inc/tfoot.php';
?>