Commit:    d701848307bcd2ac547e07beb22ae43c0d222a66
Author:    Sherif Ramadan <[email protected]>         Thu, 13 Dec 2012 13:54:12 
-0500
Parents:   209cc6044f1b981da0886a22ea84e4eea91e5bef
Branches:  master

Link:       
http://git.php.net/?p=web/master.git;a=commitdiff;h=d701848307bcd2ac547e07beb22ae43c0d222a66

Log:
Added new stats information for voting on the front page.

Changed paths:
  M  manage/user-notes.php


Diff:
diff --git a/manage/user-notes.php b/manage/user-notes.php
index 09c0164..5ee10f1 100644
--- a/manage/user-notes.php
+++ b/manage/user-notes.php
@@ -161,6 +161,32 @@ if (!$action) {
   }
 
 ?>
+<?php if (empty($_SERVER['QUERY_STRING'])) { ?>
+<?php
+  /* Calculate dates */
+  $today = strtotime('midnight');
+  $week = !date('w') ? strtotime('midnight') : strtotime('Last Sunday');
+  $month = strtotime('First Day of ' . date('F') . ' ' . date('Y'));
+  /* Handle stats queries for voting here */
+  $stats_sql = $stats = array();
+  $stats_sql['Total']       = "SELECT COUNT(votes.id) AS total FROM votes";
+  $stats_sql['Today']       = "SELECT COUNT(votes.id) AS total FROM votes 
WHERE UNIX_TIMESTAMP(votes.ts) >= " . real_clean($today);
+  $stats_sql['This Week']   = "SELECT COUNT(votes.id) AS total FROM votes 
WHERE UNIX_TIMESTAMP(votes.ts) >= " . real_clean($week);
+  $stats_sql['This Month']  = "SELECT COUNT(votes.id) AS total FROM votes 
WHERE UNIX_TIMESTAMP(votes.ts) >= " . real_clean($month);
+  foreach ($stats_sql as $key => $sql_code) {
+      $result = db_query($sql_code);
+      $row = mysql_fetch_assoc($result);
+      $stats[$key] = $row['total'];
+  }
+  /* Display the stats on the front page only */
+?>
+<div style="float: right; clear: both; border: 1px solid gray; padding: 5px; 
background-color: lightgray;">
+  <p>User Contributed Voting Statistics</p>
+  <?php foreach ($stats as $figure => $stat) { ?>
+  <div style="display: inline-block; float: left; padding: 15px;"><strong><?= 
$figure ?></strong>: <?= $stat ?></div>
+  <?php } ?>
+</div>
+<?php } ?>
 <p>Search the notes table.</p>
 <form method="post" action="<?= PHP_SELF ?>">
 <table>


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to