Code Library
Home Submit Free Hosting Link To Us Contacts

CGI Add free links

CGI Add free links CGI CGI Add free links Download (.zip)



#! /usr/bin/perl
# Add Link v 1.1 
#-----------------------------
# Installation:
#-----------------------------
# 1: change the settings below to what your settings are!!!        
# 2: Copy this file link.pl to your cgi-bin
# 3: Copy the links.html to a separate directory
#        eg /links/
# 4: chmod links.pl to 755
# 5: chmod links.html to 777
# 6: chmod /links/ to 777
# 7: change all of the settings below to your servers settings
# 8: make sure to set links.html to call link.pl

# UNIX PATH TO directory.html

$file = "/links.html";

# URL TO directory.html

$gto = "http://127.0.0.1/links.html";

# ADD LINKS TO TOP OR BOTTOM (1 = top   2 = bottom)

$top = "1";

# Get the input data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Parse the data
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
              ($name, $value) = split(/=/, $pair);

        # get rid of the % encoding
              $value =~ tr/+/ /;
              $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
              $name =~ tr/+/ /;
              $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
              $value =~ s/<!--(.|\n)*-->//g;
        
        if(! $allow_html) {
                      $value =~ s/<([^>]|\n)*>//g;
        }

              $FORM{$name} = $value;
}

open(FILES, "$file") || die "Can't open FILE: $file\n";
@files =<FILES>;
close(FILES);

open(FILES, ">$file") || die "Can't open FILE: $file\n";
foreach $line (@files) {
        if($line =~ /<!--Begin Directory-->/i) {
                if($top) {
                        print FILES "<!--Begin Directory-->\n";
                }
                
                print FILES "<br><li><a href=$FORM{'url'}>$FORM{'name'}</a>\n";                

                if(! $top) {
                        print FILES "<!--Begin Directory-->\n";
                }
        }
        else {
                print FILES "$line";
        }
}
close(FILES);

print "Location: $gto\n\n";




  • CGIAdd free links


Tatet