#!/usr/bin/perl #-----------------------------------------------------------# # # BNBSURVEY Script 3.2.2, (C)2000-2002 Bignosebird.com # Use of this script means that you accept the disclaimer and # agree to the terms of use located at the bottom of the # script. # # This script is provided without support. Please read the # README.TXT file, as well as following the troubleshooting # links and information at http://bignosebird.com/cgi.shtml # Our BBS is located at http://bbs.bignosebird.com/ # # Additional security patch added 12-30-2000 in decode # subroutine. # # Added option to block multiple vote attempts using IP # address. Additional security mods. (02-10-2002) # Modified IP based multi-vote blocking to allow time based # blocking as well. (02-16-2002) # IMPORTANT: This changed the format of the log file. There # is now a integer number representing the vote time located # between the human readable date and the first vote response # field. # #------------SCRIPT CONFIGURATION SECTION-------------------- # The script can be called in this manner to provide view without # voting: # http://longvalleyantiques.com/cgi-bin/survey/survey.cgi?survey_name=number1 # $DATA_PATH is the FULL system path to the directory where # your survey data files are stored. Your web server must have # permission to write to and create files in this directory $DATA_PATH= "/html/users/longvalleyantiquescom/html/cgi-bin/survey"; # The $DOMAIN must be your site's domain name. $DOMAIN="www.longvalleyantiques.com"; # $GRAPHICSDIR is the directory under your main html directory # containing the colored gif files. $GRAPHICSDIR="survey"; # To prevent people from voting too often, set $USE_COOKIES=1 # HOURS is the NUMBER OF HOURS before the voter can vote # again. 1 Day=24, 1 Week=168, 1 Month=720 give or take.... # To disable cookies, let $USE_COOKIES=0 # # WARNING: DO NOT ENABLE COOKIES UNTIL YOU ARE SURE EVERYTHING # IS WORKING PERFECTLY, OR YOUR DEBUGGING CAN BE SERIOUSLY # SLOWED DOWN WHILE YOU WAIT FOR THE COOKIE TO EXPIRE. ;-) $USE_COOKIES=0; $HOURS=0; # one hour delay between votes # Set $USE_LOGGING to 1 to turn on log file capture. # Log format is an ASCII tab delimited file consisting of: # Visitor's IP address, date, time, responses, e-mail, comments # Can be easily imported into spreadsheets and databases $USE_LOGGING=1; # If you USE_LOGGING, you can also block multiple votes from # the same IP address. Just set $BLOCK_IP=1 # If $HOURS (from above) is set to zero, a voter from an IP # address can only vote once. You can set a minimum time # between votes by setting $HOURS=1 (as an example) to allow # a voter from an IP address to vote every hour. $BLOCK_IP=0; # IF $SHOW_RESULTS=0 (do not display after voting), be sure # to set $JUMP_URL to the page the voter should be sent to. # By default, it sends the voter back to the page they came from. # When used with SHOW_RESULTS=1, this is the link they can click # on after viewing the voting. $SHOW_RESULTS=1; $JUMP_URL="$ENV{'HTTP_REFERER'}"; # These are the cosmetic settings in case you do not like my # terrible taste in colors! The actual result page layout can # be found near the bottom of the script. $TABLECOLOR="#FFFFFF"; $HEADINGCOLOR="#000000"; $HEADINGFONT="arial,helvetica"; $BORDERCOLOR="#000000"; $FONT="arial,helvetica"; $FONTCOLOR="#000066"; # the script starts for real here.... &decode_vars; &check_files; if ($ENV{'REQUEST_METHOD'} eq "POST" && -e $DATA_FILE && -w $DATA_FILE){ if ($BLOCK_IP == 1 && $USE_LOGGING == 1 && &is_blocked == 1 ){ &already_voted; exit; } if ($USE_COOKIES == 1){ $COOKIEVAL=&get_cookie($SURVEY_NAME); if ( $COOKIEVAL > time){ &already_voted; exit; } else{ $cookie=&set_cookie($SURVEY_NAME,(time + ($HOURS * 3600)),$HOURS); print "$cookie\n"; } } $MODE="VOTE"; &set_colors; &process_file; &do_stats; if ($SHOW_RESULTS == 1){ print "Content-type: text/html\n\n"; $PAGEHEADER=&set_page_header; $PAGEFOOTER=&set_page_footer; print "$PAGEHEADER\n"; &display_stats; print "$PAGEFOOTER\n"; } else{ print "Location: $JUMP_URL\n\n"; } exit; } if ($ENV{'REQUEST_METHOD'} eq "GET" && -e $DATA_FILE){ $MODE="VIEW"; &set_colors; &process_file; &do_stats; $PAGEHEADER=&set_page_header; $PAGEFOOTER=&set_page_footer; print "Content-type: text/html\n\n"; print "$PAGEHEADER\n"; &display_stats; print "$PAGEFOOTER\n"; exit; } sub do_stats{ $oldtag="NONE"; @groups=(); foreach $toshow (@list){ @tags=split(/\|/,$toshow); if ($tags[0] ne $oldtag){ $group=$tags[0]; push(@groups,$group); $total{$group}=0; $oldtag = $tags[0]; } $total{$group} = $total{$group} + $questions{$toshow}; } } sub display_stats{ $oldgroup="NONE"; $itemcount=0; foreach $toshow (@list){ @tags=split(/\|/,$toshow); if ($tags[0] ne $oldgroup){ if ($oldgroup ne "NONE"){ $GROUPFOOTER=&set_footer($total{$group}); print "$GROUPFOOTER\n"; } $group=$tags[0]; $GROUPHEAD=&set_group_header($title{$group}); print "$GROUPHEAD\n"; $oldgroup=$group; $itemcount=0; } if ($total{$group} > 0){ $pct=int((($questions{$toshow} / $total{$group} * 100)+.5)) ; } else{ $pct=0; } @qi=split(/\|/,$toshow); $giffile=@colors[$itemcount]; $RESPONSELINE=&set_question($qi[1],$questions{$toshow},$pct, $giffile); print "$RESPONSELINE\n"; $itemcount = $itemcount + 1; } $GROUPFOOTER=&set_footer($total{$group}); print "$GROUPFOOTER\n"; } sub process_file { &get_the_lock; if ($USE_LOGGING == 1 && $MODE eq "VOTE"){ $SYSTIME=&sys_date; $SYSINT=time; $LOG_LINE="$ENV{'REMOTE_ADDR'}\t$SYSTIME\t$SYSINT\t"; open(LO,">>$LOG_FILE"); } open(IX,"<$DATA_FILE"); while ($line=){ @loga=(); chop $line; @parts=split(/:/,$line); $q=$parts[0]; $n=$parts[1]; $t=$parts[2]; @tags=split(/\|/,$line); $ti=$tags[0]; $title{$ti} = $t; $titles{$q} = $t; if ($fields{$ti} eq $q){ $questions{$q} = $n + 1; @loga=split(/\|/,$q); if ($USE_LOGGING == 1 && $MODE eq "VOTE"){$LOG_LINE .= "$loga[1]\t";} } else{ $questions{$q} = $n; } push(@list,$q); } close(IX); if ($MODE eq "VOTE"){ open(IY,">$DATA_FILE"); foreach $toshow (@list){ print IY "$toshow:$questions{$toshow}:$titles{$toshow}:\n"; } close(IY); } if ($USE_LOGGING == 1 && $MODE eq "VOTE"){ if ($fields{'email'} eq ""){$fields{'email'}="no-email";} if ($fields{'comments'} eq ""){$fields{'comments'}="no-comment";} $LOG_LINE .= "$fields{'email'}\t$fields{'comments'}"; print LO "$LOG_LINE\n"; close(LO); } &drop_the_lock; } sub set_colors{ #this allows for up to 22 responses per question. if you have more, just #continue duplicating the middle two lines of the array below... @colors=("blue.gif","red.gif","green.gif","yellow.gif","cherry.gif", "navy.gif","pink.gif","black.gif","teal.gif","purple.gif","sky.gif", "blue.gif","red.gif","green.gif","yellow.gif","cherry.gif", "navy.gif","pink.gif","black.gif","teal.gif","purple.gif","sky.gif"); } sub decode_vars { $i=0; if ( $ENV{'REQUEST_METHOD'} eq "GET") { $temp=$ENV{'QUERY_STRING'}; } else { read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); } @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split(/=/,$item,2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $content=~s/\0//g; $key=~s/\0//g; $content=~s/\012//gs; $content=~s/\015/ /gs; $fields{$key}=$content; } if ($fields{'survey_name'}=~/^([-\@\w.]+)$/){ $SURVEY_NAME=$fields{'survey_name'}; } else {exit;} $fields{'comments'}=~s/\t/ /g; $fields{'email'}=&valid_address($fields{'email'}); } sub valid_address { my ($testmail) = @_; if ($testmail =~/ /) { return ""; } if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/) { return ""; } else { return $testmail; } } sub get_the_lock { if ($MODE ne "VOTE"){return;} my $lockfile="$DATA_PATH/$SURVEY_NAME\.lkk"; local ($endtime); $endtime = 40; $endtime = time + $endtime; while (-e $lockfile && time < $endtime) { # Do Nothing } open(LOCK_FILE, ">$lockfile"); } sub drop_the_lock { if ($MODE ne "VOTE"){return;} $lockfile="$DATA_PATH/$SURVEY_NAME\.lkk"; close(LOCK_FILE); unlink($lockfile); } sub already_voted{ print "Content-type: text/html\n\n"; print<<__END_ALREADY_VOTED__;

