403Webshell
Server IP : 208.122.213.31  /  Your IP : 216.73.216.185
Web Server : Apache
System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64
User : WHMCS_MIA_382 ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/httpd/html/baberankings.com.bak/cgi-bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/httpd/html/baberankings.com.bak/cgi-bin/showsell.pl
#! /usr/bin/perl
################################################################################
#                                                                              #
# Application : Show And Sell                                                  #
# Description : Random Advert Display Application                              #
# Version : 1.07                                                               #
# Created : 22nd September 1998 by Steve                                       #
# Last Updated : 19th October 1998                                             #
#                                                                              #
# Copyright (c) 1998 Purely By Magic. All rights reserved.                     #
# WWW    : http://www.geocites.com/purelybymagic/                              #
# Email  : purelybymagic@yahoo.co.uk                                           #
#                                                                              #
################################################################################
#                                                                              #
# Version History                                                              #
#                                                                              #
# 22/09/98 : 1.00 : Script Created                                     : steve #
# 28/09/98 : 1.01 : Added Display Of Advert Statistics                 : steve #
# 30/09/98 : 1.02 : Non-SSI Version Now Implemented                    : steve #
# 04/10/98 : 1.03 : Added The Code Generation Routine                  : steve #
# 08/10/98 : 1.04 : Now Deletes Tracking Record For Non-SSI Users      : steve #
# 10/10/98 : 1.05 : Multi-User Support Now Implemented                 : steve #
# 18/10/98 : 1.06 : Expiration Header Added To Non-SSI Version         : steve #
# 19/10/98 : 1.07 : Non-SSI Version Now Redirects To Image             : steve #
#                                                                              #
################################################################################
#                                                                              #
# Conditions for use of this application                                       #
#                                                                              #
# This application is free software and can be redistributed and/or modified   #
# if the following conditions are met:                                         #
#                                                                              #
# a) This copyright notice and the header are neither modified or removed      #
# b) The application is not sold to a third party                              #
# c) The application is not used for financial gain                            #
#                                                                              #
# This application is distributed in the hope that it will be useful           #
# but without any warranty. The use of this application removes any liability  #
# from Purely By Magic and it's employees, that may arise from the             #
# installation, implementation, modification and/or its use.                   #
#                                                                              #
################################################################################
#
# Include Section
# ===============
#
# Include The Standard Routines Into The Application
#
require "pbmmain.pl";
require "pbmscreen.pl";
require "pbmdata.pl";
#
################################################################################
#
# User Variable Section
# =====================
#
# You Will Be Required To Modify The Values Of The Variables In This Section.
# See The Installation Guide For Full Instructions.
#

# Script Location
$script = "/cgi-bin/showsell.pl";

# Advert Data Directory
$data_dir = "/usr/home/explorexxx/domains/baberankings.com/ssibanners/";

#
# The Following Two Variables Are Only Applicable If You Are Using The
# Multi-User Version Of This Script
#

# Multi-User Flag
$multi_user = 0;

# Multi-User Datafile Path
$multiuser_dir = "/client/home/";

#
################################################################################
#
# Global Variable Section
# =======================
#
# Please Do Not Modify Any Of The Following Lines As It May
# Cause The Script To Stop Functioning Correctly.
#

# Script Name
$script_name = "Show And Sell";

# Script Version
$version = "1.07";

# Multi-User Datafile Location
$multiuser_file = $multiuser_dir."showsell.mud";

# The Configuration Field List
%config_fields = (	"BASE_URL", "", "BORDER", "", "FONT", "", "COLOR", "",
					"SIZE", "", "LOGGING", "");

# Demo Mode Flag
$demo = 0;

################################################################################
################################################################################
#
# Main Code Section
# =================
#
# Please Do Not Modify Any Of The Following Lines As It May
# Cause The Script To Stop Functioning Correctly.

# Read In The Input Data
&GetInputData();

# Initialize The Output Unless We Are Redirecting Or Displaying Non-SSI Advert
&InitializeHtml() unless $INPUT{'REDIRECT'} || uc($INPUT{'SSI'}) eq 'NO';

# Get Multi-User Data If We Need To
&GetMultiUserData($INPUT{'USER'}) if $multi_user;

# Setup The Paths Needed By The Script
&SetPaths();

# Read The Configuration File If We Are Not Updating
if (!(uc($INPUT{'COMMAND'}) eq 'UPDATE' && uc($INPUT{'SCREEN'}) eq 'CONFIG'))
{
	&ReadConfigFile();
}

# Check The Configuration Values For Validity
&CheckConfig();

# Check To See If We Are In Redirection Mode
if($INPUT{'REDIRECT'} ne '')
{
	# If We Are Then Redirect The User
	&SendUser();
}
# Otherwise Check To See If We Are In Configuration Mode
elsif($INPUT{'SCREEN'} ne '')
{
	# And If So Let The Screen Handler Take Over
	&ScreenHandler();
}
# And If Not Then We Must Be Showing The Advert
else
{	
	# Read In The Advert Data
	&ReadAdvertData();
	
	# Check If We Are Using The Non-SSI Version
	if(uc($INPUT{'SSI'}) eq 'NO')
	{
		# If So Then Display The Non-SSI Version Advert
		&DisplayAdvertNonSSI();
	}
	else
	{
		# Othwerwise Display The SSI Version Advert
		&DisplayAdvertSSI();
	}
}

