Jump to content


kgbook2


  • You cannot reply to this topic
26 replies to this topic

#1 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 02 April 2006 - 04:56 PM

I have added a new snippet to the Snippet Library!

Snippet name: kgbook2
Author: kastor
Version: 1.0 (Beta)
More info: View this snippet
Description:
This snippet is an advanced guestbook, with client and serverside input check, html filter, spam protection and is highly customizable.

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

[This is an automatically created message]

#2 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 02 April 2006 - 05:06 PM

Updated Snippet Message
I have updated this snippet in the Snippet Library!

[This is an automatically created message]

#3 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 02 April 2006 - 05:33 PM

Hi,

at first you to install the snippet:
Before using the snippet, you have to decide wether to change the snippet code or Etomites index.php. If you would use my captcha functions, read this thread and do what I'm describing there. Otherwise, change the following lines:
Line 55: change $etomite->getCaptchaCode to $etomite->getCaptchaNumber
Line 110: change $etomite->validCaptchaCode to $etomite->validCaptchaNumber

Create a snippet, call it as you like and paste the snippet code inside. Now I'll explain the options (can be found at the top):
- $gbookFolder : set to the folder where the entries should be stored and read from, you will be able to edit them as you like, because the entries will be stored as ordinary documents
- $entriesPerPage: set the number of entries per page
- $thxPageId: you have to create this page. Place a polite text on int (for example: Thanks for your entry)
- $repostProtection: set to the seconds a visitor which just created an entry has to wait to create a new one
- $minCaptchaLength: set to the minimal length of the captcha text
- $maxCaptchaLength: set to the maximal length of the captcha text
- $maxURLLength: maximal length of an url before it is shortened, unit: chars. If a url is too long, it will be shown as 'http://www.etomite...'.

The guestbook makes heavy use of chunks to make you able to get a visual customizable output, so at first you need to create some chunks. Use the exact names, or change them in the appropiate line of the snippet.
I've attached the set of my chunks, of course you can use them if you will. If you want to create you own, here are the placeholders for the chunks:

Chunk: kgbook-alreadyEntered will be shown if the person had just created one entry
No placeholders. Enter a message in pure html, for example: To avoid multiple entries, you are now only allowed to read the existing entries.

Chunk: kgbook-entrydisplay holds one entry
- %name%: name of the entry creator
- %mail%: email of the creator
- %weburl%: webadress of the creator
- %message%: the entry
- %datetime%: date and time of the creation
- %number%: entry number

Chunk: kgbook-newentryfrm contains the new entry from
- %actionurl%: the action url of the form
- %captcha%: <img> tag of the captcha
- %maxcaptcha%: maximal captcha length

Chunk: kgbook-pagenavigation creates the page navigation
- %entrycount%
- %currentpage%
- %pagecount%
- %firstpage%: a complete link (<a href="">...) to the first page
- %prevpage%: a complete link (<a href="">...) to the previous page
- %nextpage%: a complete link (<a href="">...) to the next page

Chunk: kgbook-summary summary of the guest book
- %entrycount%
- %currentpage%
- %pagecount%

To customize the output itself (for example, you would like to have the new entry formular at the bottom), edit the code below line 258, documentation is in the snippet.

Not needed for Etomite 0.6.1 final!
A small patch for the makeURL function:
If you use Etomite not at the top directory of your domain, you can get problems when a visitor successfully creates an entry, because the snippet redirects to a thank you page. For this, I'm using Etomite. If you get errors and you are using etomite not at the top directory of your domain (for example http://www.kgbookist...nearth/etomite/), than apply this patch to your index.php. Be carefull, I'm using it, but test it before you will use it too!
Replace the code between line 1434 and line 1443
if(!is_numeric($id)) {
.
.
.
return $this->config['site_url']."/"."index.php?id=$id$args";
}
with this one:
if(!is_numeric($id)) {
   $this->messageQuit("`$id` is not numeric and may not be passed to makeUrl()");
	}
	if($this->config['friendly_alias_urls']==1 && isset($this->aliases[$id])) {
   $genURL = $this->config['site_url']."/".$this->aliases[$id].$this->config['friendly_url_suffix'].$args;
   return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
	} elseif($this->config['friendly_urls']==1) {
   $genURL = $this->config['site_url']."/".$this->config['friendly_url_prefix'].$id.$this->config['friendly_url_suffix'].$args;
   return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
	} else {
   $genURL = $this->config['site_url']."/"."index.php?id=$id$args";
   return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
	}

Important: Patch for Etomite 0.6.1 (and above)!
Change line 56 of the snippet from
$gbookCaptcha = $etomite->getCaptchaCode(rand($minCaptchaLength, $maxCaptchaLength), 'captcha code', 'captcha Code');
in
$gbookCaptcha = $etomite->getCaptchaCode();
.
Otherwise you'll get display problems with some browsers (see posts from smartie below).


Have fun with the guestbook.

Greetings, Kastor

Attached Files


Edited by kastor, 22 September 2006 - 01:47 PM.


#4 Dean

    Loves Etomite Forums!

  • Admin
  • 4,758 posts
  • Gender:Male

Posted 02 April 2006 - 09:10 PM

Ralph, can you check if the code posted above (the MakeURL part) needs to be committed to the base?

#5 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 02 April 2006 - 09:24 PM

Dean, on Apr 2 2006, 10:10 PM, said:

Ralph, can you check if the code posted above (the MakeURL part) needs to be committed to the base?
Its hard to read, with all the different returns, but it retains the old bug in adding the $args parameter, so wouldn't work as is for all configurations.

#6 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 02 April 2006 - 09:44 PM

Rather than taking the time to weed through the logic I'll pose this question to Kastor... Are you basing these modifications on the makeURL() API function listed below...??? The code listed has been tested across platforms and there have been no complaints regarding its functionality... :eto:

 function makeUrl($id, $alias=0, $args='') {
  // Modified by mikef
  // returns a properly formatted URL as of 0.6.1 Final
  // $id is a valid document id
  // $alias is now an unused parameter because it is now calculated based on $id
  // $args is a URL compliant text string of $_GET key=value pairs
  // Example: makeURL(45,'','?cms=Etomite')
  // ToDo: add conditional code to create $args from a $key=>$value array
    global $ETOMITE_PAGE_BASE;
    if(!is_numeric($id)) {
      $this->messageQuit("`$id` is not numeric and may not be passed to makeUrl()");
    }
    $baseURL=$ETOMITE_PAGE_BASE['www'];
    if($this->config['friendly_alias_urls']==1 && isset($this->aliases[$id])) {
      $url = $baseURL.$this->aliases[$id];
    } elseif($this->config['friendly_urls']==1) {
      $url = $baseURL.$this->config['friendly_url_prefix'].$id.$this->config['friendly_url_suffix'];
    } else {
      $url = $baseURL."index.php?id=$id";
    }
    if (strlen($args)&&strpos($url, "?")) $args="&amp;".substr($args,1);
    return $url.$args;
  }


#7 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 03 April 2006 - 09:58 AM

Hi,

my modification is not based on this one you posted. The makeURL function I get (through the download and the Bugfix thread) is this one:
 function makeUrl($id, $alias='', $args='') {
  // returns a properly formatted URL as of 0.6.1 Final
  // $id is a valid document id
  // $alias is now an unused parameter because it is now calculated based on $id
  // $args is a URL compliant text string of $_GET key=value pairs
  // Example: makeURL(45,'','?cms=Etomite')
  // ToDo: add conditional code to create $args from a $key=>$value array
    if(!is_numeric($id)) {
      $this->messageQuit("`$id` is not numeric and may not be passed to makeUrl()");
    }
    if($this->config['friendly_alias_urls']==1 && isset($this->aliases[$id])) {
      return $this->config['site_url']."/".$this->aliases[$id].$this->config['friendly_url_suffix'].$args;
    } elseif($this->config['friendly_urls']==1) {
      return $this->config['site_url']."/".$this->config['friendly_url_prefix'].$id.$this->config['friendly_url_suffix'].$args;
    } else {
      return $this->config['site_url']."/"."index.php?id=$id$args";
    }
  }
and this one is definitely not caring about if Etomite is installed in a subdirectory or not.
I think the problem is located in the config variable 'site_url' which contains only the domain without any subdirectories. To fix this problem for my snippet, I thougth it is more practicable to change only the function I'm using (makeURL) rather than variable 'site_url' and the functions relaying on it.

Greetings, Kastor

#8 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 03 April 2006 - 01:50 PM

kastor, on Apr 3 2006, 06:58 AM, said:

Hi,

my modification is not based on this one you posted. The makeURL function I get (through the download and the Bugfix thread) is this one:
<<< SNIP >>>
and this one is definitely not caring about if Etomite is installed in a subdirectory or not.
I think the problem is located in the config variable 'site_url' which contains only the domain without any subdirectories. To fix this problem for my snippet, I thougth it is more practicable to change only the function I'm using (makeURL) rather than variable 'site_url' and the functions relaying on it.

Greetings, Kastor
In Etomite Prelude Final the only reference to $this->config['site_url'], located in the executeParser function, and soon to be removed, is no longer used... In fact, color it gone as of right now as it has been deleted from the code base...

#9 DeniseDD

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 15 June 2006 - 05:57 PM

So does this thing work with the latest release?

#10 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 15 June 2006 - 06:36 PM

Yes...

#11 mmjaeger

    Likes Etomite Forums!

  • Member
  • PipPip
  • 343 posts

Posted 15 June 2006 - 07:22 PM

View PostDeniseDD, on Jun 15 2006, 07:57 PM, said:

So does this thing work with the latest release?


works like a charm incl. chapta code - just implemented it on this site: http://www.desert-dreams.ch/index.php?id=29

also added some notification function.

#12 DeniseDD

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 15 June 2006 - 07:53 PM

Okay well for now I went with the simpler Guestbook 3, see how that works out. Thanks.

#13 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 16 June 2006 - 02:19 PM

View PostDeniseDD, on Jun 15 2006, 07:53 PM, said:

Okay well for now I went with the simpler Guestbook 3, see how that works out. Thanks.
Hi,

I've tested the snippet with the recent version of Etomite and found no problems.
Maybe my snippets are not easy to install and therefore require a post for explaining installation and usage, but against the "competitors" they offer a greater flexibilty to the experienced user.

Greetings, Kastor

#14 DeniseDD

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 16 June 2006 - 02:31 PM

Very true.

#15 smartie

    Etomite Forum Newbie

  • Member
  • 11 posts

Posted 22 August 2006 - 08:56 AM

Moin,

I've a problem only in Internet Explorer with this script:

http://www.wt-zockerbase.de/index.php?id=234

The captcha-code isn't readable.

Problem is the following line in the interpreted code:
<div class="entrycaption"><span>Sicherheits-Code:</span><br/><a href=""><img src="./manager/includes/captchaCode.php?dummy=1468449196" width="captcha code" height="80" alt="" title="captcha code" /></a><br/

What's going wrong? I search the failure without a result. :-\

BTW: I use also the kmail-script, no problem there.

Edited by smartie, 22 August 2006 - 10:09 AM.


#16 mmjaeger

    Likes Etomite Forums!

  • Member
  • PipPip
  • 343 posts

Posted 22 August 2006 - 12:17 PM

View Postsmartie, on Aug 22 2006, 10:56 AM, said:

Moin,

I've a problem only in Internet Explorer with this script:

http://www.wt-zockerbase.de/index.php?id=234

The captcha-code isn't readable.

Problem is the following line in the interpreted code:
<div class="entrycaption"><span>Sicherheits-Code:</span><br/><a href=""><img src="./manager/includes/captchaCode.php?dummy=1468449196" width="captcha code" height="80" alt="" title="captcha code" /></a><br/

What's going wrong? I search the failure without a result. :-\

BTW: I use also the kmail-script, no problem there.



the problem is here: width="captcha code"

#17 smartie

    Etomite Forum Newbie

  • Member
  • 11 posts

Posted 22 August 2006 - 03:51 PM

Therefore I written it bold. ;) The question is: Why?

#18 kastor

    Etomite Forum Fan

  • Member
  • Pip
  • 79 posts

Posted 22 September 2006 - 01:44 PM

View Postsmartie, on Aug 22 2006, 03:51 PM, said:

Therefore I written it bold. ;) The question is: Why?
Hi,

sorry for the huge delay, but the last weeks were to sunny :D

It seems, that the new captcha code maker (>= 0.6.1) call is exactly like mine old one. Therefore, you have to change the snippet in the following way:
Line 56
$gbookCaptcha = $etomite->getCaptchaCode(rand($minCaptchaLength, $maxCaptchaLength), 'captcha code', 'captcha Code');
in
Line 56:
$gbookCaptcha = $etomite->getCaptchaCode();

After this change it will run fine.

Greetings, Kastor

#19 smartie

    Etomite Forum Newbie

  • Member
  • 11 posts

Posted 29 September 2006 - 09:58 PM

Moin,

thank you, it works. :)

#20 Josh

    Etomite Forum Newbie

  • Member
  • 6 posts

Posted 10 October 2006 - 03:49 AM

Any chance we could get a couple of copy/pastes of the layout being used on one of these?

Example: Page 507 from http://spielring.pytalhost.de

-I'm kindof stuck on how to format it properly (Havn't had to use chunks yet ;) )





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users