#!/usr/local/bin/perl #============================================================================== # # Name: postcard.cgi (Postcard Direct) # # Author: Peter Sundstrom (peters@ginini.com.au) # # Created: Feb 1999 # # Source: http://www.ginini.com/software/postcard-direct/ # # Description: Emails a postcard directly to the recipient. # # Copyright: (c)1999-2000 Peter Sundstrom. # All rights reserved. # # See http://www.ginini.com/software/postcard-direct/ # for licence details. # #============================================================================== use CGI::Carp qw(carpout fatalsToBrowser); #------------------------------------------------------------------------ # YOU MUST SET THE FOLLOWING OPTIONS #------------------------------------------------------------------------ BEGIN { # Full directory path containing the "Postcard Direct" essential files, # like the help file, midi files and configuration files. $PostcardRoot="/usr/local/www/virtual/www.yoyoo.com/ecard-direct"; # You shouldn't need to modify the next three settings # Full directory path where the configuration file/s are kept $ConfigDir="$PostcardRoot/config"; # Name of the default configuration filename if none is specified; $DefaultCfg="$ConfigDir/default.cfg"; # Full directory path to the additional perl modules $Modules="$PostcardRoot/modules"; } #------------------------------------------------------------------------ # END OF CONFIGURABLE OPTIONS #------------------------------------------------------------------------ Error("You need perl 5.004 or greater for this script to run") if ($] < 5.004); $Version='4.5.0'; use File::Basename; use lib "$Modules"; # URL to this script $CGI=$ENV{'SCRIPT_NAME'}; undef %Data; $Method = $ENV{'REQUEST_METHOD'}; if ($Method eq 'GET') { $Query = $ENV{'QUERY_STRING'}; } else { read(STDIN,$Query,$ENV{'CONTENT_LENGTH'}); } Error("Called without any parameters. Need to specify a postcard image") if (! "$Query"); foreach (split(/[&;]/, $Query)) { s/\+/ /g; ($key, $value) = split('=', $_); $key =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $value =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $Data{$key} = $value; } # # Unbuffer output # $|=1; # # Check to see what configuration to use # $Config="$Data{config}"; if ($Config) { Error("Invalid Configuration file format. No paths allowed.") if ($Config !~ m#^([\w.-]+)$#); Error("Configuration file $ConfigDir/$Config does not exist") if ( ! -f "$ConfigDir/$Config"); require "$ConfigDir/$Config"; } else { Error("Default configuration file $DefaultCfg does not exist") if (! -f "$DefaultCfg"); require "$DefaultCfg"; $Config=basename("$DefaultCfg"); } # # Check to see if the script is being called from a valid location # AntiLeech() if $AntiLeech; # # Set appropriate URL's # ($BasePath=$PostcardRoot) =~ s!$TopLevel!!; $BaseURL= "$WebRoot$BasePath"; $Help="$BaseURL/help.html"; $MidiURL="$BaseURL/" . basename($MidiDir); # # Set default design if none is specified # $Data{design}='default.design' unless $Data{design}; # # Check what action has been specified # if ($Data{'send'} or $Data{'send.x'}) { CheckBadData(); SendPostcard(); } elsif ($Data{'preview'} or $Data{'preview.x'}) { CheckBadData(); PreviewPostcard(); } else { DisplayForm(); } #-------------------------------------------------------------------- sub DisplayForm { Error("No postcard image or object specified") unless ($Data{image} or $Data{object}); RemoteSiteAllowed($Data{image}) if ($Data{image} =~ /http:/i); RemoteSiteAllowed($Data{object}) if ($Data{object} =~ /http:/i); open(FORM,"$Form") or Error("Can not open postcard form template $Form", $!); if ($Data{image} and $Data{image} !~ /http:/i) { $ImagePath=ImageLocation("$Data{image}"); Error("Postcard image not found

URL: $Data{image}
Directory path: $ImagePath") if (! -f $ImagePath); } elsif ($Data{object} and $Data{object} !~ /http:/i) { $ObjectPath=ImageLocation("$Data{object}"); Error("Object not found

URL: $Data{object}
Directory path: $ObjectPath") if (! -f $ObjectPath); } undef $Output; while (

) { next if (/^#/); SizeTags(); s!%CGI%!$CGI!; s!!$CGI!i; s!%CONFIG%!$Config!g; s!!$Config!ig; s!%IMAGE%!$Data{image}!g; s!!$Data{image}!ig; s!%OBJECT%!$Data{object}!g; s!!$Data{object}!ig; s!%TITLE%!$Data{title}!g; s!!$Data{title}!ig; s!%HELP%!$Help!g; s!!$Help!ig; s!%PDICON%!$PostcardRoot/images/pdicon.jpg!g; s!!$PostcardRoot/images/pdicon.jpg!ig; if (/%DESIGNS%/ or //i) { open(LIST,"$DesignList") or Error("Can not open Design list $DesignList",$!); while () { next if (/^#/ or ! /\w+/); ($File,$Description)=split(/\|/); $Output .= "