#!/usr/bin/perl ########################## ## AutoGallery v1.0.0 ## ################################################### ## post.cgi - script used to post galleries ## ################################################### package post; use lib '.'; use strict; use cgiworks; print "Content-type: text/html\n\n"; $HEADER = 1; eval { require 'ag.pl'; main(); }; err("$@", 'post.cgi') if( $@ ); exit; sub main { if( $ENV{'REQUEST_METHOD'} eq "GET" ) { $TPL{'CATS'} = ag::getcats(); fparse('_post_main.htmlt'); } else { parsepost(); postpic(); } } sub postpic { checkinput(); my $id = ag::getnewid('postid'); fappend("$DDIR/posts.db", "$id|$FRM{'gurl'}|$FRM{'desc'}|$FRM{'num'}|$FRM{'cat'}|" . time . "\n"); ag::picpage($id); ag::syncdb(); ag::build(); fparse('_post_confirm.htmlt'); } sub checkinput { for( keys %FRM ) { derr(1002, "Required Field Left Blank") if( $FRM{$_} eq '' ); } derr(1005, "Description Oversized") if( length( $FRM{'desc'} ) > int( $VAR::MD ) ); derr(1004, "Invalid Gallery URL") if( $FRM{'gurl'} !~ /^http:\/\/[\w\d\-\.]+\.[\w\d\-\.]+/ ); }