]> bicyclesonthemoon.info Git - ott/bsta/blob - reset.1.pl
Initial state as of 31.08.2023
[ott/bsta] / reset.1.pl
1 ###PERL;
2 #
3 # /bsta/2words
4 # reset is generated from reset.1.pl.
5 # 26.03.2018
6 #
7 # Reset BSTA state
8 #
9 #    Copyright (C) 2016 - 2018  Balthasar SzczepaƄski
10 #
11 #    This program is free software: you can redistribute it and/or modify
12 #    it under the terms of the GNU Affero General Public License as
13 #    published by the Free Software Foundation, either version 3 of the
14 #    License, or (at your option) any later version.
15 #
16 #    This program is distributed in the hope that it will be useful,
17 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 #    GNU Affero General Public License for more details.
20 #
21 #    You should have received a copy of the GNU Affero General Public License
22 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24 use strict;
25 #use warnings;
26 ###LIB;
27 use bsta_lib qw(writedatafile);
28
29 ###STORY_PATH;
30 ###WEBSITE;
31 ###CGI_PATH;
32 ###INDEX_PATH;
33 ###INTF_DATE;
34 ###STATE_PATH;
35 ###COIN_DATE;
36 ###CHAT_PATH;
37
38 my %story = (
39         'id'      => '0',
40         'letter'  => '',
41         'lastip'  => '0.0.0.0',
42         'content' => '',
43         'pass'    => '0',
44         'state'   => '0'
45 );
46 my %state = (
47         'state' => '0',
48         'last'  => '0',
49         'ongtime' => '',
50         'nextong' => '',
51         'ip1' => '',
52         'ip2' => '',
53         'ip3' => ''
54 );
55 my %chat = (
56         'id'      => '0',
57         'state'   => '0',
58         'content' => ''
59 );
60
61 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
62 ###PATH;
63
64 writedatafile(STATE_PATH,%state);
65 writedatafile(STORY_PATH,%story);
66 writedatafile(CHAT_PATH,%chat);
67
68 writeindex(INDEX_PATH);
69
70 #function borrowed from 2words.pl - keep consistent!
71 sub writeindex {
72         (my $indexpath) = @_;
73         my $indexfile;
74         my $indexof;
75                 
76         if(ref($indexpath)) {
77                 $indexfile=$indexpath;
78                 unless (seek($indexfile, 0, 0)) {
79                         return 0;
80                 }
81         }
82         else {
83                 unless (open ($indexfile, ">", $indexpath)) {
84                         return 0;
85                 }
86         }
87         
88         $indexof = CGI_PATH;
89         $indexof =~ s/\/$//g;
90         
91         print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'."\n";
92         print $indexfile '<html>'."\n";
93         print $indexfile ' <head>'."\n";
94         print $indexfile '  <title>Index of '.$indexof.'</title>'."\n";
95         print $indexfile ' </head>'."\n";
96         print $indexfile ' <body>'."\n";
97         print $indexfile '<h1>Index of '.$indexof.'</h1>'."\n";
98         print $indexfile '<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>'."\n";
99         print $indexfile '<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/">Parent Directory</a></td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
100         print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="2words/">2words/</a></td><td align="right">'.INTF_DATE.'  </td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
101         print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="coin/">coin/</a></td><td align="right">'.COIN_DATE.'  </td><td align="right">  - </td><td> Coincidence </td></tr>'."\n";
102         print $indexfile '<tr><th colspan="5"><hr></th></tr>'."\n";
103         print $indexfile '</table>'."\n";
104         print $indexfile '<address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
105         print $indexfile '</body></html>'."\n";
106         
107         
108         unless (ref($indexpath)) {
109                 close ($indexfile);
110         }
111         else {
112                 truncate ($indexfile , tell($indexfile));
113         }
114         
115         return 1;
116 }