bootoption fix

This commit is contained in:
mad 2018-08-13 20:11:24 +02:00
parent f4d6a616fb
commit 3048e4e9a2
1 changed files with 59 additions and 56 deletions

View File

@ -44,6 +44,7 @@ if ($config['DATABASETYPE']=="sqlite"){
exit; exit;
} }
} }
if ((isset($_POST['deletevm']))&&(isset($_POST['deletename']))){ if ((isset($_POST['deletevm']))&&(isset($_POST['deletename']))){
$vmname = clean($_POST['deletename']); $vmname = clean($_POST['deletename']);
$vmid = clean($_POST['deletevm']); $vmid = clean($_POST['deletevm']);
@ -99,73 +100,75 @@ if (isset($_REQUEST['edit'])){
} }
if (isset($formname)){ if (isset($formname)){
echo "<h2>$formname</h2></br>"; echo "<h2>$formname</h2></br>";
echo "<form name=$formname action=? method=post>"; echo "<form name=$formname action=? method=post>";
$res = $db_handle->query('PRAGMA table_info(vms)'); $res = $db_handle->query('PRAGMA table_info(vms)');
while ($col = $res->fetchArray(SQLITE3_ASSOC)) { while ($col = $res->fetchArray(SQLITE3_ASSOC)) {
$arrColnames[]=$col['name']; $arrColnames[]=$col['name'];
} }
for ($col=0; $col <count($arrColnames); $col++){ for ($col=0; $col <count($arrColnames); $col++){
if ($arrColnames[$col]!="id"){ if ($arrColnames[$col]!="id"){
if (isset($e[$arrColnames[$col]])){ if (isset($e[$arrColnames[$col]])){
$val = $e[$arrColnames[$col]]; $val = $e[$arrColnames[$col]];
} else { } else {
$val = ""; $val = "";
} }
if ($arrColnames[$col] == "bootoption"){ if ($arrColnames[$col] == "bootoption"){
echo "<div class=row><div class=col-md-1 style=text-align:right>bootoption</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=bootoptionbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>C</button>"; if($val=="") {
echo "<div class=dropdown-menu aria-labelledby=bootoptionbutton>"; $val="c";
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','c')\">c</a>"; }
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','d')\">d</a>"; echo "<div class=row><div class=col-md-1 style=text-align:right>bootoption</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=bootoptionbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
echo "</div></div></div></div><input type=hidden id=bootoptionbuttonh name=bootoption value=c>"; echo "<div class=dropdown-menu aria-labelledby=bootoptionbutton>";
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','c')\">c</a>";
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','d')\">d</a>";
echo "</div></div></div></div><input type=hidden id=bootoptionbuttonh name=bootoption value=c>";
// echo "$arrColnames[$col] <select name=bootoption><option value=c>C</option><option value=d>D</option></select></br>"; // echo "$arrColnames[$col] <select name=bootoption><option value=c>C</option><option value=d>D</option></select></br>";
} elseif ($arrColnames[$col] == "arch"){ } elseif ($arrColnames[$col] == "arch"){
echo "<div class=row><div class=col-md-1 style=text-align:right>arch</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=archbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>x86_64</button>"; echo "<div class=row><div class=col-md-1 style=text-align:right>arch</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=archbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>x86_64</button>";
echo "<div class=dropdown-menu aria-labelledby=archbutton>"; echo "<div class=dropdown-menu aria-labelledby=archbutton>";
echo "<a class=dropdown-item href=\"javascript:dropdown('archbutton','x86_64')\">x86_64</a>"; echo "<a class=dropdown-item href=\"javascript:dropdown('archbutton','x86_64')\">x86_64</a>";
echo "</div></div></div></div><input type=hidden id=archbuttonh name=arch value=x86_64>"; echo "</div></div></div></div><input type=hidden id=archbuttonh name=arch value=x86_64>";
// echo "$arrColnames[$col] <select name=arch><option value=qemu-system-x86_64>x86_64</option></select></br>"; // echo "$arrColnames[$col] <select name=arch><option value=qemu-system-x86_64>x86_64</option></select></br>";
} elseif ($arrColnames[$col] == "cdrom"){ } elseif ($arrColnames[$col] == "cdrom"){
echo "<div class=row><div class=col-md-1 style=text-align:right>cdrom</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=cdrombutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>"; echo "<div class=row><div class=col-md-1 style=text-align:right>cdrom</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=cdrombutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
echo "<div class=dropdown-menu aria-labelledby=cdrombutton>"; echo "<div class=dropdown-menu aria-labelledby=cdrombutton>";
$isodirs = explode('|', $config['ISODIRECTORY']); $isodirs = explode('|', $config['ISODIRECTORY']);
foreach($isodirs as $isodir){ foreach($isodirs as $isodir){
$files = array_diff(scandir($isodir), array('.', '..')); $files = array_diff(scandir($isodir), array('.', '..'));
$files = array_values(array_filter($files)); $files = array_values(array_filter($files));
for ($f=0; $f<count($files); $f++){ for ($f=0; $f<count($files); $f++){
if ((preg_match('/iso/', $files[$f]))||(preg_match('/ISO/', $files[$f]))){ if ((preg_match('/iso/', $files[$f]))||(preg_match('/ISO/', $files[$f]))){
echo "<a class=dropdown-item href=\"javascript:dropdown('cdrombutton','$isodir/$files[$f]')\">$isodir/$files[$f]</a>"; echo "<a class=dropdown-item href=\"javascript:dropdown('cdrombutton','$isodir/$files[$f]')\">$isodir/$files[$f]</a>";
}
} }
} }
} echo "</div></div></div></div><input type=hidden id=cdrombuttonh name=cdrom value=$val>";
echo "</div></div></div></div><input type=hidden id=cdrombuttonh name=cdrom value=$val>"; } elseif (preg_match('/format/', $arrColnames[$col])) {
} elseif (preg_match('/format/', $arrColnames[$col])) { echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>";
echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>"; } elseif (preg_match('/tapdev/', $arrColnames[$col])) {
} elseif (preg_match('/tapdev/', $arrColnames[$col])) { echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div>";
echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div>"; } elseif (preg_match('/macaddr/', $arrColnames[$col])) {
} elseif (preg_match('/macaddr/', $arrColnames[$col])) { echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div>";
echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div>"; } elseif (preg_match('/brdev/', $arrColnames[$col])) {
} elseif (preg_match('/brdev/', $arrColnames[$col])) { echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>";
echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>"; } elseif (preg_match('/drive/', $arrColnames[$col])){
} elseif (preg_match('/drive/', $arrColnames[$col])){ echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=$arrColnames[$col]button data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=$arrColnames[$col]button data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>"; echo "<div class=dropdown-menu aria-labelledby=$arrColnames[$col]button>";
echo "<div class=dropdown-menu aria-labelledby=$arrColnames[$col]button>"; $vmdirs = explode('|', $config['VMDIRECTORY']);
$vmdirs = explode('|', $config['VMDIRECTORY']); foreach($vmdirs as $vmdir){
foreach($vmdirs as $vmdir){ $files = array_diff(scandir($vmdir), array('.', '..'));
$files = array_diff(scandir($vmdir), array('.', '..')); $files = array_values(array_filter($files));
$files = array_values(array_filter($files)); for ($f=0; $f<count($files); $f++){
for ($f=0; $f<count($files); $f++){ echo "<a class=dropdown-item href=\"javascript:dropdown('$arrColnames[$col]button','$vmdir/$files[$f]')\">$vmdir/$files[$f]</a>";
echo "<a class=dropdown-item href=\"javascript:dropdown('$arrColnames[$col]button','$vmdir/$files[$f]')\">$vmdir/$files[$f]</a>"; }
} }
echo "</div></div></div><input type=hidden id=$arrColnames[$col]buttonh name=$arrColnames[$col] value=$val>";
} else {
echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>";
} }
echo "</div></div></div><input type=hidden id=$arrColnames[$col]buttonh name=$arrColnames[$col] value=$val>";
} else {
echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=$val></div></div>";
} }
} }
} echo "$editid<input type=hidden name=mode value=$formname><input class=\"btn btn-primary\" type=submit></form>";
echo "$editid<input type=hidden name=mode value=$formname><input class=\"btn btn-primary\" type=submit></form>";
} }
@ -231,7 +234,7 @@ while ($row = $res->fetchArray(SQLITE3_ASSOC)){
$button = "stop"; $button = "stop";
$buttonc = "btn-warning"; $buttonc = "btn-warning";
} }
echo "<div class=col style=\"border:solid 1px;\">$row[vmname]</br><a class=\"btn btn-primary\" href=# onclick=\"post('?', {edit: '$row[id]'});\">edit</a> "; echo "<div class=col style=\"border:solid 1px;max-width:320px;\">$row[vmname]</br><a class=\"btn btn-primary\" href=# onclick=\"post('?', {edit: '$row[id]'});\">edit</a> ";
echo "<a href=# onclick=\"post('?', {'$button': '$row[vmname]'});\"class=\"btn $buttonc\">$button</a> "; echo "<a href=# onclick=\"post('?', {'$button': '$row[vmname]'});\"class=\"btn $buttonc\">$button</a> ";
echo "<button class=\"btn btn-danger\" data-delete-text=\"Delete VM $row[vmname]!\" data-delete-vm=\"$row[id]\" data-delete-name=\"$row[vmname]\" data-toggle=\"modal\" data-target=\"#confirm-delete\">Delete VM</button> "; echo "<button class=\"btn btn-danger\" data-delete-text=\"Delete VM $row[vmname]!\" data-delete-vm=\"$row[id]\" data-delete-name=\"$row[vmname]\" data-toggle=\"modal\" data-target=\"#confirm-delete\">Delete VM</button> ";
$server = gethostname(); $server = gethostname();