cloudy

Author Topic: Free Contact Form PHP Script with image captcha - OLD VERSION  (Read 40573 times)

0 Members and 1 Guest are viewing this topic.

Offline dafuser

  • Posts: 561
  • Granbury, Texas
    • Weather from the shores of Lake Granbury
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #45 on: August 15, 2008, 06:34:13 PM »
I wanted to see the error to ensure I wasn't getting the same thing.  I saw the error your getting and I do not get that with my contact form v1.08.  Did you actually receive the test message I sent?

I see you have your contact form external from your regular site.  If you need help getting it integrated let me know...
Thanks, I already added it to the templates and call it from the "Contact Us" link in the footer. I was just using the plain contact.php for esting. Everythings workng fine. Great script.
--
Thanks Les...
Microsoft Windows: Proof that P.T. Barnum was correct.

24 inch iMac 2.8GHz C2D, 4 GB Ram (OS X 10.7 Lion) Davis Vantage Vue

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #46 on: August 15, 2008, 09:10:58 PM »
Mike,

I keep getting an "input forbidden" message when I try to test the script.
I've got this running here:
http://69.143.90.55/webfiles/wxcontact2.php

Michael
« Last Edit: August 15, 2008, 09:27:01 PM by mth »
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #47 on: August 15, 2008, 09:22:05 PM »
Mike,

I keep getting an "input forbidden" message when I try to test the script.
I've got this running here:
http://69.143.90.55/webfiles/wxcontact2.php

Michael
Probably because of your host domain does not match. You can set it correctly or disable that with a setting

 // Site Domain without the http://www like this: $domain = 'carmosaic.com';
 $domain = 'yoursite.com';

 // Make sure the form was posted from your host name only.
 // SET  $domain_protect =1; for ON,  $domain_protect = 0; for OFF.
 // this is a security feature to prevent spammers from posting from files hosted on other domain names
 // "Input Forbidden" message will result if host does not match
 $domain_protect = 1;

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #48 on: August 15, 2008, 09:26:43 PM »
Mike,

I changed the "$domain_protect" to 0 and now I am getting a PHP error when i fill in the form and click send:   Fatal error: Call to undefined function getmxrr() in C:\wdisplay\webfiles\wxcontact2.php on line 648

I'm a little embarrased as it seems everyone else is not having issues.  :oops:

Michael
« Last Edit: August 15, 2008, 09:28:19 PM by mth »
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #49 on: August 15, 2008, 09:34:19 PM »
Mike,

I changed the "$domain_protect" to 0 and now I am getting a PHP error when i fill in the form and click send:   Fatal error: Call to undefined function getmxrr() in C:\wdisplay\webfiles\wxcontact2.php on line 648

I'm a little embarrased as it seems everyone else is not having issues.  :oops:

Michael

Your php does not support the getmxrr function

Try this:

replace:
Code: [Select]
function ctf_validate_email($email) {
   // Create the syntactical validation regular expression
   $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
   // Presume that the email is invalid
   $valid = 0;
   //check for all the non-printable codes in the standard ASCII set,
   //including null bytes and newlines, and exit immediately if any are found.
   if (preg_match("/[\\000-\\037]/",$email)) {
    return 0;
   }
   // Validate the syntax
   if (eregi($regexp, $email)) {
      list($username,$domaintld) = split("@",$email);
      // Validate the domain
      if (getmxrr($domaintld,$mxrecords)) {
         $valid = 1;
      }
   } else {
      $valid = 0;
   }
   return $valid;
}


with this:
Code: [Select]
function ctf_validate_email($email) {
   // Create the syntactical validation regular expression
   $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
   // Presume that the email is invalid
   $valid = 0;
   //check for all the non-printable codes in the standard ASCII set,
   //including null bytes and newlines, and exit immediately if any are found.
   if (preg_match("/[\\000-\\037]/",$email)) {
    return 0;
   }
   // Validate the syntax
   if (eregi($regexp, $email)) {
      list($username,$domaintld) = split("@",$email);
      // Validate the domain
      if ( function_exists("getmxrr") ) {
        if (getmxrr($domaintld,$mxrecords) ) {
             $valid = 1;
        }
      } else {
             $valid = 1;
      }
   } else {
      $valid = 0;
   }
   return $valid;
}

let me know how it goes, if that makes it work, I will put that in the next release.
« Last Edit: August 15, 2008, 09:58:43 PM by MCHALLIS »

Offline NorCal Dan

  • -= Dan =-
  • Posts: 9,438
  • Davis Vue/iMac/Parallels/WinXP
  • Marysville, California
    • Skype @ KJ6RGX
    • Traveling RV Weather
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #50 on: August 15, 2008, 09:54:24 PM »
I'm a little embarrased as it seems everyone else is not having issues.  :oops:

Don't be embarrased, I had some problems here as well...ask questions and we will try to help find the problem...

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #51 on: August 15, 2008, 11:41:10 PM »
Mike,

That worked!  All is testing and is working.....I appreciate the assistance.  Thanks for sharing and keep the great scripts coming.

Michael
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #52 on: August 15, 2008, 11:56:37 PM »
Version: 1.10 - 14-Aug-2008
small fix in function ctf_validate_email
This update is not needed unless you were getting this error on send:
Fatal error: Call to undefined function getmxrr()

Offline drobbins

  • Posts: 1,596
  • Kentucky, USA
    • Cave Country Weather
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #53 on: August 16, 2008, 01:46:20 AM »
I got my first "contact" today!! :hello1: Just someone saying "Hi".

Offline chashock

  • Posts: 2
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #54 on: August 16, 2008, 05:02:37 AM »
This script is great.  I appreciate the work you've put into it.

The only question I've got is whether it is feasible to have the same form used for a domain that also has aliases, without turning off domain checking?

I have a domain xyz.com that I have aliased via Apache to also reply to abc.com.  With the way the php is currently set up, I don't see how to allow both domains to post a message, since I can only enter a single domain into the $domain variable.  Since I've used the ServerAlias Directive in Apache, and used all relative linking on the sites, when a user comes in via abc.com, there is no redirect to xyz.com, all references are from abc.com for the duration of their visit.  Therefore, if I have xyz.com listed in the script, and they come in on abc.com, they get the "Input Forbidden" error.

The obvious immediate workaround is to disable $domain_protect, but I'm wondering if an array could be used here without a large re-write of code.  I'm no PHP programmer, but thought this might be an easy way to alleviate the problem.

Your thoughts?

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #55 on: August 16, 2008, 03:26:52 PM »
This script is great.  I appreciate the work you've put into it.

The only question I've got is whether it is feasible to have the same form used for a domain that also has aliases, without turning off domain checking?

....
Your thoughts?

Here is a solution:
change your $domain config to an array with the domains you want..
// Site Domain without the http://www like this: $domain = 'carmosaic.com';
// can be a single domain:      $domain = 'carmosaic.com';
// can be an array of domains:  $domain = array('carmosaic.com','someothersite.com');
$domain = array('abc.com','xyz.com');

Change this part of the function ctf_spamcheckpost
Change:
Code: [Select]

 // Host names from where the form is authorized
 // to be posted from:
 $dom = $domain;
 $authHosts = array("$dom");

To:
Code: [Select]
// Host names from where the form is authorized
 // to be posted from:
 if (is_array($domain)) {
    $domain = array_map(strtolower, $domain);
    $authHosts = $domain;
 } else {
    $domain =  strtolower($domain);
    $authHosts = array("$domain");
 }

also change:
$msg =  "Sent from $sitename contact form at $domain

to:
$msg =  "Sent from $sitename contact form

I added to Version: 1.11 - 16-Aug-2008
This update is not needed unless you need this feature

« Last Edit: August 16, 2008, 05:07:35 PM by MCHALLIS »

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #56 on: August 16, 2008, 05:06:25 PM »

Version: 1.11 - 16-Aug-2008
added feature to have the same form used for a domain that also has aliases, without turning off domain checking
http://www.weather-watch.com/smf/index.php/topic,33604.msg274348.html#msg274348
This update is not needed unless you need this feature

Offline chashock

  • Posts: 2
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #57 on: August 18, 2008, 06:39:36 PM »
Outstanding.  Thank you so much.  I was missing the piece on how to check against the array.  Worked like a charm!

Offline reif

  • Posts: 55
  • Denver, Colorado USA
    • West Denver Weather
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #58 on: August 20, 2008, 05:51:38 PM »
Mike,

How would one go about adding check boxes to the script?

Thanks very much,
Reif Heck

Offline nyunyu

  • Posts: 8
Re: Free Contact Form PHP Script with image captcha - contact.php
« Reply #59 on: August 20, 2008, 06:24:29 PM »
Hello, i was looking for a contact form script with captcha and lands on this page.
However, I can't seems to download the secure cpatcha file. Anyone got working link?