Etomite Community Forums: Guestbook3 - Etomite Community Forums

Jump to content

Read Me

This forum is posted in automatically when a snippet is added to the library, or updated. Please use the snippet topic to discuss that snippet.
  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Guestbook3

#1 User is offline   rain 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 7
  • Joined: 06-April 05

Posted 10 May 2005 - 06:44 AM

I have added a new snippet to the Snippet Library!

Snippet name: Guestbook3
Author: rain
Version: 1.0 (Final)
More info: <a href="http://www.etomite.com/browsesnippets.html?int_snipid=91">View this snippet</a>
Description:
Guestbook3 is derived from Guestbook2 and has as extra feature some nice smiley images functionality

Please feel free to comment on this snippet, suggest improvements, or simply praise my work! ;)

[This is an automatically created message]

Attached File(s)



#2 User is offline   rain 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 7
  • Joined: 06-April 05

Posted 11 May 2005 - 11:10 AM

I have updated this snippet in the Snippet Library!

[This is an automatically created message]

#3 User is offline   rain 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 7
  • Joined: 06-April 05

Posted 11 May 2005 - 11:11 AM

I have updated this snippet in the Snippet Library!

[This is an automatically created message]

#4 User is offline   hechacker1 

  • Etomite Forum Fan
  • Pip
  • Group: Member
  • Posts: 59
  • Joined: 10-January 05
  • Location:UCSD

Posted 11 May 2005 - 11:44 AM

rain, on May 11 2005, 04:11 AM, said:

I have updated this snippet in the Snippet Library!

[This is an automatically created message]


how do I change the header color background, and also the font colors? Could you make that a variable?

http://ordorica.org/index.php?id=22

is my site as an example.

#5 User is offline   Johanna 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 2
  • Joined: 11-May 05

Posted 11 May 2005 - 02:04 PM

I`ve installed Guestbook-3 at my site, but I get an error at the Guestbooksite.. who says "Guestbook-user/manager not found. Configurate the settings".

I dont know what I have to configurate/edit in the snippet. Can anybody help?

You can see the site here: Johannas Studieside - Use the link "Gæstebog"!!! :blink:

#6 User is offline   Ralph 

  • Etomite Administrator
  • Group: Admin
  • Posts: 6,418
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

Posted 11 May 2005 - 02:22 PM

Johanna, on May 11 2005, 11:04 AM, said:

I`ve installed Guestbook-3 at my site, but I get an error at the Guestbooksite.. who says "Guestbook-user/manager not found. Configurate the settings".

I dont know what I have to configurate/edit in the snippet. Can anybody help?

You can see the site here: Johannas Studieside  -  Use the link "Gæstebog"!!! :blink:

That message refers to the fact that you need to adjust the code to include an existing Etomite user/manager as the GuestBook3 administrator... The variable which needs attention is $gbadmin which can either be hard-coded or can be sent in the snippet call... Hope this helps... :eto:

#7 User is offline   Johanna 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 2
  • Joined: 11-May 05

Posted 11 May 2005 - 02:59 PM

Thank you!

I still get errors.. so I`ll look at it later! :blush:

#8 User is offline   rain 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 7
  • Joined: 06-April 05

Posted 12 May 2005 - 06:35 PM

Oh I forgot: :blush:

if you add this:

#smilie_box {
visibility: hidden;
position: absolute;
left: 750px;
top: 285px;
padding: 5px;
margin: 22px 0 0 -26px;
border: 1px solid #0000FF;
background: #FFFFFF;
width: 200px;
}

to your style sheet,
you can use these variables to pre-position the smilie box when the smilie-button is pressed.

Perhaps there are some more make-up things that I placed directly in the snippetcode which can be placed in the style sheet. Please feel free to do so and enhance the guestbook.

#9 User is offline   Newlukai 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 12
  • Joined: 23-May 05

Posted 23 May 2005 - 03:20 PM

Hi there,

i successfully installed etomite and the guestbook3 snippet. It worked great. I didn't change anything but now I get a 'Cannot redeclare smile()' error everytime I try to watch the guestbook. I don't know where the bug is, in the snippet itself or in the etomite parser.
Can anybody help me?

Greetz
Newlukai

#10 User is offline   Ralph 

  • Etomite Administrator
  • Group: Admin
  • Posts: 6,418
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

Posted 23 May 2005 - 05:56 PM

Newlukai, on May 23 2005, 12:20 PM, said:

Hi there,

i successfully installed etomite and the guestbook3 snippet. It worked great. I didn't change anything but now I get a 'Cannot redeclare smile()' error everytime I try to watch the guestbook. I don't know where the bug is, in the snippet itself or in the etomite parser.
Can anybody help me?

Greetz
Newlukai

If you aren't doing so already, try using [!...!] for your snippet call instead of [[...]] to see if that helps... If this caching issue doesn't solve your problem then you might want to try reinstalling the snippet code, although I can't imagine how it would become only partially corrupt... Keep us posted... Also, try refreshing your site from within Etomite manager... :eto:

#11 User is offline   Newlukai 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 12
  • Joined: 23-May 05

Posted 24 May 2005 - 01:57 PM

Ralph (rad14701), on May 23 2005, 08:56 PM, said:

If you aren't doing so already, try using [!...!] for your snippet call instead of  [[...]] to see if that helps... If this caching issue doesn't solve your problem then you might want to try reinstalling the snippet code, although I can't imagine how it would become only partially corrupt... Keep us posted... Also, try refreshing your site from within Etomite manager... :eto:


I changed the snippet call but it doesn't work. I reinstalled the code more than 1 time. Doesn't work, too. Could it be that PHP 5 isn't supported?

#12 User is offline   Ralph 

  • Etomite Administrator
  • Group: Admin
  • Posts: 6,418
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

Posted 24 May 2005 - 02:28 PM

Newlukai, on May 24 2005, 10:57 AM, said:

I changed the snippet call but it doesn't work. I reinstalled the code more than 1 time. Doesn't work, too. Could it be that PHP 5 isn't supported?

Ahhhh... Another piece of the puzzle is revealed... Might have helped to have lnown about the PHP5 earlier... You may want to check into whether PHP5 does additional caching... If so, I'm sure there is a work-around... :eto:

#13 User is offline   Newlukai 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 12
  • Joined: 23-May 05

Posted 24 May 2005 - 03:02 PM

Ralph (rad14701), on May 24 2005, 05:28 PM, said:

Ahhhh... Another piece of the puzzle is revealed... Might have helped to have lnown about the PHP5 earlier... You may want to check into whether PHP5 does additional caching... If so, I'm sure there is a work-around... :eto:


OK. I'm a beginner in such issues, but I will do my best.

#14 User is offline   Prelithe 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 4
  • Joined: 07-June 05

Posted 07 June 2005 - 11:40 PM

I can say that it works with php 5 (i have tested it with php 5.0.3 apache)

I helped myself and did a few little modifications, mostly to the style so you can edit directly from css, so here is the new code:

/*
Snippet:        GuestBook3 (based on GuestBook2) - Etomite v0.6.3 - Modified 2005-09-05

Created By:     Ralph A. Dahlgren - rad14701@yahoo.com
Modified By:    Mikko K. Lammi - lammikko@gmail.com - www.parea.fi
Modified By:    Rain R. Visser
Modified By:    Prelithe - Added Styles

Demo URL GB2:   http://www.parea.fi/raaputuksia/guestbook.html

Usage:          Create an Etomite user or admin as GuestBook owner in Etomite Manager
                Change $defaultadmin variable to match GuestBook owner
                OR
                Messages will be deposited into that mailbox, but only GuestBook
                messages will be displayed within the GuestBook listing.
                Place the .gifs in assets\images
                Place the .JS in assets\site

Variables:      $gbtype - Referenced in GuestBook admin User Messages Subject
                $gbadmin - Etomite User/Admin who will receive this message

Examples:       Use the [!SnippetName!] syntax instead of regular [[SnippetName]]:
                [!GuestBook!] - Will use snippet defaults for $gbtype and $gbadmin
                [!GuestBook?gbtype=GuestBook&gbadmin=guestbook!] - Self Explanatory
                [!GuestBook?gbadmin=someuser!] - Uses $etomite->documentObject['pagetitle'] for $gbtype
                [!GuestBook?bgtype=SomeTopic!] - Uses $defaultadmin for $gbadmin

Note:           $etomite->documentObject['createdby'] was not used for $gbadmin intentionally
                To implement this capability would entail and additonal DB Query before Inserts
*/

// BEGIN SETTINGS -------------------------------------------------------------

// Variables you may want to change

$defaultadmin = "Prelithe"; // Default GuestBook admin to use if $gbadmin not passed
$gap = " :: "; // Separator between $type and $subject in User Messages Subject field
$messages = 10; // Number of messages on one page


$dateformat = "%d.%m.%Y om %H:%M:%S"; // Preferred Date & Time display format, European dateformat is "%d.%m.%Y %H:%M:%S"
$order = "DESC"; // Order of messages by postdate: DESC = descending, ASC = ascending
$server_offset_time = 21600; // number of seconds for timezone difference

// English language for guestbook

$_lang_guestbook["write_new_message"] = "Write a new message";
$_lang_guestbook["messages"] = "Messages";
$_lang_guestbook["name_or_alias"] = "Name or alias";
$_lang_guestbook["send"] = "Send";
$_lang_guestbook["reset"] = "Reset";
$_lang_guestbook["next_page"] = "Next page";
$_lang_guestbook["previous_page"] = "Previous page";
$_lang_guestbook["message"] = "Message";
$_lang_guestbook["date_and_time"] = "Date and time";
$_lang_guestbook["sender"] = "Sender";
$_lang_guestbook["cancel"] = "Cancel";
$_lang_guestbook["error"] = "GuestBook User/Manager not found... Check your settings...";
// END SETTINGS ---------------------------------------------------------------



// Variables you should not need to change
$type = isset($gbtype) ? $gbtype : $etomite->documentObject['id']; // Set $type field for new entry
$trimtype=substr($type,0,15); // Truncate $type to 15 character limit for field
$guestbookadmin = isset($gbadmin) ? $gbadmin : $defaultadmin; // Set GuestBook admin
$pageid=$etomite->documentIdentifier; // ID of the calling document
$pageurl=$etomite->makeURL($pageid); // URL if you don't have friendly uri
$tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix'];
$msgdb = $tbl."user_messages"; // DB.Prefix_user_messages variable

// Function to show smileys
function smile($text) {
    $text = str_replace(":)", "<img src=\"assets/images/smile.gif\">", $text);
    $text = str_replace(":D", "<img src=\"assets/images/biggrin.gif\">", $text);
    $text = str_replace(":haha:","<img src=\"assets/images/laugh.gif\">", $text);
    $text = str_replace(";)","<img src=\"assets/images/wink.gif\">", $text);
    $text = str_replace(":cool:","<img src=\"assets/images/cool.gif\">", $text);
    $text = str_replace(":o","<img src=\"assets/images/blush.gif\">", $text);
    $text = str_replace(":(","<img src=\"assets/images/frown.gif\">", $text);
    $text = str_replace(":foei:","<img src=\"assets/images/nono.gif\">", $text);
    $text = str_replace(":schrik:","<img src=\"assets/images/eek.gif\">", $text);
    $text = str_replace(":boos:","<img src=\"assets/images/mad.gif\">", $text);
    $text = str_replace(":dood:","<img src=\"assets/images/dead.gif\">", $text);
    $text = str_replace(":huil:","<img src=\"assets/images/cry.gif\">", $text);
    $text = str_replace(":kus:", "<img src=\"assets/images/kiss.gif\">", $text);
    $text = str_replace(":love:","<img src=\"assets/images/rose.gif\">", $text);
    $text = str_replace(":stil:", "<img src=\"assets/images/quiet.gif\">", $text);
    $text = str_replace(":kijk:","<img src=\"assets/images/look.gif\">", $text);
    $text = str_replace(":poets:", "<img src=\"assets/images/brushteeth.gif\">", $text);
    $text = str_replace(":proost:","<img src=\"assets/images/cheers.gif\">", $text);
    $text = str_replace(":clown:","<img src=\"assets/images/clown.gif\">", $text);
    $text = str_replace(":td:","<img src=\"assets/images/notgood.gif\">", $text);
    $text = str_replace(":tu:",  "<img src=\"assets/images/perfect.gif\">", $text);
    $text = str_replace(":buig:","<img src=\"assets/images/hail.gif\">", $text);
    $text = str_replace(":spring:","<img src=\"assets/images/bouncey.gif\">", $text);
    $text = str_replace(":nerd:","<img src=\"assets/images/nerd.gif\">", $text);
    $text = str_replace(":idee:","<img src=\"assets/images/idea.gif\">", $text);
    $text = str_replace(":zzz:","<img src=\"assets/images/sleep.gif\">", $text);
    $text = str_replace(":P","<img src=\"assets/images/tongue.gif\">", $text);
    $text = str_replace(":zwaai:","<img src=\"assets/images/wave.gif\">", $text);
    $text = str_replace(":fluit:", "<img src=\"assets/images/whissle.gif\">", $text);
    $text = str_replace(":verbaasd:","<img src=\"assets/images/confused.gif\">", $text);
   return $text;
}


// Function to make hyperlinks
function hyperlink($text) {
    $search = array ("/([\w\.\/\&\=\?\-]+)@([\w\.\/\&\=\?\-]+)/","/((ftp(7?):\/\/)|(ftp\.))([\w\.\/\&\=\?\-]+)/","/((http(s?):\/\/)|(www\.))([\w\.\/\&\=\?\-]+)/");
    $replace = array ("<a href='mailto:$1@$2'>$1@$2</a>","<a href='ftp$3://$4$5' target='_blank'>$4$5</a>","<a href='http$3://$4$5' target='_blank'>$4$5</a>");
    return preg_replace ($search, $replace, $text);
}

// Don't allow unwanted re-posts of messages
if($_POST['submitted'] == "TRUE") header( "Location: index.php?id=$etomite->documentIdentifier" );

// Query for the user ID (id) for the GuestBook owner
$sql = "SELECT id FROM ".$tbl."manager_users WHERE ".$tbl."manager_users.username='$guestbookadmin';";
$rs = $etomite->dbQuery($sql);
$limit = $etomite->recordCount($rs);

// Check to make sure $guestbookadmin has been created and assigned
if($limit == 1) {

    $userrec = $etomite->fetchRow($rs);
    $userid = $userrec['id'];

    // Check to see if a valid message has been submitted
    if(isset($_POST['submit']) && ($_POST['subject'] > "")  && ($_POST['message'] > "")){
        $postdate = time();

        $recipient = $userid;
        $subject = $type . $gap . strip_tags($_POST['subject']);
        $message = strip_tags($_POST['message']);

        // Query to INSERT a new GuestBook message into user_messages
        $sql = "INSERT INTO $msgdb ( id , type , subject , message , sender , recipient , private , postdate , messageread ) VALUES ( '', '$type', '$subject', '$message', '0', '$recipient', '0', '$postdate', '0' );";

        $rs = $etomite->dbQuery($sql);  // Execute the Query
        $submitted="TRUE";
    }
    else $submitted = "TRUE";

    // Display write new message form
//    if ($_GET['new_message'] == "TRUE") {
        // Display a Form for submitting a new message
        $output .= "<script language=\"javascript\" type=\"text/javascript\" src=\"assets/site/gb.js\"></script>";
        $output .= "<h2 class='GBHeaderStyle'>".$_lang_guestbook["write_new_message"]."</h2>";
        $output .= "<table width='100%'><tr><td>";
        $output .= "<form name=\"form\" method='post' action='index.php'>";
        $output .= "<input type='hidden' name='id' value='$pageid' />";
        $output .= "<input type='hidden' name='submitted' value='$submitted' />";
        $output .= $_lang_guestbook["name_or_alias"]."<br /><input name='subject' size='40' />";
        $output .= "<br /><br />".$_lang_guestbook["message"]."<br /><text"."area rows='8' cols='50' name='message'></"."text"."area>";
        $output .= "<button type=\"button\" onclick=\"show_smilies();\"><img src=\"assets/images/smile.gif\"></button><div><div id=\"smilie_box\"></div></div><br /><br />";
        $output .= "<input type='submit' name='submit' value='".$_lang_guestbook["send"]."' />";
        $output .= "  <input type='reset' name='reset' value='".$_lang_guestbook["reset"]."' />";
        $output .= "  <input type='button' value='".$_lang_guestbook["cancel"]."' onClick=\"window.location.href='$pageurl&new_message=FALSE'\">";
        $output .= "</form>";
        $output .= "</td></tr></table>";
//    }
  
    // Display write new message link
 /*   else {
        $output .= "<h2 $header_style>".$_lang_guestbook["write_new_message"]."</h2>";
        $output .= "  <form><input type='button' value='".$_lang_guestbook["write_new_message"]."' onClick=\"window.location.href='$pageurl&new_message=TRUE'\"></form>";
    }
  */
    $output .= "<h2 class='GBHeaderStyle'>".$_lang_guestbook["messages"]."</h2>";

    // Query to COUNT existing messages
    $sql = "SELECT * FROM ".$tbl."user_messages
    WHERE ".$tbl."user_messages.recipient=$userid
    AND ".$tbl."user_messages.type='".$trimtype."'
    ORDER BY ".$tbl."user_messages.postdate $order;";

    $rs = $etomite->dbQuery($sql);  // Execute the Query
    $total = $etomite->recordCount($rs);  // Number of messages found

    // Message page number from GET
    if (isset($_GET["page"])) { $page = $_GET["page"]; }
    else { $page = 1; }

    // Index where to start in result set
    $from = 0 + ($page-1)*$messages;

    // Query to SELECT existing messages
    $sql = "SELECT * FROM ".$tbl."user_messages
    WHERE ".$tbl."user_messages.recipient=$userid
    AND ".$tbl."user_messages.type='".$trimtype."'
    ORDER BY ".$tbl."user_messages.postdate $order LIMIT $from, $messages;";

    $rs = $etomite->dbQuery($sql);  // Execute the Query
    $limit = $etomite->recordCount($rs);  // Number of messages found

    // Number of pages
    $pages = ceil($total/$messages);

    // Previous page link
    $previouspage = $page-1;
    $previouspage_text .= "  <form><input type='button' value='« ".$_lang_guestbook["previous_page"]." [$previouspage/$pages]' onClick=\"window.location.href='$pageurl&page=$previouspage'\"></form>";
//    $previouspage_text = "<a href='?page=$previouspage'>« ".$_lang_guestbook["previous_page"]." [$previouspage/$pages]</a>   ";

    // Next page link
    $nextpage = $page+1;
    $nextpage_text = "  <form><input type='button' value='".$_lang_guestbook["next_page"]." [$nextpage/$pages] »' onClick=\"window.location.href='$pageurl&page=$nextpage'\"></form>";
//    $nextpage_text = "<a href='?page=$nextpage'>".$_lang_guestbook["next_page"]." [$nextpage/$pages] »</a>";

    // Previous and next page links at top of the page
    if ($previouspage > 0) { $output .= $previouspage_text; }
    if ($nextpage <= $pages) { $output .= $nextpage_text; }

    // Empty lines
    if ($total > $messages) {
        $output .= "<br /><br />";
    }

    // Loop through each of the messages and format for display
    for ($y = 0; $y < $limit; $y++) {
        if ($order == "DESC") { $number = $total - $from - $y; }
        if ($order == "ASC") { $number = $from + $y + 1; }
        $guestbookrec = $etomite->fetchRow($rs);
        $poster = str_replace($type.$gap,"",$guestbookrec['subject']);
        $message = nl2br($guestbookrec['message']);
        $postdate = strftime($dateformat, $guestbookrec['postdate']+$server_offset_time);
        $output .= "<table class='GBCommentBox' width='100%'>";
        $output .= "<tr><td nowrap width='80%'>$poster</td>";
        $output .= "<td nowrap width='20%' align=right>$postdate</td>";
        $output .= "<tr><td colspan=\"2\"> </td>";
        $output .= "<tr><td colspan=\"2\">".hyperlink(smile($message))."</td>";
        $output .= "<tr><td width='80%'> </td>";
        $output .= "<td width='20%' nowrap align=right>".$_lang_guestbook["message"].": $number/$total</td>";
        $output .= "</table><br />";
    }

    // Previous and next page links at bottom of the page
    if ($previouspage > 0) { $output .= $previouspage_text; }
    if ($nextpage <= $pages) { $output .= $nextpage_text; }
}

// If no valid GuestBook owner is found display error message...
else  $output = $_lang_guestbook["error"];

// Output
return $output;


and the stylesheet code:

.GBCommentBox {
border: 1px solid #000000; 
padding: 5px;
background-color: #FFFFFF;
}

.GBHeaderStyle {
font-size: 14px;
}

#smilie_box {
visibility: hidden;
position: relative;
left: 100px;
align: center;
padding: 5px;
margin: 22px 0 0 -26px;
border: 1px solid #0000FF;
background: #FFFFFF;
width: 300px;
}


Other changes:
Made gb_type equal to the page ID if no value was set
gb_admin is set to prelithe - change it!
Comments box shows up regardless of button pressing, just uncomment the if and else statements if you want it back to default

Hope you like!

EDIT: Sorry bout the page expanding, it's not my fault :ph34r:

#15 User is offline   Robsta 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 360
  • Joined: 23-December 04
  • Location:Exeter, Devon, UK

Posted 08 June 2005 - 12:01 AM

I've been trying to add formating to message list, and I can't seem to get it to add padding (using CSS).
   // Loop through each of the messages and format for display
    for ($y = 0; $y < $limit; $y++) {
        if ($order == "DESC") { $number = $total - $from - $y; }
        if ($order == "ASC") { $number = $from + $y + 1; }
        $guestbookrec = $etomite->fetchRow($rs);
        $poster = str_replace($type.$gap,"",$guestbookrec['subject']);
        $message = nl2br($guestbookrec['message']);
        $postdate = strftime($dateformat, $guestbookrec['postdate']+$server_offset_time);
        $output .= "<table class='GBMessageList' width='100%'>";
        $output .= "<tr><td class='GBMessagePoster' nowrap width='80%'>$poster</td>";
        $output .= "<td class='GBMessagePostDate' nowrap width='20%' align=right>$postdate</td>";
        $output .= "<tr><td colspan=\"2\"> </td>";
        $output .= "<tr><td colspan=\"2\">".hyperlink(smile($message))."</td>";
        $output .= "<tr><td width='80%'> </td>";
        $output .= "<td width='20%' nowrap align=right>".$_lang_guestbook["message"].": $number/$total</td>";
        $output .= "</table><br />";
    }


I would assume that adding a class 'GBMessageList' into CSS and applying padding, this would work. But it doesn't seem to for some reason, any ideas why? :blink: I've successfully does this to the add message form, and works a treat.

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users