Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.62 KB | None | 0 0
  1. <?php require('PaypalIPN.php');
  2.  
  3. use PaypalIPN;
  4.  
  5. $ipn = new PaypalIPN();
  6.  
  7. // Use the sandbox endpoint during testing.
  8. $ipn->useSandbox();
  9. $verified = $ipn->verifyIPN();
  10.  
  11. //////////////////////////RECOGEDORES DE CONTENIDO//////////////////////////////////
  12. $item_name_list = array();
  13. $item_quantity_list = array();
  14.  
  15. $usernames = array();
  16. $passwords = array();
  17.  
  18. $usuario_a_borrar = "empty";
  19.  
  20. //////////////////////////FUNCIONES A LLAMAR/////////////////////////////////
  21. function borrarCuenta() {
  22.             $stmt = mysqli_prepare($conn, "DELETE FROM Cuentas WHERE Username = ?");
  23.             mysqli_stmt_bind_param($stmt, "s", $usuario_a_borrar);
  24.             mysqli_stmt_execute($stmt);
  25.             mysqli_stmt_close($stmt);
  26. }
  27.  
  28. function terminarProceso() {
  29.     header("HTTP/1.1 200 OK");
  30.     die();
  31. }
  32.  
  33. function escribirCuentas() {
  34.     for ($l=0; $l<count($usernames); $l++) {
  35.         echo "Username: " . $usernames[$l] . "    Password: " . $passwords[$l] . "<br>";
  36.     }
  37. }
  38.  
  39. $escribirDatosCuentas = escribirCuentas();
  40. /////////////////////////PROCESAMIENTO DE DATOS/////////////////////////////////
  41.  
  42.  
  43. if ($verified) {
  44.     $payment_status = $_POST["payment_status"];
  45.     $txn_id = $_POST["txn_id"];
  46.     //conexión//
  47.     $servername = "XXXXXXXXXXXXXXXXXXX";
  48.     $username = "XXXXXXXXXXXXXXXXXXXXX";
  49.     $password = "XXXXXXXXXXXXXXXXXXXXX";
  50.     $dbname = "XXXXXXXXXXXXXXXXXXXXXXX";
  51.  
  52.     $conn = mysqli_connect($servername, $username, $password, $dbname);
  53.  
  54.     $transid_query = "SELECT * FROM TransactionIDs WHERE TransID = '$txn_id'";
  55.     $transid_result = mysqli_query($conn, $transid_query);
  56.  
  57.  
  58.  
  59.     if ($payment_status === "Completed" && !$transid_result) {
  60.         $payer_email = $_POST["payer_email"];
  61.         $first_name = $_POST["first_name"];
  62.         $last_name = $_POST["last_name"];
  63.        
  64.         $query_condition= "empty";
  65.         $query = "SELECT TOP 1 Username, Password FROM Cuentas WHERE '$query_condition' AND Server = euw ORDER BY Username ASC";
  66.  
  67.  
  68.         for ($i=1; $i<=999; $i++) {
  69.             if (isset($_POST["item_name$i"])) {
  70.                 array_push($item_name_list, $_POST["item_name$i"]);
  71.             }
  72.         }
  73.         for ($j=1; $j<=999; $j++) {
  74.             if (isset($_POST["quantity$j"])) {
  75.                 array_push($item_quantity_list, $_POST["quantity$j"]);
  76.             }
  77.         }
  78.         for ($k=0; $k<count($item_name_list); $k++) {
  79.             strtolower($item_name_list[$k]);
  80.            
  81.             switch (item_name_list[k]) {
  82.                 /////////////ranked-smurfs/////////////////
  83.                 case "ranked smurf - diamond v":
  84.                     $query_condition = "Ranked_Type = diamond v";
  85.                     $pre_result = mysqli_query($conn, $query);
  86.                     if (!$pre_result) {
  87.                         terminarProceso();
  88.                     }
  89.                     $result = $mysqli_fetch_array($pre_result);
  90.                     array_push($usernames, $result["Username"]);
  91.                     array_push($passwords, $result["Password"]);
  92.                     $usuario_a_borrar = $result["Username"];
  93.                     borrarCuenta($usuario_a_borrar);
  94.                     msyqli_free_result($pre_result);
  95.                 break;
  96.                 case "ranked smurf - platinum i":
  97.                     $query_condition = "Ranked_Type = platinum i";
  98.                     $pre_result = mysqli_query($conn, $query);
  99.                     if (!$pre_result) {
  100.                         terminarProceso();
  101.                     }
  102.                     $result = $mysqli_fetch_array($pre_result);
  103.                     array_push($usernames, $result["Username"]);
  104.                     array_push($passwords, $result["Password"]);
  105.                     $usuario_a_borrar = $result["Username"];
  106.                     borrarCuenta($usuario_a_borrar);
  107.                     msyqli_free_result($pre_result);
  108.                 break;
  109.                 case "ranked smurf - platinum ii":
  110.                     $query_condition = "Ranked_Type = platinum ii";
  111.                     $pre_result = mysqli_query($conn, $query);
  112.                     if (!$pre_result) {
  113.                         terminarProceso();
  114.                     }
  115.                     $result = $mysqli_fetch_array($pre_result);
  116.                     array_push($usernames, $result["Username"]);
  117.                     array_push($passwords, $result["Password"]);
  118.                     $usuario_a_borrar = $result["Username"];
  119.                     borrarCuenta($usuario_a_borrar);
  120.                     msyqli_free_result($pre_result);
  121.                 break;
  122.                 case "ranked smurf - platinum iii":
  123.                     $query_condition = "Ranked_Type = platinum iii";
  124.                     $pre_result = mysqli_query($conn, $query);
  125.                     if (!$pre_result) {
  126.                         terminarProceso();
  127.                     }
  128.                     $result = $mysqli_fetch_array($pre_result);
  129.                     array_push($usernames, $result["Username"]);
  130.                     array_push($passwords, $result["Password"]);
  131.                     $usuario_a_borrar = $result["Username"];
  132.                     borrarCuenta($usuario_a_borrar);
  133.                     msyqli_free_result($pre_result);
  134.                 break;
  135.                 case "ranked smurf - platinum iv":
  136.                     $query_condition = "Ranked_Type = platinum iv";
  137.                     $pre_result = mysqli_query($conn, $query);
  138.                     if (!$pre_result) {
  139.                         terminarProceso();
  140.                     }
  141.                     $result = $mysqli_fetch_array($pre_result);
  142.                     array_push($usernames, $result["Username"]);
  143.                     array_push($passwords, $result["Password"]);
  144.                     $usuario_a_borrar = $result["Username"];
  145.                     borrarCuenta($usuario_a_borrar);
  146.                     msyqli_free_result($pre_result);
  147.                 break;
  148.                 case "ranked smurf - platinum v":
  149.                     $query_condition = "Ranked_Type = platinum v";
  150.                     $pre_result = mysqli_query($conn, $query);
  151.                     if (!$pre_result) {
  152.                         terminarProceso();
  153.                     }
  154.                     $result = $mysqli_fetch_array($pre_result);
  155.                     array_push($usernames, $result["Username"]);
  156.                     array_push($passwords, $result["Password"]);
  157.                     $usuario_a_borrar = $result["Username"];
  158.                     borrarCuenta($usuario_a_borrar);
  159.                     msyqli_free_result($pre_result);
  160.                 break;
  161.                 case "ranked smurf - gold i":
  162.                     $query_condition = "Ranked_Type = gold i";
  163.                     $pre_result = mysqli_query($conn, $query);
  164.                     if (!$pre_result) {
  165.                         terminarProceso();
  166.                     }
  167.                     $result = $mysqli_fetch_array($pre_result);
  168.                     array_push($usernames, $result["Username"]);
  169.                     array_push($passwords, $result["Password"]);
  170.                     $usuario_a_borrar = $result["Username"];
  171.                     borrarCuenta($usuario_a_borrar);
  172.                     msyqli_free_result($pre_result);
  173.                 break;
  174.                 case "ranked smurf - gold ii":
  175.                     $query_condition = "Ranked_Type = gold ii";
  176.                     $pre_result = mysqli_query($conn, $query);
  177.                     if (!$pre_result) {
  178.                         terminarProceso();
  179.                     }
  180.                     $result = $mysqli_fetch_array($pre_result);
  181.                     array_push($usernames, $result["Username"]);
  182.                     array_push($passwords, $result["Password"]);
  183.                     $usuario_a_borrar = $result["Username"];
  184.                     borrarCuenta($usuario_a_borrar);
  185.                     msyqli_free_result($pre_result);
  186.                 break;
  187.                 case "ranked smurf - gold iii":
  188.                     $query_condition = "Ranked_Type = gold iii";
  189.                     $pre_result = mysqli_query($conn, $query);
  190.                     if (!$pre_result) {
  191.                         terminarProceso();
  192.                     }
  193.                     $result = $mysqli_fetch_array($pre_result);
  194.                     array_push($usernames, $result["Username"]);
  195.                     array_push($passwords, $result["Password"]);
  196.                     $usuario_a_borrar = $result["Username"];
  197.                     borrarCuenta($usuario_a_borrar);
  198.                     msyqli_free_result($pre_result);
  199.                 break;
  200.                 case "ranked smurf - gold iv":
  201.                     $query_condition = "Ranked_Type = gold iv";
  202.                     $pre_result = mysqli_query($conn, $query);
  203.                     if (!$pre_result) {
  204.                         terminarProceso();
  205.                     }
  206.                     $result = $mysqli_fetch_array($pre_result);
  207.                     array_push($usernames, $result["Username"]);
  208.                     array_push($passwords, $result["Password"]);
  209.                     $usuario_a_borrar = $result["Username"];
  210.                     borrarCuenta($usuario_a_borrar);
  211.                     msyqli_free_result($pre_result);
  212.                 break;
  213.                 case "ranked smurf - gold v":
  214.                     $query_condition = "Ranked_Type = gold v";
  215.                     $pre_result = mysqli_query($conn, $query);
  216.                     if (!$pre_result) {
  217.                         terminarProceso();
  218.                     }
  219.                     $result = $mysqli_fetch_array($pre_result);
  220.                     array_push($usernames, $result["Username"]);
  221.                     array_push($passwords, $result["Password"]);
  222.                     $usuario_a_borrar = $result["Username"];
  223.                     borrarCuenta($usuario_a_borrar);
  224.                     msyqli_free_result($pre_result);
  225.                 break;
  226.                 case "ranked smurf - silver i":
  227.                     $query_condition = "Ranked_Type = silver i";
  228.                     $pre_result = mysqli_query($conn, $query);
  229.                     if (!$pre_result) {
  230.                         terminarProceso();
  231.                     }
  232.                     $result = $mysqli_fetch_array($pre_result);
  233.                     array_push($usernames, $result["Username"]);
  234.                     array_push($passwords, $result["Password"]);
  235.                     $usuario_a_borrar = $result["Username"];
  236.                     borrarCuenta($usuario_a_borrar);
  237.                     msyqli_free_result($pre_result);
  238.                 break;
  239.                 case "ranked smurf - silver ii":
  240.                     $query_condition = "Ranked_Type = silver ii";
  241.                     $pre_result = mysqli_query($conn, $query);
  242.                     if (!$pre_result) {
  243.                         terminarProceso();
  244.                     }
  245.                     $result = $mysqli_fetch_array($pre_result);
  246.                     array_push($usernames, $result["Username"]);
  247.                     array_push($passwords, $result["Password"]);
  248.                     $usuario_a_borrar = $result["Username"];
  249.                     borrarCuenta($usuario_a_borrar);
  250.                     msyqli_free_result($pre_result);
  251.                 break;
  252.                 case "ranked smurf - silver iii":
  253.                     $query_condition = "Ranked_Type = silver iii";
  254.                     $pre_result = mysqli_query($conn, $query);
  255.                     if (!$pre_result) {
  256.                         terminarProceso();
  257.                     }
  258.                     $result = $mysqli_fetch_array($pre_result);
  259.                     array_push($usernames, $result["Username"]);
  260.                     array_push($passwords, $result["Password"]);
  261.                     $usuario_a_borrar = $result["Username"];
  262.                     borrarCuenta($usuario_a_borrar);
  263.                     msyqli_free_result($pre_result);
  264.                 break;
  265.                 /////////////unranked-smurfs/////////////////
  266.                 case "unranked ultimate pack(50.000+ ip)":
  267.                     $query_condition = "Unranked_Type = 50000";
  268.                     $pre_result = mysqli_query($conn, $query);
  269.                     if (!$pre_result) {
  270.                         terminarProceso();
  271.                     }
  272.                     $result = $mysqli_fetch_array($pre_result);
  273.                     array_push($usernames, $result["Username"]);
  274.                     array_push($passwords, $result["Password"]);
  275.                     $usuario_a_borrar = $result["Username"];
  276.                     borrarCuenta($usuario_a_borrar);
  277.                     msyqli_free_result($pre_result);
  278.                 break;
  279.                 case "unranked premium pack(30.000+ ip)":
  280.                     $query_condition = "Unranked_Type = 30000";
  281.                     $pre_result = mysqli_query($conn, $query);
  282.                     if (!$pre_result) {
  283.                         terminarProceso();
  284.                     }
  285.                     $result = $mysqli_fetch_array($pre_result);
  286.                     array_push($usernames, $result["Username"]);
  287.                     array_push($passwords, $result["Password"]);
  288.                     $usuario_a_borrar = $result["Username"];
  289.                     borrarCuenta($usuario_a_borrar);
  290.                     msyqli_free_result($pre_result);
  291.                 break;
  292.                 case "unranked basic pack(20.000+ ip)":
  293.                     $query_condition = "Unranked_Type = 20000";
  294.                     $pre_result = mysqli_query($conn, $query);
  295.                     if (!$pre_result) {
  296.                         terminarProceso();
  297.                     }
  298.                     $result = $mysqli_fetch_array($pre_result);
  299.                     array_push($usernames, $result["Username"]);
  300.                     array_push($passwords, $result["Password"]);
  301.                     $usuario_a_borrar = $result["Username"];
  302.                     borrarCuenta($usuario_a_borrar);
  303.                     msyqli_free_result($pre_result);
  304.                 break;
  305.             }
  306.         }
  307.    
  308.         $stmt2 = mysqli_prepare($conn, "INSERT INTO TransactionIDs (TransID) VALUES (?)");
  309.         mysqli_stmt_bind_param($stmt2, "s", $txn_id);
  310.         mysqli_stmt_execute($stmt2);
  311.         mysqli_stmt_close($stmt2);
  312.        
  313.        
  314.  
  315.  
  316.         date_default_timezone_set('Europe/Madrid');
  317.         $date = date('d/m/Y H:i:s');
  318.  
  319.         require 'phpmailer/PHPMailerAutoload.php';
  320.  
  321.         $mail = new PHPMailer;
  322.  
  323.  
  324.         $mail->isSMTP();
  325.         $mail->Host = 'smtp.gmail.com';
  326.         $mail->SMTPAuth = true;
  327.         $mail->Username = 'XXXXXXXXXXXXXXXXXXXXXXX';
  328.         $mail->Password = 'XXXXXXXXXXXXXXXXXXXXXXX';
  329.         $mail->SMTPSecure = 'tls';
  330.         $mail->Port = 587;
  331.  
  332.         $mail->setFrom('XXXXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXXXXXXX');
  333.         $mail->addAddress("$payer_email");
  334.  
  335.         $mail->isHTML(true);
  336.  
  337.         $mail->Subject = 'Order confirmation';
  338.         $mail->Body    = "<span style='font-size:14px'>Hi there, $first_name $last_name!<br><br>Thanks a lot for your purchase at our site on $date! Here are the credentials for your new smurf account:<br><br><span style='font-weight:600'>$escribirDatosCuentas</span><br><br>Remember to change your password through the official League of Legends forums. Should there be any questions or inquiries, please contact us anytime.<br><br>Your Paypal Transaction ID for the current order is: $txn_id.<br><br>Best wishes and enjoy your new account!<br><br>$signature</span>";
  339.  
  340.         $mail->send();
  341.  
  342.  
  343.         mysqli_free_result($transid_result);
  344.         mysqli_close($conn);
  345.  
  346.     }
  347. }
  348. // Reply with an empty 200 response to indicate to paypal the IPN was received correctly.
  349. header("HTTP/1.1 200 OK");
  350.  
  351. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement