ma_admin.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <table style="background-color:white;color:blue; margin-left:auto;margin-right:auto">
  2. <tr>
  3. <td>
  4. <?php
  5. global $db;
  6. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  7. if ( $isAdmin )
  8. $server_homes = $db->getIpPorts();
  9. else
  10. $server_homes = $db->getIpPortsForUser($_SESSION['user_id']);
  11. $supported_games = array( "Counter Strike Global Offensive",
  12. "Counter Strike Source",
  13. "Day of Defeat: Source",
  14. "Half-Life 2: Deathmatch",
  15. "Team Fortress 2",
  16. "Team Fortress 2 Beta" );
  17. $i = 0;
  18. foreach ($server_homes as $server_home)
  19. {
  20. if ( in_array( $server_home['game_name'], $supported_games ) )
  21. $ma_admin_server_homes[$i] = $server_home;
  22. $i++;
  23. }
  24. if( isset( $_GET['sm_admin']) )
  25. unset( $_GET['home_id-mod_id-ip-port'] );
  26. create_home_selector_address("util","",$ma_admin_server_homes);
  27. ?>
  28. </td>
  29. </tr>
  30. <?php
  31. if ( empty( $_GET['home_id-mod_id-ip-port'] ) )
  32. unset( $_GET['home_id-mod_id-ip-port'] );
  33. if( isset( $_GET['home_id-mod_id-ip-port']) and !isset( $_GET['sm_admin']) )
  34. {
  35. $pieces = explode( "-", $_GET['home_id-mod_id-ip-port'] );
  36. $post_home_id = $pieces[0];
  37. $post_mod_id = $pieces[1];
  38. $ip = $pieces[2];
  39. $port = $pieces[3];
  40. if (isset($_POST['mani']))
  41. {
  42. if($_POST['asteamid'] == "" or $_POST['aname'] == "")
  43. {
  44. if($_POST['steamid'] == "")
  45. print_failure('A steam_id is needed!');
  46. if($_POST['aname'] == "")
  47. print_failure('A nickname is needed!');
  48. }
  49. else
  50. {
  51. if($isAdmin)
  52. $server_home = $db->getGameHome($post_home_id);
  53. else
  54. $server_home = $db->getUserGameHome($_SESSION['user_id'],$post_home_id);
  55. $asteamid = '"'.$_POST['asteamid'].'"';
  56. $rcommand = 'ma_client addclient '.$_POST['aname'].'; ma_client addsteam '.$_POST['aname'].' '.$asteamid.'; ma_client setaflag '.$_POST['aname'].' +#';
  57. require_once('includes/lib_remote.php');
  58. $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
  59. $remote_retval = $remote->remote_send_rcon_command( $server_home['home_id'], $ip, $port, 'rcon2', $server_home['control_password'],'',$rcommand,$return);
  60. if ( $remote_retval === -1 )
  61. {
  62. print_failure("Failed adding admin, the server may be down or the agent is offline.");
  63. }
  64. elseif ( $remote_retval === 1 )
  65. {
  66. if( preg_match('/Unknown command "ma_client"/i',$return) )
  67. print_failure("Mani Admin Plugin is not properly installed in your server, the error was:<br><xmp>Unknown command \"ma_client\"</xmp>");
  68. else
  69. print_success("Admin added successfully.");
  70. }
  71. elseif ( $remote_retval === -10 )
  72. {
  73. print_failure("You must set the control password (rcon password) in order to add admins.");
  74. }
  75. }
  76. }
  77. ?>
  78. <tr>
  79. <td>
  80. <form action="" method="post">
  81. NickName
  82. <input type="text" name="aname" value="<?php echo (isset($_POST['aname']) and $_POST['aname'] != "") ? $_POST['aname'] : "";?>"/>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td>
  87. Steam_ID
  88. <input type="text" name="asteamid" value="<?php echo (isset($_POST['asteamid']) and $_POST['asteamid'] != "") ? $_POST['asteamid'] : "";?>"/>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td>
  93. <input name="mani" value="ADD ADMIN" type="submit"/>
  94. </form>
  95. </td>
  96. </tr>
  97. <?php
  98. }
  99. ?>
  100. </table>