Her er lige hele koden, kan jeg regne ud der snart vil blive spurt om :-):
////////////////////////////
// Get Datas
////////////////////////////
require ('tbdata.php');
////////////////////////////
$extrapages = "no";
$ip = getenv("REMOTE_ADDR");
$time = time() + 32400;
$date = date("d-m-Y H:i:s");
$passcrypt = $crypted;
$poly = filesize($thisprog);
///////////////////////////
/// Log Funktion
///////////////////////////
$readfile = file("log.txt");
$writedata = fopen ("log.txt", "a");
fputs ($writedata, "$ip entered Tagbook on $date\n") or die("Error");
fclose ($writedata);
///////////////////////////
// Write Funktion
///////////////////////////
if ($action == "write") {
////////////////////////////
// Flood Control
////////////////////////////
$readfile = file($getdata);
$lastline = count($readfile) - 1;
$datas = explode("|", $readfile[$lastline]);
$lastip = $datas[6];
$lasttime = $datas[9];
if ($ip == $lastip) {
$checktime = str_replace(" ?>","",$lasttime);
$checktime2 = $checktime + $flood;
if ($time < $checktime2) {
echo '<html>';
echo '<head><body background="../images/bg.gif">';
echo '<body bgcolor="'.$bgcolor.'">';
echo '<meta http-equiv="refresh" content="4;URL='.$thisprog.'">';
echo '<title>You already Posted</title>';
echo '</head>';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="2">No need to post a new message right after your last one.</font><br>';
echo '<font face="'.$fontm.'" color="'.$colorm.'" size="2">Du bliver viderestillet tilbage til gæstebogen...</font></p>';
echo '</body>';
echo '</html>';
exit;
}
}
////////////////////////////
// Remove html
////////////////////////////
$fixmessage = str_replace("<","<",$message);
$fixmessage = str_replace(">",">",$fixmessage);
$name = str_replace("<","<",$name);
$name = str_replace(">",">",$name);
$email = str_replace("<","<",$email);
$email = str_replace(">",">",$email);
$icq = str_replace("<","<",$icq);
$icq = str_replace(">",">",$icq);
$web = str_replace("<","<",$web);
$web = str_replace(">",">",$web);
////////////////////////////
// Remove new-lines
////////////////////////////
$fixmessage = str_replace("
","<br>",$fixmessage);
////////////////////////////
// Add HTML links
////////////////////////////
$outmessage = ereg_replace("((f|ht){1}
tp://[a-zA-Z0-9@:%_.~#-\?&]+)","<a href=\"\\1\">\\1</a>",$fixmessage);
////////////////////////////
// Add IMG tags
////////////////////////////
$fixmessage = str_replace("[IMG]","<img src=\"",$fixmessage);
$fixmessage = str_replace("[/IMG]","\">",$fixmessage);
////////////////////////////
// Add BOLD tags
////////////////////////////
$fixmessage = str_replace("[BOLD]","<b>",$fixmessage);
$fixmessage = str_replace("[/BOLD]","</b>",$fixmessage);
////////////////////////////
// PHP fail fix!
////////////////////////////
$fixmessage = str_replace("\\","",$fixmessage);
////////////////////////////
$readfile = file($getdata);
$nrall = count($readfile);
$nrall1 = $nrall - 1;
$datas = explode("|", $readfile[$nrall1]);
$nextid = $datas[0];
$nextid = str_replace("<? ","",$nextid);
$nextid = $nextid + 1;
$dateinfo = $date;
$writedata = fopen ($getdata, "a");
fputs ($writedata, "<? $nextid|$name|$email|$icq|$web|$fixmessage<br>|$ip|$dateinfo|$icon|$time ?>\n") or die("Error");
fclose ($writedata);
if ($writedate != "false") {
echo '<html>';
echo '<head>';
echo '<body bgcolor="'.$bgcolor.'">';
echo '<meta http-equiv="refresh" content="2;URL='.$thisprog.'">';
echo '<title>Thanks for posting</title>';
echo '</head>';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">Tak for din besked.<br>';
echo 'Du bliver viderestillet tilbage til gæstebogen...</font></p>';
echo '</body>';
echo '</html>';
}
exit;
}
///////////////////////////
// Comment Funktion
///////////////////////////
if ($action == "adminwrite") {
$check = md5($crypt);
if ( $check == $passcrypt ) {
////////////////////////////
// Remove new-files
////////////////////////////
$fixadmin = str_replace("
","<br>",$admin);
////////////////////////////
$searched = "0";
$file = file($getdata);
$total = count($file);
while($searched < $total) {
$datas = explode("|", $file[$searched]);
$toedit = $datas[0];
$toedit = str_replace("<? ","",$toedit);
$name = $datas[1];
$email = $datas[2];
$icq = $datas[3];
$web = $datas[4];
$message = $datas[5];
$ip = $datas[6];
$dateinfo = $datas[7];
$icon = $datas[8];
$time = $datas[9];
if ($toedit == $id) {
$newfile .= "<? $id|$name|$email|$icq|$web|$message <br><u>Webmaster Kent's kommentar:</u><br>>> $fixadmin|$ip|$dateinfo|$icon|$time";
} else {
$newfile .= $file[$searched];
}
$searched++;
}
$writedata = fopen ($getdata, "w");
fputs ($writedata, "$newfile") or die("Error");
fclose ($writedata);
if ($writedate != "false") {
echo '<html>';
echo '<head>';
echo '<body bgcolor='.$bgcolor.'">';
echo '<meta http-equiv="refresh" content="2;URL='.$thisprog.'">';
echo '<title>Thanks for posting the comment</title>';
echo '</head>';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">Thanks for posting a comment to that post in the Guestbook.<br>';
echo 'Du bliver viderestillet tilbage til gæstebogen...</font></p>';
echo '</body>';
echo '</html>';
}
exit;
} else {
echo '<html>';
echo '<head>';
echo '<body bgcolor='.$bgcolor.'">';
echo '<meta http-equiv="refresh" content="2;URL='.$thisprog.'?action=comment&id='.$id.'">';
echo '<title>Wrong Password</title>';
echo '</head>';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">FORKERT PASSWORD - DIN IP ADRESSE ER LOGGET !<br>';
echo 'You will be redirected back in a second.</font></p>';
echo '</body>';
echo '</html>';
exit;
}
}
///////////////////////////
// Delete Funktion
///////////////////////////
if ($action == "delete") {
$check = md5($crypt);
if ( $check == $passcrypt ) {
////////////////////////////
$searched = "0";
$file = file($getdata);
$total = count($file);
while($searched < $total) {
$datas = explode("|", $file[$searched]);
$todel = $datas[0];
$todel = str_replace("<? ","",$todel);
if ($todel == $id) {
$newfile .= "";
} else {
$newfile .= $file[$searched];
}
$searched++;
}
$writedata = fopen ($getdata, "w");
fputs ($writedata, "$newfile") or die("A Error Acurred or the post you deleted was the lastone!");
fclose ($writedata);
echo '<html>';
echo '<head>';
echo '<body bgcolor='.$bgcolor.'">';
echo '<meta http-equiv="refresh" content="2;URL=java script:window.close()">';
echo '<title>Post Deleted</title>';
echo '</head>';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">The Post is deleted!.<br>';
echo 'Closing Window in a second...</font></p>';
echo '</body>';
echo '</html>';
exit;
} else {
echo '<html>';
echo '<head>';
echo '<body bgcolor="'.$bgcolor.'">';
echo '<title>Enter Password</title>';
echo '</head>';
echo '<form method="POST" action="'.$thisprog.'">';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">Password: <input type="password" name="crypt" size="20"><input type="submit" value="Send" name="B1"></font></p>';
echo '<input type="hidden" name="action" value="delete">';
echo '<input type="hidden" name="id" value="'.$id.'">';
echo '</body>';
echo '</html>';
exit;
}
}
////////////////////////////
// Funktion IP
////////////////////////////
if ($action == "ip") {
$check = md5($crypt);
if ( $check == $passcrypt ) {
$file = file($getdata);
$searched = "0";
$total = count($file);
while($searched < $total) {
$datas = explode("|", $file[$searched]);
$tofind = $datas[0];
$tofind = str_replace("<? ","",$tofind);
$ipname = $datas[1];
if ($tofind == $id) {
$ip = $datas[6];
$name = $datas[1];
echo '<html>';
echo '<head>';
echo '<body bgcolor='.$bgcolor.'">';
echo '<title>Post Deleted</title>';
echo '</head>';
echo '<font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">'.$ipname.'s IP is: '.$ip.'<br><a href="java script:window.close()">Close Window</a>';
echo '</body>';
echo '</html>';
}
$searched++;
}
exit;
} else {
echo '<html>';
echo '<head>';
echo '<body bgcolor="'.$bgcolor.'">';
echo '<title>Enter Password</title>';
echo '</head>';
echo '<form method="POST" action="'.$thisprog.'">';
echo '<p><font face="'.$fontm.'" color="'.$colorm.'" size="'.$sizem.'">Password: <input type="password" name="crypt" size="20"><input type="submit" value="Send" name="B1"></font></p>';
echo '<input type="hidden" name="action" value="ip">';
echo '<input type="hidden" name="id" value="'.$id.'">';
echo '</body>';
echo '</html>';
exit;
}
}