Файл: public_html/support.php
Строк: 49
<?
include ('./system/common.php');
include ('./system/functions.php');
include ('./system/user.php');
$title = 'Поддержка';
include ('./system/h.php');
if(!$user) {
header('location: /');
exit;
}
if(isset($_GET['new_msg'])){
if(isset($_POST['text'])){
$text = $_POST['text'];
if(strlen($text) < 1 or strlen($text) > 10000)$err = 'Длина сообщения должна быть в пределах 1 - 10000 символов!';
if($err) {
echo '<div class='block red' align='center'>';
echo 'Длина сообщения должна быть в пределах 1 - 10000 символов!</div>';
include ('./system/f.php');
exit;
}
if(!$err){
mysql_query("INSERT INTO `chat` SET `id_user` = '$user[id]', `time` = '".time()."', `text` = '".text($text)."', `support` = '1'");
header('Location: ?');
exit();
}else{
header('Location: ?');
exit();
}
}else{
header('Location: ?');
exit();
}
}
if(isset($_GET['delete_post']) and $user['id'] == 1){
mysql_query("DELETE FROM `chat` WHERE `id` = '".$_GET['delete_post']."'");
header('Location: ?');
exit();
}
echo "<div class='block'>";
if(isset($_GET['to'])){
echo "<form method='post' action='?new_msg=$_GET[to]'>";
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $_GET[to] LIMIT 1"));
echo "<input type='text' name='text' value = '$opponent[login], ' style='width: 97%;'>";
echo "<input type='submit' value='Отправить'> <a href='/smiles'><img src='/images/smiles/mini_ulibka.gif'></a> </form>";
}else{
echo "<form method='post' action='?new_msg'>";
echo "<input type='text' name='text' style='width: 97%;'>";
echo "<input type='submit' value='Отправить'> <a href='/smiles'><img src='/images/smiles/mini_ulibka.gif'></a> </form>";
}
echo '</div><div class="line"></div><div class="block">';
$set['p_str'] = 10;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` where `support` = '1'"),0);
$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 * FROM `chat` where `support` = '1' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
echo " <a href='/user/$ank[id]'>$ank[login]</a>, ".vremja(time() - $post['time'])."";
if($user['id'] != $ank['id'])echo "<a href='?to=$ank[id]'> (»)</a>";
$msg = str_replace(array($user[login].','), "<b>$user[login],</b> ", $post['text']);
echo "<br>".smiles($msg);
if($user['id'] == 1) echo " <a href='?delete_post=$post[id]'><font color='red'>(x)</font></a>";
echo "<br>";
}
echo "</div>";
if($k_page>1) echo str('?',$k_page,$page);
require_once './system/f.php';
?>