Remove the unset($database) statements (#7084)
* Remove the unset($database) statements The database object is a global variable that contains a database object reference and should not be unset. * Update event_guard.php * Update event_guard.php * Update event_guard.php --------- Co-authored-by: Tim Fry <tim@fusionpbx.com> Co-authored-by: FusionPBX <markjcrane@gmail.com>
This commit is contained in:
parent
c960575796
commit
7630056bb8
|
|
@ -102,6 +102,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
//connect to the database
|
||||
$database = database::new();
|
||||
|
||||
//test a specific address
|
||||
//$ip_address = '10.7.0.253';
|
||||
//$result = access_allowed($ip_address);
|
||||
|
|
@ -174,11 +177,11 @@
|
|||
}
|
||||
|
||||
//debug info
|
||||
//if ($debug) {
|
||||
//if ($debug) {
|
||||
// print_r($json_array);
|
||||
//}
|
||||
|
||||
//registration failed - block IP address unless they are registered,
|
||||
//registration failed - block IP address unless they are registered
|
||||
if (is_array($json_array) && $json_array['Event-Subclass'] == 'sofia::register_failure') {
|
||||
//not registered so block the address
|
||||
if (!access_allowed($json_array['network-ip'])) {
|
||||
|
|
@ -195,9 +198,7 @@
|
|||
$sql .= "and hostname = :hostname ";
|
||||
//if ($debug) { echo $sql." ".$hostname."\n"; }
|
||||
$parameters['hostname'] = $hostname;
|
||||
$database = new database;
|
||||
$event_guard_logs = $database->select($sql, $parameters, 'all');
|
||||
unset($database);
|
||||
if (is_array($event_guard_logs)) {
|
||||
foreach($event_guard_logs as $row) {
|
||||
//unblock the ip address
|
||||
|
|
@ -222,13 +223,12 @@
|
|||
if (is_array($array)) {
|
||||
$p = new permissions;
|
||||
$p->add('event_guard_log_edit', 'temp');
|
||||
$database = new database;
|
||||
$database->app_name = 'event guard';
|
||||
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
|
||||
$database->save($array);
|
||||
//$message = $database->message;
|
||||
$p->delete('event_guard_log_edit', 'temp');
|
||||
unset($database, $array);
|
||||
unset($array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@
|
|||
//block an ip address
|
||||
function block($ip_address, $filter, $event) {
|
||||
//define the global variables
|
||||
global $firewall_path, $firewall_name;
|
||||
global $database, $debug, $firewall_path, $firewall_name;
|
||||
|
||||
//invalid ip address
|
||||
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
|
||||
|
|
@ -332,6 +332,7 @@
|
|||
closelog();
|
||||
|
||||
//log the blocked ip address to the database
|
||||
$array = [];
|
||||
$array['event_guard_logs'][0]['event_guard_log_uuid'] = uuid();
|
||||
$array['event_guard_logs'][0]['hostname'] = gethostname();
|
||||
$array['event_guard_logs'][0]['log_date'] = 'now()';
|
||||
|
|
@ -342,26 +343,22 @@
|
|||
$array['event_guard_logs'][0]['log_status'] = 'blocked';
|
||||
$p = new permissions;
|
||||
$p->add('event_guard_log_add', 'temp');
|
||||
$database = new database;
|
||||
$database->app_name = 'event guard';
|
||||
$database->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
|
||||
$database->save($array);
|
||||
$p->delete('event_guard_log_add', 'temp');
|
||||
unset($database, $array);
|
||||
|
||||
//send debug information to the console
|
||||
if ($debug) {
|
||||
echo "blocked address ".$ip_address .", line ".__line__."\n";
|
||||
}
|
||||
|
||||
//unset the array
|
||||
unset($event);
|
||||
}
|
||||
|
||||
//unblock the ip address
|
||||
function unblock($ip_address, $filter) {
|
||||
//define the global variables
|
||||
global $firewall_path, $firewall_name;
|
||||
global $debug, $firewall_path, $firewall_name;
|
||||
|
||||
//invalid ip address
|
||||
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
|
||||
|
|
@ -536,6 +533,8 @@
|
|||
//determine if the IP address has been allowed by the access control list node cidr
|
||||
function access_control_allowed($ip_address) {
|
||||
|
||||
global $database;
|
||||
|
||||
//invalid ip address
|
||||
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
|
||||
return false;
|
||||
|
|
@ -547,9 +546,7 @@
|
|||
$sql .= "where node_type = 'allow' ";
|
||||
$sql .= "and length(node_cidr) > 0 ";
|
||||
$parameters = null;
|
||||
$database = new database;
|
||||
$allowed_nodes = $database->select($sql, $parameters, 'all');
|
||||
unset($database);
|
||||
|
||||
//default authorized to false
|
||||
$allowed = false;
|
||||
|
|
@ -580,6 +577,8 @@
|
|||
//determine if the IP address has been allowed by a successful authentication
|
||||
function user_log_allowed($ip_address) {
|
||||
|
||||
global $database, $debug;
|
||||
|
||||
//invalid ip address
|
||||
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
|
||||
return false;
|
||||
|
|
@ -591,10 +590,8 @@
|
|||
$sql .= "where remote_address = :remote_address ";
|
||||
$sql .= "and result = 'success' ";
|
||||
$sql .= "and timestamp > NOW() - INTERVAL '8 days' ";
|
||||
$parameters['remote_address'] = $ip_address;
|
||||
$database = new database;
|
||||
$parameters['remote_address'] = $ip_address;
|
||||
$user_log_count = $database->select($sql, $parameters, 'column');
|
||||
unset($database);
|
||||
|
||||
//debug info
|
||||
if ($debug) {
|
||||
|
|
@ -616,6 +613,8 @@
|
|||
//determine if the IP address has been unblocked in the event guard log
|
||||
function event_guard_log_allowed($ip_address) {
|
||||
|
||||
global $database, $debug;
|
||||
|
||||
//invalid ip address
|
||||
if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
|
||||
return false;
|
||||
|
|
@ -626,10 +625,8 @@
|
|||
$sql .= "from v_event_guard_logs ";
|
||||
$sql .= "where ip_address = :ip_address ";
|
||||
$sql .= "and log_status = 'unblocked' ";
|
||||
$parameters['ip_address'] = $ip_address;
|
||||
$database = new database;
|
||||
$parameters['ip_address'] = $ip_address;
|
||||
$user_log_count = $database->select($sql, $parameters, 'column');
|
||||
unset($database);
|
||||
|
||||
//debug info
|
||||
if ($debug) {
|
||||
|
|
@ -651,7 +648,7 @@
|
|||
//add IP table chains
|
||||
function iptables_chain_add($chain) {
|
||||
//define the global variables
|
||||
global $firewall_path, $firewall_name;
|
||||
global $firewall_path;
|
||||
|
||||
//if the chain exists return true
|
||||
if (iptables_chain_exists($chain)) {
|
||||
|
|
@ -679,7 +676,7 @@
|
|||
//check if the iptables chain exists
|
||||
function iptables_chain_exists($chain) {
|
||||
//define the global variables
|
||||
global $firewall_path, $firewall_name;
|
||||
global $firewall_path;
|
||||
|
||||
//build the command to check if the iptables chain exists
|
||||
$command = $firewall_path."/./iptables --list INPUT --numeric | grep ".$chain." | awk '{print \$1}' | sed ':a;N;\$!ba;s/\\n/,/g' ";
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//connect to database
|
||||
$database = database::new();
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
|
@ -64,7 +67,6 @@
|
|||
$sql = "select count(*) from v_ring_groups ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$total_ring_groups = $database->select($sql, $parameters ?? null, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
|
|
@ -83,7 +85,6 @@
|
|||
$sql = "select domain_uuid from v_ring_groups ";
|
||||
$sql .= "where ring_group_uuid = :ring_group_uuid ";
|
||||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$database = new database;
|
||||
$domain_uuid = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
|
@ -113,7 +114,6 @@
|
|||
$p->add('ring_group_user_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->delete($array);
|
||||
|
|
@ -135,7 +135,6 @@
|
|||
$sql = "select count(*) from v_ring_groups ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$total_ring_groups = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
|
|
@ -222,7 +221,6 @@
|
|||
$sql = "select * from v_ring_groups ";
|
||||
$sql .= "where ring_group_uuid = :ring_group_uuid ";
|
||||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (!empty($row)) {
|
||||
//if (!permission_exists(‘ring_group_domain')) {
|
||||
|
|
@ -253,7 +251,6 @@
|
|||
$p->add('ring_group_user_add', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->save($array);
|
||||
|
|
@ -431,9 +428,8 @@
|
|||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$parameters['range_first_extension'] = $range_first_extension;
|
||||
$parameters['range_second_extension'] = $range_second_extension;
|
||||
$database = new database;
|
||||
$extensions = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters, $database);
|
||||
unset($sql, $parameters);
|
||||
// echo var_dump($extensions);
|
||||
foreach ($extensions as $extension) {
|
||||
$array["ring_groups"][0]["ring_group_destinations"][$y]["ring_group_uuid"] = $ring_group_uuid;
|
||||
|
|
@ -493,7 +489,6 @@
|
|||
$p->add("dialplan_edit", "temp");
|
||||
|
||||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->save($array);
|
||||
|
|
@ -547,7 +542,6 @@
|
|||
$sql = "select * from v_ring_groups ";
|
||||
$sql .= "where ring_group_uuid = :ring_group_uuid ";
|
||||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
|
|
@ -602,7 +596,6 @@
|
|||
$sql .= "order by destination_delay, destination_number asc ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$database = new database;
|
||||
$ring_group_destinations = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
|
@ -637,7 +630,6 @@
|
|||
$sql .= "order by u.username asc ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['ring_group_uuid'] = $ring_group_uuid;
|
||||
$database = new database;
|
||||
$ring_group_users = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
|
@ -648,7 +640,6 @@
|
|||
$sql .= "and user_enabled = 'true' ";
|
||||
$sql .= "order by username asc ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$users = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ if ($domains_processed == 1) {
|
|||
$p->delete("var_edit", "temp");
|
||||
}
|
||||
|
||||
|
||||
//set country depend variables as country code and international direct dialing code (exit code)
|
||||
if (!function_exists('set_country_vars')) {
|
||||
function set_country_vars($database, $x) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@
|
|||
$_GET['show'] = 'false';
|
||||
}
|
||||
|
||||
//connect to database
|
||||
$database = database::new();
|
||||
|
||||
//get post or get variables from http
|
||||
if (!empty($_REQUEST)) {
|
||||
$cdr_id = $_REQUEST["cdr_id"] ?? '';
|
||||
|
|
@ -571,7 +574,6 @@
|
|||
}
|
||||
}
|
||||
$sql = str_replace(" ", " ", $sql);
|
||||
$database = new database;
|
||||
if ($archive_request && $_SESSION['cdr']['archive_database']['boolean'] == 'true') {
|
||||
$database->driver = $_SESSION['cdr']['archive_database_driver']['text'];
|
||||
$database->host = $_SESSION['cdr']['archive_database_host']['text'];
|
||||
|
|
@ -583,7 +585,7 @@
|
|||
}
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
$result_count = is_array($result) ? sizeof($result) : 0;
|
||||
unset($database, $sql, $parameters);
|
||||
unset($sql, $parameters);
|
||||
|
||||
//return the paging
|
||||
if (empty($_REQUEST['export_format'])) {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//connect to database
|
||||
$database = database::new();
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
|
@ -78,7 +81,6 @@
|
|||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) from v_databases ";
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, null, 'column');
|
||||
|
||||
//prepare to page the results
|
||||
|
|
@ -92,7 +94,6 @@
|
|||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= order_by($order_by, $order);
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$databases = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//connect to database
|
||||
$database = database::new();
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
|
@ -136,7 +139,6 @@
|
|||
$array['groups'][0]['group_description'] = $group_description;
|
||||
|
||||
//save the data
|
||||
$database = new database;
|
||||
$database->app_name = 'Group Manager';
|
||||
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
|
||||
$database->save($array);
|
||||
|
|
@ -150,11 +152,10 @@
|
|||
$parameters['group_name'] = $group_name;
|
||||
$parameters['group_name_previous'] = $group_name_previous;
|
||||
$parameters['group_uuid'] = $group_uuid;
|
||||
$database = new database;
|
||||
$database->app_name = 'Group Manager';
|
||||
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
|
||||
$database->execute($sql, $parameters);
|
||||
unset($sql, $parameters, $database);
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
|
|
@ -177,7 +178,6 @@
|
|||
//$sql .= "and domain_uuid = :domain_uuid ";
|
||||
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['group_uuid'] = $group_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (!empty($row)) {
|
||||
$group_name = $row["group_name"];
|
||||
|
|
|
|||
Loading…
Reference in New Issue