cvs: docweb /scripts notes_stats.php notes_stats_output.php

[email protected] ("Sean Coates")
Newsgroups php.doc.web
Message-ID <cvssean1122856608@cvsserver>
sean		Sun Jul 31 20:36:48 2005 EDT

  Modified files:              
    /docweb/scripts	notes_stats.php notes_stats_output.php 
  Log:
  rework notes-stats for template system
  
http://cvs.php.net/diff.php/docweb/scripts/notes_stats.php?r1=1.9&r2=1.10&ty=u
Index: docweb/scripts/notes_stats.php
diff -u docweb/scripts/notes_stats.php:1.9 docweb/scripts/notes_stats.php:1.10
--- docweb/scripts/notes_stats.php:1.9	Sun Mar 27 09:46:14 2005
+++ docweb/scripts/notes_stats.php	Sun Jul 31 20:36:48 2005
@@ -17,10 +17,11 @@
 |          Vincent Gevers <[email protected]>                            |
 | Credits: Sean Coates <[email protected]>                                  |
 +----------------------------------------------------------------------+
-$Id: notes_stats.php,v 1.9 2005/03/27 14:46:14 nlopess Exp $
+$Id: notes_stats.php,v 1.10 2005/08/01 00:36:48 sean Exp $
 */
 
 require_once '../build-ops.php';
+require_once '../include/docweb_template.class.php';
 
 // Define some globally used vars
 
@@ -38,6 +39,8 @@
     $sqlite = create_db($DBFile);
 }
 
+if (!isset($_ENV['SKIP_NNTP'])) {
+
 $s = nntp_connect("news.php.net") or die("failed to connect to news server\n");
 $res = nntp_cmd($s, 'GROUP php.notes', 211) or die("failed to get infos on news group\n");
 
@@ -102,14 +105,13 @@
 sqlite_query($sqlite, 'COMMIT TRANSACTION');
 sqlite_close($sqlite);
 
+} // (end SKIP_NNTP block)
 
 /* write the output to the /www folder */
-ob_start();
 include './notes_stats_output.php';
-$output = ob_get_clean();
 
-$fp = fopen(PATH_ROOT . '/www/notes_stats.php', 'w');
-fputs($fp, $output);
+$fp = fopen(PATH_ROOT . '/www/note_stats-data.php', 'w');
+fputs($fp, $out);
 fclose($fp);
 
 /* end of the script */
http://cvs.php.net/diff.php/docweb/scripts/notes_stats_output.php?r1=1.4&r2=1.5&ty=u
Index: docweb/scripts/notes_stats_output.php
diff -u docweb/scripts/notes_stats_output.php:1.4 docweb/scripts/notes_stats_output.php:1.5
--- docweb/scripts/notes_stats_output.php:1.4	Fri Mar 25 12:11:25 2005
+++ docweb/scripts/notes_stats_output.php	Sun Jul 31 20:36:48 2005
@@ -14,18 +14,15 @@
 | [email protected] so we can mail you a copy immediately.               |
 +----------------------------------------------------------------------+
 | Authors: Vincent Gevers <[email protected]>                            |
+|          Sean Coates <[email protected]>                                  |
 +----------------------------------------------------------------------+
-$Id: notes_stats_output.php,v 1.4 2005/03/25 17:11:25 nlopess Exp $
+$Id: notes_stats_output.php,v 1.5 2005/08/01 00:36:48 sean Exp $
 */
 
-echo "<?php require_once '../include/init.inc.php';\n";
-
-// Settings for this script can be found in ./notes_stats.php
+// config comees from notes_stats.php
 
 if (@filesize($DBFile) < 3000000) { // require at least 3 MBs
-    echo "echo site_header('Statistics not available');\n";
-    echo "echo '<h2>Statistics not available</h2>';\n";
-    echo "echo site_footer();";
+    $out = FALSE;
     return;
 }
 
@@ -33,33 +30,9 @@
 
 $info = sqlite_fetch_array(sqlite_query($sqlite, 'SELECT * FROM info'), SQLITE_ASSOC);
 
-if ($info['last_article'] < 50000) {
-    echo "echo site_header('Statistics not available yet');\n";
-    echo "echo '<h2>Statistics not available yet</h2>';\n";
-    echo "echo site_footer();";
-    return;
-}
-
-echo "echo site_header('Note Statistics for " . date('j F Y', $info['build_date']) . "'); ?>\n";
-
-?>
-<h3><strong><?php echo $info['last_article']; ?></strong> subjects parsed</h3>
-
-<table border='0' cellspacing="10"><tr valign="top"><td valign="top">
-<table border='0'>
-    <tr>
-        <th colspan="5" align="center">Total Editors Stats</th>
-    </tr>
-    <tr>
-        <th>user</th>
-        <th>deleted</th>
-        <th>rejected</th>
-        <th>modified</th>
-        <th>total</th>
-    </tr>
-<?php
-
+// fetch/sort data
 $array = sqlite_fetch_all(sqlite_query($sqlite, 'SELECT * FROM notes'), SQLITE_ASSOC);
+sqlite_close($sqlite);
 $time  = time() - 60*60*24*180;
 
 foreach($array as $row) {
@@ -73,140 +46,27 @@
     }
 
 }
-
 unset($data['']);
 ksort($data);
 ksort($data_new);
-
-$bg = '#EBEBEB';
-foreach ($data as $id => $c) {
-
-    echo "<tr bgcolor=\"";
-    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB';
-    echo "$bg\">\n\t<td>".$id."</td>\n\t<td>";
-    echo isset($c['deleted']) ? $c['deleted'] : '0';
-    echo "</td>\n\t<td>";
-    echo isset($c['rejected']) ? $c['rejected'] : '0';
-    echo "</td>\n\t<td>";
-    echo isset($c['modified']) ? $c['modified'] : '0';
-    echo "</td>\n\t<td>";
-    echo $total[$id];
-    echo "</td>\n</tr>\n";
-}
-
-unset($data);
-
-?>
-</table>
-
-</td><td valign="top">
-Last half year (with more than <?php echo $minact; ?> actions counted)
-<table border='0'>
-    <tr>
-        <th colspan="5" align="center">Recent Editors stats</th>
-    </tr>
-    <tr>
-        <th>user</th>
-        <th>deleted</th>
-        <th>rejected</th>
-        <th>modified</th>
-        <th>total</th>
-    </tr>
-
-<?php
-
-$bg = '#EBEBEB';
-foreach ($data_new as $id => $c) {
-
-    if($c['total'] >= $minact) {    
-        echo "<tr bgcolor=\"";
-        $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB';
-        echo "$bg\">\n\t<td>".$id."</td>\n\t<td>";
-        echo isset($c['deleted']) ? $c['deleted'] : '0';
-        echo "</td>\n\t<td>";
-        echo isset($c['rejected']) ? $c['rejected'] : '0';
-        echo "</td>\n\t<td>";
-        echo isset($c['modified']) ? $c['modified'] : '0';
-        echo "</td>\n\t<td>";
-        echo $c['total'];
-        echo "</td>\n</tr>\n";
-    }
-
-}
-
-unset($data_new);
-
-?>
-</table>
-<br/>
-<table border='0'>
-    <tr>
-        <th colspan="3" align="center">Editors top 15</th>
-    </tr>
-    <tr>
-        <th>rank</th>
-        <th>user</th>
-        <th>total</th>
-    </tr>
-<?php
 arsort($total);
-
-$i = 0;
-foreach($total as $id => $val) {
-       
-    ++$i;
-    echo "<tr bgcolor=\"";
-    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB'; 
-    echo "$bg\">\n\t".
-    "<td>".$i."</td>\n\t".
-    "<td>".$id."</td>\n\t".
-    "<td>".$val."</td>\n".
-    "</tr>\n";
-    
-    if ($i == 15)
-        break;
-}       
-
-unset($total);
-?>
-</table>
-
-<br />
-<table border='0'>
-    <tr>
-        <th colspan="3" align="center">Manual pages most active top 20</th>
-    </tr>
-    <tr>
-        <th>rank</th>
-        <th>page</th>
-        <th>total</th>
-    </tr>
-<?php
 arsort($manual);
 
-$i = 0;
-foreach($manual as $id => $c) {
-       
-    ++$i;
-    echo "<tr bgcolor=\"";
-    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB'; 
-    echo "$bg\">\n\t".
-    "<td>".$i."</td>\n\t".
-    "<td>".$id."</td>\n\t".
-    "<td>".$c."</td>\n".
-    "</tr>\n";
-    
-    if ($i == 20)
-        break;
-}       
-
-?>
-</table>
-
-</td></tr></table>
-<?php
+$build_date = date('j F Y', $info['build_date']);
 
-echo 'Last updated ' . date('r', $info['build_date']) . "\n";
+$notesData = array(
+    'last_article' => $info['last_article'],
+    'build_date' => $build_date,
+    'data' => $data,
+    'data_new' => $data_new,
+    'total' => $total,
+    'manual' => $manual,
+    'minact' => $minact,
+);
+
+$out =  "<?php\n";
+$out .= "// This script generated by scripts/notes_stats_output.php -- DO NOT COMMIT\n";
+$out .= "\$notesData = ". var_export($notesData, true) .";\n";
+$out .= "// EOF\n?>";
 
-sqlite_close($sqlite);
-echo '<?php echo site_footer(); ?>';
+?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.