Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?php
  2. $auth = isset($_GET['key']) ? $_GET['key'] : 'wibble';
  3. $mcNick = isset($_GET['mcNick']) ? $_GET['mcNick'] : null;
  4. $twNick = isset($_GET['twNick']) ? $_GET['twNick'] : null;
  5. $twChan = isset($_GET['chan']) ? $_GET['chan'] : null;
  6. $action = isset($_GET['act']) ? $_GET['a'] : null;
  7.  
  8. class User {
  9. public $twitchusername = "";
  10. public $minecraftusername = "";
  11. public $twitchchannel = "";
  12. }
  13. $user = new User();
  14. /*act=a&
  15. chan=Sithnar&
  16. twNick=$user&
  17. mcNick=$dummyormsg&
  18. */
  19.  
  20. if($auth == $key)
  21. {
  22. if($mcNick !=null) {
  23. $mcNick = $_GET['mcNick'];
  24. $mcNick = preg_replace("/[^0-9a-zA-Z\_\- ]/m", "", $mcNick);
  25. $mcNick = preg_replace("/ /", "", $mcNick);
  26. }
  27.  
  28. if(isset($_GET['act']))
  29. {
  30. $act = $_GET['act'];
  31.  
  32. switch($act) {
  33. case 'a': $action = 'add '. $mcNick; break;
  34. case 'r': $action = 'remove ' . $mcNick; break;
  35. case 'l': $action = 'list'; break;
  36. default: $action = 'reload';
  37. }
  38.  
  39. if($act == 'a')
  40. {
  41. $jsonasarray=array();
  42. $file = 'whitelist.json';
  43. $user->twitchusername = $twNick;
  44. $user->twitchchannel = $twChan;
  45. $user->minecraftusername = $mcNick;
  46. $jsonasarray=json_decode(file_get_contents($file));
  47. $jsonasarray[]=$user;
  48. $output=$jsonasarray;
  49.  
  50. file_put_contents($file, json_encode($output));
  51. }
  52. }
  53.  
  54. $servercmd = "whitelist $action";
  55.  
  56. $host = 'localhost'; // Server host name or IP
  57. $port = 25569; // Port rcon is listening on
  58. $password = 'Test123'; // rcon.password setting set in server.properties
  59. $timeout = 3; // How long to timeout. Default 3
  60.  
  61. $rcon = new Rcon($host, $port, $password, $timeout);
  62.  
  63. if ($rcon->connect())
  64. {
  65. $rcon->send_command($servercmd);
  66. $response = $rcon->get_response();
  67. }
  68. else
  69.  
  70. { print "Sorry whitelisting is unavailable at this time";}
  71. //*/
  72. /**/
  73. print "<pre>";
  74. $arr = get_defined_vars();
  75. print_r($arr);
  76. print "</pre>";
  77.  
  78. print $response;
  79. #print "$_GET[twNick] Sucess! $_GET[mcNick] added";
  80. }
  81. return;
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement