Multiple guestbook

More
15 years 7 months ago #976 by ragou
Multiple guestbook was created by ragou
Sorry for my English.
Is there any possibility to use guestbook for multiple purposes? I mean something like list.php?="something" and each time to write data in different files?. I saw something like this in another questbook, but unfortunately the script was totally bugged and therefor useless and I don't understand so much PHP to debug it.

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #979 by Pete
Replied by Pete on topic Multiple guestbook
Personally I am not a big fan of that concept. But since you asked I have modified to existing 1.7.2 guestbook to do what you need (see attached zip file).



To add new guestbooks, open the "config.php" file and locate the following section:
Code:
// Storage File Selection ------------------------------------------------------------ $storage_file = array(); $storage_file[] = 'data/list.txt'; $storage_file[] = 'data/file2.txt'; $storage_file[] = 'data/file3.txt';

Simply add a new line for each new guestbook. Also to add a new link in the header, open the header.php file and find this section:
Code:
[ [url=guestbook.php?sf=0]<b><?php echo $addentrytxt ?> GB 1</b>[/url] ] [ [url=guestbook.php?sf=1]<b><?php echo $addentrytxt ?> GB 2</b>[/url] ] [ [url=guestbook.php?sf=2]<b><?php echo $addentrytxt ?> GB 3</b>[/url] ]<br> [ [url=list.php?sf=0&page=1&order=asc]<b><?php echo $viewguestbooktxt ?> GB 1</b>[/url] ] [ [url=list.php?sf=1&page=1&order=asc]<b><?php echo $viewguestbooktxt ?> GB 2</b>[/url] ] [ [url=list.php?sf=2&page=1&order=asc]<b><?php echo $viewguestbooktxt ?> GB 3</b>[/url] ]<br>

Add one "Add Entry" and one "List" line to the above code, incrementing "sf" to the next sequal number (in this case it would be "4").

Here is what the new Multi-GB looks like:




Pete

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #980 by ragou
Replied by ragou on topic Multiple guestbook
Hi Pete,

Thank you very much for your Multi-GB.
But my aim is a little bit different.
I like GB because of it's stability and simplicity to setup and use.
Now I use your GB as something like blog.
I want to use it for adding comments also.
Now i implement GB in my blog page with frame:
Code:
<iframe SRC="./guestbook/list.php" id="InlineFrame1" style="width:540px;height:830px;background-color:#ffffff;" scrolling="yes" frameborder="0"> </iframe>

If I want to comment many different topics I have to embed different guest book on each page. But if I can call the same GB, but make it to write data every time in different file it will be great.
I mean something like this

On page1.html
Code:
<iframe SRC="./guestbook/list.php?=file1.txt" id="InlineFrame1" style="width:540px;height:830px;background-color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>

On page2.html
Code:
<iframe SRC="./guestbook/list.php?=file2.txt" id="InlineFrame1" style="width:540px;height:830px;background-color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>

on pge3.html
Code:
<iframe SRC="./guestbook/list.php?=file3.txt" id="InlineFrame1" style="width:540px;height:830px;background- color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>
etc.

In other words - use one GB every time, but calling it each time with different parameters so it writes in different data files.
Best regards.

P.S.
I don't know how to send you the script I meant in previous post, so I'll just copy and paste the core.
Code:
<?php //error_reporting(E_ALL ^ E_NOTICE); if(isset($_REQUEST['p'])) $filename = 'data_'.$_REQUEST['p'].'.txt'; else $filename = 'data.txt'; if(!file_exists($filename)) die('Please make sure the data file for this page has been created'); $ipbans = array('0.0.0.0'); $adminpassword = 'admin'; if((isset($_GET['admin']) && $_GET['admin'] == 1) || isset($_POST['admin']) && $_POST['admin'] == 1) { if(!isset($_GET['adminpass']) && !isset($_POST['adminpass'])) { echo 'Please enter the admin password.'; echo '<form action="guestbook.php" method="get"> <input type="password" name="adminpass"/> <input type="hidden" name="admin" value="1"/> <input type="submit" value="Continue" /> <input type="hidden" name="p" value="'.$_GET['p'].'" /> </form> </body> </html>'; } elseif((isset($_GET['adminpass']) && $_GET['adminpass'] == $adminpassword) || (isset($_POST['adminpass']) && $_POST['adminpass'] == $adminpassword)) { $data = unserialize(file_get_contents($filename)); $data = array_reverse($data); if(isset($_POST['edit']) && isset($_POST['message'])) { $data[$_POST['edit']]['message'] = $_POST['message']; file_put_contents($filename, serialize(array_reverse($data))); header("Location: guestbook.php?admin=1&adminpass={$_POST['adminpass']}&p={$_REQUEST['p']}"); } elseif(isset($_GET['edit'])) { echo '<strong>Editing comment id '.$_GET['edit'].' <form action="guestbook.php" method="POST"> <textarea name="message" rows="6" cols="38"> '.$data[$_GET['edit']]['message'].' </textarea> <input type="hidden" name="edit" value="'.$_GET['edit'].'"/> <input type="hidden" name="admin" value="1"/> <input type="hidden" name="adminpass" value="'.$_GET['adminpass'].'"/> <input type="hidden" name="p" value="'.$_GET['p'].'" /> <input type="submit" value="Submit"/> </form> <br/> <br/>'; } elseif(isset($_GET['delete'])) { unset($data[$_GET['delete']]); file_put_contents($filename, serialize(array_reverse($data))); header("Location: guestbook.php?admin=1&adminpass={$_GET['adminpass']}&p={$_GET['p']}"); } elseif(isset($_GET['banuser'])) { $bannedusers = unserialize(file_get_contents('userbans.txt')); if(!isset($bannedusers)) $bannedusers = array(); array_push($bannedusers, $_GET['banuser']); file_put_contents('userbans.txt', serialize($bannedusers)); } elseif(isset($_GET['banip'])) { $bannedips = unserialize(file_get_contents('ipbans.txt')); array_push($bannedips, $_GET['banip']); file_put_contents('ipbans.txt', serialize($bannedips)); } echo '<strong>Moderate Comments</strong> <table width="100%">'; $c = 0; for($i = 0; $i < count($data); $i++) { $date = date("F j, Y, g:i a", $data[$i]['date']); $user = htmlspecialchars(stripslashes($data[$i]['user'])); $message = htmlspecialchars(stripslashes($data[$i]['message'])); $ip = $data[$i]['ip']; if(isset($data[$i]['website']) && !empty($data[$i]['website'])) { $website = htmlspecialchars(stripslashes($data[$i]['website'])); $user = "<a href=\"$website\">$user"; } if($c == 0) { $c1 = '#CCCCEE'; $c2 = '#DDDDDD'; $c = 1; } else { $c1 = '#DDDDFF'; $c2 = '#EEEEEE'; } if($data[$i]['user'] != '11jds83jd7') { echo"<tr><td width=\"200\" valign=\"top\" style=\"background-color: $c1\"><strong>$user</strong><br/>IP: $ip<br/>$date</td><td valign=\"top\" style=\"background-color: $c2\">$message</td><td style=\"background-color: $c2\"><a href=\"guestbook.php?admin=1&adminpass={$_REQUEST['adminpass']}&edit=$i&p={$_REQUEST['p']}\">Edit<br><a href=\"guestbook.php?admin=1&adminpass={$_REQUEST['adminpass']}&delete=$i&p={$_REQUEST['p']}\">Delete</tr>\n"; } }; if(count($data) == 0) { echo '<tr><td colspan="2"><strong>Няма коментари още.</strong><br/><br/></td></tr>'; } echo '</table>'; ?> <br/> <strong>Ban Username</strong> <form action="guestbook.php" method="GET"> <input type="text" name="banuser" /> <input type="hidden" name="admin" value="1"/> <input type="hidden" name="adminpass" value="<?php echo $_GET['adminpass']; ?>"/> <input type="hidden" name="p" value="<?php echo $_REQUEST['p']; ?>" /> <input type="submit" value="Submit" /> </form> <strong>Ban IP Address</strong> <form action="guestbook.php" method="GET"> <input type="text" name="banip" /> <input type="hidden" name="admin" value="1"/> <input type="hidden" name="adminpass" value="<?php echo $_GET['adminpass']; ?>"/> <input type="hidden" name="p" value="<?php echo $_REQUEST['p']; ?>" /> <input type="submit" value="Submit" /> </form> <?php } exit; } if(isset($_POST['username']) && isset($_POST['message']) && !empty($_POST['username']) && !empty($_POST['message'])) { $bannedusers = unserialize(file_get_contents('userbans.txt')); $bannedips = unserialize(file_get_contents('ipbans.txt')); if(in_array($_POST['username'], $bannedusers)) echo 'Your username has been banned by the administrator.<br/><br/>'; if(in_array($_SERVER['REMOTE_ADDR'], $bannedips)) echo 'Your IP has been banned by the administrator.<br/><br/>'; elseif($_POST['1'] + $_POST['2'] != $_POST['check']) echo('You answered the security question incorrectly.'); else { $data = unserialize(file_get_contents($filename)); array_push($data, array('user' => htmlspecialchars($_POST['username']), 'date' => mktime(), 'message' => htmlspecialchars($_POST['message']), 'website' => htmlspecialchars($_POST['website']), 'ip' => $_SERVER['REMOTE_ADDR'])); file_put_contents($filename, serialize($data)); } } ?> <html> <head> <title>My Guestbook</title> <style type="text/css"> body { font-family: Verdana, Arial, sans-serif; } th { background-color: #BBBBDD; background-image:url('images/top_gradient.png'); } table { border-collapse: collapse; background-color: #EEEEEE; border-color: black; font-size: 10px; font-family: Verdana, Arial, sans-serif; } input { font-size: 10px; border: 1px solid black; color: black; background-color: #AAAAAA; } textarea { font-size: 10px; font-family: Verdana, Arial, sans-serif; border: 1px solid black; color: black; background-color: #AAAAAA; } </style> </head> <body> <table width="100%" class="table" border="1"> <?php $data = unserialize(file_get_contents($filename)); $data = array_reverse($data); $c = 0; for($i = 0; $i < count($data); $i++) { $date = date("F j, Y, g:i a", $data[$i]['date']); $user = stripslashes($data[$i]['user']); $message = stripslashes($data[$i]['message']); if(isset($data[$i]['website']) && !empty($data[$i]['website'])) { $website = stripslashes($data[$i]['website']); $user = "<a href=\"$website\">$user"; } if($c == 0) { $c1 = '#fff'; $c2 = '#fff'; $c = 1; } else { $c1 = '#fff'; $c2 = '#fff'; $c = 0; } if($data[$i]['user'] != '11jds83jd7') { echo"<tr><td width=\"300\" valign=\"top\" style=\"background-color: $c1\"><strong>$user</strong><br/>$date</td><td valign=\"top\" style=\"background-color: $c2\">$message</td></tr>"; } } if(count($data) == 0) { echo '<tr><td colspan="2"><strong>There are no posts to display.</strong><br/><br/></td></tr>'; } $n1 = rand(0, 10); $n2 = rand(0, 10); ?> <tr> <td colspan="2"> <form action="guestbook.php" method="post"> <strong>Sign my guestbook:</strong> <table cellpadding="3"> <tr><td>Име</td><td><input type="text" name="username"/></td></tr> <tr><td>Въпрос</td><td><?php echo ''.$n1.' плюс '.$n2.' = <input type="text" name="check" size="2" maxlength="2" />?'; ?><br></td></tr> <tr><td>Website (optional)</td><td><input type="text" name="website"/></tr> <tr><td>Коментар</td><td><textarea rows="6" cols="18" name="message"></textarea></tr> <tr><td>Давай</td><td><input type="hidden" name="p" value="<?php echo $_REQUEST['p']; ?>" /><input type="hidden" name="1" value="<?php echo $n1; ?>" /><input type="hidden" name="2" value="<?php echo $n2; ?>" /><input type="submit" value="Post Message"/></tr> <tr><td colspan="2">[url=http://1scripts.net/php-scripts/index.php?p=16]Powered by 1Book[/url]</td></tr> </form> </td> </tr> </table> </body> </html>

And this is the explonation

Multiple Guestbook Setup

The script will work out of the box as a single page guestbook. However, it will also work on multiple pages.

The data files are stored as data_blah.txt where blah is a unique identifier for the page. Create a file like this for each of your desired pages.

To include the guestbook in multiple pages, use the iframe code above, adding a "p" parameter to the URL:
Code:
<iframe src="/path/guestbook/guestbook.php?p=projects" width="100%" height="300px"></iframe>

Replace "projects" with the name one of the names of the data files you created earlier (leaving out the data_ and file extension).

You should now see a different guestbook on each page.

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #981 by Pete
Replied by Pete on topic Multiple guestbook
You can do that with the code I posted. All you have to do is to change your frame code to this:

On page1.html
Code:
<iframe SRC="./guestbook/list.php?sf=0&page=1&order=asc" id="InlineFrame1" style="width:540px;height:830px;background-color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>

On page2.html
Code:
<iframe SRC="./guestbook/list.php?sf=1&page=1&order=asc" id="InlineFrame1" style="width:540px;height:830px;background-color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>

on pge3.html
Code:
<iframe SRC="./guestbook/list.php?sf=2&page=1&order=asc" id="InlineFrame1" style="width:540px;height:830px;background- color:#ffffff;" scrolling="yes" frameborder="0"> is currently configured not to display inline frames.</iframe>

And inside the config.php file, you specify the filename you wish to use:
Code:
$storage_file = array(); $storage_file[] = 'data/file1.txt'; $storage_file[] = 'data/file2.txt'; $storage_file[] = 'data/file3.txt';

The reason I don't recommend specifying the filename as a parameter in the URL is because of cross site scripting security issues.

Pete

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #982 by ragou
Replied by ragou on topic Multiple guestbook
Thank you Pete again.
It's not necessary , but I want to tell you about me. I am 55 years old widower, building (construction?)engineer, retired. My daughter is a philosopher, but in this very moment she is on a plane flying to Bombay (Mumbay) being a CEO of a big company. 20 years ago I saw the first computer in my life. I connected to Internet 8 years ago with 2-3K speed. Now my domestic speed is 16MB/s and 1.5MB/s abroad. When we were under communism we new nothing, even if we tried - "Iron curtain". Now we now, but it's too late. Don't let me be misunderstood - my country produces steel, guns, machinery, electric power by nuclear plants etc. And we are just 7 million people!
I am surprised - you answered me twice with solution of my problem.
I thank you once again.
P.S.
I am a little bit drunk (Finlandia clear and pure), so forgive me please.
P.P.S. If you want you can see my site imaloednovreme.com - Once upon a time in Bulgarian. Unfortunately it's only in Bulgarian.
Thank you once again.
Best regards - Zarko.

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #983 by Pete
Replied by Pete on topic Multiple guestbook
You are very welcome my friend. Very nice website you have.

If you ever need more help with anything feel free to ask. :D


Pete

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.127 seconds
Powered by Kunena Forum