Links Resource
A How-To Guide and knowledge base for Gossamer Threads' Links2 script.


Links Resource
Due to other obligations, and lack of feedback or support about this effort, it has been discontinued. I will leave this page up, but will be adding no others in the forseeable future...

Edit variables in links.cfg

This file tells the program where it is, where all of the other files it needs are located, and what your build preferences are. In the code below, the parts you (may) need to configure are highlighted in red.

PATHs and URLs

It is important to be sure that you enter all information correctly. You need to know the difference between your system PATH and site URL:

  1. PATH is internal to the server; you should have received this information from your web-host when you signed up with them. Example: /path/to/mysite/cgi-bin/links/admin
  2. URL (Uniform Resource Locator) is the internet address you use to access your site. Example: http://www.mysite.com/cgi-bin/links

To help you enter the correct data, a free script is available from Dot Matrix. Just upload it to the same location you installed Links2, and run it; the output will tell you most everything you need to know.

The PATHs and URLs shown are example cases only! Also, do NOT put a trailing slash (/) at the end.

$db_script_path
$db_dir_url
Set these to point to your admin directory. Most common would be like /path/to/mysite/cgi-bin/links/admin and http://www.mysite.com/cgi-bin/links/admin but you can change this. Putting Links into a directory named "links" (or...) makes organizing the files easier.

$db_cgi_url
This is the URL of the publicly-accessible cgi scripts, including search.cgi, add.cgi, and others. This normally looks like http://www.mysite.com/cgi-bin/links.

$build_root_path
$build_root_url
Set these to point to where your static (.html) pages will be kept. The PATH will be determined by your host (server), but will look similar to /path/to/mysite/public/links/pages. Your host may use 'public', 'www', 'html', 'docs', or something else. The URL should look like http://www.mysite.com/links/pages or similar. You do not HAVE to use the /links/pages naming, it can be whatever you like.

$build_new_path
$build_new_url

$build_cool_path
$build_cool_url

$build_ratings_path
$build_ratings_url
These three (six) settings are normally based on the PATH and URL you defined above; they take that information and add a directory name onto the end. You normally do not need to change these. Note that the directory names are capitalized (New, Cool, Ratings). Making them lowercase will cause an error, unless you make changes in several places in the program.

#               -------------
#                   Links
#               -------------
#               Links Manager
#
#         File: links.cfg
#  Description: Contains all the setup variables.
#       Author: Alex Krohn
#        Email: alex@gossamer-threads.com
#          Web: http://www.gossamer-threads.com/
#      Version: 2.01
#
# (c) 1998 Gossamer Threads Inc. 
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use. 
# =====================================================================

# Paths and URL's to Important Stuff
# --------------------------------------------------------
# PATH and URL of Admin CGI directory. No Trailing Slash.    
    $db_script_path   = "/alex/links/cgi-bin/admin";
    $db_dir_url       = "http://localhost/links/cgi-bin/admin";
    
# URL of User CGI directory. No Trailing Slash.
    $db_cgi_url       = "http://localhost/links/cgi-bin";
    
# PATH and URL of Pages to be built. No Trailing Slash.         
    $build_root_path  = "/alex/links/pages";
    $build_root_url   = "http://localhost/links/pages";    
    
# PATH and URL of What's New page. No Trailing slash.
    $build_new_path   = "$build_root_path/New";
    $build_new_url    = "$build_root_url/New";

# PATH and URL of What's Cool page. No Trailing slash.  
    $build_cool_path  = "$build_root_path/Cool";
    $build_cool_url   = "$build_root_url/Cool";    

# PATH and URL of What's Rating page. No Trailing slash.  
    $build_ratings_path  = "$build_root_path/Ratings";
    $build_ratings_url   = "$build_root_url/Ratings"; 


