//1-3 seconds. echo "access denied 4"; return; } } //output template to string for header processing $prov = new provision(); $prov->domain_uuid = $domain_uuid; $prov->mac = $mac; $prov->file = $file; $file_contents = $prov->render(); //deliver the customized config over HTTP/HTTPS //need to make sure content-type is correct if ($_REQUEST['content_type'] == 'application/octet-stream') { //format the mac address and $mac = $prov->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"; if ($device_vendor === "aastra" && strrpos($file, $cfg_ext, 0) === strlen($file) - strlen($cfg_ext)) { header("Content-Type: text/plain");
echo "\t<input type='button' class='btn' id='button_back_location' name='' alt='" . $text['button-back'] . "' onclick=\"window.location='devices.php'\" value='" . $text['button-back'] . "'>\n"; if (permission_exists("device_files")) { //get the template directory $prov = new provision(); $prov->domain_uuid = $domain_uuid; $template_dir = $prov->template_dir; $files = glob($template_dir . '/' . $device_template . '/*'); //add file buttons and the file list echo "\t\t<input type='button' class='btn' id='button_files' name='' alt='" . $text['button-files'] . "' onclick='show_files();' value='" . $text['button-files'] . "'>"; echo "\t\t<input type='button' class='btn' style='display: none;' id='button_back' name='' alt='" . $text['button-back'] . "' onclick='hide_files();' value='" . $text['button-back'] . "'> "; echo "\t\t<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n"; echo "\t\t\t<option value=''>" . $text['label-download'] . "</option>\n"; foreach ($files as $file) { //format the mac address and $format = new provision(); $mac = $format->format_mac($device_mac_address, $device_vendor); //render the file name $file_name = str_replace("{\$mac}", $mac, basename($file)); //add the select option echo "\t\t<option value='" . basename($file) . "'>" . $file_name . "</option>\n"; } echo "\t\t</select>\n"; //echo " <input type='button' class='btn' id='button_download' style='display: none;' alt='".$text['button-download']."' value='".$text['button-download']."' onclick='document.forms.frm.submit();'>"; } if (permission_exists('device_add') && $action != "add") { echo "\t<input type='button' class='btn' name='' alt='" . $text['button-copy'] . "' onclick=\"var new_mac = prompt('" . $text['message_device'] . "'); if (new_mac != null) { window.location='device_copy.php?id=" . $device_uuid . "&mac=' + new_mac; }\" value='" . $text['button-copy'] . "'>\n"; } echo "\t<input type='button' class='btn' value='" . $text['button-save'] . "' onclick='submit_form();'>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n";