if (is_file($user['home'] . $_POST['file'])) { file_put_contents($user['home'] . $_POST['file'], $_POST['data']); } break; case 'delete': foreach ($_POST['files'] as $f) { if (is_file($user['home'] . $f)) { unlink($user['home'] . $f); } } break; case 'rename': file_rename($_POST['path'], $_POST['newname'], $user['home']); break; case 'server_start': echo server_start($user['user']); break; case 'server_cmd': server_cmd($user['user'], $_POST['cmd']); break; case 'server_stop': server_stop($user['user']); break; case 'server_kill': server_kill($user['user']); break; case 'server_running': echo json_encode(server_running($user['user'])); break; case 'server_log': /*if($files = glob($user['home'] . "screenlog.?*")) {
// Verify running from command line if (php_sapi_name() !== 'cli') { die; } // Parse parameters into $_GET superglobal parse_str(implode('&', array_slice($argv, 1)), $_GET); // Verify an action was recieved if (empty($_GET['action'])) { die("No action specified. Example usage: php -f action=start server=alanaktion"); } // Initialize core chdir(dirname(__FILE__)); require_once 'inc/lib.php'; // Handle actions switch ($_GET['action']) { case "start": server_start($_GET['server']); break; case "stop": server_stop($_GET['server']); break; case "restart": server_stop($_GET['server']); server_start($_GET['server']); break; case "kill": server_kill($_GET['server']); break; default: die("Unknown action: {$_GET['action']}"); }
utils_message(': max_idle_servers must be in 0-9 digits and must be >= 2 and <= 64 in agispeedy.conf', 0, $SERVER['runmode'], $SERVER['output_level']); exit; } if (is_numeric($CONF['daemon']['max_connections']) == false || $CONF['daemon']['max_connections'] < 4 || $CONF['daemon']['max_connections'] > 4096) { utils_message(': max_connections must be in 0-9 digits and must be >= 4 and <= 4096 in agispeedy.conf', 0, $SERVER['runmode'], $SERVER['output_level']); exit; } if ($CONF['daemon']['max_connections'] < $CONF['daemon']['max_idle_servers']) { utils_message(': max_connections must be greater than perfork_idle_servers in agispeedy.conf', 0, $SERVER['runmode'], $SERVER['output_level']); exit; } /*------------------------------------------------------------------------- Server Runtime -------------------------------------------------------------------------*/ utils_message(': Agispeedy - AGI ApplicationServer ' . $VERSION . ' starting...', 3, $SERVER['runmode'], $SERVER['output_level']); server_start(); //start the server server_loop(); //server looping for services server_stop(); // cleanup all exit; /*------------------------------------------------------------------------- Server functions perfork and process -------------------------------------------------------------------------*/ // start the server function server_start() { $SERVER =& $GLOBALS['SERVER']; $CONF =& $GLOBALS['CONF'];
// Switch users if ($_POST['action'] == 'user-switch' && $_POST['user']) { $_SESSION['is_admin'] = true; $_SESSION['user'] = $_POST['user']; header('Location: .'); exit('Switching Users'); } // Add new user if ($_POST['action'] == 'user-add') { user_add($_POST['user'], $_POST['pass'], $_POST['role'], $_POST['dir'], $_POST['ram'], $_POST['port']); } // Start a server if ($_POST['action'] == 'server-start') { $stu = user_info($_POST['user']); if (!server_running($stu['user'])) { server_start($stu['user']); } } // Kill a server if ($_POST['action'] == 'server-stop') { if ($_POST['user'] == 'ALL') { server_kill_all(); } else { server_kill($_POST['user']); } } ?> <!doctype html> <html> <head> <title>Administration | MCHostPanel</title>