Change device_mac_address to device_address

This commit is contained in:
markjcrane 2023-06-29 23:40:11 -06:00
parent 49648e6655
commit 53779d50d3
14 changed files with 3077 additions and 3064 deletions

View File

@ -48,7 +48,7 @@
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "device_mac_address";
$apps[$x]['permissions'][$y]['name'] = "device_address";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
@ -411,8 +411,8 @@
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "device_mac_address";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "phone_mac_address";
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "device_address";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "device_mac_address";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";

View File

@ -220,29 +220,29 @@ $text['select-global']['zh-cn'] = "全球的";
$text['select-global']['ja-jp'] = "グローバル";
$text['select-global']['ko-kr'] = "글로벌";
$text['message_device']['en-us'] = "Enter the New MAC Address";
$text['message_device']['en-gb'] = "Enter the New MAC Address";
$text['message_device']['en-us'] = "Enter the New Address";
$text['message_device']['en-gb'] = "Enter the New Address";
$text['message_device']['ar-eg'] = "أدخل العنوان الجديد";
$text['message_device']['de-at'] = "Geben Sie die neue MAC Adresse ein";
$text['message_device']['de-ch'] = "Geben Sie die neue MAC Adresse ein";
$text['message_device']['de-de'] = "Geben Sie die neue MAC Adresse ein";
$text['message_device']['es-cl'] = "Introduzca la nueva dirección MAC";
$text['message_device']['es-mx'] = "Introduzca la nueva dirección MAC";
$text['message_device']['fr-ca'] = "Insérer la nouvelle adresse MAC";
$text['message_device']['fr-fr'] = "Insérer la nouvelle adresse MAC";
$text['message_device']['de-at'] = "Geben Sie die neue Adresse ein";
$text['message_device']['de-ch'] = "Geben Sie die neue Adresse ein";
$text['message_device']['de-de'] = "Geben Sie die neue Adresse ein";
$text['message_device']['es-cl'] = "Introduzca la nueva dirección";
$text['message_device']['es-mx'] = "Introduzca la nueva dirección";
$text['message_device']['fr-ca'] = "Insérer la nouvelle adresse";
$text['message_device']['fr-fr'] = "Insérer la nouvelle adresse";
$text['message_device']['he-il'] = "הכנס כתובת מאק חדשה";
$text['message_device']['it-it'] = "Inserire il nuovo MAC address";
$text['message_device']['nl-nl'] = "Voer het nieuwe MAC adres in";
$text['message_device']['pl-pl'] = "Wpisz nowy adres MAC";
$text['message_device']['pt-br'] = "Insira o novo endereço MAC";
$text['message_device']['pt-pt'] = "Introduza o novo endereço MAC";
$text['message_device']['ro-ro'] = "Introduceți noua adresă MAC";
$text['message_device']['ru-ru'] = "Введите новый MAC-адрес";
$text['message_device']['sv-se'] = "Fyll i den nya MAC-adressen";
$text['message_device']['uk-ua'] = "Введіть нову MAC адресу";
$text['message_device']['zh-cn'] = "输入新的 MAC 地址";
$text['message_device']['ja-jp'] = "新しいMACアドレスを入力してください";
$text['message_device']['ko-kr'] = "MAC 주소를 입력하십시오";
$text['message_device']['it-it'] = "Inserire il nuovo address";
$text['message_device']['nl-nl'] = "Voer het nieuwe adres in";
$text['message_device']['pl-pl'] = "Wpisz nowy adres";
$text['message_device']['pt-br'] = "Insira o novo endereço";
$text['message_device']['pt-pt'] = "Introduza o novo endereço";
$text['message_device']['ro-ro'] = "Introduceți noua adresă";
$text['message_device']['ru-ru'] = "Введите новый адрес";
$text['message_device']['sv-se'] = "Fyll i den nya adressen";
$text['message_device']['uk-ua'] = "Введіть нову адресу";
$text['message_device']['zh-cn'] = "输入新的 地址";
$text['message_device']['ja-jp'] = "新しいアドレスを入力してください";
$text['message_device']['ko-kr'] = "주소를 입력하십시오";
$text['message-maximum_devices']['en-us'] = "Maximum Devices:";
$text['message-maximum_devices']['en-gb'] = "Maximum Devices:";
@ -3266,29 +3266,29 @@ $text['label-device_model']['zh-cn'] = "模型";
$text['label-device_model']['ja-jp'] = "モデル";
$text['label-device_model']['ko-kr'] = "모델";
$text['label-device_mac_address']['en-us'] = "MAC Address";
$text['label-device_mac_address']['en-gb'] = "MAC Address";
$text['label-device_mac_address']['ar-eg'] = "العنوان الرئيسي";
$text['label-device_mac_address']['de-at'] = "MAC Adresse";
$text['label-device_mac_address']['de-ch'] = "MAC Adresse";
$text['label-device_mac_address']['de-de'] = "MAC Adresse";
$text['label-device_mac_address']['es-cl'] = "Dirección MAC";
$text['label-device_mac_address']['es-mx'] = "Dirección MAC";
$text['label-device_mac_address']['fr-ca'] = "Adresse MAC";
$text['label-device_mac_address']['fr-fr'] = "Adresse MAC";
$text['label-device_mac_address']['he-il'] = "כתובת MAC";
$text['label-device_mac_address']['it-it'] = "MAC Address";
$text['label-device_mac_address']['nl-nl'] = "MAC Adres";
$text['label-device_mac_address']['pl-pl'] = "Adres MAC";
$text['label-device_mac_address']['pt-br'] = "Endereço MAC";
$text['label-device_mac_address']['pt-pt'] = "Endereço MAC";
$text['label-device_mac_address']['ro-ro'] = "Adresa mac";
$text['label-device_mac_address']['ru-ru'] = "MAC-адрес";
$text['label-device_mac_address']['sv-se'] = "MAC-adress";
$text['label-device_mac_address']['uk-ua'] = "Адреса MAC";
$text['label-device_mac_address']['zh-cn'] = "MAC地址";
$text['label-device_mac_address']['ja-jp'] = "Macアドレス";
$text['label-device_mac_address']['ko-kr'] = "MAC 주소";
$text['label-device_address']['en-us'] = "Address";
$text['label-device_address']['en-gb'] = "Address";
$text['label-device_address']['ar-eg'] = "العنوان الرئيسي";
$text['label-device_address']['de-at'] = "Adresse";
$text['label-device_address']['de-ch'] = "Adresse";
$text['label-device_address']['de-de'] = "Adresse";
$text['label-device_address']['es-cl'] = "Dirección";
$text['label-device_address']['es-mx'] = "Dirección";
$text['label-device_address']['fr-ca'] = "Adresse";
$text['label-device_address']['fr-fr'] = "Adresse";
$text['label-device_address']['he-il'] = "כתובת ";
$text['label-device_address']['it-it'] = "Address";
$text['label-device_address']['nl-nl'] = "Adres";
$text['label-device_address']['pl-pl'] = "Adres";
$text['label-device_address']['pt-br'] = "Endereço";
$text['label-device_address']['pt-pt'] = "Endereço";
$text['label-device_address']['ro-ro'] = "Adresa";
$text['label-device_address']['ru-ru'] = "адрес";
$text['label-device_address']['sv-se'] = "adress";
$text['label-device_address']['uk-ua'] = "Адреса";
$text['label-device_address']['zh-cn'] = "地址";
$text['label-device_address']['ja-jp'] = "アドレス";
$text['label-device_address']['ko-kr'] = "주소";
$text['label-download']['en-us'] = "Download";
$text['label-download']['en-gb'] = "Download";
@ -6104,29 +6104,29 @@ $text['description-device_model']['zh-cn'] = "输入型号名称或编号。";
$text['description-device_model']['ja-jp'] = "モデル名またはモデル番号を入力します。";
$text['description-device_model']['ko-kr'] = "모델명 또는 번호를 입력하세요.";
$text['description-device_mac_address']['en-us'] = "Enter the MAC address.";
$text['description-device_mac_address']['en-gb'] = "Enter the MAC address.";
$text['description-device_mac_address']['ar-eg'] = "أدخل العنوان";
$text['description-device_mac_address']['de-at'] = "Geben Sie die MAC Adresse ein.";
$text['description-device_mac_address']['de-ch'] = "Geben Sie die MAC Adresse ein.";
$text['description-device_mac_address']['de-de'] = "Geben Sie die MAC Adresse ein.";
$text['description-device_mac_address']['es-cl'] = "Ingrese la dirección MAC";
$text['description-device_mac_address']['es-mx'] = "Ingrese la dirección MAC";
$text['description-device_mac_address']['fr-ca'] = "Entrez l'adresse MAC.";
$text['description-device_mac_address']['fr-fr'] = "Entrez l'adresse MAC.";
$text['description-device_mac_address']['he-il'] = "היכנס לכתובת MAC";
$text['description-device_mac_address']['it-it'] = "Inserire il MAC address.";
$text['description-device_mac_address']['nl-nl'] = "Voer het MAC adres in.";
$text['description-device_mac_address']['pl-pl'] = "Wprowadź adres MAC";
$text['description-device_mac_address']['pt-br'] = "Insira o endereço MAC";
$text['description-device_mac_address']['pt-pt'] = "Introduza o endereço MAC.";
$text['description-device_mac_address']['ro-ro'] = "Introduceți adresa MAC.";
$text['description-device_mac_address']['ru-ru'] = "Введите MAC-адрес.";
$text['description-device_mac_address']['sv-se'] = "Fyll i MAC-adress.";
$text['description-device_mac_address']['uk-ua'] = "Введіть адресу MAC.";
$text['description-device_mac_address']['zh-cn'] = "输入 MAC 地址。";
$text['description-device_mac_address']['ja-jp'] = "MAC アドレスを入力します。";
$text['description-device_mac_address']['ko-kr'] = "MAC 주소를 입력합니다.";
$text['description-device_address']['en-us'] = "Enter the address.";
$text['description-device_address']['en-gb'] = "Enter the address.";
$text['description-device_address']['ar-eg'] = "أدخل العنوان";
$text['description-device_address']['de-at'] = "Geben Sie die Adresse ein.";
$text['description-device_address']['de-ch'] = "Geben Sie die Adresse ein.";
$text['description-device_address']['de-de'] = "Geben Sie die Adresse ein.";
$text['description-device_address']['es-cl'] = "Ingrese la dirección";
$text['description-device_address']['es-mx'] = "Ingrese la dirección";
$text['description-device_address']['fr-ca'] = "Entrez l'adresse.";
$text['description-device_address']['fr-fr'] = "Entrez l'adresse.";
$text['description-device_address']['he-il'] = "היכנס לכתובת MAC";
$text['description-device_address']['it-it'] = "Inserire il address.";
$text['description-device_address']['nl-nl'] = "Voer het adres in.";
$text['description-device_address']['pl-pl'] = "Wprowadź adres";
$text['description-device_address']['pt-br'] = "Insira o endereço";
$text['description-device_address']['pt-pt'] = "Introduza o endereço.";
$text['description-device_address']['ro-ro'] = "Introduceți adresa.";
$text['description-device_address']['ru-ru'] = "Введите адрес.";
$text['description-device_address']['sv-se'] = "Fyll i adress.";
$text['description-device_address']['uk-ua'] = "Введіть адресу.";
$text['description-device_address']['zh-cn'] = "输入 地址。";
$text['description-device_address']['ja-jp'] = "アドレスを入力します。";
$text['description-device_address']['ko-kr'] = "주소를 입력합니다.";
$text['description-device_label']['en-us'] = "Enter the device label.";
$text['description-device_label']['en-gb'] = "Enter the device label.";

