Advertisement
Guest User

Untitled

a guest
Mar 20th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. <?php
  2. ///////////////////////////////////////////////
  3. // Dayz PHP Server Control //
  4. // Written by Sandbird //
  5. // Press Start to start the server and Stop //
  6. // to shut it down. If the server is //
  7. // stuck and you want to reboot the machine //
  8. // press the Reboot button. Dont forget to //
  9. // edit the .bat files with tour server info //
  10. ///////////////////////////////////////////////
  11.  
  12. ##################################################################
  13. # SETTINGS START
  14. ##################################################################
  15.  
  16. // request login? true - show login and password boxes, false - password box only
  17. define('USE_USERNAME', true);
  18.  
  19. include("config.php");
  20.  
  21. ##################################################################
  22. # SETTINGS END
  23. ##################################################################
  24.  
  25. // show usage example
  26. if(isset($_GET['help'])) {
  27. die('Include following code into every page you would like to protect, at the very beginning (first line):<br>&lt;?php include("' . __FILE__ . '"); ?&gt;');
  28. }
  29.  
  30. // logout?
  31. if(isset($_GET['logout'])) {
  32. setcookie("verify", ''); // clear password;
  33. die("Logged out.");
  34. }
  35.  
  36. if(!function_exists('showLoginPasswordProtect')) {
  37.  
  38. // show login form
  39. function showLoginPasswordProtect($error_msg) {
  40. ?>
  41. <html>
  42. <head>
  43. <title>Please enter password to access this page</title>
  44. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  45. <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
  46. </head>
  47. <body>
  48. <style>
  49. input { border: 1px solid black; }
  50. </style>
  51. <form method="post">
  52. <h3>Please enter password to access this page</h3>
  53. <font color="red"><?php echo $error_msg; ?></font><br />
  54. <?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?>
  55. <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" />
  56. </form>
  57. <br />
  58. </body>
  59. </html>
  60.  
  61. <?php
  62. // stop at this point
  63. die();
  64. }
  65. }
  66.  
  67. // user provided password
  68. if (isset($_POST['access_password'])) {
  69.  
  70. $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  71. $pass = $_POST['access_password'];
  72. if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
  73. || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) )
  74. ) {
  75. showLoginPasswordProtect("Incorrect password.");
  76. }
  77. else {
  78. // set cookie if password was validated
  79. setcookie("verify", md5($pass));
  80.  
  81. // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
  82. // So need to clear password protector variables
  83. unset($_POST['access_login']);
  84. unset($_POST['access_password']);
  85. unset($_POST['Submit']);
  86. }
  87.  
  88. }
  89.  
  90. else {
  91.  
  92. // check if password cookie is set
  93. if (!isset($_COOKIE['verify'])) {
  94. showLoginPasswordProtect("");
  95. }
  96.  
  97. // check if cookie is good
  98. $found = false;
  99. foreach($LOGIN_INFORMATION as $kay=>$val) {
  100. if ($_COOKIE['verify'] == md5($val)) {
  101. $found = true;
  102. break;
  103. }
  104. }
  105. if (!$found) {
  106. showLoginPasswordProtect("");
  107. }
  108.  
  109. }
  110. ///////////////////////////////////////////////
  111.  
  112. // The above code is just a user/pass security
  113. // to this page. The real action is below these
  114. // comment lines.
  115.  
  116. //////////////////////////////////////////////
  117.  
  118.  
  119. function executeCom($cmd){
  120.  
  121. // Setup the command to run
  122. $cmdline = "cmd /C $cmd";
  123.  
  124. // Make a new instance of the COM object
  125. $WshShell = new COM("WScript.Shell");
  126.  
  127. // Make the command window but dont show it.
  128. $oExec = $WshShell->Run($cmdline, 0, false);
  129.  
  130. }
  131.  
  132. if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Start"){
  133. executeCom($serverfolder."starter.bat");
  134. }
  135. if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Stop"){
  136. executeCom($serverfolder."stopper.bat");
  137. }
  138. if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Restart"){
  139. executeCom($serverfolder."restart.bat");
  140. }
  141. ?>
  142. <style type="text/css">
  143. <!--
  144. body {background-color: #333333;}
  145. .inputtextarea { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; border-color: 000000 000000 000000 000000; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; color:#333333;width:60px}
  146. .style1 {color: #00FF00;font-weight: bold;}
  147. .style2 {color: #999999;font-weight: bold;}
  148. .style3 {color: #ff4400;font-weight: none;}
  149. -->
  150. </style>
  151.  
  152. <title>Dayz Server Control</title>
  153. <p align="center" class="style1">Dayz Server Control Panel</p>
  154. <p align="center" class="style2">Press Start to start server and Stop to stop it.<br>
  155. Start will automatically stop the server first.<br>
  156. Restart will restart the server.
  157. </p>
  158.  
  159. <form method="post" name="frm" action="index.php">
  160. <p align="center">
  161. <input type="submit" name="bsubmit" value="Stop">&nbsp;&nbsp;
  162. <?php
  163. if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Stop"){?>
  164. <input type="submit" name="bsubmit" id="bsubmit" value="Start" disabled="disabled" />
  165. <Br>
  166. <div id=txt align=center class="style3">Please wait 5 seconds for server to shut down. Page will refresh automatically.</div>
  167. <meta http-equiv="refresh" content="5; URL='index.php'">
  168. <?php }else{?>
  169. <input type="submit" name="bsubmit" value="Start">
  170. <?php }
  171. if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Start"){?>
  172. <div id=txt align=center class="style1">Server should be fully up in about 60 seconds.</div>
  173. <meta http-equiv="refresh" content="5; URL='index.php'">
  174. <?php }?>
  175. </p>
  176. <p align=center>
  177. <table border=0 cellpadding=0 cellspacing=0><tr>
  178. <td width="75" height="30" background="img/danger.jpg" align=center>
  179. <input class="inputtextarea" type="submit" name="bsubmit" value="Restart">
  180. </td></tr>
  181. </td></tr></table>
  182. <br>
  183. <font class="style2">Server is currently</font><br>
  184. <?php
  185. $tasklist = exec('tasklist /FI "IMAGENAME eq '.$armaservname.'" /FO CSV');
  186. $tasklist = explode(",", strtolower($tasklist));
  187. $tasklist = str_replace('"', "", $tasklist[0]);
  188. if ($tasklist == strtolower($armaservname)) {
  189. echo "<font class='style1'><b>Online</b></font>";
  190. } else {
  191. echo "<font class='style3'><b>Offline</b></font>";
  192. }
  193. ?>
  194. </p>
  195. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement