1<?php 2 3/* 4 * haiku.php - an online Haiku demo using qemu and vnc. 5 * Copyright 2007, Francois Revol, revol@free.fr. 6 */ 7 8// parts inspired by the Free Live OS Zoo 9// http://www.oszoo.org/wiki/index.php/Free_Live_OS_Zoo 10 11 12// include local configuration that possibly overrides defines below. 13if (file_exists('haiku.conf.php')) 14 include('haiku.conf.php'); 15 16 17// name of the page 18define("PAGE_TITLE", "Haiku Online Demo"); 19 20 21// relative path to the vnc java applet jar 22// you must *copy* (apache doesn't seem to like symlinks) it there. 23 24// on debian, apt-get install vnc-java will put them in 25// /usr/share/vnc-java 26//define("VNCJAVA_PATH", "vnc-java"); 27//define("VNCJAR", "vncviewer.jar"); 28//define("VNCCLASS", "vncviewer.class"); 29 30// to use the tightvnc applet instead (supports > 8bpp): 31// on debian, apt-get install tightvnc-java will put them in 32// /usr/share/tightvnc-java 33define("VNCJAVA_PATH", "tightvnc-java"); 34define("VNCJAR", "VncViewer.jar"); 35define("VNCCLASS", "VncViewer.class"); 36 37// maximum count of qemu instances. 38define("MAX_QEMUS", 2); 39 40// size of the java applet, must match the default resolution of the image. 41//define("APPLET_WIDTH", "800"); 42//define("APPLET_HEIGHT", "600"); 43define("APPLET_WIDTH", "1024"); 44define("APPLET_HEIGHT", "768"); 45// vnc protocol base port. 46define("VNCPORTBASE", 5900); 47 48// base port for audio streams 49//define("AUDIOPORTBASE", 8080); 50define("AUDIOPORTBASE", (VNCPORTBASE + MAX_QEMUS)); 51 52// base port for serial output 53//define("SERIALPORTBASE", 9000); 54define("SERIALPORTBASE", (VNCPORTBASE + MAX_QEMUS * 2)); 55 56// timeout before the demo session is killed, as argument to /bin/sleep 57define("SESSION_TIMEOUT", "20m"); 58 59// path to qemu binary 60define("QEMU_BASE", "/usr/local"); 61define("QEMU_BIN", QEMU_BASE . "/bin/qemu"); 62define("QEMU_KEYMAPS", QEMU_BASE . "/share/qemu/keymaps"); 63// default arguments: no network, emulate tablet, readonly image file. 64define("QEMU_ARGS", "" 65 ."-daemonize " /* detach from stdin */ 66 ."-localtime " /* not UTC */ 67 ."-name '" . addslashes(PAGE_TITLE) . "' " 68 ."-monitor /dev/null " 69 ."-serial none " 70 ."-parallel none " 71 ."-net none " 72 ."-usbdevice wacom-tablet " 73 ."-vga vmware " 74 ."-snapshot "); 75 76// absolute path to the image. 77define("QEMU_IMAGE_PATH", "/home/revol/haiku.image"); 78// BAD: let's one download the image 79//define("QEMU_IMAGE_PATH", dirname($_SERVER['SCRIPT_FILENAME']) . "/haiku.image"); 80 81// max number of cpus for the VM, not more than 8 82define("QEMU_MAX_CPUS", 1); 83 84// qemu 0.8.2 needs "", qemu 0.9.1 needs ":" 85define("QEMU_VNC_PREFIX", ":"); 86 87// name of session and pid files in /tmp 88define("QEMU_SESSFILE_TMPL", "qemu-haiku-session-"); 89define("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-"); 90// name of session variable holding the qemu slot; not yet used correctly 91define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR"); 92 93 94// uncomment if you want to pass your Sonix webcam device through 95// migth need to update VID:PID 96// doesnt really work yet 97//define("QEMU_USB_PASSTHROUGH", "-usbdevice host:0c45:6005"); 98 99 100define("BGCOLOR", "#336698"); 101 102 103 104 105$vnckeymap = "en-us"; 106 107$cpucount = 1; 108 109// statics 110//$count = $_SESSION['compteur']; 111//$count = $GLOBALS['compteur']; 112$closing = 0; 113$do_kill = 0; 114$do_run = 0; 115 116function out($str) 117{ 118 echo "<div class=\"haiku_online_out\">$str</div>\n"; 119 ob_flush(); 120 flush(); 121} 122 123function dbg($str) 124{ 125 echo "<div class=\"haiku_online_debug\">$str</div>\n"; 126 ob_flush(); 127 flush(); 128} 129 130function err($str) 131{ 132 echo "<div class=\"haiku_online_error\">$str</div>\n"; 133 ob_flush(); 134 flush(); 135} 136 137function make_qemu_sessionfile_name($idx) 138{ 139 return "/tmp/" . QEMU_SESSFILE_TMPL . $idx; 140} 141 142function make_qemu_pidfile_name($idx) 143{ 144 return "/tmp/" . QEMU_PIDFILE_TMPL . $idx; 145} 146 147function find_qemu_slot() 148{ 149 for ($idx = 0; $idx < MAX_QEMUS; $idx++) { 150 $pidfile = make_qemu_pidfile_name($idx); 151 $sessfile = make_qemu_sessionfile_name($idx); 152 dbg("checking \"$pidfile\", \"$sessfile\"..."); 153 if (!file_exists($pidfile) && !file_exists($sessfile)) { 154 file_put_contents($sessfile, session_id()); 155 $sid = file_get_contents($sessfile); 156 if ($sid != session_id()) 157 continue; 158 $_SESSION[QEMU_IDX_VAR] = $idx; 159 return $idx; 160 } 161 } 162 return -1; 163} 164 165function total_qemu_slots() 166{ 167 return MAX_QEMUS; 168} 169 170 171function available_qemu_slots() 172{ 173 $count = 0; 174 for ($idx = 0; $idx < MAX_QEMUS; $idx++) { 175 $pidfile = make_qemu_pidfile_name($idx); 176 $sessfile = make_qemu_sessionfile_name($idx); 177 //dbg("checking \"$pidfile\", \"$sessfile\"..."); 178 if (!file_exists($pidfile) && !file_exists($sessfile)) 179 $count++; 180 } 181 return $count; 182} 183 184function qemu_slot() 185{ 186 return $_SESSION[QEMU_IDX_VAR]; 187} 188 189function audio_port() 190{ 191 return AUDIOPORTBASE + qemu_slot(); 192} 193 194function vnc_display() 195{ 196 return qemu_slot(); 197} 198 199function vnc_addr() 200{ 201 return $_SERVER['HTTP_HOST']; 202} 203 204function vnc_port() 205{ 206 return VNCPORTBASE + vnc_display(); 207} 208 209function vnc_addr_display() 210{ 211 return vnc_addr() . ":" . vnc_display(); 212} 213 214function vnc_url() 215{ 216 return "vnc://" . vnc_addr_display(); 217} 218 219function is_my_session_valid() 220{ 221 if (!isset($_SESSION[QEMU_IDX_VAR])) 222 return 0; 223 $idx = $_SESSION[QEMU_IDX_VAR]; 224 $sessfile = make_qemu_sessionfile_name($idx); 225 if (!file_exists($sessfile)) 226 return 0; 227 $qemusession=file_get_contents($sessfile); 228 // has expired 229 if ($qemusession != session_id()) { 230 return 0; 231 } 232 return 1; 233} 234 235 236function list_keymaps() 237{ 238 $bads = array('.', '..', 'common', 'modifiers'); 239 $keymaps = scandir(QEMU_KEYMAPS); 240 foreach ($keymaps as $key => $map) { 241 if (in_array($map, $bads)) 242 unset($keymaps[$key]); 243 } 244 return $keymaps; 245} 246 247 248function in_keymaps($keymap) 249{ 250 $keymaps = list_keymaps(); 251 252 if ($keymap == "") 253 return false; 254 if (in_array($keymap, $keymaps)) 255 return true; 256 257 return false; 258} 259 260 261function probe_keymap() 262{ 263 global $vnckeymap; 264 if (is_string($_GET['keymap']) && in_keymaps($_GET['keymap'])) 265 { 266 $vnckeymap = $_GET['keymap']; 267 dbg("Overriden keymap '" . $vnckeymap . "' in arguments."); 268 return; 269 } 270 // if the browser advertised a prefered lang... 271 if (!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) 272 return; 273 $langs = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; 274 $langs = ereg_replace(";q=[^,]*", "", $langs); 275 $langs = str_replace(" ", "", $langs); 276 $langs = split(",", $langs); 277 //print_r($langs); 278 //print_r($keymaps); 279 foreach($langs as $lang) 280 { 281 if (in_keymaps($lang)) 282 { 283 $vnckeymap = $lang; 284 dbg("Detected keymap '" . $vnckeymap . 285 "' from browser headers."); 286 return; 287 } 288 } 289} 290 291 292function probe_options_form() 293{ 294 global $cpucount; 295 $cpucount = 1; 296 if (isset($_GET['cpucount'])) 297 $cpucount = (int)$_GET['cpucount']; 298 $cpucount = max(min($cpucount, QEMU_MAX_CPUS), 1); 299 //dbg("cpucount $cpucount"); 300} 301 302 303function output_options_form() 304{ 305 global $vnckeymap; 306 $idx = qemu_slot(); 307 echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; 308 echo "<table border=\"0\" class=\"haiku_online_form\">\n"; 309 310 $keymaps = list_keymaps(); 311 echo "<tr>\n<td align=\"right\">\n"; 312 echo "Select your keymap:"; 313 echo "</td>\n<td>\n"; 314 echo "<select name=\"keymap\">"; 315 foreach ($keymaps as $keymap) { 316 echo "<option value=\"$keymap\" "; 317 if ($keymap == $vnckeymap) 318 echo "selected=\"selected\" "; 319 echo ">$keymap</option>"; 320 //echo "<option name=\"keymap\" "; 321 //echo "value=\"$keymap\">" . locale_get_display_name($keymap); 322 //echo "</option>"; 323 } 324 echo "</select>"; 325 echo "</td>\n</tr>\n"; 326 327 328 $modes = array("1024x768"/*, "800x600"*/); 329 echo "<tr "; 330 if (count($modes) < 2) 331 echo "class=\"haiku_online_disabled\""; 332 echo ">\n"; 333 echo "<td align=\"right\">\n"; 334 echo "Select display size:"; 335 echo "</td>\n<td>\n"; 336 echo "<select name=\"videomode\" "; 337 if (count($modes) < 2) 338 echo "disabled=\"disabled\""; 339 echo ">"; 340 foreach ($modes as $mode) { 341 echo "<option value=\"$mode\" "; 342 if ($mode == $videomode) 343 echo "selected=\"selected\" "; 344 echo ">$mode</option>"; 345 } 346 echo "</select>"; 347 echo "</td>\n</tr>\n"; 348 349 350 echo "<tr "; 351 if (QEMU_MAX_CPUS < 2) 352 echo "class=\"haiku_online_disabled\""; 353 echo ">\n"; 354 echo "<td align=\"right\">\n"; 355 echo "Select cpu count:"; 356 echo "</td>\n<td>\n"; 357 echo "<select name=\"cpucount\" "; 358 if (QEMU_MAX_CPUS < 2) 359 echo "disabled=\"disabled\""; 360 echo ">"; 361 for ($ncpu = 1; $ncpu <= QEMU_MAX_CPUS; $ncpu++) { 362 echo "<option value=\"$ncpu\" "; 363 if ($ncpu == 1) 364 echo "selected=\"selected\" "; 365 echo ">$ncpu</option>"; 366 } 367 echo "</select>"; 368 echo "</td>\n</tr>\n"; 369 370 371 $enable_sound = 0; 372 echo "<tr "; 373 if (!$enable_sound) 374 echo "class=\"haiku_online_disabled\""; 375 echo ">\n"; 376 echo "<td align=\"right\">\n"; 377 echo "Check to enable sound:"; 378 echo "</td>\n<td>\n"; 379 echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\" "; 380 echo "value=\"1\" "; 381 if ($enable_sound) { 382 echo "checked=\"checked\" /"; 383 } else 384 echo "disabled=\"disabled\" /"; 385 echo "><label for=\"sound_cb\">Sound</label>"; 386 echo "</td>\n</tr>\n"; 387 388 $enable_serial = 1; 389 echo "<tr "; 390 if (!$enable_serial) 391 echo "class=\"haiku_online_disabled\""; 392 echo ">\n"; 393 echo "<td align=\"right\">\n"; 394 echo "Check to enable serial output:"; 395 echo "</td>\n<td>\n"; 396 echo "<input type=\"checkbox\" name=\"serial\" id=\"serial_cb\" "; 397 echo "value=\"1\" "/*"disabled "*/; 398 if ($enable_serial) { 399 //echo "checked "; 400 } 401 echo "/><label for=\"serial_cb\">Serial</label>"; 402 echo "</td>\n</tr>\n"; 403 404 if (defined("QEMU_USB_PASSTHROUGH")) { 405 406 $enable_webcam = 1; 407 echo "<tr "; 408 if (!$enable_webcam) 409 echo "class=\"haiku_online_disabled\""; 410 echo ">\n"; 411 echo "<td align=\"right\">\n"; 412 echo "Check to enable webcam:"; 413 echo "</td>\n<td>\n"; 414 echo "<input type=\"checkbox\" name=\"webcam\" id=\"webcam_cb\" "; 415 echo "value=\"1\" "/*"disabled "*/; 416 if ($enable_webcam) { 417 //echo "checked "; 418 } 419 echo "/><label for=\"webcam_cb\">Webcam</label>"; 420 echo "</td>\n</tr>\n"; 421 } 422 /* 423 echo "<tr>\n<td align=\"right\">\n"; 424 //out("Click here to enable sound:"); 425 echo "</td>\n<td>\n"; 426 echo "</td>\n</tr>\n"; 427 428 echo "<tr>\n<td align=\"right\">\n"; 429 //out("Click here to enable sound:"); 430 echo "</td>\n<td>\n"; 431 echo "</td>\n</tr>\n"; 432 */ 433 434 echo "<tr>\n<td align=\"right\">\n"; 435 echo "Click here to start the session:"; 436 echo "</td>\n<td>\n"; 437 echo "<input type=\"submit\" name=\"run\" "; 438 echo "value=\"Start!\" />"; 439 echo "</td>\n</tr>\n"; 440 441 echo "</table>\n"; 442 echo "</form>\n"; 443 out("NOTE: You will need a Java-enabled browser to display the VNC " . 444 "Applet needed by this demo."); 445 out("You can however use instead an external <a " . 446 "href=\"http://fr.wikipedia.org/wiki/Virtual_Network_Computing\"" . 447 ">VNC viewer</a>."); 448 ob_flush(); 449 flush(); 450} 451 452function output_kill_form() 453{ 454 echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; 455 echo "<table border=\"0\" class=\"haiku_online_form\">\n"; 456 echo "<tr>\n"; 457 echo "<td>\n"; 458 echo "Click here to kill the session:"; 459 echo "</td>\n"; 460 echo "<td>\n"; 461 echo "<input type=\"submit\" name=\"kill\" "; 462 echo "value=\"Terminate\"/>"; 463 echo "</td>\n"; 464 echo "</tr>\n"; 465 echo "</table>\n"; 466 echo "</form>\n"; 467 ob_flush(); 468 flush(); 469} 470 471 472function start_qemu() 473{ 474 global $vnckeymap; 475 global $cpucount; 476 $idx = find_qemu_slot(); 477 if ($idx < 0) { 478 err("No available qemu slot, please try later."); 479 return $idx; 480 } 481 $pidfile = make_qemu_pidfile_name($idx); 482 $cmd = QEMU_BIN . " " . QEMU_ARGS; 483 if ($cpucount > 1) 484 $cmd .= " -smp " . $cpucount; 485 if (isset($_GET['serial'])) { 486 $cmd .= " -serial telnet::"; 487 $cmd .= (SERIALPORTBASE + qemu_slot()); 488 $cmd .= ",server,nowait,nodelay"; 489 } 490 if (isset($_GET['webcam']) && defined("QEMU_USB_PASSTHROUGH")) { 491 $cmd .= " " . QEMU_USB_PASSTHROUGH; 492 } 493 $cmd .= " -k " . $vnckeymap . 494 " -vnc " . QEMU_VNC_PREFIX . vnc_display() . 495 " -pidfile " . $pidfile . 496 " " . QEMU_IMAGE_PATH; 497 498 if (file_exists($pidfile)) 499 unlink($pidfile); 500 dbg("Starting <tt>" . $cmd . "</tt>..."); 501 502 $descriptorspec = array( 503 // 0 => array("pipe", "r"), // stdin 504 // 1 => array("pipe", "w"), // stdout 505 // 2 => array("pipe", "w") // stderr 506 ); 507 //$cmd="/bin/ls"; 508 //passthru($cmd, $ret); 509 //dbg("ret=$ret"); 510 $cmd .= " &"; 511 $process = proc_open($cmd, $descriptorspec, $pipes); 512 sleep(1); 513 proc_close($process); 514 515 dbg("Started QEMU."); 516 $sessfile = make_qemu_sessionfile_name($idx); 517 $cmd = "(PID=`cat " . $pidfile . "`; " . 518 "sleep " . SESSION_TIMEOUT . "; " . 519 "kill -9 \$PID && " . 520 "rm " . $pidfile . " " . $sessfile . ") &"; 521 522 $process = proc_open($cmd, $descriptorspec, $wkpipes); 523 sleep(1); 524 proc_close($process); 525 526 dbg("Started timed kill."); 527 dbg("Ready for a " . SESSION_TIMEOUT . " session."); 528} 529 530function stop_qemu() 531{ 532 $qemuidx = qemu_slot(); 533 $pidfile = make_qemu_pidfile_name($qemuidx); 534 if (file_exists($pidfile)) { 535 $pid = file_get_contents($pidfile); 536 //out("PID:" . $pid); 537 system("/bin/kill -TERM " . $pid); 538 unlink($pidfile); 539 } 540 $sessionfile = make_qemu_sessionfile_name($qemuidx); 541 if (file_exists($sessionfile)) { 542 unlink($sessionfile); 543 } 544 unset($_SESSION[QEMU_IDX_VAR]); 545 546 out("reloading..."); 547 sleep(1); 548 echo "<script>\n"; 549 echo "<!--\n"; 550 echo "window.location = \"" . $_SERVER['PHP_SELF'] . "\";\n"; 551 echo "//--></script>\n"; 552 out("Click <a href=\"" . $_SERVER['PHP_SELF'] . 553 "\">here</a> to reload the page."); 554} 555 556function output_vnc_info() 557{ 558 out("You can use an external VNC client at " . 559 "<a href=\"vnc://" . vnc_addr_display() . "\">" . 560 "vnc://" . vnc_addr_display() . "</a> " . 561 "or open <a href=\"" . $_SERVER['PHP_SELF'] . "?getfile=vncinfo&slot=" . vnc_display() . "\">this file</a>, " . 562 "or enter <tt>" . vnc_addr_display() . "</tt> in your " . 563 "<a href=\"http://fr.wikipedia.org/wiki/Virtual_Network_" . 564 "Computing\"" . 565 ">VNC viewer</a>."); 566 //echo "<br />\n"; 567} 568 569function output_vnc_info_file() 570{ 571 if (!is_my_session_valid()) 572 die("Bad request"); 573 574 header("Content-type: application/x-vnc"); 575 header('Content-Disposition: attachment; filename="onlinedemo.vnc"'); 576 577 echo "[connection]\n"; 578 echo "host=" . vnc_addr() . "\n"; 579 echo "port=" . vnc_display() . "\n"; 580 //echo "password=XXX\n"; 581 //echo "[options]\n"; 582 // cf. http://www.realvnc.com/pipermail/vnc-list/1999-December/011086.html 583 // cf. http://www.tek-tips.com/viewthread.cfm?qid=1173303&page=1 584 //echo "\n"; 585} 586 587function output_audio_player_code($external_only=false) 588{ 589 if (true) 590 return; 591 592 $port = audio_port(); 593 $url = "http://" . $_SERVER['HTTP_HOST'] . ":$port/"; 594 $icy = "icy://" . $_SERVER['HTTP_HOST'] . ":$port/"; 595 if (!$external_only) { 596 echo "<embed src=\"$url\" type=\"audio/mpeg\" "; 597 echo "autoplay=\"true\" width=\"300\" height=\"50\" "; 598 echo "controller=\"true\" align=\"right\">"; 599 } 600 out("You can use an external audio play at " . 601 "<a href=\"$url\">$url</a> or <a href=\"$icy\">$icy</a>, or use " . 602 "<a href=\"" . $_SERVER['PHP_SELF'] . "?getfile=audiopls\">this playlist</a>."); 603} 604 605function output_audio_player_file() 606{ 607 if (!is_my_session_valid()) 608 die("Bad request"); 609 610 header("Content-type: audio/x-mpegurl"); 611 //header("Content-type: text/plain"); 612 //header('Content-Disposition: attachment; filename="onlinedemo.m3u"'); 613 614 $port = audio_port(); 615 $url = "http://" . $_SERVER['HTTP_HOST'] . ":$port/"; 616 617 //echo "#EXTM3U\n"; 618 //echo "#EXTINF:0," . PAGE_TITLE . "\n"; 619 echo "$url\n"; 620 //echo "\n"; 621} 622 623function output_applet_code($external_only=false) 624{ 625 $w = APPLET_WIDTH; 626 $h = APPLET_HEIGHT; 627 $port = vnc_port(); 628 $vncjpath = VNCJAVA_PATH; 629 $jar = VNCJAR; 630 $class = VNCCLASS; 631 if ($external_only) 632 return; 633 echo "<a name=\"haiku_online_applet\"></a>"; 634 echo "<center>"; 635 echo "<applet code=$class codebase=\"$vncjpath/\" "; 636 echo "archive=\"$vncjpath/$jar\" width=$w height=$h "; 637 echo "bgcolor=\"#336698\">\n"; 638 //not needed 639 //echo "<param name=\"HOST\" value=\"$HTTP_HOST\">\n"; 640 echo "<param name=\"PORT\" value=\"$port\">\n"; 641 echo "<param name=\"PASSWORD\" value=\"\">\n"; 642 //echo "<param name=\"share desktop\" value=\"no\" />"; 643 echo "<param name=\"background-color\" value=\"#336698\">\n"; 644 echo "<param name=\"foreground-color\" value=\"#ffffff\">\n"; 645 //echo "<param name=\"background\" value=\"#336698\">\n"; 646 //echo "<param name=\"foreground\" value=\"#ffffff\">\n"; 647 echo "There should be a java applet here... "; 648 echo "make sure you have a JVM and it's enabled!<br />\n"; 649 echo "If you do not have Java you can use an external VNC "; 650 echo "client as described above.\n"; 651 652 echo "</applet>\n"; 653 echo "</center>"; 654 ob_flush(); 655 flush(); 656 // scroll to the top of the applet 657 echo "<script>\n"; 658 echo "<!--\n"; 659 echo "scrollToAnchor(\"haiku_online_applet\");"; 660 echo "//--></script>\n"; 661 ob_flush(); 662 flush(); 663} 664 665function output_serial_output_code($external_only=false) 666{ 667 if (!isset($_GET['serial'])) 668 return; 669 670 $url = "telnet://" . $_SERVER['HTTP_HOST'] . ":"; 671 $url .= (SERIALPORTBASE + qemu_slot()) . "/"; 672 out("You can get serial output at <a href=\"$url\">$url</a>"); 673 return; 674 675 // not really http... 676 $url = "http://" . $_SERVER['HTTP_HOST'] . ":"; 677 $url .= (SERIALPORTBASE + qemu_slot()) . "/"; 678 echo "<center>"; 679 echo "<iframe src=\"$url/\" type=\"text/plain\" width=\"100%\" "; 680 echo "height=\"200\"></iframe>"; 681 echo "</center>"; 682 683} 684 685 686session_start(); 687 688// parse args 689 690// output redirections... 691if (isset($_GET['getfile'])) { 692 switch ($_GET['getfile']) { 693 case "vncinfo": 694 output_vnc_info_file(); 695 break; 696 case "audiopls": 697 output_audio_player_file(); 698 break; 699 default: 700 die("Bad request"); 701 } 702 die(); 703} 704 705if (isset($_GET['close'])) 706 $closing = 1; 707 708if (isset($_GET['kill'])) 709 $do_kill = 1; 710 711if (isset($_GET['run'])) 712 $do_run = 1; 713 714if (isset($_GET['frame'])) {} 715 716 717//echo "do_run: " . $do_run . "<br>\n"; 718//echo "do_kill: " . $do_kill . "<br>\n"; 719 720?> 721<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 722<head> 723<meta name="robots" content="noindex, nofollow, noarchive" /> 724<title><?php echo PAGE_TITLE; ?></title> 725<link rel="shortcut icon" href="http://www.haiku-os.org/themes/shijin/favicon.ico" type="image/x-icon" /> 726<style type="text/css"> 727<!-- 728 /* basic style */ 729body { background-color: <?php echo BGCOLOR; ?>; } 730a:link { color:orange; } 731a:visited { color:darkorange; } 732a:hover { color:pink; } 733.haiku_online_form { color: white; } 734.haiku_online_disabled { color: grey; } 735.haiku_online_out { color: white; } 736.haiku_online_debug { color: orange; } 737.haiku_online_error { color: red; font-weight: bold; } 738.haiku_online_applet { background-color: <?php echo BGCOLOR; ?>; } 739--> 740</style> 741<script type="text/javascript"> 742function onPageUnload() { 743 //window.open("<?php echo $_SERVER["SCRIPT_NAME"] . "?close"; ?>", "closing", "width=100,height=30,location=no,menubar=no,toolbar=no,scrollbars=no"); 744} 745 746function scrollToAnchor(anchor) { 747 var a = document.anchors[anchor]; 748 if (a) { 749 if (a.scrollIntoView) 750 a.scrollIntoView(true); 751 else if (a.focus) 752 a.focus(); 753 } else 754 window.location.hash = anchor; 755} 756</script> 757</head> 758<?php 759 760 761if ($closing == 1) 762 echo "<body>"; 763else 764 echo "<body onunload=\"onPageUnload();\">"; 765 766 767out("<div style=\"text-align:right;\">Available displays: " . 768 available_qemu_slots() . "/" . total_qemu_slots() . 769 "</div>"); 770 771 772probe_keymap(); 773probe_options_form(); 774 775dbg("Checking if session is running..."); 776 777$qemuidx = -1; 778 779if (is_my_session_valid()) { 780 dbg("Session running."); 781 $qemuidx = qemu_slot(); 782 if ($do_kill) { 783 dbg("closing..."); 784 stop_qemu(); 785 } 786} else if (!$do_kill && $do_run) { 787 dbg("Need to start qemu."); 788 789 $qemuidx = start_qemu(); 790 //out("Waiting for vnc server..."); 791 //sleep(5); 792} 793 794 795if ($qemuidx >= 0 && !$do_kill) { 796 output_kill_form(); 797 output_serial_output_code(); 798 output_audio_player_code(); 799 output_vnc_info(); 800 out("Waiting for vnc server..."); 801 sleep(1); 802 output_applet_code(); 803} else { 804 output_options_form(); 805} 806 807//phpinfo(); 808 809?> 810 811</body> 812</html> 813