#!/usr/bin/perl # NOTE: the above line must be changed to show the path to the # Perl interpreter on your system! Leave the #! as is, but # the path may have to be changed if yours is different. ######################################################################### # SFEHangman v0.1 # # Simple online hangman game # # Copyright 2004, Kristina L. Pfaff-Harris # # All rights reserved. # # # ######################################################################### ##### License for SFEHangman 0.1 ##### ##### This program may be used free of charge under the following ##### conditions: ##### ##### 1. All instructions and Copyright lines must remain unchanged. ##### ##### 2. All pages generated by the program must contain one of the ##### following pieces of HTML code: ##### ##### Powered by SFEHangman: ##### ##### http://www.tesol.net/scripts ##### OR: ##### ##### ##### ##### You may not remove the information described above from the script ##### without express written permission from the author. ##### ##### 3. You may not sell or distribute this program. You may charge ##### a reasonable fee for installing it for a client as long as ##### you make it clear that you are not the author, and you are ##### not selling the program to them: only charging for installing ##### it. ##### ##### 4. You agree that this program is offered without warranty of ##### any kind, including warranty of fitness for a particular ##### purpose. You further agree that the author and all sites ##### associated in any way with this program are not liable for ##### any damage or loss incurred as a result of using this program. ##### ##### 5. You may modify the program for your own use but you may not ##### distribute modified copies under any circumstances without ##### express written permission from the author. ##### ##### 6. Use of this program requires agreement to all the terms and ##### conditions of this license. If you do not agree to one or ##### more of these terms, you may not use the program. ##### ######################################################################### ##### # ##### IMPORTANT INSTRUCTIONS: # ##### # ##### In this program, I have put **CHANGE** in all the places where # ##### you will need to modify the program to run on your server, so # ##### that you can easily find all the places where changes are # ##### necessary. This program must be chmod 755 or 775 in order to # ##### work, and the directory where you want SFEHangman to put its # ##### files must be chmod 777. # ##### # ######################################################################### # # # IMPORTANT: If you FTPed this program to your server in "binary" mode, # # it will NOT work! If you're not sure, please go back and FTP it # # to your server again and make sure you use "ascii" mode. If you get # # "500 Server Error", this is almost always the cause. :) # # # # Using the program: # # This program requires the file "sfehangman.cgi" at a minimum in # # order to work. Please read the README.sfehangman file for more # # information. # # # # Please check the Scripts for Educators FAQ first # # (http://tesol.net/scripts/FAQ/) if you have problems. If none of that # # helps, email me and I'll at least try to help. :-) # # # # I hope this program proves useful to you! Please contact me # # (http://tesol.net/scriptmail.html) for any bugs or feedback. # ######################################################################### ##### # ##### BEGIN SECTION WHERE YOU WILL NEED TO CHANGE THINGS: # ##### # ##### In this section, there are several places where you'll need # ##### to make changes. Please read all instructions carefully # ##### before you make the changes. # ##### # ######################################################################### # $path_to_words_files # This is the full system path to the hangman-wordlists folder we # asked you to create in the setup instructions in the README. # In case you didn't read the README, this needs to be set to # the full system path to a directory where you want SFEHangman # to store its wordlists. It should be a directory all its own, # made just for this purpose, and should be chmod 777. # # Please note that this is a "system path" which is different from # a web address. This must NOT begin with "http://". You may need # to ask your web hosting provider what the full system path to # your files is. # # **CHANGE** this to the full system path to the hangman-wordlists # directory. # # One slight note to the above is this: if you make a directory # called "hangman-wordlists" in the same directory where this script # is, then what I have below may work. If nothing else, it's worth # a shot. :-) $path_to_words_files = "./hangman-wordlists"; # $users_file is the full system path to where you've put # hangman_users.txt on your server. Please note that this must # NOT begin with "http://". Please ask your web hosting provider # what the full system path to files on your website is if you're # not sure what to put here. If hangman_users.txt is in the same # directory as this script, then what I have below may work. :-) $users_file = "./hangman_users.txt"; # $url_of_hangman_images # Okay, basically, this is the web address of the folder where # you've uploaded all the hangman gif files. This needs to be # what you would type into your browser to get to the .gif files. # This one MUST start with "http://". **CHANGE** this to the # full URL of the folder where you've put the hangman images: $url_of_hangman_images = "http://www.yoursite.com/hangman-images"; # $cgi_url is the web address of where you've set up this script. # You'll need to change this to the URL of where you've set it up on # your site. If you get a "File not found" error, it usually means # that this isn't set up correctly. **CHANGE** this to the web # address of this script on your web server. $cgi_url = "http://www.yoursite.com/cgi-bin/sfehangman.cgi"; # $who_can_add_wordlists lets the program know whether you want # to be the only one who can add word lists to the program, or # whether you want anyone to. # To allow anyone to add their own word lists to your program, set # $who_can_add_wordlists = "all"; # To make it so that the program requires a username and password (you # can add users through the admin interface), set # $who_can_add_wordlists = "auth"; # To make it so that the program requires the admin username and password # to add wordlists to the program, set # $who_can_add_wordlists = "admin"; # PLEASE NOTE that if you set this to "all," people can potentially # abuse your system by adding giant word lists, obscene word lists, # or otherwise eat up your diskspace. It's a pretty large security # risk to just let anyone add word lists, but some people want to # do it, so you can if you want to. $who_can_add_wordlists = "auth"; # $admin_username is an overall username you want to use to # administer this game, add users, and so forth: $admin_username = "admin"; # $admin_password is the password you want to use to log into # administration functions of this game. $admin_password = "test"; # Okay, the next few things have to do with how the program # is going to look. # $hm_width is how wide you want the hangman images to be. # In case it's too big or too small for you, you can increase # or decrease this number. $hm_width = 130; # $hm_height is how tall you want the hangman images to be. # In case it's too big or too small for you, you can increase # or decrease this number. $hm_height = 150; # $you_lose_message is what you want to show the user if they # fail to solve the word. The program will automatically replace # %%WORD%% with the word that they used. If you don't want it # to tell them what the word was, just take the "%%WORD%%" # part out. You can make this message anything you like, but # do NOT use " (double quote) or @ ("at" sign). $you_lose_message = "Uh oh, you lost. The word was %%WORD%%."; # $you_lose_message is what you want to show the user if they # solve the puzzle. The program will automatically replace # %%WORD%% with the word that they used. If you don't want it # to tell them what the word was, just take the "%%WORD%%" # part out. You can make this message anything you like, but # do NOT use " (double quote) or @ ("at" sign). $you_won_message = "You won! The word was %%WORD%%."; # $use_language tells whether or not to show accented character buttons # for certain languages. You may set $use_language to one of the following # settings: # $use_language = "french"; # $use_language = "spanish"; # $use_language = "portuguese"; # $use_language = "italian"; # $use_language = "german"; # $use_language = "norwegian"; # $use_language = "swedish"; # $use_language = "english"; # Note that these settings are case-sensitive ("German" will not work, nor # will "ITALIAN" for example), and very exact. If you try something that's # not listed, it will just revert to the 'english' setting. # I have NO idea if this will work in other language settings. I only # know it works in English. But what the heck. :-) $use_language = 'english'; # $change_language is whether or not you'd like people to be able to # change the language in use to something other than what you've set # $use_language to above. If you set $change_language = 1; here, then # a drop-down list will appear allowing people to change what language # is used. If you set $change_language = 0; then it will just use # what you've put for $use_language above and will not show the # dropdown list. $change_language = 1; # $header is a set of HTML code to display at the top of pages # generated by the program. You can make this anything you like # if you want to redesign the hangman pages, but PLEASE, # only change in between # and or you'll break it. # Try not to use @ or ". If you must use these characters, be # sure to precede them with a backslash like this: \@ \" . $header = qq[ Play Hangman Online with SFEHangman: Free Online Hangman script
]; # $footer is a set of HTML code to display at the bottom of pages # generated by the program. You can make this anything you like # if you want to redesign the hangman pages, but PLEASE, # only change in between # and or you'll break it. # Try not to use @ or ". If you must use these characters, be # sure to precede them with a backslash like this: \@ \" . # IMPORTANT: In the code below, I've got the script pre-loading # all the images (so hopefully they'll come up faster in the # game) and I have the Add a Wordlist, Admin, and Main links. # You can change this if you like, but it will also change the # look of the page, so be careful. :-) $footer = qq[

Add a Wordlist
Admin
Main

]; ######################################################################### ##### # ##### END SECTION WHERE YOU WILL NEED TO CHANGE THINGS: # ##### # ##### You should not need to change anything beyond this point. In # ##### fact, anything you change beyond this point may completely # ##### break the program and cause it not to function. However, feel # ##### free to browse through the code if you like that sort of thing. # ##### :-) # ##### # ######################################################################### my %data = &get_data(); print "Content-type: text/html\n\n"; $path_to_words_file = $path_to_words_files; if($change_language == 1){ if($data{'Language'} ne ""){ $use_language = $data{'Language'}; } } print "Language: $use_language"; if($use_language ne "french" && $use_language ne "spanish" && $use_language ne "portuguese" && $use_language ne "italian" && $use_language ne "german" && $use_language ne "norwegian" && $use_language ne "swedish"){ $non_english = 0; } else { $non_english = 1; } %language_ary = ( 'english','English', 'french','French', 'spanish','Spanish', 'portuguese','Portuguese', 'italian','Italian', 'german','German', 'norwegian','Norwegian', 'swedish','Swedish' ); if($change_language == 1){ $lang_change_form_top = "
"; $lang_change_form_bottom = "
"; $language_options = qq[ "; $lang_change_form_submit = "(Using: $language_options)"; } else { $lang_change_form_submit = "(Using: $language_ary{$use_language})"; } $footer =~ s/%%LANG%%/$language_ary{$use_language}/s; $language{'french'} = 'ÀÂÈÉÊËÔÎÏÇÙÛ'; $language{'spanish'} = 'ÁÉÍÓÚÑÜ'; $language{'portuguese'} = 'ÁÀÂÃÇÉÊÒÓÔÕÚÜ'; $language{'italian'} = 'ÀÈÉÌÎÍÒÓÙÚ'; $language{'german'} = 'ÄÖÜß'; $language{'norwegian'} = 'ÅÆØ'; $language{'swedish'} = 'ÅÄÖ'; # If you remove this link, without replacing it with a similar # HTML comment (as above in the License section) you are in violation # of the license for this program. No, I don't have the resources to # enforce this, and I know that some people will remove it anyway. # But honestly, since you didn't have to pay for this, is the link # really too much to ask? :) $footer = "
Powered by SFEHangman 0.1
$footer"; # Check for fatal config errors. &config_check(); if($data{'username'} eq "$admin_username" && $data{'password'} eq "$admin_password"){ $footer = "

$footer"; } if($data{'FA'} eq "Guess"){ &guess; } elsif($data{'FA'} eq "Add"){ &auth; &add; } elsif($data{'FA'} eq "Delete Wordlist" || $data{'FA'} eq "Delete" || $data{'FA'} eq "Edit/Delete Wordlist"){ &admin_auth; &delete_wordlist; } elsif($data{'FA'} eq "Edit Wordlist" || $data{'FA'} eq "Edit"){ &admin_auth; &edit_wordlist; } elsif($data{'FA'} eq "Admin"){ &admin_auth; &admin; } elsif($data{'FA'} eq "Add User"){ &admin_auth; &add_user; } elsif($data{'FA'} eq "Delete User"){ &admin_auth; &del_user; } elsif($data{'FA'} eq "Add Wordlist"){ &auth; &add_wordlist; } else { &new_game; } exit(); sub no_args { opendir(DIR, "$path_to_words_files") || &debug("Can't open dir '$path_to_words_files': $!"); @files = readdir(DIR); closedir(DIR); print "${header}
$lang_change_form_top
Please choose one of the following Hangman Games:

$lang_change_form_submit
$lang_change_form_bottom"; foreach $file (@files){ if($file =~ /txt$/){ $arg = $file; $arg =~ s/\.txt$//; # print "File $path_to_words_files/$file
"; open(F, "<$path_to_words_files/$file"); @lines = ; close(F); $title = shift(@lines); $title =~ s/^#//sg; $description = shift(@lines); $description =~ s/^#//sg; $author = shift(@lines); $author =~ s/^#//sg; $number_of_words = $#lines + 1; print qq[\n]; } } print "
$title ($number_of_words)(Easy)(Hard)

*Easy = 11 guesses, Hard = 7 guesses

$footer"; exit(); } sub new_game { $wordlist = $data{'wordlist'}; $level = $data{'level'}; $wordlist =~ s/\W+//sg; $path_to_words_file = "$path_to_words_file/$wordlist.txt"; unless(-f "$path_to_words_file"){ # print "Error: Cannot find words file $path_to_words_file"; &no_args; exit(); } open(F, "<$path_to_words_file") || &debug("Could not open $path_to_words_file: $!"); @words = ; close(F); # Get title and description for the game from the words list. $title = shift(@words); $title =~ s/^#//sg; $title = repipe($title); $formtitle = unpipe($title); $description = shift(@words); $description =~ s/^#//sg; $description = repipe($description); $formdescription = unpipe($description); $author = shift(@words); $author =~ s/^#//sg; $formauthor = unpipe($author); chomp($word = $words[int(rand(@words))]); print "$header
"; print "
Current word list: $title
$author

$description
"; print "

Word: "; $word =~ s/^\s+//sg; $word =~ s/\s+$//sg; foreach $char (split(//, $word)){ if($char eq " "){ print "   "; } else { print "__ "; } } print "

"; print "
"; foreach $char (split(//, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')){ print ""; if($i == 12){ print "
\n"; } $i++; } print "
"; if($non_english == 1){ foreach $char (split(//, $language{$use_language})){ print ""; if($i == 12){ print "
\n"; } $i++; } } print "



$footer"; } sub guess { $word = $data{'word'}; $wordlist = $data{'wordlist'}; $char = $data{'Char'}; $level = $data{'level'}; if($level ne "easy"){ $level = "hard"; } $guesses = $data{'guesses'}; $title = &repipe($data{'title'}); $formtitle = &unpipe($title); $description = &repipe($data{'description'}); $formdescription = &unpipe($description); $guesses += 1; $guessedchars = $data{'guessedchars'}; $correct_chars = $data{'correct_chars'}; if($guessedchars =~ /$char/i){ $no_update_hangman = 1; } else { $guessedchars .= "$char,"; } $hangman = $data{'hangman'}; $word_html = qq[

Word: ]; foreach $mychar (split(//, $word)){ foreach $guessedchar (split(/,/, $guessedchars)){ if (m_lc($mychar) eq m_lc($guessedchar)){ $word_html .= "$guessedchar "; $didone = 1; if(m_lc($mychar) eq m_lc($char)){ $guesscorrect = 1; $correct_chars = "$correct_chars,$char"; } } } if($didone == 1){ $didone = 0; next; } if($mychar eq " "){ $word_html .= "   "; } elsif (m_lc($mychar) eq m_lc($char)){ $word_html .= "$char "; $guesscorrect = 1; $correct_chars = "$correct_chars,$char" unless $correct_chars =~ /$char/i; } else { $word_html .= "__ "; } } $word_html .= "
\n"; if($guesscorrect != 1 && $no_update_hangman != 1){ $hangman++; } $hangman *= 1; if($level eq "easy"){ $image = "$url_of_hangman_images/hangman$hangman-easy.gif"; } else { $image = "$url_of_hangman_images/hangman$hangman-hard.gif"; } $lc_word = m_lc($word); @w_char = (sort(split(//, $lc_word))); @saw{@w_char} = (); foreach $w_char(sort keys %saw){ $new_word .= $w_char if $w_char =~ /\w/; } $lc_correct_chars = m_lc($correct_chars); @c_char = (sort(split(/,/, $lc_correct_chars))); @saw2{@c_char} = (); foreach $c_char(sort keys %saw2){ $new_word2 .= $c_char if $c_char =~ /\w/; } if($new_word2 eq $new_word){ $you_won = 1; } #print "Hangman $hangman data $data{'hangman'} guesscorrect $guesscorrect char $char
"; if($level eq "easy"){ $howmanyguesses = 11; } else { $howmanyguesses = 7; } if($hangman < $howmanyguesses && $you_won != 1){ $word_html .= "
"; foreach $char (split(//, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')){ $word_html .= ""; if($i == 12){ $word_html .= "
\n"; } $i++; } $word_html .= "
"; if($non_english == 1){ foreach $char (split(//, $language{$use_language})){ $word_html .= ""; if($i == 12){ print "
\n"; } $i++; } } $word_html .= "
"; } elsif ($you_won == 1){ $lc_word = m_lc($word); $you_won_message =~ s/%%WORD%%/$lc_word/sg; $word_html .= "$you_won_message
"; } else { $lc_word = m_lc($word); $you_lose_message =~ s/%%WORD%%/$lc_word/sg; $word_html .= "$you_lose_message
"; } $pguessedchars = $guessedchars; $pguessedchars =~ s/,$//; $howmanyleft = $howmanyguesses - $hangman; $hangman_html = "
Current word list: $title

$description

You've guessed: $pguessedchars
You get $howmanyleft guesses.
"; print "$header
$hangman_html $word_html



$footer"; } sub get_data { use CGI; use CGI::Carp qw/fatalsToBrowser/; $CGI::POST_MAX=4096; $CGI::DISABLE_UPLOADS=1; my $q = new CGI; my ($par, %data); @held = $q->param('hold'); foreach $par ($q->param()){ if($data{$par}){ $data{$par} .= "\0" . $q->param($par); } else { $data{$par} = $q->param($par); } } return %data; } sub unpipe { my($stuff) = $_[0]; $stuff =~ s//>/sg; $stuff =~ s/\"/"/sg; return $stuff; } sub repipe { my($stuff) = $_[0]; $stuff =~ s/<//sg; $stuff =~ s/"/\"/sg; return $stuff; } sub add { if($_[0] eq "Edit"){ $editfield = ""; $oldtitle = ""; #print "title $data{'title'}
"; $filename = lc($data{'title'}); $filename =~ s/\W+//sg; $filename = "$path_to_words_files/$filename.txt"; open(F, "<$filename") || &debug("could not open file $filename to edit!"); @words = ; close(F); $title = shift(@words); $title =~ s/^#//sg; $description = shift(@words); $description =~ s/^#//sg; $author = shift(@words); $author =~ s/^#//sg; foreach $word (@words){ $words .= $word; } } $error = "$error

" if $error ne ""; print "$header
$error
Title for this word list:
(e.g. \"Bible Words,\" \"Languages of the World,\" \"Lord of the Rings,\" etc.)


Brief description for this word list:


Enter words, one per line:

$editfield $oldtitle
"; print &get_add_wordlist_buttons(); print "
$lang_change_form_submit
$footer"; } sub add_wordlist { if($data{'Edit'} eq "Yes"){ $editfield = "Go"; # Delete the old one $oldfile = lc($data{'OldTitle'}); $oldfile =~ s/\W+//sg; if(-f "$path_to_words_files/$oldfile.txt"){ unlink("$path_to_words_files/$oldfile.txt"); } else { &debug("Could not unlink old file $path_to_words_files/$oldfile.txt"); } } $title = $data{'title'}; $f_title = unpipe($title); $description = $data{'description'}; $f_description = unpipe($description); $username = $data{'username'}; $words = $data{'words'}; $words =~ s/\r\n/\n/sg; $words =~ s/\r/\n/sg; $wordfile = $title; $wordfile =~ s/\W+//sg; $wordfile = lc($wordfile); if($title eq "" || $description eq "" || $words eq ""){ &add; exit(); } $f_title =~ s/\s+/ /sg; $f_description =~ s/\s+/ /sg; if(-f "$path_to_words_files/$wordfile.txt" && $editfield eq ""){ $error = "Oops, $path_to_words_files/$wordfile.txt already exists. Please change your brief title."; &add(); exit(); } open(F, ">$path_to_words_files/$wordfile.txt") || &debug("Could not open $path_to_words_files/$wordfile.txt $!"); print F "#$f_title\n"; print F "#$f_description\n"; print F "#by $username\n"; print F $words; close(F); print "$header
Okay! Wordlist added.
Title: $title
Description: $description
Filename: $path_to_words_files/$wordfile.txt
Words:
$words
$footer "; } sub auth { &debug("Got to auth..."); if(&admin_auth('passthru') == 1){ return 1; } $username = $data{'username'}; $password = $data{'password'}; if($who_can_add_wordlists eq "all"){ return 1; } elsif($who_can_add_wordlists eq "auth"){ if($username eq "" || $password eq ""){ $error = "Please enter your username and password to add wordlists:
"; &auth_error(); } # If it's admin, it's okay too. if($username eq "$admin_username" && $password eq "$admin_password"){ return 1; } open(F, "<$users_file") || &debug("Could not open users file ($users_file): The server gave this error: $!"); while(){ if($_ =~ /^$username\|/){ ($f_username,$f_password) = split(/\|/, $_); chomp($f_password); if(crypt($password,$f_password) ne $f_password){ $error = "Error 1: Incorrect username or password. Please try again
"; &auth_error(); } else { return 1; } } } $error = "Error: Incorrect username or password.
"; &auth_error(); } else { if($username ne "$admin_username" && $password ne "$admin_password"){ $error = "Error: Incorrect username or password.
"; &auth_error(); } else { return 1; } } $error = "Error: Not Authorized
"; &auth_error(); } sub auth_error { print "$header
$error
Username:
Password:
$footer"; exit(); } sub debug { if($debugging == 1){ print "DEBUG: $_[0]
\n"; } } sub admin_auth { $username = $data{'username'}; $password = $data{'password'}; if($username ne "$admin_username" || $password ne "$admin_password"){ $error = "Error: Incorrect username or password.
"; if($_[0] ne "passthru"){&auth_error();} } else { return 1; } } sub admin { print qq[$header
$error
User Administration:
Wordlist Administration:
$footer]; exit(); } sub add_user { if($data{'FA2'} eq ""){ print "$header
$error
Username:
Password:
Password again:
$footer"; exit(); } open(F, ">>$users_file") || &debug("Could not open users file ($users_file) for writing. The server returned this error: $!"); print F ""; close(F); $nuser = $data{'nusername'}; $npw = $data{'npassword'}; $npw2 = $data{'npassword2'}; if($npw ne $npw2){ $data{'FA2'} = ""; $error = "Error: Passwords do not match.
"; &add_user(); } if($npw eq "" || $npw2 eq ""){ $data{'FA2'} = ""; $error = "Error: Passwords may not be blank.
"; &add_user(); } if($nuser eq ""){ $data{'FA2'} = ""; $error = "Error: Username may not be blank.
"; &add_user(); } if($nuser =~ /\|/ || $npw =~ /\|/ || $npw2 =~ /\|/){ $data{'FA2'} = ""; $error = "Error: You may not use the | symbol in the username or password.
"; &add_user(); } open(F, "+<$users_file") || &debug("Could not open users file ($users_file). The server returned this error: $!"); @userlines = ; foreach $userline (@userlines){ if($userline =~ /^$nuser\|/){ $data{'FA2'} = ""; $error = "Error: user $nuser already exists.
"; &add_user(); } } foreach $userline (@userlines){ $newfile .= $userline; } $newfile .= "$nuser|" . crypt($npw, $$) . "\n"; truncate(F, length($newfile)); seek(F, 0, 0); print F $newfile; close(F); $error = "$nuser successfully added.
"; &admin; exit(); } sub del_user { if($data{'FA2'} eq ""){ # Look for the user to delete print qq[ $header
$footer]; exit(); } $userdel = $data{'deluser'}; open(F, "+<$users_file") || &debug("Could not open $users_file. The server returned this error: $!"); if($opsys eq "unix"){ flock(F, 2); } else { binmode(F); } while(){ if($_ !~ /^$userdel\|/){ $newfile .= $_; } } truncate(F, length($newfile)); seek(F, 0, 0); print F $newfile; close(F); $error = "$userdel successfully deleted.
"; &admin; exit(); } sub edit_wordlist { &add("Edit"); exit(); } sub delete_wordlist { if($data{'FA2'} eq ""){ opendir(DIR, "$path_to_words_files"); @files = readdir(DIR); closedir(DIR); print "$header
$error"; foreach $file (@files){ if($file !~ /\.txt$/){ next; } open(F, "<$path_to_words_files/$file"); @lines = ; close(F); $title = shift(@lines); $description = shift(@lines); $author = shift(@lines); $title =~ s/^#//sg; $f_title = &unpipe($title); $description =~ s/^#//sg; $author =~ s/^#by//sg; print qq[ ]; } print "
$title
$footer"; exit(); } $title = repipe($data{'title'}); $t_file = lc($title); $t_file =~ s/\W+//sg; if("${t_file}.txt" ne $data{'file'}){ $error = "Error: $title does not appear to be a valid wordlist.
"; $data{'FA2'} = ""; &delete_wordlist; exit(); } unless(-f "$path_to_words_files/$t_file.txt"){ $error = "Error: $title does not appear to be a valid wordlist.
"; $data{'FA2'} = ""; &delete_wordlist; exit(); } # if($ENV{'REMOTE_ADDR'} eq "207.228.46.235"){ unlink("$path_to_words_files/$t_file.txt"); $error = "$title successfully deleted.
"; # } # else { # $error = "Whups: no deleting in the demo. Sorry. :-)
"; # } $data{'FA2'} = ""; &delete_wordlist; exit(); } sub m_lc { my($word) = $_[0]; my($new_word,$char); my %c = ( 'á','Á', 'å','Å', 'æ','Æ', 'à','À', 'â','Â', 'ã','Ã', 'ä','Ä', 'é','É', 'è','È', 'ê','Ê', 'ë','Ë', 'í','Í', 'î','Î', 'ï','Ï', 'ì','Ì', 'ò','Ò', 'ô','Ô', 'ó','Ó', 'õ','Õ', 'ö','Ö', 'ô','Ô', 'ø','Ø', 'ç','Ç', 'ù','Ù', 'ú','Ú', 'ü','Ü', 'û','Û', 'ñ','Ñ', 'ß','ß', ); foreach $char (split(//, $word)){ foreach $key (sort(keys(%c))){ if($char eq $c{$key}){ $char = $key; } } $new_word .= $char; } $new_word = lc($new_word); $new_word; } sub m_uc { my($word) = $_[0]; my($new_word,$char); my %c = ( 'á','Á', 'å','Å', 'æ','Æ', 'à','À', 'â','Â', 'ã','Ã', 'ä','Ä', 'é','É', 'è','È', 'ê','Ê', 'ë','Ë', 'í','Í', 'î','Î', 'ï','Ï', 'ì','Ì', 'ò','Ò', 'ô','Ô', 'ó','Ó', 'õ','Õ', 'ö','Ö', 'ô','Ô', 'ø','Ø', 'ç','Ç', 'ù','Ù', 'ú','Ú', 'ü','Ü', 'û','Û', 'ñ','Ñ', 'ß','ß', ); %c = reverse(%c); foreach $char (split(//, $word)){ foreach $key (keys(%c)){ if($char eq $c{$key}){ $char = $key; } } $new_word .= $char; } $new_word = uc($new_word); $new_word; } sub get_add_wordlist_buttons { my($char,$lc_char,$lang_buttons); foreach $char (split(//, $language{$use_language})){ $lc_char = m_lc($char); $lang_buttons .= "
\n"; } return $lang_buttons; } sub config_check { unless(-d $path_to_words_files && -w $path_to_words_files){ $fatal_error = " ERROR: \$path_to_words_files ($path_to_words_files) does not appear to be correct. This should be a full system path to a directory on your website, and this program must be able to create, change, and delete files in this directory. If not, then the program cannot create word lists, and thus, nothing will be able to function. Please check that the path is correct, and that it has sufficient permissions for the program to write to it. Sometimes, that means chmod 777.

\n"; } if($who_can_add_wordlists = "auth"){ unless(-w $users_file && -f $users_file){ $fatal_error .= " ERROR: You have set up the script to allow authorized users to add wordlists (\$who_can_add_wordlists = \"auth\";) but either I cannot find the users file, or I cannot write to it. You set \$users_file = \"$users_file\"; in the script. Please double check that this is the correct system path to the file, and that the permissions are set so that the script can write to it. Sometimes, that means chmod 766.

\n"; } } if($fatal_error ne ""){ print "$header
Configuration Error Encountered

I found the following error(s) in your configuration. Please fix them or the program will not be able to run:

$fatal_error The following information about your web server may prove helpful in troubleshooting this error:

"; print "Web Server software is $ENV{'SERVER_SOFTWARE'}
\n" if $ENV{'SERVER_SOFTWARE'}; print "Base path to website files is $ENV{'DOCUMENT_ROOT'}
\n" if $ENV{'DOCUMENT_ROOT'}; print "Hostname is $ENV{'HTTP_HOST'}
\n" if $ENV{'HTTP_HOST'}; print "Server Name is $ENV{'SERVER_NAME'}
\n" if $ENV{'SERVER_NAME'}; print "Base path translated is $ENV{'PATH_TRANSLATED'}
\n" if $ENV{'PATH_TRANSLATED'}; print "Script filename is $ENV{'SCRIPT_FILENAME'}
\n" if $ENV{'SCRIPT_FILENAME'}; print "Server O/S is $^O
\n" if $^O; print "
If none of this information is helpful to you, and you're not sure how to fix the problem, please feel free to email all this stuff to me and I'll try to help you sort it out. :-) --Kristina
$footer"; exit(); } }