Added function validateMac()

This commit is contained in:
billz 2024-01-12 12:21:00 +00:00
parent c594b8f4a9
commit effa38c0a0

View file

@ -780,6 +780,23 @@ function validate_host($host)
return preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $host);
}
/**
* Validates a MAC address
*
* @param string $mac
* @return bool
*/
function validateMac($mac) {
$macAddress = strtoupper(preg_replace('/[^a-fA-F0-9]/', '', $mac));
if (strlen($macAddress) !== 12) {
return false;
}
if (!ctype_xdigit($macAddress)) {
return false;
}
return true;
}
// Gets night mode toggle value
// @return boolean
function getNightmode()