diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php
index 59e08d8869..aac9cf37b6 100644
--- a/app/dialplans/resources/classes/dialplan.php
+++ b/app/dialplans/resources/classes/dialplan.php
@@ -29,10 +29,10 @@ include "root.php";
if (!class_exists('dialplan')) {
class dialplan {
//variables
- public $db;
public $result;
public $domain_uuid;
public $dialplan_uuid;
+ public $dialplan_detail_uuid;
public $xml;
public $json;
public $display_type;
@@ -70,151 +70,114 @@ include "root.php";
//class constructor
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;
- }
-
//set the default value
$this->dialplan_global = false;
}
public function dialplan_add() {
-
- $sql = "insert into v_dialplans ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "app_uuid, ";
- $sql .= "dialplan_uuid, ";
- $sql .= "dialplan_name, ";
- $sql .= "dialplan_number, ";
- $sql .= "dialplan_destination, ";
- $sql .= "dialplan_continue, ";
- $sql .= "dialplan_order, ";
- $sql .= "dialplan_context, ";
- $sql .= "dialplan_enabled, ";
- $sql .= "dialplan_description ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- if ($this->dialplan_global) {
- $sql .= "null, ";
- }
- else {
- $sql .= "'".check_str($this->domain_uuid)."', ";
- }
- $sql .= "'".check_str($this->app_uuid)."', ";
- $sql .= "'".check_str($this->dialplan_uuid)."', ";
- $sql .= "'".check_str($this->dialplan_name)."', ";
- $sql .= "'".check_str($this->dialplan_number)."', ";
- $sql .= "'".check_str($this->dialplan_destination)."', ";
- $sql .= "'".check_str($this->dialplan_continue)."', ";
- $sql .= "'".check_str($this->dialplan_order)."', ";
- $sql .= "'".check_str($this->dialplan_context)."', ";
- $sql .= "'".check_str($this->dialplan_enabled)."', ";
- $sql .= "'".check_str($this->dialplan_description)."' ";
- $sql .= ")";
- $this->db->exec(check_sql($sql));
- unset($sql);
- } //end function
+ //build insert array
+ $array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid;
+ $array['dialplans'][0]['domain_uuid'] = !$this->dialplan_global ? $this->domain_uuid : null;
+ $array['dialplans'][0]['app_uuid'] = $this->app_uuid;
+ $array['dialplans'][0]['dialplan_name'] = $this->dialplan_name;
+ $array['dialplans'][0]['dialplan_number'] = $this->dialplan_number;
+ $array['dialplans'][0]['dialplan_destination'] = $this->dialplan_destination;
+ $array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue;
+ $array['dialplans'][0]['dialplan_order'] = $this->dialplan_order;
+ $array['dialplans'][0]['dialplan_context'] = $this->dialplan_order;
+ $array['dialplans'][0]['dialplan_enabled'] = $this->dialplan_enabled;
+ $array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_add', 'temp');
+ //execute insert
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('dialplan_add', 'temp');
+ }
public function dialplan_update() {
-
- $sql = "update v_dialplans set ";
- $sql .= "dialplan_name = '".check_str($this->dialplan_name)."', ";
- if (strlen($this->dialplan_continue) > 0) {
- $sql .= "dialplan_continue = '".check_str($this->dialplan_continue)."', ";
- }
- $sql .= "dialplan_order = '".check_str($this->dialplan_order)."', ";
- $sql .= "dialplan_context = '".check_str($this->dialplan_context)."', ";
- $sql .= "dialplan_enabled = '".check_str($this->dialplan_enabled)."', ";
- $sql .= "dialplan_description = '".check_str($this->dialplan_description)."' ";
- $sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
- $sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
- //echo "sql: ".$sql."
";
- $this->db->query($sql);
- unset($sql);
+ //build update array
+ $array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid;
+ $array['dialplans'][0]['dialplan_name'] = $this->dialplan_name;
+ if (strlen($this->dialplan_continue) > 0) {
+ $array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue;
+ }
+ $array['dialplans'][0]['dialplan_order'] = $this->dialplan_order;
+ $array['dialplans'][0]['dialplan_context'] = $this->dialplan_context;
+ $array['dialplans'][0]['dialplan_enabled'] = $this->dialplan_enabled;
+ $array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_edit', 'temp');
+ //execute update
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('dialplan_edit', 'temp');
}
public function dialplan_detail_add() {
-
- $dialplan_detail_uuid = uuid();
- $sql = "insert into v_dialplan_details ";
- $sql .= "(";
- $sql .= "dialplan_detail_uuid, ";
- $sql .= "domain_uuid, ";
- $sql .= "dialplan_uuid, ";
- $sql .= "dialplan_detail_tag, ";
- $sql .= "dialplan_detail_order, ";
- $sql .= "dialplan_detail_type, ";
- $sql .= "dialplan_detail_data, ";
- $sql .= "dialplan_detail_break, ";
- $sql .= "dialplan_detail_inline, ";
- $sql .= "dialplan_detail_group ";
- $sql .= ") ";
- $sql .= "values ";
- $sql .= "( ";
- $sql .= "'".$dialplan_detail_uuid."', ";
- if ($this->dialplan_global) {
- $sql .= "null, ";
- }
- else {
- $sql .= "'".check_str($this->domain_uuid)."', ";
- }
- $sql .= "'".check_str($this->dialplan_uuid)."', ";
- $sql .= "'".check_str($this->dialplan_detail_tag)."', ";
- $sql .= "'".check_str($this->dialplan_detail_order)."', ";
- $sql .= "'".check_str($this->dialplan_detail_type)."', ";
- $sql .= "'".check_str($this->dialplan_detail_data)."', ";
- if (strlen($this->dialplan_detail_break) == 0) {
- $sql .= "null, ";
- }
- else {
- $sql .= "'".check_str($this->dialplan_detail_break)."', ";
- }
- if (strlen($this->dialplan_detail_inline) == 0) {
- $sql .= "null, ";
- }
- else {
- $sql .= "'".check_str($this->dialplan_detail_inline)."', ";
- }
- if (strlen($this->dialplan_detail_group) == 0) {
- $sql .= "null ";
- }
- else {
- $sql .= "'".check_str($this->dialplan_detail_group)."' ";
- }
- $sql .= ")";
- //echo $sql."\n\n";
- $this->db->exec(check_sql($sql));
- unset($sql);
- } //end function
+ //build insert array
+ $dialplan_detail_uuid = uuid();
+ $array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
+ $array['dialplan_details'][0]['domain_uuid'] = !$this->dialplan_global ? $this->domain_uuid : null;
+ $array['dialplan_details'][0]['dialplan_uuid'] = $this->dialplan_uuid;
+ $array['dialplan_details'][0]['dialplan_detail_tag'] = $this->dialplan_detail_tag;
+ $array['dialplan_details'][0]['dialplan_detail_order'] = $this->dialplan_detail_order;
+ $array['dialplan_details'][0]['dialplan_detail_type'] = $this->dialplan_detail_type;
+ $array['dialplan_details'][0]['dialplan_detail_data'] = $this->dialplan_detail_data;
+ $array['dialplan_details'][0]['dialplan_detail_break'] = strlen($this->dialplan_detail_break) != 0 ? $this->dialplan_detail_break : null;
+ $array['dialplan_details'][0]['dialplan_detail_inline'] = strlen($this->dialplan_detail_inline) != 0 ? $this->dialplan_detail_inline : null;
+ $array['dialplan_details'][0]['dialplan_detail_group'] = strlen($this->dialplan_detail_group) != 0 ? $this->dialplan_detail_group : null;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_detail_add', 'temp');
+ //execute insert
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('dialplan_detail_add', 'temp');
+ }
public function dialplan_detail_update() {
-
- $sql = "update v_dialplans set ";
- $sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', ";
- $sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', ";
- $sql .= "dialplan_detail_data = '".check_str($this->dialplan_detail_data)."', ";
- if (strlen($this->dialplan_detail_break) > 0) {
- $sql .= "dialplan_detail_break = '".check_str($this->dialplan_detail_break)."', ";
- }
- if (strlen($this->dialplan_detail_inline) > 0) {
- $sql .= "dialplan_detail_inline = '".check_str($this->dialplan_detail_inline)."', ";
- }
- if (strlen($this->dialplan_detail_group) > 0) {
- $sql .= "dialplan_detail_group = '".check_str($this->dialplan_detail_group)."', ";
- }
- $sql .= "dialplan_detail_tag = '".check_str($this->dialplan_detail_tag)."' ";
- $sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
- $sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
- //echo "sql: ".$sql."
";
- $this->db->query($sql);
- unset($sql);
- } //end function
+ //build update array
+ $array['dialplan_details'][0]['dialplan_detail_uuid'] = $this->dialplan_detail_uuid;
+ $array['dialplan_details'][0]['dialplan_detail_tag'] = $this->dialplan_detail_tag;
+ $array['dialplan_details'][0]['dialplan_detail_order'] = $this->dialplan_detail_order;
+ $array['dialplan_details'][0]['dialplan_detail_type'] = $this->dialplan_detail_type;
+ $array['dialplan_details'][0]['dialplan_detail_data'] = $this->dialplan_detail_data;
+ if (strlen($this->dialplan_detail_break) != 0) {
+ $array['dialplan_details'][0]['dialplan_detail_break'] = $this->dialplan_detail_break;
+ }
+ if (strlen($this->dialplan_detail_inline) != 0) {
+ $array['dialplan_details'][0]['dialplan_detail_inline'] = $this->dialplan_detail_inline;
+ }
+ if (strlen($this->dialplan_detail_group) != 0) {
+ $array['dialplan_details'][0]['dialplan_detail_group'] = $this->dialplan_detail_group;
+ }
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_detail_edit', 'temp');
+ //execute update
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('dialplan_detail_edit', 'temp');
+ }
public function restore_advanced_xml() {
$switch_dialplan_dir = $this->switch_dialplan_dir;
@@ -244,39 +207,25 @@ include "root.php";
}
private function app_uuid_exists() {
- $sql = "select domain_uuid from v_dialplans ";
- $sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) ";
- $sql .= "and app_uuid = '".$this->app_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- if ($prep_statement) {
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- if (count($result)) {
- return true;
- }
- else {
- return false;
- }
- }
- unset($sql, $prep_statement, $result);
+ $sql = "select count(*) from v_dialplans ";
+ $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
+ $sql .= "and app_uuid = :app_uuid ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['app_uuid'] = $this->app_uuid;
+ $database = new database;
+ return $database->select($sql, $parameters, 'column') != 0 ? true : false;
+ unset($sql, $parameters);
}
public function dialplan_exists() {
- $sql = "select domain_uuid from v_dialplans ";
- $sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null)";
- $sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- if ($prep_statement) {
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- if (count($result)) {
- return true;
- }
- else {
- return false;
- }
- }
- unset($sql, $prep_statement, $result);
+ $sql = "select count(*) from v_dialplans ";
+ $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null)";
+ $sql .= "and dialplan_uuid = :dialplan_uuid ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['dialplan_uuid'] = $this->dialplan_uuid;
+ $database = new database;
+ return $database->select($sql, $parameters, 'column') != 0 ? true : false;
+ unset($sql, $parameters);
}
public function import() {
@@ -312,11 +261,10 @@ include "root.php";
//get the list of domains
if (!isset($_SESSION['domains'])) {
- $sql = "select * from v_domains; ";
- $prep_statement = $this->db->prepare($sql);
- $prep_statement->execute();
- $_SESSION['domains'] = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset($sql, $prep_statement);
+ $sql = "select * from v_domains ";
+ $database = new database;
+ $_SESSION['domains'] = $database->select($sql, null, 'all');
+ unset($sql);
}
//check if the dialplan app uuid exists
@@ -330,8 +278,6 @@ include "root.php";
}
//check if the dialplan exists
if (!$this->app_uuid_exists()) {
- //start the transaction
- $this->db->beginTransaction();
//get the attributes
$this->dialplan_uuid = uuid();
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
@@ -439,8 +385,6 @@ include "root.php";
$x++;
}
}
- //end the transaction
- $this->db->commit();
//update the session array
$_SESSION['upgrade']['app_defaults']['dialplans'][$domain['domain_name']][]['dialplan_name'] = $this->dialplan_name;
}
@@ -455,10 +399,12 @@ include "root.php";
//check the session array if it doesn't exist then build the array
if (!is_array($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) {
//get the outbound routes from the database
- $sql = "select * from v_dialplans as d, v_dialplan_details as s ";
+ $sql = "select * ";
+ $sql .= "from v_dialplans as d, ";
+ $sql .= "v_dialplan_details as s ";
$sql .= "where ";
$sql .= "( ";
- $sql .= "d.domain_uuid = '".$this->domain_uuid."' ";
+ $sql .= "d.domain_uuid = :domain_uuid ";
$sql .= "or d.domain_uuid is null ";
$sql .= ") ";
$sql .= "and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
@@ -469,92 +415,98 @@ include "root.php";
$sql .= "d.dialplan_name asc, ";
$sql .= "d.dialplan_uuid asc, ";
$sql .= "s.dialplan_detail_group asc, ";
- $sql .= "CASE s.dialplan_detail_tag ";
- $sql .= "WHEN 'condition' THEN 1 ";
- $sql .= "WHEN 'action' THEN 2 ";
- $sql .= "WHEN 'anti-action' THEN 3 ";
- $sql .= "ELSE 100 END, ";
+ $sql .= "case s.dialplan_detail_tag ";
+ $sql .= "when 'condition' then 1 ";
+ $sql .= "when 'action' then 2 ";
+ $sql .= "when 'anti-action' then 3 ";
+ $sql .= "else 100 end, ";
$sql .= "s.dialplan_detail_order asc ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset($prep_statement, $sql);
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $database = new database;
+ $dialplans = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
$x = 0; $y = 0;
- if (isset($dialplans)) foreach ($dialplans as &$row) {
- //if the previous dialplan uuid has not been set then set it
- if (!isset($previous_dialplan_uuid)) { $previous_dialplan_uuid = $row['dialplan_uuid']; }
+ if (isset($dialplans) && @sizeof($dialplans) != 0) {
+ foreach ($dialplans as &$row) {
+ //if the previous dialplan uuid has not been set then set it
+ if (!isset($previous_dialplan_uuid)) { $previous_dialplan_uuid = $row['dialplan_uuid']; }
- //increment dialplan ordinal number
- if ($previous_dialplan_uuid != $row['dialplan_uuid']) {
- $x++; $y = 0;
- }
+ //increment dialplan ordinal number
+ if ($previous_dialplan_uuid != $row['dialplan_uuid']) {
+ $x++; $y = 0;
+ }
- //build the array
- $array[$x]['dialplan_uuid'] = $row['dialplan_uuid'];
- $array[$x]['dialplan_context'] = $row['dialplan_context'];
- $array[$x]['dialplan_name'] = $row['dialplan_name'];
- $array[$x]['dialplan_continue'] = $row['dialplan_continue'];
- $array[$x]['dialplan_order'] = $row['dialplan_order'];
- $array[$x]['dialplan_enabled'] = $row['dialplan_enabled'];
- $array[$x]['dialplan_description'] = $row['dialplan_description'];
- if (strlen($row['dialplan_detail_uuid']) > 0) {
- $array[$x]['dialplan_details'][$y]['dialplan_uuid'] = $row['dialplan_uuid'];
- $array[$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row['dialplan_detail_uuid'];
- $array[$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
- $array[$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row['dialplan_detail_type'];
- $array[$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row['dialplan_detail_data'];
- $y++;
- }
+ //build the array
+ $array[$x]['dialplan_uuid'] = $row['dialplan_uuid'];
+ $array[$x]['dialplan_context'] = $row['dialplan_context'];
+ $array[$x]['dialplan_name'] = $row['dialplan_name'];
+ $array[$x]['dialplan_continue'] = $row['dialplan_continue'];
+ $array[$x]['dialplan_order'] = $row['dialplan_order'];
+ $array[$x]['dialplan_enabled'] = $row['dialplan_enabled'];
+ $array[$x]['dialplan_description'] = $row['dialplan_description'];
+ if (strlen($row['dialplan_detail_uuid']) > 0) {
+ $array[$x]['dialplan_details'][$y]['dialplan_uuid'] = $row['dialplan_uuid'];
+ $array[$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row['dialplan_detail_uuid'];
+ $array[$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
+ $array[$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row['dialplan_detail_type'];
+ $array[$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row['dialplan_detail_data'];
+ $y++;
+ }
- //set the previous dialplan_uuid
- $previous_dialplan_uuid = $row['dialplan_uuid'];
- }
- unset ($prep_statement);
- //set the session array
- $_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] = $array;
- } //end if !is_array
- //find the matching outbound routes
- if (isset($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) foreach ($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] as $row) {
- if (isset($row['dialplan_details'])) foreach ($row['dialplan_details'] as $field) {
- if ($field['dialplan_detail_tag'] == "condition") {
- if ($field['dialplan_detail_type'] == "destination_number") {
- $dialplan_detail_data = $field['dialplan_detail_data'];
- $pattern = '/'.$dialplan_detail_data.'/';
- preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE);
- if (count($matches) == 0) {
- $regex_match = false;
- }
- else {
- $regex_match = true;
- $regex_match_1 = $matches[1][0];
- $regex_match_2 = $matches[2][0];
- $regex_match_3 = $matches[3][0];
- }
+ //set the previous dialplan_uuid
+ $previous_dialplan_uuid = $row['dialplan_uuid'];
}
}
- if ($regex_match) {
- //get the variables
- if ($field[dialplan_detail_type] == "set" && $field[dialplan_detail_tag] == "action") {
- //only set variables with values not variables
- if (strpos($field[dialplan_detail_data], '$') === false) {
- $this->variables .= $field[dialplan_detail_data].",";
+ //set the session array
+ $_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] = $array;
+ }
+
+ //find the matching outbound routes
+ if (isset($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) {
+ foreach ($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] as $row) {
+ if (isset($row['dialplan_details'])) {
+ foreach ($row['dialplan_details'] as $field) {
+ if ($field['dialplan_detail_tag'] == "condition") {
+ if ($field['dialplan_detail_type'] == "destination_number") {
+ $dialplan_detail_data = $field['dialplan_detail_data'];
+ $pattern = '/'.$dialplan_detail_data.'/';
+ preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE);
+ if (count($matches) == 0) {
+ $regex_match = false;
+ }
+ else {
+ $regex_match = true;
+ $regex_match_1 = $matches[1][0];
+ $regex_match_2 = $matches[2][0];
+ $regex_match_3 = $matches[3][0];
+ }
}
}
- //process the $x detail data variables
- if ($field['dialplan_detail_tag'] == "action" && $field['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") {
- $dialplan_detail_data = $field['dialplan_detail_data'];
- $dialplan_detail_data = str_replace("\$1", $regex_match_1, $dialplan_detail_data);
- $dialplan_detail_data = str_replace("\$2", $regex_match_2, $dialplan_detail_data);
- $dialplan_detail_data = str_replace("\$3", $regex_match_3, $dialplan_detail_data);
- $this->bridges = $dialplan_detail_data;
- }
- }
- }
- } // end if isset
- } // outbound_routes
+ if ($regex_match) {
+ //get the variables
+ if ($field[dialplan_detail_type] == "set" && $field[dialplan_detail_tag] == "action") {
+ //only set variables with values not variables
+ if (strpos($field[dialplan_detail_data], '$') === false) {
+ $this->variables .= $field[dialplan_detail_data].",";
+ }
+ }
+ //process the $x detail data variables
+ if ($field['dialplan_detail_tag'] == "action" && $field['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") {
+ $dialplan_detail_data = $field['dialplan_detail_data'];
+ $dialplan_detail_data = str_replace("\$1", $regex_match_1, $dialplan_detail_data);
+ $dialplan_detail_data = str_replace("\$2", $regex_match_2, $dialplan_detail_data);
+ $dialplan_detail_data = str_replace("\$3", $regex_match_3, $dialplan_detail_data);
+ $this->bridges = $dialplan_detail_data;
+ }
+ } //if
+ } //foreach
+ } //if
+ } //foreach
+ } //if
+ } //function
//reads dialplan details from the database to build the xml
- public function xml () {
+ public function xml() {
//set the xml array and then concatenate the array to a string
/* $xml = "\n"; */
@@ -572,35 +524,37 @@ include "root.php";
if ($this->source == "dialplans") {
//get the data using a join between the dialplans and dialplan details tables
$sql = "select dialplan_uuid, dialplan_xml ";
- $sql .= "from v_dialplans \n";
- if (isset($this->uuid)) {
- $sql .= "where dialplan_uuid = '".$this->uuid."' \n";
+ $sql .= "from v_dialplans ";
+ if (is_uuid($this->uuid)) {
+ $sql .= "where dialplan_uuid = :dialplan_uuid ";
+ $parameters['dialplan_uuid'] = $this->uuid;
}
else {
if (isset($this->context)) {
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
- $sql .= "where dialplan_context = '" . $this->context . "' \n";
+ $sql .= "where dialplan_context = :dialplan_context ";
}
else {
- $sql .= "where (dialplan_context = '" . $this->context . "' or dialplan_context = '\${domain_name}') \n";
+ $sql .= "where (dialplan_context = :dialplan_context or dialplan_context = '\${domain_name}') ";
}
- $sql .= "and dialplan_enabled = 'true' \n";
+ $sql .= "and dialplan_enabled = 'true' ";
+ $parameters['dialplan_context'] = $this->context;
}
}
if ($this->is_empty == "dialplan_xml") {
- $sql .= "and p.dialplan_xml is null \n";
+ $sql .= "and p.dialplan_xml is null ";
}
- $sql .= "order by \n";
- $sql .= "dialplan_context asc, \n";
- $sql .= "dialplan_order asc \n";
- //echo $sql;
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $results = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- //echo $sql;
- foreach ($results as $row) {
- $dialplans[$row["dialplan_uuid"]] = $row["dialplan_xml"];
+ $sql .= "order by ";
+ $sql .= "dialplan_context asc, ";
+ $sql .= "dialplan_order asc ";
+ $database = new database;
+ $results = $database->select($sql, $parameters, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
+ foreach ($results as $row) {
+ $dialplans[$row["dialplan_uuid"]] = $row["dialplan_xml"];
+ }
}
+ unset($sql, $parameters, $results, $row);
}
//get the dialplans from the dialplan details
@@ -608,277 +562,278 @@ include "root.php";
//get the data using a join between the dialplans and dialplan details tables
$sql = "select ";
- $sql .= "p.domain_uuid, p.dialplan_uuid, p.app_uuid, p.dialplan_context, p.dialplan_name, p.dialplan_number, \n";
- $sql .= "p.dialplan_continue, p.dialplan_order, p.dialplan_enabled, p.dialplan_description, \n";
- $sql .= "s.dialplan_detail_uuid, s.dialplan_detail_tag, s.dialplan_detail_type, s.dialplan_detail_data, \n";
- $sql .= "s.dialplan_detail_break, s.dialplan_detail_inline, s.dialplan_detail_group, s.dialplan_detail_order \n";
- $sql .= "from v_dialplans as p, v_dialplan_details as s \n";
- $sql .= "where p.dialplan_uuid = s.dialplan_uuid \n";
+ $sql .= "p.domain_uuid, p.dialplan_uuid, p.app_uuid, p.dialplan_context, p.dialplan_name, p.dialplan_number, ";
+ $sql .= "p.dialplan_continue, p.dialplan_order, p.dialplan_enabled, p.dialplan_description, ";
+ $sql .= "s.dialplan_detail_uuid, s.dialplan_detail_tag, s.dialplan_detail_type, s.dialplan_detail_data, ";
+ $sql .= "s.dialplan_detail_break, s.dialplan_detail_inline, s.dialplan_detail_group, s.dialplan_detail_order ";
+ $sql .= "from v_dialplans as p, v_dialplan_details as s ";
+ $sql .= "where p.dialplan_uuid = s.dialplan_uuid ";
if ($this->is_empty == "dialplan_xml") {
- $sql .= "and p.dialplan_xml is null \n";
+ $sql .= "and p.dialplan_xml is null ";
}
if (isset($this->context)) {
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
- $sql .= "and p.dialplan_context = '" . $this->context . "' \n";
+ $sql .= "and p.dialplan_context = :dialplan_context ";
}
else {
- $sql .= "and (p.dialplan_context = '" . $this->context . "' or p.dialplan_context = '\${domain_name}') \n";
+ $sql .= "and (p.dialplan_context = :dialplan_context or p.dialplan_context = '\${domain_name}') ";
}
- $sql .= "and p.dialplan_enabled = 'true' \n";
+ $sql .= "and p.dialplan_enabled = 'true' ";
+ $parameters['dialplan_context'] = $this->context;
}
- if (isset($this->uuid)) {
- $sql .= "and p.dialplan_uuid = '".$this->uuid."' \n";
- $sql .= "and s.dialplan_uuid = '".$this->uuid."' \n";
+ if (is_uuid($this->uuid)) {
+ $sql .= "and p.dialplan_uuid = :dialplan_uuid ";
+ $sql .= "and s.dialplan_uuid = :dialplan_uuid ";
+ $parameters['dialplan_uuid'] = $this->uuid;
}
- $sql .= "order by \n";
- $sql .= "p.dialplan_order asc, \n";
- $sql .= "p.dialplan_name asc, \n";
- $sql .= "p.dialplan_uuid asc, \n";
- $sql .= "s.dialplan_detail_group asc, \n";
- $sql .= "CASE s.dialplan_detail_tag \n";
- $sql .= "WHEN 'condition' THEN 1 \n";
- $sql .= "WHEN 'action' THEN 2 \n";
- $sql .= "WHEN 'anti-action' THEN 3 \n";
- $sql .= "ELSE 100 END, \n";
- $sql .= "s.dialplan_detail_order asc \n";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $results = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-
- //debug info
- //echo "sql: $sql\n";
- //echo "
\n";
- //print_r($results);
- //echo "
\n";
- //exit;
+ $sql .= "order by ";
+ $sql .= "p.dialplan_order asc, ";
+ $sql .= "p.dialplan_name asc, ";
+ $sql .= "p.dialplan_uuid asc, ";
+ $sql .= "s.dialplan_detail_group asc, ";
+ $sql .= "case s.dialplan_detail_tag ";
+ $sql .= "when 'condition' then 1 ";
+ $sql .= "when 'action' then 2 ";
+ $sql .= "when 'anti-action' then 3 ";
+ $sql .= "else 100 end, ";
+ $sql .= "s.dialplan_detail_order asc ";
+ $database = new database;
+ $results = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
//loop through the results to get the xml from the dialplan_xml field or from dialplan details table
$x = 0;
- foreach ($results as $row) {
- //clear flag pass
- $pass = false;
+ if (is_array($result) && @sizeof($result) != 0) {
+ foreach ($results as $row) {
+ //clear flag pass
+ $pass = false;
- //get the dialplan
- $domain_uuid = $row["domain_uuid"];
- $dialplan_uuid = $row["dialplan_uuid"];
- //$app_uuid = $row["app_uuid"];
- $this->context = $row["dialplan_context"];
- $dialplan_name = $row["dialplan_name"];
- //$dialplan_number = $row["dialplan_number"];
- $dialplan_continue = $row["dialplan_continue"];
- //$dialplan_order = $row["dialplan_order"];
- //$dialplan_enabled = $row["dialplan_enabled"];
- //$dialplan_description = $row["dialplan_description"];
+ //get the dialplan
+ $domain_uuid = $row["domain_uuid"];
+ $dialplan_uuid = $row["dialplan_uuid"];
+ //$app_uuid = $row["app_uuid"];
+ $this->context = $row["dialplan_context"];
+ $dialplan_name = $row["dialplan_name"];
+ //$dialplan_number = $row["dialplan_number"];
+ $dialplan_continue = $row["dialplan_continue"];
+ //$dialplan_order = $row["dialplan_order"];
+ //$dialplan_enabled = $row["dialplan_enabled"];
+ //$dialplan_description = $row["dialplan_description"];
- //$get the dialplan details
- //$dialplan_detail_uuid = $row["dialplan_detail_uuid"];
- $dialplan_detail_tag = $row["dialplan_detail_tag"];
- $dialplan_detail_type = $row["dialplan_detail_type"];
- $dialplan_detail_data = $row["dialplan_detail_data"];
- $dialplan_detail_break = $row["dialplan_detail_break"];
- $dialplan_detail_inline = $row["dialplan_detail_inline"];
- $dialplan_detail_group = $row["dialplan_detail_group"];
- //$dialplan_detail_order = $row["dialplan_detail_order;
+ //$get the dialplan details
+ //$dialplan_detail_uuid = $row["dialplan_detail_uuid"];
+ $dialplan_detail_tag = $row["dialplan_detail_tag"];
+ $dialplan_detail_type = $row["dialplan_detail_type"];
+ $dialplan_detail_data = $row["dialplan_detail_data"];
+ $dialplan_detail_break = $row["dialplan_detail_break"];
+ $dialplan_detail_inline = $row["dialplan_detail_inline"];
+ $dialplan_detail_group = $row["dialplan_detail_group"];
+ //$dialplan_detail_order = $row["dialplan_detail_order;
- //remove $$ and replace with $
- $dialplan_detail_data = str_replace("$$", "$", $dialplan_detail_data);
+ //remove $$ and replace with $
+ $dialplan_detail_data = str_replace("$$", "$", $dialplan_detail_data);
- //get the dialplan detail inline
- $detail_inline = "";
- if ($dialplan_detail_inline) {
- if (strlen($dialplan_detail_inline) > 0) {
- $detail_inline = " inline=\"" . $dialplan_detail_inline . "\"";
- }
- }
-
- //close the tags
- if ($dialplan_tag_status != "closed") {
- if (($previous_dialplan_uuid != $dialplan_uuid) || ($previous_dialplan_detail_group != $dialplan_detail_group)) {
- if ($condition_tag_status != "closed") {
- if ($condition_attribute && (strlen($condition_attribute) > 0)) {
- $xml .= " \n";
- $condition_attribute = "";
- $condition_tag_status = "closed";
- }
- elseif ($condition && (strlen($condition) > 0)) {
- $xml .= " ".$condition . "/>";
- $condition = "";
- $condition_tag_status = "closed";
- }
- elseif ($condition_tag_status != "closed") {
- $xml .= " \n";
- $condition_tag_status = "closed";
- }
- $condition_tag_status = "closed";
+ //get the dialplan detail inline
+ $detail_inline = "";
+ if ($dialplan_detail_inline) {
+ if (strlen($dialplan_detail_inline) > 0) {
+ $detail_inline = " inline=\"" . $dialplan_detail_inline . "\"";
}
}
- if ($previous_dialplan_uuid != $dialplan_uuid) {
- $xml .= "\n";
- //add to the dialplanss
- $dialplans[$previous_dialplan_uuid] = $xml;
- $xml = '';
-
- $dialplan_tag_status = "closed";
- }
- }
-
- //open the tags
- if ($dialplan_tag_status == "closed") {
- $xml = '';
- $xml .= "\n";
- $dialplan_tag_status = "open";
- $first_action = true;
- $condition = "";
- $condition_attribute = "";
- }
- if ($dialplan_detail_tag == "condition") {
- //determine the type of condition
- if ($dialplan_detail_type == "hour") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "minute") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "minute-of-day") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "mday") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "mweek") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "mon") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "time-of-day") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "yday") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "year") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "wday") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "week") {
- $condition_type = 'time';
- }
- elseif ($dialplan_detail_type == "date-time") {
- $condition_type = 'time';
- }
- else {
- $condition_type = 'default';
- }
-
- // finalize any previous pending condition statements
- if ($condition_tag_status == "open") {
- if (strlen($condition) > 0) {
- $xml .= $condition . "/>\n";
- $condition = '';
- $condition_tag_status = "closed";
- }
- elseif (strlen($condition_attribute) > 0 && $condition_tag_status == "open") {
- // previous condition(s) must have been of type time
- // do not finalize if new condition is also of type time
- if ($condition_type != 'time') {
- // note: condition_break here is value from the previous loop
+ //close the tags
+ if ($dialplan_tag_status != "closed") {
+ if (($previous_dialplan_uuid != $dialplan_uuid) || ($previous_dialplan_detail_group != $dialplan_detail_group)) {
+ if ($condition_tag_status != "closed") {
+ if ($condition_attribute && (strlen($condition_attribute) > 0)) {
$xml .= " \n";
- $condition_attribute = '';
+ $condition_attribute = "";
$condition_tag_status = "closed";
}
- //else {
- // $xml .= " \n";
- // $condition_tag_status = "closed";
- //}
+ else if ($condition && (strlen($condition) > 0)) {
+ $xml .= " ".$condition . "/>";
+ $condition = "";
+ $condition_tag_status = "closed";
+ }
+ else if ($condition_tag_status != "closed") {
+ $xml .= " \n";
+ $condition_tag_status = "closed";
+ }
+ $condition_tag_status = "closed";
}
}
+ if ($previous_dialplan_uuid != $dialplan_uuid) {
+ $xml .= "\n";
- //get the condition break attribute
- $condition_break = "";
- if ($dialplan_detail_break) {
- if (strlen($dialplan_detail_break) > 0) {
- $condition_break = " break=\"" . $dialplan_detail_break . "\"";
- }
- }
+ //add to the dialplanss
+ $dialplans[$previous_dialplan_uuid] = $xml;
+ $xml = '';
- //condition tag but leave off the ending
- if ($condition_type == "default") {
- $condition = " 0)) {
- $xml .= " \n";
- $condition_attribute = "";
- }
- elseif ($condition && (strlen($condition) > 0)) {
- $xml .= $condition . ">\n";
- $condition = "";
+ $dialplan_tag_status = "closed";
}
}
- }
- if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
- if ($dialplan_detail_tag == "action") {
- if ($first_action) {
- //get the domains
- if (!isset($domains)) {
- $sql = "select * from v_domains; \n";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach($result as $row) {
- $domains[$row['domain_uuid']] = $row['domain_name'];
+ //open the tags
+ if ($dialplan_tag_status == "closed") {
+ $xml = '';
+ $xml .= "\n";
+ $dialplan_tag_status = "open";
+ $first_action = true;
+ $condition = "";
+ $condition_attribute = "";
+ }
+ if ($dialplan_detail_tag == "condition") {
+ //determine the type of condition
+ if ($dialplan_detail_type == "hour") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "minute") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "minute-of-day") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "mday") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "mweek") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "mon") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "time-of-day") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "yday") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "year") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "wday") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "week") {
+ $condition_type = 'time';
+ }
+ else if ($dialplan_detail_type == "date-time") {
+ $condition_type = 'time';
+ }
+ else {
+ $condition_type = 'default';
+ }
+
+ // finalize any previous pending condition statements
+ if ($condition_tag_status == "open") {
+ if (strlen($condition) > 0) {
+ $xml .= $condition . "/>\n";
+ $condition = '';
+ $condition_tag_status = "closed";
+ }
+ else if (strlen($condition_attribute) > 0 && $condition_tag_status == "open") {
+ // previous condition(s) must have been of type time
+ // do not finalize if new condition is also of type time
+ if ($condition_type != 'time') {
+ // note: condition_break here is value from the previous loop
+ $xml .= " \n";
+ $condition_attribute = '';
+ $condition_tag_status = "closed";
}
+ //else {
+ // $xml .= " \n";
+ // $condition_tag_status = "closed";
+ //}
}
- //add the call direction and domain name and uuid
- $xml .= " \n";
- if ($domain_uuid != null and $domain_uuid != '') {
- $domain_name = $domains[$domain_uuid];
- $xml .= " \n";
+ }
+
+ //get the condition break attribute
+ $condition_break = "";
+ if ($dialplan_detail_break) {
+ if (strlen($dialplan_detail_break) > 0) {
+ $condition_break = " break=\"" . $dialplan_detail_break . "\"";
}
- if ($domain_name != null and $domain_name != '') {
- $xml .= " \n";
+ }
+
+ //condition tag but leave off the ending
+ if ($condition_type == "default") {
+ $condition = " 0)) {
+ $xml .= " \n";
+ $condition_attribute = "";
+ }
+ else if ($condition && (strlen($condition) > 0)) {
+ $xml .= $condition . ">\n";
+ $condition = "";
+ }
}
}
- }
- if ($dialplan_detail_tag == "action") {
- $xml .= " \n";
- }
- if ($dialplan_detail_tag == "anti-action") {
- $xml .= " \n";
- }
- //save the previous values
- $previous_dialplan_uuid = $dialplan_uuid;
- $previous_dialplan_detail_group = $dialplan_detail_group;
+ if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
+ if ($dialplan_detail_tag == "action") {
+ if ($first_action) {
+ //get the domains
+ if (!isset($domains)) {
+ $sql = "select * from v_domains ";
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
+ foreach($result as $row) {
+ $domains[$row['domain_uuid']] = $row['domain_name'];
+ }
+ }
+ unset($sql, $result, $row);
+ }
+ //add the call direction and domain name and uuid
+ $xml .= " \n";
+ if ($domain_uuid != null and $domain_uuid != '') {
+ $domain_name = $domains[$domain_uuid];
+ $xml .= " \n";
+ }
+ if ($domain_name != null and $domain_name != '') {
+ $xml .= " \n";
+ }
+ $first_action = false;
+ }
+ }
+ }
+ if ($dialplan_detail_tag == "action") {
+ $xml .= " \n";
+ }
+ if ($dialplan_detail_tag == "anti-action") {
+ $xml .= " \n";
+ }
- //increment the x
- $x++;
+ //save the previous values
+ $previous_dialplan_uuid = $dialplan_uuid;
+ $previous_dialplan_detail_group = $dialplan_detail_group;
- //set flag pass
- $pass = true;
+ //increment the x
+ $x++;
+
+ //set flag pass
+ $pass = true;
+ }
}
+ unset($results, $row);
// prevent partial dialplan (pass=nil may be error in sql or empty resultset)
if ($pass == false) {
@@ -893,9 +848,10 @@ include "root.php";
if ($condition_attribute and (strlen($condition_attribute) > 0)) {
$xml .= " \n";
}
- elseif ($condition && (strlen($condition) > 0)) {
+ else if ($condition && (strlen($condition) > 0)) {
$xml .= $condition . "/>\n";
- } else {
+ }
+ else {
$xml .= " \n";
}
}
@@ -920,29 +876,29 @@ include "root.php";
//save the dialplan xml
if ($this->destination == "database") {
if (is_array($dialplans)) {
+ $x = 0;
foreach ($dialplans as $key => $value) {
- $sql = "update v_dialplans ";
- //$sql .= "set dialplan_xml = ':xml' ";
- $sql .= "set dialplan_xml = '".check_str($value)."' ";
- //$sql .= "where dialplan_uuid=:dialplan_uuid ";
- $sql .= "where dialplan_uuid = '$key';";
- //$prep_statement = $this->db->prepare(check_sql($sql));
- //$prep_statement->bindParam(':xml', $value );
- //$prep_statement->bindParam(':dialplan_uuid', $key);
- //$prep_statement->execute();
- //$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- //print_r($result);
- unset($prep_statement);
- $this->db->query($sql);
- unset($sql);
+ //build update array
+ $array['dialplans'][$x]['dialplan_uuid'] = $key;
+ $array['dialplans'][$x]['dialplan_xml'] = $value;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_edit', 'temp');
+ //execute update
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('dialplan_edit', 'temp');
}
}
- //return true;
}
- } //end method
+ }
- public function defaults () {
+ public function defaults() {
//get the array of xml files and then process thm
$xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml");
@@ -964,13 +920,14 @@ include "root.php";
}
//update the dialplan order
- $sql = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup';\n";
- $this->db->query($sql);
- $sql = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen';\n";
- $this->db->query($sql);
- $sql = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension';\n";
- $this->db->query($sql);
- unset($sql);
+ $sql[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' ";
+ $sql[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' ";
+ $sql[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' ";
+ $database = new database;
+ foreach ($sql as $query) {
+ $database->execute($query);
+ }
+ unset($sql, $query);
//add xml for each dialplan where the dialplan xml is empty
$this->source = "details";
@@ -978,10 +935,11 @@ include "root.php";
$this->is_empty = "dialplan_xml";
$array = $this->xml();
//print_r($array);
- unset($this->source,$this->destination,$this->is_empty,$array);
+ unset($this->source, $this->destination, $this->is_empty, $array);
- } // end method
- } // end class
- } // class_exists
+ }
-?>
+ }
+ }
+
+?>
\ No newline at end of file
diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php
index c7e4cab3af..fa6af67fcb 100644
--- a/app/extensions/resources/classes/extension.php
+++ b/app/extensions/resources/classes/extension.php
@@ -27,7 +27,6 @@
//define the directory class
if (!class_exists('extension')) {
class extension {
- public $db;
public $domain_uuid;
public $domain_name;
private $app_uuid;
@@ -72,14 +71,6 @@ if (!class_exists('extension')) {
public $description;
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;
- }
-
//set the application id
$this->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
}
@@ -91,21 +82,18 @@ if (!class_exists('extension')) {
}
public function exists($domain_uuid, $extension) {
- $sql = "select extension_uuid from v_extensions ";
+ $sql = "select count(*) from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
- $sql .= "and (extension = :extension or number_alias = :extension) ";
+ $sql .= "and ( ";
+ $sql .= "extension = :extension ";
+ $sql .= "or number_alias = :extension ";
+ $sql .= ") ";
$sql .= "and enabled = 'true' ";
- $prep_statement = $this->db->prepare($sql);
- $prep_statement->bindParam(':domain_uuid', $domain_uuid);
- $prep_statement->bindParam(':extension', $extension);
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if ($result && count($result) > 0) {
- return true;
- }
- else {
- return false;
- }
+ $parameters['domain_uuid'] = $domain_uuid;
+ $parameters['extension'] = $extension;
+ $database = new database;
+ return $database->select($sql, $parameters, 'column') != 0 ? true : false;
+ unset($sql, $parameters);
}
public function get_domain_uuid() {
@@ -117,7 +105,6 @@ if (!class_exists('extension')) {
}
public function voicemail() {
-
//determine the voicemail_id
if (is_numeric($this->number_alias)) {
$this->voicemail_id = $this->number_alias;
@@ -126,66 +113,58 @@ if (!class_exists('extension')) {
$this->voicemail_id = $this->extension;
}
- //update the voicemail settings
- $sql = "select * from v_voicemails ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_id = '".$this->voicemail_id."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) == 0) {
- //add the voicemail box
- $sql = "insert into v_voicemails ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "voicemail_uuid, ";
- $sql .= "voicemail_id, ";
- $sql .= "voicemail_password, ";
- if (strlen($this->greeting_id) > 0) {
- $sql .= "greeting_id, ";
- }
- $sql .= "voicemail_mail_to, ";
- $sql .= "voicemail_file, ";
- $sql .= "voicemail_local_after_email, ";
- $sql .= "voicemail_enabled, ";
- $sql .= "voicemail_description ";
- $sql .= ") ";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$this->domain_uuid."', ";
- $sql .= "'".uuid()."', ";
- $sql .= "'".$this->voicemail_id."', ";
- $sql .= "'".$this->voicemail_password."', ";
- $sql .= "'".$this->voicemail_mail_to."', ";
- $sql .= "'".$this->voicemail_file."', ";
- $sql .= "'".$this->voicemail_local_after_email."', ";
- $sql .= "'".$this->voicemail_enabled."', ";
- $sql .= "'".$this->description."' ";
- $sql .= ")";
- $this->db->exec(check_sql($sql));
- unset($sql);
+ //insert or update the voicemail settings
+ $sql = "select voicemail_uuid from v_voicemails ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_id = :voicemail_id ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['voicemail_id'] = $this->voicemail_id;
+ $database = new database;
+ $voicemail_uuid = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
+
+ if (is_uuid($voicemail_uuid)) {
+ //build update array
+ $array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_edit', 'temp');
}
else {
- //update the voicemail box
- $sql = "update v_voicemails set ";
- $sql .= "voicemail_password = '".$this->voicemail_password."', ";
- $sql .= "voicemail_mail_to = '".$this->voicemail_mail_to."', ";
- $sql .= "voicemail_file = '".$this->voicemail_file."', ";
- $sql .= "voicemail_local_after_email = '".$this->voicemail_local_after_email."', ";
- $sql .= "voicemail_enabled = '".$this->voicemail_enabled."', ";
- $sql .= "voicemail_description = '".$this->description."' ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_id = '".$this->voicemail_id."' ";
- $this->db->exec(check_sql($sql));
- unset($sql);
+ //build insert array
+ $array['voicemails'][0]['voicemail_uuid'] = uuid();
+ $array['voicemails'][0]['domain_uuid'] = $this->domain_uuid;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_add', 'temp');
}
- unset ($prep_statement);
+ if (is_array($array) && @sizeof($array) != 0) {
+ //include common array fields
+ $array['voicemails'][0]['voicemail_id'] = $this->voicemail_id;
+ $array['voicemails'][0]['voicemail_password'] = $this->voicemail_password;
+ $array['voicemails'][0]['voicemail_mail_to'] = $this->voicemail_mail_to;
+ $array['voicemails'][0]['voicemail_file'] = $this->voicemail_file;
+ $array['voicemails'][0]['voicemail_local_after_email'] = $this->voicemail_local_after_email;
+ $array['voicemails'][0]['voicemail_enabled'] = $this->voicemail_enabled;
+ $array['voicemails'][0]['voicemail_description'] = $this->description;
+ //execute insert/update
+ $database = new database;
+ $database->app_name = 'extensions';
+ $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('voicemail_edit', 'temp');
+ $p->delete('voicemail_add', 'temp');
+ }
+
+ unset($voicemail_uuid);
}
public function xml() {
if (isset($_SESSION['switch']['extensions']['dir'])) {
//declare global variables
- global $config, $db, $domain_uuid;
+ global $config, $domain_uuid;
//get the domain_name
$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
@@ -198,243 +177,246 @@ if (!class_exists('extension')) {
}
//write the xml files
- $sql = "SELECT * FROM v_extensions AS e, v_voicemails AS v ";
- $sql .= "WHERE e.domain_uuid = '$domain_uuid' ";
- $sql .= "AND COALESCE(NULLIF(e.number_alias,''),e.extension) = CAST(v.voicemail_id as VARCHAR) ";
- $sql .= "ORDER BY e.call_group ASC ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $i = 0;
+ $sql = "select * from v_extensions as e, v_voicemails as v ";
+ $sql .= "where e.domain_uuid = :domain_uuid ";
+ $sql .= "and coalesce(nullif(e.number_alias,''),e.extension) = cast(v.voicemail_id as varchar) ";
+ $sql .= "order by e.call_group asc ";
+ $parameters['domain_uuid'] = $domain_uuid;
+ $database = new database;
+ $rows = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
+
$extension_xml_condensed = false;
- while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
- $call_group = $row['call_group'];
- $call_group = str_replace(";", ",", $call_group);
- $tmp_array = explode(",", $call_group);
- foreach ($tmp_array as &$tmp_call_group) {
- $tmp_call_group = trim($tmp_call_group);
- if (strlen($tmp_call_group) > 0) {
- if (strlen($call_group_array[$tmp_call_group]) == 0) {
- $call_group_array[$tmp_call_group] = $row['extension'];
+ if (is_array($rows) && @sizeof($rows) != 0) {
+ foreach ($rows as $row) {
+ $call_group = $row['call_group'];
+ $call_group = str_replace(";", ",", $call_group);
+ $tmp_array = explode(",", $call_group);
+ foreach ($tmp_array as &$tmp_call_group) {
+ $tmp_call_group = trim($tmp_call_group);
+ if (strlen($tmp_call_group) > 0) {
+ if (strlen($call_group_array[$tmp_call_group]) == 0) {
+ $call_group_array[$tmp_call_group] = $row['extension'];
+ }
+ else {
+ $call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
+ }
+ }
+ }
+ $call_timeout = $row['call_timeout'];
+ $user_context = $row['user_context'];
+ $password = $row['password'];
+ $voicemail_password = $row['voicemail_password'];
+ //$voicemail_password = str_replace("#", "", $voicemail_password); //preserves leading zeros
+
+ //echo "enabled: ".$row['enabled'];
+ if ($row['enabled'] != "false") {
+ $extension_uuid = $row['extension_uuid'];
+ //remove invalid characters from the file names
+ $extension = $row['extension'];
+ $extension = str_replace(" ", "_", $extension);
+ $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
+ $dial_string = $row['dial_string'];
+ if (strlen($dial_string) == 0) {
+ if (strlen($_SESSION['domain']['dial_string']['text']) > 0) {
+ $dial_string = $_SESSION['domain']['dial_string']['text'];
+ }
+ else {
+ $dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
+ }
+ }
+
+ //set the password hashes
+ $a1_hash = md5($extension.":".$domain_name.":".$password);
+ $vm_a1_hash = md5($extension.":".$domain_name.":".$voicemail_password);
+
+ $xml .= "\n";
+ $cidr = '';
+ if (strlen($row['cidr']) > 0) {
+ $cidr = " cidr=\"" . $row['cidr'] . "\"";
+ }
+ $number_alias = '';
+ if (strlen($row['number_alias']) > 0) {
+ $number_alias = " number-alias=\"".$row['number_alias']."\"";
+ }
+ $xml .= " \n";
+ $xml .= " \n";
+ //$xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+
+ //voicemail settings
+ //$xml .= " \n";
+ $xml .= " \n";
+ switch ($row['voicemail_enabled']) {
+ case "true":
+ $xml .= " \n";
+ break;
+ case "false":
+ $xml .= " \n";
+ break;
+ default:
+ $xml .= " \n";
+ }
+ if (strlen($row['voicemail_mail_to']) > 0) {
+ $xml .= " \n";
+ switch ($row['voicemail_file']) {
+ case "attach":
+ $xml .= " \n";
+ break;
+ default:
+ $xml .= " \n";
+ }
+ switch ($row['voicemail_local_after_email']) {
+ case "true":
+ $xml .= " \n";
+ break;
+ case "false":
+ $xml .= " \n";
+ break;
+ default:
+ $xml .= " \n";
+ }
+ $xml .= " \n";
+ }
+
+ if (strlen($row['mwi_account']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['auth_acl']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['directory_exten_visible']) > 0) {
+ $xml .= " \n";
+ }
+ $xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+ $xml .= " \n";
+ if (strlen($row['call_group']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['user_record']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['hold_music']) > 0) {
+ $xml .= " \n";
+ }
+ $xml .= " \n";
+ if (strlen($row['call_timeout']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($switch_account_code) > 0) {
+ $xml .= " \n";
}
else {
- $call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
+ $xml .= " \n";
}
- }
- $i++;
- }
- $call_timeout = $row['call_timeout'];
- $user_context = $row['user_context'];
- $password = $row['password'];
- $voicemail_password = $row['voicemail_password'];
- //$voicemail_password = str_replace("#", "", $voicemail_password); //preserves leading zeros
-
- //echo "enabled: ".$row['enabled'];
- if ($row['enabled'] != "false") {
- $extension_uuid = $row['extension_uuid'];
- //remove invalid characters from the file names
- $extension = $row['extension'];
- $extension = str_replace(" ", "_", $extension);
- $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
- $dial_string = $row['dial_string'];
- if (strlen($dial_string) == 0) {
- if (strlen($_SESSION['domain']['dial_string']['text']) > 0) {
- $dial_string = $_SESSION['domain']['dial_string']['text'];
+ $xml .= " \n";
+ if (strlen($row['effective_caller_id_name']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['effective_caller_id_number']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['outbound_caller_id_name']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['outbound_caller_id_number']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['emergency_caller_id_name']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['emergency_caller_id_number']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['directory_full_name']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['directory_visible']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['limit_max']) > 0) {
+ $xml .= " \n";
}
else {
- $dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
+ $xml .= " \n";
}
- }
-
- //set the password hashes
- $a1_hash = md5($extension.":".$domain_name.":".$password);
- $vm_a1_hash = md5($extension.":".$domain_name.":".$voicemail_password);
-
- $xml .= "\n";
- $cidr = '';
- if (strlen($row['cidr']) > 0) {
- $cidr = " cidr=\"" . $row['cidr'] . "\"";
- }
- $number_alias = '';
- if (strlen($row['number_alias']) > 0) {
- $number_alias = " number-alias=\"".$row['number_alias']."\"";
- }
- $xml .= " \n";
- $xml .= " \n";
- //$xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
-
- //voicemail settings
- //$xml .= " \n";
- $xml .= " \n";
- switch ($row['voicemail_enabled']) {
- case "true":
- $xml .= " \n";
- break;
- case "false":
- $xml .= " \n";
- break;
- default:
- $xml .= " \n";
- }
- if (strlen($row['voicemail_mail_to']) > 0) {
- $xml .= " \n";
- switch ($row['voicemail_file']) {
- case "attach":
- $xml .= " \n";
- break;
- default:
- $xml .= " \n";
+ if (strlen($row['limit_destination']) > 0) {
+ $xml .= " \n";
}
- switch ($row['voicemail_local_after_email']) {
- case "true":
- $xml .= " \n";
- break;
- case "false":
- $xml .= " \n";
- break;
- default:
- $xml .= " \n";
+ if (strlen($row['sip_force_contact']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['sip_force_expires']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['nibble_account']) > 0) {
+ $xml .= " \n";
+ }
+ switch ($row['sip_bypass_media']) {
+ case "bypass-media":
+ $xml .= " \n";
+ break;
+ case "bypass-media-after-bridge":
+ $xml .= " \n";
+ break;
+ case "proxy-media":
+ $xml .= " \n";
+ break;
+ }
+ if (strlen($row['absolute_codec_string']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_all_enabled']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_all_destination']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_busy_enabled']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_busy_destination']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_no_answer_enabled']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_no_answer_destination']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_user_not_registered_enabled']) > 0) {
+ $xml .= " \n";
+ }
+ if (strlen($row['forward_user_not_registered_destination']) > 0) {
+ $xml .= " \n";
}
- $xml .= " \n";
- }
- if (strlen($row['mwi_account']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['auth_acl']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['directory_exten_visible']) > 0) {
- $xml .= " \n";
- }
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " \n";
- if (strlen($row['call_group']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['user_record']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['hold_music']) > 0) {
- $xml .= " \n";
- }
- $xml .= " \n";
- if (strlen($row['call_timeout']) > 0) {
- $xml .= " \n";
- }
- if (strlen($switch_account_code) > 0) {
- $xml .= " \n";
- }
- else {
- $xml .= " \n";
- }
- $xml .= " \n";
- if (strlen($row['effective_caller_id_name']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['effective_caller_id_number']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['outbound_caller_id_name']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['outbound_caller_id_number']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['emergency_caller_id_name']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['emergency_caller_id_number']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['directory_full_name']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['directory_visible']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['limit_max']) > 0) {
- $xml .= " \n";
- }
- else {
- $xml .= " \n";
- }
- if (strlen($row['limit_destination']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['sip_force_contact']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['sip_force_expires']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['nibble_account']) > 0) {
- $xml .= " \n";
- }
- switch ($row['sip_bypass_media']) {
- case "bypass-media":
- $xml .= " \n";
- break;
- case "bypass-media-after-bridge":
- $xml .= " \n";
- break;
- case "proxy-media":
- $xml .= " \n";
- break;
- }
- if (strlen($row['absolute_codec_string']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_all_enabled']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_all_destination']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_busy_enabled']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_busy_destination']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_no_answer_enabled']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_no_answer_destination']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_user_not_registered_enabled']) > 0) {
- $xml .= " \n";
- }
- if (strlen($row['forward_user_not_registered_destination']) > 0) {
- $xml .= " \n";
- }
+ if (strlen($row['do_not_disturb']) > 0) {
+ $xml .= " \n";
+ }
+ $xml .= " \n";
+ $xml .= " \n";
- if (strlen($row['do_not_disturb']) > 0) {
- $xml .= " \n";
+ if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
+ event_socket_mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context']);
+ }
+ if (strlen($extension) > 0) {
+ $fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
+ }
+ $xml .= "\n";
+ fwrite($fout, $xml);
+ unset($xml);
+ fclose($fout);
}
- $xml .= " \n";
- $xml .= " \n";
-
- if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
- event_socket_mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context']);
- }
- if (strlen($extension) > 0) {
- $fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
- }
- $xml .= "\n";
- fwrite($fout, $xml);
- unset($xml);
- fclose($fout);
}
}
- unset ($prep_statement);
+ unset($rows, $row);
//prepare extension
$extension_dir = realpath($_SESSION['switch']['extensions']['dir']);
@@ -533,4 +515,4 @@ if (!class_exists('extension')) {
}
}
-?>
+?>
\ No newline at end of file
diff --git a/app/modules/resources/classes/modules.php b/app/modules/resources/classes/modules.php
index 4262a48f0e..2efa0a5055 100644
--- a/app/modules/resources/classes/modules.php
+++ b/app/modules/resources/classes/modules.php
@@ -25,744 +25,732 @@
*/
include "root.php";
-//define the directory class
- class modules {
- //define the variables
- public $db;
- public $dir;
- public $fp;
- public $modules;
- public $msg;
+//define the modules class
+class modules {
+ //define the variables
+ public $dir;
+ public $fp;
+ public $modules;
+ public $msg;
- //get the additional information about a specific module
- public function info($name) {
- $module_label = substr($name, 4);
- $module_label = ucwords(str_replace("_", " ", $module_label));
- $mod['module_label'] = $module_label;
- $mod['module_name'] = $name;
- $mod['module_order'] = '800';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- $mod['module_description'] = '';
- switch ($name) {
- case "mod_amr":
- $mod['module_label'] = 'AMR';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'AMR codec.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_avmd":
- $mod['module_label'] = 'AVMD';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Advanced voicemail beep detection.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_blacklist":
- $mod['module_label'] = 'Blacklist';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Blacklist.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_bv":
- $mod['module_label'] = 'BV';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'BroadVoice16 and BroadVoice32 audio codecs.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_cdr_csv":
- $mod['module_label'] = 'CDR CSV';
- $mod['module_category'] = 'Event Handlers';
- $mod['module_description'] = 'CSV call detail record handler.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_cdr_sqlite":
- $mod['module_label'] = 'CDR SQLite';
- $mod['module_category'] = 'Event Handlers';
- $mod['module_description'] = 'SQLite call detail record handler.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_callcenter":
- $mod['module_label'] = 'Call Center';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Call queuing with agents and tiers for call centers.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_cepstral":
- $mod['module_label'] = 'Cepstral';
- $mod['module_category'] = 'Speech Recognition / Text to Speech';
- $mod['module_description'] = 'Text to Speech engine.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_cidlookup":
- $mod['module_label'] = 'CID Lookup';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Lookup caller id info.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_cluechoo":
- $mod['module_label'] = 'Cluechoo';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'A framework demo module.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_commands":
- $mod['module_label'] = 'Commands';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'API interface commands.';
- $mod['module_order'] = 100;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_conference":
- $mod['module_label'] = 'Conference';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Conference room module.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_console":
- $mod['module_label'] = 'Console';
- $mod['module_category'] = 'Loggers';
- $mod['module_description'] = 'Send logs to the console.';
- $mod['module_order'] = 400;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_curl":
- $mod['module_label'] = 'CURL';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Allows scripts to make HTTP requests and return responses in plain text or JSON.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_db":
- $mod['module_label'] = 'DB';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Database key / value storage functionality, dialing and limit backend.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_dialplan_asterisk":
- $mod['module_label'] = 'Dialplan Asterisk';
- $mod['module_category'] = 'Dialplan Interfaces';
- $mod['module_description'] = 'Allows Asterisk dialplans.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_dialplan_xml":
- $mod['module_label'] = 'Dialplan XML';
- $mod['module_category'] = 'Dialplan Interfaces';
- $mod['module_description'] = 'Provides dialplan functionality in XML.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_directory":
- $mod['module_label'] = 'Directory';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Dial by name directory.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_distributor":
- $mod['module_label'] = 'Distributor';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Round robin call distribution.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_dptools":
- $mod['module_label'] = 'Dialplan Plan Tools';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Provides a number of apps and utilities for the dialplan.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_enum":
- $mod['module_label'] = 'ENUM';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Route PSTN numbers over internet according to ENUM servers, such as e164.org.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_esf":
- $mod['module_label'] = 'ESF';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Holds the multi cast paging application for SIP.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_event_socket":
- $mod['module_label'] = 'Event Socket';
- $mod['module_category'] = 'Event Handlers';
- $mod['module_description'] = 'Sends events via a single socket.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_expr":
- $mod['module_label'] = 'Expr';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Expression evaluation library.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_fifo":
- $mod['module_label'] = 'FIFO';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'FIFO provides custom call queues including call park.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_flite":
- $mod['module_label'] = 'Flite';
- $mod['module_category'] = 'Speech Recognition / Text to Speech';
- $mod['module_description'] = 'Text to Speech engine.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_fsv":
- $mod['module_label'] = 'FSV';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Video application (Recording and playback).';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_g723_1":
- $mod['module_label'] = 'G.723.1';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'G.723.1 codec.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_g729":
- $mod['module_label'] = 'G.729';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'G729 codec supports passthrough mode';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_h26x":
- $mod['module_label'] = 'H26x';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'Video codecs';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_hash":
- $mod['module_label'] = 'Hash';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Resource limitation.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_httapi":
- $mod['module_label'] = 'HT-TAPI';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'HT-TAPI Hypertext Telephony API';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_http_cache":
- $mod['module_label'] = 'HTTP Cache';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'HTTP GET with caching';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_ilbc":
- $mod['module_label'] = 'iLBC';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'iLBC codec.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_ladspa":
- $mod['module_label'] = 'Ladspa';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Auto-tune calls.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_lcr":
- $mod['module_label'] = 'LCR';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Least cost routing.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_local_stream":
- $mod['module_label'] = 'Local Stream';
- $mod['module_category'] = 'Streams / Files';
- $mod['module_description'] = 'For local streams (play all the files in a directory).';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_logfile":
- $mod['module_label'] = 'Log File';
- $mod['module_category'] = 'Loggers';
- $mod['module_description'] = 'Send logs to the local file system.';
- $mod['module_order'] = 400;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_loopback":
- $mod['module_label'] = 'Loopback';
- $mod['module_category'] = 'Endpoints';
- $mod['module_description'] = 'A loopback channel driver to make an outbound call as an inbound call.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_lua":
- $mod['module_label'] = 'Lua';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'Lua script.';
- $mod['module_order'] = 200;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_memcache":
- $mod['module_label'] = 'Memcached';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'API for memcached.';
- $mod['module_enabled'] = 'true';
- $mod['module_order'] = 150;
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_native_file":
- $mod['module_label'] = 'Native File';
- $mod['module_category'] = 'File Format Interfaces';
- $mod['module_description'] = 'File interface for codec specific file formats.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_nibblebill":
- $mod['module_label'] = 'Nibblebill';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Billing module.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_opus":
- $mod['module_label'] = 'Opus';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'OPUS ultra-low delay audio codec';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_park":
- $mod['module_label'] = 'Park';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Park Calls.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_pocketsphinx":
- $mod['module_label'] = 'PocketSphinx';
- $mod['module_category'] = 'Speech Recognition / Text to Speech';
- $mod['module_description'] = 'Speech Recognition.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_rtmp":
- $mod['module_label'] = 'RTMP';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Real Time Media Protocol';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_de":
- $mod['module_label'] = 'German';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_en":
- $mod['module_label'] = 'English';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_es":
- $mod['module_label'] = 'Spanish';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_fr":
- $mod['module_label'] = 'French';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_he":
- $mod['module_label'] = 'Hebrew';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_hu":
- $mod['module_label'] = 'Hungarian';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_it":
- $mod['module_label'] = 'Italian';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_nl":
- $mod['module_label'] = 'Dutch';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_pt":
- $mod['module_label'] = 'Portuguese';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_ru":
- $mod['module_label'] = 'Russian';
- $mod['module_category'] = 'Say';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_th":
- $mod['module_label'] = 'Thai';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_say_zh":
- $mod['module_label'] = 'Chinese';
- $mod['module_category'] = 'Say';
- $mod['module_description'] = '';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_shout":
- $mod['module_label'] = 'Shout';
- $mod['module_category'] = 'Streams / Files';
- $mod['module_description'] = 'MP3 files and shoutcast streams.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_siren":
- $mod['module_label'] = 'Siren';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'Siren codec';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_sms":
- $mod['module_label'] = 'SMS';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Chat messages';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_sndfile":
- $mod['module_label'] = 'Sound File';
- $mod['module_category'] = 'File Format Interfaces';
- $mod['module_description'] = 'Multi-format file format transcoder (WAV, etc).';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_sofia":
- $mod['module_label'] = 'Sofia';
- $mod['module_category'] = 'Endpoints';
- $mod['module_description'] = 'SIP module.';
- $mod['module_order'] = 300;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_spandsp":
- $mod['module_label'] = 'SpanDSP';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'FAX provides fax send and receive.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_speex":
- $mod['module_label'] = 'Speex';
- $mod['module_category'] = 'Codecs';
- $mod['module_description'] = 'Speex codec.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_spidermonkey":
- $mod['module_label'] = 'SpiderMonkey';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'JavaScript support.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_spidermonkey_core_db":
- $mod['module_label'] = 'SpiderMonkey Core DB';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'Javascript support for SQLite.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_spidermonkey_curl":
- $mod['module_label'] = 'SpiderMonkey Curl';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'Javascript curl support.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_spidermonkey_socket":
- $mod['module_label'] = 'SpiderMonkey Socket';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'Javascript socket support.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_spidermonkey_teletone":
- $mod['module_label'] = 'SpiderMonkey Teletone';
- $mod['module_category'] = 'Languages';
- $mod['module_description'] = 'Javascript teletone support.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_syslog":
- $mod['module_label'] = 'Syslog';
- $mod['module_category'] = 'Loggers';
- $mod['module_description'] = 'Send logs to a remote syslog server.';
- $mod['module_order'] = 400;
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_tone_stream":
- $mod['module_label'] = 'Tone Stream';
- $mod['module_category'] = 'Streams / Files';
- $mod['module_description'] = 'Generate tone streams.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_tts_commandline":
- $mod['module_label'] = 'TTS Commandline';
- $mod['module_category'] = 'Speech Recognition / Text to Speech';
- $mod['module_description'] = 'Commandline text to speech engine.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_unimrcp":
- $mod['module_label'] = 'MRCP';
- $mod['module_category'] = 'Speech Recognition / Text to Speech';
- $mod['module_description'] = 'Media Resource Control Protocol.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_valet_parking":
- $mod['module_label'] = 'Valet Parking';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Call parking';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_voicemail":
- $mod['module_label'] = 'Voicemail';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Full featured voicemail module.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_voicemail_ivr":
- $mod['module_label'] = 'Voicemail IVR';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'Voicemail IVR interface.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_translate":
- $mod['module_label'] = 'Translate';
- $mod['module_category'] = 'Applications';
- $mod['module_description'] = 'format numbers into a specified format.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_xml_cdr":
- $mod['module_label'] = 'XML CDR';
- $mod['module_category'] = 'XML Interfaces';
- $mod['module_description'] = 'XML based call detail record handler.';
- $mod['module_enabled'] = 'true';
- $mod['module_default_enabled'] = 'true';
- break;
- case "mod_xml_curl":
- $mod['module_label'] = 'XML Curl';
- $mod['module_category'] = 'XML Interfaces';
- $mod['module_description'] = 'Request XML config files dynamically.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- case "mod_xml_rpc":
- $mod['module_label'] = 'XML RPC';
- $mod['module_category'] = 'XML Interfaces';
- $mod['module_description'] = 'XML Remote Procedure Calls. Issue commands from your web application.';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- break;
- default:
- $mod['module_category'] = 'Auto';
- $mod['module_enabled'] = 'false';
- $mod['module_default_enabled'] = 'false';
- }
- return $mod;
+ //get the additional information about a specific module
+ public function info($name) {
+ $module_label = substr($name, 4);
+ $module_label = ucwords(str_replace("_", " ", $module_label));
+ $mod['module_label'] = $module_label;
+ $mod['module_name'] = $name;
+ $mod['module_order'] = '800';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ $mod['module_description'] = '';
+ switch ($name) {
+ case "mod_amr":
+ $mod['module_label'] = 'AMR';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'AMR codec.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_avmd":
+ $mod['module_label'] = 'AVMD';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Advanced voicemail beep detection.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_blacklist":
+ $mod['module_label'] = 'Blacklist';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Blacklist.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_bv":
+ $mod['module_label'] = 'BV';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'BroadVoice16 and BroadVoice32 audio codecs.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_cdr_csv":
+ $mod['module_label'] = 'CDR CSV';
+ $mod['module_category'] = 'Event Handlers';
+ $mod['module_description'] = 'CSV call detail record handler.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_cdr_sqlite":
+ $mod['module_label'] = 'CDR SQLite';
+ $mod['module_category'] = 'Event Handlers';
+ $mod['module_description'] = 'SQLite call detail record handler.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_callcenter":
+ $mod['module_label'] = 'Call Center';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Call queuing with agents and tiers for call centers.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_cepstral":
+ $mod['module_label'] = 'Cepstral';
+ $mod['module_category'] = 'Speech Recognition / Text to Speech';
+ $mod['module_description'] = 'Text to Speech engine.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_cidlookup":
+ $mod['module_label'] = 'CID Lookup';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Lookup caller id info.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_cluechoo":
+ $mod['module_label'] = 'Cluechoo';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'A framework demo module.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_commands":
+ $mod['module_label'] = 'Commands';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'API interface commands.';
+ $mod['module_order'] = 100;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_conference":
+ $mod['module_label'] = 'Conference';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Conference room module.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_console":
+ $mod['module_label'] = 'Console';
+ $mod['module_category'] = 'Loggers';
+ $mod['module_description'] = 'Send logs to the console.';
+ $mod['module_order'] = 400;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_curl":
+ $mod['module_label'] = 'CURL';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Allows scripts to make HTTP requests and return responses in plain text or JSON.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_db":
+ $mod['module_label'] = 'DB';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Database key / value storage functionality, dialing and limit backend.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_dialplan_asterisk":
+ $mod['module_label'] = 'Dialplan Asterisk';
+ $mod['module_category'] = 'Dialplan Interfaces';
+ $mod['module_description'] = 'Allows Asterisk dialplans.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_dialplan_xml":
+ $mod['module_label'] = 'Dialplan XML';
+ $mod['module_category'] = 'Dialplan Interfaces';
+ $mod['module_description'] = 'Provides dialplan functionality in XML.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_directory":
+ $mod['module_label'] = 'Directory';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Dial by name directory.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_distributor":
+ $mod['module_label'] = 'Distributor';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Round robin call distribution.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_dptools":
+ $mod['module_label'] = 'Dialplan Plan Tools';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Provides a number of apps and utilities for the dialplan.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_enum":
+ $mod['module_label'] = 'ENUM';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Route PSTN numbers over internet according to ENUM servers, such as e164.org.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_esf":
+ $mod['module_label'] = 'ESF';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Holds the multi cast paging application for SIP.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_event_socket":
+ $mod['module_label'] = 'Event Socket';
+ $mod['module_category'] = 'Event Handlers';
+ $mod['module_description'] = 'Sends events via a single socket.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_expr":
+ $mod['module_label'] = 'Expr';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Expression evaluation library.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_fifo":
+ $mod['module_label'] = 'FIFO';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'FIFO provides custom call queues including call park.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_flite":
+ $mod['module_label'] = 'Flite';
+ $mod['module_category'] = 'Speech Recognition / Text to Speech';
+ $mod['module_description'] = 'Text to Speech engine.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_fsv":
+ $mod['module_label'] = 'FSV';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Video application (Recording and playback).';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_g723_1":
+ $mod['module_label'] = 'G.723.1';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'G.723.1 codec.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_g729":
+ $mod['module_label'] = 'G.729';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'G729 codec supports passthrough mode';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_h26x":
+ $mod['module_label'] = 'H26x';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'Video codecs';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_hash":
+ $mod['module_label'] = 'Hash';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Resource limitation.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_httapi":
+ $mod['module_label'] = 'HT-TAPI';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'HT-TAPI Hypertext Telephony API';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_http_cache":
+ $mod['module_label'] = 'HTTP Cache';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'HTTP GET with caching';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_ilbc":
+ $mod['module_label'] = 'iLBC';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'iLBC codec.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_ladspa":
+ $mod['module_label'] = 'Ladspa';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Auto-tune calls.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_lcr":
+ $mod['module_label'] = 'LCR';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Least cost routing.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_local_stream":
+ $mod['module_label'] = 'Local Stream';
+ $mod['module_category'] = 'Streams / Files';
+ $mod['module_description'] = 'For local streams (play all the files in a directory).';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_logfile":
+ $mod['module_label'] = 'Log File';
+ $mod['module_category'] = 'Loggers';
+ $mod['module_description'] = 'Send logs to the local file system.';
+ $mod['module_order'] = 400;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_loopback":
+ $mod['module_label'] = 'Loopback';
+ $mod['module_category'] = 'Endpoints';
+ $mod['module_description'] = 'A loopback channel driver to make an outbound call as an inbound call.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_lua":
+ $mod['module_label'] = 'Lua';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'Lua script.';
+ $mod['module_order'] = 200;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_memcache":
+ $mod['module_label'] = 'Memcached';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'API for memcached.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_order'] = 150;
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_native_file":
+ $mod['module_label'] = 'Native File';
+ $mod['module_category'] = 'File Format Interfaces';
+ $mod['module_description'] = 'File interface for codec specific file formats.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_nibblebill":
+ $mod['module_label'] = 'Nibblebill';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Billing module.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_opus":
+ $mod['module_label'] = 'Opus';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'OPUS ultra-low delay audio codec';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_park":
+ $mod['module_label'] = 'Park';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Park Calls.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_pocketsphinx":
+ $mod['module_label'] = 'PocketSphinx';
+ $mod['module_category'] = 'Speech Recognition / Text to Speech';
+ $mod['module_description'] = 'Speech Recognition.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_rtmp":
+ $mod['module_label'] = 'RTMP';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Real Time Media Protocol';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_de":
+ $mod['module_label'] = 'German';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_en":
+ $mod['module_label'] = 'English';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_es":
+ $mod['module_label'] = 'Spanish';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_fr":
+ $mod['module_label'] = 'French';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_he":
+ $mod['module_label'] = 'Hebrew';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_hu":
+ $mod['module_label'] = 'Hungarian';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_it":
+ $mod['module_label'] = 'Italian';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_nl":
+ $mod['module_label'] = 'Dutch';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_pt":
+ $mod['module_label'] = 'Portuguese';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_ru":
+ $mod['module_label'] = 'Russian';
+ $mod['module_category'] = 'Say';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_th":
+ $mod['module_label'] = 'Thai';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_say_zh":
+ $mod['module_label'] = 'Chinese';
+ $mod['module_category'] = 'Say';
+ $mod['module_description'] = '';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_shout":
+ $mod['module_label'] = 'Shout';
+ $mod['module_category'] = 'Streams / Files';
+ $mod['module_description'] = 'MP3 files and shoutcast streams.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_siren":
+ $mod['module_label'] = 'Siren';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'Siren codec';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_sms":
+ $mod['module_label'] = 'SMS';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Chat messages';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_sndfile":
+ $mod['module_label'] = 'Sound File';
+ $mod['module_category'] = 'File Format Interfaces';
+ $mod['module_description'] = 'Multi-format file format transcoder (WAV, etc).';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_sofia":
+ $mod['module_label'] = 'Sofia';
+ $mod['module_category'] = 'Endpoints';
+ $mod['module_description'] = 'SIP module.';
+ $mod['module_order'] = 300;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_spandsp":
+ $mod['module_label'] = 'SpanDSP';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'FAX provides fax send and receive.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_speex":
+ $mod['module_label'] = 'Speex';
+ $mod['module_category'] = 'Codecs';
+ $mod['module_description'] = 'Speex codec.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_spidermonkey":
+ $mod['module_label'] = 'SpiderMonkey';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'JavaScript support.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_spidermonkey_core_db":
+ $mod['module_label'] = 'SpiderMonkey Core DB';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'Javascript support for SQLite.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_spidermonkey_curl":
+ $mod['module_label'] = 'SpiderMonkey Curl';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'Javascript curl support.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_spidermonkey_socket":
+ $mod['module_label'] = 'SpiderMonkey Socket';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'Javascript socket support.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_spidermonkey_teletone":
+ $mod['module_label'] = 'SpiderMonkey Teletone';
+ $mod['module_category'] = 'Languages';
+ $mod['module_description'] = 'Javascript teletone support.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_syslog":
+ $mod['module_label'] = 'Syslog';
+ $mod['module_category'] = 'Loggers';
+ $mod['module_description'] = 'Send logs to a remote syslog server.';
+ $mod['module_order'] = 400;
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_tone_stream":
+ $mod['module_label'] = 'Tone Stream';
+ $mod['module_category'] = 'Streams / Files';
+ $mod['module_description'] = 'Generate tone streams.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_tts_commandline":
+ $mod['module_label'] = 'TTS Commandline';
+ $mod['module_category'] = 'Speech Recognition / Text to Speech';
+ $mod['module_description'] = 'Commandline text to speech engine.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_unimrcp":
+ $mod['module_label'] = 'MRCP';
+ $mod['module_category'] = 'Speech Recognition / Text to Speech';
+ $mod['module_description'] = 'Media Resource Control Protocol.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_valet_parking":
+ $mod['module_label'] = 'Valet Parking';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Call parking';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_voicemail":
+ $mod['module_label'] = 'Voicemail';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Full featured voicemail module.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_voicemail_ivr":
+ $mod['module_label'] = 'Voicemail IVR';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'Voicemail IVR interface.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_translate":
+ $mod['module_label'] = 'Translate';
+ $mod['module_category'] = 'Applications';
+ $mod['module_description'] = 'format numbers into a specified format.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_xml_cdr":
+ $mod['module_label'] = 'XML CDR';
+ $mod['module_category'] = 'XML Interfaces';
+ $mod['module_description'] = 'XML based call detail record handler.';
+ $mod['module_enabled'] = 'true';
+ $mod['module_default_enabled'] = 'true';
+ break;
+ case "mod_xml_curl":
+ $mod['module_label'] = 'XML Curl';
+ $mod['module_category'] = 'XML Interfaces';
+ $mod['module_description'] = 'Request XML config files dynamically.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ case "mod_xml_rpc":
+ $mod['module_label'] = 'XML RPC';
+ $mod['module_category'] = 'XML Interfaces';
+ $mod['module_description'] = 'XML Remote Procedure Calls. Issue commands from your web application.';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
+ break;
+ default:
+ $mod['module_category'] = 'Auto';
+ $mod['module_enabled'] = 'false';
+ $mod['module_default_enabled'] = 'false';
}
+ return $mod;
+ }
- //check to see if the module exists in the array
- public function exists($name) {
- //set the default
- $result = false;
- //look for the module
- foreach ($this->modules as &$row) {
- if ($row['module_name'] == $name) {
- $result = true;
- break;
- }
- }
- //return the result
- return $result;
- }
-
- //check the status of the module
- public function active($name) {
- if (!$this->fp) {
- $this->fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
- }
- if ($this->fp) {
- $cmd = "api module_exists ".$name;
- $response = trim(event_socket_request($this->fp, $cmd));
- if ($response == "true") {
- return true;
- }
- else {
- return false;
+ //check to see if the module exists in the array
+ public function exists($name) {
+ //set the default
+ $result = false;
+ //look for the module
+ foreach ($this->modules as &$row) {
+ if ($row['module_name'] == $name) {
+ $result = true;
+ break;
}
}
- else {
- return false;
- }
- }
+ //return the result
+ return $result;
+ }
- //get the list of modules
- public function get_modules() {
- $sql = " select * from v_modules ";
- $sql .= "order by module_category, module_label";
- $prep_statement = $this->db->prepare($sql);
- $prep_statement->execute();
- $this->modules = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset ($prep_statement, $sql);
+ //check the status of the module
+ public function active($name) {
+ if (!$this->fp) {
+ $this->fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
}
+ if ($this->fp) {
+ $cmd = "api module_exists ".$name;
+ $response = trim(event_socket_request($this->fp, $cmd));
+ return $response == "true" ? true : false;
+ }
+ else {
+ return false;
+ }
+ }
- //add missing modules for more module info see http://wiki.freeswitch.com/wiki/Modules
- public function synch() {
- if ($handle = opendir($this->dir)) {
- $modules_new = '';
- $module_found = false;
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- if (substr($file, -3) == ".so" || substr($file, -4) == ".dll") {
- if (substr($file, -3) == ".so") {
- $name = substr($file, 0, -3);
- }
- if (substr($file, -4) == ".dll") {
- $name = substr($file, 0, -4);
- }
- if (!$this->exists($name)) {
- //set module found to true
- $module_found = true;
- //get the module array
- $mod = $this->info($name);
- //append the module label
- $modules_new .= "".$mod['module_label']."\n";
- //set the order
- $order = $mod['module_order'];
- //insert the data
- $module_uuid = uuid();
- $sql = "insert into v_modules ";
- $sql .= "(";
- $sql .= "module_uuid, ";
- $sql .= "module_label, ";
- $sql .= "module_name, ";
- $sql .= "module_description, ";
- $sql .= "module_category, ";
- $sql .= "module_order, ";
- $sql .= "module_enabled, ";
- $sql .= "module_default_enabled ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$module_uuid."', ";
- $sql .= "'".$mod['module_label']."', ";
- $sql .= "'".$mod['module_name']."', ";
- $sql .= "'".$mod['module_description']."', ";
- $sql .= "'".$mod['module_category']."', ";
- $sql .= "'".$order."', ";
- $sql .= "'".$mod['module_enabled']."', ";
- $sql .= "'".$mod['module_default_enabled']."' ";
- $sql .= ")";
- $this->db->exec($sql);
- unset($sql);
- }
+ //get the list of modules
+ public function get_modules() {
+ $sql = " select * from v_modules ";
+ $sql .= "order by module_category, module_label";
+ $database = new database;
+ $this->modules = $database->select($sql, null, 'all');
+ unset($sql);
+ }
+
+ //add missing modules for more module info see http://wiki.freeswitch.com/wiki/Modules
+ public function synch() {
+ if ($handle = opendir($this->dir)) {
+ $modules_new = '';
+ $module_found = false;
+ $x = 0;
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != "..") {
+ if (substr($file, -3) == ".so" || substr($file, -4) == ".dll") {
+ if (substr($file, -3) == ".so") {
+ $name = substr($file, 0, -3);
+ }
+ if (substr($file, -4) == ".dll") {
+ $name = substr($file, 0, -4);
+ }
+ if (!$this->exists($name)) {
+ //set module found to true
+ $module_found = true;
+ //get the module array
+ $mod = $this->info($name);
+ //append the module label
+ $modules_new .= "".$mod['module_label']."\n";
+ //set the order
+ $order = $mod['module_order'];
+ //build insert array
+ $array['modules'][$x]['module_uuid'] = uuid();
+ $array['modules'][$x]['module_label'] = $mod['module_label'];
+ $array['modules'][$x]['module_name'] = $mod['module_name'];
+ $array['modules'][$x]['module_description'] = $mod['module_description'];
+ $array['modules'][$x]['module_category'] = $mod['module_category'];
+ $array['modules'][$x]['module_order'] = $order;
+ $array['modules'][$x]['module_enabled'] = $mod['module_enabled'];
+ $array['modules'][$x]['module_default_enabled'] = $mod['module_default_enabled'];
+ $x++;
}
}
}
- closedir($handle);
- if ($module_found) {
- $msg = "Added New Modules:
\n";
- $msg .= "\n";
- $msg .= $modules_new;
- $msg .= "
\n";
- $this->msg = $msg;
- }
+ }
+ if (is_array($array) && @sizeof($array) != 0) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('module_add', 'temp');
+ //execute insert
+ $database = new database;
+ $database->app_name = 'modules';
+ $database->app_uuid = '5eb9cba1-8cb6-5d21-e36a-775475f16b5e';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('module_add', 'temp');
+ }
+ closedir($handle);
+ if ($module_found) {
+ $msg = "Added New Modules:
\n";
+ $msg .= "\n";
+ $msg .= $modules_new;
+ $msg .= "
\n";
+ $this->msg = $msg;
}
}
+ }
- //save the modules.conf.xml file
- function xml() {
- //set the globals
- global $config, $domain_uuid;
+ //save the modules.conf.xml file
+ function xml() {
+ //set the globals
+ global $config, $domain_uuid;
- //get the database connection
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $db = $database->db;
+ //compose xml
+ $xml = "\n";
+ $xml .= " \n";
- $xml = "\n";
- $xml .= " \n";
+ $sql = "select * from v_modules ";
+ $sql .= "order by module_order asc, ";
+ $sql .= "module_category asc ";
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ unset($sql);
- $sql = "select * from v_modules ";
- $sql .= "order by module_order ASC, ";
- $sql .= "module_category ASC";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $prev_module_cat = '';
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+ $prev_module_cat = '';
+ if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($prev_module_cat != $row['module_category']) {
$xml .= "\n \n";
@@ -772,29 +760,29 @@ include "root.php";
}
$prev_module_cat = $row['module_category'];
}
- $xml .= "\n";
- $xml .= " \n";
- $xml .= "";
+ }
+ unset($result, $row);
- $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/modules.conf.xml","w");
- fwrite($fout, $xml);
- unset($xml);
- fclose($fout);
+ $xml .= "\n";
+ $xml .= " \n";
+ $xml .= "";
- //apply settings
- $_SESSION["reload_xml"] = true;
+ $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/modules.conf.xml","w");
+ fwrite($fout, $xml);
+ unset($xml);
+ fclose($fout);
- }
- } //class
+ //apply settings
+ $_SESSION["reload_xml"] = true;
+ }
+
+}
- //add the database structure
/*
require_once "resources/classes/modules.php";
$mod = new modules;
$mod->dir = $_SESSION['switch']['mod']['dir'];
echo $mod->dir."\n";
-//database connection object
- $mod->db = $db;
//get modules from the database
$mod->get_modules();
//module exists
diff --git a/app/registrations/resources/classes/registrations.php b/app/registrations/resources/classes/registrations.php
index 7a123530ef..84bac197cc 100644
--- a/app/registrations/resources/classes/registrations.php
+++ b/app/registrations/resources/classes/registrations.php
@@ -8,19 +8,11 @@
if (!class_exists('registrations')) {
class registrations {
- 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;
- }
+
}
/**
@@ -47,105 +39,105 @@ if (!class_exists('registrations')) {
//get the default settings
$sql = "select sip_profile_name from v_sip_profiles ";
$sql .= "where sip_profile_enabled = 'true' ";
- if ($profile == 'all' || $profile == '') {
- $prep_statement = $this->db->prepare($sql);
+ if ($profile != 'all' && $profile != '') {
+ $sql .= "and sip_profile_name = :sip_profile_name ";
+ $parameters['sip_profile_name'] = $profile;
}
- else {
- $sql .= "and sip_profile_name=:sip_profile_name ";
- $prep_statement = $this->db->prepare($sql);
- $prep_statement->bindParam(':sip_profile_name', $profile);
- }
- $prep_statement->execute();
- $sip_profiles = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($sip_profiles as $field) {
+ $database = new database;
+ $sip_profiles = $database->select($sql, $parameters, 'all');
+ if (is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
+ foreach ($sip_profiles as $field) {
- //get sofia status profile information including registrations
- $cmd = "api sofia xmlstatus profile ".$field['sip_profile_name']." reg";
- $xml_response = trim(event_socket_request($fp, $cmd));
- if ($xml_response == "Invalid Profile!") { $xml_response = "".$text['label-message'].""; }
- $xml_response = str_replace("", "", $xml_response);
- $xml_response = str_replace("", "", $xml_response);
- if (strlen($xml_response) > 101) {
- try {
- $xml = new SimpleXMLElement($xml_response);
+ //get sofia status profile information including registrations
+ $cmd = "api sofia xmlstatus profile ".$field['sip_profile_name']." reg";
+ $xml_response = trim(event_socket_request($fp, $cmd));
+ if ($xml_response == "Invalid Profile!") { $xml_response = "".$text['label-message'].""; }
+ $xml_response = str_replace("", "", $xml_response);
+ $xml_response = str_replace("", "", $xml_response);
+ if (strlen($xml_response) > 101) {
+ try {
+ $xml = new SimpleXMLElement($xml_response);
+ }
+ catch(Exception $e) {
+ echo $e->getMessage();
+ exit;
+ }
+ $array = json_decode(json_encode($xml), true);
}
- catch(Exception $e) {
- echo $e->getMessage();
- exit;
+
+ //normalize the array
+ if (is_array($array) && !is_array($array['registrations']['registration'][0])) {
+ $row = $array['registrations']['registration'];
+ unset($array['registrations']['registration']);
+ $array['registrations']['registration'][0] = $row;
}
- $array = json_decode(json_encode($xml) , true);
- }
- //normalize the array
- if (is_array($array) && !is_array($array['registrations']['registration'][0])) {
- $row = $array['registrations']['registration'];
- unset($array['registrations']['registration']);
- $array['registrations']['registration'][0] = $row;
- }
+ //set the registrations array
+ if (is_array($array)) {
+ foreach ($array['registrations']['registration'] as $row) {
- //set the registrations array
- if (is_array($array)) {
- foreach ($array['registrations']['registration'] as $row) {
+ //build the registrations array
+ //$registrations[0] = $row;
+ $user_array = explode('@', $row['user']);
+ $registrations[$id]['user'] = $row['user'] ?: '';
+ $registrations[$id]['call-id'] = $row['call-id'] ?: '';
+ $registrations[$id]['contact'] = $row['contact'] ?: '';
+ $registrations[$id]['sip-auth-user'] = $row['sip-auth-user'] ?: '';
+ $registrations[$id]['agent'] = $row['agent'] ?: '';
+ $registrations[$id]['host'] = $row['host'] ?: '';
+ $registrations[$id]['network-port'] = $row['network-port'] ?: '';
+ $registrations[$id]['sip-auth-realm'] = $row['sip-auth-realm'] ?: '';
+ $registrations[$id]['mwi-account'] = $row['mwi-account'] ?: '';
+ $registrations[$id]['status'] = $row['status'] ?: '';
+ $registrations[$id]['ping-time'] = $row['ping-time'] ?: '';
+ $registrations[$id]['sip_profile_name'] = $field['sip_profile_name'];
- //build the registrations array
- //$registrations[0] = $row;
- $user_array = explode('@', $row['user']);
- $registrations[$id]['user'] = $row['user'] ?: '';
- $registrations[$id]['call-id'] = $row['call-id'] ?: '';
- $registrations[$id]['contact'] = $row['contact'] ?: '';
- $registrations[$id]['sip-auth-user'] = $row['sip-auth-user'] ?: '';
- $registrations[$id]['agent'] = $row['agent'] ?: '';
- $registrations[$id]['host'] = $row['host'] ?: '';
- $registrations[$id]['network-port'] = $row['network-port'] ?: '';
- $registrations[$id]['sip-auth-realm'] = $row['sip-auth-realm'] ?: '';
- $registrations[$id]['mwi-account'] = $row['mwi-account'] ?: '';
- $registrations[$id]['status'] = $row['status'] ?: '';
- $registrations[$id]['ping-time'] = $row['ping-time'] ?: '';
- $registrations[$id]['sip_profile_name'] = $field['sip_profile_name'];
-
- //get network-ip to url or blank
- if(isset($row['network-ip'])) {
- $registrations[$id]['network-ip'] = $row['network-ip'];
- } else {
- $registrations[$id]['network-ip'] = '';
- }
-
- //get the LAN IP address if it exists replace the external ip
- $call_id_array = explode('@', $row['call-id']);
- if (isset($call_id_array[1])) {
- $agent = $row['agent'];
- $lan_ip = $call_id_array[1];
- if (false !== stripos($agent, 'grandstream')) {
- $lan_ip = str_ireplace(
- array('A','B','C','D','E','F','G','H','I','J'),
- array('0','1','2','3','4','5','6','7','8','9'),
- $lan_ip);
+ //get network-ip to url or blank
+ if (isset($row['network-ip'])) {
+ $registrations[$id]['network-ip'] = $row['network-ip'];
+ }
+ else {
+ $registrations[$id]['network-ip'] = '';
}
- elseif(1 === preg_match('/\ACL750A/', $agent)) {
- //required for GIGASET Sculpture CL750A puts _ in it's lan ip account
- $lan_ip = preg_replace('/_/', '.', $lan_ip);
- }
- $registrations[$id]['lan-ip'] = $lan_ip;
- } else {
- $registrations[$id]['lan-ip'] = '';
- }
- //remove unrelated domains
- if (count($_SESSION["domains"]) > 1) {
- if (!(permission_exists('registration_all') && $profile == "all")) {
- if ($registrations[$id]['sip-auth-realm'] == $_SESSION['domain_name']) {}
- elseif ($user_array[1] == $_SESSION['domain_name']){}
- else {
- unset($registrations[$id]);
+ //get the LAN IP address if it exists replace the external ip
+ $call_id_array = explode('@', $row['call-id']);
+ if (isset($call_id_array[1])) {
+ $agent = $row['agent'];
+ $lan_ip = $call_id_array[1];
+ if (false !== stripos($agent, 'grandstream')) {
+ $lan_ip = str_ireplace(
+ array('A','B','C','D','E','F','G','H','I','J'),
+ array('0','1','2','3','4','5','6','7','8','9'),
+ $lan_ip);
+ }
+ elseif(1 === preg_match('/\ACL750A/', $agent)) {
+ //required for GIGASET Sculpture CL750A puts _ in it's lan ip account
+ $lan_ip = preg_replace('/_/', '.', $lan_ip);
+ }
+ $registrations[$id]['lan-ip'] = $lan_ip;
+ }
+ else {
+ $registrations[$id]['lan-ip'] = '';
+ }
+
+ //remove unrelated domains
+ if (count($_SESSION["domains"]) > 1) {
+ if (!(permission_exists('registration_all') && $profile == "all")) {
+ if ($registrations[$id]['sip-auth-realm'] == $_SESSION['domain_name']) {}
+ else if ($user_array[1] == $_SESSION['domain_name']) {}
+ else {
+ unset($registrations[$id]);
+ }
}
}
- }
- //increment the array id
- $id++;
+ //increment the array id
+ $id++;
+ }
+ unset($array);
}
- unset($array);
- }
+ }
}
//return the registrations array
@@ -166,17 +158,14 @@ if (!class_exists('registrations')) {
//get the default settings
$sql = "select sip_profile_name from v_sip_profiles ";
$sql .= "where sip_profile_enabled = 'true' ";
- if ($profile == 'all' || $profile == '') {
- $prep_statement = $this->db->prepare($sql);
+ if ($profile != 'all' && $profile != '') {
+ $sql .= "and sip_profile_name = :sip_profile_name ";
+ $parameters['sip_profile_name'] = $profile;
}
- else {
- $sql .= "and sip_profile_name=:sip_profile_name ";
- $prep_statement = $this->db->prepare($sql);
- $prep_statement->bindParam(':sip_profile_name', $profile);
- }
- $prep_statement->execute();
- $sip_profiles = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($sip_profiles as $field) {
+ $database = new database;
+ $sip_profiles = $database->select($sql, $parameters, 'all');
+ if (is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
+ foreach ($sip_profiles as $field) {
//get sofia status profile information including registrations
$cmd = "api sofia xmlstatus profile ".$field['sip_profile_name']." reg";
@@ -193,10 +182,11 @@ if (!class_exists('registrations')) {
echo $e->getMessage();
exit;
}
- $array = json_decode(json_encode($xml) , true);
+ $array = json_decode(json_encode($xml), true);
$count = $count + count($array['registrations']['registration']);
}
+ }
}
//return the registrations count
@@ -205,10 +195,11 @@ if (!class_exists('registrations')) {
}
}
+
/*
$obj = new registrations;
$registrations = $obj->get('all');
print($registrations);
*/
-?>
+?>
\ No newline at end of file
diff --git a/app/scripts/resources/classes/scripts.php b/app/scripts/resources/classes/scripts.php
index 7d84ed560b..62ae17a7dd 100644
--- a/app/scripts/resources/classes/scripts.php
+++ b/app/scripts/resources/classes/scripts.php
@@ -53,8 +53,7 @@ if (!class_exists('scripts')) {
* Called when the object is created
*/
public function __construct() {
- //connect to the database if not connected
- require_once "resources/classes/database.php";
+ //get database properties
$database = new database;
$database->connect();
$this->db = $database->db;
@@ -137,35 +136,16 @@ if (!class_exists('scripts')) {
$this->db_path = str_replace("\\", "/", $this->db_path);
//get the odbc information
- $sql = "select count(*) as num_rows from v_databases ";
+ $sql = "select * from v_databases ";
$sql .= "where database_driver = 'odbc' ";
- $prep_statement = $this->db->prepare($sql);
- if ($prep_statement) {
- $prep_statement->execute();
- $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
- unset($prep_statement);
- if ($row['num_rows'] > 0) {
- $odbc_num_rows = $row['num_rows'];
-
- $sql = "select * from v_databases ";
- $sql .= "where database_driver = 'odbc' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (is_array($result)) {
- foreach ($result as &$row) {
- $this->dsn_name = $row["database_name"];
- $this->dsn_username = $row["database_username"];
- $this->dsn_password = $row["database_password"];
- break; //limit to 1 row
- }
- unset ($prep_statement);
- }
- }
- else {
- $odbc_num_rows = '0';
- }
+ $database = new database;
+ $row = $database->select($sql, null, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
+ $this->dsn_name = $row["database_name"];
+ $this->dsn_username = $row["database_username"];
+ $this->dsn_password = $row["database_password"];
}
+ unset($sql, $row);
//get the recordings directory
if (is_array($_SESSION['switch']['recordings'])) {
@@ -183,7 +163,8 @@ if (!class_exists('scripts')) {
//find the location to write the config.lua
if (is_dir("/etc/fusionpbx")){
$config = "/etc/fusionpbx/config.lua";
- } elseif (is_dir("/usr/local/etc/fusionpbx")){
+ }
+ else if (is_dir("/usr/local/etc/fusionpbx")){
$config = "/usr/local/etc/fusionpbx/config.lua";
}
else {
@@ -346,9 +327,11 @@ if (!class_exists('scripts')) {
unset($tmp);
fclose($fout);
}
- } //end config_lua
- } //end scripts class
+ }
+
+ }
}
+
/*
//example use
@@ -356,4 +339,5 @@ if (!class_exists('scripts')) {
$obj = new scripts;
$obj->write_config();
*/
-?>
+
+?>
\ No newline at end of file
diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php
index d2f0f43c3e..ce0adb456f 100644
--- a/app/voicemails/resources/classes/voicemail.php
+++ b/app/voicemails/resources/classes/voicemail.php
@@ -26,7 +26,6 @@
//define the voicemail class
class voicemail {
- public $db;
public $domain_uuid;
public $domain_name;
public $voicemail_uuid;
@@ -37,14 +36,6 @@
public $app_uuid;
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;
- }
-
//set the application specific uuid
$this->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
@@ -63,60 +54,55 @@
public function get_voicemail_id() {
//check if for valid input
- if (is_uuid($this->voicemail_uuid) && is_uuid($this->domain_uuid) ) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->voicemail_uuid) || !is_uuid($this->domain_uuid)) {
return false;
}
//get the voicemail id if it isn't set already
if (!isset($this->voicemail_id)) {
$sql = "select voicemail_id from v_voicemails ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (is_array($result)) foreach ($result as &$row) {
- $this->voicemail_id = $row["voicemail_id"];
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['voicemail_uuid'] = $this->voicemail_uuid;
+ $database = new database;
+ $voicemail_id = $database->select($sql, $parameters, 'column');
+ if (is_numeric($voicemail_id)) {
+ $this->voicemail_id = $voicemail_id;
}
- unset ($prep_statement);
+ unset($sql, $parameters, $voicemail_id);
}
}
public function voicemails() {
//check if for valid input
- if (is_uuid($this->domain_uuid)) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->domain_uuid)) {
return false;
}
//set the voicemail id and voicemail uuid arrays
- if (isset($_SESSION['user']['extension'])) foreach ($_SESSION['user']['extension'] as $index => $row) {
- if (strlen($row['number_alias']) > 0) {
- $voicemail_ids[$index]['voicemail_id'] = $row['number_alias'];
- }
- else {
- $voicemail_ids[$index]['voicemail_id'] = $row['user'];
+ if (isset($_SESSION['user']['extension'])) {
+ foreach ($_SESSION['user']['extension'] as $index => $row) {
+ $voicemail_ids[$index]['voicemail_id'] = strlen($row['number_alias']) > 0 ? $row['number_alias'] : $row['user'];
}
}
- if (isset($_SESSION['user']['voicemail'])) foreach ($_SESSION['user']['voicemail'] as $row) {
- if (strlen($row['voicemail_uuid']) > 0) {
- $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid'];
+ if (isset($_SESSION['user']['voicemail'])) {
+ foreach ($_SESSION['user']['voicemail'] as $row) {
+ if (strlen($row['voicemail_uuid']) > 0) {
+ $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid'];
+ }
}
}
//get the uuid and voicemail_id
$sql = "select * from v_voicemails ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- if (strlen($this->voicemail_uuid) > 0) {
+ $sql .= "where domain_uuid = :domain_uuid ";
+ if (is_uuid($this->voicemail_uuid)) {
if (permission_exists('voicemail_delete')) {
//view specific voicemail box usually reserved for an admin or superadmin
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $parameters['voicemail_uuid'] = $this->voicemail_uuid;
}
else {
//ensure that the requested voicemail box is assigned to this user
@@ -124,10 +110,10 @@
if (is_array($voicemail_uuids)) {
foreach($voicemail_uuids as $row) {
if ($voicemail_uuid == $row['voicemail_uuid']) {
- $sql .= "and voicemail_uuid = '".$row['voicemail_uuid']."' ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $parameters['voicemail_uuid'] = $row['voicemail_uuid'];
$found = true;
}
- $x++;
}
}
//id requested is not owned by the user return no results
@@ -137,20 +123,18 @@
}
}
else {
- $x = 0;
- if (count($voicemail_ids) > 0) {
+ if (is_array($voicemail_ids) && @sizeof($voicemail_ids) != 0) {
//show only the assigned voicemail ids
- $sql .= "and (";
- if (is_array($voicemail_ids)) foreach($voicemail_ids as $row) {
- if ($x == 0) {
- $sql .= "voicemail_id = '".$row['voicemail_id']."' ";
- }
- else {
- $sql .= " or voicemail_id = '".$row['voicemail_id']."'";
- }
+ $x = 0;
+ $sql .= "and ( ";
+ foreach($voicemail_ids as $row) {
+ $sql_where_or[] = "voicemail_id = :voicemail_id_".$x;
+ $parameters['voicemail_id_'.$x] = $row['voicemail_id'];
$x++;
}
- $sql .= ")";
+ $sql .= implode(' or ', $sql_where_or);
+ $sql .= ") ";
+ unset($sql_where_or);
}
else {
//no assigned voicemail ids so return no results
@@ -158,10 +142,10 @@
}
}
$sql .= "order by voicemail_id asc ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- unset ($prep_statement);
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $database = new database;
+ $result = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
return $result;
}
@@ -170,13 +154,15 @@
$voicemails = $this->voicemails();
//add the voicemail messages to the array
- if (is_array($voicemails)) foreach ($voicemails as &$row) {
- //get the voicemail messages
- $this->voicemail_uuid = $row['voicemail_uuid'];
- $this->voicemail_id = $row['voicemail_id'];
- $result = $this->voicemail_messages();
- $voicemail_count = count($result);
- $row['messages'] = $result;
+ if (is_array($voicemails)) {
+ foreach ($voicemails as &$row) {
+ //get the voicemail messages
+ $this->voicemail_uuid = $row['voicemail_uuid'];
+ $this->voicemail_id = $row['voicemail_id'];
+ $result = $this->voicemail_messages();
+ $voicemail_count = count($result);
+ $row['messages'] = $result;
+ }
}
//return the array
@@ -186,43 +172,40 @@
public function voicemail_messages() {
//check if for valid input
- if (is_numeric($this->voicemail_id) && is_uuid($this->domain_uuid)) {
- //input is valid
- }
- else {
+ if (!is_numeric($this->voicemail_id) || !is_uuid($this->domain_uuid)) {
return false;
}
//get the message from the database
$sql = "select * from v_voicemail_messages as m, v_voicemails as v ";
- $sql .= "where m.domain_uuid = '$this->domain_uuid' ";
+ $sql .= "where m.domain_uuid = :domain_uuid ";
$sql .= "and m.voicemail_uuid = v.voicemail_uuid ";
- if (is_array($this->voicemail_id)) {
- $sql .= "and (";
+ if (is_array($this->voicemail_id) && @sizeof($this->voicemail_id) != 0) {
$x = 0;
- if (is_array($this->voicemail_id)) foreach($this->voicemail_id as $row) {
- if ($x > 0) {
- $sql .= "or ";
- }
- $sql .= "v.voicemail_id = '".$row['voicemail_id']."' ";
+ $sql .= "and ( ";
+ foreach ($this->voicemail_id as $row) {
+ $sql_where_or[] = "v.voicemail_id = :voicemail_id_".$x;
+ $parameters['voicemail_id_'.$x] = $row['voicemail_id'];
$x++;
}
+ $sql .= implode(' or ', $sql_where_or);
$sql .= ") ";
+ unset($sql_where_or);
}
else {
- $sql .= "and v.voicemail_id = '$this->voicemail_id' ";
+ $sql .= "and v.voicemail_id = :voicemail_id ";
+ $parameters['voicemail_id'] = $this->voicemail_id;
}
if (strlen($this->order_by) == 0) {
$sql .= "order by v.voicemail_id, m.created_epoch desc ";
}
else {
- $sql .= "order by v.voicemail_id, m.$this->order_by $this->order ";
+ $sql .= "order by v.voicemail_id, m.".$this->order_by." ".$this->order." ";
}
- //$sql .= "limit $this->rows_per_page offset $this->offset ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset ($prep_statement, $sql);
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $database = new database;
+ $result = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
//update the array with additional information
if (is_array($result)) {
@@ -259,11 +242,7 @@
$this->get_voicemail_id();
//check if for valid input
- if (is_uuid($this->voicemail_uuid)
- && is_uuid($this->domain_uuid)) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->voicemail_uuid) || !is_uuid($this->domain_uuid)) {
return false;
}
@@ -279,69 +258,67 @@
@rmdir($file_path);
}
- //delete voicemail destinations
- $sql = "delete from v_voicemail_destinations ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
+ //build voicemail destinations delete array
+ $array['voicemail_destinations'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['voicemail_destinations'][0]['voicemail_uuid'] = $this->voicemail_uuid;
- //delete voicemail greetings
+ //build voicemail greetings delete array
if (is_numeric($this->voicemail_id)) {
- $sql = "delete from v_voicemail_greetings ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_id = '".$this->voicemail_id."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
+ $array['voicemail_greetings'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['voicemail_greetings'][0]['voicemail_id'] = $this->voicemail_id;
}
- //delete voicemail options
- $sql = "delete from v_voicemail_options ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
+ //build voicemail options delete array
+ $array['voicemail_options'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['voicemail_options'][0]['voicemail_uuid'] = $this->voicemail_uuid;
+
+ //build voicemail delete array
+ $array['voicemails'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['voicemails'][0]['voicemail_uuid'] = $this->voicemail_uuid;
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_destination_delete', 'temp');
+ if (is_numeric($this->voicemail_id)) {
+ $p->add('voicemail_greeting_delete', 'temp');
+ }
+ $p->add('voicemail_option_delete', 'temp');
+ $p->add('voicemail_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('voicemail_destination_delete', 'temp');
+ if (is_numeric($this->voicemail_id)) {
+ $p->delete('voicemail_greeting_delete', 'temp');
+ }
+ $p->delete('voicemail_option_delete', 'temp');
+ $p->delete('voicemail_delete', 'temp');
- //delete voicemail
- $sql = "delete from v_voicemails ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
}
public function message_count() {
//check if for valid input
- if (is_uuid($this->voicemail_uuid) && is_uuid($this->domain_uuid)) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->voicemail_uuid) || !is_uuid($this->domain_uuid)) {
return false;
}
- //get the message count
- $sql = "select count(*) as num_rows from v_voicemail_messages ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $prep_statement = $this->db->prepare($sql);
- if ($prep_statement) {
- $prep_statement->execute();
- $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
- if ($row['num_rows'] > 0) {
- $num_rows = $row['num_rows'];
- }
- else {
- $num_rows = '0';
- }
- }
-
//return the message count
- return $num_rows;
+ $sql = "select count(*) from v_voicemail_messages ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['voicemail_uuid'] = $this->voicemail_uuid;
+ $database = new database;
+ return $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
+
}
public function message_waiting() {
@@ -362,19 +339,17 @@
$this->get_voicemail_id();
//check if for valid input
- if (is_numeric($this->voicemail_id)
- && is_uuid($this->voicemail_uuid)
- && is_uuid($this->domain_uuid)
- && is_uuid($this->voicemail_message_uuid)) {
- //input is valid
- }
- else {
+ if (!is_numeric($this->voicemail_id)
+ || !is_uuid($this->voicemail_uuid)
+ || !is_uuid($this->domain_uuid)
+ || !is_uuid($this->voicemail_message_uuid)
+ ) {
return false;
}
//delete the recording
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
- if ($this->voicemail_message_uuid != '') {
+ if (is_uuid($this->voicemail_message_uuid)) {
foreach (glob($file_path."/intro_".$this->voicemail_message_uuid.".*") as $file_name) {
unlink($file_name);
}
@@ -388,16 +363,26 @@
}
}
- //delete voicemail message(s)
- $sql = "delete from v_voicemail_messages ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- if ($this->voicemail_message_uuid != '') {
- $sql .= "and voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
+ //build delete array
+ $array['voicemail_messages'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['voicemail_messages'][0]['voicemail_uuid'] = $this->voicemail_uuid;
+ if (is_uuid($this->voicemail_message_uuid)) {
+ $array['voicemail_messages'][0]['voicemail_message_uuid'] = $this->voicemail_message_uuid;
}
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql);
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_message_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('voicemail_message_delete', 'temp');
//check the message waiting status
$this->message_waiting();
@@ -406,35 +391,38 @@
public function message_toggle() {
//check if for valid input
- if (is_uuid($this->voicemail_uuid)
- && is_uuid($this->domain_uuid)
- && is_uuid($this->voicemail_message_uuid)) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->voicemail_uuid)
+ || !is_uuid($this->domain_uuid)
+ || !is_uuid($this->voicemail_message_uuid)
+ ) {
return false;
}
//get message status
$sql = "select message_status from v_voicemail_messages ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $sql .= "and voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $row = $prep_statement->fetch(PDO::FETCH_NAMED);
- $new_status = ($row['message_status'] == 'saved') ? 'null' : "'saved'";
- unset($sql, $prep_statement, $row);
+ $sql .= "where voicemail_message_uuid = :voicemail_message_uuid ";
+ $parameters['voicemail_message_uuid'] = $this->voicemail_message_uuid;
+ $database = new database;
+ $new_status = $database->select($sql, $parameters, 'column') != 'saved' ? 'saved' : null;
+ unset($sql, $parameters);
- //set message status
- $sql = "update v_voicemail_messages set ";
- $sql .= "message_status = ".$new_status." ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $sql .= "and voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
+ //build message status update array
+ $array['voicemail_messages'][0]['voicemail_message_uuid'] = $this->voicemail_message_uuid;
+ $array['voicemail_messages'][0]['message_status'] = $new_status;
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_message_edit', 'temp');
+
+ //execute update
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->save($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('voicemail_message_edit', 'temp');
//check the message waiting status
$this->message_waiting();
@@ -443,24 +431,30 @@
public function message_saved() {
//check if for valid input
- if (is_uuid($this->voicemail_uuid)
- && is_uuid($this->domain_uuid)
- && is_uuid($this->voicemail_message_uuid)) {
- //input is valid
- }
- else {
+ if (!is_uuid($this->voicemail_uuid)
+ || !is_uuid($this->domain_uuid)
+ || !is_uuid($this->voicemail_message_uuid)
+ ) {
return false;
}
- //set the voicemail status to saved
- $sql = "update v_voicemail_messages set ";
- $sql .= "message_status = 'saved' ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
- $sql .= "and voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql, $prep_statement);
+ //build message status update array
+ $array['voicemail_messages'][0]['voicemail_message_uuid'] = $this->voicemail_message_uuid;
+ $array['voicemail_messages'][0]['message_status'] = 'saved';
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_message_edit', 'temp');
+
+ //execute update
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->save($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('voicemail_message_edit', 'temp');
//check the message waiting status
$this->message_waiting();
@@ -469,13 +463,11 @@
public function message_download() {
//check if for valid input
- if (is_numeric($this->voicemail_id)
- && is_uuid($this->voicemail_uuid)
- && is_uuid($this->domain_uuid)
- && is_uuid($this->voicemail_message_uuid)) {
- //input is valid
- }
- else {
+ if (!is_numeric($this->voicemail_id)
+ || !is_uuid($this->voicemail_uuid)
+ || !is_uuid($this->domain_uuid)
+ || !is_uuid($this->voicemail_message_uuid)
+ ) {
return false;
}
@@ -490,42 +482,41 @@
//prepare base64 content from db, if enabled
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
- $sql = "select message_base64 from ";
+ $sql = "select message_base64 ";
+ $sql .= "from ";
$sql .= "v_voicemail_messages as m, ";
$sql .= "v_voicemails as v ";
$sql .= "where ";
$sql .= "m.voicemail_uuid = v.voicemail_uuid ";
- $sql .= "and v.voicemail_id = '".$this->voicemail_id."' ";
- $sql .= "and m.voicemail_uuid = '".$this->voicemail_uuid."' ";
- $sql .= "and m.domain_uuid = '".$this->domain_uuid."' ";
- $sql .= "and m.voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
- $prep_statement = $this->db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- if (is_array($result)) {
- foreach($result as &$row) {
- if ($row['message_base64'] != '') {
- $message_decoded = base64_decode($row['message_base64']);
- file_put_contents($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $message_decoded);
- $finfo = finfo_open(FILEINFO_MIME_TYPE); //determine mime type (requires PHP >= 5.3.0, must be manually enabled on Windows)
- $file_mime = finfo_file($finfo, $path.'/msg_'.$this->voicemail_message_uuid.'.ext');
- finfo_close($finfo);
- switch ($file_mime) {
- case 'audio/x-wav':
- case 'audio/wav':
- $file_ext = 'wav';
- break;
- case 'audio/mpeg':
- case 'audio/mp3':
- $file_ext = 'mp3';
- break;
- }
- rename($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $path.'/msg_'.$this->voicemail_message_uuid.'.'.$file_ext);
- }
- break;
+ $sql .= "and v.voicemail_id = :voicemail_id ";
+ $sql .= "and m.voicemail_uuid = :voicemail_uuid ";
+ $sql .= "and m.domain_uuid = :domain_uuid ";
+ $sql .= "and m.voicemail_message_uuid = :voicemail_message_uuid ";
+ $parameters['voicemail_id'] = $this->voicemail_id;
+ $parameters['voicemail_uuid'] = $this->voicemail_uuid;
+ $parameters['domain_uuid'] = $this->domain_uuid;
+ $parameters['voicemail_message_uuid'] = $this->voicemail_message_uuid;
+ $database = new database;
+ $message_base64 = $database->select($sql, $parameters, 'column');
+ if ($message_base64 != '') {
+ $message_decoded = base64_decode($message_base64);
+ file_put_contents($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $message_decoded);
+ $finfo = finfo_open(FILEINFO_MIME_TYPE); //determine mime type (requires PHP >= 5.3.0, must be manually enabled on Windows)
+ $file_mime = finfo_file($finfo, $path.'/msg_'.$this->voicemail_message_uuid.'.ext');
+ finfo_close($finfo);
+ switch ($file_mime) {
+ case 'audio/x-wav':
+ case 'audio/wav':
+ $file_ext = 'wav';
+ break;
+ case 'audio/mpeg':
+ case 'audio/mp3':
+ $file_ext = 'mp3';
+ break;
}
+ rename($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $path.'/msg_'.$this->voicemail_message_uuid.'.'.$file_ext);
}
- unset ($sql, $prep_statement, $result, $message_decoded);
+ unset($sql, $parameters, $message_base64, $message_decoded);
}
//prepare and stream the file
@@ -571,7 +562,8 @@
@unlink($path.'/msg_'.$this->voicemail_message_uuid.'.'.$file_ext);
}
- } // download
+ }
+
}
//example voicemail messages
@@ -607,4 +599,4 @@ foreach ($_SESSION['user']['extension'] as $value) {
}
*/
-?>
+?>
\ No newline at end of file
diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php
index 00700b9dfc..c0925434b2 100644
--- a/app/voicemails/voicemail_messages.php
+++ b/app/voicemails/voicemail_messages.php
@@ -59,7 +59,6 @@
$voicemail_uuid = $_REQUEST["voicemail_uuid"];
if (is_uuid($voicemail_message_uuid) && $voicemail_id != '' && is_uuid($voicemail_uuid)) {
$voicemail = new voicemail;
- $voicemail->db = $db;
$voicemail->domain_uuid = $_SESSION['domain_uuid'];
$voicemail->voicemail_id = $voicemail_id;
$voicemail->voicemail_uuid = $voicemail_uuid;
@@ -76,7 +75,6 @@
//get the voicemail
$vm = new voicemail;
- $vm->db = $db;
$vm->domain_uuid = $_SESSION['domain_uuid'];
$vm->voicemail_uuid = $voicemail_uuid;
$vm->order_by = $order_by;
diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php
index fc28dd096f..7a8a110450 100644
--- a/core/authentication/resources/classes/plugins/database.php
+++ b/core/authentication/resources/classes/plugins/database.php
@@ -26,85 +26,62 @@ class plugin_database {
*/
function database() {
- //save the database connection to a local variable
- include "root.php";
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $db = $database->db;
+ //set the default status
+ $user_authorized = false;
//check the username and password if they don't match then redirect to the login
- $sql = "select * from v_users ";
+ $sql = "select * from v_users where ";
if (strlen($this->key) > 30) {
- $sql .= "where api_key = :key ";
- //$sql .= "where api_key = '".$this->key."' ";
+ $sql .= "api_key = :key ";
+ $parameters['api_key'] = $this->key;
}
else {
- $sql .= "where lower(username) = lower(:username) ";
- //$sql .= "where username = '".$this->username."' ";
+ $sql .= "lower(username) = lower(:username) ";
+ $parameters['username'] = $this->username;
}
- if ($_SESSION["users"]["unique"]["text"] == "global") {
- //unique username - global (example: email address)
- }
- else {
- //unique username - per domain
+ if ($_SESSION["users"]["unique"]["text"] != "global") {
+ //unique username per domain (not globally unique across system - example: email address)
$sql .= "and domain_uuid = :domain_uuid ";
- //$sql .= "and domain_uuid = '".$this->domain_uuid."' ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
}
$sql .= "and (user_enabled = 'true' or user_enabled is null) ";
- $prep_statement = $db->prepare($sql);
- if ($_SESSION["users"]["unique"]["text"] != "global") {
- $prep_statement->bindParam(':domain_uuid', $this->domain_uuid);
- }
- if (strlen($this->key) > 30) {
- $prep_statement->bindParam(':key', $this->key);
- }
- if (strlen($this->username) > 0) {
- $prep_statement->bindParam(':username', $this->username);
- }
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- $user_authorized = false;
- if (is_array($result)) {
- foreach ($result as &$row) {
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
- //get the domain uuid when users are unique globally
- if ($_SESSION["users"]["unique"]["text"] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
- //set the domain_uuid
- $this->domain_uuid = $row["domain_uuid"];
- $this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
+ //get the domain uuid when users are unique globally
+ if ($_SESSION["users"]["unique"]["text"] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
+ //set the domain_uuid
+ $this->domain_uuid = $row["domain_uuid"];
+ $this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
- //set the domain session variables
- $_SESSION["domain_uuid"] = $this->domain_uuid;
- $_SESSION["domain_name"] = $this->domain_name;
+ //set the domain session variables
+ $_SESSION["domain_uuid"] = $this->domain_uuid;
+ $_SESSION["domain_name"] = $this->domain_name;
- //set the setting arrays
- $domain = new domains();
- $domain->db = $db;
- $domain->set();
- }
+ //set the setting arrays
+ $domain = new domains();
+ $domain->db = $db;
+ $domain->set();
+ }
- //set the user_uuid
- $this->user_uuid = $row['user_uuid'];
- $this->contact_uuid = $row['contact_uuid'];
+ //set the user_uuid
+ $this->user_uuid = $row['user_uuid'];
+ $this->contact_uuid = $row['contact_uuid'];
- //if salt is not defined then use the default salt for backwards compatibility
- if (strlen($row["salt"]) == 0) {
- $row["salt"] = 'e3.7d.12';
- }
+ //if salt is not defined then use the default salt for backwards compatibility
+ if (strlen($row["salt"]) == 0) {
+ $row["salt"] = 'e3.7d.12';
+ }
- //compare the password provided by the user with the one in the database
- if (md5($row["salt"].$this->password) == $row["password"]) {
- $user_authorized = true;
- } elseif (strlen($this->key) > 30 && $this->key == $row["api_key"]) {
- $user_authorized = true;
- } else {
- $user_authorized = false;
- }
+ //compare the password provided by the user with the one in the database
+ if (md5($row["salt"].$this->password) == $row["password"]) {
+ $user_authorized = true;
+ }
+ else if (strlen($this->key) > 30 && $this->key == $row["api_key"]) {
+ $user_authorized = true;
+ }
- //end the loop
- break;
- }
}
unset($result);
@@ -119,14 +96,10 @@ class plugin_database {
$result["domain_uuid"] = $this->domain_uuid;
$result["contact_uuid"] = $this->contact_uuid;
$result["sql"] = $sql;
- if ($user_authorized) {
- $result["authorized"] = "true";
- }
- else {
- $result["authorized"] = "false";
- }
+ $result["authorized"] = $user_authorized ? 'true' : 'false';
+
return $result;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/core/authentication/resources/classes/plugins/ldap.php b/core/authentication/resources/classes/plugins/ldap.php
index 54e4ffdcb0..569233e127 100644
--- a/core/authentication/resources/classes/plugins/ldap.php
+++ b/core/authentication/resources/classes/plugins/ldap.php
@@ -23,13 +23,6 @@ class plugin_ldap {
*/
function ldap() {
- //save the database connection to a local variable
- include "root.php";
- require_once "resources/classes/database.php";
- $database = new database;
- $database->connect();
- $db = $database->db;
-
//use ldap to validate the user credentials
if (isset($_SESSION["ldap"]["certpath"])) {
$s = "LDAPTLS_CERT=" . $_SESSION["ldap"]["certpath"]["text"];
@@ -41,13 +34,13 @@ class plugin_ldap {
}
$host = $_SESSION["ldap"]["server_host"]["text"];
$port = $_SESSION["ldap"]["server_port"]["numeric"];
- $connect = ldap_connect($host,$port)
+ $connect = ldap_connect($host, $port)
or die("Could not connect to the LDAP server.");
//ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10);
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
//ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
- //set the default for $user_authorized to false
+ //set the default status
$user_authorized = false;
//provide backwards compatability
@@ -69,54 +62,37 @@ class plugin_ldap {
$user_authorized = true;
break;
}
- else {
- //connection failed
- $user_authorized = false;
- }
- }
- else {
- //password not provided
- $user_authorized = false;
}
}
//check to see if the user exists
if ($user_authorized) {
$sql = "select * from v_users ";
- $sql .= "where username=:username ";
- if ($_SESSION["users"]["unique"]["text"] == "global") {
- //unique username - global (example: email address)
- }
- else {
- //unique username - per domain
- $sql .= "and domain_uuid=:domain_uuid ";
- }
- $prep_statement = $db->prepare($sql);
+ $sql .= "where username = :username ";
if ($_SESSION["users"]["unique"]["text"] != "global") {
- $prep_statement->bindParam(':domain_uuid', $this->domain_uuid);
+ //unique username per domain (not globally unique across system - example: email address)
+ $sql .= "and domain_uuid = :domain_uuid ";
+ $parameters['domain_uuid'] = $this->domain_uuid;
}
- $prep_statement->bindParam(':username', $this->username);
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) > 0) {
- foreach ($result as &$row) {
- if ($_SESSION["users"]["unique"]["text"] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
- //get the domain uuid
- $this->domain_uuid = $row["domain_uuid"];
- $this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
+ $parameters['username'] = $this->username;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
+ if ($_SESSION["users"]["unique"]["text"] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
+ //get the domain uuid
+ $this->domain_uuid = $row["domain_uuid"];
+ $this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
- //set the domain session variables
- $_SESSION["domain_uuid"] = $this->domain_uuid;
- $_SESSION["domain_name"] = $this->domain_name;
+ //set the domain session variables
+ $_SESSION["domain_uuid"] = $this->domain_uuid;
+ $_SESSION["domain_name"] = $this->domain_name;
- //set the setting arrays
- $domain = new domains();
- $domain->db = $db;
- $domain->set();
- }
- $this->user_uuid = $row["user_uuid"];
- $this->contact_uuid = $row["contact_uuid"];
+ //set the setting arrays
+ $domain = new domains();
+ $domain->set();
}
+ $this->user_uuid = $row["user_uuid"];
+ $this->contact_uuid = $row["contact_uuid"];
}
else {
//salt used with the password to create a one way hash
@@ -127,53 +103,40 @@ class plugin_ldap {
$this->user_uuid = uuid();
$this->contact_uuid = uuid();
- //add the user
- $sql = "insert into v_users ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "user_uuid, ";
- $sql .= "contact_uuid, ";
- $sql .= "username, ";
- $sql .= "password, ";
- $sql .= "salt, ";
- $sql .= "add_date, ";
- $sql .= "add_user, ";
- $sql .= "user_enabled ";
- $sql .= ") ";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$this->domain_uuid."', ";
- $sql .= "'".$this->user_uuid."', ";
- $sql .= "'".$this->contact_uuid."', ";
- $sql .= "'".strtolower($this->username)."', ";
- $sql .= "'".md5($salt.$password)."', ";
- $sql .= "'".$salt."', ";
- $sql .= "now(), ";
- $sql .= "'".strtolower($this->username)."', ";
- $sql .= "'true' ";
- $sql .= ")";
- $db->exec(check_sql($sql));
- unset($sql);
+ //build user insert array
+ $array['users'][0]['user_uuid'] = $this->user_uuid;
+ $array['users'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['users'][0]['contact_uuid'] = $this->contact_uuid;
+ $array['users'][0]['username'] = strtolower($this->username);
+ $array['users'][0]['password'] = md5($salt.$password);
+ $array['users'][0]['salt'] = $salt;
+ $array['users'][0]['add_date'] = now();
+ $array['users'][0]['add_user'] = strtolower($this->username);
+ $array['users'][0]['user_enabled'] = 'true';
- //add the user to group user
- $group_name = 'user';
- $sql = "insert into v_user_groups ";
- $sql .= "(";
- $sql .= "user_group_uuid, ";
- $sql .= "domain_uuid, ";
- $sql .= "group_name, ";
- $sql .= "user_uuid ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".uuid()."', ";
- $sql .= "'".$this->domain_uuid."', ";
- $sql .= "'".$group_name."', ";
- $sql .= "'".$this->user_uuid."' ";
- $sql .= ")";
- $db->exec(check_sql($sql));
- unset($sql);
+ //build user group insert array
+ $array['user_groups'][0]['user_group_uuid'] = uuid();
+ $array['user_groups'][0]['domain_uuid'] = $this->domain_uuid;
+ $array['user_groups'][0]['group_name'] = 'user';
+ $array['user_groups'][0]['user_uuid'] = $this->user_uuid;
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('user_add', 'temp');
+ $p->add('user_group_add', 'temp');
+
+ //execute insert
+ $database = new database;
+ $database->app_name = 'authentication';
+ $database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
+ $database->save($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('user_add', 'temp');
+ $p->delete('user_group_add', 'temp');
}
+ unset($sql, $parameters, $row);
}
//result array
@@ -185,14 +148,9 @@ class plugin_ldap {
}
$result["user_uuid"] = $this->user_uuid;
$result["domain_uuid"] = $this->domain_uuid;
- if ($user_authorized) {
- $result["authorized"] = "true";
- }
- else {
- $result["authorized"] = "false";
- }
+ $result["authorized"] = $user_authorized ? 'true' : 'false';
return $result;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/core/groups/resources/classes/permission.php b/core/groups/resources/classes/permission.php
index eee18da465..57451fc623 100644
--- a/core/groups/resources/classes/permission.php
+++ b/core/groups/resources/classes/permission.php
@@ -29,105 +29,113 @@
//delete the permissions
function delete() {
- //set the variables
- $db = $this->db;
//get unprotected groups and their domain uuids (if any)
- $sql = "select group_name, domain_uuid from v_groups where group_protected <> 'true' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- $result_count = count($result);
- if ($result_count > 0) {
+ $sql = "select group_name, domain_uuid ";
+ $sql .= "from v_groups ";
+ $sql .= "where group_protected <> 'true' ";
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
foreach($result as $row) {
$unprotected_groups[$row['group_name']] = $row['domain_uuid'];
}
}
- unset ($prep_statement, $sql, $result, $result_count);
+ unset($sql, $result, $row);
//delete unprotected group permissions
if (is_array($unprotected_groups) && sizeof($unprotected_groups) > 0) {
+ $x = 0;
foreach ($unprotected_groups as $unprotected_group_name => $unprotected_domain_uuid) {
- $sql = "delete from v_group_permissions where ";
- $sql .= "group_name = '".$unprotected_group_name."' ";
- $sql .= "and domain_uuid ".(($unprotected_domain_uuid != '') ? " = '".$unprotected_domain_uuid."' " : " is null ");
- if (false === $db->exec($sql)) {
- //echo $db->errorCode() . "
";
- $info = $db->errorInfo();
- print_r($info);
- // $info[0] == $db->errorCode() unified error code
- // $info[1] is the driver specific error code
- // $info[2] is the driver specific error string
- }
+ //build delete array
+ $array['group_permissions'][$x]['group_name'] = $unprotected_group_name;
+ $array['group_permissions'][$x]['domain_uuid'] = $unprotected_domain_uuid != '' ? $unprotected_domain_uuid : null;
+ $x++;
+ }
+ if (is_array($array) && @sizeof($array) != 0) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('group_permission_delete', 'temp');
+ //execute delete
+ $database = new database;
+ $database->app_name = 'groups';
+ $database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
+ $database->delete($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('group_permission_delete', 'temp');
}
}
}
//restore the permissions
function restore() {
- //set the variables
- $db = $this->db;
-
//delete the group permisisons
$this->delete();
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
- $x=0;
+ $x = 0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
//restore default permissions
- foreach($apps as $row) {
+ $x = 0;
+ foreach ($apps as $row) {
foreach ($row['permissions'] as $permission) {
//set the variables
if ($permission['groups']) {
foreach ($permission['groups'] as $group) {
//check group protection
- $sql = "select * from v_groups ";
- $sql .= "where group_name = '".$group."' ";
+ $sql = "select count(*) from v_groups ";
+ $sql .= "where group_name = :group_name ";
$sql .= "and group_protected = 'true'";
- $prep_statement = $db->prepare(check_sql($sql));
- if ($prep_statement) {
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset ($prep_statement);
- if (count($result) == 0) {
- //if the item uuid is not currently in the db then add it
- $sql = "select * from v_group_permissions ";
- $sql .= "where permission_name = '".$permission['name']."' ";
- $sql .= "and group_name = '$group' ";
- $prep_statement = $db->prepare(check_sql($sql));
- if ($prep_statement) {
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- unset ($prep_statement);
- if (count($result) == 0) {
- //insert the default permissions into the database
- $sql = "insert into v_group_permissions ";
- $sql .= "(";
- $sql .= "group_permission_uuid, ";
- $sql .= "permission_name, ";
- $sql .= "group_name ";
- $sql .= ") ";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".uuid()."', ";
- $sql .= "'".$permission['name']."', ";
- $sql .= "'".$group."' ";
- $sql .= ");";
- $db->exec(check_sql($sql));
- unset($sql);
- } // if count
- } // if prepared statement
- } // if count
- } // if prepared statement
- } // foreach group permission
- } // if permission
- } // foreach permission
- } // foreach app
+ $parameters['group_name'] = $group;
+ $database = new database;
+ $num_rows = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
- } // function
- } // class
+ if ($num_rows == 0) {
+ //if the item uuid is not currently in the db then add it
+ $sql = "select count(*) from v_group_permissions ";
+ $sql .= "where permission_name = :permission_name ";
+ $sql .= "and group_name = :group_name ";
+ $parameters['permission_name'] = $permission['name'];
+ $parameters['group_name'] = $group;
+ $database = new database;
+ $num_rows = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
+
+ if ($num_rows == 0) {
+ //build default permissions insert array
+ $array['group_permissions'][$x]['group_permission_uuid'] = uuid();
+ $array['group_permissions'][$x]['permission_name'] = $permission['name'];
+ $array['group_permissions'][$x]['group_name'] = $group;
+ $x++;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (is_array($array) && @sizeof($array)) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('group_permission_add', 'temp');
+
+ //execute insert
+ $database = new database;
+ $database->app_name = 'groups';
+ $database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
+ $database->save($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('group_permission_add', 'temp');
+ }
+
+ }
+
+ }
?>
\ No newline at end of file
diff --git a/resources/classes/captcha.php b/resources/classes/captcha.php
index 28462857c0..55b5f33ad6 100644
--- a/resources/classes/captcha.php
+++ b/resources/classes/captcha.php
@@ -34,8 +34,6 @@ class captcha {
/**
* Called when the object is created
*/
- //public $db;
- //public $domain_uuid;
public $code;
/**