From 9f49e6537a5625d5123709b1e35c2a0ef9c81321 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 9 Jan 2016 11:10:37 -0700 Subject: [PATCH] Continued work on formatting the mac address for upper or lower case. --- app/devices/device_edit.php | 8 ++---- app/provision/index.php | 25 ++++++++++++------- app/provision/resources/classes/provision.php | 12 +++------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 2580cced3f..c89e93e8b6 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -357,10 +357,6 @@ require_once "resources/require.php"; unset ($prep_statement); } -//format the mac address - $format = new provision(); - $formatted_mac_address = $format->format_mac($device_mac_address, $device_vendor); - //use the mac address to get the vendor if (strlen($device_vendor) == 0) { $template_array = explode("/", $device_template); @@ -557,7 +553,7 @@ require_once "resources/require.php"; else { $domain_name = $_SESSION['domain_name']; } - echo " window.location = 'https://".$domain_name."/app/provision?mac=".$formatted_mac_address."&file=' + d + '&content_type=application/octet-stream';\n"; + echo " window.location = 'https://".$domain_name."/app/provision?mac=".$device_mac_address."&file=' + d + '&content_type=application/octet-stream';\n"; echo " }\n"; echo "\n"; @@ -607,7 +603,7 @@ require_once "resources/require.php"; echo " \n"; foreach ($files as $file) { //render the file name - $file_name = str_replace("{\$mac}",$device_mac_address,basename($file)); + $file_name = str_replace("{\$mac}",$mac,basename($file)); //add the select option echo " \n"; } diff --git a/app/provision/index.php b/app/provision/index.php index 8b2c3b2fc6..431c78f632 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -298,15 +298,22 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); //deliver the customized config over HTTP/HTTPS //need to make sure content-type is correct if ($_REQUEST['content_type'] == 'application/octet-stream') { - $file_name = str_replace("{\$mac}",$mac,$file); - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="'.basename($file_name).'"'); - header('Content-Transfer-Encoding: binary'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - header('Content-Length: ' . filesize($file_contents)); + //format the mac address and + $format = new provision(); + $mac = $format->format_mac($mac, $device_vendor); + + //replace the variable name with the value + $file_name = str_replace("{\$mac}", $mac, $file); + + //set the headers + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.basename($file_name).'"'); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file_contents)); } else { $cfg_ext = ".cfg"; diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index feb6722d0f..d0d3abfb83 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -891,15 +891,11 @@ include "root.php"; $this->file = $file_name; $file_contents = $this->render(); + //format the mac address + $mac = $this->format_mac($device_mac_address, $device_vendor); + //replace {$mac} in the file name - if ($device_vendor == "aastra" || $device_vendor == "cisco") { - //upper case the mac address for aastra phones - $file_name = str_replace("{\$mac}", strtoupper($device_mac_address), $file_name); - } - else { - //all other phones - $file_name = str_replace("{\$mac}", $device_mac_address, $file_name); - } + $file_name = str_replace("{\$mac}", $mac, $file_name); //write the file //echo $directory.'/'.$file_name."\n";