Пример #1
0
function table_percent($id, $format = 'narrow')
{
    global $filters, $loaded_data, $field_names, $ua;
    if (isset($filters[$id])) {
        return;
    }
    if ($id == 'resource') {
        $data =& $loaded_data['pages'];
    } else {
        if ($id == 'source') {
            $data =& $loaded_data['visits']['source'];
        } else {
            $data =& $loaded_data['visits'][$id];
        }
    }
    if (empty($data)) {
        return;
    }
    arsort($data);
    $new_filters = $filters;
    $max_rows = 50;
    $size = sizeof($data);
    $total = array_sum($data);
    echo "<div class='tablewrap {$format}'>";
    // we have to do this to allow scrolling :(
    echo "<table><thead><tr><th>{$field_names[$id]} ({$size})<th>%<tbody>";
    $pos = 0;
    foreach ($data as $key => $hits) {
        $new_filters[$id] = $key;
        $pct = $total ? $hits / $total * 100 : 0;
        echo '<tr><td>';
        if ($id == 'browser') {
            echo '<a class="toggle" id="browser_' . $key . '">+</a> ';
        }
        $label = get_value_label($id, $key);
        echo filter_link($new_filters, $key == '' ? __('Unknown') : $label);
        echo '<td class="center">' . format_number($pct);
        if ($id == 'browser' && $key != '' && isset($loaded_data['visits']['version'][$key])) {
            arsort($loaded_data['visits']['version'][$key]);
            foreach ($loaded_data['visits']['version'][$key] as $key2 => $hits2) {
                $pct = $total > 0 ? $hits2 / $total * 100 : 0;
                echo '<tr class="detail detail_browser_' . $key . '">';
                echo '<td>' . htmlspecialchars($key2);
                echo '<td class="center">' . format_number($pct);
            }
        }
        $pos++;
        if ($pos >= $max_rows) {
            break;
        }
    }
    echo '</table></div>';
}
Пример #2
0
function render_page()
{
    global $ss;
    scripts_i18n();
    page_head();
    echo '<div id="main">';
    echo '<h2>' . __('Latest visitors') . '</h2>';
    $page_size = 20;
    $offset = isset($_GET['offset']) ? abs(intval($_GET['offset'])) : 0;
    $query = "SELECT * FROM `{$ss->tables['visits']}` ORDER BY `date` DESC, `start_time` DESC LIMIT {$offset},{$page_size}";
    $visits = array();
    if ($result = $ss->query($query)) {
        while ($assoc = @mysql_fetch_assoc($result)) {
            $visits[] = $assoc;
        }
    }
    $ua = new SimpleStatsUA();
    echo '<table id="paths" class="center wide" data-offset="' . $offset . '" data-page_size="' . $page_size . '"><thead>';
    echo '<tr><th colspan="2" class="left">' . __('IP Address') . '/' . __('Pages');
    echo '<th>' . __('Time');
    echo '<th>' . __('Browser');
    echo '<th>' . __('Operating system');
    echo '<th>' . __('Country');
    echo '<tbody>';
    foreach ($visits as $visit) {
        $start_ts = strtotime($visit['date'] . ' ' . $visit['start_time']);
        $hits = explode("\n", $visit['resource']);
        $dy_label = strftime('%d %b', $start_ts);
        $start_ts = date('H:i', $start_ts);
        $full_ua = $ss->options['log_user_agents'] && !empty($visit['user_agent']) ? $visit['user_agent'] : '';
        if ($visit['browser'] == 0) {
            $browser_name = '';
        } elseif ($visit['browser'] == 1) {
            $browser_name = __('(Robot)');
        } else {
            $browser_name = $ua->browser_name_from_id($visit['browser']);
        }
        $robot_class = $visit['browser'] == 1 ? ' bot' : '';
        $title = $full_ua ? ' title="' . htmlspecialchars($full_ua) . '"' : '';
        echo "<tr class='visit-header{$robot_class}'>";
        echo '<td colspan="2" class="left">' . htmlspecialchars($visit['remote_ip']);
        echo '<td>' . $dy_label . '</td>';
        echo "<td class='ua'{$title}>" . htmlspecialchars($browser_name) . ' ' . htmlspecialchars($visit['version']);
        echo '<td>' . htmlspecialchars($ua->platform_name_from_id($visit['platform']));
        echo '<td>' . htmlspecialchars(country_name($visit['country'])) . '</tr>';
        $row = 0;
        foreach ($hits as $hit) {
            if (empty($hit)) {
                continue;
            }
            @(list($time, $resource) = explode(' ', $hit, 2));
            // dump the seconds part of the time
            $time = substr($time, 0, 5);
            $r = htmlspecialchars($resource);
            echo '<tr class="hit">';
            echo '<td colspan="2" class="left"><a href="' . $r . '" class="goto">&rarr;</a> ' . filter_link(array('resource' => $resource), $resource) . "<td>{$time}";
            if ($row == 0 && !empty($visit['referrer'])) {
                echo '<td colspan="3" class="right">';
                if (!empty($visit['search_terms'])) {
                    echo filter_link(array('search_terms' => $visit['search_terms']), $visit['search_terms']);
                } else {
                    echo filter_link(array('domain' => $visit['domain']), $visit['domain']);
                }
                echo ' <a href="' . htmlspecialchars($visit['referrer']) . '" rel="external noreferrer" class="goto ext">&rarr;</a>';
            } else {
                echo '<td colspan="3">&nbsp;';
            }
            echo '</tr>';
            $row++;
        }
    }
    echo '</table>';
    echo '<nav class="center wide hide-if-no-js"><a class="ajax" style="display:block; padding: 5px" id="load-more">— ' . __('more') . ' —</a></nav>';
    echo '</div>';
    page_foot();
}
Пример #3
0
        echo h($row["user"]);
        ?>
"><?php 
        echo h($names[$row["user_id"]]["name"]);
        ?>
 (@<?php 
        echo h($row["user"]);
        ?>
)</a>
        </div>
        <div class="tweet-icon">
          <img src="<?php 
        echo h($names[$row["user_id"]]["icon"]);
        ?>
" alt="icon">
        </div>
        <div class="tweet-area">
          <div class="tweet-body">
            <?php 
        echo filter_link($row["body"]);
        ?>
          </div>
        </div>
      </div>
<?php 
    }
}
?>
    </div>
  </body>
</html>