]> bicyclesonthemoon.info Git - ott/bsta/blob - reset.1.pl
Adapted for new config tool.
[ott/bsta] / reset.1.pl
1 ###RUN_PERL: #!/usr/bin/perl
2
3 # reset is generated from reset.1.pl.
4 #
5 # Reset BSTA state
6 #
7 # Copyright (C) 2016 - 2018, 2023  Balthasar SzczepaƄski
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as
11 # published by the Free Software Foundation, either version 3 of the
12 # License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU Affero General Public License for more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 use strict;
23 #use warnings;
24 ###PERL_LIB: use lib /botm/lib/bsta
25 use bsta_lib qw(writedatafile);
26
27 ###PERL_CGI_PATH:           CGI_PATH           = /bsta/
28
29 ###PERL_DATA_CHAT_PATH:     DATA_CHAT_PATH     = /botm/data/bsta/chat
30 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
31 ###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
32
33 ###PERL_WWW_INDEX_PATH:     WWW_INDEX_PATH     = /botm/www/1190/bsta/index.htm
34
35 ###PERL_WEBSITE:            WEBSITE            = 1190.bicyclesonthemoon.info
36
37 ###PERL_COIN_DATE:          COIN_DATE          = 13-Nov-2016 22:15
38 ###PERL_INTF_DATE:          INTF_DATE          = 28-Sep-2016 20:34
39
40 my %story = (
41         'id'      => '0',
42         'letter'  => '',
43         'lastip'  => '0.0.0.0',
44         'content' => '',
45         'pass'    => '0',
46         'state'   => '0'
47 );
48 my %state = (
49         'state' => '0',
50         'last'  => '0',
51         'ongtime' => '',
52         'nextong' => '',
53         'ip1' => '',
54         'ip2' => '',
55         'ip3' => ''
56 );
57 my %chat = (
58         'id'      => '0',
59         'state'   => '0',
60         'content' => ''
61 );
62
63 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
64 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
65
66 writedatafile(DATA_STATE_PATH,%state);
67 writedatafile(DATA_STORY_PATH,%story);
68 writedatafile(DATA_CHAT_PATH,%chat);
69
70 writeindex(WWW_INDEX_PATH);
71
72 #function borrowed from 2words.pl - keep consistent!
73 sub writeindex {
74         (my $indexpath) = @_;
75         my $indexfile;
76         my $indexof;
77                 
78         if(ref($indexpath)) {
79                 $indexfile=$indexpath;
80                 unless (seek($indexfile, 0, 0)) {
81                         return 0;
82                 }
83         }
84         else {
85                 unless (open ($indexfile, ">", $indexpath)) {
86                         return 0;
87                 }
88         }
89         
90         $indexof = CGI_PATH;
91         $indexof =~ s/\/$//g;
92         
93         print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'."\n";
94         print $indexfile '<html>'."\n";
95         print $indexfile ' <head>'."\n";
96         print $indexfile '  <title>Index of '.$indexof.'</title>'."\n";
97         print $indexfile ' </head>'."\n";
98         print $indexfile ' <body>'."\n";
99         print $indexfile '<h1>Index of '.$indexof.'</h1>'."\n";
100         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";
101         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";
102         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";
103         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";
104         print $indexfile '<tr><th colspan="5"><hr></th></tr>'."\n";
105         print $indexfile '</table>'."\n";
106         print $indexfile '<address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
107         print $indexfile '</body></html>'."\n";
108         
109         
110         unless (ref($indexpath)) {
111                 close ($indexfile);
112         }
113         else {
114                 truncate ($indexfile , tell($indexfile));
115         }
116         
117         return 1;
118 }