From 5b5541819712df670c81574ec780c29be21ee131 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Wed, 5 Feb 2014 14:13:02 +0000 Subject: [PATCH] Update the provision PHP class to normalize the Mac Address before checking if it exists in the devices table in the database. --- app/provision/resources/classes/provision.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 0ed76d731f..4c59e4589b 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -31,6 +31,7 @@ include "root.php"; public $domain_uuid; public $domain_name; public $template_dir; + public $mac; public function __construct() { //get the database object @@ -40,6 +41,10 @@ include "root.php"; if (strlen($this->template_dir) == 0) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/provision"; } + //normalize the mac address + if (isset($this->mac)) { + $this->mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->mac)); + } } public function __destruct() { @@ -54,9 +59,10 @@ include "root.php"; //define the function which checks to see if the mac address exists in devices private function mac_exists($mac) { + //normalize the mac address + $mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $mac)); //check in the devices table for a specific mac address $sql = "SELECT count(*) as count FROM v_devices "; - //$sql .= "WHERE domain_uuid=:domain_uuid "; $sql .= "WHERE device_mac_address=:mac "; $prep_statement = $this->db->prepare(check_sql($sql)); if ($prep_statement) {