Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ///////////////////////////////////////////////
- // Dayz PHP Server Control //
- // Written by Sandbird //
- // Press Start to start the server and Stop //
- // to shut it down. If the server is //
- // stuck and you want to reboot the machine //
- // press the Reboot button. Dont forget to //
- // edit the .bat files with tour server info //
- ///////////////////////////////////////////////
- ##################################################################
- # SETTINGS START
- ##################################################################
- // request login? true - show login and password boxes, false - password box only
- define('USE_USERNAME', true);
- include("config.php");
- ##################################################################
- # SETTINGS END
- ##################################################################
- // show usage example
- if(isset($_GET['help'])) {
- die('Include following code into every page you would like to protect, at the very beginning (first line):<br><?php include("' . __FILE__ . '"); ?>');
- }
- // logout?
- if(isset($_GET['logout'])) {
- setcookie("verify", ''); // clear password;
- die("Logged out.");
- }
- if(!function_exists('showLoginPasswordProtect')) {
- // show login form
- function showLoginPasswordProtect($error_msg) {
- ?>
- <html>
- <head>
- <title>Please enter password to access this page</title>
- <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
- <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
- </head>
- <body>
- <style>
- input { border: 1px solid black; }
- </style>
- <form method="post">
- <h3>Please enter password to access this page</h3>
- <font color="red"><?php echo $error_msg; ?></font><br />
- <?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?>
- <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" />
- </form>
- <br />
- </body>
- </html>
- <?php
- // stop at this point
- die();
- }
- }
- // user provided password
- if (isset($_POST['access_password'])) {
- $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
- $pass = $_POST['access_password'];
- if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
- || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) )
- ) {
- showLoginPasswordProtect("Incorrect password.");
- }
- else {
- // set cookie if password was validated
- setcookie("verify", md5($pass));
- // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
- // So need to clear password protector variables
- unset($_POST['access_login']);
- unset($_POST['access_password']);
- unset($_POST['Submit']);
- }
- }
- else {
- // check if password cookie is set
- if (!isset($_COOKIE['verify'])) {
- showLoginPasswordProtect("");
- }
- // check if cookie is good
- $found = false;
- foreach($LOGIN_INFORMATION as $kay=>$val) {
- if ($_COOKIE['verify'] == md5($val)) {
- $found = true;
- break;
- }
- }
- if (!$found) {
- showLoginPasswordProtect("");
- }
- }
- ///////////////////////////////////////////////
- // The above code is just a user/pass security
- // to this page. The real action is below these
- // comment lines.
- //////////////////////////////////////////////
- function executeCom($cmd){
- // Setup the command to run
- $cmdline = "cmd /C $cmd";
- // Make a new instance of the COM object
- $WshShell = new COM("WScript.Shell");
- // Make the command window but dont show it.
- $oExec = $WshShell->Run($cmdline, 0, false);
- }
- if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Start"){
- executeCom($serverfolder."starter.bat");
- }
- if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Stop"){
- executeCom($serverfolder."stopper.bat");
- }
- if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Restart"){
- executeCom($serverfolder."restart.bat");
- }
- ?>
- <style type="text/css">
- <!--
- body {background-color: #333333;}
- .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}
- .style1 {color: #00FF00;font-weight: bold;}
- .style2 {color: #999999;font-weight: bold;}
- .style3 {color: #ff4400;font-weight: none;}
- -->
- </style>
- <title>Dayz Server Control</title>
- <p align="center" class="style1">Dayz Server Control Panel</p>
- <p align="center" class="style2">Press Start to start server and Stop to stop it.<br>
- Start will automatically stop the server first.<br>
- Restart will restart the server.
- </p>
- <form method="post" name="frm" action="index.php">
- <p align="center">
- <input type="submit" name="bsubmit" value="Stop">
- <?php
- if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Stop"){?>
- <input type="submit" name="bsubmit" id="bsubmit" value="Start" disabled="disabled" />
- <Br>
- <div id=txt align=center class="style3">Please wait 5 seconds for server to shut down. Page will refresh automatically.</div>
- <meta http-equiv="refresh" content="5; URL='index.php'">
- <?php }else{?>
- <input type="submit" name="bsubmit" value="Start">
- <?php }
- if (isset($_POST['bsubmit']) && $_POST['bsubmit'] == "Start"){?>
- <div id=txt align=center class="style1">Server should be fully up in about 60 seconds.</div>
- <meta http-equiv="refresh" content="5; URL='index.php'">
- <?php }?>
- </p>
- <p align=center>
- <table border=0 cellpadding=0 cellspacing=0><tr>
- <td width="75" height="30" background="img/danger.jpg" align=center>
- <input class="inputtextarea" type="submit" name="bsubmit" value="Restart">
- </td></tr>
- </td></tr></table>
- <br>
- <font class="style2">Server is currently</font><br>
- <?php
- $tasklist = exec('tasklist /FI "IMAGENAME eq '.$armaservname.'" /FO CSV');
- $tasklist = explode(",", strtolower($tasklist));
- $tasklist = str_replace('"', "", $tasklist[0]);
- if ($tasklist == strtolower($armaservname)) {
- echo "<font class='style1'><b>Online</b></font>";
- } else {
- echo "<font class='style3'><b>Offline</b></font>";
- }
- ?>
- </p>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement