Advertisement
Kaiquegabriel

Untitled

Jul 23rd, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. <?PHP
  2. $host = "localhost"; /* HOST */
  3. $user = "root"; /* USER */
  4. $passwd = "xxxxxx"; /* PASSWORD */
  5. $db = "otserv"; /* DB */
  6. $retorno_token = 'E33999D4466E4847AB39104A7A182434'; // Token gerado pelo PagSeguro
  7. ##############################################################
  8. # CONFIGURAÇÕES
  9. ##############################################################
  10.  
  11.  
  12. if (empty($_POST['Referencia'])) { header("Location http://pagseguro.com.br"); }
  13.  
  14. list($accname, $world) = explode('-', $_POST['Referencia']);
  15. if ($world=='sv') {
  16. $retorno_host = "$host"; // Local da base de dados MySql
  17. $retorno_database = "$db"; // Nome da base de dados MySql
  18. $retorno_usuario = "$user"; // Usuario com acesso a base de dados MySql
  19. $retorno_senha = "$passwd"; // Senha de acesso a base de dados MySql
  20. }
  21.  
  22. ###############################################################
  23. # NÃO ALTERE DESTA LINHA PARA BAIXOs#
  24.  
  25. $lnk = mysql_connect("$host", "$user", "$passwd") or die ('Nao foi possível conectar ao MySql: ' . mysql_error());
  26. mysql_select_db("$db", $lnk) or die ('Nao foi possível ao banco de dados selecionado no MySql: ' . mysql_error());
  27.  
  28. // Validando dados no PagSeguro
  29.  
  30. $PagSeguro = 'Comando=validar';
  31. $PagSeguro .= '&Token=' . $retorno_token;
  32. $Cabecalho = "Retorno PagSeguro";
  33.  
  34. foreach ($_POST as $key => $value)
  35. {
  36. $value = urlencode(stripslashes($value));
  37. $PagSeguro .= "&$key=$value";
  38. }
  39.  
  40. if (function_exists('curl_exec'))
  41. {
  42. $curl = true;
  43. }
  44. elseif ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen ('ssl://pagseguro.uol.com.br', 443, $errno, $errstr, 30)) )
  45. {
  46. $fsocket = true;
  47. }
  48. elseif ($fp = @fsockopen('pagseguro.uol.com.br', 80, $errno, $errstr, 30))
  49. {
  50. $fsocket = true;
  51. }
  52.  
  53. if ($curl == true)
  54. {
  55. $ch = curl_init();
  56.  
  57. curl_setopt($ch, CURLOPT_URL, 'https://pagseguro.uol.com.br/Security/NPI/Default.aspx');
  58. curl_setopt($ch, CURLOPT_POST, true);
  59. curl_setopt($ch, CURLOPT_POSTFIELDS, $PagSeguro);
  60. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  61. curl_setopt($ch, CURLOPT_HEADER, false);
  62. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  63. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  64.  
  65. curl_setopt($ch, CURLOPT_URL, 'https://pagseguro.uol.com.br/Security/NPI/Default.aspx');
  66. $resp = curl_exec($ch);
  67.  
  68. curl_close($ch);
  69. $confirma = (strcmp ($resp, "VERIFICADO") == 0);
  70. }
  71. elseif ($fsocket == true)
  72. {
  73. $Cabecalho = "POST /Security/NPI/Default.aspx HTTP/1.0\r\n";
  74. $Cabecalho .= "Content-Type: application/x-www-form-urlencoded\r\n";
  75. $Cabecalho .= "Content-Length: " . strlen($PagSeguro) . "\r\n\r\n";
  76.  
  77. if ($fp || $errno>0)
  78. {
  79. fputs ($fp, $Cabecalho . $PagSeguro);
  80. $confirma = false;
  81. $resp = '';
  82. while (!feof($fp))
  83. {
  84. $res = @fgets ($fp, 1024);
  85. $resp .= $res;
  86. if (strcmp ($res, "VERIFICADO") == 0)
  87. {
  88. $confirma=true;
  89. break;
  90. }
  91. }
  92. fclose ($fp);
  93. }
  94. else
  95. {
  96. echo "$errstr ($errno)<br />\n";
  97. }
  98. }
  99.  
  100.  
  101. if ($confirma) {
  102. ## Recebendo Dados ##
  103. $TransacaoID = $_POST['TransacaoID'];
  104. $VendedorEmail = $_POST['VendedorEmail'];
  105. $Referencia = $_POST['Referencia'];
  106. $TipoFrete = $_POST['TipoFrete'];
  107. $ValorFrete = $_POST['ValorFrete'];
  108. $Extras = $_POST['Extras'];
  109. $Anotacao = $_POST['Anotacao'];
  110. $TipoPagamento = $_POST['TipoPagamento'];
  111. $StatusTransacao = $_POST['StatusTransacao'];
  112. $CliNome = $_POST['CliNome'];
  113. $CliEmail = $_POST['CliEmail'];
  114. $CliEndereco = $_POST['CliEndereco'];
  115. $CliNumero = $_POST['CliNumero'];
  116. $CliComplemento = $_POST['CliComplemento'];
  117. $CliBairro = $_POST['CliBairro'];
  118. $CliCidade = $_POST['CliCidade'];
  119. $CliEstado = $_POST['CliEstado'];
  120. $CliCEP = $_POST['CliCEP'];
  121. $CliTelefone = $_POST['CliTelefone'];
  122. $NumItens = $_POST['ProdValor_1'];
  123. $ProdQuantidade_x = $POST['ProdQuantidade_1'];
  124.  
  125. # GRAVA OS DADOS NO BANCO DE DADOS #
  126. mysql_query("INSERT into PagSeguroTransacoes SET
  127. TransacaoID='$TransacaoID',
  128. VendedorEmail='$VendedorEmail',
  129. Referencia='$Referencia',
  130. TipoFrete='$TipoFrete',
  131. ValorFrete='$ValorFrete',
  132. Extras='$Extras',
  133. Anotacao='$accname',
  134. TipoPagamento='$TipoPagamento',
  135. StatusTransacao='$StatusTransacao',
  136. CliNome='$CliNome',
  137. CliEmail='$CliEmail',
  138. CliEndereco='$CliEndereco',
  139. CliNumero='$CliNumero',
  140. CliComplemento='$CliComplemento',
  141. CliBairro='$CliBairro',
  142. CliCidade='$CliCidade',
  143. CliEstado='$CliEstado',
  144. CliCEP='$CliCEP',
  145. CliTelefone='$CliTelefone',
  146. NumItens='$NumItens',
  147. Data=now(),
  148. ProdQuantidade_x='$ProdQuantidade_x';");
  149.  
  150. if ($StatusTransacao == "Aprovado") {
  151. mysql_query("UPDATE accounts SET premium_points = premium_points + '$NumItens' WHERE name = '".htmlspecialchars($accname)."'");
  152. mysql_query("UPDATE PagSeguroTransacoes SET StatusTransacao = 'Entregue' WHERE CONVERT( `PagSeguroTransacoes`.`TransacaoID` USING utf8 ) = '$TransacaoID' AND CONVERT( `PagSeguroTransacoes`.`StatusTransacao` USING utf8 ) = 'Aprovado' LIMIT 1 ;");
  153. mysql_query('OPTIMIZE TABLE `pagsegurotransacoes`');
  154. }
  155. }
  156. ?>
  157. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  158. <html xmlns="http://www.w3.org/1999/xhtml">
  159. <head>
  160. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  161. <title>Donate Server</title>
  162. <style type="text/css">
  163. body {
  164. font-family: Tahoma, Geneva, sans-serif;
  165. font-size: 16px;
  166. width: 900px;
  167. margin: 0px auto;
  168. margin-top: 30px;
  169. }
  170. b {
  171. font-size: 18px;
  172. font-weight: bold;
  173. }
  174. </style>
  175. </head>
  176.  
  177. <body>
  178. <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  179. <tr>
  180. <td width="11%" align="center" valign="middle"><img src="images/true.png" height="auto" width="64" /></td>
  181. <td width="89%"><p><b>S</b>ua compra está sendo processada por nossos sistemas de apuração, dentro de no máximo <u>1 hora seus pontos serão creditados</u>, caso o pagamento não for efetuado, ficará em aberto 1 ou mais pagamentos pendentes em sua conta. Caso você tenha mais de 3 pagamentos pendentes por falta de pagamento, sua conta será bloqueada temporariamente para efetuar pagamentos.</p></td>
  182. </tr>
  183. </table>
  184. <!--p><b>ID de Transação:</b> <?php echo $_POST['TransacaoID']; ?></p-->
  185. </body>
  186. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement