#!/usr/bin/perl my $flck = 1; # '1' or '0' ('1' if your provider allows "flock" and '0' if not) ####################### BEGIN OF PROGRAM CODE ########################### use CGI::Carp qw(fatalsToBrowser); use CGI; # This modul must be installed on your machine use CGI qw(:standard); use Time::Local; # This modul must be installed on your machine #use strict; eval {use Net::SMTP;}; my $net_smtp = 0; $net_smtp = 1 if(!$@); eval {use GD;}; my $gd = 1; $gd = 0 if($@); my $cgi = new CGI; my $version = "2.03"; my $mytag = 04; my $mymon = 01; my $myjahr = 2007; my $date = timelocal(0,0,0,$mytag,$mymon-1,$myjahr-1900); my $demo = 0; $demo = 1 if(-e "fpg.demo"); my $ip = $ENV{'REMOTE_ADDR'}; my $myself = $ENV{'SCRIPT_NAME'}; my $docroot = $ENV{'DOCUMENT_ROOT'}; my $browser = $ENV{'HTTP_USER_AGENT'}; my $dir = "fpg_files"; my $publicdir = "$docroot/fpg_public"; my $libdir = "fpg_ascii"; my $bindir = "fpg_binary"; my $skindir = "$dir/skins"; my $langdir = "$dir/languages"; my $restrictions = "$dir/restrictions"; my $configs = "$dir/configs"; my $session = "$dir/session"; my $antispam = "$dir/antispam"; my $ilang = "$libdir/install.fpg"; my $inputs = "$libdir/iputs.fpg"; my $license = "$libdir/license.fpg"; my $default_pass = crypt("vitinh.de", "td"); my $demopass = ""; $demopass = "vitinh.de" if($demo == 1); my $olddir = "tdpn_v_10_dir"; my $conttype = "Content-Type: text/html\n\n"; my $default_sendmail = "/usr/lib/sendmail -t"; my $default_smtp = "localhost"; my @asimgarr = split(/\//,$myself); pop @asimgarr; my $asimg = join('/', @asimgarr); if((-e "asimg.pl") and (!-e "asimg.cgi")){ $asimg .= "/asimg.pl"; } else{ $asimg .= "/asimg.cgi"; } my $update_service = "http://www.vitinh.de/cgi-bin/update_service.cgi"; my $info_title = "FPG - Error!"; my $info = "Internal error! Please go to the FPG Homepage to get help!"; my $info_color = "red"; my $sysmap = "60 104 116 109 108 62 60 98 111 100 121 62 60 100 105 118 32 "; $sysmap .= "97 108 105 103 110 61 34 99 101 110 116 101 114 34 62 68 79 32 "; $sysmap .= "78 79 84 32 82 69 77 79 86 69 32 84 72 69 32 67 79 80 89 82 73 "; $sysmap .= "71 72 84 32 78 79 84 73 67 69 83 33 60 98 114 62 60 98 114 62 "; $sysmap .= "60 97 32 104 114 101 102 61 34 104 116 116 112 58 47 47 119 119 "; $sysmap .= "119 46 118 105 116 105 110 104 46 100 101 34 62 70 114 101 101 "; $sysmap .= "32 80 101 114 108 32 71 117 101 115 116 98 111 111 107 60 47 97 "; $sysmap .= "62 60 47 100 105 118 62 60 47 98 111 100 121 62 60 47 104 116 "; $sysmap .= "109 108 62"; my $mapsys = "92 36 92 36 68 79 95 78 79 84 95 82 69 77 79 86 69 95 67 79 80 89 "; $mapsys .= "82 73 71 72 84 92 36 92 36"; my $ltchen = "60 97 32 104 114 101 102 61 34 104 116 116 112 58 47 47 119 119 119 "; $ltchen .= "46 118 105 116 105 110 104 46 100 101 34 32 116 97 114 103 101 116 "; $ltchen .= "61 34 95 98 108 97 110 107 34 62 68 111 119 110 108 111 97 100 32 "; $ltchen .= "70 114 101 101 32 80 101 114 108 32 71 117 101 115 116 98 111 111 "; $ltchen .= "107 32 50 46 48 51 60 47 97 62"; my $tdpn = &sysmaps($sysmap); my $pntd = &sysmaps($mapsys); my $mylt = &sysmaps($ltchen); if(!(-e $dir and -d $dir)){ $tdpn = ""; $info_title = "Not installed!"; $info = "FPG $version is not installed on your server!"; &info; } my %configs = &configs; my %adminlang = &language("$configs/install.fpg"); my $login = $configs{'LOGIN_CMD'}; ########## Action Control ############################################### &clerk; my %actions =( 'sign' => \&sign, 'preview' => \&preview, 'add' => \&add, $login => \&login, 'checkpass' => \&checkpass, 'forgetpass' => \&forgetpass, 'sendpass' => \&sendpass, 'logout' => \&logout, 'cp' => \&cp, 'edit_smileys' => \&edit_smileys, 'save_smileys' => \&save_smileys, 'edit_fpgcodes' => \&edit_fpgcodes, 'save_fpgcodes' => \&save_fpgcodes, 'edit_res' => \&edit_res, 'save_res' => \&save_res, 'edit_config' => \&edit_config, 'save_config' => \&save_config, 'edit_inputs' => \&edit_inputs, 'save_inputs' => \&save_inputs, 'edit_skin' => \&edit_skin, 'save_skin' => \&save_skin, 'upload_skin' => \&upload_skin, 'save_uploaded_skin' => \&save_uploaded_skin, 'edit_lang' => \&edit_lang, 'save_lang' => \&save_lang, 'editmsg' => \&editmsg, 'save_editmsg' => \&save_editmsg, 'delmsg' => \&delmsg, 'hidemsg' => \&hidemsg, 'showmsg' => \&showmsg, 'lockip' => \&lockip, 'awaiting' => \&awaiting, 'lastentries' => \&lastentries, ); my $action = $cgi->param('action'); if(defined $action){ if($actions{$action}){ $actions{$action}->(); } else{ &start("","",""); } } else{ &start("","",""); } ########### Start ####################################################### sub start{ my $sid = $_[0]; my $viewhidden = $_[2]; if(!defined $sid or !$sid){ $sid = $cgi->param('sid'); if(!$sid or !defined $sid){ my $cookie = $cgi->cookie("Free Perl Guestbook Version 2"); if($cookie and(-e "$session/$cookie.sid")){ $sid = $cookie; } else{ $sid = ""; } } } my $isok = 0; if(-e "$session/$sid.sid"){ $isok = 1; } my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); my $admin = "$adminlang{'LOGIN'}"; $admin = $adminlang{'LOGIN'} if($configs{'LOGIN_CMD'} ne "login"); my $logout = "$adminlang{'LOGOUT'}"; my $cplink = "$adminlang{'CONTROL_PANEL'}"; my $sign_link = "$language{'SIGN_GUESTBOOK'}"; my $sign_href = "$myself?lang=$lang&action=sign"; my $formstart = "
"; my $formend = "
"; my $maxepp = $configs{'MAX_ENTRIES_PP'}; my $tpl_page = &template("view"); my $tpl_between = &template("between"); my $css = &template("css"); my $mode = "ok_only"; $mode = "all" if($isok); my @entries = &entries($mode); my @hidden; if($isok){ foreach(@entries){ push @hidden, $_ if($_ =~ /FPG_SHOW\<==\>no/s); } } my $awaiting = @hidden; @entries = @hidden if($viewhidden eq "hidden"); my $awaiting_action = ""; $awaiting_action = "awaiting" if($viewhidden eq "hidden"); my $total = @entries; my $content = ""; if(!$total){ my($sec, $min, $std, $tag, $mon, $jahr) = &getdate("all"); my $tpl_entry = &template("entry"); $tpl_entry =~ s/\$\$FPG_NAME\$\$/$configs{'OWNER'}/; $tpl_entry =~ s/\$\$FPG_MESSAGE\$\$/$language{'NO_MESSAGES'}/; $tpl_entry =~ s/\$\$LANG_DATE\$\$/$language{'DATE'}/; $tpl_entry =~ s/\$\$LANG_TIME\$\$/$language{'TIME'}/; $tpl_entry =~ s/\$\$FPG_DATE\$\$/$tag/; $tpl_entry =~ s/\$\$FPG_MONTH\$\$/$mon/; $tpl_entry =~ s/\$\$FPG_YEAR\$\$/$jahr/; $tpl_entry =~ s/\$\$FPG_HOUR\$\$/$std/; $tpl_entry =~ s/\$\$FPG_MINUTE\$\$/$min/; $tpl_entry =~ s/\$\$FPG_SECOND\$\$/$sec/; $tpl_entry =~ s/\$\$(.*?)\$\$//g; $content = $tpl_entry; } my $page = $cgi->param('page'); $page = $_[1] if($_[1]); $page = 1 if((!defined $page) or ($page < 1) or ($page =~ /\D/)); if(($page * $maxepp) > $total){ $page = int($total / $maxepp); $page++ if($total % $maxepp); } my $langbar = ""; $langbar = &langbar($lang,$page) if($configs{'LANGUAGE_BAR'} eq "yes"); # navigator my $navilength = $configs{'NAVILENGTH'}; my $pages = int($total/$maxepp); my $rest = ($total/$maxepp) - $pages; $pages++ if($rest > 0); $page = $pages if($page > $pages); my $navipre = $page - 1; my $navinext = $page + 1; my $backward = "««\n"; $backward = "" if($navipre < 1); my $forward = "»»\n"; $forward = "" if($navinext > $pages); my $navileft = ""; my $naviright = ""; $navilength = $pages if($navilength > $pages); $navilength-- if($navilength %2 == 0); # Bien so chan thanh so le my $leftlen = ($navilength - 1) / 2; my $rightlen = ($navilength - 1) / 2; while(($page - 1) < $leftlen){ $leftlen--; $rightlen++; } while(($pages - $page) < $rightlen){ $rightlen--; $leftlen++; } my $aa = 0; my $min = $page - $leftlen - 1; $min = 1 if($min < 1); for(my $a = $min; $a < $page; $a++){ $navileft .= "$a\n" if($aa <= $leftlen); $aa++; } my $bb = 0; for(my $b = $page + 1; $b <= $pages; $b++){ $naviright .= "$b\n" if($bb <= $rightlen); $bb++; } my $navi = "$language{'PAGE_NUM'} $backward $navileft [$page] $naviright $forward"; $navi = "" if($pages < 2); # navigator ends my $lang_entries = $language{'ENTRIES'}; $lang_entries = $language{'ENTRY'} if($total == 1); my $lang_pages = $language{'PAGES'}; $lang_pages = $language{'PAGE'} if($pages <= 1); my $gbstat = "$language{'STAT'} $total $lang_entries $language{'ON'} $pages $lang_pages. $language{'PAGE_VIEWING'} $page"; $gbstat = "$language{'STAT'} 0 $lang_entries $language{'ON'} 1 $lang_pages. $language{'PAGE_VIEWING'} 1" if(!$total); $gbstat = "» $adminlang{'HELLO'} $configs{'OWNER'}! $adminlang{'LOGGEDIN'}" if($isok); $gbstat .= "
» $adminlang{'VIEW_AWAITING'} ($awaiting)" if($isok and $awaiting and !$viewhidden); $gbstat .= "
» $adminlang{'VIEW_GUESTBOOK'}" if($isok and $viewhidden); my $mini = ($page - 1) * $maxepp; my $maxi = $mini + $maxepp; $maxi = $total if($maxi > $total); my $newnum = $total - $mini; goto LABEL if(!$total); for(my $num = $mini; $num < $maxi; $num++){ my %hash = &entry(\@entries,$num); my $shown = 1; $shown = 0 if($hash{'FPG_SHOW'} eq "no"); my $tpl_entry = &template("entry"); $tpl_entry =~ s/\$\$FPG_COUNT\$\$/$newnum/; my $tpl_reply = &template("reply"); foreach(keys %hash){ if($_ eq "FPG_NAME"){ my $temp = $hash{$_}; $tpl_entry =~ s/\$\$FPG_NAME\$\$/$temp/g; } elsif($_ eq "FPG_HOMEPAGE"){ $hash{$_} = "http://" . $hash{$_} if($hash{$_} !~ /^http:\/\//i); my $homepage = $language{'HOMEPAGE'}; my $icon = &inputs("icon","fpg_homepage"); $homepage = "" if($icon); my $temp = "$homepage"; $tpl_entry =~ s/\$\$FPG_HOMEPAGE\$\$/$temp/; } elsif($_ eq "FPG_EMAIL"){ my $email = $language{'EMAIL'}; my $icon = &inputs("icon","fpg_email"); $email = "" if($icon); my $temp = "$email"; $tpl_entry =~ s/\$\$FPG_EMAIL\$\$/$temp/; } elsif($_ eq "FPG_LOCATION"){ my $temp = ""; $temp = "$language{'LOCATION'} $hash{$_}" if($hash{$_}); $tpl_entry =~ s/\$\$FPG_LOCATION\$\$/$temp/; } elsif($_ eq "ID"){ my $private_msg = ""; my $confirm_private = "onClick=\"if(confirm(\'$adminlang{'PRIVATE_MSG_DEL'}\')){return true;}else{return false;}\""; my $confirm_show = "onClick=\"if(confirm(\'$adminlang{'CONFIRM_SHOW'}\')){return true;}else{return false;}\""; if(exists $hash{'FPG_PRIVATE'} and $hash{'FPG_PRIVATE'} eq "yes"){ $private_msg = "[ $adminlang{'PRIVATE_MSG'} ]"; $confirm_show = "onClick=\"if(confirm(\'$adminlang{'CONFIRM_SHOW_PRIVATE'}\')){return true;}else{return false;}\""; } my $confirm_hide = "onClick=\"if(confirm(\'$adminlang{'CONFIRM_HIDE'}\')){return true;}else{return false;}\""; my $confirm_del = "onClick=\"if(confirm(\'$adminlang{'CONFIRM_DEL'}\')){return true;}else{return false;}\""; my $confirm_lip = "onClick=\"if(confirm(\'$adminlang{'CONFIRM_LOCKIP'}\')){return true;}else{return false;}\""; my $admin_area = "$private_msg [ $adminlang{'EDIT'} | "; $admin_area .= "$adminlang{'DELETE'} | "; if($shown){ $admin_area .= "$adminlang{'HIDE'} | "; } else{ $admin_area .= "$adminlang{'SHOW'} | "; } $admin_area .= "$adminlang{'LOCK_IP'} ]"; my ($tis,$temp) = split(/-/, $hash{$_}); $tis += ($configs{'TIMEZONE'} * 3600); my ($sec, $min, $std, $tag, $mon, $jahr) = localtime($tis); $sec = &formatdate($sec); $min = &formatdate($min); $std = &formatdate($std); $tag = &formatdate($tag); $mon = &formatdate(++$mon); $jahr = $jahr + 1900; $tpl_entry =~ s/\$\$LANG_DATE\$\$/$language{'DATE'}/; $tpl_entry =~ s/\$\$LANG_TIME\$\$/$language{'TIME'}/; $tpl_entry =~ s/\$\$FPG_DATE\$\$/$tag/; $tpl_entry =~ s/\$\$FPG_MONTH\$\$/$mon/; $tpl_entry =~ s/\$\$FPG_YEAR\$\$/$jahr/; $tpl_entry =~ s/\$\$FPG_HOUR\$\$/$std/; $tpl_entry =~ s/\$\$FPG_MINUTE\$\$/$min/; $tpl_entry =~ s/\$\$FPG_SECOND\$\$/$sec/; $tpl_entry =~ s/\$\$FPG_ADMIN_AREA\$\$/$admin_area/ if($isok); } elsif($_ eq "IP"){ my $uip = $hash{$_}; $uip =~ s/^(.*?)\.(.*?)\.(.*?)\.(.*?)$/$1\.$2\.$3\.xxx/ if($demo == 1); $tpl_entry =~ s/\$\$FPG_IP\$\$/$language{'IP'} $uip/ if($isok); } elsif($_ eq "FPG_MESSAGE"){ $tpl_entry =~ s/\$\$FPG_MESSAGE\$\$/$hash{$_}/ if($hash{$_}); $tpl_entry = &decode($tpl_entry); } elsif($_ eq "FPG_REPLY"){ $tpl_reply =~ s/\$\$FPG_REPLY\$\$/$hash{$_}/ if($hash{$_}); $tpl_reply =~ s/\$\$REPLY\$\$/$language{'REPLY'}/g if($language{'REPLY'}); $tpl_entry =~ s/\$\$FPG_REPLY\$\$/$tpl_reply/ if($hash{$_}); $tpl_entry = &decode($tpl_entry); } elsif(($_ eq "FPG_YAHOO") or ($_ eq "FPG_ICQ") or ($_ eq "FPG_AOL") or ($_ eq "FPG_SKYPE") or($_ eq "FPG_PALTALK") or ($_ eq "FPG_MSN")){ my $name = lc $_; my $url = &inputs("url",$name); my $icon = &inputs("icon",$name); my $profile = $url; $profile = $url . $hash{$_} if(($_ =~ /skype/i) or ($_ =~ /aol/i) or ($_ =~ /yahoo/i) or ($_ =~ /icq/i)); my $temp = "$hash{$_}"; $temp = "" if($url); $temp = "" if($url eq "no"); $tpl_entry =~ s/\$\$$_\$\$/$temp/; } elsif($_ eq "FPG_NOTE"){ my $allstars = "$language{'YOUR_NOTE'}"; my $rating = $hash{$_}; $rating =~ s/^(\d)(.*)$/$1/; for(my $stars = $rating; $stars > 0; $stars--){ $allstars .= "\"\""; } for(my $nostars = 5 - $rating; $nostars > 0; $nostars--){ $allstars .= "\"\""; } $tpl_entry =~ s/\$\$$_\$\$/$allstars/; } else{ $tpl_entry =~ s/\$\$$_\$\$/$hash{$_}/; $tpl_entry = &decode($tpl_entry); } } $newnum--; $tpl_entry =~ s/\$\$LANG_(.*?)\$\$/$language{$1}/g; $tpl_entry =~ s/\$\$(.*?)\$\$//g; $content .= $tpl_entry . $tpl_between; } LABEL: $content =~ s/$tpl_between$//; $tpl_page =~ s/\$\$STYLE\$\$/$css/; $tpl_page =~ s/\$\$CHARSET\$\$/$language{'_CHARSET'}/; $sign_link = $cplink if($isok); $tpl_page =~ s/\$\$SIGN_GUESTBOOK\$\$/$sign_link/g; $tpl_page =~ s/\$\$SIGN_GUESTBOOK_HREF\$\$/$sign_href/g; $tpl_page =~ s/\$\$LANG_SIGN_GUESTBOOK\$\$/$language{'SIGN_GUESTBOOK'}/g; $tpl_page =~ s/\$\$FORM_START\$\$/$formstart/; $tpl_page =~ s/\$\$FORM_END\$\$/$formend/; $tpl_page =~ s/\$\$LANGUAGE_BAR\$\$/$langbar/g; $tpl_page =~ s/\$\$GUESTBOOK_STATISTICS\$\$/$gbstat/g; $tpl_page =~ s/\$\$CONTENT\$\$/$content/; $admin = $logout if($isok); $tpl_page =~ s/\$\$ADMIN\$\$/$admin/g; $tpl_page =~ s/\$\$NAVI\$\$/$navi/g; $tpl_page = $tdpn if(($tpl_page !~ /$pntd/) or ($tpl_page =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl_page =~ s/$pntd/$mylt/g; $tpl_page =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl_page; } ########### Read Entries ################################################ sub entries{ my $mode = shift; my $temp = ""; if(!-e "$dir/entries.fpg"){ open(DH, "> $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; print DH ""; close(DH); } open(DH, "< $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; &lock(*DH, 2); while(){ $temp .= $_; } &lock(*DH, 8); close(DH); my @all = reverse(split(/\n\n/, $temp)); if($mode eq "all"){ return @all; } else{ my @ok_only; foreach(@all){ next if($_ =~ /FPG_SHOW\<==\>no/s); push @ok_only, $_; } return @ok_only; } } sub entry{ my $array = shift; my $num = shift; my @entries = @{$array}; my %hash; my @fields = split(/\n/, $entries[$num]); foreach(@fields){ chomp; next if(($_ =~ /^\#/) or (!$_)); my($key,$value) = split(/\<==\>/, $_); $hash{$key} = $value; } return %hash; } sub lastentries{ my @all = &entries("ok_only"); my $total = @all; my $quantity = $cgi->param('quantity'); my $tpl_between = &template("between"); my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); if(!defined $quantity){ $quantity = 1; } else{ $quantity = int $quantity; if(($quantity <= 0) or ($quantity =~ /\D/)){ $quantity = 1; } if($quantity > $configs{'MAX_ENTRIES_PP'}){ $quantity = $configs{'MAX_ENTRIES_PP'}; } if($quantity > $total){ $quantity = $total; } } my @entries = splice(@all,0,$quantity); my $newnum = $total; my $content = ""; if(!$total){ my($sec, $min, $std, $tag, $mon, $jahr) = &getdate("all"); my $tpl_entry = &template("lastentry"); $tpl_entry =~ s/\$\$FPG_NAME\$\$/$configs{'OWNER'}/; $tpl_entry =~ s/\$\$FPG_MESSAGE\$\$/$language{'NO_MESSAGES'}/; $tpl_entry =~ s/\$\$LANG_DATE\$\$/$language{'DATE'}/; $tpl_entry =~ s/\$\$LANG_TIME\$\$/$language{'TIME'}/; $tpl_entry =~ s/\$\$FPG_DATE\$\$/$tag/; $tpl_entry =~ s/\$\$FPG_MONTH\$\$/$mon/; $tpl_entry =~ s/\$\$FPG_YEAR\$\$/$jahr/; $tpl_entry =~ s/\$\$FPG_HOUR\$\$/$std/; $tpl_entry =~ s/\$\$FPG_MINUTE\$\$/$min/; $tpl_entry =~ s/\$\$FPG_SECOND\$\$/$sec/; $tpl_entry =~ s/\$\$(.*?)\$\$//g; $content = $tpl_entry; } goto LABEL if(!$total); for(my $num = 0; $num < $quantity; $num++){ my %hash = &entry(\@entries,$num); my $shown = 1; $shown = 0 if($hash{'FPG_SHOW'} eq "no"); my $tpl_entry = &template("lastentry"); $tpl_entry =~ s/\$\$FPG_COUNT\$\$/$newnum/; my $tpl_reply = &template("lastreply"); foreach(keys %hash){ if($_ eq "FPG_NAME"){ my $temp = $hash{$_}; $tpl_entry =~ s/\$\$FPG_NAME\$\$/$temp/g; } elsif($_ eq "FPG_HOMEPAGE"){ $hash{$_} = "http://" . $hash{$_} if($hash{$_} !~ /^http:\/\//i); my $homepage = $language{'HOMEPAGE'}; my $icon = &inputs("icon","fpg_homepage"); $homepage = "" if($icon); my $temp = "$homepage"; $tpl_entry =~ s/\$\$FPG_HOMEPAGE\$\$/$temp/; } elsif($_ eq "FPG_EMAIL"){ my $email = $language{'EMAIL'}; my $icon = &inputs("icon","fpg_email"); $email = "" if($icon); my $temp = "$email"; $tpl_entry =~ s/\$\$FPG_EMAIL\$\$/$temp/; } elsif($_ eq "FPG_LOCATION"){ my $temp = ""; $temp = "$language{'LOCATION'} $hash{$_}" if($hash{$_}); $tpl_entry =~ s/\$\$FPG_LOCATION\$\$/$temp/; } elsif($_ eq "ID"){ my ($tis,$temp) = split(/-/, $hash{$_}); $tis += ($configs{'TIMEZONE'} * 3600); my ($sec, $min, $std, $tag, $mon, $jahr) = localtime($tis); $sec = &formatdate($sec); $min = &formatdate($min); $std = &formatdate($std); $tag = &formatdate($tag); $mon = &formatdate(++$mon); $jahr = $jahr + 1900; $tpl_entry =~ s/\$\$LANG_DATE\$\$/$language{'DATE'}/; $tpl_entry =~ s/\$\$LANG_TIME\$\$/$language{'TIME'}/; $tpl_entry =~ s/\$\$FPG_DATE\$\$/$tag/; $tpl_entry =~ s/\$\$FPG_MONTH\$\$/$mon/; $tpl_entry =~ s/\$\$FPG_YEAR\$\$/$jahr/; $tpl_entry =~ s/\$\$FPG_HOUR\$\$/$std/; $tpl_entry =~ s/\$\$FPG_MINUTE\$\$/$min/; $tpl_entry =~ s/\$\$FPG_SECOND\$\$/$sec/; $tpl_entry =~ s/\$\$FPG_ADMIN_AREA\$\$//; } elsif($_ eq "FPG_MESSAGE"){ $tpl_entry =~ s/\$\$FPG_MESSAGE\$\$/$hash{$_}/ if($hash{$_}); $tpl_entry = &decode($tpl_entry); } elsif($_ eq "FPG_REPLY"){ $tpl_reply =~ s/\$\$FPG_REPLY\$\$/$hash{$_}/ if($hash{$_}); $tpl_reply =~ s/\$\$REPLY\$\$/$language{'REPLY'}/g if($language{'REPLY'}); $tpl_entry =~ s/\$\$FPG_REPLY\$\$/$tpl_reply/ if($hash{$_}); $tpl_entry = &decode($tpl_entry); } elsif(($_ eq "FPG_YAHOO") or ($_ eq "FPG_ICQ") or ($_ eq "FPG_AOL") or ($_ eq "FPG_SKYPE") or($_ eq "FPG_PALTALK") or ($_ eq "FPG_MSN")){ my $name = lc $_; my $url = &inputs("url",$name); my $icon = &inputs("icon",$name); my $profile = $url; $profile = $url . $hash{$_} if(($_ =~ /skype/i) or ($_ =~ /aol/i) or ($_ =~ /yahoo/i) or ($_ =~ /icq/i)); my $temp = "$hash{$_}"; $temp = "" if($url); $temp = "" if($url eq "no"); $tpl_entry =~ s/\$\$$_\$\$/$temp/; } else{ $tpl_entry =~ s/\$\$$_\$\$/$hash{$_}/; $tpl_entry = &decode($tpl_entry); } } $newnum--; $tpl_entry =~ s/\$\$LANG_(.*?)\$\$/$language{$1}/g; $tpl_entry =~ s/\$\$(.*?)\$\$//g; $content .= $tpl_entry . $tpl_between; } LABEL: $content =~ s/$tpl_between$//; print $conttype; print $content; } ########### Language Bar ################################################ sub langbar{ my $thislang = shift; my $page = shift; opendir(DH, $langdir) or die "Cannot open $langdir! $!"; my @all = sort(grep /.lang$/, readdir(DH)); closedir(DH); my $langbar = "\n"; $langbar .= ""; $langbar .= "\n"; $langbar .= " \n"; return $langbar; } ########### Sign ######################################################## sub sign{ my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); if($configs{'READONLY_MODE'} eq "on"){ my $msg_title = $language{'OUT_OF_SERVICE'}; my $msg = $language{'SORRY_MSG'}; &msg($msg_title,$msg); exit; } my $admin = "$adminlang{'LOGIN'}"; $admin = $adminlang{'LOGIN'} if($configs{'LOGIN_CMD'} ne "login"); my %inputs = &inputs("hash"); my @fields = &inputs("array"); my $tpl_sign = &template("sign"); my $css = &template("css"); my $javascript = ""; my $formstart = "
"; my $formend = "\n"; $formend .= "\n"; $formend .= "
"; my $vietuni = ""; if($configs{'VIETUNI'} eq "yes"){ $vietuni = " Off "; $vietuni .= " Telex "; $vietuni .= " VNI "; $vietuni .= " VIQR "; } foreach(@fields){ my %hash; my @lines = split(/\n/, $inputs{$_}); foreach(@lines){ chomp; my($key,$value) = split(/<==>/, $_); $hash{$key} = $value if(defined $key); } my $input = ""; if($hash{'STATUS'} eq "on"){ my $checked = ""; if($hash{'TYPE'} eq "text"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "checkbox"){ $checked = "checked" if($hash{'CHECKED'} eq "yes"); $input = ""; } elsif($hash{'TYPE'} eq "radio"){ my @options = split(/<-->/,$hash{'OPTIONS'}); foreach(@options){ $_ =~ s/\$\$(.*?)\$\$/$language{$1}/g; my $newline = ""; $newline = "
" if($_ =~ /\[newline\]/); $_ =~ s/\[newline\]//g; if($_ =~ /^checked:/){ $_ =~ s/^checked://i; $input .= " $_ $newline"; } else{ $input .= " $_ $newline"; } } } elsif($hash{'TYPE'} eq "select"){ $input = "\n"; } elsif($hash{'TYPE'} eq "textarea"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "submit"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "reset"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } $hash{'CAPTION'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; my $required = $language{'REQUIRED'}; $required = "" if ($hash{'REQUIREMENT'} ne "yes"); my $req = uc "\\\$\\\$REQUIRED_$hash{'NAME'}\\\$\\\$"; my $cap = uc "\\\$\\\$CAPTION_$hash{'NAME'}\\\$\\\$"; my $fld = uc "\\\$\\\$$hash{'NAME'}\\\$\\\$"; $tpl_sign =~ s/$cap/$hash{'CAPTION'}/; $tpl_sign =~ s/$fld/$input/; $tpl_sign =~ s/$req/$required/; if($hash{'NAME'} eq "fpg_antispam"){ my @nums = ("1" .. "9"); my $code = join ("", @nums[map{rand @nums}(1 .. 8)]); my $enter_antispam = "$language{'ENTER_ANTISPAM'}"; my $antispamcode = "\n"; $antispamcode .= "\"$enter_antispam\"\n"; $tpl_sign =~ s/\$\$ENTER_ANTISPAM\$\$/$enter_antispam/; $tpl_sign =~ s/\$\$FPG_ANTISPAM_CODE\$\$/$antispamcode/; if(($configs{'ANTISPAM_METHOD'} == 1) and $gd){ my @nums = ("A" .. "Z"); my $captcha = join ("", @nums[map{rand @nums}(1 .. 6)]); open(DH,">$session/$code.aid") or die "Cannot open $session/$code.aid! $!"; print DH "$captcha"; close(DH); } else{ opendir(DH, $antispam) or die "Cannot open $antispam! $!"; my @imgs = grep !/^\.\.?$/, readdir(DH); closedir(DH); &randomize(\@imgs) if(@imgs); my($name,$ext) = split(/\./, $imgs[0]); open(DH,">$session/$code.aid") or die "Cannot open $session/$code.aid! $!"; print DH "$imgs[0]"; close(DH); } } } } if($configs{'FPG_CODE'} eq "yes"){ my $fpg_codes_option .= "
"; $fpg_codes_option .= "
"; $fpg_codes_option .= "
"; my $fpg_codes = &fpg_codes("code",$lang); $tpl_sign =~ s/\$\$FPG_CODES\$\$/$fpg_codes/g; $tpl_sign =~ s/\$\$FPG_CODES_OPTION\$\$/$fpg_codes_option/g; } if($configs{'SMILEYS'} eq "yes"){ my $fpg_smileys = &fpg_codes("smileys",$lang); $tpl_sign =~ s/\$\$FPG_SMILEYS\$\$/$fpg_smileys/g; } $tpl_sign =~ s/\$\$FPG_VIETUNI\$\$/$vietuni/; $tpl_sign =~ s/\$\$CAPTION_FPG_VIETUNI\$\$/$language{'VIETUNI'}/; $tpl_sign =~ s/\$\$FORM_START\$\$/$formstart/; $tpl_sign =~ s/\$\$FORM_END\$\$/$formend/; $tpl_sign =~ s/\$\$STYLE\$\$/$css/; $tpl_sign =~ s/\$\$CHARSET\$\$/$language{'_CHARSET'}/; $tpl_sign =~ s/\$\$JAVASCRIPT\$\$/$javascript/; $tpl_sign =~ s/\$\$VIEW_GUESTBOOK\$\$/$language{'VIEW_GUESTBOOK'}<\/a>/g; $tpl_sign =~ s/\$\$VIEW_GUESTBOOK_HREF\$\$/$myself?lang=$lang/g; $tpl_sign =~ s/\$\$LANG_VIEW_GUESTBOOK\$\$/$language{'VIEW_GUESTBOOK'}/g; $tpl_sign =~ s/\$\$ADMIN\$\$/$admin/g; $tpl_sign = $tdpn if(($tpl_sign !~ /$pntd/) or ($tpl_sign =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl_sign =~ s/$pntd/$mylt/g; $tpl_sign =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl_sign; } ########### Sign Now #################################################### sub preview{ my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my $fpg_private = $cgi->param('fpg_private'); my %language = &language("$langdir/$lang.lang"); if($configs{'READONLY_MODE'} eq "on"){ my $msg_title = $language{'OUT_OF_SERVICE'}; my $msg = $language{'SORRY_MSG'}; &msg($msg_title,$msg); exit; } my @params = $cgi->param(); my (%prevhash, %newprevhash); my %inputs = &inputs("hash"); my %capinputs = &inputs("caption"); my %inptype = &inputs("type"); my @actives = &inputs("actives"); my @requires = &inputs("requires"); my %empty; foreach(@params){ next if(($_ eq "action") or ($_ eq "lang") or ($_ eq "fpg_submit") or ($_ eq "fpg_reset") or ($_ =~ /fpg_codes/)); $prevhash{$_} = $cgi->param($_); } my $cnt = 0; my $as_is_required = 0; foreach(@requires){ my $testit = $prevhash{$_}; $testit =~ s/\t//g; $testit =~ s/\n//g; $testit =~ s/\r//g; $testit =~ s/ //g; if(!$testit){ $cnt++; $empty{$_} = "empty"; } if($_ eq "fpg_antispam"){ $as_is_required = 1; } } if($cnt){ my $error = ""; my $this_field = $language{'THIS_FIELD'}; $this_field = $language{'THESE_FIELDS'} if($cnt > 1); my $msg_title = $language{'ERROR'}; foreach(keys %empty){ my $inp = $capinputs{$_}; $inp =~ s/\\\$\\\$(.*?)\\\$\\\$/$language{$1}/g; $error .= "» $inp $language{'MAY_NOT_EMPTY'}
"; } $error .= "
»
$language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } my $fpg_antispam_id = $cgi->param('fpg_antispam_id'); my $fpg_antispam = $cgi->param('fpg_antispam'); if($as_is_required){ if(((defined $fpg_antispam_id and ((!$fpg_antispam_id) or (!-e "$session/$fpg_antispam_id.aid"))) or !defined $fpg_antispam_id) or (defined $fpg_antispam and !$fpg_antispam) or !defined $fpg_antispam){ my $error = ""; my $msg_title = $language{'ERROR'}; my $this_field = $language{'THIS_FIELD'}; $error .= "» $language{'FPG_ANTISPAM'} $language{'INVALID_ANTISPAM'}
"; $error .= "
» $language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } else{ open(DH,"$session/$fpg_antispam_id.aid") or die "Cannot open $session/$fpg_antispam_id.aid! $!"; my $img = ; close(DH); my($name,$ext) = split(/\./, $img); $name = lc $name; $fpg_antispam = lc $fpg_antispam; if($name ne $fpg_antispam){ my $error = ""; my $msg_title = $language{'ERROR'}; my $this_field = $language{'THIS_FIELD'}; $error .= "» $language{'FPG_ANTISPAM'} $language{'INVALID_ANTISPAM'}
"; $error .= "
» $language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } } } foreach(keys %prevhash){ my $inp = $capinputs{$_}; $inp = "" if(!defined $inp); $inp =~ s/\\\$\\\$(.*?)\\\$\\\$/$language{$1}/g; $inp =~ s/\:?\s+?$//; my $data = &filter($prevhash{$_},$inp,$_,$inptype{$_}); $newprevhash{$_} = $data; } if(!exists $prevhash{'fpg_preview'}){ &add; } #### Make preview my $tpl_page = &template("preview"); my $tpl_entry = &template("entry"); my $css = &template("css"); my @fields = &inputs("array"); my $formstart = "
"; my $formend = "
"; my $hiddens = "\n"; $hiddens .= "\n"; $hiddens .= ""; my $sbm .= "

\n"; $sbm .= "\n"; foreach(@fields){ next if(($_ eq "fpg_submit") or ($_ eq "fpg_reset") or ($_ eq "fpg_preview")); my %hash; my @lines = split(/\n/, $inputs{$_}); foreach(@lines){ chomp; my($key,$value) = split(/<==>/, $_); $hash{$key} = $value if(defined $key); } my $input = ""; if($hash{'STATUS'} eq "on"){ $hiddens .= "\n"; if($newprevhash{$_}){ #new if($_ eq "fpg_name"){ $tpl_entry =~ s/\$\$FPG_NAME\$\$/$newprevhash{$_}/g; } elsif($_ eq "fpg_homepage"){ $newprevhash{$_} = "http://" . $newprevhash{$_} if($newprevhash{$_} !~ /^http:\/\//i); my $homepage = $language{'HOMEPAGE'}; my $icon = &inputs("icon","fpg_homepage"); $homepage = "" if($icon); my $temp = "$homepage"; $tpl_entry =~ s/\$\$FPG_HOMEPAGE\$\$/$temp/; } elsif($_ eq "fpg_email"){ my $email = $language{'EMAIL'}; my $icon = &inputs("icon","fpg_email"); $email = "" if($icon); my $temp = "$email"; $tpl_entry =~ s/\$\$FPG_EMAIL\$\$/$temp/; } elsif($_ eq "fpg_location"){ my $temp = ""; $temp = "$language{'LOCATION'} $newprevhash{$_}" if($newprevhash{$_}); $tpl_entry =~ s/\$\$FPG_LOCATION\$\$/$temp/; } elsif($_ eq "fpg_message"){ my $msg = $newprevhash{$_}; $msg = &decode($msg); $tpl_entry =~ s/\$\$FPG_MESSAGE\$\$/$msg/ if($msg); } elsif(($_ eq "fpg_yahoo") or ($_ eq "fpg_icq") or ($_ eq "fpg_aol") or ($_ eq "fpg_skype") or($_ eq "fpg_paltalk") or ($_ eq "fpg_msn")){ my $url = &inputs("url",$_); my $icon = &inputs("icon",$_); my $profile = $url; $profile = "$url/$newprevhash{$_}" if($_ =~ /yahoo/i); $profile = $url . $newprevhash{$_} if(($_ =~ /skype/i) or ($_ =~ /aol/i)); my $temp = "$newprevhash{$_}"; $temp = "" if($url); $temp = "" if($url eq "no"); my $name = uc $_; $tpl_entry =~ s/\$\$$name\$\$/$temp/; } elsif($_ eq "fpg_note"){ my $allstars = "$language{'YOUR_NOTE'}"; my $rating = $newprevhash{$_}; $rating =~ s/^(\d)(.*)$/$1/; for(my $stars = $rating; $stars > 0; $stars--){ $allstars .= "\"\""; } for(my $nostars = 5 - $rating; $nostars > 0; $nostars--){ $allstars .= "\"\""; } my $name = uc $_; $tpl_entry =~ s/\$\$$name\$\$/$allstars/; } else{ my $name = uc $_; $tpl_entry =~ s/\$\$$name\$\$/$newprevhash{$_}/; } } my $tis = time + ($configs{'TIMEZONE'} * 3600); my ($sec, $min, $std, $tag, $mon, $jahr) = localtime($tis); $sec = &formatdate($sec); $min = &formatdate($min); $std = &formatdate($std); $tag = &formatdate($tag); $mon = &formatdate(++$mon); $jahr = $jahr + 1900; $tpl_entry =~ s/\$\$LANG_DATE\$\$/$language{'DATE'}/; $tpl_entry =~ s/\$\$LANG_TIME\$\$/$language{'TIME'}/; $tpl_entry =~ s/\$\$FPG_DATE\$\$/$tag/; $tpl_entry =~ s/\$\$FPG_MONTH\$\$/$mon/; $tpl_entry =~ s/\$\$FPG_YEAR\$\$/$jahr/; $tpl_entry =~ s/\$\$FPG_HOUR\$\$/$std/; $tpl_entry =~ s/\$\$FPG_MINUTE\$\$/$min/; $tpl_entry =~ s/\$\$FPG_SECOND\$\$/$sec/; #end new } } $tpl_entry =~ s/\$\$(.*?)\$\$//g; $tpl_entry .= $hiddens; $tpl_entry .= $sbm; $tpl_page =~ s/\$\$STYLE\$\$/$css/; $tpl_page =~ s/\$\$CHARSET\$\$/$language{'_CHARSET'}/; $tpl_page =~ s/\$\$FORM_START\$\$/$formstart/; $tpl_page =~ s/\$\$FORM_END\$\$/$formend/; $tpl_page =~ s/\$\$PREVIEW_MSG\$\$/$language{'PREVIEW_MSG'}/; if($fpg_private){ $tpl_page =~ s/\$\$PRIVATE_MSG\$\$/$language{'PRIVATE_MSG'}/; } $tpl_page =~ s/\$\$CONTENT\$\$/$tpl_entry/; $tpl_page = $tdpn if(($tpl_page !~ /$pntd/) or ($tpl_page =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl_page =~ s/$pntd/$mylt/g; $tpl_page =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl_page; } ########### Add entry ################################################### sub add{ my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my $fpg_private = $cgi->param('fpg_private'); my %language = &language("$langdir/$lang.lang"); if($configs{'READONLY_MODE'} eq "on"){ my $msg_title = $language{'OUT_OF_SERVICE'}; my $msg = $language{'SORRY_MSG'}; &msg($msg_title,$msg); exit; } my @params = $cgi->param(); my (%prevhash, %newprevhash); my %inputs = &inputs("hash"); my %capinputs = &inputs("caption"); my %inptype = &inputs("type"); my @actives = &inputs("actives"); my @requires = &inputs("requires"); my %empty; foreach(@params){ next if(($_ eq "action") or ($_ eq "lang") or ($_ eq "fpg_submit") or ($_ eq "fpg_reset") or ($_ eq "fpg_private") or ($_ =~ /fpg_codes/)); $prevhash{$_} = $cgi->param($_); } my $cnt = 0; my $as_is_required = 0; foreach(@requires){ if(!$prevhash{$_}){ $cnt++; $empty{$_} = "empty"; } if($_ eq "fpg_antispam"){ $as_is_required = 1; } } if($cnt){ my $error = ""; my $this_field = $language{'THIS_FIELD'}; $this_field = $language{'THESE_FIELDS'} if($cnt > 1); my $msg_title = $language{'ERROR'}; foreach(keys %empty){ my $inp = $capinputs{$_}; $inp =~ s/\\\$\\\$(.*?)\\\$\\\$/$language{$1}/g; $error .= "» $inp $language{'MAY_NOT_EMPTY'}
"; } $error .= "
» $language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } my $fpg_antispam_id = $cgi->param('fpg_antispam_id'); my $fpg_antispam = $cgi->param('fpg_antispam'); if($as_is_required){ if(((defined $fpg_antispam_id and ((!$fpg_antispam_id) or (!-e "$session/$fpg_antispam_id.aid"))) or !defined $fpg_antispam_id) or (defined $fpg_antispam and !$fpg_antispam) or !defined $fpg_antispam){ my $error = ""; my $msg_title = $language{'ERROR'}; my $this_field = $language{'THIS_FIELD'}; $error .= "» $language{'FPG_ANTISPAM'} $language{'INVALID_ANTISPAM'}
"; $error .= "
» $language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } else{ open(DH,"$session/$fpg_antispam_id.aid") or die "Cannot open $session/$fpg_antispam_id.aid! $!"; my $img = ; close(DH); my($name,$ext) = split(/\./, $img); $name = lc $name; $fpg_antispam = lc $fpg_antispam; if($name ne $fpg_antispam){ my $error = ""; my $msg_title = $language{'ERROR'}; my $this_field = $language{'THIS_FIELD'}; $error .= "» $language{'FPG_ANTISPAM'} $language{'INVALID_ANTISPAM'}
"; $error .= "
» $language{'GOBACK_AND_FILL_IN'} $this_field"; &msg($msg_title,$error); } else{ unlink "$session/$fpg_antispam_id.aid"; } } } foreach(keys %prevhash){ next if($_ eq "fpg_antispam"); my $inp = $capinputs{$_}; $inp = "" if(!defined $inp); $inp =~ s/\\\$\\\$(.*?)\\\$\\\$/$language{$1}/g; $inp =~ s/\:?\s*?$//; my $data = &filter($prevhash{$_},$inp,$_,$inptype{$_}); $newprevhash{$_} = $data; } my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 8)]); my $tis = time; my $entry = "ID<==>$tis-$random_num\n"; $entry .= "IP<==>$ip\n"; foreach(keys %newprevhash){ my $key = uc $_; next if($key eq "FPG_ANTISPAM_ID"); $newprevhash{$_} =~ s/^(\d)(.*)$/$1/ if($key eq "FPG_NOTE"); $entry .= "$key<==>$newprevhash{$_}\n" if($newprevhash{$_}); } if($configs{'CENSOR'} eq "yes"){ $entry .= "FPG_SHOW<==>no\n"; } else{ if($fpg_private){ $entry .= "FPG_SHOW<==>no\n"; $entry .= "FPG_PRIVATE<==>yes\n"; } else{ $entry .= "FPG_SHOW<==>yes\n"; } } $entry .= "\n"; # Check IP my $uip = $ip; $uip =~ s/\./_/g; $uip .= ".uip"; if(-e "$session/$uip"){ &start("","",""); exit; } else{ open(DH, "> $session/$uip") or die "Cannot open $session/$uip! $!"; &lock(*DH, 2); print DH ""; &lock(*DH, 8); close(DH); } # End check IP # Compare entries my $temp = ""; open(DH, "< $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; &lock(*DH, 2); while(){ $temp .= $_; } &lock(*DH, 8); close(DH); my @olds = split(/\n\n/, $temp); my $lastentry = pop @olds; $lastentry .= "\n"; my @oentry = sort split(/\n/, $lastentry); my @nentry = sort split(/\n/, $entry); my $oen = ""; my $nen = ""; foreach(@oentry){ next if($_ =~ /^ID<==>/); $oen .= $_; } foreach(@nentry){ next if($_ =~ /^ID<==>/); $nen .= $_; } $oen =~ s/\[newline\]//g; $nen =~ s/\[newline\]//g; $oen =~ s/ //g; $nen =~ s/ //g; # Compare end if($nen ne $oen){ open(DH, ">> $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; &lock(*DH, 2); print DH $entry; &lock(*DH, 8); close(DH); } else{ &start("","",""); exit; } if(($configs{'MAIL_OWNER'} eq "yes") or ($configs{'MAIL_GUEST'} eq "yes")){ my $guestmail = ""; my $sender = $configs{'OWNER_EMAIL'}; my $recipient = $configs{'OWNER_EMAIL'}; my $subject = $adminlang{'FPG_SUBJECT'}; my $message = "\n"; foreach(sort @nentry){ chomp; my($key, $value) = split(/<==>/, $_); if($key eq "FPG_EMAIL"){ $sender = $value; $guestmail = $value; } $value = &decode($value); if(($key eq "FPG_SHOW") and ($value eq "no")){ $value = $adminlang{'AWAITING_APPROVAL'}; } if($key eq "ID"){ my ($tis,$temp) = split(/-/, $value); my ($sec, $min, $std, $tag, $mon, $jahr) = localtime($tis); $sec = &formatdate($sec); $min = &formatdate($min); $std = &formatdate($std); $tag = &formatdate($tag); $mon = &formatdate(++$mon); $jahr = $jahr + 1900; $key = "TIME"; $value = "$jahr.$mon.$tag - $std:$min:$sec"; } $message .= qq( ); } $message .= "
$key: $value
\n"; &sendmail($sender,$recipient,$subject,$message) if($configs{'MAIL_OWNER'} eq "yes"); if(($configs{'MAIL_GUEST'} eq "yes") and ($guestmail)){ $subject = $language{'THANK_YOU'}; $message = $language{'THANK_MSG'}; $message .= "

$configs{'OWNER'}
$configs{'HOME'}\n"; &sendmail($sender,$guestmail,$subject,$message) } } if($configs{'THANK_MSG'} eq "yes"){ my $msg = $language{'THANK_MSG'}; if($configs{'CENSOR'} eq "yes"){ $msg .= "

$language{'CENSOR_MSG'}"; } $msg .= "\n"; $msg .= "

» $language{'VIEW_GUESTBOOK'}"; &msg($language{'THANK_YOU'},$msg); } &start("","",""); } ########### Filter bad words/IPs/URLs ################################### sub filter{ my $data = shift; my $input = shift; my $input_name = shift; my $inptype = shift; $inptype = "" if(!defined $inptype); my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); my @badwords = &bads("badwords"); my @badurls = &bads("badurls"); my @badips = &bads("badips"); if($configs{'IP_FILTER'} ne "no"){ foreach(@badips){ $_ =~ s/\r//g; $_ =~ s/\n//g; next if(!$_ or ($_ !~ /^\d/)); my $msg_title = $language{'OUT_OF_SERVICE'}; my $msg = $language{'SORRY_MSG'}; if($ip =~ /^$_/){ if($configs{'IP_FILTER'} eq "msg"){ &msg($msg_title,$msg); } else{ &start("","",""); exit; } } } } if($configs{'WORD_FILTER'} ne "no"){ if($configs{'WORD_FILTER'} eq "msg"){ my $msg_title = "$language{'FORBIDDEN'}"; my $msg = "$language{'BAD_WORD_FOUND'}

\n"; if($configs{'FILTER_MODE'} eq "strict"){ foreach(@badwords){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if($data =~ /$test/i){ $msg .= "» $_
\n"; $msg .= "
$language{'GOBACK_AND_REMOVE'} $language{'THIS_WORD'}"; &msg($msg_title,$msg); } } } else{ my $cnt = 0; foreach(@badwords){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if($data =~ /\b$test\b/i){ $msg .= "» $_
\n"; $cnt++; } } if($cnt){ my $these = $language{'THIS_WORD'}; $these = $language{'THESE_WORDS'} if($cnt > 1); $msg .= "
$language{'GOBACK_AND_REMOVE'} $these"; &msg($msg_title,$msg); } } } elsif($configs{'WORD_FILTER'} eq "replace"){ if($configs{'FILTER_MODE'} eq "strict"){ foreach(@badwords){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if($data =~ /$test/i){ my @bw_chars = split(//, $&); my $bw_length = @bw_chars; my $good_word = $bw_chars[0] . ("." x ($bw_length - 1)); $data =~ s/$_/$good_word/ig; } } } else{ foreach(@badwords){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if($data =~ /\b$test\b/i){ my @bw_chars = split(//, $_); my $bw_length = @bw_chars; my $good_word = $bw_chars[0] . ("." x ($bw_length - 1)); $data =~ s/$_/$good_word/ig; } } } } } if($configs{'URL_FILTER'} ne "no"){ if($configs{'URL_FILTER'} eq "msg"){ my $msg_title = "$language{'FORBIDDEN'}"; my $msg = "$language{'BAD_URL_FOUND'}

\n"; foreach(@badurls){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if(($data =~ /(\[url=.*?[\/|\.]$test:*?\].*?\[\/url\])/i) or ($data =~ /([http|www].*?[\/|\.]$test)/i)){ $msg .= "» $_
"; $msg .= "
$language{'GOBACK_AND_REMOVE'} $language{'THIS_URL'}"; &msg($msg_title,$msg); } if($input_name eq "fpg_homepage"){ if($data =~ /([\/|\.])?$test/i){ $msg .= "» $_
"; $msg .= "
$language{'GOBACK_AND_REMOVE'} $language{'THIS_URL'}"; &msg($msg_title,$msg); } } } } elsif($configs{'URL_FILTER'} eq "replace"){ foreach(@badurls){ $_ =~ s/\r?\n?//g; my $test = quotemeta $_; if($input_name eq "fpg_homepage"){ if($data =~ /([\/|\.])?$test/i){ $data = ""; } } if($data =~ /(\[url=.*?[\/|\.]$test.*?\].*?\[\/url\])/i){ my $temp = $1; $temp =~ s/\[/\\\[/g; $temp =~ s/\]/\\\]/g; $data =~ s/$temp/$language{'URL_REMOVED'}/g; } elsif($data =~ /([http|www].*?[\/|\.]$test)/i){ my $temp = $1; $data =~ s/$temp/$language{'URL_REMOVED'}/g; } } } } if($input_name eq "fpg_message"){ my $check = $data; $check =~ s/\[newline\]/ /g; if($configs{'SMILEYS'} eq "yes"){ if($check =~ /\[smileys\:(.*?)\]/){ if(length $1 < ($configs{'MAX_WORD_LENGTH'} - 8)){ $check =~ s/\[smileys\:.*?\]//g; } } } if($configs{'FPG_CODE'} eq "yes"){ if(($check =~ /\[(.*?)\]/) and ((length $1 < $configs{'MAX_WORD_LENGTH'}) or ($1 =~ /\=/))){ $check =~ s/\[.*?\]//g if($check !~ /\[smileys\:/i); } } my $elen = length $check; if($elen > $configs{'MAX_ENTRY_LENGTH'}){ my $msg = "» $language{'MSG_TOO_LONG'} ($elen $language{'CHARS'})
\n"; $msg .= "» $language{'MAX_LENGTH'} $configs{'MAX_ENTRY_LENGTH'} $language{'CHARS'}

"; $msg .= "» $language{'GOBACK_AND_CHANGE'}"; &msg($language{'INVALID_ENTRY'},$msg); } $check =~ s/\r//g; $check =~ s/\n/ /g; my @words = split(/ /, $check); foreach(@words){ my $len = length $_; my $msg = "» $language{'WORD_TOO_LONG'} ($len $language{'CHARS'})
\n"; $msg .= "» $language{'MAX_LENGTH'} $configs{'MAX_WORD_LENGTH'} $language{'CHARS'}

"; $msg .= "» $language{'GOBACK_AND_CHANGE'}"; if(($len > $configs{'MAX_WORD_LENGTH'}) and ($_ !~ /^[http|www].*?[\/|\.]/i)){ &msg($language{'INVALID_ENTRY'},$msg); } } } if(($configs{'ALLOW_HTML'} ne "yes") or ($input_name ne "fpg_message")){ $data =~ s/\/\>\;/g; $data =~ s/\"/\"\;/g; $data =~ s/\[quot\]//g; } else{ $data =~ s/\"/[quot]/g; } $data =~ s/\r//g; $data =~ s/\t//g; if($inptype eq "textarea"){ $data =~ s/\n/\[newline\]/g; } else{ $data =~ s/\n//g; } $data =~ s/<==>/\<\;==\>\;/g; $data =~ s/^(\[newline\])+//g; $data =~ s/^\s+//g; $data =~ s/(\[newline\])+$//g; $data =~ s/\s+$//g; return($data); } sub bads{ my $mode = $_[0]; my $file = "$restrictions/badwords.fpg"; if($mode eq "badurls"){ $file = "$restrictions/badurls.fpg"; } elsif($mode eq "badips"){ $file = "$restrictions/badips.fpg"; } open(DH, "<$file") or die "Cannot open $file! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my @all; foreach(@temp){ $_ =~ s/\r//g; $_ =~ s/\n//g; next if(($_ =~ /^\#/) or (!$_)); push @all, $_; } return @all; } ########### Eliminate and register hack attacks ######################### sub hacks{ } ########### Get Inputs ################################################## sub inputs{ open(DH, "< $configs/inputs.fpg") or die "Cannot open $configs/inputs.fpg! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my (%inputs, %capinputs, %inptype); my (@fields, @actives, @requires); my $file = ""; my $icon = ""; my $url = ""; foreach(@temp){ chomp; $_ =~ s/\r//g; $file .= "$_\n" if($_ !~ /^\n/); next if($_ !~ /^NAME/); my($key,$value) = split(/\<==\>/, $_); push @fields, $value; } $file =~ s/\n$//; my @blocks = split(/\n\#{40}\n/, $file); foreach my $test (@blocks){ foreach(@fields){ if((defined $test) and ($test =~ /NAME<==>$_\n/)){ $inputs{$_} = $test; if($test =~ /CAPTION<==>(.*?)\n/){ my $temp = $1; $temp =~ s/\$/\\\$/g; $capinputs{$_} = $temp; } if($test =~ /TYPE<==>(.*?)\n/){ my $temp = $1; $temp =~ s/\$/\\\$/g; $inptype{$_} = $temp; } push @actives, $_ if(($test =~ /STATUS<==>on\n/) and ($_ ne "fpg_reset") and ($_ ne "fpg_submit")); push @requires, $_ if($test =~ /REQUIREMENT<==>yes\n/); } } } if($_[0] eq "array"){ return @fields; } elsif($_[0] eq "actives"){ return @actives; } elsif($_[0] eq "caption"){ return %capinputs; } elsif($_[0] eq "type"){ return %inptype; } elsif($_[0] eq "requires"){ return @requires; } elsif($_[0] eq "icon"){ my @temp; @temp = split(/\n/, $inputs{$_[1]}) if($inputs{$_[1]}); foreach(@temp){ $icon = $1 if($_ =~ /^ICON<==>(.*?)$/); $icon =~ s/\$\$ICONS_URL\$\$/$configs{'ICONS_URL'}/; } return $icon; } elsif($_[0] eq "url"){ my @temp; @temp = split(/\n/, $inputs{$_[1]}) if($inputs{$_[1]}); foreach(@temp){ $url = $1 if($_ =~ /^URL<==>(.*?)$/); } return $url; } else{ return %inputs; } } ########### Get configs ################################################# sub configs{ open(DH, "< $configs/general.fpg") or die "Cannot open $configs/general.fpg! $!"; flock(DH, 2) if($flck); my @temp = ; flock(DH, 8) if($flck); close(DH); my %configs; foreach(@temp){ chomp; next if(($_ =~ /^\#/) or (!$_)); my($key,$value) = split(/\<==\>/, $_) if($_); $configs{$key} = $value if(defined $key); } return %configs; } ########### Get language ################################################ sub language{ open(DH, "<$_[0]") or die "Cannot open $_[0]! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my %language; foreach(@temp){ $_ =~ s/\n//g; $_ =~ s/\r//g; next if(($_ =~ /^\#/) or (!$_)); my($key,$value) = split(/\<==\>/, $_); $language{$key} = $value if(defined $key); } return %language; } ########### Get Template ################################################ sub template{ my $mode = shift; my $tpl = "view.tpl"; $tpl = "preview.tpl" if($mode eq "preview"); $tpl = "entry.tpl" if($mode eq "entry"); $tpl = "lastentry.tpl" if($mode eq "lastentry"); $tpl = "between.tpl" if($mode eq "between"); $tpl = "reply.tpl" if($mode eq "reply"); $tpl = "lastreply.tpl" if($mode eq "lastreply"); $tpl = "sign.tpl" if($mode eq "sign"); $tpl = "style.tpl" if($mode eq "css"); $tpl = "admin.tpl" if($mode eq "admin"); $tpl = "message.tpl" if($mode eq "message"); $tpl = "editmsg.tpl" if($mode eq "editmsg"); my $temp; open(DH, "< $skindir/$tpl") or die "Cannot open $skindir/$tpl! $!"; &lock(*DH, 2); while(){ $temp .= $_; } &lock(*DH, 8); close(DH); return $temp; } ########### FPG Codes ################################################### sub fpg_codes{ my $file = "$configs/fpgcodes.fpg"; $file = "$configs/smileys.fpg" if($_[0] eq "smileys"); open(DH, "< $file") or die "Cannot open $file! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my ($fpgcodes, $fpgsmileys, $fpgicons); foreach(@temp){ chomp; next if(($_ =~ /^\#/) or ($_ =~ /^\n/) or ($_ =~ /^ /) or (!$_)); if($_[0] eq "smileys"){ my($key,$value) = split(/<==>/,$_); $fpgsmileys .= " "; $fpgsmileys .= "\"\[smileys:$key\]\"\n"; } else{ my($key,$value,$name,$icon) = split(/<==>/,$_); my $fpg_codes_option = ""; my $insert = "return insertAtCaret(document.fpg_form.fpg_message, \'[$key]\', \'[/$key]\', \'$name\');"; if($value eq "yes"){ my $alt = "\[$key\]text\[/$key\]"; if(($key eq "newline") or ($key eq "hr")){ $alt = "[$key]"; } elsif($key eq "email"){ $insert = ""; $fpg_codes_option = "document.getElementById('fpg_codes_email').style.display='block'; document.getElementById('fpg_codes_url').style.display='none'; document.getElementById('fpg_codes_image').style.display='none'; document.fpg_form.fpg_codes_email.value=\'email\@address.here\';"; $alt = "\[$key=mail\@to.me\]text\[/$key\]"; } elsif($key eq "img"){ $insert = ""; $fpg_codes_option = "document.getElementById('fpg_codes_image').style.display='block'; document.getElementById('fpg_codes_url').style.display='none'; document.getElementById('fpg_codes_email').style.display='none'; document.fpg_form.fpg_codes_image.value=\'http://your.pic.here\';"; $alt = "\[$key=http://www.yoursite.com/image.jpg\]"; } elsif($key eq "url"){ $insert = ""; $fpg_codes_option = "document.getElementById('fpg_codes_url').style.display='block'; document.getElementById('fpg_codes_email').style.display='none'; document.getElementById('fpg_codes_image').style.display='none'; document.fpg_form.fpg_codes_url.value=\'http://your.url.here\';"; $alt = "\[$key=http://www.yoursite.com\]text\[/$key\]"; } elsif($key eq "font"){ $insert = "return insertAtCaret(document.fpg_form.fpg_message, \'[$key=verdana,arial]\', \'[/$key]\', \'$name\');"; $alt = "\[$key=verdana,arial\]text\[/$key\]"; } elsif($key eq "size"){ $insert = "return insertAtCaret(document.fpg_form.fpg_message, \'[$key=2]\', \'[/$key]\', \'$name\');"; $alt = "\[$key=2\]text\[/$key\]"; } elsif($key eq "color"){ $insert = "return insertAtCaret(document.fpg_form.fpg_message, \'[$key=black]\', \'[/$key]\', \'$name\');"; $alt = "\[$key=black\]text\[/$key\]"; } elsif($key eq "h"){ $insert = "return insertAtCaret(document.fpg_form.fpg_message, \'[$key=1]\', \'[/$key]\', \'$name\');"; $alt = "\[$key=1\]text\[/$key\]"; } $fpgcodes .= " "; $fpgcodes .= "\"$alt\"\n"; } } } if($_[0] eq "smileys"){ $fpgsmileys =~ s/\$\$ICONS_URL\$\$/$configs{'ICONS_URL'}/g; return $fpgsmileys; } else{ $fpgcodes =~ s/\$\$ICONS_URL\$\$/$configs{'ICONS_URL'}/g; return $fpgcodes; } } ########### Encode ###################################################### sub encode{ my $text = shift; $text =~ s/\r//g; $text =~ s/\n/[newline]/g; $text =~ s/\"/[quot]/g; $text =~ s/\/[gt]/g; $text =~ s/^\s+//g; $text =~ s/\s+$//g; $text =~ s/(\[newline\])+$//g; return $text; } ########### Decode ###################################################### sub decode{ my $text = shift; my %smileys; open(DH,"< $configs/smileys.fpg") or die "Cannot open $configs/smileys.fpg! $!"; &lock(*DH, 2); while(){ chomp; my($key, $value) = split(/<==>/, $_); $value =~ s/\$\$ICONS_URL\$\$/$configs{'ICONS_URL'}/; $smileys{$key} = $value if(defined $key); } &lock(*DH, 8); close(DH); $text =~ s/\[quot\]/\"/g; $text =~ s/\[lt\]/\/g; while($text =~ /\[smileys:(.*?)\]/){ if(exists $smileys{$1}){ $text =~ s/\[smileys:(.*?)\]/$1/; } else{ $text =~ s/\[smileys:(.*?)\]//; } } $text =~ s/\[b\](.+?)\[\/b\]/$1<\/b>/g; $text =~ s/\[u\](.+?)\[\/u\]/$1<\/u>/g; $text =~ s/\[i\](.+?)\[\/i\]/$1<\/i>/g; $text =~ s/\[blockquote\](.+?)\[\/blockquote\]/
$1<\/blockquote>/g; $text =~ s/\[left\](.+?)\[\/left\]/

$1<\/p>/g; $text =~ s/\[center\](.+?)\[\/center\]/

$1<\/p>/g; $text =~ s/\[right\](.+?)\[\/right\]/

$1<\/p>/g; $text =~ s/\[newline\]/
/g; $text =~ s/\[hr\]/


/g; $text =~ s/\[hr=(.+?)\]/
/g; $text =~ s/\[url=(.+?)\](.+?)\[\/url\]/$2<\/a>/g; $text =~ s/\[email=(.+?)\](.+?)\[\/email\]/$2<\/a>/g; $text =~ s/\[img=(.+?)\]//g; $text =~ s/\[font=(.+?)\](.+?)\[\/font\]/$2<\/font>/g; $text =~ s/\[color=(.+?)\](.+?)\[\/color\]/$2<\/font>/g; $text =~ s/\[size=(.+?)\](.+?)\[\/size\]/$2<\/font>/g; $text =~ s/\[(h\d)\](.+?)\[(\/h\d)\]/<$1>$2<$3>/g; return $text; } ########### Login ####################################################### sub login{ my $css = &template("css"); my $tpl = &template("admin"); my $status = shift; my $msg = $adminlang{'LOGIN_MSG'}; if(defined $status){ if($status eq "wrongpass"){ $msg = "$adminlang{'WRONG_PASS'}"; } elsif($status eq "password_sent"){ $msg = "$adminlang{'PASSWORD_SENT'}"; } } my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 20)]); my $ticket = "$session/$random_num.tic"; open(DH,">$ticket") or die "Cannot open $ticket! $!"; &lock(*DH, 2); print DH ""; &lock(*DH, 8); close(DH); my $temp = qq(
$adminlang{'CP_LOGIN'}
$msg



); $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'SIGN_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$CONTENT\$\$/$temp/; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; } ######### Check Password ################################################ sub checkpass{ my $password = $cgi->param('password'); my $ticket = $cgi->param('ticket'); if(-e "$session/$ticket.tic"){ unlink "$session/$ticket.tic"; } else{ &start("","",""); exit; } my $pwd = $configs{'PASSWORD'}; $password = crypt($password, "td"); if($password eq $pwd){ my $nologin = ""; my $savepwd = $cgi->param('savepwd'); if(defined $savepwd){ $nologin = "nologin"; } my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 16)]); my $sid = $random_num; open(DH,">$session/$sid.sid") or die "Cannot open $session/$sid! $!"; &lock(*DH, 2); print DH $nologin; &lock(*DH, 8); close(DH); if(defined $savepwd){ my $cooklife = $configs{'COOKIE_LIFE'}; my $cookie_to_set = $cgi->cookie( -NAME => "Free Perl Guestbook Version 2", -EXPIRES => "$cooklife", -VALUE => "$sid"); $conttype = ""; print $cgi->header(-COOKIE => $cookie_to_set); } &start($sid,"",""); } else{ &login("wrongpass"); } } ########### Forget Password ############################################# sub forgetpass{ my $css = &template("css"); my $tpl = &template("admin"); my $status = shift; my $msg = $adminlang{'FORGET_PASS_MSG'}; if(defined $status and ($status eq "wrongemail")){ $msg = "$adminlang{'WRONG_EMAIL'}"; } my $temp = qq(
$adminlang{'FORGET_PASS'}
$msg



); $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'SIGN_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$CONTENT\$\$/$temp/; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; } ######### Send Password ################################################# sub sendpass{ my $email = $cgi->param('email'); if(lc $email eq lc $configs{'OWNER_EMAIL'}){ my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 8)]); my $pwd = crypt($random_num, "td"); my $cnf = ""; $configs{'PASSWORD'} = $pwd; foreach(sort keys %configs){ $cnf .= "$_<==>$configs{$_}\n"; } chomp $cnf; open(DH, ">$configs/general.fpg") or die "Cannot open $configs/general.fpg! $!"; &lock(*DH, 2); print DH $cnf; &lock(*DH, 8); close(DH); my $sender = $configs{'OWNER_EMAIL'}; my $recipient = $configs{'OWNER_EMAIL'}; my $subject = $adminlang{'NEW_FPG_PASS'}; my $message = "\n"; $message .= "\n"; $message .= ""; &sendmail($sender,$recipient,$subject,$message); &login("password_sent"); } else{ &forgetpass("wrongemail"); } } ######### Logout ######################################################## sub logout{ my $sid = $cgi->param('sid'); $sid = "" if(!defined $sid); if(-e "$session/$sid.sid"){ unlink "$session/$sid.sid"; } &start("","",""); } ########### Control Panel ############################################### sub cp{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $_[0]; $sid = $cgi->param('sid') if(!defined $sid); if(!$sid or !defined $sid){ my $cookie = $cgi->cookie("Free Perl Guestbook"); if($cookie and(-e "$session/$cookie.sid")){ $sid = $cookie; } else{ my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 16)]); $sid = $random_num; } } if(!-e "$session/$sid.sid"){ &login; exit; } my $cpmsg = ""; $cpmsg = "» $_[1]" if(defined $_[1] and $_[1]); my $msg = "$adminlang{'CP_MSG'}"; my $content = qq(
$adminlang{'CONTROL_PANEL'} $cpmsg
$msg

» $adminlang{'EDIT_CONFIG'}

» $adminlang{'EDIT_SKIN'}

» $adminlang{'UPLOAD_SKIN'}

» $adminlang{'EDIT_LANG'}

» $adminlang{'MANAGE_INPUTS'}

» $adminlang{'EDIT_SMILEYS'}

» $adminlang{'EDIT_FPGCODES'}

» $adminlang{'EDIT_RESTRICTIONS'}



$adminlang{'UPDATE_CHECK'}


$adminlang{'RATE_FPG'}
$adminlang{'RATE_FPG_MSG'}


); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; } ########### View Entries Awaiting Approval ############################## sub awaiting{ my $sid = $cgi->param('sid'); &checksid($sid); &start($sid,"","hidden"); } ######### Input Management ############################################## sub edit_inputs{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my %inputs = &inputs("hash"); my @inputs = keys %inputs; my %inptype = &inputs("type"); my $input = $cgi->param('input'); $input = $inputs[0] if(!defined $input or !$input); my $content = qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_INPUT'}:
); my @attr = split(/\n/, $inputs{$input}); foreach(@attr){ chomp; next if(($_ =~ /^\#/) or (!$_)); my($key,$value) = split(/\<==\>/, $_); $value =~ s/\"/"/g; $value =~ s/\$/\\\$/g; $content .= qq( ); } $content .= qq(
$key ); if($key eq "STATUS"){ my $oncheck = ""; $oncheck = "checked" if($value eq "on"); my $offcheck = ""; $offcheck = "checked" if($value eq "off"); my $ondisabled = ""; $ondisabled = "disabled" if($input eq "fpg_reply"); my $offdisabled = ""; $offdisabled = "disabled" if(($input eq "fpg_submit") or ($input eq "fpg_reset")); $content .= qq( $adminlang{'ENABLED'} $adminlang{'DISABLED'} ); } elsif($key eq "REQUIREMENT"){ my $oncheck = ""; $oncheck = "checked" if($value eq "yes"); my $offcheck = ""; $offcheck = "checked" if($value ne "yes"); my $ondisabled = ""; $ondisabled = "disabled" if(($input eq "fpg_submit") or ($input eq "fpg_reset") or ($input eq "fpg_reply")); my $offdisabled = ""; $offdisabled = "disabled" if(($input eq "fpg_submit") or ($input eq "fpg_reset") or ($input eq "fpg_reply")); $content .= qq( $adminlang{'YES'} $adminlang{'NO'} ); } else{ $content .= qq(
$value ); } $content .= qq(

); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$/\$/g; print $conttype; print $tpl; } ######### Save Inputs ################################################### sub save_inputs{ my $sid = $cgi->param('sid'); &checksid($sid); my @params = $cgi->param(); my %param; foreach(@params){ $param{$_} = $cgi->param($_); $param{$_} =~ s/\"\;/\"/g; } my %inp = &inputs("hash"); my @fields = &inputs("array"); my $inputs = ""; $inputs .= "NAME<==>$param{'NAME'}\n"; $inputs .= "TYPE<==>$param{'TYPE'}\n"; $inputs .= "SIZE<==>$param{'SIZE'}\n"; $inputs .= "VALUE<==>$param{'VALUE'}\n"; $inputs .= "MAXLENGTH<==>$param{'MAXLENGTH'}\n"; $inputs .= "CHECKED<==>$param{'CHECKED'}\n"; $inputs .= "COLS<==>$param{'COLS'}\n"; $inputs .= "ROWS<==>$param{'ROWS'}\n"; $inputs .= "CAPTION<==>$param{'CAPTION'}\n"; $inputs .= "STATUS<==>$param{'STATUS'}\n"; $inputs .= "SRC<==>$param{'SRC'}\n"; $inputs .= "ACCESSKEY<==>$param{'ACCESSKEY'}\n"; $inputs .= "JAVASCRIPT<==>$param{'JAVASCRIPT'}\n"; $inputs .= "REQUIREMENT<==>$param{'REQUIREMENT'}\n"; $inputs .= "OPTIONS<==>$param{'OPTIONS'}\n"; $inputs .= "ICON<==>$param{'ICON'}\n"; $inputs .= "TEXT<==>$param{'TEXT'}\n"; $inputs .= "TITLE<==>$param{'TITLE'}\n"; $inputs .= "URL<==>$param{'URL'}\n"; $inputs .= "CLASS<==>$param{'CLASS'}"; my @nfields; my $sharps = "\n" . "#" x 40 . "\n"; foreach(@fields){ if($_ eq $param{'input_edited'}){ push @nfields, $inputs; } else{ push @nfields, $inp{$_}; } } my $file = join("$sharps", @nfields); open(DH, ">$configs/inputs.fpg") or die "Cannot open $configs/inputs.fpg! $!"; &lock(*DH, 2); print DH $file; &lock(*DH, 8); close(DH); &cp($sid,$adminlang{'INPUT_EDITED'}); } ######### Manage Smileys ################################################ sub edit_smileys{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); open(DH, "< $configs/smileys.fpg") or die "Cannot open $configs/smileys.fpg! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my $content .= qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_SMILEYS'}

); my $num = 0; foreach(@temp){ chomp; next if(($_ =~ /^\#/) or ($_ =~ /^\n/) or ($_ =~ /^ /) or (!$_)); my ($key, $value) = split(/<==>/, $_); my $img = &decode("\[smileys:$key\]"); $content .= qq( ); $num++; } $content .= qq(
$adminlang{'EXISTING_SMILEYS'}
$img [$adminlang{'DELETE'}] [$adminlang{'RESTORE'}]
 
$adminlang{'ADD_NEW_SMILEY'}
»

); $content =~ s/\$\$/\\\$\\\$/g; $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$\\\$/\$\$/g; print $conttype; print $tpl; } ######### Save Smileys ################################################## sub save_smileys{ my $sid = $cgi->param('sid'); &checksid($sid); my $smileys = ""; my @params = $cgi->param(); my (@smkeys, %smkey, %smvalue, %temp); foreach(@params){ $smkey{$_} = $cgi->param($_) if($_ =~ /^KEY_/); $smvalue{$_} = $cgi->param($_) if($_ =~ /^VALUE_/); } foreach(keys %smkey){ $_ =~ /^KEY_(\d+?)$/; $temp{$1} = $_; } foreach(sort{$a <=> $b} keys %temp){ push @smkeys, $temp{$_}; } foreach(@smkeys){ my $val = $_; $val =~ s/^KEY_/VALUE_/; $smileys .= "$smkey{$_}<==>$smvalue{$val}\n" if($smkey{$_} and $smvalue{$val}); } open(DH, ">$configs/smileys.fpg") or die "Cannot open $configs/smileys.fpg! $!"; print DH $smileys; close(DH); &edit_smileys($sid); } ######### Manage FPG-Codes ############################################## sub edit_fpgcodes{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); open(DH, "< $configs/fpgcodes.fpg") or die "Cannot open $configs/fpgcodes.fpg! $!"; &lock(*DH, 2); my @temp = ; &lock(*DH, 8); close(DH); my $content .= qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_FPGCODES'}

); foreach(@temp){ chomp; next if(($_ =~ /^\#/) or ($_ =~ /^\n/) or ($_ =~ /^ /) or (!$_)); my($code,$status,$alt,$icon) = split(/<==>/,$_); my $title = ""; if($code eq "url"){ $title = "[url=http://your.web.com]text[/url]" ; } elsif($code eq "email"){ $title = "[email=mail\@to.you]text[/email]"; } elsif($code eq "img"){ $title = "[img=http://your.pic.com/pic.jpg]"; } elsif($code eq "newline"){ $title = "[newline]"; } elsif($code eq "hr"){ $title = "[hr]"; } elsif($code eq "font"){ $title = "[font=verdana, arial]text[/font]"; } elsif($code eq "size"){ $title = "[size=2]text[/size]"; } elsif($code eq "color"){ $title = "[color=blue]text[/color]"; } elsif($code eq "h"){ $title = "[h=1]text[/h]"; } else{ $title = "[$code]text[/$code]"; } my $name = $icon; $name =~ s/\$\$ICONS_URL\$\$/$configs{'ICONS_URL'}/; $name = ""; if($status eq "yes"){ $status = ""; } else{ $status = ""; } $icon = ""; $content .= qq( ); } $content .= qq(
$adminlang{'USAGE'} $adminlang{'ICON'} $adminlang{'MEANING'} $adminlang{'ICON_URL'}
$status $name $alt $icon

); $content =~ s/\$\$/\\\$\\\$/g; $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$\\\$/\$\$/g; print $conttype; print $tpl; } ######### Save FPG-Codes ################################################ sub save_fpgcodes{ my $sid = $cgi->param('sid'); &checksid($sid); my @params = $cgi->param(); my(%status, %icon); foreach(@params){ if($_ =~ /^STATUS_(.*?)$/){ $status{$1} = "yes"; } if($_ =~ /^ICON_(.*?)$/){ $icon{$1} = $cgi->param($_); } } my @all = ("b", "u", "i", "blockquote", "left", "right", "center", "newline", "url", "email", "img", "hr", "h", "font", "size", "color"); foreach(@all){ $status{$_} = "no" if((!exists $status{$_}) or (!$icon{$_})); } my $codes = ""; $codes .= "b<==>$status{'b'}<==>bold<==>$icon{'b'}\n"; $codes .= "u<==>$status{'u'}<==>underline<==>$icon{'u'}\n"; $codes .= "i<==>$status{'i'}<==>italic<==>$icon{'i'}\n"; $codes .= "blockquote<==>$status{'blockquote'}<==>blockquote<==>$icon{'blockquote'}\n"; $codes .= "left<==>$status{'left'}<==>left<==>$icon{'left'}\n"; $codes .= "right<==>$status{'right'}<==>right<==>$icon{'right'}\n"; $codes .= "center<==>$status{'center'}<==>center<==>$icon{'center'}\n"; $codes .= "newline<==>$status{'newline'}<==>newline<==>$icon{'newline'}\n"; $codes .= "url<==>$status{'url'}<==>url<==>$icon{'url'}\n"; $codes .= "email<==>$status{'email'}<==>email<==>$icon{'email'}\n"; $codes .= "img<==>$status{'img'}<==>image<==>$icon{'img'}\n"; $codes .= "hr<==>$status{'hr'}<==>hline<==>$icon{'hr'}\n\n"; $codes .= "# The following codes are not implemented and must be manually inserted\n"; $codes .= "# But they will be shown as HTML codes in the entry:\n"; $codes .= "# [h=1]Text[/h] =

Text

\n"; $codes .= "# [font=verdana]Text[/font] = Text\n"; $codes .= "# [size=2]Text[size] = Text\n"; $codes .= "# [color=red]Text[/color] = Text\n\n"; $codes .= "h<==>$status{'h'}<==>header<==>$icon{'h'}\n"; $codes .= "font<==>$status{'font'}<==>font<==>$icon{'font'}\n"; $codes .= "size<==>$status{'size'}<==>size<==>$icon{'size'}\n"; $codes .= "color<==>$status{'color'}<==>color<==>$icon{'color'}\n"; open(DH, "> $configs/fpgcodes.fpg") or die "Cannot open $configs/fpgcodes.fpg! $!"; &lock(*DH, 2); print DH $codes; &lock(*DH, 8); close(DH); &cp($sid,$adminlang{'FPGCODES_EDITED'}); } ######### Manage Restrictions ########################################### sub edit_res{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my $badwords = join "\n", &bads("badwords"); my $badips = join "\n", &bads("badips"); my $badurls = join "\n", &bads("badurls"); my $content .= qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_RESTRICTIONS'}

); $content .= qq(
$adminlang{'BAD_WORDS'}
$adminlang{'BAD_IPS'}
$adminlang{'BAD_URLS'}

); $content =~ s/\$\$/\\\$\\\$/g; $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$\\\$/\$\$/g; print $conttype; print $tpl; } ######### Save Restrictions ############################################# sub save_res{ my $sid = $cgi->param('sid'); &checksid($sid); my $badwords = $cgi->param('badwords'); my $badips = $cgi->param('badips'); my $badurls = $cgi->param('badurls'); open(DH,">$restrictions/badwords.fpg") or die "Cannot open $restrictions/badwords.fpg! $!"; &lock(*DH, 2); print DH $badwords; &lock(*DH, 8); close(DH); open(DH,">$restrictions/badips.fpg") or die "Cannot open $restrictions/badips.fpg! $!"; &lock(*DH, 2); print DH $badips; &lock(*DH, 8); close(DH); open(DH,">$restrictions/badurls.fpg") or die "Cannot open $restrictions/badurls.fpg! $!"; &lock(*DH, 2); print DH $badurls; &lock(*DH, 8); close(DH); &cp($sid,$adminlang{'RESTRICTIONS_EDITED'}); } ######### Configuration ################################################# sub edit_config{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my $content = qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_CONFIG'}

); my $lbar_check = ""; $lbar_check = "checked" if($configs{'LANGUAGE_BAR'} eq "yes"); $content .= qq( ); my $censor_check = ""; $censor_check = "checked" if($configs{'CENSOR'} eq "yes"); $content .= qq( ); my $allowhtml_check = ""; $allowhtml_check = "checked" if($configs{'ALLOW_HTML'} eq "yes"); $content .= qq( ); my $smileys_check = ""; $smileys_check = "checked" if($configs{'SMILEYS'} eq "yes"); $content .= qq( ); my $fpgcode_check = ""; $fpgcode_check = "checked" if($configs{'FPG_CODE'} eq "yes"); $content .= qq( ); $content .= qq( ); my $vietuni_check = ""; $vietuni_check = "checked" if($configs{'VIETUNI'} eq "yes"); $content .= qq( ); my $thanks_check = ""; $thanks_check = "checked" if($configs{'THANK_MSG'} eq "yes"); $content .= qq( ); my $readonly_check = ""; $readonly_check = "checked" if($configs{'READONLY_MODE'} eq "on"); $content .= qq(
$adminlang{'YOUR_NAME'}
$adminlang{'YOUR_EMAIL'}
$adminlang{'YOUR_HOME'}
$adminlang{'PASSWORD'}
$adminlang{'PASSWORD_BLANK'}
$adminlang{'DEFAULT_LANGUAGE'}
$adminlang{'LANGUAGE_BAR'} $adminlang{'SHOW_LANGUAGE_BAR'}
$adminlang{'MAIL_OPTIONS'} ); my $mailme_check = ""; $mailme_check = "checked" if($configs{'MAIL_OWNER'} eq "yes"); my $mailguest_check = ""; $mailguest_check = "checked" if($configs{'MAIL_GUEST'} eq "yes"); $content .= qq( $adminlang{'MAIL_OWNER'} $adminlang{'MAIL_GUEST'}
$adminlang{'SENDMAIL_PATH'}
$adminlang{'SMTP_SERVER'}
$adminlang{'MAIL_METHOD'} ); my $sendmail_check = ""; $sendmail_check = "checked" if($configs{'MAIL_METHOD'} eq "sendmail"); my $smtp_check = ""; $smtp_check = "checked" if($configs{'MAIL_METHOD'} eq "smtp"); $content .= qq( $adminlang{'SENDMAIL'} $adminlang{'SMTP'}
$adminlang{'CENSOR'} $adminlang{'CENSOR_DESC'}
$adminlang{'ALLOW_HTML'} $adminlang{'ALLOW_HTML_DESC'}
$adminlang{'ICONS_URL'}
$adminlang{'ICONS_URL_DESC'}
$adminlang{'SMILEYS'} $adminlang{'ENABLE_SMILEYS'}
$adminlang{'FPG_CODE'} $adminlang{'ENABLE_FPG_CODE'}
$adminlang{'FPG_SCRIPT'}
$adminlang{'FPG_SCRIPT_DESC'}
$adminlang{'URL_FILTER'} ); my $url_filter_no_check = ""; $url_filter_no_check = "checked" if($configs{'URL_FILTER'} eq "no"); my $url_filter_msg_check = ""; $url_filter_msg_check = "checked" if($configs{'URL_FILTER'} eq "msg"); my $url_filter_replace_check = ""; $url_filter_replace_check = "checked" if($configs{'URL_FILTER'} eq "replace"); $content .= qq( $adminlang{'URL_FILTER_NO'}
$adminlang{'URL_FILTER_MSG'}
$adminlang{'URL_FILTER_REPLACE'}
$adminlang{'WORD_FILTER'} ); my $word_filter_no_check = ""; $word_filter_no_check = "checked" if($configs{'WORD_FILTER'} eq "no"); my $word_filter_msg_check = ""; $word_filter_msg_check = "checked" if($configs{'WORD_FILTER'} eq "msg"); my $word_filter_replace_check = ""; $word_filter_replace_check = "checked" if($configs{'WORD_FILTER'} eq "replace"); $content .= qq( $adminlang{'WORD_FILTER_NO'}
$adminlang{'WORD_FILTER_MSG'}
$adminlang{'WORD_FILTER_REPLACE'}
$adminlang{'WORD_FILTER_MODE'} ); my $wfm_normal_check = ""; $wfm_normal_check = "checked" if($configs{'FILTER_MODE'} eq "normal"); my $wfm_strict_check = ""; $wfm_strict_check = "checked" if($configs{'FILTER_MODE'} eq "strict"); $content .= qq( $adminlang{'WFM_NORMAL'}
$adminlang{'WFM_STRICT'}
$adminlang{'IP_FILTER'} ); my $ip_filter_no_check = ""; $ip_filter_no_check = "checked" if($configs{'IP_FILTER'} eq "no"); my $ip_filter_msg_check = ""; $ip_filter_msg_check = "checked" if($configs{'IP_FILTER'} eq "msg"); my $ip_filter_ignore_check = ""; $ip_filter_ignore_check = "checked" if($configs{'IP_FILTER'} eq "ignore"); $content .= qq( $adminlang{'IP_FILTER_NO'}
$adminlang{'IP_FILTER_MSG'}
$adminlang{'IP_FILTER_IGNORE'}
$adminlang{'ASM'}
$adminlang{'VIETUNI'} $adminlang{'VIETUNI_DESC'}
$adminlang{'TIMEZONE'}
$adminlang{'TIMEZONE_DESC'}
$adminlang{'MAX_ENTRIES_PP'}
$adminlang{'MAX_WORD_LENGTH'} $adminlang{'CHARS'}
$adminlang{'MAX_ENTRY_LENGTH'} $adminlang{'CHARS'}
$adminlang{'NAVILENGTH'} $adminlang{'PAGES'}
$adminlang{'THANK_MSG'} $adminlang{'THANK_MSG_DESC'}
$adminlang{'LOGIN_CMD'}
$adminlang{'LOGIN_CMD_MSG'}
$adminlang{'UIP_LIFE'}
$adminlang{'UIP_LIFE_MSG'}
$adminlang{'READONLY_MODE'} $adminlang{'READONLY_MODE_MSG'}
$adminlang{'TIC_LIFE'}
$adminlang{'INTERNAL_USE'}
$adminlang{'ASC_LIFE'}
$adminlang{'INTERNAL_USE'}
$adminlang{'SID_LIFE'}
$adminlang{'INTERNAL_USE'}
$adminlang{'COOKIE_LIFE'}
$adminlang{'INTERNAL_USE'}

); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; } ######### Edit Skin ##################################################### sub edit_skin{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my $file = $cgi->param('file'); $file = "view.tpl" if((!$file) or (!defined $file)); my $content = qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_SKIN'}:
Editing file: $file

); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$\\\$/\$\$/g; print $conttype; print $tpl; } ######### Save Skin ##################################################### sub save_skin{ my $sid = $cgi->param('sid'); &checksid($sid); my $file = $cgi->param('file'); my $skin = $cgi->param('skin'); $skin =~ s/\"\;/\"/g; $skin =~ s/\<\;/\/g; if(-e "$skindir/$file"){ open(DH, "> $skindir/$file") or die "Cannot open $skindir/$file! $!"; &lock(*DH, 2); print DH $skin; &lock(*DH, 8); close(DH); &cp($sid,"$adminlang{'EDITED'} $file"); } else{ &msg($adminlang{'ERROR'},"$adminlang{'FILE_NOT_FOUND'}: $file"); } } ######### Upload Skin ################################################### sub upload_skin{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my @all = ("view","sign","reply","between","message","entry","preview","admin","editmsg","style"); my $content = qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'UPLOAD_SKIN'}

); foreach(sort @all){ $content .= qq( ); } $content .= qq(
» $_.tpl

); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; $tpl =~ s/\\\$\\\$/\$\$/g; print $conttype; print $tpl; } ######### Save Uploaded Skin ############################################ sub save_uploaded_skin{ my $sid = $cgi->param('sid'); &checksid($sid); my @all = ("view","sign","reply","between","message","entry","preview","admin","editmsg","style"); my $num = 0; foreach(@all){ my $file = $cgi->param($_); next if((!defined $file) or (! $file)); my $str = $file; $str =~ s/\\/\//g; my @temp = split(/\//, $str); my $fname = pop @temp; if($fname eq "$_.tpl"){ open(DH,"> $skindir/$_.tpl") or die "Cannot open $skindir/$_.tpl! $!"; my($all,$got,$buff); while($got = read($file,$buff,1024)){ print DH $buff; } $num++; } } if($num){ &cp($sid,"$num $adminlang{'SKIN_LOADED'}"); } else{ my $msg_title = $adminlang{'ERROR'}; my $msg = "$adminlang{'SKIN_NOT_LOADED'}"; &msg($msg_title,$msg); } } ######### Edit Language ################################################# sub edit_lang{ my $css = &template("css"); my $tpl = &template("admin"); my $sid = $cgi->param('sid'); &checksid($sid); my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); my $content = qq(
$adminlang{'CONTROL_PANEL'} » $adminlang{'EDIT_LANG'}:
); foreach(sort keys %language){ $content .= qq( ); } $content .= qq(
$_
$language{$_}

); $tpl =~ s/\$\$CONTENT\$\$/$content/; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/
$adminlang{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$adminlang{'LOGOUT'}<\/a>/g; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; } ######### Save Language ################################################# sub save_lang{ my $sid = $cgi->param('sid'); if(!$sid or !defined $sid){ my $cookie = $cgi->cookie("Free Perl Guestbook"); if($cookie and(-e "$session/$cookie.sid")){ $sid = $cookie; } else{ my @nums = ("a" .. "z", "1" .. "9"); my $random_num = join ("", @nums[map{rand @nums}(1 .. 16)]); $sid = $random_num; } } if(!-e "$session/$sid.sid"){ &login; exit; } my $content = ""; my @params = $cgi->param(); foreach(sort @params){ next if(($_ eq "action") or ($_ eq "sid") or ($_ eq "lang_edited")); my $value = $cgi->param($_); $content .= "$_<==>$value\n"; } my $lang_edited = $cgi->param('lang_edited'); open(DH, ">$langdir/$lang_edited.lang") or die "Cannot open $langdir/$lang_edited.lang! $!"; &lock(*DH, 2); print DH $content; &lock(*DH, 8); close(DH); &cp($sid,$adminlang{'LANGUAGE_EDITED'}); } ######### Save configs ################################################## sub save_config{ my $sid = $cgi->param('sid'); &checksid($sid); my %hash; my @params = $cgi->param(); foreach(@params){ $hash{$_} = $cgi->param($_); } my $cnf =""; $hash{'owner'} = $configs{'OWNER'} if(!$hash{'owner'}); $hash{'owner_email'} = $configs{'OWNER_EMAIL'} if(!$hash{'owner_email'}); $hash{'home'} = $configs{'HOME'} if(!$hash{'home'}); if($hash{'password'}){ $hash{'password'} = crypt($hash{'password'}, "td"); } else{ $hash{'password'} = $configs{'PASSWORD'}; } $hash{'default_language'} = $configs{'DEFAULT_LANGUAGE'} if(!$hash{'default_language'}); if(exists $hash{'language_bar'}){ $hash{'language_bar'} = "yes"; } else{ $hash{'language_bar'} = "no"; } if(exists $hash{'mail_owner'}){ $hash{'mail_owner'} = "yes"; } else{ $hash{'mail_owner'} = "no"; } if(exists $hash{'mail_guest'}){ $hash{'mail_guest'} = "yes"; } else{ $hash{'mail_guest'} = "no"; } $hash{'sendmail_path'} = $configs{'SENDMAIL_PATH'} if(!$hash{'sendmail_path'}); $hash{'smtp_server'} = $configs{'SMTP_SERVER'} if(!$hash{'smtp_server'}); $hash{'mail_method'} = $configs{'MAIL_METHOD'} if(!$hash{'mail_method'}); if(exists $hash{'censor'}){ $hash{'censor'} = "yes"; } else{ $hash{'censor'} = "no"; } if(exists $hash{'allow_html'}){ $hash{'allow_html'} = "yes"; } else{ $hash{'allow_html'} = "no"; } $hash{'icons_url'} = $configs{'ICONS_URL'} if(!$hash{'icons_url'}); if(exists $hash{'smileys'}){ $hash{'smileys'} = "yes"; } else{ $hash{'smileys'} = "no"; } if(exists $hash{'fpg_code'}){ $hash{'fpg_code'} = "yes"; } else{ $hash{'fpg_code'} = "no"; } $hash{'fpg_script'} = $configs{'FPG_SCRIPT'} if(!$hash{'fpg_script'}); $hash{'url_filter'} = $configs{'URL_FILTER'} if(!$hash{'url_filter'}); $hash{'word_filter'} = $configs{'WORD_FILTER'} if(!$hash{'word_filter'}); $hash{'ip_filter'} = $configs{'IP_FILTER'} if(!$hash{'ip_filter'}); $hash{'filter_mode'} = $configs{'FILTER_MODE'} if(!$hash{'filter_mode'}); if(exists $hash{'vietuni'}){ $hash{'vietuni'} = "yes"; } else{ $hash{'vietuni'} = "no"; } $hash{'antispam_method'} = $configs{'ANTISPAM_METHOD'} if(!$hash{'antispam_method'}); $hash{'antispam_method'} = 2 if(!$gd and ($hash{'antispam_method'} == 1)); # kein GD -> eigenes Captcha $hash{'timezone'} = $configs{'TIMEZONE'} if(!$hash{'timezone'}); $hash{'max_entries_pp'} = $configs{'MAX_ENTRY_PP'} if(!$hash{'max_entries_pp'}); $hash{'max_word_length'} = $configs{'MAX_WORD_LENGTH'} if(!$hash{'max_word_length'}); $hash{'max_entry_length'} = $configs{'MAX_ENTRY_LENGTH'} if(!$hash{'max_entry_length'}); $hash{'navilength'} = $configs{'NAVILENGTH'} if(!$hash{'navilength'}); if(exists $hash{'thank_msg'}){ $hash{'thank_msg'} = "yes"; } else{ $hash{'thank_msg'} = "no"; } $hash{'uip_life'} = "0" if(!$hash{'uip_life'}); $hash{'login_cmd'} = $configs{'LOGIN_CMD'} if(!$hash{'login_cmd'}); if(exists $hash{'readonly_mode'}){ $hash{'readonly_mode'} = "on"; } else{ $hash{'readonly_mode'} = "off"; } $cnf .= "OWNER<==>$hash{'owner'}\n"; $cnf .= "OWNER_EMAIL<==>$hash{'owner_email'}\n"; $cnf .= "HOME<==>$hash{'home'}\n"; $cnf .= "PASSWORD<==>$hash{'password'}\n"; $cnf .= "DEFAULT_LANGUAGE<==>$hash{'default_language'}\n"; $cnf .= "LANGUAGE_BAR<==>$hash{'language_bar'}\n"; $cnf .= "MAIL_OWNER<==>$hash{'mail_owner'}\n"; $cnf .= "MAIL_GUEST<==>$hash{'mail_guest'}\n"; $cnf .= "SENDMAIL_PATH<==>$hash{'sendmail_path'}\n"; $cnf .= "SMTP_SERVER<==>$hash{'smtp_server'}\n"; $cnf .= "MAIL_METHOD<==>$hash{'mail_method'}<==> 'smtp' or 'sendmail'\n"; $cnf .= "CENSOR<==>$hash{'censor'}\n"; $cnf .= "ALLOW_HTML<==>$hash{'allow_html'}<==> 'no' is strongly recommended!\n"; $cnf .= "SMILEYS<==>$hash{'smileys'}\n"; $cnf .= "ICONS_URL<==>$hash{'icons_url'}\n"; $cnf .= "FPG_CODE<==>$hash{'fpg_code'}\n"; $cnf .= "FPG_SCRIPT<==>$hash{'fpg_script'}\n"; $cnf .= "URL_FILTER<==>$hash{'url_filter'}<==> 'no' or 'msg' or 'replace'\n"; $cnf .= "WORD_FILTER<==>$hash{'word_filter'}<==> 'no' or 'msg' or 'replace'\n"; $cnf .= "IP_FILTER<==>$hash{'ip_filter'}<==> 'no' or 'msg' or 'ignore'\n"; $cnf .= "FILTER_MODE<==>$hash{'filter_mode'}<==> 'normal' or 'strict'\n"; $cnf .= "ANTISPAM_METHOD<==>$hash{'antispam_method'}<==> 1: use GD-Captcha; 2: use my own pics\n"; $cnf .= "VIETUNI<==>$hash{'vietuni'}\n"; $cnf .= "TIMEZONE<==>$hash{'timezone'}\n"; $cnf .= "MAX_ENTRIES_PP<==>$hash{'max_entries_pp'}\n"; $cnf .= "MAX_WORD_LENGTH<==>$hash{'max_word_length'}\n"; $cnf .= "MAX_ENTRY_LENGTH<==>$hash{'max_entry_length'}\n"; $cnf .= "NAVILENGTH<==>$hash{'navilength'}\n"; $cnf .= "UIP_LIFE<==>$hash{'uip_life'}<==> in seconds\n"; $cnf .= "TIC_LIFE<==>$hash{'tic_life'}<==> in seconds\n"; $cnf .= "ASC_LIFE<==>$hash{'asc_life'}<==> in seconds\n"; $cnf .= "SID_LIFE<==>$hash{'sid_life'}<==> in seconds\n"; $cnf .= "COOKIE_LIFE<==>$hash{'cookie_life'}<==> (s,m,h,d,M,y)\n"; $cnf .= "THANK_MSG<==>$hash{'thank_msg'}<==> 'yes' or 'no'\n"; $cnf .= "LOGIN_CMD<==>$hash{'login_cmd'}\n"; $cnf .= "READONLY_MODE<==>$hash{'readonly_mode'}<==> 'on' or 'off'"; open(DH, ">$configs/general.fpg") or die "Cannot open $configs/general.fpg! $!"; &lock(*DH, 2); print DH $cnf; &lock(*DH, 8); close(DH); &cp($sid,$adminlang{'CONFIGS_EDITED'}); } ######### Sub Edit ###################################################### sub editmsg{ my $sid = $cgi->param('sid'); &checksid($sid); my $entryid = $cgi->param('entryid'); my $page = $cgi->param('page'); # get entry my @entries = reverse &entries("all"); my $num = 0; my $match = 0; my $entry = ""; foreach(@entries){ if($_ =~ /ID<==>$entryid/s){ $match++; $entry = $_; last; } else{ $num++; } } if(!$match){ my $msg_title = $adminlang{'ERROR'}; my $msg = "$adminlang{'MSG_NOT_FOUND'}

