View file besedka/index.php

File size: 11.63Kb
<?php
      error_reporting(0);
session_name('PHP');
session_start();

include '../header/config.inc.php';
include '../header/function.inc.php';
include '../header/header.inc.php';
include '../header/connect.inc.php';
include '../header/click-club.class.php';
If (!isset($_GET['log'])) define("anybody","true");
include '../header/enter.inc.php';
include '../ban.php';

mysql_query("update `".prefix."users` set `mesto`='В беседке', `online`='".time()."' where `id` = '".$_USER['id']."';");

    If (!isset($_GET['page']) || !is_numeric($_GET['page'])) $page=1;
	

 else { $page=intval($_GET['page']); $page;}
$result=mysql_query("SELECT * FROM `".prefix."chat` ORDER BY `id` DESC LIMIT ".(($page-1)*num_best_on_page).",".(num_best_on_page+1));
If (!$result){
echo '<div class="menuindex">Oшибкa зaпpoca к бд...</div>';
break;
}
          $rand=rand(1000,9999);
      echo'<div class="downsw"><b>Беседка</b></div>';
	  echo'<div class="menuindex">';
 if($_USER['java']=='0'){


echo 	<<<HTML

    <script language="JavaScript" type="text/javascript">
            function tag(text1, text2, text3) {
            if ((document.selection)) {
                document.form.msg.focus();
                document.form.document.selection.createRange().text = text3+text1+document.form.document.selection.createRange().text+text2+text3;
            } else if(document.forms['post'].elements['text'].selectionStart!=undefined) {
                var element = document.forms['post'].elements['text'];
                var str = element.value;
                var start = element.selectionStart;
                var length = element.selectionEnd - element.selectionStart;
                element.value = str.substr(0, start) + text3 + text1 + str.substr(start, length) + text2 + text3 + str.substr(start + length);
            } else document.form.msg.value += text3+text1+text2+text3;}</script>

<script language="javascript" type="text/javascript">
function ShowOrHide(d1) {
	  if (d1 != '') DoDiv(d1);
}

function DoDiv(id) {
	  var item = null;
	  if (document.getElementById) {
		item = document.getElementById(id);
	  } else if (document.all){
		item = document.all[id];
	  } else if (document.layers){
		item = document.layers[id];
	  }
	  if (!item) {
	  }
	  else if (item.style) {
		if (item.style.display == "none"){ item.style.display = ""; }
		else {item.style.display = "none"; }
	  }else{ item.visibility = "show"; }
}

function bbcode(text) {
        var txtarea = document.post.text;
        text = '' + text + '';
        if (txtarea.createTextRange && txtarea.caretPos) {
                var caretPos = txtarea.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
                txtarea.focus();
        } else {
                txtarea.value  += text;
                txtarea.focus();
        }
}

</script>

   <div class="menuindex">
<a href="javascript:ShowOrHide('1')">[BBcode]<img src="/images/niz.png" alt="red" title="Развернуть" border="0"/></a> <a href="javascript:ShowOrHide('2')">[Смайлы]<img src="/images/niz.png" alt="red" title="Развернуть" border="0"/></a></div>
<div id="1" style="display:none;"><div class="downsw">
<a href="javascript:tag('[red]', '[/red]', '')"><img src="/includes/bb/re.png" alt="red" title="Красный" border="0"/></a>
<a href="javascript:tag('[green]', '[/green]', '')"><img src="/includes/bb/gr.png" alt="green" title="Зеленый" border="0"/></a>
<a href="javascript:tag('[blue]', '[/blue]', '')"><img src="/includes/bb/bl.png" alt="blue" title="Синий" border="0"/></a>
<a href="javascript:tag('[b]', '[/b]', '')"><img src="/includes/bb/b.png" alt="b" title="Жирный" border="0"/></a>
<a href="javascript:tag('[i]', '[/i]', '')"><img src="/includes/bb/i.png" alt="i" title="Наклонный" border="0"/></a>
<a href="javascript:tag('[u]', '[/u]', '')"><img src="/includes/bb/u.png" alt="u" title="Подчеркнутый" border="0"/></a>
<a href="javascript:tag('[s]', '[/s]', '')"><img src="/includes/bb/s.png" alt="s" title="Зачеркнутый" border="0"/></a>
<a href="javascript:tag('[url=]', '[/url]', '')"><img src="/includes/bb/l.png" alt="url" title="Ссылка" border="0"/></a>
<a href="javascript:tag('[c]', '[/c]', '')"><img src="/includes/bb/q.png" alt="quote" title="Цитата" border="0"/></a>
<a href="javascript:tag('[img alt=]', '[/img]', '')"><img src="/includes/bb/img.png" alt="img" title="Ссылка" border="0"/></a>
<a href="javascript:tag('[left]', '[/left]', '')"><img src="/includes/bb/vl.png" alt="quote" title="Выравнивание влево" border="0"/></a>
<a href="javascript:tag('[center]', '[/center]', '')"><img src="/includes/bb/vc.png" alt="quote" title="Выравнивание по центру" border="0"/></a>
<a href="javascript:tag('[right]', '[/right]', '')"><img src="/includes/bb/vp.png" alt="quote" title="Выравнивание вправо" border="0"/></a>

 </div>

      </div>
      <div id="2" style="display:none;"><div class="downsw">
<a href="javascript:bbcode(':)')"><img src="/smile/1.gif" alt=":)" title=":)" border="0"/></a>
<a href="javascript:bbcode(':(')"><img src="/smile/2.gif" alt=":(" title=":(" border="0"/></a>
<a href="javascript:bbcode('lol')"><img src="/smile/6.gif" alt="lol" title="lol" border="0"/></a>
<a href="javascript:bbcode(':D')"><img src="/smile/7.gif" alt=":D" title=":D" border="0"/></a>
<a href="javascript:bbcode('zloy')"><img src="/smile/8.gif" alt="zloy" title="zloy" border="0"/></a>

<a href="javascript:bbcode('wall')"><img src="/smile/11.gif" alt="wall" title="wall" border="0"/></a>

<a href="javascript:bbcode('=O')"><img src="/smile/12.gif" alt="=O" title="=O" border="0"/></a>

<a href="javascript:bbcode('beer')"><img src="/smile/27.gif" alt="beer" title="beer" border="0"/></a>




 </div>

      </div>
<form action="add.php" name="post" method="POST" onsubmit="return checkForm(this)">
&nbsp;&nbsp;<textarea name="text" rows="6" class="form" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$loginvst</textarea>
<br />
&nbsp;Настроение: <select name="nastr">
<option value="1">Без эмоций</option>
<option value="2">Beceлo</option>
<option value="3">Гpycтнo</option>
<option value="4">Гopдo</option>
<option value="5">Шeпoтoм</option>
<option value="6">Гpoмкo</option>
<option value="7">Увepeннo</option></select><br />

&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />    <a href="/besedka/?$rand"><input type="button" class="form" value="Обновить" /></a>
</form>


HTML;

 }