# Thats All Folks!!!
exit;

################################################################################
################################################################################
#
# Subroutine Section
# ==================
#
# Please do not modify any of the following lines as it may
# cause the script to stop functioning correctly.
#
################################################################################
#
# Subroutine Used To Handle The Configuration Screens
#
sub ScreenHandler
{
	# Check To See If The Password Is Correct
	my $checksum = &CheckPassword($INPUT{'PASSWORD'});

	# If Not Then Show The Login Screen
	if(! $checksum) { &ShowLoginScreen(); return; }
	
	# If We Have Come From The Login Screen Then Show The Configuration Screen
	if(uc($INPUT{'SCREEN'}) eq 'LOGIN')
	{
		&ShowConfigScreen();
	}

	# If We Have Come From The Configuration Screen Then Handle The Options	
	if(uc($INPUT{'SCREEN'}) eq 'CONFIG')
	{
		# Check To See If We Are Updating The Configuration Options
		if(uc($INPUT{'COMMAND'}) eq 'UPDATE')
		{
			# If So Then Write Away The New Configuration File
			&WriteConfigFile() if(!$demo);
			
			# And Show The Main Configuration Screen Again
			&ShowConfigScreen();
		}
	
		# Check To See If We Are Going To Manage The Adverts
		if(uc($INPUT{'COMMAND'}) eq 'MANAGE')
		{
			# If So Then Read The Advert Data
			&ReadAdvertData();
			
			# And Show The List Of Adverts
			&ShowAdvertList();
		}
	
		# Check To See If We Are Going To Generate HTML Code
		if(uc($INPUT{'COMMAND'}) eq 'GENERATE')
		{
			# Generate The Code
			&GenerateCode();
		}

		# Check To See If We Are Going To Test The Adverts
		if(uc($INPUT{'COMMAND'}) eq 'TEST')
		{
			# Read In The Advert Data
			&ReadAdvertData();
	
			# And Display the Advert
			&DisplayAdvertSSI();
		}

		# Check To See If We Are Going To Manage The Adverts
		if(uc($INPUT{'COMMAND'}) eq 'CHANGE')
		{
			# If So Then Show The Password Change Screen
			&ShowPasswordChange();
		}
	}
	
	# If We Have Come From The Code Generation Screen Then Handle The Options	
	if(uc($INPUT{'SCREEN'}) eq 'GENERATE')
	{
		# Check To See If We Are Going To Return To The Configuration Menu
		if(uc($INPUT{'COMMAND'}) eq 'RETURN')
		{
			# If So Then Show It
			&ShowConfigScreen();
		}
	}
	
	# If We Have Come From The Advert List Screen Then Handle The Options	
	if(uc($INPUT{'SCREEN'}) eq 'CHANGE')
	{
		# Check To See If We Are Going To Change The Password
		if(uc($INPUT{'COMMAND'}) eq 'OK')
		{
			# Initialize The Password Check Field
			my $pass_check = "";
			
			# If We Are Not In Demo Mode Then Store The New Password
			if(!$demo) { $pass_check = StoreNewPassword(); }
			else { $pass_check = ""; }

			# If The New Password Is Ok Then Return To The Configuration Menu
			if($pass_check)
			{
				&ShowConfigScreen();
			}
			else
			{
				&ShowPasswordChange();
			}
		}
		
		# Check To See If We Are Going To Return To The Configuration Menu
		if(uc($INPUT{'COMMAND'}) eq 'RETURN')
		{
			# If So Then Show It
			&ShowConfigScreen();
		}
	}
	
	# If We Have Come From The Advert List Screen Then Handle The Options	
	if(uc($INPUT{'SCREEN'}) eq 'LIST')
	{
		# Check To See If We Are Going To Modify An Advert
		if(uc($INPUT{'COMMAND'}) eq 'MODIFY')
		{
			# Read The Advert Data
			&ReadAdvertData();
			
			# Check If We Have A Advert To Modify
			if (uc($INPUT{'ADVERT'}) eq 'NONE')
			{
				# If Not Then Show The Advert List Again
				&ShowAdvertList();
			}
			else
			{
				# Otherwise Show The Advert Details
				&ShowAdvertDetails();
			}
		}

		# Check To See If We Are Going To Add A New Advert
		if(uc($INPUT{'COMMAND'}) eq 'ADD')
		{
			# If So And There Is An Advert To Add Then Do It
			if (uc($INPUT{'ADD_FILE'}) ne 'NONE') { &AddNewAdvert(); }
			
			# Read In The New Advert Data
			&ReadAdvertData();
			
			# And Show The New Advert List
			&ShowAdvertList();
		}

		# Check To See If We Are Going To Return To The Configuration Menu
		if(uc($INPUT{'COMMAND'}) eq 'STATISTICS')
		{
			# If So Then Read The Advert Data
			&ReadAdvertData();
			
			# And Show The Statistics
			&ShowAdvertStats();
		}

		# Check To See If We Are Going To Return To The Configuration Menu
		if(uc($INPUT{'COMMAND'}) eq 'RETURN')
		{
			# If So Then Show It
			&ShowConfigScreen();
		}
	}

	# If We Have Come From The Stats Screen Then Handle The Options
	if(uc($INPUT{'SCREEN'}) eq 'STATS')
	{
		# Check To See If We Are Going To Return To The Advert List Screen
		if(uc($INPUT{'COMMAND'}) eq 'RETURN')
		{
			# If So The Read The Advert Data
			&ReadAdvertData();
			
			# And Show The Advert List
			&ShowAdvertList();
		}
	}
	
	# If We Have Come From The Details Screen Then Handle The Options
	if(uc($INPUT{'SCREEN'}) eq 'DETAILS')
	{
		# Check To See If We Are Going To Update The Advert Details
		if(uc($INPUT{'COMMAND'}) eq 'UPDATE')
		{
			# If So Then Write Away The New Details
			&EditAdvert();
			
			# Read The Updated Advert Data
			&ReadAdvertData();
			
			# And Show The Updated Advert Details
			&ShowAdvertDetails();
		}

		# Check To See If We Are Going To Remove The Advert
		if(uc($INPUT{'COMMAND'}) eq 'REMOVE')
		{
			# If So The Delete It
			&DeleteAdvert();
			
			# Read The Updated Advert Data
			&ReadAdvertData();
			
			# Adn Show The Updated Advert List
			&ShowAdvertList();
		}

		# Check To See If We Are Going To Return To The Advert List Screen
		if(uc($INPUT{'COMMAND'}) eq 'RETURN')
		{
			# If So The Read The Advert Data
			&ReadAdvertData();
			
			# And Show The Advert List
			&ShowAdvertList();
		}
	}
}
################################################################################
#
# Subroutine Used To Read In The Advert Information From The Advert Data File
#
sub ReadAdvertData
{
	# Check We Have A Advert Datafile To Work With
	&CheckDataFile($advert_file);

	# Setup The Database Filename
	$database_file = $advert_file;
	
	# Open The Advert File For Input
	open(ADVERT, "<$database_file") || FileError($database_file);
	
	# Initialize The Global Total Advert Count
	$total_adverts = 0;
	
	# Process Each Line In The Advert File
	while(<ADVERT>)
	{
		# Get Rid Of The Newline At The End Of The Input Line
		chomp($_);

		# Split The Input Line Into Fields
		my ($advert_name, $advert_type, $advert_url, $advert_desc) = split(/\|/, $_);
		
		# If We Dont Have A Valid Name Then Ignore It
		if(!length($advert_name)) { next; }
		
		# If We Dont Have A Valid Type Then Ignore It
		if(lc($advert_type) ne 'gif' && lc($advert_type) ne 'jpg') { next; }
		
		# If We Dont Have A Valid URL Then Ignore It
		if(length($advert_url) le 0) { next; }
		
		# If The Advert Graphic File Foes Not Exist Then Ignore It
		if(! -e "$data_dir$advert_name.$advert_type") { next; }
	
		# Increment The Total Number Of Adverts
		$total_adverts++;

		# Store The Current Advert Information
		$adverts_name{$total_adverts} = $advert_name;
		$adverts_type{$total_adverts} = $advert_type;
		$adverts_url{$total_adverts}  = $advert_url;
		$adverts_desc{$total_adverts} = $advert_desc;
	}

	# Close The Adverts File
	close(ADVERT);
}
#
################################################################################
#
# Subroutine Used To Display The Advert Graphic
#
sub DisplayAdvertSSI
{
	# Randomize The Random Number Generator
	srand(time ^ $$);
	
	# Pick A Random Number
	my $ad_chosen = (int(rand $total_adverts)) + 1;

	# Get The Necessary Information About The Chosen Advert
	my $advert_name = $adverts_name{$ad_chosen}.".".$adverts_type{$ad_chosen};
	my $advert_path = $advert_url.$advert_name;
	my $advert_url = "$script?redirect=".$adverts_name{$ad_chosen};
	my $advert_desc = $adverts_desc{$ad_chosen};

	# Write Out The Advert HTML Source
	print "<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"0\">\n";
	print "<TR>\n";
	print "<TD>\n";
	print "<CENTER>\n";
	print "<A HREF=\"$advert_url\">";
	print "<IMG BORDER=\"$border\" ALT=\"$advert_desc\" ";
	print "SRC=\"$advert_path\">";
	
	# Only Display The Slogan If There Is One Setup
	if(length($advert_desc) gt 0)
	{
		print "<FONT FACE=\"$font\" SIZE=\"$size\" COLOR=\"$color\">";
		print "<BR>$advert_desc";
		print "</FONT>";
	}
	
	# Write Out The Advert HTML Source Footer
	print "</A>\n";
	print "</CENTER>\n";
	print "</TD>\n";
	print "</TR>\n";
	print "</TABLE>\n";

	# Log The Display Of The Advert If Logging Is On
	UpdateLog("$advert_name|SHOWN") if $log_switch eq 'YES';
}
#
################################################################################
#
# Subroutine Used To Display The Advert Graphic For Non-SSI Users
#
sub DisplayAdvertNonSSI
{
	# Randomize The Random Number Generator
	srand(time ^ $$);
	
	# Pick A Random Number
	my $ad_chosen = (int(rand $total_adverts)) + 1;

	# Get A User Unique Key
	my $advert_key = GetIpKey();
	
	# Setup The Database Filename
	$database_file = $track_file;

	# Call The Edit Record Routine With Appropriate Data
	&EditRecord($advert_key, $adverts_name{$ad_chosen});

	# Get The Necessary Information About The Chosen Advert
	my $advert_name = $adverts_name{$ad_chosen}.".".$adverts_type{$ad_chosen};
	my $advert_path = $advert_url.$advert_name;

	# Write Out The Expiration Header
	print "Expires: 1 Jan 98\n";
	
	# Redirect The User To The Advert Graphic
	&RedirectUser($advert_path);

	# Log The Display Of The Advert If Logging Is On
	UpdateLog("$advert_name|SHOWN") if $log_switch eq 'YES';
}
#
################################################################################
#
# Subroutine Used To Send User To Advertiser's URL
#
sub SendUser
{
	# Read In The Advert Data
	&ReadAdvertData();
	
	# Initialize The Advert Chosen Variable
	my $ad_chosen = "";

	# Check If We Are Using The Non-SSI Version
	if(uc($INPUT{'SSI'}) eq 'NO')
	{
		# Setup The Database Filename
		$database_file = $track_file;

		# Set The Redirect Name To The Advert Shown
		$INPUT{'REDIRECT'} = ReadRecord(GetIpKey());
	}

	# Search Each Of The Adverts
	foreach $key (keys %adverts_name)
	{
		# Check To See If This Is The Right Advert
		if($adverts_name{$key} eq $INPUT{'REDIRECT'})
		{
			# If It Is Then Store The Value
			$ad_chosen = $key;
			last;
		}
	}
	
	# Setup The Advert Name
	my $advert_name = $adverts_name{$ad_chosen}.".".$adverts_type{$ad_chosen};
	
	# Log The Click Of The Advert If Logging Is On
	UpdateLog("$advert_name|CLICKED") if $log_switch eq 'YES';

	# Check If We Are Using The Non-SSI Version
	if(uc($INPUT{'SSI'}) eq 'NO')
	{
		# Setup The Database Filename
		$database_file = $track_file;

		# Delete The Tracking Record
		DeleteRecord(GetIpKey());
	}

	# Send The User To The New URL
	&RedirectUser($adverts_url{$ad_chosen});
}
#
################################################################################
#
# Subroutine Used To Show The Configuration Screen
#
sub ShowConfigScreen
{
	# Setup Our Lists
	my @font_list = ("Arial", "Comic Sans MS", "Courier", "MS Sans Serif",
						"Times New Roman", "Verdana");
	my @color_list = ("Black", "Blue", "Green", "Red", "White", "Yellow");
	my @size_list = (1, 2, 3, 4);
	my @border_list = (0, 1, 2, 3, 4);

	# Initialize The Screen
	&InitializeScreen($script_name, $version, "Configuration Menu", "#639463");
	
	# Store The Screen Name And Password
	&StoreConfig("SCREEN", "CONFIG");
	&StoreConfig("PASSWORD", $INPUT{'PASSWORD'});
	&StoreConfig("USER", $INPUT{'USER'});
	
	# Create The General Header
	&CreateHeader("General");
	
	# Create The Advert Base URL Input Field
	&CreateRow("Advert Base URL");
	&SetInput("TEXT", "BASE_URL", 30);
	&EndRow();

	# Create The Advert Border Lookup Field	
	&CreateRow("Advert Border");
	&SetInput("LOOKUP", "BORDER", @border_list);
	&EndRow();
	
	# Create The Slogan Font Lookup Field	
	&CreateRow("Slogan Font");
	&SetInput("LOOKUP", "FONT", @font_list);
	&EndRow();
	
	# Create The Slogan Font Color Lookup Field	
	&CreateRow("Slogan Font Color");
	&SetInput("LOOKUP", "COLOR", @color_list);
	&EndRow();
	
	# Create The Slogan Font Size Lookup Field	
	&CreateRow("Slogan Font Size");
	&SetInput("LOOKUP", "SIZE", @size_list);
	&EndRow();
	
	# Create The Logging Question Field	
	&CreateRow("Enable Logging?");
	&SetInput("QUESTION", "LOGGING");
	&EndRow();

	# Create The Commands Header
	&CreateHeader("Commands");
	
	# Create The Update Button	
	&CreateRow("Update Changes");
	&SetInput("BUTTON", "Update");
	&EndRow();
	
	# Create The Manage Button	
	&CreateRow("Manage Adverts");
	&SetInput("BUTTON", "Manage");
	&EndRow();
	
	# Create The Test Adverts Button	
	&CreateRow("Test Adverts");
	&SetInput("BUTTON", "Test");
	&EndRow();
	
	# Create The Test Adverts Button	
	&CreateRow("Generate HTML");
	&SetInput("BUTTON", "Generate");
	&EndRow();
	
	# Create The Change Password Button	
	&CreateRow("Change Password");
	&SetInput("BUTTON", "Change");
	&EndRow();
	
	# Finalize The Screen
	&FinishScreen();
}
#
################################################################################
#
# Subroutine Used To Show The Advert List Screen
#
sub ShowAdvertList
{
	# Initialize The Screen
	&InitializeScreen($script_name, $version, "Advert Maintenance", "#639463");

	# Find All The Adverts That Can Be Added
	&FindNewAdverts();

	# Store The Screen Name And Password
	&StoreConfig("SCREEN", "LIST");
	&StoreConfig("PASSWORD", $INPUT{'PASSWORD'});
	&StoreConfig("USER", $INPUT{'USER'});
	
	# Create The Modify Header
	&CreateHeader("Select Advert To Modify");

	# Create The Advert Selection List	
	print "<TR><TD COLSPAN=\"2\"><CENTER>";
	print "<SELECT NAME=\"ADVERT\" SIZE=\"1\">";

	foreach $key (keys %adverts_name)
	{
		my $option_text = $adverts_name{$key}." : ".$adverts_desc{$key};
		
		if(length($adverts_desc{$key}) eq 0)
		{
			$option_text .= "No Slogan Entered";
		}
		
		print "<OPTION VALUE=\"$adverts_name{$key}\">$option_text</OPTION>";
	}

	# If There Are No Adverts Then Say So
	if ($total_adverts eq 0)
	{
		print "<OPTION VALUE=\"NONE\">No Adverts Configured</OPTION>";
	}

	print "</SELECT><BR><BR>";
	print "<INPUT TYPE=\"Submit\" NAME=\"COMMAND\" VALUE=\"Modify\">";
	print "</CENTER></TD></TR>";

	# Create The Commands Header
	&CreateHeader("Commands");
	
	# Create The Add New Advert List
	&CreateRow("Add A New Advert");
	&SetInput("LOOKUP", "ADD_FILE", @files_found);
	&SetInput("BUTTON", "Add");
	&EndRow();
	
	# Create The Return Button
	&CreateRow("View Statistics");
	&SetInput("BUTTON", "Statistics");
	&EndRow();
	
	# Create The Return Button
	&CreateRow("Return To Configuration");
	&SetInput("BUTTON", "Return");
	&EndRow();
	
	# Finalize The Screen
	&FinishScreen();
}
#
################################################################################
#
# Subroutine Used To Show The Advert List Screen
#
sub ShowAdvertStats
{
	# Analyse The Advert Log File
	&AnalyseAdvertLog();

	# Initialize The Screen
	&InitializeScreen($script_name, $version, "Advert Statistics", "#639463");

	# Store The Screen Name And Password
	&StoreConfig("SCREEN", "STATS");
	&StoreConfig("PASSWORD", $INPUT{'PASSWORD'});
	&StoreConfig("USER", $INPUT{'USER'});
	
	# Write Out The Statistics Table Header
	print "<TR><TD COLSPAN=\"2\"><CENTER>";
	print "<TABLE WIDTH=\"100%\">\n";
	print "<TR>";
	print "<TD><FONT FACE=\"Arial\" SIZE=\"2\"><B>Advert</B></FONT></TD>";
	print "<TD WIDTH=\"50\">";
	print "<CENTER>";
	print "<FONT FACE=\"Arial\" SIZE=\"2\"><B>Shown</B></FONT>";
	print "</CENTER>";
	print "</TD>";
	print "<TD>";
	print "<CENTER>";
	print "<FONT FACE=\"Arial\" SIZE=\"2\"><B>Clicked</B></FONT>";
	print "</CENTER>";
	print "</TD>";
	print "<TD><FONT FACE=\"Arial\" SIZE=\"2\"><B>Ratio</B></FONT></TD>";
	print "</TR>";
	print "<TR><TD COLSPAN=\"4\"><HR></TD></TR>";
	
	# Process Each Of The Logged Adverts
	foreach $key ( sort { $SHOWN{$b} <=> $SHOWN{$a} } keys %SHOWN)
	{
		# Calculate The Required Stats
		my $ad_shown = int($SHOWN{$key});
		my $ad_clicked = int($CLICKED{$key});
		my $ratio = 0;
		
		# Check We Are Not Going To Divide By Zero
		if($ad_shown gt 0 && $ad_clicked gt 0)
		{
			# If Not Then Calculate The Ratio
			$ratio = sprintf("%.2f%", (($ad_clicked / $ad_shown) * 100));
		}
		else
		{
			# Otherwise Tell The User There Is No Ratio
			$ratio = "Not Available";
		}
		
		# Display The Statistics For The Current Advert
		print "<TR>";
		print "<TD><FONT FACE=\"Arial\" SIZE=\"2\">$key</FONT></TD>";
		print "<TD>";
		print "<CENTER>";
		print "<FONT FACE=\"Arial\" COLOR=\"#FF0000\" SIZE=\"2\">$ad_shown</FONT>";
		print "</CENTER>";
		print "</TD>";
		print "<TD>";
		print "<CENTER>";
		print "<FONT FACE=\"Arial\" COLOR=\"#0000FF\" SIZE=\"2\">$ad_clicked</FONT>";
		print "</CENTER>";
		print "</TD>";
		print "<TD><FONT FACE=\"Arial\" SIZE=\"2\">$ratio</FONT></TD>";
		print "</TR>";
	}

	# Display The Table Footer
	print "</TABLE>";
	print "</CENTER></TD></TR>";

	# Create The Commands Header
	&CreateHeader("Commands");
	
	# Create The Return Button
	&CreateRow("Return To List");
	&SetInput("BUTTON", "Return");
	&EndRow();
	
	# Finalize The Screen
	&FinishScreen();
}
#
################################################################################
#
# Subroutine Used To Show The Advert Details Screen
#
sub ShowAdvertDetails
{
	# Analyse The Advert Log File
	&AnalyseAdvertLog();

	# Initialize The Advert Chosen Variable
	my $ad_chosen = "";

	# Search Each Of The Adverts
	foreach $key (keys %adverts_name)
	{
		# Check To See If This Is The Right Advert
		if($adverts_name{$key} eq $INPUT{'ADVERT'})
		{
			# If It Is Then Store The Value
			$ad_chosen = $key;
			last;
		}
	}
	
	# Setup The Advert Name, Path And Slogan
	my $advert_name = $adverts_name{$ad_chosen}.".".$adverts_type{$ad_chosen};
	my $advert_path = $advert_url.$advert_name;
	my $advert_desc = $adverts_desc{$ad_chosen};
	
	# Store The Advert URL And Slogan Details
	$CONFIG{'ADVERT_URL'} = $adverts_url{$ad_chosen};
	$CONFIG{'ADVERT_SLOGAN'} = $adverts_desc{$ad_chosen};

	# Initialize The Screen
	&InitializeScreen($script_name, $version, "Advert Details", "#639463");
	
	# Store The Screen Name And Password
	&StoreConfig("SCREEN", "DETAILS");
	&StoreConfig("PASSWORD", $INPUT{'PASSWORD'});
	&StoreConfig("USER", $INPUT{'USER'});
	
	# Store The Advert Name And Type
	&StoreConfig("ADVERT", $adverts_name{$ad_chosen});
	&StoreConfig("ADVERT_TYPE", $adverts_type{$ad_chosen});
	&StoreConfig("USER", $INPUT{'USER'});
	
	# Create The Advert Image Header
	&CreateHeader("Advert Image ($adverts_name{$ad_chosen}.".
					"$adverts_type{$ad_chosen})");
	
	# Show The How The Advert Will Look
	print "<TR>\n";
	print "<TD COLSPAN=\"2\">\n";
	print "<CENTER>\n";
	print "<A HREF=\"$CONFIG{'ADVERT_URL'}\" TARGET=\"_blank\">";
	print "<IMG BORDER=\"$border\" ALT=\"$advert_desc\" SRC=\"$advert_path\">";
	
	# Only Write Out The Slogan If It Is Setup
	if(length($CONFIG{'ADVERT_SLOGAN'}) gt 0)
	{
		print "<FONT FACE=\"$font\" SIZE=\"$size\" COLOR=\"$color\">";
		print "<BR>$CONFIG{'ADVERT_SLOGAN'}";
		print "</FONT>";
	}
	
	# Write Out The Footer
	print "</A>\n";
	print "</CENTER>\n";
	print "</TD>\n";
	print "</TR>\n";
	
	# Create Advert Details Header
	&CreateHeader("Advert Log");
	
	# Create The Advert Shown Count Label
	my $ad_shown = int($SHOWN{$adverts_name{$ad_chosen}});
	&CreateRow("Shown");
	&SetInput("LABEL", $ad_shown." time(s)");
	&EndRow();

	# Create The Advert Clicked Count Label
	my $ad_clicked = int($CLICKED{$adverts_name{$ad_chosen}});
	&CreateRow("Clicked");
	&SetInput("LABEL", $ad_clicked." time(s)");
	&EndRow();

	# Create The Advert Ratio Label
	&CreateRow("Ratio");

	# Check That We Are Not Going To Divide By Zero
	if($ad_shown gt 0 && $ad_clicked gt 0)
	{
		# If Not Then Calculate The Ratio And Display It
		$ratio = sprintf("%.2f%", (($ad_clicked / $ad_shown) * 100));
		&SetInput("LABEL", $ratio);
	}
	else
	{
		# Otherwise Tell The User There Is No Ratio
		&SetInput("LABEL", "Not Available");
	}
	&EndRow();
	
	# Create Advert Details Header
	&CreateHeader("Advert Details");
	
	# Create The Advert Base URL Input Field
	&CreateRow("Advert URL");
	&SetInput("TEXT", "ADVERT_URL", 30);
	&EndRow();

	# Create The Advert Slogan Input Field
	&CreateRow("Advert Slogan");
	&SetInput("TEXT", "ADVERT_SLOGAN", 40);
	&EndRow();

	# Create The Commands Header
	&CreateHeader("Commands");
	
	# Create The Update Button	
	&CreateRow("Update Changes");
	&SetInput("BUTTON", "Update");
	&EndRow();
	
	# Create The Remove Button	
	&CreateRow("Remove Advert");
	&SetInput("BUTTON", "Remove");
	&EndRow();
	
	# Create The Return Button	
	&CreateRow("Return To List");
	&SetInput("BUTTON", "Return");
	&EndRow();
	
	# Finalize The Screen
	&FinishScreen();
}
#
################################################################################
#
# Subroutine Used To Generate The HTML Code For Showing Adverts
#
sub GenerateCode
{
	# Initialize The Screen
	&InitializeScreen($script_name, $version, "Code Generator", "#639463");

	# Store The Screen Name And Password
	&StoreConfig("SCREEN", "GENERATE");
	&StoreConfig("PASSWORD", $INPUT{'PASSWORD'});
	&StoreConfig("USER", $INPUT{'USER'});

	# Create The Commands Header
	&CreateHeader("Cut And Paste Appropriate Code");
		
	# Create The Code Text Area	
	print "<TR><TD COLSPAN=\"2\"><CENTER>";
	print "<TEXTAREA NAME=\"MESSAGE\" COLS=\"60\" ROWS=\"10\" WRAP=\"OFF\">";

	# Generate The SSI Code
	print "<!-- SHOW AND SELL : SSI CODE START -->\n";
	print "<!--#exec cgi=\"$script";
	print "?user=$INPUT{'USER'}" if $multi_user;
	print "\"-->\n";
	print "<!-- SHOW AND SELL : SSI CODE END -->\n\n";
	
	# Generate The Non-SSI Code
	print "<!-- SHOW AND SELL : NON-SSI CODE START -->\n";
	print "<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"0\">\n";
	print "<TR>\n";
	print "<TD>\n";
	print "<CENTER>\n";
	print "<A HREF=\"$script?redirect=yes&ssi=no";
	print "&user=$INPUT{'USER'}" if $multi_user;
	print "\">\n";
	print "<IMG SRC=\"$script?ssi=no\"";
	print " BORDER=$CONFIG{'BORDER'} ALT=\"Click Here To Visit Our Sponsor\"><BR>\n";
	print "<FONT FACE=\"$CONFIG{'FONT'}\" SIZE=\"$CONFIG{'SIZE'}\"";
	print " COLOR=\"$CONFIG{'COLOR'}\">";
	print "Click Here To Visit Our Sponsor</FONT>\n";
	print "</A>\n";
	print "</CENTER>\n";
	print "</TD>\n";
	print "</TR>\n";
	print "</TABLE>\n";
	print "<!-- SHOW AND SELL : NON-SSI CODE END -->\n";

	# Finish Off The Code Text Area
	print "</TEXTAREA>";
	print "</CENTER></TD></TR>";

	# Create The Commands Header
	&CreateHeader("Commands");
	
	# Create The Return Button
	&CreateRow("Return To Configuration");
	&SetInput("BUTTON", "Return");
	&EndRow();
	
	# Finalize The Screen
	&FinishScreen();
}
#
################################################################################
#
# Subroutine Used To Check The Configuration Settings
#
sub CheckConfig
{
	# If We Do Not Have A Base URL Then Default It
	if ($CONFIG{'BASE_URL'} eq '')
		{ $CONFIG{'BASE_URL'} = "http://www.yoursite.com/showsell/"; }
		
	# If The Base URL Does Not End In A Forward Slash Then Add It
	if (!($CONFIG{'BASE_URL'} =~ /\/$/i)) { $CONFIG{'BASE_URL'} .= "/"; }
		
	# If We Do Not Have Border Setting Then Default It
	if ($CONFIG{'BORDER'} eq '')
		{ $CONFIG{'BORDER'} = "1"; }
		
	# If We Do Not Have A Font Setting Then Default It
	if ($CONFIG{'FONT'} eq '')
		{ $CONFIG{'FONT'} = "Arial"; }
		
	# If We Do Not Have A Font Colour Setting Then Default It
	if ($CONFIG{'COLOR'} eq '')
		{ $CONFIG{'COLOR'} = "Red"; }
		
	# If We Do Not Have A Font Size Setting Then Default It
	if ($CONFIG{'SIZE'} eq '')
		{ $CONFIG{'SIZE'} = "2"; }
		
	# If We Do Not Have A Logging Option Then Default It
	if ($CONFIG{'LOGGING'} eq '')
		{ $CONFIG{'LOGGING'} = "YES"; }
		
	# Set The Global Variables To Their Appropriate Values
	$advert_url = $CONFIG{'BASE_URL'};
	$border = $CONFIG{'BORDER'};
	$font = $CONFIG{'FONT'};
	$color = $CONFIG{'COLOR'};
	$size = $CONFIG{'SIZE'};
	$log_switch = $CONFIG{'LOGGING'};
}
#
################################################################################
#
# Subroutine Used To Build A List Of Available Adverts
#
sub FindNewAdverts
{
	# Setup The Directory We Want To Look In
	my $search_dir = $data_dir;
	chop($search_dir);

	# Create A String Of All The Currently Used Adverts
	my $current_adverts = join("|", values %adverts_name);
	
	# Open The Directory For Processing
	opendir(FILES, $search_dir);
		
	# Read In The First File
	$file = readdir(FILES);

	# Keep Processing Directory Until A Blank is Returned
	while(length($file) gt 0)
	{
		# Split The Filename Up
		my ($filename, $extension) = split(/\./, $file);
		
		# And Read In The Next File
		$file = readdir(FILES);

		# Ignore Any Invalid File Types
		if (uc($extension) ne 'GIF' && uc($extension) ne 'JPG') { next; }
		
		# Ignore Any Adverts Already Used
		if ($current_adverts =~ /$filename/i) { next; }

		# If It Is A Blank File Then Ignore It
		if (-s "$filename") { next; }

		# If It Is Not A Readable File The Ignore It
		if (-r "$filename") { next; }
		
		# Store The Advert
		push(@files_found, "$filename.$extension");
	}
		
	# Close The Directory
	closedir(FILES);

	# If We Have Not Found Any Adverts Then Say So
	if (@files_found eq 0) { push(@files_found, "None"); }
}
#
################################################################################
#
# Subroutine Used To Add A New Advert
#
sub AddNewAdvert
{
	# If We Are In Demo Mode Then Return
	if($demo) { return; }

	# Setup The Database Filename
	$database_file = $advert_file;
	
	# Split The Filename Into Seperate Parts
	my ($filename, $extension) = split(/\./, $INPUT{'ADD_FILE'});

	# Call The Add Record Routine With Appropriate Data
	&EditRecord($filename, $extension,
				"http://www.nowhere.com", "Click Here To Visit Our Sponsor");
	
}
################################################################################
#
# Subroutine Used To Edit An Advert
#
sub EditAdvert
{
	# If We Are In Demo Mode Then Return
	if($demo) { return; }
	
	# Setup The Database Filename
	$database_file = $advert_file;

	# Call The Edit Record Routine With Appropriate Data
	&EditRecord($INPUT{'ADVERT'}, $INPUT{'ADVERT_TYPE'},
				$INPUT{'ADVERT_URL'}, $INPUT{'ADVERT_SLOGAN'});
}
#
################################################################################
#
# Subroutine Used To Delete An Advert
#
sub DeleteAdvert
{
	# If We Are In Demo Mode Then Return
	if($demo) { return; }

	# Setup The Database Filename
	$database_file = $advert_file;
	
	# Call The Delete Record Routine With Appropriate Data
	&DeleteRecord($INPUT{'ADVERT'});
}
#
################################################################################
#
# Subroutine Used To Analyse Advert Log File
#
sub AnalyseAdvertLog
{
	# Check We Have A Log File To Work With
	&CheckDataFile($log_file);

	# Open The Log File
	open(LOGFILE, "<$log_file") || FileError($log_file);
	
	# Initialize The Totals Variables
	foreach $value (values %adverts_name)
	{
		$SHOWN{$value} = 0;
		$CLICKED{$value} = 0;
	}
	
	# Process The Log File
	while(<LOGFILE>)
	{
		# Get Rid Of Any Line Returns
		chomp($_);
		
		# Split Up The Log File Line
		my($year, $month, $day, $hour,
			$min, $host, $file, $type) = split(/\|/, $_);

		# Split Up The Filename
		my ($filename, $extension) = split(/\./, $file);

		# If It Was Shown Then Increment The Appropriate Counter
		if($type eq 'SHOWN') { $SHOWN{$filename}++; }

		# If It Was Clicked Then Increment The Appropriate Counter
		if($type eq 'CLICKED') { $CLICKED{$filename}++; }
	}

	# Close The Log File
	close(LOGFILE);
}
#
################################################################################
#
# Subroutine Used To Setup Datafile Paths
#
sub SetPaths
{
	# Setup The Filenames Needed By The Script
	$advert_file = $data_dir."showsell.dat";
	$config_file = $data_dir."showsell.cfg";
	$password_file = $data_dir."showsell.pwd";
	$log_file = $data_dir."showsell.log";
	$track_file = $data_dir."showsell.trk";
}
#
################################################################################
################################################################################
################################################################################

Youez - 2016 - github.com/yon3zu
LinuXploit