#!/usr/bin/perl #----------------------- # C R O O K E D B U S H . C O M - E D I T C O N T E N T # Designed by Intelliscript.net. Please don't remove this copyright notice. Thanks! #----------------------- # User Defined Variables #----------------------- $adminpass = "password"; $content_path = "../content/";#with ending slash @domain_possibilities = ("www.fightingarts.org.uk","fightingarts.org.uk"); $url_to_upload_script = "/cgi-bin/upload_pic.pl"; $upload_dir = "/fightingarts.org.uk/public_html/content/uploads/"; $upload_url = "/content/uploads/"; $max_upload = "500000"; #----------------------- # READ WEB ENVIRONMENT #----------------------- $url = $ENV{'SERVER_NAME'}; $script_url = $ENV{'SCRIPT_NAME'}; $referring = $ENV{'HTTP_REFERER'}; #_______________________ #----------------------- # Program #----------------------- $copyright_year = "2003"; $version = "30615.0951"; print "Content-type: text/html\n\n"; &parse_form; unless(!$FROMWEB{'file'}){$active_text_file = $FROMWEB{'file'}} else{ $active_text_file = $referring; $active_text_file =~ s/http:\/\///; $active_text_file =~ s/$url\///; foreach $domain (@domain_possibilities){ $active_text_file =~ s/$domain\///; } $active_text_file =~ s/.shtml|.html|.html//; } &check_password; exit; #----------------------- # Check for password #----------------------- sub check_password{ &password_good if ($FROMWEB{'password'} eq $adminpass); &password_bad; } #----------------------- # Invalid password, show password box #----------------------- sub password_bad{ print qq~ Enter a Valid Password


Please enter a valid password:



 

~; exit; } #----------------------- # Valid password, check for save command #----------------------- sub password_good{ &save if ($FROMWEB{'action'} =~ /save/i); &upload if ($FROMWEB{'action'} =~ /upload/i); &delete_file if ($FROMWEB{'action'} =~ /delete/i); &edit; exit; } #----------------------- # Save command, save edits #----------------------- sub save{ # Write text to server $file = $FROMWEB{'content'}; $file =~ s/\r//sg; # go through line by line, and convert \n to
IF there is no table tag on the line # @lines = split(/\n/,$file); # foreach $line (@lines){ # if ($line !~ // && $line !~ /<\/p>/){ # $line = $line."
"; # } # } # $file = join ("\n",@lines); chomp ($file); open (server_file, ">$content_path$active_text_file.txt") or &dienice("I can't open the server file: $content_path$active_text_file.txt
\nError Code: $!"); print server_file "$file"; close (server_file); # Print save confirmation to browser print qq~ Changes Have Been Saved.

Edit Saved

The edits have been saved to the server.  Return to Page (remember to refresh)

~; }#save #----------------------- # No save command, edit server file in HTML #----------------------- sub edit{ # First open the file open(FILE,"$content_path$active_text_file.txt") || &dienice("Can't open the file $content_path$active_text_file.txt
\nError Code: $!"); @FILE = ; close(FILE); chomp (@FILE); print qq~ Edit Content

Edit Content of $active_text_file Page


~; }#edit #------------------------- # Upload #------------------------- sub upload{ # display all files with delete buttons print "

File List

"; opendir (FILELIST, "$upload_dir"); rewinddir (FILELIST); @dirlist = grep(!/^\.\.?$/, readdir (FILELIST)); closedir (FILELIST); @directory = @dirlist; #grep {$_ =~ /.jpg/} @dirlist; print "\n"; foreach $file (@directory){ print qq~ ~; } print "
$upload_url$file delete
"; if ($FROMWEB{'action'} =~ /confirmation/i){ # print confirmation print qq~ Photo Upload Confirmation

Your photo(s) have been successfully uploaded.
Thank you.
Click Here to Continue.

~; } else{ # subtract $total_files_size from the grand total allowed in $INI{'maximum_upload'} $allowed_to_upload = $INI{'maximum_upload'} - $total_files_size; # = all pics in this dir if ($max_upload <= 0) { &dienice("You have exceeded your allowed upload amount. Delete some files to make room.")} #--------- print <Photo Upload

You may upload graphic files no more than $max_upload bytes in size. The file(s) must be GIF or JPEG so that they can be viewed by others on the Internet.

Photo 1:
Photo 2:
Photo 3:
Photo 4:
 
HTML } exit; }#upload #----------------------- sub delete_file{ unlink( "$upload_dir$FROMWEB{'file'}") or &dienice("I can't delete the server file: $upload_dir$FROMWEB{'file'}
\nError Code: $!"); # Print save confirmation to browser print qq~ Upload Deleted

Deleted

The file has been deleted from the server.  Return to Page (remember to refresh)

~; exit; } #----------------------- # Parse Form - take info from web #----------------------- sub parse_form{ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @input_chunks = split(/&/, $buffer); foreach $chunk (@input_chunks) { ($name, $value) = split(/=/, $chunk); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $FROMWEB{$name} = $value; } @input_chunks = split(/&/, $ENV{'QUERY_STRING'}); foreach $chunk (@input_chunks) { ($name, $value) = split(/=/, $chunk); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $FROMWEB{$name} = $value; } }#parse_form #----------------------- # Displays error messages (beautify this later) #----------------------- sub dienice { my($errmsg) = @_; print qq~

Attention

$errmsg

\n











~; exit; }#dienice