#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); #use strict; # // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # COPYRIGHT NOTICE # Copyright 2002 by Eclypse Software - Your software partner # Programmers: bizzy & # Hai Cong Thuong # Email: [bizzy241@hotmail.com] # # # All Rights Reserved. # # By using this script you agree to release the author # from any liability or damages that might arise from # its use. # # WARNING: This program is protected by copyright law and international # treaties. # # Redistribution prohibited without prior permission. # # // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * BEGIN { my $path = $0; if($path =~ s{[\\/][^/\\]+$}{}) { chdir($path) || die "Couldn't navigate to '$path' directory!"; }; }; &ini_setts ; # // Initialize software settings. # As a security precaution, we will not accept any unusual characters # in the environment URL. if( $IO{'EnvFilter'} eq "yes" ) { if( $ENV{'QUERY_STRING'} ne "") { if ( $ENV{'QUERY_STRING'} =~ /[\!\~\`\%\$\&\n\s]/ ) { &HTML; &quitdie("CGI security block. The environment url contains invalid characters"); } } } $iString="."; chomp($iString); push(@INC, $iString); &DateTime; @values = # --1 $ENV{'QUERY_STRING'} # --2 ; # --3 foreach $i( @values ) { ($file # --1 , $action # --2 , $pagevalue) # --3 = split(/\=/,$i); } # /////////////////////////////////////////////////////////////////////////////// # // // # // Initialize System // # // // # /////////////////////////////////////////////////////////////////////////////// # // System has been designed to reduce server load by only loading specific # // e-Guestbook software components when requested. Code has been reduced to # // a minimum to further enhance server performance. if (($ENV{'QUERY_STRING'} eq "")||($file eq "Display")) { &HTML; require "./mDisplay.cgi"; exit; } elsif ($file eq "Sign") { &HTML; require "./mSign.cgi"; exit; } elsif ($file eq "sign.submit") { &HTML; require "./mSignSubmit.cgi"; exit; } elsif ($file eq "CP") { &HTML; require "./mCp.cgi"; &FunctionCP; exit; } elsif ($file eq "CP2") { require "./mCp2.cgi"; exit; } elsif ($file eq "SettsEdit") { require "./mCp2.cgi"; &ConfigInit; exit; } elsif ($file eq "SettsSubmit") { require "./mCp2.cgi"; &SettsSave; exit; } elsif ($file eq "Logout") { require "./mCp2.cgi"; &FunctionLogOut; exit; } elsif ($file eq "DeleteConfirm") { &HTML; require "./mData004.cgi"; exit; } elsif ($file eq "Edit") { &HTML; require "./mEdit.cgi"; exit; } elsif ($file eq "Stats") { &HTML; require "./mStats.cgi"; exit;} elsif ($file eq "Search") { &HTML; require "./mSearch.cgi"; exit;} elsif ($file eq "ModuleAdd") { &HTML; require "./mModerate.cgi"; &FunctionModAdd("$IO{'DirData'}/Entries.txt","$action");exit;} elsif ($file eq "ModuleDelete") { &HTML; require "./mModerate.cgi"; &FunctionModDelete("$IO{'DirData'}/Entries.txt","$action");exit;} elsif ($file eq "AdminPost") { &HTML; &TemplateFile("AdminPost"); exit; } elsif ($file eq "AdminPostSubmit") { &HTML; require "./mSignSubmit.cgi"; exit; } elsif ($file eq "ConfigInit") { &HTML; require "./mConfigEdit.cgi"; &FunctionFileInit("$action"); exit; } elsif ($file eq "ConfigSave") { &HTML; require "./mConfigEdit.cgi"; &FunctionFileSave("$action"); exit; } elsif ($file eq "Backup") { &HTML; require "./mConfigEdit.cgi"; &FunctionBackup; exit; } elsif ($file eq "BulkMail") { &HTML; require "./mBulkMail.cgi"; exit; } else { &HTML; &quitdie("URL error - can not determine function :: $ENV{'QUERY_STRING'}"); } # /////////////////////////////////////////////////////////////////////////////// # // // # // GLOBAL SOFTWARE ROUTINES // # // // # /////////////////////////////////////////////////////////////////////////////// sub quitdie { my ( $temp ) = @_[0]; my ( $var ) = @_[1]; open(x, "<$IO{'DirTemplates'}/message_posted.html") || print "$! : $temp"; while () { $_ =~ s/\$msgs/$temp/; print ( "$_" ); } close(x); if ( $var ne "yes" ) { exit; } } sub ini_setts { # Open CONFIG file for memory open( FILE, "<./Config.cgi" ) || print "$!"; while () { chomp( $_ ); if( $_ ne "" ) { # prevent wasting memory if ( $_ =~ /[%]/ ) { next; } # Do some splitting ( $tempName, $tempValue ) = split( /\=/,$_ ); chop($tempName); chop($tempValue); # Do some more splitting ($Alpha,$Beta,$Gamma)=split(/\"/,$tempValue); $IO{$tempName}=$Beta; } next; } close(FILE) || print "$!"; } sub TemplateFile { &DateTime; # Get parameter my ( $tempString ) = shift; # Open TEMPLATE FOR OUTPUT open(x, "<$IO{'DirTemplates'}/$tempString.html") || &quitdie("$! : $IO{'DirTemplates'}/$tempString.html
"); while () { $_ =~ s/\$date/$date/; while ( $_ =~ /\$img_url/ ) { $_ =~ s/\$img_url/$IO{'URLtoFolder'}/; } $_ =~ s/\$guestbook_title/$IO{'GuestbookTitle'}/; $_ =~ s/\$entries/$entries/; $_ =~ s/\$message/$IO{'WelcomeMessage'}/; $_ =~ s/\$count/$count/; $_ =~ s/\$localtime/$localtime/; $_ =~ s/\$website_url/$IO{'WebsiteURL'}/; $_ =~ s/\$website_title/$IO{'WebsiteName'}/; print("$_"); } close(x) || print "$!"; } sub DateTime { require "./Modules/ModuleTime.cgi"; &ModuleTime("GMT","$IO{'TimeZoneOffset'}","$IO{'Hour12'}"); $localtime = $time; } sub Parse { read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value)=split(/=/, $pair); $value=~ tr/+/ /; $value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name}=$value; } } sub Alpha { # Do cookie routine if($ENV{'HTTP_COOKIE'}) { @COOKIES=split(/; /,$ENV{'HTTP_COOKIE'}); foreach $Cookie(@COOKIES) { # Do some splitting ($Name, $Value) = split(/=/,$Cookie); $Cookie{$Name}=$Value; } } # Is admin logged in? if(($Cookie{'UserName'} eq $IO{'AdminUsername'}) && ($Cookie{'PassWord'} eq $IO{'AdminPassword'})) { $ADMIN{'In'} = 1; } } sub HTML { my ( $iString )="Content-type: text/html\n\n"; print "$iString"; } sub ADMINerror { if(!$ADMIN{'In'}) { my ( $Temp )="You need to log-in administrator"; $Temp.="

Return to Main"; &quitdie("$Temp"); exit; } } exit;