CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Premeture end of script headers...

 



prsnlty
Deleted

Mar 19, 2000, 7:46 PM

Post #1 of 5 (694 views)
Premeture end of script headers... Can't Post

Hello,
I have installed a script with about a dozen cgis as a part of it. One of them is erroring:"Premature end of script headers: /www/htdocs/personality-creations/cgi-bin/banner/getpaid.cgi" This perticular cgi I didn't do anything to it but upload and chmod it as that's all I was supposed to do.
Could it be due to the script that called it or is this "getpaid.cgi" the problem. If so what does the above mentioned error really mean?
Thanks for your help :-)



Cretep
User

Mar 20, 2000, 5:03 AM

Post #2 of 5 (694 views)
Re: Premeture end of script headers... [In reply to] Can't Post

Hi
First of all if you have telnet access use the -wc switch. This will pinpoint the problem. You can do this by entering this at the command prompt:
:/ >cd /www/htdocs/personality-creations/cgi-bin/banner It will then return something like this
:/www/htdocs/personality-creations/cgi-bin/banner > Then type the following

:/www/htdocs/personality-creations/cgi-bin/banner > getpaid.cgi -wc And it should tell you the problem.

However if you don't have telnet access or you don't want to get you hands dirty then post the script here and we can take it from there.

Best regards

Peter Crouch


prsnlty
Deleted

Mar 20, 2000, 5:43 AM

Post #3 of 5 (694 views)
Re: Premeture end of script headers... [In reply to] Can't Post

I don't believe I have telnet access, just ftp. If it's the same thing I don't understand how to use it.
This is the script that is receiving the error below and thank you :-)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl
####################################################################################################
# BANANA BANNER CLICKTHROUGH SYSTEM Version 1.0
# Copyright 1999 Bananascripts, Inc. webmaster@bananascripts.com
# Created 10/10/99 Last Modified 10/20/99
####################################################################################################
# Selling the code for this program without prior written consent is
# expressly forbidden.
#
# Love your monkeys http://www.bananascripts.com/ Bananascripts, Inc.
#
# Obtain written permission before redistributing this software over the Internet or
# in any other medium. In all cases copyright and header must remain intact.
#####################################################################################################
require "configure.cgi";
&configure;
####################################################################################################

$host = "$ENV{'REMOTE_HOST'}";
$refer = "$ENV{'HTTP_REFERER'}";

print "Content-Type: text/html\n";
print "Set-Cookie: $agentcode=nukedaccount; path=/; expires=Mon, 01-Jan-2001 00:00:00 GMT\n";

&getperiod;
&checkuniques;

if ($affiliate ne "nukedaccount"){
&logclick;
}

###################################################################
sub checkuniques {

$cookie="$ENV{'HTTP_COOKIE'}";
($trash,$affiliate) = split(/$agentcode=/,$cookie);
if ($affiliate=~ /;/){
($affiliate,$trash) = split(/;/,$affiliate);
}

}
###################################################################
sub logclick {

open (DATABASE, "$memberdatabase");
@database=<DATABASE>;
close DATABASE;

foreach $database (@database) {
chomp $database;
($name,$company,$sitename,$url,$email,$address,$city,$state,$zip,$country,$ssnumber,$username,$password,$recruiter) = split(/\|/,$database);
if ($affiliate eq $username){
last;
}
}

open (FILE, ">>$cgidirectory/logs/$affiliate.$period.db");
flock(FILE, 2);
chomp $date;
print FILE "$shortdate|$host|$refer|$affiliate|$primarycommission\n";
flock(FILE, 8);
close (FILE);

open (FILE, ">>$cgidirectory/logs/$period.log");
flock(FILE, 2);
chomp $date;
print FILE "$shortdate|$host|$refer|$affiliate|$primarycommission\n";
flock(FILE, 8);
close (FILE);

}
############################################################
# SUBROUTINES
############################################################
sub form_parse {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}}
############################################################
# GET PERIOD
############################################################
sub getperiod {
require "ctime.pl";
chop($date = &ctime(time));
($weekday,$month,$day,$time,$zone,$year)=split(/ /,$date);

if ($day eq ""){
$day = $time;
}

$shortdate = "$month $day";
open (SCHEDULESEEDS, "$cgidirectory/data/schedule.db");
@schedules=<SCHEDULESEEDS>;

foreach $schedules (@schedules){
($searchperiod,$getpaydays)=split(/\|/,$schedules);
(@searchpaydays)=split(/\,/,$getpaydays);
foreach $searchpaydays(@searchpaydays){
chomp $searchpaydays;
if ($shortdate eq $searchpaydays){
$currentperiod = $searchperiod;
@currentpaydays = @searchpaydays;
}
}
}


$period = $FORM{'period'};

if ($period eq ""){
@paydays = @currentpaydays;
$period = $currentperiod;
$startdate = $paydays[0];
$periodlength = @paydays;
$periodcue = $periodlength - 1;
$stopdate = $paydays[$periodcue];
}

else {
foreach $schedules (@schedules){
($searchperiod,$getpaydays)=split(/\|/,$schedules);
(@searchpaydays)=split(/\,/,$getpaydays);
if ($period eq $searchperiod){
@paydays = @searchpaydays;
}
}

$startdate = $paydays[0];
$periodlength = @paydays;
$periodcue = $periodlength - 1;
$stopdate = $paydays[$periodcue];
}

$lastperiod = $period - 1;
$nextperiod = $period + 1;

}

1; # Return true



darian
Deleted

Mar 20, 2000, 11:40 PM

Post #4 of 5 (694 views)
Re: Premeture end of script headers... [In reply to] Can't Post

I personaly would use another script. This for a couple reasons.

1. The writer is slurping your database in and using a foreach statement which can cause problems as your database gets larger. Since this is a banner script you don't want it to have to pull in 1000's of records then sort through them one by one just to give them a click count. This will eat up system resources if you ever get alot of hits. This will not be much trouble if you only get a few hits a day and your database is very small.

2. The writer does not test for errors anywhere. If you get an error in this script you get the error you are getting now: "Premeture end of script headers."

As I said before I would use another script. But if you want you can always modify this one (with the original creators authority of course Smile ) to work the way it should.


prsnlty
Deleted

Mar 21, 2000, 6:29 AM

Post #5 of 5 (694 views)
Re: Premeture end of script headers... [In reply to] Can't Post

Hello and thank you Darian :-) This script was a free one. It took me 3 months just to get it to run as far as it is :-( I have written the writer of the script several time without a reply. I know he still exists because his site is continually updated. The thing is, I already have 28 affiliates. They all signed up the first day I offered it from my site. When I realized that it didn't show the individuals their clicks I stopped offering it. I had tested it with a false affiliate (me) but didn't test every angle. Back then I was really new to this and figured if it ran it was ok. Do you know of someone who could modify it? The script has several other cgi's and none are erroring except this one.
No, this is not good! "The writer is slurping your database in", The main reason I took this script was because I don't have to use SSI as I don't have my pages set up for it (also because it was inexpensive). Only because when I began building this domain (and I never had a domain before,) I didn't know that to have SSI I had to name my pages .shtml. I now have over 500 pages that I would have to change and would have to redirect each one of them. ARGH! Eventually I intend to do so, can't until next January due to a new site being built that is business only. BTW, all of those pages are named .shtml.
OK, to fix this cgi, it would also mean fixing the others that accompany it as well.. correct? I like the way it only records the hits when the visitor clicks into certian coded pages, plus nonssi use and free :-) So, unless I can find another that offers this I'll have to have this one modified. Any suggestions?
Thanks again :-)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives