diff --git a/web/index.php b/web/index.php index c63472b..25eacd7 100644 --- a/web/index.php +++ b/web/index.php @@ -63,15 +63,18 @@ while ($row = $res->fetchArray(SQLITE3_ASSOC)){ session_unset(); session_destroy(); session_start(); + echo "killed inituser!"; } } + if ($usersfound=="no"){ + $_SESSION['username']="inituser"; + $_SESSION['isadmin']="1"; if (!isset($_POST['newusername'])){ echo "

You have no users in the datbase!


"; // echo "Aborting...."; // exit; - $_SESSION['username']="inituser"; - $_SESSION['isadmin']="1"; + $mode="usermgmt"; } } elseif ((isset($_POST['login']))&&(isset($_POST['username']))&&(isset($_POST['password']))){ @@ -84,10 +87,11 @@ if ($usersfound=="no"){ $_SESSION['username']=$user; $_SESSION['isadmin']=$row['admin']; } else { - echo "Password not correct! $pass"; + echo "Password not correct!"; } } } + if (isset($_SESSION['username'])){ if ((isset($_POST['deletevm']))&&(isset($_POST['deletename']))){ if($_SESSION['isadmin']!=1){ @@ -162,12 +166,14 @@ if (isset($_SESSION['username'])){ //usermanagement if ((isset($_POST['usermgmt']))||($mode=="usermgmt")){ $mode="usermgmt"; - if (($_SESSEION['username']=="inituser")||($_SESSION['isadmin']=="1")){ + if (($_SESSION['username']=="inituser")||($_SESSION['isadmin']=="1")){ $sql="SELECT * FROM users"; $res = $db_handle->query($sql); echo "
"; //echo "
Username
Is Admin
New Password
"; - echo "

Existing users

"; + if ($_SESSION['username']!="inituser"){ + echo "

Existing users

"; + } while ($row = $res->fetchArray(SQLITE3_ASSOC)){ echo "
"; if ($row['admin']=="1"){ @@ -196,7 +202,11 @@ if (isset($_SESSION['username'])){ //start vm if (isset($_REQUEST['start'])){ $vmname = clean($_REQUEST['start']); - $sql="SELECT * FROM vms WHERE vmname='$vmname'"; + $sqllimit=""; + if($_SESSION['isadmin']!="1"){ + $sqllimit="WHERE username='$_SESSION[username]'"; + } + $sql="SELECT * FROM vms WHERE vmname='$vmname' $sqllimit"; $res = $db_handle->query($sql); while ($row = $res->fetchArray(SQLITE3_ASSOC)){ $shellout = shell_exec("/usr/bin/wrap-nlvmi start $vmname bla"); @@ -205,7 +215,10 @@ if (isset($_SESSION['username'])){ } if (isset($_REQUEST['stop'])){ $vmname = clean($_REQUEST['stop']); - $sql="SELECT * FROM vms WHERE vmname='$vmname'"; + if($_SESSION['isadmin']!="1"){ + $sqllimit="WHERE username='$_SESSION[username]'"; + } + $sql="SELECT * FROM vms WHERE vmname='$vmname' $sqllimit"; $res = $db_handle->query($sql); while ($row = $res->fetchArray(SQLITE3_ASSOC)){ if(checkvm($vmname)){ @@ -331,8 +344,9 @@ if (isset($_SESSION['username'])){ $sqlv = rtrim($sqlv, ','); $sqlv.=")"; $sql = "$sqls$sqlc$sqlv"; - echo $sql; + //echo $sql; $result = $db_handle->exec($sql); + $mode=""; } elseif ($_REQUEST['mode']=="editvm"){ $mode="editvm"; $sql="UPDATE vms SET "; @@ -372,13 +386,14 @@ if (isset($_SESSION['username'])){ $button = "stop"; $buttonc = "btn-warning"; } - echo "
$row[vmname]
edit "; + echo "
$row[vmname]
edit "; echo "$button "; echo " "; $server = gethostname(); if (preg_match('/stop/', $button)) { echo "VNC
"; } + echo "
"; } } echo "
";