Copyright (C) 2008-2018 All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('device_add') || permission_exists('device_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //check for duplicates if ($_GET["check"] == 'duplicate') { //mac address if ($_GET["mac"] != '' && $_GET["mac"] != "000000000000") { $sql = "select "; $sql .= "d2.domain_name "; $sql .= "from "; $sql .= "v_devices as d1, "; $sql .= "v_domains as d2 "; $sql .= "where "; $sql .= "d1.domain_uuid = d2.domain_uuid and "; $sql .= "d1.device_mac_address = '".check_str($_GET["mac"])."' "; if ($_GET["device_uuid"] != '') { $sql .= " and d1.device_uuid <> '".check_str($_GET["device_uuid"])."' "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['domain_name'] != '') { echo $text['message-duplicate'].((if_group("superadmin") && $_SESSION["domain_name"] != $row["domain_name"]) ? ": ".$row["domain_name"] : null); } } unset($prep_statement); } //username if ($_GET['username'] != '') { $sql = "select "; $sql .= "d2.domain_name, "; $sql .= "d1.device_mac_address "; $sql .= "from "; $sql .= "v_devices as d1, "; $sql .= "v_domains as d2 "; $sql .= "where "; $sql .= "d1.domain_uuid = d2.domain_uuid and "; $sql .= "d1.device_username = '".check_str($_GET["username"])."' "; if ($_GET['domain_uuid'] != '') { $sql .= "and d2.domain_uuid = '".check_str($_GET['domain_uuid'])."' "; } if ($_GET['device_uuid'] != '') { $sql .= "and d1.device_uuid <> '".check_str($_GET["device_uuid"])."' "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['domain_name'] != '') { echo $text['message-duplicate_username'].((if_group("superadmin")) ? ": ".format_mac($row['device_mac_address']).(($_SESSION["domain_name"] != $row["domain_name"]) ? " (".$row["domain_name"].")" : null) : null); } } unset($prep_statement); } exit; } //include the device class require_once "app/devices/resources/classes/device.php"; //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $device_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get total device count from the database, check limit, if defined if ($action == 'add') { if ($_SESSION['limit']['devices']['numeric'] != '') { $sql = "select count(*) as num_rows from v_devices where domain_uuid = '".$_SESSION['domain_uuid']."' "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); $total_devices = $row['num_rows']; } unset($prep_statement, $row); if ($total_devices >= $_SESSION['limit']['devices']['numeric']) { messages::add($text['message-maximum_devices'].' '.$_SESSION['limit']['devices']['numeric'], 'negative'); header('Location: devices.php'); return; } } } //get http post variables and set them to php variables if (count($_POST) > 0) { //device mac address if (permission_exists('device_mac_address')) { $device_mac_address = check_str($_POST["device_mac_address"]); $device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address)); $_POST["device_mac_address"] = $device_mac_address; } else { $sql = "select * from v_devices "; $sql .= "where device_uuid = '$device_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $device_mac_address = $row["device_mac_address"]; $_POST["device_mac_address"] = $device_mac_address; } unset ($prep_statement); } //get assigned user $device_user_uuid = check_str($_POST["device_user_uuid"]); //devices $device_label = check_str($_POST["device_label"]); $device_vendor = check_str($_POST["device_vendor"]); $device_uuid_alternate = check_str($_POST["device_uuid_alternate"]); $device_model = check_str($_POST["device_model"]); $device_firmware_version = check_str($_POST["device_firmware_version"]); $device_enabled = check_str($_POST["device_enabled"]); $device_template = check_str($_POST["device_template"]); $device_description = check_str($_POST["device_description"]); //lines $line_number = check_str($_POST["line_number"]); $server_address = check_str($_POST["server_address"]); $outbound_proxy_primary = check_str($_POST["outbound_proxy_primary"]); $outbound_proxy_secondary = check_str($_POST["outbound_proxy_secondary"]); $display_name = check_str($_POST["display_name"]); $user_id = check_str($_POST["user_id"]); $auth_id = check_str($_POST["auth_id"]); $password = check_str($_POST["password"]); //profile $device_profile_uuid = check_str($_POST["device_profile_uuid"]); //keys $device_key_category = check_str($_POST["device_key_category"]); $device_key_id = check_str($_POST["device_key_id"]); $device_key_type = check_str($_POST["device_key_type"]); $device_key_line = check_str($_POST["device_key_line"]); $device_key_value = check_str($_POST["device_key_value"]); $device_key_extension = check_str($_POST["device_key_extension"]); $device_key_label = check_str($_POST["device_key_label"]); //settings //$device_setting_category = check_str($_POST["device_setting_category"]); $device_setting_subcategory = check_str($_POST["device_setting_subcategory"]); //$device_setting_name = check_str($_POST["device_setting_name"]); $device_setting_value = check_str($_POST["device_setting_value"]); $device_setting_enabled = check_str($_POST["device_setting_enabled"]); $device_setting_description = check_str($_POST["device_setting_description"]); } //use the mac address to get the vendor if (strlen($device_vendor) == 0) { $device_vendor = device::get_vendor($device_mac_address); } //add or update the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data $msg = ''; //if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } //if (strlen($device_label) == 0) { $msg .= "Please provide: Label
\n"; } //if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor
\n"; } //if (strlen($device_model) == 0) { $msg .= "Please provide: Model
\n"; } //if (strlen($device_firmware_version) == 0) { $msg .= "Please provide: Firmware Version
\n"; } //if (strlen($device_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($device_template) == 0) { $msg .= "Please provide: Template
\n"; } //if (strlen($device_username) == 0) { $msg .= "Please provide: Username
\n"; } //if (strlen($device_password) == 0) { $msg .= "Please provide: Password
\n"; } //if (strlen($device_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add or update the database if ($_POST["persistformvar"] != "true") { //add domain_uuid to the array foreach ($_POST as $key => $value) { if (is_array($value)) { $y = 0; foreach ($value as $k => $v) { if (!isset($v["domain_uuid"])) { $_POST[$key][$y]["domain_uuid"] = $_POST["domain_uuid"]; } $y++; } } } //array cleanup $x = 0; //unset($_POST["autocomplete"]); unset($_POST["target_file"]); unset($_POST["file_action"]); foreach ($_POST["device_lines"] as $row) { //unset the empty row if (strlen($row["line_number"]) == 0) { unset($_POST["device_lines"][$x]); } //unset device_detail_uuid if the field has no value if (strlen($row["device_line_uuid"]) == 0) { unset($_POST["device_lines"][$x]["device_line_uuid"]); } //increment the row $x++; } $x = 0; foreach ($_POST["device_keys"] as $row) { //unset the empty row if (strlen($row["device_key_category"]) == 0) { unset($_POST["device_keys"][$x]); } //unset device_detail_uuid if the field has no value if (strlen($row["device_key_uuid"]) == 0) { unset($_POST["device_keys"][$x]["device_key_uuid"]); } //increment the row $x++; } $x = 0; foreach ($_POST["device_settings"] as $row) { //unset the empty row if (strlen($row["device_setting_subcategory"]) == 0) { unset($_POST["device_settings"][$x]); } //unset device_detail_uuid if the field has no value if (strlen($row["device_setting_uuid"]) == 0) { unset($_POST["device_settings"][$x]["device_setting_uuid"]); } //increment the row $x++; } //set the default $save = true; //check to see if the mac address exists if ($action == "add") { if ($device_mac_address == "" || $device_mac_address == "000000000000") { //allow duplicates to be used as templaes } else { $save = true; } } else { $save = true; } //prepare the array $array['devices'][] = $_POST; //save the device if ($save) { $database = new database; $database->app_name = 'devices'; $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; if (strlen($device_uuid) > 0) { $database->uuid($device_uuid); } $database->save($array); $response = $database->message; if (strlen($response['uuid']) > 0) { $device_uuid = $response['uuid']; } } //write the provision files if (strlen($_SESSION['provision']['path']['text']) > 0) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); } //set the message if (!isset($_SESSION['message'])) { if ($save) { if ($action == "add") { //save the message to a session variable messages::add($text['message-add']); } if ($action == "update") { //save the message to a session variable messages::add($text['message-update']); } //redirect the browser header("Location: device_edit.php?id=$device_uuid"); exit; } } } //if ($_POST["persistformvar"] != "true") } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $sql = "select * from v_devices "; $sql .= "where device_uuid = '$device_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $device_mac_address = $row["device_mac_address"]; $device_provisioned_ip = $row["device_provisioned_ip"]; $domain_uuid = $row["domain_uuid"]; $device_label = $row["device_label"]; //$device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2); $device_label = $row["device_label"]; $device_user_uuid = $row["device_user_uuid"]; $device_username = $row["device_username"]; $device_password = $row["device_password"]; $device_vendor = $row["device_vendor"]; $device_uuid_alternate = $row["device_uuid_alternate"]; $device_model = $row["device_model"]; $device_firmware_version = $row["device_firmware_version"]; $device_enabled = $row["device_enabled"]; $device_template = $row["device_template"]; $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } unset ($prep_statement); } //use the mac address to get the vendor if (strlen($device_vendor) == 0) { $template_array = explode("/", $device_template); $device_vendor = $template_array[0]; } //set the sub array index $x = "999"; //alternate device settings if (strlen($device_uuid_alternate) > 0) { $sql = "select * from v_devices "; $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; $sql .= "and device_uuid = '$device_uuid_alternate' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_alternate = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); } //get device lines $sql = "SELECT * FROM v_device_lines "; $sql .= "where device_uuid = '".$device_uuid."' "; $sql .= "order by line_number asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED); $device_lines[$x]['line_number'] = ''; $device_lines[$x]['server_address'] = ''; $device_lines[$x]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text']; $device_lines[$x]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text']; $device_lines[$x]['display_name'] = ''; $device_lines[$x]['user_id'] = ''; $device_lines[$x]['auth_id'] = ''; $device_lines[$x]['password'] = ''; $device_lines[$x]['shared_line'] = ''; $device_lines[$x]['enabled'] = ''; $device_lines[$x]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; $device_lines[$x]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; $device_lines[$x]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; //get device keys $sql = "SELECT * FROM v_device_keys "; $sql .= "WHERE device_uuid = '".$device_uuid."' "; $sql .= "ORDER by "; $sql .= "device_key_vendor asc, "; $sql .= "CASE device_key_category "; $sql .= "WHEN 'line' THEN 1 "; $sql .= "WHEN 'memory' THEN 2 "; $sql .= "WHEN 'programmable' THEN 3 "; $sql .= "WHEN 'expansion' THEN 4 "; $sql .= "WHEN 'expansion-1' THEN 5 "; $sql .= "WHEN 'expansion-2' THEN 6 "; $sql .= "ELSE 100 END, "; if ($db_type == "mysql") { $sql .= "device_key_id asc "; } else { $sql .= "cast(device_key_id as numeric) asc "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); $device_keys[$x]['device_key_category'] = ''; $device_keys[$x]['device_key_id'] = ''; $device_keys[$x]['device_key_type'] = ''; $device_keys[$x]['device_key_line'] = ''; $device_keys[$x]['device_key_value'] = ''; $device_keys[$x]['device_key_extension'] = ''; $device_keys[$x]['device_key_label'] = ''; //get the vendor functions $sql = "SELECT v.name as vendor_name, f.name, f.value "; $sql .= "FROM v_device_vendors as v, v_device_vendor_functions as f "; $sql .= "where v.device_vendor_uuid = f.device_vendor_uuid "; $sql .= "and v.enabled = 'true' "; $sql .= "and f.enabled = 'true' "; $sql .= "order by v.name asc, f.name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); //get device settings $sql = "SELECT * FROM v_device_settings "; $sql .= "WHERE device_uuid = '".$device_uuid."' "; $sql .= "ORDER by device_setting_subcategory asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); $device_settings[$x]['device_setting_name'] = ''; $device_settings[$x]['device_setting_value'] = ''; $device_settings[$x]['enabled'] = ''; $device_settings[$x]['device_setting_description'] = ''; //get the users $sql = "SELECT * FROM v_users "; $sql .= "WHERE domain_uuid = '".$domain_uuid."' "; $sql .= "AND user_enabled = 'true' "; $sql .= "ORDER by username asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $users = $prep_statement->fetchAll(PDO::FETCH_NAMED); //use the mac address to get the vendor if (strlen($device_vendor) == 0) { $device_vendor = device::get_vendor($device_mac_address); } //get the device line info for provision button foreach($device_lines as $row) { if (strlen($row['user_id']) > 0) { $user_id = $row['user_id']; } if (strlen($row['server_address']) > 0) { $server_address = $row['server_address']; } } //get the sip profile name $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $command = "sofia_contact */".$user_id."@".$server_address; $contact_string = event_socket_request($fp, "api ".$command); if (substr($contact_string, 0, 5) == "sofia") { $contact_array = explode("/", $contact_string); $sip_profile_name = $contact_array[1]; } else { $sip_profile_name = 'internal'; } } //show the header require_once "resources/header.php"; //javascript to change select to input and back again ?> \n"; echo " var fade_speed = 400;\n"; echo " function show_files() {\n"; echo " document.getElementById('file_action').value = 'files';\n"; echo " $('#button_back_location').fadeOut(fade_speed);\n"; echo " $('#button_files').fadeOut(fade_speed, function() {\n"; echo " $('#button_back').fadeIn(fade_speed);\n"; echo " $('#target_file').fadeIn(fade_speed);\n"; echo " $('#button_download').fadeIn(fade_speed);\n"; echo " });"; echo " }"; echo " function hide_files() {\n"; echo " document.getElementById('file_action').value = '';\n"; echo " $('#button_download').fadeOut(fade_speed);\n"; echo " $('#target_file').fadeOut(fade_speed);\n"; echo " $('#button_back').fadeOut(fade_speed, function() {\n"; echo " $('#button_files').fadeIn(fade_speed)\n"; echo " $('#button_back_location').fadeIn(fade_speed);\n"; echo " });"; echo " document.getElementById('target_file').selectedIndex = 0;\n"; echo " }\n"; echo " function download(d) {\n"; echo " if (d == '".$text['label-download']."') return;\n"; if ($_SESSION['provision']['http_domain_filter']['text'] == "false") { $domain_name = $_SERVER["HTTP_HOST"]; } else { $domain_name = $_SESSION['domain_name']; } if (!isset($_SERVER['HTTP_PROTOCOL'])) { $_SERVER['HTTP_PROTOCOL'] = 'http'; if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; } if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } } echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?mac=".$device_mac_address."&file=' + d + '&content_type=application/octet-stream';\n"; echo " }\n"; echo "\n"; echo " $( document ).ready(function() {\n"; echo " $('#default_setting_search').focus();\n"; if ($search == '') { echo " // scroll to previous category\n"; echo " var category_span_id;\n"; echo " var url = document.location.href;\n"; echo " var hashindex = url.indexOf('#');\n"; echo " if (hashindex == -1) { }\n"; echo " else {\n"; echo " category_span_id = url.substr(hashindex + 1);\n"; echo " }\n"; echo " if (category_span_id) {\n"; echo " $('#page').animate({scrollTop: $('#anchor_'+category_span_id).offset().top - 200}, 'slow');\n"; echo " }\n"; } echo " });\n"; echo ""; } //add the QR code if (permission_exists("device_line_password") && $device_template == "grandstream/wave") { //set the mode if (isset($_SESSION['theme']['qr_image'])) { if (strlen($_SESSION['theme']['qr_image']) > 0) { $mode = '4'; } else { $mode = '0'; } } else { $mode = '4'; } //build the xml $row = $device_lines[0]; $xml = ""; $xml .= ""; $xml .= ""; $xml .= "".$row['server_address'].""; $xml .= "".$row['outbound_proxy_primary'].""; $xml .= "".$row['outbound_proxy_secondary'].""; $xml .= "".$row['user_id'].""; $xml .= "".$row['auth_id'].""; $xml .= "".$row['password'].""; $xml .= "".$row['user_id'].""; $xml .= "".$row['display_name'].""; $xml .= "{x+|*x+|*++}"; $xml .= "0"; $xml .= "*97"; $xml .= ""; $xml .= ""; //qr code generation $_GET['type'] = "text"; $qr_vcard = true; include "contacts_vcard.php"; echo ""; echo ""; echo ""; echo ""; if (isset($_SESSION['theme']['qr_image'])) { echo ""; } else { echo ""; } } //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo " ".$text['header-device'].""; echo "\n"; echo " \n"; if (permission_exists("device_line_password") && $device_template == "grandstream/wave") { echo " \n"; } echo "  \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 " "; echo " "; echo " \n"; //echo " "; } if (permission_exists('device_add') && $action != "add") { echo " \n"; } echo " \n"; echo "
\n"; echo " ".$text['description-device']; echo "

