phpn00bf4life
06-27-2005, 06:43 PM
C&C Rest is in next post... kinda long script.
<?php
session_start();
header("Cache-Control: Private");
/*
*******************************************
# Script Author: Jonathon ******* #
# Script Contact: elite_ksk@hotmail.com #
# Script Start Date: 7/20/05 #
# Script Description: Well this is where#
# all the functions are for the site, and#
# the site class, it's kind of the main #
# frame for the site, with out this it #
# wouldn't work or anything like that #
*******************************************
# function[include] DESC: Simple enough #
# it just does a quick security check #
# then includes the requested file, and #
# of course this is a fairly simple and #
# easy function #
# function[add] DESC: This is a quick #
# add slashes function, made mainly for #
# all database queries. #
# function[strip] DESC: This is another #
# quick function to strip the slashes #
# from returned mysql stuff. #
# function[bb] DESC: This is a bb code #
# translater, in other words it takes #
# a certain var([body]), and then finds #
# all patterns and replaces them with #
# html. This also deals with smilies #
# class[site] DESC: This is a full site #
# class. Main areas is the db stuff, the#
*******************************************
*/
//Check and see if IN_SITE is defined
if(!defined("IN_SITE")){
//Hacking attempt possibly
echo'Sorry, but the file you are trying to access is not allowed, and your
ip will be recorded';
$ip = $_SERVER['REMOTE_ADDR'];
$problem_body = "User trying to access the file: " . $area . ", and their
ip is: " . $ip;
$date = date("M, Y, D");
$time = time();
$insert = new site;
$connect = $this->connect();
$insert->query = "INSERT INTO " . $g_db_pre . "problems
VAULES('$problem_body','$date','$time')";
$insert->query();
die();
}
class site {
//First Site Templating System
var $template;
var $html;
var $parameters = array();
//Get's Template...
function HtmlTemplate ( $template ) {
$this->template = $template;
$this->html = implode ("",(file($this->template)));
//Read it up :)
}
//Now Let's Set some parameters...
function SetParameter ( $variable, $value ) {
$this->parameters[$variable] = $value;
}
//Now Let's actually create the return stuff...
function CreatePage ( ) {
//We'll create the {TEMPLATE}
foreach($this->parameters as $key => $value) {
$template_name = '{' . $key . '}';
$this->html = str_replace($template_name,$value,$this->html);
}
}
//Set the varialbes for the database queries now...
var $dbtype;
var $dbquery;
var $dbconnectiontype;
var $dbhost;
var $dbuser;
var $dbpass;
var $dbname;
//Here comes the fun DB PART...
function DBConnect ( ) {
//make static variables
if ( $this->dbtype == "mysql" ) {
if ( $this->dbconnectiontype != "" ) {
$connection = mysql_pconnect($this->dbhost,$this->dbuser,$this->dbpass) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
$connect = mysql_select_db($this->dbname,$connection) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
return $connect;
//Done with if statement...
} else {
$connection = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
$connect = mysql_select_db($this->dbname,$connection) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
return $connect;
//Done with else statement...
}
//Done with if statement...
} else {
//Currently we have no other db's coding setup so just kill it...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Done with else statement
}
//Done with DBConnect
}
//For DB queries we set up a function
function DBQuery ( $db_connect ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_query($this->query,$db_connect);
return $result;
//Done with if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Done with else statement
}
//Done with DBQuery
}
function DBFree ( $query ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_free_result ( $query );
return $result;
//done with the if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Close else statement
}
//Done with DBFree
}
//For Fetching DB results ... pfft...
function DBFetch ( $db_connect ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_fetch_array(mysql_query($this->dbquery)) or die ("MySQL ERROR -> DEBUG -> " . mysql_error());
return $result;
//Close if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Close else statement...
}
//Done with Function DBFetch
}
var $temp_file_name;
var $file_name;
var $upload_dir;
var $upload_log_dir;
var $max_file_size;
var $banned_array;
var $ext_array;
function validate_extension() {
//Variables
$file_name = trim($this->file_name);
$extension = strtolower(strrchr($file_name,"."));
$ext_array = $this->ext_array;
$ext_count = count($ext_array);
//Validate
if(!$file_name) {
return false;
} else {
if (!$ext_array) {
return true;
} else {
foreach ($ext_array as $value) {
if ($first_char <> ".") {
$first_char = substr($value,0,1);
$extension[] = ".".strtolower($value);
} else {
$extension[] = strtolower($value);
}
}
//okay...
foreach($extensions as $value) {
if($value == $extension) {
$valid_extension = "TRUE";
}
}
//Let's return true or false...
if($valid_extension) {
return true;
} else {
return false;
}
}
}
}
function validate_size() {
$temp_file_name = trim($this->$temp_file_name);
$max_file_size = trim($this->max_file_size);
if(!$temp_file_name) {
$size = filesize($temp_file_name);
if($size > $max_file_size) {
return false;
} else {
return true;
}
} else {
return false;
}
}
function existing_file() {
$file_name = trim($this->file_name);
$upload_dir = $this->get_upload_directory();
if($upload_dir == "ERROR") {
return true;
} else {
$file = $upload_dir . $file_name;
if (file_exists($file)) {
return true;
} else {
return false;
}
}
}
function get_file_size() {
//Make Sizes
$temp_file_name = trim($this->temp_file_name);
$kb = 1024;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
//get sizes...
if($temp_file_name) {
$size = filesize($temp_file_name);
if($size < $kb) {
$file_size = "$size Bytes";
}
elseif ($size < $mb) {
$final = round($size/$kb,2);
$file_size = "$final KB";
}
elseif ($size < $gb) {
$final = round($size/$mb,2);
$file_size = "$final MB";
}
elseif($size < $tb) {
$final = round($size/$gb,2);
$file_size = "$final GB";
} else {
$final = round($size/$tb,2);
$file_size = "$final TB";
}
} else {
$file_size = "ERROR: NO FILE PASSED TO get_file_size()";
}
return $file_size;
}
function get_max_size() {
$max_file_size = trim($this->max_file_size);
$kb = 1024;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
if ($max_file_size) {
if ($max_file_size < $kb) {
$max_file_size = "max_file_size Bytes";
}
elseif ($max_file_size < $mb) {
$final = round($max_file_size/$kb,2);
$max_file_size = "$final KB";
}
elseif ($max_file_size < $gb) {
$final = round($max_file_size/$mb,2);
$max_file_size = "$final MB";
}
elseif($max_file_size < $tb) {
$final = round($max_file_size/$gb,2);
$max_file_size = "$final GB";
} else {
$final = round($max_file_size/$tb,2);
$max_file_size = "$final TB";
}
} else {
$max_file_size = "ERROR: NO SIZE PARAMETER PASSED TO get_max_size()";
}
return $max_file_size;
}
function validate_user() {
//Variables
$banned_array = $this->banned_array;
$ip = trim($_SERVER['REMOTE_ADDR']);
$cpu = gethostbyaddr($ip);
$count = count($banned_array);
//Check em...
if($count < 1) {
return true;
} else {
foreach($banned_array as $key => $value) {
if($value == $ip ."-".$cpu) {
return false;
} else {
return true;
}
}
}
}
<?php
session_start();
header("Cache-Control: Private");
/*
*******************************************
# Script Author: Jonathon ******* #
# Script Contact: elite_ksk@hotmail.com #
# Script Start Date: 7/20/05 #
# Script Description: Well this is where#
# all the functions are for the site, and#
# the site class, it's kind of the main #
# frame for the site, with out this it #
# wouldn't work or anything like that #
*******************************************
# function[include] DESC: Simple enough #
# it just does a quick security check #
# then includes the requested file, and #
# of course this is a fairly simple and #
# easy function #
# function[add] DESC: This is a quick #
# add slashes function, made mainly for #
# all database queries. #
# function[strip] DESC: This is another #
# quick function to strip the slashes #
# from returned mysql stuff. #
# function[bb] DESC: This is a bb code #
# translater, in other words it takes #
# a certain var([body]), and then finds #
# all patterns and replaces them with #
# html. This also deals with smilies #
# class[site] DESC: This is a full site #
# class. Main areas is the db stuff, the#
*******************************************
*/
//Check and see if IN_SITE is defined
if(!defined("IN_SITE")){
//Hacking attempt possibly
echo'Sorry, but the file you are trying to access is not allowed, and your
ip will be recorded';
$ip = $_SERVER['REMOTE_ADDR'];
$problem_body = "User trying to access the file: " . $area . ", and their
ip is: " . $ip;
$date = date("M, Y, D");
$time = time();
$insert = new site;
$connect = $this->connect();
$insert->query = "INSERT INTO " . $g_db_pre . "problems
VAULES('$problem_body','$date','$time')";
$insert->query();
die();
}
class site {
//First Site Templating System
var $template;
var $html;
var $parameters = array();
//Get's Template...
function HtmlTemplate ( $template ) {
$this->template = $template;
$this->html = implode ("",(file($this->template)));
//Read it up :)
}
//Now Let's Set some parameters...
function SetParameter ( $variable, $value ) {
$this->parameters[$variable] = $value;
}
//Now Let's actually create the return stuff...
function CreatePage ( ) {
//We'll create the {TEMPLATE}
foreach($this->parameters as $key => $value) {
$template_name = '{' . $key . '}';
$this->html = str_replace($template_name,$value,$this->html);
}
}
//Set the varialbes for the database queries now...
var $dbtype;
var $dbquery;
var $dbconnectiontype;
var $dbhost;
var $dbuser;
var $dbpass;
var $dbname;
//Here comes the fun DB PART...
function DBConnect ( ) {
//make static variables
if ( $this->dbtype == "mysql" ) {
if ( $this->dbconnectiontype != "" ) {
$connection = mysql_pconnect($this->dbhost,$this->dbuser,$this->dbpass) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
$connect = mysql_select_db($this->dbname,$connection) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
return $connect;
//Done with if statement...
} else {
$connection = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
$connect = mysql_select_db($this->dbname,$connection) or die("MySQL ERROR -> DEBUG -> " . mysql_error());
return $connect;
//Done with else statement...
}
//Done with if statement...
} else {
//Currently we have no other db's coding setup so just kill it...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Done with else statement
}
//Done with DBConnect
}
//For DB queries we set up a function
function DBQuery ( $db_connect ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_query($this->query,$db_connect);
return $result;
//Done with if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Done with else statement
}
//Done with DBQuery
}
function DBFree ( $query ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_free_result ( $query );
return $result;
//done with the if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Close else statement
}
//Done with DBFree
}
//For Fetching DB results ... pfft...
function DBFetch ( $db_connect ) {
if ( $this->dbtype == "mysql" ) {
$result = mysql_fetch_array(mysql_query($this->dbquery)) or die ("MySQL ERROR -> DEBUG -> " . mysql_error());
return $result;
//Close if statement
} else {
//Currently we have no other db's coding setup so just kill the script...
die("DB ERROR -> DEBUG -> Please choose a DB TYPE");
//Close else statement...
}
//Done with Function DBFetch
}
var $temp_file_name;
var $file_name;
var $upload_dir;
var $upload_log_dir;
var $max_file_size;
var $banned_array;
var $ext_array;
function validate_extension() {
//Variables
$file_name = trim($this->file_name);
$extension = strtolower(strrchr($file_name,"."));
$ext_array = $this->ext_array;
$ext_count = count($ext_array);
//Validate
if(!$file_name) {
return false;
} else {
if (!$ext_array) {
return true;
} else {
foreach ($ext_array as $value) {
if ($first_char <> ".") {
$first_char = substr($value,0,1);
$extension[] = ".".strtolower($value);
} else {
$extension[] = strtolower($value);
}
}
//okay...
foreach($extensions as $value) {
if($value == $extension) {
$valid_extension = "TRUE";
}
}
//Let's return true or false...
if($valid_extension) {
return true;
} else {
return false;
}
}
}
}
function validate_size() {
$temp_file_name = trim($this->$temp_file_name);
$max_file_size = trim($this->max_file_size);
if(!$temp_file_name) {
$size = filesize($temp_file_name);
if($size > $max_file_size) {
return false;
} else {
return true;
}
} else {
return false;
}
}
function existing_file() {
$file_name = trim($this->file_name);
$upload_dir = $this->get_upload_directory();
if($upload_dir == "ERROR") {
return true;
} else {
$file = $upload_dir . $file_name;
if (file_exists($file)) {
return true;
} else {
return false;
}
}
}
function get_file_size() {
//Make Sizes
$temp_file_name = trim($this->temp_file_name);
$kb = 1024;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
//get sizes...
if($temp_file_name) {
$size = filesize($temp_file_name);
if($size < $kb) {
$file_size = "$size Bytes";
}
elseif ($size < $mb) {
$final = round($size/$kb,2);
$file_size = "$final KB";
}
elseif ($size < $gb) {
$final = round($size/$mb,2);
$file_size = "$final MB";
}
elseif($size < $tb) {
$final = round($size/$gb,2);
$file_size = "$final GB";
} else {
$final = round($size/$tb,2);
$file_size = "$final TB";
}
} else {
$file_size = "ERROR: NO FILE PASSED TO get_file_size()";
}
return $file_size;
}
function get_max_size() {
$max_file_size = trim($this->max_file_size);
$kb = 1024;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
if ($max_file_size) {
if ($max_file_size < $kb) {
$max_file_size = "max_file_size Bytes";
}
elseif ($max_file_size < $mb) {
$final = round($max_file_size/$kb,2);
$max_file_size = "$final KB";
}
elseif ($max_file_size < $gb) {
$final = round($max_file_size/$mb,2);
$max_file_size = "$final MB";
}
elseif($max_file_size < $tb) {
$final = round($max_file_size/$gb,2);
$max_file_size = "$final GB";
} else {
$final = round($max_file_size/$tb,2);
$max_file_size = "$final TB";
}
} else {
$max_file_size = "ERROR: NO SIZE PARAMETER PASSED TO get_max_size()";
}
return $max_file_size;
}
function validate_user() {
//Variables
$banned_array = $this->banned_array;
$ip = trim($_SERVER['REMOTE_ADDR']);
$cpu = gethostbyaddr($ip);
$count = count($banned_array);
//Check em...
if($count < 1) {
return true;
} else {
foreach($banned_array as $key => $value) {
if($value == $ip ."-".$cpu) {
return false;
} else {
return true;
}
}
}
}