Fix multiple PHP warnings

This commit is contained in:
markjcrane
2025-11-01 19:58:21 -06:00
parent a675660473
commit bf5bb4f642
41 changed files with 539 additions and 442 deletions
@@ -216,7 +216,7 @@
//primary table //primary table
$sql = "select * from v_" . $this->table . " "; $sql = "select * from v_" . $this->table . " ";
$sql .= "where " . $this->uuid_prefix . "uuid in (" . implode(', ', $uuids) . ") "; $sql .= "where " . $this->uuid_prefix . "uuid in (" . implode(', ', $uuids) . ") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
@@ -51,6 +51,9 @@
public $queue_description; public $queue_description;
public $destination_number; public $destination_number;
public $queue_cc_exit_keys; public $queue_cc_exit_keys;
public $queue_cid_prefix;
public $queue_greeting;
public $queue_timeout_action;
/** /**
* Set in the constructor. Must be a database object and cannot be null. * Set in the constructor. Must be a database object and cannot be null.
@@ -526,7 +529,7 @@
//primary table //primary table
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') "; $sql .= "where ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
@@ -84,6 +84,8 @@
private $extension; private $extension;
private $number_alias; private $number_alias;
private $toll_allow; private $toll_allow;
private $toggle_field;
private $toggle_values;
/** /**
* called when the object is created * called when the object is created
@@ -156,6 +158,10 @@
*/ */
public function toggle(array $records) { public function toggle(array $records) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) { if (!$token->validate($_SERVER['PHP_SELF'])) {
@@ -170,14 +176,10 @@
//check we have permission for this action //check we have permission for this action
if (permission_exists('call_forward')) { if (permission_exists('call_forward')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
// initialize an empty array // initialize an empty array
$uuids = []; $uuids = [];
$extensions = []; $extensions = [];
//get current toggle state //get current toggle state
foreach ($records as $x => $record) { foreach ($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
@@ -262,7 +264,7 @@
$p->delete('extension_edit', 'temp'); $p->delete('extension_edit', 'temp');
//send feature event notify to the phone //send feature event notify to the phone
if ($settings->get('device', 'feature_sync', false)) { if ($this->settings->get('device', 'feature_sync', false)) {
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$feature_event_notify = new feature_event_notify; $feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $this->domain_name; $feature_event_notify->domain_name = $this->domain_name;
@@ -51,6 +51,7 @@
public $debug; public $debug;
public $extension_uuid; public $extension_uuid;
public $extension; public $extension;
public $number_alias;
public $enabled; public $enabled;
/** /**
@@ -110,7 +111,7 @@
$user_status = "Logged Out"; $user_status = "Logged Out";
$esl = event_socket::create(); $esl = event_socket::create();
if ($esl->is_connected()) { if ($esl->is_connected()) {
$switch_cmd .= "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'"; $switch_cmd = "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'";
$esl->request('api '.$switch_cmd); $esl->request('api '.$switch_cmd);
} }
@@ -430,7 +430,7 @@
$p->delete('follow_me_edit', 'temp'); $p->delete('follow_me_edit', 'temp');
//send feature event notify to the phone //send feature event notify to the phone
if ($settings->get('device', 'feature_sync', false)) { if ($this->settings->get('device', 'feature_sync', false)) {
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$feature_event_notify = new feature_event_notify; $feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $this->domain_name; $feature_event_notify->domain_name = $this->domain_name;
@@ -335,6 +335,7 @@
$call_recording_time = $row['call_recording_time']; $call_recording_time = $row['call_recording_time'];
$call_recording_date_formatted = $row['call_recording_date_formatted']; $call_recording_date_formatted = $row['call_recording_date_formatted'];
$call_recording_time_formatted = $row['call_recording_time_formatted']; $call_recording_time_formatted = $row['call_recording_time_formatted'];
$call_recording_base64 = $row['call_recording_base64'];
if (!empty($storage_type) && $storage_type == 'base64' && !empty($row['call_recording_base64'])) { if (!empty($storage_type) && $storage_type == 'base64' && !empty($row['call_recording_base64'])) {
file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64'])); file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64']));
} }
@@ -398,7 +399,7 @@
} }
//if base64, remove temp recording file //if base64, remove temp recording file
if (!empty($storage_type) && $storage_type == 'base64' && !empty($row['call_recording_base64'])) { if (!empty($storage_type) && $storage_type == 'base64' && !empty($call_recording_base64)) {
@unlink($full_recording_path); @unlink($full_recording_path);
} }
@@ -446,7 +447,7 @@
$sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH24MISS') AS call_recording_time, "; $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH24MISS') AS call_recording_time, ";
$sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, "; $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, ";
$sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted "; $sql .= "TO_CHAR(timezone(:time_zone, call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted ";
if (!empty($storage_type) && $storage_type == 'base64' && $row['call_recording_base64'] != '') { if (!empty($storage_type) && $storage_type == 'base64') {
$sql .= ", call_recording_base64 "; $sql .= ", call_recording_base64 ";
} }
$sql .= "from view_call_recordings "; $sql .= "from view_call_recordings ";
@@ -124,7 +124,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
if ($not_admin) { if ($not_admin) {
$sql .= "and r.conference_room_uuid = u.conference_room_uuid "; $sql .= "and r.conference_room_uuid = u.conference_room_uuid ";
$sql .= "and u.user_uuid = :user_uuid "; $sql .= "and u.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid; $parameters['user_uuid'] = $this->user_uuid;
} }
if (isset($this->conference_room_uuid)) { if (isset($this->conference_room_uuid)) {
$sql .= "and r.conference_room_uuid = :conference_room_uuid "; $sql .= "and r.conference_room_uuid = :conference_room_uuid ";
+1
View File
@@ -86,6 +86,7 @@
private $uuid_prefix; private $uuid_prefix;
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
private $tables;
/** /**
* Create a settings object using key/value pairs in the $setting_array. * Create a settings object using key/value pairs in the $setting_array.
+34 -25
View File
@@ -524,10 +524,10 @@
} }
if ($regex_match) { if ($regex_match) {
//get the variables //get the variables
if ($field[dialplan_detail_type] == "set" && $field[dialplan_detail_tag] == "action") { if ($field['dialplan_detail_type'] == "set" && $field['dialplan_detail_tag'] == "action") {
//only set variables with values not variables //only set variables with values not variables
if (strpos($field[dialplan_detail_data], '$') === false) { if (strpos($field['dialplan_detail_data'], '$') === false) {
$this->variables .= $field[dialplan_detail_data].","; $this->variables .= $field['dialplan_detail_data'].",";
} }
} }
//process the $x detail data variables //process the $x detail data variables
@@ -700,9 +700,12 @@
} }
//define the values before they are used //define the values before they are used
$previous_dialplan_uuid = null; $previous_dialplan_uuid = '';
$previous_dialplan_detail_group = null; $previous_dialplan_detail_group = '';
$dialplan_tag_status = null; $dialplan_tag_status = '';
$condition_attribute = '';
$condition_break = '';
$xml = '';
//loop through the results to get the xml from the dialplan_xml field or from dialplan details table //loop through the results to get the xml from the dialplan_xml field or from dialplan details table
$x = 0; $x = 0;
@@ -869,7 +872,7 @@
} }
//get the condition break attribute //get the condition break attribute
$condition_break = ""; $condition_break = '';
if ($dialplan_detail_break) { if ($dialplan_detail_break) {
if (!empty($dialplan_detail_break)) { if (!empty($dialplan_detail_break)) {
$condition_break = " break=\"" . $dialplan_detail_break . "\""; $condition_break = " break=\"" . $dialplan_detail_break . "\"";
@@ -974,7 +977,7 @@
if ($condition_attribute && (!empty($condition_attribute))) { if ($condition_attribute && (!empty($condition_attribute))) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n"; $xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
} }
else if (!empty($condition) && substr($string, -1) == ">") { else if (!empty($condition) && substr($condition, -1) == ">") {
$xml .= $condition . "\n"; $xml .= $condition . "\n";
} }
else if (!empty($condition)) { else if (!empty($condition)) {
@@ -1035,29 +1038,35 @@
$xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml"); $xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml");
foreach ($xml_list as $xml_file) { foreach ($xml_list as $xml_file) {
//get and parse the xml //get and parse the xml
$xml_string = file_get_contents($xml_file); $xml_string = file_get_contents($xml_file);
//get the order number prefix from the file name
$name_array = explode('_', basename($xml_file));
if (is_numeric($name_array[0])) {
$dialplan_order = $name_array[0];
}
else {
$dialplan_order = 0;
}
$dialplan->dialplan_order = $dialplan_order;
$this->xml = $xml_string; //get the order number prefix from the file name
$this->import(); $name_array = explode('_', basename($xml_file));
if (is_numeric($name_array[0])) {
$dialplan_order = $name_array[0];
}
else {
$dialplan_order = 0;
}
//set the xml string
$this->xml = $xml_string;
//get the domains
$sql = 'select * from v_domains';
$domains = $this->database->select($sql, null, 'all');
$this->import($domains);
unset($sql);
} }
//update the dialplan order //update the dialplan order
$sql[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' "; $sql_array[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' ";
$sql[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' "; $sql_array[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' ";
$sql[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' "; $sql_array[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' ";
foreach ($sql as $query) { foreach ($sql_array as $query) {
$this->database->execute($query); $this->database->execute($query);
} }
unset($sql, $query); unset($sql_array, $query);
//add xml for each dialplan where the dialplan xml is empty //add xml for each dialplan where the dialplan xml is empty
$this->source = "details"; $this->source = "details";
@@ -219,7 +219,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) { if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
@@ -286,7 +286,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) { if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where event_guard_log_uuid in (".implode(', ', $uuids).") "; $sql .= "where event_guard_log_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0; $x = 0;
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -302,7 +302,7 @@
$array[$this->table][$x] = $row; $array[$this->table][$x] = $row;
//add copy to the description //add copy to the description
$array[$this->table][$x][event_guard_log.'_uuid'] = uuid(); $array[$this->table][$x]['event_guard_log_uuid'] = uuid();
//increment the id //increment the id
$x++; $x++;
@@ -68,6 +68,7 @@
private $toggle_values; private $toggle_values;
private $description_field; private $description_field;
private $location; private $location;
private $extension_uuid;
/** /**
* called when the object is created * called when the object is created
@@ -117,6 +118,20 @@
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $this->domain_uuid; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
if (empty($this->extension_uuid)) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle, extension_uuid ";
$sql .= "from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in :uuid ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['uuid'] = $record['uuid'];
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$this->extension_uuid = $rows[0]['extension_uuid'];
}
unset($sql, $parameters);
}
} }
//increment the id //increment the id
@@ -130,13 +145,15 @@
unset($array); unset($array);
//clear the cache //clear the cache
$sql = "select extension, number_alias, user_context from v_extensions "; if (!empty($this->extension_uuid)) {
$sql .= "where extension_uuid = :extension_uuid "; $sql = "select extension, number_alias, user_context from v_extensions ";
$parameters['extension_uuid'] = $this->extension_uuid; $sql .= "where extension_uuid = :extension_uuid ";
$extension = $this->database->select($sql, $parameters, 'row'); $parameters['extension_uuid'] = $this->extension_uuid;
$cache = new cache; $extension = $this->database->select($sql, $parameters, 'row');
$cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]); $cache = new cache;
$cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]); $cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]);
}
//set message //set message
message::add($text['message-delete']); message::add($text['message-delete']);
@@ -179,7 +196,7 @@
$parameters['domain_uuid'] = $this->domain_uuid; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$extension_uuid = $rows[0]['extension_uuid']; $this->extension_uuid = $rows[0]['extension_uuid'];
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
} }
@@ -208,7 +225,7 @@
//clear the cache //clear the cache
$sql = "select extension, number_alias, user_context from v_extensions "; $sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid "; $sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid; $parameters['extension_uuid'] = $this->extension_uuid;
$extension = $this->database->select($sql, $parameters, 'row'); $extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache; $cache = new cache;
$cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]); $cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]);
@@ -259,8 +276,6 @@
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
// var_dump($row); exit;
//convert boolean values to a string //convert boolean values to a string
foreach($row as $key => $value) { foreach($row as $key => $value) {
if (gettype($value) == 'boolean') { if (gettype($value) == 'boolean') {
@@ -285,7 +300,6 @@
//save the changes and set the message //save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) { if (is_array($array) && @sizeof($array) != 0) {
//save the array //save the array
$this->database->save($array); $this->database->save($array);
unset($array); unset($array);
@@ -246,6 +246,7 @@
$call_group = $row['call_group'] ?? ''; $call_group = $row['call_group'] ?? '';
$call_group = str_replace(";", ",", $call_group); $call_group = str_replace(";", ",", $call_group);
$tmp_array = explode(",", $call_group); $tmp_array = explode(",", $call_group);
$call_group_array = [];
foreach ($tmp_array as $tmp_call_group) { foreach ($tmp_array as $tmp_call_group) {
$tmp_call_group = trim($tmp_call_group); $tmp_call_group = trim($tmp_call_group);
if (!empty($tmp_call_group)) { if (!empty($tmp_call_group)) {
+1
View File
@@ -32,6 +32,7 @@
private $toggle_values; private $toggle_values;
private $description_field; private $description_field;
private $location; private $location;
private $uuid_prefix;
/** /**
* called when the object is created * called when the object is created
+8 -1
View File
@@ -40,10 +40,17 @@
public $domain_uuid; public $domain_uuid;
/** /**
* declare public variables * declare ivr menu primary uuid key
* @var string
*/ */
public $ivr_menu_uuid; public $ivr_menu_uuid;
/**
* declare order_by variables
* @var string
*/
public $order_by;
/** /**
* Set in the constructor. Must be a database object and cannot be null. * Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object * @var database Database Object
@@ -48,25 +48,25 @@
private $settings; private $settings;
/** /**
* User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array * User UUID set in the constructor. This can be passed in through the $this->settings_array associative array or set in the session global array
* @var string * @var string
*/ */
private $user_uuid; private $user_uuid;
/** /**
* Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array * Username set in the constructor. This can be passed in through the $this->settings_array associative array or set in the session global array
* @var string * @var string
*/ */
private $username; private $username;
/** /**
* Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array * Domain UUID set in the constructor. This can be passed in through the $this->settings_array associative array or set in the session global array
* @var string * @var string
*/ */
private $domain_uuid; private $domain_uuid;
/** /**
* Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array * Domain name set in the constructor. This can be passed in through the $this->settings_array associative array or set in the session global array
* @var string * @var string
*/ */
private $domain_name; private $domain_name;
@@ -188,12 +188,18 @@
} }
public function reload() { public function reload() {
//add multi-lingual support
$language = new text;
$text = $language->get();
//if the handle does not exist create it //if the handle does not exist create it
$esl = event_socket::create(); $esl = event_socket::create();
//if the handle still does not exist show an error message //if the handle still does not exist show an error message
if (!$esl->is_connected()) { if (!$esl->is_connected()) {
$msg = "<div align='center'>".$text['message-event-socket']."<br /></div>"; $msg = "<div align='center'>".$text['message-event-socket']."<br /></div>";
} }
//send the api command to check if the module exists //send the api command to check if the module exists
if ($esl->is_connected()) { if ($esl->is_connected()) {
$cmd = "reload mod_local_stream"; $cmd = "reload mod_local_stream";
@@ -202,48 +208,6 @@
} }
} }
public function xml() {
//build the list of categories
$music_on_hold_dir = $this->settings->get('switch', 'sounds').'/music';
//default category (note: GLOB_BRACE doesn't work on some systems)
$array_1 = glob($music_on_hold_dir."/8000".$class_name.".php", GLOB_ONLYDIR);
$array_2 = glob($music_on_hold_dir."/16000".$class_name.".php", GLOB_ONLYDIR);
$array_3 = glob($music_on_hold_dir."/32000".$class_name.".php", GLOB_ONLYDIR);
$array_4 = glob($music_on_hold_dir."/48000".$class_name.".php", GLOB_ONLYDIR);
$array = array_merge((array)$array_1,(array)$array_2,(array)$array_3,(array)$array_4);
unset($array_1,$array_2,$array_3,$array_4);
//other categories
if (count($_SESSION['domains']) > 1) {
$array = array_merge($array, glob($music_on_hold_dir."/*/*/*", GLOB_ONLYDIR));
}
else {
$array = array_merge($array, glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR));
}
//list the categories
$xml = "";
foreach($array as $moh_dir) {
//set the directory
$moh_dir = substr($moh_dir, strlen($music_on_hold_dir."/"));
//get and set the rate
$sub_array = explode("/", $moh_dir);
$moh_rate = end($sub_array);
//set the name
$moh_name = $moh_dir;
if ($moh_dir == $moh_rate) {
$moh_name = "default/$moh_rate";
}
//build the xml
$xml .= " <directory name=\"$moh_name\" path=\"\$\${sounds_dir}/music/$moh_dir\">\n";
$xml .= " <param name=\"rate\" value=\"".$moh_rate."\"/>\n";
$xml .= " <param name=\"shuffle\" value=\"true\"/>\n";
$xml .= " <param name=\"channels\" value=\"1\"/>\n";
$xml .= " <param name=\"interval\" value=\"20\"/>\n";
$xml .= " <param name=\"timer-name\" value=\"soft\"/>\n";
$xml .= " </directory>\n";
$this->xml = $xml;
}
}
public function save() { public function save() {
//get the contents of the template //get the contents of the template
if (file_exists('/usr/share/examples/fusionpbx')) { if (file_exists('/usr/share/examples/fusionpbx')) {
@@ -254,7 +218,7 @@
} }
//check where the default music is stored //check where the default music is stored
$default_moh_prefix = 'music/default'; $default_moh_prefix = 'music/default';
if(file_exists($settings->get('switch', 'sounds').'/music/8000')) { if(file_exists($this->settings->get('switch', 'sounds').'/music/8000')) {
$default_moh_prefix = 'music'; $default_moh_prefix = 'music';
} }
//replace the variables //replace the variables
@@ -262,7 +226,7 @@
$file_contents = preg_replace("/[\t ]*(?:<!--)?{v_moh_categories}(?:-->)?/", $this->xml, $file_contents); $file_contents = preg_replace("/[\t ]*(?:<!--)?{v_moh_categories}(?:-->)?/", $this->xml, $file_contents);
//write the XML config file //write the XML config file
$fout = fopen($settings->get('switch', 'conf')."/autoload_configs/local_stream.conf.xml","w"); $fout = fopen($this->settings->get('switch', 'conf')."/autoload_configs/local_stream.conf.xml","w");
fwrite($fout, $file_contents); fwrite($fout, $file_contents);
fclose($fout); fclose($fout);
@@ -288,7 +252,7 @@
//build an array of the sound files //build an array of the sound files
$music_directory = $this->settings->get('switch', 'sounds').'/music'; $music_directory = $this->settings->get('switch', 'sounds').'/music';
if (file_exists($music_directory)) { if (file_exists($music_directory)) {
$files = array_merge(glob($music_directory.'/*/*/*.wav'), glob($music_directory.'/*/*/*/*.wav'), glob($stream_path.'/*/*/*/*.mp3'), glob($stream_path.'/*/*/*/*.ogg')); $files = array_merge(glob($music_directory.'/*/*/*.wav'), glob($music_directory.'/*/*/*/*.wav'));
} }
//build a new file array //build a new file array
@@ -309,10 +273,9 @@
foreach($a2 as $sample_rate => $file_path) { foreach($a2 as $sample_rate => $file_path) {
//echo "domain_name ".$domain_name."<br />\n"; //echo "domain_name ".$domain_name."<br />\n";
//echo "category_name ".$category_name."<br />\n"; //echo "category_name ".$category_name."<br />\n";
foreach($domains as $domain) { foreach($domains as $field) {
//view_array($field, false);
if ($field['domain_name'] === $domain_name) { if ($field['domain_name'] === $domain_name) {
$domain_uuid = $domain['domain_uuid']; $domain_uuid = $field['domain_uuid'];
//echo "domain_uuid ".$domain_uuid."<br />\n"; //echo "domain_uuid ".$domain_uuid."<br />\n";
} }
} }
@@ -320,7 +283,6 @@
if ($domain_name == 'global' || $domain_name == 'default') { if ($domain_name == 'global' || $domain_name == 'default') {
$domain_uuid = null; $domain_uuid = null;
} }
//view_array($row, false);
$array['music_on_hold'][$i]['music_on_hold_uuid'] = uuid(); $array['music_on_hold'][$i]['music_on_hold_uuid'] = uuid();
$array['music_on_hold'][$i]['domain_uuid'] = $domain_uuid; $array['music_on_hold'][$i]['domain_uuid'] = $domain_uuid;
@@ -350,7 +312,7 @@
//echo $this->database->message; //echo $this->database->message;
unset($array); unset($array);
$p->delete('music_on_hold_add', 'temp'); $p->delete('music_on_hold_add', 'temp');
} }
/** /**
@@ -375,7 +337,6 @@
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//filter checked records //filter checked records
// view_array($records, 0);
foreach ($records as $music_on_hold_uuid => $record) { foreach ($records as $music_on_hold_uuid => $record) {
if (is_uuid($music_on_hold_uuid)) { if (is_uuid($music_on_hold_uuid)) {
if ($record['checked'] == 'true') { if ($record['checked'] == 'true') {
@@ -41,7 +41,6 @@
/** /**
* declare private variables * declare private variables
*/ */
private $database; private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
@@ -49,7 +48,10 @@
private $uuid_prefix; private $uuid_prefix;
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
public $xml; private $json;
private $xml;
private $display_type;
/** /**
* called when the object is created * called when the object is created
@@ -270,7 +272,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) { if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
@@ -338,7 +340,7 @@
//primary table //primary table
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
+1 -1
View File
@@ -217,7 +217,7 @@
//send a request to a remote server to validate the MAC address and secret //send a request to a remote server to validate the MAC address and secret
if (!empty($_SERVER['auth_server'])) { if (!empty($_SERVER['auth_server'])) {
$result = send_http_request($_SERVER['auth_server'], 'mac='.url_encode($_REQUEST['mac']).'&secret='.url_encode($_REQUEST['secret'])); $result = send_http_request($_SERVER['auth_server'], 'mac='.urlencode($_REQUEST['mac']).'&secret='.urlencode($_REQUEST['secret']));
if ($result == "false") { if ($result == "false") {
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".escape($_REQUEST['mac'])); syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".escape($_REQUEST['mac']));
http_error('404'); http_error('404');
+30 -24
View File
@@ -52,6 +52,7 @@
public $template_dir; public $template_dir;
public $device_address; public $device_address;
public $device_template; public $device_template;
public $file;
/** /**
* Set in the constructor. Must be a database object and cannot be null. * Set in the constructor. Must be a database object and cannot be null.
@@ -555,33 +556,38 @@
//get a new primary key //get a new primary key
$device_uuid = uuid(); $device_uuid = uuid();
//prepare the array //prepare the auto insert enabled
$x = 0; if (!empty($device_address)) {
$array['devices'][$x]['domain_uuid'] = $domain_uuid; $device_vendor = device::get_vendor($device_address);
$array['devices'][$x]['device_uuid'] = $device_uuid;
$array['devices'][$x]['device_address'] = $device_address;
$array['devices'][$x]['device_vendor'] = $device_vendor;
$array['devices'][$x]['device_enabled'] = true;
$array['devices'][$x]['device_template'] = $device_template;
$array['devices'][$x]['device_description'] = $_SERVER['HTTP_USER_AGENT'];
//add the dialplan permission //prepare the array
$p = permissions::new(); $x = 0;
$p->add("device_add", "temp"); $array['devices'][$x]['domain_uuid'] = $domain_uuid;
$p->add("device_edit", "temp"); $array['devices'][$x]['device_uuid'] = $device_uuid;
$array['devices'][$x]['device_address'] = $device_address;
$array['devices'][$x]['device_vendor'] = $device_vendor;
$array['devices'][$x]['device_enabled'] = true;
$array['devices'][$x]['device_template'] = $device_template;
$array['devices'][$x]['device_description'] = $_SERVER['HTTP_USER_AGENT'];
//save to the data //add the dialplan permission
$this->database->app_name = 'devices'; $p = permissions::new();
$this->database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; $p->add("device_add", "temp");
if (!empty($device_uuid)) { $p->add("device_edit", "temp");
$this->database->uuid($device_uuid);
//save to the data
$this->database->app_name = 'devices';
$this->database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
if (!empty($device_uuid)) {
$this->database->uuid($device_uuid);
}
$this->database->save($array);
$message = $this->database->message;
//remove the temporary permission
$p->delete("device_add", "temp");
$p->delete("device_edit", "temp");
} }
$this->database->save($array);
$message = $this->database->message;
//remove the temporary permission
$p->delete("device_add", "temp");
$p->delete("device_edit", "temp");
} }
} }
//} //}
@@ -1,6 +1,8 @@
<?php <?php
function device_by_mac($device_address) { function device_by_mac($device_address) {
global $database;
$sql = "select * from v_devices "; $sql = "select * from v_devices ";
$sql .= "where device_address = :device_address "; $sql .= "where device_address = :device_address ";
$sql .= "and device_enabled = true "; $sql .= "and device_enabled = true ";
@@ -10,6 +12,8 @@ function device_by_mac($device_address) {
} }
function device_by_ext($ext, $domain) { function device_by_ext($ext, $domain) {
global $database;
$sql = "select t1.* "; $sql = "select t1.* ";
$sql .= "from v_devices t1 "; $sql .= "from v_devices t1 ";
$sql .= "inner join v_device_lines t2 on t1.device_uuid = t2.device_uuid "; $sql .= "inner join v_device_lines t2 on t1.device_uuid = t2.device_uuid ";
@@ -98,6 +98,10 @@
*/ */
public function get($profile = 'all') { public function get($profile = 'all') {
//add multi-lingual support
$language = new text;
$text = $language->get(null, '/app/registrations');
//initialize the id used in the registrations array //initialize the id used in the registrations array
$id = 0; $id = 0;
@@ -116,8 +120,6 @@
} }
} }
//get the default settings //get the default settings
$sql = "select sip_profile_name from v_sip_profiles "; $sql = "select sip_profile_name from v_sip_profiles ";
$sql .= "where true "; $sql .= "where true ";
@@ -142,10 +144,6 @@
//show an error message //show an error message
if ($xml_response == "Invalid Profile!") { if ($xml_response == "Invalid Profile!") {
//add multi-lingual support
$language = new text;
$text = $language->get(null, '/app/registrations');
//show the error message //show the error message
$xml_response = "<error_msg>".escape($text['label-message'])."</error_msg>"; $xml_response = "<error_msg>".escape($text['label-message'])."</error_msg>";
} }
@@ -407,6 +405,7 @@
//set message //set message
if (is_array($response_api)) { if (is_array($response_api)) {
$message = '';
foreach ($response_api as $registration_user => $response) { foreach ($response_api as $registration_user => $response) {
if (is_array($response['command'])) { if (is_array($response['command'])) {
foreach($response['command'] as $command) { foreach($response['command'] as $command) {
@@ -78,6 +78,7 @@
private $uuid_prefix; private $uuid_prefix;
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
private $dialplan_global;
public function __construct(array $setting_array = []) { public function __construct(array $setting_array = []) {
//set domain and user UUIDs //set domain and user UUIDs
@@ -33,20 +33,39 @@
class authentication { class authentication {
/** /**
* Define variables and their scope * Declare Public variables
*
* @var mixed
*/ */
private $database;
public $domain_uuid; public $domain_uuid;
public $user_uuid; public $user_uuid;
public $domain_name; public $domain_name;
public $username; public $username;
public $password; public $password;
public $key;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
private $settings;
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct(array $setting_array = []) { public function __construct(array $setting_array = []) {
$this->database = $setting_array['database'] ?? database::new(); //set the config object
$config = $setting_array['config'] ?? config::load();
//set the database connection
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
//set the settings object
$this->settings = $setting_array['settings'];
//intialize the object
$this->user_uuid = null; $this->user_uuid = null;
} }
@@ -68,7 +87,7 @@ class authentication {
} }
//create a settings object to pass to plugins //create a settings object to pass to plugins
$settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid]); $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid]);
//start the session if its not started //start the session if its not started
if (session_status() === PHP_SESSION_NONE) { if (session_status() === PHP_SESSION_NONE) {
@@ -114,7 +133,7 @@ class authentication {
$object->password = $this->password; $object->password = $this->password;
} }
//initialize the plugin send the authentication object and settings //initialize the plugin send the authentication object and settings
$array = $object->$name($this, $settings); $array = $object->$name($this, $this->settings);
//build a result array //build a result array
if (!empty($array) && is_array($array)) { if (!empty($array) && is_array($array)) {
@@ -187,11 +206,11 @@ class authentication {
//user is authorized - get user settings, check user cidr //user is authorized - get user settings, check user cidr
if ($authorized) { if ($authorized) {
//get the cidr restrictions from global, domain, and user default settings //get the cidr restrictions from global, domain, and user default settings
$settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]); $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
$cidr_list = $settings->get('domain', 'cidr', []); $cidr_list = $this->settings->get('domain', 'cidr', []);
if (check_cidr($cidr_list, $_SERVER['REMOTE_ADDR'])) { if (check_cidr($cidr_list, $_SERVER['REMOTE_ADDR'])) {
//user passed the cidr check //user passed the cidr check
self::create_user_session($result, $settings); self::create_user_session($result, $this->settings);
} else { } else {
//user failed the cidr check - no longer authorized //user failed the cidr check - no longer authorized
$authorized = false; $authorized = false;
@@ -456,12 +475,10 @@ class authentication {
} }
//set a default value for unqiue //set a default value for unqiue
if (empty($_SESSION["users"]["unique"]["text"])) { $_SESSION["users"]["unique"]["text"] = $this->settings->get('users', 'unique', '');
$_SESSION["users"]["unique"]["text"] = 'false';
}
//get the domain name from the username //get the domain name from the username
if (!empty($_SESSION['username']) && $_SESSION["users"]["unique"]["text"] != "global") { if (!empty($_SESSION['username']) && $this->settings->get('users', 'unique', '') != "global") {
$username_array = explode("@", $_SESSION['username']); $username_array = explode("@", $_SESSION['username']);
if (count($username_array) > 1) { if (count($username_array) > 1) {
//get the domain name //get the domain name
@@ -57,6 +57,9 @@ class plugin_database {
//pre-process some settings //pre-process some settings
$theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
$theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
$theme_login_type = $settings->get('theme', 'login_brand_type', '');
$theme_login_image = $settings->get('theme', 'login_brand_image', '');
$theme_login_text = $settings->get('theme', 'login_brand_text', '');
$theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
$theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
@@ -67,6 +70,12 @@ class plugin_database {
$login_destination = $settings->get('login', 'destination'); $login_destination = $settings->get('login', 'destination');
$users_unique = $settings->get('users', 'unique', ''); $users_unique = $settings->get('users', 'unique', '');
//set the default login type and image
if (empty($theme_login_type)) {
$theme_login_type = 'image';
$theme_login_image = $theme_logo;
}
//determine whether to show the forgot password for resetting the password //determine whether to show the forgot password for resetting the password
$login_password_reset_enabled = false; $login_password_reset_enabled = false;
if (!empty($settings->get('login', 'password_reset_key'))) { if (!empty($settings->get('login', 'password_reset_key'))) {
@@ -41,6 +41,13 @@ class plugin_email {
public $contact_uuid; public $contact_uuid;
public $debug; public $debug;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
/** /**
* Called when the object is created * Called when the object is created
*/ */
@@ -60,6 +67,9 @@ class plugin_email {
//pre-process some settings //pre-process some settings
$theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
$theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
$theme_login_type = $settings->get('theme', 'login_brand_type', '');
$theme_login_image = $settings->get('theme', 'login_brand_image', '');
$theme_login_text = $settings->get('theme', 'login_brand_text', '');
$theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
$theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
@@ -69,7 +79,7 @@ class plugin_email {
//$login_domain_name = $settings->get('login', 'domain_name'); //$login_domain_name = $settings->get('login', 'domain_name');
$login_destination = $settings->get('login', 'destination'); $login_destination = $settings->get('login', 'destination');
$users_unique = $settings->get('users', 'unique', ''); $users_unique = $settings->get('users', 'unique', '');
//get the domain //get the domain
$domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_array = explode(":", $_SERVER["HTTP_HOST"]);
$domain_name = $domain_array[0]; $domain_name = $domain_array[0];
@@ -8,15 +8,25 @@
class plugin_ldap { class plugin_ldap {
/** /**
* Declare public variables * Declare Public variables
*
* @var mixed
*/ */
public $debug; public $debug;
public $domain_name; public $domain_name;
public $domain_uuid;
public $username; public $username;
public $password; public $password;
public $user_uuid; public $user_uuid;
public $contact_uuid; public $contact_uuid;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
/** /**
* Called when the object is created * Called when the object is created
*/ */
@@ -37,13 +47,14 @@ class plugin_ldap {
if ($_REQUEST["username"]) { if ($_REQUEST["username"]) {
//pre-process some settings //pre-process some settings
$settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico'; $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
$settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : ''; $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
$settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : ''; $login_destination = $settings->get('login', 'destination');
$settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png'; $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
$settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px'; $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px'; $background_videos = $settings->get('theme', 'background_video', null);
$settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null; $theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null;
$users_unique = $settings->get('users', 'unique', '');
//get the domain //get the domain
$domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_array = explode(":", $_SERVER["HTTP_HOST"]);
@@ -72,12 +83,12 @@ class plugin_ldap {
//assign default values to the template //assign default values to the template
$view->assign("project_path", PROJECT_PATH); $view->assign("project_path", PROJECT_PATH);
$view->assign("login_destination_url", $settings['login']['destination']); $view->assign("login_destination_url", $login_destination);
$view->assign("favicon", $settings['theme']['favicon']); $view->assign("favicon", $theme_favicon);
$view->assign("login_logo_width", $settings['theme']['login_logo_width']); $view->assign("login_logo_width", $theme_login_logo_width);
$view->assign("login_logo_height", $settings['theme']['login_logo_height']); $view->assign("login_logo_height", $theme_login_logo_height);
$view->assign("login_logo_source", $settings['theme']['logo']); $view->assign("login_logo_source", $theme_logo);
$view->assign("background_video", $settings['theme']['background_video']); $view->assign("background_video", $theme_background_video);
//add the token name and hash to the view //add the token name and hash to the view
//$view->assign("token_name", $token['name']); //$view->assign("token_name", $token['name']);
@@ -90,16 +101,16 @@ class plugin_ldap {
} }
//use ldap to validate the user credentials //use ldap to validate the user credentials
if (isset($_SESSION["ldap"]["certpath"])) { if (!empty($settings->get('ldap', 'certpath', ''))) {
$s = "LDAPTLS_CERT=" . $_SESSION["ldap"]["certpath"]["text"]; $s = "LDAPTLS_CERT=" . $settings->get('ldap', 'certpath', '');
putenv($s); putenv($s);
} }
if (isset($_SESSION["ldap"]["certkey"])) { if (!empty($settings->get('ldap', 'certkey', ''))) {
$s = "LDAPTLS_KEY=" . $_SESSION["ldap"]["certkey"]["text"]; $s = "LDAPTLS_KEY=" . $settings->get('ldap', 'certkey', '');
putenv($s); putenv($s);
} }
$host = $_SESSION["ldap"]["server_host"]["text"]; $host = $settings->get('ldap', 'server_host', '');
$port = $_SESSION["ldap"]["server_port"]["numeric"]; $port = $settings->get('ldap', 'server_port', '');
$connect = ldap_connect($host, $port) $connect = ldap_connect($host, $port)
or die("Could not connect to the LDAP server."); or die("Could not connect to the LDAP server.");
//ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10); //ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10);
@@ -110,13 +121,13 @@ class plugin_ldap {
$user_authorized = false; $user_authorized = false;
//provide backwards compatability //provide backwards compatability
if (!empty($_SESSION["ldap"]["user_dn"]["text"])) { if (!empty($settings->get('ldap', 'user_dn', ''))) {
$_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"]; $ldap_user_dn[] = $settings->get('ldap', 'user_dn', '');
} }
//check all user_dn in the array //check all user_dn in the array
foreach ($_SESSION["ldap"]["user_dn"] as $user_dn) { foreach ($ldap_user_dn as $user_dn) {
$bind_dn = $_SESSION["ldap"]["user_attribute"]["text"]."=".$this->username.",".$user_dn; $bind_dn = $settings->get('ldap', 'user_attribute', '')."=".$this->username.",".$user_dn;
$bind_pw = $this->password; $bind_pw = $this->password;
//Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind //Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind
//called below with all arguments '*uninitialized*'. However, the debugger //called below with all arguments '*uninitialized*'. However, the debugger
@@ -135,7 +146,7 @@ class plugin_ldap {
if ($user_authorized) { if ($user_authorized) {
$sql = "select * from v_users "; $sql = "select * from v_users ";
$sql .= "where username = :username "; $sql .= "where username = :username ";
if ($settings['users']['unique'] != "global") { if (!empty($users_unique) && $users_unique != "global") {
//unique username per domain (not globally unique across system - example: email address) //unique username per domain (not globally unique across system - example: email address)
$sql .= "and domain_uuid = :domain_uuid "; $sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid; $parameters['domain_uuid'] = $this->domain_uuid;
@@ -144,10 +155,14 @@ class plugin_ldap {
$parameters['username'] = $this->username; $parameters['username'] = $this->username;
$row = $this->database->select($sql, $parameters, 'row'); $row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) { if (is_array($row) && @sizeof($row) != 0) {
if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) { if (!empty($users_unique) && $users_unique == "global" && $row["domain_uuid"] != $this->domain_uuid) {
//get the domain uuid //set the domain uuid
$this->domain_uuid = $row["domain_uuid"]; $this->domain_uuid = $row["domain_uuid"];
$this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
//set the domain name
$sql .= "select domain_name from v_domains where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
$this->domain_name = $this->database->select($sql, $parameters, 'column');
//set the domain session variables //set the domain session variables
$_SESSION["domain_uuid"] = $this->domain_uuid; $_SESSION["domain_uuid"] = $this->domain_uuid;
@@ -176,7 +191,7 @@ class plugin_ldap {
$array['users'][0]['username'] = strtolower($this->username); $array['users'][0]['username'] = strtolower($this->username);
$array['users'][0]['password'] = md5($salt.$password); $array['users'][0]['password'] = md5($salt.$password);
$array['users'][0]['salt'] = $salt; $array['users'][0]['salt'] = $salt;
$array['users'][0]['add_date'] = now(); $array['users'][0]['add_date'] = 'now()';
$array['users'][0]['add_user'] = strtolower($this->username); $array['users'][0]['add_user'] = strtolower($this->username);
$array['users'][0]['user_enabled'] = true; $array['users'][0]['user_enabled'] = true;
@@ -32,15 +32,25 @@
class plugin_totp { class plugin_totp {
/** /**
* Define variables and their scope * Declare Public variables
*
* @var mixed
*/ */
public $debug; public $debug;
public $domain_name; public $domain_name;
public $domain_uuid;
public $username; public $username;
public $password; public $password;
public $user_uuid; public $user_uuid;
public $user_email; public $user_email;
public $contact_uuid; public $contact_uuid;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
private $user_totp_secret; private $user_totp_secret;
/** /**
@@ -62,6 +72,9 @@ class plugin_totp {
//pre-process some settings //pre-process some settings
$theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico');
$theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png');
$theme_login_type = $settings->get('theme', 'login_brand_type', '');
$theme_login_image = $settings->get('theme', 'login_brand_image', '');
$theme_login_text = $settings->get('theme', 'login_brand_text', '');
$theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px');
$theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
@@ -71,7 +84,7 @@ class plugin_totp {
//$login_domain_name = $settings->get('login', 'domain_name'); //$login_domain_name = $settings->get('login', 'domain_name');
$login_destination = $settings->get('login', 'destination'); $login_destination = $settings->get('login', 'destination');
$users_unique = $settings->get('users', 'unique', ''); $users_unique = $settings->get('users', 'unique', '');
//get the username //get the username
if (isset($_SESSION["username"])) { if (isset($_SESSION["username"])) {
$this->username = $_SESSION["username"]; $this->username = $_SESSION["username"];
@@ -57,6 +57,7 @@
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $tables; private $tables;
private $table;
private $uuid_prefix; private $uuid_prefix;
/** /**
+217 -209
View File
@@ -328,47 +328,49 @@
$this->name = 'dashboard_widget'; $this->name = 'dashboard_widget';
$this->table = 'dashboard_widgets'; $this->table = 'dashboard_widgets';
if (permission_exists($this->name.'_delete')) { //permission not found return false
if (!permission_exists($this->name.'_delete')) {
return false;
}
//validate the token //add multi-lingual support
$token = new token; $language = new text;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { $text = $language->get();
message::add($this->text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//add multi-lingual support //validate the token
$language = new text; $token = new token;
$text = $language->get(); if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//delete multiple records //delete multiple records
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//build the delete array //build the delete array
$x = 0; $x = 0;
foreach ($records as $record) { foreach ($records as $record) {
//add to the array //add to the array
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$array[$this->table][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; $array[$this->table][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid']; $array[$this->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
} }
//increment the id //increment the id
$x++; $x++;
} }
//delete the checked rows //delete the checked rows
if (is_array($array) && @sizeof($array) != 0) { if (is_array($array) && @sizeof($array) != 0) {
//execute delete //execute delete
$this->database->delete($array); $this->database->delete($array);
unset($array); unset($array);
//set message //set message
message::add($text['message-delete']); message::add($text['message-delete']);
} }
unset($records); unset($records);
} }
}
} }
public function toggle_widgets($records) { public function toggle_widgets($records) {
@@ -377,64 +379,66 @@
$this->table = 'dashboard_widgets'; $this->table = 'dashboard_widgets';
$this->toggle_field = 'widget_enabled'; $this->toggle_field = 'widget_enabled';
if (permission_exists($this->name.'_edit')) { //permission not found return false
if (!permission_exists($this->name.'_edit')) {
return false;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($this->text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location); header('Location: '.$this->location);
exit; exit;
} }
//toggle the checked records //toggle the checked records
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state //get current toggle state
foreach($records as $record) { foreach($records as $record) {
if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$uuids[] = "'".$record['dashboard_widget_uuid']."'"; $uuids[] = "'".$record['dashboard_widget_uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
} }
} }
if (is_array($uuids) && @sizeof($uuids) != 0) { unset($sql, $parameters, $rows, $row);
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; }
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
}
unset($sql, $parameters, $rows, $row);
}
//build update array //build update array
$x = 0; $x = 0;
foreach($states as $uuid => $state) { foreach($states as $uuid => $state) {
//create the array //create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid; $array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id //increment the id
$x++; $x++;
} }
//save the changes //save the changes
if (is_array($array) && @sizeof($array) != 0) { if (is_array($array) && @sizeof($array) != 0) {
//save the array //save the array
$this->database->save($array); $this->database->save($array);
unset($array); unset($array);
//set message //set message
message::add($text['message-toggle']); message::add($text['message-toggle']);
} }
unset($records, $states); unset($records, $states);
} }
}
} }
public function assign_widgets($records, $dashboard_uuid, $group_uuid) { public function assign_widgets($records, $dashboard_uuid, $group_uuid) {
@@ -442,76 +446,78 @@
$this->name = 'dashboard_widget'; $this->name = 'dashboard_widget';
$this->table = 'dashboard_widgets'; $this->table = 'dashboard_widgets';
if (permission_exists($this->name.'_add')) { //permission not found return false
if (!permission_exists($this->name.'_add')) {
return false;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location); header('Location: '.$this->location);
exit; exit;
} }
//assign multiple records //assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//define the group_name and group_uuid //define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) { if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups "; $sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid "; $sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid; $parameters['group_uuid'] = $group_uuid;
$group = $this->database->select($sql, $parameters, 'row'); $group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
$x = 0;
foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
//build array
$uuids[] = "'".$record['dashboard_widget_uuid']."'";
//assign dashboard widget groups
$array[$this->name.'_groups'][$x][$this->name.'_group_uuid'] = uuid();
$array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid;
$array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid'];
//increment
$x++;
}
}
unset($records);
//exlude exist rows
if (!empty($array) && @sizeof($array) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid, ";
$sql .= "group_uuid from v_".$this->name."_groups ";
$dashboard_widget_groups = $this->database->select($sql, null, 'all');
$array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) {
foreach ($dashboard_widget_groups as $existing_array_item) {
if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) {
return false;
}
}
return true;
});
unset($dashboard_widget_groups);
} }
//add the checked rows from group //build the delete array
if (!empty($array) && is_array($array) && @sizeof($array) != 0) { $x = 0;
//execute save foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$this->database->save($array); //build array
unset($array); $uuids[] = "'".$record['dashboard_widget_uuid']."'";
//set message //assign dashboard widget groups
message::add($text['message-add']); $array[$this->name.'_groups'][$x][$this->name.'_group_uuid'] = uuid();
$array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid;
$array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid'];
//increment
$x++;
} }
}
unset($records);
//exlude exist rows
if (!empty($array) && @sizeof($array) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid, ";
$sql .= "group_uuid from v_".$this->name."_groups ";
$dashboard_widget_groups = $this->database->select($sql, null, 'all');
$array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) {
foreach ($dashboard_widget_groups as $existing_array_item) {
if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) {
return false;
}
}
return true;
});
unset($dashboard_widget_groups);
} }
}
//add the checked rows from group
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute save
$this->database->save($array);
unset($array);
//set message
message::add($text['message-add']);
}
}
} }
public function unassign_widgets($records, $dashboard_uuid, $group_uuid) { public function unassign_widgets($records, $dashboard_uuid, $group_uuid) {
@@ -519,85 +525,87 @@
$this->name = 'dashboard_widget'; $this->name = 'dashboard_widget';
$this->table = 'dashboard_widgets'; $this->table = 'dashboard_widgets';
if (permission_exists($this->name.'_add')) { //permission not found return now
if (!permission_exists($this->name.'_add')) {
return false;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//validate the token //validate the token
$token = new token; $token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) { if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location); header('Location: '.$this->location);
exit; exit;
} }
//assign multiple records //assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) { if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//define the group_name and group_uuid //define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) { if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups "; $sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid "; $sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid; $parameters['group_uuid'] = $group_uuid;
$group = $this->database->select($sql, $parameters, 'row'); $group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
$x = 0;
foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
//build array
$uuids[] = "'".$record['dashboard_widget_uuid']."'";
//assign dashboard widget groups
$array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid;
$array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid'];
//increment
$x++;
} }
}
//build the delete array unset($records);
$x = 0;
foreach ($records as $record) { //include child dashboard widgets and their dasboard_uuid too
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) { if (!empty($uuids) && @sizeof($uuids) != 0) {
//build array $sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." ";
$uuids[] = "'".$record['dashboard_widget_uuid']."'"; $sql .= "where ".$this->name."_parent_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
//assign dashboard widget groups //assign dashboard widget groups
$array[$this->name.'_groups'][$x]['dashboard_uuid'] = $dashboard_uuid; $array[$this->name.'_groups'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $record['dashboard_widget_uuid']; $array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $row['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid']; $array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid'];
//increment //increment
$x++; $x++;
} }
} }
}
unset($records); unset($uuids);
//include child dashboard widgets and their dasboard_uuid too //add the checked rows from group
if (!empty($uuids) && @sizeof($uuids) != 0) { if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." "; //grant temporary permissions
$sql .= "where ".$this->name."_parent_uuid in (".implode(', ', $uuids).") "; $p = new permissions;
$rows = $this->database->select($sql, null, 'all'); $p->add('dashboard_widget_group_delete', 'temp');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
//assign dashboard widget groups
$array[$this->name.'_groups'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array[$this->name.'_groups'][$x][$this->name.'_uuid'] = $row['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['group_uuid'] = $group['group_uuid'];
//increment
$x++;
}
}
}
unset($uuids); //execute delete
$this->database->delete($array);
unset($array);
//add the checked rows from group //revoke temporary permissions
if (!empty($array) && is_array($array) && @sizeof($array) != 0) { $p->delete('dashboard_widget_group_delete', 'temp');
//grant temporary permissions
$p = new permissions;
$p->add('dashboard_widget_group_delete', 'temp');
//execute delete //set message
$this->database->delete($array); message::add($text['message-delete']);
unset($array); }
}
//revoke temporary permissions
$p->delete('dashboard_widget_group_delete', 'temp');
//set message
message::add($text['message-delete']);
}
}
}
} }
} }
@@ -59,6 +59,7 @@
/** /**
* declare private variables * declare private variables
*/ */
private $domain_uuid;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -211,7 +212,7 @@
$token = new token; $token = new token;
if (!$token->validate('/core/domain_settings/domain_settings.php')) { if (!$token->validate('/core/domain_settings/domain_settings.php')) {
message::add($text['message-invalid_token'],'negative'); message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location); header('Location: '.$this->list_page);
exit; exit;
} }
@@ -38,6 +38,7 @@
*/ */
private $database; private $database;
private $database_group_permissions;
/** /**
* called when the object is created * called when the object is created
+1 -1
View File
@@ -120,7 +120,7 @@
} }
//validate the username and password //validate the username and password
$auth = new authentication; $auth = new authentication(['settings' => $settings]);
$result = $auth->validate(); $result = $auth->validate();
//if not authorized //if not authorized
+7 -7
View File
@@ -739,11 +739,11 @@ class database {
* <p><b>Note:</b><br> * <p><b>Note:</b><br>
* Table name must be sanitized. Otherwise, a warning will be * Table name must be sanitized. Otherwise, a warning will be
* emitted and false will be returned.</p> * emitted and false will be returned.</p>
* @param type $table_name Sanitized name of the table to search for. * @param string $table_name Sanitized name of the table to search for.
* @return boolean Returns <i>true</i> if the table exists and <i>false</i> if it does not. * @return boolean Returns <i>true</i> if the table exists and <i>false</i> if it does not.
* @depends connect() * @depends connect()
*/ */
public function table_exists ($table_name) { public function table_exists (string $table_name) {
if (self::sanitize($table_name) != $table_name) { if (self::sanitize($table_name) != $table_name) {
trigger_error('Table Name must be sanitized', E_USER_WARNING); trigger_error('Table Name must be sanitized', E_USER_WARNING);
return false; return false;
@@ -793,12 +793,12 @@ class database {
* <p><b>Note:</b><br> * <p><b>Note:</b><br>
* Tables and Column names must be sanitized. Otherwise, a warning will be * Tables and Column names must be sanitized. Otherwise, a warning will be
* emitted and false will be returned.</p> * emitted and false will be returned.</p>
* @param type $table_name Sanitized name of the table to search for. * @param string $table_name Sanitized name of the table to search for.
* @param type $column_name Sanitized name of the column to search for. * @param string $column_name Sanitized name of the column to search for.
* @return boolean Returns <i>true</i> if the column exists and <i>false</i> if it does not. * @return boolean Returns <i>true</i> if the column exists and <i>false</i> if it does not.
* @depends connect() * @depends connect()
*/ */
public function column_exists ($table_name, $column_name) { public function column_exists (string $table_name, string $column_name) {
//sanitize the table name //sanitize the table name
if (self::sanitize($table_name) != $table_name) { if (self::sanitize($table_name) != $table_name) {
trigger_error('Table Name must be sanitized', E_USER_WARNING); trigger_error('Table Name must be sanitized', E_USER_WARNING);
@@ -955,7 +955,7 @@ class database {
if (is_array($this->where)) { if (is_array($this->where)) {
foreach($this->where as $row) { foreach($this->where as $row) {
//sanitize the name //sanitize the name
$array['name'] = self::sanitize($array['name']); $row['name'] = self::sanitize($row['name']);
//validate the operator //validate the operator
switch ($row['operator']) { switch ($row['operator']) {
@@ -1997,7 +1997,7 @@ class database {
foreach ($field_value as $sub_row) { foreach ($field_value as $sub_row) {
//build the delete array //build the delete array
if ($action == 'delete' && $sub_row['checked'] == 'true') { if ($sub_row['checked'] == 'true') {
//delete the child data //delete the child data
$delete_array[$child_name][$y][$child_key_name] = $sub_row[$child_key_name]; $delete_array[$child_name][$y][$child_key_name] = $sub_row[$child_key_name];
+1 -1
View File
@@ -411,7 +411,7 @@ class domains {
if (is_array($uuids) && @sizeof($uuids) != 0) { if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0; $x = 0;
foreach ($rows as $row) { foreach ($rows as $row) {
+13 -9
View File
@@ -57,6 +57,10 @@
public $read_confirmation; public $read_confirmation;
public $error; public $error;
public $response; public $response;
public $headers;
public $content_type;
public $reply_to;
public $date;
/** /**
* Set in the constructor. Must be a database object and cannot be null. * Set in the constructor. Must be a database object and cannot be null.
@@ -554,19 +558,19 @@
$this->recipients = explode(';', $this->recipients); // convert to array of addresses $this->recipients = explode(';', $this->recipients); // convert to array of addresses
} }
foreach ($this->recipients as $this->recipient) { foreach ($this->recipients as $recipient) {
if (is_array($this->recipient)) { // check if each recipient has multiple fields if (is_array($recipient)) { // check if each recipient has multiple fields
if ($this->recipient["address"] != '' && valid_email($this->recipient["address"])) { // check if valid address if ($recipient["address"] != '' && valid_email($recipient["address"])) { // check if valid address
switch ($this->recipient["delivery"]) { switch ($recipient["delivery"]) {
case "cc" : $mail->AddCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break; case "cc" : $mail->AddCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break;
case "bcc" : $mail->AddBCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break; case "bcc" : $mail->AddBCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break;
default : $mail->AddAddress($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); default : $mail->AddAddress($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]);
} }
$address_found = true; $address_found = true;
} }
} }
else if ($this->recipient != '' && valid_email($this->recipient)) { // check if recipient value is simply (only) an address else if ($recipient != '' && valid_email($recipient)) { // check if recipient value is simply (only) an address
$mail->AddAddress($this->recipient); $mail->AddAddress($recipient);
$address_found = true; $address_found = true;
} }
} }
+2 -7
View File
@@ -52,8 +52,9 @@ class file {
* Glob search for a list of files * Glob search for a list of files
* @var string $dir this is the directory to scan * @var string $dir this is the directory to scan
* @var boolean $recursive get the sub directories * @var boolean $recursive get the sub directories
* @return array list of files or an empty array if not found
*/ */
public function glob($dir, $recursive) { public function glob($dir, $recursive): array {
$files = []; $files = [];
if ($dir != '' || $dir != '/') { if ($dir != '' || $dir != '/') {
$tree = glob(rtrim($dir, '/') . '/*'); $tree = glob(rtrim($dir, '/') . '/*');
@@ -69,12 +70,6 @@ class file {
} }
} }
} }
else {
$files[] = $file;
}
}
else {
$files[] = $file;
} }
return $files; return $files;
} }
+7 -7
View File
@@ -785,16 +785,16 @@
$menu_tags = ''; $menu_tags = '';
switch ($menu_item_category) { switch ($menu_item_category) {
case "internal": case "internal":
$menu_tags = "href='".PROJECT_PATH.$submenu_item_link."'"; $menu_tags = "href='".PROJECT_PATH.$menu_item_link."'";
break; break;
case "external": case "external":
if (substr($submenu_item_link, 0,1) == "/") { if (substr($menu_item_link, 0,1) == "/") {
$submenu_item_link = PROJECT_PATH.$submenu_item_link; $menu_item_link = PROJECT_PATH.$menu_item_link;
} }
$menu_tags = "href='".$submenu_item_link."' target='_blank'"; $menu_tags = "href='".$menu_item_link."' target='_blank'";
break; break;
case "email": case "email":
$menu_tags = "href='mailto:".$submenu_item_link."'"; $menu_tags = "href='mailto:".$menu_item_link."'";
break; break;
} }
@@ -805,11 +805,11 @@
$menu_html .= "<a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$menu_item_title."</h2></a>\n"; $menu_html .= "<a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$menu_item_title."</h2></a>\n";
} }
else { else {
if ($submenu_item_link == "/login.php" || $submenu_item_link == "/users/signup.php") { if ($menu_item_link == "/login.php" || $menu_item_link == "/users/signup.php") {
//hide login and sign-up when the user is logged in //hide login and sign-up when the user is logged in
} }
else { else {
if (empty($submenu_item_link)) { if (empty($menu_item_link)) {
$menu_html .= "<h2 align='center' style=''>".$menu_item_title."</h2>\n"; $menu_html .= "<h2 align='center' style=''>".$menu_item_title."</h2>\n";
} }
else { else {
+8 -8
View File
@@ -36,13 +36,13 @@
public $data_types; public $data_types;
//class constructor //class constructor
public function __construct() { public function __construct($setting_array) {
//includes files //includes files
require dirname(__DIR__, 2) . "/resources/require.php"; require dirname(__DIR__, 2) . "/resources/require.php";
//connect to the database //open a database connection
$this->database = database::new(); $this->database = $setting_array['database'] ?? database::new();
//get the list of installed apps from the core and mod directories //get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
@@ -122,7 +122,7 @@
$this->database->beginTransaction(); $this->database->beginTransaction();
//execute the sql query //execute the sql query
try { try {
$this->database->query($sql); $this->database->execute($sql, null);
} catch (PDOException $error) { } catch (PDOException $error) {
echo "error: " . $error->getMessage() . " sql: $sql<br/>"; echo "error: " . $error->getMessage() . " sql: $sql<br/>";
} }
@@ -138,7 +138,7 @@
return true; return true;
} }
} }
return $false; return false;
} }
//check if a column exists //check if a column exists
@@ -208,7 +208,7 @@
//database table exists alternate //database table exists alternate
private function db_table_exists_alternate($db_type, $table_name) { private function db_table_exists_alternate($db_type, $table_name) {
$sql = "select count(*) from $table_name "; $sql = "select count(*) from $table_name ";
$result = $this->database->query($sql); $result = $this->database->execute($sql, null);
if ($result > 0) { if ($result > 0) {
return true; //table exists return true; //table exists
} else { } else {
@@ -282,7 +282,7 @@
return true; return true;
} }
} }
return $false; return false;
} }
//database column exists //database column exists
@@ -839,7 +839,7 @@
foreach ($update_array as $sql) { foreach ($update_array as $sql) {
if (strlen(trim($sql))) { if (strlen(trim($sql))) {
try { try {
$this->database->db->query(trim($sql)); $this->database->execute(trim($sql), null);
if ($format == "text") { if ($format == "text") {
$response .= " $sql;\n"; $response .= " $sql;\n";
} }
+1 -1
View File
@@ -94,7 +94,7 @@ class sounds {
if (is_array($sound_files) && @sizeof($sound_files) != 0) { if (is_array($sound_files) && @sizeof($sound_files) != 0) {
foreach ($sound_files as $value) { foreach ($sound_files as $value) {
if (substr($value, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { if (substr($value, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") {
$value = substr($var, 71); $value = substr($value, 71);
} }
$array['sounds'][$x]['name'] = $value; $array['sounds'][$x]['name'] = $value;
$array['sounds'][$x]['value'] = $value; $array['sounds'][$x]['value'] = $value;
+1 -1
View File
@@ -295,7 +295,7 @@ class text {
} }
} }
} }
if(empty($append) && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) { if(empty($append) && array_key_exists($comment[$lang_label], $lang_code)) {
$append = " //$comment[$lang_label][$lang_code]"; $append = " //$comment[$lang_label][$lang_code]";
} }
fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n"); fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n");
+7 -2
View File
@@ -35,7 +35,7 @@
private $default_tone_label; private $default_tone_label;
private $database; private $database;
/** /**
* called when the object is created * called when the object is created
*/ */
public function __construct(array $setting_array = []) { public function __construct(array $setting_array = []) {
@@ -47,6 +47,11 @@
$this->database = $setting_array['database'] ?? database::new(); $this->database = $setting_array['database'] ?? database::new();
} }
/**
* tones_list function
*
* @return array
*/
public function tones_list() { public function tones_list() {
//get the tones //get the tones
$sql = "select * from v_vars "; $sql = "select * from v_vars ";
@@ -68,6 +73,6 @@
unset($sql, $tones, $tone); unset($sql, $tones, $tone);
//return the tones //return the tones
return $tone_list ?? ''; return $tone_list ?? [];
} }
} }
+5
View File
@@ -1,9 +1,14 @@
<?php <?php
/**
* xml class
*/
class xml { class xml {
/** /**
* Escapes xml special characters to html entities and sanitze switch special chars. * Escapes xml special characters to html entities and sanitze switch special chars.
* @param mixed $string
* @return void
*/ */
static function sanitize($string) { static function sanitize($string) {
$string = preg_replace('/\$\{[^}]+\}/', '', $string); $string = preg_replace('/\$\{[^}]+\}/', '', $string);