<?php
/*$ref=getenv('HTTP_REFERER');
if(!ereg("^[url]http://адрес.нашего.сайта[/url]",$ref)) {
echo("error wrong referer!");
exit;
} */
$file_gb="ggb.xml";
$file_tmp="/gbtmp.txt";
$MAX=50;
echo "<head>
<link rel='stylesheet' type='text/css' href='../scripts/style.css'>
</head>";
// Запись в ИксЭмЭл
function add($Ftitle,$Fmail,$Fsite,$Fauthor,$Fpost) {
global $Fsite;
global $Fpost;
global $Fauthor;
global $Fmail;
global $Ftitle;
global $numerlas;
$nun=$numerlas+1;
function stripFormSlashes($arr) {
if (!is_array($arr)){
return stripslashes($arr);
} else {
return array_map('stripFormSlashes',$arr);
}
}
if (get_magic_quotes_gpc()) {
$_GET=stripFormSlashes($_GET);
$_POST=stripFormSlashes($_POST);
}
$dom=new DOMDocument('/gbook/gb.xml');
$dom->load('/gbook/gb.xml');
$postreply=$dom->createElement('postreply');
//num
$num=$dom->createElement('num');
$numtext=$dom->createTextNode($nun);
$num->appendChild($numtext);
//author
$author=$dom->createElement('author');
$authortext=$dom->createTextNode($_POST['Fauthor']);
$author->appendChild($authortext);
//mail
$mail=$dom->createElement('mail');
$mailtext=$dom->createTextNode($_POST['Fmail']);
$mail->appendChild($mailtext);
//post
$post=$dom->createElement('post');
$posttext=$dom->createTextNode($_POST['Fpost']);
$post->appendChild($posttext);
//site
$site=$dom->createElement('site');
$sitetext=$dom->createTextNode($_POST['Fsite']);
$site->appendChild($sitetext);
//title
$title=$dom->createElement('title');
$titletext=$dom->createTextNode($_POST['Ftitle']);
$title->appendChild($titletext);
//date
$date=$dom->createElement('date');
$datetext=$dom->createTextNode(date('d\.m\.Y\.\-G\:i'));
$date->appendChild($datetext);
//conning
$postreply->appendChild($num);
$postreply->appendChild($mail);
$postreply->appendChild($site);
$postreply->appendChild($title);
$postreply->appendChild($date);
$postreply->appendChild($author);
$postreply->appendChild($post);
//saving
$dom->save('/gbook/gb.xml');
echo"Quote Saved\n";
//unset ($Ftitle,$Fauthor,$Fpost,$Fpost,$Fmail);
//echo "$Ftitle,$Fauthor,$Fpost,$Fpost,$Fmail";
//echo "постец - $_POST[Fpost]";
}
//Функция анти ХСС
function nohtml($string) {
$html = array ( "&" => "&", "\"" => "\"", "<" => "<", ">" => ">", " " => " " );
for(reset($html); $key=key($html); next($html)) {
$string = str_replace("$key","$html[$key]",$string);
}
}
// Собственно просмотр
function view()
{
$xml=simplexml_load_file('/gbook/gb.xml');
foreach ($xml->postreply as $postreply) {
echo'<br><FIELDSET >';
$num=htmlspecialchars($postreply->num);
$mail=htmlspecialchars($postreply->mail);
$site=htmlspecialchars($postreply->site);
$date=htmlspecialchars($postreply->date);
$author=htmlspecialchars($postreply->author);
$title=htmlspecialchars($postreply->title);
$post=htmlspecialchars($postreply->post);
$mail=str_replace("@","@",$mail);
echo "<LEGEND>$num</LEGEND>
<table style='border;0' width='100%' height='100%' id='news'>
<tr>
<th>$title</th><td>$date</td>
</tr>
<tr>
<td class='aus'><a class='gbook' href='mailto:$mail'>$author</a></td><td><a href='http://$site' target=blank>$site</a></td>
</tr>
<tr>
<td colspan=2>$post</td>
</tr>
</table>
</fieldset><br>";
global $numerlas;
$numerlas = $num;
//if ($num==50) break;
}
}
echo "
<form method='POST'>
<table>
<tr>
<th>Тема</th>
<td><input type='tex' name='Ftitle' size='52'></td></tr>
<tr>
<th>Электроящик:</th>
<td><input type='text' name='Fmail' size='52'></td></tr>
<tr> <th>Сайт:</th>
<td><input type='text' value='Пожалуйста, не пишите [url]http://[/url]' name='Fsite' size='52'></td></tr>
<tr> <th>Автор:</th>
<td><input type='text' name='Fauthor' size='52'></td></tr>
<tr> <th>Пост:</th>
<td><textarea rows='6' name='Fpost' cols='41'></textarea>
<p><input type='submit' value='Отправить' name='go'><input type='reset' value='Сброс' name='B10'></td></tr>
</table>
</form>
";
if (isset($go)) {
add($Ftitle,$Fmail,$Fsite,$Fauthor,$Fpost);
}
else {
echo "Вот, то где собачка порылась....";
}
@view();
//echo "$numerlas\n";
//foreach ($_POST as $a){
//echo "$a";
//}
?>