Здравствуйте Уже второй день ломаю голову не работают системные сообщения в Админке ....
Вот Код
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'> }
if ($_POST['action']!="") {
switch ($_POST['action']) {
case "sysmsg":
if (filesize("tmpdisk/chat.txt")>20*1024) {
//file_put_contents("chat.txt", file_get_contents("chat.txt", NULL, NULL, 3*1024), LOCK_EX);
//@chmod("$fp", 0644);
// удаление последней строки
$file=file("tmpdisk/chat.txt");
$fp=fopen("tmpdisk/chat.txt","w");
flock ($fp,LOCK_EX);
for ($s=0;$s<count($file)/1.5;$s++) {
unset($file[$s]);
}
fputs($fp, implode("",$file));
fputs($fp ,"\r\n:[".time ()."]:[!sys2all!!]:[<font color=#FF0033> ".($_POST['msg'])."</font>]:[1]\r\n"); //работа с файлом
flock ($fp,LOCK_UN);
fclose($fp);
}
else {
$fp = fopen ("tmpdisk/chat.txt","a"); //открытие
flock ($fp,LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fputs($fp ,"\r\n:[".time ()."]:[!sys2all!!]::[<font color=#FF0033> ".($_POST['msg'])."</font>]:[1]\r\n"); //работа с файлом
fflush ($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock ($fp,LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose ($fp); //закрытие
}
//echo "Отправлено системное сообщение в чат.";
break;
}
}
?>
<HTML>
<script>
var xmlHttpp=[]
function ajax_func(func,iid,getpar,postpar){
xmlHttpp[iid]=GetXmlHttpObject1()
if (xmlHttpp[iid]==null){
alert ("Browser does not support HTTP Request")
return
}
document.getElementById(iid).innerHTML="<img src='
var url="./ajax/"+func+".php"
url=url+"?"+getpar
xmlHttpp[iid].open("POST",url,true);
xmlHttpp[iid].onreadystatechange=function() {
if (xmlHttpp[iid].readyState==4 || xmlHttpp[iid].readyState=="complete") {
if (document.getElementById(iid)=='[object HTMLInputElement]')
document.getElementById(iid).value=xmlHttpp[iid].responseText;
else
document.getElementById(iid).innerHTML=xmlHttpp[iid].responseText;
document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight+10;
}
}
xmlHttpp[iid].setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttpp[iid].send(postpar);
}
function GetXmlHttpObject1()
{
var xmlHttp1=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp1=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp1;
}
</script>
</HTML>
<?
}
if (($user['align']>2) && ($user['align']<3)) {
?>
<hr><div id='content' style='width:100%;'>
<div style='width:100%; height:40%;' id=adm_act>
<div style='float:left;'>Отправить системное сообщение в чат</div><div style='float:left; margin-left:10px;'>
<input name='sysmsg' id='sysmsg' size=100>
<input type="button" OnClick=" document.getElementById('action').value='sysmsg'; document.getElementById('msg').value=document.getElementById('sysmsg').value; document.actform.submit(); " value="Отправить">
Сейчас в клубе: <?=$online[0];?>
</div>
<form method=POST name='actform'>
<input type=hidden name='action' id='action'>
<input type=hidden name='msg' id='msg'>
</form>
</div>
<?
/*
<div id='content' style='width:100%;'>
<div style='float:left;'>Отправить системное сообщение в чат</div><div style='float:left; margin-left:10px;'><input name='sysmsg' id='sysmsg' size=100> <input type=button OnClick=" document.getElementById('action').value='sysmsg'; document.getElementById('msg').value=document.getElementById('sysmsg').value; document.actform.submit(); "></div>
<div style='clear:both;'></div>
</div>
<form method=POST name='actform'>
<input type=hiddn name='action' id='action'>
<input type=hiddn name='msg' id='msg'>
</form> */
}
</div>
Вот Код
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'> }
if ($_POST['action']!="") {
switch ($_POST['action']) {
case "sysmsg":
if (filesize("tmpdisk/chat.txt")>20*1024) {
//file_put_contents("chat.txt", file_get_contents("chat.txt", NULL, NULL, 3*1024), LOCK_EX);
//@chmod("$fp", 0644);
// удаление последней строки
$file=file("tmpdisk/chat.txt");
$fp=fopen("tmpdisk/chat.txt","w");
flock ($fp,LOCK_EX);
for ($s=0;$s<count($file)/1.5;$s++) {
unset($file[$s]);
}
fputs($fp, implode("",$file));
fputs($fp ,"\r\n:[".time ()."]:[!sys2all!!]:[<font color=#FF0033> ".($_POST['msg'])."</font>]:[1]\r\n"); //работа с файлом
flock ($fp,LOCK_UN);
fclose($fp);
}
else {
$fp = fopen ("tmpdisk/chat.txt","a"); //открытие
flock ($fp,LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fputs($fp ,"\r\n:[".time ()."]:[!sys2all!!]::[<font color=#FF0033> ".($_POST['msg'])."</font>]:[1]\r\n"); //работа с файлом
fflush ($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock ($fp,LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose ($fp); //закрытие
}
//echo "Отправлено системное сообщение в чат.";
break;
}
}
?>
<HTML>
<script>
var xmlHttpp=[]
function ajax_func(func,iid,getpar,postpar){
xmlHttpp[iid]=GetXmlHttpObject1()
if (xmlHttpp[iid]==null){
alert ("Browser does not support HTTP Request")
return
}
document.getElementById(iid).innerHTML="<img src='
Вам необходимо зарегистрироваться для просмотра ссылок
/>";var url="./ajax/"+func+".php"
url=url+"?"+getpar
xmlHttpp[iid].open("POST",url,true);
xmlHttpp[iid].onreadystatechange=function() {
if (xmlHttpp[iid].readyState==4 || xmlHttpp[iid].readyState=="complete") {
if (document.getElementById(iid)=='[object HTMLInputElement]')
document.getElementById(iid).value=xmlHttpp[iid].responseText;
else
document.getElementById(iid).innerHTML=xmlHttpp[iid].responseText;
document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight+10;
}
}
xmlHttpp[iid].setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttpp[iid].send(postpar);
}
function GetXmlHttpObject1()
{
var xmlHttp1=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp1=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp1;
}
</script>
</HTML>
<?
}
if (($user['align']>2) && ($user['align']<3)) {
?>
<hr><div id='content' style='width:100%;'>
<div style='width:100%; height:40%;' id=adm_act>
<div style='float:left;'>Отправить системное сообщение в чат</div><div style='float:left; margin-left:10px;'>
<input name='sysmsg' id='sysmsg' size=100>
<input type="button" OnClick=" document.getElementById('action').value='sysmsg'; document.getElementById('msg').value=document.getElementById('sysmsg').value; document.actform.submit(); " value="Отправить">
Сейчас в клубе: <?=$online[0];?>
</div>
<form method=POST name='actform'>
<input type=hidden name='action' id='action'>
<input type=hidden name='msg' id='msg'>
</form>
</div>
<?
/*
<div id='content' style='width:100%;'>
<div style='float:left;'>Отправить системное сообщение в чат</div><div style='float:left; margin-left:10px;'><input name='sysmsg' id='sysmsg' size=100> <input type=button OnClick=" document.getElementById('action').value='sysmsg'; document.getElementById('msg').value=document.getElementById('sysmsg').value; document.actform.submit(); "></div>
<div style='clear:both;'></div>
</div>
<form method=POST name='actform'>
<input type=hiddn name='action' id='action'>
<input type=hiddn name='msg' id='msg'>
</form> */
}
</div>