Jump to content


Photo

[ger - Germany] Guestbook3


  • Please log in to reply
No replies to this topic

#1 Helicopter

Helicopter

    Etomite Forum Newbie

  • Member
  • 15 posts

Posted 23 September 2005 - 03:11 PM

/*

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 German Translation by Rainer Vetter



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 = "gästebuch"; // 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

$header_style = "style='font-size: medium;'"; // Css style for header

$message_box_style = "style='border: 1px solid #000000; padding: 5px; background-color: #A0C0FF'"; // Css style for message box

$dateformat = "%d.%m.%Y um %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 = 00000; // number of seconds for timezone difference



// German language for guestbook 



$_lang_guestbook["write_new_message"] = "Neuen Eintrag schreiben";

$_lang_guestbook["messages"] = "Bisherige Einträge";

$_lang_guestbook["name_or_alias"] = "Name";

$_lang_guestbook["send"] = "Senden";

$_lang_guestbook["reset"] = "Zurücksetzen";

$_lang_guestbook["next_page"] = "Nächste Seite";

$_lang_guestbook["previous_page"] = "Vorherige Seite";

$_lang_guestbook["message"] = "Eintrag";

$_lang_guestbook["date_and_time"] = "Datum und Uhrzeit";

$_lang_guestbook["sender"] = "Absender";

$_lang_guestbook["cancel"] = "Löschen";

$_lang_guestbook["error"] = "Gastenboek User/Manager niet gevonden... Check de settings...";

/*



// Dutch language for guestbook 



$_lang_guestbook["write_new_message"] = "Plaats nieuw bericht";

$_lang_guestbook["messages"] = "Berichten";

$_lang_guestbook["name_or_alias"] = "Naam of alias";

$_lang_guestbook["send"] = "Zend";

$_lang_guestbook["reset"] = "Reset";

$_lang_guestbook["next_page"] = "Volgende pagina";

$_lang_guestbook["previous_page"] = "Vorige pagina";

$_lang_guestbook["message"] = "Bericht";

$_lang_guestbook["date_and_time"] = "Datum en tijd";

$_lang_guestbook["sender"] = "Verzender";

$_lang_guestbook["cancel"] = "Annuleren";

$_lang_guestbook["error"] = "Gastenboek User/Manager niet gevonden... Check de settings...";

/*

// 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...";



Finnish language for guestbook - Replace English language for guestbook lines



$_lang_guestbook["write_new_message"] = "Kirjoita uusi viesti";

$_lang_guestbook["messages"] = "Viestit";

$_lang_guestbook["name_or_alias"] = "Nimi tai nimimerkki";

$_lang_guestbook["send"] = "Lähetä";

$_lang_guestbook["reset"] = "Tyhjennä";

$_lang_guestbook["next_page"] = "Seuraava sivu";

$_lang_guestbook["previous_page"] = "Edellinen sivu";

$_lang_guestbook["message"] = "Viesti";

$_lang_guestbook["date_and_time"] = "Päiväys";

$_lang_guestbook["sender"] = "Lähettäjä";

$_lang_guestbook["cancel"] = "Annulär";

$_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['pagetitle']; // 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 $header_style>".$_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 $header_style>".$_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 $message_box_style width='100%'>";

        $output .= "<tr bgcolor=#FFCC66><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;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users