| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 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 : |
#
################################################################################
# #
# File : PBM Data Subroutines #
# Description : Contains All The Data Subroutines Used By Our Applications #
# Version : 1.04 #
# Created : 22nd September 1998 by Steve #
# Last Updated : 10th 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 #
# 30/09/98 : 1.01 : EditRecord Now Adds Record If Not Found : steve #
# 30/09/98 : 1.02 : Removed AddRecord Function (See Line Above) : steve #
# 30/09/98 : 1.03 : Added The ReadRecord Function : steve #
# 10/10/98 : 1.04 : Added The GetMultiUserData Function : 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. #
# #
################################################################################
################################################################################
#
# Subroutine Used To Read The Configuration File
#
sub ReadConfigFile
{
# Check To See If We Have A Config Datafile To Work With
&CheckDataFile($config_file);
# Open The Configuration File
open(CONFIG, "<$config_file") || FileError($config_file);
# Process Each Of The Lines In The Configuration File
while(<CONFIG>)
{
# Remove The Newline Character If There Is One
chomp($_);
# Split The Input Line Into Fields
my ($config_name, $config_value) = split(/\|/, $_);
# Store The Configuration Value
$CONFIG{$config_name} = $config_value;
}
# Close The Configuration File
close(CONFIG);
}
#
################################################################################
#
# Subroutine Used To Write The Configuration File
#
sub WriteConfigFile
{
# Check To See If We Have A Config Datafile To Work With
&CheckDataFile($config_file);
# Open The Configuration File
open(CONFIG, ">$config_file") || FileError($config_file);
# Process Each Of The Configuration Variables
foreach $key (keys %CONFIG)
{
# Write Out The Configuration Variable Value
print CONFIG "$key|$CONFIG{$key}\n";
}
# Close The Configuration File
close(CONFIG);
}
#
################################################################################
#
# Subroutine Used To Edit A Record In The Datafile
#
sub EditRecord
{
# Check To See If We Have A Database File To Work With
&CheckDataFile($database_file);
# Get The Record Key And Field Values
my ($key, @values) = @_;
# Create A Temporary Filename
my $tempfile_path = $database_file.".TMP";
# Initialize The Record Found Variable
my $found = 0;
# Setup The Record String With The Key As The Primary Value
my $record_string = $key;
# Add Each Of The Values To The Record String
foreach $value (@values) { $record_string .= "|$value"; }
# And Finish It Off With An End Of Line Character
$record_string .= "\n";
# Open The Current Database File And The Temporary One
open(OLD_DATA, "<$database_file") || FileError($database_file);
open(NEW_DATA, ">$tempfile_path") || FileError($tempfile_path);
# Process Each Line Of The Current Database
while(<OLD_DATA>)
{
# Get The Key Of The Current Record
my ($temp_key, @temp_values) = split(/\|/, $_);
# If It Is The One We Want To Edit Then Write Out The
# New Record Otherwise Write Out The Current One
if($key eq $temp_key) { print NEW_DATA $record_string; $found = 1; }
else { print NEW_DATA $_; }
}
# If We Didn't Find The Record Then Add It In
if(!$found) { print NEW_DATA $record_string; }
# Close The Files
close(OLD_DATA);
close(NEW_DATA);
# And Copy The Temporary One Over The Top Of The Old One
rename($tempfile_path, $database_file);
}
#
################################################################################
#
# Subroutine Used To Delete A Record In The Datafile
#
sub DeleteRecord
{
# Check To See If We Have A Database File To Work With
&CheckDataFile($database_file);
# Get The Record Key And Field Values
my ($key, @values) = @_;
# Create A Temporary Filename
my $tempfile_path = $database_file.".TMP";
# Open The Current Database File And The Temporary One
open(OLD_DATA, "<$database_file") || FileError($database_file);
open(NEW_DATA, ">$tempfile_path") || FileError($tempfile_path);
# Process Each Line Of The Current Database
while(<OLD_DATA>)
{
# Get The Key Of The Current Record
my ($temp_key, @temp_values) = split(/\|/, $_);
# If It Is Not The One We Want To Delete Then Write It Out
if($key ne $temp_key) { print NEW_DATA $_; }
}
# Close The Files
close(OLD_DATA);
close(NEW_DATA);
# And Copy The Temporary One Over The Top Of The Old One
rename($tempfile_path, $database_file);
}
#
################################################################################
#
# Subroutine Used To Read A Record In The Datafile
#
sub ReadRecord
{
# Check To See If We Have A Database File To Work With
&CheckDataFile($database_file);
# Get The Record Key To Read
my ($key) = @_;
# Initialize The Record String Variable
my $record_string = "";
# Open The Current Database File
open(DATA, "<$database_file") || FileError($database_file);
# Process Each Line Of The Current Database
while(<DATA>)
{
# Get Rid of Any Newline Characters
chomp($_);
# Get The Key Of The Current Record
my ($temp_key, @temp_values) = split(/\|/, $_);
# If It Is The One We Want Then Store The Record String And Leave
if($key eq $temp_key)
{
$record_string = join("", @temp_values);
last;
}
}
# Close The File
close(DATA);
# Return The Record String
return $record_string;
}
#
################################################################################
#
# Subroutine Used To Write Out A Message To A Logfile
#
sub GetMultiUserData
{
# Check To See If We Have A Multi-User Datafile To Work With
&CheckDataFile($multiuser_file);
# Get The Username Off The Stack
my ($username) = @_;
# Show An Error If We Do Not Have A Username
if(length($username) le 0)
{
&AddError("You must specify a username");
&ShowErrors();
}
# Initialize The User Found Variable
my $user_found = 0;
# Open The Multi-User Datafile
open(MULTI, "<$multiuser_file") || FileError($mutliuser_file);
# Process Each Line Of The File
while(<MULTI>)
{
# Get Rid of Any Newline Characters
chomp($_);
# Split The Input Line Into Fields
my ($user, $data_path) = split(/\|/, $_);
# If It Is The One We Want Setup The Variables
if($user eq $username)
{
$data_dir = $data_path;
$user_found = 1;
last;
}
}
# Close The File
close(MULTI);
# Show An Error If We Havent Found The User
if(!$user_found)
{
&AddError("Cannot find user details for <B>'$username'</B>");
&ShowErrors();
}
}
################################################################################
#
# Subroutine Used To Write Out A Message To A Logfile
#
sub UpdateLog
{
# Check To See If We Have A Log Datafile To Work With
&CheckDataFile($log_file);
# Get The Log Message Off The Stack
my ($log_message) = @_;
# Get Each Of The Current Date Variables We Need And Fix The Month Variable
my ($min, $hour, $day, $month, $year) = (localtime)[1,2,3,4,5];
$month++;
# Make It Year 2000 Compatible
if($year lt 98) { $year = 2000 + $year; } else { $year = $year + 1900; }
# Format The Log Time String
my $log_time = sprintf("%02d|%02d|%02d|%02d|%02d|",
$year, $month, $day, $hour, $min);
# Get The Hostaddress Of The User
my $host_address = GetHostAddress();
# Open The Log File
open(LOGFILE, ">>$log_file") || FileError($log_file);
# Write Out The Log Message Line
print LOGFILE "$log_time$host_address\|$log_message\n";
# Close The Log File
close(LOGFILE);
}
#
################################################################################
#
# Subroutine Used To Check If A Datafile Exists And Create It If Necessary
#
sub CheckDataFile
{
# Get The Data File Name
my ($data_file) = @_;
# Check To See If The File Exists
if(! -e $data_file)
{
# And If Not Then Create It
open(TEMP, ">$data_file") || FileError($data_file);
close(TEMP);
}
}
#
#################################################################################
#################################################################################
# Stop The 'require' Complaining
1;