Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.61 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["chave"]) AND $_POST["chave"]=="33sio5IBXW2hFoTT"){
  3.    
  4.     $css="{background: #FFD1D1 !important; border: 1px solid #F8ACAC !important;}";
  5.     $id_error_fields=array();
  6.     if (isset($_POST["name"]) AND strlen($_POST["name"])>=5)
  7.     {
  8.         $name=$_POST["name"];
  9.     }
  10.     else{
  11.         $name=$_POST["name"];
  12.         array_push($id_error_fields, "name");
  13.     }
  14.    
  15.     if (isset($_POST["morada"]) AND strlen($_POST["morada"])>=5)
  16.     {
  17.         $morada=$_POST["morada"];
  18.     }else{
  19.         $morada=$_POST["morada"];
  20.         array_push($id_error_fields, "morada");
  21.     }
  22.    
  23.     if (isset($_POST["codpostal"]) AND strlen($_POST["codpostal"])>=7)
  24.     {
  25.         $codpostal=$_POST["codpostal"];
  26.     }else{
  27.         $codpostal=$_POST["codpostal"];
  28.         array_push($id_error_fields, "codpostal");
  29.     }
  30.    
  31.     if (isset($_POST["localidade"]) AND strlen($_POST["localidade"])>=3)
  32.     {
  33.         $localidade=$_POST["localidade"];
  34.     }else{
  35.         $localidade=$_POST["localidade"];
  36.         array_push($id_error_fields, "localidade");
  37.     }
  38.    
  39.     if (isset($_POST["escolhauni"]) AND strlen($_POST["escolhauni"])>=1)
  40.     {
  41.         $escolhauni=$_POST["escolhauni"];
  42.     }else{
  43.        
  44.         array_push($id_error_fields, "escolhauni");
  45.     }
  46.    
  47.    
  48.     if (isset($_POST["email"]) AND filter_var($_POST["email"], FILTER_VALIDATE_EMAIL))
  49.     {
  50.         $email=$_POST["email"];
  51.     }else{
  52.         $email=$_POST["email"];
  53.         array_push($id_error_fields, "email");
  54.     }
  55.     if (isset($_POST["phone"]) AND strlen($_POST["phone"])>8)
  56.     {
  57.         $phone=$_POST["phone"];
  58.     }else{
  59.         $phone=$_POST["phone"];
  60.         array_push($id_error_fields, "phone");
  61.     }
  62.     if (isset($_POST["montanteminimo"]) AND strlen($_POST["montanteminimo"])>1)
  63.     {
  64.         $montanteminimo=$_POST["montanteminimo"];
  65.     }else{
  66.         $montanteminimo=$_POST["montanteminimo"];
  67.         array_push($id_error_fields, "montanteminimo");
  68.     }
  69.     if (isset($_POST["montantemaximo"]) AND strlen($_POST["montantemaximo"])>1)
  70.     {
  71.         $montanteminimo=$_POST["montantemaximo"];
  72.     }else{
  73.         $montanteminimo=$_POST["montantemaximo"];
  74.         array_push($id_error_fields, "montantemaximo");
  75.     }
  76.     if (isset($_POST["message"]) AND strlen($_POST["message"])>8)
  77.     {
  78.         $message=$_POST["message"];
  79.     }else{
  80.         $message=$_POST["message"];
  81.         array_push($id_error_fields, "message");
  82.     }
  83.    
  84.     if (count($id_error_fields)>0){
  85.         $type_error="alert";
  86.         $error_text="Corrija os Campos a vermelho!";
  87.         $script='<script type="text/javascript">window.onload = function() {';
  88.         foreach ($id_error_fields as $id_error_field){
  89.             $id_error_field="error_".$id_error_field;
  90.             $script.='document.getElementById("'.$id_error_field.'").className="error";';
  91.  
  92.         }
  93.         $script.="}</script>";
  94.     }else{
  95.         if($escolhauni=="escolhauni_cartao")
  96.             $text_escolhauni="Cartão Unibanco";
  97.         else
  98.             $text_escolhauni="Crédito Pessoal";
  99.         require_once("./function/function_post_send_email.php");
  100.         $map = array('á' => 'a','º' => '','ª' => '','à' => 'a','ã' => 'a','â' => 'a','é' => 'e','è' => 'e','ê' => 'e','í' => 'i','ì' => 'i','ó' => 'o','ò' => 'o','ô' => 'o','õ' => 'o','ú' => 'u','ù' => 'u','ü' => 'u','ç' => 'c','Á' => 'A','À' => 'A','Ã' => 'A','Â' => 'A','É' => 'E','È' => 'E','Ê' => 'E','Í' => 'I','Ì' => 'I','Ó' => 'O','Ò' => 'O','Ô' => 'O','Õ' => 'O','Ú' => 'U','Ù' => 'U','Ü' => 'U','Ç' => 'C');
  101.         $nome_sem_acentos= strtr($name, $map);
  102.         $headers= 'MIME-Version: 1.0' . "\r\n";
  103.         $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n" .
  104.         "From: " . $nome_sem_acentos . "<" . $email . ">"."\r\n" .
  105.         "Reply-To: " . $email . "\r\n" .
  106.         "Return-Path: " . $email . "\r\n";
  107.         //--------------------------------------------------Fim Headers
  108.        
  109.         //--------------------------------------------------Construção de mensagem
  110.         $raw_mensage = '<html><body>
  111.         <h1>Pedido Crédio - Site - Pontopay:</h1>
  112.         <table>
  113.         <tr><th>Nome:</th><td>'.$name.'<td><tr>
  114.         <tr><th>Morada:</th><td>'.$morada.'<td><tr>
  115.         <tr><th>Código Postal:</th><td>'.$codpostal.'<td><tr>
  116.         <tr><th>Localidade:</th><td>'.$localidade.'<td><tr>
  117.         <tr><th>Email:</th><td>'.$email.'<td><tr>
  118.         <tr><th>Telefone / Telemóvel:</th><td>'.$phone.'<td><tr>
  119.         <tr><th>Tipo de Crédito:</th><td>'.$text_escolhauni.'<td><tr>
  120.         <tr><th>Mensagem:</th><td><blockquote>'.$message.'</blockquote><td><tr>
  121.         </body></html>';
  122.         $raw_mensage = wordwrap($raw_mensage, 70);
  123.         //--------------------------------------------------Fim Construção de mensagem
  124.         //--------------------------------------------------Assunto do Email
  125.         $title_email="Pedido Crédito - Site - Pontopay";
  126.         //--------------------------------------------------Fim Assunto do Email
  127.         //--------------------------------------------------Servidor de envio onde está o ficheiro de envio
  128.         $config = parse_ini_file("./config.ini", true);
  129.         $write_log=$config["config"]["write_log"];
  130.         $hostname=$config["config"]["hostname"];
  131.         $default_server = $config["master_server"]["url_server"];
  132.         //--------------------------------------------------Email de recepção
  133.         $para=$config["config"]["send_mail_admin"];
  134.         //--------------------------------------------------Fim Email de recepção
  135.         //--------------------------------------------------Fim Servidor de envio onde está o ficheiro de envio
  136.        
  137.         if (post_send_email($para, $title_email, $raw_mensage, $headers, $default_server)){
  138.             $type_error="success";
  139.             $error_text="A sua mensagem foi enviada com sucesso, responderemos brevemente. Obrigado!";
  140.             unset($name);
  141.             unset($morada);
  142.             unset($codpostal);
  143.             unset($localidade);
  144.             unset($email);
  145.             unset($phone);
  146.             unset($montanteminimo);
  147.             unset($montantemaximo);
  148.             unset($escolhauni);
  149.             unset($message);
  150.            
  151.         }else{
  152.             $type_error="alert";
  153.             $error_text="Ocorreu um erro e a sua mensagem não foi enviada, tente novamente mais tarde!";
  154.         }
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement