Update provision.php

Prevent php warning in the provision php class.
This commit is contained in:
FusionPBX 2017-01-31 16:49:47 -07:00 committed by GitHub
parent 3c067947de
commit 02006cb9c2
1 changed files with 178 additions and 160 deletions

View File

@ -196,6 +196,7 @@ include "root.php";
$user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql);
if (is_array($user_contacts)) {
foreach ($user_contacts as &$row) {
$uuid = $row['contact_uuid'];
$phone_label = strtolower($row['phone_label']);
@ -232,6 +233,7 @@ include "root.php";
unset($contact, $numbers, $uuid, $phone_label);
}
}
}
public function render() {
@ -278,6 +280,7 @@ include "root.php";
//build the provision array
$provision = Array();
if (is_array($_SESSION['provision'])) {
foreach($_SESSION['provision'] as $key=>$val) {
if (strlen($val['var']) > 0) { $value = $val['var']; }
if (strlen($val['text']) > 0) { $value = $val['text']; }
@ -286,6 +289,7 @@ include "root.php";
if (strlen($value) > 0) { $provision[$key] = $value; }
unset($value);
}
}
//check to see if the mac_address exists in devices
if (strlen($_REQUEST['user_id']) == 0 || strlen($_REQUEST['userid']) == 0) {
@ -483,11 +487,13 @@ include "root.php";
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if (is_array($result)) {
foreach($result as $row) {
$key = $row['device_setting_subcategory'];
$value = $row['device_setting_value'];
$provision[$key] = $value;
}
}
unset ($prep_statement);
}
@ -500,11 +506,13 @@ include "root.php";
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if (is_array($result)) {
foreach($result as $row) {
$key = $row['device_setting_subcategory'];
$value = $row['device_setting_value'];
$provision[$key] = $value;
}
}
unset ($prep_statement);
}
@ -537,6 +545,7 @@ include "root.php";
//assign the keys array
$view->assign("lines", $device_lines);
//set the variables
if (is_array($device_lines)) {
foreach($device_lines as $row) {
//set the variables
$line_number = $row['line_number'];
@ -597,6 +606,7 @@ include "root.php";
$view->assign("sip_port_".$line_number, $sip_port);
$view->assign("register_expires_".$line_number, $register_expires);
}
}
unset ($prep_statement);
}
@ -627,6 +637,7 @@ include "root.php";
if ($prep_statement) {
$prep_statement->execute();
$extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (is_array($extensions)) {
foreach ($extensions as $row) {
//get the contact_uuid
$uuid = $row['contact_uuid'];
@ -657,6 +668,7 @@ include "root.php";
}
}
}
}
//assign the contacts array to the template
if (is_array($contacts)) {
@ -701,6 +713,7 @@ include "root.php";
$keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//override profile keys with device keys
if (is_array($keys)) {
foreach($keys as $row) {
//set the variables
$id = $row['device_key_id'];
@ -724,6 +737,7 @@ include "root.php";
$device_keys[$id]['device_key_owner'] = "device";
}
}
}
unset($keys);
}
@ -900,9 +914,11 @@ include "root.php";
}
//replace the dynamic provision variables that are defined in default, domain, and device settings
if (is_array($provision)) {
foreach($provision as $key=>$val) {
$view->assign($key, $val);
}
}
//set the template directory
if (strlen($provision["template_dir"]) > 0) {
@ -965,6 +981,7 @@ include "root.php";
function write() {
//build the provision array
$provision = Array();
if (is_array($_SESSION['provision'])) {
foreach($_SESSION['provision'] as $key=>$val) {
if (strlen($val['var']) > 0) { $value = $val['var']; }
if (strlen($val['text']) > 0) { $value = $val['text']; }
@ -973,6 +990,7 @@ include "root.php";
if (strlen($value) > 0) { $provision[$key] = $value; }
unset($value);
}
}
//check either we have destination path to write files
if(strlen($provision["path"]) == 0){
@ -988,7 +1006,7 @@ include "root.php";
unset ($prep_statement);
//process each device
foreach ($result as &$row) {
if (is_array($result)) foreach ($result as &$row) {
//get the values from the database and set as variables
$domain_uuid = $row["domain_uuid"];
$device_uuid = $row["device_uuid"];
@ -1028,7 +1046,7 @@ include "root.php";
}
//loop through the provision templates
foreach ($dir_array as &$template_path) {
if (is_array($dir_array)) foreach ($dir_array as &$template_path) {
if (is_dir($template_path)) continue;
if (!file_exists($template_path)) continue;
@ -1048,7 +1066,7 @@ include "root.php";
//render and write configuration to file
$provision_dir_array = explode(";", $provision["path"]);
foreach($provision_dir_array as $directory) {
if (is_array($provision_dir_array)) foreach($provision_dir_array as $directory) {
//destinatino file path
$dest_path = path_join($directory, $file_name);