Location: PHPKode > projects > Open QEMU Manager > openqemumanager/index.php
<?php
include_once "lib/db.inc.php";
include_once "lib/users.inc.php";
include_once "lib/forms.inc.php";
include_once "lib/actions.inc.php";
include_once "lib/vm.inc.php";
include_once "lib/defines.inc.php";

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
echo "<head>\n";
echo "	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
echo "	<title>Open QEMU Manager</title>\n";
echo "	<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" charset=\"utf-8\" />\n";
echo "</head>\n";
echo "<body>\n";

$a_locale=explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); 
switch(substr($a_locale[0],0,2)) {
 case "it":
   $locale="it_IT";
   break;
}
setlocale(LC_ALL, "$locale");
bindtextdomain("OQM", "./locales");
textdomain("OQM");
$vm_id=$_GET['vm_id'];
$page=$_GET['page'];
$action=$_GET['action'];
$section=$_GET['section'];

$errors="";
$warnings="";
$oks="";

switch($page) {
 case "hardware":
   if ($vm_id!="" && isAdmin())
     execHardwareForm($vm_id);
   break;
 case "drives":
   if ($vm_id!="")
     execDrivesForm($vm_id);
   break;
 case "network":
   if ($vm_id!="" && isAdmin())
     execNetworkForm($vm_id);
   break;
 case "advanced":
   if ($vm_id!="" && isAdmin())
     execAdvancedForm($vm_id);
   break;
 case "path":
   if (isAdmin()) execPathForm();
   break;
 case "networking":
   if (isAdmin()) execNetworkingForm();
   break;
 case "debug":
   if (isAdmin()) execDebugForm();
   break;
 case "vm":
   if (isAdmin()) execVMForm();
   break;
 case "vdisk":
   if (isAdmin()) execVDiskForm();
   break;
 case "vcdrom":
   if (isAdmin()) execVCDROMForm();
   break;
 case "users":
   if (isAdmin()) execUsersForm();
   break;
 default:
 case "status":
   if ($vm_id!="")
     execStatusForm($vm_id);
   break;
 }


switch($action) {
 case "run":
   runVirtualMachine($vm_id);
   break;
 case "stop":
   stopVirtualMachine($vm_id);
   break;
 }

if ($errors<>"") {
  echo "<div class id=\"errors\">\n";
  echo $errors;
  echo "</div>\n";
 } else if ($warnings<>"") {
  echo "<div class id=\"warnings\">\n";
  echo $warnings;
  echo "</div>\n";
 } else if ($oks<>"") {
  echo "<div class id=\"oks\">\n";
  echo $oks;
  echo "</div>\n";
 } else {
  echo "<div class>\n";
  echo "&nbsp;";
  echo "</div>\n";
 }

echo "<div id=\"wrapper\">\n";
echo "  <div id=\"title\">\n";
echo "    <h1>Open QEMU Manager</h1>\n";
echo "  </div>\n";
echo "  <div id=\"nav\">";
if ($section=="vm" || $section=="") {
  echo "    <a href=\"?section=vm&page=status&vm_id=".$vm_id."\">"._("Status")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=vm&page=hardware&vm_id=".$vm_id."\">"._("Hardware")."</a>\n";
  echo "    <a href=\"?section=vm&page=drives&vm_id=".$vm_id."\">"._("Drives")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=vm&page=network&vm_id=".$vm_id."\">"._("Network")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=vm&page=advanced&vm_id=".$vm_id."\">"._("Advanced")."</a>\n";
}
if ($section=="advanced") {
  if (isAdmin()) echo "    <a href=\"?section=advanced&page=path\">"._("Path")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=advanced&page=networking\">"._("Networking")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=advanced&page=debug\">"._("Debug")."</a>\n";
}
if ($section=="machine") {
  if (isAdmin()) echo "    <a href=\"?section=machine&page=vm\">"._("VM")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=machine&page=vdisk\">"._("VDisk")."</a>\n";
  if (isAdmin()) echo "    <a href=\"?section=machine&page=vcdrom\">"._("VCDRom")."</a>\n";
}
if ($section=="users") {
  if (isAdmin()) echo "    <a href=\"?section=users&page=users\">"._("Users")."</a>\n";
}
echo "  </div>\n";
echo "  <div id=\"body\">\n";
echo "    <div id=\"body-top\">\n";
echo "      <div id=\"body-top-2\">\n";
echo "      </div>\n";
echo "      <div id=\"body-bot\">\n";
echo "        <div id=\"welcome\">\n";
echo "          <h2>"._("Running Machine")."</h2>\n";
showRunningMachine($vm_id,$section,$page);
echo "          <h2>"._("Stopped Machine")."</h2>\n";
showStoppedMachine($vm_id,$section,$page);
if (isAdmin()) {
  echo "          <h2>".("Setup")."</h2>\n";
  showSetup($section,$page);
}
echo "        <br><br><br>";
echo "        </div>\n";
echo "        <div id=\"content\">\n";

switch($page) {
 case "hardware":
   if ($vm_id!="" && isAdmin())
     showHardwareForm($vm_id);
   break;
 case "drives":
   if ($vm_id!="")
     showDrivesForm($vm_id);
   break;
 case "network":
   if ($vm_id!="" && isAdmin())
     showNetworkForm($vm_id);
   break;
 case "advanced":
   if ($vm_id!="" && isAdmin())
     showAdvancedForm($vm_id);
   break;
 case "path":
   if (isAdmin()) showPathForm();
   break;
 case "networking":
   if (isAdmin()) showNetworkingForm();
   break;
 case "debug":
   if (isAdmin()) showDebugForm();
   break;
 case "vm":
   if (isAdmin()) showVMForm();
   break;
 case "vdisk":
   if (isAdmin()) showVDiskForm();
   break;
 case "vcdrom":
   if (isAdmin()) showVCDROMForm();
   break;
 case "users":
   if (isAdmin()) showUsersForm();
   break;
 default:
 case "status":
   if ($vm_id!="")
     showStatusForm($vm_id);
   break;
 
 }

echo "          <div class=\"clear-flat\">\n";
echo "          </div>\n";
echo "        </div>\n";
echo "        <div class=\"clear\">\n";
echo "        </div>\n";
echo "      </div>\n";
echo "    </div>\n";
echo "  </div>\n";
echo "  <div id=\"footer\">Version 0.4\n";
echo "  <!-- Template offered by <a href=\"http://www.freecsstemplates.org/\">http://www.freecsstemplates.org/ -->";
echo "	</div>\n";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
Return current item: Open QEMU Manager