]> bicyclesonthemoon.info Git - yplom/facebug1/commitdiff
Changed suggeasted by others; license info
authorb <b@7dec801f-c475-4e67-ba99-809552d69c55>
Wed, 13 Jan 2016 20:55:31 +0000 (20:55 +0000)
committerb <b@7dec801f-c475-4e67-ba99-809552d69c55>
Wed, 13 Jan 2016 20:55:31 +0000 (20:55 +0000)
git-svn-id: svn://botcastle1b/yplom/facebug1@16 7dec801f-c475-4e67-ba99-809552d69c55

bot.1.pl
config.1.txt
configure.pl
if.css
interface.1.pl
make.sh
makefile.1.mak
readthis.txt
settings

index 08eed9caedfca2caeaaf0df91dd766671ced0f2c..02231274feadc226ca2c6ba37eb08646b3eae1a4 100644 (file)
--- a/bot.1.pl
+++ b/bot.1.pl
@@ -1,7 +1,7 @@
 ###PERL;
 
 # bot is generated from bot.1.pl
-# 02.01.2016
+# 13.01.2016
 #
 # This is the facebook bot. It depends on the proxy.
 # It reads pages from m.facebook.com archived on the proxy, extracts threads,
@@ -27,7 +27,7 @@ use Fcntl;
 use File::Copy;
 ###PROXY_LIB;
 ###FACEBUG_LIB;
-use proxy_lib qw(url2path urldiv2path path2urldiv getcgi divideurl joinurl readconfigfile entitydecode entityencode urldecode readheaderfile);
+use proxy_lib qw(url2path urldiv2path path2urldiv getcgi divideurl joinurl readconfigfile entitydecode entityencode urldecode urlencode readheaderfile);
 use facebug_lib qw(key readdatafile writedatafile gettimenumber);
 use POSIX qw(strftime locale_h);
 
@@ -35,6 +35,7 @@ use POSIX qw(strftime locale_h);
 ###GROUPSETTINGS_PATH;
 ###KEY_BITS;
 ###MAX_REDIRECTIONS;
+###DETAILED_LOGS;
 
 my $time = time();
 srand ($time-$$);