Database Options
$db_use_flock
File Lock. Flock should be used primarily for writing or updating database files. If you are using Links under Windows (set up under Active State Perl on your home computer, for example), set this to '0'. If it still causes problems, comment it out (#).

$db_nocache
Default setting ('0') will cache (store) pages in the viewers' browser, which makes them load faster when re-visited. Setting to '1' will force a "refresh" for each page visit.

$db_iis
Working on a good explanation...


$db_main_category
The default setup in category.def puts the category name in the '1' position. Unless you make major changes to the script, leave this as is.

@db_referers
If you enter your sites' URL and/or IP address ("http://mysite.com","http://www.mysite.com","12.345.678"), then the add.cgi can only be accessed by using a link from your site (Add A Resource); it will no longer function by going directly to it, as in pointing your browser to http://mysite.com/cgi-bin/links/add.cgi. Using @db_referers will reduce the chances of your site being besieged by mass-submissions (spam). Note that each entry between the (parenthesis) is contained by "double quote" marks, and seperated by commas. Also, enter all URLs that apply to your site, with and without the 'www'. If you have a static IP address, you can use it, too.

          
# Database Options  
# --------------------------------------------------------
# You really need to use flock(). However if your system doesn't support it (Win95),
# then turn this off at your own risk!
    $db_use_flock        = 1;
# Use Pragma: no-cache to stop browsers from caching output? (0 = cache, 1 = nocache)
    $db_nocache          = 0;
# Use IIS headers? Set this to 1 if your web server needs the full headers (HTTP/1.0 etc.)
    $db_iis              = 0;
# Field number of category in category.db
    $db_main_category    = 1;
# Referers -- which hosts are allowed to add to your database.
    @db_referers = ();
 


E-mail Options
$db_mail_path
To use sendmail, set this to the location provided by your host. This should be one of the following: /usr/sbin/sendmail, /lib/sendmail, or /bin/sendmail.

$db_smtp_server
To use SMTP (Secure Mail Transfer Protocol), set this to the location of your mail server. Generally mail.mysite.com.

$db_admin_email
Set to the primary e-mail account for your URL, such as contact@mysite.com. If this is not set, you will not receive any messages from Links (eg: when someone adds a site).

$db_email_add
When a person adds their link using add.cgi, upon addition (validation) to the database you can tell Links to send an approval message to the person who submitted it. By default, they will NOT receive a message. This email notice is defined in "e-mail_add.txt" using templates.

$db_email_modify
Like above, but when activated notifies a person when their link is modified.

$db_mailer_log
You can keep a record of all messages Links sends. You will need to create the file (mailer_log.db)in the /data directory. Enter the full PATH to the database here, like: /path/to/mysite/cgi-bin/links/admin/data/. Not recommended due to disk space usage.
 
# Email Options
# --------------------------------------------------------
# NOTE: Be sure to edit the text of the message. It can be found
# in the templates directory: email-add.txt, email-del.txt and
# email-mod.txt respectively.

# Set only ONE of either $db_mail_path which should go to a 
# mail program like sendmail, or $db_smtp_server which will use
# a SMTP server. Do not set both at once!

# PATH of sendmail.                 # SMTP Server
    $db_mail_path     = '';         $db_smtp_server  = '';
    
# Email address of the administrator. BE SURE TO SET! 
    $db_admin_email   = '';

# Notify visitors automatically when their links are validated?
    $db_email_add     = 0;

# Notify visitors automatically when their links are modified?
    $db_email_modify  = 0;
    
# Log all outgoing messages? Put the full path to a logfile and make sure it
# exists and is writeable (chmod 666 -rw-rw-rw-). This logfile can get pretty
# big!
    $db_mailer_log     = '';    


Build Options
$db_popular_cutoff
Popular cutoff is the setting for a relative number of links to show on the What's Popular (Cool) page. If you want to display an absolute number of links (eg: 10, instead of 3%), you will need to use a code modification.

$db_new_cutoff
New cutoff determines how long (in days) a link will appear on the What's New page.

$search_bold
Leave at '1' to have words that match search terms show in bold text in the search results .

$build_index
Every directory that Links creates will contain an 'index' page.

The most comon name for an index file is index.html; others are home.html and main.html. Best to leave as is.
$build_extension
What goes after the dot. By default Links builds static pages, so .html is normally used. An older form is .htm, and depending on what changes you make to the program, you might use .shtml. For starters, leave as .html.

$db_single_category
By default, if a person browsing your pages decides to click the 'Add Resource' link while looking category-3, subcategory-D, Links will automatically select that (sub)category to place their submission into. The (sub)category will display on the 'Add Resource' page, with no option to change. Set this to '0' and instead of the (sub)category being entered, there will be a drop-down selection box that the visitor can use to select which (sub)category to add their site to.

$build_dir_per
This is one of those real technical things, and can have a major impact on your ability to make changes (delete directories) on your server. Leave this set to 777 unless you really know what you're doing.

$build_span_pages
One of the real handy features in Links is the ability to automatically create pages that are linked to each other (next/previous). Leave this at '1' to maintain this function.

$build_links_per_page
Tell the program how many links to put on a page before spanning to another page (assuming build_span_pages is set to '1').

$build_detailed
Turning this on ('1') will create an additional page for each link. The new pages will be built in a directory named 'Detailed' that will be created in the location you define here. The default location is in the directory that the category pages go in. In order to access these static Detailed Pages, you will need to add a link to them in the link.html template. It should look like so: <a href="/$build_root_url/Detailed/<%ID%>.html">Detailed Page</a>.

$build_use_templates
For most users, and especially beginners, using templates will be much easier to learn. Also, when you decide to make changes to the script, there are more mods abvailable for template-based use. The alternative (when set to '0') is to use the site_html.pl file, which contains the same information as the templates, but puts it all into one file.

$build_site_title
Enter the name that will appear on the Top Page, and also in the title bar at the top of the browser.


# Build Options
# --------------------------------------------------------
# Setting for popular cutoff, can either be a percent (i.e. top 3%), or
# a fixed value (i.e. top 10). Enter 0.03 or 10 respectively.
    $db_popular_cutoff  = 0.03;  # Top 3%
# Number of days a link is considered New.  
    $db_new_cutoff      = 14;    # 14 days old.
# Return search results bolded (1 = yes, 0 = no).
    $search_bold        = 1;
# The name of an index file.
    $build_index        = "index.html";
# The extension to use for non index files:
    $build_extension    = ".html";
    
# Should your add.cgi automatically select what category the user
# is adding his link into?
    $db_single_category = 1;

# Directory Permissions. Do NOT put quotes around it. Set to 0777 
# for world writeable. If you put this at 0755, you might need a 
# script to remove any directories created as they will be owned 
# by the web server or user nobody. Better solution might be to 
# run the nph-build routine from the command shell.
    $build_dir_per      = 0777;

# The script can now break up category pages that have more then x
# number of links in it. It will also create next and previous links
# to help navigate. Set this to 1 if you want to break up pages or 0 if
# you want to have only one page per category.
# Setting this to one, will also break up the What's New pages into
# per day sections (not affected by number of links per page).
    $build_span_pages     = 1;

# Number of links per page.
    $build_links_per_page = 10;

# Detailed View: The script can build a single html page per link. This is 
# great if you have a review in your database. To enable, you must set
# the directory where all the pages will be stored, the url to that directory
# and set the enable option.
    $build_detailed    = 0;
    $build_detail_path = "$build_root_path/Detailed";
    $build_detail_url  = "$build_root_url/Detailed";

# Use Templates: instead of editing site_html.pl, you can edit regular html pages
# encoded with special <%links_tags%>. It's not as flexible as site_html.pl, but it 
# may be easier. 
    $build_use_templates = 1;
        
# Site Title, the default title to use. You should really spend some time customizing
# the directory though!
    $build_site_title = 'Gossamer Threads Links';


Time & Path Settings

Do not make any changes below here unless you know what you are doing, or you are following the installation instructions of a mod(ification). If you are going to make changes, it's a good idea to make a backup copy of the file, first.

# Date Routines
# --------------------------------------------------------
# Your date format can be whatever you like, as long as the following
# two functions are defined &date_to_unix and &unix_to_date:
# The default is dd-mmm-yyyy.

sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about.. 
#     timelocal does not like to be in array context, don't do my($time) = timelocal (..)
#     int your values just in case to remove spaces, etc.
#     catch the fatal error timelocal will generate if you have a bad date..
#     don't forget that the month is indexed from 0!
#
    my $date = shift; my $i;
    my %months = map { $_ => $i++ } qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
    my ($day, $mon, $year) = split(/-/, $date);
    
    exists $months{$mon} or return undef; 
    $day = int($day); $year = $year - 1900;
    
    require Time::Local;
    my $time = 0;
    eval {
        $time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year);
    };
    if ($@) { die "invalid date format: $date - parsed as (day: $day, month: $months{$mon}, year: $year). Reason: $@";  } 
    return $time;
}

sub unix_to_date {
# --------------------------------------------------------
# This routine must take a unix time and return your date format
# A much simpler routine, just make sure your format isn't so complex that
# you can't get it back into unix time.
#
    my $time   = shift;
    my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
    my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
    $year      = $year + 1900;    
    return "$day-$months[$mon]-$year";
}

sub long_date {
# --------------------------------------------------------
# This routine is for printing a nicer date format on the what's new page. It should 
# take in a date in your current format and return a new one.
    my $time   = shift;
    $time      = &date_to_unix ($time);
    my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
    my @months = qw!January February March April May June July August September October November December!;
    my @days   = qw!Sunday Monday Tuesday Wednesday Thursday Friday Saturday!;
    $year      = $year + 1900;  
    return "$days[$dweek], $months[$mon] $day $year";
}   

# -------------------------------------------------------------
# Extra Paths -- unless you feel the need to rename files, you
# can leave this as is.
# -------------------------------------------------------------
    $db_script_url     = $db_dir_url . "/admin.cgi";        # Admin script.
    $db_header_path    = $db_script_path . "/header";       # Place to store header and footers.
    $db_footer_path    = $db_script_path . "/footer";       
    $build_search_url  = $db_cgi_url . "/search.cgi";       # URL of search script.
    $build_add_url     = $db_cgi_url . "/add.cgi";          # URL of add script.
    $build_modify_url  = $db_cgi_url . "/modify.cgi";       # URL of modify script.
    $build_jump_url    = $db_cgi_url . "/jump.cgi";         # URL of jump script.
    $build_email_url   = $db_cgi_url . "/subscribe.cgi";    # URL of email update script.
    $build_rate_url    = $db_cgi_url . "/rate.cgi";         # URL of rate script.
    $db_mail_url       = $db_dir_url . "/nph-email.cgi";    # URL of admin mass mail script.
    $build_css_url     = $build_root_url . "/links.css";    # URL to your CSS file.
    
    $db_lib_path              = $db_script_path;                            # PATH of library files.
    $db_links_name            = "$db_script_path/data/links.db";            # PATH to links database.
    $db_category_name         = "$db_script_path/data/categories.db";       # PATH to category database.
    $db_valid_name            = "$db_script_path/data/validate.db";         # PATH to validation database.
    $db_modified_name         = "$db_script_path/data/modified.db";         # PATH to modification database.
    $db_url_name              = "$db_script_path/data/url.db";              # PATH to URL lookup database.
    $db_email_name            = "$db_script_path/data/email.db";            # PATH to email database.
    $db_links_id_file_name    = "$db_script_path/data/linksid.txt";         # PATH to links counter file.
    $db_category_id_file_name = "$db_script_path/data/categoryid.txt";      # PATH to category counter file.
    $db_hits_path             = "$db_script_path/data/hits";                # PATH to hits directory.
    $db_template_path         = "$db_script_path/templates";                # PATH to templates.
    $db_rates_path            = "$db_script_path/data/rates";               # PATH to ratings.
1;
Updated: Oct 13, 2003 Links Engine Powered By Gossamer Threads http://linksresource.com contact@linksresource.com