#! /usr/bin/perl # ######################################## # # script to edit DTN site content # written by benjamin ramey # bsr@rameydesign.net # january, 2004 # ######################################## if( $ENV{ 'REQUEST_METHOD' } eq 'POST' ) { read( STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } ); @pairs = split( /&/, $buffer ); #split form contents into name=value pairs foreach $pair ( @pairs ) #step through the array @pairs { ( $name, $value ) = split( /=/, $pair); #split each pair into the form element name and that form element's value $name =~ tr/+/ /; #replace all the + signs with spaces $value =~ tr/+/ /; $name =~ s/%(..)/pack( "C", hex( $1 ) )/eg; #replace all hexidecimal characters with their corresponding, easier to understand characters $value =~ s/%(..)/pack( "C", hex( $1 ) )/eg; if( $contents{ $name } ) #in case there is a multiple-select scroll down menu this will append a value to an already existing key instead of reassigning it { $contents{ $name } .= "\t$value"; } else{ $contents{ $name } = $value; } #but, normally, we'll just assign the value in the hash to it's corresponding key } } ##################################################################################################################################################################### # MAIN PROGRAM ##################################################################################################################################################################### if( $contents{ 'file' } ) { $file_path = $contents{ 'file' }; } else { $file_path = "nothing yet"; } $username = "warren4"; $password = "john316"; print "Content-type: text/html\n\n"; &Print_Top_HTML; #always need to display at least this &Password; &Print_Bottom_HTML; #and we always need to display this exit; ############## ############## DISPLAYS PASSWORD PAGES, SO ONLY WARREN CAN ACCESS EDITING SECTIONS ############## sub Password { if( !$contents{ 'username' } && !$contents{ 'file' } ) { print<<"HTML";
| Edit DTN | ||
|
Please enter the following information before you start editing DtN. |
||
| Edit DTN | ||
| ERROR: Either your username or password was not entered correctly. Please make sure you typed them in correctly. Both username and password are case sensitive!! | ||
| Edit DTN | ||
| ERROR: This section not yet editable. | ||
| Edit DTN | ||
|
To update the links list on the "Resources" page, click below. |
||
| Edit Media Page | ||
|
HTML
if( !$contents{ 'media_edit_action' } )
{
print <<"HTML";
Choose what you would like to do: HTML } elsif( $contents{ 'media_edit_action' } eq 'delete_album' ) { &Media_Edit_Delete_Album; } elsif( $contents{ 'media_edit_action' } eq 'add_album' ) { &Media_Edit_Add_Album; } elsif( $contents{ 'media_edit_action' } eq 'edit_album' ) { &Media_Edit_Edit_Album; } elsif( $contents{ 'media_edit_action' } eq 'delete_video' ) { &Media_Edit_Delete_Video; } elsif( $contents{ 'media_edit_action' } eq 'add_video' ) { &Media_Edit_Add_Video; } elsif( $contents{ 'media_edit_action' } eq 'edit_video' ) { &Media_Edit_Edit_Video; } print <<"HTML"; |
||
| Edit Mission & Travel Page | ||
|
HTML
if( !$contents{ 'travel_edit_action' } )
{
print <<"HTML";
Choose what you would like to do: HTML } elsif( $contents{ 'travel_edit_action' } eq 'cmm' ) { &Travel_Edit_Add_CMM; } print <<"HTML"; |
||
| Edit Random Verse List | ||
|
HTML
if( !$contents{ 'edit_verses' } )
{
print<<"HTML";
Below all current verses in the list are listed. If you want to delete a verse, check it's corresponding checkbox.
If you want to add a verse, fill in the appropriate information at the bottom of the list where it says "Add Verse". HTML } elsif( $contents{ 'edit_verses' } ) { require Tie::File; my $in_verses = 0; my $verse_counter = 0; my $deleted = 0; tie( my @file_lines, 'Tie::File', $verse_file ) or print "can't open file"; for( my $i = 0; $i <= $#file_lines; $i++ ) { if( $file_lines[ $i ] =~ m/~VERSES~/ ) { $in_verses = 1; } if( $file_lines[ $i ] =~ m/~ENDVERSES~/ ) { $in_verses = 0; my $new_verse = "\t\tverses[ $verse_counter ] = \"\\\"$contents{ 'verse_text' }\\\" $contents{ 'verse_ref' }\"\;"; if( $contents{ 'verse_text' } ) { splice( @file_lines, $i, 1, ( $new_verse, "\t\t//~ENDVERSES~" ) ); } $i = $#file_lines; } if( ($file_lines[ $i ] =~ m/verses\[ $contents{ 'verses_delete' } \]/) && $in_verses && !$deleted ) { splice( @file_lines, $i, 1 ); $i--; $verse_counter--; $deleted = 1; } if( ($file_lines[ $i ] =~ s/verses\[ \d+ \]/verses\[ $verse_counter \]/) && $in_verses ) { $verse_counter++; } } untie( @file_lines ); if( $contents{ 'verses_delete' } ) { print<<"HTML"; Verse(s) deleted! HTML } if( $contents{ 'verse_text' } ) { print<<"HTML"; $contents{ 'verse_ref' } has been added to the list! HTML } } print <<"HTML"; |
||
|
||||
![]()
|
![]()
|
|||
| all site content copyright of Disciple the Nations, all rights reserved | site designed by ramey design | ||||