' ); $replace = array('&', '"', ''', '<', '>' ); $str = str_replace($search, $replace, $str); return $str; } if(isset($_REQUEST['logout'])){ session_start(); session_unset(); session_destroy(); } else { session_start(); } $mode=""; function checkvm($vmname) { $shellout = shell_exec("/usr/bin/wrap-nlvmi checkvm $vmname bla");//){ if (preg_match_all('/running/', $shellout)){ return 0; } return 1; } //read config file $configfile = new SplFileObject("/etc/nlvmi/nlvmi.conf"); while (!$configfile->eof()) { $line = $configfile->fgets(); if (!preg_match('/^#/', $line)){ if (!preg_match('/^$/', $line)){ if (preg_match('/=/', $line)){ $configparam = explode('=', $line); $p = rtrim($configparam[1]); //echo "B$p"; $config[$configparam[0]]=str_replace('"', '', $p); } } } } $file = null; //check db connection if ($config['DATABASETYPE']=="sqlite"){ $db_handle = new SQLite3($config['SQLITEFILE']); $query = "SELECT name FROM sqlite_master WHERE type='table' AND name='vms';"; $db_handle->exec($query); $result = $db_handle->query($query); $row = $result->fetchArray(); if (!$row['name']=="vms"){ echo "DB connection failed!"; exit; } } //check login $usersfound = "no"; $sql="SELECT * FROM users LIMIT 1"; $res = $db_handle->query($sql); while ($row = $res->fetchArray(SQLITE3_ASSOC)){ $usersfound="yes"; if ($_SESSION['username']=="inituser"){ session_unset(); session_destroy(); session_start(); } } if ($usersfound=="no"){ if (!isset($_POST['newusername'])){ echo "