Skip to content

Commit

Permalink
erase and restart entire project, old base was a 2014 version, new ba…
Browse files Browse the repository at this point in the history
…se is a 2016 version
  • Loading branch information
RedDragonWebDesign committed Oct 27, 2020
1 parent 5fc32dc commit 602bc2d
Show file tree
Hide file tree
Showing 962 changed files with 14,359 additions and 7,395 deletions.
119 changes: 36 additions & 83 deletions src/_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*
*/

require_once($prevFolder."include/lib_autolink/lib_autolink.php");


include($prevFolder."include/lib_autolink/lib_autolink.php");


// General functions to filter out all <, >, ", and ' symbols
function filterArray($arrValues) {
Expand All @@ -39,11 +42,14 @@ function filterText($strText) {
$temp = str_replace("&middot;", "&#38;middot;", $value);
$temp = str_replace("&raquo;", "&#38;raquo;", $temp);
$temp = str_replace("&laquo;", "&#38;laquo;", $temp);



return $temp;
}

function getPreciseTime($intTime, $timeFormat="", $bypassTimeDiff=false) {

$timeDiff = (!$bypassTimeDiff) ? time() - $intTime : 99999;

if($timeDiff < 3) {
Expand Down Expand Up @@ -78,12 +84,24 @@ function getPreciseTime($intTime, $timeFormat="", $bypassTimeDiff=false) {


$dispLastDate = date($timeFormat, $intTime);

}

return $dispLastDate;

}

function getDateUTC($time, $timeFormat = "D M j, Y g:i a") {

$date = new DateTime();
$date->setTimezone(new DateTimeZone("UTC"));
$date->setTimestamp($time);

return $date->format($timeFormat);

}


function parseBBCode($strText) {
global $MAIN_ROOT;

Expand Down Expand Up @@ -152,9 +170,10 @@ function parseBBCode($strText) {
function autoLinkImage($strText) {

$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\')>/", "<a href='$2' target='_blank'><img src='$2'></a>", $strText);
$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\') alt=(\"|\')(.*)(\"|\') width=(\"|\')(.*)(\"|\') height=(\"|\')(.*)(\"|\') \/>/", "<a href='$2' target='_blank'><img src='$2' width='$8' height='$11'></a>", $strText);
$strText = preg_replace("/<img src=(\"|\')(.*)(\"|\') alt=(\"|\')(.*)(\"|\') \/>/", "<a href='$2' target='_blank'><img src='$2'></a>", $strText);


return $strText;
}

Expand All @@ -170,7 +189,8 @@ function deleteFile($filename) {


function getHTTP() {
if(isset($_SERVER['HTTPS']) && (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off")) {

if(!isset($_SERVER['HTTPS']) || (isset($_SERVER['HTTPS']) && (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off"))) {
$dispHTTP = "http://";
}
else {
Expand Down Expand Up @@ -236,94 +256,27 @@ function encryptPassword($password) {
return $returnArr;
}

// Example usage: html_var_export($limit, '$limit');
function html_var_export($var, $var_name = NULL)
{
$output = '';

if ( $var_name )
{
$output .= $var_name . ' = ';
}

$output .= nl2br_and_nbsp(var_export($var, TRUE)) . "<br /><br />";

echo $output;
}

function nl2br_and_nbsp($string)
{
$string = nl2br($string);

$string = nbsp($string);

return $string;
}

function nbsp($string)
{
$string = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);

// replace more than 1 space in a row with &nbsp;
$string = preg_replace('/ /m', '&nbsp;&nbsp;', $string);
$string = preg_replace('/ &nbsp;/m', '&nbsp;&nbsp;', $string);
$string = preg_replace('/&nbsp; /m', '&nbsp;&nbsp;', $string);

if ( $string == ' ' )
{
$string = '&nbsp;';
function getSelected($arrValues, $selectedValue) {
$returnArr = array();
foreach($arrValues as $value) {
$returnArr[$value] = ($value == $selectedValue) ? " selected" : "";
}

// Convert 2 space tab to 4 space tab
$string = preg_replace('/&nbsp;&nbsp;/m', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);

return $string;
}

function debug_string_backtrace() {
ob_start();
debug_print_backtrace();
$trace = ob_get_contents();
ob_end_clean();

// Remove first item from backtrace as it's this function which
// is redundant.
$trace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);

// sanitize HTML
$trace = htmlspecialchars($trace);

// Put each stack trace on its own line
$trace = preg_replace('/\n/', '<br />', $trace);

// Delete all but 1st stack trace
// $trace = preg_replace('/\n.*/', '', $trace);

return $trace;
return $returnArr;
}

/** Dump your entire SQL table into an array. You can use this function to do a `WHERE $condition1Field = $condition1Value AND $condition2Field = $condition2Value` type query. */
function sql_array_select_where($sqlTableAsArray, $condition1Field, $condition1Value, $condition2Field, $condition2Value) {
$result = [];
foreach ( $sqlTableAsArray as $key => $row ) {
if (
isset($row[$condition1Field]) &&
$row[$condition1Field] == $condition1Value &&
isset($row[$condition2Field]) &&
$row[$condition1Field] == $condition2Value
) {
$result[] = $row;
}
}
return $result;
}

// Class Loaders

function BTCS4Loader($class_name) {
require_once(BASE_DIRECTORY."classes/".strtolower($class_name).".php");
if(file_exists(BASE_DIRECTORY."classes/".strtolower($class_name).".php")) {
include_once(BASE_DIRECTORY."classes/".strtolower($class_name).".php");
}
elseif(file_exists(include_once(BASE_DIRECTORY."classes/formcomponents/".strtolower($class_name).".php"))) {
include_once(BASE_DIRECTORY."classes/formcomponents/".strtolower($class_name).".php");
}
}

spl_autoload_register("BTCS4Loader", true, true);

require_once(BASE_DIRECTORY."include/phpmailer/PHPMailerAutoload.php");
include_once(BASE_DIRECTORY."include/phpmailer/PHPMailerAutoload.php");
?>
128 changes: 43 additions & 85 deletions src/_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,29 @@
*/


// This setup page should not be changed. Edit _config.php to configure your website.

// There are two ways to turn on debug mode. You can turn it on here. Or you can turn it on in My Account -> Administrator Options -> Website Settings -> Debug Mode.
// Turning it on here gets the benefit of earlier PHP warnings. You get all of them, not just the ones that are thrown after the database is loaded.
// Debug Mode features: all PHP warnings, all SQL warnings, SQL profiler (query count, list of queries)
$debug = true;
define('SHOUTBOX_RELOAD_MS', 20000); // 20 seconds

// Error reporting default = off.
mysqli_report(MYSQLI_REPORT_OFF);
error_reporting(0);
ini_set('display_errors', '0');

function debug() {
mysqli_report(MYSQLI_REPORT_STRICT);
error_reporting(E_ALL);
ini_set('display_errors', '1');
}
// Check PHP Version

if ( $debug ) {
debug();
if(version_compare(phpversion(), "5.3") < 0) {
die("You must be using at least PHP version 5.3 in order to run Bluethrust Clan Scripts v4. Your current PHP Version: ".phpversion());
}

// DECLARE GLOBAL VARIABLES
$PAGE_NAME = "";
$EXTERNAL_JAVASCRIPT = '';
$SQL_PROFILER = [];

if (version_compare(PHP_VERSION, '7.0', '<')) {
die("These scripts need PHP version 7.0 or later to run. Please change this setting in your web host control panel (for example, cPanel).");
}
// This setup page should not be changed. Edit _config.php to configure your website.

ini_set('display_errors', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.gc_maxlifetime', 60*60*24*3);

if(!isset($prevFolder)) {
$prevFolder = "";
}

if(get_magic_quotes_gpc() == 1) {
foreach($_GET as $key=>$value) { $_GET[$key] = stripslashes($value); }
foreach($_POST as $key=>$value) { $_POST[$key] = stripslashes($value); }
}


if(isset($_COOKIE['btUsername']) && isset($_COOKIE['btPassword'])) {
session_start();
$_SESSION['btUsername'] = $_COOKIE['btUsername'];
Expand All @@ -61,22 +49,21 @@ function debug() {
$_SESSION['csrfKey'] = md5(uniqid());
}

// CONFIG.PHP INCLUDED HERE *************************
require_once($prevFolder."_config.php");
// **************************************************

include($prevFolder."_config.php");
define("BASE_DIRECTORY", $BASE_DIRECTORY);
//define("BASE_DIRECTORY", str_replace("//", "/", $_SERVER['DOCUMENT_ROOT'].$MAIN_ROOT));
define("MAIN_ROOT", $MAIN_ROOT);

// FUNCTIONS.PHP INCLUDED HERE **********************
require_once(BASE_DIRECTORY."_functions.php");
// **************************************************

$PAGE_NAME = "";
include_once(BASE_DIRECTORY."_functions.php");

define("FULL_SITE_URL", getHTTP().$_SERVER['SERVER_NAME'].MAIN_ROOT);


$mysqli = new btmysql($dbhost, $dbuser, $dbpass, $dbname);


$mysqli->set_tablePrefix($dbprefix);
$mysqli->set_testingMode(true);

Expand All @@ -93,79 +80,50 @@ function debug() {
define("THEME", $THEME);

$arrWebsiteLogoURL = parse_url($websiteInfo['logourl']);

if(!isset($arrWebsiteLogoURL['scheme']) || $arrWebsiteLogoURL['scheme'] == "") {
$websiteInfo['logourl'] = $MAIN_ROOT."themes/".$THEME."/".$websiteInfo['logourl'];
}

$IP_ADDRESS = $_SERVER['REMOTE_ADDR'];
// Default websiteinfo values
include_once(BASE_DIRECTORY."include/websiteinfo_defaults.php");


if(!isset($_SESSION['appendIP'])) {
$_SESSION['appendIP'] = substr(md5(uniqid().time()),0,10);
}

assert_options(ASSERT_BAIL);
$IP_ADDRESS = $_SERVER['REMOTE_ADDR'];

// Check Debug Mode

if($websiteInfo['debugmode'] == 1) {
debug();
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT);
}
else {
ini_set('display_errors', 0);
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT);
//ini_set('error_reporting', E_ALL);
}


// Check for Ban

$ipbanObj = new IPBan($mysqli);
if($ipbanObj->isBanned($IP_ADDRESS)) {
die("<script type='text/javascript'>window.location = '".$MAIN_ROOT."banned.php';</script>");
}

$websiteInfo['default_timezone'] = (!isset($websiteInfo['default_timezone']) || $websiteInfo['default_timezone'] == "") ? "UTC" : $websiteInfo['default_timezone'];
date_default_timezone_set($websiteInfo['default_timezone']);


$hooksObj = new btHooks();
$btThemeObj = new btTheme();
$clockObj = new Clock($mysqli);
$btThemeObj->setThemeDir($THEME);
$btThemeObj->setClanName($CLAN_NAME);
$btThemeObj->initHead();
$breadcrumbObj = new BreadCrumb();

require_once(BASE_DIRECTORY."plugins/mods.php");

// Caches for commonly queried SQL tables. Need to get the # of SQL queries down.
// Only cache tables where you are not going to have to read the new data on the same page. Else you may introudce hard to diagnose bugs.
// Make sure your table has a primary_key, and that the SELECT query is picking by the primary_key.
$tablesToCache = [
'clocks' => 'clock_id',
'console' => 'console_id',
// 'console_members' => 'privilege_id',
'consolecategory' => 'consolecategory_id',
'gamesplayed' => 'gamesplayed_id',
'menu_category' => 'menucategory_id',
'menu_item' => 'menuitem_id',
'menuitem_link' => 'menulink_id',
// 'rank_privileges' => 'privilege_id',
'rankcategory' => 'rankcategory_id',
'ranks' => 'rank_id',
];
$sqlCache = [];
foreach ( $tablesToCache as $table => $primaryKey ) {
$sqlCache[$table] = [];
$result = $mysqli->query("SELECT * FROM ".$dbprefix.$table);
if ( $result ) {
while ( $row = $result->fetch_assoc() ) {
$sqlCache[$table][$row[ $primaryKey ]] = $row;
}
}
}

// classes/member.php::hasAccess()
$sqlCache['console_members'] = [];
$result = $mysqli->query("SELECT * FROM ".$dbprefix."console_members");
if ( $result ) {
while ( $row = $result->fetch_assoc() ) {
$sqlCache['console_members'][] = $row;
}
}

// classes/consoleoptions.php::hasAccess()
$sqlCache['rank_privileges'] = [];
$result = $mysqli->query("SELECT * FROM ".$dbprefix."rank_privileges");
if ( $result ) {
while ( $row = $result->fetch_assoc() ) {
$sqlCache['rank_privileges'][] = $row;
}
}
include_once(BASE_DIRECTORY."plugins/mods.php");
?>
8 changes: 4 additions & 4 deletions src/classes/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
*
*/

require_once("btmysql.php");
require_once("rank.php");
require_once("rankcategory.php");
require_once("member.php");
include_once("btmysql.php");
include_once("rank.php");
include_once("rankcategory.php");
include_once("member.php");


class Access {
Expand Down
Loading

0 comments on commit 602bc2d

Please sign in to comment.