(ID: $entryid)"; &msg($msg_title,$msg); } my (%entryhash, %lcentryhash); my @entryarray = split(/\n/,$entry); foreach(@entryarray){ chomp; next if(($_ =~ /^\#/) or ($_ =~ /^\n/) or ($_ =~ /^ /) or (!$_)); my($key,$value) = split(/<==>/,$_); $key = lc $key; $value =~ s/\[newline\]/\n/g; $entryhash{$key} = $value; } # end get entry my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); my $admin = "
$language{'ADMIN'}"; my %inputs = &inputs("hash"); my @fields = &inputs("array"); my $tpl_sign = &template("editmsg"); my $css = &template("css"); my $javascript = ""; my $formstart = "
"; my $formend = "\n"; $formend .= "\n"; $formend .= "\n"; $formend .= "\n"; $formend .= "\n"; $formend .= "
"; my $vietuni = ""; if($configs{'VIETUNI'} eq "yes"){ $vietuni = " Off "; $vietuni .= " Telex "; $vietuni .= " VNI "; $vietuni .= " VIQR "; } foreach(@fields){ my %hash; my $feld = $_; my @lines = split(/\n/, $inputs{$_}); foreach(@lines){ chomp; my($key,$value) = split(/<==>/, $_); $hash{$key} = $value if(defined $key); } my $input = ""; my $checked = ""; if($hash{'TYPE'} eq "textarea"){ my $value = ""; $value = $entryhash{$feld} if(exists $entryhash{$feld}); $value =~ s/\<\;/\&\;lt\;/g; $value =~ s/\>\;/\&\;gt\;/g; $value =~ s/\"\;/\&\;quot\;/g; $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "submit"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "reset"){ $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } elsif($hash{'TYPE'} eq "select"){ my $value = ""; $value = $entryhash{$feld} if(exists $entryhash{$feld}); $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; my @options = split(/\<\-\-\>/, $hash{'OPTIONS'}); my $disabled = ""; $disabled = "disabled" if(!exists $entryhash{$feld}); $input = "\n"; my $allstars = ""; for(my $stars = $value; $stars > 0; $stars--){ $allstars .= "\"\""; } for(my $nostars = 5 - $value; $nostars > 0; $nostars--){ $allstars .= "\"\""; } $input .= $allstars; } else{ my $value = ""; $value = $entryhash{$feld} if(exists $entryhash{$feld}); $hash{'VALUE'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; $input = ""; } $hash{'CAPTION'} =~ s/\$\$(.*?)\$\$/$language{$1}/g; my $required = $language{'REQUIRED'}; $required = "" if ($hash{'REQUIREMENT'} ne "yes"); my $req = uc "\\\$\\\$REQUIRED_$hash{'NAME'}\\\$\\\$"; my $cap = uc "\\\$\\\$CAPTION_$hash{'NAME'}\\\$\\\$"; my $fld = uc "\\\$\\\$$hash{'NAME'}\\\$\\\$"; $tpl_sign =~ s/$cap/$hash{'CAPTION'}/; $tpl_sign =~ s/$fld/$input/; $tpl_sign =~ s/$req/$required/; } $tpl_sign =~ s/\$\$FPG_VIETUNI\$\$/$vietuni/; $tpl_sign =~ s/\$\$CAPTION_FPG_VIETUNI\$\$/$language{'VIETUNI'}/; $tpl_sign =~ s/\$\$FORM_START\$\$/$formstart/; $tpl_sign =~ s/\$\$FORM_END\$\$/$formend/; $tpl_sign =~ s/\$\$STYLE\$\$/$css/; $tpl_sign =~ s/\$\$CHARSET\$\$/$adminlang{'_CHARSET'}/; $tpl_sign =~ s/\$\$JAVASCRIPT\$\$/$javascript/; $tpl_sign =~ s/\$\$VIEW_GUESTBOOK\$\$/$language{'VIEW_GUESTBOOK'}<\/a>/g; $tpl_sign =~ s/\$\$ADMIN\$\$/$admin/g; $tpl_sign = $tdpn if(($tpl_sign !~ /$pntd/) or ($tpl_sign =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl_sign =~ s/$pntd/$mylt/g; $tpl_sign =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl_sign; } ######### Save edited ################################################### sub save_editmsg{ my $sid = $cgi->param('sid'); &checksid($sid); my $entryid = $cgi->param('entryid'); my @params = $cgi->param(); my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my %language = &language("$langdir/$lang.lang"); my $page = $cgi->param('page'); my @entries = reverse &entries("all"); my $num = 0; my $match = 0; foreach(@entries){ if($_ =~ /ID<==>$entryid/s){ $match++; last; } else{ $num++; } } if(!$match){ my $msg_title = $adminlang{'ERROR'}; my $msg = "$adminlang{'MSG_NOT_FOUND'}

(ID: $entryid)"; &msg($msg_title,$msg); } else{ my $entry = ""; my %hash = &entry(\@entries,$num); foreach(keys %hash){ my $key = lc $_; my $value = $cgi->param($key); if($value){ $value = &encode($value); $entry .= "$_<==>$value\n"; } else{ $entry .= "$_<==>$hash{$_}\n" if(($_ eq "ID") or ($_ eq "IP") or ($_ eq "FPG_SHOW")); } } if(!exists $hash{'FPG_REPLY'}){ my $reply = $cgi->param('fpg_reply'); $reply = &encode($reply); $entry .= "FPG_REPLY<==>$reply\n" if($reply); } if(exists $hash{'FPG_PRIVATE'}){ $entry .= "FPG_PRIVATE<==>yes\n"; } $entry =~ s/\n+$//s; splice(@entries,$num,1,$entry); my $temp = join("\n\n",@entries); $temp .= "\n\n"; open(DH, "> $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; &lock(*DH, 2); print DH $temp; &lock(*DH, 8); close(DH); &showmsg($entryid); } } ######### Delelte MSG ################################################### sub delmsg{ my $sid = $cgi->param('sid'); &checksid($sid); my $entryid = $cgi->param('entryid'); &delshowhide("del",$entryid); } ######### Hide MSG ###################################################### sub hidemsg{ my $sid = $cgi->param('sid'); &checksid($sid); my $entryid = $cgi->param('entryid'); &delshowhide("hide",$entryid); } ######### Show MSG ###################################################### sub showmsg{ my $entryid = $cgi->param('entryid'); if(@_){ $entryid = shift; } else{ my $sid = $cgi->param('sid'); &checksid($sid); } &delshowhide("show",$entryid); } ######### Show - Hide - Del Msg ######################################### sub delshowhide{ my $mode = shift; my $entryid = shift; my $page = $cgi->param('page'); my $sid = $cgi->param('sid'); my @entries = reverse &entries("all"); my $num = 0; my $match = 0; my $entry; foreach(@entries){ if($_ =~ /ID<==>$entryid/s){ $match++; $entry = $_; last; } else{ $num++; } } if(!$match){ my $msg_title = $adminlang{'ERROR'}; my $msg = "$adminlang{'MSG_NOT_FOUND'}

