| | |
New to php and need some help with a guestbook
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 16
Reputation:
Solved Threads: 0
I have just put together a personal site and am trying to integrate a php guestbook. I obtained a free guestbook, called easyboard and have followed the instructions asto the installation but the html page that I've incorprated the board isn't actually working it displays all the deperate parts that would normally come upon completion of an action.
I have posted all the files as txt files so that you can atleast read the coding that I have downloaded and also edited. The links for these are
The main html page
http://www.daveclissold.com/board/board-html.txt
The script pages
http://www.daveclissold.com/board/easyboard-php.txt
http://www.daveclissold.com/board/ea..._admin-php.txt
http://www.daveclissold.com/board/ea...ntries-php.txt
If you know what is going wrong please help as I really would like to get this up and running asap
Regards
Dave
I have posted all the files as txt files so that you can atleast read the coding that I have downloaded and also edited. The links for these are
The main html page
http://www.daveclissold.com/board/board-html.txt
The script pages
http://www.daveclissold.com/board/easyboard-php.txt
http://www.daveclissold.com/board/ea..._admin-php.txt
http://www.daveclissold.com/board/ea...ntries-php.txt
If you know what is going wrong please help as I really would like to get this up and running asap
Regards
Dave
•
•
Join Date: Jun 2005
Posts: 16
Reputation:
Solved Threads: 0
Here is the scripts so you do not need to download them
Main PHP page which is linked to in my site
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DaveClissold.com - Changing my life one day at a time</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="author" content="Will Rossiter" />
<style type="text/css" media="screen">
@import url(../images/styles.css);
.style18 {color: #CCCCCC; font-size: 12px; font-family: Verdana; }
.style19 {color: #FFFFFF}
.style20 {font-family: Verdana}
.style21 {color: #FF0000}
</style>
</head>
<body>
<!--RiteCounter--><script type="text/javascript" src="http://www.ritecounter.com/c/52/51905.js"></script><noscript><div><a href="http://logodesign.ritecounter.com"><img src="http://www.ritecounter.com/scripts/htmlc.php?id=51905" alt="Online Logo Design" style="border:0 hidden"/></a></div></noscript><!--END RiteCounter-->
<div id="container">
<div id="leftcol">
<h1><img src="/images/davelogo12.jpg" alt="" width="200" height="80" /></h1>
<p class="sub">Changing my life one day at a time <a href="http://www.willr.co.nz"></a></p>
<h3>Navigation</h3>
<ul>
<li><a href="/index.html"><span class="style18"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Home</a></li>
<li><a href="/diary/diarymain.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Diary</a></li>
<li><a href="/recipes.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Recipes</a></li>
<li><a href="/photos.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Photos</a></li>
<li><a href="/links.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Links</a></li>
<li><a href="mailto:dave@daveclissold.com"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Contact</a></li>
</ul>
</div>
<div id="rightcol">
<div align="left">
<!--
Switches, if these get deleted, easyboard will not have the functionality
they represent.
spamprotect adds a _nospam_ to each email to avoid bots to scan your page
for spamming
increase:x defines how many guestbook entries will be displayed at a time
and enables the display of back / next links
owner:email defines the owner of the guestbook, each entry will be sent
there as a copy
-->
<!-- spamprotect -->
<!-- increase:10 -->
<!-- owner:dave.clissold@gmail.com -->
<!-- ### The welcome message ### -->
<!-- start:item -->
</div>
<p align="left">
<h4 align="left"><strong>%Name%</strong> email:<a href="mailto:%email%?body=Please remove the _nospam_ in the email" class="content">%email% wrote on %entrydate%</h4>
</p>
<p align="left">%message%</p>
<p align="left">
<div align="left"><br />
<!-- end:item -->
</div>
<div align="right">
<p>
<!-- start:back -->
<h2 class="style18"><a href="../backurl" class="content">< previous </a>
<!-- end:back --><!-- start:next --><a href="../nexturl" class="content">next ></a></h2>
<h2 class="style18"><a href="..//board/easyboard.php?action=sign" class="content">Sign Guestbook</a></h2></p>
<!-- ### The message displayed when someone tries to spam the book by reloading ### -->
<!-- start:spam -->
</div>
<div class="warning">
<p class="style21">Please do NOT spam this guestbook, thank you!</p>
</div>
<br />
<div align="right">
<p><h2 class="style18"><a href="..//board/easyboard.php?action=view" class="content">View Guestbook</a></h2></p>
</div>
<!-- end:spam -->
<!-- ### The message displayed when someone forgot to enter a field ### -->
<!-- ### the "field" comment will get replaced with the missing field names ### -->
<!-- start:forgottenfields -->
<div class="warning">
<p>Sorry you forgot to enter the following fields:
<!-- fields -->
Please re-enter them.</p>
</div>
<p><br />
<!-- end:forgottenfields -->
<!-- ### The message displayed when the entered email is invalid ### -->
<!-- start:invalidemail -->
</p>
<div class="warning">
<p>The email you entered was not valid</p>
</div>
<p><br />
<!-- end:invalidemail -->
<!-- ### The message displayed when someone succesfully signed the guestbook ### -->
<!-- start:thanks -->
</p>
<div class="thanks">
<p>Thank you for your support in my quest for completing this challenge and turning my life around.</p>
</div>
<br />
<div><h2 class="style18" align="right"><a href="..//board/easyboard.php?action=view" class="content">View Guestbook</a></h2></div>
<!-- end:thanks -->
<!-- ### The entry form, each input element will be added as data ### -->
<!-- ### See the easyboard homepage for more info! ### -->
<!-- start:form -->
<form method="post">
<table border="0">
<tr>
<td class="content" width="10%"><p>Name
</p></td>
<td><input type="text" name="Name" size="20" class="input" value="%Name%" /></td>
</tr>
<tr>
<td class="content" width="10%"><p>Email
</p></td>
<td><input type="text" name="email" size="20" class="input" value="%email%" /></td>
</tr>
<tr>
<td class="content" width="10%"><p>Website</p></td>
<td><input type="text" name="url" size="20" class="input" value="%url%" /></td>
</tr>
<tr>
<td class="content" colspan="2"><p>Your Message
</p></td>
</tr>
<tr>
<td colspan="2"><textarea name="message" cols="40" rows="5" class="input" >%message%</textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<!-- ### these two fields are mandatory ### -->
<input type="submit" value="Add to Guestbook"/></td>
</tr>
</table>
</form>
<br />
<div align="right">
<p><h2 class="style18"><a href="..//board/easyboard.php?action=view" class="content style19 style20">View Guestbook</a></h2></p>
</div>
<!-- end:form -->
<!-- ### The display of the book ### -->
<!-- start:item -->
<div class="gbhead"><br />
<p><h4><strong>%Name%</strong> email:<a href="mailto:%email%?body=Please remove the _nospam_ in the email" class="content">%email% wrote on %entrydate%</h4>
</p>
<p>%message%
</p>
<p></div>
<br />
<!-- end:item -->
<div align="right">
<p>
<!-- start:back -->
<h2 class="style18"><a href="../backurl" class="content">< previous </a>
<!-- end:back --><!-- start:next --><a href="../nexturl" class="content">next ></a></h2>
<h2 class="style18"><a href="..//board/easyboard.php?action=sign" class="content">Sign Guestbook</a></h2></p>
</div>
<!-- end:display -->
<p align="right"> Copyright © 2007, Dave Clissold. All rights reserved</p>
</div></div>
<!-- Stats Script Start -->
<script type="text/javascript">
<!--
var FCS_Account="891";
var FCS_Server="http://www.statsrely.com/newdesign";
var FCS_Page="DetectName";
var FCS_Url="DetectUrl";
var FCS_Offset="8";
var FCS_Interval="24";
var FCS_Cntimg="100";
// -->
</script>
<script type="text/javascript" src="http://www.statsrely.com//js.php?usr=891">
</script>
<noscript>
<a href="http://www.statsrely.com/" target="_blank">
<img src="http://www.statsrely.com/newdesign/stat.php?usr=891&offset=8&interval=24&cntimg=100" title="Stats Rely Free Hit Counter!"></a>
</noscript>
<!-- Stats Script End -->
</body>
</html>[/PHP]
This is the php script that I downloaded as part of the zip file
[PHP]<?php
/*
Easyboard Version 3.4
written by Christian Heilmann
Homepage:http://www.onlinetools.org/
Do not change any code here, the whole functionality is triggered by
comments in the HTML Template!
requires entries.xml and guestbook_template.html to work.
*/
$action=$_GET['action'];
if ($_POST['action']!="") {$action=$_POST['action'];}
$start=$_GET['start'];
$action=strip_tags($action);
$start=strip_tags($start);
$HTML=load("easyboard_template.html");
preg_match("/<!-- dateformat
.*?) -->/",$HTML,$dateformat);
if($dateformat[1]==""){$dateformat = "M d Y H:i:s";}
else {$dateformat = $dateformat[1];}
if ($action==''){
echo displaysetup("invalidemail,forgottenfields,thanks,form,display,spam");
}
if ($action=="view"){
$gb=load("easyboard_entries.xml");
if (untag($gb,"entry",1)!=""){
$HTML=displaysetup("invalidemail,forgottenfields,thanks,form,hello,spam");
preg_match_all("/<!-- start:item -->(.*?)<!-- end:item -->/si",$HTML,$item);
$entries=array_reverse(untag($gb,"entry",1));
preg_match_all("/%(.*?)%/",$item[1][0],$vars);
preg_match("/<!-- increase
.*?) -->/si",$HTML,$inc);
if ($inc[1]==""){$increase=sizeof($entries);}
else{$increase=$inc[1];}
if(!$start){$start=0;}
$end=$start+$increase;
if ($start >= $increase){
preg_match_all("/<!-- start:back -->(.*?)<!-- end:back -->/si",$HTML,$back);
$back=$back[1][0];
$back=preg_replace("/backurl/",$PHP_SELF."?action=view&start=".($start-$increase),$back);
$HTML=preg_replace("/<!-- start:back -->(.*?)<!-- end:back -->/si",$back,$HTML);
}
else {$HTML=preg_replace("/<!-- start:back -->(.*?)<!-- end:back -->/si","",$HTML);}
if ($end < sizeof($entries)){
preg_match_all("/<!-- start:next -->(.*?)<!-- end:next -->/si",$HTML,$back);
$back=$back[1][0];
$back=preg_replace("/nexturl/si",$PHP_SELF."?action=view&start=".($start+$increase),$back);
$HTML=preg_replace("/<!-- start:next -->(.*?)<!-- end:next -->/si",$back,$HTML);
}
else {$HTML=preg_replace("/<!-- start:next -->(.*?)<!-- end:next -->/si","",$HTML);}
$disp=array_slice($entries,$start,$increase);
$htmlinclude="";
foreach ($disp as $e){
$ditem=$item[1][0];
foreach ($vars[1] as $v){
$con=untag($e,$v,0);
$ditem=preg_replace("/%".$v."%/si",stripslashes(nl2br(htmlentities($con))),$ditem);
}
if (preg_match("/<!-- spamprotect -->/si",$HTML)){$ditem=preg_replace("/@/si","@_nospam_",$ditem);}
$htmlinclude.= $ditem;
}
$HTML=preg_replace("/<!-- start:item -->.*?<!-- end:item -->/si",$htmlinclude,$HTML);
}
else {
$HTML=displaysetup("invalidemail,forgottenfields,thanks,form,display,spam");
}
echo $HTML;
}
if ($action=="sign"){
$HTML=displaysetup("invalidemail,forgottenfields,thanks,display,hello,spam");
$HTML=preg_replace("/%.*%/","",$HTML);
echo $HTML;
}
if ($action=="verify"){
$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
$HTML=preg_replace("/%".$keys[$i]."%/si",stripslashes($_POST[$keys[$i]]),$HTML);
}
$req=explode(",",$_POST['required']);
foreach ($req as $r){
if ($_POST[$r]==""){
$errorfields[]=$r;
}
}
/*
ZZZzz |\ _,,,---,,_
Sometimes when I look at the z /,`.-'`' -. ;-;;,_.
amount of work on my schedule zz|,4- ) )-,_. ,\ ( `'-'
I wish that I was born a cat '---''(_/--' `-'\_)
*/
$HTML=displaysetup("display,hello");
if ($errorfields[0]!=""){
$inc="<ul>";
foreach ($errorfields as $e){$inc.="<li>$e</li>";}
$inc.="</ul>";
$HTML=preg_replace("/<!-- fields -->/si",$inc,$HTML);
$HTML=displaysetup("spam,thanks");
}
else {$HTML=displaysetup("forgottenfields");}
if (checkmail($_POST['email'])){$HTML=displaysetup("invalidemail");}
if (checkmail($_POST['email']) and $errorfields[0]==""){
$gb=load("easyboard_entries.xml");
$id=count(untag($gb,"entry",1));
$allentries=untag($gb,"entry",1);
if ($id==1 and $allentries[0]==""){$id=1;}
else {$id++;}
$data="\n<entry>";
$data.="\n\t<entryid>$id</entryid>";
$data.="\n\t<entrydate>".date ($dateformat)."</entrydate>";
$mail.="New Entry id
id\nDate:".date ($dateformat)."\n";
$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
if ($keys[$i]!="required" and $keys[$i]!="action"){
$data.="\n\t<".$keys[$i].">".stripslashes($_POST[$keys[$i]])."</".$keys[$i].">";
$mail.="\n".$keys[$i].":".stripslashes($_POST[$keys[$i]]);
}
}
$data.="\n</entry>";
$preg="/\s|<entry>|<\/entry>|<entryid>.*?<\/entryid>|<entrydate>.*?<\/entrydate>/si";
if(preg_replace($preg,"",$data) == preg_replace($preg,"",$allentries[count($allentries)-1])){$HTML=displaysetup("thanks,form");}
else{save ("easyboard_entries.xml",preg_replace("/<\/guestbook>/","".$data."\n</guestbook>",$gb));
$HTML=displaysetup("spam,form");
if (preg_match("/<!-- owner:.*? -->/si",$HTML)){
preg_match_all("/<!-- owner
.*?) -->/si",$HTML,$owner);
$mailheaders = "From: Easyboard\n";
$mailheaders .= "Reply-To: $email\n";
mail ($owner[1][0],"New entry in the Guestbook!",$mail,$mailheaders);
}
}
}
if (!checkmail($_POST['email'])){$HTML=displaysetup("spam,thanks");}
echo preg_replace("/<!--.*?-->/","",$HTML);
}
function displaysetup($fields){
global $HTML;
$fields=explode(",",$fields);
foreach ($fields as $f){
$HTML=preg_replace("/<!-- start:".$f." -->.*?<!-- end:".$f." -->/si","",$HTML);
}
return $HTML;
}
/*
Function urlize($name)
checks if the submitted string is a valid email and returns a boolean
*/
function checkmail($string){
global $HTML;
if (preg_match("/<!-- nomailcheck -->/",$HTML)){return true;}
return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}
/*
Function urlize($name)
converts an item name into a url na,e
*/
function urlize($name){
return strtolower(preg_replace("/[^\w\.]/","",$name));
}
/*
Function load($file)
reads the content of the file that you send and returns it
*/
function load($filelocation){
if (file_exists($filelocation)){
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
/*
Function save($file,$content)
writes the content to the file and generates it if needed
*/
function save($filelocation,$newdatas){
$newfile = @fopen($filelocation,"w+");
@fwrite($newfile, $newdatas);
@fclose($newfile);
if($newfile!=""){$fileerror=0;}
else {$fileerror=1;}
return $fileerror;
}
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@_nospam_onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}
?>[/PHP]
Here is the admin php script
[PHP]
<?
/*
Admin for Easyboard
written by Christian Heilmann
*/
$action=$_GET['action'];
$id=$_GET['id'];
$action=strip_tags($action);
$id=strip_tags($id);
$self=$HTTP_SERVER_VARS["PHP_SELF"];
$data=load("easyboard_entries.xml");
$entries=untag($data,"entry",1);
if ($_POST['edited']=="change"){
$gb="<?xml version=\"1.0\"?>\n";
$gb.="\n\t<guestbook>";
$id=$_POST['entryid'];
if($entries[0]!=''){foreach ($entries as $k=>$e){
if (untag($e,"entryid",0)!=$id){
$gb.="\n\t<entry>";
$gb.=$e;
$gb.="\n\t</entry>";
}
else {
$gb.="\n\t<entry>";
$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
if ($keys[$i]!="edited"){
$gb.= "\n\t<".$keys[$i].'>'.$_POST[$keys[$i]].'</'.$keys[$i].'>';
}
}
$gb.="\n\t</entry>";
}
}}
$gb.="\n\t</guestbook>";
$data=save("easyboard_entries.xml",$gb);
$self=explode("/",$self);
header("Location:".$self[count($self)-1]);
}
if ($action=="del"){
$gb="<?xml version=\"1.0\"?>\n";
$gb.="\n\t<guestbook>";
$k=0;
if($entries[0]!=''){foreach ($entries as $e){
if (untag($e,"entryid",0)!=$id){
$k++;
$gb.="\n\t<entry>";
$gb.=rtrim(preg_replace("/<entryid>.*?<\/entryid>/","<entryid>$k</entryid>",$e));
$gb.="\n\t\t</entry>";
}
}}
$gb.="\n\t</guestbook>";
$data=save("easyboard_entries.xml",$gb);
$self=explode("/",$self);
header("Location:".$self[count($self)-1]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Easyboard admin</title>
<style type="text/css">
body {
background:#cccccc;
font-family:verdana,sans serif;
font-size:1em;
color:#333333;
font-weight:bold;
}
td {
font-weight:bold;
background:#eeeeee;
color:#333333;
padding:5px;
font-family:verdana,sans serif;
font-size:x-small;
}
.entry {
font-weight:normal;
background:#eeeeee;
color:#333333;
padding:5px;
border-top:none;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-bottom:1px solid #333333;
font-family:verdana,sans serif;
font-size:x-small;
}
.del {
background:#eeeeff;
padding:5px;
border-top:1px solid #333333;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-bottom:1px solid #333333;
font-family:verdana,sans serif;
font-size:x-small;
}
a{
font-family:verdana,sans serif;
font-size:x-small;
color:#336699;
text-decoration:none;
}
</style>
</head>
<body>
<?php
if (!$action or $action!="del" and $action!="edit"){
echo "<html><head><meta http-equiv=\"expires\" content=\"Fri, 5 Apr 1996 23:59:59 GMT\"></head><body>This is the admin part of easyboard, simply click the delete links to delete or edit to edit the entry.<br><br>";
if($entries[0]!=''){foreach ($entries as $e){
echo "<div class=\"del\"><a href=\"$self?action=del&id=".untag($e,"entryid",0)."\">delete</a>|<a href=\"$self?action=edit&id=".untag($e,"entryid",0)."\">edit</a></div>";
echo "<div class=\"entry\">";
preg_match_all("/<(.*?)>(.*?)<\/.*?>/si",$e,$item);
foreach ($item[1] as $f=>$i){
if ($i != "entryid"){echo "<strong>".$item[1][$f]."</strong>: ".nl2br($item[2][$f])."<br>";}
}
echo "</div><br>";
}}
}
if ($action=="edit"){
if($entries[0]!=''){foreach ($entries as $k=>$e){
if (untag($e,"entryid",0)==$id){
echo '<form method="post" action="'.$self.'">';
echo '<input name="entryid" type="hidden" value="'.untag($e,"entryid",0).'">';
echo '<input name="entrydate" type="hidden" value="'.untag($e,"entrydate",0).'">';
echo '<table border="0"><tr><td colspan="2">Please edit the entry:</td></tr>';
preg_match_all("/<(.*?)>(.*?)<\/.*?>/si",$e,$item);
foreach ($item[1] as $f=>$i){
if ($i != "entryid" and $i!="entrydate"){
echo '<tr>';
echo '<td valign="top">'.$item[1][$f].'</td><td>';
if (strlen($item[2][$f]) < 50){
echo '<input type="text" name="'.$item[1][$f].'" value="'.$item[2][$f].'">';
}
else {
echo '<textarea cols="60" rows="6" name="'.$item[1][$f].'">'.$item[2][$f].'</textarea>';
}
echo '</td></tr>';
}
}
echo '<tr><td colspan="2" align="right"><input type="submit" value="change" name="edited">';
echo '</td></tr></table>';
echo '</form>';
}
}}
}
/*
Function load($file)
reads the content of the file that you send and returns it
*/
function load($filelocation){
if (file_exists($filelocation)){
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
/*
Function save($file,$content)
writes the content to the file and generates it if needed
*/
function save($filelocation,$newdatas){
$newfile = @fopen($filelocation,"w+");
@fwrite($newfile, $newdatas);
@fclose($newfile);
if($newfile!=""){$fileerror=0;}
else {$fileerror=1;}
return $fileerror;
}
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@_nospam_onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}
?>
</body>
</html>
[/PHP]
I know its a lot but its I'm probably missing out on something very basic which not knowing PHP I will pick up on very quickly.
Thanks in advance for your help.
Main PHP page which is linked to in my site
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DaveClissold.com - Changing my life one day at a time</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="author" content="Will Rossiter" />
<style type="text/css" media="screen">
@import url(../images/styles.css);
.style18 {color: #CCCCCC; font-size: 12px; font-family: Verdana; }
.style19 {color: #FFFFFF}
.style20 {font-family: Verdana}
.style21 {color: #FF0000}
</style>
</head>
<body>
<!--RiteCounter--><script type="text/javascript" src="http://www.ritecounter.com/c/52/51905.js"></script><noscript><div><a href="http://logodesign.ritecounter.com"><img src="http://www.ritecounter.com/scripts/htmlc.php?id=51905" alt="Online Logo Design" style="border:0 hidden"/></a></div></noscript><!--END RiteCounter-->
<div id="container">
<div id="leftcol">
<h1><img src="/images/davelogo12.jpg" alt="" width="200" height="80" /></h1>
<p class="sub">Changing my life one day at a time <a href="http://www.willr.co.nz"></a></p>
<h3>Navigation</h3>
<ul>
<li><a href="/index.html"><span class="style18"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Home</a></li>
<li><a href="/diary/diarymain.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Diary</a></li>
<li><a href="/recipes.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Recipes</a></li>
<li><a href="/photos.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Photos</a></li>
<li><a href="/links.html"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Links</a></li>
<li><a href="mailto:dave@daveclissold.com"><span class="style19"><img src="/images/bullet.jpg" alt="bullet" width="11" height="11" /></span> Contact</a></li>
</ul>
</div>
<div id="rightcol">
<div align="left">
<!--
Switches, if these get deleted, easyboard will not have the functionality
they represent.
spamprotect adds a _nospam_ to each email to avoid bots to scan your page
for spamming
increase:x defines how many guestbook entries will be displayed at a time
and enables the display of back / next links
owner:email defines the owner of the guestbook, each entry will be sent
there as a copy
-->
<!-- spamprotect -->
<!-- increase:10 -->
<!-- owner:dave.clissold@gmail.com -->
<!-- ### The welcome message ### -->
<!-- start:item -->
</div>
<p align="left">
<h4 align="left"><strong>%Name%</strong> email:<a href="mailto:%email%?body=Please remove the _nospam_ in the email" class="content">%email% wrote on %entrydate%</h4>
</p>
<p align="left">%message%</p>
<p align="left">
<div align="left"><br />
<!-- end:item -->
</div>
<div align="right">
<p>
<!-- start:back -->
<h2 class="style18"><a href="../backurl" class="content">< previous </a>
<!-- end:back --><!-- start:next --><a href="../nexturl" class="content">next ></a></h2>
<h2 class="style18"><a href="..//board/easyboard.php?action=sign" class="content">Sign Guestbook</a></h2></p>
<!-- ### The message displayed when someone tries to spam the book by reloading ### -->
<!-- start:spam -->
</div>
<div class="warning">
<p class="style21">Please do NOT spam this guestbook, thank you!</p>
</div>
<br />
<div align="right">
<p><h2 class="style18"><a href="..//board/easyboard.php?action=view" class="content">View Guestbook</a></h2></p>
</div>
<!-- end:spam -->
<!-- ### The message displayed when someone forgot to enter a field ### -->
<!-- ### the "field" comment will get replaced with the missing field names ### -->
<!-- start:forgottenfields -->
<div class="warning">
<p>Sorry you forgot to enter the following fields:
<!-- fields -->
Please re-enter them.</p>
</div>
<p><br />
<!-- end:forgottenfields -->
<!-- ### The message displayed when the entered email is invalid ### -->
<!-- start:invalidemail -->
</p>
<div class="warning">
<p>The email you entered was not valid</p>
</div>
<p><br />
<!-- end:invalidemail -->
<!-- ### The message displayed when someone succesfully signed the guestbook ### -->
<!-- start:thanks -->
</p>
<div class="thanks">
<p>Thank you for your support in my quest for completing this challenge and turning my life around.</p>
</div>
<br />
<div><h2 class="style18" align="right"><a href="..//board/easyboard.php?action=view" class="content">View Guestbook</a></h2></div>
<!-- end:thanks -->
<!-- ### The entry form, each input element will be added as data ### -->
<!-- ### See the easyboard homepage for more info! ### -->
<!-- start:form -->
<form method="post">
<table border="0">
<tr>
<td class="content" width="10%"><p>Name
</p></td><td><input type="text" name="Name" size="20" class="input" value="%Name%" /></td>
</tr>
<tr>
<td class="content" width="10%"><p>Email
</p></td><td><input type="text" name="email" size="20" class="input" value="%email%" /></td>
</tr>
<tr>
<td class="content" width="10%"><p>Website</p></td>
<td><input type="text" name="url" size="20" class="input" value="%url%" /></td>
</tr>
<tr>
<td class="content" colspan="2"><p>Your Message
</p></td></tr>
<tr>
<td colspan="2"><textarea name="message" cols="40" rows="5" class="input" >%message%</textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<!-- ### these two fields are mandatory ### -->
<input type="submit" value="Add to Guestbook"/></td>
</tr>
</table>
</form>
<br />
<div align="right">
<p><h2 class="style18"><a href="..//board/easyboard.php?action=view" class="content style19 style20">View Guestbook</a></h2></p>
</div>
<!-- end:form -->
<!-- ### The display of the book ### -->
<!-- start:item -->
<div class="gbhead"><br />
<p><h4><strong>%Name%</strong> email:<a href="mailto:%email%?body=Please remove the _nospam_ in the email" class="content">%email% wrote on %entrydate%</h4>
</p>
<p>%message%
</p>
<p></div>
<br />
<!-- end:item -->
<div align="right">
<p>
<!-- start:back -->
<h2 class="style18"><a href="../backurl" class="content">< previous </a>
<!-- end:back --><!-- start:next --><a href="../nexturl" class="content">next ></a></h2>
<h2 class="style18"><a href="..//board/easyboard.php?action=sign" class="content">Sign Guestbook</a></h2></p>
</div>
<!-- end:display -->
<p align="right"> Copyright © 2007, Dave Clissold. All rights reserved</p>
</div></div>
<!-- Stats Script Start -->
<script type="text/javascript">
<!--
var FCS_Account="891";
var FCS_Server="http://www.statsrely.com/newdesign";
var FCS_Page="DetectName";
var FCS_Url="DetectUrl";
var FCS_Offset="8";
var FCS_Interval="24";
var FCS_Cntimg="100";
// -->
</script>
<script type="text/javascript" src="http://www.statsrely.com//js.php?usr=891">
</script>
<noscript>
<a href="http://www.statsrely.com/" target="_blank">
<img src="http://www.statsrely.com/newdesign/stat.php?usr=891&offset=8&interval=24&cntimg=100" title="Stats Rely Free Hit Counter!"></a>
</noscript>
<!-- Stats Script End -->
</body>
</html>[/PHP]
This is the php script that I downloaded as part of the zip file
[PHP]<?php
/*
Easyboard Version 3.4
written by Christian Heilmann
Homepage:http://www.onlinetools.org/
Do not change any code here, the whole functionality is triggered by
comments in the HTML Template!
requires entries.xml and guestbook_template.html to work.
*/
$action=$_GET['action'];
if ($_POST['action']!="") {$action=$_POST['action'];}
$start=$_GET['start'];
$action=strip_tags($action);
$start=strip_tags($start);
$HTML=load("easyboard_template.html");
preg_match("/<!-- dateformat
.*?) -->/",$HTML,$dateformat);if($dateformat[1]==""){$dateformat = "M d Y H:i:s";}
else {$dateformat = $dateformat[1];}
if ($action==''){
echo displaysetup("invalidemail,forgottenfields,thanks,form,display,spam");
}
if ($action=="view"){
$gb=load("easyboard_entries.xml");
if (untag($gb,"entry",1)!=""){
$HTML=displaysetup("invalidemail,forgottenfields,thanks,form,hello,spam");
preg_match_all("/<!-- start:item -->(.*?)<!-- end:item -->/si",$HTML,$item);
$entries=array_reverse(untag($gb,"entry",1));
preg_match_all("/%(.*?)%/",$item[1][0],$vars);
preg_match("/<!-- increase
.*?) -->/si",$HTML,$inc); if ($inc[1]==""){$increase=sizeof($entries);}
else{$increase=$inc[1];}
if(!$start){$start=0;}
$end=$start+$increase;
if ($start >= $increase){
preg_match_all("/<!-- start:back -->(.*?)<!-- end:back -->/si",$HTML,$back);
$back=$back[1][0];
$back=preg_replace("/backurl/",$PHP_SELF."?action=view&start=".($start-$increase),$back);
$HTML=preg_replace("/<!-- start:back -->(.*?)<!-- end:back -->/si",$back,$HTML);
}
else {$HTML=preg_replace("/<!-- start:back -->(.*?)<!-- end:back -->/si","",$HTML);}
if ($end < sizeof($entries)){
preg_match_all("/<!-- start:next -->(.*?)<!-- end:next -->/si",$HTML,$back);
$back=$back[1][0];
$back=preg_replace("/nexturl/si",$PHP_SELF."?action=view&start=".($start+$increase),$back);
$HTML=preg_replace("/<!-- start:next -->(.*?)<!-- end:next -->/si",$back,$HTML);
}
else {$HTML=preg_replace("/<!-- start:next -->(.*?)<!-- end:next -->/si","",$HTML);}
$disp=array_slice($entries,$start,$increase);
$htmlinclude="";
foreach ($disp as $e){
$ditem=$item[1][0];
foreach ($vars[1] as $v){
$con=untag($e,$v,0);
$ditem=preg_replace("/%".$v."%/si",stripslashes(nl2br(htmlentities($con))),$ditem);
}
if (preg_match("/<!-- spamprotect -->/si",$HTML)){$ditem=preg_replace("/@/si","@_nospam_",$ditem);}
$htmlinclude.= $ditem;
}
$HTML=preg_replace("/<!-- start:item -->.*?<!-- end:item -->/si",$htmlinclude,$HTML);
}
else {
$HTML=displaysetup("invalidemail,forgottenfields,thanks,form,display,spam");
}
echo $HTML;
}
if ($action=="sign"){
$HTML=displaysetup("invalidemail,forgottenfields,thanks,display,hello,spam");
$HTML=preg_replace("/%.*%/","",$HTML);
echo $HTML;
}
if ($action=="verify"){
$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
$HTML=preg_replace("/%".$keys[$i]."%/si",stripslashes($_POST[$keys[$i]]),$HTML);
}
$req=explode(",",$_POST['required']);
foreach ($req as $r){
if ($_POST[$r]==""){
$errorfields[]=$r;
}
}
/*
ZZZzz |\ _,,,---,,_
Sometimes when I look at the z /,`.-'`' -. ;-;;,_.
amount of work on my schedule zz|,4- ) )-,_. ,\ ( `'-'
I wish that I was born a cat '---''(_/--' `-'\_)
*/
$HTML=displaysetup("display,hello");
if ($errorfields[0]!=""){
$inc="<ul>";
foreach ($errorfields as $e){$inc.="<li>$e</li>";}
$inc.="</ul>";
$HTML=preg_replace("/<!-- fields -->/si",$inc,$HTML);
$HTML=displaysetup("spam,thanks");
}
else {$HTML=displaysetup("forgottenfields");}
if (checkmail($_POST['email'])){$HTML=displaysetup("invalidemail");}
if (checkmail($_POST['email']) and $errorfields[0]==""){
$gb=load("easyboard_entries.xml");
$id=count(untag($gb,"entry",1));
$allentries=untag($gb,"entry",1);
if ($id==1 and $allentries[0]==""){$id=1;}
else {$id++;}
$data="\n<entry>";
$data.="\n\t<entryid>$id</entryid>";
$data.="\n\t<entrydate>".date ($dateformat)."</entrydate>";
$mail.="New Entry id
id\nDate:".date ($dateformat)."\n";$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
if ($keys[$i]!="required" and $keys[$i]!="action"){
$data.="\n\t<".$keys[$i].">".stripslashes($_POST[$keys[$i]])."</".$keys[$i].">";
$mail.="\n".$keys[$i].":".stripslashes($_POST[$keys[$i]]);
}
}
$data.="\n</entry>";
$preg="/\s|<entry>|<\/entry>|<entryid>.*?<\/entryid>|<entrydate>.*?<\/entrydate>/si";
if(preg_replace($preg,"",$data) == preg_replace($preg,"",$allentries[count($allentries)-1])){$HTML=displaysetup("thanks,form");}
else{save ("easyboard_entries.xml",preg_replace("/<\/guestbook>/","".$data."\n</guestbook>",$gb));
$HTML=displaysetup("spam,form");
if (preg_match("/<!-- owner:.*? -->/si",$HTML)){
preg_match_all("/<!-- owner
.*?) -->/si",$HTML,$owner);$mailheaders = "From: Easyboard\n";
$mailheaders .= "Reply-To: $email\n";
mail ($owner[1][0],"New entry in the Guestbook!",$mail,$mailheaders);
}
}
}
if (!checkmail($_POST['email'])){$HTML=displaysetup("spam,thanks");}
echo preg_replace("/<!--.*?-->/","",$HTML);
}
function displaysetup($fields){
global $HTML;
$fields=explode(",",$fields);
foreach ($fields as $f){
$HTML=preg_replace("/<!-- start:".$f." -->.*?<!-- end:".$f." -->/si","",$HTML);
}
return $HTML;
}
/*
Function urlize($name)
checks if the submitted string is a valid email and returns a boolean
*/
function checkmail($string){
global $HTML;
if (preg_match("/<!-- nomailcheck -->/",$HTML)){return true;}
return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}
/*
Function urlize($name)
converts an item name into a url na,e
*/
function urlize($name){
return strtolower(preg_replace("/[^\w\.]/","",$name));
}
/*
Function load($file)
reads the content of the file that you send and returns it
*/
function load($filelocation){
if (file_exists($filelocation)){
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
/*
Function save($file,$content)
writes the content to the file and generates it if needed
*/
function save($filelocation,$newdatas){
$newfile = @fopen($filelocation,"w+");
@fwrite($newfile, $newdatas);
@fclose($newfile);
if($newfile!=""){$fileerror=0;}
else {$fileerror=1;}
return $fileerror;
}
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@_nospam_onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}
?>[/PHP]
Here is the admin php script
[PHP]
<?
/*
Admin for Easyboard
written by Christian Heilmann
*/
$action=$_GET['action'];
$id=$_GET['id'];
$action=strip_tags($action);
$id=strip_tags($id);
$self=$HTTP_SERVER_VARS["PHP_SELF"];
$data=load("easyboard_entries.xml");
$entries=untag($data,"entry",1);
if ($_POST['edited']=="change"){
$gb="<?xml version=\"1.0\"?>\n";
$gb.="\n\t<guestbook>";
$id=$_POST['entryid'];
if($entries[0]!=''){foreach ($entries as $k=>$e){
if (untag($e,"entryid",0)!=$id){
$gb.="\n\t<entry>";
$gb.=$e;
$gb.="\n\t</entry>";
}
else {
$gb.="\n\t<entry>";
$keys=array_keys($_POST);
for ($i=0;$i<count($_POST);$i++){
if ($keys[$i]!="edited"){
$gb.= "\n\t<".$keys[$i].'>'.$_POST[$keys[$i]].'</'.$keys[$i].'>';
}
}
$gb.="\n\t</entry>";
}
}}
$gb.="\n\t</guestbook>";
$data=save("easyboard_entries.xml",$gb);
$self=explode("/",$self);
header("Location:".$self[count($self)-1]);
}
if ($action=="del"){
$gb="<?xml version=\"1.0\"?>\n";
$gb.="\n\t<guestbook>";
$k=0;
if($entries[0]!=''){foreach ($entries as $e){
if (untag($e,"entryid",0)!=$id){
$k++;
$gb.="\n\t<entry>";
$gb.=rtrim(preg_replace("/<entryid>.*?<\/entryid>/","<entryid>$k</entryid>",$e));
$gb.="\n\t\t</entry>";
}
}}
$gb.="\n\t</guestbook>";
$data=save("easyboard_entries.xml",$gb);
$self=explode("/",$self);
header("Location:".$self[count($self)-1]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Easyboard admin</title>
<style type="text/css">
body {
background:#cccccc;
font-family:verdana,sans serif;
font-size:1em;
color:#333333;
font-weight:bold;
}
td {
font-weight:bold;
background:#eeeeee;
color:#333333;
padding:5px;
font-family:verdana,sans serif;
font-size:x-small;
}
.entry {
font-weight:normal;
background:#eeeeee;
color:#333333;
padding:5px;
border-top:none;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-bottom:1px solid #333333;
font-family:verdana,sans serif;
font-size:x-small;
}
.del {
background:#eeeeff;
padding:5px;
border-top:1px solid #333333;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-bottom:1px solid #333333;
font-family:verdana,sans serif;
font-size:x-small;
}
a{
font-family:verdana,sans serif;
font-size:x-small;
color:#336699;
text-decoration:none;
}
</style>
</head>
<body>
<?php
if (!$action or $action!="del" and $action!="edit"){
echo "<html><head><meta http-equiv=\"expires\" content=\"Fri, 5 Apr 1996 23:59:59 GMT\"></head><body>This is the admin part of easyboard, simply click the delete links to delete or edit to edit the entry.<br><br>";
if($entries[0]!=''){foreach ($entries as $e){
echo "<div class=\"del\"><a href=\"$self?action=del&id=".untag($e,"entryid",0)."\">delete</a>|<a href=\"$self?action=edit&id=".untag($e,"entryid",0)."\">edit</a></div>";
echo "<div class=\"entry\">";
preg_match_all("/<(.*?)>(.*?)<\/.*?>/si",$e,$item);
foreach ($item[1] as $f=>$i){
if ($i != "entryid"){echo "<strong>".$item[1][$f]."</strong>: ".nl2br($item[2][$f])."<br>";}
}
echo "</div><br>";
}}
}
if ($action=="edit"){
if($entries[0]!=''){foreach ($entries as $k=>$e){
if (untag($e,"entryid",0)==$id){
echo '<form method="post" action="'.$self.'">';
echo '<input name="entryid" type="hidden" value="'.untag($e,"entryid",0).'">';
echo '<input name="entrydate" type="hidden" value="'.untag($e,"entrydate",0).'">';
echo '<table border="0"><tr><td colspan="2">Please edit the entry:</td></tr>';
preg_match_all("/<(.*?)>(.*?)<\/.*?>/si",$e,$item);
foreach ($item[1] as $f=>$i){
if ($i != "entryid" and $i!="entrydate"){
echo '<tr>';
echo '<td valign="top">'.$item[1][$f].'</td><td>';
if (strlen($item[2][$f]) < 50){
echo '<input type="text" name="'.$item[1][$f].'" value="'.$item[2][$f].'">';
}
else {
echo '<textarea cols="60" rows="6" name="'.$item[1][$f].'">'.$item[2][$f].'</textarea>';
}
echo '</td></tr>';
}
}
echo '<tr><td colspan="2" align="right"><input type="submit" value="change" name="edited">';
echo '</td></tr></table>';
echo '</form>';
}
}}
}
/*
Function load($file)
reads the content of the file that you send and returns it
*/
function load($filelocation){
if (file_exists($filelocation)){
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
/*
Function save($file,$content)
writes the content to the file and generates it if needed
*/
function save($filelocation,$newdatas){
$newfile = @fopen($filelocation,"w+");
@fwrite($newfile, $newdatas);
@fclose($newfile);
if($newfile!=""){$fileerror=0;}
else {$fileerror=1;}
return $fileerror;
}
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@_nospam_onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}
?>
</body>
</html>
[/PHP]
I know its a lot but its I'm probably missing out on something very basic which not knowing PHP I will pick up on very quickly.
Thanks in advance for your help.
Edit the following line:
[PHP]$HTML=load("easyboard_template.html");[/PHP]
so that it says:
[PHP]$HTML=load("board.html");[/PHP]
Then point your browser at easyboard.php.
[PHP]$HTML=load("easyboard_template.html");[/PHP]
so that it says:
[PHP]$HTML=load("board.html");[/PHP]
Then point your browser at easyboard.php.
Last edited by DanceInstructor; Mar 22nd, 2007 at 11:46 am.
Looks like its working ok to me. Change the link in your site menu to point at:
http://www.daveclissold.com/board/board.php?action=view
http://www.daveclissold.com/board/board.php?action=view
![]() |
Similar Threads
- How to create a Comment Box/Guestbook in HTML (Site Layout and Usability)
- need help in php (PHP)
- Having prolems with a guestbook (HTML and CSS)
- Guestbook question (Existing Scripts)
- Filtering My sql through Php using drop down menu and text field (PHP)
- Host Matrix - Free Php Hosting & Webmaster Resources. (Web Hosting Deals)
Other Threads in the PHP Forum
- Previous Thread: Show secured file
- Next Thread: code output not correct
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






