Ihan toimiva vieraskirja, värit laita itse ja tee data.txt ja chmoddaa 666.
Suomi.inc.php
<?php // Kirosana filtteri: $lgbdwrd = array("vittuu koko sivu"); // Document encoding $metatag = "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">"; // "selvennykset" $lgtxt[0] = "Vieraskirja..."; $lgtxt[1] = "Etusivu"; $lgtxt[2] = "Uusi viesti"; $lgtxt[3] = "Admin"; $lgtxt[4] = "Edellinen"; $lgtxt[5] = "Seuraava"; $lgtxt[6] = "Yhteensä viestejä"; $lgtxt[7] = "Uusi viesti"; $lgtxt[8] = "Nimi"; $lgtxt[9] = "Sähköpostiosoite"; $lgtxt[10] = "Kotisivuosoite"; $lgtxt[11] = "Viesti"; $lgtxt[12] = "Yksityisviesti sivun ylläpitäjälle"; $lgtxt[13] = "» Tyhjennä"; $lgtxt[14] = "» Lähetä"; $lgtxt[15] = "Tallennetu"; $lgtxt[16] = "Lähetetty"; $lgtxt[17] = "Ei osoitetta"; $lgtxt[18] = "Ei kotisivuja"; $lgtxt[20] = "Admin"; $lgtxt[21] = "Anna salasana."; $lgtxt[22] = "» Kirjaudu sisään"; $lgtxt[23] = "Poista"; $lgtxt[24] = "Muokkaa"; $lgtxt[25] = "Päivämäärä"; $lgtxt[26] = "Kello"; $lgtxt[27] = "Ip"; $lgtxt[28] = "Selain"; $lgtxt[29] = "Muokkaa viesti"; $lgtxt[30] = "Vastaus"; $lgtxt[50] = "HTML koodit sallittu"; $lgtxt[51] = "HTML koodit ei sallittu"; $lgerr[0] = "Virhe"; $lgerr[1] = "Viestin lähettäminen epäonnistui, sanat viestissä ovat liian pitkiä."; $lgerr[2] = "Viestin lähettäminen epäonnistui, viesti on liian pitkä."; $lgerr[3] = "Viestin lähettäminen epäonnistui, nimi tai viesti kenttä oli tyhjä."; $lgerr[4] = "Viestin lähettäminen epäonnistui, voit lähettää vain yhden viestin."; $lgerr[5] = "Kirjautuminen epäonnistui, väärä salasana."; $lgerr[6] = "Viestin poistaminen epäonnistui, kirjaudu ensin sisään."; $lgerr[7] = "Viestin muokkaaminen epäonnistui, kirjaudu sisään."; $lgpri[0] = "Yksityisviesti"; $lgpri[1] = "Viestisi on lähetetty ylläpitäjälle!"; ############################################################ ?>
viekku.php
<?php session_start(); $gb_name = "Vieraskirja"; // Vieraskirjan nimi $gb_data = "data.txt"; // chmoddaa 666 $gb_psswd = "salasana"; // Salasanasi $gb_mail = "mailisi@hotmail.com"; // Mailisi, privaatti viestit tähä... include("suomi.inc.php"); // Elä koske // true = Päällä, false = Ei päällä $gb_flthtml = false; // Html koodi filtteri (tässä o vissii jotekii vääripäi :D) $gb_url2lnk = true; // Muuttaa osoitteen linkiksi viestissä $gb_smiley = false; // Hymiöt $gb_fltbdwrd = false; // Kirosanojen poistaja $gb_privmsg = true; // Privaatti viestit $gb_fltspam = true; // Spam filtteri $gb_msgpg = 5; // Viestejä per sivu $gb_lngwrd = 35; // Sanoja enintään per viesti. $gb_lngmsg = 250; // Viestejen määrä ########################################################################## function flt_tags ($text, $html){ if ($html) { $text = strip_tags($text); $text = htmlspecialchars($text);} $text = ereg_replace("\|", "", $text); $text = ereg_replace("\r", "", $text); $text = ereg_replace("\n", "<br> ", $text); $text = stripslashes($text); $text = trim($text); return $text; } function flt_bdwrd ($text, $badwords){ foreach ($badwords as $badword){ $text = str_replace ($badword, "***", $text);} return $text; } function flt_smiley ($text){ $text = ereg_replace(" :)", " <img src=\"images/sm01.gif\" width=\"15\" height=\"15\" alt=\":)\" border=\"0\">", $text); $text = ereg_replace(" :D", " <img src=\"images/sm02.gif\" width=\"15\" height=\"15\" alt=\":D\" border=\"0\">", $text); $text = ereg_replace(" 8)", " <img src=\"images/sm03.gif\" width=\"15\" height=\"15\" alt=\"8)\" border=\"0\">", $text); $text = ereg_replace(" ;)", " <img src=\"images/sm04.gif\" width=\"15\" height=\"15\" alt=\";)\" border=\"0\">", $text); $text = ereg_replace(" :P", " <img src=\"images/sm05.gif\" width=\"15\" height=\"15\" alt=\":P\" border=\"0\">", $text); $text = ereg_replace(" :o", " <img src=\"images/sm06.gif\" width=\"15\" height=\"15\" alt=\":o\" border=\"0\">", $text); $text = ereg_replace(" :\(", " <img src=\"images/sm07.gif\" width=\"15\" height=\"15\" alt=\":(\" border=\"0\">", $text); return $text; } function test_lngwrd ($text, $lng){ $test = explode(" ", $text); foreach ($test as $word){ if (strlen($word) > $lng){$tmp = true;}} if ($tmp){return $tmp;} } function test_lngmsg ($text, $lng){ if (strlen($text) > $lng){$tmp = true;} if ($tmp){return $tmp;} } function test_email($email){ if (eregi("^([a-z]|[0-9]|\.|-|_)+@([a-z]|[0-9]|\.|-|_)+\.([a-z]|[0-9]){2,3}$", $email, $arr_vars) && !eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $email, $arr_vars)){ return true;} else {return false;} } ############################################################ # Main code if($action == "msgnew"){ if ($spam && $gb_fltspam){$msg_txt = $lgerr[4]; $msg_cap = $lgerr[0]; $id="message";} else { if($name & $message){ $name = flt_tags ($name,1); $email = flt_tags ($email,1); $page = flt_tags ($page,1); $message = flt_tags ($message,$gb_flthtml); $index = date("YmdHis",time()); $day = date("d.m.Y",time()); $time = date("H:i",time()); if (test_lngwrd($message,$gb_lngwrd)){$msg_txt = $lgerr[1]; $msg_cap = $lgerr[0]; $id="message";} elseif (test_lngmsg($message,$gb_lngmsg)){$msg_txt = $lgerr[2]; $msg_cap = $lgerr[0]; $id="message";} elseif ($private) { $mail_msg = "---------------------------------------------------------------\n". "The folowning information was submitted on\n". "$day $time\n". "---------------------------------------------------------------\n". "Nimi: $name\n". "Email: $email\n". "URL: $page\n". "viesti: $message.\n". "---------------------------------------------------------------\n". "Remote host: $REMOTE_HOST \n". "Remote address: $REMOTE_ADDR \n". "User Agent: $HTTP_USER_AGENT \n". "---------------------------------------------------------------\n"; mail($gb_mail, "Privaatti vieraskirja viesti", $mail_msg, "From: $name <$email>"); $msg_txt = $lgpri[1]; $msg_cap = $lgpri[0]; $id="message"; session_register("spam"); $spam = true; } else { $data = fopen($gb_data, "a"); fwrite($data, "$index|$day|$time|$REMOTE_ADDR|$HTTP_USER_AGENT|$name|$email|$page|$message|||\r\n"); fclose($data); session_register("spam"); $spam = true; } } else{$msg_txt = $lgerr[3]; $msg_cap = $lgerr[0]; $id = "message";} } } if($action == "logon"){ if ($password == $gb_psswd){ session_register("psswd"); $psswd = $password; } else {$msg_txt = $lgerr[5]; $msg_cap = $lgerr[0]; $id="message";} } if($msgdelete || $msgdelete == "0" ){ if ($psswd == $gb_psswd){ $data = file($gb_data); rsort ($data); unset($data[$msgdelete]); $fp = fopen($gb_data,"w"); foreach ($data as $row){fputs($fp, $row);} fclose($fp); } else{$msg_txt = $lgerr[6]; $msg_cap = $lgerr[0]; $id="message";} } if($msgedit || $msgedit == "0" ){ if ($psswd == $gb_psswd){ $id = "edit"; } else{$msg_txt = $lgerr[7]; $msg_cap = $lgerr[0]; $id="message";} } if($msgreplace){ if ($psswd == $gb_psswd){ $data = file($gb_data); rsort ($data); $message = flt_tags ($message,$gb_flthtml); $comment = flt_tags ($comment,0); $data[$num] = "$index|$day|$time|$ip|$browser|$name|$email|$page|$message|$comment|0\r\n"; $fp = fopen($gb_data,"w"); foreach ($data as $row){fputs($fp, $row);} fclose($fp); } else{$msg_txt = $lgerr[6]; $msg_cap = $lgerr[0] [0]; $id="message";} } ############################################################ # HTML code ?> <html> <head> <title><?php print("$gb_name");?></title> <?php print("$metatag");?> <style type="text/css"> <!-- a { text-decoration: none} .fontnorm { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px} .fontmini { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px} --> </style> <SCRIPT language="JavaScript" type="text/javascript"> <!-- function setsmiley(which){ document.newmessage.message.value = document.newmessage.message.value + which; } //--> </SCRIPT> </head> <body bgcolor="#0084FF" text="#000000" link="#333333" vlink="#333333" alink="#333333"> <table width="500" border="0" cellspacing="0" cellpadding="2" align="center"> <tr><td bgcolor="#0084FF"> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <tr><td bgcolor="#0084FF"> <span class="fontnorm"> <b><?php print("$gb_name");?></b></span><br> <span class="fontmini"> <?php print("$gb_name [0]");?></span> </td></tr><tr><td bgcolor="#0084FF" class="fontmini"> » <a href="<?php print("$PHP_SELF");?>"><?php print("$lgtxt[1]");?></a> | <a href="<?php print("$PHP_SELF?id=new");?>"><?php print("$lgtxt[2]");?></a> | <a href="<?php print("$PHP_SELF?id=admin");?>"><?php print("$lgtxt[3]");?></a> </td></tr></table> </td></tr> </table> <table width="500" border="0" cellspacing="1" cellpadding="0" align="center"> <tr><td class="fontmini"><?php $data = file($gb_data); $maxmsg = count($data); print ("$lgtxt[6]: $maxmsg"); ?></td><td align="right" class="fontmini"> <?php rsort ($data); If(!$pg){$pg=0;} If($pg==0){print("<font color=\"#DDDDDD\">« $lgtxt[4]</font>");} else{$tmp = $pg -1; print("<a href=\"$PHP_SELF?pg=$tmp\">« $lgtxt[4]</a>");} $tmp = $pg * $gb_msgpg + $gb_msgpg; print(" | "); if ($maxmsg > $tmp){$tmp = $pg + 1; print ("<a href=\"$PHP_SELF?pg=$tmp\">$lgtxt[5] »</a>");} else {print("<font color=\"#DDDDDD\">$lgtxt[5] »</font>");} ?> </td></tr> </table> <table width="500" border="0" cellspacing="0" cellpadding="2" align="center"> <tr><td bgcolor="#0084FF"> <?php ############################################################ # Error message if ($id=="message"){?> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <tr><td bgcolor="#0084FF" colspan="2" align="center" class="fontnorm"><b><?php print($msg_cap);?></b></td></tr> <tr><td bgcolor="#0084FF" colspan="2" align="center" class="fontnorm"><p><br><?php print($msg_txt);?><br><br></p></td></tr> </table> <?php } ############################################################ # admin elseif ($id=="admin"){?> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <tr><td bgcolor="#FFFFFF" colspan="2" align="center" class="fontnorm"><b><?php print($lgtxt[20]);?></b></td></tr> <tr><td bgcolor="#FFFFFF" colspan="2" align="center" class="fontnorm"><p><?php print($lgtxt[21]);?><br> <form method="post" action="<?php print $PHP_SELF ?>"> <input type="password" name="password"> <input name="action" type="hidden" value="logon"> <input type="submit" name="Submit" value="<?php print($lgtxt[22]);?>"> </form> <br></p></td></tr> </table> <?php } ############################################################ # Edit entry elseif ($id=="edit"){ $data = file($gb_data); rsort ($data); $info = explode("|",$data[$msgedit]); ?> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <form method="post" action="<?php print $PHP_SELF ?>"> <tr><td bgcolor="#DDDDDD" colspan="2" align="center" class="fontnorm"><b><?php print("$lgtxt[29]");?></b></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[25]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="day" size="40" value="<?php print("$info[1]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[26]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="time" size="40" value="<?php print("$info[2]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[27]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="ip" size="40" value="<?php print("$info[3]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[28]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="browser" size="40" value="<?php print("$info[4]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[8]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="name" size="40" value="<?php print("$info[5]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[9]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="email" size="40" value="<?php print("$info[6]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[10]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="page" size="40" value="<?php print("$info[7]"); ?>"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[11]");?> :</td> <td bgcolor="#FFFFFF" width="363"><textarea name="message" cols="40" rows="5"><?php print("$info[8]"); ?></textarea></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[30]");?> :</td> <td bgcolor="#FFFFFF" width="363"><textarea name="comment" cols="40" rows="5"><?php print("$info[9]"); ?></textarea></td></tr> <tr><td bgcolor="#FFFFFF" width="130"><input type="hidden" name="index" value="<?php print("$info[0]"); ?>"> <input type="hidden" name="num" value="<?php print("$msgedit"); ?>"></td> <td bgcolor="#0084FF" width="363"><input type="submit" name="msgreplace" value="<?php print("$lgtxt[14]");?>"></td></tr> </form> </table> <?php } ############################################################ # Add entry elseif ($id=="new"){?> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <form name="newmessage" method="post" action="<?php print $PHP_SELF ?>"> <tr><td bgcolor="#FFFFFF" colspan="2" align="center" class="fontnorm"><b><?php print("$lgtxt[7]");?></b></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[8]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="name" maxlength="30" size="40"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[9]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="email" maxlength="40" size="40"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[10]");?> :</td> <td bgcolor="#FFFFFF" width="363"><input type="text" name="page" maxlength="40" value="http://" size="40"></td></tr> <tr><td bgcolor="#FFFFFF" width="130" align="right" class="fontnorm"><?php print("$lgtxt[11]");?> :</td> <td bgcolor="#FFFFFF" width="363" class="fontnorm"><textarea name="message" cols="40" rows="5"></textarea> <?php if ($gb_privmsg){?><br><input type="checkbox" name="private" value="true"> <?php print("$lgtxt[12]");?><?php }?></td></tr> <?php if ($gb_smiley){?> <tr><td bgcolor="#0084FF" width="130"> </td> <td bgcolor="#0084FF" width="363"> <A HREF="javascript:setsmiley(' :)')" ONFOCUS="filter:blur()"><img src="images/sm01.gif" width="15" height="15" alt=":)" border="0"></a> <A HREF="javascript:setsmiley(' :D')" ONFOCUS="filter:blur()"><img src="images/sm02.gif" width="15" height="15" alt=":D" border="0"></a> <A HREF="javascript:setsmiley(' 8)')" ONFOCUS="filter:blur()"><img src="images/sm03.gif" width="15" height="15" alt="8)" border="0"></a> <A HREF="javascript:setsmiley(' ;)')" ONFOCUS="filter:blur()"><img src="images/sm04.gif" width="15" height="15" alt=";)" border="0"></a> <A HREF="javascript:setsmiley(' :P')" ONFOCUS="filter:blur()"><img src="images/sm05.gif" width="15" height="15" alt=":P" border="0"></a> <A HREF="javascript:setsmiley(' :o')" ONFOCUS="filter:blur()"><img src="images/sm06.gif" width="15" height="15" alt=":o" border="0"></a> <A HREF="javascript:setsmiley(' :(')" ONFOCUS="filter:blur()"><img src="images/sm07.gif" width="15" height="15" alt=":(" border="0"></a> </td></tr> <?php }?> <tr><td bgcolor="#FFFFFF" width="130"> </td> <td bgcolor="#FFFFFF" width="363"> <input name="action" type="hidden" value="msgnew"> <input type="reset" name="reset" value="<?php print("$lgtxt[13]");?>"> <input type="submit" name="Submit" value="<?php print("$lgtxt[14]");?>"> </td></tr> </form> </table> <?php } ############################################################ # Show gbook else {?> <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"> <tr><td bgcolor="#FFFFFF" width="130" align="center" class="fontnorm"><b><?php print("$lgtxt[8]");?>:</b></td> <td bgcolor="#FFFFFF" width="363" align="center" class="fontnorm"><b><?php print("$lgtxt[11]");?>:</b></td></tr> <?php $frstmsg = $pg * $gb_msgpg; $lastmsg = $pg * $gb_msgpg + $gb_msgpg; if ($lastmsg > $maxmsg){$lastmsg=$maxmsg;} for ($u=$frstmsg; $u<$lastmsg; $u++) { $entry = explode("|",$data[$u]); if ($gb_flthtml) {$entry[8] = strip_tags($entry[8]);} if ($gb_fltbdwrd) {$entry[8] = flt_bdwrd($entry[8],$lgbdwrd);} if ($gb_url2lnk) {$entry[8] = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $entry[8]);} if ($gb_smiley){$entry[8] = flt_smiley ($entry[8]);} ?> <tr> <td bgcolor="#0084FF" width="130" align="center" class="fontnorm"> <?php print("$entry[5]");?><p> <img src="images/g_ip.gif" width="16" height="16" alt="<?php if ($psswd == $gb_psswd){print("IP: $entry[3]");} else {print("IP: $lgtxt[15]");} ?>"> <img src="images/g_br.gif" width="16" height="16" alt="<?php print("OS: $entry[4]"); ?>"> <?php if ($entry[6]){?><a href="mailto:<?php print("$entry[6]"); ?>"><img src="images/g_em.gif" width="16" height="16" alt="<?php print("$entry[6]"); ?>" border="0"></a><?php } else {?><img src="images/g_em.gif" width="16" height="16" alt="<?php print("$lgtxt[17]"); ?>" border="0"><?php } if ($entry[7] and $entry[7] != "http://"){?><a href="<?php print("$entry[7]"); ?>" target="_blank"><img src="images/g_hm.gif" width="16" height="16" alt="<?php print("$entry[7]"); ?>" border="0"></a><?php } else {?><img src="images/g_hm.gif" width="16" height="16" alt="<?php print("$lgtxt[18]"); ?>" border="0"><?php } ?> </p> </td> <td bgcolor="#FFFFFF" width="363"> <span class="fontmini"><?php print("$lgtxt[16] $entry[1] $entry[2]"); if ($psswd == $gb_psswd){?> [ <a href="<?php print("$PHP_SELF?msgdelete=$u"); ?>"><?php print("$lgtxt[23]"); ?></a> | <a href="<?php print("$PHP_SELF?msgedit=$u"); ?>"><?php print("$lgtxt[24]"); ?></a> ] <?php }?> </span> <hr noshade size="1"> <span class="fontnorm"><?php print("$entry[8]"); if($entry[9]){ print("<p><i>- $entry[9]</i></p>");}?></span> </td> </tr> <?php }?> </table> <?php } ############################################################ ?> </td></tr> </table> <table width="500" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td class="fontmini" width="50%"></td> <td class="fontmini" width="50%" align="right"> <?php If ($gb_flthtml) print($lgtxt[51]); else print($lgtxt[50]); ?> </td> </tr> </table> </body> </html>
Ainiin, ja hymiöitä en voinu laittaa mukaa nii jos tartteet pyyä multa tai tee ite ja laita hakemistot oikein.
Esimerkkisivuu?
Pist vaikka linkki zippiin, mistä saa koko härpäkkeen ladattuu.
Itse koodi kyllä mukavaa luettavaa, vaikkakin sisennykset osittain puuttuu. Selkeydestä iso plussa, tosin kommentoinnista iso miinus.
lainaus:
Esimerkkisivuu?
Pist vaikka linkki zippiin, mistä saa koko härpäkkeen ladattuu.Itse koodi kyllä mukavaa luettavaa, vaikkakin sisennykset osittain puuttuu. Selkeydestä iso plussa, tosin kommentoinnista iso miinus.
Juuh tota, toi on mun eka "projektini" php:ssa. Voisin kyllä laittaa esimerkki sivun ja että mistä voitte ottaa sen. :)
http://www.wanha.org/~blur/viekku/viekku.php esimerkki sivu. Koko hökötyksen lataus http://personal.inet.fi/peli/hh-flames/viekku.zip
Aihe on jo aika vanha, joten et voi enää vastata siihen.