Advertisement
Guest User

Untitled

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