class = "databox filters"; $table->cellstyle = array(); $table->cellstyle[0] = array(); $table->cellstyle[1] = array(); $table->cellstyle[0][0] = "text-align: right;"; $table->cellstyle[0][1] = "text-align: left;"; $table->cellstyle[0][2] = "text-align: right;"; $table->cellstyle[0][3] = "text-align: left;"; $table->cellstyle[0][4] = "text-align: right;"; $table->cellstyle[0][5] = "text-align: left;"; $table->cellstyle[1][0] = "text-align: right;"; $table->cellstyle[1][1] = "text-align: left;"; $table->cellstyle[1][2] = "text-align: right;"; $table->cellstyle[1][3] = "text-align: left;"; $table->cellstyle[1][5] = "text-align: right;"; $table->data = array(); $data = array(); $data[0] = "" . __('Search') . ""; $data[1] = html_print_input_text("filter_text", $filter_text, __("Free text for search (*)"), 20, 40, true); $data[2] = "" . __("Max. hours old") . ""; $data[3] = html_print_input_text("filter_period", $filter_period, __("Max. hours old"), 3, 6, true); $data[4] = "" . __("IP") . ""; $data[5] = html_print_input_text("filter_ip", $filter_ip, __("IP"), 15, 15, true); $table->data[0] = $data; $data = array(); $actions_sql = "SELECT DISTINCT(accion), accion AS text FROM tsesion"; $data[0] = "" . __("Action") . ""; $data[1] = html_print_select_from_sql($actions_sql, "filter_type", $filter_type, "", __("All"), "", true); $users_sql = "SELECT id_user, id_user AS text FROM tusuario"; $data[2] = "" . __("User") . ""; $data[3] = html_print_select_from_sql($users_sql, "filter_user", $filter_user, "", __("All"), "", true); $data[4] = ""; $data[5] = html_print_submit_button(__("Filter"), "filter", false, 'class="sub search"', true); $table->data[1] = $data; $form = '
'; $form .= html_print_table($table, true); $form .= '
'; ui_toggle($form, __("Filter"), "", false); // ui_toggle(graphic_user_activity(400, 150), __("Chart")); $filter = "1=1"; if (!empty($filter_type)) { $filter .= sprintf (" AND accion = '%s'", $filter_type); } if (!empty($filter_user)) { $filter .= sprintf(" AND id_usuario = '%s'", $filter_user); } if (!empty($filter_text)) { $filter .= sprintf(" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $filter_text, $filter_text); } if (!empty($filter_ip)) { $filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $filter_ip); } if (!empty($filter_period)) { switch ($config["dbtype"]) { case "mysql": $filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -' . $filter_period . ' HOUR)'; break; case "postgresql": $filter .= ' AND fecha >= NOW() - INTERVAL \'' . $filter_period . ' HOUR \''; break; case "oracle": $filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_period . '\' HOUR)'; break; } } $count_sql = sprintf("SELECT COUNT(*) FROM tsesion WHERE %s", $filter); $count = (int) db_get_value_sql($count_sql); $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs" . $filter_query; ui_pagination($count, $url); switch ($config["dbtype"]) { case "mysql": $sql = sprintf( "SELECT * FROM tsesion WHERE %s ORDER BY fecha DESC LIMIT %d, %d", $filter, $offset, $config["block_size"] ); break; case "postgresql": $sql = sprintf( "SELECT * FROM tsesion WHERE %s ORDER BY fecha DESC LIMIT %d OFFSET %d", $filter, $config["block_size"], $offset ); break; case "oracle": $set = array(); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; $sql = sprintf( "SELECT * FROM tsesion WHERE %s ORDER BY fecha DESC", $filter ); $result = oracle_recode_query($sql, $set); break; } $result = db_get_all_rows_sql($sql); if (empty($result)) $result = array(); $table = new stdClass(); $table->cellpadding = 4; $table->cellspacing = 4; $table->width = '100%'; $table->class = "databox data"; $table->size = array(); $table->data = array(); $table->head = array(); $table->align = array(); $table->rowclass = array(); $table->head[0] = __('User'); $table->head[1] = __('Action'); $table->head[2] = __('Date'); $table->head[3] = __('Source IP'); $table->head[4] = __('Comments'); if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { $table->head[5] = enterprise_hook('tableHeadEnterpriseAudit', array('title1')); $table->head[6] = enterprise_hook('tableHeadEnterpriseAudit', array('title2')); } $table->size[0] = 80; $table->size[2] = 130; $table->size[3] = 100; $table->size[4] = 200; if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { $table->size[5] = enterprise_hook('tableHeadEnterpriseAudit', array('size1')); $table->size[6] = enterprise_hook('tableHeadEnterpriseAudit', array('size2')); $table->align[5] = enterprise_hook('tableHeadEnterpriseAudit', array('align')); $table->align[6] = enterprise_hook('tableHeadEnterpriseAudit', array('align2')); } $table->colspan = array(); $table->rowstyle = array(); $rowPair = true; $iterator = 0; // Get data foreach ($result as $row) { $iterator++; $table->rowclass[] = $rowPair ? "rowPair" : "rowOdd"; $rowPair = !$rowPair; $data = array(); $data[0] = $row["id_usuario"]; $data[1] = ui_print_session_action_icon($row["accion"], true) . $row["accion"]; $data[2] = ui_print_help_tip($row["fecha"], true) . ui_print_timestamp($row["utimestamp"], true); $data[3] = $row["ip_origen"]; $data[4] = $row["descripcion"]; if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { $data[5] = enterprise_hook("cell1EntepriseAudit", array($row["id_sesion"])); $data[6] = enterprise_hook("cell2EntepriseAudit", array($row["id_sesion"])); } $table->data[] = $data; if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { rowEnterpriseAudit($table, $iterator, $row["id_sesion"]); } } html_print_table($table); echo '
'; $csv_url = ui_get_full_url(false, false, false, false) . 'index.php?sec=gextensions&sec2=godmode/audit_log_csv' . $filter_query; echo '' . html_print_button(__("Export to CSV"), "export_csv", false, "", "class=sub upd", true, false) . ''; echo '
'; if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { enterprise_hook('enterpriseAuditFooter'); } ?>