Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions if (!permission_exists('event_guard_log_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the http post data if (!empty($_POST['event_guard_logs']) && is_array($_POST['event_guard_logs'])) { $action = $_POST['action']; $search = $_POST['search'] ?? ''; $event_guard_logs = $_POST['event_guard_logs']; } //process the http post data by action if (!empty($action) && !empty($event_guard_logs) && is_array($event_guard_logs) && @sizeof($event_guard_logs) != 0) { switch ($action) { case 'copy': if (permission_exists('event_guard_log_add')) { $obj = new event_guard; $obj->copy($event_guard_logs); } break; case 'toggle': //if (permission_exists('event_guard_log_edit')) { // $obj = new event_guard; // $obj->toggle($event_guard_logs); //} //break; case 'delete': if (permission_exists('event_guard_log_delete')) { $obj = new event_guard; $obj->unblock($event_guard_logs); } break; } //redirect the user header('Location: event_guard_logs.php'.($search != '' ? '?search='.urlencode($search) : '')); exit; } //get order and order by $order_by = $_GET["order_by"] ?? null; $order = $_GET["order"] ?? null; //add the search if (!empty($_GET["search"])) { $search = $_GET["search"]; } //get the count $sql = "select count(event_guard_log_uuid) "; $sql .= "from v_event_guard_logs "; $sql .= "where true "; if (isset($search)) { $sql .= "and ("; $sql .= " lower(hostname) like :search "; $sql .= " or filter like :search "; $sql .= " or ip_address like :search "; $sql .= " or extension like :search "; $sql .= " or lower(user_agent) like :search "; $sql .= " or lower(log_status) like :search "; $sql .= ") "; $parameters['search'] = '%'.strtolower($search).'%'; } if (isset($_GET["filter"]) && $_GET["filter"] != '') { $sql .= "and filter = :filter "; $parameters['filter'] = $_GET["filter"]; } $num_rows = $database->select($sql, $parameters ?? null, 'column'); unset($sql, $parameters); //prepare to page the results $rows_per_page = $settings->get('domain', 'paging', 50); $param = !empty($search) ? "&search=".$search : null; $page = !empty($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); //set the time format options: 12h, 24h if ($settings->get('domain', 'time_format') == '24h') { $time_format = 'HH24:MI:SS'; } else { $time_format = 'HH12:MI:SS am'; } //get the list $sql = "select "; $sql .= "event_guard_log_uuid, "; $sql .= "hostname, "; $sql .= "log_date, "; $sql .= "to_char(timezone(:time_zone, log_date), 'DD Mon YYYY') as log_date_formatted, \n"; $sql .= "to_char(timezone(:time_zone, log_date), '".$time_format."') as log_time_formatted, \n"; $sql .= "filter, "; $sql .= "ip_address, "; $sql .= "extension, "; $sql .= "user_agent, "; $sql .= "log_status "; $sql .= "from v_event_guard_logs "; $sql .= "where true "; if (!empty($search)) { $sql .= "and ("; $sql .= " lower(hostname) like :search "; $sql .= " or filter like :search "; $sql .= " or ip_address like :search "; $sql .= " or extension like :search "; $sql .= " or lower(user_agent) like :search "; $sql .= " or lower(log_status) like :search "; $sql .= ") "; $parameters['search'] = '%'.strtolower($search).'%'; } if (!empty($_GET["filter"])) { $sql .= "and filter = :filter "; $parameters['filter'] = $_GET["filter"]; } $sql .= order_by($order_by, $order, 'log_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); $parameters['time_zone'] = $time_zone; $event_guard_logs = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //additional includes $document['title'] = $text['title-event_guard_logs']; require_once "resources/header.php"; //show the content echo "
\n"; if (permission_exists('event_guard_log_add') && $event_guard_logs) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]); } if (permission_exists('event_guard_log_edit') && $event_guard_logs) { echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]); } if (permission_exists('event_guard_log_delete') && $event_guard_logs) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); } echo $text['title_description-event_guard_logs']."\n"; echo "