Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/07/2012, 17:03
franquitov
 
Fecha de Ingreso: julio-2012
Ubicación: Tinogasta
Mensajes: 5
Antigüedad: 11 años, 9 meses
Puntos: 0
Respuesta: Error al enviar un mensaje desde mi web

no le entendi por eso busco ayuda:
este es el codigo completo de wp-contactform/wp-contactform.php

?<?php
/*
Plugin Name: Formulario de Contacto
Plugin URI: http://ryanduff.net/projects/wp-contactform/
Description: Formulario de contacto para que tus lectores contacten contigo. Puede ser integrado en una página estática o una anotación. Funciona con WordPress 1.5 ó +
Author: Ryan Duff, huaylla, Traducción: InKiLiNo
Author URI: http://huaylla.com
Version: 2.1 Español
*/


load_plugin_textdomain('wpcf'); // NLS

/* Declare strings that change depending on input. This also resets them so errors clear on resubmission. */
$wpcf_strings = array(
'name' => '<div class="contactright"><input type="text" name="wpcf_your_name" id="wpcf_your_name" size="30" maxlength="50" value="' . $_POST['wpcf_your_name'] . '" /> (Obligatorio)</div>',
'email' => '<div class="contactright"><input type="text" name="wpcf_email" id="wpcf_email" size="30" maxlength="50" value="' . $_POST['wpcf_email'] . '" /> (Obligatorio)</div>',
'msg' => '<div class="contactright"><textarea name="wpcf_msg" id="wpcf_msg" cols="35" rows="8" >' . $_POST['wpcf_msg'] . '</textarea></div>',
'error' => '');

/*
This shows the quicktag on the write pages
Based off Owen's Quicktag Template
http://asymptomatic.net/wp-hacks/
*/
function wpcf_add_quicktag() {
if(strpos($_SERVER['REQUEST_URI'], 'post.php') || strpos($_SERVER['REQUEST_URI'], 'page-new.php')) {
?>
<script language="JavaScript" type="text/javascript"><!--
var toolbar = document.getElementById("ed_toolbar");
<?php

edit_insert_button("Formulario de Contacto", "wpcf_handler", "Formulario de Contacto");

?>

var state_my_button = true;

function wpcf_handler() {
if(state_my_button) {
edInsertContent(edCanvas, '<!-'+'-contact form-'+'->');
}
}

//--></script>
<?php
}
}

if(!function_exists('edit_insert_button')) {
//edit_insert_button: Inserts a button into the editor
function edit_insert_button($caption, $js_onclick, $title = '') {
?>
if(toolbar) {
var theButton = document.createElement('input');
theButton.type = 'button';
theButton.value = '<?php echo $caption; ?>';
theButton.onclick = <?php echo $js_onclick; ?>;
theButton.className = 'ed_button';
theButton.title = "<?php echo $title; ?>";
theButton.id = "<?php echo "ed_{$caption}"; ?>";
toolbar.appendChild(theButton);
}
<?php

}
}

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'] = '<div class="contactright"><input type="text" name="wpcf_your_name" id="wpcf_your_name" size="30" maxlength="50" value="' . $_POST['wpcf_your_name'] . '" class="contacterror" /> (Obligatorio)</div>';
}

if(!is_email($_POST['wpcf_email']))
{
$ok = false; $reason = 'empty';
$wpcf_strings['email'] = '<div class="contactright"><input type="text" name="wpcf_email" id="wpcf_email" size="30" maxlength="50" value="' . $_POST['wpcf_email'] . '" class="contacterror" /> (Oblogatorio)</div>';
}

if(empty($_POST['wpcf_msg']))
{
$ok = false; $reason = 'empty';
$wpcf_strings['msg'] = '<div class="contactright"><textarea name="wpcf_msg" id="wpcf_message" cols="35" rows="8" class="contacterror">' . $_POST['wpcf_msg'] . '</textarea></div>';
}

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'] = "<div style='font-weight: bold;'>No puedes usar lo siguiente en los campos Nombre y Correo Electrónico:un salto de línea, o las expresiones 'mime-version', 'content-type', 'cc:' or 'to:'.</div>";
} elseif($reason == 'empty') {
$wpcf_strings['error'] = '<div style="font-weight: bold;">' . stripslashes(get_option('wpcf_error_msg')) . '</div>';
}
return false;
}
}

/*Wrapper function which calls the form.*/
function wpcf_callback( $content )
{
global $wpcf_strings;

/* Run the input check. */
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');
$encoding = get_option('blog_charset');
$success_msg = get_option('wpcf_success_msg');
$success_msg = stripslashes($success_msg);
//$from = get_option('admin_email');

$name = $_POST['wpcf_your_name'];
$email = $_POST['wpcf_email'];
$website = $_POST['wpcf_website'];
$msg = $_POST['wpcf_msg'];

$headers = "From: $name <$email>\n"; // your email client will show the person's email address like normal
$headers .= "Content-Type: text/plain; $encoding\n"; // sets the mime type

$fullmsg = "$name wrote:\n";
$fullmsg .= $msg . "\n\n";
$fullmsg .= "Web: " . $website . "\n";
$fullmsg .= "Mail: " . $email . "\n";
$fullmsg .= "IP: " . getip();

//mail($recipient, $subject, $fullmsg, $headers, "-f $from");
mail($recipient, $subject, $fullmsg, $headers);


$results = '<div style="font-weight: bold;">' . $success_msg . '</div>';
echo $results;
}
else // Else show the form. If there are errors the strings will have updated during running the inputcheck.
{
$form = '<div class="contactform">
' . $wpcf_strings['error'] . '
<form action="' . get_permalink() . '" method="post" name="form">
<div class="contactleft"><label for="wpcf_your_name">' . __('Tu Nombre: ', 'wpcf') . '</label></div>' . $wpcf_strings['name'] . '
<div class="contactleft"><label for="wpcf_email">' . __('Tu Email:', 'wpcf') . '</label></div>' . $wpcf_strings['email'] . '
<div class="contactleft"><label for="wpcf_website">' . __('Tu Sitio Web:', 'wpcf') . '</label></div><div class="contactright"><input type="text" name="wpcf_website" id="wpcf_website" size="30" maxlength="100" value="' . $_POST['wpcf_website'] . '" /></div>
<div class="contactleft"><label for="message">' . __('Tu Mensaje: ', 'wpcf') . '</label></div>' . $wpcf_strings['msg'] . '
<div class="contactright"><input type="submit" name="Enviar" value="Enviar" /><input type="hidden" name="wpcf_stage" value="process" /></div>
</form>
</div>';
//<div style="clear:both; height:1px;">&nbsp;</div>';
return preg_replace('|<!--contact form-->|', $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()
{
?>
<style type="text/css" media="screen">

/* Begin Contact Form CSS */

.contactform {
position: relative;
overflow: hidden;
}

.contactleft {
width: 25%;
text-align: right;
clear: both;
float: left;
display: inline;
padding: 4px;
margin: 5px 0;
}

.contactright {
width: 70%;
text-align: left;
float: right;
display: inline;
padding: 4px;
margin: 5px 0;
}

.contacterror {
border: 1px solid #ff0000;
}
/* End Contact Form CSS */

</style>

<?php

}

function wpcf_add_options_page()
{
add_options_page('Opciones', 'Formulario de Contacto', 'manage_options', 'wp-contactform/options-contactform.php');
}

/* Action calls for all functions */

//if(get_option('wpcf_show_quicktag') == true) {add_action('admin_footer', 'wpcf_add_quicktag');}

add_action('admin_menu', 'wpcf_add_options_page');
add_filter('wp_head', 'wpcf_css');
add_filter('the_content', 'wpcf_callback', 7);

?>