@@ -299,10 +300,12 @@ sub processfile {
        my $closetag=0;# if there is a tag to close
        my $ignoretext;# if text should be ignored and not added to post/thread content
        my $link;      # if bot is inside a link
+       my $namelink;
        my $hidename;  # if bot is inside a part which contains a name to be hidden
        my $attnumber; # number of current attachment
        my $incomplete;# if thread firstpost's content is incomplete 
        my $firstpost; # if the bot is in the firstpost (important if pagetype='post')
+       my $description;
        
        my $content;
        
@@ -411,6 +414,12 @@ sub processfile {
                        # thread author is in first <h3>
                        if (($tag{'<'} eq 'h3') and ($thread{($shared?'shared-':'').'author'} eq '')) {
                                $mode = 'thread-author';
+                               $link=0;
+                               $namelink=0;
+                               unless ($shared) {
+                                       $description=0;
+                               }
+                               $hidename;
                        }
                        # elsif (($tag{'<'} eq 'div')and($tag{'id'} !~ /^ufi_/)) {
                        elsif ($tag{'<'} eq 'div') {
@@ -422,6 +431,7 @@ sub processfile {
                                        $ignoretext=1; # text in firstposts only inside <p>
                                        $hidename=0;
                                        $link=0;
+                                       $namelink=0;
                                }
                                # The thread contains "shared" content
                                elsif (($tag{'id'} =~ /^([a-zA-Z0-9]_[a-zA-Z0-9]_[a-zA-Z0-9])$/) and !$shared and ($thread{'shared'} eq '')) {
@@ -450,7 +460,7 @@ sub processfile {
                                if (lc($tag{'aria-label'})eq 'likes') {
                                        $mode='thread-likes';
                                }
-                               ###DUPLICADED!
+                               ### this code had to be duplicated:
                                # there is an image attached
                                elsif ($tag{'href'} =~ /^\/photo\.php\?(.*&)?fbid=([0-9]+)(&.*)?$/) {
                                        my $imgnum=$2;
@@ -499,7 +509,7 @@ sub processfile {
                                                $mode = 'thread-attachment-img';
                                        }
                                }
-                               ###END OF DUPLICATED
+                               ###END OF DUPLICATED CODE
                                # there is a link attached
                                elsif ($tag{'href'} =~ /^https?:\/\/([a-z0-9\.\-]+)?facebook\.com\/l\.php\?(.*&)?u=([^&]+)(&.*)?$/) {
                                        ++$attnumber;
@@ -609,6 +619,10 @@ sub processfile {
                                                                        }
                                                                }
                                                                
+                                                               if ($description <= 0) {
+                                                                       delete $thread{'description'};
+                                                               }
+                                                               
                                                                # overwrite previous information with new one
                                                                foreach my $ind (keys %thread) {
                                                                        $thread2{$ind}=$thread{$ind};
@@ -622,8 +636,10 @@ sub processfile {
                                                                        writedatafile($threadfile,%thread2);
                                                                        truncate ($threadfile , tell($threadfile));
                                                                        
-                                                                       foreach my $ind (keys %thread2) {
-                                                                               print "$ind: $thread2{$ind}\n"; ####
+                                                                       if (DETAILED_LOGS) {
+                                                                               foreach my $ind (keys %thread2) {
+                                                                                       print "$ind: $thread2{$ind}\n"; ####
+                                                                               }
                                                                        }
                                                                        print "saved.\n\n";
                                                                }
@@ -648,19 +664,61 @@ sub processfile {
                # author name
                elsif ($mode eq 'thread-author') {
                        # name can be found in hyperlinks
-                       if ($tag{'<'} eq 'a') {
+                       if ($tag{'<'} eq 'span') {
+                               $description=-1;
+                       }
+                       elsif ($tag{'<'} eq 'a') {
+                               if ($tag{'href'} =~ /^https?:\/\/([a-z0-9\.\-]+)?facebook\.com\/l\.php\?(.*&)?u=([^&]+)(&.*)?$/) {
+                                       unless ($shared) {
+                                               $thread{'description'}.='<a href="'.entityencode(urldecode($3)).'">';
+                                               $link=1;
+                                       }
+                               }
                                # there are two types of facebook user IDs
-                               if ($tag{'href'} =~ /^\/([A-Za-z0-9\.]+)\/?(\?.*)?$/) {
-                                       my $author = $1;
-                                       if ($tag{'href'} =~ /^\/profile\.php\?(.*&)?id=([^&]+)(&.*)?$/) {
-                                               $author = urldecode($2);
+                               elsif ($tag{'href'} =~ /^\/([A-Za-z0-9\.]+)\/?(\?.*)?$/) {
+                                       my $person = $1;
+                                       unless ($person =~ /^(photo|post).php$/) {
+                                               if ($tag{'href'} =~ /^\/profile\.php\?(.*&)?id=([^&]+)(&.*)?$/) {
+                                                       $person = urldecode($2);
+                                               }
+                                               unless ($shared) {
+                                                       $thread{'description'}.='<b class="ni">'.(($$names{$person} ne '')?$$names{$person}:$$names{'default'});
+                                                       $link=1;
+                                                       $namelink=1;
+                                                       $hidename=1;
+                                               }
+                                               
+                                               if ($thread{($shared?'shared-':'').'author'} eq '') {
+                                                       $thread{($shared?'shared-':'').'author'} = $person;
+                                                       $thread{($shared?'shared-':'').'name'} = ($$names{$person} ne '')?$$names{$person}:$$names{'default'};
+                                               }
+                                       }
+                               }
+                               elsif ($tag{'href'} eq '#') {
+                                       unless ($shared) {
+                                               $thread{'description'}.='<b class="ni">'.$$names{'default'};
+                                               $link=1;
+                                               $namelink=1;
+                                               $hidename=1;
                                        }
                                        if ($thread{($shared?'shared-':'').'author'} eq '') {
-                                               $thread{($shared?'shared-':'').'author'} = $author;
-                                               $thread{($shared?'shared-':'').'name'} = ($$names{$author} ne '')?$$names{$author}:$$names{'default'};
+                                               $thread{($shared?'shared-':'').'name'} = $$names{'default'};
                                        }
                                }
                        }
+                       elsif ($tag{'<'} eq '/a') {
+                               if($link) {
+                                       if($namelink) {
+                                               $thread{'description'}.='</b>';
+                                               $namelink=0;
+                                       }
+                                       else {
+                                               $thread{'description'}.='</a>';
+                                       }
+                                       $link=0;
+                                       $hidename=0;
+                               }
+                       }
                        # go out of <h3>
                        elsif ($tag{'<'} eq '/h3') {
                                $mode='thread';
@@ -737,14 +795,27 @@ sub processfile {
                                                if ($tag{'href'} =~ /^\/profile\.php\?(.*&)?id=([^&]+)(&.*)?$/) {
                                                        $person = urldecode($2);
                                                }
-                                               $thread{($shared?'shared-':'').'postcontent'}.='<a href="#">'.(($$names{$person} ne '')?$$names{$person}:$$names{'default'});
+                                               $thread{($shared?'shared-':'').'postcontent'}.='<b class="ni">'.(($$names{$person} ne '')?$$names{$person}:$$names{'default'});
+                                               $link=1;
+                                               $namelink=1;
+                                               $hidename=1;
+                                       }
+                                       elsif ($tag{'href'} eq '#') {
+                                               $thread{($shared?'shared-':'').'postcontent'}.='<b class="ni">'.$$names{'default'};
                                                $link=1;
+                                               $namelink=1;
                                                $hidename=1;
                                        }
                                }
                                elsif ($tag{'<'} eq '/a') {
                                        if($link) {
-                                               $thread{($shared?'shared-':'').'postcontent'}.='</a>';
+                                               if($namelink) {
+                                                       $thread{($shared?'shared-':'').'postcontent'}.='</b>';
+                                                       $namelink=0;
+                                               }
+                                               else {
+                                                       $thread{($shared?'shared-':'').'postcontent'}.='</a>';
+                                               }
                                                $link=0;
                                                $hidename=0;
                                        }
@@ -757,12 +828,12 @@ sub processfile {
                        elsif ($tag{'<'} eq 'a') {
                                if (($tag{'href'}=~/^\/groups\/$$settings{'id'}\/?\?(.*&)?id=([^&]+)(&.*)?$/) and ($pagetype ne 'thread')) {
                                        unless($incomplete) {
-                                               $thread{($shared?'shared-':'').'postcontent'}.='<p><b>Post not completely archived.</b></p>';
+                                               $thread{($shared?'shared-':'').'postcontent'}.='<p><b class = "br">Post not completely archived.</b></p>';
                                        }
                                        $incomplete=1;
                                }
                                
-                               ### HAD TO BE DUPLICATED :(
+                               ### this code had to be duplicated:
                                
                                
                                # there is an image attached
@@ -969,6 +1040,7 @@ sub processfile {
                                        $ignoretext=0;
                                        $hidename=0;
                                        $link=0;
+                                       $namelink=0;
                                }
                                else {
                                        ++$level;
@@ -1046,8 +1118,10 @@ sub processfile {
                                                                        writedatafile($postfile,%post2);
                                                                        truncate ($postfile , tell($postfile));
                                                        
-                                                                       foreach my $ind (keys %post2) {
-                                                                               print "$ind: $post2{$ind}\n";
+                                                                       if(DETAILED_LOGS) {
+                                                                               foreach my $ind (keys %post2) {
+                                                                                       print "$ind: $post2{$ind}\n";
+                                                                               }
                                                                        }
                                                                        print "saved.\n\n";
                                                                }
@@ -1230,14 +1304,27 @@ sub processfile {
                                                if ($tag{'href'} =~ /^\/profile\.php\?(.*&)?id=([^&]+)(&.*)?$/) {
                                                        $person = urldecode($2);
                                                }
-                                               $post{'content'}.='<a href="#">'.(($$names{$person} ne '')?$$names{$person}:$$names{'default'});
+                                               $post{'content'}.='<b class="ni">'.(($$names{$person} ne '')?$$names{$person}:$$names{'default'});
+                                               $link=1;
+                                               $namelink=1;
+                                               $hidename=1;
+                                       }
+                                       elsif ($tag{'href'} eq '#') {
+                                               $post{'content'}.='<b class="ni">'.$$names{'default'};
                                                $link=1;
+                                               $namelink=1;
                                                $hidename=1;
                                        }
                                }
                                elsif ($tag{'<'} eq '/a') {
                                        if($link) {
-                                               $post{'content'}.='</a>';
+                                               if ($namelink) {
+                                                       $post{'content'}.='</b>';
+                                                       $namelink=0;
+                                               }
+                                               else {
+                                                       $post{'content'}.='</a>';
+                                               }
                                                $link=0;
                                                $hidename=0;
                                        }
@@ -1298,12 +1385,20 @@ sub processfile {
                                $thread{($shared?'shared-':'').'postcontent'}.=$text;
                        }
                }
+               if($mode eq 'thread-author') {
+                       unless ($hidename or $shared){
+                               $thread{'description'}.=$text;
+                               if (($text =~ /[a-z]/) and (!$link) and ($description == 0)) {
+                                       $description = 1;
+                               }
+                       }
+               }
                # the format facebook uses for showing time is not always helpful (for
                # example: "2 mins ago") There is no setting to change it in facebook.
                # at least in the m.facebook.com. The bot corrently DOES NOT interpret the
                # text.
                elsif ($mode eq 'thread-time') {
-                       $thread{($shared?'shared-':'').'timetext'}.=$text;
+                       $thread{($shared?'shared-':'').'timetext'}.=facebooktime($timenumber,$text);
                }
                elsif ($mode eq 'thread-attachment-link-title') {
                        $thread{($shared?'shared-':'').'linktitle-'.$attnumber}.=$text;
@@ -1328,7 +1423,7 @@ sub processfile {
                        }
                }
                elsif ($mode eq 'post-time') {
-                       $post{'timetext'}.=$text;
+                       $post{'timetext'}.=facebooktime($timenumber,$text);
                }
                elsif ($mode eq 'post-link-title') {
                        $post{'linktitle-'.$attnumber}.=$text;
@@ -1472,7 +1567,9 @@ sub saveimg {
        $archbasepath = urldiv2path($prot, $host, $port, $path, $query);
        $archheadpath = $archbasepath.'@h';
        $archimgpath = $archbasepath.'@v';
-       print "url: $url\n";
+       if (DETAILED_LOGS) {
+               print "url: $url\n";
+       }
        # Read the http header. Only interested in the status. If a redirection then
        # follow it and read again. If 200 it's ok to continue processing. Otherwise
        # return.
@@ -1487,7 +1584,9 @@ sub saveimg {
                        if ($location !~ /^[a-z]+:\/\//) {
                                $location = $prot.'://'.$host.(($port ne '')?(':'.$port):'').$location;
                        }
-                       print "Redirect: $location\n";
+                       if (DETAILED_LOGS) {
+                               print "Redirect: $location\n";
+                       }
                        ($prot, $host, $port, $path, $query) = divideurl($location);
                        $archbasepath = urldiv2path($prot, $host, $port, $path, $query);
                        $archheadpath = $archbasepath.'@h';
@@ -1558,3 +1657,220 @@ sub saveimg {
        return $header{'key'};
        
 }
+
+# function to get time from facebook time text
+# arguments: 1 - time number (when page was downloaded), 2 - facebook time text
+# returns a time number on success and the unchanged time text on failure.
+sub facebooktime {
+       (my $timenumber, my $timetext) = @_;
+       $timetext = lc ($timetext);
+       
+       my $year;
+       my $month;
+       my $day;
+       my $hour;
+       my $minute;
+       my $ampm;
+       
+       my $subtype;
+       my $subvalue;
+       my $returnvalue;
+       
+       # There are multible possible format of facebook time text format
+       
+       # Jan 2
+       # January 2
+       if ($timetext =~ /^ *([a-z]{3,}) +([0-9]+) *$/) {
+               $month = $1;
+               $day = int($2);
+               $year = int(substr($timenumber,0,4));
+               $hour='';
+               $minute='';
+       }
+       # Jan 2, 2015
+       # January 2, 2015
+       elsif ($timetext =~ /^ *([a-z]{3,}) +([0-9]+), +([0-9]{4}) *$/) {
+               $month = $1;
+               $day = int($2);
+               $year = int($3);
+               $hour='';
+               $minute='';
+       }
+       # Jan 2 at 10:02am
+       # January 2 at 10:02am
+       elsif ($timetext =~ /^ *([a-z]{3,}) +([0-9]+) +at +([0-9]{1,2}):([0-9]{2})([ap]m) *$/) {
+               $month = $1;
+               $day = int($2);
+               $year = int(substr($timenumber,0,4));
+               $hour=int($3);
+               $minute=int($4);
+               $ampm=$5;
+               if($ampm eq 'pm') {
+                       $hour += 12;
+               }
+       }
+       # Jan 2, 2015 at 10:02am
+       # January 2, 2015 at 10:02am 
+       elsif ($timetext =~ /^ *([a-z]{3,}) +([0-9]+), +([0-9]{4}) +at +([0-9]{1,2}):([0-9]{2})([ap]m) *$/) {
+               $month = $1;
+               $day = int($2);
+               $year = int($3);
+               $hour=int($4);
+               $minute=int($5);
+               $ampm=$6;
+               if($ampm eq 'pm') {
+                       $hour += 12;
+               }
+       }
+       # 1 hr
+       # 2 hours ago
+       # etc...
+       elsif ($timetext =~ /^ *([0-9]+) +h(ou)?rs?( +ago)? *$/) {
+               $subtype='h';
+               $subvalue=int($1);
+               $hour = int(substr($timenumber,8,2));
+       }
+       # 4 mins
+       # 2 minutes ago
+       # etc...
+       elsif ($timetext =~ /^ *([0-9]+) +min(ute)?s?( +ago)? *$/) {
+               $subtype='m';
+               $subvalue=int($1);
+               $minute = int(substr($timenumber,10,2));
+               $hour = int(substr($timenumber,8,2));
+       }
+       # 2 days ago
+       # etc...
+       elsif ($timetext =~ /^ *([0-9]+) +days?( +ago)? *$/) {
+               $subtype='d';
+               $subvalue=int($1);
+       }
+       elsif ($timetext =~ /^ *yesterday +at +([0-9]{1,2}):([0-9]{2})([ap]m) */) {
+               $subtype='d';
+               $subvalue=1;
+               $hour=int($1);
+               $minute=int($2);
+               $ampm=$3;
+               if($ampm eq 'pm') {
+                       $hour += 12;
+               }
+       }
+       else {
+               # print "FAIL 1 -".urlencode($timetext)."-\n";
+               return $timetext;
+       }
+       
+       if ($year !~ /^[0-9]+$/) {
+               $year = int(substr($timenumber,0,4));
+       }
+       if ($month !~ /^[0-9]+$/) {
+               if ($month eq '') {
+                       $month = int(substr($timenumber,4,2));
+               }
+               elsif ($month =~ /^jan/) {
+                       $month=1;
+               }
+               elsif ($month =~ /^feb/) {
+                       $month=2;
+               }
+               elsif ($month =~ /^mar/) {
+                       $month=3;
+               }
+               elsif ($month =~ /^apr/) {
+                       $month=4;
+               }
+               elsif ($month =~ /^may/) {
+                       $month=5;
+               }
+               elsif ($month =~ /^jun/) {
+                       $month=6;
+               }
+               elsif ($month =~ /^jul/) {
+                       $month=7;
+               }
+               elsif ($month =~ /^aug/) {
+                       $month=8;
+               }
+               elsif ($month =~ /^sep/) {
+                       $month=9;
+               }
+               elsif ($month =~ /^oct/) {
+                       $month=10;
+               }
+               elsif ($month =~ /^nov/) {
+                       $month=11;
+               }
+               elsif ($month =~ /^dec/) {
+                       $month=12;
+               }
+               else {
+                       # print "FAIL 2\n";
+                       return $timetext;
+               }
+               
+       }
+       if ($day !~ /^[0-9]+$/) {
+               $day = substr($timenumber,6,2);
+       }
+       
+       if ($subtype eq 'm') {
+               $minute -= $subvalue;
+               $subvalue = 0;
+               while($minute <0) {
+                       $minute += 60;
+                       ++$subvalue;
+                       $subtype = 'h';
+               }
+       }
+       if ($subtype eq 'h') {
+               $hour -= $subvalue;
+               $subvalue = 0;
+               while($hour <0) {
+                       $hour += 24;
+                       ++$subvalue;
+                       $subtype = 'd';
+               }
+       }
+       if ($subtype eq 'd') {
+               $day -= $subvalue;
+               if ($day <1) {
+                       --$month;
+                       if($month<1) {
+                               --$year;
+                               $month=12;
+                               $day = 31;
+                       }
+                       else {
+                               if ($month == 2) {
+                                       if($year%4) {
+                                               $day = 28;
+                                       }
+                                       elsif ($year%100) {
+                                               $day = 29;
+                                       }
+                                       elsif ($year%400) {
+                                               $day = 28;
+                                       }
+                                       else {
+                                               $day = 29;
+                                       }
+                               }
+                               elsif ((($month%2) and ($month < 8)) or ((!($month%2)) and ($month >= 8))) {
+                                       $day = 31;
+                               }
+                               else {
+                                       $day = 30;
+                               }
+                       }
+               }
+       }
+       
+       $returnvalue= sprintf('%04u%02u%02u',$year,$month,$day);
+       if($hour ne '') {
+               $returnvalue.=sprintf('%02u',$hour);
+               if($minute ne '') {
+                       $returnvalue.=sprintf('%02u',$minute);
+               }
+       }
+       return $returnvalue;
+}
\ No newline at end of file
index f0ba9664ddcff0005ae9e906d19fe6482c5bd4cb..ed26be0fb4281b69f48b41c42e570ed32852f944 100644 (file)
@@ -1,4 +1,24 @@
 # config.txt is generated from config.1.txt
+# 13.01.2016
+#
+# The file with the autogenerated configurations for Apache2 and crontab
+# 
+#    Copyright (C) 2015-2016  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 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/>.
+#
+# ! the license is for config.1.txt, not config.txt.
 
 8<------------------------------------------------------------------------------
 # Copy this to your Apache2 configuration:
index bf642c213d67ac27456e2dc46d1ad16bd3c4585c..c60e97f3de1dba9b8bf87776df262b6cb5845560 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 # configure.pl
-# 02.01.2016
+# 13.01.2016
 #
 # The facebook interface software, when run on a server, will use different
 # directories, host names, tcp ports, etc. than the server on which this
@@ -74,6 +74,13 @@ $def{'HTML_HEAD'}           = "use constant HTML_HEAD          => '".$set{'html_
 $def{'HTML_TOP'}            = "use constant HTML_TOP           => '".$set{'html_top'}."';";
 $def{'HTML_BOTTOM'}         = "use constant HTML_BOTTOM        => '".$set{'html_bottom'}."';";
 
+if(($set{'detailed_logs'} eq 'yes') or ($set{'detailed_logs'} =~ /^[0-9]*[1-9][0-9]*$/)) {
+       $def{'DETAILED_LOGS'}     = "use constant DETAILED_LOGS      => 1;";
+}
+else {
+       $def{'DETAILED_LOGS'}     = "use constant DETAILED_LOGS      => 0;";
+}
+
 
 $def{'PROXY_LIB'}   = "use lib '".$set{'proxy_lib_path'}."';";
 $def{'FACEBUG_LIB'} = "use lib '".$set{'lib_path'}."';";
diff --git a/if.css b/if.css
index a9a955a197a84efc11fb27748ba5a42dfec69581..b371b98156f7a81a90d0ee25ee4e9f74333c8d6a 100644 (file)
--- a/if.css
+++ b/if.css
@@ -1,5 +1,23 @@
-/* It's derived from botm.css, the default style of\r
-   1190.bicyclesonthemoon.info. */\r
+/* if.css                                                                     */\r
+/* 13.01.2016                                                                 */\r
+/*                                                                            */\r
+/* The CSS for the facebook interface. It's derived from botm.css, the default*/\r
+/* style of 1190.bicyclesonthemoon.info.                                      */\r
+/*                                                                            */\r
+/*    Copyright (C) 2015-2016  Balthasar Szczepański                          */\r
+/*                                                                            */\r
+/*    This program is free software: you can redistribute it and/or modify    */\r
+/*    it under the terms of the GNU Affero General Public License as          */\r
+/*    published by the Free Software Foundation, either version 3 of the      */\r
+/*    License, or (at your option) any later version.                         */\r
+/*                                                                            */\r
+/*    This program is distributed in the hope that it will be useful,         */\r
+/*    but WITHOUT ANY WARRANTY; without even the implied warranty of          */\r
+/*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           */\r
+/*    GNU Affero General Public License for more details.                     */\r
+/*                                                                            */\r
+/*    You should have received a copy of the GNU Affero General Public License*/\r
+/*    along with this program.  If not, see <http://www.gnu.org/licenses/>.   */\r
 \r
 html\r
 {\r
index 31cb963c56a3ee4fa4ce6c3244a4bf6ee7977b6a..4b1f198d776ef6cb75816910b3fe24ed7e7dd686 100644 (file)
@@ -1,7 +1,7 @@
 ###PERL;
 
 # interface.pl is generated from interface.1.pl
-# 05.01.2015
+# 13.01.2016
 #
 # This is the software of the facebook interface, to access archived groups,
 # threads, images, etc.
@@ -325,8 +325,12 @@ sub showpost {
        }
        $$postcontent =~ s/&img([^;]+);/insertimg($1)/ge;
        print '<div class="post-'.($even?'0':'1').'" id="'.(($pmode eq 'thread')?'':($idt[1].'-'.(($pmode eq 'post')?'':($idt[2].'-')))).$postid.'">';
-       print '<div class="post-name">'.entityencode($$post{'name'}).(($$post{'timetext'} ne '')?(' &bull; '.$$post{'timetext'}):'').(($$post{'likes'} ne '')?(' &bull; likes: <b>'.$$post{'likes'}.'</b>'):'').(($$post{'replies'} ne '')?(' &bull; replies: <b>'.$$post{'replies'}.'</b>'):'').'</div>'."\n";
-       print '<div class="post-content-'.($even?'0':'1').'">'.$$postcontent.'</div>'."\n";
+       print '<div class="post-name">'.entityencode($$post{'name'}).(($$post{'timetext'} ne '')?(' &bull; '.showtime($$post{'timetext'})):'').(($$post{'likes'} ne '')?(' &bull; likes: <b>'.$$post{'likes'}.'</b>'):'').(($$post{'replies'} ne '')?(' &bull; replies: <b>'.$$post{'replies'}.'</b>'):'').'</div>'."\n";
+       print '<div class="post-content-'.($even?'0':'1').'">';
+       if ($$post{'description'} ne '') {
+               print '<p><b class = "br">'.$$post{'description'}.'</b></p>';
+       }
+       print $$postcontent.'</div>'."\n";
        
        # "shared post" (post inside a post)
        if ($$post{'shared'}) {
@@ -338,8 +342,12 @@ sub showpost {
                }
                $$postcontent =~ s/&img([^;]+);/insertimg($1)/ge;
                print '<div class="post-'.($even?'1':'0').'" id="'.(($pmode eq 'thread')?'':($idt[1].'-'.(($pmode eq 'post')?'':($idt[2].'-')))).'-shared'.$postid.'">';
-               print '<div class="post-name">'.entityencode($$post{'shared-name'}).(($$post{'shared-timetext'} ne '')?(' &bull; '.$$post{'shared-timetext'}):'').'</div>'."\n";
-               print '<div class="post-content-'.($even?'1':'0').'">'.$$postcontent.'</div>'."\n";
+               print '<div class="post-name">'.entityencode($$post{'shared-name'}).(($$post{'shared-timetext'} ne '')?(' &bull; '.showtime($$post{'shared-timetext'})):'').'</div>'."\n";
+               print '<div class="post-content-'.($even?'1':'0').'">';
+               if ($$post{'shared-description'} ne '') {
+                       print '<p><b class = "br">'.$$post{'shared-description'}.'</b></p>';
+               }
+               print $$postcontent.'</div>'."\n";
                
                # shared posts can have attachments too
                $first=1;
@@ -631,10 +639,10 @@ sub thread {
                        # reverse order
                        print '<form class="inline" method="post" action="'.GROUP_PATH.'/'.$threadid.'" ><input type="hidden" name="skey" value="'.$skey.'">';
                        if($rev){
-                               print '<input type="submit" value="show chronological" class="button">';
+                               print '<input type="submit" value="show oldest first" class="button">';
                        }
                        else {
-                               print '<input type="submit" value="show antichronological" class="button"><input type="hidden" name="rev" value="1">';
+                               print '<input type="submit" value="show newest first" class="button"><input type="hidden" name="rev" value="1">';
                        }
                        print '</form>'."\n";
                }
@@ -843,7 +851,7 @@ sub list {
                        next;
                }
                $even = !$even;
-               print '<tr class="'.($even?'list-entry-0':'list-entry-1').'"><td class="list-cell">'.(($group{'name'}ne'')?(entityencode($group{'name'})):$groupid).'</td><td class="list-cell"><form method="post" action="'.GROUP_PATH.'/'.$groupid.'" class="inline"><input type="hidden" name="skey" value="'.$skey.'"><input type="submit" value="show chronological" class="button"></form> <form method="post" action="'.GROUP_PATH.'/'.$groupid.'" class="inline"><input type="hidden" name="skey" value="'.$skey.'"><input type="hidden" name="rev" value="1"><input type="submit" value="show antichronological" class="button"></form></td></tr>'."\n";
+               print '<tr class="'.($even?'list-entry-0':'list-entry-1').'"><td class="list-cell">'.(($group{'name'}ne'')?(entityencode($group{'name'})):$groupid).'</td><td class="list-cell"><form method="post" action="'.GROUP_PATH.'/'.$groupid.'" class="inline"><input type="hidden" name="skey" value="'.$skey.'"><input type="submit" value="show oldest first" class="button"></form> <form method="post" action="'.GROUP_PATH.'/'.$groupid.'" class="inline"><input type="hidden" name="skey" value="'.$skey.'"><input type="hidden" name="rev" value="1"><input type="submit" value="show newest first" class="button"></form></td></tr>'."\n";
        }
        
        print '</table>'."\n";
@@ -993,7 +1001,7 @@ sub login {
        }
        
        # if password confirmed create the key and the access file
-       $key=$time.'f'.key(KEY_BITS);
+       $key=key(KEY_BITS);
        $accesspath=ACCESS_PATH.$key;
        
        open ($accessfile,">",$accesspath) or return loginpage("Couldn't create temporary file $accesspath.","Status: 500 Internal Server Error\n");
@@ -1035,7 +1043,7 @@ sub login {
                my $dir;
        
                print '<form class="inline" method="post" action="'.INTERFACE_PATH.'">';
-               print '<input type="submit" value="show the previous page" class="button">';
+               print '<input type="submit" value="continue to the previously requested page" class="button">';
                print '<input type="hidden" name="skey" value="'.entityencode($key).'">';
                print '<input type="hidden" name="mode" value="'.entityencode($cgi{'rmode'}).'">';
                if ($cgi{'rid'} ne '') {
@@ -1235,3 +1243,22 @@ sub getposition {
        }
        return;
 }
+
+sub showtime {
+       (my $timetext) = @_;
+       my $returnvalue;
+       
+       if ($timetext =~ /^[0-9]+$/) {
+               $returnvalue = int(substr($timetext,6,2)).'.'.substr($timetext,4,2).'.'.int(substr($timetext,0,4));
+               if (length($timetext) >= 10) {
+                       $returnvalue.= ', '.int(substr($timetext,8,2));
+                       if (length($timetext) >= 12) {
+                               $returnvalue.= ':'.substr($timetext,10,2);
+                       }
+               }
+       }
+       else {
+               $returnvalue = $timetext;
+       }
+       return $returnvalue;
+}
diff --git a/make.sh b/make.sh
index f584d54854b5d2ce396f35dd5970c1e7b42e9e4a..c7f185ddea70df2e93738467d9942e41a624496c 100644 (file)
--- a/make.sh
+++ b/make.sh
@@ -1,8 +1,26 @@
 #!/bin/sh
 
+# make.sh
+# 13.01.2016
+#
 # This is the script for making the software. Normally, the makefile is used for
 # this purpose. But the makefile has to be generated first.
 # This script generates the makefile and then uses it and finally removes it.
+#
+#    Copyright (C) 2015-2016  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 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/>.
 
 set -x
 perl configure.pl settings <makefile.1.mak >makefile
index 33ffcc4d0c5b2e06c271dbd1d29dd0461ef88c6f..9338aa969165575d3bfd80b8ae4337e5334769aa 100644 (file)
@@ -1,4 +1,22 @@
 # makefile is generated from makefile.1.mak.
+# 13.01.2016
+#
+# This is the makefile
+#
+#    Copyright (C) 2015-2016  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 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/>.
 
 ###CC;
 ###CF;
index 922e9c36fa1fb4bfe0fd4b073037416dc964b5b2..d379c3a4da4ecf3facf4b51179cb11ffabea9c54 100644 (file)
@@ -29,7 +29,7 @@ Run 'make.sh'. It will generate the programs and copy them to the correct
 location.
 It will also generate config.txt.
 Open this file and copy its fragments to your Apache2 config and crontab.
-Restart Apache2. (no need for this yet)
+Restart Apache2.
 
 To add a facebook group:
 
index 2a980cbb7f26feff0204048aa50d84fe3016ae2c..615e017a3476ecd01e49d3088e6145dbe4c2c6b8 100644 (file)
--- a/settings
+++ b/settings
@@ -1,3 +1,23 @@
+# settings
+# 13.01.2016
+#
+# In this file are defined values specific for the user's system
+# 
+#    Copyright (C) 2015-2016  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 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/>.
+
 #all directory paths must end with '/' and must already exist.
 
 bin_path  = /yplom/bin/facebug1/  #Where the software will be located
@@ -5,7 +25,7 @@ data_path = /yplom/data/facebug1/ #where the software  will remember data; subdi
                                   #group, groupsettings
 log_path  = /yplom/log/facebug1/  #where the software will remember data
 tmp_path  = /yplom/tmp/facebug1/  #for temporary fies
-www_path  = /yplom/www/facebug1/  #for the www server unused
+www_path  = /yplom/www/facebug1/  #for the www server
 lib_path  = /yplom/lib/facebug1/
 
 proxy_bin_path  = /yplom/bin/proxy/  #where the proxy software is located
@@ -58,3 +78,5 @@ bot_args = 207426296087284 # facebook groups which will be processed by the bot
 html_top    = <a href="/"><img border="0" alt="1190.bicyclesonthemoon.info" src="/img/botmlogo2.png"></img></a><br>
 html_bottom = <br><br>The facebook interface by Balthasar Szczepański, 2015-2016<br>Released under the <a href="http://www.gnu.org/licenses/agpl.html">AGPL3 license</a><br>The sources and instructions are available <a href="http://1190.bicyclesonthemoon.info/facebug/">here</a>.<br><br><a href="/">1190.bicyclesonthemoon.info</a>
 html_head   = <link rel="icon" type="image/png" href="/img/favicon.png">
+
+detailed_log = no # If the bot should output much details