Skip to content

Commit

Permalink
Enhancement (config): Use constants instead of variables for configur…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
leojonathanoh committed Dec 20, 2023
1 parent 2bed1ca commit 88c0c9a
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"editor.trimAutoWhitespace": false,
"files.associations": {
"*.ai": "bat",
"*.ai.add": "bat",
"*.con": "ini",
"*.aspx": "php",
},
// "editor.trimAutoWhitespace": false
"files.trimTrailingWhitespace": false,
}
10 changes: 5 additions & 5 deletions src/bf2sclone/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function defineVar($name, $default) {
}

// Database connection information
$DBIP = getVar('DBIP', '127.0.0.1');
$DBNAME = getVar('DBNAME', 'bf2stats');
$DBLOGIN = getVar('DBLOGIN', 'admin');
$DBPASSWORD = getVar('DBPASSWORD', 'admin');
defineVar('DBIP', '127.0.0.1');
defineVar('DBNAME', 'bf2stats');
defineVar('DBLOGIN', 'admin');
defineVar('DBPASSWORD', 'admin');

// Leader board title
$TITLE = getVar('TITLE', 'BF2S Clone');
defineVar('TITLE', 'BF2S Clone2');

// Refresh time in seconds for stats
defineVar('RANKING_REFRESH_TIME', 600); // -> default: 600 seconds (10 minutes)
Expand Down
6 changes: 3 additions & 3 deletions src/bf2sclone/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
include('config.inc.php');

// Setup the database connection
$link = mysqli_connect($DBIP, $DBLOGIN, $DBPASSWORD) or die('Could not connect: ' . mysqli_error($GLOBALS['link']));
mysqli_select_db($GLOBALS['link'], $DBNAME) or die('Could not select database');
$link = mysqli_connect(DBIP, DBLOGIN, DBPASSWORD) or die('Could not connect: ' . mysqli_error($GLOBALS['link']));
mysqli_select_db($GLOBALS['link'], DBNAME) or die('Could not select database');

// process page start:
$time_start = microtime(true);
Expand Down Expand Up @@ -254,7 +254,7 @@
$s['data'] = loadGamespyData($s['ip'], $s['queryport']);
$serversWithGamespyData[] = $s;
}
$servers = $serversWithGamespyData;
$servers = $serversWithGamespyData;
unset($serversWithGamespyData);

// Include our template file
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/current-ranking.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>Rankings, '. $TITLE .'</title>
<title>Rankings, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/two-tiers.css">
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .'</title>
<title>' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -21,7 +21,7 @@
<div id="page-1">
<div id="page-2">
<h1 id="page-title">'. $TITLE .' Leaderboard</h1>
<h1 id="page-title">'. esc_attr(TITLE) .' Leaderboard</h1>
<div id="page-3">
<div id="content"><div id="content-id">
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/my-leaderboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>My Leader Board, '. $TITLE .'</title>
<title>My Leader Board, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/playerstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>' . $player['name'] .' '. getRankByID($player['rank']) . ' Stats, '. $TITLE .'</title>
<title>' . esc_attr($player['name'] . ' ' . getRankByID($player['rank']) . ' Stats, ' . TITLE) . '</title>
<link rel="icon" href="' . $ROOT . 'favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="' . $ROOT . 'favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" media="screen" href="'.$ROOT.'css/two-tiers.css">
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>Search Players, '. $TITLE .'</title>
<title>Search Players, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. ($s['data'] ? esc_attr($s['data']['server']['hostname']) . ', ' . $TITLE : '-') . '</title>
<title>' . (isset($s['data']) ? esc_attr($s['data']['server']['hostname']) . ', ' : 'Unknown server, ') . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand Down
2 changes: 1 addition & 1 deletion src/bf2sclone/template/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>' . esc_attr('Servers, ' . $TITLE) . '</title>
<title>Servers, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-badges-sf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - SF Badges</title>
<title>SF Badges, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 SF Badges<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 SF Badges<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-badges.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - Badges</title>
<title>Badges, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 Badges<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 Badges<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - UBAR</title>
<title>UBAR, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">UBAR<small> '. $TITLE .' Battlefield 2 Awards and Ranks Guide</small></h1>
<h1 id="page-title">UBAR<small> ' . esc_attr(TITLE) . ' Battlefield 2 Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-medals-sf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - SF Medals</title>
<title>SF Medals, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 SF Medals<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 SF Medals<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-medals.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - Medals</title>
<title>Medals, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 Medals<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 Medals<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-ranks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - Ranks</title>
<title>Ranks, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 Ranks<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 Ranks<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-ribbons-sf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - SF Ribbons</title>
<title>SF Ribbons, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 SF Ribbons<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 SF Ribbons<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-ribbons.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - Ribbons</title>
<title>Ribbons, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 Ribbons<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 Ribbons<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down
4 changes: 2 additions & 2 deletions src/bf2sclone/template/ubar-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="inner">
<head>
<title>'. $TITLE .' - Ribbons</title>
<title>Ribbons, ' . esc_attr(TITLE) . '</title>
<link rel="icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="'.$ROOT.'favicon.ico" type="image/x-icon">
Expand All @@ -22,7 +22,7 @@
<body class="inner">
<div id="page-1">
<div id="page-2">
<h1 id="page-title">BF2 Badges<small> '. $TITLE .' Awards and Ranks Guide</small></h1>
<h1 id="page-title">BF2 Badges<small> ' . esc_attr(TITLE) . ' Awards and Ranks Guide</small></h1>
<div id="page-3">
<div id="content"><div id="content-id"><!-- template header end == begin content below -->
Expand Down

0 comments on commit 88c0c9a

Please sign in to comment.