diff --git a/app/conference_centers/resources/classes/conference_centers.php b/app/conference_centers/resources/classes/conference_centers.php
index ca6e80d838..e8d0751608 100644
--- a/app/conference_centers/resources/classes/conference_centers.php
+++ b/app/conference_centers/resources/classes/conference_centers.php
@@ -28,7 +28,6 @@
//define the conference center class
class conference_centers {
- public $db;
public $domain_uuid;
public $meeting_uuid;
public $order_by;
@@ -44,13 +43,7 @@
* Called when the object is created
*/
public function __construct() {
- //connect to the database if not connected
- if (!$this->db) {
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $this->db = $database->db;
- }
+
}
/**
@@ -72,7 +65,7 @@
if (permission_exists("conference_room_view_all")) {
$not_admin = 0;
}
- $sql = "select count(*) as num_rows from v_conference_rooms as r, v_meetings as p ";
+ $sql = "select count(*) from v_conference_rooms as r, v_meetings as p ";
if ($not_admin) {
$sql .= "v_meeting_users as u, ";
}
@@ -101,7 +94,6 @@
* get the list of conference rooms
*/
public function rooms() {
-
//get variables used to control the order
$order_by = $this->order_by;
$order = $this->order;
@@ -114,7 +106,6 @@
//validate the order
switch ($order) {
case 'asc':
- break;
case 'desc':
break;
default:
@@ -157,7 +148,8 @@
}
if (strlen($this->order_by) == 0) {
$sql .= "order by r.description, r.meeting_uuid asc ";
- } else {
+ }
+ else {
$sql .= "order by $order_by $order ";
}
$sql .= "limit :rows_per_page offset :offset ";
@@ -196,9 +188,8 @@
//set the previous uuid
$previous = $row["conference_room_uuid"];
}
- unset($conference_rooms);
}
- unset ($parameters, $sql);
+ unset($sql, $parameters, $conference_rooms);
return $result;
}
@@ -213,22 +204,21 @@
//get call recording from database
if (is_uuid($_GET['id'])) {
- $conference_session_uuid = check_str($_GET['id']);
- }
- if ($conference_session_uuid != '') {
+ $conference_session_uuid = $_GET['id'];
$sql = "select recording from v_conference_sessions ";
$sql .= "where conference_session_uuid = :conference_session_uuid ";
- //$sql .= "and domain_uuid = '".$domain_uuid."' \n";
+ //$sql .= "and domain_uuid = :domain_uuid ";
$parameters['conference_session_uuid'] = $conference_session_uuid;
+ //$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$conference_sessions = $database->select($sql, $parameters, 'all');
if (is_array($conference_sessions)) {
- foreach($conference_sessions as &$row) {
+ foreach ($conference_sessions as &$row) {
$recording = $row['recording'];
break;
}
}
- unset ($sql, $prep_statement, $conference_sessions);
+ unset($sql, $parameters, $conference_sessions);
}
//set the path for the directory
@@ -239,23 +229,23 @@
$record_name = basename($recording);
//download the file
- if (file_exists($record_path . '/' . $record_name . '.wav')) {
- $record_name = $record_name . '.wav';
+ if (file_exists($record_path.'/'.$record_name.'.wav')) {
+ $record_name = $record_name.'.wav';
}
else {
- if (file_exists($record_path . '/' . $record_name . '.mp3')) {
- $record_name = $record_name . '.mp3';
+ if (file_exists($record_path.'/'.$record_name.'.mp3')) {
+ $record_name = $record_name.'.mp3';
}
}
//download the file
- if (file_exists($record_path . '/' . $record_name)) {
+ if (file_exists($record_path.'/'.$record_name)) {
//content-range
//if (isset($_SERVER['HTTP_RANGE'])) {
// range_download($full_recording_path);
//}
ob_clean();
- $fd = fopen($record_path . '/' . $record_name, "rb");
+ $fd = fopen($record_path.'/'.$record_name, "rb");
if ($_GET['t'] == "bin") {
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
@@ -274,14 +264,14 @@
header('Content-Disposition: attachment; filename="'.$record_name.'"');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- // header("Content-Length: " . filesize($full_recording_path));
+ // header("Content-Length: ".filesize($full_recording_path));
ob_clean();
fpassthru($fd);
}
//if base64, remove temp recording file
//if ($_SESSION['conference']['storage_type']['text'] == 'base64' && $row['conference_recording_base64'] != '') {
- // @unlink($record_path . '/' . $record_name);
+ // @unlink($record_path.'/'.$record_name);
//}
}
} //end download method
@@ -301,4 +291,4 @@
print_r($result);
*/
-?>
+?>
\ No newline at end of file
diff --git a/app/fax/resources/classes/fax.php b/app/fax/resources/classes/fax.php
index 1154b8d080..23572699ae 100644
--- a/app/fax/resources/classes/fax.php
+++ b/app/fax/resources/classes/fax.php
@@ -88,12 +88,23 @@
$this->dialplan_uuid = uuid();
}
else {
- //delete the previous details
- $sql = "delete from v_dialplan_details ";
- $sql .= "where dialplan_uuid = '".$this->dialplan_uuid."' ";
- $sql .= "and domain_uuid = '".$this->domain_uuid."' ";
- $this->db->exec($sql);
- unset($sql);
+ //build previous details delete array
+ $array['dialplan_details'][0]['dialplan_uuid'] = $this->dialplan_uuid;
+ $array['dialplan_details'][0]['domain_uuid'] = $this->domain_uuid;
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_detail_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('dialplan_detail_delete', 'temp');
}
//set the fax name
@@ -195,4 +206,4 @@ $c->fax_description = $fax_description;
$c->dialplan();
*/
-?>
+?>
\ No newline at end of file
diff --git a/app/messages/resources/classes/messages.php b/app/messages/resources/classes/messages.php
index 2d580f9f92..b56a4f96b5 100644
--- a/app/messages/resources/classes/messages.php
+++ b/app/messages/resources/classes/messages.php
@@ -8,19 +8,11 @@
if (!class_exists('messages')) {
class messages {
- public $db;
-
/**
* Called when the object is created
*/
public function __construct() {
- //connect to the database if not connected
- if (!$this->db) {
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $this->db = $database->db;
- }
+
}
/**
@@ -50,14 +42,29 @@ if (!class_exists('messages')) {
}
//delete the checked rows
if ($action == 'delete') {
+ $x = 0;
foreach($messages as $row) {
if ($row['action'] == 'delete' or $row['checked'] == 'true') {
- $sql = "delete from v_messages ";
- $sql .= "where message_uuid = '".$row['message_uuid']."'; ";
- $this->db->query($sql);
- unset($sql);
+ //build delete array
+ $array['messages'][$x]['message_uuid'] = $row['message_uuid'];
+ $x++;
}
}
+ if (is_array($array) && @sizeof($array) != 0) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('message_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'messages';
+ $database->app_uuid = '4a20815d-042c-47c8-85df-085333e79b87';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('message_delete', 'temp');
+ }
unset($messages);
}
}
@@ -79,4 +86,4 @@ $obj = new messages;
$obj->delete();
*/
-?>
+?>
\ No newline at end of file
diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php
index 362fcb4b3a..b5e6e363c3 100644
--- a/app/provision/resources/classes/provision.php
+++ b/app/provision/resources/classes/provision.php
@@ -28,16 +28,12 @@ include "root.php";
//define the provision class
class provision {
- public $db;
public $domain_uuid;
public $domain_name;
public $template_dir;
public $mac;
public function __construct() {
- //get the database object
- global $db;
- $this->db = $db;
//set the default template directory
if (PHP_OS == "Linux") {
//set the default template dir
@@ -49,7 +45,8 @@ include "root.php";
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
- } elseif (PHP_OS == "FreeBSD") {
+ }
+ else if (PHP_OS == "FreeBSD") {
//if the FreeBSD port is installed use the following paths by default.
if (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) {
if (strlen($this->template_dir) == 0) {
@@ -67,17 +64,20 @@ include "root.php";
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
- } elseif (PHP_OS == "NetBSD") {
+ }
+ else if (PHP_OS == "NetBSD") {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
- } elseif (PHP_OS == "OpenBSD") {
+ }
+ else if (PHP_OS == "OpenBSD") {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
- } else {
+ }
+ else {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
@@ -105,59 +105,54 @@ include "root.php";
//normalize the mac address
$mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $mac));
//check in the devices table for a specific mac address
- $sql = "SELECT count(*) FROM v_devices ";
- $sql .= "WHERE device_mac_address=:mac ";
+ $sql = "select count(*) from v_devices ";
+ $sql .= "where device_mac_address = :mac ";
$parameters['mac'] = $mac;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
- if ($num_rows > 0) {
- return true;
- }
- else {
- return false;
- }
+ return $num_rows > 0 ? true : false;
+ unset($sql, $parameters, $num_rows);
}
//set the mac address in the correct format for the specific vendor
public function format_mac($mac, $vendor) {
switch (strtolower($vendor)) {
- case "algo":
- $mac = strtoupper($mac);
- break;
- case "aastra":
- $mac = strtoupper($mac);
- break;
- case "cisco":
- $mac = strtoupper($mac);
- break;
- case "linksys":
- $mac = strtolower($mac);
- break;
- case "mitel":
- $mac = strtoupper($mac);
- break;
- case "polycom":
- $mac = strtolower($mac);
- break;
- case "snom":
- $mac = strtolower($mac);
- break;
- case "escene":
- $mac = strtolower($mac);
- break;
- case "grandstream":
- $mac = strtolower($mac);
- break;
- case "yealink":
- $mac = strtolower($mac);
- break;
- case "gigaset":
- $mac = strtoupper($mac);
- break;
- default:
- $mac = strtolower($mac);
+ case "algo":
+ return strtoupper($mac);
+ break;
+ case "aastra":
+ return strtoupper($mac);
+ break;
+ case "cisco":
+ return strtoupper($mac);
+ break;
+ case "linksys":
+ return strtolower($mac);
+ break;
+ case "mitel":
+ return strtoupper($mac);
+ break;
+ case "polycom":
+ return strtolower($mac);
+ break;
+ case "snom":
+ return strtolower($mac);
+ break;
+ case "escene":
+ return strtolower($mac);
+ break;
+ case "grandstream":
+ return strtolower($mac);
+ break;
+ case "yealink":
+ return strtolower($mac);
+ break;
+ case "gigaset":
+ return strtoupper($mac);
+ break;
+ default:
+ return strtolower($mac);
}
- return $mac;
}
//send http error
@@ -177,12 +172,7 @@ include "root.php";
//define a function to check if a contact exists in the contacts array
private function contact_exists($contacts, $uuid) {
- if (is_array($contacts[$uuid])) {
- return true;
- }
- else {
- return false;
- }
+ return is_array($contacts[$uuid]) ? true : false;
}
private function contact_append(&$contacts, &$line, $domain_uuid, $device_user_uuid, $is_group) {
@@ -282,8 +272,8 @@ include "root.php";
//get the domain_name
if (strlen($domain_name) == 0) {
- $sql = "SELECT domain_name FROM v_domains ";
- $sql .= "WHERE domain_uuid=:domain_uuid ";
+ $sql = "select domain_name from v_domains ";
+ $sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$domain_name = $database->select($sql, $parameters, 'column');
@@ -291,9 +281,9 @@ include "root.php";
}
//build the provision array
- $provision = Array();
+ $provision = array();
if (is_array($_SESSION['provision'])) {
- foreach($_SESSION['provision'] as $key=>$val) {
+ foreach ($_SESSION['provision'] as $key => $val) {
if (strlen($val['var']) > 0) { $value = $val['var']; }
if (strlen($val['text']) > 0) { $value = $val['text']; }
if (strlen($val['boolean']) > 0) { $value = $val['boolean']; }
@@ -313,66 +303,64 @@ include "root.php";
if ($this->mac_exists($mac)) {
//get the device_template
- //if (strlen($device_template) == 0) {
- $sql = "SELECT * FROM v_devices ";
- $sql .= "WHERE device_mac_address = :mac_address ";
- if ($provision['http_domain_filter'] == "true") {
- $sql .= "AND domain_uuid=:domain_uuid ";
+ $sql = "select * from v_devices ";
+ $sql .= "where device_mac_address = :mac_address ";
+ if ($provision['http_domain_filter'] == "true") {
+ $sql .= "and domain_uuid=:domain_uuid ";
+ $parameters['domain_uuid'] = $domain_uuid;
+ }
+ $parameters['mac_address'] = $mac;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ unset($parameters);
+
+ if (is_array($row) && sizeof($row) != 0) {
+
+ //checks either device enabled
+ if ($row['device_enabled'] != 'true') {
+ if ($_SESSION['provision']['debug']['boolean'] == 'true') {
+ echo "
device disabled
";
+ }
+ else {
+ $this->http_error('404');
+ }
+ exit;
+ }
+
+ //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 ";
+ $sql .= "where domain_uuid = :domain_uuid and device_mac_address = :device_mac_address ";
$parameters['domain_uuid'] = $domain_uuid;
- }
- $parameters['mac_address'] = $mac;
- $database = new database;
- $row = $database->select($sql, $parameters, 'row');
- unset($parameters);
+ $parameters['device_mac_address'] = strtolower($mac);
+ $parameters['device_provisioned_date'] = date("Y-m-d H:i:s");
+ $parameters['device_provisioned_method'] = (isset($_SERVER["HTTPS"]) ? 'https' : 'http');
+ $parameters['device_provisioned_ip'] = $_SERVER['REMOTE_ADDR'];
+ $database = new database;
+ $database->execute($sql, $parameters);
+ unset($parameters);
- if (is_array($row) && sizeof($row) != 0) {
-
- //checks either device enabled
- if($row['device_enabled'] != 'true'){
- if ($_SESSION['provision']['debug']['boolean'] == 'true'){
- echo "
device disabled
";
- }
- else {
- $this->http_error('404');
- }
- exit;
- }
-
- //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 ";
- $sql .= "WHERE domain_uuid = :domain_uuid AND device_mac_address = :device_mac_address ";
- $parameters['domain_uuid'] = $domain_uuid;
- $parameters['device_mac_address'] = strtolower($mac);
- $parameters['device_provisioned_date'] = date("Y-m-d H:i:s");
- $parameters['device_provisioned_method'] = (isset($_SERVER["HTTPS"]) ? 'https' : 'http');
- $parameters['device_provisioned_ip'] = $_SERVER['REMOTE_ADDR'];
- $database = new database;
- $database->execute($sql, $parameters);
- unset($parameters);
-
- //set the variables from values in the database
- $device_uuid = $row["device_uuid"];
- $device_label = $row["device_label"];
- if (strlen($row["device_vendor"]) > 0) {
- $device_vendor = strtolower($row["device_vendor"]);
- }
- $device_user_uuid = $row["device_user_uuid"];
- $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($row);
- //}
+ //set the variables from values in the database
+ $device_uuid = $row["device_uuid"];
+ $device_label = $row["device_label"];
+ if (strlen($row["device_vendor"]) > 0) {
+ $device_vendor = strtolower($row["device_vendor"]);
+ }
+ $device_user_uuid = $row["device_user_uuid"];
+ $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($row);
//find a template that was defined on another phone and use that as the default.
if (strlen($device_template) == 0) {
- $sql = "SELECT * FROM v_devices ";
- $sql .= "WHERE domain_uuid=:domain_uuid ";
- $sql .= "AND device_enabled='true' ";
+ $sql = "select * from v_devices ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and device_enabled = 'true' ";
$sql .= "limit 1 ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
@@ -395,6 +383,7 @@ include "root.php";
$templates['Linksys/SPA-2102'] = 'linksys/spa2102';
$templates['Linksys/SPA-3102'] = 'linksys/spa3102';
$templates['Linksys/SPA-9212'] = 'linksys/spa921';
+
$templates['Cisco/SPA301'] = 'cisco/spa301';
$templates['Cisco/SPA301D'] = 'cisco/spa302d';
$templates['Cisco/SPA303'] = 'cisco/spa303';
@@ -406,6 +395,7 @@ include "root.php";
$templates['Cisco/SPA512G'] = 'cisco/spa512g';
$templates['Cisco/SPA514G'] = 'cisco/spa514g';
$templates['Cisco/SPA525G2'] = 'cisco/spa525g2';
+
$templates['snom300-SIP'] = 'snom/300';
$templates['snom320-SIP'] = 'snom/320';
$templates['snom360-SIP'] = 'snom/360';
@@ -468,6 +458,7 @@ include "root.php";
$templates['HW GXV3140'] = 'grandstream/gxv3140';
$templates['HW GXV3240'] = 'grandstream/gxv3240';
$templates['HW GXV3175'] = 'grandstream/gxv3175';
+
$templates['PolycomVVX-VVX_101-UA/4'] = 'polycom/4.x';
$templates['PolycomVVX-VVX_201-UA/4'] = 'polycom/4.x';
$templates['PolycomVVX-VVX_300-UA/4'] = 'polycom/4.x';
@@ -492,6 +483,7 @@ include "root.php";
$templates['PolycomVVX-VVX_501-UA/5'] = 'polycom/5.x';
$templates['PolycomVVX-VVX_600-UA/5'] = 'polycom/5.x';
$templates['PolycomVVX-VVX_601-UA/5'] = 'polycom/5.x';
+
$templates['Vesa VCS754'] = 'vtech/vcs754';
$templates['Wget/1.11.3'] = 'konftel/kt300ip';
foreach ($templates as $key=>$value){
@@ -503,7 +495,7 @@ include "root.php";
unset($templates);
//mac address does not exist in the table so add it
- if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" and strlen($domain_uuid) > 0) {
+ if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" && is_uuid($domain_uuid)) {
//get a new primary key
$device_uuid = uuid();
@@ -541,12 +533,12 @@ include "root.php";
//}
//alternate device_uuid
- if (strlen($device_uuid) > 0 && is_uuid($device_uuid)) {
- $sql = "SELECT * FROM v_devices ";
- $sql .= "WHERE device_uuid = :device_uuid ";
- $sql .= "AND device_enabled = 'true' ";
+ if (is_uuid($device_uuid)) {
+ $sql = "select * from v_devices ";
+ $sql .= "where device_uuid = :device_uuid ";
+ $sql .= "and device_enabled = 'true' ";
if ($provision['http_domain_filter'] == "true") {
- $sql .= "AND domain_uuid=:domain_uuid ";
+ $sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['device_uuid'] = $device_uuid;
@@ -559,10 +551,10 @@ include "root.php";
//override the original device_uuid
$device_uuid = $device_uuid_alternate;
//get the new devices information
- $sql = "SELECT * FROM v_devices ";
- $sql .= "WHERE device_uuid = :device_uuid ";
+ $sql = "select * from v_devices ";
+ $sql .= "where device_uuid = :device_uuid ";
if($provision['http_domain_filter'] == "true") {
- $sql .= "AND domain_uuid=:domain_uuid ";
+ $sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
}
$parameters['device_uuid'] = $device_uuid;
@@ -585,10 +577,10 @@ include "root.php";
}
//get the device settings table in the provision category from the profile and update the provision array
- if ((strlen($device_uuid) > 0) and (strlen($device_profile_uuid) > 0)) {
- $sql = "SELECT * FROM v_device_profile_settings ";
- $sql .= "WHERE device_profile_uuid = :device_profile_uuid ";
- $sql .= "AND profile_setting_enabled = 'true' ";
+ if (is_uuid($device_uuid) && is_uuid($device_profile_uuid)) {
+ $sql = "select * from v_device_profile_settings ";
+ $sql .= "where device_profile_uuid = :device_profile_uuid ";
+ $sql .= "and profile_setting_enabled = 'true' ";
$parameters['device_profile_uuid'] = $device_profile_uuid;
$database = new database;
$device_profile_settings = $database->select($sql, $parameters, 'all');
@@ -603,10 +595,10 @@ include "root.php";
}
//get the device settings table in the provision category and update the provision array
- if (strlen($device_uuid) > 0) {
- $sql = "SELECT * FROM v_device_settings ";
- $sql .= "WHERE device_uuid = :device_uuid ";
- $sql .= "AND device_setting_enabled = 'true' ";
+ if (is_uuid($device_uuid)) {
+ $sql = "select * from v_device_settings ";
+ $sql .= "where device_uuid = :device_uuid ";
+ $sql .= "and device_setting_enabled = 'true' ";
$parameters['device_uuid'] = $device_uuid;
$database = new database;
$device_settings = $database->select($sql, $parameters, 'all');
@@ -648,7 +640,7 @@ include "root.php";
$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);
//get the provisioning information from device lines table
- if (strlen($device_uuid) > 0) {
+ if (is_uuid($device_uuid)) {
//get the device lines array
$sql = "select * from v_device_lines ";
$sql .= "where device_uuid = :device_uuid ";
@@ -739,7 +731,7 @@ include "root.php";
$view->assign("user", $lines);
//get the list of contact directly assigned to the user
- if (strlen($device_user_uuid) > 0 and strlen($domain_uuid) > 0) {
+ if (is_uuid($device_user_uuid) && is_uuid($domain_uuid)) {
//get the contacts assigned to the groups and add to the contacts array
if ($_SESSION['provision']['contact_groups']['boolean'] == "true") {
$this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, true);
@@ -752,7 +744,7 @@ include "root.php";
}
//get the extensions and add them to the contacts array
- if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['contact_extensions']['boolean'] == "true") {
+ if (is_uuid($device_uuid) && is_uuid($domain_uuid) && $_SESSION['provision']['contact_extensions']['boolean'] == "true") {
//get contacts from the database
$sql = "select extension_uuid as contact_uuid, directory_first_name, directory_last_name, ";
$sql .= "effective_caller_id_name, effective_caller_id_number, ";
@@ -807,11 +799,11 @@ include "root.php";
}
//get the provisioning information from device keys
- if (isset($device_uuid)) {
+ if (is_uuid($device_uuid)) {
//get the device profile keys
- if (isset($device_profile_uuid) && is_uuid($device_profile_uuid)) {
- $sql = "SELECT ";
+ if (is_uuid($device_profile_uuid)) {
+ $sql = "select ";
$sql .= "profile_key_id as device_key_id, ";
$sql .= "profile_key_category as device_key_category, ";
$sql .= "profile_key_vendor as device_key_vendor, ";
@@ -822,28 +814,28 @@ include "root.php";
$sql .= "profile_key_protected as device_key_protected, ";
$sql .= "profile_key_label as device_key_label, ";
$sql .= "profile_key_icon as device_key_icon ";
- $sql .= "FROM v_device_profile_keys ";
- $sql .= "WHERE device_profile_uuid = :device_profile_uuid ";
+ $sql .= "from v_device_profile_keys ";
+ $sql .= "where device_profile_uuid = :device_profile_uuid ";
if (strtolower($device_vendor) == 'escene'){
- $sql .= "AND (lower(profile_key_vendor) = 'escene' or lower(profile_key_vendor) = 'escene programmable' or profile_key_vendor is null) ";
+ $sql .= "and (lower(profile_key_vendor) = 'escene' or lower(profile_key_vendor) = 'escene programmable' or profile_key_vendor is null) ";
}
else {
- $sql .= "AND (lower(profile_key_vendor) = :device_vendor or profile_key_vendor is null) ";
+ $sql .= "and (lower(profile_key_vendor) = :device_vendor or profile_key_vendor is null) ";
$parameters['device_vendor'] = $device_vendor;
}
- $sql .= "ORDER BY ";
- $sql .= "profile_key_vendor ASC, ";
- $sql .= "CASE profile_key_category ";
- $sql .= "WHEN 'line' THEN 1 ";
- $sql .= "WHEN 'memory' THEN 2 ";
- $sql .= "WHEN 'programmable' THEN 3 ";
- $sql .= "WHEN 'expansion' THEN 4 ";
- $sql .= "ELSE 100 END, ";
+ $sql .= "order by ";
+ $sql .= "profile_key_vendor asc, ";
+ $sql .= "case profile_key_category ";
+ $sql .= "when 'line' then 1 ";
+ $sql .= "when 'memory' then 2 ";
+ $sql .= "when 'programmable' then 3 ";
+ $sql .= "when 'expansion' then 4 ";
+ $sql .= "else 100 end, ";
if ($GLOBALS['db_type'] == "mysql") {
- $sql .= "profile_key_id ASC ";
+ $sql .= "profile_key_id asc ";
}
else {
- $sql .= "CAST(profile_key_id as numeric) ASC ";
+ $sql .= "cast(profile_key_id as numeric) asc ";
}
$parameters['device_profile_uuid'] = $device_profile_uuid;
$database = new database;
@@ -868,28 +860,28 @@ include "root.php";
}
//get the device keys
- $sql = "SELECT * FROM v_device_keys ";
- $sql .= "WHERE device_uuid = :device_uuid ";
+ $sql = "select * from v_device_keys ";
+ $sql .= "where device_uuid = :device_uuid ";
if (strtolower($device_vendor) == 'escene'){
- $sql .= "AND (lower(device_key_vendor) = 'escene' or lower(device_key_vendor) = 'escene programmable' or device_key_vendor is null) ";
+ $sql .= "and (lower(device_key_vendor) = 'escene' or lower(device_key_vendor) = 'escene programmable' or device_key_vendor is null) ";
}
else {
- $sql .= "AND (lower(device_key_vendor) = :device_vendor or device_key_vendor is null) ";
+ $sql .= "and (lower(device_key_vendor) = :device_vendor or device_key_vendor is null) ";
$parameters['device_vendor'] = $device_vendor;
}
- $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 .= "ELSE 100 END, ";
+ $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 .= "else 100 end, ";
if ($GLOBALS['db_type'] == "mysql") {
- $sql .= "device_key_id ASC ";
+ $sql .= "device_key_id asc ";
}
else {
- $sql .= "CAST(device_key_id as numeric) ASC ";
+ $sql .= "cast(device_key_id as numeric) asc ";
}
$parameters['device_uuid'] = $device_uuid;
$database = new database;
@@ -1048,7 +1040,6 @@ include "root.php";
}
}
}
- unset ($prep_statement);
//set the mac address in the correct format
$mac = $this->format_mac($mac, $device_vendor);
@@ -1056,7 +1047,8 @@ include "root.php";
// set date/time for versioning provisioning templates
if (strlen($_SESSION['provision']['version_format']['text']) > 0) {
$time = date($_SESSION['provision']['version_format']['text']);
- } else {
+ }
+ else {
$time = date("dmyHi");
}
@@ -1077,8 +1069,8 @@ include "root.php";
//personal ldap password
global $laddr_salt;
- if (isset($device_user_uuid)) {
- $sql = "SELECT contact_uuid FROM v_users WHERE user_uuid = :device_user_uuid ";
+ if (is_uuid($device_user_uuid)) {
+ $sql = "select contact_uuid from v_users where user_uuid = :device_user_uuid ";
$parameters['device_user_uuid'] = $device_user_uuid;
$database = new database;
$contact_uuid = $database->select($sql, $parameters, 'column');
@@ -1173,9 +1165,9 @@ include "root.php";
function write() {
//build the provision array
- $provision = Array();
+ $provision = array();
if (is_array($_SESSION['provision'])) {
- foreach($_SESSION['provision'] as $key=>$val) {
+ foreach ($_SESSION['provision'] as $key => $val) {
if (strlen($val['var']) > 0) { $value = $val['var']; }
if (strlen($val['text']) > 0) { $value = $val['text']; }
if (strlen($val['boolean']) > 0) { $value = $val['boolean']; }
@@ -1186,7 +1178,7 @@ include "root.php";
}
//check either we have destination path to write files
- if(strlen($provision["path"]) == 0) {
+ if (strlen($provision["path"]) == 0) {
return;
}
@@ -1198,101 +1190,107 @@ include "root.php";
$result = $database->select($sql, null, 'all');
//process each device
- 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"];
- $device_mac_address = $row["device_mac_address"];
- $device_label = $row["device_label"];
- $device_vendor = strtolower($row["device_vendor"]);
- $device_model = $row["device_model"];
- $device_firmware_version = $row["device_firmware_version"];
- $device_enabled = $row["device_enabled"];
- $device_template = $row["device_template"];
- $device_username = $row["device_username"];
- $device_password = $row["device_password"];
- $device_description = $row["device_description"];
+ 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"];
+ $device_mac_address = $row["device_mac_address"];
+ $device_label = $row["device_label"];
+ $device_vendor = strtolower($row["device_vendor"]);
+ $device_model = $row["device_model"];
+ $device_firmware_version = $row["device_firmware_version"];
+ $device_enabled = $row["device_enabled"];
+ $device_template = $row["device_template"];
+ $device_username = $row["device_username"];
+ $device_password = $row["device_password"];
+ $device_description = $row["device_description"];
- //clear the cache
- clearstatcache();
+ //clear the cache
+ clearstatcache();
- //loop through the provision template directory
- $dir_array = array();
- if (strlen($device_template) > 0) {
- $template_path = path_join($this->template_dir, $device_template);
- $dir_list = opendir($template_path);
- if ($dir_list) {
- $x = 0;
- while (false !== ($file = readdir($dir_list))) {
- $ignore = $file == "." || $file == ".." || substr($file, -3) == ".db" ||
- substr($file, -4) == ".svn" || substr($file, -4) == ".git";
- if (!$ignore) {
- $dir_array[] = path_join($template_path, $file);
- if ($x > 1000) { break; };
- $x++;
+ //loop through the provision template directory
+ $dir_array = array();
+ if (strlen($device_template) > 0) {
+ $template_path = path_join($this->template_dir, $device_template);
+ $dir_list = opendir($template_path);
+ if ($dir_list) {
+ $x = 0;
+ while (false !== ($file = readdir($dir_list))) {
+ $ignore = $file == "." || $file == ".." || substr($file, -3) == ".db" ||
+ substr($file, -4) == ".svn" || substr($file, -4) == ".git";
+ if (!$ignore) {
+ $dir_array[] = path_join($template_path, $file);
+ if ($x > 1000) { break; };
+ $x++;
+ }
}
+ closedir($dir_list);
+ unset($x, $file);
}
- closedir($dir_list);
- unset($x, $file);
+ unset($dir_list, $template_path);
}
- unset($dir_list, $template_path);
- }
- //loop through the provision templates
- if (is_array($dir_array)) foreach ($dir_array as &$template_path) {
- if (is_dir($template_path)) continue;
- if (!file_exists($template_path)) continue;
+ //loop through the provision templates
+ if (is_array($dir_array)) {
+ foreach ($dir_array as &$template_path) {
+ if (is_dir($template_path)) continue;
+ if (!file_exists($template_path)) continue;
- //template file name
- $file_name = basename($template_path);
+ //template file name
+ $file_name = basename($template_path);
- //configure device object
- $this->domain_uuid = $domain_uuid;
- $this->mac = $device_mac_address;
- $this->file = $file_name;
+ //configure device object
+ $this->domain_uuid = $domain_uuid;
+ $this->mac = $device_mac_address;
+ $this->file = $file_name;
- //format the mac address
- $mac = $this->format_mac($device_mac_address, $device_vendor);
+ //format the mac address
+ $mac = $this->format_mac($device_mac_address, $device_vendor);
- //replace {$mac} in the file name
- $file_name = str_replace("{\$mac}", $mac, $file_name);
+ //replace {$mac} in the file name
+ $file_name = str_replace("{\$mac}", $mac, $file_name);
- //render and write configuration to file
- $provision_dir_array = explode(";", $provision["path"]);
- if (is_array($provision_dir_array)) foreach($provision_dir_array as $directory) {
- //destinatino file path
- $dest_path = path_join($directory, $file_name);
+ //render and write configuration to file
+ $provision_dir_array = explode(";", $provision["path"]);
+ if (is_array($provision_dir_array)) {
+ foreach ($provision_dir_array as $directory) {
+ //destinatino file path
+ $dest_path = path_join($directory, $file_name);
- if ($device_enabled == 'true') {
- //output template to string for header processing
- $file_contents = $this->render();
+ if ($device_enabled == 'true') {
+ //output template to string for header processing
+ $file_contents = $this->render();
- //write the file
- if(!is_dir($directory)) {
- mkdir($directory, 0777, true);
- }
- $fh = fopen($dest_path,"w") or die("Unable to write to $directory for provisioning. Make sure the path exists and permissons are set correctly.");
- fwrite($fh, $file_contents);
- fclose($fh);
+ //write the file
+ if (!is_dir($directory)) {
+ mkdir($directory, 0777, true);
+ }
+ $fh = fopen($dest_path,"w") or die("Unable to write to $directory for provisioning. Make sure the path exists and permissons are set correctly.");
+ fwrite($fh, $file_contents);
+ fclose($fh);
+ }
+ else { // device disabled
+ //remove only files with `{$mac}` name
+ if (strpos($template_path, '{$mac}') !== false){
+ unlink($dest_path);
+ }
+ }
+
+ unset($dest_path);
+ }
}
- else { // device disabled
- //remove only files with `{$mac}` name
- if(strpos($template_path, '{$mac}') !== false){
- unlink($dest_path);
- }
- }
-
- unset($dest_path);
+ //unset variables
+ unset($file_name, $provision_dir_array);
}
- //unset variables
- unset($file_name, $provision_dir_array);
- } //end for each
+ }
- //unset variables
- unset($dir_array);
+ //unset variables
+ unset($dir_array);
+ }
}
} //end write function
} //end provision class
-?>
+?>
\ No newline at end of file
diff --git a/app/streams/resources/classes/streams.php b/app/streams/resources/classes/streams.php
index 53649860d1..3c814ee2d6 100644
--- a/app/streams/resources/classes/streams.php
+++ b/app/streams/resources/classes/streams.php
@@ -29,19 +29,11 @@
if (!class_exists('streams')) {
class streams {
- public $db;
-
/**
* Called when the object is created
*/
public function __construct() {
- //connect to the database if not connected
- if (!$this->db) {
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $this->db = $database->db;
- }
+
}
/**
@@ -71,21 +63,36 @@ if (!class_exists('streams')) {
}
//delete the checked rows
if ($action == 'delete') {
+ $x = 0;
foreach($streams as $row) {
if ($row['action'] == 'delete' or $row['checked'] == 'true') {
- $sql = "delete from v_streams ";
- $sql .= "where stream_uuid = '".$row['stream_uuid']."'; ";
- $this->db->query($sql);
- unset($sql);
+ //build delete array
+ $array['streams'][$x++]['stream_uuid'] = $row['stream_uuid'];
+ $x++;
}
}
+ if (is_array($array) && @sizeof($array) != 0) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('stream_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'streams';
+ $database->app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('stream_delete', 'temp');
+ }
unset($streams);
}
}
}
- } //end the delete function
+ }
- } //end the class
+ }
}
/*
@@ -93,4 +100,4 @@ $obj = new streams;
$obj->delete();
*/
-?>
+?>
\ No newline at end of file