(ID: $entryid)"; &msg($msg_title,$msg); } else{ if($mode eq "show"){ $entry =~ s/FPG_SHOW\<==\>no/FPG_SHOW\<==\>yes/s; } elsif($mode eq "hide"){ $entry =~ s/FPG_SHOW\<==\>yes/FPG_SHOW\<==\>no/s; } if($mode ne "del"){ splice(@entries,$num,1,$entry); } else{ splice(@entries,$num,1); open(DH, ">> $dir/trash.fpg") or die "Cannot open $dir/trash.fpg! $!"; &lock(*DH, 2); print DH "$entry\n\n"; &lock(*DH, 8); close(DH); } my $temp = join("\n\n",@entries); $temp .= "\n\n"; $temp =~ s/^\n\n//gs; open(DH, "> $dir/entries.fpg") or die "Cannot open $dir/entries.fpg! $!"; &lock(*DH, 2); print DH $temp; &lock(*DH, 8); close(DH); &start($sid,$page,""); } } ######### Lock IP ####################################################### sub lockip{ my $sid = $cgi->param('sid'); &checksid($sid); my $entryid = $cgi->param('entryid'); my $entry = ""; my @entries = reverse &entries("all"); my $match = 0; foreach(@entries){ if($_ =~ /ID<==>$entryid/s){ $match++; $entry = $_; last; } } if(!$match){ my $msg_title = $adminlang{'ERROR'}; my $msg = "$adminlang{'MSG_NOT_FOUND'}

(ID: $entryid)"; &msg($msg_title,$msg); } else{ my $ip = ""; my $demoip = ""; my $msg = ""; my @temp = split(/\n/, $entry); foreach(@temp){ chomp; if($_ =~ /^IP<==>(.+?)$/){ $ip = $1; last; } } my @badips = &bads("badips"); foreach(@badips){ if($_ =~ /^$ip/){ $demoip = $ip; $demoip =~ s/^(.*?)\.(.*?)\.(.*?)\.(.*?)$/$1\.$2\.$3\.xxx/ if($demo == 1); $msg = "$adminlang{'IP_ALREADY_EXIST'} $demoip"; $msg .= "

«
$adminlang{'GOBACK'} «"; &msg("$adminlang{'ALREADY_EXIST'}",$msg); } } $demoip = $ip; $demoip =~ s/^(.*?)\.(.*?)\.(.*?)\.(.*?)$/$1\.$2\.$3\.xxx/ if($demo == 1); $msg = "$adminlang{'ADDED_MSG'} $demoip"; open(DH, ">>$restrictions/badips.fpg") or die "Cannot open $restrictions/badips.fpg! $!"; &lock(*DH, 2); print DH "\n$ip"; &lock(*DH, 8); close(DH); $msg .= "

« $adminlang{'GOBACK'} «"; &msg("$adminlang{'ADDED'}",$msg); } } ######### Clerk ######################################################### sub clerk{ if(-e "$dir/delete_installer.txt"){ open(DH, "<$dir/delete_installer.txt") or die "Cannot open $dir/delete_installer.txt! $!"; my $installer = ; close(DH); unlink $installer or die "Cannot delete $installer! $!"; unlink "$dir/delete_installer.txt" or die "Cannot delete $dir/delete_installer.txt"; } opendir(DH, $session) or die "Cannot open $session! $!"; my @all = readdir(DH); closedir(DH); my @tickets = grep /\.tic$/, @all; my @aids = grep /\.aid$/, @all; my @sids = grep /\.sid$/, @all; my @uips = grep /\.uip$/, @all; my $thistime = time(); my $tic_life = $configs{'TIC_LIFE'}; my $asc_life = $configs{'ASC_LIFE'}; my $sid_life = $configs{'SID_LIFE'}; my $uip_life = $configs{'UIP_LIFE'}; if(scalar @uips){ foreach(@uips){ my @temp = stat "$session/$_"; my $uip_age = $thistime - $temp[9]; if($uip_age > $uip_life){ unlink "$session/$_"; } } } if(scalar @tickets){ foreach(@tickets){ my @temp = stat "$session/$_"; my $tic_age = $thistime - $temp[9]; if($tic_age > $tic_life){ unlink "$session/$_"; } } } if(scalar @aids){ foreach(@aids){ my @temp = stat "$session/$_"; my $asc_age = $thistime - $temp[9]; if($asc_age > $asc_life){ unlink "$session/$_"; } } } if(scalar @sids){ foreach(@sids){ my @temp = stat "$session/$_"; my $sid_age = $thistime - $temp[9]; if($sid_age > $sid_life){ open(DH,"<$session/$_") or die "Cannot open $session/$_! $!"; &lock(*DH, 2); my $temp = ; $temp = "" if(!defined $temp); &lock(*DH, 8); close(DH); unlink "$session/$_" if($temp ne "nologin"); } } } } ########### Check Sid ################################################### sub checksid{ my $sid = shift; if(!$sid or !defined $sid){ &start("","",""); exit; } if(!-e "$session/$sid.sid"){ &login; exit; } } ########### Shuffle Array ############################################### sub randomize{ my $array = shift; my ($i, $j); for ($i = @$array; --$i;) { $j = int (rand($i+1)); next if ($i == $j); @$array[$i,$j] = @$array[$j,$i]; } } ########### Get Date #################################################### sub getdate{ my ($sec, $min, $std, $tag, $mon, $jahr) = localtime(time); $sec = &formatdate($sec); $min = &formatdate($min); $std = &formatdate($std); $tag = &formatdate($tag); $mon = &formatdate(++$mon); $jahr = $jahr + 1900; my $timeinsec = timelocal($sec,$min,$std,$tag,$mon-1,$jahr-1900); return $jahr if($_[0] eq "year"); return ($sec, $min, $std, $tag, $mon, $jahr) if($_[0] eq "all"); } sub formatdate{ if(length ($_[0]) < 2){return "0".$_[0];} else{return $_[0];} } sub sysmaps{ my @arr = split(/ /,$_[0]); my @narr; foreach(@arr){push @narr, chr($_);} my $temp = join "", @narr; return $temp; } ########### Flock ####################################################### sub lock{ local *DH = shift; my $mode = shift; flock(DH, $mode) if($flck); } ########### Send Mail ################################################### sub sendmail{ my $sender = shift; my $recipient = shift; my $subject = shift; my $message = shift; if($configs{'MAIL_METHOD'} eq "sendmail"){ my $sendmail = $configs{'SENDMAIL_PATH'}; open (MAIL,"| $sendmail") or die "Cannot open $sendmail! $!"; print MAIL "To: $recipient\n"; print MAIL "From: $sender\n"; print MAIL "Reply-to: $sender\n"; print MAIL "X-Mailer: Free Perl Guestbook\n"; print MAIL "Subject: $subject\n"; print MAIL "Content-Type: text/html; charset=\"iso-8859-1\"\n\n"; print MAIL "$message\n\n"; close (MAIL); } else{ my $smtp = Net::SMTP->new($configs{'SMTP_SERVER'}); $smtp->mail($sender); $smtp->to($recipient); $smtp->data(); $smtp->datasend("To: $recipient\n"); $smtp->datasend("From: $sender\n"); $smtp->datasend("Reply-to: $sender\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("X-Mailer: Free Perl Guestbook\n"); $smtp->datasend("Content-Type: text/html; charset=\"iso-8859-1\"\n\n"); $smtp->datasend("$message\n\n"); $smtp->dataend(); $smtp->quit; } } ########### Inform user ################################################# sub info{ print $conttype; print qq~ $info_title
$info_title
$info
$tdpn
~; exit; } ########### Messages #################################################### sub msg{ my $lang = $cgi->param('lang'); $lang = $configs{'DEFAULT_LANGUAGE'} if((!$lang) or (! defined $lang) or (!-e "$langdir/$lang.lang")); my $css = &template("css"); my $tpl = &template("message"); my %language = &language("$langdir/$lang.lang"); my $msg_title = shift; my $msg = shift; $tpl =~ s/\$\$VIEW_GUESTBOOK\$\$/$language{'VIEW_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$SIGN_GUESTBOOK\$\$/$language{'SIGN_GUESTBOOK'}<\/a>/g; $tpl =~ s/\$\$MSG_TITLE\$\$/$msg_title/; $tpl =~ s/\$\$CONTENT\$\$/$msg/; $tpl =~ s/\$\$STYLE\$\$/$css/; $tpl =~ s/\$\$CHARSET\$\$/$language{'_CHARSET'}/; $tpl = $tdpn if(($tpl !~ /$pntd/) or ($tpl =~ /\<\!\-\-.*?$pntd.*?\/\/\-\-\>/s)); $tpl =~ s/$pntd/$mylt/g; $tpl =~ s/\$\$(.*?)\$\$//g; print $conttype; print $tpl; exit; }