Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

cgiwrap error and I need advice, help Thanks

Quote Reply
cgiwrap error and I need advice, help Thanks
Hi all:


I installed links to try it and at first certain admin sections would'nt work.

Building
Build All - Internal Sever Error malformed header from script. Bad header=HTTP/1.0 200 OK
Staggered - - Internal Sever Error malformed header from script. Bad header=HTTP/1.0 200 OK
Staggered - - Internal Sever Error malformed header from script. Bad header=HTTP/1.0 200 OK
(Auto) - - Internal Sever Error malformed header from script. Bad header=HTTP/1.0 200 OK
Edit Templates (These work)

---------------------

Verifying Links
Quick Check
Detailed

I removed the HTTP/1.0 200 OK from the script as was stated in a previous thread which is no longer here, and the above

Quick Check
Detailed

And now they work. I also removed this from the nph-build.cgi file, but it still doen't work, build?

the Admin section is not paasword protected as there is no real reason to do so as I have evidentally not started to build with the above problem.

web site is located here
http://www.paaw.com/

built by html pages and it's getting a tad big for that :-(


Please respond to what files yo would need to see.

Heres the address to the admin section and please note that I am aware that it is not protected. I want those who can help to see for them selves as I am evidentally doing something wrong.

My Webhosting provider is Interspped

http://www.interspeed.net/

Thank you





------------------
Gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
http://paaw.com/cgi-bin/cgiwrap/paaw/admin/admin.cgi



ooops admin URL, sorry
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Thanks for posting your web host. I used to run my site at Interspeed, and am working on a beta of another there. I used to get the same errors when building, but the pages *do* build. FTP in and you should find that all the pages and directories were created. I have yet to find a solution to the problem there. It is an Interspeed problem. I just lived with it. I moved my site to Hostway, and haven't had a problem with it.
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Thnakyou gopgirl. There were some other notices posted earlier that I guess are no longer here. But even those posts did not solve the problem.

I guess there is nobdy who can.


Thank you for your post and info on the web hosying provider. Maybe somebody will come in and beable to help me out so I won't have to do that.

Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Thanks for the tip on the nph-verify...
You also need to comment out
$nph++ in nph-build and nph-email
and set the use html equal to 1 instead of 0

My server uses cgiwrap as well, they said they would take it out but then my other scripts stopped working,,,so I did the above mods instead...but my verify wouldn't work,,now I know why.

Brad

Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
thanks Brad back as it now works,,,,, as Fred Flintstone would say!!!


yyyYYYYYYYAAAABBBBBAAAA DDDDDDAAAABBBAAA DOOOO!!!!!!

1 problem though, check out the build feature it has 1 error.

It states this:

CGI ERROR
==========================================
Error Message : Error building! Links database is 0 bytes!
Script Location : /usr/local/www/htdocs/paaw//cgi-bin/admin/nph-build.cgi
Perl Version : 5.00404

Form Variables

Building pages Works as far as coming up, but what is the above error? but what is this?

/usr/local/www/htdocs/paaw//cgi-bin/admin/nph

Thanks everyone, check it out and it's still not protected as there still has been nothing built. I will reinstall it upon getting it right.


gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
seems all the options on the links pages are creating an error. I wish I had hair to pull out.

Take a look

http://paaw.com/links/pages/

try to add url

try to search.

soemthing is miscofigured there, I just cant figure it out. Checked the links.cfg.

Anyone?
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi,

I have the same problem as "Gerardo" . I'm also with interspeed .net
Please anyone can hep us? also if some one can suggest a good ISP with reasnable price and good features.

Thank you all for answering us
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi Jacob,


I've been tampering with the cgiwrap and on somethings it's not the cgiwrap. I guess we needed to read the documentation a bit. However, I am still having some errors.


/usr/local/www/htdocs/your site/cgi-bin/

within the script it has commented out to use the full path to obtain the cript. You have to add the "Full Path". The best thing to do is look at the errors and see what the server is having a problem with and which "script".


However I am still getting the above error


/usr/local/www/htdocs/paaw//cgi-bin/admin/nph

it seems it has after paaaw // cgi-bin (is the problem) but cant locate the problem as of now.

Any suggestions, anyone?

Also check out this url

http://paaw.com/links/pages/

see what works and what does not work.

Thanks
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Did You Correctly Add Category's First Because When I Was Testing Out Links I Forgot To Add A Category So It Would Work And I GOt The Same

CGI ERROR
==========================================
Error Message : Error building! Links database is 0 bytes!
Script Location : /usr/local/www/htdocs/paaw//cgi-bin/admin/nph-build.cgi
Perl Version : 5.00404

Error So Try Adding At Least One Category Before Building All Your Pages Hope This Helps If Not Send Me An E-mail At apankow@chorus.net And I Will Help You The Best I Can.
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
yup, I did that and it worked. Now we have a new problem.

When I go to a category to add a URL I get the following statement:
---------------------------------------
Auto submission is not allowed in this directory. Please visit
the site to add your entry.
----------------------------------------

Any suggestions?
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
for my above posting, remember I am dealing with cgiwrap.


I did use the search, but still not having any luck even with this thread below.


Thanks.
-----
http://www.gossamer-threads.com/scripts/forum/resources/Forum11/HTML/000857.html
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
never mind, I found that one also. All set
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi gerardo

please can you post how you fix the problem? I have the same problem that you have. I appreciate your reply.. Thanks
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
hi Jacob:


I got your message in paaw's message board which I removed only to make room for a new topic one. I tried to email you but the e-mail you left did not work?


If you want to leave an email address that works, I'd be more than glad to help with what I know.

gerardo

I also have ICQ and AOL chat

Gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi gerardo,

I'm sorry to post the message in your paaw's board I couldn't find your E-mail and that was the only place to contact you.
you can E-mail me at ( vip0@mailcity.com ) -0=zero not O - please send me the fixes you made for Links to make it work? I think "Links" is accpeting new pages but every time I click on "Build All" I get the error message that you know. Please you can reply to me here or on my mail address.. Thank you very much for your help
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
no problem about the posting of the message as I need to arrange that differently anyway. I emailed you some suggestions and hope you got them.


Gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi gerardo,
I didn't get the E-mail ! did you send it to the right address? you can also post it here if you like, so every one get benefit of your work .. Thanks

[This message has been edited by Jacob (edited August 29, 1999).]
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Here's a copy of the nph-nuild.cgi


Note: where it states,WHO? that is your user name for your ISP account. Hope this helps.

Gerardo


#!/usr/local/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: nph-build.cgi
# Description: Builds a set of HTML pages from the template directory. This is a
# non parsed header script, and should display the output directly as it may
# take quite a while to perform. It can also be called from the
# command line or via a cron routine. Read the README for more details.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.0
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================


# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "/usr/local/www/htdocs/WHO?/cgi-bin/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
use vars qw(%category %subcategories @links @new_links @cool_links %stats $grand_total $use_html $nph $date $time);
};
if ($@) {
# print "HTTP/1.1 200\n";
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {
# --------------------------------------------------------
#
$|++;

$use_html = 0;
$ENV{'REQUEST_METHOD'} and $use_html++;

$use_html and (%in = &parse_form);

# Either build the whole directory, parts of it, or just the new/popular section.
if ($use_html) {
if ($in{'staggered'}) { &build_staggered; }
else { &build_all; }
}
else { &build_all; }
}

sub build_staggered {
# --------------------------------------------------------
# Builds the directory in steps.
#
my %in = &parse_form;

# $nph++;
&html_print_headers() if ($use_html);
my %steps = ( 1 => 'Updating New and Popular Records and rebuilding URL database',
2 => 'Rebuilding Category Pages',
3 => 'Building Detailed View Pages',
4 => 'Updating Home/New/Cool Pages'
);
my $step = $in{'step'} | | 1;
my $limit = $in{'limit'} | | 20;
my $offset = $in{'offset'} | | 0;
my $auto = $in{'auto'} | | 0;
my $start = time();
my $date = &get_date;
my $time = &get_time;

my $header = qq~
<html>
<head>
<title>Rebuilding Directory -- Phase $phase</title>
~;

my $sub_head = qq~
</head>

<body bgcolor=#FFFFFF>
<H2><TT>Building Pages</TT></H2>
<P><em>Step: $steps{$step}</em>
<PRE>
Pages built on $date at $time
--------------------------------------------------------

~;
CASE: {

($step == 1) and do {
print $header;
print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=2&auto=$auto">~ if ($auto);
print $sub_head;

my $t1 = time();
print "Backing up database . . .\n";
&build_backup;
print "Done (", time - $t1, " s)\n\n";

$t1 = time();
print "Building URL Index . . .\n";
&build_url_index;
print "Done (", time - $t1, " s)\n\n";

print "Updating New and Popular Records . . .\n";
$t1 = time();
&build_update_newpop;
print "Done (", time - $t1, " s)\n\n";

print "Updating ratings .. \n";
$t1 = time();
&build_update_ratings;
print "Done (", time - $t1, " s)\n\n";

my $elapsed = time() - $start;
print "------------------------------------------------\n";
print "Step 1 took $elapsed seconds.\n\n";
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=2&auto=$auto">On to Step 2</A></B></FONT></P>~;
last CASE;
};

($step == 2) and do {
my @category_list = &category_list; my $i;
print $header;
if ($auto) {
($offset > $#category_list) ?
(print qq~<meta http-equiv="Refresh" content="0; URL=nph-build.cgi?staggered=1&step=3&auto=$auto">~) :
(print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=2&limit=$limit&offset=~, $offset + $limit, qq~&auto=$auto">~);
}
print $sub_head;

print "Rebuilding Categories $offset -> ", $offset + $limit - 1, ".\n\n";
for ($i = $offset; $i <= $offset + $limit -1; $i++) {
last unless ($category_list[$i] =~ /\w+/);
%category = ();
%subcategories = ();
@links = ();
@new_links = ();
@cool_links = ();
%stats = ();
$grand_total = 0;
my $t1 = time();

print "** Building Category: $category_list[$i] ... \n";
&build_single_category ($category_list[$i]);
print "** Done (", time - $t1, " s)!\n\n";
}
$offset = $offset + $limit;

my $elapsed = time() - $start;
print "------------------------------------------------\n";
print "This phase of step 2 took $elapsed seconds.\n\n";
($offset > $#categories) ?
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=3">Go on to Step 3!</A></B></FONT></P>~ :
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=2&limit=$limit&offset=$offset&auto=$auto">Next $limit Categories!</A></B></FONT></P>~;
last CASE;
};

($step == 3) and do {
print $header;
print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=4&auto=$auto">~ if ($auto);
print $sub_head;

if ($build_detailed) {
my $t1 = time();
print "Generating detailed view pages . . . \n";
&build_detailed_view;
print "** Done (", time - $t1, " s)!\n";
}
else {
print "Detailed Building is not turned on -- Skipping!\n\n";
}
my $elapsed = time() - $start;

print "------------------------------------------------\n";
print "Step 3 took $elapsed seconds.\n\n";
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=4&auto=1">Go on to Step 4!</A></B></FONT></P>~;
last CASE;
};

($step == 4) and do {
print $header, $sub_head;

my $t1 = time();
print "** Loading Category information . . .\n";
&build_category_information;
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Loading Summary information . . .\n";
&build_stats (1);
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Creating Home Page . . .\n";
&build_home_page;
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Creating What's New Pages . . .\n";
&build_new_page;
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Creating What's Cool Page. . .\n";
&build_cool_page;
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Creating Top Rated Page. . .\n";
&build_rate_page;
print "** Done (", time - $t1, " s)!\n\n";

my $elapsed = time() - $start;
print "------------------------------------------------\n";
print qq~Step 4 took $elapsed seconds.\n\n<b><a href="$build_root_url" target="_top">Your site</a> is now up to date!</b>~;
last CASE;
};

&cgierr("Unkown step: $step.");
};
}

sub build_all {
# --------------------------------------------------------
# Rebuild the entire directory.

# Determine if we are printing to command line, or to browser.
# $nph++;
&html_print_headers() if ($use_html);

my $start = time();
my $date = &get_date;
my $time = &get_time;

# Print HTML Header
$use_html ?
print qq|<html><head><tittle>Links Manager: Building Pages</title></head>
<BASE TARGET="_top">
<BODY BGCOLOR=#FFFFFF><H2><TT>Building Pages</TT></H2>
<PRE>| :
print qq|Building Pages\n|;
print "Pages built on " . $date . " at " . $time . "\n";
print "--------------------------------------------------------\n\n";

# Backup the database.
print "Backing up database . . .\n";
&build_backup;
print "Done.\n\n";

# Rebuild URL Index (This file is auto-generated, you will never need to touch it!
print "Building URL Index . . .\n";
&build_url_index;
print "Done.\n\n";

# Update New and Popular Records..
print "Updating New and Popular Records . . .\n";
&build_update_newpop;
print "Done.\n\n";

# Update voting information ..
print "Updating ratings .. \n";
&build_update_ratings;
print "Done.\n\n";

# Load Category Information
print "Loading Category Information . . .\n";
&build_category_information;
print "Done.\n\n";

# Generate some stats for future pages...
print "Gathering Category and Link information . . .\n";
&build_stats;
print "Done\n\n";

# Generate detailed view pages.
if ($build_detailed) {
print "Generating detailed view pages . . . \n";
&build_detailed_view;
print "Done\n\n";
}

# Create Home Page
$use_html ?
print qq|Building <A HREF="$build_root_url/$build_index">Home Pages</A> . . .\n| :
print qq|Building Home Page . . .\n|;
&build_home_page;
print "\tDone\n\n";

# Create What's New Page
$use_html ?
print "Building <A HREF=\"$build_new_url/$build_index\">What's New</A> Page . . .\n" :
print "Building What's New Page . . .\n";
&build_new_page;
print "Done\n\n";

# Create What's Cool Page
$use_html ?
print "Building <A HREF=\"$build_cool_url/$build_index\">What's Cool</A> Page . . .\n" :
print "Building What's Cool Page . . .\n";
&build_cool_page;
print "Done\n\n";

# Create Top Rated Page
$use_html ?
print "Building <A HREF=\"$build_ratings_url/$build_index\">Top Rated</A> Page . . .\n" :
print "Building Top Rated . . .\n";
&build_rate_page;
print "Done\n\n";

# Create Category Pages
print "Building Category Pages . . .\n";
&build_category_pages;
print "Done\n\n";

# We are finished!
print "Pages Built (", time() - $start, " s)!";
print "</PRE></BODY></HTML>" if ($use_html);
}

sub build_backup {
# --------------------------------------------------------
# Backs up important database files.
#
my $date = &get_date;
if (-e "$db_script_path/backup/$date.links.db") {
print "\tBackup exists for today.. Skipping\n";
return;
}

# Try to do it the right way..
eval { require File::Copy; };
if (!$@) {
print "\tBacking up links, category and email database (File::Copy) ... \n";
&File::Copy::copy ("$db_script_path/data/links.db", "$db_script_path/backup/$date.links.db") or &cgierr ("Unable to copy links backup. Reason: $!");
&File::Copy::copy ("$db_script_path/data/categories.db", "$db_script_path/backup/$date.category.db") or &cgierr ("Unable to copy category backup. Reason: $!");
&File::Copy::copy ("$db_script_path/data/email.db", "$db_script_path/backup/$date.email.db") or &cgierr ("Unable to copy email backup. Reason: $!");
}
# Otherwise, the ugly way.
else {
print "\tBacking up links, category and email database (Regular - $@) ... \n";
foreach (qw!links categories email!) {
open (TMP, "$db_script_path/data/$_.db") or &cgierr ("Unable to open $db_script_path/data/$_.db. Reason: $!");
open (TMPOUT, ">$db_script_path/backup/$date.$_.db") or &cgierr ("Unable to open $db_script_path/$date.$_.db. Reason: $!");
while (<TMP> ) {
print TMPOUT;
}
close TMP;
close TMPOUT;
}
}
}

sub build_url_index {
# --------------------------------------------------------
# This routine builds a quick URL lookup database so the script
# does not have to search the links.db for every hit.

my $time = time();
my @values = ();
my $count = 0;

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
open (URL, ">$db_url_name") or &cgierr("unable to open url index: $db_url_name. Reason: $!");
if ($db_use_flock) { flock (URL, 2) or &cgierr ("unable to get exclusive lock. Reason: $!"); }
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
print URL "$values[$db_key_pos]$db_delim$values[$db_url]\n";
$count++;
}
close DB;
close URL;

# Build the count file used to do random links.
open (CNT, ">$db_hits_path/index.count") or &cgierr("unable to open count file: '$db_hits_path/index.count'. Reason: $!");
if ($db_use_flock) { flock (CNT, 2) or &cgierr ("unable to get exclusive lock on $db_hits_path/index.count. Reason: $!"); }
print CNT $count;
close CNT;
}

sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.
#

# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
}
closedir HITS;

# Update the links database.
open (DB, "$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\tUpdating rating to $values[$db_rating] for link id $id\n";
}
print DBTMP &join_encode(&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB> ) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");
}
}

sub build_update_newpop {
# --------------------------------------------------------
# This routines updates the database, and marks new records new,
# old records old, popular records popular, and unpopular records,
# unpopular.

my ($id, %hits, @values, $days, @popular, $cutoff);

# Let's collect how many hits we've gotten.
opendir (HITS, $db_hits_path) or &cgierr ("unable to open hits directory: $db_hits_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_hits_path/$id") or &cgierr ("unable to open hit counter: $db_hits_path/$id. Reason: $!");
$hits{$id} = int <HIT>;
close HIT;
}
closedir HITS;

# Now go through the links database and update new links, and
# add the hits.
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$values[$db_modified] or print "Warning: No date for line: $_. Skipping..\n" and next LINE;

# Calculate days old and then mark new.
$days = &days_old($values[$db_modified], $date);
($days <= $db_new_cutoff) and ($new_records{$values[$db_key_pos]}++);

# Build an array of popular hits.
exists $hits{$id} ?
push (@popular, $values[$db_hits] + $hits{$id}) :
push (@popular, $values[$db_hits]);
}
close DB;

# Sort the popular list, and set the cutoff mark.
@popular = sort { $b <=> $a } @popular;
($db_popular_cutoff < 1) ?
($cutoff = $popular[int($db_popular_cutoff * $#popular)]) :
($cutoff = $popular[$db_popular_cutoff - 1]);
($cutoff < 2) and ($cutoff = 2);

# Display our cutoffs.
print "\tWhat's New Cutoff: $db_new_cutoff days\n";
print "\tPopular Cutoff: $cutoff hits\n";

# Now update the New and Cool tags on the links.
open (DB, "$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

# Store the new number of hits.
exists $hits{$id} and ($values[$db_hits] = $values[$db_hits] + $hits{$id});

# Check to see if the record is popular...
if ($values[$db_hits] >= $cutoff) {
print "\tUpdating record: $id, marking as popular ($values[$db_hits]).\n";
$values[$db_ispop] = "Yes";
}
else {
$values[$db_ispop] = "No";
}

# Check to see if the record is new...
if ($new_records{$id}) {
print "\tUpdating record: $id, marking as new.\n";
$values[$db_isnew] = "Yes";
}
else {
$values[$db_isnew] = "No";
}
print DBTMP &join_encode (&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB> ) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

# Finally, clean out the hits directory.
foreach (keys %hits) {
next unless /^\d+$/;
unlink ("$db_hits_path/$_") or &cgierr ("Can't remove hit file: '$db_hits_path/$_'. Reason: $!");
}
}

sub build_category_information {
# --------------------------------------------------------
# This routine loads the category information into memory and
# does some grouping.

my ($name, @values, @base, $base,);

open (DB, "<$db_category_name") or &cgierr("unable to open database: $db_category_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$name = $values[$db_main_category];

# We store the category information in a globally accessable hash %category, indexed by category name.
@{$category{$name}} = @values;

# We also initilize the days_old variable to Jan 1. 1990 so that if
# this category doesn't have any links, we still have a valid date
# for it.
$stats{$name}[1] = "1-Jan-1990";
$stats{$name}[0] = 0;

# We now figure out if this category is a subcategory of something,
# and if so, store it in the hash of arrays %subcategories.
(@base) = split (/\//, $name);
pop @base; $base = join ("/", @base);
if ($base) {
push (@{$subcategories{$base}}, $name);
}
}
close DB;
}

sub build_stats {
# --------------------------------------------------------
# This routine does a lot of the messy work. It builds globally accessible
# arrays of new_links and cool_links. It finds out how many links are in each
# category, and whether a category contains a new/modified link.

my (@values, $category, $cat, @alt_categories, @categorylist, $depth, $i, $cat);
my $staggered_mode = shift &#0124; &#0124; undef;

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$category = $values[$db_category];

# Add the link to the list of links.
push (@{$links{$category}}, @values) if (!$staggered_mode);
$grand_total++;

# Add the link to the alternate categories as well.
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
push (@{$links{$_}}, @values);
}
}

# Add the link to the list of new links if it is new.
push (@{$new_links{$category}}, @values) if ($values[$db_isnew] eq "Yes");

# Add the link to the list of cool links if it is popular.
push (@{$cool_links{$category}}, @values) if ($values[$db_ispop] eq "Yes");

# This adds one to the total of each category above the current category.
# We have to caluclate the affect of the link on each alt category as well as the main.
foreach $cat ($category, @alt_categories) {

# Calculate the stats: the number of links and the newest link.
@categorylist = split (/\//, $cat);
$depth = $#categorylist;

# This adds one to the total of each category above the current category,
# and also marks any above categories new, if this link is new.
for $i (0 .. $depth) {
$stats{$cat}[0]++;
if ((!$stats{$cat}[1]) &#0124; &#0124; &compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
pop (@categorylist);
$cat = join("/", @categorylist);
}
}
}
close DB;

# Now we have to sort the links and categories..
if (!$staggered_mode) {
foreach $link ( keys %links ) {
@{$links{$link}} = &build_sorthit (@{$links{$link}});
}
foreach $cat ( keys %subcategories ) {
@{$subcategories{$cat}} = sort @{$subcategories{$cat}};
}
}
$grand_total &#0124; &#0124;= 0;
}

sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_detail_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}

sub build_category_pages {
# --------------------------------------------------------
# This routine builds all the category pages. Each category uses
# the same template which is defined in &site_html_category.

my $build_single = shift;

my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks);
local ($category, $links, $title_linked, $title, $total, $category_name, $category_name_escaped);
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);

# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
next CATEGORY if ($build_single and ($build_single ne $cat));

$url = "$build_root_url/" . &urlencode($cat) . "/";
$use_html ?
print qq|Building Category: <A HREF="$url" TARGET="_blank">$cat</A>\n| :
print qq|Building Category: $cat\n|;
print "\tSubcategories: " . ($#{$subcategories{$cat}} + 1) . "\n";
print "\tLinks: " . (($#{$links{$cat}}+1) / ($#db_cols+1)) . "\n";

# Let's make sure the directory exists, build it if it doesn't.
$dir = &build_dir ($cat);
print "\tDirectory: $dir\n";
print "\tFilename : $dir/$build_index\n";

# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$ca
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Another note to look for in the above script.

$nph++;
you will see the above and it needs to be commented out, like below.

# $nph++;

Of course the script needs to be uploaded in to your host in ASCII mode and the file must chmod at 755, read your read me file about that.


Another Note:

Note the below that the

print "HTTP/1.1 200\n";

also needs to be commented out.

};
if ($@) {
print "HTTP/1.1 200\n";
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;


-------------------------------------------

and so it should look like this.


};
if ($@) {
# print "HTTP/1.1 200\n";
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;


That'd be it, hope this helps.


gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Hi gerardo,

Thank you very much Smile it is working fine now. what about your new post here and having some problem with "Buil All" it makes me worry, I hope it is not becuase of teh changes you made in nph-buil.cgi?

Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Don't know as it works fine now. What happened to me yesterday could of been because I was not working on my own computer, but the one I have at work? They build fine now, don't really know what happened.

It could also be the server we're on, so I suggest building slowly and back up everything just in case.

All the best Gerardo.

I don't know if I am going to continue doing what I am doing as I am an actor and I need to get back to what I love and get away from the internet and so I may be closing paaw.com even though the affiliates make some money.

I just cant be involved with to many tech problems. Best Of Luck

Gerardo
Quote Reply
Re: cgiwrap error and I need advice, help Thanks In reply to
Here is what the links.cfg should look like on interspeed servers:

# PATH and URL of Admin CGI directory. No Trailing Slash.
$db_script_path = "/usr/local/www/htdocs/USERNAME/cgi-bin/links/admin";
$db_dir_url = "http://www.URL.com/cgi-bin/cgiwrap/USERNAME/links/admin";

# URL of User CGI directory. No Trailing Slash.
$db_cgi_url = "http://www.URL.com/cgi-bin/cgiwrap/USERNAME/links";

# PATH and URL of Pages to be built. No Trailing Slash.
$build_root_path = "/usr/local/www/htdocs/USERNAME/links";
$build_root_url = "http://www.URL.com/links";

Use the above format and follow the other suggestions listed in this post and you'll be set!

Good luck!

------------------
CGI Script Installation Center
http://cgi.defend.net