#!/usr/bin/perl #============================================================================== # # Name: pd.cgi (Postcard Direct) # # Author: Peter Sundstrom (Ginini Technologies Limited) # # Source: http://postcard-direct.com/ # # Version: 6.1.0 # # Copyright: (c)1999-2007 Peter Sundstrom. # All rights reserved. # # See http://postcard-direct.com/#licence # for licence details. # #============================================================================== BEGIN { require CGI::Carp; sub handle_errors { my $msg=shift; print qq(
$msg\n); print qq(
Example: $script?image=/pd/images/photo.jpg
"); } # # Check to see what configuration to use and set the language. # $config=$p{config}; if ($config) { CheckBadPath($config,"Configuration file"); CheckConfigPath("$config_dir/$config"); } else { $config='pdconfig.txt'; } $lang=$p{lang} if ($p{lang}); require "$config_dir/$config"; Error("Document Root: $document_root can not be found",undef,"Manually set \$document_root in the configuration file") unless (-d $document_root); # # Check to see if the script is being called from a valid location # AntiLeech() if ($anti_leech and not $p{'showcard'}); # # Set appropriate URL's # $help = "$pdurl/help/$lang/help.html"; $midi_url = "$pdurl/" . basename($midi_dir); # # Set default design if none is specified # $p{design}='default.txt' unless $p{design}; # # Set default title if none is specified # $p{title}=$title unless $p{title}; # # Check what action has been specified # if ($p{'send'} or $p{'send.x'}) { CheckBadData(); SendPostcard(); } elsif ($p{'preview'} or $p{'preview.x'}) { CheckBadData(); PreviewPostcard(); } elsif ($p{'imageupload'}) { ProcessUpload(); } elsif ($p{'upload'}) { DisplayUploadForm(); } elsif ($p{'showcard'}) { ShowCard(); } elsif ($p{'sendcards'}) { if (-f "$modules/mimelite.pm") { require mimelite; MIME::Lite->import(); } else { Error("Module $modules/mimelite.pm does not exist"); } CheckStoredCards(); } else { DisplayForm(); } ##################################################################### # SUB ROUTINES START HERE ##################################################################### #-------------------------------------------------------------------- # # Displays the postcard input form # sub DisplayForm { Error("No postcard image or object specified",undef,"Example: $script?image=/pd/images/photo.jpg") unless ($p{image} or $p{object}); if ($p{image}) { RemoteSiteAllowed($p{image}) if ($p{image} =~ /http:/i); } if ($p{object}) { RemoteSiteAllowed($p{object}) if ($p{object} =~ /http:/i); } # # Set the form name if it is specified as a parameter # if ($p{form}) { CheckBadPath($p{form},"Form name"); $form="$template_dir/$p{form}"; } open FORM,$form or Error("Can not open postcard form template $form", $!,"Check the pathname or form name is correct"); # # Obtain image information (if any) # if ($p{image}) { if ($p{image} =~ /http:/i) { $image_path=GetRemoteObject($p{image}); } else { $image_path=ObjectLocation($p{image}); ObjectNotFound($p{image},$image_path) unless -f $image_path; } } # # Obtain object information (if any) # if ($p{object}) { if ($p{object} =~ /http:/i) { $object_path=GetRemoteObject($p{object}); } else { $object_path=ObjectLocation($p{object}); ObjectNotFound($p{object},$object_path) unless -f $object_path; } } my $form_output; $subject=$p{subject} if $p{subject}; while (