Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["chave"]) AND $_POST["chave"]=="33sio5IBXW2hFoT"){
  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"])>8)
  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"])>=8)
  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"])>=8)
  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.  
  56. if (isset($_POST["phone"]) AND strlen($_POST["phone"])>8)
  57. {
  58. $phone=$_POST["phone"];
  59. }else{
  60. $phone=$_POST["phone"];
  61. array_push($id_error_fields, "phone");
  62. }
  63.  
  64. if (isset($_POST["montantemin"]) AND strlen($_POST["montantemin"])>1)
  65. {
  66. $montantemin=$_POST["montantemin"];
  67. }else{
  68. $montantemin=$_POST["montantemin"];
  69. array_push($id_error_fields, "montantemin");
  70. }
  71.  
  72. if (isset($_POST["montantemax"]) AND strlen($_POST["montantemax"])>1)
  73. {
  74. $montantemax=$_POST["montantemax"];
  75. }else{
  76. $montantemax=$_POST["montantemax"];
  77. array_push($id_error_fields, "montantemax");
  78. }
  79.  
  80. if (isset($_POST["message"]) AND strlen($_POST["message"])>8)
  81. {
  82. $message=$_POST["message"];
  83. }else{
  84. $message=$_POST["message"];
  85. array_push($id_error_fields, "message");
  86. }
  87.  
  88. if (count($id_error_fields)>0){
  89. $type_error="alert";
  90. $error_text="Corrija os Campos a vermelho!";
  91. $script='<script type="text/javascript">window.onload = function() {';
  92. foreach ($id_error_fields as $id_error_field){
  93. $id_error_field="error_".$id_error_field;
  94. $script.='document.getElementById("'.$id_error_field.'").className="error";';
  95.  
  96. }
  97. $script.="}</script>";
  98. }else{
  99. if($escolhauni=="escolhauni_creditopessoal")
  100. $text_escolhauni="Crédito Pessoal";
  101. if($escolhauni=="escolhauni_creditoconsolidado")
  102. $text_escolhauni="Crédito Consolidado";
  103. if($escohauni=="escolhauni_creditoautomovel")
  104. $text_escolhauni="Crédito Automóvel";
  105. if($escohauni=="escolhauni_creditoempresas")
  106. $text_escolhauni="Crédito Empresas";
  107. if($escohauni=="escolhauni_microcreditos")
  108. $text_escolhauni="Microcréditos";
  109. if($escohauni=="escolhauni_projetosfinanciados")
  110. $text_escolhauni="Projetos Financiados";
  111.  
  112. require_once("./function/function_post_send_email.php");
  113. $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');
  114. $nome_sem_acentos= strtr($name, $map);
  115. $headers= 'MIME-Version: 1.0' . "\r\n";
  116. $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n" .
  117. "From: " . $nome_sem_acentos . "<" . $email . ">"."\r\n" .
  118. "Reply-To: " . $email . "\r\n" .
  119. "Return-Path: " . $email . "\r\n";
  120. //--------------------------------------------------Fim Headers
  121.  
  122. //--------------------------------------------------Construção de mensagem
  123. $raw_mensage = '<html><body>
  124. <h1>Pedido Adesão Crédito - Site - Pontopay:</h1>
  125. <table>
  126. <tr><th>Nome:</th><td>'.$name.'<td><tr>
  127. <tr><th>Morada:</th><td>'.$morada.'<td><tr>
  128. <tr><th>Código Postal:</th><td>'.$codpostal.'<td><tr>
  129. <tr><th>Localidade:</th><td>'.$localidade.'<td><tr>
  130. <tr><th>Email:</th><td>'.$email.'<td><tr>
  131. <tr><th>Telf./Tlm.:</th><td>'.$phone.'<td><tr>
  132. <tr><th>Montante mínimo a financiar:</th><td>'.$montantemin.'<td><tr>
  133. <tr><th>Montante máximo a financiar:</th><td>'.$montantemax.'<td><tr>
  134. <tr><th>Escolha:</th><td>'.$text_escolhauni.'<td><tr>
  135. <tr><th>Mensagem:</th><td><blockquote>'.$message.'</blockquote><td><tr>
  136. </body></html>';
  137. $raw_mensage = wordwrap($raw_mensage, 70);
  138. //--------------------------------------------------Fim Construção de mensagem
  139. //--------------------------------------------------Assunto do Email
  140. $title_email="Pedido Adesao Crédito - Site - Pontopay";
  141. //--------------------------------------------------Fim Assunto do Email
  142. //--------------------------------------------------Servidor de envio onde está o ficheiro de envio
  143. $config = parse_ini_file("./config.ini", true);
  144. $write_log=$config["config"]["write_log"];
  145. $hostname=$config["config"]["hostname"];
  146. $default_server = $config["master_server"]["url_server"];
  147. //--------------------------------------------------Email de recepção
  148. $para=$config["config"]["send_mail_admin"];
  149. //--------------------------------------------------Fim Email de recepção
  150. //--------------------------------------------------Fim Servidor de envio onde está o ficheiro de envio
  151.  
  152. if (post_send_email($para, $title_email, $raw_mensage, $headers, $default_server)){
  153. $type_error="success";
  154. $error_text="A sua mensagem foi enviada com sucesso, responderemos brevemente. Obrigado!";
  155. unset($name);
  156. unset($morada);
  157. unset($codpostal);
  158. unset($localidade);
  159. unset($email);
  160. unset($phone);
  161. unset($montantemin);
  162. unset($montantemax);
  163. unset($escolhauni);
  164. unset($message);
  165.  
  166. }else{
  167. $type_error="alert";
  168. $error_text="Ocorreu um erro e a sua mensagem não foi enviada, tente novamente mais tarde!";
  169. }
  170. }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement