cvs: docweb /scripts notes_stats.php notes_stats_output.php

[email protected] ("Vincent Gevers")
Newsgroups php.doc.web
Message-ID <cvsvincent1107555033@cvsserver>
vincent		Fri Feb  4 17:10:33 2005 EDT

  Modified files:              
    /docweb/scripts	notes_stats.php notes_stats_output.php 
  Log:
  Some fixes to allow older notes to get parsed
  Allow a fetching resume
  and make sure the output is echo'ed to /www/notes_stats.php
  
  
http://cvs.php.net/diff.php/docweb/scripts/notes_stats.php?r1=1.5&r2=1.6&ty=u
Index: docweb/scripts/notes_stats.php
diff -u docweb/scripts/notes_stats.php:1.5 docweb/scripts/notes_stats.php:1.6
--- docweb/scripts/notes_stats.php:1.5	Fri Feb  4 06:20:36 2005
+++ docweb/scripts/notes_stats.php	Fri Feb  4 17:10:33 2005
@@ -17,11 +17,16 @@
 |          Vincent Gevers <[email protected]>                            |
 | Credits: Sean Coates <[email protected]>                                  |
 +----------------------------------------------------------------------+
-$Id: notes_stats.php,v 1.5 2005/02/04 11:20:36 nlopess Exp $
+$Id: notes_stats.php,v 1.6 2005/02/04 22:10:33 vincent Exp $
 */
 
 require_once '../build-ops.php';
 
+// Define some globally used vars
+
+// This setting is used in the output script
+$minact = 100;
+
 $DBFile = SQLITE_DIR . 'notes_stats.sqlite';
 
 
@@ -48,7 +53,6 @@
 $sql = '';
 $last_update = time();
 
-
 for ($i = $first; $i < $last; $i++) {
     $line = fgets($s, 4096);
     list($n, $subj, $author, $odate) = explode("\t", $line, 5);
@@ -68,7 +72,7 @@
      * note ID modified in SECTION by EDITOR
      */
 
-    if (preg_match('/note (\d+) (.+) (?:from|in) (\S+) by (\w*)/S', $subj, $d)) {
+    if (preg_match('/^note (\d+) (.+) (?:from|in) (.+) by (.+)/S', $subj, $d)) {
         if ($d[2] == 'approved') {
             continue;
         }
@@ -77,6 +81,10 @@
             $d[2] = 'rejected';
         }
 
+        if (substr($d[3], 0, -4)) {
+            $d[3] = str_replace('.php', '', $d[3]);
+        }
+
         $d[] = strtotime($odate);
         $sql .= make_sql($d);
 
@@ -86,7 +94,8 @@
 
 @fclose($s);
 
-$sql .= "UPDATE info SET last_article=$last, build_date=$last_update;";
+// using $i to allow a fetching resume
+$sql .= "UPDATE info SET last_article=$i, build_date=$last_update;";
 
 sqlite_query($sqlite, $sql);
 sqlite_close($sqlite);
@@ -148,7 +157,7 @@
 );
 
 CREATE TABLE notes (
-  note INTEGER PRIMARY KEY,
+  note INTEGER,
   action TEXT,
   manpage TEXT,
   who TEXT,
http://cvs.php.net/diff.php/docweb/scripts/notes_stats_output.php?r1=1.2&r2=1.3&ty=u
Index: docweb/scripts/notes_stats_output.php
diff -u docweb/scripts/notes_stats_output.php:1.2 docweb/scripts/notes_stats_output.php:1.3
--- docweb/scripts/notes_stats_output.php:1.2	Fri Feb  4 06:59:28 2005
+++ docweb/scripts/notes_stats_output.php	Fri Feb  4 17:10:33 2005
@@ -15,20 +15,18 @@
 +----------------------------------------------------------------------+
 | Authors: Vincent Gevers <[email protected]>                            |
 +----------------------------------------------------------------------+
-$Id: notes_stats_output.php,v 1.2 2005/02/04 11:59:28 nlopess Exp $
+$Id: notes_stats_output.php,v 1.3 2005/02/04 22:10:33 vincent Exp $
 */
 
-echo "<?php require_once '../include/init.inc.php';";
+echo "<?php require_once '../include/init.inc.php';\n";
 
-$minact = 100;
-
-$DBFile = SQLITE_DIR.'notes_stats.sqlite';
+// Settings for this script can be found in ./notes_stats.php
 
 if (@filesize($DBFile) < 10) {
-    echo site_header('Statistics not available');
-    echo '<h2>Statistics not available</h2>';
-    echo site_footer();
-    exit;
+    echo "echo site_header('Statistics not available');\n";
+    echo "echo '<h2>Statistics not available</h2>';\n";
+    echo "echo site_footer();";
+    return;
 }
 
 $sqlite = sqlite_open($DBFile);
@@ -36,13 +34,13 @@
 $info = sqlite_fetch_array(sqlite_query($sqlite, 'SELECT * FROM info'), SQLITE_ASSOC);
 
 if ($info['last_article'] < 50000) {
-    echo site_header('Statistics not available yet');
-    echo '<h2>Statistics not available yet</h2>';
-    echo site_footer();
-    exit;
+    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']) . "'); ?>";
+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>
@@ -212,5 +210,3 @@
 
 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.