Advertisement
Guest User

Untitled

a guest
Nov 24th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <?php
  2.  
  3. /* MYSQL */
  4. class SQL {
  5. public static function connect() {
  6. $servername = "51.255.132.138";
  7. $username = "";
  8. $password = "";
  9. $dbname = "";
  10.  
  11. $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
  12. return $conn;
  13. }
  14. }
  15.  
  16.  
  17. /* For processing the payments and adding up shit to the SQL */
  18. class UGC {
  19. public static function getStatus(){
  20. $product_no = $_REQUEST['item_number']; // Product ID
  21. $product_transaction = $_REQUEST['tx']; // Paypal transaction ID
  22. $product_price = $_REQUEST['amt']; // Paypal received amount value
  23. $product_currency = $_REQUEST['cc']; // Paypal received currency type
  24. $product_status = $_REQUEST['st']; // Paypal product status
  25. $name = $_POST['name'];
  26.  
  27. if (!empty($_REQUEST)) {
  28. if($_REQUEST['st'] == 'Completed') { //if the request was completed
  29. echo "<h3 id='success'>Thanks For Donation</h3>";
  30. echo "<P>Transaction Status - " . $product_status . "</P>";
  31. echo "<P>Transaction ID - " . $product_transaction . "</P>";
  32. echo "<P>Amount - " . $product_price . "</P>";
  33. echo "<P>Name - " . $name . "</P>";
  34.  
  35.  
  36. $sql = SQL::connect();
  37. $sql->real_escape_string($name);
  38.  
  39.  
  40. $result = $sql->query("SELECT UGC FROM playerdata WHERE PlayerName='".$name."' LIMIT 1");
  41.  
  42. if($result->num_rows >= 1) {
  43. while($row = $result->fetch_assoc()) {
  44. $points = $row['UGC'];
  45. $this->updateSAMP($points, $name); //this will update the SA:MP players
  46. }
  47. }
  48. else {
  49. echo "IN-Game name not found please contact an administrator to add the money manually";
  50. }
  51. $sql->close();
  52. }
  53. else {
  54. echo "<h3 id='fail'>Payment Failed</h3>";
  55. echo "<P>Transaction Status - Uncompleted</P>";
  56. echo "<P>Transaction ID - " . $product_transaction . "</P>";
  57. }
  58. }
  59. else {
  60. echo "<h3 id='fail'>Empty Request</h3>";
  61. }
  62. }
  63.  
  64. private function updateSAMP($product_price, $points, $name) { /* Why private? We only use it inside another function in this class. */
  65. $sql = SQL::connect();
  66.  
  67. $sql->real_escape_string($points);
  68. $sql->real_escape_string($username);
  69.  
  70. $product_price = $product_price*100;
  71. $ugc = $points + $product_price;
  72.  
  73. $sql->query("UPDATE playerdata SET UGC='".$ugc."' WHERE PlayerName='".$name."'");
  74.  
  75. $sql->close();
  76. }
  77. }
  78.  
  79.  
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement