Файл: includes/wap/admin/gb.php
Строк: 119
<?php
error_reporting(7);
Header("Content-type:text/vnd.wap.wml; charset=Utf-8");
Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Header("Cache-Control: no-cache, must-relative");
touch($userpath.'gb-free-message.dat');
$page=$query2+0;
if ($page<1) $page=1;
if (($query3!='delete')&&($query3!='edit')&&($query3!='answer'))
{
$f=fopen($userpath.'gb-free-message.dat','r+');
$tmp=$_tmp='';
while (!feof($f))
{
$_tmp=trim(fgets($f,65536));
if ($_tmp!='') $tmp.=$_tmp."n";
}
fseek($f,0,SEEK_SET);
fwrite($f,$tmp);
$tr=strlen($tmp);
ftruncate($f,$tr);
fclose($f);
}
if (($query3=='delete')||($query3=='answer'))
{
$query4=$query4+0;
$f=fopen($userpath.'gb-free-message.dat','r+');
for ($i=0;(!feof($f));$i++)
{
if ($i<$query4) $tmp_begin.=trim(fgets($f,65536))."n";
if ($i==$query4) $tmp_answer=explode("t",trim(fgets($f,65536)),5);
if ($i>$query4) $tmp_end.=trim(fgets($f,65536))."n";
}
fclose($f);
/*
0-время
1-имя
2-мыло
3-текст
4-ответ
*/
$newanswer=trim(utf2cyr(str_replace("n"," ",str_replace("r"," ",stripslashes($HTTP_POST_VARS['t'])))));
if ($HTTP_POST_VARS['tr2cyr']=='yes') $newanswer=trim(tr2rus($newanswer));
if ($query3=='answer')
{
if ($newanswer=='')
{
print $head.cyr2utf('<card id="edit" title="Изменяем ответ"><p>'.
'Ответ:<br/><input name="text'.$nocache.'" type="text" title="Ответ" value="'.str_replace("$","$$",htmlspecialchars($tmp_answer[4])).'" maxlength="512"/>'.
'<br/><select name="tr2cyr'.$nocache.'" multiple="true" value=""><option value="yes">Транслит</option></select>'.
'<br/><anchor>Заменить'.
'<go href="/?'.$id.'/admin/gb/'.$page.'/answer/'.$query4.'" method="post">'.
'<postfield name="t" value="$(text'.$nocache.')"/>'.
'<postfield name="tr2cyr" value="$(tr2cyr'.$nocache.')"/>'.
'</go>'.
'</anchor>'.
' <br/> <br/><a href="?'.$id.'/admin/gb">Отмена</a>'.
'</p></card></wml>');
exit();
}
else
{
$message2file=$tmp_begin.$tmp_answer[0]."t".$tmp_answer[1]."t".$tmp_answer[2]."t".$tmp_answer[3]."t".$newanswer."n".$tmp_end;
$f=fopen($userpath.'gb-free-message.dat','r+');
fseek($f,0,SEEK_SET);
fseek($f,0,SEEK_SET);
fwrite($f,$message2file);
$tr=strlen($message2file);
if ($tr<102400) ftruncate($f,$tr);
else ftruncate($f,102400);
fclose($f);
}
}
if ($query3=='delete')
{
$message2file=$tmp_begin."n".$tmp_end;
$f=fopen($userpath.'gb-free-message.dat','r+');
fseek($f,0,SEEK_SET);
$text=fread($f,102400);
fseek($f,0,SEEK_SET);
fwrite($f,$message2file);
$tr=strlen($message2file);
if ($tr<102400) ftruncate($f,$tr);
else ftruncate($f,102400);
fclose($f);
}
}
print $head.cyr2utf('<card id="gb" title="Админка:Гостевая книга"><do name="x" type="options" label="xPanel"><go href="?'.$id.'"/></do><do name="m" type="options" label="Админская"><go href="?'.$id.'/admin"/></do><p><small>');
$f=fopen($userpath.'gb-free-message.dat','r+');
fseek($f,0,SEEK_SET);
$cntpage=1;
$screen='';
$i=0;
while ($cntpage<=$page)
{
while (true)
{
if (feof($f)) { print $screen; $screen=''; break; }
$printmsg='';
$i++;
$tmpa=explode("t",fgets($f,65536),5);
if ((trim($tmpa[0])=='')&&(trim($tmpa[1])=='')) continue;
$printmsg='</small><u><anchor>'.date("j.m G:i",$tmpa[0]).'<go href="#op"><setvar name="l" value="'.($i-1).'"/></go></anchor></u>';
$printmsg.=' <b>'.cyr2utf(str_replace("$","$$",htmlspecialchars($tmpa[1]))).'</b> <small>';
$printmsg.='('.cyr2utf(str_replace("$","$$",htmlspecialchars($tmpa[2]))).')';
$printmsg.=' <br/>'.cyr2utf(str_replace("$","$$",htmlspecialchars($tmpa[3]))).' <br/>';
if ($tmpa[4]!='') $printmsg.=cyr2utf('<b>Ответ:</b> '.str_replace("$","$$",htmlspecialchars($tmpa[4]))).' <br/>';
$printmsg.=' <br/>';
if (strlen($screen.$printmsg)>2200)
{
if ($cntpage==$page) { print $screen; $screen=''; break; }
else { $screen=$printmsg; break; }
}
$screen.=$printmsg;
}
$cntpage++;
if ($screen=='') break;
}
print '</small>';
if ($page>1) print '<a href="?'.$id.'/admin/gb/'.($page-1).'"><<<</a> <br/>';
if (!feof($f)) print '<a href="?'.$id.'/admin/gb/'.($page+1).'">>>></a> <br/>';
print '<a href="/?'.$id.'" accesskey="#">xPanel</a>';
print '</p></card>';
print cyr2utf('<card id="op" title="Запись"><p>'.
'<a href="/?'.$id.'/admin/gb/'.$page.'/answer/$(l)">Ответ</a> <br/>'.
'<a href="/?'.$id.'/admin/gb/'.$page.'/delete/$(l)">Удалить</a> <br/>'.
' <br/><a href="#gb">Назад</a> <br/>'.
'</p></card></wml>');
exit();
?>