Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old January 2nd, 2001, 09:39 PM
powertabs powertabs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 1 powertabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Need help with a Browse Script!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway