Author Topic: How to disable Product Inquiry?  (Read 23427 times)

Stingraynut

  • Beginner
  • *
  • Posts: 48
Re: How to disable Product Inquiry?
« Reply #15 on: December 19, 2011, 08:50:20 am »
kevinwood 
Quote
I also added some code to ps_communication to ensure that spammers couldn't just auto-post the form.
I'd be very interested in knowing how to do that - I suspect the spammers on my site are a mixture of human and bot. I have the image captcha working, thanks to BanquetTables.pro but I have been wondering how to stop the bots too

Rob

kevinwood

  • Jr. Member
  • **
  • Posts: 151
Re: How to disable Product Inquiry?
« Reply #16 on: December 19, 2011, 15:24:54 pm »
kevinwood 
Quote
I also added some code to ps_communication to ensure that spammers couldn't just auto-post the form.
I'd be very interested in knowing how to do that - I suspect the spammers on my site are a mixture of human and bot. I have the image captcha working, thanks to BanquetTables.pro but I have been wondering how to stop the bots too

Rob

If you are following BanquetTables.pro's directions to include his 'spam prevention question', it adds an element to the form that is submitted.  You can modify ps_communication.php to check for this element.  Just before the line:

Code: [Select]
$Itemid = $sess->getShopItemid();
Add the following:

Code: [Select]
if ( $d["ziptie"] != "1234" ) {
     return false;
}

this will cause VM to not send the email if the form does not contain this value.  It is not fool-proof; if someone takes the time to look at the contents of the form being posted and wants to automate it, they can add this value to their automation.

marcella

  • Beginner
  • *
  • Posts: 6
Re: How to disable Product Inquiry?
« Reply #17 on: December 24, 2011, 18:25:46 pm »
Can anybody post the entire process for this? I've edited the shop.ask.tpl  but there is no title to the box and even though the value in the code is set as 1234, when I tested it with this it worked but we are still getting spam.  So far the only thing I've done is replace the old shop.ask.tpl with this code:

<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
$doc =& JFactory::getDocument();
$doc->setMetaData( 'robots', 'noindex' );
/**
*
* @version $Id: shop.ask.tpl.php 1813 2009-06-17 18:36:15Z Aravot $
* @package VirtueMart
* @subpackage themes
* @copyright Copyright (C) 2007-2009 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName( __FILE__ );

if ( $set == 0 ) { // This is the enquiry form!

   $validate = vmIsJoomla( '1.5' ) ? JUtility::getHash( $mainframe->getCfg( 'db' ) ) : mosHash( $mainframe->getCfg( 'db' ) );
   ?>
   <br />
   
   <form action="<?php echo $mm_action_url ?>index.php" method="post" name="emailForm" id="emailForm">
<label for="ziptie"><img style="vertical-align:middle" src="images/spampre.png"></label>
   <input type="text" name="ziptie" id="ziptie" size="10" class="inputbox" value="<?php echo $ziptie ?>"><br /><br />
   <label for="contact_name"><?php echo $VM_LANG->_('NAME_PROMPT') ?></label>
   <br /><input type="text" name="name" id="contact_name" size="80" class="inputbox" value="<?php echo $name ?>"><br /><br />
   <label for="contact_mail"><?php echo $VM_LANG->_('EMAIL_PROMPT') ?></label>
   <br /><input type="text" id="contact_mail" name="email" size="80" label="Your email" class="inputbox" value="<?php echo $email ?>"><br /><br />
   <label for="contact_text"><?php echo $VM_LANG->_('MESSAGE_PROMPT') ?></label><br />
   <textarea rows="10" cols="60" name="text" id="contact_text" class="inputbox"><?php echo utf8_decode($subject) ?></textarea><br />
   
   <input type="button" name="send" value="<?php echo $VM_LANG->_('SEND_BUTTON') ?>" class="button" onclick="validateEnquiryForm()" />   
   
   <input type="hidden" name="product_id" value="<?php echo  $db_product->f("product_id")  ?>" />
   <input type="hidden" name="product_sku" value="<?php echo  shopMakeHtmlSafe($db_product->f("product_sku"))  ?>" />
   <input type="hidden" name="set" value="1" />   
   <input type="hidden" name="func" value="productAsk" />
   <input type="hidden" name="page" value="shop.ask" />
   <input type="hidden" name="option" value="com_virtuemart" />
   <input type="hidden" name="flypage" value="<?php echo $flypage ?>" />
   <input type="hidden" name="Itemid" value="<?php echo $Itemid ?>" />
   
   <input type="hidden" name="<?php echo $validate ?>" value="1" />
   </form>
   <script type="text/javascript"><!--
   function validateEnquiryForm() {
      if ( ( document.emailForm.text.value == "" ) || ( document.emailForm.email.value.search("@") == -1 ) || ( document.emailForm.email.value.search("[.*]" ) == -1 ) ) {
         alert( "<?php echo $VM_LANG->_('CONTACT_FORM_NC',false); ?>" );
      } else if ( ( document.emailForm.email.value.search(";") != -1 ) || ( document.emailForm.email.value.search(",") != -1 ) || ( document.emailForm.email.value.search(" ") != -1 ) ) {
         alert( "You cannot enter more than one email address" );

      } else if ( ( document.emailForm.ziptie.value.search("1234") ==-1 ) || ( document.emailForm.ziptie.value.search("4") ==-1 ) || ( document.emailForm.ziptie.value.search("4") ==-1 ) ) {
         alert( "Make sure the spam prevention question is correct" );

      }
else {
         document.emailForm.action = "<?php echo sefRelToAbs("index.php"); ?>"
         document.emailForm.submit();
      }
   }
   --></script>
   
   <?php
}
else { // if set==1 then we have sent the email to the vendor and say thank you here.
  ?>
   <img src="<?php echo VM_THEMEURL ?>images/button_ok.png" height="48" width="48" align="center" alt="Success" border="0" />
   Thank You, You will be contacted shortly.
 
 
  <?php
}
?>

jstratos

  • Beginner
  • *
  • Posts: 42
Re: How to disable Product Inquiry?
« Reply #18 on: October 07, 2012, 19:13:35 pm »
Thanks Pro... this works great using your validation code 1234, but I tried to change that to say 1532 (to match my png file) and ran into problems probably because I may have missed some other changes to the code to make it work.

Any suggestions on what else to alter?

jstratos

  • Beginner
  • *
  • Posts: 42
Re: How to disable Product Inquiry?
« Reply #19 on: October 07, 2012, 19:17:58 pm »
Quote
<label for="ziptie"><img style="vertical-align:middle" src="images/spampre.png"></label>

Marcella, did you create your PNG file and save it to your images folder?