###PERL_LIB: use lib /botm/lib/bsta
use botm_common (
'HTTP_STATUS',
- 'read_data_file', 'write_data_file',
'read_header_env',
'url_query_decode', 'url_query_encode',
'merge_url',
'print_html_start', 'print_html_end',
'print_html_head_start', 'print_html_head_end',
'print_html_body_start', 'print_html_body_end',
- 'merge_settings'
+ 'merge_settings',
+ 'read_chat', 'write_chat',
+ 'read_coincidence', 'read_settings', 'read_state'
);
use File::Copy;
###PERL_CGI_COIN_PATH: CGI_COIN_PATH = /bsta/coin
###PERL_DATA_CHAT_PATH: DATA_CHAT_PATH = /botm/data/bsta/chat
-###PERL_DATA_COIN_PATH: DATA_COIN_PATH = /botm/data/bsta/coincidence
-###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
-###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state
###PERL_WEBSITE_NAME: WEBSITE_NAME = Bicycles on the Moon
$page = get_id(\%cgi, -1);
$password = get_password(\%cgi);
-%coin = read_data_file(DATA_COIN_PATH());
-%settings = read_data_file(DATA_SETTINGS_PATH());
-%state = read_data_file(DATA_STATE_PATH());
+%coin = read_coincidence();
+%settings = read_settings();
+%state = read_state();
$password_ok = ($password eq $settings{'password'});
if ($page < 0) {
if (open_encoded($fh, "+<", DATA_CHAT_PATH())) {
if (flock($fh, 2)) {
- %chat = read_data_file($fh);
+ %chat = read_chat($fh);
$chat_state = int($chat{'state'});
$chat_id = int($chat{'id'});
$chat_state = CHAT_STATE->{'active'};
$chat{'state'} = $chat_state;
}
- write_data_file($fh, \%chat);
+ write_chat($fh, \%chat);
}
else {
$status = HTTP_STATUS->{'bad_request'};
$chat_state = CHAT_STATE->{'ready'};
$chat{'state'} = $chat_state;
}
- write_data_file($fh, \%chat);
+ write_chat($fh, \%chat);
}
elsif ($words eq '') {
$status = HTTP_STATUS->{'bad_request'};
if ($username =~ /^[A-Za-z]*$/) {
$chat{'content'} .= 'leave@'.$username.': '.$words."\n";
if ($username ne '') {
- write_data_file($fh, \%chat);
+ write_chat($fh, \%chat);
}
else {
my %new_chat;
if ($chat_state > 1) {
- write_data_file(DATA_CHAT_PATH.$chat_id, \%chat);
+ write_chat($chat_id, \%chat);
$new_chat{'id'} = $chat_id+1;
}
else {
}
$new_chat{'state'} = CHAT_STATE->{'disconnected'};
$new_chat{'content'} = '';
- write_data_file($fh, \%new_chat);
+ write_chat($fh, \%new_chat);
}
}
else {
$chat_state = CHAT_STATE->{'active'};
$chat{'state'} = $chat_state;
}
- write_data_file($fh, \%chat);
+ write_chat($fh, \%chat);
}
else {
$status = HTTP_STATUS->{'bad_request'};
# old chat archive
else {
$chat_id = $page;
- %chat = read_data_file(DATA_CHAT_PATH());
+ %chat = read_chat();
$last_id = int($chat{'id'});
if ($chat_id < $last_id) {
- %chat = read_data_file(DATA_CHAT_PATH.$page);
+ %chat = read_chat($page);
$chat_state = int($chat{'state'});
@chat_lines = split(/\r?\n/, $chat{'content'});
}
$newer_url = merge_url($newer_url , {'query' => $password_query, 'append_query' => 1, 'preserve_fragment' => 1});
}
+my $_password = $password_ok ? html_entity_encode_dec($settings{'password'}, 1): '';
my $abbr = abbr_name($username);
my $_website_name = html_entity_encode_dec(WEBSITE_NAME() , 1);
my $_server = html_entity_encode_dec($coin {'server'} , 1);
my $_key = html_entity_encode_dec($coin {'key'} , 1);
-my $_password = html_entity_encode_dec($settings{'password'}, 1);
my $_cgi_username = html_entity_encode_dec($cgi {'username'}, 1);
my $_username = html_entity_encode_dec($username , 1);
my $_abbr = html_entity_encode_dec($abbr , 1);