View File

@ -44,21 +44,21 @@
//set the http get/post variable(s) to a php variable
if (is_uuid($_REQUEST["id"]) && isset($_REQUEST["mac"])) {
$device_uuid = $_REQUEST["id"];
$device_mac_address = $_REQUEST["mac"];
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
$device_address = $_REQUEST["mac"];
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
}
//set the default
$save = true;
//check to see if the mac address exists
if ($device_mac_address == "" || $device_mac_address == "000000000000") {
//check to see if the device address exists
if ($device_address == "" || $device_address == "000000000000") {
//allow duplicates to be used as templaes
}
else {
$sql = "select count(*) from v_devices ";
$sql .= "where device_mac_address = :device_mac_address ";
$parameters['device_mac_address'] = $device_mac_address;
$sql .= "where device_address = :device_address ";
$parameters['device_address'] = $device_address;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
if ($num_rows == 0) {
@ -151,15 +151,15 @@
}
}
//normalize the mac address
if (isset($device_mac_address) && !empty($device_mac_address)) {
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
//normalize the device address
if (isset($device_address) && !empty($device_address)) {
$device_address = strtolower($device_address);
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
}
//create the device array
$device = $devices[0];
$device["device_mac_address"] = $device_mac_address;
$device["device_address"] = $device_address;
$device["device_lines"] = $device_lines;
$device["device_keys"] = $device_keys;
$device["device_settings"] = $device_settings;

View File

@ -76,7 +76,7 @@
//define possible columns in the array
$available_columns['devices'][] = 'device_uuid';
$available_columns['devices'][] = 'device_profile_uuid';
$available_columns['devices'][] = 'device_mac_address';
$available_columns['devices'][] = 'device_address';
$available_columns['devices'][] = 'device_label';
$available_columns['devices'][] = 'device_vendor';
$available_columns['devices'][] = 'device_template';

View File

@ -92,9 +92,9 @@
exit;
}
//device mac address
if (permission_exists('device_mac_address')) {
$device_mac_address = $_POST["device_mac_address"];
//device device address
if (permission_exists('device_address')) {
$device_address = $_POST["device_address"];
}
else {
$sql = "select * from v_devices ";
@ -103,7 +103,7 @@
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$device_mac_address = $row["device_mac_address"];
$device_address = $row["device_address"];
}
unset($sql, $parameters, $row);
}
@ -161,16 +161,16 @@
//$device_setting_enabled = $_POST["device_setting_enabled"];
//$device_setting_description = $_POST["device_setting_description"];
//normalize the mac address
if (!empty($device_mac_address)) {
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
//normalize the address
if (!empty($device_address)) {
$device_address = strtolower($device_address);
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
}
}
//use the mac address to get the vendor
//use the device address to get the vendor
if (empty($device_vendor)) {
$device_vendor = device::get_vendor($device_mac_address ?? null);
$device_vendor = device::get_vendor($device_address ?? null);
}
//add or update the database
@ -186,7 +186,7 @@
//check for all required data
$msg = '';
if (empty($device_mac_address)) { $msg .= $text['message-required'].$text['label-device_mac_address']."<br>\n"; }
if (empty($device_address)) { $msg .= $text['message-required'].$text['label-device_address']."<br>\n"; }
//if (empty($device_label)) { $msg .= "Please provide: Label<br>\n"; }
//if (empty($device_vendor)) { $msg .= "Please provide: Vendor<br>\n"; }
//if (empty($device_model)) { $msg .= "Please provide: Model<br>\n"; }
@ -210,7 +210,7 @@
}
//check for duplicates
if ($action == 'add' && $device_mac_address != "000000000000") {
if ($action == 'add' && $device_address != "000000000000") {
$sql = "select ";
$sql .= "d2.domain_name ";
$sql .= "from ";
@ -218,11 +218,11 @@
$sql .= "v_domains as d2 ";
$sql .= "where ";
$sql .= "d1.domain_uuid = d2.domain_uuid and ";
$sql .= "d1.device_mac_address = :device_mac_address ";
$sql .= "d1.device_address = :device_address ";
if (!empty($_GET["device_uuid"]) && is_uuid($_GET["device_uuid"])) {
$sql .= " and d1.device_uuid <> :device_uuid ";
}
$parameters['device_mac_address'] = $device_mac_address;
$parameters['device_address'] = $device_address;
$database = new database;
$domain_name = $database->select($sql, $parameters, 'column');
if ($domain_name != '') {
@ -245,8 +245,8 @@
//prepare the array
$array['devices'][0]['domain_uuid'] = $domain_uuid;
$array['devices'][0]['device_uuid'] = $device_uuid;
if (permission_exists('device_mac_address')) {
$array['devices'][0]['device_mac_address'] = $device_mac_address;
if (permission_exists('device_address')) {
$array['devices'][0]['device_address'] = $device_address;
}
//$array['devices'][0]['device_provisioned_ip'] = $device_provisioned_ip;
if (permission_exists('device_label')) {
@ -509,11 +509,11 @@
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$device_mac_address = $row["device_mac_address"];
$device_address = $row["device_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_address = substr($device_address, 0,2).'-'.substr($device_address, 2,2).'-'.substr($device_address, 4,2).'-'.substr($device_address, 6,2).'-'.substr($device_address, 8,2).'-'.substr($device_address, 10,2);
$device_label = $row["device_label"];
$device_user_uuid = $row["device_user_uuid"];
$device_username = $row["device_username"];
@ -534,12 +534,12 @@
//set the defaults
if (empty($device_enabled)) { $device_enabled = 'true'; }
//use the mac address to get the vendor
//use the device address to get the vendor
if (empty($device_vendor)) {
//get the device vendor using the mac address
$device_vendor = device::get_vendor($device_mac_address ?? null);
//get the device vendor using the device address
$device_vendor = device::get_vendor($device_address ?? null);
//if the vendor was not found using the mac address use an alternative method
//if the vendor was not found using the device address use an alternative method
if (empty($device_vendor)) {
$template_array = explode("/", $device_template ?? '');
$device_vendor = $template_array[0] ?? '';
@ -664,9 +664,9 @@
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//use the mac address to get the vendor
//use the device address to get the vendor
if (empty($device_vendor)) {
$device_vendor = device::get_vendor($device_mac_address ?? null);
$device_vendor = device::get_vendor($device_address ?? null);
}
//get the device line info for provision button
@ -720,7 +720,7 @@
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=".escape($device_mac_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?mac=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
echo " }\n";
echo "\n";
@ -869,9 +869,9 @@
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
echo " <option value=''>".$text['label-download']."</option>\n";
foreach ($files as $file) {
//format the mac address and
//format the device address
$format = new provision();
$mac = $format->format_mac($device_mac_address, $device_vendor);
$mac = $format->format_address($device_address, $device_vendor);
//render the file name
$file_name = str_replace("{\$mac}", $mac, basename($file));
//add the select option
@ -929,16 +929,16 @@
echo "<tr>\n";
echo "<td class='vncell' width='30%' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_mac_address']."\n";
echo " ".$text['label-device_address']."\n";
echo "</td>\n";
echo "<td class='vtable' width='70%' align='left'>\n";
if (permission_exists('device_mac_address')) {
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"".escape($device_mac_address ?? '')."\"/>\n";
if (permission_exists('device_address')) {
echo " <input class='formfld' type='text' name='device_address' id='device_address' maxlength='255' value=\"".escape($device_address ?? '')."\"/>\n";
echo "<br />\n";
echo $text['description-device_mac_address']."\n";
echo $text['description-device_address']."\n";
}
else {
echo escape($device_mac_address ?? '');
echo escape($device_address ?? '');
}
echo " <div style='display: none;' id='duplicate_mac_response'></div>\n";
echo " ".escape($device_provisioned_ip ?? '')." (<a href='http://".escape($device_provisioned_ip ?? '')."' target='_blank'>http</a>|<a href='https://".escape($device_provisioned_ip ?? '')."' target='_blank'>https</a>)\n";
@ -1794,7 +1794,7 @@
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
$label = $device_alternate[0]['device_label'];
if (empty($label)) { $label = $device_alternate[0]['device_description']; }
if (empty($label)) { $label = $device_alternate[0]['device_mac_address']; }
if (empty($label)) { $label = $device_alternate[0]['device_address']; }
echo " <table>\n";
echo " <tr>\n";
echo " <td><a href='?id=".escape($device_uuid_alternate)."' id='device_uuid_alternate_link'>".escape($label)."</a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"".escape($device_uuid_alternate)."\" />&nbsp;</td>";

File diff suppressed because it is too large Load Diff

View File

@ -126,7 +126,7 @@
}
if (!empty($search)) {
$sql .= "(";
$sql .= " lower(d.device_mac_address) like :search ";
$sql .= " lower(d.device_address) like :search ";
$sql .= " or lower(d.device_label) like :search ";
$sql .= " or lower(d.device_vendor) like :search ";
$sql .= " or lower(d.device_enabled) like :search ";
@ -212,7 +212,7 @@
}
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(d.device_mac_address) like :search ";
$sql .= " lower(d.device_address) like :search ";
$sql .= " or lower(d.device_label) like :search ";
$sql .= " or lower(d.device_vendor) like :search ";
$sql .= " or lower(d.device_enabled) like :search ";
@ -361,7 +361,7 @@
if (!empty($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param);
}
echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_address', $text['label-device_address'], $order_by, $order, null, null, $param ?? null);
echo th_order_by('device_label', $text['label-device_label'], $order_by, $order, null, null, $param ?? null);
if ($device_alternate) {
echo th_order_by('device_template', $text['label-device_uuid_alternate'], $order_by, $order, null, null, $param ?? null);
@ -413,7 +413,7 @@
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
}
echo " <td class='no-wrap'>";
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_mac($row['device_mac_address']))."</a>" : escape(format_mac($row['device_mac_address']));
echo permission_exists('device_edit') ? "<a href='".$list_row_url."'>".escape(format_device_address($row['device_address']))."</a>" : escape(format_device_address($row['device_address']));
echo " </td>\n";
echo " <td>".escape($row['device_label'])."&nbsp;</td>\n";
if ($device_alternate) {

View File

@ -1687,29 +1687,29 @@ $text['label-device_template']['zh-cn'] = "模板";
$text['label-device_template']['ja-jp'] = "レンプレート";
$text['label-device_template']['ko-kr'] = "주형";
$text['label-device_mac_address']['en-us'] = "MAC Address";
$text['label-device_mac_address']['en-gb'] = "MAC Address";
$text['label-device_mac_address']['ar-eg'] = "العنوان الرئيسي";
$text['label-device_mac_address']['de-at'] = "MAC Adresse";
$text['label-device_mac_address']['de-ch'] = "MAC Adresse";
$text['label-device_mac_address']['de-de'] = "MAC Adresse";
$text['label-device_mac_address']['es-cl'] = "Mac dirección";
$text['label-device_mac_address']['es-mx'] = "Mac dirección";
$text['label-device_mac_address']['fr-ca'] = "Adresse MAC";
$text['label-device_mac_address']['fr-fr'] = "Adresse MAC";
$text['label-device_mac_address']['he-il'] = "כתובת MAC";
$text['label-device_mac_address']['it-it'] = "MAC Address";
$text['label-device_mac_address']['nl-nl'] = "MAC-Adres";
$text['label-device_mac_address']['pl-pl'] = "Adres MAC";
$text['label-device_mac_address']['pt-br'] = "Endereço MAC";
$text['label-device_mac_address']['pt-pt'] = "Endereço MAC";
$text['label-device_mac_address']['ro-ro'] = "Adresa mac";
$text['label-device_mac_address']['ru-ru'] = "MAC Адреса";
$text['label-device_mac_address']['sv-se'] = "MAC-adress";
$text['label-device_mac_address']['uk-ua'] = "Адреса MAC";
$text['label-device_mac_address']['zh-cn'] = "MAC地址";
$text['label-device_mac_address']['ja-jp'] = "Macアドレス";
$text['label-device_mac_address']['ko-kr'] = "MAC 주소";
$text['label-device_address']['en-us'] = "Address";
$text['label-device_address']['en-gb'] = "Address";
$text['label-device_address']['ar-eg'] = "العنوان الرئيسي";
$text['label-device_address']['de-at'] = "Adresse";
$text['label-device_address']['de-ch'] = "Adresse";
$text['label-device_address']['de-de'] = "Adresse";
$text['label-device_address']['es-cl'] = "dirección";
$text['label-device_address']['es-mx'] = "dirección";
$text['label-device_address']['fr-ca'] = "Adresse";
$text['label-device_address']['fr-fr'] = "Adresse";
$text['label-device_address']['he-il'] = "כתובת";
$text['label-device_address']['it-it'] = "Address";
$text['label-device_address']['nl-nl'] = "Adres";
$text['label-device_address']['pl-pl'] = "Adres";
$text['label-device_address']['pt-br'] = "Endereço";
$text['label-device_address']['pt-pt'] = "Endereço";
$text['label-device_address']['ro-ro'] = "Adresa";
$text['label-device_address']['ru-ru'] = "Адреса";
$text['label-device_address']['sv-se'] = "adress";
$text['label-device_address']['uk-ua'] = "Адреса";
$text['label-device_address']['zh-cn'] = "地址";
$text['label-device_address']['ja-jp'] = "アドレス";
$text['label-device_address']['ko-kr'] = "주소";
$text['label-description']['en-us'] = "Description";
$text['label-description']['en-gb'] = "Description";

View File

@ -172,20 +172,20 @@
//device provisioning variables
if (is_array($_POST["devices"]) && @sizeof($_POST["devices"]) != 0) {
foreach ($_POST["devices"] as $d => $device) {
$device_mac_address = strtolower($device["device_mac_address"]);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
$device_address = strtolower($device["device_address"]);
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
$line_numbers[$d] = $device["line_number"];
$device_mac_addresses[$d] = $device_mac_address;
$device_addresses[$d] = $device_address;
$device_templates[$d] = $device["device_template"];
}
}
//get or set the device_uuid
if (!empty($device_mac_addresses) && is_array($device_mac_addresses) && @sizeof($device_mac_addresses) != 0) {
foreach ($device_mac_addresses as $d => $device_mac_address) {
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
if (!empty($device_addresses) && is_array($device_addresses) && @sizeof($device_addresses) != 0) {
foreach ($device_addresses as $d => $device_address) {
$device_address = strtolower($device_address);
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
$sql = "select ";
$sql .= "d1.device_uuid, ";
@ -196,8 +196,8 @@
$sql .= "v_domains as d2 ";
$sql .= "where ";
$sql .= "d1.domain_uuid = d2.domain_uuid and ";
$sql .= "d1.device_mac_address = :device_mac_address ";
$parameters['device_mac_address'] = $device_mac_address;
$sql .= "d1.device_address = :device_address ";
$parameters['device_address'] = $device_address;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
@ -520,9 +520,9 @@
}
//assign the device to the extension(s)
if (is_array($device_mac_addresses) && @sizeof($device_mac_addresses) != 0) {
foreach ($device_mac_addresses as $d => $device_mac_address) {
if (is_mac($device_mac_address)) {
if (is_array($device_addresses) && @sizeof($device_addresses) != 0) {
foreach ($device_addresses as $d => $device_address) {
if (!emtpy($device_address)) {
//get the device vendor
if (isset($device_templates[$d])) {
//use the the template to get the vendor
@ -530,8 +530,8 @@
$device_vendor = $template_array[0];
}
else {
//use the mac address to get the vendor
$device_vendor = device::get_vendor($device_mac_address);
//use the device address to get the vendor
$device_vendor = device::get_vendor($device_address);
}
//determine the name
@ -592,10 +592,10 @@
}
//build the devices array
if ($device_unique && $device_mac_address != '000000000000') {
if ($device_unique && $device_address != '000000000000') {
$array["devices"][$j]["device_uuid"] = $device_uuids[$d];
$array["devices"][$j]["domain_uuid"] = $_SESSION['domain_uuid'];
$array["devices"][$j]["device_mac_address"] = $device_mac_address;
$array["devices"][$j]["device_address"] = $device_address;
$array["devices"][$j]["device_label"] = $extension;
if (!empty($device_vendor)) {
$array["devices"][$j]["device_vendor"] = $device_vendor;
@ -898,12 +898,12 @@
}
//get the device lines
$sql = "select d.device_mac_address, d.device_template, d.device_description, l.device_line_uuid, l.device_uuid, l.line_number ";
$sql = "select d.device_address, d.device_template, d.device_description, l.device_line_uuid, l.device_uuid, l.line_number ";
$sql .= "from v_device_lines as l, v_devices as d ";
$sql .= "where (l.user_id = :user_id_1 or l.user_id = :user_id_2)";
$sql .= "and l.domain_uuid = :domain_uuid ";
$sql .= "and l.device_uuid = d.device_uuid ";
$sql .= "order by l.line_number, d.device_mac_address asc ";
$sql .= "order by l.line_number, d.device_address asc ";
$parameters['user_id_1'] = $extension ?? null;
$parameters['user_id_2'] = $number_alias ?? null;
$parameters['domain_uuid'] = $domain_uuid;
@ -914,7 +914,7 @@
//get the devices
$sql = "select * from v_devices ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by device_mac_address asc ";
$sql .= "order by device_address asc ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$devices = $database->select($sql, $parameters, 'all');
@ -1252,7 +1252,7 @@
echo " ".$text['label-line']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$text['label-device_mac_address']."&nbsp;\n";
echo " ".$text['label-device_address']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$text['label-device_template']."&nbsp;\n";
@ -1264,10 +1264,10 @@
if ($action == 'update') {
if (is_array($device_lines) && @sizeof($device_lines) != 0) {
foreach ($device_lines as $row) {
$device_mac_address = format_mac($row['device_mac_address']);
$device_address = format_device_address($row['device_address']);
echo " <tr>\n";
echo " <td class='vtable'>".escape($row['line_number'])."</td>\n";
echo " <td class='vtable'><a href='".PROJECT_PATH."/app/devices/device_edit.php?id=".escape($row['device_uuid'])."'>".escape($device_mac_address)."</a></td>\n";
echo " <td class='vtable'><a href='".PROJECT_PATH."/app/devices/device_edit.php?id=".escape($row['device_uuid'])."'>".escape($device_address)."</a></td>\n";
echo " <td class='vtable'>".escape($row['device_template'])."&nbsp;</td>\n";
//echo " <td class='vtable'>".$row['device_description']."&nbsp;</td>\n";
echo " <td>\n";
@ -1295,49 +1295,49 @@
?>
<script>
var Objs;
function changeToInput_device_mac_address_<?php echo $d; ?>(obj){
function changeToInput_device_address_<?php echo $d; ?>(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
tb.setAttribute('id', 'device_mac_address_<?php echo $d; ?>');
tb.setAttribute('id', 'device_address_<?php echo $d; ?>');
tb.setAttribute('style', 'width: 80%;');
tb.setAttribute('pattern', '^([0-9A-Fa-f]{2}[:-]?){5}([0-9A-Fa-f]{2})$');
tb.value=obj.options[obj.selectedIndex].value;
document.getElementById('btn_select_to_input_device_mac_address_<?php echo $d; ?>').style.visibility = 'hidden';
document.getElementById('btn_select_to_input_device_address_<?php echo $d; ?>').style.visibility = 'hidden';
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ replace_device_mac_address_<?php echo $d; ?>(this.objs); }
tbb.onclick=function(){ replace_device_address_<?php echo $d; ?>(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
replace_device_mac_address_<?php echo $d; ?>(this.objs);
replace_device_address_<?php echo $d; ?>(this.objs);
}
function replace_device_mac_address_<?php echo $d; ?>(obj){
function replace_device_address_<?php echo $d; ?>(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
document.getElementById('btn_select_to_input_device_mac_address_<?php echo $d; ?>').style.visibility = 'visible';
document.getElementById('btn_select_to_input_device_address_<?php echo $d; ?>').style.visibility = 'visible';
}
</script>
<?php
echo " <select id='device_mac_address_".$d."' name='devices[".$d."][device_mac_address]' class='formfld' style='width: 180px;' onchange=\"changeToInput_device_mac_address_".$d."(this); this.style.visibility='hidden';\">\n";
echo " <select id='device_address_".$d."' name='devices[".$d."][device_address]' class='formfld' style='width: 180px;' onchange=\"changeToInput_device_address_".$d."(this); this.style.visibility='hidden';\">\n";
echo " <option value=''></option>\n";
if (is_array($devices) && @sizeof($devices) != 0) {
foreach ($devices as $field) {
if (!empty($field["device_mac_address"])) {
$selected = $field_current_value == $field["device_mac_address"] ? "selected='selected'" : null;
echo " <option value='".escape($field["device_mac_address"])."' ".$selected.">".escape($field["device_mac_address"])." - ".escape($field['device_model'])." ".escape($field['device_description'])."</option>\n";
if (!empty($field["device_address"])) {
$selected = $field_current_value == $field["device_address"] ? "selected='selected'" : null;
echo " <option value='".escape($field["device_address"])."' ".$selected.">".escape($field["device_address"])." - ".escape($field['device_model'])." ".escape($field['device_description'])."</option>\n";
}
}
}
echo " </select>\n";
echo " <input type='button' id='btn_select_to_input_device_mac_address_".$d."' class='btn' alt='".$text['button-back']."' onclick=\"changeToInput_device_mac_address_".$d."(document.getElementById('device_mac_address_".$d."')); this.style.visibility='hidden';\" value='&#9665;'>\n";
echo " <input type='button' id='btn_select_to_input_device_address_".$d."' class='btn' alt='".$text['button-back']."' onclick=\"changeToInput_device_address_".$d."(document.getElementById('device_address_".$d."')); this.style.visibility='hidden';\" value='&#9665;'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";

View File

@ -28,21 +28,21 @@
if ($domains_processed == 1) {
//normalize the mac address
$sql = "select device_uuid, device_mac_address ";
$sql = "select device_uuid, device_address ";
$sql .= "from v_devices ";
$sql .= "where (device_mac_address like '%-%' or device_mac_address like '%:%') ";
$sql .= "where (device_address like '%-%' or device_address like '%:%') ";
$database = new database;
$result = $database->select($sql, null, 'all');
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
//define update values
$device_uuid = $row["device_uuid"];
$device_mac_address = $row["device_mac_address"];
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
$device_address = $row["device_address"];
$device_address = strtolower($device_address);
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
//build update array
$array['devices'][0]['device_uuid'] = $device_uuid;
$array['devices'][0]['device_mac_address'] = $device_mac_address;
$array['devices'][0]['device_address'] = $device_address;
//grant temporary permissions
$p = new permissions;
$p->add('device_add', 'temp');

View File

@ -38,18 +38,23 @@
$device_template = '';
//define PHP variables from the HTTP values
$mac = $_REQUEST['mac'];
if (isset($_REQUEST['mac'])) {
$device_address = $_REQUEST['mac'];
}
if (isset($_REQUEST['address'])) {
$device_address = $_REQUEST['address'];
}
$file = $_REQUEST['file'];
$ext = $_REQUEST['ext'];
//if (!empty($_REQUEST['template'])) {
// $device_template = $_REQUEST['template'];
//}
//get the mac address for Cisco 79xx in the URL as &name=SEP000000000000
if (empty($mac)) {
//get the device address for Cisco 79xx in the URL as &name=SEP000000000000
if (empty($device_address)) {
$name = $_REQUEST['name'];
if (substr($name, 0, 3) == "SEP") {
$mac = strtolower(substr($name, 3, 12));
$device_address = strtolower(substr($name, 3, 12));
unset($name);
}
}
@ -57,12 +62,12 @@
// Escence make request based on UserID for Memory keys
// The file name is fixed to `Account1_Extern.xml`.
// (Account1 is the first account you register)
if (empty($mac) && !empty($ext)) {
if (empty($device_address) && !empty($ext)) {
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
$domain_name = $domain_array[0];
$device = device_by_ext($ext, $domain_name);
if ($device !== false && ($device['device_vendor'] == 'escene' || $device['device_vendor'] == 'grandstream')) {
$mac = $device['device_mac_address'];
$device_address = $device['device_address'];
}
}
@ -81,71 +86,71 @@
exit;
}
//check alternate MAC source
if (empty($mac)) {
//check alternate device address source
if (empty($device_address)) {
//set the http user agent
//$_SERVER['HTTP_USER_AGENT'] = "Yealink SIP-T38G 38.70.0.125 00:15:65:00:00:00";
//$_SERVER['HTTP_USER_AGENT'] = "Yealink SIP-T56A 58.80.0.25 001565f429a4";
//Yealink: 17 digit mac appended to the user agent, so check for a space exactly 17 digits before the end.
if (strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,7)) == "yealink" || strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,5)) == "vp530") {
if (strstr(substr($_SERVER['HTTP_USER_AGENT'],-4), ':')) { //remove colons if they exist
$mac = substr($_SERVER['HTTP_USER_AGENT'],-17);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-17);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
} else { //take mac as is - fixes T5X series
$mac = substr($_SERVER['HTTP_USER_AGENT'],-12);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-12);
}
}
//HTek: $_SERVER['HTTP_USER_AGENT'] = "Htek UC926 2.0.4.2 00:1f:c1:00:00:00"
if (substr($_SERVER['HTTP_USER_AGENT'],0,4) == "Htek") {
$mac = substr($_SERVER['HTTP_USER_AGENT'],-17);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-17);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
//Panasonic: $_SERVER['HTTP_USER_AGENT'] = "Panasonic_KX-UT670/01.022 (0080f000000)"
if (substr($_SERVER['HTTP_USER_AGENT'],0,9) == "Panasonic") {
$mac = substr($_SERVER['HTTP_USER_AGENT'],-14);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-14);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
//Grandstream: $_SERVER['HTTP_USER_AGENT'] = "Grandstream Model HW GXP2135 SW 1.0.7.97 DevId 000b828aa872"
if (substr($_SERVER['HTTP_USER_AGENT'],0,11) == "Grandstream") {
$mac = substr($_SERVER['HTTP_USER_AGENT'],-12);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-12);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
//Audiocodes: $_SERVER['HTTP_USER_AGENT'] = "AUDC-IPPhone/2.2.8.61 (440HDG-Rev0; 00908F602AAC)"
if (substr($_SERVER['HTTP_USER_AGENT'],0,12) == "AUDC-IPPhone") {
$mac = substr($_SERVER['HTTP_USER_AGENT'],-13);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-13);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
//Aastra: $_SERVER['HTTP_USER_AGENT'] = "Aastra6731i MAC:00-08-5D-29-4C-6B V:3.3.1.4365-SIP"
if (substr($_SERVER['HTTP_USER_AGENT'],0,6) == "Aastra") {
preg_match("/MAC:([A-F0-9-]{17})/", $_SERVER['HTTP_USER_AGENT'], $matches);
$mac = $matches[1];
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = $matches[1];
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
//Flyingvoice: $_SERVER['HTTP_USER_AGENT'] = "Flyingvoice FIP13G V0.6.24 00:21:F2:22:AE:F1"
if (strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,11)) == "flyingvoice") {
$mac = substr($_SERVER['HTTP_USER_AGENT'],-17);
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
$device_address = substr($_SERVER['HTTP_USER_AGENT'],-17);
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
}
}
//prepare the mac address
if (isset($mac)) {
//normalize the mac address to lower case
$mac = strtolower($mac);
//replace all non hexadecimal values and validate the mac address
$mac = preg_replace("#[^a-fA-F0-9./]#", "", $mac);
if (strlen($mac) != 12) {
echo "invalid mac address";
exit;
}
//prepare the device address
if (isset($device_address)) {
//normalize the device address to lower case
$device_address = strtolower($device_address);
//replace all non hexadecimal values and validate the device address
$device_address = preg_replace("#[^a-fA-F0-9./]#", "", $device_address);
//if (strlen($device_address) != 12) {
// echo "invalid mac address";
// exit;
//}
}
//get the domain_uuid, domain_name, device_name and device_vendor
$sql = "select d.device_uuid, d.domain_uuid, d.device_vendor, n.domain_name ";
$sql .= "from v_devices as d, v_domains as n ";
$sql .= "where device_mac_address = :mac ";
$sql .= "where device_address = :device_address ";
$sql .= "and d.domain_uuid = n.domain_uuid; ";
$parameters['mac'] = $mac;
$parameters['device_address'] = $device_address;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
@ -267,22 +272,22 @@
//check if provisioning has been enabled
if ($provision["enabled"] != "true") {
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but provisioning is not enabled for ".check_str($_REQUEST['mac']));
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but provisioning is not enabled for ".escape($_REQUEST['mac']));
http_error('404');
}
//send a request to a remote server to validate the MAC address and secret
if (!empty($_SERVER['auth_server'])) {
$result = send_http_request($_SERVER['auth_server'], 'mac='.check_str($_REQUEST['mac']).'&secret='.check_str($_REQUEST['secret']));
$result = send_http_request($_SERVER['auth_server'], 'mac='.url_encode($_REQUEST['mac']).'&secret='.url_encode($_REQUEST['secret']));
if ($result == "false") {
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".check_str($_REQUEST['mac']));
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".escape($_REQUEST['mac']));
http_error('404');
}
}
//use the mac address to get the vendor
//use the device address to get the vendor
if (empty($device_vendor)) {
$device_vendor = device::get_vendor($mac);
$device_vendor = device::get_vendor($device_address);
}
//keep backwards compatibility
@ -300,7 +305,7 @@
}
}
if (!$found) {
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but failed CIDR check for ".check_str($_REQUEST['mac']));
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but failed CIDR check for ".escape($_REQUEST['mac']));
http_error('404');
}
}
@ -429,18 +434,18 @@
//output template to string for header processing
$prov = new provision;
$prov->domain_uuid = $domain_uuid;
$prov->mac = $mac;
$prov->device_address = $device_address;
$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);
//format the device address and
$device_address_formatted = $prov->format_address($device_address, $device_vendor);
//replace the variable name with the value
$file_name = str_replace("{\$mac}", $mac, $file);
$file_name = str_replace("{\$device_address}", $device_address_formatted, $file);
//set the headers
header('Content-Description: File Transfer');

View File

@ -31,7 +31,7 @@
public $domain_uuid;
public $domain_name;
public $template_dir;
public $mac;
public $device_address;
public function __construct() {
//set the default template directory
@ -82,9 +82,9 @@
}
}
//normalize the mac address
if (isset($this->mac)) {
$this->mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->mac));
//normalize the device address
if (isset($this->device_address)) {
$this->device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->device_address));
}
}
@ -92,14 +92,14 @@
return $this->domain_uuid;
}
//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
//define the function which checks to see if the device address exists in devices
private function device_exists($device_address) {
//normalize the device address
$device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_address));
//check in the devices table for a specific device address
$sql = "select count(*) from v_devices ";
$sql .= "where device_mac_address = :mac ";
$parameters['mac'] = $mac;
$sql .= "where device_address = :device_address ";
$parameters['device_address'] = $device_address;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
if ($num_rows > 0) {
@ -111,44 +111,44 @@
unset($sql, $parameters, $num_rows);
}
//set the mac address in the correct format for the specific vendor
public function format_mac($mac, $vendor) {
//set the device address in the correct format for the specific vendor
public function format_address($device_address, $vendor) {
switch (strtolower($vendor)) {
case "algo":
return strtoupper($mac);
return strtoupper($device_address);
break;
case "aastra":
return strtoupper($mac);
return strtoupper($device_address);
break;
case "cisco":
return strtoupper($mac);
return strtoupper($device_address);
break;
case "linksys":
return strtolower($mac);
return strtolower($device_address);
break;
case "mitel":
return strtoupper($mac);
return strtoupper($device_address);
break;
case "polycom":
return strtolower($mac);
return strtolower($device_address);
break;
case "snom":
return strtolower($mac);
return strtolower($device_address);
break;
case "escene":
return strtolower($mac);
return strtolower($device_address);
break;
case "grandstream":
return strtolower($mac);
return strtolower($device_address);
break;
case "yealink":
return strtolower($mac);
return strtolower($device_address);
break;
case "gigaset":
return strtoupper($mac);
return strtoupper($device_address);
break;
default:
return strtolower($mac);
return strtolower($device_address);
}
}
@ -257,11 +257,11 @@
$domain_uuid = $this->domain_uuid;
$device_template = $this->device_template;
$template_dir = $this->template_dir;
$mac = $this->mac;
$device_address = $this->device_address;
$file = $this->file;
//set the mac address to lower case to be consistent with the database
$mac = strtolower($mac);
//set the device address to lower case to be consistent with the database
$device_address = strtolower($device_address);
//get the device template
//if (!empty($_REQUEST['template'])) {
@ -296,7 +296,8 @@
elseif (is_array($val) && !is_uuid($val['uuid'])) { $value = $val; }
if (isset($value)) {
$value = str_replace('${domain_name}', $domain_name, $value);
$value = str_replace('${mac_address}', $mac, $value);
$value = str_replace('${mac_address}', $device_address, $value);
$value = str_replace('${device_address}', $device_address, $value);
$provision[$key] = $value;
}
unset($value);
@ -308,18 +309,18 @@
$provision["http_auth_password"] = $_SESSION['provision']["http_auth_password"][0];
}
//check to see if the mac_address exists in devices
//check to see if the device_address exists in devices
//if (empty($_REQUEST['user_id']) || empty($_REQUEST['userid'])) {
if ($this->mac_exists($mac)) {
if ($this->device_exists($device_address)) {
//get the device_template
$sql = "select * from v_devices ";
$sql .= "where device_mac_address = :mac_address ";
$sql .= "where device_address = :device_address ";
if ($provision['http_domain_filter'] == "true") {
$sql .= "and domain_uuid=:domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['mac_address'] = $mac;
$parameters['device_address'] = $device_address;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
unset($parameters);
@ -340,9 +341,9 @@
//register that we have seen the device
$sql = "update v_devices ";
$sql .= "set device_provisioned_date = :device_provisioned_date, device_provisioned_method = :device_provisioned_method, device_provisioned_ip = :device_provisioned_ip, device_provisioned_agent = :device_provisioned_agent ";
$sql .= "where domain_uuid = :domain_uuid and device_mac_address = :device_mac_address ";
$sql .= "where domain_uuid = :domain_uuid and device_address = :device_address ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['device_mac_address'] = strtolower($mac);
$parameters['device_address'] = strtolower($device_address);
$parameters['device_provisioned_date'] = 'now()';
$parameters['device_provisioned_method'] = (isset($_SERVER["HTTPS"]) ? 'https' : 'http');
$parameters['device_provisioned_ip'] = $_SERVER['REMOTE_ADDR'];
@ -521,7 +522,7 @@
}
unset($templates);
//mac address does not exist in the table so add it
//device address does not exist in the table so add it
if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" && is_uuid($domain_uuid)) {
//get a new primary key
@ -531,7 +532,7 @@
$x = 0;
$array['devices'][$x]['domain_uuid'] = $domain_uuid;
$array['devices'][$x]['device_uuid'] = $device_uuid;
$array['devices'][$x]['device_mac_address'] = $mac;
$array['devices'][$x]['device_address'] = $device_address;
$array['devices'][$x]['device_vendor'] = $device_vendor;
$array['devices'][$x]['device_enabled'] = 'true';
$array['devices'][$x]['device_template'] = $device_template;
@ -665,8 +666,8 @@
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
//create a mac address with back slashes for backwards compatability
$mac_dash = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2);
//create a device address with back slashes for backwards compatability
//$address_dash = substr($device_address, 0,2).'-'.substr($device_address, 2,2).'-'.substr($device_address, 4,2).'-'.substr($device_address, 6,2).'-'.substr($device_address, 8,2).'-'.substr($device_address, 10,2);
//get the provisioning information
if (is_uuid($device_uuid)) {
@ -1110,8 +1111,8 @@
}
}
//set the mac address in the correct format
$mac = $this->format_mac($mac, $device_vendor);
//set the device address in the correct format
$device_address = $this->format_address($device_address, $device_vendor);
// set date/time for versioning provisioning templates
if (!empty($_SESSION['provision']['version_format']['text'])) {
@ -1122,8 +1123,10 @@
}
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$view->assign("mac" , $mac);
$view->assign("time" , $time);
$view->assign("device_address", $device_address);
$view->assign("address", $device_address);
$view->assign("mac", $device_address);
$view->assign("time", $time);
$view->assign("label", $device_label);
$view->assign("device_label", $device_label);
$view->assign("firmware_version", $device_firmware_version);
@ -1131,12 +1134,12 @@
$view->assign("project_path", PROJECT_PATH);
$view->assign("server1_address", $server1_address);
$view->assign("proxy1_address", $proxy1_address);
$view->assign("user_id",$user_id);
$view->assign("password",$password);
$view->assign("template",$device_template);
$view->assign("location",$device_location);
$view->assign("device_location",$device_location);
$view->assign("microtime",microtime(true));
$view->assign("user_id", $user_id);
$view->assign("password", $password);
$view->assign("template", $device_template);
$view->assign("location", $device_location);
$view->assign("device_location", $device_location);
$view->assign("microtime", microtime(true));
//personal ldap password
global $laddr_salt;
@ -1188,6 +1191,9 @@
//if $file is not provided then look for a default file that exists
if (empty($file)) {
if (file_exists($template_dir."/".$device_template ."/{\$address}")) {
$file = "{\$address}";
}
if (file_exists($template_dir."/".$device_template ."/{\$mac}")) {
$file = "{\$mac}";
}
@ -1223,7 +1229,7 @@
if ($_SESSION['provision']['debug']['boolean'] == 'true') {
$tmp_file = "/tmp/provisioning_log.txt";
$fh = fopen($tmp_file, 'w') or die("can't open file");
$tmp_string = $mac."\n";
$tmp_string = $device_address."\n";
fwrite($fh, $tmp_string);
fclose($fh);
}
@ -1267,7 +1273,7 @@
//get the values from the database and set as variables
$domain_uuid = $row["domain_uuid"];
$device_uuid = $row["device_uuid"];
$device_mac_address = $row["device_mac_address"];
$device_address = $row["device_address"];
$device_label = $row["device_label"];
$device_vendor = strtolower($row["device_vendor"]);
$device_model = $row["device_model"];
@ -1314,14 +1320,15 @@
//configure device object
$this->domain_uuid = $domain_uuid;
$this->mac = $device_mac_address;
$this->device_address = $device_address;
$this->file = $file_name;
//format the mac address
$mac = $this->format_mac($device_mac_address, $device_vendor);
//format the device address
$address_formatted = $this->format_address($device_address, $device_vendor);
//replace {$mac} in the file name
$file_name = str_replace("{\$mac}", $mac, $file_name);
$file_name = str_replace("{\$mac}", $address_formatted, $file_name);
$file_name = str_replace("{\$address}", $address_formatted, $file_name);
//render and write configuration to file
$provision_dir_array = explode(";", $provision["path"]);

View File

@ -1,10 +1,10 @@
<?php
function device_by_mac($mac) {
function device_by_mac($device_address) {
$sql = "select * from v_devices ";
$sql .= "where device_mac_address = :mac ";
$sql .= "where device_address = :device_address ";
$sql .= "and device_enabled = 'true' ";
$parameters['mac'] = $mac;
$parameters['device_address'] = $device_address;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
return is_array($row) && @sizeof($row) != 0 ? $row : false;

File diff suppressed because it is too large Load Diff