Guestbook - adding custom field

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
spirelli
Posts: 996
Joined: Tue 27. Jul 2004, 13:37
Location: London

Guestbook - adding custom field

Post by spirelli »

Hi,

is it possible to add an extra eld to the guestbook form? What it is, I want to get rid of the 'Website' field. Instead I want to have an entry field called 'Location' where people can enter their location (country or city).

Maybe the website field could be used somehow? But of course, I just want to display the plain text enterd in this field.

Also: Where is the date mad time of the entry stored? I have had a look in the database but can't find it. I want to change it as I've just transfered entries from an old guestbook to phpwcms and would like to display their original enty date.

Thanks a lot!
Last edited by spirelli on Thu 4. Nov 2004, 21:48, edited 1 time in total.
spirelli
Posts: 996
Joined: Tue 27. Jul 2004, 13:37
Location: London

Post by spirelli »

anyone knows the answer or has a suggestion for these two questions above?
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

sorry dude, you can't add/change any fields without getting dirty with the source code.
spirelli
Posts: 996
Joined: Tue 27. Jul 2004, 13:37
Location: London

Post by spirelli »

thanks for the reply!
Last edited by spirelli on Thu 4. Nov 2004, 21:42, edited 1 time in total.
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

sorry it was not better news.
if your needs are sufficient then maybe it is worth posting them in the wish list to see if anyone would take up the challenge.
spirelli
Posts: 996
Joined: Tue 27. Jul 2004, 13:37
Location: London

Post by spirelli »

Is there no simple hack to just use the existing Homepage field!? It would just have to be modified so that it displays the field content without trying to make a website link out of it.

Thanks
starletina
Posts: 6
Joined: Sat 10. Jun 2006, 02:37

Post by starletina »

OK - after some fiddling around I just changed my guestbook to include a 'topic' field instead of the website field. Here's what you do - it's a bit longwinded but works:

1) In your wcms database there's a table called phpwcms_guestbook. In this table you need to add a field called guestbook_location, type: text

2) Edit the following file on your server /include/inc_front/content/cnt18.article.inc.php

You will need to make the following changes:
add this line at line 210:
$guestbook['post']['location'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_location']));
add this line at 235:
$guestbook['sql'] .= "guestbook_location='".aporeplace($guestbook['post']['location'])."', ";
add this line at 267:
$guestbook['form'] = str_replace('{LOCATION}', html_specialchars($guestbook['post']['location']), $guestbook['form']);
add this line at 279:
$guestbook['signed'] = str_replace('{LOCATION}', html_specialchars($guestbook['post']['location']), $guestbook['signed']);
add this line at 503:
$guestbook['c'] = str_replace('{LOCATION}', nl2br($guestbook['row']['guestbook_location']), $guestbook['c']);
3) Change this file on your server: phpwcms_template/inc_cntpart/guestbook/default.html. Assuming you have kept default.html in it's original format you need to make the following changes:

change line 19 to:
</strong>{EMAIL}, {NAME}, {LOCATION}, {MSG} </p>
to replace 'website' field with the location field change lines 55 and 56 to:
<tr>
<td align="right" class="v10">website:&nbsp;</td>
<td><input name="guestbook_location" type="text" id="guestbook_location" style="width: 350px" class="v12" value="{LOCATION}" size="50" maxlength="1000" /></td>
</tr>
change lines 108 to 111 to:
<p style="background-color:#D7E3E2 "> <strong>Guestbook listing<br>
</strong>{EMAIL}, {NAME}, {LOCATION}, {MSG}, {URL}, {ID},
{DBID}, {TIMESTAMP:FORMAT} (<a href="http://www.php.net/manual/en/function.date.php" target="_blank" style="text-decoration:underline">FORMAT&nbsp;=&nbsp;d.m.Y&nbsp;or&nbsp;H:i:s</a>)</p>
<p>
and finally add the Location to be visible in people's guestbook entries, lines 120 - 124:
<tr>
<td colspan="2"><a href="mailto:{EMAIL}"><strong>{NAME}</strong></a> {LOCATION} {EMAIL}<br />
{MSG}</td>
</tr>
Hope this helps :)
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

starletina wrote:Hope this helps :)
Unfortunately, LINE NUMBERS in files... often CHANGE from version to version as new releases come out (and there have been a few).

You should probably specify which version you are referring to ... if you are unable to show the before AND after code examples.
starletina
Posts: 6
Joined: Sat 10. Jun 2006, 02:37

Post by starletina »

Thanks Dexxus, solution above refers to version 1.1 of phpwcms. Changes below highlighted in red:

for /include/inc_front/content/cnt18.article.inc.php
<?php

if(!function_exists('guestbook_pages')) {

function guestbook_pages($pages=0, $wrap=' ||', $current=0, $total=1, $link='', $linkadd='') {
// used to create pages listing ... 1 2 3 ...
$wrap = explode('|', $wrap);
$pages = intval($pages);
$current = intval($current);
$total = intval($total);
$navpages = '';
$start = 1;
$end = $total;

if($pages && $pages < $total) {
$start = $current - (ceil(($pages-1) / 2) - 1);
if($start < 1) $start = 1;
$end = $start + $pages - 1;
if($end > $total) {
$start = $total - $pages + 1;
$end = $total;
}

}
// pages listing
for($x=$start; $x<=$end; $x++) {
if($navpages) $navpages .= $wrap[0];
if($x-1 != $current) {
$navpages .= '<a href="'.$link.($x-1).$linkadd.'">';
$navpages .= $x.'</a>';
} else {
$navpages .= $wrap[1].$x.$wrap[2];
}
}
//return $total.' '.$current;
return $navpages;

}

}


$content["main"] .= headline($crow["acontent_title"], $crow["acontent_subtitle"], $template_default["article"]);
$guestbook = unserialize($crow["acontent_form"]);

if(!$guestbook['aliasID']) {
$guestbook['cid'] = $crow["acontent_id"];
} else {
$guestbook['cid'] = $guestbook['aliasID'];
}
$guestbook['cid'] = intval($guestbook['cid']);

$guestbook['template'] = @file_get_contents(PHPWCMS_ROOT.$phpwcms["templates"].'inc_cntpart/guestbook/'.$guestbook['template']);
if(!$guestbook['template']) {

$guestbook['template'] = '<!--BAN_START//-->
shit fuck **** ****
<!--BAN_END//-->
<!--BAN_REPLACE_START//-->
<strong>banned</strong>
<!--BAN_REPLACE_END//-->
<!--FORM_START//-->
<table border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#F5F5F5" style="margin-bottom:10px;">
<tr bgcolor="#E1E1E1">
<td colspan="2"><strong>&nbsp;&nbsp;sign my guestbook</strong> <span style="font-size:10px;color:#CC3300;">(fields
marked * are obligatory)</span></td>
</tr>
<tr bgcolor="#E1E1E1"><td colspan="2"><img src="img/leer.gif" width="1" height="1" alt="" /></td></tr>
<!--FORM_ERROR_START//-->
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td></tr>
<tr><td colspan="2">&nbsp;&nbsp;<span style="color:#CC3300;">not signed - fill in all neccessary info</span></td></tr>
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td></tr>
<!--FORM_ERROR_END//-->
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td></tr>
<tr>
<td align="right" class="v10">email<span style="color:#CC3300;">*</span>:&nbsp;</td>
<td><input name="guestbook_email" type="text" id="guestbook_email" style="width: 350px" class="v12" value="{EMAIL}" size="50" maxlength="250" />&nbsp;</td>
</tr>
<tr>
<td align="right" class="v10">name<span style="color:#CC3300;">*</span>:&nbsp;</td>
<td><input name="guestbook_name" type="text" id="guestbook_name" style="width: 350px" class="v12" value="{NAME}" size="50" maxlength="500" /></td>
</tr>
<tr>
<td align="right" class="v10">website:&nbsp;</td>
<td><input name="guestbook_url" type="text" id="guestbook_url" style="width: 350px" class="v12" value="{URL}" size="50" maxlength="1000" /></td>
</tr>
<tr>
<td align="right" valign="top" class="v10">&nbsp;&nbsp;message:&nbsp;</td>
<td><textarea name="guestbook_msg" cols="50" rows="6" id="guestbook_msg" class="v12" style="width: 350px">{MSG}</textarea></td>
</tr>
<tr>
<td align="right" valign="top" class="v10">display:&nbsp;</td>
<td><input name="guestbook_show" type="radio" value="0" checked>show email<br>
<input name="guestbook_show" type="radio" value="1">hide email<br>
<input type="radio" name="guestbook_show" value="2">show email as "info at mail dot com"</td>
</tr>
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="4" alt="" /></td></tr>
<tr>
<td align="right">&nbsp;</td>
<td><input name="guestbook_send" type="submit" id="guestbook_send" value="sign guestbook" class="v11" /></td>
</tr>
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="6" alt="" /></td></tr>
</table>
<!--FORM_END//-->
<!--FORM_SUCCESS_START//-->
<div style="margin-top:5px; margin-bottom: 5px;">Thanks {NAME}! You have successfully signed our guestbook.</div>
<!--FORM_SUCCESS_END//-->
<!--NAV_START//-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
<tr>
<td><strong>{FIRST:<<} {BACK:<}</strong> {PAGE:5:&nbsp;|<strong>|</strong>} <strong>{NEXT:>} {LAST:>>}</strong></td>
<td align="right">{ARCHIVE:%Y/%m|alle Eintr&auml;ge|go|&nbsp;}&nbsp;{JUMP:page|go|&nbsp;}</td>
</tr>
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td></tr>
</table>
<!--NAV_END//-->
<!--GUESTBOOK_START//-->
{FORM} {NAV}
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<!--GUESTBOOK_ENTRY_START//-->
<tr bgcolor="#F5F5F5">
<td width="1%" align="right"><strong>{ID}&nbsp;&nbsp;</strong></td>
<td width="99%">{DBID} | {TIMESTAMP:m/d/Y H:i}</td>
</tr>
<tr><td colspan="2"><a href="mailto:{EMAIL}"><strong>{NAME}</strong></a> {URL:visit website} {EMAIL}<br />{MSG}</td></tr>
<tr><td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td></tr>
<!--GUESTBOOK_ENTRY_END//-->
</table>
<!--GUESTBOOK_END//-->
<!--COMMENT_START//-->
<span style="color:#00CC00;">|</span>
<!--COMMENT_END//-->';

}

