";
}
//read config file
@@ -96,9 +94,6 @@ if ($usersfound=="no"){
$_SESSION['isadmin']="1";
if (!isset($_POST['newusername'])){
echo "
You have no users in the datbase!
";
-// echo "Aborting....";
-// exit;
-
$mode="usermgmt";
}
} elseif ((isset($_POST['login']))&&(isset($_POST['username']))&&(isset($_POST['password']))){
@@ -198,7 +193,41 @@ if (isset($_SESSION['username'])){
}
}
}
-
+//insert new server in db
+ if(isset($_POST['newservername'])){
+ if($_SESSION['isadmin']!=1){
+ echo "you are not allowed to add servers!";
+ } else {
+ $newservername = clean($_POST['newhostname']);
+ $connectstring = clean($_POST['connectstring']);
+ $vmdirectory = clean($_POST['vmdirectory']);
+ $isodirectory = clean($_POST['isodirectory']);
+ $sqlu="INSERT INTO servers ('hostname','connectstring','vmdirectory','isodirectory') VALUES('$newservername',$connectstring','$vmdirectory','$isodirectory')";
+ $res = $db_handle->query($sqlu);
+ echo "success";
+ exit;
+ }
+ }
+//update server in db
+ if(isset($_POST['changehostname'])){
+ if($_SESSION['isadmin']!=1){
+ echo "you are not allowed to change servers!";
+ } else {
+ $newservername = clean($_POST['changehostname']);
+ $connectstring = clean($_POST['connectstring']);
+ $vmdirectory = clean($_POST['vmdirectory']);
+ $isodirectory = clean($_POST['isodirectory']);
+ $changeid = clean($_POST['changeid']);
+ $sql="UPDATE servers SET hostname='$newservername', connectstring='$connectstring', vmdirectory='$vmdirectory', isodirectory='$isodirectory' where id='$changeid'";
+ if($db_handle->query($sql)){
+ echo "success";
+ exit;
+ } else {
+ echo "$sql";
+ exit;
+ }
+ }
+ }
//insert or update vm in db
if(isset($_REQUEST['mode'])){
if($_REQUEST['mode']=="newvm"){
@@ -232,10 +261,7 @@ if (isset($_SESSION['username'])){
$res = $db_handle->exec($sql);
echo "success";
exit;
-
-// $mode="";
} elseif ($_REQUEST['mode']=="editvm"){
-// $mode="";
$sql="UPDATE vms SET ";
foreach(array_keys($_REQUEST) as $rkey){
if (($rkey!="mode")&&($rkey!="editid")&&($rkey!="rand")){
@@ -256,18 +282,16 @@ if (isset($_SESSION['username'])){
$sql = rtrim($sql, ',');
$eid=clean($_REQUEST['editid']);
$sql .= " WHERE id='$eid'";
-// if($db_handle->exec($sql)){
$res = $db_handle->exec($sql);
echo "success";
- //echo $res;
exit;
- //}
}
}
if (isset($_POST['serverbuttoni'])){
serverdepropdown($_POST['serverbuttoni'], "no cdrom", 'cdrom');
exit;
- } elseif (isset($_POST['serverbuttona'])){
+//not nice, i know... Will do a function later...
+ } elseif (isset($_POST['serverbuttona'])){
serverdepropdown($_POST['serverbuttona'], "no drive1", 'drive1');
echo "
format1
";
echo "
";
@@ -298,6 +322,7 @@ if (isset($_SESSION['username'])){
echo "
";
exit;
}
+
//ajax queries are all done, time for the header
include('header.php');
@@ -337,6 +362,31 @@ if (isset($_SESSION['username'])){
}
+//servermanagement
+ if (isset($_POST['servermgmt'])){
+ $mode="servermgmt";
+ if ($_SESSION['isadmin']=="1"){
+ $sql="SELECT * FROM servers";
+ $res = $db_handle->query($sql);
+ echo "";
+ //echo "