Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Contact Plugin
#67
Internet54 thanks for great plugin! Have no problems with it except CAPTCHA. So I added a securimage captcha.
Hope it will help someone.
1. Download lastest version of secureimage and copy it to root folder of your site. For more details see CAPTCHA homepage above.
2. Replace plugin code with the code below:
Code:
<?php
////////////////////////////////////////////////////////
// Simple Contact v1.1 for GetSimple 2.X
// Plugin created by internet54 - http://internet54.com/
// Author: David Guerra - david@internet54.com
// Last Edited on March 9th, 2010
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
// EDITABLE OPTIONS

// Your email address
$sc_to = 'YOUR_ADRESS_HERE';

// 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',                  # 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
);

# 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'));
/////////////////////////////////////////

// Show options in plugin page
function sc_options() {
    echo "<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_to;
    $error = 0;
    if( isset($_POST['sc_submitted']) ) {
        $sc_email = $_POST['sc_email'];
        if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$sc_email )){
            $successmsg = "<div style=\"color:red; text-align:center;\">Invalid email address entered.</div>";
            $error = 1;
        }
        if ( empty($_POST['sc_name']) || empty($_POST['sc_email']) || empty($_POST['sc_subject']) || empty($_POST['sc_message'])) {
            $successmsg = "<div style=\"color:red; text-align:center;\">Please fill out all fields.</div>";
            $error = 1;
        }
        if (sc_check()) {
            $successmsg = "<div style=\"color:red; text-align:center;\">Captcha answer incorrect.</div>";
            $error = 1;            
        }
        if ($error != 1){
            $from = "From: " .$_POST['sc_email'];
            $message = "Name: ".$_POST['sc_name'];
            $message = $message."\n". "E-mail: ".$_POST['sc_email'];
            $message = $message."\n". "Message: ".$_POST['sc_message'];
            mail($sc_to, $_POST['sc_subject'], $message, $from);
            $successmsg = "<div style=\"color:green; text-align:center;\">Thank you... The form was successfully sent.</div>";
            //Clear values
            $_POST = array();
        }
    } else {
        $successmsg = "";
    }
}

function sc_check() {

    session_start();
    require_once('./securimage/securimage.php');

    $securimage = new Securimage();
    if ($securimage->check($_POST['sc_captcha']) == false)
        return 1;

    return 0;
}

// Form Display
function sc_form () {
    global $successmsg;
    global $sc_captcha_question;
    global $sc_captcha;
    print '<div id="sc-container">';
    echo $successmsg;
    <div><b>Name:</b> <input class="text" type="text" value="" name="sc_name" /></div>
    <div><b>Email:</b> <input class="text" type="text" value="" name="sc_email" /></div>
    <div><b>Subject:</b> <input class="text" type="text" value="" name="sc_subject" /></div>
    <div><b>Message:</b> <textarea class="text" name="sc_message" ></textarea></div>
    <div><b>Please enter symbols from the picture below:</b><img id="captcha" src="../securimage/securimage_show.php" alt="CAPTCHA image" title="Reload image" onclick="document.getElementById(\'captcha\').src = \'/securimage/securimage_show.php?\' + Math.random(); return false" /><br /> <input class="text" type="text" value="" name="sc_captcha" maxlength="6" /></div>
    <div><input type="submit" value="Send" id="contact-submit" name="contact-submit" /></div>
    <input type="hidden" value="true" name="sc_submitted" />
    </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'));
}
?>
}
3. Thus we have nice dynamic click-to-reload CAPTCHA (see pic in attachment) with a lot of options in contact plugin in just about 5 lines of additional code.
4. Tnx internet54 again Wink
Reply


Messages In This Thread
Simple Contact Plugin - by internet54 - 2010-03-05, 15:10:47
Simple Contact Plugin - by ccagle8 - 2010-03-05, 21:30:59
Simple Contact Plugin - by bnowell - 2010-03-06, 00:37:46
Simple Contact Plugin - by internet54 - 2010-03-06, 01:14:11
Simple Contact Plugin - by bnowell - 2010-03-06, 02:21:06
Simple Contact Plugin - by internet54 - 2010-03-06, 02:34:36
Simple Contact Plugin - by Zegnåt - 2010-03-06, 03:40:10
Simple Contact Plugin - by matt - 2010-03-06, 04:48:05
Simple Contact Plugin - by Zegnåt - 2010-03-06, 07:12:28
Simple Contact Plugin - by internet54 - 2010-03-06, 08:50:02
Simple Contact Plugin - by matt - 2010-03-06, 10:07:35
Simple Contact Plugin - by internet54 - 2010-03-10, 06:11:38
Simple Contact Plugin - by spilarix - 2010-03-23, 08:53:09
Simple Contact Plugin - by internet54 - 2010-03-23, 11:08:04
Simple Contact Plugin - by Zegnåt - 2010-03-23, 16:33:26
Simple Contact Plugin - by spilarix - 2010-03-24, 01:21:17
Simple Contact Plugin - by kotos - 2010-04-01, 21:52:59
Simple Contact Plugin - by spilarix - 2010-04-02, 19:07:58
Simple Contact Plugin - by mouffin - 2010-04-04, 01:36:09
Simple Contact Plugin - by Oleg06 - 2010-04-04, 05:25:31
Simple Contact Plugin - by Oleg06 - 2010-04-06, 19:52:27
Simple Contact Plugin - by spilarix - 2010-04-07, 00:22:19
Simple Contact Plugin - by Oleg06 - 2010-04-07, 03:31:04
Simple Contact Plugin - by internet54 - 2010-04-07, 08:08:01
Simple Contact Plugin - by Oleg06 - 2010-04-11, 00:59:53
Simple Contact Plugin - by banter - 2010-04-12, 07:00:09
Simple Contact Plugin - by El-Cherubin - 2010-05-17, 05:25:53
Simple Contact Plugin - by morgenmuffel - 2010-05-17, 10:28:02
Simple Contact Plugin - by an8dres26h - 2010-05-18, 04:46:13
Simple Contact Plugin - by morgenmuffel - 2010-05-18, 07:06:26
Simple Contact Plugin - by Oleg06 - 2010-05-18, 16:13:52
Simple Contact Plugin - by an8dres26h - 2010-05-19, 01:14:12
Simple Contact Plugin - by morgenmuffel - 2010-05-19, 07:41:23
Simple Contact Plugin - by morgenmuffel - 2010-05-19, 08:46:10
Simple Contact Plugin - by NickC - 2010-05-20, 20:06:54
Simple Contact Plugin - by an8dres26h - 2010-05-21, 02:34:15
Simple Contact Plugin - by samrayner - 2010-05-22, 21:07:35
Simple Contact Plugin - by Oleg06 - 2010-05-22, 23:45:58
Simple Contact Plugin - by morgenmuffel - 2010-05-23, 08:38:12
Simple Contact Plugin - by Oleg06 - 2010-05-23, 16:22:13
Simple Contact Plugin - by cscott - 2010-06-17, 06:05:17
Simple Contact Plugin - by folieplus - 2010-07-07, 20:25:08
Simple Contact Plugin - by yojoe - 2010-07-08, 03:44:37
Simple Contact Plugin - by folieplus - 2010-07-08, 19:31:33
Simple Contact Plugin - by suprchic66 - 2010-07-09, 06:32:20
Simple Contact Plugin - by morgenmuffel - 2010-07-17, 10:30:35
Simple Contact Plugin - by Zegnåt - 2010-07-17, 20:06:32
Simple Contact Plugin - by morgenmuffel - 2010-07-20, 14:36:14
Simple Contact Plugin - by core - 2010-07-22, 00:26:25
Simple Contact Plugin - by simple123 - 2010-07-29, 04:33:28
Simple Contact Plugin - by NeBox - 2010-08-06, 23:35:36
Simple Contact Plugin - by martonos - 2010-08-07, 02:31:57
Simple Contact Plugin - by morgenmuffel - 2010-08-07, 09:57:27
Simple Contact Plugin - by internet54 - 2010-08-19, 13:19:34
Simple Contact Plugin - by vsky - 2010-08-19, 15:03:21
Simple Contact Plugin - by fotothink - 2010-08-19, 20:46:53
Simple Contact Plugin - by internet54 - 2010-08-19, 23:08:19
Simple Contact Plugin - by morgenmuffel - 2010-08-20, 07:18:25
Simple Contact Plugin - by fotothink - 2010-08-20, 18:34:56
Simple Contact Plugin - by vsky - 2010-08-20, 20:33:32
Simple Contact Plugin - by fotothink - 2010-08-20, 21:09:38
Simple Contact Plugin - by vsky - 2010-08-20, 21:19:45
Simple Contact Plugin - by fotothink - 2010-08-21, 01:20:17
Simple Contact Plugin - by vsky - 2010-08-21, 05:01:29
Simple Contact Plugin - by fotothink - 2010-08-21, 15:26:25
Simple Contact Plugin - by Rene - 2010-08-25, 17:19:12
Simple Contact Plugin - by 9dogs - 2010-09-04, 09:24:25
Simple Contact Plugin - by tankmiche - 2010-09-12, 20:13:12
Simple Contact Plugin - by rozmiar - 2010-09-15, 23:35:27
Simple Contact Plugin - by vsky - 2010-09-16, 09:25:19
Simple Contact Plugin - by rozmiar - 2010-09-24, 19:50:14
Simple Contact Plugin - by mikesalami - 2011-04-08, 09:49:36



Users browsing this thread: 1 Guest(s)