diff --git a/web/index.php b/web/index.php index 4b79e23..5934639 100644 --- a/web/index.php +++ b/web/index.php @@ -144,6 +144,25 @@ if (isset($_SESSION['username'])){ $sql="SELECT id,prio FROM vms WHERE vmname='$vmname' AND id='$vmid'"; $res = $db_handle->query($sql); while ($row = $res->fetchArray(SQLITE3_ASSOC)){ + $prio = $row['prio']; + $nextprio = $prio + 1; + $lastprio = "no"; + while ($lastprio == "no"){ + $sqln="SELECT id FROM vms WHERE prio='$nextprio'"; + $nid = $db_handle->query($sqln)->fetchArray(SQLITE3_ASSOC)['id']; + if($nid == ""){ + $lastprio = "yes"; + } else { + $sqlu="UPDATE vms SET prio='$prio' WHERE id='$nid'"; + if (!$db_handle->query($sqlu)){ + echo "SQL $sqlu failed!"; + exit; + } else { + $nextprio = $nextprio + 1; + $prio = $prio + 1; + } + } + } $sqld="DELETE FROM vms WHERE id='$vmid'"; if ($db_handle->query($sqld)){ echo "VM $vmname deleted!"; @@ -313,12 +332,9 @@ if (isset($_SESSION['username'])){ $sqlv .= "'$rvalue',"; } } -// $sqlc = rtrim($sqlc, ','); $sqlc.=" 'prio')"; -// $sqlv = rtrim($sqlv, ','); $sqlv.=" '$prio')"; $sql = "$sqls$sqlc$sqlv"; - //echo $sql; $res = $db_handle->exec($sql); echo "success"; exit; @@ -416,8 +432,7 @@ if (isset($_SESSION['username'])){ if (($_SESSION['username']=="inituser")||($_SESSION['isadmin']=="1")){ $sql="SELECT * FROM users"; $res = $db_handle->query($sql); - echo "
"; - //echo "
Username
Is Admin
New Password
"; + echo "
"; if ($_SESSION['username']!="inituser"){ echo "

Existing users

"; } @@ -452,7 +467,6 @@ if (isset($_SESSION['username'])){ $sql="SELECT * FROM servers"; $res = $db_handle->query($sql); echo "
"; - //echo "
Username
Is Admin
New Password
"; echo "

Existing servers

"; echo "
hostname
connectstring
VM directory
ISO directory
"; while ($row = $res->fetchArray(SQLITE3_ASSOC)){ @@ -550,7 +564,7 @@ if (isset($_SESSION['username'])){ } $server = $e['server']; for ($col=0; $col "; echo "x86_64"; echo ""; -// echo "$arrColnames[$col]
"; } elseif (preg_match('/format/', $arrColnames[$col])){ formatbuttons($arrColnames[$col], $val); } elseif ($arrColnames[$col] == "autostart"){ @@ -593,7 +606,6 @@ if (isset($_SESSION['username'])){ } echo "
autostart
"; } elseif ($arrColnames[$col] == "cdrom"){ - //echo "
"; serverdepropdown($server, $val, "cdrom"); echo "
"; } elseif (preg_match('/tapdev/', $arrColnames[$col])) { @@ -630,7 +642,7 @@ if (isset($_SESSION['username'])){ if(($mode!="newvm")&&($mode!="editvm")&&($mode!='usermgmt')){ - if ($_SESSION['isadmin']=="1"){ + if ($_SESSION['isadmin']=="1"){ $sqllimit=""; echo "
Create a new VM

"; } else { @@ -651,9 +663,7 @@ if (isset($_SESSION['username'])){ $buttonc = "btn-warning"; } $vncport = sprintf("%02d", $row['vncport']); - echo "
"; - //style=\"margin:5px;padding:5px;border:solid 1px;max-width:295px;\"> - echo "
"; + echo "

"; echo "
"; echo "
$row[vmname]
$row[server]
$row[cpus] CPUs, $row[memory] MB RAM
$row[drive1]
"; echo "
VNC port: 59$vncport
edit ";