"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('device_template')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_line_view')) { echo " "; echo " "; echo " "; echo " "; } if (permission_exists('device_profile_edit')) { //device profile $sql = "select * from v_device_profiles "; $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; $sql .= "order by device_profile_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); if ($result_count > 0) { echo " "; echo " "; echo " "; echo " "; } } if (permission_exists('device_key_edit')) { $vendor_count = 0; foreach($device_keys as $row) { if ($previous_vendor != $row['device_key_vendor']) { $previous_vendor = $row['device_key_vendor']; $vendor_count++; } } echo " "; echo " "; echo " "; echo " "; } //device settings if (permission_exists('device_setting_edit')) { echo " "; echo " "; echo " \n"; echo " \n"; } if (permission_exists('device_user')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_alternate')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_vendor')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_model')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_firmware')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_domain')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } else { echo " \n"; } if (permission_exists('device_enable')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
\n"; echo " ".$text['label-device_mac_address']."\n"; echo "\n"; if (permission_exists('device_mac_address')) { echo " \n"; echo "
\n"; echo $text['description-device_mac_address']."\n"; } else { echo $device_mac_address; } echo " \n"; echo " ".$device_provisioned_ip."(http|https)\n"; echo "
\n"; echo " ".$text['label-device_label']."\n"; echo "\n"; if (permission_exists('device_label')) { echo " \n"; echo "
\n"; echo $text['description-device_label']."\n"; } else { echo $device_label; } echo "
\n"; echo " ".$text['label-device_template']."\n"; echo "\n"; $device = new device; $template_dir = $device->get_template_dir(); echo "\n"; echo "
\n"; echo $text['description-device_template']."\n"; echo "
".$text['label-lines'].""; echo " \n"; echo " \n"; echo " \n"; if (permission_exists('device_line_server_address')) { echo " \n"; } if (permission_exists('device_outbound_proxy_primary')) { echo " \n"; } if (permission_exists('device_outbound_proxy_secondary')) { echo " \n"; } echo " \n"; echo " \n"; if (permission_exists('device_line_auth_id')) { echo " \n"; } if (permission_exists('device_line_password')) { echo " \n"; } echo " \n"; if (permission_exists('device_line_transport')) { echo " \n"; } if (permission_exists('device_line_register_expires')) { echo " \n"; } if (permission_exists('device_line_shared')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; $x = 0; foreach($device_lines as $row) { //set the defaults if (!permission_exists('device_line_server_address')) { if (strlen($row['server_address']) == 0) { $row['server_address'] = $_SESSION['domain_name']; } } if (strlen($row['sip_transport']) == 0) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; } if (strlen($row['sip_port']) == 0) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } if (strlen($row['register_expires']) == 0) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; } //determine whether to hide the element if (strlen($device_line_uuid) == 0) { $element['hidden'] = false; $element['visibility'] = "visibility:visible;"; } else { $element['hidden'] = true; $element['visibility'] = "visibility:hidden;"; } //add the primary key uuid if (strlen($row['device_line_uuid']) > 0) { echo " \n"; } //show each row in the array echo " \n"; echo " \n"; if (permission_exists('device_line_server_address')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_outbound_proxy_primary')) { if (permission_exists('device_outbound_proxy_secondary')) { $placeholder_label = $text['label-primary']; } echo " \n"; unset($placeholder_label); } if (permission_exists('device_outbound_proxy_secondary')) { echo " \n"; } echo " \n"; echo " \n"; if (permission_exists('device_line_auth_id')) { echo " \n"; } if (permission_exists('device_line_password')) { echo " \n"; } echo " \n"; if (permission_exists('device_line_transport')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_line_register_expires')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_line_shared')) { echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; $x++; } echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-outbound_proxy_primary']."".$text['label-outbound_proxy_secondary']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-shared_line']."".$text['label-enabled']." 
\n"; $selected = "selected=\"selected\" "; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (strlen($row['device_line_uuid']) > 0) { if (permission_exists('device_delete')) { echo " $v_link_label_delete\n"; } } echo "
\n"; if (strlen($text['description-lines']) > 0) { echo "
".$text['description-lines']."\n"; } echo "
".$text['label-profile'].""; echo " \n"; echo " "; echo " "; echo "
".$text['description-profile2']."\n"; echo "
".$text['label-keys'].""; echo " \n"; if ($vendor_count == 0) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (permission_exists('device_key_extension')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; } $x = 0; foreach($device_keys as $row) { //set the column names if ($previous_device_key_vendor != $row['device_key_vendor']) { echo " \n"; echo " \n"; echo " \n"; if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; if (permission_exists('device_key_extension')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; } //determine whether to hide the element if (strlen($device_key_uuid) == 0) { $element['hidden'] = false; $element['visibility'] = "visibility:visible;"; } else { $element['hidden'] = true; $element['visibility'] = "visibility:hidden;"; } //add the primary key uuid if (strlen($row['device_key_uuid']) > 0) { echo " \n"; } //show all the rows in the array echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('device_key_extension')) { echo "\n"; } echo "\n"; //echo " \n"; echo " \n"; echo " \n"; //set the previous vendor $previous_device_key_vendor = $row['device_key_vendor']; //increment the array key $x++; } echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
\n"; echo " \n"; echo "\n"; $selected = "selected='selected'"; echo " \n"; echo "\n"; //echo " \n"; if (strlen($row['device_key_vendor']) > 0) { $device_key_vendor = $row['device_key_vendor']; } else { $device_key_vendor = $device_vendor; } ?> \n"; echo " \n"; $previous_vendor = ''; $i=0; foreach ($vendor_functions as $function) { if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) { if ($i > 0) { echo " \n"; } echo " \n"; } $selected = ''; if (strtolower($row['device_key_vendor']) == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { $selected = "selected='selected'"; } if (strlen($row['device_key_vendor']) == 0) { echo " \n"; } if (strlen($row['device_key_vendor']) > 0 && strtolower($row['device_key_vendor']) == $function['vendor_name']) { echo " \n"; } $previous_vendor = $function['vendor_name']; $i++; } if (strlen($row['device_key_vendor']) == 0) { echo " \n"; } echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; //echo " \n"; //echo " \n"; if (strlen($row['device_key_uuid']) > 0) { if (permission_exists('device_key_delete')) { echo " $v_link_label_delete\n"; } } echo "
\n"; if (strlen($text['description-keys']) > 0) { echo "
".$text['description-keys']."\n"; } echo "
".$text['label-settings'].""; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $x = 0; foreach($device_settings as $row) { //determine whether to hide the element if (strlen($device_setting_uuid) == 0) { $element['hidden'] = false; $element['visibility'] = "visibility:visible;"; } else { $element['hidden'] = true; $element['visibility'] = "visibility:hidden;"; } //add the primary key uuid if (strlen($row['device_setting_uuid']) > 0) { echo " \n"; } //show alls rows in the array echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (strlen($text['description-settings']) > 0) { echo "
".$text['description-settings']."\n"; } echo " "; echo " \n"; echo " \n"; $x++; } /* echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']." 
\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; if (strlen($row['device_setting_uuid']) > 0) { if (permission_exists('device_edit')) { echo " $v_link_label_edit\n"; } if (permission_exists('device_delete')) { echo " $v_link_label_delete\n"; } } echo "
\n"; echo " \n"; */ echo "
\n"; echo "
\n"; echo " ".$text['label-user']."\n"; echo "\n"; echo " "; unset($users); echo "
\n"; echo " ".$text['description-user']."\n"; } if (permission_exists('device_username_password')) { echo "
\n"; echo " ".$text['label-device']."\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo $text['description-device']."\n"; echo "
\n"; echo " ".$text['label-device_uuid_alternate']."\n"; echo "\n"; if (strlen($device_uuid_alternate) == 0) { echo " "; } else { $label = $device_alternate[0]['device_label']; if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } echo " \n"; echo " \n"; echo " "; echo " \n"; echo " \n"; echo "
$label $v_link_label_delete
\n"; unset($label); } echo $text['description-device_uuid_alternate']."\n"; echo "
\n"; echo " ".$text['label-device_vendor']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_vendor']."\n"; echo "
\n"; echo " ".$text['label-device_model']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_model']."\n"; echo "
\n"; echo " ".$text['label-device_firmware_version']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_firmware_version']."\n"; echo "
\n"; echo " ".$text['label-domain']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-domain_name']."\n"; echo "
\n"; echo " ".$text['label-device_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_enabled']."\n"; echo "
\n"; echo " ".$text['label-device_description']."\n"; echo "\n"; if (permission_exists('device_description')) { echo " \n"; echo "
\n"; echo $text['description-device_description']."\n"; } else { echo $device_description."\n"; } echo "
\n"; if ($action == "update") { echo " \n"; } echo "
"; echo " \n"; echo "
"; echo "

"; echo "
"; echo "\n"; //show the footer require_once "resources/footer.php"; ?>