Пример #1
0
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>No authentication entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $string = "<table class=\"table table-bordered table-striped table-hover table-condensed table-rounded\">\n  <thead>\n    <tr>\n      <th style=\"width: 200px;\">Date</th>\n      <th style=\"width: 200px;\">User</th>\n      <th style=\"width: 200px;\">From</th>\n      <th>Action</th>\n    </tr>\n  </thead>\n  <tbody>";
        foreach ($authlog['entries'] as $entry) {
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>
        <td>' . $entry['user'] . '</td>
        <td>' . $entry['address'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}
Пример #2
0
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>No authentication entries found!</h4>');
    } else {
        $string = generate_box_open($vars['header']);
        // Entries have been returned. Print the table.
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        $cols = array('date' => array('Date', 'style="width: 150px;"'), 'user' => 'User', 'from' => 'From', 'ua' => array('User-Agent', 'style="width: 200px;"'), 'NONE' => 'Action');
        if ($vars['page'] == 'preferences') {
            unset($cols['user']);
        }
        $string .= get_table_header($cols);
        //, $vars); // Currently sorting is not available
        $string .= '<tbody>' . PHP_EOL;
        foreach ($authlog['entries'] as $entry) {
            if (strlen($entry['user_agent']) > 1) {
                $entry['detect_browser'] = detect_browser($entry['user_agent']);
                //r($entry['detect_browser']);
                $entry['user_agent'] = '<i class="' . $entry['detect_browser']['icon'] . '"></i>&nbsp;' . $entry['detect_browser']['browser_full'];
                if ($entry['detect_browser']['platform']) {
                    $entry['user_agent'] .= ' (' . $entry['detect_browser']['platform'] . ')';
                }
            }
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>';
            if (isset($cols['user'])) {
                $string .= '
        <td>' . escape_html($entry['user']) . '</td>';
            }
            $string .= '
        <td>' . ($_SESSION['userlevel'] > 5 ? generate_popup_link('ip', $entry['address']) : preg_replace('/^\\d+/', '*', $entry['address'])) . '</td>
        <td>' . $entry['user_agent'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>没有发现任何认证项目!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $string = '<table class="table table-bordered table-striped table-hover table-condensed table-rounded">' . PHP_EOL;
        $cols = array('date' => array('Date', 'style="width: 200px;"'), 'user' => '用户', 'from' => 'From', 'ua' => array('User-Agent', 'style="width: 200px;"'), 'NONE' => 'Action');
        $string .= get_table_header($cols);
        //, $vars); // Currently sorting is not available
        $string .= '<tbody>' . PHP_EOL;
        foreach ($authlog['entries'] as $entry) {
            if (strlen($entry['user_agent']) > 1) {
                $entry['detect_browser'] = detect_browser($entry['user_agent'], TRUE);
                $entry['user_agent'] = $entry['detect_browser']['browser'];
                if ($entry['detect_browser']['platform']) {
                    $entry['user_agent'] .= ' (' . $entry['detect_browser']['platform'] . ')';
                }
            }
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>
        <td>' . escape_html($entry['user']) . '</td>
        <td>' . $entry['address'] . '</td>
        <td>' . $entry['user_agent'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}