Go Back   Mosets Community > Archives > Mosets Hot Property 1.0 > Hot Property 1.0 Tips and Tricks

 
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2009, 10:30 PM
Stijn's Avatar
Stijn Stijn is offline
Mosets'd
 
Join Date: Oct 2006
Location: The Netherlands
Posts: 253
Default Simple Captcha for HP Beta 5 - Thnx to Rtenny

Hello all,

I altered the Rtenny simple captcha to work with Beta 5

Step 1:

Open /components/com_hotproperty/controllers/properties.php

Around line 87 find:
PHP Code:
'where' => array('Property.id' => $id),
            
'contain' => array(
                
'Agent' => array()
            )
        )); 
After this add:
PHP Code:
// Check code text
        
if ( JRequest::getVar'code',    '','post' ) <>  JRequest::getVar'code2','','post' ) ) {
            
$this->setMessage(JText::_('Please enter the correct code!.'), 'error');
            return 
false;
        } 
Save and close the file.

Step 2:

Open /components/com_hotproperty/views/properties/tmpl/default_contact.php

Around line 44 find:
PHP Code:
<li>
                <?php echo MosetsHTML::_('form.label'JText::_('Enquiry'), 'enquiry'true); ?>
                <?php echo MosetsHTML::_('form.textarea''enquiry'''false305, array('class' => 'required')); ?>
            </li>
After this add:
PHP Code:
<li>
                <?php $code=""; for ($i=0;$i<=6;$i++){ $code.=chr(rand(65,90));} ?>
                <?php echo MosetsHTML::_('form.label'JText::_('Repeat Code - Case Sensitive'), 'code'); ?>
                <span style="background: white; padding: 2px; font-size: 10pt; color: black;"><?php echo $code?></span>
                <input type="text" name="code" value="" /><br /><br />
                <input type="hidden" name="code2" value="<?php echo $code?>" />
            </li>
Save and close the file.

Special Thnx to Rtenny
__________________
www.trouwportaal.nl
Joomla 2.5.x and Mosets Tree 3.0.x
  #2  
Old 10-19-2009, 05:03 AM
landlordslink landlordslink is offline
Mosets'd
 
Join Date: Feb 2009
Location: Wanganui New Zealand
Posts: 145
Default

Cool Thanks!
__________________
www.realestate365.co.nz
  #3  
Old 10-21-2009, 10:56 AM
mattejennings mattejennings is offline
Mosets'd
 
Join Date: Aug 2008
Posts: 81
Default

Thanks for this
  #4  
Old 10-25-2009, 04:16 AM
samarapadilla7394 samarapadilla7394 is offline
Mosets'd
 
Join Date: Jul 2008
Posts: 57
Default

Thanks!
  #5  
Old 11-09-2009, 03:28 AM
rtenny rtenny is offline
Mosets'd
 
Join Date: Sep 2006
Location: Spain
Posts: 613
Default

Cool, glad to see my solution working in the Beta5 now
__________________
On the box it said "Needs Win98 or better" - so I installed Linux.
  #6  
Old 01-27-2010, 04:02 PM
ssnobben ssnobben is offline
Mosets'd
 
Join Date: Nov 2006
Posts: 805
Default

Does it work with RC1 ?

rgds
__________________
Success in the long run Its not about the code its about the people and community that's make it!
  #7  
Old 02-10-2010, 03:33 AM
Drugoholic Drugoholic is offline
Mosets'd
 
Join Date: Sep 2009
Posts: 66
Default

Quote:
Originally Posted by ssnobben View Post
Does it work with RC1 ?

rgds
Yes, it works for RC1
Just make sure you add
PHP Code:
array('class' => 'required'
to
PHP Code:
echo MosetsHTML::_('form.label'JText::_('Repeat Code - Case Sensitive'), 'code'); 
So your visitor would know they have missed the captcha.
  #8  
Old 06-09-2010, 05:09 PM
danielgysel10199 danielgysel10199 is offline
Mosets'd
 
Join Date: Apr 2010
Posts: 16
Default

Does this work with HP 1.0.1?

I see the form, but it will submit without filing in the Captcha.
  #9  
Old 06-10-2010, 02:28 AM
rtenny rtenny is offline
Mosets'd
 
Join Date: Sep 2006
Location: Spain
Posts: 613
Default

Quote:
Originally Posted by danielgysel10199 View Post
Does this work with HP 1.0.1?

I see the form, but it will submit without filing in the Captcha.
you have to change something in the php files as well, not only in the form
/components/com_hotproperty/controllers/properties.php
__________________
On the box it said "Needs Win98 or better" - so I installed Linux.
  #10  
Old 10-18-2011, 01:01 AM
carmenmariacastell carmenmariacastell is offline
Mosets'd
 
Join Date: Apr 2011
Posts: 9
Default

Quote:
Originally Posted by rtenny View Post
you have to change something in the php files as well, not only in the form
/components/com_hotproperty/controllers/properties.php
and what i need to change???
  #11  
Old 10-25-2011, 08:48 AM
rtenny rtenny is offline
Mosets'd
 
Join Date: Sep 2006
Location: Spain
Posts: 613
Default

Quote:
Originally Posted by carmenmariacastell View Post
and what i need to change???
Replace the function contact with this code

Code:
	function contact()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit('Invalid Token');
		
		$hotproperty =& MosetsFactory::getApplication('hotproperty');
		
		$id = JRequest::getInt('id', null);

		$model =& $this->getModel();
		$property = $model->getData('first', array(
			'where' => array('Property.id' => $id),
			'contain' => array(
				'Agent' => array()
			)
		));
		
		if (!empty($property)) {
			jimport('joomla.mail.helper');
			
			$email			= JRequest::getVar('email', '', 'post');
			$contactnumber	= JRequest::getVar('contactnumber', '', 'post');
			$name			= JRequest::getVar('name', '', 'post');
			$enquiry		= JRequest::getVar('enquiry', '', 'post');
			$code		= JRequest::getVar('code', 		'',	'post');
			$code2		= JRequest::getVar('code2', 		'',	'post');

			if (!$enquiry || !$name || empty($email) || JMailHelper::isEmailAddress($email) == false) {
				$this->setMessage(JText::_('Please complete the form before submitting.'), 'error');
			}elseif($code <> $code2){
				$this->setMessage(JText::_('Please enter the correct security code.'), 'error');
				return false;
			} else {
				// Prevent form submission if one of the banned text is discovered in the email field
				require_once(JPath::clean(MosetsApplication::getPath('helpers', 'hotproperty') . '/spam.php'));
				if(!HotpropertyHelperSpam::isValid($name, $hotproperty->getCfg('banned_name')) || !HotpropertyHelperSpam::isValid($email, $hotproperty->getCfg('banned_email')) || !HotpropertyHelperSpam::isValid($enquiry, $hotproperty->getCfg('banned_enquiry'))) {
					$this->setMessage(JText::_('Sorry but your enquiry does not fulfil our spam policy.'), 'error');
					return false;
				}
				
				$mail_body		= sprintf(JText::_('CONTACT_ENQUIRY'), $name, $email, $contactnumber, $enquiry);
				$mail_recipient = $property->Agent->email;
				$mail_subject = $property->name;
				
				$uri =& JURI::getInstance();
				$property_link = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_(MosetsRoute::getLink('hotproperty', array('view' => 'properties', 'layout' => 'property', 'id' => $id)), false);
				$mail_body .= "Ref No: ".HotpropertyControllerProperties::HP_VALUE('refno',$property->id)."\n\n";				
				$mail_body .= sprintf(JText::_("You may see the property's info at this url: %s"), $property_link);

				$mail =& JFactory::getMailer();
				$mail->setSender(array($email, $name));
				$mail->addRecipient($mail_recipient);
				$mail->setSubject($mail_subject);
				$mail->setBody($mail_body);
				
				if ($mail->send()) {
					$this->setMessage(JText::_('Thank you for your enquiry. Our agent will contact you as soon as possible.'));
				} else {
					$this->setMessage(sprintf(JText::_('Error while %s: %s'), JText::_('sending mail'), $mail->getError()), 'error');
					return false;
				}
			}
		} else {
			JError::raiseError(404, sprintf(JText::_('Property #%s not found'), $id));
			return false;
		}
		
		return true;
	}
__________________
On the box it said "Needs Win98 or better" - so I installed Linux.
  #12  
Old 02-24-2012, 03:03 AM
johnlanglois johnlanglois is offline
Mosets'd
 
Join Date: Sep 2011
Posts: 32
Default Code result in error

Quote:
Originally Posted by rtenny View Post
Replace the function contact with this code

Code:
	function contact()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit('Invalid Token');
		
		$hotproperty =& MosetsFactory::getApplication('hotproperty');
		
		$id = JRequest::getInt('id', null);

		$model =& $this->getModel();
		$property = $model->getData('first', array(
			'where' => array('Property.id' => $id),
			'contain' => array(
				'Agent' => array()
			)
		));
		
		if (!empty($property)) {
			jimport('joomla.mail.helper');
			
			$email			= JRequest::getVar('email', '', 'post');
			$contactnumber	= JRequest::getVar('contactnumber', '', 'post');
			$name			= JRequest::getVar('name', '', 'post');
			$enquiry		= JRequest::getVar('enquiry', '', 'post');
			$code		= JRequest::getVar('code', 		'',	'post');
			$code2		= JRequest::getVar('code2', 		'',	'post');

			if (!$enquiry || !$name || empty($email) || JMailHelper::isEmailAddress($email) == false) {
				$this->setMessage(JText::_('Please complete the form before submitting.'), 'error');
			}elseif($code <> $code2){
				$this->setMessage(JText::_('Please enter the correct security code.'), 'error');
				return false;
			} else {
				// Prevent form submission if one of the banned text is discovered in the email field
				require_once(JPath::clean(MosetsApplication::getPath('helpers', 'hotproperty') . '/spam.php'));
				if(!HotpropertyHelperSpam::isValid($name, $hotproperty->getCfg('banned_name')) || !HotpropertyHelperSpam::isValid($email, $hotproperty->getCfg('banned_email')) || !HotpropertyHelperSpam::isValid($enquiry, $hotproperty->getCfg('banned_enquiry'))) {
					$this->setMessage(JText::_('Sorry but your enquiry does not fulfil our spam policy.'), 'error');
					return false;
				}
				
				$mail_body		= sprintf(JText::_('CONTACT_ENQUIRY'), $name, $email, $contactnumber, $enquiry);
				$mail_recipient = $property->Agent->email;
				$mail_subject = $property->name;
				
				$uri =& JURI::getInstance();
				$property_link = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_(MosetsRoute::getLink('hotproperty', array('view' => 'properties', 'layout' => 'property', 'id' => $id)), false);
				$mail_body .= "Ref No: ".HotpropertyControllerProperties::HP_VALUE('refno',$property->id)."\n\n";				
				$mail_body .= sprintf(JText::_("You may see the property's info at this url: %s"), $property_link);

				$mail =& JFactory::getMailer();
				$mail->setSender(array($email, $name));
				$mail->addRecipient($mail_recipient);
				$mail->setSubject($mail_subject);
				$mail->setBody($mail_body);
				
				if ($mail->send()) {
					$this->setMessage(JText::_('Thank you for your enquiry. Our agent will contact you as soon as possible.'));
				} else {
					$this->setMessage(sprintf(JText::_('Error while %s: %s'), JText::_('sending mail'), $mail->getError()), 'error');
					return false;
				}
			}
		} else {
			JError::raiseError(404, sprintf(JText::_('Property #%s not found'), $id));
			return false;
		}
		
		return true;
	}
The line
Code:
$mail_body .= "Ref No: ".HotpropertyControllerProperties::HP_VALUE('refno',$property->id)."\n\n";
resulted in the error "PHP Fatal error: Call to undefined method HotpropertyControllerProperties::HP_VALUE() in /home1/.....clientwebsite/components/com_hotproperty/controllers/properties.php on line 123"

I changed back to the previous mailbody to remove the error.

I have noticed that when the form loads the capture letters they are all caps, even though the message says they are case sensitive.
Isn't it supposed to convert those to symbols instead of letters?

Also, when the form stops for a capture problem, all the fields have to be re-entered. Shouldn't the form be able to re-poplulate those fields?

Finally, is there a way to control where the form goes upon a successful submission?

Thanks.
  #13  
Old 07-11-2012, 06:56 PM
rtenny rtenny is offline
Mosets'd
 
Join Date: Sep 2006
Location: Spain
Posts: 613
Default

My solution only provided simple letter captcha NO images. Never thought that it would still be used after si many years. Mosets should have addressed this problem years ago.
__________________
On the box it said "Needs Win98 or better" - so I installed Linux.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Captcha rtenny Hot Property 1.0 Tips and Tricks 12 02-18-2013 12:46 AM
Hot Property 1.0.0 Beta 3 dknight Announcements 2 10-09-2008 11:42 PM


All times are GMT +8. The time now is 08:42 PM.

Copyright © 2005-2010 Mosets Consulting

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.