1e8fc4975SFrançois Revol<?php 2e8fc4975SFrançois Revol 3e8fc4975SFrançois Revol/* 4e8fc4975SFrançois Revol * haiku.php - an online Haiku demo using qemu and vnc. 5e8fc4975SFrançois Revol * Copyright 2007, Francois Revol, revol@free.fr. 6e8fc4975SFrançois Revol */ 7e8fc4975SFrançois Revol 8664c8b6dSFrançois Revol// parts inspired by the Free Live OS Zoo 9664c8b6dSFrançois Revol// http://www.oszoo.org/wiki/index.php/Free_Live_OS_Zoo 10664c8b6dSFrançois Revol 11*98d26da2SFrançois Revol// name of the page 12*98d26da2SFrançois Revoldefine("PAGE_TITLE", "Haiku Online Demo"); 13*98d26da2SFrançois Revol 14664c8b6dSFrançois Revol 15e8fc4975SFrançois Revol// relative path to the vnc java applet jar 16e8fc4975SFrançois Revol// you must *copy* (apache doesn't seem to like symlinks) it there. 17e8fc4975SFrançois Revol 18e8fc4975SFrançois Revol// on debian, apt-get install vnc-java will put them in 19e8fc4975SFrançois Revol// /usr/share/vnc-java 20e8fc4975SFrançois Revol//define("VNCJAVA_PATH", "vnc-java"); 21e8fc4975SFrançois Revol//define("VNCJAR", "vncviewer.jar"); 22e8fc4975SFrançois Revol//define("VNCCLASS", "vncviewer.class"); 23e8fc4975SFrançois Revol 24e8fc4975SFrançois Revol// to use the tightvnc applet instead (supports > 8bpp): 25e8fc4975SFrançois Revol// on debian, apt-get install tightvnc-java will put them in 26e8fc4975SFrançois Revol// /usr/share/tightvnc-java 27e8fc4975SFrançois Revoldefine("VNCJAVA_PATH", "tightvnc-java"); 28e8fc4975SFrançois Revoldefine("VNCJAR", "VncViewer.jar"); 29e8fc4975SFrançois Revoldefine("VNCCLASS", "VncViewer.class"); 30e8fc4975SFrançois Revol 31e8fc4975SFrançois Revol// maximum count of qemu instances. 3291054f1dSFrançois Revoldefine("MAX_QEMUS", 2); 33e8fc4975SFrançois Revol 34e8fc4975SFrançois Revol// size of the java applet, must match the default resolution of the image. 3552a7cf96SFrançois Revol//define("APPLET_WIDTH", "800"); 3652a7cf96SFrançois Revol//define("APPLET_HEIGHT", "600"); 3752a7cf96SFrançois Revoldefine("APPLET_WIDTH", "1024"); 3852a7cf96SFrançois Revoldefine("APPLET_HEIGHT", "768"); 39e8fc4975SFrançois Revol// vnc protocol base port. 40e8fc4975SFrançois Revoldefine("VNCPORTBASE", 5900); 41e8fc4975SFrançois Revol 42664c8b6dSFrançois Revol// base port for audio streams 43f0cbfcafSFrançois Revol//define("AUDIOPORTBASE", 8080); 44f0cbfcafSFrançois Revoldefine("AUDIOPORTBASE", (VNCPORTBASE + MAX_QEMUS)); 45f0cbfcafSFrançois Revol 46f0cbfcafSFrançois Revol// base port for serial output 47f0cbfcafSFrançois Revol//define("SERIALPORTBASE", 9000); 48f0cbfcafSFrançois Revoldefine("SERIALPORTBASE", (VNCPORTBASE + MAX_QEMUS * 2)); 49664c8b6dSFrançois Revol 50e8fc4975SFrançois Revol// timeout before the demo session is killed, as argument to /bin/sleep 514720c31bSFrançois Revoldefine("SESSION_TIMEOUT", "20m"); 52e8fc4975SFrançois Revol 53e8fc4975SFrançois Revol// path to qemu binary 54c6f50a6aSFrançois Revoldefine("QEMU_BASE", "/usr/local"); 55c6f50a6aSFrançois Revoldefine("QEMU_BIN", QEMU_BASE . "/bin/qemu"); 56c6f50a6aSFrançois Revoldefine("QEMU_KEYMAPS", QEMU_BASE . "/share/qemu/keymaps"); 57e8fc4975SFrançois Revol// default arguments: no network, emulate tablet, readonly image file. 584720c31bSFrançois Revoldefine("QEMU_ARGS", "" 59d2bef01cSFrançois Revol ."-daemonize " /* detach from stdin */ 60d2bef01cSFrançois Revol ."-localtime " /* not UTC */ 61*98d26da2SFrançois Revol ."-name '" . PAGE_TITLE . "' " 624720c31bSFrançois Revol ."-monitor /dev/null " 634720c31bSFrançois Revol ."-serial none " 644720c31bSFrançois Revol ."-parallel none " 654720c31bSFrançois Revol ." -net none " 664720c31bSFrançois Revol ."-usbdevice wacom-tablet " 674720c31bSFrançois Revol ."-vga vmware " 684720c31bSFrançois Revol ."-snapshot"); 69d2bef01cSFrançois Revol 70e8fc4975SFrançois Revol// absolute path to the image. 718ad2eabaSFrançois Revoldefine("QEMU_IMAGE_PATH","/home/revol/haiku/trunk/generated.x86/haiku.image"); 728ad2eabaSFrançois Revol// qemu 0.8.2 needs "", qemu 0.9.1 needs ":" 738ad2eabaSFrançois Revoldefine("QEMU_VNC_PREFIX", ":"); 74e8fc4975SFrançois Revol 75e8fc4975SFrançois Revol// name of session and pid files in /tmp 76e8fc4975SFrançois Revoldefine("QEMU_SESSFILE_TMPL", "qemu-haiku-session-"); 77e8fc4975SFrançois Revoldefine("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-"); 78e8fc4975SFrançois Revol// name of session variable holding the qemu slot; not yet used correctly 79e8fc4975SFrançois Revoldefine("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR"); 80e8fc4975SFrançois Revol 81f0cbfcafSFrançois Revol 82f0cbfcafSFrançois Revol// uncomment if you want to pass your Sonix webcam device through 83f0cbfcafSFrançois Revol// migth need to update VID:PID 84f0cbfcafSFrançois Revol//define("QEMU_USB_PASSTHROUGH", "-usbdevice host:0c45:6005"); 85f0cbfcafSFrançois Revol 86f0cbfcafSFrançois Revol 874720c31bSFrançois Revoldefine("BGCOLOR", "#336698"); 884720c31bSFrançois Revol 89f0cbfcafSFrançois Revol 904720c31bSFrançois Revol$vnckeymap = "en-us"; 914720c31bSFrançois Revol 92f0cbfcafSFrançois Revol$cpucount = 1; 93f0cbfcafSFrançois Revol 944720c31bSFrançois Revol// statics 95*98d26da2SFrançois Revol//$count = $_SESSION['compteur']; 964720c31bSFrançois Revol//$count = $GLOBALS['compteur']; 974720c31bSFrançois Revol$closing = 0; 984720c31bSFrançois Revol$do_kill = 0; 994720c31bSFrançois Revol$do_run = 0; 1004720c31bSFrançois Revol 1014720c31bSFrançois Revolfunction out($str) 1024720c31bSFrançois Revol{ 1034720c31bSFrançois Revol echo "<div class=\"haiku_online_out\">$str</div>\n"; 1044720c31bSFrançois Revol ob_flush(); 1054720c31bSFrançois Revol flush(); 1064720c31bSFrançois Revol} 1074720c31bSFrançois Revol 108e8fc4975SFrançois Revolfunction dbg($str) 109e8fc4975SFrançois Revol{ 1104720c31bSFrançois Revol echo "<div class=\"haiku_online_debug\">$str</div>\n"; 1114720c31bSFrançois Revol ob_flush(); 1124720c31bSFrançois Revol flush(); 113e8fc4975SFrançois Revol} 114e8fc4975SFrançois Revol 115e8fc4975SFrançois Revolfunction err($str) 116e8fc4975SFrançois Revol{ 1174720c31bSFrançois Revol echo "<div class=\"haiku_online_error\">$str</div>\n"; 1184720c31bSFrançois Revol ob_flush(); 1194720c31bSFrançois Revol flush(); 120e8fc4975SFrançois Revol} 121e8fc4975SFrançois Revol 122e8fc4975SFrançois Revolfunction make_qemu_sessionfile_name($idx) 123e8fc4975SFrançois Revol{ 124e8fc4975SFrançois Revol return "/tmp/" . QEMU_SESSFILE_TMPL . $idx; 125e8fc4975SFrançois Revol} 126e8fc4975SFrançois Revol 127e8fc4975SFrançois Revolfunction make_qemu_pidfile_name($idx) 128e8fc4975SFrançois Revol{ 129e8fc4975SFrançois Revol return "/tmp/" . QEMU_PIDFILE_TMPL . $idx; 130e8fc4975SFrançois Revol} 131e8fc4975SFrançois Revol 132e8fc4975SFrançois Revolfunction find_qemu_slot() 133e8fc4975SFrançois Revol{ 134e8fc4975SFrançois Revol for ($idx = 0; $idx < MAX_QEMUS; $idx++) { 135e8fc4975SFrançois Revol $pidfile = make_qemu_pidfile_name($idx); 136e8fc4975SFrançois Revol $sessfile = make_qemu_sessionfile_name($idx); 137e8fc4975SFrançois Revol dbg("checking \"$pidfile\", \"$sessfile\"..."); 138e8fc4975SFrançois Revol if (!file_exists($pidfile) && !file_exists($sessfile)) { 139e8fc4975SFrançois Revol file_put_contents($sessfile, session_id()); 140e8fc4975SFrançois Revol $sid = file_get_contents($sessfile); 141e8fc4975SFrançois Revol if ($sid != session_id()) 142e8fc4975SFrançois Revol continue; 143e8fc4975SFrançois Revol $_SESSION[QEMU_IDX_VAR] = $idx; 144e8fc4975SFrançois Revol return $idx; 145e8fc4975SFrançois Revol } 146e8fc4975SFrançois Revol } 147e8fc4975SFrançois Revol return -1; 148e8fc4975SFrançois Revol} 149e8fc4975SFrançois Revol 1504720c31bSFrançois Revolfunction total_qemu_slots() 1514720c31bSFrançois Revol{ 1524720c31bSFrançois Revol return MAX_QEMUS; 1534720c31bSFrançois Revol} 1544720c31bSFrançois Revol 1554720c31bSFrançois Revol 1564720c31bSFrançois Revolfunction available_qemu_slots() 1574720c31bSFrançois Revol{ 1584720c31bSFrançois Revol $count = 0; 1594720c31bSFrançois Revol for ($idx = 0; $idx < MAX_QEMUS; $idx++) { 1604720c31bSFrançois Revol $pidfile = make_qemu_pidfile_name($idx); 1614720c31bSFrançois Revol $sessfile = make_qemu_sessionfile_name($idx); 1624720c31bSFrançois Revol //dbg("checking \"$pidfile\", \"$sessfile\"..."); 1634720c31bSFrançois Revol if (!file_exists($pidfile) && !file_exists($sessfile)) 1644720c31bSFrançois Revol $count++; 1654720c31bSFrançois Revol } 1664720c31bSFrançois Revol return $count; 1674720c31bSFrançois Revol} 1684720c31bSFrançois Revol 169e8fc4975SFrançois Revolfunction qemu_slot() 170e8fc4975SFrançois Revol{ 171e8fc4975SFrançois Revol return $_SESSION[QEMU_IDX_VAR]; 172e8fc4975SFrançois Revol} 173e8fc4975SFrançois Revol 174664c8b6dSFrançois Revolfunction audio_port() 175664c8b6dSFrançois Revol{ 176664c8b6dSFrançois Revol return AUDIOPORTBASE + qemu_slot(); 177664c8b6dSFrançois Revol} 178664c8b6dSFrançois Revol 179e8fc4975SFrançois Revolfunction vnc_display() 180e8fc4975SFrançois Revol{ 181e8fc4975SFrançois Revol return qemu_slot(); 182e8fc4975SFrançois Revol} 183e8fc4975SFrançois Revol 184*98d26da2SFrançois Revolfunction vnc_addr() 185*98d26da2SFrançois Revol{ 186*98d26da2SFrançois Revol return $_SERVER['HTTP_HOST']; 187*98d26da2SFrançois Revol} 188*98d26da2SFrançois Revol 189e8fc4975SFrançois Revolfunction vnc_port() 190e8fc4975SFrançois Revol{ 191e8fc4975SFrançois Revol return VNCPORTBASE + vnc_display(); 192e8fc4975SFrançois Revol} 193e8fc4975SFrançois Revol 1944720c31bSFrançois Revolfunction vnc_addr_display() 1954720c31bSFrançois Revol{ 196*98d26da2SFrançois Revol return vnc_addr() . ":" . vnc_display(); 1974720c31bSFrançois Revol} 1984720c31bSFrançois Revol 1994720c31bSFrançois Revolfunction vnc_url() 2004720c31bSFrançois Revol{ 2014720c31bSFrançois Revol return "vnc://" . vnc_addr_display(); 2024720c31bSFrançois Revol} 2034720c31bSFrançois Revol 204e8fc4975SFrançois Revolfunction is_my_session_valid() 205e8fc4975SFrançois Revol{ 206e8fc4975SFrançois Revol if (!isset($_SESSION[QEMU_IDX_VAR])) 207e8fc4975SFrançois Revol return 0; 208e8fc4975SFrançois Revol $idx = $_SESSION[QEMU_IDX_VAR]; 209e8fc4975SFrançois Revol $sessfile = make_qemu_sessionfile_name($idx); 210e8fc4975SFrançois Revol if (!file_exists($sessfile)) 211e8fc4975SFrançois Revol return 0; 212e8fc4975SFrançois Revol $qemusession=file_get_contents($sessfile); 213e8fc4975SFrançois Revol // has expired 214e8fc4975SFrançois Revol if ($qemusession != session_id()) { 215e8fc4975SFrançois Revol return 0; 216e8fc4975SFrançois Revol } 217e8fc4975SFrançois Revol return 1; 218e8fc4975SFrançois Revol} 219e8fc4975SFrançois Revol 220e8fc4975SFrançois Revol 2214720c31bSFrançois Revolfunction list_keymaps() 2224720c31bSFrançois Revol{ 2234720c31bSFrançois Revol $bads = array('.', '..', 'common', 'modifiers'); 2244720c31bSFrançois Revol $keymaps = scandir(QEMU_KEYMAPS); 2254720c31bSFrançois Revol foreach ($keymaps as $key => $map) { 2264720c31bSFrançois Revol if (in_array($map, $bads)) 2274720c31bSFrançois Revol unset($keymaps[$key]); 2284720c31bSFrançois Revol } 2294720c31bSFrançois Revol return $keymaps; 2304720c31bSFrançois Revol} 2314720c31bSFrançois Revol 2324720c31bSFrançois Revol 2334720c31bSFrançois Revolfunction in_keymaps($keymap) 2344720c31bSFrançois Revol{ 2354720c31bSFrançois Revol $keymaps = list_keymaps(); 2364720c31bSFrançois Revol 2374720c31bSFrançois Revol if ($keymap == "") 2384720c31bSFrançois Revol return false; 2394720c31bSFrançois Revol if (in_array($keymap, $keymaps)) 2404720c31bSFrançois Revol return true; 2414720c31bSFrançois Revol 2424720c31bSFrançois Revol return false; 2434720c31bSFrançois Revol} 244c6f50a6aSFrançois Revol 245c6f50a6aSFrançois Revol 246c6f50a6aSFrançois Revolfunction probe_keymap() 247c6f50a6aSFrançois Revol{ 248c6f50a6aSFrançois Revol global $vnckeymap; 2494720c31bSFrançois Revol if (is_string($_GET['keymap']) && in_keymaps($_GET['keymap'])) 2504720c31bSFrançois Revol { 2514720c31bSFrançois Revol $vnckeymap = $_GET['keymap']; 2524720c31bSFrançois Revol dbg("Overriden keymap '" . $vnckeymap . "' in arguments."); 2534720c31bSFrançois Revol return; 2544720c31bSFrançois Revol } 255c6f50a6aSFrançois Revol // if the browser advertised a prefered lang... 256c6f50a6aSFrançois Revol if (!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) 257c6f50a6aSFrançois Revol return; 258c6f50a6aSFrançois Revol $langs = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; 259c6f50a6aSFrançois Revol $langs = ereg_replace(";q=[^,]*", "", $langs); 260c6f50a6aSFrançois Revol $langs = str_replace(" ", "", $langs); 261c6f50a6aSFrançois Revol $langs = split(",", $langs); 262c6f50a6aSFrançois Revol //print_r($langs); 263c6f50a6aSFrançois Revol //print_r($keymaps); 264c6f50a6aSFrançois Revol foreach($langs as $lang) 265c6f50a6aSFrançois Revol { 2664720c31bSFrançois Revol if (in_keymaps($lang)) 267c6f50a6aSFrançois Revol { 2684720c31bSFrançois Revol $vnckeymap = $lang; 269664c8b6dSFrançois Revol dbg("Detected keymap '" . $vnckeymap . 270664c8b6dSFrançois Revol "' from browser headers."); 271c6f50a6aSFrançois Revol return; 272c6f50a6aSFrançois Revol } 273c6f50a6aSFrançois Revol } 274c6f50a6aSFrançois Revol} 2754720c31bSFrançois Revol 2764720c31bSFrançois Revol 277f0cbfcafSFrançois Revolfunction probe_options_form() 278f0cbfcafSFrançois Revol{ 279f0cbfcafSFrançois Revol global $cpucount; 280f0cbfcafSFrançois Revol $cpucount = 1; 281f0cbfcafSFrançois Revol if (isset($_GET['cpucount'])) 282f0cbfcafSFrançois Revol $cpucount = (int)$_GET['cpucount']; 283f0cbfcafSFrançois Revol $cpucount = max(min($cpucount, 8), 1); 284f0cbfcafSFrançois Revol //dbg("cpucount $cpucount"); 285f0cbfcafSFrançois Revol $cpucount = 1; // force for now 286f0cbfcafSFrançois Revol} 287f0cbfcafSFrançois Revol 288f0cbfcafSFrançois Revol 2894720c31bSFrançois Revolfunction output_options_form() 2904720c31bSFrançois Revol{ 2914720c31bSFrançois Revol global $vnckeymap; 2924720c31bSFrançois Revol $idx = qemu_slot(); 2934720c31bSFrançois Revol echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; 2944720c31bSFrançois Revol echo "<table border=\"0\" class=\"haiku_online_form\">\n"; 295d2bef01cSFrançois Revol 296f0cbfcafSFrançois Revol $keymaps = list_keymaps(); 297d2bef01cSFrançois Revol echo "<tr>\n<td align=\"right\">\n"; 2984720c31bSFrançois Revol echo "Select your keymap:"; 299d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 3004720c31bSFrançois Revol echo "<select name=\"keymap\">"; 3014720c31bSFrançois Revol foreach ($keymaps as $keymap) { 302f0cbfcafSFrançois Revol echo "<option value=\"$keymap\" "; 3034720c31bSFrançois Revol if ($keymap == $vnckeymap) 304f0cbfcafSFrançois Revol echo "selected=\"selected\" "; 3054720c31bSFrançois Revol echo ">$keymap</option>"; 3064720c31bSFrançois Revol //echo "<option name=\"keymap\" "; 3074720c31bSFrançois Revol //echo "value=\"$keymap\">" . locale_get_display_name($keymap); 3084720c31bSFrançois Revol //echo "</option>"; 3094720c31bSFrançois Revol } 3104720c31bSFrançois Revol echo "</select>"; 311d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 3124720c31bSFrançois Revol 313f0cbfcafSFrançois Revol 3144720c31bSFrançois Revol $modes = array("1024x768"/*, "800x600"*/); 3154720c31bSFrançois Revol echo "<tr "; 3164720c31bSFrançois Revol if (count($modes) < 2) 3174720c31bSFrançois Revol echo "class=\"haiku_online_disabled\""; 3184720c31bSFrançois Revol echo ">\n"; 3194720c31bSFrançois Revol echo "<td align=\"right\">\n"; 3204720c31bSFrançois Revol echo "Select display size:"; 321d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 3224720c31bSFrançois Revol echo "<select name=\"videomode\" "; 3234720c31bSFrançois Revol if (count($modes) < 2) 324f0cbfcafSFrançois Revol echo "disabled=\"disabled\""; 3254720c31bSFrançois Revol echo ">"; 3264720c31bSFrançois Revol foreach ($modes as $mode) { 327f0cbfcafSFrançois Revol echo "<option value=\"$mode\" "; 3284720c31bSFrançois Revol if ($mode == $videomode) 329f0cbfcafSFrançois Revol echo "selected=\"selected\" "; 3304720c31bSFrançois Revol echo ">$mode</option>"; 3314720c31bSFrançois Revol } 3324720c31bSFrançois Revol echo "</select>"; 333d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 3344720c31bSFrançois Revol 335f0cbfcafSFrançois Revol 336f0cbfcafSFrançois Revol $maxcpus = 8; 337f0cbfcafSFrançois Revol echo "<tr "; 338f0cbfcafSFrançois Revol if (!$enable_cpus) 339f0cbfcafSFrançois Revol echo "class=\"haiku_online_disabled\""; 340f0cbfcafSFrançois Revol echo ">\n"; 341f0cbfcafSFrançois Revol echo "<td align=\"right\">\n"; 342f0cbfcafSFrançois Revol echo "Select cpu count:"; 343f0cbfcafSFrançois Revol echo "</td>\n<td>\n"; 344f0cbfcafSFrançois Revol echo "<select name=\"cpucount\" "; 345f0cbfcafSFrançois Revol if (!$enable_cpus) 346f0cbfcafSFrançois Revol echo "disabled=\"disabled\""; 347f0cbfcafSFrançois Revol echo ">"; 348f0cbfcafSFrançois Revol for ($ncpu = 1; $ncpu <= $maxcpus; $ncpu++) { 349f0cbfcafSFrançois Revol echo "<option value=\"$ncpu\" "; 350f0cbfcafSFrançois Revol if ($ncpu == 1) 351f0cbfcafSFrançois Revol echo "selected=\"selected\" "; 352f0cbfcafSFrançois Revol echo ">$ncpu</option>"; 353f0cbfcafSFrançois Revol } 354f0cbfcafSFrançois Revol echo "</select>"; 355f0cbfcafSFrançois Revol echo "</td>\n</tr>\n"; 356f0cbfcafSFrançois Revol 357f0cbfcafSFrançois Revol 358f0cbfcafSFrançois Revol $enable_sound = 0; 3594720c31bSFrançois Revol echo "<tr "; 3604720c31bSFrançois Revol if (!$enable_sound) 3614720c31bSFrançois Revol echo "class=\"haiku_online_disabled\""; 3624720c31bSFrançois Revol echo ">\n"; 3634720c31bSFrançois Revol echo "<td align=\"right\">\n"; 364d2bef01cSFrançois Revol echo "Check to enable sound:"; 365d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 366d2bef01cSFrançois Revol echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\" "; 367f0cbfcafSFrançois Revol echo "value=\"1\" "; 368664c8b6dSFrançois Revol if ($enable_sound) { 36991054f1dSFrançois Revol echo "checked=\"checked\" /"; 370f0cbfcafSFrançois Revol } else 371f0cbfcafSFrançois Revol echo "disabled=\"disabled\" /"; 37291054f1dSFrançois Revol echo "><label for=\"sound_cb\">Sound</label>"; 373d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 374d2bef01cSFrançois Revol 375f0cbfcafSFrançois Revol $enable_serial = 1; 376f0cbfcafSFrançois Revol echo "<tr "; 377f0cbfcafSFrançois Revol if (!$enable_serial) 378f0cbfcafSFrançois Revol echo "class=\"haiku_online_disabled\""; 379f0cbfcafSFrançois Revol echo ">\n"; 380f0cbfcafSFrançois Revol echo "<td align=\"right\">\n"; 381f0cbfcafSFrançois Revol echo "Check to enable serial output:"; 382f0cbfcafSFrançois Revol echo "</td>\n<td>\n"; 383f0cbfcafSFrançois Revol echo "<input type=\"checkbox\" name=\"serial\" id=\"serial_cb\" "; 384f0cbfcafSFrançois Revol echo "value=\"1\" "/*"disabled "*/; 385f0cbfcafSFrançois Revol if ($enable_serial) { 386f0cbfcafSFrançois Revol //echo "checked "; 38791054f1dSFrançois Revol } 38891054f1dSFrançois Revol echo "/><label for=\"serial_cb\">Serial</label>"; 389f0cbfcafSFrançois Revol echo "</td>\n</tr>\n"; 390f0cbfcafSFrançois Revol 391f0cbfcafSFrançois Revol if (defined("QEMU_USB_PASSTHROUGH")) { 392f0cbfcafSFrançois Revol 393f0cbfcafSFrançois Revol $enable_webcam = 1; 394f0cbfcafSFrançois Revol echo "<tr "; 395f0cbfcafSFrançois Revol if (!$enable_webcam) 396f0cbfcafSFrançois Revol echo "class=\"haiku_online_disabled\""; 397f0cbfcafSFrançois Revol echo ">\n"; 398f0cbfcafSFrançois Revol echo "<td align=\"right\">\n"; 399f0cbfcafSFrançois Revol echo "Check to enable webcam:"; 400f0cbfcafSFrançois Revol echo "</td>\n<td>\n"; 401f0cbfcafSFrançois Revol echo "<input type=\"checkbox\" name=\"webcam\" id=\"webcam_cb\" "; 402f0cbfcafSFrançois Revol echo "value=\"1\" "/*"disabled "*/; 403f0cbfcafSFrançois Revol if ($enable_webcam) { 404f0cbfcafSFrançois Revol //echo "checked "; 40591054f1dSFrançois Revol } 40691054f1dSFrançois Revol echo "/><label for=\"webcam_cb\">Webcam</label>"; 407f0cbfcafSFrançois Revol echo "</td>\n</tr>\n"; 408f0cbfcafSFrançois Revol } 409d2bef01cSFrançois Revol /* 410d2bef01cSFrançois Revol echo "<tr>\n<td align=\"right\">\n"; 4114720c31bSFrançois Revol //out("Click here to enable sound:"); 412d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 413d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 414d2bef01cSFrançois Revol 415d2bef01cSFrançois Revol echo "<tr>\n<td align=\"right\">\n"; 416d2bef01cSFrançois Revol //out("Click here to enable sound:"); 417d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 418d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 419d2bef01cSFrançois Revol */ 420d2bef01cSFrançois Revol 421d2bef01cSFrançois Revol echo "<tr>\n<td align=\"right\">\n"; 4224720c31bSFrançois Revol echo "Click here to start the session:"; 423d2bef01cSFrançois Revol echo "</td>\n<td>\n"; 4244720c31bSFrançois Revol echo "<input type=\"submit\" name=\"run\" "; 4254720c31bSFrançois Revol echo "value=\"Start!\" />"; 426d2bef01cSFrançois Revol echo "</td>\n</tr>\n"; 427d2bef01cSFrançois Revol 4284720c31bSFrançois Revol echo "</table>\n"; 4294720c31bSFrançois Revol echo "</form>\n"; 430664c8b6dSFrançois Revol out("NOTE: You will need a Java-enabled browser to display the VNC " . 431664c8b6dSFrançois Revol "Applet needed by this demo."); 4324720c31bSFrançois Revol out("You can however use instead an external <a " . 4334720c31bSFrançois Revol "href=\"http://fr.wikipedia.org/wiki/Virtual_Network_Computing\"" . 4344720c31bSFrançois Revol ">VNC viewer</a>."); 4354720c31bSFrançois Revol ob_flush(); 4364720c31bSFrançois Revol flush(); 4374720c31bSFrançois Revol} 4384720c31bSFrançois Revol 4394720c31bSFrançois Revolfunction output_kill_form() 4404720c31bSFrançois Revol{ 4414720c31bSFrançois Revol echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; 4424720c31bSFrançois Revol echo "<table border=\"0\" class=\"haiku_online_form\">\n"; 4434720c31bSFrançois Revol echo "<tr>\n"; 4444720c31bSFrançois Revol echo "<td>\n"; 4454720c31bSFrançois Revol echo "Click here to kill the session:"; 4464720c31bSFrançois Revol echo "</td>\n"; 4474720c31bSFrançois Revol echo "<td>\n"; 4484720c31bSFrançois Revol echo "<input type=\"submit\" name=\"kill\" "; 4494720c31bSFrançois Revol echo "value=\"Terminate\"/>"; 4504720c31bSFrançois Revol echo "</td>\n"; 4514720c31bSFrançois Revol echo "</tr>\n"; 4524720c31bSFrançois Revol echo "</table>\n"; 4534720c31bSFrançois Revol echo "</form>\n"; 4544720c31bSFrançois Revol ob_flush(); 4554720c31bSFrançois Revol flush(); 456c6f50a6aSFrançois Revol} 457c6f50a6aSFrançois Revol 458c6f50a6aSFrançois Revol 459e8fc4975SFrançois Revolfunction start_qemu() 460e8fc4975SFrançois Revol{ 461c6f50a6aSFrançois Revol global $vnckeymap; 462f0cbfcafSFrançois Revol global $cpucount; 463e8fc4975SFrançois Revol $idx = find_qemu_slot(); 464e8fc4975SFrançois Revol if ($idx < 0) { 465e8fc4975SFrançois Revol err("No available qemu slot, please try later."); 466e8fc4975SFrançois Revol return $idx; 467e8fc4975SFrançois Revol } 468e8fc4975SFrançois Revol $pidfile = make_qemu_pidfile_name($idx); 469f0cbfcafSFrançois Revol $cmd = QEMU_BIN . " " . QEMU_ARGS; 470f0cbfcafSFrançois Revol if ($cpucount > 1) 471f0cbfcafSFrançois Revol $cmd .= " -smp " . $cpucount; 472f0cbfcafSFrançois Revol if (isset($_GET['serial'])) { 473f0cbfcafSFrançois Revol $cmd .= " -serial telnet::"; 474f0cbfcafSFrançois Revol $cmd .= (SERIALPORTBASE + qemu_slot()); 475f0cbfcafSFrançois Revol $cmd .= ",server,nowait,nodelay"; 476f0cbfcafSFrançois Revol } 477f0cbfcafSFrançois Revol if (isset($_GET['webcam']) && defined("QEMU_USB_PASSTHROUGH")) { 478f0cbfcafSFrançois Revol $cmd .= " " . QEMU_USB_PASSTHROUGH; 479f0cbfcafSFrançois Revol } 480f0cbfcafSFrançois Revol $cmd .= " -k " . $vnckeymap . 481664c8b6dSFrançois Revol " -vnc " . QEMU_VNC_PREFIX . vnc_display() . 482664c8b6dSFrançois Revol " -pidfile " . $pidfile . 483664c8b6dSFrançois Revol " " . QEMU_IMAGE_PATH; 484e8fc4975SFrançois Revol 485e8fc4975SFrançois Revol if (file_exists($pidfile)) 486e8fc4975SFrançois Revol unlink($pidfile); 487e8fc4975SFrançois Revol dbg("Starting <tt>" . $cmd . "</tt>..."); 488e8fc4975SFrançois Revol 489e8fc4975SFrançois Revol $descriptorspec = array( 490e8fc4975SFrançois Revol // 0 => array("pipe", "r"), // stdin 491e8fc4975SFrançois Revol // 1 => array("pipe", "w"), // stdout 492e8fc4975SFrançois Revol // 2 => array("pipe", "w") // stderr 493e8fc4975SFrançois Revol ); 494e8fc4975SFrançois Revol //$cmd="/bin/ls"; 495e8fc4975SFrançois Revol //passthru($cmd, $ret); 496e8fc4975SFrançois Revol //dbg("ret=$ret"); 497e8fc4975SFrançois Revol $cmd .= " &"; 498e8fc4975SFrançois Revol $process = proc_open($cmd, $descriptorspec, $pipes); 499e8fc4975SFrançois Revol sleep(1); 500e8fc4975SFrançois Revol proc_close($process); 501e8fc4975SFrançois Revol 502e8fc4975SFrançois Revol dbg("Started QEMU."); 503e8fc4975SFrançois Revol $sessfile = make_qemu_sessionfile_name($idx); 504664c8b6dSFrançois Revol $cmd = "(PID=`cat " . $pidfile . "`; " . 505664c8b6dSFrançois Revol "sleep " . SESSION_TIMEOUT . "; " . 506664c8b6dSFrançois Revol "kill -9 \$PID && " . 507664c8b6dSFrançois Revol "rm " . $pidfile . " " . $sessfile . ") &"; 508e8fc4975SFrançois Revol 509e8fc4975SFrançois Revol $process = proc_open($cmd, $descriptorspec, $wkpipes); 510e8fc4975SFrançois Revol sleep(1); 511e8fc4975SFrançois Revol proc_close($process); 512e8fc4975SFrançois Revol 513e8fc4975SFrançois Revol dbg("Started timed kill."); 514e8fc4975SFrançois Revol dbg("Ready for a " . SESSION_TIMEOUT . " session."); 515e8fc4975SFrançois Revol} 516e8fc4975SFrançois Revol 5174720c31bSFrançois Revolfunction stop_qemu() 5184720c31bSFrançois Revol{ 5194720c31bSFrançois Revol $qemuidx = qemu_slot(); 5204720c31bSFrançois Revol $pidfile = make_qemu_pidfile_name($qemuidx); 5214720c31bSFrançois Revol if (file_exists($pidfile)) { 5224720c31bSFrançois Revol $pid = file_get_contents($pidfile); 5234720c31bSFrançois Revol //out("PID:" . $pid); 5244720c31bSFrançois Revol system("/bin/kill -TERM " . $pid); 5254720c31bSFrançois Revol unlink($pidfile); 5264720c31bSFrançois Revol } 5274720c31bSFrançois Revol $sessionfile = make_qemu_sessionfile_name($qemuidx); 5284720c31bSFrançois Revol if (file_exists($sessionfile)) { 5294720c31bSFrançois Revol unlink($sessionfile); 5304720c31bSFrançois Revol } 5314720c31bSFrançois Revol unset($_SESSION[QEMU_IDX_VAR]); 5324720c31bSFrançois Revol 5334720c31bSFrançois Revol out("reloading..."); 5344720c31bSFrançois Revol sleep(1); 5354720c31bSFrançois Revol echo "<script>\n"; 5364720c31bSFrançois Revol echo "<!--\n"; 5374720c31bSFrançois Revol echo "window.location = \"" . $_SERVER['PHP_SELF'] . "\";\n"; 5384720c31bSFrançois Revol echo "//--></script>\n"; 5394720c31bSFrançois Revol out("Click <a href=\"" . $_SERVER['PHP_SELF'] . 5404720c31bSFrançois Revol "\">here</a> to reload the page."); 5414720c31bSFrançois Revol} 5424720c31bSFrançois Revol 5434720c31bSFrançois Revolfunction output_vnc_info() 5444720c31bSFrançois Revol{ 545664c8b6dSFrançois Revol out("You can use an external VNC client at " . 546664c8b6dSFrançois Revol "<a href=\"vnc://" . vnc_addr_display() . "\">" . 547664c8b6dSFrançois Revol "vnc://" . vnc_addr_display() . "</a> " . 548*98d26da2SFrançois Revol "or open <a href=\"" . $_SERVER['PHP_SELF'] . "?getfile=vncinfo&slot=" . vnc_display() . "\">this file</a>, " . 5494720c31bSFrançois Revol "or enter <tt>" . vnc_addr_display() . "</tt> in your " . 550664c8b6dSFrançois Revol "<a href=\"http://fr.wikipedia.org/wiki/Virtual_Network_" . 551664c8b6dSFrançois Revol "Computing\"" . 552f0cbfcafSFrançois Revol ">VNC viewer</a>."); 553f0cbfcafSFrançois Revol //echo "<br />\n"; 5544720c31bSFrançois Revol} 555e8fc4975SFrançois Revol 556*98d26da2SFrançois Revolfunction output_vnc_info_file() 557*98d26da2SFrançois Revol{ 558*98d26da2SFrançois Revol if (!is_my_session_valid()) 559*98d26da2SFrançois Revol die("Bad request"); 560*98d26da2SFrançois Revol 561*98d26da2SFrançois Revol header("Content-type: application/x-vnc"); 562*98d26da2SFrançois Revol header('Content-Disposition: attachment; filename="onlinedemo.vnc"'); 563*98d26da2SFrançois Revol 564*98d26da2SFrançois Revol echo "[connection]\n"; 565*98d26da2SFrançois Revol echo "host=" . vnc_addr() . "\n"; 566*98d26da2SFrançois Revol echo "port=" . vnc_display() . "\n"; 567*98d26da2SFrançois Revol //echo "password=XXX\n"; 568*98d26da2SFrançois Revol //echo "[options]\n"; 569*98d26da2SFrançois Revol // cf. http://www.realvnc.com/pipermail/vnc-list/1999-December/011086.html 570*98d26da2SFrançois Revol // cf. http://www.tek-tips.com/viewthread.cfm?qid=1173303&page=1 571*98d26da2SFrançois Revol //echo "\n"; 572*98d26da2SFrançois Revol} 573*98d26da2SFrançois Revol 574664c8b6dSFrançois Revolfunction output_audio_player_code($external_only=false) 575664c8b6dSFrançois Revol{ 576664c8b6dSFrançois Revol if (true) 577664c8b6dSFrançois Revol return; 578664c8b6dSFrançois Revol 579664c8b6dSFrançois Revol $port = audio_port(); 580664c8b6dSFrançois Revol $url = "http://" . $_SERVER['HTTP_HOST'] . ":$port/"; 581664c8b6dSFrançois Revol $icy = "icy://" . $_SERVER['HTTP_HOST'] . ":$port/"; 582664c8b6dSFrançois Revol if (!$external_only) { 583664c8b6dSFrançois Revol echo "<embed src=\"$url\" type=\"audio/mpeg\" "; 584664c8b6dSFrançois Revol echo "autoplay=\"true\" width=\"300\" height=\"50\" "; 585664c8b6dSFrançois Revol echo "controller=\"true\" align=\"right\">"; 586664c8b6dSFrançois Revol } 587664c8b6dSFrançois Revol out("You can use an external audio play at " . 588*98d26da2SFrançois Revol "<a href=\"$url\">$url</a> or <a href=\"$icy\">$icy</a>, or use " . 589*98d26da2SFrançois Revol "<a href=\"" . $_SERVER['PHP_SELF'] . "?getfile=audiopls\">this playlist</a>."); 590*98d26da2SFrançois Revol} 591*98d26da2SFrançois Revol 592*98d26da2SFrançois Revolfunction output_audio_player_file() 593*98d26da2SFrançois Revol{ 594*98d26da2SFrançois Revol if (!is_my_session_valid()) 595*98d26da2SFrançois Revol die("Bad request"); 596*98d26da2SFrançois Revol 597*98d26da2SFrançois Revol header("Content-type: audio/x-mpegurl"); 598*98d26da2SFrançois Revol //header("Content-type: text/plain"); 599*98d26da2SFrançois Revol //header('Content-Disposition: attachment; filename="onlinedemo.m3u"'); 600*98d26da2SFrançois Revol 601*98d26da2SFrançois Revol $port = audio_port(); 602*98d26da2SFrançois Revol $url = "http://" . $_SERVER['HTTP_HOST'] . ":$port/"; 603*98d26da2SFrançois Revol 604*98d26da2SFrançois Revol //echo "#EXTM3U\n"; 605*98d26da2SFrançois Revol //echo "#EXTINF:0," . PAGE_TITLE . "\n"; 606*98d26da2SFrançois Revol echo "$url\n"; 607*98d26da2SFrançois Revol //echo "\n"; 608664c8b6dSFrançois Revol} 609664c8b6dSFrançois Revol 610664c8b6dSFrançois Revolfunction output_applet_code($external_only=false) 611e8fc4975SFrançois Revol{ 612e8fc4975SFrançois Revol $w = APPLET_WIDTH; 613e8fc4975SFrançois Revol $h = APPLET_HEIGHT; 614e8fc4975SFrançois Revol $port = vnc_port(); 615e8fc4975SFrançois Revol $vncjpath = VNCJAVA_PATH; 616e8fc4975SFrançois Revol $jar = VNCJAR; 617e8fc4975SFrançois Revol $class = VNCCLASS; 618664c8b6dSFrançois Revol if ($external_only) 619664c8b6dSFrançois Revol return; 620f0cbfcafSFrançois Revol echo "<a name=\"haiku_online_applet\"></a>"; 6214720c31bSFrançois Revol echo "<center>"; 6224720c31bSFrançois Revol echo "<applet code=$class codebase=\"$vncjpath/\" "; 6234720c31bSFrançois Revol echo "archive=\"$vncjpath/$jar\" width=$w height=$h "; 6244720c31bSFrançois Revol echo "bgcolor=\"#336698\">\n"; 6254720c31bSFrançois Revol //not needed 6264720c31bSFrançois Revol //echo "<param name=\"HOST\" value=\"$HTTP_HOST\">\n"; 6274720c31bSFrançois Revol echo "<param name=\"PORT\" value=\"$port\">\n"; 6284720c31bSFrançois Revol echo "<param name=\"PASSWORD\" value=\"\">\n"; 6294720c31bSFrançois Revol //echo "<param name=\"share desktop\" value=\"no\" />"; 6304720c31bSFrançois Revol echo "<param name=\"background-color\" value=\"#336698\">\n"; 6314720c31bSFrançois Revol echo "<param name=\"foreground-color\" value=\"#ffffff\">\n"; 6324720c31bSFrançois Revol //echo "<param name=\"background\" value=\"#336698\">\n"; 6334720c31bSFrançois Revol //echo "<param name=\"foreground\" value=\"#ffffff\">\n"; 6344720c31bSFrançois Revol echo "There should be a java applet here... "; 6354720c31bSFrançois Revol echo "make sure you have a JVM and it's enabled!<br />\n"; 6364720c31bSFrançois Revol echo "If you do not have Java you can use an external VNC "; 6374720c31bSFrançois Revol echo "client as described above.\n"; 6384720c31bSFrançois Revol 6394720c31bSFrançois Revol echo "</applet>\n"; 6404720c31bSFrançois Revol echo "</center>"; 6414720c31bSFrançois Revol ob_flush(); 6424720c31bSFrançois Revol flush(); 6434720c31bSFrançois Revol // scroll to the top of the applet 6444720c31bSFrançois Revol echo "<script>\n"; 6454720c31bSFrançois Revol echo "<!--\n"; 6464720c31bSFrançois Revol echo "window.location.hash = \"haiku_online_applet\";"; 6474720c31bSFrançois Revol echo "//--></script>\n"; 6484720c31bSFrançois Revol ob_flush(); 6494720c31bSFrançois Revol flush(); 650e8fc4975SFrançois Revol} 651e8fc4975SFrançois Revol 652f0cbfcafSFrançois Revolfunction output_serial_output_code($external_only=false) 653f0cbfcafSFrançois Revol{ 654f0cbfcafSFrançois Revol if (!isset($_GET['serial'])) 655f0cbfcafSFrançois Revol return; 656f0cbfcafSFrançois Revol 657f0cbfcafSFrançois Revol $url = "telnet://" . $_SERVER['HTTP_HOST'] . ":"; 658f0cbfcafSFrançois Revol $url .= (SERIALPORTBASE + qemu_slot()) . "/"; 659f0cbfcafSFrançois Revol out("You can get serial output at <a href=\"$url\">$url</a>"); 660f0cbfcafSFrançois Revol return; 661f0cbfcafSFrançois Revol 662f0cbfcafSFrançois Revol // not really http... 663f0cbfcafSFrançois Revol $url = "http://" . $_SERVER['HTTP_HOST'] . ":"; 664f0cbfcafSFrançois Revol $url .= (SERIALPORTBASE + qemu_slot()) . "/"; 665f0cbfcafSFrançois Revol echo "<center>"; 666f0cbfcafSFrançois Revol echo "<iframe src=\"$url/\" type=\"text/plain\" width=\"100%\" "; 667f0cbfcafSFrançois Revol echo "height=\"200\"></iframe>"; 668f0cbfcafSFrançois Revol echo "</center>"; 669f0cbfcafSFrançois Revol 670f0cbfcafSFrançois Revol} 671f0cbfcafSFrançois Revol 672*98d26da2SFrançois Revol 673*98d26da2SFrançois Revolsession_start(); 674*98d26da2SFrançois Revol 675*98d26da2SFrançois Revol// parse args 676*98d26da2SFrançois Revol 677*98d26da2SFrançois Revol// output redirections... 678*98d26da2SFrançois Revolif (isset($_GET['getfile'])) { 679*98d26da2SFrançois Revol switch ($_GET['getfile']) { 680*98d26da2SFrançois Revol case "vncinfo": 681*98d26da2SFrançois Revol output_vnc_info_file(); 682*98d26da2SFrançois Revol break; 683*98d26da2SFrançois Revol case "audiopls": 684*98d26da2SFrançois Revol output_audio_player_file(); 685*98d26da2SFrançois Revol break; 686*98d26da2SFrançois Revol default: 687*98d26da2SFrançois Revol die("Bad request"); 688*98d26da2SFrançois Revol } 689*98d26da2SFrançois Revol die(); 690*98d26da2SFrançois Revol} 691*98d26da2SFrançois Revol 692*98d26da2SFrançois Revolif (isset($_GET['close'])) 693*98d26da2SFrançois Revol $closing = 1; 694*98d26da2SFrançois Revol 695*98d26da2SFrançois Revolif (isset($_GET['kill'])) 696*98d26da2SFrançois Revol $do_kill = 1; 697*98d26da2SFrançois Revol 698*98d26da2SFrançois Revolif (isset($_GET['run'])) 699*98d26da2SFrançois Revol $do_run = 1; 700*98d26da2SFrançois Revol 701*98d26da2SFrançois Revolif (isset($_GET['frame'])) {} 702*98d26da2SFrançois Revol 703*98d26da2SFrançois Revol 704*98d26da2SFrançois Revol//echo "do_run: " . $do_run . "<br>\n"; 705*98d26da2SFrançois Revol//echo "do_kill: " . $do_kill . "<br>\n"; 706*98d26da2SFrançois Revol 707*98d26da2SFrançois Revol?> 708*98d26da2SFrançois Revol<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 709*98d26da2SFrançois Revol<head> 710*98d26da2SFrançois Revol<meta name="robots" content="noindex, nofollow, noarchive" /> 711*98d26da2SFrançois Revol<title><?php echo PAGE_TITLE; ?></title> 712*98d26da2SFrançois Revol<link rel="shortcut icon" href="http://www.haiku-os.org/themes/shijin/favicon.ico" type="image/x-icon" /> 713*98d26da2SFrançois Revol<style type="text/css"> 714*98d26da2SFrançois Revol<!-- 715*98d26da2SFrançois Revol /* basic style */ 716*98d26da2SFrançois Revolbody { background-color: <?php echo BGCOLOR; ?>; } 717*98d26da2SFrançois Revola:link { color:orange; } 718*98d26da2SFrançois Revola:visited { color:darkorange; } 719*98d26da2SFrançois Revola:hover { color:pink; } 720*98d26da2SFrançois Revol.haiku_online_form { color: white; } 721*98d26da2SFrançois Revol.haiku_online_disabled { color: grey; } 722*98d26da2SFrançois Revol.haiku_online_out { color: white; } 723*98d26da2SFrançois Revol.haiku_online_debug { color: orange; } 724*98d26da2SFrançois Revol.haiku_online_error { color: red; font-weight: bold; } 725*98d26da2SFrançois Revol.haiku_online_applet { background-color: <?php echo BGCOLOR; ?>; } 726*98d26da2SFrançois Revol--> 727*98d26da2SFrançois Revol</style> 728*98d26da2SFrançois Revol<script type="text/javascript"> 729*98d26da2SFrançois Revolfunction onPageUnload() { 730*98d26da2SFrançois Revol //window.open("<?php echo $_SERVER["SCRIPT_NAME"] . "?close"; ?>", "closing", "width=100,height=30,location=no,menubar=no,toolbar=no,scrollbars=no"); 731*98d26da2SFrançois Revol} 732*98d26da2SFrançois Revol</script> 733*98d26da2SFrançois Revol</head> 734*98d26da2SFrançois Revol<?php 735*98d26da2SFrançois Revol 736*98d26da2SFrançois Revol 737*98d26da2SFrançois Revolif ($closing == 1) 738*98d26da2SFrançois Revol echo "<body>"; 739*98d26da2SFrançois Revolelse 740*98d26da2SFrançois Revol echo "<body onunload=\"onPageUnload();\">"; 741*98d26da2SFrançois Revol 742*98d26da2SFrançois Revol 743f0cbfcafSFrançois Revolout("<div style=\"text-align:right;\">Available displays: " . 7444720c31bSFrançois Revol available_qemu_slots() . "/" . total_qemu_slots() . 7454720c31bSFrançois Revol "</div>"); 7464720c31bSFrançois Revol 7474720c31bSFrançois Revol 7484720c31bSFrançois Revolprobe_keymap(); 749f0cbfcafSFrançois Revolprobe_options_form(); 7504720c31bSFrançois Revol 751e8fc4975SFrançois Revoldbg("Checking if session is running..."); 752e8fc4975SFrançois Revol 7534720c31bSFrançois Revol$qemuidx = -1; 754c6f50a6aSFrançois Revol 755e8fc4975SFrançois Revolif (is_my_session_valid()) { 7564720c31bSFrançois Revol dbg("Session running."); 757e8fc4975SFrançois Revol $qemuidx = qemu_slot(); 7584720c31bSFrançois Revol if ($do_kill) { 759e8fc4975SFrançois Revol dbg("closing..."); 7604720c31bSFrançois Revol stop_qemu(); 761e8fc4975SFrançois Revol } 7624720c31bSFrançois Revol} else if (!$do_kill && $do_run) { 7634720c31bSFrançois Revol dbg("Need to start qemu."); 7644720c31bSFrançois Revol 7654720c31bSFrançois Revol $qemuidx = start_qemu(); 766f0cbfcafSFrançois Revol //out("Waiting for vnc server..."); 767f0cbfcafSFrançois Revol //sleep(5); 7684720c31bSFrançois Revol} 7694720c31bSFrançois Revol 7704720c31bSFrançois Revol 7714720c31bSFrançois Revolif ($qemuidx >= 0 && !$do_kill) { 7724720c31bSFrançois Revol output_kill_form(); 773f0cbfcafSFrançois Revol output_serial_output_code(); 774664c8b6dSFrançois Revol output_audio_player_code(); 7754720c31bSFrançois Revol output_vnc_info(); 776f0cbfcafSFrançois Revol out("Waiting for vnc server..."); 777f0cbfcafSFrançois Revol sleep(1); 7784720c31bSFrançois Revol output_applet_code(); 7794720c31bSFrançois Revol} else { 7804720c31bSFrançois Revol output_options_form(); 781e8fc4975SFrançois Revol} 782e8fc4975SFrançois Revol 783d2bef01cSFrançois Revol//phpinfo(); 784e8fc4975SFrançois Revol 785e8fc4975SFrançois Revol?> 786e8fc4975SFrançois Revol 787e8fc4975SFrançois Revol</body> 788e8fc4975SFrançois Revol</html> 789