
Originally Posted by
spottedhaggis any chance u making your modified version availabler, mine is now getting spammed to death
thanks
Well, I wasn't smart enought to modify the code within the php file that generates the verification code, so I used the Human Verification contribution found here:
http://www.oscommerce.com/community/contributions,1476
Here is my guestbook_sign.php and guestbook_sign.tpl.php files for the required mod's (I assume your using oscMax, but if not and you don't hav the BTS template system, the modificaitons will both be inside of guestbook_sign.php).
Let me know if you have any problems...
guestbook_sign.php:
Code:
<?php
/*
$Id: guestbook_sign.php,v 1.0 2003/07/15 Exp $
Guestbook for osC(2.2MS2) v1.0
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
if (GUESTBOOK_SHOW == 'false') {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'SSL'));
}
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_GUESTBOOK_SIGN);
if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
$gb_name = tep_db_prepare_input($HTTP_POST_VARS['gb_name']);
$gb_email = tep_db_prepare_input($HTTP_POST_VARS['gb_email']);
$gb_location = tep_db_prepare_input($HTTP_POST_VARS['gb_location']);
$gb_text = tep_db_prepare_input($HTTP_POST_VARS['gb_text']);
$error = false;
if (strlen($gb_name) < GUESTBOOK_NAME_MIN_LENGTH) {
$error = true;
$messageStack->add('guestbook', JS_GUESTBOOK_NAME);
}
if (strlen($gb_text) < GUESTBOOK_TEXT_MIN_LENGTH) {
$error = true;
$messageStack->add('guestbook', JS_GUESTBOOK_TEXT);
}
// BOF // Contrib: Human confirmation v1.2
$thecode_okay = false;
$noautomationcode = $HTTP_SESSION_VARS["noautamationcode"];
// -> v1.1 // Changed to work w/ random image names
$img_dir = $HTTP_SESSION_VARS["noautamationdir"];
$img_name = $HTTP_SESSION_VARS["noautamationname"];
// Find and delete old images
if (strlen($img_name) >= 6) {
$dirHandle = dir($img_dir);
while($fileHandle = $dirHandle->read()) {
if (substr($fileHandle,0,strlen($img_name)) == $img_name)
@unlink($img_dir.$fileHandle);
}
$dirHandle->close();
}
// <- v1.1 // Changed to work w/ random image names
$thecode_okay = (isset($HTTP_POST_VARS['thecode']) && ($HTTP_POST_VARS['thecode'] == $noautomationcode ));
if ($thecode_okay == false) {
$error = true;
$messageStack->add('guestbook', ENTRY_HUMANCHECK_ERROR);
}
// EOF // Contrib: Human confirmation v1.2
if (!empty($gb_email)) {
if (!tep_validate_email($gb_email)) {
$error = true;
$messageStack->add('guestbook', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
}
if ($error == false) {
if (tep_validate_email($gb_email)) {
//mail to visitor
$email_text = sprintf(EMAIL_VISITOR_GREET, $gb_name);
$email_text .= EMAIL_VISITOR_MESSAGE;
tep_mail($gb_name, $gb_email, EMAIL_VISITOR_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
//mail to store owner
tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_OWNER_SUBJECT, $gb_text, $gb_name, $gb_email);
tep_db_query("insert into " . TABLE_GUESTBOOK . " (visitors_name, visitors_email, visitors_location, date_added) values ('" . tep_db_input($gb_name) . "', '" . tep_db_input($gb_email) . "', '" . tep_db_input($gb_location) . "', now())");
$insert_id = tep_db_insert_id();
tep_db_query("insert into " . TABLE_GUESTBOOK_DESCRIPTION . " (entry_id, languages_id, entry_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($gb_text) . "')");
tep_redirect(tep_href_link(FILENAME_GUESTBOOK, tep_get_all_get_params(array('action'))));
}
} elseif (tep_session_is_registered('customer_id')) {
$account_query_one = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$account_one = tep_db_fetch_array($account_query_one);
$account_query_two = tep_db_query("select a.entry_country_id, b.countries_id, b.countries_name from " . TABLE_ADDRESS_BOOK . " a, " . TABLE_COUNTRIES ." b where a.customers_id = '" . (int)$customer_id . "' and a.entry_country_id = b.countries_id");
$account_two = tep_db_fetch_array($account_query_two);
$gb_name = $account_one['customers_firstname'] . ' ' . $account_one['customers_lastname'];
$gb_email = $account_one['customers_email_address'];
$gb_location = $account_two['countries_name'];
}
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_GUESTBOOK, tep_get_all_get_params()));
$content = 'guestbook_sign';
require(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE);
require(DIR_WS_INCLUDES . 'application_bottom.php');
?> guestbook_sign.tpl.php:
Code:
<script language="javascript"><!--
function checkForm() {
var error = 0;
var error_message = "<?php echo JS_ERROR; ?>";
var gb_name = document.guestbook_sign.gb_name.value;
var gb_text = document.guestbook_sign.gb_text.value;
if (gb_name.length < <?php echo GUESTBOOK_NAME_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_GUESTBOOK_NAME; ?>";
error = 1;
}
if (gb_text.length < <?php echo GUESTBOOK_TEXT_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_GUESTBOOK_TEXT; ?>";
error = 1;
}
if (error == 1) {
alert(error_message);
return false;
} else {
return true;
}
}
//--></script>
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
<td width="100%" valign="top"><?php echo tep_draw_form('guestbook_sign', tep_href_link(FILENAME_GUESTBOOK_SIGN, 'action=process'), 'post', 'onSubmit="return checkForm();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
if ($messageStack->size('guestbook') > 0) {
?>
<tr>
<td><?php echo $messageStack->output('guestbook'); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
}
?>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td class="main" width="30%"><?php echo ENTRY_NAME; ?></td>
<td class="main"><?php echo tep_draw_input_field('gb_name'); ?></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_EMAIL; ?></td>
<td class="main"><?php echo tep_draw_input_field('gb_email') . ENTRY_HELP_OPTIONAL; ?></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_LOCATION; ?></td>
<td class="main"><?php echo tep_draw_input_field('gb_location') . ENTRY_HELP_OPTIONAL; ?></td>
</tr>
<?PHP
// BOF // Contrib: Human confirmation v1.2
if (!tep_session_is_registered('noautamationcode')) tep_session_register('noautamationcode');
include('includes/human_confirmation.php');
tep_session_close('noautamationcode');
// EOF // Contrib: Human confirmation v1.2
?>
<tr>
<td class="main"><?php echo ENTRY_ENQUIRY; ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_textarea_field('gb_text', 'soft', 60, 15); ?></td>
</tr>
<tr>
<td colspan="2" class="smallText" align="right"><?php echo TEXT_NO_HTML; ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_GUESTBOOK, tep_get_all_get_params(array('entry_id', 'action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></form></td>
</tr></table> I also modified the html section of the includes/human_confirmation.php file to make it display right - here it is:
Code:
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main"><b><?php echo CATEGORY_HUMANCHECK; ?></b></td>
</tr>
<tr>
<td colspan="2"><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" cellspacing="2" cellpadding="2">
<tr>
<?php
echo '<td class=main align=center valign=middle width=' . $td_width . '>';
echo tep_image( $img_name );
echo '<br>';
echo tep_draw_input_field('thecode');
?>
</td>
<td class="main"><?php echo ENTRY_HUMANCHECK; ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
Bookmarks