You Already Voted!

__END_ALREADY_VOTED__ } # # This routine takes (name,value,hours,path,domain) as arguments # to set a cookie. # # 0 hours means a current browser session cookie life # sub set_cookie() { my ($name,$value,$expires) = @_; $name=&cookie_scrub($name); $value=&cookie_scrub($value); $expires=$expires * 3600; $expires=int($expires); my $expire_at=&cookie_date($expires); my $namevalue="$name=$value"; my $COOKIE=""; if ($expires != 0) { $COOKIE= "Set-Cookie: $namevalue; path=$path; expires=$expire_at; "; } else { $COOKIE= "Set-Cookie: $namevalue; "; #current session cookie if 0 } return $COOKIE; } # # This routine removes cookie of (name) by setting the expiration # to a date/time GMT of (now - 24hours) # sub remove_cookie() { my ($name) = @_; $name=&cookie_scrub($name); my $value=""; my $cookie=""; my $expires=&cookie_date(-86400); my $namevalue="$name=$value"; my $COOKIE= "Set-Cookie: $namevalue; expires=$expires; "; return $COOKIE; } # # given a cookie name, this routine returns the value component # of the name=value pair # a returned value of 0 means no cookie # sub get_cookie() { my ($name) = @_; $name=&cookie_scrub($name); my $temp=$ENV{'HTTP_COOKIE'}; @pairs=split(/\; /,$temp); foreach my $sets (@pairs) { my ($key,$value)=split(/=/,$sets); $clist{$key} = $value; } if ($clist{$name} eq "") {$clist{$name}="0";} my $retval=$clist{$name}; return $retval; } # # this routine accepts the number of seconds to add to the server # time to calculate the expiration string for the cookie. Cookie # time is ALWAYS GMT! # sub cookie_date() { my ($seconds) = @_; my %mn = ('Jan','01', 'Feb','02', 'Mar','03', 'Apr','04', 'May','05', 'Jun','06', 'Jul','07', 'Aug','08', 'Sep','09', 'Oct','10', 'Nov','11', 'Dec','12' ); my $sydate=gmtime(time+$seconds); my ($day, $month, $num, $time, $year) = split(/\s+/,$sydate); my $zl=length($num); if ($zl == 1) { $num = "0$num"; } my $retdate="$day $num-$month-$year $time GMT"; return $retdate; } # # don't allow = or ; as valid elements of name or data # sub cookie_scrub() { my($retval) = @_; $retval=~s/\;//g; $retval=~s/\=//g; return $retval; } # # check to see if the IP of this client has been logged. # if so, return 1 to indicate client should be blocked. # only called if $USE_LOGGING and $BLOCK_IP are set to 1. # added 02/10/2002 # # Modified on 02/16/2002 so that if $HOURS are not equal # to 0, you can control the time between votes based on # IP address the same way as with cookies. # sub is_blocked{ my $current_time=time; my @solog=(); open(OLOGS,"<$LOG_FILE"); my @logs=; close(OLOGS); my $lcounter=@logs; for ($lcounter; $lcounter >= 0; $lcounter--){ if ( $logs[$lcounter]=~/^$ENV{'REMOTE_ADDR'}/){ if ($HOURS == 0){ return 1; } @solog=split(/\t/,@logs[$lcounter]); if ( ($solog[3] + ($HOURS * 3600)) > $current_time ){ return 1; } } } return 0; } sub sys_date{ my %mn = ('Jan','01', 'Feb','02', 'Mar','03', 'Apr','04', 'May','05', 'Jun','06', 'Jul','07', 'Aug','08', 'Sep','09', 'Oct','10', 'Nov','11', 'Dec','12' ); my $sydate=localtime(time); my ($day, $month, $num, $time, $year) = split(/\s+/,$sydate); my $zl=length($num); if ($zl == 1) { $num = "0$num";} my $retval="$year\-$mn{$month}\-$num\t$time"; return $retval; } sub check_files{ $DATA_FILE="$DATA_PATH/$SURVEY_NAME\.srv"; $LOG_FILE="$DATA_PATH/$SURVEY_NAME\.log"; if ( !-e $DATA_FILE){ print "Content-type: text/html\n\n Data File is Missing!\n"; exit; } if ( !-w $DATA_FILE){ print "Content-type: text/html\n\n Data File Cannot be Written to!\n"; exit; } if ( !-e "$LOG_FILE" && $USE_LOGGING == 1){ open(OP,">>$LOG_FILE"); close(OP); } if ( !-w "$DATA_PATH/$SURVEY_NAME\.log" && $USE_LOGGING == 1){ print "Content-type: text/html\n\n Log File Cannot be Written to!\n"; exit; } } ######################## COSMETIC SECTION ########################## # # The following subroutines contain the HTML text (and some logic # so be careful editing!) that is presented when viewing the survey # results. # sub set_page_header{ my $PAGEHEAD=<<__END_PAGE_HEAD__;
__END_GROUP_HEADER__ return $GROUP_HEADER; } sub set_question{ my ($respitem,$count,$pct,$giffile) = @_; my $factor = $pct * 2.50; my $SCALE=int($factor); my $RESPONSE=<<__END_RESPONSE_LINE__; __END_RESPONSE_LINE__ return $RESPONSE; } sub set_footer{ my ($tot) = @_; my $FOOTGROUP=<<__END_GROUP_FOOTER__; __END_GROUP_FOOTER__ return $FOOTGROUP; } sub set_page_footer{ my $PAGEFOOT=<<__END_PAGE_FOOT__;
The Survey Results!
College Freshmen

__END_PAGE_HEAD__ return $PAGEHEAD; } sub set_group_header{ my ($GROUP_HEADING)=@_; my $GROUP_HEADER=<<__END_GROUP_HEADER__;

$GROUP_HEADING
Response Number Percent Graph
$respitem $count $pct\%
Total Number of Responses: $tot

__END_PAGE_FOOT__ return $PAGEFOOT; } #--------DISCLAIMER-AND-COPYRIGHT-INFORMATION---------------------------# # ANY SOFTWARE PROVIDED BY BIGNOSEBIRD.COM, INC. IS ``AS IS'' AND ANY # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BIGNOSEBIRD.COM, INC. OR # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SCRIPT IS PROVIDED WITHOUT SUPPORT # # THIS SCRIPT IS FREEWARE AND CAN BE USED FOR BOTH COMMERCIAL AND # NON-COMMERCIAL USE. REPUBLICATION OF THE SCRIPT REQUIRES OUR PERMISSION. # webmaster\@bignosebird.com #-----------------------------------------------------------------------# ####
College Survey
for college freshmen

Welcome! I am conducting this survey for statistical information. Your identity will not be disclosed to anyone in accordance with our privacy policy. Please fill this out carefully and put honesty into it because all information you provide is very important.
Your email is being asked just in case I have to add or change questions and I know that I can email you to get the results from the exact same audience.
Thank you for filling out this survey!

E-Mail Address (optional)

 

Gender Male Female No Answer

 

 

1. Do you prefer applying to colleges online or offline?
Online Offline No Preference

 

2. If you did not have the opportunity to apply to colleges online, would you have preferred to apply online?
Yes No No Answer

 

3. When online, if you could apply to more than one college at a time, using only one application form, would you take advantage of this opportunity?
Yes No No Answer

 

4. With regard to question 3, would you pay a one-time $20.00 fee to apply to more than one college, excluding the cost for the application fee?
Yes No No Answer

 

5. Checkmark all of the functions, provided you were a registered member (you paid the $20.00 one-time registration fee), that you would have liked to have with your account?

New email address used primarily to receive and respond to emails from college-related material

Option to see a list of colleges you could apply to with the information and facts about the college

Your personal information and universal questions (name, address, etc.) already in the database so you do not have to re-type that information again. This would allow you to concentrate on non-universal questions (such as essays)

A portfolio that consists of the colleges you A. Will apply to B. ALready applied to C. Might apply to.

Ability to find money for college via almost a million scholarships plus financial aid tips

To have acceptance/rejection letters sent to you in the portfolio, by email, and by postal mail

 

Comments

##
## ITEM_1|Male:0:Respondent's Sex: ITEM_1|Female:0:Respondent's Sex: ITEM_1|No Answer:0:Respondent's Sex: ITEM_2|Alabama:0:State: ITEM_2|Alaska:0:State: ITEM_2|Arizona:0:State: ITEM_2|Arkansas:0:State: ITEM_2|California:0:State: ITEM_2|Colorado:0:State: ITEM_2|Connecticut:0:State: ITEM_2|Delaware:0:State: ITEM_2|District of Columbia:0:State: ITEM_2|Florida:0:State: ITEM_2|Georgia:0:State: ITEM_2|Hawaii:0:State: ITEM_2|Idaho:0:State: ITEM_2|Illinois:0:State: ITEM_2|Indiana:0:State: ITEM_2|Iowa:0:State: ITEM_2|Kansas:0:State: ITEM_2|Kentucky:0:State: ITEM_2|Louisiana:0:State: ITEM_2|Maine:0:State: ITEM_2|Maryland:0:State: ITEM_2|Massachusetts:0:State: ITEM_2|Michigan:0:State: ITEM_2|Minnesota:0:State: ITEM_2|Mississippi:0:State: ITEM_2|Missouri:0:State: ITEM_2|Montana:0:State: ITEM_2|Nebraska:0:State: ITEM_2|Nevada:0:State: ITEM_2|New Hampshire:0:State: ITEM_2|New Jersey:0:State: ITEM_2|New Mexico:0:State: ITEM_2|New York:0:State: ITEM_2|North Carolina:0:State: ITEM_2|North Dakota:0:State: ITEM_2|Ohio:0:State: ITEM_2|Oklahoma:0:State: ITEM_2|Oregon:0:State: ITEM_2|Pennsylvania:0:State: ITEM_2|Rhode Island:0:State: ITEM_2|South Carolina:0:State: ITEM_2|South Dakota:0:State: ITEM_2|Tennessee:0:State: ITEM_2|Texas:0:State: ITEM_2|Utah:0:State: ITEM_2|Vermont:0:State: ITEM_2|Virginia:0:State: ITEM_2|Washington:0:State: ITEM_2|West Virginia:0:State: ITEM_2|Wisconsin:0:State: ITEM_2|Wyoming:0:State: ITEM_3|Online:0:Prefer to apply online v offline: ITEM_3|Offline:0:Prefer to apply online v offline: ITEM_3|No Preference:0:Prefer to apply online v offline: ITEM_4|Yes:0:Would prefer to apply online with opportunity: ITEM_4|No:0:Would prefer to apply online with opportunity: ITEM_4|No Answer:0:Would prefer to apply online with opportunity: ITEM_5|Yes:0:Would use one form: ITEM_5|No:0:Would use one form: ITEM_5|No Answer:0:Would use one form: ITEM_6|Yes:0:Would pay registeration fee ($20): ITEM_6|No:0:Would pay registeration fee ($20): ITEM_6|No Answer:0:Would pay registeration fee ($20): ITEM_7|Want own email address:0:Functions: ITEM_7|Want college list:0:Functions: ITEM_7|Want pre-answered questions:0:Functions: ITEM_7|Want portfolio:0:Functions: ITEM_7|Want scholarship info:0:Functions: ITEM_7|Want all forms of contact for admissions status:0:Functions: