diff --git a/index.php b/index.php deleted file mode 120000 index 4908441..0000000 --- a/index.php +++ /dev/null @@ -1 +0,0 @@ -/var/www/localhost/htdocs/nlvmi/index.php \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..be87e23 --- /dev/null +++ b/index.php @@ -0,0 +1,127 @@ +' ); + $replace = array('&', '"', ''', '<', '>' ); + + $str = str_replace($search, $replace, $str); + return $str; +} +//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; + } +} + +//form for edit and new vms +if (isset($_REQUEST['edit'])){ + $formname="editvm"; + $eid=clean($_REQUEST['edit']); + $sql="SELECT * FROM vms WHERE id='$eid'"; + $res = $db_handle->query($sql); + $editid = ""; + while ($row = $res->fetchArray(SQLITE3_ASSOC)){ + $e = $row; + } +} elseif(isset($_REQUEST['newvm'])) { + $formname="newvm"; + $editid=""; +} +//echo $e[vmname]; +if (isset($formname)){ +echo "