if (isset($preferences['order_by']) && $preferences['order_by'] != "") {
    $orderby = $preferences['order_by'];
}
$start = time() - $preferences['log_period'];
$end = time();
$query = "SELECT SQL_CALC_FOUND_ROWS * FROM logs WHERE ctime > '{$start}' AND ctime <= '{$end}' {$msg_req}";
$query .= " ORDER BY ctime DESC, host_name ASC, log_id DESC, service_description ASC";
$query .= " LIMIT " . $page * $preferences['entries'] . "," . $preferences['entries'];
$res = $dbb->query($query);
$nbRows = $dbb->numberRows();
$data = array();
$outputLength = $preferences['output_length'] ? $preferences['output_length'] : 50;
if (!$centreon->user->admin) {
    $pearDB = $db;
    $aclObj = new CentreonACL($centreon->user->get_id(), $centreon->user->get_admin());
    $lca = array("LcaHost" => $aclObj->getHostServices($dbb, null, 1));
}
while ($row = $res->fetchRow()) {
    if (!$centreon->user->admin) {
        $continue = true;
        if (isset($row['host_id']) && isset($lca['LcaHost'][$row['host_id']])) {
            $continue = false;
        } elseif (isset($row['host_id']) && isset($row['service_description'])) {
            foreach ($lca['LcaHost'][$row['host_id']] as $key => $value) {
                if ($value == $row['service_description']) {
                    $continue = false;
                }
            }
        }
        if ($continue == true) {
            continue;