Update app_defaults.php

This commit is contained in:
FusionPBX
2017-01-10 01:09:11 -07:00
committed by GitHub
parent 2bfbce7ec8
commit b4019239ba
+24 -20
View File
@@ -33,19 +33,21 @@
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) { if (is_array($result)) {
$device_uuid = $row["device_uuid"]; foreach($result as $row) {
$device_mac_address = $row["device_mac_address"]; $device_uuid = $row["device_uuid"];
$device_mac_address = strtolower($device_mac_address); $device_mac_address = $row["device_mac_address"];
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address); $device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
$sql = "update v_devices set "; $sql = "update v_devices set ";
$sql .= "device_mac_address = '".$device_mac_address."' "; $sql .= "device_mac_address = '".$device_mac_address."' ";
$sql .= "where device_uuid = '".$device_uuid."' "; $sql .= "where device_uuid = '".$device_uuid."' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
}
unset($prep_statement, $result);
} }
unset($prep_statement, $result);
} }
//process this code online once //process this code online once
@@ -276,18 +278,20 @@
foreach ($array as $setting) { foreach ($array as $setting) {
$found = false; $found = false;
$missing[$x] = $setting; $missing[$x] = $setting;
foreach ($default_settings as $row) { if (is_array($default_settings)) {
if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) { foreach ($default_settings as $row) {
$found = true; if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) {
//remove items from the array that were found $found = true;
unset($missing[$x]); //remove items from the array that were found
unset($missing[$x]);
}
} }
$x++;
} }
$x++;
} }
//add the missing default settings //add the missing default settings
if (count($missing) > 0) foreach ($missing as $row) { if (is_array($missing)) foreach ($missing as $row) {
//add the default settings //add the default settings
$orm = new orm; $orm = new orm;
$orm->name('default_settings'); $orm->name('default_settings');
@@ -305,7 +309,7 @@
$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) { if (is_array($result)) foreach ($result as &$row) {
//set the variable //set the variable
$var_name = check_str($row['var_name']); $var_name = check_str($row['var_name']);
//remove the 'v_' prefix from the variable name //remove the 'v_' prefix from the variable name
@@ -349,4 +353,4 @@
unset($array); unset($array);
} }
?> ?>