else
{
	echo ' <form action="add.php" name="post" method="POST">
&nbsp;&nbsp;<textarea type="text" name="text" rows="6"/>'.$loginvst.'</textarea>
<br />
&nbsp;Настроение: <select name="nastr">
<option value="1">Без эмоций</option>
<option value="2">Beceлo</option>
<option value="3">Гpycтнo</option>
<option value="4">Гopдo</option>
<option value="5">Шeпoтoм</option>
<option value="6">Гpoмкo</option>
<option value="7">Увepeннo</option></select><br />

&nbsp;&nbsp;<input type="submit"  class="form" value="Добавить" />    <a href="/besedka/?'.$rand.'"><input type="button" class="form" value="Обновить" /></a>
</form>';
}
echo'</div>';
$next=false;
$num=mysql_num_rows($result);
If ($num>0){
If ($num<=num_best_on_page) $read=$num; else {
$read=num_best_on_page;
$next=true;
}

for ($i=0;$i<$read;$i++){
 $id = ''.mysql_result($result,$i,'id').'';
                    	$user = ''.mysql_result($result,$i,'user').'';
                    	$login = ''.mysql_result($result,$i,'user').'';
                       $nastr = ''.mysql_result($result,$i,'nastr').'';

                        $date = ''.mysql_result($result,$i,'date').'';
                        $text = ''.mysql_result($result,$i,'text').'';
                        $anss = ''.mysql_result($result,$i,'ans').'';
                        $ansuser = ''.mysql_result($result,$i,'ansuser').'';

                        $text	=	smiles(parsebb(smile(antirek(antimat(stripslashes(nl2br($text)))))));

              

$d = mysql_query("select * from `".prefix."users` where login='".$user."'");
$dat = mysql_fetch_array($d);

$time = time();
$online = ($dat['online'] > ($time - 300));
switch($dat['online'])
{
case $online: $online='[<font color="#00AA00">On</font>]'; break;
default: $online='[<font color="red">Off</font>]'; break;}

$ggg=mysql_query("SELECT * FROM `".prefix."users` WHERE `login`='".$user."'");
$row=mysql_fetch_array($ggg);

$admin=$row['admin'];
if($admin=='1') $user ="<font color='ff0000'>".$user."</font></a> <img src='/images/admin.png' alt='!'/>";

/////////////////////////////////////////////

if ($dat[pol]=="Мужской")
{ 
$img_pol='<img src="/images/pol/m.png"/>';
}
if ($dat[pol]=="Женский")
{ 
$img_pol='<img src="/images/pol/j.png"/>';
}

     $mode=mysql_query("SELECT * FROM `".prefix."moderka` WHERE `mod`='".$_USER['login']."'");
If(!$mode){echo 'err';}
if (mysql_num_rows($mode)!=0){
	$moder = $_USER['login'];
	
}



                   	 If ($_USER['admin']  || $moder){$adm ='[<a href="del.php?id='.$id.'"><font color="red">del</font></a>] [<a href="ans.php?id='.$id.'"><font color="green">Aотв</font></a>]';  }

                  if($_USER['login']==$login || $_USER['admin'])  {$edit='[<a href="edit.php?id='.$id.'"><font color="green">ред</font></a>]';}
                    else{$edit='';}
if (!empty($anss)) {

	$ans	=	smiles(smile(parsebb(stripslashes(nl2br(htmlspecialchars($anss))))));
	$ans	=	'<div class="reply"><b><font color ="green">'.$ansuser.':</font></b> <br /><font color ="red">'.$ans.'</font></div>';
} else {
	$ans	=	'';
}
 $l = "'[b]".$login."[/b], '";

echo '
<div class="menuindex"><a href="/info.php'.$_zapros.'user='.$login.'">'.$img_pol.'  <b>'.$user.'</b></a>'.$online.' '.$nastr.' ['.$date.'] '.$adm.'';
 if($_USER['java']=='0'){ echo' [<a href="javascript:bbcode('.$l.')"><font color="green">отв</font></a>]';}
 else {echo' [<a href="add.php?user='.$login.'"><font color="green">отв</font></a>]'; }

echo''.$edit.'<br />'.$text.'

'.$ans.'</div>';

}

} else echo '<div class="menuindex">Cообщений еще нет! Будь первым!</div>';


   echo '<div class="menuindex">';
If ($page>1) echo '<a href="'.$_zapros.'page='.($page-1).'">';
echo '&#171; Haзaд';
If ($page>1) echo '</a>';
echo ' | ';
If ($next) echo '<a href="'.$_zapros.'page='.($page+1).'">';
echo 'Дaлee &#187;';
If ($next) echo '</a>';
                     echo '</div>';

/////////////////////////////////////////////
if ($_USER[pol]=="Мужской")
{ 
$img_pol='<img src="/images/pol/m.png"/>';
}
if ($_USER[pol]=="Женский")
{ 
$img_pol='<img src="/images/pol/j.png"/>';
}


   $result=mysql_query("SELECT `text` FROM `".prefix."chat` ");
If (!$result){
echo '<div class="menuindex">Oшибкa зaпpoca к бд...</div>';
break;
}




            echo'<div class="menuindexom">';
             If ($_USER['admin'])
{echo'&#187; <a href="del.user.php">Удаление всех сообщений пользователя!</a><br />
&#187; <a href="del.chat.php">Очистить чат!</a><br />

';  }

echo'Кто здесь: ';
                                                          $time = time();
                          $n2 = 'В беседке';

                 $q = mysql_query("select * from `".prefix."users` where `online` > ($time - 300) && `mesto` = '".$n2."'");
 $reg=mysql_num_rows($q);
 while ($field=mysql_fetch_array($q))
 {

  if($field['mesto']=='В беседке' || $field['mesto']=='Пишет ответ в беседке' || $field['mesto']=='Добовляет ответ на сообщение в беседке' || $field['mesto']=='Редактирует сообщение в беседке')
echo'<a href="/info.php'.$_zapros.'user='.$field['login'].'"> '.$img_pol.' <font color="#009900"><b>'.htmlspecialchars(stripslashes(trim($field['login']))).'</b></font></a>[<a href="add.php?user='.$field['login'].'"><font color="green">отв</font></a>] ';

 }

   echo"</div>";
 echo '<div class="menuindex">';
    echo '
Bceгo cooбщeний: '.mysql_num_rows($result);
                                      echo '</div>';
									  

include "../header/end.inc.php";

?>