]> bicyclesonthemoon.info Git - ott/bsta/commitdiff
reworked reset and added reset password
authorb <rowerynaksiezycu@gmail.com>
Sat, 30 Dec 2023 11:24:26 +0000 (11:24 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sat, 30 Dec 2023 11:24:26 +0000 (11:24 +0000)
bsta.1.cron
reset.1.pl
settings-again.txt
settings-bsta.txt
settings-debug.txt
settings-tbst.txt
settings.txt

index 52f63d367e705ec7a0880edf1f1ff5214e2bf2fe..96c38df5ce614bb51b0a795bbeb0888d483e2662 100644 (file)
@@ -2,4 +2,4 @@
 
 ###CRON_OLDLOGS_SCHEDULE; ###CRON_USER; ###CRON_OLDLOGS; ###CRON_LOG; ###CRON_LOG_SIZE_LIMIT; ###CRON_LOGS_TOTAL; ###CRON_LOGS_UNCOMPRESSED;
 ###CRON_ONG_SCHEDULE; ###CRON_USER; ###CRON_ONG; >> ###CRON_ONG_LOG;
-###CRON_RESET_SCHEDULE; ###CRON_USER; ###CRON_RESET;
+###CRON_RESET_SCHEDULE; ###CRON_USER; ###CRON_RESET; ###CRON_RESET_PASSWORD;
index 998096a0f25be5873db451e7dc880386a3ff3343..7c8fada0db58c7e9cb05585818c76c47b3906c53 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 use strict;
-#use warnings;
+use utf8;
+use Encode::Locale ('decode_argv');
+use Encode ('encode', 'decode');
+
 ###PERL_LIB: use lib /botm/lib/bsta
-use bsta_lib qw(writedatafile);
+use botm_common (
+       'read_data_file', 'write_data_file',
+);
+use bsta_lib (
+       'STATE', 'INTF_STATE',
+       'write_index'
+);
 
-###PERL_CGI_PATH:           CGI_PATH           = /bsta/
+binmode STDIN,  ':encoding(UTF-8)';
+binmode STDOUT, ':encoding(UTF-8)';
+binmode STDERR, ':encoding(UTF-8)';
+decode_argv();
 
 ###PERL_DATA_CHAT_PATH:     DATA_CHAT_PATH     = /botm/data/bsta/chat
+###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/state
 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
 ###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
 
-###PERL_WWW_INDEX_PATH:     WWW_INDEX_PATH     = /botm/www/1190/bsta/index.htm
+###PERL_RESET_PASSWORD:     RESET_PASSWORD     = ''
 
-###PERL_WEBSITE:            WEBSITE            = 1190.bicyclesonthemoon.info
+my %story;
+my %state;
+my %chat;
+my %settings;
 
-###PERL_COIN_DATE:          COIN_DATE          = 13-Nov-2016 22:15
-###PERL_INTF_DATE:          INTF_DATE          = 28-Sep-2016 20:34
+delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
 
-my %story = (
-       'id'      => '0',
-       'letter'  => '',
-       'lastip'  => '0.0.0.0',
-       'content' => '',
-       'pass'    => '0',
-       'state'   => '0'
-);
-my %state = (
-       'state' => '0',
-       'last'  => '0',
+%settings = read_data_file(DATA_SETTINGS_PATH());
+unless (
+       ($ARGV[0] ne '') && (
+               ($ARGV[0] eq $settings{'password'}) ||
+               ($ARGV[0] eq RESET_PASSWORD())
+       )
+) {
+       print STDERR "Wrong password; no reset.\n";
+       exit 1;
+}
+
+%state = (
+       'state' => STATE->{'inactive'},
+       'last'  => 0,
        'ongtime' => '',
        'nextong' => '',
        'ip1' => '',
        'ip2' => '',
        'ip3' => ''
 );
-my %chat = (
-       'id'      => '0',
-       'state'   => '0',
+%story = (
+       'id'      => 0,
+       'letter'  => '',
+       'lastip'  => '0.0.0.0',
+       'content' => '',
+       'pass'    => 0,
+       'state'   => INTF_STATE->{'X'}
+);
+%chat = (
+       'id'      => 0,
+       'state'   => 0, # TODO chat state enum?
        'content' => ''
 );
 
-delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
-###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
-
-writedatafile(DATA_STATE_PATH,%state);
-writedatafile(DATA_STORY_PATH,%story);
-writedatafile(DATA_CHAT_PATH,%chat);
-
-writeindex(WWW_INDEX_PATH);
+write_data_file(DATA_STATE_PATH(), '', '', \%state);
+write_data_file(DATA_STORY_PATH(), '', '', \%story);
+write_data_file(DATA_CHAT_PATH() , '', '', \%chat);
 
-#function borrowed from 2words.pl - keep consistent!
-sub writeindex {
-       (my $indexpath) = @_;
-       my $indexfile;
-       my $indexof;
-               
-       if(ref($indexpath)) {
-               $indexfile=$indexpath;
-               unless (seek($indexfile, 0, 0)) {
-                       return 0;
-               }
-       }
-       else {
-               unless (open ($indexfile, ">", $indexpath)) {
-                       return 0;
-               }
-       }
-       
-       $indexof = CGI_PATH;
-       $indexof =~ s/\/$//g;
-       
-       print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'."\n";
-       print $indexfile '<html>'."\n";
-       print $indexfile ' <head>'."\n";
-       print $indexfile '  <title>Index of '.$indexof.'</title>'."\n";
-       print $indexfile ' </head>'."\n";
-       print $indexfile ' <body>'."\n";
-       print $indexfile '<h1>Index of '.$indexof.'</h1>'."\n";
-       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";
-       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";
-       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";
-       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";
-       print $indexfile '<tr><th colspan="5"><hr></th></tr>'."\n";
-       print $indexfile '</table>'."\n";
-       print $indexfile '<address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
-       print $indexfile '</body></html>'."\n";
-       
-       
-       unless (ref($indexpath)) {
-               close ($indexfile);
-       }
-       else {
-               truncate ($indexfile , tell($indexfile));
-       }
-       
-       return 1;
-}
+write_index(
+       \%state,
+       \%settings,
+       $story{'pass'},
+       $story{'state'},
+       0 # pause
+);
index 10b67c0a049c7fc02498a7a9f50e1bf9131dc019..0e5c207b26580e03716ef4db1c700b845303731f 100644 (file)
@@ -69,6 +69,7 @@ ong_schedule: 0 * * * *
 
 # When to RESET EVERYTHING
 reset_schedule: 33 4 * * *
+reset_password: again
 
 cron_user: b
 
index e2426f194a6bb5a76df5a22258ab7aef06419f22..6e2fbb391340db3883ef5c37782332486884b5d7 100644 (file)
@@ -69,6 +69,7 @@ ong_schedule: 0 * * * *
 
 # When to RESET EVERYTHING
 reset_schedule: #33 4 * * *
+reset_password: 
 
 cron_user: b
 
index ec1a28c699ff1e856fb09b1542a3649f9d8c6cda..c53dfd301a49953cc8f839fa59f32fe675522c82 100644 (file)
@@ -69,6 +69,7 @@ ong_schedule: #0 * * * *
 
 # When to RESET EVERYTHING
 reset_schedule: #33 4 * * *
+reset_password: bstreset
 
 cron_user: b
 
index 2365d73b7c6b29825d4c97173bfaa1fd2ac53815..bc183cef57c85b9122dec02f46686e6d82f5244a 100644 (file)
@@ -69,6 +69,7 @@ ong_schedule: #0 * * * *
 
 # When to RESET EVERYTHING
 reset_schedule: #33 4 * * *
+reset_password: 
 
 cron_user: b
 
index a346d99f6327ae2faef78f418d3895c5bf960995..45bd4009b155127045269b93bd76fb466d0e1e35 100644 (file)
@@ -102,6 +102,7 @@ CRON_USER    = $cron_user
 CRON_OLDLOGS_SCHEDULE = $oldlogs_schedule
 CRON_ONG_SCHEDULE     = $ong_schedule
 CRON_RESET_SCHEDULE   = $reset_schedule
+CRON_RESET_PASSWORD   = $reset_password
 
 CRON_LOG_SIZE_LIMIT    = $log_size_limit
 CRON_LOGS_UNCOMPRESSED = $logs_uncompressed
@@ -180,6 +181,8 @@ PERL_INTF_DATE          = @_PERL_CONSTANT_STR( INTF_DATE, $intf_date)
 
 PERL_GZIP               = @_PERL_CONSTANT_STR( GZIP, $gzip)
 
+PERL_RESET_PASSWORD     = @_PERL_CONSTANT_STR( RESET_PASSWORD, $reset_password)
+
 PERL_LOG_SIZE_LIMIT     = @_PERL_CONSTANT(     LOG_SIZE_LIMIT   , $log_size_limit)
 PERL_LOGS_UNCOMPRESSED  = @_PERL_CONSTANT(     LOGS_UNCOMPRESSED, $logs_uncompressed)
 PERL_LOGS_TOTAL         = @_PERL_CONSTANT(     LOGS_TOTAL       , $logs_total)