'
(' . __('required', 'wpcf') . ')
',
'email' => ' (' . __('required', 'wpcf') . ')
',
'msg' => '',
'error' => '');
/*
This shows the quicktag on the write pages
Based off Buttonsnap Template
http://redalt.com/downloads
*/
if(get_option('wpcf_show_quicktag') == true) {
include('buttonsnap.php');
add_action('init', 'wpcf_button_init');
add_action('marker_css', 'wpcf_marker_css');
function wpcf_button_init() {
$wpcf_button_url = buttonsnap_dirname(__FILE__) . '/wpcf_button.png';
buttonsnap_textbutton($wpcf_button_url, __('Insert Contact Form', 'wpcf'), '');
buttonsnap_register_marker('contact form', 'wpcf_marker');
}
function wpcf_marker_css() {
$wpcf_marker_url = buttonsnap_dirname(__FILE__) . '/wpcf_marker.gif';
echo "
.wpcf_marker {
display: block;
height: 15px;
width: 155px
margin-top: 5px;
background-image: url({$wpcf_marker_url});
background-repeat: no-repeat;
background-position: center;
}
";
}
}
function wpcf_is_malicious($input) {
$is_malicious = false;
$bad_inputs = array("\r", "\n", "mime-version", "content-type", "cc:", "to:");
foreach($bad_inputs as $bad_input) {
if(strpos(strtolower($input), strtolower($bad_input)) !== false) {
$is_malicious = true; break;
}
}
return $is_malicious;
}
/* This function checks for errors on input and changes $wpcf_strings if there are any errors. Shortcircuits if there has not been a submission */
function wpcf_check_input()
{
if(!(isset($_POST['wpcf_stage']))) {return false;} // Shortcircuit.
$_POST['wpcf_your_name'] = stripslashes(trim($_POST['wpcf_your_name']));
$_POST['wpcf_email'] = stripslashes(trim($_POST['wpcf_email']));
$_POST['wpcf_website'] = stripslashes(trim($_POST['wpcf_website']));
$_POST['wpcf_msg'] = stripslashes(trim($_POST['wpcf_msg']));
global $wpcf_strings;
$ok = true;
if(empty($_POST['wpcf_your_name']))
{
$ok = false; $reason = 'empty';
$wpcf_strings['name'] = ' (' . __('required', 'wpcf') . ')
';
}
if(!is_email($_POST['wpcf_email']))
{
$ok = false; $reason = 'empty';
$wpcf_strings['email'] = ' (' . __('required', 'wpcf') . ')
';
}
if(empty($_POST['wpcf_msg']))
{
$ok = false; $reason = 'empty';
$wpcf_strings['msg'] = '';
}
if(wpcf_is_malicious($_POST['wpcf_your_name']) || wpcf_is_malicious($_POST['wpcf_email'])) {
$ok = false; $reason = 'malicious';
}
if($ok == true)
{
return true;
}
else {
if($reason == 'malicious') {
$wpcf_strings['error'] = "You can not use any of the following in the Name or Email fields: a linebreak, or the phrases 'mime-version', 'content-type', 'cc:' or 'to:'.
";
} elseif($reason == 'empty') {
$wpcf_strings['error'] = '' . stripslashes(get_option('wpcf_error_msg')) . '
';
}
return false;
}
}
/*Wrapper function which calls the form.*/
function wpcf_callback( $content )
{
global $wpcf_strings;
/* Run the input check. */
if(! preg_match('||', $content)) {
return $content;
}
if(wpcf_check_input()) // If the input check returns true (ie. there has been a submission & input is ok)
{
$recipient = get_option('wpcf_email');
$subject = get_option('wpcf_subject');
$success_msg = get_option('wpcf_success_msg');
$success_msg = stripslashes($success_msg);
$name = $_POST['wpcf_your_name'];
$email = $_POST['wpcf_email'];
$website = $_POST['wpcf_website'];
$msg = $_POST['wpcf_msg'];
$fullmsg = "$name wrote ($email) :\n";
$fullmsg .= wordwrap($msg, 80, "\n") . "\n\n";
$fullmsg .= "Website: " . $website . "\n";
$fullmsg .= "IP: " . getip();
//mail($recipient, $subject, $fullmsg, $headers);
////////////////////////////////////////////////////////////////
// Send email via my ISP authenticated gateway
// MOD by Vivek
// See url for more info:
// http://www.cyberciti.biz/tips/howto-php-send-email-via-smtp-authentication.html
// Just setup $params host, port, username and password below
///////////////////////////////////////////////////////////////
include("Mail.php");
$recipients = $recipient;
$headers["From"] = $email;
$headers["To"] = $recipient;
$headers["Subject"] = $subject;
//** MODIFY settings as per your requirements **//
$params["host"] = "smtp.net4india.com";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "smtpUsername";
$params["password"] = "smtpPassword";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
// send email
$mail_object->send($recipients, $headers, $fullmsg);
//////////////////////////////////////////////////////////////////////////
///////////////////////////// MOD DONE by vivek ///////////////////////////
//////////////////////////////////////////////////////////////////////////
$results = '' . $success_msg . '
';
echo $results;
}
else // Else show the form. If there are errors the strings will have updated during running the inputcheck.
{
$form = '
';
return str_replace('', $form, $content);
}
}
/*Can't use WP's function here, so lets use our own*/
function getip()
{
if (isset($_SERVER))
{
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
$ip_addr = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_CLIENT_IP"]))
{
$ip_addr = $_SERVER["HTTP_CLIENT_IP"];
}
else
{
$ip_addr = $_SERVER["REMOTE_ADDR"];
}
}
else
{
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) )
{
$ip_addr = getenv( 'HTTP_X_FORWARDED_FOR' );
}
elseif ( getenv( 'HTTP_CLIENT_IP' ) )
{
$ip_addr = getenv( 'HTTP_CLIENT_IP' );
}
else
{
$ip_addr = getenv( 'REMOTE_ADDR' );
}
}
return $ip_addr;
}
/*CSS Styling*/
function wpcf_css()
{
?>