Hallo!
Ich möchte auf der Startseite meiner Homepage den letzten Eintrag aus meinem Gästebuch und meinem Forum stehen haben. Wie mache ich das mit PHP?
Ich hätte es gerne in dieser Form:
Gästebuch:
25.01.05 14:09 von User
Forum:
25.01.05 14:09 von User
Mein Forum ist das Burning Board 2.2.1
Und hier wäre mein Gästebuch-Code:
PHP
<html>
<head>
<title>Guestbook</title>
<script src="fade.js" language="Javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css">
<SCRIPT language=Javascript><!--
function setsmile(Zeichen) {
document.info.nachricht.value =
document.info.nachricht.value + Zeichen;
}
//-->
</SCRIPT>
</head>
<body style="background-image: url(http://noability.de/newdesign/Texthintergrund.jpg); background-attachment: fixed;">
<form name=info method=post ACTION="book.php">
<center>
<h1>Gästebuch</h1>
<table>
<tr>
<td>Name:</td>
<td><input maxLength="30" size="44" name="username" class="form"></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><input maxLength="30" size="44" name="usermail" class="form"></td>
</tr>
<tr>
<td>Homepage:</td>
<td><input maxLength="30" size="44" name="userhp" class="form"></td>
</tr>
<tr>
<td>ICQ#:</td>
<td><input maxLength="30" size="44" name="usericq" class="form"></td>
</tr>
<tr>
<td><center>Message:
[url='javascript:setsmile(':)')'][img]smile-02.gif[/img][/url]
[url='javascript:setsmile(':(')'][img]smile-10.gif[/img][/url]
[url='javascript:setsmile(';)')'][img]smile-05.gif[/img][/url]
[url='javascript:setsmile(':P')'][img]smile-06.gif[/img][/url]
[url='javascript:setsmile(':D')'][img]smile-03.gif[/img][/url]
[url='javascript:setsmile(';(')'][img]smile-07.gif[/img][/url]
[url='javascript:setsmile('8)')'][img]smile-01.gif[/img][/url]
[url='javascript:setsmile(':o')'][img]smile-04.gif[/img][/url]
[url='javascript:setsmile(':-|')'][img]smile-08.gif[/img][/url]
[url='javascript:setsmile('!!!')'][img]smile-09.gif[/img][/url]
[url='javascript:setsmile('8O')'][img]smile-11.gif[/img][/url]
[url='javascript:setsmile(':-')'][img]smile-12.gif[/img][/url]</p>
Um Bilder einzufügen benutze [url='javascript:setsmile('[img]URL[/img]')'][img]URL[/img][/url]</p>
</td>
<td><textarea name="nachricht" rows="10" cols="30" maxLength="100000" class="form"></textarea></td>
</tr>
</table>
<input type="submit" value="Senden" name="Submit" class="formbu"></td>
<input type="hidden" value="1" name="adminaction"></p>
</form>
<?php
// ***********************************CONFIGURATION***************************************
$name = 'bookdata.txt'; // Where the entries will be stored.
$timetowarp= 60; // Max Number of connected character till it warps. Adapt it if you change the fontsize! ATTENTION: Set this value not that small. Long picture URLs may not work anymore!
$admincode = 'whynot'; // Set the administration codeto delete messages!!!
$accolor = 'AAAAAA'; // Set color of entry-number and activ-page color.
$superusercode = '0000'; // Set the passcode for the superuser.
$superuserdisplayname = 'Your name'; // Set the display name of the superuser.
$usperuserdisplaycolor = 'FF0000'; // Set the displaycolor of the superuser.
// *********************************************WRITE DATA*****************************
$admin = $_GET['admin'];
$adminaction = $_POST['adminaction'];
$username = $_POST['username'];
$usermail = $_POST['usermail'];
$userhp = $_POST['userhp'];
$usericq = $_POST['usericq'];
$nachricht = $_POST['nachricht'];
$passcode = $_POST['passcode'];
$page = $_GET['page'];
$block = $_GET['block'];
if ($adminaction == 1 ) {
$adminaction = 0;
$ok = true;
$nachricht = eregi_replace("\[img]URL\[/img]", "", $nachricht);
if ($username == "" ) { $ok = false;}
if ($usermail== "" ) { $usermail = "No Entry!";}
if ($userhp== "" ) { $userhp = "No Homepage";}
if ($usericq== "" ) { $usericq = "No ICQ";}
if ($nachricht == "" ) { $ok = false;}
if (strpos($usermail, '@') == 0) { $usermail = "No Entry!";}
$username = ereg_replace (">", ">", $username);
$username = ereg_replace ("<", "<", $username);
$usermail = ereg_replace ("<", "<", $usermail);
$usermail = ereg_replace (">", ">", $usermail);
$userhp = ereg_replace ("<", "<", $userhp);
$userhp = ereg_replace (">", ">", $userhp);
$usericq = ereg_replace ("<", "<", $usericq);
$usericq = ereg_replace (">", ">", $usericq);
$nachricht = ereg_replace ("<", "<", $nachricht);
$nachricht = ereg_replace (">", ">", $nachricht);
$nachricht = ereg_replace ("\r\n", "
", $nachricht);
$nachricht = ereg_replace ("\n\r", "
", $nachricht);
$nachricht = ereg_replace ("\n", "
", $nachricht);
if ($ok == true) {
// RELOAD PROTECTION
if ( file_exists( $name) == TRUE)
{
$fd = fopen($name, "r");
$array = file($name);
fclose ($fd);
$zeilen = 0;
$i = sizeof($array);
while ($i--) {
$zeilen = $zeilen+1;
$arrayback[$zeilen] = trim($array[$i]);
}}
$zeile = $arrayback[1];
$temp = substr($zeile,strpos($zeile, '>')+1,strlen($zeile));
$temp = substr($temp,strpos($temp,">")+1, strlen($temp));
$nachrichtmirror = substr($temp,strpos($temp,">")+1,strlen($temp));
if ($nachricht <> $nachrichtmirror) {
$datumeingabe = date("d.m.y / H:i");
$file = fopen($name, "a");
fputs($file, "$datumeingabe>$username>$usermail>$userhp>$usericq>$nachricht");
fputs($file, "\r\n");
fclose($file);
} else {
// **********************************************RELOADSPERRE************************
echo '
Du hast das gleiche schon davor geschreiben!</p>';
}
}
// END RELOAD PROTECTION
if ($ok == false)
{
// ********************************************ZU WENIG ANGABEN
echo '
Bitte alle Felder ausfüllen!!!</p>';
}
}
$_GET['page'];
if ($page == '' ) {$page = 1;}
$_GET['block'];
if ($block == '' ) {$block = 1;}
$_GET['admin'];
if ($admin == '' ) {$admin = 0;}
// READ AND WRITE DATA IF DATABASE NEEDS TO BE CHANGED
if ($admin == 2) {
if ($passcode == $admincode) {
$fd = fopen($name, "r");
$array = file($name);
$i = sizeof($array);
fclose ($fd);
$fd = fopen($name, "w");
$s = 0;
while ($s <= $i):
if ($HTTP_POST_VARS['mes'][$s+1] <> 'DEL') { fputs($fd, $array[$s]); }
$s++;
endwhile;
fclose ($fd);
// ***************************************POSTS LÖSCHEN**********************************************
echo '[url='book.php?admin=0'][b]Ausgewählte Posts wurden gelöscht!!![/b][/url]
';
}
// ***************************************FALSCHES PASSWORT*****************************************
else { echo '<font color="#FF0000">[b]Falsches Passwort!!![/b]</font>
'; }
$admin=1;
}
// END READ AND WRITE DATA IF DATABASE NEEDS TO BE CHANGED
// READ DATA
if ( file_exists( $name) == TRUE)
{
$fd = fopen($name, "r");
$array = file($name);
fclose ($fd);
$zeilen = 0;
$i = sizeof($array);
while ($i--) {
$zeilen = $zeilen+1;
$arrayback[$zeilen] = trim($array[$i]) . "
\n";
}
// END READ DATA
$pagecopy = $page;
$page = ($page-1)*10;
if ($admin == 1 ) {echo '<form method=post ACTION="book.php?admin=2">'; }
echo '
Dieses Gästebuch enthält '.$zeilen.' Einträge.</p>';
for ($i = 1; $i <= 10; $i++) {
$zeile = $arrayback[$i+$page];
if ($zeile <> "") {
$datum = substr($zeile,0, strpos($zeile, '>') );
$temp = substr($zeile,strpos($zeile, '>')+1,strlen($zeile));
$username = substr($temp,0,strpos($temp,">"));
$temp = substr($temp,strpos($temp,">")+1, strlen($temp));
$usermail = substr($temp,0,strpos($temp,">"));
$temp = substr($temp,strpos($temp,">")+1, strlen($temp));
$userhp = substr($temp,0,strpos($temp,">"));
$temp = substr($temp,strpos($temp,">")+1, strlen($temp));
$usericq = substr($temp,0,strpos($temp,">"));
$nachricht = substr($temp,strpos($temp,">")+1, strlen($temp));
$nachricht = eregi_replace('\\\"', '"', $nachricht);
$nachricht = eregi_replace("\\\'", "'", $nachricht);
// SIMILIES ADAPTION
$nachricht = eregi_replace(":P", '[img]smile-06.gif[/img]', $nachricht);
$nachricht = eregi_replace("8)", '[img]smile-01.gif[/img]', $nachricht);
$nachricht = eregi_replace(":)", '[img]smile-02.gif[/img]', $nachricht);
$nachricht = eregi_replace(":-)", '[img]smile-02.gif[/img]', $nachricht);
$nachricht = eregi_replace(":D", '[img]smile-03.gif[/img]', $nachricht);
$nachricht = eregi_replace(":o", '[img]smile-04.gif[/img]', $nachricht);
$nachricht = eregi_replace(";)", '[img]smile-05.gif[/img]', $nachricht);
$nachricht = eregi_replace(";-)", '[img]smile-05.gif[/img]', $nachricht);
$nachricht = eregi_replace(";\(", '[img]smile-07.gif[/img]', $nachricht);
$nachricht = eregi_replace(":-\|", '[img]smile-08.gif[/img]', $nachricht);
$nachricht = eregi_replace("!!!", '[img]smile-09.gif[/img]', $nachricht);
$nachricht = eregi_replace(":\(", '[img]smile-10.gif[/img]', $nachricht);
$nachricht = eregi_replace("8o", '[img]smile-11.gif[/img]', $nachricht);
$nachricht = eregi_replace(":-", '[img]smile-12.gif[/img]', $nachricht);
// GENERATE URL LINKs
$fractal ='';
$setoff = 0;
for ($l = 0; $l <= strlen($nachricht); $l++) {
if ($nachricht[$l+0].$nachricht[$l+1].$nachricht[$l+2].$nachricht[$l+3] == 'http') {
if ($nachricht[$l-1] <> ']' ) {
$fractal = $fractal.'<a href="';
$setoff = 1;
$linkstrpos = $l;
}
}
if ($setoff == 1 ) { if ($nachricht[$l] == ' ' ) { $linkname = substr($nachricht, $linkstrpos, $l-$linkstrpos); $fractal = $fractal.'" target="_new">'.$linkname.'</a>'; $setoff = 0; } }
if ($setoff == 1 ) { if ($nachricht[$l] == '<' ) { $linkname = substr($nachricht, $linkstrpos, $l-$linkstrpos); $fractal = $fractal.'" target="_new">'.$linkname.'</a>'; $setoff = 0; } }
$fractal = $fractal.$nachricht[$l];
}
$nachricht = $fractal;
// CONVERT IMAGES
$nachricht = ereg_replace('\[\img]', '<img src="', $nachricht);
$nachricht = ereg_replace('\[\/img]', '">', $nachricht);
// DO THE WARPING
$warpcount = 0;
$fractal ='';
$iz = 0;
for ($z = 0; $z <= strlen($nachricht); $z++) {
$fractal = $fractal.$nachricht[$z];
$iz++;
if ($iz == $timetowarp) {
$dowarp = false;
if (strpos(substr($nachricht, ($warpcount*$timetowarp), $timetowarp),' ') === false ) { $dowarp = true; }
if (strpos(substr($nachricht, ($warpcount*$timetowarp), $timetowarp),'<') === true ) { $dowarp = false; }
if (strpos(substr($nachricht, ($warpcount*$timetowarp), $timetowarp),'/') === true ) { $dowarp = false; }
if ($dowarp == true) { $fractal = $fractal.' ';}
$warpcount = $warpcount+1;
$iz = 0;
}
}
$nachricht = $fractal;
// END DO THE WARPING
$nummerdis = $zeilen-($i+$page)+1;
// ***************************************EINTRAG LÖSCHEN**************************************
if ($admin == 1 ) {$deletebox = '
Diesen Eintrag löschen!!!<input type="checkbox" name="mes['.$nummerdis.']" value="DEL" >';}
if ($usermail <> 'No Entry!' ) { $mailthere = '<a href="mailto:'.$usermail.'">';} else { $mailthere = '';}
if ($userhp <> 'No Homepage' ) { $linkthere = '<a href="'.$userhp.'">';} else { $linkthere = '';}
// SUPERUSER
if ($username === $superusercode )
{
$username = $superuserdisplayname;
$suci = '<font color="#'.$usperuserdisplaycolor.'">';
$tmpaccolor = $usperuserdisplaycolor;
}
else
{
$suci = '';
$tmpaccolor = $accolor;
}
// END SUPERUSER
echo '<table cellpadding=8 cellspacing=0 border=2 width=100%>
<tr>
<td>[b]'.$nummerdis.'[/b] Es schrieb [b]'.$suci.$username.'[/b] '.$mailthere.$usermail.'</a> / '.$linkthere.$userhp.'</a> / '.$usericq.'</td</tr><tr><td>
'.$suci.$nachricht.$deletebox.'
[b]'.$suci.$datum.' Uhr[/b]
</td>
</tr>
</TABLE>';
}}
// GENERATE DYNAMIC PAGE SELECTION
$pages = ceil($zeilen/10);
echo 'Seite:';
if ($block > 1 )
{
echo '[url='book.php?block=1']<< [/url][url='book.php?block='.($block-25).'&admin='.$admin.'']< [/url]';
}
for ($i = $block; $i <= $pages; $i++)
{
echo '[b][url='book.php?page='.$i.'&block='.$block.'&admin='.$admin.'']'.$activcolor.$i.'[/url] </font>| ';
$intercount = $intercount+1;
if ($intercount == 25 ) {
if ($zeilen > $intercount*10 ) {
echo '[url='book.php?page='.($i+1).'&block='.($i+1).'']>[/url]
[url='book.php?page='.(((floor(($pages/25)))*25)+1).'&block='.(((floor(($pages/25)))*25)+1).'&admin='.$admin.'']>>[/url]';
}
break; }
}
echo $activcolor;
echo '</font>[/b]</tr></table>';
}
if ($admin == 1 ) {
echo'
[b]<font color="#FF0000"> Passwort: </font>
<input type="password" maxLength="10" size="11" name="passcode" class="form">
<input type="submit" value="Submit" name="Submit" class="formbu">
</form>';
}
if ($admin == 0 ) {$disadmin= '<align="right">
[url='book.php?admin=1']Administration[/url] ';}
if ($admin == 1 ) {$disadmin= '<align="right">
[url='book.php?admin=0']Administration verlassen [/url]';}
// END GENERATE DYNAMIC PAGE SELECTION
echo $disadmin ;
echo $messcount;
?>
</body>
</html>
Alles anzeigen
Vielen Dank schon im Voraus für die HIlfe!