wez             Thu Nov 11 14:33:28 2004 EDT

  Modified files:              
    /livedocs   build-ops.in build.sh configure.in mk_notes.php 
  Log:
  reinstate user-notes fetching via token
  # grrr
  
  
http://cvs.php.net/diff.php/livedocs/build-ops.in?r1=1.10&r2=1.11&ty=u
Index: livedocs/build-ops.in
diff -u livedocs/build-ops.in:1.10 livedocs/build-ops.in:1.11
--- livedocs/build-ops.in:1.10  Sat Sep 11 08:22:44 2004
+++ livedocs/build-ops.in       Thu Nov 11 14:33:26 2004
@@ -17,4 +17,5 @@
 # LANGUAGES="en ar cs de es fi fr he hk hu it ja kr nl pl pt_BR ro ru sk sv tw 
zh"
 LANGUAGES="@LANGUAGES@"
 [EMAIL PROTECTED]@
[EMAIL PROTECTED]@
 
http://cvs.php.net/diff.php/livedocs/build.sh?r1=1.25&r2=1.26&ty=u
Index: livedocs/build.sh
diff -u livedocs/build.sh:1.25 livedocs/build.sh:1.26
--- livedocs/build.sh:1.25      Sat Aug 14 17:34:05 2004
+++ livedocs/build.sh   Thu Nov 11 14:33:27 2004
@@ -6,8 +6,10 @@
 
 echo "####################"
 
-if test -n "$NOTES_MIRROR" ; then
+if test -n "$NOTES_MIRROR$NOTES_TOKEN" ; then
        echo "Building user notes"
+       TOKEN=$NOTES_TOKEN
+       export TOKEN
        ${PHP} ${LIVEDOCSFORPHP}/mk_notes.php ${OUTPUTDIR} ${GENDIR} 
${NOTES_MIRROR}
 fi
 
http://cvs.php.net/diff.php/livedocs/configure.in?r1=1.28&r2=1.29&ty=u
Index: livedocs/configure.in
diff -u livedocs/configure.in:1.28 livedocs/configure.in:1.29
--- livedocs/configure.in:1.28  Sat Aug 14 17:34:05 2004
+++ livedocs/configure.in       Thu Nov 11 14:33:27 2004
@@ -1,5 +1,5 @@
 ## A configure script
-## $Id: configure.in,v 1.28 2004/08/14 21:34:05 iliaa Exp $
+## $Id: configure.in,v 1.29 2004/11/11 19:33:27 wez Exp $
 
 AC_PREREQ(2.13)
 AC_INIT(livedoc.php)
@@ -87,6 +87,10 @@
   [NOTES_MIRROR="$withval"],
   [NOTES_MIRROR=""])
 
+AC_ARG_WITH(notes-token,[  --with-notes-token=TOKEN      token to fetch user 
notes],
+  [NOTES_TOKEN="$withval"],
+  [NOTES_TOKEN=""])
+
 AC_ARG_WITH(web-base,[  --with-web-base[=DIR]           Relative URL for 
livedocs links  [default=/]],
   [WEBBASE="$withval"],
   [WEBBASE="/"])
@@ -128,6 +132,7 @@
 AC_SUBST(OUTPUTDIRFORPHP)
 AC_SUBST(XSLTPROC)
 AC_SUBST(NOTES_MIRROR)
+AC_SUBST(NOTES_TOKEN)
 
 AC_OUTPUT(build-ops config.php .htaccess)
 
http://cvs.php.net/diff.php/livedocs/mk_notes.php?r1=1.4&r2=1.5&ty=u
Index: livedocs/mk_notes.php
diff -u livedocs/mk_notes.php:1.4 livedocs/mk_notes.php:1.5
--- livedocs/mk_notes.php:1.4   Wed Aug 18 16:56:57 2004
+++ livedocs/mk_notes.php       Thu Nov 11 14:33:27 2004
@@ -19,7 +19,7 @@
 // | livedocs.                                                            |
 // +----------------------------------------------------------------------+
 //
-// $Id: mk_notes.php,v 1.4 2004/08/18 20:56:57 iliaa Exp $
+// $Id: mk_notes.php,v 1.5 2004/11/11 19:33:27 wez Exp $
 
 $create = <<<SQL
 BEGIN;
@@ -38,6 +38,9 @@
 $mirror = $argv[3];
 
 if (file_exists($dbname)) {
+       if (filemtime($dbname) < time() + (60 * 60)) {
+               exit(0);
+       }
        unlink($dbname);
 }
 
@@ -50,28 +53,58 @@
 $n_notes = 0;
 $buffer = '';
 
-$name = tempnam($tmpdir, 'notes');
-copy('http://'.$mirror.'.php.net/backend/notes/all.bz2', $name);
-$fp = fopen("compress.bzip2://".$name, 'r');
-
-while (($line = fgetcsv($fp, 100000, '|'))) {
-       if (!isset($line[5]) || isset($line[6])) {
-               echo "LINE: ".implode('|', $line)."\n\n";
-               continue;
+$token = getenv("TOKEN");
+if (strlen($token)) {
+       $n_data = 0;
+       $fp = fopen("http://master.php.net/fetch/user-notes.php?token=$token";, 
"r");
+       do {
+               $line = fgets($fp);
+               $n_data += strlen($line);
+               if (!strlen($line))
+                       break;
+               if (!strstr($line, '|')) {
+                       echo "LINE: $line\n\n";
+                       continue;
+               }
+
+               list ($id, $sect, $rate, $ts, $user, $note) = explode('|', 
$line);
+               $n_notes++;
+
+               $note = 
sqlite_escape_string(gzuncompress(base64_decode($note)));
+               $user = sqlite_escape_string($user);
+
+               printf("\r%d notes %d bytes", $n_notes, $n_data);
+
+               sqlite_query($DB, "INSERT INTO notes values ($id, '$sect', 
$rate, $ts, '$user', '$note');");
+
+       } while (true);
+
+} else {
+
+       $name = tempnam($tmpdir, 'notes');
+       copy('http://'.$mirror.'.php.net/backend/notes/all.bz2', $name);
+       $fp = fopen("compress.bzip2://".$name, 'r');
+
+       while (($line = fgetcsv($fp, 100000, '|'))) {
+               if (!isset($line[5]) || isset($line[6])) {
+                       echo "LINE: ".implode('|', $line)."\n\n";
+                       continue;
+               }
+               ++$n_notes;
+
+               if ($n_notes % 1000) {
+                       $buffer .= "INSERT INTO notes values (".$line[0].", 
'".$line[1]."', ".$line[2].", ".$line[3].", 
+                               '".sqlite_escape_string($line[4])."', 
'".sqlite_escape_string(base64_decode($line[5]))."');";
+               } else {
+                       sqlite_query($DB, $buffer);
+                       $buffer = '';
+               }
        }
-       ++$n_notes;
 
-       if ($n_notes % 1000) {
-               $buffer .= "INSERT INTO notes values (".$line[0].", 
'".$line[1]."', ".$line[2].", ".$line[3].", 
-                       '".sqlite_escape_string($line[4])."', 
'".sqlite_escape_string(base64_decode($line[5]))."');";
-       } else {
-               sqlite_query($DB, $buffer);
-               $buffer = '';
-       }
+       $n_data = ftell($fp);
 }
-
-printf("\rDone: %d notes %d bytes\n", $n_notes, ftell($fp));
-
+       
+printf("\rDone: %d notes %d bytes\n", $n_notes, $n_data);
 sqlite_query($DB, 'COMMIT');
 
 fclose($fp);

Reply via email to