Skip to content

Commit 602bc2d

Browse files
erase and restart entire project, old base was a 2014 version, new base is a 2016 version
1 parent 5fc32dc commit 602bc2d

File tree

962 files changed

+14359
-7395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

962 files changed

+14359
-7395
lines changed

src/_functions.php

Lines changed: 36 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
*
1313
*/
1414

15-
require_once($prevFolder."include/lib_autolink/lib_autolink.php");
15+
16+
17+
include($prevFolder."include/lib_autolink/lib_autolink.php");
18+
1619

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

4348
return $temp;
4449
}
4550

4651
function getPreciseTime($intTime, $timeFormat="", $bypassTimeDiff=false) {
52+
4753
$timeDiff = (!$bypassTimeDiff) ? time() - $intTime : 99999;
4854

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

7985

8086
$dispLastDate = date($timeFormat, $intTime);
87+
8188
}
8289

8390
return $dispLastDate;
8491

8592
}
8693

94+
function getDateUTC($time, $timeFormat = "D M j, Y g:i a") {
95+
96+
$date = new DateTime();
97+
$date->setTimezone(new DateTimeZone("UTC"));
98+
$date->setTimestamp($time);
99+
100+
return $date->format($timeFormat);
101+
102+
}
103+
104+
87105
function parseBBCode($strText) {
88106
global $MAIN_ROOT;
89107

@@ -152,9 +170,10 @@ function parseBBCode($strText) {
152170
function autoLinkImage($strText) {
153171

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

157-
176+
158177
return $strText;
159178
}
160179

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

171190

172191
function getHTTP() {
173-
if(isset($_SERVER['HTTPS']) && (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off")) {
192+
193+
if(!isset($_SERVER['HTTPS']) || (isset($_SERVER['HTTPS']) && (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off"))) {
174194
$dispHTTP = "http://";
175195
}
176196
else {
@@ -236,94 +256,27 @@ function encryptPassword($password) {
236256
return $returnArr;
237257
}
238258

239-
// Example usage: html_var_export($limit, '$limit');
240-
function html_var_export($var, $var_name = NULL)
241-
{
242-
$output = '';
243-
244-
if ( $var_name )
245-
{
246-
$output .= $var_name . ' = ';
247-
}
248-
249-
$output .= nl2br_and_nbsp(var_export($var, TRUE)) . "<br /><br />";
250-
251-
echo $output;
252-
}
253-
254-
function nl2br_and_nbsp($string)
255-
{
256-
$string = nl2br($string);
257-
258-
$string = nbsp($string);
259-
260-
return $string;
261-
}
262-
263-
function nbsp($string)
264-
{
265-
$string = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);
266-
267-
// replace more than 1 space in a row with &nbsp;
268-
$string = preg_replace('/ /m', '&nbsp;&nbsp;', $string);
269-
$string = preg_replace('/ &nbsp;/m', '&nbsp;&nbsp;', $string);
270-
$string = preg_replace('/&nbsp; /m', '&nbsp;&nbsp;', $string);
271-
272-
if ( $string == ' ' )
273-
{
274-
$string = '&nbsp;';
259+
function getSelected($arrValues, $selectedValue) {
260+
$returnArr = array();
261+
foreach($arrValues as $value) {
262+
$returnArr[$value] = ($value == $selectedValue) ? " selected" : "";
275263
}
276-
277-
// Convert 2 space tab to 4 space tab
278-
$string = preg_replace('/&nbsp;&nbsp;/m', '&nbsp;&nbsp;&nbsp;&nbsp;', $string);
279-
280-
return $string;
281-
}
282-
283-
function debug_string_backtrace() {
284-
ob_start();
285-
debug_print_backtrace();
286-
$trace = ob_get_contents();
287-
ob_end_clean();
288-
289-
// Remove first item from backtrace as it's this function which
290-
// is redundant.
291-
$trace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);
292-
293-
// sanitize HTML
294-
$trace = htmlspecialchars($trace);
295-
296-
// Put each stack trace on its own line
297-
$trace = preg_replace('/\n/', '<br />', $trace);
298-
299-
// Delete all but 1st stack trace
300-
// $trace = preg_replace('/\n.*/', '', $trace);
301-
302-
return $trace;
264+
return $returnArr;
303265
}
304266

305-
/** Dump your entire SQL table into an array. You can use this function to do a `WHERE $condition1Field = $condition1Value AND $condition2Field = $condition2Value` type query. */
306-
function sql_array_select_where($sqlTableAsArray, $condition1Field, $condition1Value, $condition2Field, $condition2Value) {
307-
$result = [];
308-
foreach ( $sqlTableAsArray as $key => $row ) {
309-
if (
310-
isset($row[$condition1Field]) &&
311-
$row[$condition1Field] == $condition1Value &&
312-
isset($row[$condition2Field]) &&
313-
$row[$condition1Field] == $condition2Value
314-
) {
315-
$result[] = $row;
316-
}
317-
}
318-
return $result;
319-
}
320267

321268
// Class Loaders
322269

323270
function BTCS4Loader($class_name) {
324-
require_once(BASE_DIRECTORY."classes/".strtolower($class_name).".php");
271+
if(file_exists(BASE_DIRECTORY."classes/".strtolower($class_name).".php")) {
272+
include_once(BASE_DIRECTORY."classes/".strtolower($class_name).".php");
273+
}
274+
elseif(file_exists(include_once(BASE_DIRECTORY."classes/formcomponents/".strtolower($class_name).".php"))) {
275+
include_once(BASE_DIRECTORY."classes/formcomponents/".strtolower($class_name).".php");
276+
}
325277
}
326278

327279
spl_autoload_register("BTCS4Loader", true, true);
328280

329-
require_once(BASE_DIRECTORY."include/phpmailer/PHPMailerAutoload.php");
281+
include_once(BASE_DIRECTORY."include/phpmailer/PHPMailerAutoload.php");
282+
?>

src/_setup.php

Lines changed: 43 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,29 @@
1313
*/
1414

1515

16-
// This setup page should not be changed. Edit _config.php to configure your website.
17-
18-
// 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.
19-
// 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.
20-
// Debug Mode features: all PHP warnings, all SQL warnings, SQL profiler (query count, list of queries)
21-
$debug = true;
22-
define('SHOUTBOX_RELOAD_MS', 20000); // 20 seconds
23-
24-
// Error reporting default = off.
25-
mysqli_report(MYSQLI_REPORT_OFF);
26-
error_reporting(0);
27-
ini_set('display_errors', '0');
28-
29-
function debug() {
30-
mysqli_report(MYSQLI_REPORT_STRICT);
31-
error_reporting(E_ALL);
32-
ini_set('display_errors', '1');
33-
}
16+
// Check PHP Version
3417

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

39-
// DECLARE GLOBAL VARIABLES
40-
$PAGE_NAME = "";
41-
$EXTERNAL_JAVASCRIPT = '';
42-
$SQL_PROFILER = [];
4322

44-
if (version_compare(PHP_VERSION, '7.0', '<')) {
45-
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).");
46-
}
23+
// This setup page should not be changed. Edit _config.php to configure your website.
4724

25+
ini_set('display_errors', 1);
4826
ini_set('session.use_only_cookies', 1);
4927
ini_set('session.gc_maxlifetime', 60*60*24*3);
5028

29+
if(!isset($prevFolder)) {
30+
$prevFolder = "";
31+
}
32+
33+
if(get_magic_quotes_gpc() == 1) {
34+
foreach($_GET as $key=>$value) { $_GET[$key] = stripslashes($value); }
35+
foreach($_POST as $key=>$value) { $_POST[$key] = stripslashes($value); }
36+
}
37+
38+
5139
if(isset($_COOKIE['btUsername']) && isset($_COOKIE['btPassword'])) {
5240
session_start();
5341
$_SESSION['btUsername'] = $_COOKIE['btUsername'];
@@ -61,22 +49,21 @@ function debug() {
6149
$_SESSION['csrfKey'] = md5(uniqid());
6250
}
6351

64-
// CONFIG.PHP INCLUDED HERE *************************
65-
require_once($prevFolder."_config.php");
66-
// **************************************************
67-
52+
include($prevFolder."_config.php");
6853
define("BASE_DIRECTORY", $BASE_DIRECTORY);
6954
//define("BASE_DIRECTORY", str_replace("//", "/", $_SERVER['DOCUMENT_ROOT'].$MAIN_ROOT));
7055
define("MAIN_ROOT", $MAIN_ROOT);
7156

72-
// FUNCTIONS.PHP INCLUDED HERE **********************
73-
require_once(BASE_DIRECTORY."_functions.php");
74-
// **************************************************
57+
58+
$PAGE_NAME = "";
59+
include_once(BASE_DIRECTORY."_functions.php");
7560

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

63+
7864
$mysqli = new btmysql($dbhost, $dbuser, $dbpass, $dbname);
7965

66+
8067
$mysqli->set_tablePrefix($dbprefix);
8168
$mysqli->set_testingMode(true);
8269

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

9582
$arrWebsiteLogoURL = parse_url($websiteInfo['logourl']);
96-
9783
if(!isset($arrWebsiteLogoURL['scheme']) || $arrWebsiteLogoURL['scheme'] == "") {
9884
$websiteInfo['logourl'] = $MAIN_ROOT."themes/".$THEME."/".$websiteInfo['logourl'];
9985
}
10086

101-
$IP_ADDRESS = $_SERVER['REMOTE_ADDR'];
87+
// Default websiteinfo values
88+
include_once(BASE_DIRECTORY."include/websiteinfo_defaults.php");
89+
90+
91+
if(!isset($_SESSION['appendIP'])) {
92+
$_SESSION['appendIP'] = substr(md5(uniqid().time()),0,10);
93+
}
10294

103-
assert_options(ASSERT_BAIL);
95+
$IP_ADDRESS = $_SERVER['REMOTE_ADDR'];
10496

10597
// Check Debug Mode
98+
10699
if($websiteInfo['debugmode'] == 1) {
107-
debug();
100+
ini_set('display_errors', 1);
101+
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT);
102+
}
103+
else {
104+
ini_set('display_errors', 0);
105+
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT);
106+
//ini_set('error_reporting', E_ALL);
108107
}
109108

109+
110110
// Check for Ban
111+
111112
$ipbanObj = new IPBan($mysqli);
112113
if($ipbanObj->isBanned($IP_ADDRESS)) {
113114
die("<script type='text/javascript'>window.location = '".$MAIN_ROOT."banned.php';</script>");
114115
}
115116

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

119+
119120
$hooksObj = new btHooks();
120121
$btThemeObj = new btTheme();
121122
$clockObj = new Clock($mysqli);
122123
$btThemeObj->setThemeDir($THEME);
123124
$btThemeObj->setClanName($CLAN_NAME);
124125
$btThemeObj->initHead();
126+
$breadcrumbObj = new BreadCrumb();
125127

126-
require_once(BASE_DIRECTORY."plugins/mods.php");
127-
128-
// Caches for commonly queried SQL tables. Need to get the # of SQL queries down.
129-
// 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.
130-
// Make sure your table has a primary_key, and that the SELECT query is picking by the primary_key.
131-
$tablesToCache = [
132-
'clocks' => 'clock_id',
133-
'console' => 'console_id',
134-
// 'console_members' => 'privilege_id',
135-
'consolecategory' => 'consolecategory_id',
136-
'gamesplayed' => 'gamesplayed_id',
137-
'menu_category' => 'menucategory_id',
138-
'menu_item' => 'menuitem_id',
139-
'menuitem_link' => 'menulink_id',
140-
// 'rank_privileges' => 'privilege_id',
141-
'rankcategory' => 'rankcategory_id',
142-
'ranks' => 'rank_id',
143-
];
144-
$sqlCache = [];
145-
foreach ( $tablesToCache as $table => $primaryKey ) {
146-
$sqlCache[$table] = [];
147-
$result = $mysqli->query("SELECT * FROM ".$dbprefix.$table);
148-
if ( $result ) {
149-
while ( $row = $result->fetch_assoc() ) {
150-
$sqlCache[$table][$row[ $primaryKey ]] = $row;
151-
}
152-
}
153-
}
154-
155-
// classes/member.php::hasAccess()
156-
$sqlCache['console_members'] = [];
157-
$result = $mysqli->query("SELECT * FROM ".$dbprefix."console_members");
158-
if ( $result ) {
159-
while ( $row = $result->fetch_assoc() ) {
160-
$sqlCache['console_members'][] = $row;
161-
}
162-
}
163-
164-
// classes/consoleoptions.php::hasAccess()
165-
$sqlCache['rank_privileges'] = [];
166-
$result = $mysqli->query("SELECT * FROM ".$dbprefix."rank_privileges");
167-
if ( $result ) {
168-
while ( $row = $result->fetch_assoc() ) {
169-
$sqlCache['rank_privileges'][] = $row;
170-
}
171-
}
128+
include_once(BASE_DIRECTORY."plugins/mods.php");
129+
?>

src/classes/access.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
*
1414
*/
1515

16-
require_once("btmysql.php");
17-
require_once("rank.php");
18-
require_once("rankcategory.php");
19-
require_once("member.php");
16+
include_once("btmysql.php");
17+
include_once("rank.php");
18+
include_once("rankcategory.php");
19+
include_once("member.php");
2020

2121

2222
class Access {

0 commit comments

Comments
 (0)