2

画面上でMinecraftサーバーを実行しています(screen -X mc java -jar minecraft_server.jar)。この内容を Web ページに印刷する方法はありますか? 私はそれが線に沿ったものになると思っていました

<?php
$console = exec(console.sh)
echo $console;
header("refresh: 5";);
?>

ただし、これは何も印刷しません。ユーザーごとの画面と関係があると思いますが、phpにこれを実行させる方法はありますか? それとも、画面をファイルに出力しても、画面に添付できるようにする方法はありますか?

ありがとうございます!

編集:以下の回答はうまくいきますが、http://phpshell.sourceforge.netをお勧めします。端末にログインしてコンソールを表示するとともに、チャットを行うことができます。ただし、これはインタラクティブであり、管理者のみが機能します。

4

1 に答える 1

3

これらのいずれかが機能するはずです。

<?php
$logs = "PATH_TO_SERVER_LOGS/server.log";
$fh = fopen($logs, 'r');
$theData = fread($fh, filesize($logs));
fclose($fh);
echo $theData;
header("refresh: 5");
?>

<?php
//Replace ./server.log with the path to your server logs and make sure apache has the proper //permissions to read the file.
$file = file_get_contents('./server.log', true);
echo $file;
header("refresh: 5");
?>
于 2013-08-03T23:49:00.310 に答える