introduce mac generator
This commit is contained in:
parent
d57893514d
commit
e4c3b52cd5
|
@ -155,8 +155,18 @@ function checkmacfree($vmname,$mac,$db_handle){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['checkmac'])){
|
||||||
|
$mac = clean($_POST['checkmac']);
|
||||||
|
$mf = checkmacfree('novm', $mac, $db_handle);
|
||||||
|
if ($mf == 0){
|
||||||
|
echo "mac is free";
|
||||||
|
} else {
|
||||||
|
echo "mac not free";
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
|
||||||
//delete vms
|
//delete vms
|
||||||
if (isset($_SESSION['username'])){
|
} elseif (isset($_SESSION['username'])){
|
||||||
if ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="vm")){
|
if ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="vm")){
|
||||||
if($_SESSION['isadmin']!=1){
|
if($_SESSION['isadmin']!=1){
|
||||||
echo "you are not allowed to delete vms!";
|
echo "you are not allowed to delete vms!";
|
||||||
|
@ -777,7 +787,7 @@ if (isset($_SESSION['username'])){
|
||||||
} 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\" placeholder=\"$placehold[$colname]\"></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\" placeholder=\"$placehold[$colname]\"></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\" placeholder=\"$placehold[$colname]\"></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] id=$arrColnames[$col] value=\"$val\" placeholder=\"$placehold[$colname]\"></div><div onclick=genmac('$arrColnames[$col]') class=\"btn btn-primary\">gen</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\" placeholder=\"$placehold[$colname]\"></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\" placeholder=\"$placehold[$colname]\"></div></div>";
|
||||||
} elseif (preg_match('/drive/', $arrColnames[$col])){
|
} elseif (preg_match('/drive/', $arrColnames[$col])){
|
||||||
|
|
31
web/nlvmi.js
31
web/nlvmi.js
|
@ -215,3 +215,34 @@ function createimg(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function genmac(field){
|
||||||
|
freemacfound = "no";
|
||||||
|
while (freemacfound == "no"){
|
||||||
|
var text = "";
|
||||||
|
var possible = "abcdef0123456789";
|
||||||
|
for (j=0; j < 4; j++){
|
||||||
|
text += ":";
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
|
}
|
||||||
|
var newmac = "52:54:00"+ text;
|
||||||
|
freemacfound = checkmac(newmac, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkmac(newmac,field){
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: "?rand="+ makeid(),
|
||||||
|
data: "checkmac="+ newmac,
|
||||||
|
success: function(response){
|
||||||
|
if (response == "mac is free"){
|
||||||
|
$('#'+ field).val(newmac);
|
||||||
|
return newmac;
|
||||||
|
} else {
|
||||||
|
return "no";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue