From 98d26da2c33ba9022b1bc9729cb617fd8a052bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 22 Apr 2009 16:56:17 +0000 Subject: [PATCH] - move functions before html start to be able to use them when outputting something else, - add support for generating a .vnc file and a .m3u for audio. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30331 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- 3rdparty/mmu_man/onlinedemo/haiku.php | 177 ++++++++++++++++++-------- 1 file changed, 121 insertions(+), 56 deletions(-) diff --git a/3rdparty/mmu_man/onlinedemo/haiku.php b/3rdparty/mmu_man/onlinedemo/haiku.php index 52f67b242e..85029ff6af 100755 --- a/3rdparty/mmu_man/onlinedemo/haiku.php +++ b/3rdparty/mmu_man/onlinedemo/haiku.php @@ -8,6 +8,9 @@ // parts inspired by the Free Live OS Zoo // http://www.oszoo.org/wiki/index.php/Free_Live_OS_Zoo +// name of the page +define("PAGE_TITLE", "Haiku Online Demo"); + // relative path to the vnc java applet jar // you must *copy* (apache doesn't seem to like symlinks) it there. @@ -55,7 +58,7 @@ define("QEMU_KEYMAPS", QEMU_BASE . "/share/qemu/keymaps"); define("QEMU_ARGS", "" ."-daemonize " /* detach from stdin */ ."-localtime " /* not UTC */ - ."-name 'Haiku Online Demo' " + ."-name '" . PAGE_TITLE . "' " ."-monitor /dev/null " ."-serial none " ."-parallel none " @@ -89,64 +92,12 @@ $vnckeymap = "en-us"; $cpucount = 1; // statics -$count = $_SESSION['compteur']; +//$count = $_SESSION['compteur']; //$count = $GLOBALS['compteur']; $closing = 0; $do_kill = 0; $do_run = 0; -// parse args -if (isset($_GET['close'])) - $closing = 1; - -if (isset($_GET['kill'])) - $do_kill = 1; - -if (isset($_GET['run'])) - $do_run = 1; - -if (isset($_GET['frame'])) {} - -session_start(); - -//echo "do_run: " . $do_run . "
\n"; -//echo "do_kill: " . $do_kill . "
\n"; - -?> - - - -Haiku Online Demo - - - - -"; -else - echo ""; - function out($str) { echo "
$str
\n"; @@ -230,6 +181,11 @@ function vnc_display() return qemu_slot(); } +function vnc_addr() +{ + return $_SERVER['HTTP_HOST']; +} + function vnc_port() { return VNCPORTBASE + vnc_display(); @@ -237,7 +193,7 @@ function vnc_port() function vnc_addr_display() { - return $_SERVER['HTTP_HOST'] . ":" . vnc_display(); + return vnc_addr() . ":" . vnc_display(); } function vnc_url() @@ -589,6 +545,7 @@ function output_vnc_info() out("You can use an external VNC client at " . "" . "vnc://" . vnc_addr_display() . " " . + "or open this file, " . "or enter " . vnc_addr_display() . " in your " . "\n"; } +function output_vnc_info_file() +{ + if (!is_my_session_valid()) + die("Bad request"); + + header("Content-type: application/x-vnc"); + header('Content-Disposition: attachment; filename="onlinedemo.vnc"'); + + echo "[connection]\n"; + echo "host=" . vnc_addr() . "\n"; + echo "port=" . vnc_display() . "\n"; + //echo "password=XXX\n"; + //echo "[options]\n"; + // cf. http://www.realvnc.com/pipermail/vnc-list/1999-December/011086.html + // cf. http://www.tek-tips.com/viewthread.cfm?qid=1173303&page=1 + //echo "\n"; +} + function output_audio_player_code($external_only=false) { if (true) @@ -610,7 +585,26 @@ function output_audio_player_code($external_only=false) echo "controller=\"true\" align=\"right\">"; } out("You can use an external audio play at " . - "$url or $icy."); + "$url or $icy, or use " . + "this playlist."); +} + +function output_audio_player_file() +{ + if (!is_my_session_valid()) + die("Bad request"); + + header("Content-type: audio/x-mpegurl"); + //header("Content-type: text/plain"); + //header('Content-Disposition: attachment; filename="onlinedemo.m3u"'); + + $port = audio_port(); + $url = "http://" . $_SERVER['HTTP_HOST'] . ":$port/"; + + //echo "#EXTM3U\n"; + //echo "#EXTINF:0," . PAGE_TITLE . "\n"; + echo "$url\n"; + //echo "\n"; } function output_applet_code($external_only=false) @@ -675,6 +669,77 @@ function output_serial_output_code($external_only=false) } + +session_start(); + +// parse args + +// output redirections... +if (isset($_GET['getfile'])) { + switch ($_GET['getfile']) { + case "vncinfo": + output_vnc_info_file(); + break; + case "audiopls": + output_audio_player_file(); + break; + default: + die("Bad request"); + } + die(); +} + +if (isset($_GET['close'])) + $closing = 1; + +if (isset($_GET['kill'])) + $do_kill = 1; + +if (isset($_GET['run'])) + $do_run = 1; + +if (isset($_GET['frame'])) {} + + +//echo "do_run: " . $do_run . "
\n"; +//echo "do_kill: " . $do_kill . "
\n"; + +?> + + + +<?php echo PAGE_TITLE; ?> + + + + +"; +else + echo ""; + + out("
Available displays: " . available_qemu_slots() . "/" . total_qemu_slots() . "
");