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

View File

@@ -216,7 +216,7 @@
//primary table
$sql = "select * from v_" . $this->table . " ";
$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) {
$y = 0;
foreach ($rows as $x => $row) {

View File

@@ -51,6 +51,9 @@
public $queue_description;
public $destination_number;
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.
@@ -526,7 +529,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$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) {
$y = 0;
foreach ($rows as $x => $row) {

View File

@@ -84,6 +84,8 @@
private $extension;
private $number_alias;
private $toll_allow;
private $toggle_field;
private $toggle_values;
/**
* called when the object is created
@@ -156,6 +158,10 @@
*/
public function toggle(array $records) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
@@ -170,10 +176,6 @@
//check we have permission for this action
if (permission_exists('call_forward')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
// initialize an empty array
$uuids = [];
$extensions = [];
@@ -262,7 +264,7 @@
$p->delete('extension_edit', 'temp');
//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) {
$feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $this->domain_name;

View File

@@ -51,6 +51,7 @@
public $debug;
public $extension_uuid;
public $extension;
public $number_alias;
public $enabled;
/**
@@ -110,7 +111,7 @@
$user_status = "Logged Out";
$esl = event_socket::create();
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);
}

View File

@@ -430,7 +430,7 @@
$p->delete('follow_me_edit', 'temp');
//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) {
$feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $this->domain_name;

View File

@@ -335,6 +335,7 @@
$call_recording_time = $row['call_recording_time'];
$call_recording_date_formatted = $row['call_recording_date_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'])) {
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 (!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);
}
@@ -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), '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 ";
if (!empty($storage_type) && $storage_type == 'base64' && $row['call_recording_base64'] != '') {
if (!empty($storage_type) && $storage_type == 'base64') {
$sql .= ", call_recording_base64 ";
}
$sql .= "from view_call_recordings ";

View File

@@ -124,7 +124,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
if ($not_admin) {
$sql .= "and r.conference_room_uuid = u.conference_room_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)) {
$sql .= "and r.conference_room_uuid = :conference_room_uuid ";

View File

@@ -86,6 +86,7 @@
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
private $tables;
/**
* Create a settings object using key/value pairs in the $setting_array.

View File

@@ -524,10 +524,10 @@
}
if ($regex_match) {
//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
if (strpos($field[dialplan_detail_data], '$') === false) {
$this->variables .= $field[dialplan_detail_data].",";
if (strpos($field['dialplan_detail_data'], '$') === false) {
$this->variables .= $field['dialplan_detail_data'].",";
}
}
//process the $x detail data variables
@@ -700,9 +700,12 @@
}
//define the values before they are used
$previous_dialplan_uuid = null;
$previous_dialplan_detail_group = null;
$dialplan_tag_status = null;
$previous_dialplan_uuid = '';
$previous_dialplan_detail_group = '';
$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
$x = 0;
@@ -869,7 +872,7 @@
}
//get the condition break attribute
$condition_break = "";
$condition_break = '';
if ($dialplan_detail_break) {
if (!empty($dialplan_detail_break)) {
$condition_break = " break=\"" . $dialplan_detail_break . "\"";
@@ -974,7 +977,7 @@
if ($condition_attribute && (!empty($condition_attribute))) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
}
else if (!empty($condition) && substr($string, -1) == ">") {
else if (!empty($condition) && substr($condition, -1) == ">") {
$xml .= $condition . "\n";
}
else if (!empty($condition)) {
@@ -1035,29 +1038,35 @@
$xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml");
foreach ($xml_list as $xml_file) {
//get and parse the xml
$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;
$xml_string = file_get_contents($xml_file);
$this->xml = $xml_string;
$this->import();
//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;
}
//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
$sql[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' ";
$sql[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' ";
$sql[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' ";
foreach ($sql as $query) {
$sql_array[] = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup' ";
$sql_array[] = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen' ";
$sql_array[] = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension' ";
foreach ($sql_array as $query) {
$this->database->execute($query);
}
unset($sql, $query);
unset($sql_array, $query);
//add xml for each dialplan where the dialplan xml is empty
$this->source = "details";

View File

@@ -219,7 +219,7 @@
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, 'all');
$rows = $this->database->select($sql, null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -286,7 +286,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$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) {
$x = 0;
foreach ($rows as $row) {
@@ -302,7 +302,7 @@
$array[$this->table][$x] = $row;
//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
$x++;

View File

@@ -68,6 +68,7 @@
private $toggle_values;
private $description_field;
private $location;
private $extension_uuid;
/**
* called when the object is created
@@ -117,6 +118,20 @@
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['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
@@ -130,13 +145,15 @@
unset($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $this->extension_uuid;
$extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]);
if (!empty($this->extension_uuid)) {
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $this->extension_uuid;
$extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete(gethostname().":directory:".$extension["number_alias"]."@".$extension["user_context"]);
}
//set message
message::add($text['message-delete']);
@@ -179,7 +196,7 @@
$parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$extension_uuid = $rows[0]['extension_uuid'];
$this->extension_uuid = $rows[0]['extension_uuid'];
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
@@ -208,7 +225,7 @@
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$parameters['extension_uuid'] = $this->extension_uuid;
$extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete(gethostname().":directory:".$extension["extension"]."@".$extension["user_context"]);
@@ -259,8 +276,6 @@
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
// var_dump($row); exit;
//convert boolean values to a string
foreach($row as $key => $value) {
if (gettype($value) == 'boolean') {
@@ -285,7 +300,6 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->save($array);
unset($array);

View File

@@ -246,6 +246,7 @@
$call_group = $row['call_group'] ?? '';
$call_group = str_replace(";", ",", $call_group);
$tmp_array = explode(",", $call_group);
$call_group_array = [];
foreach ($tmp_array as $tmp_call_group) {
$tmp_call_group = trim($tmp_call_group);
if (!empty($tmp_call_group)) {

View File

@@ -32,6 +32,7 @@
private $toggle_values;
private $description_field;
private $location;
private $uuid_prefix;
/**
* called when the object is created

View File

@@ -40,10 +40,17 @@
public $domain_uuid;
/**
* declare public variables
* declare ivr menu primary uuid key
* @var string
*/
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.
* @var database Database Object

View File

@@ -48,25 +48,25 @@
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
*/
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
*/
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
*/
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
*/
private $domain_name;
@@ -188,12 +188,18 @@
}
public function reload() {
//add multi-lingual support
$language = new text;
$text = $language->get();
//if the handle does not exist create it
$esl = event_socket::create();
//if the handle still does not exist show an error message
if (!$esl->is_connected()) {
$msg = "<div align='center'>".$text['message-event-socket']."<br /></div>";
}
//send the api command to check if the module exists
if ($esl->is_connected()) {
$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() {
//get the contents of the template
if (file_exists('/usr/share/examples/fusionpbx')) {
@@ -254,7 +218,7 @@
}
//check where the default music is stored
$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';
}
//replace the variables
@@ -262,7 +226,7 @@
$file_contents = preg_replace("/[\t ]*(?:<!--)?{v_moh_categories}(?:-->)?/", $this->xml, $file_contents);
//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);
fclose($fout);
@@ -288,7 +252,7 @@
//build an array of the sound files
$music_directory = $this->settings->get('switch', 'sounds').'/music';
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
@@ -309,10 +273,9 @@
foreach($a2 as $sample_rate => $file_path) {
//echo "domain_name ".$domain_name."<br />\n";
//echo "category_name ".$category_name."<br />\n";
foreach($domains as $domain) {
//view_array($field, false);
foreach($domains as $field) {
if ($field['domain_name'] === $domain_name) {
$domain_uuid = $domain['domain_uuid'];
$domain_uuid = $field['domain_uuid'];
//echo "domain_uuid ".$domain_uuid."<br />\n";
}
}
@@ -320,7 +283,6 @@
if ($domain_name == 'global' || $domain_name == 'default') {
$domain_uuid = null;
}
//view_array($row, false);
$array['music_on_hold'][$i]['music_on_hold_uuid'] = uuid();
$array['music_on_hold'][$i]['domain_uuid'] = $domain_uuid;
@@ -375,7 +337,6 @@
if (is_array($records) && @sizeof($records) != 0) {
//filter checked records
// view_array($records, 0);
foreach ($records as $music_on_hold_uuid => $record) {
if (is_uuid($music_on_hold_uuid)) {
if ($record['checked'] == 'true') {

View File

@@ -41,7 +41,6 @@
/**
* declare private variables
*/
private $database;
private $permission_prefix;
private $list_page;
@@ -49,7 +48,10 @@
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
public $xml;
private $json;
private $xml;
private $display_type;
/**
* called when the object is created
@@ -270,7 +272,7 @@
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 .= "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) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -338,7 +340,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$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) {
$y = 0;
foreach ($rows as $x => $row) {

View File

@@ -217,7 +217,7 @@
//send a request to a remote server to validate the MAC address and secret
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") {
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".escape($_REQUEST['mac']));
http_error('404');

View File

@@ -52,6 +52,7 @@
public $template_dir;
public $device_address;
public $device_template;
public $file;
/**
* Set in the constructor. Must be a database object and cannot be null.
@@ -555,33 +556,38 @@
//get a new primary key
$device_uuid = uuid();
//prepare the array
$x = 0;
$array['devices'][$x]['domain_uuid'] = $domain_uuid;
$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'];
//prepare the auto insert enabled
if (!empty($device_address)) {
$device_vendor = device::get_vendor($device_address);
//add the dialplan permission
$p = permissions::new();
$p->add("device_add", "temp");
$p->add("device_edit", "temp");
//prepare the array
$x = 0;
$array['devices'][$x]['domain_uuid'] = $domain_uuid;
$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
$this->database->app_name = 'devices';
$this->database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
if (!empty($device_uuid)) {
$this->database->uuid($device_uuid);
//add the dialplan permission
$p = permissions::new();
$p->add("device_add", "temp");
$p->add("device_edit", "temp");
//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");
}
}
//}

View File

@@ -1,6 +1,8 @@
<?php
function device_by_mac($device_address) {
global $database;
$sql = "select * from v_devices ";
$sql .= "where device_address = :device_address ";
$sql .= "and device_enabled = true ";
@@ -10,6 +12,8 @@ function device_by_mac($device_address) {
}
function device_by_ext($ext, $domain) {
global $database;
$sql = "select t1.* ";
$sql .= "from v_devices t1 ";
$sql .= "inner join v_device_lines t2 on t1.device_uuid = t2.device_uuid ";

View File

@@ -98,6 +98,10 @@
*/
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
$id = 0;
@@ -116,8 +120,6 @@
}
}
//get the default settings
$sql = "select sip_profile_name from v_sip_profiles ";
$sql .= "where true ";
@@ -142,10 +144,6 @@
//show an error message
if ($xml_response == "Invalid Profile!") {
//add multi-lingual support
$language = new text;
$text = $language->get(null, '/app/registrations');
//show the error message
$xml_response = "<error_msg>".escape($text['label-message'])."</error_msg>";
}
@@ -407,6 +405,7 @@
//set message
if (is_array($response_api)) {
$message = '';
foreach ($response_api as $registration_user => $response) {
if (is_array($response['command'])) {
foreach($response['command'] as $command) {

View File

@@ -78,6 +78,7 @@
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
private $dialplan_global;
public function __construct(array $setting_array = []) {
//set domain and user UUIDs

View File

@@ -33,20 +33,39 @@
class authentication {
/**
* Define variables and their scope
* Declare Public variables
*
* @var mixed
*/
private $database;
public $domain_uuid;
public $user_uuid;
public $domain_name;
public $username;
public $password;
public $key;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
private $settings;
/**
* Called when the object is created
*/
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;
}
@@ -68,7 +87,7 @@ class authentication {
}
//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
if (session_status() === PHP_SESSION_NONE) {
@@ -114,7 +133,7 @@ class authentication {
$object->password = $this->password;
}
//initialize the plugin send the authentication object and settings
$array = $object->$name($this, $settings);
$array = $object->$name($this, $this->settings);
//build a result array
if (!empty($array) && is_array($array)) {
@@ -187,11 +206,11 @@ class authentication {
//user is authorized - get user settings, check user cidr
if ($authorized) {
//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]);
$cidr_list = $settings->get('domain', 'cidr', []);
$this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
$cidr_list = $this->settings->get('domain', 'cidr', []);
if (check_cidr($cidr_list, $_SERVER['REMOTE_ADDR'])) {
//user passed the cidr check
self::create_user_session($result, $settings);
self::create_user_session($result, $this->settings);
} else {
//user failed the cidr check - no longer authorized
$authorized = false;
@@ -456,12 +475,10 @@ class authentication {
}
//set a default value for unqiue
if (empty($_SESSION["users"]["unique"]["text"])) {
$_SESSION["users"]["unique"]["text"] = 'false';
}
$_SESSION["users"]["unique"]["text"] = $this->settings->get('users', 'unique', '');
//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']);
if (count($username_array) > 1) {
//get the domain name

View File

@@ -57,6 +57,9 @@ class plugin_database {
//pre-process some settings
$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_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_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);
@@ -67,6 +70,12 @@ class plugin_database {
$login_destination = $settings->get('login', 'destination');
$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
$login_password_reset_enabled = false;
if (!empty($settings->get('login', 'password_reset_key'))) {

View File

@@ -41,6 +41,13 @@ class plugin_email {
public $contact_uuid;
public $debug;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
/**
* Called when the object is created
*/
@@ -60,6 +67,9 @@ class plugin_email {
//pre-process some settings
$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_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_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);

View File

@@ -8,15 +8,25 @@
class plugin_ldap {
/**
* Declare public variables
* Declare Public variables
*
* @var mixed
*/
public $debug;
public $domain_name;
public $domain_uuid;
public $username;
public $password;
public $user_uuid;
public $contact_uuid;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
/**
* Called when the object is created
*/
@@ -37,13 +47,14 @@ class plugin_ldap {
if ($_REQUEST["username"]) {
//pre-process some settings
$settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico';
$settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : '';
$settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : '';
$settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png';
$settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px';
$settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px';
$settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null;
$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');
$login_destination = $settings->get('login', 'destination');
$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');
$background_videos = $settings->get('theme', 'background_video', null);
$theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null;
$users_unique = $settings->get('users', 'unique', '');
//get the domain
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
@@ -72,12 +83,12 @@ class plugin_ldap {
//assign default values to the template
$view->assign("project_path", PROJECT_PATH);
$view->assign("login_destination_url", $settings['login']['destination']);
$view->assign("favicon", $settings['theme']['favicon']);
$view->assign("login_logo_width", $settings['theme']['login_logo_width']);
$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
$view->assign("login_logo_source", $settings['theme']['logo']);
$view->assign("background_video", $settings['theme']['background_video']);
$view->assign("login_destination_url", $login_destination);
$view->assign("favicon", $theme_favicon);
$view->assign("login_logo_width", $theme_login_logo_width);
$view->assign("login_logo_height", $theme_login_logo_height);
$view->assign("login_logo_source", $theme_logo);
$view->assign("background_video", $theme_background_video);
//add the token name and hash to the view
//$view->assign("token_name", $token['name']);
@@ -90,16 +101,16 @@ class plugin_ldap {
}
//use ldap to validate the user credentials
if (isset($_SESSION["ldap"]["certpath"])) {
$s = "LDAPTLS_CERT=" . $_SESSION["ldap"]["certpath"]["text"];
if (!empty($settings->get('ldap', 'certpath', ''))) {
$s = "LDAPTLS_CERT=" . $settings->get('ldap', 'certpath', '');
putenv($s);
}
if (isset($_SESSION["ldap"]["certkey"])) {
$s = "LDAPTLS_KEY=" . $_SESSION["ldap"]["certkey"]["text"];
if (!empty($settings->get('ldap', 'certkey', ''))) {
$s = "LDAPTLS_KEY=" . $settings->get('ldap', 'certkey', '');
putenv($s);
}
$host = $_SESSION["ldap"]["server_host"]["text"];
$port = $_SESSION["ldap"]["server_port"]["numeric"];
$host = $settings->get('ldap', 'server_host', '');
$port = $settings->get('ldap', 'server_port', '');
$connect = ldap_connect($host, $port)
or die("Could not connect to the LDAP server.");
//ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10);
@@ -110,13 +121,13 @@ class plugin_ldap {
$user_authorized = false;
//provide backwards compatability
if (!empty($_SESSION["ldap"]["user_dn"]["text"])) {
$_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"];
if (!empty($settings->get('ldap', 'user_dn', ''))) {
$ldap_user_dn[] = $settings->get('ldap', 'user_dn', '');
}
//check all user_dn in the array
foreach ($_SESSION["ldap"]["user_dn"] as $user_dn) {
$bind_dn = $_SESSION["ldap"]["user_attribute"]["text"]."=".$this->username.",".$user_dn;
foreach ($ldap_user_dn as $user_dn) {
$bind_dn = $settings->get('ldap', 'user_attribute', '')."=".$this->username.",".$user_dn;
$bind_pw = $this->password;
//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
@@ -135,7 +146,7 @@ class plugin_ldap {
if ($user_authorized) {
$sql = "select * from v_users ";
$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)
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
@@ -144,10 +155,14 @@ class plugin_ldap {
$parameters['username'] = $this->username;
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
//get the domain uuid
if (!empty($users_unique) && $users_unique == "global" && $row["domain_uuid"] != $this->domain_uuid) {
//set the domain uuid
$this->domain_uuid = $row["domain_uuid"];
$this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
//set the domain 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
$_SESSION["domain_uuid"] = $this->domain_uuid;
@@ -176,7 +191,7 @@ class plugin_ldap {
$array['users'][0]['username'] = strtolower($this->username);
$array['users'][0]['password'] = md5($salt.$password);
$array['users'][0]['salt'] = $salt;
$array['users'][0]['add_date'] = now();
$array['users'][0]['add_date'] = 'now()';
$array['users'][0]['add_user'] = strtolower($this->username);
$array['users'][0]['user_enabled'] = true;

View File

@@ -32,15 +32,25 @@
class plugin_totp {
/**
* Define variables and their scope
* Declare Public variables
*
* @var mixed
*/
public $debug;
public $domain_name;
public $domain_uuid;
public $username;
public $password;
public $user_uuid;
public $user_email;
public $contact_uuid;
/**
* Declare Private variables
*
* @var mixed
*/
private $database;
private $user_totp_secret;
/**
@@ -62,6 +72,9 @@ class plugin_totp {
//pre-process some settings
$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_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_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px');
$theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000);

View File

@@ -57,6 +57,7 @@
private $permission_prefix;
private $list_page;
private $tables;
private $table;
private $uuid_prefix;
/**

View File

@@ -328,47 +328,49 @@
$this->name = 'dashboard_widget';
$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
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($this->text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
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->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
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->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
}
//increment the id
$x++;
}
//increment the id
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->delete($array);
unset($array);
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
public function toggle_widgets($records) {
@@ -377,64 +379,66 @@
$this->table = 'dashboard_widgets';
$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
$language = new text;
$text = $language->get();
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($this->text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach($records as $record) {
if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$uuids[] = "'".$record['dashboard_widget_uuid']."'";
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach($records as $record) {
if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($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) {
$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);
}
unset($sql, $parameters, $rows, $row);
}
//build update array
$x = 0;
foreach($states as $uuid => $state) {
//create the array
$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];
//build update array
$x = 0;
foreach($states as $uuid => $state) {
//create the array
$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];
//increment the id
$x++;
}
//increment the id
$x++;
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->save($array);
unset($array);
$this->database->save($array);
unset($array);
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
public function assign_widgets($records, $dashboard_uuid, $group_uuid) {
@@ -442,76 +446,78 @@
$this->name = 'dashboard_widget';
$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
$language = new text;
$text = $language->get();
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$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);
//define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$group = $this->database->select($sql, $parameters, 'row');
}
//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']);
//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
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) {
@@ -519,85 +525,87 @@
$this->name = 'dashboard_widget';
$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
$language = new text;
$text = $language->get();
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//assign multiple records
if (is_array($records) && @sizeof($records) != 0 && !empty($group_uuid)) {
//define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$group = $this->database->select($sql, $parameters, 'row');
//define the group_name and group_uuid
if (!empty($records) && @sizeof($records) != 0) {
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$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
$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']."'";
unset($records);
//include child dashboard widgets and their dasboard_uuid too
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." ";
$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
$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'];
$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++;
$x++;
}
}
}
unset($records);
unset($uuids);
//include child dashboard widgets and their dasboard_uuid too
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." ";
$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
$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++;
}
}
}
//add the checked rows from group
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('dashboard_widget_group_delete', 'temp');
unset($uuids);
//execute delete
$this->database->delete($array);
unset($array);
//add the checked rows from group
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('dashboard_widget_group_delete', 'temp');
//revoke temporary permissions
$p->delete('dashboard_widget_group_delete', 'temp');
//execute delete
$this->database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('dashboard_widget_group_delete', 'temp');
//set message
message::add($text['message-delete']);
}
}
}
//set message
message::add($text['message-delete']);
}
}
}
}

View File

@@ -59,6 +59,7 @@
/**
* declare private variables
*/
private $domain_uuid;
private $permission_prefix;
private $list_page;
private $table;
@@ -211,7 +212,7 @@
$token = new token;
if (!$token->validate('/core/domain_settings/domain_settings.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
header('Location: '.$this->list_page);
exit;
}

View File

@@ -38,6 +38,7 @@
*/
private $database;
private $database_group_permissions;
/**
* called when the object is created

View File

@@ -120,7 +120,7 @@
}
//validate the username and password
$auth = new authentication;
$auth = new authentication(['settings' => $settings]);
$result = $auth->validate();
//if not authorized

View File

@@ -739,11 +739,11 @@ class database {
* <p><b>Note:</b><br>
* Table name must be sanitized. Otherwise, a warning will be
* 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.
* @depends connect()
*/
public function table_exists ($table_name) {
public function table_exists (string $table_name) {
if (self::sanitize($table_name) != $table_name) {
trigger_error('Table Name must be sanitized', E_USER_WARNING);
return false;
@@ -793,12 +793,12 @@ class database {
* <p><b>Note:</b><br>
* Tables and Column names must be sanitized. Otherwise, a warning will be
* emitted and false will be returned.</p>
* @param type $table_name Sanitized name of the table to search for.
* @param type $column_name Sanitized name of the column to search for.
* @param string $table_name Sanitized name of the table 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.
* @depends connect()
*/
public function column_exists ($table_name, $column_name) {
public function column_exists (string $table_name, string $column_name) {
//sanitize the table name
if (self::sanitize($table_name) != $table_name) {
trigger_error('Table Name must be sanitized', E_USER_WARNING);
@@ -955,7 +955,7 @@ class database {
if (is_array($this->where)) {
foreach($this->where as $row) {
//sanitize the name
$array['name'] = self::sanitize($array['name']);
$row['name'] = self::sanitize($row['name']);
//validate the operator
switch ($row['operator']) {
@@ -1997,7 +1997,7 @@ class database {
foreach ($field_value as $sub_row) {
//build the delete array
if ($action == 'delete' && $sub_row['checked'] == 'true') {
if ($sub_row['checked'] == 'true') {
//delete the child data
$delete_array[$child_name][$y][$child_key_name] = $sub_row[$child_key_name];

View File

@@ -411,7 +411,7 @@ class domains {
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$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) {
$x = 0;
foreach ($rows as $row) {

View File

@@ -57,6 +57,10 @@
public $read_confirmation;
public $error;
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.
@@ -554,19 +558,19 @@
$this->recipients = explode(';', $this->recipients); // convert to array of addresses
}
foreach ($this->recipients as $this->recipient) {
if (is_array($this->recipient)) { // check if each recipient has multiple fields
if ($this->recipient["address"] != '' && valid_email($this->recipient["address"])) { // check if valid address
switch ($this->recipient["delivery"]) {
case "cc" : $mail->AddCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break;
case "bcc" : $mail->AddBCC($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]); break;
default : $mail->AddAddress($this->recipient["address"], ($this->recipient["name"]) ? $this->recipient["name"] : $this->recipient["address"]);
foreach ($this->recipients as $recipient) {
if (is_array($recipient)) { // check if each recipient has multiple fields
if ($recipient["address"] != '' && valid_email($recipient["address"])) { // check if valid address
switch ($recipient["delivery"]) {
case "cc" : $mail->AddCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break;
case "bcc" : $mail->AddBCC($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]); break;
default : $mail->AddAddress($recipient["address"], ($recipient["name"]) ? $recipient["name"] : $recipient["address"]);
}
$address_found = true;
}
}
else if ($this->recipient != '' && valid_email($this->recipient)) { // check if recipient value is simply (only) an address
$mail->AddAddress($this->recipient);
else if ($recipient != '' && valid_email($recipient)) { // check if recipient value is simply (only) an address
$mail->AddAddress($recipient);
$address_found = true;
}
}

View File

@@ -52,8 +52,9 @@ class file {
* Glob search for a list of files
* @var string $dir this is the directory to scan
* @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 = [];
if ($dir != '' || $dir != '/') {
$tree = glob(rtrim($dir, '/') . '/*');
@@ -69,12 +70,6 @@ class file {
}
}
}
else {
$files[] = $file;
}
}
else {
$files[] = $file;
}
return $files;
}

View File

@@ -785,16 +785,16 @@
$menu_tags = '';
switch ($menu_item_category) {
case "internal":
$menu_tags = "href='".PROJECT_PATH.$submenu_item_link."'";
$menu_tags = "href='".PROJECT_PATH.$menu_item_link."'";
break;
case "external":
if (substr($submenu_item_link, 0,1) == "/") {
$submenu_item_link = PROJECT_PATH.$submenu_item_link;
if (substr($menu_item_link, 0,1) == "/") {
$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;
case "email":
$menu_tags = "href='mailto:".$submenu_item_link."'";
$menu_tags = "href='mailto:".$menu_item_link."'";
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";
}
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
}
else {
if (empty($submenu_item_link)) {
if (empty($menu_item_link)) {
$menu_html .= "<h2 align='center' style=''>".$menu_item_title."</h2>\n";
}
else {

View File

@@ -36,13 +36,13 @@
public $data_types;
//class constructor
public function __construct() {
public function __construct($setting_array) {
//includes files
require dirname(__DIR__, 2) . "/resources/require.php";
//connect to the database
$this->database = database::new();
//open a database connection
$this->database = $setting_array['database'] ?? database::new();
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
@@ -122,7 +122,7 @@
$this->database->beginTransaction();
//execute the sql query
try {
$this->database->query($sql);
$this->database->execute($sql, null);
} catch (PDOException $error) {
echo "error: " . $error->getMessage() . " sql: $sql<br/>";
}
@@ -138,7 +138,7 @@
return true;
}
}
return $false;
return false;
}
//check if a column exists
@@ -208,7 +208,7 @@
//database table exists alternate
private function db_table_exists_alternate($db_type, $table_name) {
$sql = "select count(*) from $table_name ";
$result = $this->database->query($sql);
$result = $this->database->execute($sql, null);
if ($result > 0) {
return true; //table exists
} else {
@@ -282,7 +282,7 @@
return true;
}
}
return $false;
return false;
}
//database column exists
@@ -839,7 +839,7 @@
foreach ($update_array as $sql) {
if (strlen(trim($sql))) {
try {
$this->database->db->query(trim($sql));
$this->database->execute(trim($sql), null);
if ($format == "text") {
$response .= " $sql;\n";
}

View File

@@ -94,7 +94,7 @@ class sounds {
if (is_array($sound_files) && @sizeof($sound_files) != 0) {
foreach ($sound_files as $value) {
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]['value'] = $value;

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]";
}
fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n");

View File

@@ -35,7 +35,7 @@
private $default_tone_label;
private $database;
/**
/**
* called when the object is created
*/
public function __construct(array $setting_array = []) {
@@ -47,6 +47,11 @@
$this->database = $setting_array['database'] ?? database::new();
}
/**
* tones_list function
*
* @return array
*/
public function tones_list() {
//get the tones
$sql = "select * from v_vars ";
@@ -68,6 +73,6 @@
unset($sql, $tones, $tone);
//return the tones
return $tone_list ?? '';
return $tone_list ?? [];
}
}

View File

@@ -1,9 +1,14 @@
<?php
/**
* xml class
*/
class xml {
/**
* Escapes xml special characters to html entities and sanitze switch special chars.
* @param mixed $string
* @return void
*/
static function sanitize($string) {
$string = preg_replace('/\$\{[^}]+\}/', '', $string);