how to send a copy of posts to home page

Everything related to GBook PHP guestbook
Post Reply
chiapil
Posts: 3
Joined: Fri May 15, 2009 9:19 am

how to send a copy of posts to home page

Post by chiapil »

/*************************************
Title: sending a copy of posts to home page
Version: 1.6
Author:
Demo:
Download:
Website: not online yet -- www.talkindrum.it

Short description:

I love this script!!!
and...

I would like to have a short preview of the guestbook posts in the home page like a little space in which visitors could look at the last messages left before to go to the real gbook page.
What i want is that every time someone post a new message it go in the gbook page as usual and also like a copy or whatever (which will link back to the gbook page) in a small div in home page.

Would be helpful, even if no one have a solution, to know what is the variable name of the posts and in which way posts are sent to the page, just to try to get it done by myself...

THAAAAAAAAAAANKS!!!!!!!!!! :)

Chiara


*************************************/

(Here below you can write additional info, longer description and comments)
chiapil
Posts: 3
Joined: Fri May 15, 2009 9:19 am

Post by chiapil »

Does anyone have any hint? would be very very very appreciated
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Hi chiapil,

I have not done anything like this myself, but i think you will have to look in the gbook.php at the following function (GBook 1.6 line 947 and following): function printEntries($lines,$start,$end) {

After some copy and past work i have this (very ugly code, with original not needed code commented to show you what the original code was):

Code: Select all

<?php
error_reporting(E_ALL ^ E_NOTICE);
define('IN_SCRIPT',true);

require('settings.php');
require($settings['language']);
$settings['verzija']='1.6';

/*
if ($page>0) {
    $start=($page*10)-9;$end=$start+9;
} else {
    $page=1;$start=1;$end=10;
}
*/
// instead of function above set start and end of number of messages manually
$start=1;$end=5;

$lines=file($settings['logfile']);
$total = count($lines);
//printEntries($lines,$start,$end);
//exit();

//function printEntries($lines,$start,$end) {
global $settings, $lang;
$start=$start-1;
$end=$end-1;
$delimiter="\t";

for ($i=$start;$i<=$end;$i++) {
$lines[$i]=rtrim($lines[$i]);
list($name,$from,$email,$url,$comment,$added,$isprivate,$reply)=explode($delimiter,$lines[$i]);
echo '
<table border="0" cellspacing="0" cellpadding="2" width="95%" class="entries">
<tr>
<td class="upper" style="width:35%"><b>'.$lang['t15'].'</b></td>
<td class="upper" style="width:65%"><b>'.$lang['t16'].'</b></td>
</tr>
<tr>
<td valign="top" style="width:35%">'.$lang['t17'].' <b>'.$name.'</b><br />
';
if ($from)
{
    echo $lang['t18'].' '.$from.'<br />';
}
if ($settings['use_url'] && $url)
{
    $target = $settings['url_blank'] ? 'target="_blank"' : '';
    echo $lang['t19'].' <a href="go.php?url='.$url.'" class="smaller" '.$target.'>'.$url.'</a><br />';
}
if ($email)
{
    if ($settings['hide_emails'])
    {
        echo $lang['t20'].' <a href="gbook.php?a=viewEmail&num='.$i.'" class="smaller">'.$lang['t27'].'</a>';
    }
    else
    {
        echo $lang['t20'].' <a href="mailto:'.$email.'" class="smaller">'.$email.'</a>';
    }
}

echo '
</td>
<td valign="top" style="width:65%">
';

    if (empty($isprivate) || empty($settings['use_private']))
    {
        echo $comment;
    }
    else
    {
        echo '
        <br />
        <br />
        <i><a href="gbook.php?a=viewprivate&num='.$i.'">'.$lang['t58'].'</a></i>
        <br />
        ';
    }

    if (!empty($reply))
    {
        echo '<br /><br /><i><b>'.$lang['t30'].'</b> '.$reply.'</i>';
    }

echo '
    <br />&nbsp;

    <table border="0" width="100%" cellspacing="2" cellpadding="0" class="gbookMenu">
    <tr>
    <td style="width:50%" class="smaller">'.$lang['t31'].' '.$added.'</td>
    <td style="width:50%; text-align:right">
    <a href="gbook.php?a=delete&num='.$i.'"><img src="images/delete.gif" width="14" height="14" alt="'.$lang['t32'].'" style="border:none; vertical-align:text-bottom" /></a>
    &nbsp;<a href="gbook.php?a=reply&num='.$i.'"><img src="images/reply.gif" width="14" height="14" alt="'.$lang['t33'].'" style="border:none; vertical-align:text-bottom" /></a>
    &nbsp;<a href="gbook.php?a=viewIP&num='.$i.'"><img src="images/ip.gif" width="14" height="14" alt="'.$lang['t09'].'" style="border:none; vertical-align:text-bottom" /></a>
    &nbsp;
    </td>
    </tr>
    </table>

</td>
</tr>
</table>
';
}
//} // END printEntries
echo '
<!--
Changing the "Powered by" credit sentence without purchasing a licence is illegal!
Please visit http://www.phpjunkyard.com/copyright-removal.php for more information.
-->
<p style="text-align:center" class="smaller">Powered by <a href="http://www.phpjunkyard.com/php-guestbook-script.php" class="smaller" >PHP guestbook</a> 1.6 from <a href="http://www.phpjunkyard.com/" class="smaller" >PHPJunkyard - Free PHP scripts</a></p><p style="text-align:center"><a href="http://www.phpjunkyard.com/tutorials/guestbook-spam.php" ><img src="images/nospam.gif" alt="Guestbook SPAM? Stop it!" style="border:none" /></a></p>
';
?> 
Works for me if the file in which this is pasted is inside the gbook directory.

I think this should be enough to get you going :wink:

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
chiapil
Posts: 3
Joined: Fri May 15, 2009 9:19 am

Post by chiapil »

more than enough! im gonna try right now and Ill let you know.


cheers
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Yes, please let me know.
Especially if you got it working when the php page is not inside the gbook folder. I might than even use it on one of my own pages ;-)

Bytheway, the code i gave you is not ugly by itself (it is the original code from Klemen), it is just the way i pasted it all together. I think the code could be leaner and needs some change in layout output to be usable in a div on the home page.

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
Post Reply