Changes the names from hardwware_phones and phones to devices.

This commit is contained in:
Mark Crane
2013-04-09 22:33:42 +00:00
parent 9374f6ba4b
commit eacb503fab
2 changed files with 47 additions and 47 deletions
+10 -10
View File
@@ -25,23 +25,23 @@
*/ */
//normalize the mac address //normalize the mac address
$sql = "select hardware_phone_uuid, phone_mac_address "; $sql = "select device_uuid, device_mac_address ";
$sql .= "from v_hardware_phones "; $sql .= "from v_devices ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and (phone_mac_address like '%-%' or phone_mac_address like '%:%') "; $sql .= "and (device_mac_address like '%-%' or device_mac_address like '%:%') ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) { foreach($result as $row) {
$hardware_phone_uuid = $row["hardware_phone_uuid"]; $device_uuid = $row["device_uuid"];
$phone_mac_address = $row["phone_mac_address"]; $device_mac_address = $row["device_mac_address"];
$phone_mac_address = strtolower($phone_mac_address); $device_mac_address = strtolower($device_mac_address);
$phone_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $phone_mac_address); $device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
$sql = "update v_hardware_phones set "; $sql = "update v_devices set ";
$sql .= "phone_mac_address = '".$phone_mac_address."' "; $sql .= "device_mac_address = '".$device_mac_address."' ";
$sql .= "where hardware_phone_uuid = '".$hardware_phone_uuid."' "; $sql .= "where device_uuid = '".$device_uuid."' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
} }
+37 -37
View File
@@ -40,60 +40,60 @@ else {
$tmp_array = ''; $tmp_array = '';
//get the hardware phone list //get the hardware phone list
$sql = "select * from v_hardware_phones "; $sql = "select * from v_devices ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$phone_mac_address = $row["phone_mac_address"]; $device_mac_address = $row["device_mac_address"];
$phone_label = $row["phone_label"]; $device_label = $row["device_label"];
$phone_vendor = $row["phone_vendor"]; $device_vendor = $row["device_vendor"];
$phone_model = $row["phone_model"]; $device_model = $row["device_model"];
$phone_firmware_version = $row["phone_firmware_version"]; $device_firmware_version = $row["device_firmware_version"];
$phone_provision_enable = $row["phone_provision_enable"]; $device_provision_enable = $row["device_provision_enable"];
$phone_template = $row["phone_template"]; $device_template = $row["device_template"];
$phone_username = $row["phone_username"]; $device_username = $row["device_username"];
$phone_password = $row["phone_password"]; $device_password = $row["device_password"];
$phone_time_zone = $row["phone_time_zone"]; $device_time_zone = $row["device_time_zone"];
$phone_description = $row["phone_description"]; $device_description = $row["device_description"];
//use the mac address to find the vendor //use the mac address to find the vendor
if (strlen($phone_vendor) == 0) { if (strlen($device_vendor) == 0) {
switch (substr($phone_mac_address, 0, 6)) { switch (substr($device_mac_address, 0, 6)) {
case "00085d": case "00085d":
$phone_vendor = "aastra"; $device_vendor = "aastra";
break; break;
case "000e08": case "000e08":
$phone_vendor = "linksys"; $device_vendor = "linksys";
break; break;
case "0004f2": case "0004f2":
$phone_vendor = "polycom"; $device_vendor = "polycom";
break; break;
case "00907a": case "00907a":
$phone_vendor = "polycom"; $device_vendor = "polycom";
break; break;
case "001873": case "001873":
$phone_vendor = "cisco"; $device_vendor = "cisco";
break; break;
case "00045a": case "00045a":
$phone_vendor = "linksys"; $device_vendor = "linksys";
break; break;
case "000625": case "000625":
$phone_vendor = "linksys"; $device_vendor = "linksys";
break; break;
case "001565": case "001565":
$phone_vendor = "yealink"; $device_vendor = "yealink";
break; break;
case "000413": case "000413":
$phone_vendor = "snom"; $device_vendor = "snom";
default: default:
$phone_vendor = ""; $device_vendor = "";
} }
} }
//set the mac address in the correct format //set the mac address in the correct format
switch ($phone_vendor) { switch ($device_vendor) {
case "aastra": case "aastra":
$mac = strtoupper($mac); $mac = strtoupper($mac);
break; break;
@@ -106,7 +106,7 @@ else {
} }
//loop through the provision template directory //loop through the provision template directory
$provision_template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template; $provision_template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$device_template;
clearstatcache(); clearstatcache();
$dir_list = ''; $dir_list = '';
@@ -159,14 +159,14 @@ else {
$file_size = round(filesize($new_path)/1024, 2); $file_size = round(filesize($new_path)/1024, 2);
//get the contents of the template //get the contents of the template
$file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/".$file_name); $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$device_template ."/".$file_name);
//prepare the files //prepare the files
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_contents = str_replace("{v_mac}", $phone_mac_address, $file_contents); $file_contents = str_replace("{v_mac}", $device_mac_address, $file_contents);
$file_contents = str_replace("{v_label}", $phone_label, $file_contents); $file_contents = str_replace("{v_label}", $device_label, $file_contents);
$file_contents = str_replace("{v_firmware_version}", $phone_firmware_version, $file_contents); $file_contents = str_replace("{v_firmware_version}", $device_firmware_version, $file_contents);
$file_contents = str_replace("{domain_time_zone}", $phone_time_zone, $file_contents); $file_contents = str_replace("{domain_time_zone}", $device_time_zone, $file_contents);
$file_contents = str_replace("{domain_name}", $_SESSION['domain_name'], $file_contents); $file_contents = str_replace("{domain_name}", $_SESSION['domain_name'], $file_contents);
$file_contents = str_replace("{v_server1_address}", $server1_address, $file_contents); $file_contents = str_replace("{v_server1_address}", $server1_address, $file_contents);
$file_contents = str_replace("{v_proxy1_address}", $proxy1_address, $file_contents); $file_contents = str_replace("{v_proxy1_address}", $proxy1_address, $file_contents);
@@ -178,12 +178,12 @@ else {
} }
//create a mac address with back slashes for backwards compatability //create a mac address with back slashes for backwards compatability
$mac_dash = substr($phone_mac_address, 0,2).'-'.substr($phone_mac_address, 2,2).'-'.substr($phone_mac_address, 4,2).'-'.substr($phone_mac_address, 6,2).'-'.substr($phone_mac_address, 8,2).'-'.substr($phone_mac_address, 10,2); $mac_dash = 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);
//lookup the provisioning information for this MAC address. //lookup the provisioning information for this MAC address.
$sql2 = "select * from v_extensions "; $sql2 = "select * from v_extensions ";
$sql2 .= "where domain_uuid = '$domain_uuid' "; $sql2 .= "where domain_uuid = '$domain_uuid' ";
$sql2 .= "and (provisioning_list like '%|".$phone_mac_address.":%' or provisioning_list like '%|".$mac_dash.":%') "; $sql2 .= "and (provisioning_list like '%|".$device_mac_address.":%' or provisioning_list like '%|".$mac_dash.":%') ";
$sql2 .= "and enabled = 'true' "; $sql2 .= "and enabled = 'true' ";
$prep_statement_2 = $db->prepare(check_sql($sql2)); $prep_statement_2 = $db->prepare(check_sql($sql2));
$prep_statement_2->execute(); $prep_statement_2->execute();
@@ -197,7 +197,7 @@ else {
if (strlen($prov_row_array[0]) > 0) { if (strlen($prov_row_array[0]) > 0) {
//echo "mac address: ".$prov_row_array[0]."<br />"; //echo "mac address: ".$prov_row_array[0]."<br />";
//echo "line_number: ".$prov_row_array[1]."<br />"; //echo "line_number: ".$prov_row_array[1]."<br />";
if ($prov_row_array[0] == $phone_mac_address) { if ($prov_row_array[0] == $device_mac_address) {
$line_number = $prov_row_array[1]; $line_number = $prov_row_array[1];
//echo "prov_row: ".$prov_row."<br />"; //echo "prov_row: ".$prov_row."<br />";
//echo "line_number: ".$line_number."<br />"; //echo "line_number: ".$line_number."<br />";
@@ -242,13 +242,13 @@ else {
} }
//replace {v_mac} in the file name //replace {v_mac} in the file name
if (substr($phone_mac_address, 0, 6) == "00085d") { if (substr($device_mac_address, 0, 6) == "00085d") {
//upper case the mac address for aastra phones //upper case the mac address for aastra phones
$file_name = str_replace("{v_mac}", strtoupper($phone_mac_address), $file_name); $file_name = str_replace("{v_mac}", strtoupper($device_mac_address), $file_name);
} }
else { else {
//all other phones //all other phones
$file_name = str_replace("{v_mac}", $phone_mac_address, $file_name); $file_name = str_replace("{v_mac}", $device_mac_address, $file_name);
} }
//write the configuration to the directory //write the configuration to the directory