Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Contact Plugin
#26
internet54 Wrote:If you are having problems with not having emails sent, it's because the captcha is implemented incorrectly. Just make all 3 questions and answers the same to override the problem. Sorry.

I couldn't get this to work properly for a while until I did the above, changed all three Q&A's to the same and now its fine, thank you!
Reply
#27
Hello,

This plugin seems to be very cool Smile Could we had more 3 questions for the captcha? the captcha works randomly?

thanks
Reply
#28
Ok I have altered this plugin so multiple questions work and it isn't case sensitive, however there is a caveat It will return an error if you answer is under 5 characters in length, could i get a few people to test it out?

See Lower Post

////////////////////////////////////////Edit/////////////////////////////////////

Answer must be 5 or more characters
if you are in a country that uses umlauts (cant figure out how to do them here) you will need to change

strtoupper to mb_strtoupper (I know very little about umlauts etc so try it yourself)

////////////////////////////////////////Edit 2 ///////////////////////////////////

Ok the 4 char thing is a known bug in php crypt with certain versions of PHP 5.3, so stick to having answers above 4 chars if you are using an effected version of php5.3

see here
http://www.mail-archive.com/php-bugs@lis...29606.html
Reply
#29
For some reason, even if captcha fails or a user forgets to input an email address it still emails the admin. Also under support when you check contact form submission it says the sender is From: no-reply@get-simple.info
Reply
#30
an8dres26h Wrote:For some reason, even if captcha fails or a user forgets to input an email address it still emails the admin. Also under support when you check contact form submission it says the sender is From: no-reply@get-simple.info
Hi An8dres26h, that is not happening for me

Heres a copy of my code it has been changed from the standard, your answers need to be larger than 4 characters, and it saves your inputs so they are not all wiped if you make a mistake
You should just need to add your email address

Updated - 19/05/2010, minor bug fix see later post
////////////////////////////////////////////////////////



Should add the code needs a cleanup, but it does work as it is now
Reply
#31
Thank you, and everything worked really
Reply
#32
@morgenmuffel

I tried that new code but still had no success. The admin still receives an email if the user submits it without meeting all the form requirements
Reply
#33
an8dres26h Wrote:@morgenmuffel

I tried that new code but still had no success. The admin still receives an email if the user submits it without meeting all the form requirements
Its working fine for me, you mentioned earlier that the emails appeared to be coming from no-reply@get-simple.info where exactly are you seeing this? as mine are all coming from the address set in line 13 of the script

Did you follow the instructions as given here?
http://internet54.com/getsimple/simple-contact-plugin
Did this happen with the very first version of the form available on the above site?

@oleg or anyone else, are you guys having the same issue as described by an8dres26h

Newer version below has fix for 5.3 problem and allows multiple questions and answers
Reply
#34
Ok this has a fix for the php 5.3 5 Character bug, it should work on all versions of php,

so you can use questions with small answers eg 1+ 1 = 2

Code:
<?php
////////////////////////////////////////////////////////
// Simple Contact v1.1.4 for GetSimple 2.X
// Plugin created by internet54 - http://internet54.com/
// Author: David Guerra - david@internet54.com
// Last Edited on May 19th, 2010
// Altered by Nigel Thomson, 19 may 2010
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// EDITABLE OPTIONS

// Your email address
$sc_to = 'your@email.com';

// Create 3 questions
$q1 = 'What is the capital of England?';
$q2 = 'What is the capital of Texas?';
$q3 = 'What colour is grass?';
$q4 = 'What is the capital of New Zealand?';
$q5 = 'What is 1 + 2?';


// The answers relative to the questions
$a1 = 'London';
$a2 = 'Austin';
$a3 = 'green';
$a4 = 'Wellington';
$a5 = '3';

// DO NOT EDIT PAST THIS LINE
////////////////////////////////////////////////////////

# get correct id for plugin
$thisfile = basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,    # ID of plugin, should be filename minus php
    'Simple Contact',    # Title of plugin
    '1.1.4',    # Version of plugin
    'internet54',    # Author of plugin
    'http://internet54.com',    # Author URL
    'This plugin will install a simple contact form into your website.',    # Plugin Description
    'plugins',    # Page type of plugin
    'sc_options'    # Function that displays content
);
# -----------------------------------------------
if( isset($_POST['sc_submitted']) ) {
        $sc_name = $_POST['sc_name'];
        $sc_email = $_POST['sc_email'];
        $sc_subject = $_POST['sc_subject'];
        $sc_message = $_POST['sc_message'];
        $sc_compare = $_POST['sc_compare'];
}
# Creates a menu option on the Admin/Theme sidebar
//add_action('admin-menu','createSideMenu',array($thisfile,'Plugin Gal'));
add_action('plugins-sidebar', 'createSideMenu', array($thisfile, 'Simple Contact'));
/////////////////////////////////////////

// Captcha maker thanks to Brian Nowell for the input
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3, $q4 => $a4, $q5 => $a5);
$qindex = array_rand($question_array);

$sc_captcha_question = $qindex;
$sc_captcha = crypt(mb_strtoupper($question_array[$qindex].'lard'));
// lard was added to the above function to beat the php 5.3 "5 char bug" that effects some versions of php

// Show options in plugin page
function sc_options() {
    print "<h2>How to get this thing working?</h2>
    <p>Please add this line of code in your template files where you want your contact form to display. For example
    place this code into your contact template file so it displays on that page.  This plugin is set to display the form right below the content of the page.<br />
    <p><strong>if (function_exists('sc_show')) { sc_show(); }</strong><br />
    Make sure to wrap it in php tags.</p>";
}

// PHP mail function
function sc_mail () {
    global $successmsg;
    global $sc_captcha;
    global $sc_to;
    global $sc_name;
    global $sc_email;
    global $sc_subject;
    global $sc_message;
    $error = 0;
    $successmsg = "";

    if( isset($_POST['sc_submitted']) ) {
         $sc_name = $_POST['sc_name'];
        $sc_email = $_POST['sc_email'];
        $sc_subject = $_POST['sc_subject'];
        $sc_message = $_POST['sc_message'];
        $sc_compare = $_POST['sc_compare'];
       if (!preg_match("/[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}/", $sc_email)){ // Php 5.3 compatibility
            $successmsg .= "<div style=\"color:red; text-align:center;\">Invalid email address entered.</div>";
            $error = 1;
        }
        if ( empty($sc_name) || empty($sc_email) || empty($sc_subject) || empty($sc_message)) {
            $successmsg .= "<div style=\"color:red; text-align:center;\">Please fill out all fields.</div>";
            $error = 1;
        }
        if (crypt(mb_strtoupper($_POST['sc_captcha'].'lard'), $sc_compare)!= $sc_compare) {
// lard was added to the above function to beat the php 5.3 "5 char bug" that effects some versions of php
            $successmsg .= "<div style=\"color:red; text-align:center;\">Captcha answer incorrect.</div>";
            $error = 1;            
        }
        if ($error != 1){
            $from = "From: " .$sc_email;
            $message = "Name: ".$sc_name;
            $message = $message."\n". "E-mail: ".$sc_email;
            $message = $message."\n". "Message: ".$sc_message;
            mail($sc_to, $sc_subject, $message, $from);
            $successmsg = "<div style=\"color:red; text-align:center;\">Thank you... The form was successfully sent.</div>";
            //Clear values
            $_POST = array();
            $sc_email = $sc_name = $sc_subject = $sc_message = '';
        }
    } else {
        $successmsg = '';
    }
}

// Form Display
function sc_form () {
    global $successmsg;
    global $sc_captcha_question;
    global $sc_captcha;
    global $sc_email;
    global $sc_name;
    global $sc_subject;
    global $sc_message;

    print '<div id="sc-container">';
    print $successmsg;
    print '<form action="" method="post" class="contactform" >
    <div><b>Name:</b> <input class="text" type="text" value="'.$sc_name.'" name="sc_name" /></div>
    <div><b>Email:</b> <input class="text" type="text" value="'.$sc_email.'" name="sc_email" /></div>
    <div><b>Subject:</b> <input class="text" type="text" value="'.$sc_subject.'" name="sc_subject" /></div>
    <div><b>Message:</b> <textarea class="text" name="sc_message" >'.$sc_message.'</textarea></div>
    <div><b>Captcha:</b> '.$sc_captcha_question.'<br /> <input class="text" type="text" value="" name="sc_captcha" /></div>
    <div><input type="submit" value="Send Email" id="contact-submit" name="contact-submit" /></div>
    <input type="hidden" value="true" name="sc_submitted" />
    <input type="hidden" value="'.$sc_captcha.'" name="sc_compare" />
    </form>
    </div>';
}

// Run the plugin in the theme
function sc_show() {
    global $thisfile;
    add_action('content-top', 'sc_mail', array($thisfile, 'Simple Contact'));
    add_action('content-bottom', 'sc_form', array($thisfile, 'Simple Contact'));
}
?>
Reply
#35
I can't get this to work using Method 1. The sc_show function is entered (verified with an echo debug statement), but it seems the add_hooks functions don't have any effect.

However, Method 2 does work.

As a user, I quite like getting a copy of the email. You can implement this very easily by copying the mail() function call to the line below and changing the To parameter to "To: " . _POST['sc_email'].

A quick question. Does PHP's mail() function protect against header injections such as CC: and BC: ? I'd hate for my site to become a spam proxy. Actually, more to the point, my hosting company would hate it and they would visit their wrath on me.
Reply
#36
LOG FILE ENTRY
Date: May 20th, 2010 - 9:32 AM
From: no-reply@get-simple.info
Subject:
Captcha:

is what is viewable in the contact logs. Also if the captcha fails I still get an email to my email address
Reply
#37
Thanks for your work on this guys.

Tip: If you'd like to use the default template for the contact page but don't want the form appearing on all pages, create a new contact.php, add the Simple Contact line and just include the default template.

Code:
<?php
if (function_exists('sc_show')) { sc_show(); }
include "template.php";
?>

Then make sure you select contact.php as the template for your page.
Reply
#38
why the message is sent only after a page refresh? and the first written: the answer to the question wrong
Reply
#39
Oleg06 Wrote:why the message is sent only after a page refresh? and the first written: the answer to the question wrong
http://neowebtime.ru/0/contact/cont
which version are you using Oleg?

Looking at the source code of the page you have linked to you are using the original you needed to keep all your answers the same, if they are different it will fail sometimes, because the original answer is overwritten when the form is submitted, which mean unless the same question/answer is randomly selected the send will fail.

If it is one of the updated versions eg v1.1.4 it will work fine

@NickC, I couldn't tell you if it is open to spam, my hosting server runs magic quotes, and my test one i haven't figured out how to get php_mail work on windows BUT, you should just be able to do this

if you are using a version of php that is either 5.2 or above then just use the inbuilt filters like so

Code:
$sc_name = filter_var($sc_name, FILTER_SANITIZE_STRING);

On whichever fields you want

If you are using below php 5.2 then do something like this

Code:
$sc_name = preg_replace( '((?:\n|\r|\t|%0A|%0D|%08|%09)+)i' , '', $sc_name );

Ok here is my contact form, that uses the second method
Reply
#40
Thanks, works
Reply
#41
Hello everyone! First up, thanks for the work on this plugin!
Unfortunately I don't seem to be able to get it to work. I placed simple-contact.php in the plugins folder (and it appears in the admin interface) and I also placed the line <?php if (function_exists('sc_show')) { sc_show(); } ?> in my contact template.
When I load the page now, the content area where the form should be is just empty. And yes, the page is using the correct template, still no form.
Any ideas?

[Edit] Ah, fixed the problem myself, now it's working fine!

I just missed that there are two methods of including the form and I used the wrong one.

Method 1:
Add this code if you are already using the function get_page_content().
<?php if (function_exists('sc_show')) { sc_show(); } ?>

or
Method2:

Add this code above your <html> tag call.
<?php if (function_exists('sc_mail')) { sc_mail(); } ?>

And, add this anywhere on the page to display the form.
<?php if (function_exists('sc_form')) { sc_form(); } ?>

[/Edit]
Reply
#42
Hi,

i installed the plugin and everything seems to work except two issues.

1. there is a problem with the charset while using ä, ü, ö or ß. is it possible to set a charset like utf-8 or iso?
2. in the incoming mail the subject always look like - www-data@mymail.com. so before the @ theres is always this www-data..

thanx for help...
Reply
#43
If you didn't do it already, edit simple-contact.php and change your e-mail address in line 13.

Simple contact plugin doesn't encode message content *to utf-8.
Addons: blue business theme, Online Visitors, Notepad
Reply
#44
2. hi, yes i edited line 13 and i recieve the emails. the problem was not the subject (sorry) - its the from field in outlook: there should be info@xxx.xx and not www-data@xxx.xx

