-###PERL;
-#
+###RUN_PERL: #!/usr/bin/perl
+
# /bsta/coin
# chat.pl is generated from chat.1.pl.
-# 11.01.2017
#
# The coincidence interface
#
-# Copyright (C) 2016-2017 Balthasar Szczepański
+# Copyright (C) 2016, 2017, 2023 Balthasar Szczepański
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
#use warnings;
-###LIB;
+###PERL_LIB: use lib /botm/lib/bsta
use bsta_lib qw(failpage gethttpheader getcgi entityencode readdatafile writedatafile urlencode);
use File::Copy;
-###LOGO_PATH;
-###FAVICON_PATH;
-###COIN_PATH;
-###CHAT_PATH;
-###WEBSITE_NAME;
-###FAVICON_PATH;
-###CSS_PATH;
-###LOGO_PATH;
-###WEBSITE;
-###COINCIDENCE_PATH;
-###CGI_PATH;
+###PERL_CGI_PATH: CGI_PATH = /bsta/
+###PERL_CGI_COIN_PATH: CGI_COIN_PATH = /bsta/coin
+###PERL_CGI_CSS_PATH: CGI_CSS_PATH = /bsta/bsta.css
+###PERL_CGI_LOGO_PATH: CGI_LOGO_PATH = /bsta/botmlogo.png
+
+###PERL_DATA_CHAT_PATH: DATA_CHAT_PATH = /botm/data/bsta/chat
+###PERL_DATA_COIN_PATH: DATA_COIN_PATH = /botm/data/bsta/coincidence
+
+###PERL_WEBSITE: WEBSITE = 1190.bicyclesonthemoon.info
+###PERL_WEBSITE_NAME: WEBSITE_NAME = Bicycles on the Moon
+###PERL_FAVICON_PATH: FAVICON_PATH = /img/favicon.png
my %http;
my %cgi;
my $lastid;
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
-###PATH;
+###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
$method=$1;
$password=$cgi{'p'};
}
-%coin=readdatafile(COIN_PATH);
+%coin=readdatafile(DATA_COIN_PATH);
if($password eq $coin{'password'}){
$passwordOK = 1;
}
if($page < 0) {
- if (open ($chatfile,"+<",CHAT_PATH)){
+ if (open ($chatfile,"+<",DATA_CHAT_PATH)){
if (flock($chatfile,2)) {
%chat=readdatafile($chatfile);
writedatafile($chatfile,%chat);
}
elsif ($chatstate > 1) {
- writedatafile(CHAT_PATH.$chatid,%chat);
+ writedatafile(DATA_CHAT_PATH.$chatid,%chat);
my %newchat;
$newchat{'id'}=$chatid+1;
$newchat{'state'}=0;
}
}
else {
- # %chat=readdatafile(CHAT_PATH);
+ # %chat=readdatafile(DATA_CHAT_PATH);
# $chatid=int($chat{'id'})-$page;
- %chat=readdatafile(CHAT_PATH);
+ %chat=readdatafile(DATA_CHAT_PATH);
$lastid=int($chat{'id'});
- %chat=readdatafile(CHAT_PATH.$page);
+ %chat=readdatafile(DATA_CHAT_PATH.$page);
$chatid=int($chat{'id'});
$chatstate=int($chat{'state'});
@chatlines = split(/\r?\n/,$chat{'content'});
# print "Content-type: text/plain\n\n";
-# print CHAT_PATH."\n";
+# print DATA_CHAT_PATH."\n";
# print 'state: '.$chat{'state'}."\n";
# print 'id: '.$chat{'id'}."\n\n";
# print $chat{'content'};
print '<title>Coincidence • '.WEBSITE_NAME.'</title>'."\n";
print '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
print '<link rel="icon" type="image/png" href="'.FAVICON_PATH.'">'."\n";
-print '<link rel="stylesheet" href="'.CSS_PATH.'">'."\n";
+print '<link rel="stylesheet" href="'.CGI_CSS_PATH.'">'."\n";
print '</head><body>'."\n";
-print '<a href="/"><img id="botmlogo" src="'.LOGO_PATH.'" alt="'.WEBSITE.'"></a>'."\n";
+print '<a href="/"><img id="botmlogo" src="'.CGI_LOGO_PATH.'" alt="'.WEBSITE.'"></a>'."\n";
print '<div id="all">'."\n";
print '<div id="inst" class="ins">'."\n";
print '<span class="br">'.entityencode($message).'</span>'."\n";
}
if ($page < 0) {
- print '<form method="post" action="'.COINCIDENCE_PATH.'">'."\n";
+ print '<form method="post" action="'.CGI_COIN_PATH.'">'."\n";
if ($passwordOK) {
print '<input class="intxc" type="text" name="words">'."\n";
print '<input class="inbt" type="submit" value="Send">'."\n";
print '</div>'."\n";
print '<div id="underlinks">'."\n";
-print '<a href="'.CGI_PATH.'">BSTA</a> | <a href="'.COINCIDENCE_PATH.($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Once again</a>';
+print '<a href="'.CGI_PATH.'">BSTA</a> | <a href="'.CGI_COIN_PATH.($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Once again</a>';
if ($chatid > 0) {
- print ' | <a href="'.COINCIDENCE_PATH.'/'.($chatid-1).($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Before</a>';
+ print ' | <a href="'.CGI_COIN_PATH.'/'.($chatid-1).($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Before</a>';
}
if ($chatid < $lastid) {
- print ' | <a href="'.COINCIDENCE_PATH.'/'.(($chatid < $lastid-1)?($chatid +1):'').($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Unbefore</a>';
+ print ' | <a href="'.CGI_COIN_PATH.'/'.(($chatid < $lastid-1)?($chatid +1):'').($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Unbefore</a>';
}
if ($chatid > 0) {
- print ' | <a href="'.COINCIDENCE_PATH.'/0'.($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Initially</a>';
+ print ' | <a href="'.CGI_COIN_PATH.'/0'.($passwordOK?('?p='.urlencode($coin{'password'})):'').'">Initially</a>';
}
print ' | (This interface is only a demo, a proof of concept. It is very limited. No autorefresh, no private chat, etc. For full functionality use the actual Coincidence client.)'."\n";
print "\n";
-# print CHAT_PATH."\n";
+# print DATA_CHAT_PATH."\n";
# print 'state: '.$chat{'state'}."\n";
# print 'id: '.$chat{'id'}."\n\n";
# print $chat{'content'};