84bd26f0f3ec02df3b974b55b63358dcbad4575c
[mspang/plceo1.git] / Gopher.pl
1 #
2 # Date                  Name                            Modification
3 # ----          ----                ------------
4 # 94/11/20              Alex Brodsky            Split off from main ceo file
5 # 96/10/23              Nikita Borisov          Use dbmtie instead of fakedbm
6 #
7
8
9 sub Gopher_Quota
10 {
11     local($useQUOTALOG) = $QUOTALOG;
12     if ($NEXTTERMQUOTA)
13     {
14         $useQUOTALOG = $NEXTQUOTALOG;
15     }
16     open (QLOG, $useQUOTALOG) || do
17     {
18         print "\n${beep}Unable to open quota log file: $!\n";
19         return;
20     };
21     dbmopen(QUOTA,$QUOTADB,0600) || do
22     {
23         print "\n${beep}Unable to open quota database: $!\n";
24         close(QLOG);
25         return;
26     };
27     %Quota = ();
28     while(<QLOG>)
29     {
30         next if (/^\s*$/ || /^\s*#/);
31         ($qdate, $quid, $qamt, $qtot, $qleft) = split(/;/);
32         next if $quid eq "csc\@math";
33         $Quota{$QUOTA{$quid}} = $qtot;
34     }
35     close(QLOG);
36     $qleft =~ s/\D//g;
37     open (GOPQUOTA, ">$GOPHERDIR/quota_log") || do
38     {
39         print "\n${beep}Unable to open output file: $!\n";
40         return;
41     };
42     select(GOPQUOTA);
43     $-=0;
44     $= = 50000;
45     foreach $qnum (sort {$a<=>$b} keys %Quota)
46     {
47         ($qname, $qsid, $quid) = split(/;/,$QUOTA{$qnum});
48         $qqta = $Quota{$qnum};
49         write;
50     }
51     dbmclose(QUOTA);
52     print "\nQuota remaining: $qleft MB\n";
53     select(STDOUT);
54     close(GOPQUOTA);
55 #   system <<EOJ;
56 #rcp $editfile csc_disk@descartes:Gopher/office_info/quota_log
57 #EOJ
58 }
59
60 sub Gopher_Members
61 {
62     local($nummems);
63     open (GOPMEMBER, ">$GOPHERDIR/members_list") || do
64     {
65         print "\n${beep}Unable to open output file: $!\n";
66         return;
67     };
68     eval { dbmtie($MEMDB,\%MEM) } || do
69     {
70         print "\n${beep}Unable to open member database: $!\n";
71         close(SCRMEMBER);
72         return;
73     };
74     select(GOPMEMBER);
75     $-=0;
76     $= = 50000;
77     $nummems=0;
78     foreach $memnum (sort {$a<=>$b} split(/,/,$MEM{$TERM}))
79     {
80         ($memname,$memsid,$memprog,$memphone,$memuid,$mempw,$memdate,$memterms)
81             = split(/;/,$MEM{$memnum});
82         write;
83         ++$nummems;
84     }
85     dbmuntie(\%MEM);
86     print "\nTotal: $nummems\n";
87     select(STDOUT);
88     close(GOPMEMBER);
89 #   system <<EOJ;
90 #rcp $editfile csc_disk@descartes:Gopher/office_info/members_list
91 #EOJ
92 }
93
94 sub Gopher_Outstanding
95 {
96  ## Read the library file
97     dbmopen(LIB, $LIBDB, 0600) || do
98     {
99         print "\n${beep}Error opening library database: $!\n";
100         return;
101     };
102     %Outstand = ();
103     foreach $bid (keys %LIB)
104     {
105         ($whohas) = $LIB{$bid} =~ /W\{(\d+)\}/;
106         next if $whohas == 0;
107         ($btitle) = $LIB{$bid} =~ /N\{([^\}]*)\}/;
108         ($bodate) = $LIB{$bid} =~ /D\{([^\}]*)\}/;
109         $Outstand{$bid}="$whohas#$btitle#$bodate";
110     }
111     dbmclose(LIB);
112
113     eval { dbmtie($MEMDB,\%MEM) } || do
114     {
115         print "\n${beep}Error opening members database: $!\n";
116         return;
117     };
118     open (OUTSTAND, ">$GOPHERDIR/library_outstand") || do
119     {
120         print "\n${beep}Unable to open outstanding books file: $!\n";
121         dbmuntie(\%MEM);
122         return;
123     };
124     select(OUTSTAND);
125     $-=0;
126     $= = 50000;
127     foreach $obid (keys %Outstand)
128     {
129         ($onum,$obtitle,$odate) = $Outstand{$obid} =~ /^(.*)#(.*)#(.*)$/;
130         $oname = (split(/;/,$MEM{$onum}))[0];
131         write;
132     }
133     dbmuntie(\%MEM);
134     select(STDOUT);
135     close(OUTSTAND);
136 #   &MakeOutstandFile(50000);
137 #   system <<EOJ;
138 #rcp $editfile csc_disk@descartes:Gopher/office_info/library_outstand
139 #EOJ
140 }
141
142 1;