htdocs/ajax-active.php
author Dan
Tue, 20 Jan 2009 22:08:17 -0500
changeset 52 a8f0e99883d1
permissions -rw-r--r--
Web interface can now update with AJAX
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     1
<?php
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     2
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     3
require_once('../stats-fe.php');
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     4
require_once('../timezone.php');
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     5
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     6
if ( !isset($channel) )
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     7
{
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     8
  $channel_list = stats_channel_list();
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
     9
  $first_channel = $channel_list[0];
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    10
  $channel = ( isset($_REQUEST['channel']) && in_array($_REQUEST['channel'], $channel_list) ) ? $_REQUEST['channel'] : $first_channel;
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    11
}
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    12
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    13
?>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    14
    <h1>Active members</h1>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    15
    <p>For the last 1, 5, and 15 minutes:
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    16
        <?php echo count(stats_activity_percent($channel, 1)) . ', ' .
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    17
                   count(stats_activity_percent($channel, 5)) . ', ' .
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    18
                   count(stats_activity_percent($channel, 15)) . ' (respectively)';
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    19
        ?>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    20
        </p>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    21
    <h1>Currently active members:</h1>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    22
    <p>These people have posted in the last 3 minutes:</p>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    23
    <ul>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    24
      <?php
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    25
      $datum = stats_activity_percent($channel, 3);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    26
      $count = stats_message_count($channel, 3);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    27
      if ( empty($datum) )
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    28
        echo '<li>No recent posts.</li>';
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    29
      foreach ( $datum as $usernick => $pct )
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    30
      {
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    31
        $total = round($pct * $count);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    32
        $pct = round(100 * $pct, 1);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    33
        echo "<li>$usernick - $pct% ($total)</li>\n";
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    34
      }
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    35
      ?>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    36
    </ul>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    37
    <p>Last 20 minutes:</p>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    38
    <ul>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    39
      <?php
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    40
      $datum = stats_activity_percent($channel, 20);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    41
      $count = stats_message_count($channel, 20);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    42
      if ( empty($datum) )
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    43
        echo '<li>No recent posts.</li>';
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    44
      foreach ( $datum as $usernick => $pct )
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    45
      {
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    46
        $total = round($pct * $count);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    47
        $pct = round(100 * $pct, 1);
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    48
        echo "<li>$usernick - $pct% ($total)</li>\n";
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    49
      }
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    50
      ?>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    51
    </ul>
a8f0e99883d1 Web interface can now update with AJAX
Dan
parents:
diff changeset
    52