In nph-buil.cgi the following editing is necessary:
Color coded in build staggered UNCOMMENT all lines as shown in this color
color coded in build all UNCOMMENT all lines in this color
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'} || 10;
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);
}
In links.def remove the lines in this color
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, 'name', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, 'a@a.com', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
);
Do not copy and paste the changes in links.def as shown above as your settings and numbers are most likely different then the ones i used here, just remove the 4 lines in your script by hand.
Don't forget to CHMOD both files afterwards in 755!
What it will do:
When you have removed the 3 folders "cool" "new" "rating" (you can of course also keep any one of them and in that case you just uncomment or dlete the appropriate portions in the 2 scripts above only) out of your main dir completely hit "build" or "build staggered" (or auto staggered) and you'll notice that the usual rundown of "new" and such stuff is no longer taking up time, script runs straight and quick through step 1.
Once finished with building check back into your main dir, the 3 folders will no longer be installed there by Links which will save you disk space or time to clean those 3 folders out of old crap.
Now some help for me please nayone????
i want to find out how to do a similar thing to the BACKUP!!!
I want Links2 to build only one backup at the time and delete any older ones as it builds a new new during any build process.
There has been a mod postet that promised to do just that, but it didn't work!
Any corrections to that one or a better one or just some new hints please.
Color coded in build staggered UNCOMMENT all lines as shown in this color
color coded in build all UNCOMMENT all lines in this color
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'} || 10;
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);
}
In links.def remove the lines in this color
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, 'name', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, 'a@a.com', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
);
Do not copy and paste the changes in links.def as shown above as your settings and numbers are most likely different then the ones i used here, just remove the 4 lines in your script by hand.
Don't forget to CHMOD both files afterwards in 755!
What it will do:
When you have removed the 3 folders "cool" "new" "rating" (you can of course also keep any one of them and in that case you just uncomment or dlete the appropriate portions in the 2 scripts above only) out of your main dir completely hit "build" or "build staggered" (or auto staggered) and you'll notice that the usual rundown of "new" and such stuff is no longer taking up time, script runs straight and quick through step 1.
Once finished with building check back into your main dir, the 3 folders will no longer be installed there by Links which will save you disk space or time to clean those 3 folders out of old crap.
Now some help for me please nayone????
i want to find out how to do a similar thing to the BACKUP!!!
I want Links2 to build only one backup at the time and delete any older ones as it builds a new new during any build process.
There has been a mod postet that promised to do just that, but it didn't work!
Any corrections to that one or a better one or just some new hints please.