// get guestbook sections
$guestbook['form'] = get_tmpl_section('FORM', $guestbook['template']);
$guestbook['signed'] = get_tmpl_section('FORM_SUCCESS', $guestbook['template']);
$guestbook['nav'] = get_tmpl_section('NAV', $guestbook['template']);
$guestbook['nav'] = get_tmpl_section('NAV', $guestbook['template']);
$guestbook['entry'] = get_tmpl_section('GUESTBOOK_ENTRY', $guestbook['template']);
$guestbook['list'] = get_tmpl_section('GUESTBOOK', $guestbook['template']);
$guestbook['ban'] = trim(get_tmpl_section('BAN', $guestbook['template']).' '.$guestbook['banned']);
$guestbook['replace'] = trim(get_tmpl_section('BAN_REPLACE', $guestbook['template']));
$guestbook['comment'] = trim(get_tmpl_section('COMMENT', $guestbook['template']));
$guestbook['comment'] = explode('|', $guestbook['comment']);
$guestbook['comment'][0] = trim($guestbook['comment'][0]);
$guestbook['comment'][1] = trim($guestbook['comment'][1]);

$guestbook['readform'] = 0;
$guestbook['flooding'] = 0;

if($guestbook['time']) {

if(isset($_COOKIE['phpwcms_guestbook'])) {

if($_COOKIE['phpwcms_guestbook']+$guestbook['time'] >= time()) {
$guestbook['flooding'] = $guestbook['readform'] = 1;
}

}

if(!$guestbook['flooding']) {

$guestbook['sql'] = "SELECT MAX(guestbook_created) FROM ".DB_PREPEND."phpwcms_guestbook WHERE ";
$guestbook['sql'] .= "guestbook_cid='".$guestbook['cid']."' AND ";
$guestbook['sql'] .= "guestbook_ip='".aporeplace($_SERVER['REMOTE_ADDR'])."' AND ";
$guestbook['sql'] .= "guestbook_useragent=MD5('".aporeplace($_SERVER['HTTP_USER_AGENT'])."')";

if($guestbook['result'] = mysql_query($guestbook['sql'], $db)) {
if($guestbook['row'] = mysql_fetch_row($guestbook['result'])) {
if($guestbook['row'][0]+$guestbook['time'] >= time()) {
$guestbook['flooding'] = $guestbook['readform'] = 1;
}
}
mysql_free_result($guestbook['result']);
}
}

}


if(isset($_POST['guestbook_email']) && !$guestbook['flooding']) {

$guestbook['post']['email'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_email']));
$guestbook['post']['name'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_name']));
$guestbook['post']['url'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_url']));
$guestbook['post']['location'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_location']));
$guestbook['post']['msg'] = clean_slweg(remove_unsecure_rptags($_POST['guestbook_msg']));
$guestbook['post']['msg'] = preg_replace('/\[c\](.*?)\[\/c\]/is', "$1", $guestbook['post']['msg']);
$guestbook['post']['show'] = intval($_POST['guestbook_show']);
if($guestbook['post']['show'] > 2) {
$guestbook['post']['show'] = 0;
}

// check URL and try to connect - if fails set to ''
if($guestbook['post']['url']) {
if(!strstr($guestbook['post']['url'], "http://")) {
$guestbook['post']['url'] = 'http://'.$guestbook['post']['url'];
}
if ($guestbook['fp'] = @fopen($guestbook['post']['url'],"r")) {
fclose($guestbook['fp']);
} else {
$guestbook['post']['url'] = '';
}
}

if(is_valid_email($guestbook['post']['email']) && $guestbook['post']['name']) {

$guestbook['sql'] = "INSERT INTO ".DB_PREPEND."phpwcms_guestbook SET ";
$guestbook['sql'] .= "guestbook_cid='".$guestbook['cid']."', ";
$guestbook['sql'] .= "guestbook_msg='".aporeplace($guestbook['post']['msg'])."', ";
$guestbook['sql'] .= "guestbook_location='".aporeplace($guestbook['location']['location'])."', ";
$guestbook['sql'] .= "guestbook_name='".aporeplace($guestbook['post']['name'])."', ";
$guestbook['sql'] .= "guestbook_email='".aporeplace($guestbook['post']['email'])."', ";
$guestbook['sql'] .= "guestbook_created='".time()."', ";
$guestbook['sql'] .= "guestbook_url='".aporeplace($guestbook['post']['url'])."', ";
$guestbook['sql'] .= "guestbook_show='".$guestbook['post']['show']."', ";
$guestbook['sql'] .= "guestbook_ip='".aporeplace($_SERVER['REMOTE_ADDR'])."', ";
$guestbook['sql'] .= "guestbook_useragent=MD5('".aporeplace($_SERVER['HTTP_USER_AGENT'])."')";
mysql_query($guestbook['sql'], $db);
if(mysql_insert_id($db)) {
$guestbook['readform'] = 1;
if($guestbook['cookie'] && $guestbook['time']) {
setcookie('phpwcms_guestbook', time(), time()+intval($guestbook['time']));
}
} else {
$guestbook['readform'] = 0;
$content["main"] .= '<div style="color:#FF3300;">A technical problem occured while you ';
$content["main"] .= 'have tried to sign the guestbook</div>';
}
}
}

if(!$guestbook['readform']) {

if(!isset($_POST['guestbook_email'])) {
// remove post form error part
//$guestbook['form'] = preg_replace("/<!--FORM_ERROR_START-->(.*?)<!--FORM_ERROR_END-->/si", '', $guestbook['form']);
$guestbook['form'] = replace_tmpl_section('FORM_ERROR', $guestbook['form'], '');
}
$guestbook['form'] = str_replace('{EMAIL}', html_specialchars($guestbook['post']['email']), $guestbook['form']);
$guestbook['form'] = str_replace('{NAME}', html_specialchars($guestbook['post']['name']), $guestbook['form']);
$guestbook['form'] = str_replace('{URL}', html_specialchars($guestbook['post']['url']), $guestbook['form']);
$guestbook['form'] = str_replace('{LOCATION}', html_specialchars($guestbook['post']['location']), $guestbook['form']); $guestbook['form'] = str_replace('{MSG}', html_specialchars($guestbook['post']['msg']), $guestbook['form']);
// build sign guestbook form
$guestbook['form'] = '<form name="sign_guestbook" method="post" style="margin:0;padding:0;">'.$guestbook['form'].'</form>';

} else {

if(!$guestbook['flooding']) {
// if successfully signed show signed info
$guestbook['signed'] = str_replace('{EMAIL}', html_specialchars($guestbook['post']['email']), $guestbook['signed']);
$guestbook['signed'] = str_replace('{NAME}', html_specialchars($guestbook['post']['name']), $guestbook['signed']);
$guestbook['signed'] = str_replace('{URL}', html_specialchars($guestbook['post']['url']), $guestbook['signed']);
$guestbook['signed'] = str_replace('{LOCATION}', html_specialchars($guestbook['post']['location']), $guestbook['signed']); $guestbook['signed'] = str_replace('{MSG}', html_specialchars($guestbook['post']['msg']), $guestbook['signed']);
$guestbook['form'] = $guestbook['signed'];
} else {
$guestbook['form'] = '';
}

}


// start guestbook listing

// first check for all available related guestbook entries
$guestbook['archivedate'] = false;
$guestbook['archiveselect'] = false;
$guestbook['sql'] = "SELECT * FROM ".DB_PREPEND."phpwcms_guestbook WHERE guestbook_cid=";
$guestbook['sql'] .= $guestbook['cid']." AND guestbook_trashed=0 ";
if(isset($_GET['gbd']) && $_GET['gbs']) {
//$aktion[5] = 0;
$guestbook['archivedate'] = $_GET['gbd'];
$guestbook['archiveselect'] = $_GET['gbs'];
$guestbook['sql'] .= "AND FROM_UNIXTIME(guestbook_created,'".aporeplace($guestbook['archivedate']);
$guestbook['sql'] .= "')='".aporeplace($guestbook['archiveselect'])."' ";
}
if(isset($_POST['showarchive']) && $_POST['showarchive']) {
//$aktion[5] = 0;
$guestbook['archivedate'] = $_POST['archivedate'];
$guestbook['archiveselect'] = $_POST['showarchive'];
$guestbook['sql'] .= "AND FROM_UNIXTIME(guestbook_created,'".aporeplace($guestbook['archivedate']);
$guestbook['sql'] .= "')='".aporeplace($guestbook['archiveselect'])."' ";
}
$guestbook['sql'] .= "ORDER BY guestbook_created DESC";

//echo '<pre>'.htmlentities($guestbook['sql']).'</pre>';

$guestbook['counter'] = 1;

if($guestbook['listing'] && $guestbook['listcount']) {

if($guestbook['result'] = mysql_query($guestbook['sql'].';', $db)) {
$guestbook['count'] = mysql_num_rows($guestbook['result']);
mysql_free_result($guestbook['result']);
//echo '<pre>'.htmlentities($guestbook['count']).'</pre>';
}

$guestbook['pagecount'] = ceil($guestbook['count'] / $guestbook['listcount']);
if($guestbook['pagecount'] > 1 || $guestbook['archivedate']) {

if(isset($_POST['showguestbookpage'])) $aktion[5] = intval($_POST['showguestbookpage'])-1;
$guestbook['start_entry'] = $aktion[5] * $guestbook['listcount'];
$guestbook['sql'] .= ' LIMIT '.$guestbook['start_entry'].','.$guestbook['listcount'];

$guestbook['link_to'] = 'index.php?';
$guestbook['link_to'] .= 'id='.$aktion[0].','.$aktion[1].','.$aktion[2].','.$aktion[3].','.$aktion[4].',';
$guestbook['link_add'] = '';
if($guestbook['archivedate']) {
$guestbook['link_add'] .= '&gbd='.htmlentities(urlencode($guestbook['archivedate']));
$guestbook['link_add'] .= '&gbs='.htmlentities(urlencode($guestbook['archiveselect']));
}


// goto previous guestbook page
if($aktion[5] > 0) {
$guestbook['prev_replace'] = '<a href="'.$guestbook['link_to'].($aktion[5] - 1).$guestbook['link_add'].'">$1</a>';
$guestbook['first_replace'] = '<a href="'.$guestbook['link_to'].'0'.$guestbook['link_add'].'">$1</a>';
} else {
$guestbook['prev_replace'] = '$1';
$guestbook['first_replace'] = $guestbook['prev_replace'];
}
$guestbook['nav'] = preg_replace('/{BACK:(.*?)}/s', $guestbook['prev_replace'], $guestbook['nav']);
$guestbook['nav'] = preg_replace('/{FIRST:(.*?)}/s', $guestbook['first_replace'], $guestbook['nav']);

// goto next guestbook page
if($aktion[5]+1 < $guestbook['pagecount']) {
$guestbook['next_replace'] = '<a href="'.$guestbook['link_to'].($aktion[5] + 1).$guestbook['link_add'].'">$1</a>';
$guestbook['last_replace'] = '<a href="'.$guestbook['link_to'].($guestbook['pagecount']-1).$guestbook['link_add'].'">$1</a>';
} else {
$guestbook['next_replace'] = '$1';
$guestbook['last_replace'] = $guestbook['next_replace'];
}
$guestbook['nav'] = preg_replace('/{NEXT:(.*?)}/s', $guestbook['next_replace'], $guestbook['nav']);
$guestbook['nav'] = preg_replace('/{LAST:(.*?)}/s', $guestbook['last_replace'], $guestbook['nav']);

$guestbook['nav'] = preg_replace('/{PAGE:(\d+):(.*?)}/se', 'guestbook_pages($1, "$2", '.$aktion[5].', '.$guestbook['pagecount'].', "'.$guestbook['link_to'].'", "'.$guestbook['link_add'].'")', $guestbook['nav']);

// archive (form)
if( ! ( strpos($guestbook['nav'],'{ARCHIVE')===false ) ) {
preg_match('/{ARCHIVE:(.*?)}/s', $guestbook['nav'], $guestbook['archiveval']);
$guestbook['archiveval'] = explode('|', $guestbook['archiveval'][1]);
$guestbook['archive'] = '<form name="guestbookarchive" id="guestbookarchive" method="post" ';
$guestbook['archive'] .= 'action="index.php?id='.$aktion[0].','.$aktion[1].','.$aktion[2].','.$aktion[3].','.$aktion[4];
$guestbook['archive'] .= ',0" style="display:inline;margin:0;padding:0">';
$guestbook['archive'] .= '<select name="showarchive" id="showarchive" onChange="document.guestbookarchive.submit();">';

if(!isset($guestbook['archiveval'][1]) || !$guestbook['archiveval'][1]) {
$guestbook['archiveval'][1] = 'all entries';
}
$guestbook['archive'] .= '<option value="">'.$guestbook['archiveval'][1]."</option>\n";

if(!isset($guestbook['archiveval'][0]) || !$guestbook['archiveval'][0]) {
$guestbook['archiveval'][0] = '%m/%Y';
}

$guestbook['asql'] = "SELECT DISTINCT FROM_UNIXTIME(guestbook_created,'".aporeplace($guestbook['archiveval'][0]);
$guestbook['asql'] .= "') AS guestbook_date FROM ".DB_PREPEND."phpwcms_guestbook WHERE guestbook_cid=";
$guestbook['asql'] .= $guestbook['cid']." AND guestbook_trashed=0 ORDER BY guestbook_created DESC";

if($guestbook['result'] = mysql_query($guestbook['asql'], $db)) {

while($guestbook['row'] = mysql_fetch_row($guestbook['result'])) {

$guestbook['row'][0] = html_specialchars($guestbook['row'][0]);
$guestbook['archive'] .= '<option value="'.$guestbook['row'][0].'"';
if($guestbook['archiveselect'] == $guestbook['row'][0]) {
$guestbook['archive'] .= ' selected="selected"';
}
$guestbook['archive'] .= '>'.$guestbook['row'][0]."</option>\n";

}

mysql_free_result($guestbook['result']);

}
$guestbook['archive'] .= '</select>';
$guestbook['archive'] .= '<input type="hidden" name="archivedate" value="'.html_specialchars($guestbook['archiveval'][0]).'">';
if(isset($guestbook['archiveval'][2]) && $guestbook['archiveval'][2]) {
$guestbook['archive'] .= $guestbook['jumpval'][3];
// check if send button is image or text
if(preg_match('/[\.png|\.jpg|\.jpeg|\.gif]$/i', $guestbook['archiveval'][2], $matches)) {
$guestbook['archive'] .= '<input name="archivesubmit" type="image" src="'.trim($guestbook['archiveval'][2]).'" border="0">';
} else {
$guestbook['archive'] .= '<input name="archivesubmit" type="submit" value="'.$guestbook['archiveval'][2].'">';
}
}
$guestbook['archive'] .= '</form>';
$guestbook['nav'] = preg_replace('/{ARCHIVE:(.*?)}/s', $guestbook['archive'], $guestbook['nav']);

}

// jump to menu (form)
if( ! ( strpos($guestbook['nav'],'{JUMP')===false ) ) {
preg_match('/{JUMP:(.*?)}/s', $guestbook['nav'], $guestbook['jumpval']);
$guestbook['jumpval'] = explode('|', $guestbook['jumpval'][1]);
$guestbook['jump'] = '<form name="guestbookjump" id="guestbookjump" method="post" ';
$guestbook['jump'] .= 'action="index.php?id='.$aktion[0].','.$aktion[1].','.$aktion[2].','.$aktion[3].','.$aktion[4];
$guestbook['jump'] .= ',0" style="display:inline;margin:0;padding:0">';
$guestbook['jump'] .= '<select name="showguestbookpage" id="showpage" onChange="document.guestbookjump.submit();">';
for($ixx=1; $ixx <= $guestbook['pagecount']; $ixx++) {
if($ixx != $aktion[5]+1) {
$guestbook['jump'] .= '<option value="'.$ixx.'">'.$guestbook['jumpval'][0].$ixx."</option>\n";
} else {
$guestbook['jump'] .= '<option value="'.$ixx.'" selected="selected">'.$guestbook['jumpval'][0].$ixx."</option>\n";
}
}
$guestbook['jump'] .= '</select>';
if($guestbook['archivedate']) {
$guestbook['jump'] .= '<input type="hidden" name="archivedate" value="'.html_specialchars($guestbook['archivedate']).'">';
$guestbook['jump'] .= '<input type="hidden" name="showarchive" value="'.html_specialchars($guestbook['archiveselect']).'">';
}
if(isset($guestbook['jumpval'][1]) && $guestbook['jumpval'][1]) {
$guestbook['jump'] .= $guestbook['jumpval'][2];
// check if send button is image or text
if(preg_match('/[\.png|\.jpg|\.jpeg|\.gif]$/i', $guestbook['jumpval'][1], $matches)) {
$guestbook['jump'] .= '<input name="jumpsubmit" type="image" src="'.trim($guestbook['jumpval'][1]).'" border="0">';
} else {
$guestbook['jump'] .= '<input name="jumpsubmit" type="submit" value="'.$guestbook['jumpval'][1].'">';
}
}
$guestbook['jump'] .= '</form>';
$guestbook['nav'] = preg_replace('/{JUMP:(.*?)}/s', $guestbook['jump'], $guestbook['nav']);
}

$guestbook['counter'] = $guestbook['start_entry']+1;

} else {
// no navigation neccessary
$guestbook['nav'] = '';
}

} else {
// no navigation neccessary
$guestbook['nav'] = '';
}

$guestbook['entry_list'] = '';

if($guestbook['result'] = mysql_query($guestbook['sql'].';', $db)) {

$guestbook['ban_count'] = 0;
if($guestbook['ban']) {
$guestbook['ban'] = preg_replace('/\s{1,}/is', ' ', $guestbook['ban']);
$guestbook['ban'] = explode(' ', $guestbook['ban']);
if(is_array($guestbook['ban']) && count($guestbook['ban'])) {
foreach($guestbook['ban'] as $key => $value) {
$guestbook['ban'][$key] = '/'.$value.'/i';
$guestbook['ban_count']++;
}
}
}

while($guestbook['row'] = mysql_fetch_assoc($guestbook['result'])) {

$guestbook['row']['guestbook_msg'] = html_specialchars($guestbook['row']['guestbook_msg']);
if($guestbook['ban_count']) {
$guestbook['row']['guestbook_msg'] = preg_replace($guestbook['ban'], $guestbook['replace'], $guestbook['row']['guestbook_msg']);
}


$guestbook['c'] = str_replace('{ID}', $guestbook['counter'], $guestbook['entry']);
$guestbook['c'] = str_replace('{DBID}', $guestbook['row']['guestbook_id'], $guestbook['c']);

switch($guestbook['row']['guestbook_show']) {
case 1: $guestbook['row']['guestbook_email'] = '#';
$guestbook['c'] = preg_replace('/<a (.*?){0,1}href=[\'|"]{0,1}mailto:.*?[\'|"]{0,1}( .*?){0,1}>(.*?)<\/a>/is', "$3", $guestbook['c']);
break;
case 2: $guestbook['c'] = preg_replace('/<a (.*?){0,1}href=[\'|"]{0,1}mailto:.*?[\'|"]{0,1}( .*?){0,1}>(.*?)<\/a>/is', "$3", $guestbook['c']);
$guestbook['row']['guestbook_email'] = preg_replace('/(.*?)@(.*?)\.([a-zA-Z]+)$/i', "$1 at $2 dot $3", $guestbook['row']['guestbook_email']);
break;
}


$guestbook['c'] = str_replace('{EMAIL}', html_specialchars($guestbook['row']['guestbook_email']), $guestbook['c']);
$guestbook['c'] = str_replace('{NAME}', html_specialchars($guestbook['row']['guestbook_name']), $guestbook['c']);
$guestbook['c'] = str_replace('{MSG}', nl2br($guestbook['row']['guestbook_msg']), $guestbook['c']);
$guestbook['c'] = str_replace('{LOCATION}', nl2br($guestbook['row']['guestbook_location']), $guestbook['c']);
$guestbook['c'] = str_replace('{URL}', html_specialchars($guestbook['row']['guestbook_url']), $guestbook['c']);

$guestbook['url_replace'] = ($guestbook['row']['guestbook_url']) ? '<a href="'.html_specialchars($guestbook['row']['guestbook_url']).'" target="_blank">$1</a>' : '';
$guestbook['c'] = preg_replace('/{URL:(.*)}/s', $guestbook['url_replace'], $guestbook['c']);

$guestbook['c'] = preg_replace('/{TIMESTAMP:(.*)}/e', "date('$1',\$guestbook['row']['guestbook_created'])", $guestbook['c']);

$guestbook['entry_list'] .= $guestbook['c'];

$guestbook['counter']++;
}
mysql_free_result($guestbook['result']);

// comments
$guestbook['entry_list'] = preg_replace('/\[c\](.*?)\[\/c\]/is', $guestbook['comment'][0]."$1".$guestbook['comment'][1], $guestbook['entry_list']);

}
$guestbook['list'] = str_replace('{NAV}', $guestbook['nav'], $guestbook['list']);
$guestbook['list'] = str_replace('{FORM}', $guestbook['form'], $guestbook['list']);
$guestbook['list'] = replace_tmpl_section('GUESTBOOK_ENTRY', $guestbook['list'], $guestbook['entry_list']);
$content['main'] .= $guestbook['list'];

// delete guetbook array
unset($guestbook);


?>
for phpwcms_template/inc_cntpart/guestbook/default.html:
<p style="background-color:#D7E3E2 "><strong>List of banned words - make a listing divided by simple space " ".
</strong>if possible try to insert no HTML chars.<strong><br>
</strong>shit **** fuck and so on </p>
<p>
<!--BAN_START//-->
<!--BAN_END//-->
</p>
<p style="background-color:#D7E3E2 "><strong>Replace banned words by this HTML
code. </strong><strong><br>
</strong>banned OR <img src="..."> </p>
<p>
<!--BAN_REPLACE_START//-->
<strong>banned word</strong>
<!--BAN_REPLACE_END//-->
</p>
<p style="background-color:#D7E3E2 "><strong>Guestbook HTML form and form error message <br>
</strong>{EMAIL}, {NAME}, {LOCATION}, {MSG} </p>
<p>
<!--FORM_START//-->
<table border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#F5F5F5" style="margin-bottom:10px;">
<tr bgcolor="#E1E1E1">
<td colspan="2"><strong>&nbsp;&nbsp;sign my guestbook</strong> <span style="font-size:10px;color:#CC3300;">(fields
marked * are obligatory)</span></td>
</tr>
<tr bgcolor="#E1E1E1">
<td colspan="2"><img src="img/leer.gif" width="1" height="1" alt="" /></td>
</tr>
<!--FORM_ERROR_START//-->
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td>
</tr>
<tr>
<td colspan="2">&nbsp;&nbsp;<span style="color:#CC3300;">not signed - fill
in all neccessary info</span></td>
</tr>
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td>
</tr>
<!--FORM_ERROR_END//-->
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td>
</tr>
<tr>
<td align="right" class="v10">email<span style="color:#CC3300;">*</span>:&nbsp;</td>
<td><input name="guestbook_email" type="text" id="guestbook_email" style="width: 350px" class="v12" value="{EMAIL}" size="50" maxlength="250" />
&nbsp;</td>
</tr>
<tr>
<td align="right" class="v10">name<span style="color:#CC3300;">*</span>:&nbsp;</td>
<td><input name="guestbook_name" type="text" id="guestbook_name" style="width: 350px" class="v12" value="{NAME}" size="50" maxlength="500" /></td>
</tr>
<tr>
<td align="right" class="v10">location:&nbsp;</td>
<td><input name="guestbook_location" type="text" id="guestbook_location" style="width: 350px" class="v12" value="{LOCATION}" size="50" maxlength="1000" /></td>
</tr>
<tr>
<td align="right" valign="top" class="v10">&nbsp;&nbsp;message:&nbsp;</td>
<td><textarea name="guestbook_msg" cols="50" rows="6" id="guestbook_msg" class="v12" style="width: 350px">{MSG}</textarea></td>
</tr>
<tr>
<td align="right" valign="top" class="v10">display:&nbsp;</td>
<td><input name="guestbook_show" type="radio" value="0" checked>show email<br>
<input name="guestbook_show" type="radio" value="1">hide email<br>
<input type="radio" name="guestbook_show" value="2">show email as "info at mail dot com"</td>
</tr>
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="4" alt="" /></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td><input name="guestbook_send" type="submit" id="guestbook_send" value="sign guestbook" class="v11" /></td>
</tr>
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="6" alt="" /></td>
</tr>
</table>
<!--FORM_END//-->
</p>
<p style="background-color:#D7E3E2 "> <strong>Success Text - displayed when guestbook
entry created<br>
</strong>{NAME}</p>
<p>
<!--FORM_SUCCESS_START//-->
<div style="margin-top:5px; margin-bottom: 5px;">Thanks {NAME}! You have successfully signed our guestbook.</div>
<!--FORM_SUCCESS_END//-->
</p>
<p style="background-color:#D7E3E2 "> <strong>Guestbook navigation<br>
</strong><span class="chatlist">{FIRST:HTML}, {LAST:HTML}, {BACK:HTML}, {NEXT:HTML},
{JUMP:LISTTEXT|BUTTON|SPACER}, {PAGE:COUNT:SPACER|WRAP_ACTIVE_BEFORE|AFTER}<br>
(HTML = link text or image tag, like <img src="back.gif" border="0" />)</span></p>
<p>
<!--NAV_START//-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
<tr>
<td><strong>{FIRST:<<} {BACK:<}</strong> {PAGE:5:&nbsp;|<strong>|</strong>} <strong>{NEXT:>}
{LAST:>>}</strong></td>
<td align="right">{ARCHIVE:%Y/%m|alle Eintr&auml;ge|go|&nbsp;}&nbsp;{JUMP:page
|go|&nbsp;}</td>
</tr>
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td>
</tr>
</table>
<!--NAV_END//-->
</p>
<p style="background-color:#D7E3E2 "> <strong>Guestbook listing<br>
</strong>{EMAIL}, {NAME}, {LOCATION}, {MSG}, {URL}, {ID},
{DBID}, {TIMESTAMP:FORMAT} (<a href="http://www.php.net/manual/en/function.date.php" target="_blank" style="text-decoration:underline">FORMAT&nbsp;=&nbsp;d.m.Y&nbsp;or&nbsp;H:i:s</a>)</p>

<p>
<!--GUESTBOOK_START//-->
{FORM} {NAV}
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<!--GUESTBOOK_ENTRY_START//-->
<tr bgcolor="#F5F5F5">
<td width="1%" align="right"><strong>{ID}&nbsp;&nbsp;</strong></td>
<td width="99%">{DBID} | {TIMESTAMP:m/d/Y H:i}</td>
</tr>
<tr>
<td colspan="2"><a href="mailto:{EMAIL}"><strong>{NAME}</strong></a> {LOCATION} {EMAIL}<br />
{MSG}</td>
</tr>
<tr>
<td colspan="2"><img src="img/leer.gif" width="1" height="3" alt="" /></td>
</tr>
<!--GUESTBOOK_ENTRY_END//-->
</table>
<!--GUESTBOOK_END//-->
</p>
<p style="background-color:#D7E3E2 "><strong>Comments of edited articles</strong><strong> </strong>[c]...[/c]<br>
normal HTML code like <span style="color:#FF3300">|</span></p>
<p>
<!--COMMENT_START//-->
<span style="color:#00CC00;">|</span>
<!--COMMENT_END//-->
</p>
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

starletina wrote:Thanks Dexxus,
NO--> Thank **YOU** for your contribution and clarity! :P
culda_a
Posts: 521
Joined: Tue 28. Feb 2006, 01:39
Contact:

Post by culda_a »

I have a question... I have use guestbook in one site but after i enter one comment if I want to enter another one is not possible...!!! do you know why?
or is related to ip address and it have to pass some time before can somebody enter a new comment?
ImagePackging design,labels, catalogs,postcards,
starletina
Posts: 6
Joined: Sat 10. Jun 2006, 02:37

Post by starletina »

When a user posts a comment in the guestbook there's a parameter called "flooding" which sets a cookie that determines how long it should be before the user can see the form again and post another comment.

On the guestbook form in the CMS you'll notice that if you set the flooding to "0" you should be able to post another comment on the page immediately (if you refresh the page after you've posted a comment).

However if you allow flooding to be "0" then you run the risk of someone posting repeated nuisance comments in a short space of time. If the flooding is set to around 5 minutes for example someone is less likely to bother to flood your guestbook...
Post Reply