#!/usr/bin/perl
# $| = 1;
#-----------------------
# set up
print "Content-type: text/html\r\n\r\n";
my $uri = $ENV{'REQUEST_URI'};
my $host = $ENV{'HTTP_HOST'};
my @key = ();
my $this_program = "business.small";
my $articledir = "/home/loopbiz/public_html/bizarticles";
my $logfile = "/home/loopbiz/public_html/logs/business.html";
my $showgoogle = 1;
$showgoogle = 0 if($uri =~ /link-to-us/);
$uri =~ s/^\///g;
$uri =~ s/$this_program//;
$uri = "small_business.html" if($uri =~ /index.htm[l]?/);
$uri =~ s/-/_/g;
my $urifile = $articledir . "/" . $uri;
$urifile =~ s/\.html/\.art/;
$urifile = $articledir . "/small_business.art" if($urifile !~ /\.art$/);
my $hosturl = "http://" . $host;
$urifile =~ s/\/\//\//g; # change any double slashes to a single
$uri =~ s/^\///g; # zap any leading slash
my $pageurl = $hosturl . "/" . $uri;
#-----------------------
# If not loopbiz, just go to the index page
if($host !~ /loopbiz.com/)
{
$hosturl = "http://" . $host;
print "The page $pageurl
seems to be missing please go back to the home page
http://$host.";
}
else
{
$keys = $uri;
$keys =~ s#\.html##;
$keys =~ s#/([^\.]+)#$1#;
$bannertarget = "http://loopbiz.com/businessbuilder.html";
$bannerimage = "http://loopbiz.com/images/strategic_planning.jpg";
$bannerimage = "http://loopbiz.com/images/business_tool.jpg" if($urifile =~ /tool/);
$sponsorad = "
";
$skyscraper = "
";
$topad = "
";
$ad120x240 = "
";
$topad = "" unless $showgoogle;
$articlepermission = "
You may copy this article and place it on your own website, as long as you do not change it and include this resource box including the live link to the Loopbiz.com Small Business Strategy site.
Copyright © 2004-2018 http://loopbiz.com/
";
## Loopbiz.com provides small business resources. You may use our articles on your website, with permission. Visit us at Small Business Resources
(@key) = split(/[_\-]/,$keys);
$pagetemplate = "./bizarticles/business_shell";
$toptemplate = "./stuff.top";
$allkeys = join(" ",@key);
my $capallkeys = "\u$allkeys";
open(PAGE, $pagetemplate);
@lines = ;
close(PAGE);
if( -f $urifile)
{
open(PAGE, $urifile);
@slines = ;
close(PAGE);
$story = join(' ',@slines);
$story =~ s/XX-PERMISSION-XX/$articlepermission/;
$story =~ s/\n \n/\n\n/g;
if($bottemplate)
{
open(PAGE, $bottemplate);
@blines = ;
close(PAGE);
$botinfo = @blines;
}
}
foreach (@lines)
{
s/XX-ADTOP-XX/$topad/g if(/XX-ADTOP-XX/);
s/XX-AD120x240-XX/$ad120x240/g if(/XX-AD120x240-XX/);
s/XX-ADSKYSCRAPER-XX/$skyscraper/g if(/XX-ADSKYSCRAPER-XX/);
s/XX-SITEURL-XX/$hosturl/g if(/XX-SITEURL-XX/);
s/XX-PAGENAME-XX/$uri/g if(/XX-PAGENAME-XX/);
s/XX-PAGEURL-XX/$pageurl/g if(/XX-PAGEURL-XX/);
s/XX-STORY-XX/$story/g if(/XX-STORY-XX/);
s/XX-BOTINFO-XX/$botinfo/g if(/XX-BOTINFO-XX/);
s/XX-TOPINFO-XX/$topinfo/g if(/XX-TOPINFO-XX/);
s/XX-KEYS-XX/$allkeys/g if(/XX-KEYS-XX/);
s/XX-CAPKEYS-XX/$capallkeys/g if(/XX-CAPKEYS-XX/);
# s/XX-ADSENSE-XX/$adsense/g if(/XX-ADSENSE-XX/);
s/XX-SPONSORAD-XX/$sponsorad/g if(/XX-SPONSORAD-XX/);
print $_;
}
}
# foreach $e (keys %ENV)
# {
# $env = $env . $e . " = " . $ENV{$e} . "\n";
# }
# $env = "\n$ENV{REMOTE_ADDR}\t$ENV{DATE_LOCAL}\n$ENV{HTTP_USER_AGENT}\n$ENV{HTTP_REFERER}\n=====\n";
&logit("$ENV{DATE_LOCAL}\t$uri\t$ENV{HTTP_REFERER}\t$ENV{REMOTE_ADDR}\n",$logfile);
sub expandkeys
{
my(@keys) = @_;
my($klist) = '';
my($count) = $#keys + 1;
}
sub logit
{
my($message,$logfile) = @_;
return if(!$message);
open(LOG, ">>$logfile") || return();
flock(LOG,2);
# reposition pointer to append
seek(LOG,2,0);
chomp($message);
print(LOG $message,"\n");
close(LOG);
}