Guest User

Untitled

a guest
Jul 7th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.78 KB | None | 0 0
  1. <?php
  2.     require '../xf_connector.php';
  3.     require __DIR__ . '/rcon/SourceQuery/bootstrap.php';
  4.     $servername = "localhost";
  5.     $username = "admin_xenforo";
  6.     $password = "DATABASE PASSWORD HERE";
  7.     $dbname = "admin_xenforo";
  8.     // Create connection
  9.     $conn = new mysqli($servername, $username, $password, $dbname);
  10.     // Check connection
  11.     if ($conn->connect_error) {
  12.         die("Connection failed: " . $conn->connect_error);
  13.     }
  14.  
  15.     use xPaw\SourceQuery\SourceQuery;
  16.    
  17.     // For the sake of this example
  18.     //Header( 'Content-Type: text/plain' );
  19.     //Header( 'X-Content-Type-Options: nosniff' );
  20.    
  21.     // Edit this ->
  22.     define( 'SQ_SERVER_ADDR', '81.169.231.76' );
  23.     define( 'SQ_SERVER_PORT', 28016 );
  24.     define( 'SQ_TIMEOUT',     1 );
  25.     define( 'SQ_ENGINE',      SourceQuery::SOURCE );
  26.     // Edit this <-
  27.    
  28.     //CHECK IF USER IS DONATOR
  29.     if(isset($steamId)){
  30.         //$player = $_POST['player'];
  31.         $sql = "SELECT * FROM xf_user_upgrade_active WHERE user_id=$userId";
  32.         $result = $conn->query($sql);
  33.         if ($result->num_rows > 0) {
  34.             // output data
  35.             while($row = $result->fetch_assoc()) {
  36.                 $UserID = $row['user_id'];
  37.                 $UserUpgradeID = $row['user_upgrade_id'];
  38.                 if($row['user_upgrade_id'] == 1){ //IF USER IS DONATOR PACKAGE ID 1
  39.                     $sql = "SELECT * FROM donators WHERE userid=$UserID";
  40.                     $result2 = $conn->query($sql);
  41.                     if ($result2->num_rows > 0) {
  42.                         while($row2 = $result2->fetch_assoc())
  43.                         {
  44.                             echo "<center><p style='color:red;'>You already redeemed your donation!</p></center>";
  45.                             die();
  46.                         }
  47.                     }
  48.                     else{
  49.                             $Query = new SourceQuery( );
  50.                             try
  51.                             {
  52.                                 $Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
  53.                                
  54.                                 $Query->SetRconPassword( '@Game-Maniac!' );
  55.                                
  56.                                 $Query->Rcon( "usergroup add $steamId donator1" );
  57.                                 echo "<center><p style='color:green;'>You are added as a Dontator on Rust!</p></center>";
  58.                             }
  59.                             catch( Exception $e )
  60.                             {
  61.                                 //echo $e->getMessage( );
  62.                             }
  63.                             finally
  64.                             {
  65.                                 $Query->Disconnect( );
  66.                             }
  67.                             $sql = "INSERT INTO donators (name, userid)
  68.                                     VALUES ('$username', '$UserID')";
  69.                             if ($conn->query($sql) === TRUE) {
  70.                                 echo "<center><p style='color:green;'>Kit Redeem Succesfull!</p></center>";
  71.                             } else {
  72.                                 echo "Error: " . $sql . "<br>" . $conn->error;
  73.                             }
  74.                         }
  75.                 }
  76.             }
  77.         }
  78.         else{
  79.             echo "<center><p style='color:red;'>You are NOT a donator!</p>";
  80.             die();
  81.         }
  82.         //$conn->close();
  83.     }
  84.     else{
  85.         echo "<center><p style='color:red;'>You have no Steam Account configured on this Forum account!</p><a style='color:orange;' target='_parent' href='https://game-maniacs.com/forum/index.php?register/steam&amp;reg=1&amp;assoc=1' >Associate with Steam</a></center>";
  86.         die();
  87.         }
  88. ?>
Add Comment
Please, Sign In to add comment