|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I need some major help with this Browse Script I'm working on. The script is supposed to browse my directories and display the results and the corresponding file types in a table. Here's an example site using this script: http://www.tabster.com/tabs.pl
Whenever I try running the script I get the error message... "Premature end of script headers: /data1/hm/powertabs/cgi-bin/browse.pl" Could someone take a look at it and tell what my error is? It involves two scripts... One called: setup.pl #!/usr/local/bin/perl # this is the root directory of where your files are stored $root_dir = '/data1/hm/powertabs'; # this is the url equivalent to $root_dir $root_url = 'http://powertabs.hypermart.net/tab'; # this is the full url of ftp.pl $script_url = 'http://powertabs.hypermart.net/cgi-bin/browse.pl'; # this is the url of the directory where you have your icons $icon_url = 'http://powertabs.hypermart.net/images'; # this is the path to header.shtml $header = '/data1/hm/powertabs/header.shtml'; # this is the path to footer.shtml $footer = '/data1/hm/powertabs/footer.shtml'; # this is the heading for the top of the page $top_title = 'P O W E R T A B S . C O M - Your ultimate tab resource!'; # this is the background color for the top row of the table $background = 'bgcolor=0065A8'; # This is your list of mirrors... if you have none, then for mirror 1 just # put your own site... make sure to put a comma after each mirror unless it's # the last mirror! %mirrors = ( "Mirror 1 Name" => "http://powertabs.hypermart.net", ); ################ # sub routines # ################ sub get_header_footer { open (FILEA,"$header") | | die "Open header Failed: $!n"; @dataa = ; close(FILEA); open (FILEB,"$footer") | | die "Open footer Failed: $!n"; @datab = ; close(FILEB); } sub print_header { foreach $linez (@dataa) { chomp($linez); print "$linezn"; } } sub print_footer { foreach $liney (@datab) { chomp($liney); print "$lineyn"; } } sub parse { if ($ENV{'QUERY_STRING'} eq "") { $forminfo = ; } else { $forminfo = $ENV{'QUERY_STRING'}; } @key_value_pairs = split(/&/,$forminfo); foreach $pair (@key_value_pairs){ ($key,$value) = split(/=/,$pair); $value =~ s/+/ /g; $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg; $FORM_DATA{$key} = $value; } } And one called: browse.pl #!/usr/local/bin/perl ######################################################## # # # Written By Drew Robbins # # Re-written by Ryan Camer # # Used with permission # # # ######################################################## require "setup.pl"; &parse; &get_files; &get_header_footer; ######################################################## print "Content-type: text/html" , "nn"; &print_header; print "nn"; print " Location: /tab$location n"; print "n"; print "n"; print "NAMEn"; print "TYPEn"; print "DESCRIPTIONn"; print "nn"; for($i=1; $in"; if ($temp_file eq '..') { print "n"; print "n"; print "n"; print "n"; } else { $txt = "$root_dir/$real_path/_"."$temp_file.txt"; if (open (DESCRIPTION,"$txt")) { @description = ; close(DESCRIPTION); } else { @description = ""; } print " n"; print "$temp_filen"; print "Directoryn"; print "$description[0]n"; } print "nn"; } } for($i=1; $i; close(DESCRIPTION); } else { $description[0] = ""; } $icon = "file.gif"; if ($ext =~ /htm/i) { $icon = "html.gif"; } if ($ext =~ /txt/i) { $icon = "txt.gif"; } if ($ext =~ /pl/i | | $ext =~ /cgi/i) { $icon = "cgi.gif"; } if ($ext =~ /zip/i) { $icon = "zip.gif"; } if ($ext =~ /exe/i) { $icon = "exe.gif"; } if ($ext =~ /gif/i) { $icon = "gif.gif"; } if ($ext =~ /jpg/i) { $icon = "jpg.gif"; } print "n"; print " $temp_filen"; print "U$extE Filen"; print "$description[0]n"; print "nn"; } } print " n"; print " nn"; &print_footer; ################ # sub routines # ################ sub get_files { $full_path = $root_dir; if ($FORM_DATA{"dir"} ) { $check_dir = $FORM_DATA{"dir"}; $full_path = "$full_path/$check_dir"; $full_url = "$root_url/$check_dir"; $real_path = "$check_dir/"; $location = "/$check_dir"; $back_one = "$check_dir?"; $back_one =~ s//([^/]|n)*?//g; if ($back_one eq "$check_dir"."?") { $back_one = ""; } else { $back_one = "?dir=$back_one"; } } chdir($full_path); opendir (DIR, $full_path); @allfiles = readdir(DIR); $totalnum=@allfiles; @allfiles = sort @allfiles; closedir (DIR); } Please e-mail your response to: webmaster@powertabs.com Thanks. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Need help with a Browse Script!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|