\r\n --> \n

Cause all the .php files containing lines ending with \r\n to instead end with \n.

DYI with:

find fusionpbx -type f -name '*.php' -exec dos2unix '{}' \;
This commit is contained in:
Harry G. Coin
2016-04-25 20:30:23 -05:00
parent 89e5ecbcdf
commit 91a92d8e5e
118 changed files with 40760 additions and 40760 deletions
+138 -138
View File
@@ -1,139 +1,139 @@
<?php
/**
* cache class provides an abstracted cache
*
* @method string set
* @method string get
* @method string delete
* @method string flush
*/
class cache {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Add a specific item in the cache
* @var string $key the cache id
* @var string $value string to be cached
*/
public function set($key, $value) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
//run the memcache
$command = "memcache set ".$key." ".$value;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Get a specific item from the cache
* @var string $key cache id
*/
public function get($key) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
//run the memcache
$command = "memcache get ".$key;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Delete a specific item from the cache
* @var string $key cache id
*/
public function delete($key) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: MEMCACHE\n";
$event .= "Event-Subclass: delete\n";
$event .= "API-Command: memcache\n";
$event .= "API-Command-Argument: delete ".$key."\n";
event_socket_request($fp, $event);
//run the memcache
$command = "memcache delete ".$key;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Delete the entire cache
*/
public function flush() {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: MEMCACHE\n";
$event .= "Event-Subclass: flush\n";
$event .= "API-Command: memcache\n";
$event .= "API-Command-Argument: flush\n";
event_socket_request($fp, $event);
//run the memcache
$command = "memcache flush";
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
}
<?php
/**
* cache class provides an abstracted cache
*
* @method string set
* @method string get
* @method string delete
* @method string flush
*/
class cache {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Add a specific item in the cache
* @var string $key the cache id
* @var string $value string to be cached
*/
public function set($key, $value) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
//run the memcache
$command = "memcache set ".$key." ".$value;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Get a specific item from the cache
* @var string $key cache id
*/
public function get($key) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
//run the memcache
$command = "memcache get ".$key;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Delete a specific item from the cache
* @var string $key cache id
*/
public function delete($key) {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: MEMCACHE\n";
$event .= "Event-Subclass: delete\n";
$event .= "API-Command: memcache\n";
$event .= "API-Command-Argument: delete ".$key."\n";
event_socket_request($fp, $event);
//run the memcache
$command = "memcache delete ".$key;
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
/**
* Delete the entire cache
*/
public function flush() {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
return false;
}
//send a custom event
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: MEMCACHE\n";
$event .= "Event-Subclass: flush\n";
$event .= "API-Command: memcache\n";
$event .= "API-Command-Argument: flush\n";
event_socket_request($fp, $event);
//run the memcache
$command = "memcache flush";
$result = event_socket_request($fp, 'api '.$command);
//close event socket
fclose($fp);
// return result
return $result;
}
}
?>
+126 -126
View File
@@ -1,127 +1,127 @@
<?php
/**
* config
*
* @method get config.php
* @method find find the path to the config.php file
* @method exists determin if the the config.php file exists
*/
class config {
/**
* database variables and config path
*/
public $db_type;
public $db_name;
public $db_username;
public $db_password;
public $db_host;
public $db_path;
public $db_port;
public $config_path;
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Determine whether the config.php exists
* @var string $db_type - type of database
* @var string $db_name - name of the database
* @var string $db_username - username to access the database
* @var string $db_password - password to access the database
* @var string $db_host - hostname of the database server
* @var string $db_path - path of the database file
* @var string $db_port - network port to connect to the database
*/
public function get() {
$this->find();
if ($this->exists()) {
require $this->config_path;
$this->db_type = $db_type;
$this->db_name = $db_name;
$this->db_username = $db_username;
$this->db_password = $db_password;
$this->db_host = $db_host;
$this->db_path = $db_path;
$this->db_port = $db_port;
}
}
/**
* Find the path to the config.php
* @var string $config_path - full path to the config.php file
*/
public function find() {
//get the PROJECT PATH
include "root.php";
// find the file
if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
$this->config_path = $_SERVER["PROJECT_ROOT"]."/resources/config.php";
} elseif (file_exists("/etc/fusionpbx/config.php")) {
$this->config_path = "/etc/fusionpbx/config.php";
} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
$this->config_path = "/usr/local/etc/fusionpbx/config.php";
}
else {
$this->config_path = '';
}
//return the path
return $this->config_path;
}
/**
* Determine whether the config.php exists
*/
public function exists() {
$this->find();
if (strlen($this->config_path) > 0) {
return true;
}
else {
return false;
}
}
}
/*
$config = new config;
$config_exists = $config->exists();
$config_path = $config->find();
$config->get();
$db_type = $config->db_type;
$db_name = $config->db_name;
$db_username = $config->db_username;
$db_password = $config->db_password;
$db_host = $config->db_host;
$db_path = $config->db_path;
$db_port = $config->db_port;
echo "config_path: ".$config_path."\n";
if ($config_exists) {
echo "config_exists: true\n";
} else {
echo "config_exists: false\n";
}
echo "db_type: ".$db_type."\n";
echo "db_name: ".$db_name."\n";
echo "db_username: ".$db_username."\n";
echo "db_password: ".$db_password."\n";
echo "db_host: ".$db_host."\n";
echo "db_path: ".$db_path."\n";
echo "db_port: ".$db_port."\n";
*/
<?php
/**
* config
*
* @method get config.php
* @method find find the path to the config.php file
* @method exists determin if the the config.php file exists
*/
class config {
/**
* database variables and config path
*/
public $db_type;
public $db_name;
public $db_username;
public $db_password;
public $db_host;
public $db_path;
public $db_port;
public $config_path;
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Determine whether the config.php exists
* @var string $db_type - type of database
* @var string $db_name - name of the database
* @var string $db_username - username to access the database
* @var string $db_password - password to access the database
* @var string $db_host - hostname of the database server
* @var string $db_path - path of the database file
* @var string $db_port - network port to connect to the database
*/
public function get() {
$this->find();
if ($this->exists()) {
require $this->config_path;
$this->db_type = $db_type;
$this->db_name = $db_name;
$this->db_username = $db_username;
$this->db_password = $db_password;
$this->db_host = $db_host;
$this->db_path = $db_path;
$this->db_port = $db_port;
}
}
/**
* Find the path to the config.php
* @var string $config_path - full path to the config.php file
*/
public function find() {
//get the PROJECT PATH
include "root.php";
// find the file
if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
$this->config_path = $_SERVER["PROJECT_ROOT"]."/resources/config.php";
} elseif (file_exists("/etc/fusionpbx/config.php")) {
$this->config_path = "/etc/fusionpbx/config.php";
} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
$this->config_path = "/usr/local/etc/fusionpbx/config.php";
}
else {
$this->config_path = '';
}
//return the path
return $this->config_path;
}
/**
* Determine whether the config.php exists
*/
public function exists() {
$this->find();
if (strlen($this->config_path) > 0) {
return true;
}
else {
return false;
}
}
}
/*
$config = new config;
$config_exists = $config->exists();
$config_path = $config->find();
$config->get();
$db_type = $config->db_type;
$db_name = $config->db_name;
$db_username = $config->db_username;
$db_password = $config->db_password;
$db_host = $config->db_host;
$db_path = $config->db_path;
$db_port = $config->db_port;
echo "config_path: ".$config_path."\n";
if ($config_exists) {
echo "config_exists: true\n";
} else {
echo "config_exists: false\n";
}
echo "db_type: ".$db_type."\n";
echo "db_name: ".$db_name."\n";
echo "db_username: ".$db_username."\n";
echo "db_password: ".$db_password."\n";
echo "db_host: ".$db_host."\n";
echo "db_path: ".$db_path."\n";
echo "db_port: ".$db_port."\n";
*/
?>
+280 -280
View File
@@ -1,280 +1,280 @@
<?php
/**
* destinations
*
* @method get_array get the destinations
* @method select build the html select
*/
class destinations {
/**
* destinations array
*/
public $destinations;
/**
* Called when the object is created
*/
public function __construct() {
//set the global variables
global $db, $db_type;
//get the array from the app_config.php files
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
$i = 0;
foreach ($apps as $x => &$app) {
if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) {
$this->destinations[] = $row;
}
}
//put the array in order
foreach ($this->destinations as $row) {
$option_groups[] = $row['label'];
}
array_multisort($option_groups, SORT_ASC, $this->destinations);
//add the sql and data to the array
$x = 0;
foreach ($this->destinations as $row) {
if ($row['type'] = 'sql') {
if (isset($row['sql'])) {
if (is_array($row['sql'])) {
$sql = trim($row['sql'][$db_type])." ";
}
else {
$sql = trim($row['sql'])." ";
}
}
else {
$field_count = count($row['field']);
$fields = '';
$c = 1;
foreach ($row['field'] as $key => $value) {
if ($field_count != $c) { $delimiter = ','; } else { $delimiter = ''; }
$fields .= $value." as ".$key.$delimiter." ";
$c++;
}
$sql = "select ".$fields;
$sql .= " from v_".$row['name']." ";
}
if (isset($row['where'])) {
$sql .= trim($row['where'])." ";
}
$sql .= "order by ".trim($row['order_by']);
$sql = str_replace("\${domain_uuid}", $_SESSION['domain_uuid'], $sql);
$sql = trim($sql);
$statement = $db->prepare($sql);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_NAMED);
unset($statement);
$this->destinations[$x]['result']['sql'] = $sql;
$this->destinations[$x]['result']['data'] = $result;
}
$x++;
}
$this->destinations[$x]['type'] = 'array';
$this->destinations[$x]['label'] = 'other';
$this->destinations[$x]['name'] = 'dialplan';
$this->destinations[$x]['field']['name'] = "name";
$this->destinations[$x]['field']['destination'] = "destination";
$this->destinations[$x]['select_value']['dialplan'] = "transfer:\${destination}";
$this->destinations[$x]['select_value']['ivr'] = "menu-exec-app:transfer \${destination}";
$this->destinations[$x]['select_label'] = "\${name}";
$y = 0;
$this->destinations[$x]['result']['data'][$y]['label'] = 'check_voicemail';
$this->destinations[$x]['result']['data'][$y]['name'] = '*98';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*98 XML ${context}';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'company_directory';
$this->destinations[$x]['result']['data'][$y]['name'] = '*411';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*411 XML ${context}';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['name'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['application'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['destination'] = '';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'record';
$this->destinations[$x]['result']['data'][$y]['name'] = '*732';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*732 XML ${context}';
$y++;
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Get the destination menu
* @var string $destination_type can be ivr, dialplan, call_center_contact or bridge
* @var string $destination_name - current name
* @var string $destination_value - current value
*/
public function select($destination_type, $destination_name, $destination_value) {
//remove special characters from the name
$destination_id = str_replace("]", "", $destination_name);
$destination_id = str_replace("[", "_", $destination_id);
//add additional
if (if_group("superadmin")) {
$response = "<script>\n";
$response .= "var Objs;\n";
$response .= "\n";
$response .= "function changeToInput".$destination_id."(obj){\n";
$response .= " tb=document.createElement('INPUT');\n";
$response .= " tb.type='text';\n";
$response .= " tb.name=obj.name;\n";
$response .= " tb.className='formfld';\n";
$response .= " tb.setAttribute('id', '".$destination_id."');\n";
$response .= " tb.setAttribute('style', '".$select_style."');\n";
if ($onchange != '') {
$response .= " tb.setAttribute('onchange', \"".$onchange."\");\n";
$response .= " tb.setAttribute('onkeyup', \"".$onchange."\");\n";
}
$response .= " tb.value=obj.options[obj.selectedIndex].value;\n";
$response .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'hidden';\n";
$response .= " tbb=document.createElement('INPUT');\n";
$response .= " tbb.setAttribute('class', 'btn');\n";
$response .= " tbb.setAttribute('style', 'margin-left: 4px;');\n";
$response .= " tbb.type='button';\n";
$response .= " tbb.value=$('<div />').html('&#9665;').text();\n";
$response .= " tbb.objs=[obj,tb,tbb];\n";
$response .= " tbb.onclick=function(){ Replace".$destination_id."(this.objs); }\n";
$response .= " obj.parentNode.insertBefore(tb,obj);\n";
$response .= " obj.parentNode.insertBefore(tbb,obj);\n";
$response .= " obj.parentNode.removeChild(obj);\n";
$response .= " Replace".$destination_id."(this.objs);\n";
$response .= "}\n";
$response .= "\n";
$response .= "function Replace".$destination_id."(obj){\n";
$response .= " obj[2].parentNode.insertBefore(obj[0],obj[2]);\n";
$response .= " obj[0].parentNode.removeChild(obj[1]);\n";
$response .= " obj[0].parentNode.removeChild(obj[2]);\n";
$response .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'visible';\n";
if ($onchange != '') {
$response .= " ".$onchange.";\n";
}
$response .= "}\n";
$response .= "</script>\n";
$response .= "\n";
}
//set default to false
$select_found = false;
$response .= " <select name='".$destination_name."' id='".$destination_id."' class='formfld' style='".$select_style."' onchange=\"".$onchange."\">\n";
$response .= " <option value=''></option>\n";
foreach ($this->destinations as $row) {
$name = $row['name'];
$label = $row['label'];
$destination = $row['field']['destination'];
//add multi-lingual support
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) {
$language2 = new text;
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name);
}
if (count($row['result']['data']) > 0 and strlen($row['select_value'][$destination_type]) > 0) {
$response .= " <optgroup label='".$text2['title-'.$label]."'>\n";
$label2 = $label;
foreach ($row['result']['data'] as $data) {
$select_value = $row['select_value'][$destination_type];
$select_label = $row['select_label'];
foreach ($row['field'] as $key => $value) {
if ($key == 'destination' and is_array($value)){
if ($value['type'] == 'csv') {
$array = explode($value['delimiter'], $data[$key]);
$select_value = str_replace("\${destination}", $array[0], $select_value);
$select_label = str_replace("\${destination}", $array[0], $select_label);
}
}
else {
if (strpos($value,',') !== false) {
$keys = explode(",", $value);
foreach ($keys as $k) {
if (strlen($data[$k]) > 0) {
$select_value = str_replace("\${".$key."}", $data[$k], $select_value);
if (strlen($data['label']) == 0) {
$select_label = str_replace("\${".$key."}", $data[$k], $select_label);
}
else {
$label = $data['label'];
$select_label = str_replace("\${".$key."}", $text2['option-'.$label], $select_label);
}
}
}
}
else {
$select_value = str_replace("\${".$key."}", $data[$key], $select_value);
if (strlen($data['label']) == 0) {
$select_label = str_replace("\${".$key."}", $data[$key], $select_label);
}
else {
$label = $data['label'];
$select_label = str_replace("\${".$key."}", $text2['option-'.$label], $select_label);
}
}
//application: hangup
if (strlen($data['application']) > 0) {
$select_value = str_replace("transfer", $data['application'], $select_value);
}
}
}
$select_value = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_value);
$select_value = str_replace("\${context}", $_SESSION['context'], $select_value); //to do: context can come from the array
$select_label = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_label);
$select_label = str_replace("\${context}", $_SESSION['context'], $select_label);
$select_label = trim($select_label);
if ($select_value == $destination_value) { $selected = "selected='selected' "; $select_found = true; } else { $selected = ''; }
if ($label2 == 'destinations') { $select_label = format_phone($select_label); }
$response .= " <option value='".$select_value."' ".$selected.">".$select_label."</option>\n";
}
$response .= " </optgroup>\n";
unset($text);
}
}
if (!$select_found) {
$destination_label = str_replace(":", " ", $destination_value);
$destination_label = str_replace("menu-exec-app:", " ", $destination_label);
$response .= " <option value='".$destination_value."' selected='selected'>".trim($destination_label)."</option>\n";
}
$response .= " </select>\n";
if (if_group("superadmin")) {
$response .= "<input type='button' id='btn_select_to_input_".$destination_id."' class='btn' name='' alt='back' onclick='changeToInput".$destination_id."(document.getElementById(\"".$destination_id."\"));this.style.visibility = \"hidden\";' value='&#9665;'>";
}
//return the formatted destinations
return $response;
}
}
/*
$obj = new destinations;
//$destinations = $obj->destinations;
echo $obj->select('ivr', 'example1', 'menu-exec-app:transfer 32 XML voip.fusionpbx.com');
echo $obj->select('ivr', 'example2', '');
echo $obj->select('ivr', 'example3', '');
echo $obj->select('ivr', 'example4', '');
echo $obj->select('ivr', 'example5', '');
echo $obj->select('ivr', 'example6', '');
*/
?>
<?php
/**
* destinations
*
* @method get_array get the destinations
* @method select build the html select
*/
class destinations {
/**
* destinations array
*/
public $destinations;
/**
* Called when the object is created
*/
public function __construct() {
//set the global variables
global $db, $db_type;
//get the array from the app_config.php files
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
$i = 0;
foreach ($apps as $x => &$app) {
if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) {
$this->destinations[] = $row;
}
}
//put the array in order
foreach ($this->destinations as $row) {
$option_groups[] = $row['label'];
}
array_multisort($option_groups, SORT_ASC, $this->destinations);
//add the sql and data to the array
$x = 0;
foreach ($this->destinations as $row) {
if ($row['type'] = 'sql') {
if (isset($row['sql'])) {
if (is_array($row['sql'])) {
$sql = trim($row['sql'][$db_type])." ";
}
else {
$sql = trim($row['sql'])." ";
}
}
else {
$field_count = count($row['field']);
$fields = '';
$c = 1;
foreach ($row['field'] as $key => $value) {
if ($field_count != $c) { $delimiter = ','; } else { $delimiter = ''; }
$fields .= $value." as ".$key.$delimiter." ";
$c++;
}
$sql = "select ".$fields;
$sql .= " from v_".$row['name']." ";
}
if (isset($row['where'])) {
$sql .= trim($row['where'])." ";
}
$sql .= "order by ".trim($row['order_by']);
$sql = str_replace("\${domain_uuid}", $_SESSION['domain_uuid'], $sql);
$sql = trim($sql);
$statement = $db->prepare($sql);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_NAMED);
unset($statement);
$this->destinations[$x]['result']['sql'] = $sql;
$this->destinations[$x]['result']['data'] = $result;
}
$x++;
}
$this->destinations[$x]['type'] = 'array';
$this->destinations[$x]['label'] = 'other';
$this->destinations[$x]['name'] = 'dialplan';
$this->destinations[$x]['field']['name'] = "name";
$this->destinations[$x]['field']['destination'] = "destination";
$this->destinations[$x]['select_value']['dialplan'] = "transfer:\${destination}";
$this->destinations[$x]['select_value']['ivr'] = "menu-exec-app:transfer \${destination}";
$this->destinations[$x]['select_label'] = "\${name}";
$y = 0;
$this->destinations[$x]['result']['data'][$y]['label'] = 'check_voicemail';
$this->destinations[$x]['result']['data'][$y]['name'] = '*98';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*98 XML ${context}';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'company_directory';
$this->destinations[$x]['result']['data'][$y]['name'] = '*411';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*411 XML ${context}';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['name'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['application'] = 'hangup';
$this->destinations[$x]['result']['data'][$y]['destination'] = '';
$y++;
$this->destinations[$x]['result']['data'][$y]['label'] = 'record';
$this->destinations[$x]['result']['data'][$y]['name'] = '*732';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*732 XML ${context}';
$y++;
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Get the destination menu
* @var string $destination_type can be ivr, dialplan, call_center_contact or bridge
* @var string $destination_name - current name
* @var string $destination_value - current value
*/
public function select($destination_type, $destination_name, $destination_value) {
//remove special characters from the name
$destination_id = str_replace("]", "", $destination_name);
$destination_id = str_replace("[", "_", $destination_id);
//add additional
if (if_group("superadmin")) {
$response = "<script>\n";
$response .= "var Objs;\n";
$response .= "\n";
$response .= "function changeToInput".$destination_id."(obj){\n";
$response .= " tb=document.createElement('INPUT');\n";
$response .= " tb.type='text';\n";
$response .= " tb.name=obj.name;\n";
$response .= " tb.className='formfld';\n";
$response .= " tb.setAttribute('id', '".$destination_id."');\n";
$response .= " tb.setAttribute('style', '".$select_style."');\n";
if ($onchange != '') {
$response .= " tb.setAttribute('onchange', \"".$onchange."\");\n";
$response .= " tb.setAttribute('onkeyup', \"".$onchange."\");\n";
}
$response .= " tb.value=obj.options[obj.selectedIndex].value;\n";
$response .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'hidden';\n";
$response .= " tbb=document.createElement('INPUT');\n";
$response .= " tbb.setAttribute('class', 'btn');\n";
$response .= " tbb.setAttribute('style', 'margin-left: 4px;');\n";
$response .= " tbb.type='button';\n";
$response .= " tbb.value=$('<div />').html('&#9665;').text();\n";
$response .= " tbb.objs=[obj,tb,tbb];\n";
$response .= " tbb.onclick=function(){ Replace".$destination_id."(this.objs); }\n";
$response .= " obj.parentNode.insertBefore(tb,obj);\n";
$response .= " obj.parentNode.insertBefore(tbb,obj);\n";
$response .= " obj.parentNode.removeChild(obj);\n";
$response .= " Replace".$destination_id."(this.objs);\n";
$response .= "}\n";
$response .= "\n";
$response .= "function Replace".$destination_id."(obj){\n";
$response .= " obj[2].parentNode.insertBefore(obj[0],obj[2]);\n";
$response .= " obj[0].parentNode.removeChild(obj[1]);\n";
$response .= " obj[0].parentNode.removeChild(obj[2]);\n";
$response .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'visible';\n";
if ($onchange != '') {
$response .= " ".$onchange.";\n";
}
$response .= "}\n";
$response .= "</script>\n";
$response .= "\n";
}
//set default to false
$select_found = false;
$response .= " <select name='".$destination_name."' id='".$destination_id."' class='formfld' style='".$select_style."' onchange=\"".$onchange."\">\n";
$response .= " <option value=''></option>\n";
foreach ($this->destinations as $row) {
$name = $row['name'];
$label = $row['label'];
$destination = $row['field']['destination'];
//add multi-lingual support
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) {
$language2 = new text;
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name);
}
if (count($row['result']['data']) > 0 and strlen($row['select_value'][$destination_type]) > 0) {
$response .= " <optgroup label='".$text2['title-'.$label]."'>\n";
$label2 = $label;
foreach ($row['result']['data'] as $data) {
$select_value = $row['select_value'][$destination_type];
$select_label = $row['select_label'];
foreach ($row['field'] as $key => $value) {
if ($key == 'destination' and is_array($value)){
if ($value['type'] == 'csv') {
$array = explode($value['delimiter'], $data[$key]);
$select_value = str_replace("\${destination}", $array[0], $select_value);
$select_label = str_replace("\${destination}", $array[0], $select_label);
}
}
else {
if (strpos($value,',') !== false) {
$keys = explode(",", $value);
foreach ($keys as $k) {
if (strlen($data[$k]) > 0) {
$select_value = str_replace("\${".$key."}", $data[$k], $select_value);
if (strlen($data['label']) == 0) {
$select_label = str_replace("\${".$key."}", $data[$k], $select_label);
}
else {
$label = $data['label'];
$select_label = str_replace("\${".$key."}", $text2['option-'.$label], $select_label);
}
}
}
}
else {
$select_value = str_replace("\${".$key."}", $data[$key], $select_value);
if (strlen($data['label']) == 0) {
$select_label = str_replace("\${".$key."}", $data[$key], $select_label);
}
else {
$label = $data['label'];
$select_label = str_replace("\${".$key."}", $text2['option-'.$label], $select_label);
}
}
//application: hangup
if (strlen($data['application']) > 0) {
$select_value = str_replace("transfer", $data['application'], $select_value);
}
}
}
$select_value = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_value);
$select_value = str_replace("\${context}", $_SESSION['context'], $select_value); //to do: context can come from the array
$select_label = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_label);
$select_label = str_replace("\${context}", $_SESSION['context'], $select_label);
$select_label = trim($select_label);
if ($select_value == $destination_value) { $selected = "selected='selected' "; $select_found = true; } else { $selected = ''; }
if ($label2 == 'destinations') { $select_label = format_phone($select_label); }
$response .= " <option value='".$select_value."' ".$selected.">".$select_label."</option>\n";
}
$response .= " </optgroup>\n";
unset($text);
}
}
if (!$select_found) {
$destination_label = str_replace(":", " ", $destination_value);
$destination_label = str_replace("menu-exec-app:", " ", $destination_label);
$response .= " <option value='".$destination_value."' selected='selected'>".trim($destination_label)."</option>\n";
}
$response .= " </select>\n";
if (if_group("superadmin")) {
$response .= "<input type='button' id='btn_select_to_input_".$destination_id."' class='btn' name='' alt='back' onclick='changeToInput".$destination_id."(document.getElementById(\"".$destination_id."\"));this.style.visibility = \"hidden\";' value='&#9665;'>";
}
//return the formatted destinations
return $response;
}
}
/*
$obj = new destinations;
//$destinations = $obj->destinations;
echo $obj->select('ivr', 'example1', 'menu-exec-app:transfer 32 XML voip.fusionpbx.com');
echo $obj->select('ivr', 'example2', '');
echo $obj->select('ivr', 'example3', '');
echo $obj->select('ivr', 'example4', '');
echo $obj->select('ivr', 'example5', '');
echo $obj->select('ivr', 'example6', '');
*/
?>
+195 -195
View File
@@ -1,195 +1,195 @@
<?php
class buffer {
private $content;
private $eol;
public function __construct() {
$this->content = '';
$this->eol = "\n";
}
public function append($str) {
$this->content .= $str;
}
public function read_line() {
$ar = explode($this->eol, $this->content, 2);
if (count($ar) != 2) {
return false;
}
$this->content = $ar[1];
return $ar[0];
}
public function read_n($n) {
if (strlen($this->content) < $n) {
return false;
}
$s = substr($this->content, 0, $n);
$this->content = substr($this->content, $n);
return $s;
}
public function read_all($n) {
$tmp = $this->content;
$this->content = '';
return $tmp;
}
}
//$b = new buffer;
//$b->append("hello\nworld\n");
//print($b->read_line());
//print($b->read_line());
class event_socket {
private $buffer;
private $fp;
public function __construct($fp = false) {
$this->buffer = new buffer;
$this->fp = $fp;
}
public function __destructor() {
$this->close();
}
public function read_event() {
if (!$this->fp) {
return false;
}
$b = $this->buffer;
$content_length = 0;
$content = Array();
while (true) {
while(($line = $b->read_line()) !== false ) {
if ($line == '') {
break 2;
}
$kv = explode(':', $line, 2);
$content[trim($kv[0])] = trim($kv[1]);
}
usleep(100);
if (feof($this->fp)) {
break;
}
$buffer = fgets($this->fp, 1024);
$b->append($buffer);
}
if (array_key_exists('Content-Length', $content)) {
$str = $b->read_n($content['Content-Length']);
if ($str === false) {
while (!feof($this->fp)) {
$buffer = fgets($this->fp, 1024);
$b->append($buffer);
$str = $b->read_n($content['Content-Length']);
if ($str !== false) {
break;
}
}
}
if ($str !== false) {
$content['$'] = $str;
}
}
return $content;
}
public function connect($host, $port, $password) {
$fp = fsockopen($host, $port, $errno, $errdesc, 3);
if (!$fp) {
return false;
}
socket_set_blocking($fp, false);
$this->fp = $fp;
// Wait auth request and send response
while (!feof($fp)) {
$event = $this->read_event();
if(@$event['Content-Type'] == 'auth/request'){
fputs($fp, "auth $password\n\n");
break;
}
}
// Wait auth response
while (!feof($fp)) {
$event = $this->read_event();
if (@$event['Content-Type'] == 'command/reply') {
if (@$event['Reply-Text'] == '+OK accepted') {
return $fp;
}
$this->fp = false;
fclose($fp);
return false;
}
}
return false;
}
public function request($cmd) {
if (!$this->fp) {
return false;
}
$cmd_array = explode("\n", $cmd);
foreach ($cmd_array as &$value) {
fputs($this->fp, $value."\n");
}
fputs($this->fp, "\n"); //second line feed to end the headers
$event = $this->read_event();
if (array_key_exists('$', $event)) {
return $event['$'];
}
return $event;
}
public function reset_fp($fp = false){
$tmp = $this->fp;
$this->fp = $fp;
return $tmp;
}
public function close() {
if ($this->fp) {
fclose($fp->fp);
$this->fp = false;
}
}
}
/*
function event_socket_create($host, $port, $password) {
$esl = new event_socket;
if ($esl->connect($host, $port, $password)) {
return $esl->reset_fp();
}
return false;
}
function event_socket_request($fp, $cmd) {
$esl = new event_socket($fp);
$result = $esl->request($cmd);
$esl->reset_fp();
return $result;
}
*/
// $esl = new event_socket;
// $esl->connect('127.0.0.1', 8021, 'ClueCon');
// print($esl->request('api sofia status'));
// $fp = event_socket_create('127.0.0.1', 8021, 'ClueCon');
// print(event_socket_request($fp, 'api sofia status'));
<?php
class buffer {
private $content;
private $eol;
public function __construct() {
$this->content = '';
$this->eol = "\n";
}
public function append($str) {
$this->content .= $str;
}
public function read_line() {
$ar = explode($this->eol, $this->content, 2);
if (count($ar) != 2) {
return false;
}
$this->content = $ar[1];
return $ar[0];
}
public function read_n($n) {
if (strlen($this->content) < $n) {
return false;
}
$s = substr($this->content, 0, $n);
$this->content = substr($this->content, $n);
return $s;
}
public function read_all($n) {
$tmp = $this->content;
$this->content = '';
return $tmp;
}
}
//$b = new buffer;
//$b->append("hello\nworld\n");
//print($b->read_line());
//print($b->read_line());
class event_socket {
private $buffer;
private $fp;
public function __construct($fp = false) {
$this->buffer = new buffer;
$this->fp = $fp;
}
public function __destructor() {
$this->close();
}
public function read_event() {
if (!$this->fp) {
return false;
}
$b = $this->buffer;
$content_length = 0;
$content = Array();
while (true) {
while(($line = $b->read_line()) !== false ) {
if ($line == '') {
break 2;
}
$kv = explode(':', $line, 2);
$content[trim($kv[0])] = trim($kv[1]);
}
usleep(100);
if (feof($this->fp)) {
break;
}
$buffer = fgets($this->fp, 1024);
$b->append($buffer);
}
if (array_key_exists('Content-Length', $content)) {
$str = $b->read_n($content['Content-Length']);
if ($str === false) {
while (!feof($this->fp)) {
$buffer = fgets($this->fp, 1024);
$b->append($buffer);
$str = $b->read_n($content['Content-Length']);
if ($str !== false) {
break;
}
}
}
if ($str !== false) {
$content['$'] = $str;
}
}
return $content;
}
public function connect($host, $port, $password) {
$fp = fsockopen($host, $port, $errno, $errdesc, 3);
if (!$fp) {
return false;
}
socket_set_blocking($fp, false);
$this->fp = $fp;
// Wait auth request and send response
while (!feof($fp)) {
$event = $this->read_event();
if(@$event['Content-Type'] == 'auth/request'){
fputs($fp, "auth $password\n\n");
break;
}
}
// Wait auth response
while (!feof($fp)) {
$event = $this->read_event();
if (@$event['Content-Type'] == 'command/reply') {
if (@$event['Reply-Text'] == '+OK accepted') {
return $fp;
}
$this->fp = false;
fclose($fp);
return false;
}
}
return false;
}
public function request($cmd) {
if (!$this->fp) {
return false;
}
$cmd_array = explode("\n", $cmd);
foreach ($cmd_array as &$value) {
fputs($this->fp, $value."\n");
}
fputs($this->fp, "\n"); //second line feed to end the headers
$event = $this->read_event();
if (array_key_exists('$', $event)) {
return $event['$'];
}
return $event;
}
public function reset_fp($fp = false){
$tmp = $this->fp;
$this->fp = $fp;
return $tmp;
}
public function close() {
if ($this->fp) {
fclose($fp->fp);
$this->fp = false;
}
}
}
/*
function event_socket_create($host, $port, $password) {
$esl = new event_socket;
if ($esl->connect($host, $port, $password)) {
return $esl->reset_fp();
}
return false;
}
function event_socket_request($fp, $cmd) {
$esl = new event_socket($fp);
$result = $esl->request($cmd);
$esl->reset_fp();
return $result;
}
*/
// $esl = new event_socket;
// $esl->connect('127.0.0.1', 8021, 'ClueCon');
// print($esl->request('api sofia status'));
// $fp = event_socket_create('127.0.0.1', 8021, 'ClueCon');
// print(event_socket_request($fp, 'api sofia status'));
+190 -190
View File
@@ -1,191 +1,191 @@
<?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) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* groups class provides methods for add, delete groups, and add default groups
*
* @method string add
* @method boolean delete
* @method boolean defaults
*/
if (!class_exists('groups')) {
class groups {
public $db;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database if not connected
if (!$this->db) {
require_once "resources/classes/database.php";
$database = new database;
$database->connect();
$this->db = $database->db;
}
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* add a group
*/
public function add() {
$id = uuid();
//return $id;
return false;
}
/**
* delete a group
*/
public function delete($id) {
return false;
}
/**
* add defaults groups
*/
public function defaults() {
//if the are no groups add the default groups
$sql = "SELECT * FROM v_groups ";
$sql .= "WHERE domain_uuid is null ";
$result = $this->db->query($sql)->fetch();
$prep_statement = $this->db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) == 0) {
$x = 0;
$tmp[$x]['group_name'] = 'superadmin';
$tmp[$x]['group_description'] = 'Super Administrator Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'admin';
$tmp[$x]['group_description'] = 'Administrator Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'user';
$tmp[$x]['group_description'] = 'User Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'public';
$tmp[$x]['group_description'] = 'Public Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'agent';
$tmp[$x]['group_description'] = 'Call Center Agent Group';
$tmp[$x]['group_protected'] = 'false';
$this->db->beginTransaction();
foreach($tmp as $row) {
if (strlen($row['group_name']) > 0) {
$sql = "insert into v_groups ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "group_uuid, ";
$sql .= "group_name, ";
$sql .= "group_description, ";
$sql .= "group_protected ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "null, ";
$sql .= "'".uuid()."', ";
$sql .= "'".$row['group_name']."', ";
$sql .= "'".$row['group_description']."', ";
$sql .= "'".$row['group_protected']."' ";
$sql .= ")";
$this->db->exec($sql);
unset($sql);
}
}
$this->db->commit();
}
unset($prep_statement, $result);
}
//if there are no permissions listed in v_group_permissions then set the default permissions
$sql = "select count(*) as count from v_group_permissions ";
$sql .= "where domain_uuid is null ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset ($prep_statement);
if ($result['count'] == 0) {
//build the apps array
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
//no permissions found add the defaults
$this->db->beginTransaction();
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
foreach ($row['groups'] as $group) {
//add the record
$sql = "insert into v_group_permissions ";
$sql .= "(";
$sql .= "group_permission_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "null, ";
$sql .= "'".$row['name']."', ";
$sql .= "'".$group."' ";
$sql .= ")";
$this->db->exec($sql);
unset($sql);
}
}
}
$this->db->commit();
}
}
} //end scripts class
}
/*
//example use
$group = new groups;
$group->defaults();
*/
<?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) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* groups class provides methods for add, delete groups, and add default groups
*
* @method string add
* @method boolean delete
* @method boolean defaults
*/
if (!class_exists('groups')) {
class groups {
public $db;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database if not connected
if (!$this->db) {
require_once "resources/classes/database.php";
$database = new database;
$database->connect();
$this->db = $database->db;
}
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* add a group
*/
public function add() {
$id = uuid();
//return $id;
return false;
}
/**
* delete a group
*/
public function delete($id) {
return false;
}
/**
* add defaults groups
*/
public function defaults() {
//if the are no groups add the default groups
$sql = "SELECT * FROM v_groups ";
$sql .= "WHERE domain_uuid is null ";
$result = $this->db->query($sql)->fetch();
$prep_statement = $this->db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) == 0) {
$x = 0;
$tmp[$x]['group_name'] = 'superadmin';
$tmp[$x]['group_description'] = 'Super Administrator Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'admin';
$tmp[$x]['group_description'] = 'Administrator Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'user';
$tmp[$x]['group_description'] = 'User Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'public';
$tmp[$x]['group_description'] = 'Public Group';
$tmp[$x]['group_protected'] = 'false';
$x++;
$tmp[$x]['group_name'] = 'agent';
$tmp[$x]['group_description'] = 'Call Center Agent Group';
$tmp[$x]['group_protected'] = 'false';
$this->db->beginTransaction();
foreach($tmp as $row) {
if (strlen($row['group_name']) > 0) {
$sql = "insert into v_groups ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "group_uuid, ";
$sql .= "group_name, ";
$sql .= "group_description, ";
$sql .= "group_protected ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "null, ";
$sql .= "'".uuid()."', ";
$sql .= "'".$row['group_name']."', ";
$sql .= "'".$row['group_description']."', ";
$sql .= "'".$row['group_protected']."' ";
$sql .= ")";
$this->db->exec($sql);
unset($sql);
}
}
$this->db->commit();
}
unset($prep_statement, $result);
}
//if there are no permissions listed in v_group_permissions then set the default permissions
$sql = "select count(*) as count from v_group_permissions ";
$sql .= "where domain_uuid is null ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset ($prep_statement);
if ($result['count'] == 0) {
//build the apps array
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
//no permissions found add the defaults
$this->db->beginTransaction();
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
foreach ($row['groups'] as $group) {
//add the record
$sql = "insert into v_group_permissions ";
$sql .= "(";
$sql .= "group_permission_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "null, ";
$sql .= "'".$row['name']."', ";
$sql .= "'".$group."' ";
$sql .= ")";
$this->db->exec($sql);
unset($sql);
}
}
}
$this->db->commit();
}
}
} //end scripts class
}
/*
//example use
$group = new groups;
$group->defaults();
*/
?>
+104 -104
View File
@@ -1,105 +1,105 @@
<?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) 2015 All Rights Reserved.
*/
/**
* permission class
*
* @method string add
* @method string delete
* @method string exists
*/
if (!class_exists('permissions')) {
class permissions {
/**
* Add a permission
* @var string $permission
*/
public function add($permission, $type = '') {
if (!$this->exists($permission)) {
//set the ordinal number
$i = count($_SESSION["permissions"])+1;
//set the permission
$_SESSION["permissions"][$i]["permission_name"] = $permission;
$_SESSION["permissions"][$i]["permission_type"] = "temp";
}
}
/**
* Remove the permission
* @var string $permission
*/
public function delete($permission, $type = '') {
if ($this->exists($permission)) {
foreach($_SESSION["permissions"] as $key => $row) {
if ($row['permission_name'] == $permission) {
if ($row['permission_name'] == $permission) {
if ($type == 'temp') {
if ($row['permission_type'] == "temp") {
unset($_SESSION["permissions"][$key]);
}
}
else {
unset($_SESSION["permissions"][$key]);
}
}
break;
}
}
}
}
/**
* Check to see if the permission exists
* @var string $permission
*/
function exists($permission) {
//set default false
$result = false;
//search for the permission
if (count($_SESSION["permissions"]) > 0) {
foreach($_SESSION["permissions"] as $row) {
if ($row['permission_name'] == $permission) {
$result = true;
break;
}
}
}
//return the result
return $result;
}
}
}
//examples
/*
//add the permission
$p = new permissions;
$p->add($permission);
//delete the permission
$p = new permissions;
$p->delete($permission);
*/
<?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) 2015 All Rights Reserved.
*/
/**
* permission class
*
* @method string add
* @method string delete
* @method string exists
*/
if (!class_exists('permissions')) {
class permissions {
/**
* Add a permission
* @var string $permission
*/
public function add($permission, $type = '') {
if (!$this->exists($permission)) {
//set the ordinal number
$i = count($_SESSION["permissions"])+1;
//set the permission
$_SESSION["permissions"][$i]["permission_name"] = $permission;
$_SESSION["permissions"][$i]["permission_type"] = "temp";
}
}
/**
* Remove the permission
* @var string $permission
*/
public function delete($permission, $type = '') {
if ($this->exists($permission)) {
foreach($_SESSION["permissions"] as $key => $row) {
if ($row['permission_name'] == $permission) {
if ($row['permission_name'] == $permission) {
if ($type == 'temp') {
if ($row['permission_type'] == "temp") {
unset($_SESSION["permissions"][$key]);
}
}
else {
unset($_SESSION["permissions"][$key]);
}
}
break;
}
}
}
}
/**
* Check to see if the permission exists
* @var string $permission
*/
function exists($permission) {
//set default false
$result = false;
//search for the permission
if (count($_SESSION["permissions"]) > 0) {
foreach($_SESSION["permissions"] as $row) {
if ($row['permission_name'] == $permission) {
$result = true;
break;
}
}
}
//return the result
return $result;
}
}
}
//examples
/*
//add the permission
$p = new permissions;
$p->add($permission);
//delete the permission
$p = new permissions;
$p->delete($permission);
*/
?>
+286 -286
View File
@@ -1,286 +1,286 @@
<?php
/**
* switch_settings class provides access methods related to FreeSWITCH
*
* @method settings will add missing switch directories to default settings
*/
if (!class_exists('switch_settings')) {
class switch_settings {
public $db;
public $event_socket_ip_address;
public $event_socket_port;
public $event_socket_password;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database if not connected
if (!$this->db) {
require_once "resources/classes/database.php";
$database = new database;
$database->connect();
$this->db = $database->db;
}
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* settings Set switch directories in default settings
*/
public function settings() {
//define the variables
if (!isset($this->event_socket_ip_address)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_ip_address = $_SESSION['event_socket_ip_address'];
}
else {
$this->event_socket_ip_address = '127.0.0.1';
}
}
if (!isset($this->event_socket_port)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_port = $_SESSION['event_socket_port'];
}
else {
$this->event_socket_port = '8021';
}
}
if (!isset($this->event_socket_password)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_password = $_SESSION['event_socket_password'];
}
else {
$this->event_socket_password = 'ClueCon';
}
}
{ //connect to event socket
$esl = new event_socket;
$esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password);
//run the api command
$result = $esl->request('api global_getvar');
} //close event socket
//set the result as a named array
$vars = array();
foreach (explode("\n", $result) as $row) {
$a = explode("=", $row);
if (substr($a[0], -4) == "_dir") {
$vars[$a[0]] = $a[1];
}
}
//set the bin directory
if ($vars['base_dir'] == "/usr/local/freeswitch") {
$bin = "/usr/local/freeswitch/bin";
} else {
$bin = "";
}
//create the default settings array
$x=0;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'bin';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $bin;
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'base';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['base_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'call_center';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/autoload_configs';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'conf';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'db';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['db_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'dialplan';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/dialplan';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'extensions';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/directory';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'grammar';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['grammar_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'log';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['log_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'mod';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['mod_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'phrases';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/lang';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'recordings';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['recordings_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'scripts';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['script_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'sip_profiles';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/sip_profiles';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'sounds';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['sounds_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'storage';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['storage_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'voicemail';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['storage_dir'].'/voicemail';
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
//get an array of the default settings
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_category = 'switch' ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//find the missing default settings
$x = 0;
foreach ($array as $setting) {
$found = false;
$missing[$x] = $setting;
foreach ($default_settings as $row) {
if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) {
$found = true;
//remove items from the array that were found
unset($missing[$x]);
}
}
$x++;
}
//add the missing default settings
if (is_array($missing)) {
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if (sizeof($missing) != $i) {
$sql .= ",\n";
}
$i++;
}
$this->db->exec(check_sql($sql));
unset($missing);
}
//set the default settings
foreach ($array as $row) {
if (!isset($_SESSION['switch'][$row['default_setting_subcategory']])) {
if ($row['default_setting_enabled'] != "false") {
$_SESSION['switch'][$row['default_setting_subcategory']] = $row['default_setting_value'];
}
}
}
//unset the array variable
unset($array);
}
}
}
?>
<?php
/**
* switch_settings class provides access methods related to FreeSWITCH
*
* @method settings will add missing switch directories to default settings
*/
if (!class_exists('switch_settings')) {
class switch_settings {
public $db;
public $event_socket_ip_address;
public $event_socket_port;
public $event_socket_password;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database if not connected
if (!$this->db) {
require_once "resources/classes/database.php";
$database = new database;
$database->connect();
$this->db = $database->db;
}
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* settings Set switch directories in default settings
*/
public function settings() {
//define the variables
if (!isset($this->event_socket_ip_address)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_ip_address = $_SESSION['event_socket_ip_address'];
}
else {
$this->event_socket_ip_address = '127.0.0.1';
}
}
if (!isset($this->event_socket_port)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_port = $_SESSION['event_socket_port'];
}
else {
$this->event_socket_port = '8021';
}
}
if (!isset($this->event_socket_password)) {
if (strlen($_SESSION['event_socket_ip_address']) > 0) {
$this->event_socket_password = $_SESSION['event_socket_password'];
}
else {
$this->event_socket_password = 'ClueCon';
}
}
{ //connect to event socket
$esl = new event_socket;
$esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password);
//run the api command
$result = $esl->request('api global_getvar');
} //close event socket
//set the result as a named array
$vars = array();
foreach (explode("\n", $result) as $row) {
$a = explode("=", $row);
if (substr($a[0], -4) == "_dir") {
$vars[$a[0]] = $a[1];
}
}
//set the bin directory
if ($vars['base_dir'] == "/usr/local/freeswitch") {
$bin = "/usr/local/freeswitch/bin";
} else {
$bin = "";
}
//create the default settings array
$x=0;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'bin';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $bin;
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'base';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['base_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'call_center';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/autoload_configs';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'conf';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'db';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['db_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'dialplan';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/dialplan';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'extensions';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/directory';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'grammar';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['grammar_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'log';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['log_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'mod';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['mod_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'phrases';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/lang';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'recordings';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['recordings_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'scripts';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['script_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'sip_profiles';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['conf_dir'].'/sip_profiles';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'sounds';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['sounds_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'storage';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['storage_dir'];
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'switch';
$array[$x]['default_setting_subcategory'] = 'voicemail';
$array[$x]['default_setting_name'] = 'dir';
$array[$x]['default_setting_value'] = $vars['storage_dir'].'/voicemail';
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = '';
$x++;
//get an array of the default settings
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_category = 'switch' ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//find the missing default settings
$x = 0;
foreach ($array as $setting) {
$found = false;
$missing[$x] = $setting;
foreach ($default_settings as $row) {
if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) {
$found = true;
//remove items from the array that were found
unset($missing[$x]);
}
}
$x++;
}
//add the missing default settings
if (is_array($missing)) {
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if (sizeof($missing) != $i) {
$sql .= ",\n";
}
$i++;
}
$this->db->exec(check_sql($sql));
unset($missing);
}
//set the default settings
foreach ($array as $row) {
if (!isset($_SESSION['switch'][$row['default_setting_subcategory']])) {
if ($row['default_setting_enabled'] != "false") {
$_SESSION['switch'][$row['default_setting_subcategory']] = $row['default_setting_value'];
}
}
}
//unset the array variable
unset($array);
}
}
}
?>
+101 -101
View File
@@ -1,101 +1,101 @@
<?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 template class
if (!class_exists('template')) {
class template {
public $engine;
public $template_dir;
public $cache_dir;
private $object;
private $var_array;
public function __construct(){
}
public function init() {
if ($this->engine === 'smarty') {
require_once "resources/templates/engine/smarty/Smarty.class.php";
$this->object = new Smarty();
$this->object->setTemplateDir($this->template_dir);
$this->object->setCompileDir($this->cache_dir);
$this->object->setCacheDir($this->cache_dir);
}
if ($this->engine === 'raintpl') {
require_once "resources/templates/engine/raintpl/rain.tpl.class.php";
$this->object = new RainTPL();
RainTPL::configure('tpl_dir', realpath($this->template_dir)."/");
RainTPL::configure('cache_dir', realpath($this->cache_dir)."/");
}
if ($this->engine === 'twig') {
require_once "resources/templates/engine/Twig/Autoloader.php";
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem($this->template_dir);
$this->object = new Twig_Environment($loader);
$lexer = new Twig_Lexer($this->object, array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}'),
));
$this->object->setLexer($lexer);
}
}
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
public function assign($key, $value) {
if ($this->engine === 'smarty') {
$this->object->assign($key, $value);
}
if ($this->engine === 'raintpl') {
$this->object->assign($key, $value);
}
if ($this->engine === 'twig') {
$this->var_array[$key] = $value;
}
}
public function render($name) {
if ($this->engine === 'smarty') {
return $this->object->fetch($name);
}
if ($this->engine === 'raintpl') {
return $this->object-> draw($name, 'return_string=true');
}
if ($this->engine === 'twig') {
return $this->object->render($name,$this->var_array);
}
}
}
}
?>
<?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 template class
if (!class_exists('template')) {
class template {
public $engine;
public $template_dir;
public $cache_dir;
private $object;
private $var_array;
public function __construct(){
}
public function init() {
if ($this->engine === 'smarty') {
require_once "resources/templates/engine/smarty/Smarty.class.php";
$this->object = new Smarty();
$this->object->setTemplateDir($this->template_dir);
$this->object->setCompileDir($this->cache_dir);
$this->object->setCacheDir($this->cache_dir);
}
if ($this->engine === 'raintpl') {
require_once "resources/templates/engine/raintpl/rain.tpl.class.php";
$this->object = new RainTPL();
RainTPL::configure('tpl_dir', realpath($this->template_dir)."/");
RainTPL::configure('cache_dir', realpath($this->cache_dir)."/");
}
if ($this->engine === 'twig') {
require_once "resources/templates/engine/Twig/Autoloader.php";
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem($this->template_dir);
$this->object = new Twig_Environment($loader);
$lexer = new Twig_Lexer($this->object, array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}'),
));
$this->object->setLexer($lexer);
}
}
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
public function assign($key, $value) {
if ($this->engine === 'smarty') {
$this->object->assign($key, $value);
}
if ($this->engine === 'raintpl') {
$this->object->assign($key, $value);
}
if ($this->engine === 'twig') {
$this->var_array[$key] = $value;
}
}
public function render($name) {
if ($this->engine === 'smarty') {
return $this->object->fetch($name);
}
if ($this->engine === 'raintpl') {
return $this->object-> draw($name, 'return_string=true');
}
if ($this->engine === 'twig') {
return $this->object->render($name,$this->var_array);
}
}
}
}
?>
+82 -82
View File
@@ -1,83 +1,83 @@
<?php
/**
* Get the text for the correct translation
*
* @method array get
*/
class text {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Get a specific item from the cache
* @var string $language_code examples: en-us, es-cl, fr-fr, pt-pt
* @var string $app_path examples: app/exec or core/domains
*/
public function get($language_code = null, $app_path = null, $exclude_global = false) {
//get the global app_languages.php
if (!$exclude_global){
include $_SERVER["PROJECT_ROOT"]."/resources/app_languages.php";
}
//get the app_languages.php
if ($app_path != null) {
$lang_path = $_SERVER["PROJECT_ROOT"]."/".$app_path."/app_languages.php";
}
else {
$lang_path = getcwd().'/app_languages.php';
}
if(file_exists($lang_path)){
require $lang_path;
}
//get the available languages
krsort($text);
foreach ($text as $lang_label => $lang_codes) {
foreach ($lang_codes as $lang_code => $lang_text) {
if ($lang_text != '') {
$app_languages[] = $lang_code;
}
}
}
$_SESSION['app']['languages'] = array_unique($app_languages);
//check the session language
if (isset($_SESSION['domain']) and $language_code == null){
$language_code = $_SESSION['domain']['language']['code'];
} elseif ($language_code == null){
$language_code = 'en-us';
}
//reduce to specific language
if ($language_code != 'all') {
foreach ($text as $key => $value) {
if (strlen($value[$language_code]) > 0) {
$text[$key] = $value[$language_code];
} else {
//fallback to en-us
$text[$key] = $value['en-us'];
}
}
}
//return the array of translations
return $text;
}
}
<?php
/**
* Get the text for the correct translation
*
* @method array get
*/
class text {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* Get a specific item from the cache
* @var string $language_code examples: en-us, es-cl, fr-fr, pt-pt
* @var string $app_path examples: app/exec or core/domains
*/
public function get($language_code = null, $app_path = null, $exclude_global = false) {
//get the global app_languages.php
if (!$exclude_global){
include $_SERVER["PROJECT_ROOT"]."/resources/app_languages.php";
}
//get the app_languages.php
if ($app_path != null) {
$lang_path = $_SERVER["PROJECT_ROOT"]."/".$app_path."/app_languages.php";
}
else {
$lang_path = getcwd().'/app_languages.php';
}
if(file_exists($lang_path)){
require $lang_path;
}
//get the available languages
krsort($text);
foreach ($text as $lang_label => $lang_codes) {
foreach ($lang_codes as $lang_code => $lang_text) {
if ($lang_text != '') {
$app_languages[] = $lang_code;
}
}
}
$_SESSION['app']['languages'] = array_unique($app_languages);
//check the session language
if (isset($_SESSION['domain']) and $language_code == null){
$language_code = $_SESSION['domain']['language']['code'];
} elseif ($language_code == null){
$language_code = 'en-us';
}
//reduce to specific language
if ($language_code != 'all') {
foreach ($text as $key => $value) {
if (strlen($value[$language_code]) > 0) {
$text[$key] = $value[$language_code];
} else {
//fallback to en-us
$text[$key] = $value['en-us'];
}
}
}
//return the array of translations
return $text;
}
}
?>
+76 -76
View File
@@ -1,77 +1,77 @@
<?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) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* users class provides methods for adding and removing users
*
* @method string add
* @method boolean delete
*/
if (!class_exists('users')) {
class users {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* add a user
*/
public function add($username, $password) {
$id = uuid();
//return $id;
return false;
}
/**
* delete a user
*/
public function delete($id) {
return false;
}
} //end scripts class
}
/*
//example use
$user = new users;
$user->add($username, $password);
*/
<?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) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* users class provides methods for adding and removing users
*
* @method string add
* @method boolean delete
*/
if (!class_exists('users')) {
class users {
/**
* Called when the object is created
*/
public function __construct() {
//place holder
}
/**
* Called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* add a user
*/
public function add($username, $password) {
$id = uuid();
//return $id;
return false;
}
/**
* delete a user
*/
public function delete($id) {
return false;
}
} //end scripts class
}
/*
//example use
$user = new users;
$user->add($username, $password);
*/
?>