1 - Чат
2 - Смайлики
Нужно чтоб при нажатие вводилось в чат сам смайлик а не путь.
Помогите уже перепробовал все не получается.
За раннее спасибо
<?php
define('PROTECTOR', 1);
$headmod = 'chat';//фикс. места
$textl='Чат';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
//если бан
$req = mysql_query("SELECT * FROM `ban` WHERE `usr` = '$log' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
echo"<div class=\"block tmar _center\"><font color='red'> Ваш персонаж забанен! Доступ в чат закрыт!<br> Осталось: ";
$ban[ban_time]=$ban[ban_time]-time();
if($ban[ban_time]<60){
echo "$ban[ban_time] сек.</font>";
}elseif($ban[ban_time]>60 and $ban[ban_time]<3600){
$ban[ban_time]=round($ban[ban_time]/60);
echo "$ban[ban_time] мин.<br>";
}elseif($ban[ban_time]>3600 and $ban[ban_time]<86400){
$ban[ban_time]=round($ban[ban_time]/3600);
echo "$ban[ban_time] часов.<br>";}
else{
$ban[ban_time]=round($ban[ban_time]/86400);
echo "$ban[ban_time] суток.<br>";
}
echo "Забанил: $ban[admin]</br></font></div>";
echo'<div class="block tmar _center"><a href="javascript:history.go(-1)">« Назад</a></div>';
include('files/down.php');exit;}
//конец бана
switch($_GET[mod]){
default:
function smiles($string){
$dir = opendir ("pic/smiles/");
while ($file = readdir ($dir)) {
if (preg_match (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
/////////////
$rand = rand(1000,9999);
///////////////////
echo'<div class="hid" align="left">';
echo "<div class=\"block tmar _center\">
<p><center><b><font color='#f4d06e'>Общий чат</font></b><br><small><span style=\"color: #e32636; font-weight: bold;\">торговля в общем чате запрещена</span></small><br><img src='pic/img_split.png'></center>
<a href=\"chat.php?r=$rand\"><u>Обновить</u></a> |
<a href=\"#\"><u>Правила чата</u></a> |
<a href=\"/smile.php?\"><u>Выбрать смайлик</u></a>
</p>
</div>";
echo "
<script type=\"text/javascript\">
function startTime()
{
var tm=new Date();
var h=tm.getHours();
var m=tm.getMinutes();
var s=tm.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+\":\"+m+\":\"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i=\"0\" + i;
}
return i;
}
</script>
<div class=\"block tmar _center\"><center><body onload=\"startTime()\"> <span style=\"color: lime; font-weight: bold;text-shadow: 1px 0 8px green;\"><p id=\"txt\"> </p></span> </body>
</center></div>";
echo "<div class=\"block tmar _center\"><form action=\"chat.php?mod=writes\" method=\"POST\">";
echo "<input type=\"text\" name=\"zin\" maxlength=\"5000\"/> <input type=\"submit\" value=\"Написать\" class=\"ibutton\"></div>";
if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0")
{
$_GET[page] = 0;
}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 10;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT komentaras FROM komentarai"));
$puslap = floor($viso/10);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM komentarai ORDER BY id DESC LIMIT $num,10");
echo"<div class=\"block tmar _left\">";
while($dsa = mysql_fetch_array($asd))
{
$nickas = strip_tags($dsa['nick']);
$koment = strip_tags($dsa['komentaras']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$nickas'");
$pic = mysql_fetch_array($req);
switch($pic[pol]){
case 'm':
$pol='<span style="color: #92ace4;">';
break;
case 'w':
$pol='<span style="color: #de52de;">';
break;
}
switch($pic[prava]){
case '5':
$pol='<span style="color: #feca04; font-weight: bold;text-shadow: 1px 0 8px #feca04;">';
break;
case '3':
$pol='<span style="color: green;">';
break;
}
switch($pic[system]){
case '1':
$pol='<span style="color: #FE2E2E;">';
break;
}
echo "<b>[$time] <a href=\"search.php?nick=$nickas&go=go\">$pol$nickas</span></a>
<a href=\"chat.php?nick=$nickas&mod=write\"><font color='yellow'>(»)</font></a>:</b> $koment</span>";
if($udata[prava]>=2){
echo"[<a href=\"chat.php?mod=del_post&p=$dsa[id]\"><span style=\"color: #e32636; font-weight: bold;\">X</span></a>][<a href=\"pred.php?go=pred&user=$nickas\"><span style=\"color: green; font-weight: bold;\">П</span></a>]";
}
if($udata[prava] >= 4)
{
echo"<b>[<a href=\"ban.php?mod=10&usr=$nickas\"><span style=\"color: #e32636; font-weight: bold;\">Б</span></a></b>]";
}
echo'<br/>';
}
echo "</div>";
if($udata[prava] >= 2)
{
echo "<div class=\"block tmar _center\"><small>Опции модератора:<br><a href=\"chat.php?mod=trinti\"><span style=\"color: #e32636; font-weight: bold;text-shadow: 1px 0 8px red;\">Очистить чат</span></a></small></div>";
}echo "<center>";
echo "<img src='pic/img_split.png'><br>";
if ($_GET[page] > 0)
{
echo "<a href=\"chat.php?page=$back\"><img src='pic/prev_active.png'></a> ";
}
elseif ($_GET[page] == 0)
{
echo "<img src='pic/prev_dis.png'>";
}
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo " <a href=\"chat.php?page=$next\"><img src='pic/next_active.png'></a>";}
else
{echo "<img src='pic/next_dis.png'>";}
echo "</center>";
break;
case 'del_post':
if($udata[prava] >= 2)
{
if(empty($_GET[p])){
echo"<div class=\"block tmar _center\">Не выбран пост!</div>";
}else{
$asd = mysql_query("SELECT * FROM komentarai WHERE id='$_GET[p]' LIMIT 1");
$avto=mysql_num_rows($asd);
if($avto==0){
echo'<div class="block tmar _center">Нет такого поста!</div>';
}else{
mysql_query("DELETE FROM `komentarai` WHERE id='$_GET[p]' LIMIT 1");
echo'<div class="block tmar _center">Пост успешно удалён!</div>';
echo "<div class=\"block tmar _center\"><a href=\"chat.php?\">Назад</a></div>";
}
}
}else{
echo "<div class=\"block tmar _center\">Ошибка! Доступ закрыт!</div>";
}
break;
case 'write':
echo"<div class=\"block tmar _center\"><b>Сообщение</b><br/>";
echo "<form action=\"chat.php?mod=writes\" method=\"POST\">";
if (isset($_GET[nick]))
{
$_GET[nick] = htmlspecialchars($_GET[nick]);
echo "<input type=\"text\" name=\"zin\" maxlength=\"250\" value=\"$_GET[nick], \" size=\"10\"/><br/>";
}
else
{
echo "<input type=\"text\" name=\"zin\" maxlength=\"250\" size=\"10\"/><br/>";
}
echo "<input type=\"submit\" value=\"Ok\" class=\"ibutton\"></div>";
echo "<div class=\"block tmar _center\"><a href=\"chat.php?\">Назад</a></div>";
break;
case 'writes':
if($udata[lvl] <= 4){
echo "<div class=\"block tmar _center\">В чат можно писать с 5 уровня.</div><div class=\"block tmar _center\"><a href=\"chat.php\">« Назад</a></div>";break;}
$msg=$_POST['zin'];
$msg=substr($msg, 0, 512);
$msg=stripslashes(htmlspecialchars($msg));
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);
$msg = addslashes($msg);
$msg=preg_replace ("|[\r\n]+|si","",$msg);
$a = mysql_num_rows(mysql_query("SELECT komentaras FROM komentarai WHERE komentaras = '$msg'"));
$b = mysql_fetch_array(mysql_query("SELECT kada FROM komentarai WHERE nick = '$log' ORDER BY kada DESC LIMIT 1"));
$data_kom = strip_tags($b['kada']);
$data = date("y/m/d H:i:s", strtotime("+20 seconds"));
$data_dbr = date("y/m/d H:i:s");
$time = date("H:i");
if($data_dbr >= $data_kom && $msg != "")
{
mysql_query("INSERT INTO komentarai SET nick = '$log', komentaras = '$msg', kada = '$data', time = '$time'");
$rand = rand(1000,9999);
//start
function smiles($string){
$dir = opendir ("pic/smiles/");
while ($file = readdir ($dir)) {
if (preg_match (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
/////////////
$rand = rand(1000,9999);
///////////////////
echo'<div class="hid" align="left">';
echo "<div class=\"block tmar _center\">
<p><center><b><font color='#f4d06e'>Общий чат</font></b><br><small><span style=\"color: #e32636; font-weight: bold;\">торговля в общем чате запрещена</span></small><br><img src='pic/img_split.png'></center>
<a href=\"chat.php?r=$rand\"><u>Обновить</u></a> |
<a href=\"#\"><u>Правила чата</u></a> |
<a href=\"/smile.php?\"><u>Выбрать смайлик</u></a>
</p>
</div>";
echo "<div class=\"block tmar _center\">
<script type=\"text/javascript\">
function startTime()
{
var tm=new Date();
var h=tm.getHours();
var m=tm.getMinutes();
var s=tm.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+\":\"+m+\":\"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i=\"0\" + i;
}
return i;
}
</script>
<center><body onload=\"startTime()\"> <span style=\"color: lime; font-weight: bold;text-shadow: 1px 0 8px green;\"><p id=\"txt\"> </p></span> </body>
</center></div>";
echo "<div class=\"block tmar _center\"><form action=\"chat.php?mod=writes\" method=\"POST\">";
echo "<input type=\"text\" name=\"zin\" maxlength=\"5000\"/> <input type=\"submit\" value=\"Написать\" class=\"ibutton\"></div>";
if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0")
{
$_GET[page] = 0;
}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 10;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT komentaras FROM komentarai"));
$puslap = floor($viso/10);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM komentarai ORDER BY id DESC LIMIT $num,10");
echo"<div class=\"block tmar _left\">";
while($dsa = mysql_fetch_array($asd))
{
$nickas = strip_tags($dsa['nick']);
$koment = strip_tags($dsa['komentaras']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$nickas'");
$pic = mysql_fetch_array($req);
switch($pic[pol]){
case 'm':
$pol='<span style="color: #92ace4;">';
break;
case 'w':
$pol='<span style="color: #de52de;">';
break;
}
switch($pic[prava]){
case '5':
$pol='<span style="color: #feca04; font-weight: bold;text-shadow: 1px 0 8px #feca04;">';
break;
case '3':
$pol='<span style="color: green;">';
break;
}
switch($pic[system]){
case '1':
$pol='<span style="color: #FE2E2E;">';
break;
}
echo "<b>[$time] <a href=\"search.php?nick=$nickas&go=go\">$pol$nickas</span></a>
<a href=\"chat.php?nick=$nickas&mod=write\"><font color='yellow'>(»)</font></a>:</b> $koment ";
if($udata[prava]>=2){
echo"[<a href=\"chat.php?mod=del_post&p=$dsa[id]\"><span style=\"color: #e32636; font-weight: bold;\">X</span></a>][<a href=\"pred.php?go=pred&user=$nickas\"><span style=\"color: green; font-weight: bold;\">П</span></a>]";
}
if($udata[prava] >= 4)
{
echo"<b>[<a href=\"ban.php?mod=10&usr=$nickas\"><span style=\"color: #e32636; font-weight: bold;\">Б</span></a></b>]";
}
echo'<br/>';
}
echo "</div>";
if($udata[prava] >= 2)
{
echo "<div class=\"block tmar _center\"><small>Опции модератора:<br><a href=\"chat.php?mod=trinti\"><span style=\"color: #e32636; font-weight: bold;text-shadow: 1px 0 8px red;\">Очистить чат</span></a></small></div>";
}echo "<center>";
echo "<img src='pic/img_split.png'><br>";
if ($_GET[page] > 0)
{
echo "<a href=\"chat.php?page=$back\"><img src='pic/prev_active.png'></a> ";
}
elseif ($_GET[page] == 0)
{
echo "<img src='pic/prev_dis.png'>";
}
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo " <a href=\"chat.php?page=$next\"><img src='pic/next_active.png'></a>";}
else
{echo "<img src='pic/next_dis.png'>";}
echo "</center>";
//end
}
elseif($data_dbr < $data_kom)
{
$sec = $data_kom-$data_dbr;
$rand = rand(1000,9999);
echo "<div class=\"block tmar _center\">Защита от Флуда! Подождите $sec секунд</div>";
echo"<div class=\"block tmar _center\"><a href=\"chat.php?r=$rand\">Продолжить</a><div>";
}
elseif($msg == "")
{
$rand = rand(1000,9999);
echo "<div class=\"block tmar _center\">Вы не написали сообщение!</div>";
echo"<div class=\"block tmar _center\"><a href=\"chat.php?r=$rand\">Продолжить</a></div>";
}
else
{
$rand = rand(1000,9999);
echo "<div class=\"block tmar _center\">Ошибка!</div>";
echo"<div class=\"block tmar _center\"><a href=\"chat.php?r=$rand\">Продолжить</a></div>";
}
break;
case 'trinti':
if($udata[prava] >= 2)
{
mysql_query("DELETE FROM komentarai");
echo "<div class=\"block tmar _center\">Все сообщения удалены!</div>";
echo "<div class=\"block tmar _center\"><a href=\"chat.php?\">Назад</a></div>";
}
else
{
echo "<div class=\"block tmar _center\">Ошибка! Доступ закрыт!</div>";
}
break;
}
echo "</div>";
include($path.'files/down.php');
?>
<?php
define('PROTECTOR', 1);
$textl='Справка по смайлам';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
$dir = opendir ("pic/smiles");
while ($file = readdir ($dir))
{ if (ereg (".gif$", "$file"))
{$a[]=$file;}}
closedir ($dir);
sort($a);
$total = count($a);
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + 10){ $end = $total; }
else {$end = $start + 10; }
for ($i = $start; $i < $end; $i++){
$smkod=str_replace("pic/smiles/.gif","",$a[$i]);
echo '<a href="chat.php?nick=:'.$smkod.'&mod=write"><img src="pic/smiles/'.$a[$i].'" alt=""></a>';
echo '- :'.$smkod.'<br>';
}
$a=count($a);
$ba=ceil($a/10);
$ba2=floor(($a-1)/10)*10;
echo'<br/>Страницы:';
$asd=$start-(10*4);
$asd2=$start+(10*5);
if($asd<$a && $asd>0){echo " <a href=\"smile.php?start=0&id=\">1</a> ... ";}
for($i=$asd; $i<$asd2;)
{
if($i<$a && $i>=0){
$ii=floor(1+$i/10);
if ($start==$i) {
echo ' <b>'.$ii.'</b>';
}
else {
echo " <a href=\"smile.php?start=$i&id=\">$ii</a>";
}}
$i=$i+10;}
if($asd2<$a){echo " ... <a href=\"smile.php?start=$ba2\">$ba</a>";}
echo "<br/><a href=\"chat.php?\">Назад</a>";
include('files/down.php');
?>