Gossamer Forum
Home : Products : Links 2.0 : Customization :

AltCategories problem

Quote Reply
AltCategories problem
I added AltCategories to a database and ran into a little problem....I also have the 3-levels of new mod and it seems to have thrown everything out of wack because when I go to look at the links, fields are coming up in the wrong place...ie: Contact name is now in description, email in contact name, etc, etc. Any suggestion how to easily repair this?

Quote Reply
Post deleted by rayhne In reply to
Quote Reply
Re: AltCategories problem In reply to
YEA...because you have the WRONG PATH references in the following codes:

Code:

require "http://www.fanficweb.net/cgi-bin/saabdir/admin/db_utils.pl";

require "http://www.fanficweb.net/cgi-bin/saabdir/admin/links.def";


Let's see...you must've used ABSOLUTE PATHS in your admin.cgi and other .cgi scripts, NOT RELATIVE URL PATHS, so what you makes you think that this particular script is different????

REPLACE the above codes with something like the following:

Code:

require "/absolute/full/path/to/cgi-bin/saabdir/admin/db_utils.pl";
require "/absolute/full/path/to/cgi-bin/saabdir/admin/links.def";


Next time, read the MOD/HACK instructions more carefully.

bye...

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
As surprising as this may sound, I did read the instructions and even followed them. My addfields.cgi looks like this now...

#You must EDIT YOUR links.def script BEFORE entering these variable and running this script!
$field_default = ""; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "5"; #Put the new field number here.
$total_fields = "15"; #Put the last field number here.
#Change these value to match your settings
require "/home/sites/site86/web/cgi-bin/saabdir/admin/db_utils.pl";
require "/home/sites/site86/web/cgi-bin/saabdir/admin/links.def";

And it still isn't working.

Quote Reply
Re: AltCategories problem In reply to
What I'm getting is an internal error

The server encountered an internal error or misconfiguration and was unable to complete your request.

I followed the instructions for both the Multiple Categories and addfields.cgi...the only chagne I made was in the nph-build.cgi for the 3-levels of new.

Quote Reply
Re: AltCategories problem In reply to
1) Did you chmod 755 the addfields.cgi script?
2) Did you put the appropriate PERL PATH in the first line of the script?
3) Are you running this script in the data folder?

If you answered yes to ALL the above questions, then type in the following command line:

Code:

perl -c addfields.cgi


to check the syntax.

Then post the syntax errors if any...

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
How to I use perl -c addfields.cgi?

Quote Reply
Re: AltCategories problem In reply to
(like mentioned in quite a few threads in the support forums...)

perl -c

1) Open telnet.
2) Access your account via telnet.
3) Connect to the folder where addfields.cgi is located:

Code:

cd /cgi-bin/links/


(although you should move the addfields.cgi script into the data folder as I already mentioned.)

4) Then check the syntax:

Code:

perl -c addfields.cgi


Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
I don't use telenet...I go through WS-FTP...and addfields.cgi is in the data folder. Has been since I started this.

Quote Reply
Re: AltCategories problem In reply to
You can run the command through WS_FTP as well...in the command line option....

Make sure you have done the following (again):

1) The permission of the file is set to 755.
2) Make sure you are using the correct Perl path.
3) Make sure that you uploaded the file in ASCII mode.

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
Nice point there about telnet etc.
I also don't have telnet access and basically having the same problem.

Can you do the command line thing with CuteFTP does anyone know and if so how...

Stu2000 - The Ultimate World
http://www.world-porn.org/worldhackerz/
Quote Reply
Re: AltCategories problem In reply to
Okay, here's a stupid question....what's suppose to happen when I enter perl -c addfields.cgi into the command line. All that happen was all the files name dissappear, though a refresh brought them back.

Quote Reply
Re: AltCategories problem In reply to
Typically, an error message will appear...

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
Okay...let's try this...where is the command line on WS-FPT?

Quote Reply
Re: AltCategories problem In reply to
Lets try this...this is what I have (mods already in use are: Horizontal Categories, Deadlink mailer2, 3 levels of new graphics/updated):

In links.def, I put:

# 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|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
AltCategories => [5, 'alpha', 0, 500, 0, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [7, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [8, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [9, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [10, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [11, 'alpha', 0, 5, 0, 'No', ''],
Rating => [12, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [13, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [14, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
DateAdded => [15, 'date', 15, 15, 0, \&get_date, '']
);

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_alt = 5;
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 9; $db_isnew = 10; $db_ispop = 11;
$db_contact_name = 7; $db_contact_email = 8; $db_title = 1;
$db_votes = 13; $db_rating = 12; $db_mail = 14;
$db_dateadded = 15;

# Field names you want to allow visitors to search on:
@search_fields = (1,2,6);

In nph-build.cgi, I put:

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, %unique_categories);
my $staggered_mode = shift || 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.
%unique_categories = "";
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) {
if (! defined ($unique_categories{$cat})) {
$unique_categories{$cat} += 1;
$stats{$cat}[0]++;
}
# Store the most recent modification date for links in this category.
if ((!$stats{$cat}[1]) ||
&compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
# Store the most recent add date for links in this category.
if ((!$stats{$cat}[2]) ||
&compare_dates($values[$db_dateadded], $stats{$cat}[2])) {
$stats{$cat}[2] = $values[$db_dateadded];
}
# Is (modified) Date more recent than DateAdded?
if (&compare_dates($stats{$cat}[1], $stats{$cat}[2])) {
# Yes, so does it qualify as an "updated" link?
if (&days_old($stats{$cat}[1]) <= $db_new_cutoff) {
# Yes, so set updated link flag for this category.
$stats{$cat}[3] = "Yes";
}
}
# Is this a new link?
if (&days_old($stats{$cat}[2]) <= $db_new_cutoff) {
# Yes, so set new link flag for this category.
$stats{$cat}[4] = "Yes";
}
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 ||= 0;
}

In db_utils.pl, I put:

sub build_html_record_form {
#--------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_;
$output = "<p><table border=1>";
# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
($db_select_fields{$db_cols[$db_alt]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
}
foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=5") . "</td></tr>\n";}
elsif ($db_select_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~;}
elsif ($db_form_len{$field} == -1) {$output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
else {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~;}
}
$output .= "</table></p>\n";
return $output;
}

And my addfields.cgi looks like:

#!/usr/bin/perl
# -------------------------------------------
#You must EDIT YOUR links.def script BEFORE entering these variable and running this script!
$field_default = "5"; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "5"; #Put the new field number here.
$total_fields = "16"; #Put the last field number here.
#Change these value to match your settings
require "/home/sites/site86/web/cgi-bin/saabdir/admin/db_utils.pl";
require "/home/sites/site86/web/cgi-bin/saabdir/admin/links.def";

#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;

$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "<LINKS.DB") exit;print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or print "Unable to open output database. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit;
print "\n\n\tProcessing records\n";
while ( ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy ID, Title, URL, Date and Category
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old links.db to new links2.db
for $i ($new_field .. $total_fields) {
$rec_out[$i + 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.\n\n";



Quote Reply
Re: AltCategories problem In reply to
WHY did you re-post your CODES??? Not necessary!

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
I don't know...desperation maybe? Actually, I thought maybe some might spot an error that I couldn't see.

Quote Reply
Re: AltCategories problem In reply to
Doesn't answer my question, why you would post the codes TWICE in the forum? Please delete the second set of codes, thank you...

Regards,

Eliot Lee
Quote Reply
Re: AltCategories problem In reply to
I deleted the first version...the second had more of the details.

Quote Reply
Re: AltCategories problem In reply to
Finally got this working by simply offline editing the links.db files. Well worth the hassle though. :) Thanks for your patience, Anthro. (hope you got lots of it because I doubt this'll be the last time I panick...:P)