1. is there any posibility to add an iso charset?

thanx
Reply
#45
Sorry if this is covered somewhere else. My form says that the message was sent, but I didn't receive it. Checked spam folder as well.

I know from other sites I have running on the same server, I have to use SMTP to get forms to work. How can I use SMTP with this plugin? Or is there another option?
Reply
#46
folieplus Wrote:Hi,

i installed the plugin and everything seems to work except two issues.

1. there is a problem with the charset while using ä, ü, ö or ß. is it possible to set a charset like utf-8 or iso?

thanx for help...

1) What exactly is the problem
2) which version of the script are you using,
3) is it not recognising those characters rejecting them or replacing them,
4) is the error happening in the message part of the message or the email address

I have never needed to use umlauts and accented characters, are they allowed in email addresses?
Reply
#47
morgenmuffel Wrote:I have never needed to use umlauts and accented characters, are they allowed in email addresses?
Not by default, no.

In some countries (Sweden is one of them) they’re introducing domains with “accented” characters. An example would be where I live: http://åmål.se/. So you could assume email addresses like info@åmål.se could pop up in the future.

I would need to check the RFC document defining email addresses to give the real answer but I don’t think there characters are accepted within the name part of an email address. The one exception to this rule I can think of would be an address like "Zegnåt Webdevelopment"@zegnat.net. I remember having read that by using quotation marks things like spaces are allowed. I’ve never actually seen an email address like that though, and I think 99% of all web forms will not allow for such an address to be entered anyway.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#48
folieplus Wrote:Hi,

i installed the plugin and everything seems to work except two issues.

1. there is a problem with the charset while using ä, ü, ö or ß. is it possible to set a charset like utf-8 or iso?


thanx for help...

Ok I can confirm there is a bug regarding those characters when i put them into my contact form they are converted from

ä, ü, ö or ß.

to

ä, ü, ö or ß

I am just backtracking to see if this is a bug i have introduced in my alterations to the simple contact form or if it was already there.

************************Edit 1
Update
this effects all versions of the simple contact form plugin both the original version by internet54 and my hacked version. I do not know whats causing it, i'll have a look.


************************Edit 2
Update
The bug only seems to appear in outlook (I don't have any other email clients installed, so i can't check them), if i view the email in webmail I see ä, ü, ö or ß. however when i view it in outlook I see ä, ü, ö or ß

Same thing happens for emails sent via the stock included contact form that comes with get-simple

************************Edit 3
Update
Ok i can sort of fix it by setting the encoding of the email

line 113 of my previous hack

Quote: if ($error != 1){
$from = "From: " .$sc_email;
$message = "Name: ".$sc_name;
$message = $message."\n". "E-mail: ".$sc_email;
$message = $message."\n". "Message: ".$sc_message;
mail($sc_to, $sc_subject, $message, $from);
$successmsg = "<div style=\"color:red; text-align:center;\">Thank you... The form was successfully sent.</div>";
//Clear values
$_POST = array();
$sc_email = $sc_name = $sc_subject = $sc_message = '';
}


replace that bit with this

Quote: if ($error != 1){
$headers = "From: " .$sc_email . "\r\n";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"\"\n";
$message = "Name: ".$sc_name;
$message = $message."\n". "E-mail: ".$sc_email;
$message = $message."\n". "Message: ".$sc_message;
mail($sc_to, $sc_subject, $message, $headers);
$successmsg = "<div style=\"color:red; text-align:center;\">Thank you... The form was successfully sent.</div>";
//Clear values
$_POST = array();
$sc_email = $sc_name = $sc_subject = $sc_message = '';
}


Make sure you test that it works, as i am from a country that doesn't use these characters I could be doing things wrong here, infact that is probably why it is effecting me as the default character set on my comp doesn't support those characters or the default character set encoding put on them, actually i haven't a clue, but i doubt anyone is reading this far,

Basically if you are having an issue try the above fix, if you are not having a problem ignore it
Reply
#49
i put in my template code:
Code:
<?php get_page_content(); ?>
<?php if (function_exists('sc_mail')) { sc_mail(); } ?>
<?php if (function_exists('sc_form')) { sc_form(); } ?>

and every time when i press
Reply
#50
sorry it seems not simple to get contact form

why is there not a standard one in the new version ?
Reply




Users browsing this thread: 1 Guest(s)