Файл: minichat_by_KoT/minichat_by_KoT/add.php
Строк: 87
<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################
require 'sid.php';
header("Cache-Control: no-cache");
header('Content-Type:text/html; charset=UTF-8');
require'config.php';
$link = connect_db();
list($row, $id, $ps) = check_login($link);
include 'head.php';
$row['avr'] = 0;
$act = check($_GET['act']);
$rm = intval($_GET['rm']);
if (empty($rm)) header('Location: menu.php?'.$ref.'');
if (empty($act)) {
$rooms = mysql_fetch_array(mysql_query("SELECT * FROM `rooms` WHERE `rm`='$rm'"));
if (mysql_affected_rows() == 0)
{
include 'head.php';
echo $bad .' Такой комнаты не существует!' . $div5;
echo $div3 . '<a href="menu.php?'.$ref.'"><b>В меню</b></a>' . $div5;
include 'foot.php';
exit();
}
echo $div1 . '<b>Сказать в чат</b>' . $div5;
echo $div3 . '
<form action="add.php?rm='.$rm.'&act=add" method="POST" name="form">
Текст:
<br/>
<textarea name="msg" class="text" maxlength="200" cols="24" rows="5" title="Тест сообщения"/></textarea>
<br/>';
if ($row['level'] == 2) {
echo '<select name="shrift">
<option value="0">Шрифт</option>
<option value="1">Курсив</option>
<option value="2">Подчёркнутый</option>
<option value="3">Курс. и подч.</option>
<option value="4">Жирный</option>
<option value="5">Жирн. и подч.</option>
<option value="6">Большой</option>
</select>
<br/>';
}
echo '<input type="submit" class="ibutton" value="Сказать" name="add"/>
</form>
' . $div5;
echo quickpaste('msg');
echo quicksmiles();
echo '<br/><small>Быстрые смайлы</small>';
} else {
$rooms = mysql_fetch_array(mysql_query("SELECT * FROM `rooms` WHERE `rm`='$rm'"));
$col_shr = abs(intval($_POST['col_shr']));
$font = abs(intval($_POST['font']));
if ($row['cvet'] == 0) $col_shr = 0;
elseif ($row['cvet'] == 1) $col_shr = 1;
elseif ($row['cvet'] == 2) $col_shr = 2;
elseif ($row['cvet'] == 3) $col_shr = 3;
elseif ($row['cvet'] == 4) $col_shr = 4;
elseif ($row['cvet'] == 5) $col_shr = 5;
elseif ($row['cvet'] == 6) $col_shr = 6;
elseif ($row['cvet'] == 7) $col_shr = 7;
elseif ($row['cvet'] == 8) $col_shr = 8;
elseif ($row['cvet'] == 9) $col_shr = 9;
if (($row['level'] == 2) and ($_POST['shrift'] == 1)) $font = 1;
elseif (($row['level'] == 2) and ($_POST['shrift'] == 2)) $font = 2;
elseif (($row['level'] == 2) and ($_POST['shrift'] == 3)) $font = 3;
elseif (($row['level'] == 2) and ($_POST['shrift'] == 4)) $font = 4;
elseif (($row['level'] == 2) and ($_POST['shrift'] == 5)) $font = 5;
elseif (($row['level'] == 2) and ($_POST['shrift'] == 6)) $font = 6;
elseif (($row['gameid'] == 4) and ($row['gamekik'] > $time)) $font = 7;
$msg = mysql_real_escape_string(check($_POST['msg']));
$prvt = intval($_POST['prvt']);
if (isset($_GET['nk'])) $nk = (int)$_GET['nk'];
if ($prvt != 0) {
if (isset($_POST['prvt']) && isset($_GET['nk'])) $privat = intval($_GET['nk']);
}
else $privat = 0;
// Если короткое сообщ
if (strlen2($msg) < 3) { header ('Location: room.php?rm='.$rm.'&err=p'); exit; }
// Если сообщ повторяются
$Sql_p = mysql_fetch_assoc(mysql_query("SELECT * FROM `message` WHERE `rm`='$rm' AND `user_id`='$row[id]' AND `msg`='$msg'"));
if (!empty($Sql_p)) {
header('Location: room.php?rm='.$rm.'&err=c');
exit;
}
$msg = iconv('utf-8', 'windows-1251', $msg);
$msg = mb_substr($msg, 0,500, 'UTF8');
$msg = iconv('windows-1251', 'utf-8', $msg);
if ($row['translit'] == 1) $msg = trun_to_rus($msg);
// Антифлуд
if (!isset($_SESSION['flood_time'])) $_SESSION['flood_time'] = 0;
if ($_SESSION['flood_time'] > time()) {
$mess = mysql_result(mysql_query("SELECT count(*) FROM `message` WHERE `user_id`='$id' AND `time` < '".$_SESSION['flood_time']."'"),0);
if ($mess > 0) { header('Location: room.php?rm='.$rm.'&err=t'); exit; }
}
$_SESSION['flood_time'] = time() + 10; // Время интервала антифлуда
// Если на юзера навели порчу
if ($row['gamekik'] > $time && $row['gameid'] == 5) {
$msg = str_replace($msg, 'Ик..Ик..Ик..', $msg);
} else {
$msg = $msg;
}
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`komu`,`privat`,`inps`,`color`,`font`) VALUES ('$row[user]','$row[id]','$today','$msg','$rm','$nk','$privat','$inps','$col_shr','$font')");
posts_add(); // запись постов
if ($rm == 1) require 'umnik2.php';
header ('Location: room.php?rm='.$rm.'');
exit;
}
echo $div3 . '<a href="room.php?rm='.$rm.'"><b>В комнату</b></a>' . $div5;
include 'foot.php';
?>