spool generation script
authorx99bachelart <x99bachelart>
Fri, 19 Sep 2003 12:40:05 +0000 (12:40 +0000)
committerx99bachelart <x99bachelart>
Fri, 19 Sep 2003 12:40:05 +0000 (12:40 +0000)
include/spool.inc.php
scripts/spoolgen.php [new file with mode: 0644]

index 3d54680..7201164 100644 (file)
@@ -70,12 +70,13 @@ class spool {
    
   function spool(&$_nntp,$_group,$_display=0,$_since=""){
        global $news;
+    $prefix_path=(preg_match("/\/scripts\/?$/",getcwd())?"..":".");    
     $groupinfo = $_nntp->group($_group);
     if (!$groupinfo) {
       $this = false;
       return false;
     }
-       $spoolfile=realpath("./spool/spool-$_group.dat");
+       $spoolfile=realpath("$prefix_path/spool/spool-$_group.dat");
     if (file_exists($spoolfile)) {
       $f = fopen($spoolfile,"r");
       $this = unserialize(fread($f,filesize($spoolfile)));
@@ -143,7 +144,7 @@ class spool {
         $this->overview[$id] = $msg;
       }
       uasort($this->overview,"spoolcompare");
-      $f = fopen("spool/spool-$_group.dat","w");
+      $f = fopen("$prefix_path/spool/spool-$_group.dat","w");
       fputs($f,serialize($this));
       fclose($f);
     }
@@ -240,7 +241,7 @@ class spool {
       $ids = array_flip($this->ids);
       unset($ids[$_id]);
       $this->ids = array_flip($ids);
-      $f = fopen("spool/spool-{$this->group}.dat","w");
+      $f = fopen("$prefix_path/spool/spool-{$this->group}.dat","w");
       fputs($f,serialize($this));
       fclose($f);
     }
diff --git a/scripts/spoolgen.php b/scripts/spoolgen.php
new file mode 100644 (file)
index 0000000..1b22d44
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/********************************************************************************
+* spoolgen.php : spool generation
+* --------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+ini_set('max_execution_time','300');
+ini_set('include_path','.:..:../custom/banana:../../custom/banana:../public/include:../../public/include');
+
+require("include/encoding.inc.php");
+require("include/config.inc.php");
+require("include/NetNNTP.inc.php");
+include("include/post.inc.php");
+include("include/groups.inc.php");
+require("include/spool.inc.php");
+require("include/password.inc.php");
+
+
+$nntp = new nntp($news['server']);
+if (!$nntp) {
+  print "cannot connect to server\n";
+  exit;
+}
+
+if ($news['user']!="anonymous") {
+  $result = $nntp->authinfo($news["user"],$news["pass"]);
+  if (!$result) {
+    print "authentication error\n";
+    exit;
+  }
+}
+unset($result);
+
+$groups = new groups($nntp,2);
+$list = array_keys($groups->overview);
+unset($groups);
+foreach ($list as $g) {
+  print "Generating spool for $g : ";
+  $spool = new spool($nntp,$g);
+  print "done.\n";
+  unset($spool);
+}
+$nntp->quit();
+?>