nabend,
ich hab hier ma vor geraumer zeit nen code bekommen über wer-weiss-was.de, womit ich ein gästebuch habe…queellcode wie folgt:
<?php $filename = 'comments.txt';$script = 'guests.php'; $form = 'Name:Beitrag:
';
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$pglen = 6; $page = isset( $_GET['p']) ? $_GET['p'] : 1;
print make_header("Guests");
if( ! isset( $_POST['submit'] ) ) {
function mydecode($s) { return chr(hexdec($s)); }
$rg = "/\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)[\s\r\n]+/";
preg_match_all($rg, file_get_contents($filename), $tm, PREG_SET_ORDER);
$offset = ($page - 1) * $pglen;
print $form;
foreach( array_slice( array_reverse($tm), $offset, $pglen) as $record ) {
$name = implode('', array_map('mydecode', str_split($record[4], 2)));
$text = implode('', array_map('mydecode', str_split($record[5], 2)));
print "$name ($record[3]) schrieb "
. "am $record[1] ($record[2])"
. nl2br(htmlentities($text,ENT_QUOTES)) . "\n";
}
print make_pagelinks( $page, $pglen, count($tm), "$script?p=" );
}
else {
function myencode($n) { return sprintf("%02X",ord($n)); }
$name = implode('', array_map('myencode', str_split($_POST['name'])));
$text = implode('', array_map('myencode', str_split($_POST['text'])));
$time = date("Y-m-d H:i:s"); $client = $_SERVER['REMOTE_ADDR'];
if( strlen($name) > 1 && strlen($text) > 1 ) {
$fh = fopen($filename, 'a') or die("Dateifehler $filename !");
fwrite($fh, "$time $client $name $text\n");
fclose($fh);
}
print '';
}
print '