mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Move the class files from includes to the resources directory.
This commit is contained in:
46
resources/classes/array_order.php
Normal file
46
resources/classes/array_order.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class array_order {
|
||||
|
||||
var $sort_fields;
|
||||
var $backwards = false;
|
||||
var $numeric = false;
|
||||
|
||||
function sort() {
|
||||
$args = func_get_args();
|
||||
$array = $args[0];
|
||||
if (!$array) return array();
|
||||
$this->sort_fields = array_slice($args, 1);
|
||||
if (!$this->sort_fields) return $array();
|
||||
|
||||
if ($this->numeric) {
|
||||
usort($array, array($this, 'numericCompare'));
|
||||
} else {
|
||||
usort($array, array($this, 'stringCompare'));
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function numericCompare($a, $b) {
|
||||
foreach($this->sort_fields as $sort_field) {
|
||||
if ($a[$sort_field] == $b[$sort_field]) {
|
||||
continue;
|
||||
}
|
||||
return ($a[$sort_field] < $b[$sort_field]) ? ($this->backwards ? 1 : -1) : ($this->backwards ? -1 : 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function stringCompare($a, $b) {
|
||||
foreach($this->sort_fields as $sort_field) {
|
||||
$cmp_result = strcasecmp($a[$sort_field], $b[$sort_field]);
|
||||
if ($cmp_result == 0) continue;
|
||||
return ($this->backwards ? -$cmp_result : $cmp_result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//$order = new array_order();
|
||||
//$registrations = $order->sort($registrations, 'domain', 'user');
|
||||
|
||||
?>
|
||||
561
resources/classes/database.php
Normal file
561
resources/classes/database.php
Normal file
@@ -0,0 +1,561 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the database class
|
||||
if (!class_exists('database')) {
|
||||
class database {
|
||||
public $db;
|
||||
public $driver;
|
||||
public $type;
|
||||
public $host;
|
||||
public $port;
|
||||
public $name; //database name
|
||||
public $username;
|
||||
public $password;
|
||||
public $path;
|
||||
public $table;
|
||||
public $where; //array
|
||||
public $order_by; //array
|
||||
public $order_type;
|
||||
public $limit;
|
||||
public $offset;
|
||||
public $fields;
|
||||
public $count;
|
||||
public $sql;
|
||||
public $result;
|
||||
|
||||
public function connect() {
|
||||
|
||||
if (strlen($this->type) == 0 && strlen($this->name) == 0) {
|
||||
//include config.php
|
||||
include "root.php";
|
||||
include "includes/config.php";
|
||||
|
||||
//backwards compatibility
|
||||
if (isset($dbtype)) { $db_type = $dbtype; }
|
||||
if (isset($dbhost)) { $db_host = $dbhost; }
|
||||
if (isset($dbport)) { $db_port = $dbport; }
|
||||
if (isset($dbname)) { $db_name = $dbname; }
|
||||
if (isset($dbusername)) { $db_username = $dbusername; }
|
||||
if (isset($dbpassword)) { $db_password = $dbpassword; }
|
||||
if (isset($dbfilepath)) { $db_path = $db_file_path; }
|
||||
if (isset($dbfilename)) { $db_name = $dbfilename; }
|
||||
|
||||
//set defaults
|
||||
if (isset($db_type)) { $this->driver = $db_type; }
|
||||
if (isset($db_type)) { $this->type = $db_type; }
|
||||
if (isset($db_host)) { $this->host = $db_host; }
|
||||
if (isset($db_port)) { $this->port = $db_port; }
|
||||
if (isset($db_name)) { $this->name = $db_name; }
|
||||
if (isset($db_username)) { $this->username = $db_username; }
|
||||
if (isset($db_password)) { $this->password = $db_password; }
|
||||
if (isset($db_path)) { $this->path = $db_path; }
|
||||
}
|
||||
if (strlen($this->driver) == 0) {
|
||||
$this->driver = $this->type;
|
||||
}
|
||||
|
||||
if ($this->driver == "sqlite") {
|
||||
if (strlen($this->name) == 0) {
|
||||
$server_name = $_SERVER["SERVER_NAME"];
|
||||
$server_name = str_replace ("www.", "", $server_name);
|
||||
$db_name_short = $server_name;
|
||||
$this->name = $server_name.'.db';
|
||||
}
|
||||
else {
|
||||
$db_name_short = $this->name;
|
||||
}
|
||||
$this->path = realpath($this->path);
|
||||
if (file_exists($this->path.'/'.$this->name)) {
|
||||
$this->db = new PDO('sqlite:'.$this->path.'/'.$this->name); //sqlite 3
|
||||
}
|
||||
else {
|
||||
echo "not found";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->driver == "mysql") {
|
||||
try {
|
||||
//required for mysql_real_escape_string
|
||||
if (function_exists(mysql_connect)) {
|
||||
$mysql_connection = mysql_connect($this->host, $this->username, $this->password);
|
||||
}
|
||||
//mysql pdo connection
|
||||
if (strlen($this->host) == 0 && strlen($this->port) == 0) {
|
||||
//if both host and port are empty use the unix socket
|
||||
$this->db = new PDO("mysql:host=$this->host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->name", $this->username, $this->password);
|
||||
}
|
||||
else {
|
||||
if (strlen($this->port) == 0) {
|
||||
//leave out port if it is empty
|
||||
$this->db = new PDO("mysql:host=$this->host;dbname=$this->name;", $this->username, $this->password, array(
|
||||
PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
}
|
||||
else {
|
||||
$this->db = new PDO("mysql:host=$this->host;port=$this->port;dbname=$this->name;", $this->username, $this->password, array(
|
||||
PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->driver == "pgsql") {
|
||||
//database connection
|
||||
try {
|
||||
if (strlen($this->host) > 0) {
|
||||
if (strlen($this->port) == 0) { $this->port = "5432"; }
|
||||
$this->db = new PDO("pgsql:host=$this->host port=$this->port dbname=$this->name user=$this->username password=$this->password");
|
||||
}
|
||||
else {
|
||||
$this->db = new PDO("pgsql:dbname=$this->name user=$this->username password=$this->password");
|
||||
}
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->driver == "odbc") {
|
||||
//database connection
|
||||
try {
|
||||
$this->db = new PDO("odbc:".$this->name, $this->username, $this->password);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
echo 'Connection failed: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function tables() {
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
if ($this->type == "sqlite") {
|
||||
$sql = "SELECT name FROM sqlite_master ";
|
||||
$sql .= "WHERE type='table' ";
|
||||
$sql .= "order by name;";
|
||||
}
|
||||
if ($this->type == "pgsql") {
|
||||
$sql = "select table_name as name ";
|
||||
$sql .= "from information_schema.tables ";
|
||||
$sql .= "where table_schema='public' ";
|
||||
$sql .= "and table_type='BASE TABLE' ";
|
||||
$sql .= "order by table_name ";
|
||||
}
|
||||
if ($this->type == "mysql") {
|
||||
$sql = "show tables";
|
||||
}
|
||||
if ($this->type == "mssql") {
|
||||
$sql = "SELECT * FROM sys.Tables order by name asc";
|
||||
}
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$tmp = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if ($this->type == "pgsql" || $this->type == "sqlite" || $this->type == "mssql") {
|
||||
foreach ($tmp as &$row) {
|
||||
$result[]['name'] = $row['name'];
|
||||
}
|
||||
}
|
||||
if ($this->type == "mysql") {
|
||||
foreach ($tmp as &$row) {
|
||||
$table_array = array_values($row);
|
||||
$result[]['name'] = $table_array[0];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function table_info() {
|
||||
//public $db;
|
||||
//public $type;
|
||||
//public $table;
|
||||
//public $name;
|
||||
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//get the table info
|
||||
if (strlen($this->table) == 0) { return false; }
|
||||
if ($this->type == "sqlite") {
|
||||
$sql = "PRAGMA table_info(".$this->table.");";
|
||||
}
|
||||
if ($this->type == "pgsql") {
|
||||
$sql = "SELECT ordinal_position, ";
|
||||
$sql .= "column_name, ";
|
||||
$sql .= "data_type, ";
|
||||
$sql .= "column_default, ";
|
||||
$sql .= "is_nullable, ";
|
||||
$sql .= "character_maximum_length, ";
|
||||
$sql .= "numeric_precision ";
|
||||
$sql .= "FROM information_schema.columns ";
|
||||
$sql .= "WHERE table_name = '".$this->table."' ";
|
||||
$sql .= "and table_catalog = '".$this->name."' ";
|
||||
$sql .= "ORDER BY ordinal_position; ";
|
||||
}
|
||||
if ($this->type == "mysql") {
|
||||
$sql = "DESCRIBE ".$this->table.";";
|
||||
}
|
||||
if ($this->type == "mssql") {
|
||||
$sql = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '".$this->table."'";
|
||||
}
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
//set the result array
|
||||
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function fields() {
|
||||
//public $db;
|
||||
//public $type;
|
||||
//public $table;
|
||||
//public $name;
|
||||
|
||||
//get the table info
|
||||
$table_info = $this->table_info();
|
||||
|
||||
//set the list of fields
|
||||
if ($this->type == "sqlite") {
|
||||
foreach($table_info as $row) {
|
||||
$result[]['name'] = $row['name'];
|
||||
}
|
||||
}
|
||||
if ($this->type == "pgsql") {
|
||||
foreach($table_info as $row) {
|
||||
$result[]['name'] = $row['column_name'];
|
||||
}
|
||||
}
|
||||
if ($this->type == "mysql") {
|
||||
foreach($table_info as $row) {
|
||||
$result[]['name'] = $row['Field'];
|
||||
}
|
||||
}
|
||||
if ($this->type == "mssql") {
|
||||
foreach($table_info as $row) {
|
||||
$result[]['name'] = $row['COLUMN_NAME'];
|
||||
}
|
||||
}
|
||||
|
||||
//return the result array
|
||||
return $result;
|
||||
}
|
||||
|
||||
//public function disconnect() {
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public function find() {
|
||||
//connect;
|
||||
//table;
|
||||
//where;
|
||||
//order_by;
|
||||
//limit;
|
||||
//offset;
|
||||
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//get data from the database
|
||||
$sql = "select * from ".$this->table." ";
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (count($this->order_by) > 0) {
|
||||
$sql .= "order by ";
|
||||
$i = 1;
|
||||
foreach($this->order_by as $row) {
|
||||
if (count($this->order_by) == $i) {
|
||||
$sql .= $row['name']." ".$row['order']." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $row['name']." ".$row['order'].", ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if ($this->limit) {
|
||||
$sql .= " limit ".$this->limit." offset ".$this->offset." ";
|
||||
}
|
||||
//echo $sql;
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function add(){
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//add data to the database
|
||||
$sql = "insert into ".$this->table;
|
||||
$sql .= " (";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
$sql .= $name." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name.", ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
if (strlen($value) > 0) {
|
||||
$sql .= "'".$value."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$value."' ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($value) > 0) {
|
||||
$sql .= "'".$value."', ";
|
||||
}
|
||||
else {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ")";
|
||||
//execute the query, show exceptions
|
||||
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
try {
|
||||
$this->sql = $sql;
|
||||
$this->db->exec($sql);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo "<b>Error:</b><br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td>\n";
|
||||
echo $e->getMessage();
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
unset($this->fields);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function update() {
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//udate the database
|
||||
$sql = "update ".$this->table." set ";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
if (strlen($name) > 0 && $value == null) {
|
||||
$sql .= $name." = null ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name." = '".$value."' ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($name) > 0 && $value == null) {
|
||||
$sql .= $name." = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name." = '".$value."', ";
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->db->exec(check_sql($sql));
|
||||
unset($this->fields);
|
||||
unset($this->where);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//delete from the database
|
||||
$sql = "delete from ".$this->table." ";
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
//echo $sql."<br>\n";
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
unset($this->where);
|
||||
}
|
||||
|
||||
public function count() {
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//get the number of rows
|
||||
$sql = "select count(*) as num_rows from ".$this->table." ";
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
unset($this->where);
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
$this->result = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$this->result = 0;
|
||||
}
|
||||
}
|
||||
unset($prep_statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_md5')) {
|
||||
function php_md5($string) {
|
||||
return md5($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_unix_time_stamp')) {
|
||||
function php_unix_time_stamp($string) {
|
||||
return strtotime($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_now')) {
|
||||
function php_now() {
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_left')) {
|
||||
function php_left($string, $num) {
|
||||
return substr($string, 0, $num);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_right')) {
|
||||
function php_right($string, $num) {
|
||||
return substr($string, (strlen($string)-$num), strlen($string));
|
||||
}
|
||||
}
|
||||
|
||||
//example usage
|
||||
/*
|
||||
//find
|
||||
require_once "resources/classes/database.php";
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->type = $db_type;
|
||||
$database->table = "v_extensions";
|
||||
$where[0]['name'] = 'domain_uuid';
|
||||
$where[0]['value'] = $_SESSION["domain_uuid"];
|
||||
$where[0]['operator'] = '=';
|
||||
$database->where = $where;
|
||||
$order_by[0]['name'] = 'extension';
|
||||
$database->order_by = $order_by;
|
||||
$database->order_type = 'desc';
|
||||
$database->limit = '2';
|
||||
$database->offset = '0';
|
||||
$database->find();
|
||||
print_r($database->result);
|
||||
//insert
|
||||
require_once "resources/classes/database.php";
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->type = $db_type;
|
||||
$database->table = "v_ivr_menus";
|
||||
$fields[0]['name'] = 'domain_uuid';
|
||||
$fields[0]['value'] = $_SESSION["domain_uuid"];
|
||||
$database->add();
|
||||
print_r($database->result);
|
||||
*/
|
||||
?>
|
||||
365
resources/classes/dialplan.php
Normal file
365
resources/classes/dialplan.php
Normal file
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the dialplan class
|
||||
if (!class_exists('dialplan')) {
|
||||
class dialplan {
|
||||
//variables
|
||||
public $result;
|
||||
public $domain_uuid;
|
||||
public $dialplan_uuid;
|
||||
public $xml;
|
||||
public $json;
|
||||
public $display_type;
|
||||
public $default_context;
|
||||
|
||||
//dialplans
|
||||
public $dialplan_name;
|
||||
public $dialplan_continue;
|
||||
public $dialplan_order;
|
||||
public $dialplan_context;
|
||||
public $dialplan_enabled;
|
||||
public $dialplan_description;
|
||||
|
||||
//dialplan_details
|
||||
public $dialplan_detail_tag;
|
||||
public $dialplan_detail_order;
|
||||
public $dialplan_detail_type;
|
||||
public $dialplan_detail_data;
|
||||
public $dialplan_detail_break;
|
||||
public $dialplan_detail_inline;
|
||||
public $dialplan_detail_group;
|
||||
|
||||
public function dialplan_add() {
|
||||
global $db;
|
||||
$sql = "insert into v_dialplans ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "app_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_name, ";
|
||||
$sql .= "dialplan_continue, ";
|
||||
$sql .= "dialplan_order, ";
|
||||
$sql .= "dialplan_context, ";
|
||||
$sql .= "dialplan_enabled, ";
|
||||
$sql .= "dialplan_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$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_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 .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function dialplan_update() {
|
||||
global $db;
|
||||
$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)."' ";
|
||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||
//echo "sql: ".$sql."<br />";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function dialplan_detail_add() {
|
||||
global $db;
|
||||
$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."', ";
|
||||
$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";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function dialplan_detail_update() {
|
||||
global $db;
|
||||
$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)."' ";
|
||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||
//echo "sql: ".$sql."<br />";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function restore_advanced_xml() {
|
||||
$switch_dialplan_dir = $this->switch_dialplan_dir;
|
||||
if (is_dir($switch_dialplan_dir)) {
|
||||
//get the contents of the dialplan/default.xml
|
||||
$file_default_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/conf/dialplan/default.xml';
|
||||
$file_default_contents = file_get_contents($file_default_path);
|
||||
//prepare the file contents and the path
|
||||
if (count($_SESSION['domains']) < 2) {
|
||||
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
|
||||
$file_default_contents = str_replace("{v_domain}", 'default', $file_default_contents);
|
||||
//set the file path
|
||||
$file_path = $switch_dialplan_dir.'/default.xml';
|
||||
}
|
||||
else {
|
||||
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
|
||||
$file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents);
|
||||
//set the file path
|
||||
$file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml';
|
||||
}
|
||||
//write the default dialplan
|
||||
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.');
|
||||
fwrite($fh, $file_default_contents);
|
||||
fclose($fh);
|
||||
//set the message
|
||||
$this->result['dialplan']['restore']['msg'] = "Default Restored";
|
||||
}
|
||||
}
|
||||
|
||||
private function app_uuid_exists() {
|
||||
global $db;
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and app_uuid = '".$this->app_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
}
|
||||
|
||||
public function dialplan_exists() {
|
||||
global $db;
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
}
|
||||
|
||||
public function import() {
|
||||
if (strlen($this->xml) > 0) {
|
||||
//replace the variables
|
||||
$this->xml = str_replace("{v_context}", $this->default_context, $this->xml);
|
||||
$this->xml = str_replace("{v_pin_number}", generate_password(8, 1), $this->xml);
|
||||
$this->xml = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->xml);
|
||||
//convert the xml string to an xml object
|
||||
$xml = simplexml_load_string($this->xml);
|
||||
//convert to json
|
||||
$json = json_encode($xml);
|
||||
//convert to an array
|
||||
$dialplan = json_decode($json, true);
|
||||
}
|
||||
if (strlen($this->json) > 0) {
|
||||
//convert to an array
|
||||
$dialplan = json_decode($json, true);
|
||||
}
|
||||
|
||||
//ensure the condition array uniform
|
||||
if (is_array($dialplan)) {
|
||||
if (!is_array($dialplan['extension']['condition'][0])) {
|
||||
$tmp = $dialplan['extension']['condition'];
|
||||
unset($dialplan['extension']['condition']);
|
||||
$dialplan['extension']['condition'][0] = $tmp;
|
||||
}
|
||||
}
|
||||
//check if the dialplan app uuid exists
|
||||
$this->app_uuid = $dialplan['extension']['@attributes']['app_uuid'];
|
||||
if ($this->app_uuid_exists()) {
|
||||
//dialplan entry already exists do nothing
|
||||
}
|
||||
else {
|
||||
//get the attributes
|
||||
$this->dialplan_uuid = uuid();
|
||||
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
|
||||
$this->dialplan_context = $dialplan['@attributes']['name'];
|
||||
if ($this->display_type == "text") {
|
||||
echo " ".$this->dialplan_name.": added\n";
|
||||
}
|
||||
if (strlen($dialplan['extension']['@attributes']['continue']) > 0) {
|
||||
$this->dialplan_continue = $dialplan['extension']['@attributes']['continue'];
|
||||
}
|
||||
if (strlen($dialplan['extension']['@attributes']['enabled']) > 0) {
|
||||
$this->dialplan_enabled = $dialplan['extension']['@attributes']['enabled'];
|
||||
}
|
||||
else {
|
||||
$this->dialplan_enabled = "true";
|
||||
}
|
||||
$this->dialplan_description = '';
|
||||
$this->dialplan_add();
|
||||
//loop through the condition array
|
||||
$x = 0;
|
||||
$group = 0;
|
||||
$order = 5;
|
||||
foreach ($dialplan['extension']['condition'] as &$row) {
|
||||
unset($this->dialplan_detail_break);
|
||||
unset($this->dialplan_detail_inline);
|
||||
$this->dialplan_detail_tag = 'condition';
|
||||
$this->dialplan_detail_type = $row['@attributes']['field'];
|
||||
$this->dialplan_detail_data = $row['@attributes']['expression'];
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
if (strlen($row['@attributes']['break']) > 0) {
|
||||
$this->dialplan_detail_break = $row['@attributes']['break'];
|
||||
}
|
||||
$this->dialplan_detail_add();
|
||||
if (is_array($row['action']) || is_array($row['anti-action'])) {
|
||||
$condition_self_closing_tag = false;
|
||||
if (!is_array($row['action'][0])) {
|
||||
if ($row['action']['@attributes']['application']) {
|
||||
$tmp = $row['action'];
|
||||
unset($row['action']);
|
||||
$row['action'][0] = $tmp;
|
||||
}
|
||||
}
|
||||
if (!is_array($row['anti-action'][0])) {
|
||||
if ($row['anti-action']['@attributes']['application']) {
|
||||
$tmp = $row['anti-action'];
|
||||
unset($row['anti-action']);
|
||||
$row['anti-action'][0] = $tmp;
|
||||
}
|
||||
}
|
||||
$order = $order + 5;
|
||||
unset($this->dialplan_detail_break);
|
||||
unset($this->dialplan_detail_inline);
|
||||
foreach ($row['action'] as &$row2) {
|
||||
$this->dialplan_detail_tag = 'action';
|
||||
$this->dialplan_detail_type = $row2['@attributes']['application'];
|
||||
$this->dialplan_detail_data = $row2['@attributes']['data'];
|
||||
if (strlen($row2['@attributes']['inline']) > 0) {
|
||||
$this->dialplan_detail_inline = $row2['@attributes']['inline'];
|
||||
}
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
$this->dialplan_detail_add();
|
||||
$order = $order + 5;
|
||||
}
|
||||
foreach ($row['anti-action'] as &$row2) {
|
||||
$this->dialplan_detail_tag = 'anti-action';
|
||||
$this->dialplan_detail_type = $row2['@attributes']['application'];
|
||||
$this->dialplan_detail_data = $row2['@attributes']['data'];
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
$this->dialplan_detail_add();
|
||||
$order = $order + 5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$condition_self_closing_tag = true;
|
||||
}
|
||||
//if not a self closing tag then increment the group
|
||||
if (!$condition_self_closing_tag) {
|
||||
$group++;
|
||||
}
|
||||
$row['group'] = $group;
|
||||
$order = $order + 5;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
690
resources/classes/directory.php
Normal file
690
resources/classes/directory.php
Normal file
@@ -0,0 +1,690 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the directory class
|
||||
class switch_directory {
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $db_type;
|
||||
public $extension;
|
||||
public $number_alias;
|
||||
public $password;
|
||||
public $vm_password;
|
||||
public $accountcode;
|
||||
public $effective_caller_id_name;
|
||||
public $effective_caller_id_number;
|
||||
public $outbound_caller_id_name;
|
||||
public $outbound_caller_id_number;
|
||||
public $limit_max=5;
|
||||
public $limit_destination;
|
||||
public $vm_enabled=1;
|
||||
public $vm_mailto;
|
||||
public $vm_attach_file;
|
||||
public $vm_keep_local_after_email;
|
||||
public $user_context;
|
||||
public $range;
|
||||
public $autogen_users;
|
||||
public $toll_allow;
|
||||
public $call_group;
|
||||
public $hold_music;
|
||||
public $auth_acl;
|
||||
public $cidr;
|
||||
public $sip_force_contact;
|
||||
public $sip_force_expires;
|
||||
public $nibble_account;
|
||||
public $mwi_account;
|
||||
public $sip_bypass_media;
|
||||
public $enabled;
|
||||
public $description;
|
||||
|
||||
// get domain_uuid
|
||||
public function get_domain_uuid() {
|
||||
return $this->domain_uuid;
|
||||
}
|
||||
// set domain_uuid
|
||||
public function set_domain_uuid($domain_uuid){
|
||||
$this->domain_uuid = $domain_uuid;
|
||||
}
|
||||
|
||||
// get domain_name
|
||||
public function get_domain_name() {
|
||||
return $this->domain_name;
|
||||
}
|
||||
// set domain_name
|
||||
public function set_domain_name($domain_name){
|
||||
$this->domain_name = $domain_name;
|
||||
}
|
||||
|
||||
// get db_type
|
||||
public function get_db_type() {
|
||||
return $this->db_type;
|
||||
}
|
||||
// set db_type
|
||||
public function set_db_type($db_type){
|
||||
$this->db_type = $db_type;
|
||||
}
|
||||
|
||||
// get extension
|
||||
public function get_extension() {
|
||||
return $this->extension;
|
||||
}
|
||||
// set extension
|
||||
public function set_extension($extension){
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
public function add() {
|
||||
global $db;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
$extension = $this->extension;
|
||||
$number_alias = $this->number_alias;
|
||||
$password = $this->password;
|
||||
$autogen_users = $this->autogen_users;
|
||||
$provisioning_list = $this->provisioning_list;
|
||||
$vm_password = $this->vm_password;
|
||||
$accountcode = $this->accountcode;
|
||||
$effective_caller_id_name = $this->effective_caller_id_name;
|
||||
$effective_caller_id_number = $this->effective_caller_id_number;
|
||||
$outbound_caller_id_name = $this->outbound_caller_id_name;
|
||||
$outbound_caller_id_number = $this->outbound_caller_id_number;
|
||||
$limit_max = $this->limit_max;
|
||||
$limit_destination = $this->limit_destination;
|
||||
$vm_enabled = $this->vm_enabled;
|
||||
$vm_mailto = $this->vm_mailto;
|
||||
$vm_attach_file = $this->vm_attach_file;
|
||||
$vm_keep_local_after_email = $this->vm_keep_local_after_email;
|
||||
$user_context = $this->user_context;
|
||||
$toll_allow = $this->toll_allow;
|
||||
$call_group = $this->call_group;
|
||||
$hold_music = $this->hold_music;
|
||||
$auth_acl = $this->auth_acl;
|
||||
$cidr = $this->cidr;
|
||||
$sip_force_contact = $this->sip_force_contact;
|
||||
$sip_force_expires = $this->sip_force_expires;
|
||||
$nibble_account = $this->nibble_account;
|
||||
$mwi_account = $this->mwi_account;
|
||||
$sip_bypass_media = $this->sip_bypass_media;
|
||||
$enabled = $this->enabled;
|
||||
$description = $this->description;
|
||||
|
||||
$db->beginTransaction();
|
||||
for ($i=1; $i<=$range; $i++) {
|
||||
if (extension_exists($extension)) {
|
||||
//extension exists
|
||||
}
|
||||
else {
|
||||
//extension does not exist add it
|
||||
$password = generate_password();
|
||||
$sql = "insert into v_extensions ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "extension_uuid, ";
|
||||
$sql .= "extension, ";
|
||||
$sql .= "number_alias, ";
|
||||
$sql .= "password, ";
|
||||
$sql .= "provisioning_list, ";
|
||||
$sql .= "vm_password, ";
|
||||
$sql .= "accountcode, ";
|
||||
$sql .= "effective_caller_id_name, ";
|
||||
$sql .= "effective_caller_id_number, ";
|
||||
$sql .= "outbound_caller_id_name, ";
|
||||
$sql .= "outbound_caller_id_number, ";
|
||||
$sql .= "limit_max, ";
|
||||
$sql .= "limit_destination, ";
|
||||
$sql .= "vm_enabled, ";
|
||||
$sql .= "vm_mailto, ";
|
||||
$sql .= "vm_attach_file, ";
|
||||
$sql .= "vm_keep_local_after_email, ";
|
||||
$sql .= "user_context, ";
|
||||
$sql .= "toll_allow, ";
|
||||
$sql .= "call_group, ";
|
||||
$sql .= "hold_music, ";
|
||||
$sql .= "auth_acl, ";
|
||||
$sql .= "cidr, ";
|
||||
$sql .= "sip_force_contact, ";
|
||||
if (strlen($sip_force_expires) > 0) {
|
||||
$sql .= "sip_force_expires, ";
|
||||
}
|
||||
if (strlen($nibble_account) > 0) {
|
||||
$sql .= "nibble_account, ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
$sql .= "mwi_account, ";
|
||||
}
|
||||
$sql .= "sip_bypass_media, ";
|
||||
$sql .= "enabled, ";
|
||||
$sql .= "description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$extension_uuid', ";
|
||||
$sql .= "'$extension', ";
|
||||
$sql .= "'$number_alias', ";
|
||||
$sql .= "'$password', ";
|
||||
$sql .= "'$provisioning_list', ";
|
||||
$sql .= "'user-choose', ";
|
||||
$sql .= "'$accountcode', ";
|
||||
$sql .= "'$effective_caller_id_name', ";
|
||||
$sql .= "'$effective_caller_id_number', ";
|
||||
$sql .= "'$outbound_caller_id_name', ";
|
||||
$sql .= "'$outbound_caller_id_number', ";
|
||||
$sql .= "'$limit_max', ";
|
||||
$sql .= "'$limit_destination', ";
|
||||
$sql .= "'$vm_enabled', ";
|
||||
$sql .= "'$vm_mailto', ";
|
||||
$sql .= "'$vm_attach_file', ";
|
||||
$sql .= "'$vm_keep_local_after_email', ";
|
||||
$sql .= "'$user_context', ";
|
||||
$sql .= "'$toll_allow', ";
|
||||
$sql .= "'$call_group', ";
|
||||
$sql .= "'$hold_music', ";
|
||||
$sql .= "'$auth_acl', ";
|
||||
$sql .= "'$cidr', ";
|
||||
$sql .= "'$sip_force_contact', ";
|
||||
if (strlen($sip_force_expires) > 0) {
|
||||
$sql .= "'$sip_force_expires', ";
|
||||
}
|
||||
if (strlen($nibble_account) > 0) {
|
||||
$sql .= "'$nibble_account', ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
if (strpos($mwi_account, '@') === false) {
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$mwi_account .= "@".$domain_name;
|
||||
}
|
||||
else {
|
||||
$mwi_account .= "@\$\${domain}";
|
||||
}
|
||||
}
|
||||
$sql .= "'$mwi_account', ";
|
||||
}
|
||||
$sql .= "'$sip_bypass_media', ";
|
||||
$sql .= "'$enabled', ";
|
||||
$sql .= "'$description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
$extension++;
|
||||
}
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
public function update() {
|
||||
global $db;
|
||||
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
$extension = $this->extension;
|
||||
$number_alias = $this->number_alias;
|
||||
$password = $this->password;
|
||||
$autogen_users = $this->autogen_users;
|
||||
$provisioning_list = $this->provisioning_list;
|
||||
$vm_password = $this->vm_password;
|
||||
$accountcode = $this->accountcode;
|
||||
$effective_caller_id_name = $this->effective_caller_id_name;
|
||||
$effective_caller_id_number = $this->effective_caller_id_number;
|
||||
$outbound_caller_id_name = $this->outbound_caller_id_name;
|
||||
$outbound_caller_id_number = $this->outbound_caller_id_number;
|
||||
$limit_max = $this->limit_max;
|
||||
$limit_destination = $this->limit_destination;
|
||||
$vm_enabled = $this->vm_enabled;
|
||||
$vm_mailto = $this->vm_mailto;
|
||||
$vm_attach_file = $this->vm_attach_file;
|
||||
$vm_keep_local_after_email = $this->vm_keep_local_after_email;
|
||||
$user_context = $this->user_context;
|
||||
$toll_allow = $this->toll_allow;
|
||||
$call_group = $this->call_group;
|
||||
$hold_music = $this->hold_music;
|
||||
$auth_acl = $this->auth_acl;
|
||||
$cidr = $this->cidr;
|
||||
$sip_force_contact = $this->sip_force_contact;
|
||||
$sip_force_expires = $this->sip_force_expires;
|
||||
$nibble_account = $this->nibble_account;
|
||||
$mwi_account = $this->mwi_account;
|
||||
$sip_bypass_media = $this->sip_bypass_media;
|
||||
$enabled = $this->enabled;
|
||||
$description = $this->description;
|
||||
|
||||
//$user_list_array = explode("|", $user_list);
|
||||
//foreach($user_list_array as $tmp_user){
|
||||
// $user_password = generate_password();
|
||||
// if (strlen($tmp_user) > 0) {
|
||||
// user_add($tmp_user, $user_password, $user_email);
|
||||
// }
|
||||
//}
|
||||
//unset($tmp_user);
|
||||
|
||||
if (strlen($password) == 0) {
|
||||
$password = generate_password();
|
||||
}
|
||||
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "extension = '$extension', ";
|
||||
$sql .= "number_alias = '$number_alias', ";
|
||||
$sql .= "password = '$password', ";
|
||||
$sql .= "provisioning_list = '$provisioning_list', ";
|
||||
if (strlen($vm_password) > 0) {
|
||||
$sql .= "vm_password = '$vm_password', ";
|
||||
}
|
||||
else {
|
||||
$sql .= "vm_password = 'user-choose', ";
|
||||
}
|
||||
$sql .= "accountcode = '$accountcode', ";
|
||||
$sql .= "effective_caller_id_name = '$effective_caller_id_name', ";
|
||||
$sql .= "effective_caller_id_number = '$effective_caller_id_number', ";
|
||||
$sql .= "outbound_caller_id_name = '$outbound_caller_id_name', ";
|
||||
$sql .= "outbound_caller_id_number = '$outbound_caller_id_number', ";
|
||||
$sql .= "limit_max = '$limit_max', ";
|
||||
$sql .= "limit_destination = '$limit_destination', ";
|
||||
$sql .= "vm_enabled = '$vm_enabled', ";
|
||||
$sql .= "vm_mailto = '$vm_mailto', ";
|
||||
$sql .= "vm_attach_file = '$vm_attach_file', ";
|
||||
$sql .= "vm_keep_local_after_email = '$vm_keep_local_after_email', ";
|
||||
$sql .= "user_context = '$user_context', ";
|
||||
$sql .= "toll_allow = '$toll_allow', ";
|
||||
$sql .= "call_group = '$call_group', ";
|
||||
$sql .= "hold_music = '$hold_music', ";
|
||||
$sql .= "auth_acl = '$auth_acl', ";
|
||||
$sql .= "cidr = '$cidr', ";
|
||||
$sql .= "sip_force_contact = '$sip_force_contact', ";
|
||||
if (strlen($sip_force_expires) == 0) {
|
||||
$sql .= "sip_force_expires = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "sip_force_expires = '$sip_force_expires', ";
|
||||
}
|
||||
if (strlen($nibble_account) == 0) {
|
||||
$sql .= "nibble_account = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "nibble_account = '$nibble_account', ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
if (strpos($mwi_account, '@') === false) {
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$mwi_account .= "@".$domain_name;
|
||||
}
|
||||
else {
|
||||
$mwi_account .= "@\$\${domain}";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= "mwi_account = '$mwi_account', ";
|
||||
$sql .= "sip_bypass_media = '$sip_bypass_media', ";
|
||||
$sql .= "enabled = '$enabled', ";
|
||||
$sql .= "description = '$description' ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$extension_uuid'";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
function delete() {
|
||||
global $db;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$extension_uuid = $this->extension_uuid;
|
||||
if (strlen($extension_uuid)>0) {
|
||||
$sql = "delete from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$extension_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
|
||||
function import_sql($data){
|
||||
$count=count($data);
|
||||
$keys=$values=SplFixedArray($count);
|
||||
$keys=array_keys($data);
|
||||
$values=array_values($data);
|
||||
for($i=0;$i<$count;$i++){
|
||||
$keys[$i]= str_replace("-", "_", $keys[$i]);
|
||||
$this->{$keys[$i]}=$values[$i];
|
||||
}
|
||||
}
|
||||
|
||||
function set_bool(&$var,$default=null){
|
||||
$var=strtolower($var);
|
||||
if ($var==="true") return;
|
||||
elseif ($var==="false") return;
|
||||
elseif ($var==true) $var="true";
|
||||
elseif ($var==false) $var="false";
|
||||
elseif(!is_null($default)) {
|
||||
$var=$default;
|
||||
$this->set_bool($var);
|
||||
}
|
||||
}
|
||||
|
||||
function generate_xml($single=1){
|
||||
//switch_account_code!! How should we be passing this??
|
||||
|
||||
if ($this->enabled== "false" || !$this->enabled) {
|
||||
return false;//This the best way??
|
||||
}
|
||||
|
||||
$this->vm_password = str_replace("#", "", $this->vm_password); //preserves leading zeros//**Generic Validation!
|
||||
|
||||
/*if(!in_array($this->vm_enabled,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_enabled = "true";
|
||||
}
|
||||
if(!in_array($this->vm_attach_file,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_attach_file = "true";
|
||||
}
|
||||
if(!in_array($this->vm_keep_local_after_email,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_keep_local_after_email = "true";
|
||||
}
|
||||
*/
|
||||
$this->set_bool($this->vm_enabled,1);
|
||||
$this->set_bool($this->vm_attach_file,1);
|
||||
$this->set_bool($this->vm_keep_local_after_email,1);
|
||||
|
||||
//remove invalid characters from the file names //**Generic Validation!
|
||||
$this->extension = str_replace(" ", "_", $this->extension);
|
||||
$this->extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $this->extension);
|
||||
|
||||
/*if (!$extension_xml_condensed) { <--- what do I do with this??
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/v_".$extension.".xml","w");
|
||||
$xml .= "<include>\n";
|
||||
}*/
|
||||
if (strlen($this->cidr)) {
|
||||
$this->cidr = " cidr=\"" . $this->cidr . "\"";
|
||||
}
|
||||
if (strlen($this->number_alias)) {
|
||||
$this->number_alias = " number-alias=\"".$this->number_alias."\"";
|
||||
}
|
||||
if($single) $xml = "<include>\n";
|
||||
else $xml = "";
|
||||
$xml .= " <user id=\"".$this->extension."\"".$this->cidr."".$this->number_alias.">\n";
|
||||
$xml .= " <params>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $this->password . "\"/>\n";
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"".$this->vm_enabled."\"/>\n";
|
||||
|
||||
if ($this->vm_enabled=="true"){
|
||||
$xml .= " <param name=\"vm-password\" value=\"" . $this->vm_password . "\"/>\n";
|
||||
if(strlen($this->vm_mailto)) {
|
||||
$xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"".$this->vm_attach_file."\"/>\n";
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"".$this->vm_keep_local_after_email."\"/>\n";
|
||||
$xml .= " <param name=\"vm-mailto\" value=\"" . $this->vm_mailto . "\"/>\n";
|
||||
}
|
||||
}
|
||||
if (strlen($this->mwi_account)) {
|
||||
$xml .= " <param name=\"MWI-Account\" value=\"" . $this->mwi_account . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->auth_acl)) {
|
||||
$xml .= " <param name=\"auth-acl\" value=\"" . $this->auth_acl . "\"/>\n";
|
||||
}
|
||||
$xml .= " </params>\n";
|
||||
|
||||
$xml .= " <variables>\n";
|
||||
if (strlen($this->hold_music)) {
|
||||
$xml .= " <variable name=\"hold_music\" value=\"" . $this->hold_music . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->toll_allow)){
|
||||
$xml .= " <variable name=\"toll_allow\" value=\"" . $this->toll_allow . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->accountcode)){
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $this->accountcode . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"user_context\" value=\"" . $this->user_context . "\"/>\n";
|
||||
if (strlen($this->effective_caller_id_name)) {
|
||||
$xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $this->effective_caller_id_name . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_number)) {
|
||||
$xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $this->effective_caller_id_number . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_name)) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $this->outbound_caller_id_name . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_number)) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $this->outbound_caller_id_number . "\"/>\n";
|
||||
}
|
||||
if (!strlen($this->limit_max)) {//**validation
|
||||
$this->limit_max=5;
|
||||
}
|
||||
$xml .= " <variable name=\"limit_max\" value=\"" . $this->limit_max . "\"/>\n";
|
||||
if (strlen($this->limit_destination)) {
|
||||
$xml .= " <variable name=\"limit_destination\" value=\"" . $this->limit_destination . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->sip_force_contact)) {
|
||||
$xml .= " <variable name=\"sip-force-contact\" value=\"" . $this->sip_force_contact . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->sip_force_expires)) {
|
||||
$xml .= " <variable name=\"sip-force-expires\" value=\"" . $this->sip_force_expires . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->nibble_account)) {
|
||||
$xml .= " <variable name=\"nibble_account\" value=\"" . $this->nibble_account . "\"/>\n";
|
||||
}
|
||||
switch ($this->sip_bypass_media) {
|
||||
case "bypass-media":
|
||||
$xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
}
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= " </user>\n";
|
||||
if($single) { $xml .= "</include>\n"; }
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function xml_save_all() {
|
||||
global $db, $config;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
|
||||
//get the system settings paths and set them as variables
|
||||
$settings_array = v_settings();
|
||||
foreach($settings_array as $name => $value) {
|
||||
$$name = $value;
|
||||
}
|
||||
|
||||
//determine the extensions parent directory
|
||||
$extension_parent_dir = realpath($_SESSION['switch']['extensions']['dir']."/..");
|
||||
|
||||
// delete all old extensions to prepare for new ones
|
||||
if($dh = opendir($_SESSION['switch']['extensions']['dir'])) {
|
||||
$files = Array();
|
||||
while($file = readdir($dh)) {
|
||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
||||
if(is_dir($dir . "/" . $file)) {
|
||||
//this is a directory do nothing
|
||||
} else {
|
||||
//check if file is an extension; verify the file numeric and the extension is xml
|
||||
if (substr($file,0,2) == 'v_' && substr($file,-4) == '.xml') {
|
||||
unlink($_SESSION['switch']['extensions']['dir']."/".$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "order by call_group asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$i = 0;
|
||||
$extension_xml_condensed = false;
|
||||
if ($extension_xml_condensed) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/v_extensions.xml","w");
|
||||
$xml = "<include>\n";
|
||||
}
|
||||
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) {
|
||||
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'];
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($row['enabled'] != "false") {
|
||||
//$this->import_sql($row);//Do I need to be worried about ghost values? Maybe I should make a new object?
|
||||
//if (strlen($switch_account_code)) $this->accountcode=$switch_account_code;
|
||||
//$xml.=$this->generate_xml(1);
|
||||
|
||||
$one_row=new fs_directory;
|
||||
$one_row->import_sql($row);//make a new object to flush ghost rows. And we can call this as static.
|
||||
if (strlen($switch_account_code)) $one_row->accountcode=$switch_account_code;
|
||||
$xml.=$one_row->generate_xml(false);
|
||||
|
||||
if (!$extension_xml_condensed) {
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if ($extension_xml_condensed) {
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
|
||||
//define the group members
|
||||
$xml = "<!--\n";
|
||||
$xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " FreeSWITCH works off the concept of users and domains just like email.\n";
|
||||
$xml .= " You have users that are in domains for example 1000@domain.com.\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " When freeswitch gets a register packet it looks for the user in the directory\n";
|
||||
$xml .= " based on the from or to domain in the packet depending on how your sofia profile\n";
|
||||
$xml .= " is configured. Out of the box the default domain will be the IP address of the\n";
|
||||
$xml .= " machine running FreeSWITCH. This IP can be found by typing \"sofia status\" at the\n";
|
||||
$xml .= " CLI. You will register your phones to the IP and not the hostname by default.\n";
|
||||
$xml .= " If you wish to register using the domain please open vars.xml in the root conf\n";
|
||||
$xml .= " directory and set the default domain to the hostname you desire. Then you would\n";
|
||||
$xml .= " use the domain name in the client instead of the IP address to register\n";
|
||||
$xml .= " with FreeSWITCH.\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$xml .= "-->\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "<include>\n";
|
||||
$xml .= " <!--the domain or ip (the right hand side of the @ in the addr-->\n";
|
||||
if ($extension_dir_name == "default") {
|
||||
$xml .= " <domain name=\"\$\${domain}\">\n";
|
||||
}
|
||||
else {
|
||||
$xml .= " <domain name=\"".$extension_dir_name."\">\n";
|
||||
}
|
||||
$xml .= " <params>\n";
|
||||
//$xml .= " <param name=\"dial-string\" value=\"{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}\"/>\n";
|
||||
$xml .= " </params>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " <variables>\n";
|
||||
$xml .= " <variable name=\"record_stereo\" value=\"true\"/>\n";
|
||||
$xml .= " <variable name=\"default_gateway\" value=\"\$\${default_provider}\"/>\n";
|
||||
$xml .= " <variable name=\"default_areacode\" value=\"\$\${default_areacode}\"/>\n";
|
||||
$xml .= " <variable name=\"transfer_fallback_extension\" value=\"operator\"/>\n";
|
||||
$xml .= " <variable name=\"export_vars\" value=\"domain_name\"/>\n";
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " <groups>\n";
|
||||
$xml .= " <group name=\"".$extension_dir_name."\">\n";
|
||||
$xml .= " <users>\n";
|
||||
$xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$extension_dir_name."/*.xml\"/>\n";
|
||||
$xml .= " </users>\n";
|
||||
$xml .= " </group>\n";
|
||||
$xml .= "\n";
|
||||
$previous_call_group = "";
|
||||
foreach ($call_group_array as $key => $value) {
|
||||
$call_group = $key;
|
||||
$extension_list = $value;
|
||||
if (strlen($call_group) > 0) {
|
||||
if ($previous_call_group != $call_group) {
|
||||
$xml .= " <group name=\"$call_group\">\n";
|
||||
$xml .= " <users>\n";
|
||||
$xml .= " <!--\n";
|
||||
$xml .= " type=\"pointer\" is a pointer so you can have the\n";
|
||||
$xml .= " same user in multiple groups. It basically means\n";
|
||||
$xml .= " to keep searching for the user in the directory.\n";
|
||||
$xml .= " -->\n";
|
||||
$extension_array = explode(",", $extension_list);
|
||||
foreach ($extension_array as &$tmp_extension) {
|
||||
$xml .= " <user id=\"$tmp_extension\" type=\"pointer\"/>\n";
|
||||
}
|
||||
$xml .= " </users>\n";
|
||||
$xml .= " </group>\n";
|
||||
$xml .= "\n";
|
||||
}
|
||||
$previous_call_group = $call_group;
|
||||
}
|
||||
unset($call_group);
|
||||
}
|
||||
$xml .= " </groups>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " </domain>\n";
|
||||
$xml .= "</include>";
|
||||
|
||||
//remove invalid characters from the file names
|
||||
$extension_dir_name = str_replace(" ", "_", $extension_dir_name);
|
||||
$extension_dir_name = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension_dir_name);
|
||||
|
||||
//write the xml file
|
||||
$fout = fopen($extension_parent_dir."/".$extension_dir_name.".xml","w");
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
|
||||
//syncrhonize the phone directory
|
||||
sync_directory();
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//call reloadxml direct
|
||||
//$cmd = "api reloadxml";
|
||||
//event_socket_request_cmd($cmd);
|
||||
//unset($cmd);
|
||||
|
||||
} //end function
|
||||
} //class
|
||||
|
||||
?>
|
||||
180
resources/classes/domains.php
Normal file
180
resources/classes/domains.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
sreis
|
||||
*/
|
||||
|
||||
class domains {
|
||||
|
||||
public function set() {
|
||||
|
||||
//set the variable
|
||||
$db = $this->db;
|
||||
|
||||
//clear the sessions
|
||||
unset($_SESSION['contact']);
|
||||
unset($_SESSION['domain']);
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['ldap']);
|
||||
unset($_SESSION['login']);
|
||||
unset($_SESSION['provision']);
|
||||
unset($_SESSION['security']);
|
||||
unset($_SESSION['server']);
|
||||
unset($_SESSION['switch']);
|
||||
|
||||
//get the default settings
|
||||
$sql = "select * from v_default_settings ";
|
||||
$sql .= "where default_setting_enabled = 'true' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as $row) {
|
||||
$name = $row['default_setting_name'];
|
||||
$category = $row['default_setting_category'];
|
||||
$subcategory = $row['default_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$name] = $row['default_setting_value'];
|
||||
}
|
||||
} else {
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][$subcategory][] = $row['default_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$subcategory][$name] = $row['default_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get the domains settings
|
||||
$sql = "select * from v_domain_settings ";
|
||||
$sql .= "where domain_uuid = '" . $_SESSION["domain_uuid"] . "' ";
|
||||
$sql .= "and domain_setting_enabled = 'true' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as $row) {
|
||||
$name = $row['domain_setting_name'];
|
||||
$category = $row['domain_setting_category'];
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
//$$category[$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
} else {
|
||||
//$$category[$subcategory][$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][$subcategory][] = $row['domain_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get the user settings
|
||||
$sql = "select * from v_user_settings ";
|
||||
$sql .= "where domain_uuid = '" . $_SESSION["domain_uuid"] . "' ";
|
||||
$sql .= "and user_uuid = '" . $_SESSION["user_uuid"] . "' ";
|
||||
$sql .= "and user_setting_enabled = 'true' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as $row) {
|
||||
$name = $row['user_setting_name'];
|
||||
$category = $row['user_setting_category'];
|
||||
$subcategory = $row['user_setting_subcategory'];
|
||||
if (strlen($subcategory) == 0) {
|
||||
//$$category[$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][] = $row['user_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$name] = $row['user_setting_value'];
|
||||
}
|
||||
} else {
|
||||
//$$category[$subcategory][$name] = $row['domain_setting_value'];
|
||||
if ($name == "array") {
|
||||
$_SESSION[$category][$subcategory][] = $row['user_setting_value'];
|
||||
}
|
||||
else {
|
||||
$_SESSION[$category][$subcategory][$name] = $row['user_setting_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//set the values from the session variables
|
||||
if (strlen($_SESSION['domain']['time_zone']['name']) > 0) {
|
||||
//server time zone
|
||||
$_SESSION['time_zone']['system'] = date_default_timezone_get();
|
||||
//domain time zone set in system settings
|
||||
$_SESSION['time_zone']['domain'] = $_SESSION['domain']['time_zone']['name'];
|
||||
//set the domain time zone as the default time zone
|
||||
date_default_timezone_set($_SESSION['domain']['time_zone']['name']);
|
||||
}
|
||||
|
||||
//set the context
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$_SESSION["context"] = $_SESSION["domain_name"];
|
||||
} else {
|
||||
$_SESSION["context"] = 'default';
|
||||
}
|
||||
|
||||
//recordings add the domain to the path if there is more than one domains
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
if (strlen($_SESSION['switch']['recordings']['dir']) > 0) {
|
||||
if (substr($_SESSION['switch']['recordings']['dir'], -strlen($_SESSION["domain_name"])) != $_SESSION["domain_name"]) {
|
||||
//get the default recordings directory
|
||||
$sql = "select * from v_default_settings ";
|
||||
$sql .= "where default_setting_enabled = 'true' ";
|
||||
$sql .= "and default_setting_category = 'switch' ";
|
||||
$sql .= "and default_setting_subcategory = 'recordings' ";
|
||||
$sql .= "and default_setting_name = 'dir' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$result_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result_default_settings as $row) {
|
||||
$name = $row['default_setting_name'];
|
||||
$category = $row['default_setting_category'];
|
||||
$subcategory = $row['default_setting_subcategory'];
|
||||
$switch_recordings_dir = $row['default_setting_value'];
|
||||
}
|
||||
//add the domain
|
||||
$_SESSION['switch']['recordings']['dir'] = $switch_recordings_dir . '/' . $_SESSION["domain_name"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
530
resources/classes/fax.php
Normal file
530
resources/classes/fax.php
Normal file
@@ -0,0 +1,530 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the directory class
|
||||
class switch_fax {
|
||||
|
||||
public $db;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $dialplan_uuid;
|
||||
public $context;
|
||||
public $fax_uuid;
|
||||
public $fax_name;
|
||||
public $fax_extension;
|
||||
public $fax_email;
|
||||
public $fax_pin_number;
|
||||
public $fax_caller_id_name;
|
||||
public $fax_caller_id_number;
|
||||
public $fax_forward_number;
|
||||
public $fax_user_list;
|
||||
public $fax_description;
|
||||
|
||||
public function __construct() {
|
||||
require_once "resources/classes/database.php";
|
||||
$this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
public function count() {
|
||||
$database = new database;
|
||||
$database->domain_uuid = $this->domain_uuid;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
return $database->count();
|
||||
}
|
||||
|
||||
public function find() {
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
if ($this->fax_uuid) {
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
}
|
||||
if ($this->order_by) {
|
||||
$database->order_by = $this->order_by;
|
||||
}
|
||||
if ($this->order_type) {
|
||||
$database->order_type = $this->order_type;
|
||||
}
|
||||
return $database->find();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
//add the fax
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
//add the dialplan
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_name'] = $this->fax_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $this->context;
|
||||
$database->fields['dialplan_enabled'] = $this->fax_enabled;
|
||||
$database->fields['dialplan_description'] = $this->fax_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
$database->add();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->fax_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); }
|
||||
if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); }
|
||||
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
|
||||
$dialplan_detail_data .= "email=".$this->fax_email." ";
|
||||
$dialplan_detail_data .= "extension=".$this->fax_extension." ";
|
||||
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
|
||||
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
|
||||
$dialplan_detail_data .= "domain=".$domain_name." ";
|
||||
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
|
||||
$dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} ";
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true';
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'playback';
|
||||
$database->fields['dialplan_detail_data'] = 'silence_stream://2000';
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}';
|
||||
$database->fields['dialplan_detail_order'] = '035';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'rxfax';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '040';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'hangup';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '045';
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//add the fax
|
||||
$fax_uuid = uuid();
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
$database->fields['fax_extension'] = $this->fax_extension;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
}
|
||||
$database->fields['fax_uuid'] = $this->fax_uuid;
|
||||
$database->fields['fax_name'] = $this->fax_name;
|
||||
$database->fields['fax_email'] = $this->fax_email;
|
||||
$database->fields['fax_pin_number'] = $this->fax_pin_number;
|
||||
$database->fields['fax_caller_id_name'] = $this->fax_caller_id_name;
|
||||
$database->fields['fax_caller_id_number'] = $this->fax_caller_id_number;
|
||||
$database->fields['fax_forward_number'] = $this->fax_forward_number;
|
||||
$database->fields['fax_user_list'] = $this->fax_user_list;
|
||||
$database->fields['fax_description'] = $this->fax_description;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
//udate the fax
|
||||
//get the dialplan uuid
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
}
|
||||
|
||||
//if the extension number is empty and the dialplan exists then delete the dialplan
|
||||
if (strlen($this->fax_extension) == 0) {
|
||||
if (strlen($this->dialplan_uuid) > 0) {
|
||||
//delete dialplan entry
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//delete the child dialplan information
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//update the table to remove the dialplan_uuid
|
||||
$this->dialplan_uuid = '';
|
||||
}
|
||||
}
|
||||
|
||||
//update the fax
|
||||
$fax_uuid = uuid();
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->fields['fax_uuid'] = $this->fax_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['fax_name'] = $this->fax_name;
|
||||
$database->fields['fax_extension'] = $this->fax_extension;
|
||||
$database->fields['fax_email'] = $this->fax_email;
|
||||
$database->fields['fax_pin_number'] = $this->fax_pin_number;
|
||||
$database->fields['fax_caller_id_name'] = $this->fax_caller_id_name;
|
||||
$database->fields['fax_caller_id_number'] = $this->fax_caller_id_number;
|
||||
$database->fields['fax_forward_number'] = $this->fax_forward_number;
|
||||
$database->fields['fax_user_list'] = $this->fax_user_list;
|
||||
$database->fields['fax_description'] = $this->fax_description;
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
//update the dialplan
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['dialplan_name'] = $this->fax_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $this->context;
|
||||
$database->fields['dialplan_enabled'] = $this->fax_enabled;
|
||||
$database->fields['dialplan_description'] = $this->dialplan_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
if ($this->dialplan_uuid) {
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
}
|
||||
else {
|
||||
// $this->dialplan_uuid = uuid();
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//delete the old dialplan details to prepare for new details
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->fax_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); }
|
||||
if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); }
|
||||
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
|
||||
$dialplan_detail_data .= "email=".$this->fax_email." ";
|
||||
$dialplan_detail_data .= "extension=".$this->fax_extension." ";
|
||||
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
|
||||
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
|
||||
$dialplan_detail_data .= "domain=".$domain_name." ";
|
||||
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
|
||||
$dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} ";
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true';
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'playback';
|
||||
$database->fields['dialplan_detail_data'] = 'silence_stream://2000';
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}';
|
||||
$database->fields['dialplan_detail_order'] = '035';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'rxfax';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '040';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'hangup';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '045';
|
||||
$database->add();
|
||||
}
|
||||
}
|
||||
|
||||
function delete() {
|
||||
//create the database object
|
||||
$database = new database;
|
||||
|
||||
//start the transaction
|
||||
//$count = $database->db->exec("BEGIN;");
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) > 0) {
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
unset($this->fax_uuid);
|
||||
}
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) == 0) {
|
||||
//select the dialplan entries
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
//delete the child dialplan information
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//delete the dialplan information
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
}
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) > 0) {
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
unset($this->fax_uuid);
|
||||
}
|
||||
|
||||
//commit the transaction
|
||||
//$count = $database->db->exec("COMMIT;");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
require_once "resources/classes/database.php";
|
||||
require_once "resources/classes/fax.php";
|
||||
$fax = new switch_fax;
|
||||
$fax->domain_uuid = $_SESSION["domain_uuid"];
|
||||
print_r($fax->find());
|
||||
*/
|
||||
?>
|
||||
389
resources/classes/menu.php
Normal file
389
resources/classes/menu.php
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2013
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//define the menu class
|
||||
class menu {
|
||||
public $menu_uuid;
|
||||
|
||||
//delete items in the menu that are not protected
|
||||
function delete() {
|
||||
//set the variable
|
||||
$db = $this->db;
|
||||
//remove the menu languages
|
||||
$sql = "delete from v_menu_languages ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
//remove the old menu
|
||||
$sql = "delete from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and (menu_item_protected <> 'true' ";
|
||||
$sql .= "or menu_item_protected is null); ";
|
||||
$db->exec(check_sql($sql));
|
||||
}
|
||||
|
||||
//restore the menu
|
||||
function restore() {
|
||||
//set the variables
|
||||
$db = $this->db;
|
||||
|
||||
//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;
|
||||
foreach ($config_list as &$config_path) {
|
||||
include($config_path);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//use the app array to restore the default menu
|
||||
//$db->beginTransaction();
|
||||
foreach ($apps as $row) {
|
||||
foreach ($row['menu'] as $menu) {
|
||||
//set the variables
|
||||
$menu_item_title = $menu['title']['en-us'];
|
||||
$menu_item_uuid = $menu['uuid'];
|
||||
$menu_item_parent_uuid = $menu['parent_uuid'];
|
||||
$menu_item_category = $menu['category'];
|
||||
$menu_item_path = $menu['path'];
|
||||
$menu_item_order = $menu['order'];
|
||||
$menu_item_description = $menu['desc'];
|
||||
|
||||
//if the item uuid is not currently in the db then add it
|
||||
$sql = "select * from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and menu_item_uuid = '$menu_item_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) == 0) {
|
||||
//insert the default menu into the database
|
||||
$sql = "insert into v_menu_items ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "menu_uuid, ";
|
||||
//$sql .= "menu_item_language, ";
|
||||
$sql .= "menu_item_title, ";
|
||||
$sql .= "menu_item_link, ";
|
||||
$sql .= "menu_item_category, ";
|
||||
if (strlen($menu_item_order) > 0) {
|
||||
$sql .= "menu_item_order, ";
|
||||
}
|
||||
if (strlen($menu_item_parent_uuid) > 0) {
|
||||
$sql .= "menu_item_parent_uuid, ";
|
||||
}
|
||||
$sql .= "menu_item_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$menu_item_uuid."', ";
|
||||
$sql .= "'".$this->menu_uuid."', ";
|
||||
//$sql .= "'$menu_item_language', ";
|
||||
$sql .= "'$menu_item_title', ";
|
||||
$sql .= "'$menu_item_path', ";
|
||||
$sql .= "'$menu_item_category', ";
|
||||
if (strlen($menu_item_order) > 0) {
|
||||
$sql .= "'$menu_item_order', ";
|
||||
}
|
||||
if (strlen($menu_item_parent_uuid) > 0) {
|
||||
$sql .= "'$menu_item_parent_uuid', ";
|
||||
}
|
||||
$sql .= "'$menu_item_description' ";
|
||||
$sql .= ")";
|
||||
if ($menu_item_uuid == $menu_item_parent_uuid) {
|
||||
//echo $sql."<br />\n";
|
||||
}
|
||||
else {
|
||||
$db->exec(check_sql($sql));
|
||||
}
|
||||
unset($sql);
|
||||
//set the menu languages
|
||||
foreach ($menu["title"] as $menu_language => $menu_item_title) {
|
||||
$menu_language_uuid = uuid();
|
||||
$sql = "insert into v_menu_languages ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_language_uuid, ";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "menu_uuid, ";
|
||||
$sql .= "menu_language, ";
|
||||
$sql .= "menu_item_title ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$menu_language_uuid."', ";
|
||||
$sql .= "'".$menu_item_uuid."', ";
|
||||
$sql .= "'".$this->menu_uuid."', ";
|
||||
$sql .= "'$menu_language', ";
|
||||
$sql .= "'$menu_item_title' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if there are no groups listed in v_menu_item_groups under menu_uuid then add the default groups
|
||||
foreach($apps as $app) {
|
||||
foreach ($app['menu'] as $sub_row) {
|
||||
foreach ($sub_row['groups'] as $group) {
|
||||
$sql = "select count(*) as count from v_menu_item_groups ";
|
||||
$sql .= "where menu_item_uuid = '".$sub_row['uuid']."' ";
|
||||
$sql .= "and group_name = '$group' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
unset ($prep_statement);
|
||||
if ($sub_result['count'] == 0) {
|
||||
//no menu item groups found add the defaults
|
||||
|
||||
//add the record
|
||||
$sql = "insert into v_menu_item_groups ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_uuid, ";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "group_name ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$this->menu_uuid."', ";
|
||||
$sql .= "'".$sub_row['uuid']."', ";
|
||||
$sql .= "'".$group."' ";
|
||||
$sql .= ")";
|
||||
$db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} //end function
|
||||
|
||||
//create the menu
|
||||
function build_html($sql, $menu_item_level) {
|
||||
|
||||
$db = $this->db;
|
||||
$db_menu_full = '';
|
||||
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
if (strlen($sql) == 0) { //default sql for base of the menu
|
||||
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid from v_menu_items as i, v_menu_languages as l ";
|
||||
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
|
||||
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
|
||||
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_item_parent_uuid is null ";
|
||||
$sql .= "and i.menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "and menu_item_uuid is not null ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by i.menu_item_order asc ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach($result as $field) {
|
||||
unset($prep_statement2, $sql2, $result2);
|
||||
$menu_tags = '';
|
||||
switch ($field['menu_item_category']) {
|
||||
case "internal":
|
||||
$menu_tags = "href='".PROJECT_PATH.$field['menu_item_link']."'";
|
||||
break;
|
||||
case "external":
|
||||
if (substr($field['menu_item_link'], 0,1) == "/") {
|
||||
$field['menu_item_link'] = PROJECT_PATH . $field['menu_item_link'];
|
||||
}
|
||||
$menu_tags = "href='".$field['menu_item_link']."' target='_blank'";
|
||||
break;
|
||||
case "email":
|
||||
$menu_tags = "href='mailto:".$field['menu_item_link']."'";
|
||||
break;
|
||||
}
|
||||
|
||||
//prepare the protected menus
|
||||
if ($field['menu_item_protected'] == "true") {
|
||||
$menu_item_title = $field['menu_item_title'];
|
||||
}
|
||||
else {
|
||||
$menu_item_title = $field['menu_language_title'];
|
||||
}
|
||||
|
||||
if ($menu_item_level == "main") {
|
||||
$db_menu = "<ul class='menu_main'>\n";
|
||||
$db_menu .= "<li>\n";
|
||||
if (!isset($_SESSION["username"])) {
|
||||
$_SESSION["username"] = '';
|
||||
}
|
||||
if (strlen($_SESSION["username"]) == 0) {
|
||||
$db_menu .= "<a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$menu_item_title."</h2></a>\n";
|
||||
}
|
||||
else {
|
||||
if ($field['menu_item_link'] == "/login.php" || $field['menu_item_link'] == "/users/signup.php") {
|
||||
//hide login and sign-up when the user is logged in
|
||||
}
|
||||
else {
|
||||
$db_menu .= "<a ".$menu_tags." style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$menu_item_title."</h2></a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menu_item_level = 0;
|
||||
if (strlen($field['menu_item_uuid']) > 0) {
|
||||
$db_menu .= $this->build_child_html($menu_item_level, $field['menu_item_uuid']);
|
||||
}
|
||||
|
||||
if ($menu_item_level == "main") {
|
||||
$db_menu .= "</li>\n";
|
||||
$db_menu .= "</ul>\n\n";
|
||||
}
|
||||
|
||||
$db_menu_full .= $db_menu;
|
||||
} //end for each
|
||||
|
||||
unset($prep_statement, $sql, $result);
|
||||
return $db_menu_full;
|
||||
}
|
||||
|
||||
//create the sub menus
|
||||
function build_child_html($menu_item_level, $menu_item_uuid) {
|
||||
|
||||
$db = $this->db;
|
||||
$menu_item_level = $menu_item_level+1;
|
||||
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid ";
|
||||
$sql .= "from v_menu_items as i, v_menu_languages as l ";
|
||||
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
|
||||
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
|
||||
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_item_parent_uuid = '$menu_item_uuid' ";
|
||||
$sql .= "and i.menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by l.menu_item_title, i.menu_item_order asc ";
|
||||
$prep_statement_2 = $db->prepare($sql);
|
||||
$prep_statement_2->execute();
|
||||
$result_2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result_2) > 0) {
|
||||
//child menu found
|
||||
$db_menu_sub = "<ul class='menu_sub'>\n";
|
||||
|
||||
foreach($result_2 as $row) {
|
||||
$menu_item_link = $row['menu_item_link'];
|
||||
$menu_item_category = $row['menu_item_category'];
|
||||
$menu_item_uuid = $row['menu_item_uuid'];
|
||||
$menu_item_parent_uuid = $row['menu_item_parent_uuid'];
|
||||
|
||||
//prepare the protected menus
|
||||
if ($row['menu_item_protected'] == "true") {
|
||||
$menu_item_title = $row['menu_item_title'];
|
||||
}
|
||||
else {
|
||||
$menu_item_title = $row['menu_language_title'];
|
||||
}
|
||||
|
||||
//prepare the menu_tags according to the category
|
||||
switch ($menu_item_category) {
|
||||
case "internal":
|
||||
$menu_tags = "href='".PROJECT_PATH.$menu_item_link."'";
|
||||
break;
|
||||
case "external":
|
||||
if (substr($menu_item_link, 0,1) == "/") {
|
||||
$menu_item_link = PROJECT_PATH . $menu_item_link;
|
||||
}
|
||||
$menu_tags = "href='".$menu_item_link."' target='_blank'";
|
||||
break;
|
||||
case "email":
|
||||
$menu_tags = "href='mailto:".$menu_item_link."'";
|
||||
break;
|
||||
}
|
||||
|
||||
$db_menu_sub .= "<li>";
|
||||
|
||||
//get sub menu for children
|
||||
if (strlen($menu_item_uuid) > 0) {
|
||||
$str_child_menu = $this->build_child_html($menu_item_level, $menu_item_uuid);
|
||||
}
|
||||
|
||||
if (strlen($str_child_menu) > 1) {
|
||||
$db_menu_sub .= "<a ".$menu_tags.">".$menu_item_title."</a>";
|
||||
$db_menu_sub .= $str_child_menu;
|
||||
unset($str_child_menu);
|
||||
}
|
||||
else {
|
||||
$db_menu_sub .= "<a ".$menu_tags.">".$menu_item_title."</a>";
|
||||
}
|
||||
$db_menu_sub .= "</li>\n";
|
||||
}
|
||||
unset($sql, $result_2);
|
||||
$db_menu_sub .="</ul>\n";
|
||||
return $db_menu_sub;
|
||||
}
|
||||
unset($prep_statement_2, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
766
resources/classes/modules.php
Normal file
766
resources/classes/modules.php
Normal file
@@ -0,0 +1,766 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//add the database structure
|
||||
/*
|
||||
require_once "includes/classes/modules.php";
|
||||
$mod = new switch_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
|
||||
if ($mod->exists("mod_lua")) {
|
||||
echo "exists true\n";
|
||||
}
|
||||
else {
|
||||
echo "exists false\n";
|
||||
}
|
||||
//module active
|
||||
if ($mod->active("mod_lua")) {
|
||||
echo "active true\n";
|
||||
}
|
||||
else {
|
||||
echo "active false\n";
|
||||
}
|
||||
//synch
|
||||
$mod->synch();
|
||||
echo $mod->msg;
|
||||
//show module info
|
||||
$result = $mod->info("mod_lua");
|
||||
echo "<pre>\n";
|
||||
print_r($result);
|
||||
echo "</pre>\n";
|
||||
//list modules
|
||||
//$result = $mod->modules
|
||||
//echo "<pre>\n";
|
||||
//print_r($result);
|
||||
//echo "</pre>\n";
|
||||
*/
|
||||
|
||||
//define the directory class
|
||||
class switch_modules {
|
||||
public $db;
|
||||
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_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_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_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_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_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_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_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_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'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
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_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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
//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 .= "<li>".$mod['module_label']."</li>\n";
|
||||
//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_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 .= "'".$mod['module_enabled']."', ";
|
||||
$sql .= "'".$mod['module_default_enabled']."' ";
|
||||
$sql .= ")";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
if ($module_found) {
|
||||
//save_module_xml();
|
||||
$msg = "<strong>Added New Modules:</strong><br />\n";
|
||||
$msg .= "<ul>\n";
|
||||
$msg .= $modules_new;
|
||||
$msg .= "</ul>\n";
|
||||
$this->msg = $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //class
|
||||
|
||||
?>
|
||||
50
resources/classes/root.php
Normal file
50
resources/classes/root.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
// make sure the PATH_SEPARATOR is defined
|
||||
if (!defined("PATH_SEPARATOR")) {
|
||||
if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
|
||||
}
|
||||
|
||||
// make sure the document_root is set
|
||||
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
|
||||
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
|
||||
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
|
||||
//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
|
||||
//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
|
||||
|
||||
// if the project directory exists then add it to the include path otherwise add the document root to the include path
|
||||
if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
|
||||
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
|
||||
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
|
||||
}
|
||||
else {
|
||||
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
|
||||
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
|
||||
}
|
||||
|
||||
?>
|
||||
129
resources/classes/schema.php
Normal file
129
resources/classes/schema.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2013
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the schema class
|
||||
class schema {
|
||||
public $db;
|
||||
public $apps;
|
||||
public $db_type;
|
||||
public $result;
|
||||
|
||||
//get the list of installed apps from the core and mod directories
|
||||
public function __construct() {
|
||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
||||
$x=0;
|
||||
foreach ($config_list as &$config_path) {
|
||||
include($config_path);
|
||||
$x++;
|
||||
}
|
||||
$this->apps = $apps;
|
||||
}
|
||||
|
||||
//create the database schema
|
||||
public function sql() {
|
||||
$sql = '';
|
||||
$sql_schema = '';
|
||||
foreach ($this->apps as $app) {
|
||||
if (count($app['db'])) {
|
||||
foreach ($app['db'] as $row) {
|
||||
//create the sql string
|
||||
$table_name = $row['table'];
|
||||
$sql = "CREATE TABLE " . $row['table'] . " (\n";
|
||||
$field_count = 0;
|
||||
foreach ($row['fields'] as $field) {
|
||||
if ($field['deprecated'] == "true") {
|
||||
//skip this field
|
||||
}
|
||||
else {
|
||||
if ($field_count > 0 ) { $sql .= ",\n"; }
|
||||
if (is_array($field['name'])) {
|
||||
$sql .= $field['name']['text']." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $field['name']." ";
|
||||
}
|
||||
if (is_array($field['type'])) {
|
||||
$sql .= $field['type'][$this->db_type];
|
||||
}
|
||||
else {
|
||||
$sql .= $field['type'];
|
||||
}
|
||||
if ($field['key']['type'] == "primary") {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
if ($field['key']['type'] == "foreign") {
|
||||
if ($this->db_type == "pgsql") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
if ($this->db_type == "sqlite") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
if ($this->db_type == "mysql") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
}
|
||||
$field_count++;
|
||||
}
|
||||
}
|
||||
if ($this->db_type == "mysql") {
|
||||
$sql .= ") ENGINE=INNODB;";
|
||||
}
|
||||
else {
|
||||
$sql .= ");";
|
||||
}
|
||||
$this->result['sql'][] = $sql;
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create the database schema
|
||||
public function exec() {
|
||||
foreach ($this->result['sql'] as $sql) {
|
||||
//start the sql transaction
|
||||
$this->db->beginTransaction();
|
||||
//execute the sql query
|
||||
try {
|
||||
$this->db->query($sql);
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
echo "error: " . $error->getMessage() . " sql: $sql<br/>";
|
||||
}
|
||||
//complete the transaction
|
||||
$this->db->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//example use
|
||||
//require_once "resources/classes/schema.php";
|
||||
//$schema = new schema;
|
||||
//$schema->db_type = $db_type;
|
||||
//$schema->sql();
|
||||
//$result_array = $schema->result['sql'];
|
||||
//print_r($result_array);
|
||||
Reference in New Issue
Block a user