|
@@ -62,10 +62,12 @@
|
|
|
}
|
|
|
|
|
|
//prepare the array
|
|
|
- foreach ($user_logs as $row) {
|
|
|
- $array['user_logs'][$x]['checked'] = $row['checked'];
|
|
|
- $array['user_logs'][$x]['user_log_uuid'] = $row['user_log_uuid'];
|
|
|
- $x++;
|
|
|
+ if (!empty($user_logs)) {
|
|
|
+ foreach ($user_logs as $row) {
|
|
|
+ $array['user_logs'][$x]['checked'] = $row['checked'];
|
|
|
+ $array['user_logs'][$x]['user_log_uuid'] = $row['user_log_uuid'];
|
|
|
+ $x++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//prepare the database object
|
|
@@ -74,10 +76,8 @@
|
|
|
$database->app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
|
|
|
|
|
|
//send the array to the database class
|
|
|
- if ($action == 'delete') {
|
|
|
- if (permission_exists('user_log_delete')) {
|
|
|
- $database->delete($array);
|
|
|
- }
|
|
|
+ if (!empty($action) && $action == 'delete' && permission_exists('user_log_delete')) {
|
|
|
+ $database->delete($array);
|
|
|
}
|
|
|
|
|
|
//redirect the user
|
|
@@ -89,24 +89,32 @@
|
|
|
$order_by = $_GET["order_by"] ?? null;
|
|
|
$order = $_GET["order"] ?? null;
|
|
|
|
|
|
-//add the search
|
|
|
- if (isset($_GET["search"])) {
|
|
|
+//define the variables
|
|
|
+ $search = '';
|
|
|
+ $show = '';
|
|
|
+
|
|
|
+//add the search variable
|
|
|
+ if (!empty($_GET["search"])) {
|
|
|
$search = strtolower($_GET["search"]);
|
|
|
- $search = htmlspecialchars($search);
|
|
|
+ }
|
|
|
+
|
|
|
+//add the show variable
|
|
|
+ if (!empty($_GET["show"])) {
|
|
|
+ $show = $_GET["show"];
|
|
|
}
|
|
|
|
|
|
//get the count
|
|
|
$sql = "select count(user_log_uuid) ";
|
|
|
$sql .= "from v_user_logs ";
|
|
|
- if (permission_exists('user_log_all') && !empty($_GET['show']) && $_GET['show'] == 'all') {
|
|
|
+ if (permission_exists('user_log_all') && $show == 'all') {
|
|
|
$sql .= "where true ";
|
|
|
}
|
|
|
else {
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
}
|
|
|
- if (isset($search)) {
|
|
|
- $sql .= "and (";
|
|
|
+ if (!empty($search)) {
|
|
|
+ $sql .= "and ( ";
|
|
|
$sql .= " lower(username) like :search ";
|
|
|
$sql .= " or lower(type) like :search ";
|
|
|
$sql .= " or lower(result) like :search ";
|
|
@@ -121,8 +129,8 @@
|
|
|
|
|
|
//prepare to page the results
|
|
|
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
|
|
- $param = !empty($search) ? "search=".$search : null;
|
|
|
- $param .= !empty($_GET['show']) && $_GET['show'] == 'all' && permission_exists('user_log_all') ? "&show=all" : null;
|
|
|
+ $param = !empty($search) ? "&search=".$search : null;
|
|
|
+ $param .= (!empty($_GET['page']) && $show == 'all' && permission_exists('user_log_all')) ? "&show=all" : 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);
|
|
@@ -139,25 +147,26 @@
|
|
|
|
|
|
//get the list
|
|
|
$sql = "select ";
|
|
|
- $sql .= "domain_uuid, ";
|
|
|
$sql .= "user_log_uuid, ";
|
|
|
- $sql .= "timestamp, ";
|
|
|
- $sql .= "to_char(timezone(:time_zone, timestamp), 'DD Mon YYYY') as date_formatted, \n";
|
|
|
- $sql .= "to_char(timezone(:time_zone, timestamp), 'HH12:MI:SS am') as time_formatted, \n";
|
|
|
+ $sql .= "u.domain_uuid, ";
|
|
|
+ $sql .= "d.domain_name, ";
|
|
|
+ $sql .= "to_char(timezone(:time_zone, timestamp), 'DD Mon YYYY') as date_formatted, ";
|
|
|
+ $sql .= "to_char(timezone(:time_zone, timestamp), 'HH12:MI:SS am') as time_formatted, ";
|
|
|
+ $sql .= "user_uuid, ";
|
|
|
$sql .= "username, ";
|
|
|
$sql .= "type, ";
|
|
|
$sql .= "result, ";
|
|
|
$sql .= "remote_address, ";
|
|
|
$sql .= "user_agent ";
|
|
|
- $sql .= "from v_user_logs ";
|
|
|
- if (permission_exists('user_log_all') && !empty($_GET['show']) && $_GET['show'] == 'all') {
|
|
|
+ $sql .= "from v_user_logs as u, v_domains as d ";
|
|
|
+ if (permission_exists('user_log_all') && $show == 'all') {
|
|
|
$sql .= "where true ";
|
|
|
}
|
|
|
else {
|
|
|
- $sql .= "where domain_uuid = :domain_uuid ";
|
|
|
+ $sql .= "where u.domain_uuid = :domain_uuid ";
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
}
|
|
|
- if (isset($search)) {
|
|
|
+ if (!empty($search)) {
|
|
|
$sql .= "and ( ";
|
|
|
$sql .= " lower(username) like :search ";
|
|
|
$sql .= " or lower(type) like :search ";
|
|
@@ -167,10 +176,11 @@
|
|
|
$sql .= ") ";
|
|
|
$parameters['search'] = '%'.$search.'%';
|
|
|
}
|
|
|
+ $sql .= "and u.domain_uuid = d.domain_uuid ";
|
|
|
$sql .= order_by($order_by, $order, 'timestamp', 'desc');
|
|
|
$sql .= limit_offset($rows_per_page, $offset);
|
|
|
$database = new database;
|
|
|
- $user_logs = $database->select($sql, $parameters, 'all');
|
|
|
+ $user_logs = $database->select($sql, $parameters ?? null, 'all');
|
|
|
unset($sql, $parameters);
|
|
|
|
|
|
//create token
|
|
@@ -190,16 +200,15 @@
|
|
|
}
|
|
|
echo "<form id='form_search' class='inline' method='get'>\n";
|
|
|
if (permission_exists('user_log_all')) {
|
|
|
- if (!empty($_GET['show']) && $_GET['show'] == 'all') {
|
|
|
+ if ($show == 'all') {
|
|
|
echo " <input type='hidden' name='show' value='all'>\n";
|
|
|
}
|
|
|
else {
|
|
|
- echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all'.(!empty($search) ? '&search='.urlencode($search) : null)]);
|
|
|
+ echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&search='.$search]);
|
|
|
}
|
|
|
}
|
|
|
- echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search ?? '')."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
|
|
|
+ echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
|
|
|
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']);
|
|
|
- //echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'user_logs.php','style'=>($search == '' ? 'display: none;' : null)]);
|
|
|
if ($paging_controls_mini != '') {
|
|
|
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
|
|
}
|
|
@@ -221,12 +230,12 @@
|
|
|
|
|
|
echo "<table class='list'>\n";
|
|
|
echo "<tr class='list-header'>\n";
|
|
|
- if (permission_exists('user_log_add') || permission_exists('user_log_edit') || permission_exists('user_log_delete')) {
|
|
|
+ if (permission_exists('user_log_delete')) {
|
|
|
echo " <th class='checkbox'>\n";
|
|
|
- echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($user_logs) ? "style='visibility: hidden;'" : null).">\n";
|
|
|
+ echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".empty($user_logs ? "style='visibility: hidden;'" : null).">\n";
|
|
|
echo " </th>\n";
|
|
|
}
|
|
|
- if (!empty($_GET['show']) && $_GET['show'] == 'all' && permission_exists('user_log_all')) {
|
|
|
+ if ($show == 'all' && permission_exists('user_log_all')) {
|
|
|
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
|
|
|
}
|
|
|
echo "<th class='left'>".$text['label-date']."</th>\n";
|
|
@@ -236,24 +245,20 @@
|
|
|
echo th_order_by('result', $text['label-result'], $order_by, $order);
|
|
|
echo th_order_by('remote_address', $text['label-remote_address'], $order_by, $order);
|
|
|
echo th_order_by('user_agent', $text['label-user_agent'], $order_by, $order);
|
|
|
- if (permission_exists('user_log_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
|
|
- echo " <td class='action-button'> </td>\n";
|
|
|
- }
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
if (!empty($user_logs) && is_array($user_logs) && @sizeof($user_logs) != 0) {
|
|
|
$x = 0;
|
|
|
foreach ($user_logs as $row) {
|
|
|
- $list_row_url = permission_exists('user_log_edit') ? "user_log_edit.php?id=".urlencode($row['user_log_uuid']) : null;
|
|
|
- echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
|
|
- if (permission_exists('user_log_add') || permission_exists('user_log_edit') || permission_exists('user_log_delete')) {
|
|
|
+ echo "<tr class='list-row'>\n";
|
|
|
+ if (permission_exists('user_log_delete')) {
|
|
|
echo " <td class='checkbox'>\n";
|
|
|
echo " <input type='checkbox' name='user_logs[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
|
|
echo " <input type='hidden' name='user_logs[$x][user_log_uuid]' value='".escape($row['user_log_uuid'])."' />\n";
|
|
|
echo " </td>\n";
|
|
|
}
|
|
|
- if (!empty($_GET['show']) && $_GET['show'] == 'all' && permission_exists('user_log_all')) {
|
|
|
- echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
|
|
|
+ if ($show == 'all' && permission_exists('user_log_all')) {
|
|
|
+ echo " <td>".escape($row['domain_name'])."</td>\n";
|
|
|
}
|
|
|
echo " <td>".escape($row['date_formatted'])."</td>\n";
|
|
|
echo " <td class='left hide-md-dn'>".escape($row['time_formatted'])."</td>\n";
|
|
@@ -262,11 +267,6 @@
|
|
|
echo " <td>".escape($row['result'])."</td>\n";
|
|
|
echo " <td>".escape($row['remote_address'])."</td>\n";
|
|
|
echo " <td>".escape($row['user_agent'])."</td>\n";
|
|
|
- if (permission_exists('user_log_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
|
|
- echo " <td class='action-button'>\n";
|
|
|
- echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
|
|
- echo " </td>\n";
|
|
|
- }
|
|
|
echo "</tr>\n";
|
|
|
$x++;
|
|
|
}
|