Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/11/2011, 23:02
Dr_Chichi
 
Fecha de Ingreso: septiembre-2006
Mensajes: 330
Antigüedad: 17 años, 7 meses
Puntos: 2
Respuesta: formulario manda a otra pagina

aqui esta lo que sigue

Código:
$mensaje_error='';

		$form_nombre=limpiar($_POST['form_nombre']);
		$form_email=limpiar($_POST['form_email']);
		$form_asunto=limpiar($_POST['form_asunto']);
		$form_mensaje=limpiar($_POST['form_mensaje']);

		if(!isset($form_nombre))				
			$mensaje_error.=$mensaje_nombre_vacio;
		if(!isset($form_email))					
			$mensaje_error.=$mensaje_email_vacio;
		if(!isset($form_asunto))				
			$mensaje_error.=$mensaje_asunto_vacio;
		if(!isset($form_mensaje))				
			$mensaje_error.=$mensaje_mensaje_vacio;

		if(!email_valido($form_email))
			$mensaje_error.=$mensaje_mail_no_valido;

		
		$form_nombre_len=strlen($form_nombre);			
		$form_email_len=strlen($form_email);			
		$form_asunto_len=strlen($form_asunto);			
		$form_mensaje_len=strlen($form_mensaje);		

	
		if( ($form_nombre_len<=$nombre_min) && (!empty($form_nombre)) )
			$mensaje_error.=$mensaje_nombre_min;
		
		if( ($form_email_len<=$email_min)  && (!empty($form_email)) )
			$mensaje_error.=$mensaje_email_min;
		
		if( ($form_asunto_len<=$asunto_min) && (!empty($form_asunto)) )
			$mensaje_error.=$mensaje_asunto_min;

		if( ($form_mensaje_len<=$mensaje_min) && (!empty($form_mensaje)) )
			$mensaje_error.=$mensaje_mensaje_min;

		

		if($form_nombre_len>=$nombre_max)			
			$mensaje_error.=$mensaje_nombre_max;
		if($form_email_len>=$email_max)				
			$mensaje_error.=$mensaje_email_max;
		if($form_asunto_len>=$asunto_max)			
			$mensaje_error.=$mensaje_asunto_max;
		if($form_mensaje_len>=$mensaje_max)			
			$mensaje_error.=$mensaje_mensaje_max;

		
		if($adjunto_enviar==TRUE)
		{
			$archivo=$_FILES['form_archivo']['name'];		
			$temporal=$_FILES['form_archivo']['tmp_name'];		
		
			if($temporal!='')					
			{
				
				$adjunto_tamano=filesize($temporal)/1024;	
				if($adjunto_tamano>=$adjunto_max)
					$mensaje_error.=$mensaje_adjunto_max;
			}
		}
		else
			$temporal='';					

		
		if ((cuenta_letras_mayusculas($form_asunto)>$porcentaje_may_aceptadas) || (cuenta_letras_mayusculas($form_mensaje)>$porcentaje_may_aceptadas))
			$mensaje_error.=$mensaje_muchas_may;


		if( (censurar($form_asunto,$censura_lista)==FALSE) || (censurar($form_mensaje,$censura_lista)==FALSE) )
			$mensaje_error.=$mensaje_censura;

		if(empty($mensaje_error))			
		{
	
			$ip=ip();												
			setlocale (LC_TIME,$idioma);			
			$fecha=gmstrftime("%a, %d/%b/%y %H:%M:%S (%Z)",time());	
			$mensaje_texto=$form_mensaje."\n\n".$enviado_por.' '.$ip."\n".$enviado_el.' '.$fecha;

			
			if($temporal!='')
			{
				
				$buffer = implode("",file($temporal));		
				$buffer = chunk_split(base64_encode($buffer));	

				
				$cabecera = "MIME-version: 1.0\n";
				$cabecera .= "From: $form_nombre<$form_email>\n";
				$cabecera .= "Return-Path: $email_admin\n";
				$cabecera .= "Content-type: multipart/mixed; ";
				$cabecera .= "boundary=\"Message-Boundary\"\n";
				$cabecera .= "Content-transfer-encoding: 7BIT\n";
				$cabecera .= "X-attachments: $temporal";

				
				$mensaje = "--Message-Boundary\n";
				$mensaje .= "Content-type: text/plain; charset=ISO-8859-1\n";
				$mensaje .= "Content-transfer-encoding: 7BIT\n";
				$mensaje .= "Content-description: Mail message body\n\n";
				$mensaje .=$mensaje_texto;

				
				$mensaje .= "\n\n--Message-Boundary\n";
				$mensaje .= "Content-type: Binary; name=\"$archivo\"\n";
				$mensaje .= "Content-Transfer-Encoding: BASE64\n";
				$mensaje .= "Content-disposition: attachment; filename=\"$archivo\"\n\n";
				$mensaje .= "$buffer\n";
				$mensaje .= "--Message-Boundary--\n";
			}
			else
			{
				
				$cabecera = "From: $form_nombre<$form_email>\n";
				$cabecera .= "Return-Path: $email_admin\n";

				
				$mensaje = $mensaje_texto;
			}

			
			
			if (@mail($email_admin,$form_asunto,$mensaje,$cabecera))	
			{
				
				if($acuse_activo==TRUE)
				{
					
					if (@mail($form_email,$acuse_mail_asunto,$acuse_mail_cuerpo))	
						$salida=$acuse_mail_enviado;
					else	
						$salida=$acuse_mail_fallido;
				}
				else	
					$salida=$mensaje_mail_enviado;		
			}
			else		
				$salida=$mensaje_mail_fallido;		
		}
		else															 
		{
			
			$mensaje_error=$mensaje_error_inicial.$mensaje_error.$mensaje_error_final;

			
			$salida=formulario($form_nombre,$form_email,$form_asunto,$form_mensaje,$mensaje_error);
		}
	}
	else															
		$salida=formulario();			

	return $salida;					
}


function limpiar($texto)
{
	$texto = trim($texto);			
	$texto = stripslashes($texto);			
	$texto = strip_tags($texto);			
	return $texto;					
}


function email_valido($email)
{
	if (preg_match('!^[a-z0-9.+-_]+@([a-z0-9-]+(?:.[a-z0-9-]+)+)$!i',$email,$partes))
	{

		if (!checkdnsrr($partes[1]))
			return FALSE;
		else
			return TRUE;
	}
	else
		return FALSE;
}


function ip()
{
	if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
	elseif (isset($_SERVER['HTTP_VIA']))
		$ip = $_SERVER['HTTP_VIA'];
	elseif (isset($_SERVER['REMOTE_ADDR']))
		$ip = $_SERVER['REMOTE_ADDR'];
	else
		$ip = 'desconocida';

	return $ip;				
}


function cuenta_letras_mayusculas($cadena)
{
	$string2=strtolower ($cadena);				
	similar_text ($cadena,$string2,$porcentaje); 		
	$porcentaje=100-$porcentaje;				
	return $porcentaje;
}


function censurar($texto,$filtro)
{
   	foreach ($filtro as $palabra)
	{
		if(eregi($palabra,$texto)!='')
			return FALSE;
	}
	return TRUE;
}


function formulario($form_nombre='',$form_email='',$form_asunto='',$form_mensaje='',$mensaje_error='')
{

	global $titulo_nombre,$titulo_email,$titulo_asunto,$titulo_mensaje;
	global $nombre_size,$email_size,$asunto_size,$mensaje_cols,$mensaje_rows;
	global $titulo_web,$mensaje_principal,$nombre_max,$email_max,$asunto_max;
	global $adjunto_enviar,$titulo_adjunto,$adjunto_max,$archivo_size;

	$url=$_SERVER['PHP_SELF'];		
	if($adjunto_enviar==TRUE)
	{
		$adjunto =<<<EOT
$titulo_adjunto<br />
<input type="file" name="form_archivo" size="$archivo_size" /><br />
EOT;
	}
	else
		$adjunto ='';

	$formulario =<<<EOT
$mensaje_principal
$mensaje_error
<p>&nbsp;</p>

<form enctype="multipart/form-data" method="post" action="$url">
 
  <table width="503" border="0">
  <tr>
    <td width="100">$titulo_nombre</td>
    <td width="387"><input type="text" name="form_nombre" maxlength="$nombre_max" size="$nombre_size" value="$form_nombre" /></td>
  </tr>
  <tr>
    <td>$titulo_email</td>
    <td><input type="text" name="form_email" maxlength="$email_max" size="$email_size" value="$form_email" /></td>
  </tr>
  <tr>
    <td>$titulo_asunto</td>
    <td><input type="text" name="form_asunto" maxlength="$asunto_max" size="$asunto_size" value="$form_asunto" /></td>
  </tr>
</table>
<p> $titulo_mensaje<br />
<textarea cols="$mensaje_cols" style="background-image:images/form.jpg" rows="$mensaje_rows" name="form_mensaje">$form_mensaje</textarea><br />
$adjunto
  <input type="submit" name="form_enviar" value="Enviar" />
</p>
</form>
EOT;

	return $formulario;						
}


function html($cuerpo)
{

	global $titulo_web;

	$pagina =<<<EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$titulo_web</title>

</head>
<body>
<h1>$titulo_web</h1>
$cuerpo
</body>
</html>
EOT;

	return $pagina;
}


?>