Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* MYSQL */
- class SQL {
- public static function connect() {
- $servername = "51.255.132.138";
- $username = "";
- $password = "";
- $dbname = "";
- $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
- return $conn;
- }
- }
- /* For processing the payments and adding up shit to the SQL */
- class UGC {
- public static function getStatus(){
- $product_no = $_REQUEST['item_number']; // Product ID
- $product_transaction = $_REQUEST['tx']; // Paypal transaction ID
- $product_price = $_REQUEST['amt']; // Paypal received amount value
- $product_currency = $_REQUEST['cc']; // Paypal received currency type
- $product_status = $_REQUEST['st']; // Paypal product status
- $name = $_POST['name'];
- if (!empty($_REQUEST)) {
- if($_REQUEST['st'] == 'Completed') { //if the request was completed
- echo "<h3 id='success'>Thanks For Donation</h3>";
- echo "<P>Transaction Status - " . $product_status . "</P>";
- echo "<P>Transaction ID - " . $product_transaction . "</P>";
- echo "<P>Amount - " . $product_price . "</P>";
- echo "<P>Name - " . $name . "</P>";
- $sql = SQL::connect();
- $sql->real_escape_string($name);
- $result = $sql->query("SELECT UGC FROM playerdata WHERE PlayerName='".$name."' LIMIT 1");
- if($result->num_rows >= 1) {
- while($row = $result->fetch_assoc()) {
- $points = $row['UGC'];
- $this->updateSAMP($points, $name); //this will update the SA:MP players
- }
- }
- else {
- echo "IN-Game name not found please contact an administrator to add the money manually";
- }
- $sql->close();
- }
- else {
- echo "<h3 id='fail'>Payment Failed</h3>";
- echo "<P>Transaction Status - Uncompleted</P>";
- echo "<P>Transaction ID - " . $product_transaction . "</P>";
- }
- }
- else {
- echo "<h3 id='fail'>Empty Request</h3>";
- }
- }
- private function updateSAMP($product_price, $points, $name) { /* Why private? We only use it inside another function in this class. */
- $sql = SQL::connect();
- $sql->real_escape_string($points);
- $sql->real_escape_string($username);
- $product_price = $product_price*100;
- $ugc = $points + $product_price;
- $sql->query("UPDATE playerdata SET UGC='".$ugc."' WHERE PlayerName='".$name."'");
- $sql->close();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement