View file panel/adminchat.php

File size: 5.82Kb
<?php
// mod by Golem http://veplog.ru

require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";


$rand =rand(100,999);
$dates=date("d.m.y",$sitetime);
$times=date("H:i",$sitetime);

if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!="") {
if ($dostup==101 || $dostup==102 || $dostup==103 || $dostup==105){


echo '<div class=tp> <b>Админ-чат</b></div>';

##########################################################################
##                         Главная страница
##########################################################################
if(!isset($action)){

echo '<div class=tpanel>[<a href="adminchat.php?r='.$rand.'&amp;'.SID.'">Обновить</a>] ';
echo '[<a href="index.php?">В админку</a>]</div>';

if($config_themes!="wml"){
echo'<div class=body><form action="adminchat.php?action=add&amp;'.SID.'" method="post"><b>Сообщение:</b><br>';
echo'<textarea cols="20" rows="2" name="msg"></textarea><br>';

if($config_translit=="1"){
echo'<input name="trans" type="checkbox" value="y" />Транслит<br>';}

echo'<input type="submit" value="Написать" /></form></div><div class=body>';

}else{

echo'<br>--------------------<br>Сообщение:<br>';
echo'<input name="msg"/><br>';

if($config_translit=="1"){
echo'Транслит: <select name="trans"><option value="0">Нет</option>';
echo'<option value="y">Да</option></select><br>';}
echo'<anchor>Написать';
echo'<go href="adminchat.php?action=add&amp;'.SID.'" method="post">';
echo'<postfield name="msg" value="$(msg)"/>';
echo'<postfield name="trans" value="$(trans)"/>';
echo'</go></anchor><br>--------------------<br>';
}



$file = file("../local/adminchat.dat");
$file = array_reverse($file);
$total = count($file);
if($total<1){echo'<div class=body>(<b>Сообщений нет</b>)</div>';}
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $config_bookpost){ $end = $total; }
else {$end = $start + $config_bookpost; }
for ($i = $start; $i < $end; $i++){



$data = explode("|",$file[$i]);
//////////////////////////////////////////////////////////////
echo'<div class="forum">';
$data[0]=bb_code($data[0]);

if(!empty($udata[45])){
$ava = file("../local/profil/$data[1].prof");
$avv = explode(":||:",$ava[0]);

if($avv[43]!="" && $avv[43]!="noavatar.gif"){
echo'<div class=r0>';}else{
echo'<div class=r0>'; }
echo'<b><a href="../pages/anketa.php?uz='.$data[1].'&amp;'.SID.'"> '.$data[1].' </a></b> '.user_online($data[1]);
}else{ echo'<div class=r0><b><a href="../pages/anketa.php?uz='.$data[1].'&amp;'.SID.'"> '.$data[1].' </a></b> '.user_online($data[1]);}


if($dates==$data[2]){$data[2]='<font color="#FF0000">Сегодня</font>';}


echo'<small> ('.$data[2].' / '.$data[3].')</small><br>'.$data[0].'</div>';

}

echo'</div><div class=panel>';
if ($start != 0) {echo '<a href="adminchat.php?">Чат </a> ';}else{echo'Чат ';}
echo'|';
if ($total > $start + $config_bookpost) {echo ' <a href="adminchat.php?start='.($start + $config_bookpost).'&amp;'.SID.'"> Раньше&gt;</a>';}else{echo' Раньше&gt;';}
}


//---------------------------------------- ДОБАВЛЕНИЕ СООБЩЕНИЯ -------------------------------------------//
if($action=="add") {

$brow=check($brow);
$msg=wordwrap($msg,150,' ',1);
$msg=substr($msg,0,1200);
$msg=check($msg);
$log=check($log);


////////////////////////////////////////
if($trans=="y"){$msg=transliter($msg);}
$msg=preg_replace ("|[\r\n]+|si","<br>",$msg);
$msg = antimat($msg);
$msg = smiles($msg);
////////////////////////////////////////

$text=$msg.'|'.$log.'|'.$dates.'|'.$times.'|'.$brow.'|'.$ip.'|';
$text=preg_replace ("|[\r\n]+|si","",$text);

$fp=fopen("../local/adminchat.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
flock ($fp,LOCK_UN);
fclose($fp);


$file=file("../local/adminchat.dat"); $i = count($file);
if ($i>=100) {
$fp=fopen("../local/adminchat.dat","w");
flock ($fp,LOCK_EX);
unset($file[0]);
unset($file[1]);
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
}


header ("Location: adminchat.php?isset=addon&".SID);
}


//---------------------------------------- ПОДТВЕРЖДЕНИЕ ОЧИСТКИ -------------------------------------------//
if ($action=="prodel") {
echo'<div class=body>Вы уверены что хотите удалить все сообщения в админ-чате?<br>';
echo'- <b><a href="adminchat.php?action=delchat&amp;'.SID.'">Да уверен!</a></b><br>';

echo '- <a href="adminchat.php?'.SID.'">Вернуться</a></div>';
}

//---------------------------------------- ОЧИСТКА АДМИН-ЧАТА -------------------------------------------//
if ($action=="delchat") {
if ($dostup==101 || $dostup==102){
clear_files("../local/adminchat.dat");

header ("Location: adminchat.php?isset=mp_admindelchat&".SID);
}}


if ($total>0 && ($dostup==101 || $dostup==102)){
echo '<br>- <a href="adminchat.php?action=prodel&amp;'.SID.'">Очистить чат</a></div>';
}

echo'<div class=btm>[<a href="index.php?'.SID.'">В админку</a>]<br>';
echo'[<a href="../index.php?'.SID.'">На главную</a>]</div>';

} else {header ("Location: ../index.php?isset=404&".SID);}
} else {header ("Location: ../index.php?isset=404&".SID);}

include_once"../themes/$config_themes/foot.php";
?>