Advertisement
Guest User

Untitled

a guest
Dec 20th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?php
  2. /*
  3. __PocketMine Plugin__
  4. name=ListLoader
  5. description=Allows use of an external whitelist
  6. version=0.1
  7. author=Falkirks
  8. class=ListLoader
  9. apiversion=10
  10. */
  11. $domain = "SQL Domain";
  12. $conuser = "Username to connect as";
  13. $password = "Password to connect with";
  14. $db = "Database to connect to";
  15. $tablename = "Table to load (eg: mybb_user)";
  16. $usercol = "The colum with usernames probably is username";
  17. class ListLoader implements Plugin{
  18.  
  19. public function __construct(ServerAPI $api, $server = false){
  20. $this->api = $api;
  21. }
  22. public function init(){
  23. $this->api->schedule(10*1200, array($this, "purgePlayers()"), array(), true);
  24. console("[INFO] ListLoader Enabled!");
  25. }
  26. public function purgePlayers() {
  27. console("[ListLoader] Purging Data...");
  28. $con=mysqli_connect($domain,$conuser",$password,$db);
  29. if (mysqli_connect_errno()){
  30. console("[ListLoader] Failed to connect to database, make sure you have defined variables in the plugin.");
  31. console("[ListLoader] Make sure you have defined all variables in the plugin.");
  32. }
  33. $result = mysqli_query($con,"SELECT" . $usercol . "FROM" . $tablename);
  34. foreach ($result as $user) {
  35. foreach ($user as $username) {
  36. $save .= $username;
  37. $save .= "\r\n";
  38. }
  39. }
  40. file_put_contents('white-list.txt',$save);
  41. mysqli_close($con);
  42. $this->api->console->run(whitelist reload);
  43. console("[ListLoader] Whitelist purged");
  44. $this->api->chat->broadcast("[ListLoader] White-list purged! ");
  45. }
  46. public function __destruct(){
  47. }
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement