diff options
author | Matthijs Kuiper <info@matthijskuiper.nl> | 2017-02-07 01:46:48 +0100 |
---|---|---|
committer | Matthijs Kuiper <info@matthijskuiper.nl> | 2017-02-07 01:50:06 +0100 |
commit | 3f77d02c3631becfa96acc7aaedc9dfad379fdd2 (patch) | |
tree | d9055dda336e87096ea02f5c56f49fba81e32ccb /html | |
parent | fb6cb4ff3d4a84185c72c572bb26d0c5b868773a (diff) |
Move db connect from config to functions
Diffstat (limited to 'html')
-rwxr-xr-x | html/includes/config.php | 78 | ||||
-rwxr-xr-x | html/includes/functions.php | 85 |
2 files changed, 73 insertions, 90 deletions
diff --git a/html/includes/config.php b/html/includes/config.php index 7e9bd6f..7b086f6 100755 --- a/html/includes/config.php +++ b/html/includes/config.php @@ -5,9 +5,6 @@ $hostname = ""; $uname = "";
$upass = "";
-$dbconnect = mysql_connect($hostname,$uname,$upass);
-$dbconnect2 = mysql_select_db($dbname);
-
// The key needed to run the import script
$import_adminkey = 'fietsbel';
@@ -19,11 +16,11 @@ $import_homedir = ''; // Use the MySQL temporary tables feature?
// Available since MySQL 3.23 - requires CREATE TEMPORARY TABLE privilege since 4.0.2
-$import_use_temporary_tables = true; // set to true if available
+$import_use_temporary_tables = true; // set to true if available
// Use temporary heap tables?
// This will (at any cost) keep the entire table in RAM and may speed and/or fuck things up
-$import_use_heap_tables = false; // DON'T USE IF YOU DON'T KNOW WHAT YOU'RE DOING!
+$import_use_heap_tables = false; // DON'T USE IF YOU DON'T KNOW WHAT YOU'RE DOING!
// Log files start with...
$import_log_start = "Unreal.ngLog";
@@ -141,48 +138,49 @@ $pic_enable = true; // FTP Connection Details
-$ftp_use = false; // Whether to auto get the log files
-$ftp_interval = 0; // How often in minutes to allow stats update
-$ftp_type = 'sockets'; // Which FTP module do you want to use?
- // sockets - (recommended)
- // Use PHP's socket extension to connect to the FTP server
- // will fallback to 'pure' if no sockets available
- // pure - Use fsockopen() to connnect to the FTP server
- // should work with any php version
- // php - Use PHP's FTP extension (must be compiled in)
- // Debugging will not be available with this module and
- // error handling may not be as good as with the other modules
+$ftp_use = false; // Whether to auto get the log files
+$ftp_interval = 0; // How often in minutes to allow stats update
+$ftp_type = 'sockets'; // Which FTP module do you want to use?
+ // sockets - (recommended)
+ // Use PHP's socket extension to connect to the FTP server
+ // will fallback to 'pure' if no sockets available
+ // pure - Use fsockopen() to connnect to the FTP server
+ // should work with any php version
+ // php - Use PHP's FTP extension (must be compiled in)
+ // Debugging will not be available with this module and
+ // error handling may not be as good as with the other modules
-$ftp_debug = false; // Debugging output that may help you to resolve ftp problems
+$ftp_debug = false; // Debugging output that may help you to resolve ftp problems
// UT Server 1
$i = 0;
-$ftp_hostname[$i] = ''; // FTP server location here
-$ftp_port[$i] = 21; // FTP Port - do not remove this even if you do not use ftp
- // Do not add '' around the port either
-$ftp_uname[$i] = ''; // FTP Username
-$ftp_upass[$i] = ''; // FTP Password
-$ftp_dir[$i][] = '/'; // Directory of the log files - MUST NOT end with a /
-//$ftp_dir[$i][] = '/'; // You may repeat this entry as often as you wish but please remember
-//$ftp_dir[$i][] = '/'; // to enter the directory relative to the last one
-//$ftp_dir[$i][] = '/'; // (or use an absolute path)
-$ftp_passive[$i] = true; // Use passive transfer mode for this connection?
-$ftp_delete[$i] = true; // Delete logs after download?
+$ftp_hostname[$i] = ''; // FTP server location here
+$ftp_port[$i] = 21; // FTP Port - do not remove this even if you do not use ftp
+ // Do not add '' around the port either
+$ftp_uname[$i] = ''; // FTP Username
+$ftp_upass[$i] = ''; // FTP Password
+$ftp_dir[$i][] = '/'; // Directory of the log files - MUST NOT end with a /
+// $ftp_dir[$i][] = '/'; // You may repeat this entry as often as you wish but please remember
+// $ftp_dir[$i][] = '/'; // to enter the directory relative to the last one
+// $ftp_dir[$i][] = '/'; // (or use an absolute path)
+$ftp_passive[$i] = true; // Use passive transfer mode for this connection?
+$ftp_delete[$i] = true; // Delete logs after download?
/*
// UT Server 2 --- Uncomment this one if needed, or copy/paste the block above if more servers are needed.
$i++;
-$ftp_hostname[$i] = ''; // FTP server location here
-$ftp_port[$i] = 21; // FTP Port - do not remove this even if you do not use ftp
- // Do not add '' around the port either
-$ftp_uname[$i] = ''; // FTP Username
-$ftp_upass[$i] = ''; // FTP Password
-$ftp_dir[$i][] = '/'; // Directory of the log files - MUST NOT end with a /
-//$ftp_dir[$i][] = '/'; // You may repeat this entry as often as you wish but please remember
-//$ftp_dir[$i][] = '/'; // to enter the directory relative to the last one
-//$ftp_dir[$i][] = '/'; // (or use an absolute path)
-$ftp_passive[$i] = true; // Use passive transfer mode for this connection?
-$ftp_delete[$i] = true; // Delete logs after download?
+$ftp_hostname[$i] = ''; // FTP server location here
+$ftp_port[$i] = 21; // FTP Port - do not remove this even if you do not use ftp
+ // Do not add '' around the port either
+$ftp_uname[$i] = ''; // FTP Username
+$ftp_upass[$i] = ''; // FTP Password
+$ftp_dir[$i][] = '/'; // Directory of the log files - MUST NOT end with a /
+// $ftp_dir[$i][] = '/'; // You may repeat this entry as often as you wish but please remember
+// $ftp_dir[$i][] = '/'; // to enter the directory relative to the last one
+// $ftp_dir[$i][] = '/'; // (or use an absolute path)
+$ftp_passive[$i] = true; // Use passive transfer mode for this connection?
+$ftp_delete[$i] = true; // Delete logs after download?
*/
-?>
\ No newline at end of file +
+?>
diff --git a/html/includes/functions.php b/html/includes/functions.php index 1975914..b8cab68 100755 --- a/html/includes/functions.php +++ b/html/includes/functions.php @@ -1,6 +1,12 @@ <?php
+// Connect to database
+mysql_connect($hostname, $uname, $upass);
+mysql_select_db($dbname);
+
+// Error reporting
// error_reporting(E_ALL & ~E_NOTICE);
-error_reporting(0);
+// error_reporting(-1); // Turn on all errors
+error_reporting(0); // Turn off all errors
@ini_set('track_errors', '1');
// Image Rotation Code
@@ -27,14 +33,14 @@ require_once(dirname(__FILE__) .'/countries.php'); // Addslashes if magic_quotes are off
function my_addslashes($data) {
- IF (!get_magic_quotes_gpc()) {
+ if (!get_magic_quotes_gpc()) {
$data = addslashes($data);
}
return $data;
}
function my_stripslashes($data) {
- IF (!get_magic_quotes_gpc()) {
+ if (!get_magic_quotes_gpc()) {
$data = $data;
} else {
$data = stripslashes($data);
@@ -46,7 +52,7 @@ function my_fgets($fp, $length = -1, $compression = 'none') { static $use_fgets = NULL;
if ($use_fgets === NULL) $use_fgets = (version_compare(phpversion(), "4.3.0", ">=")) ? true : false;
-
+
if ($use_fgets and $compression == 'none') {
if ($length == -1) {
return(fgets($fp));
@@ -54,7 +60,7 @@ function my_fgets($fp, $length = -1, $compression = 'none') { return(fgets($fp, $length));
}
}
-
+
$buffer = '';
$i = 0;
while(!feof($fp)) {
@@ -90,7 +96,7 @@ function my_fopen($filename, $mode, &$compression) { }
}
}
-
+
switch($compression) {
case 'bz2': $fp = @bzopen($filename, $mode); break;
case 'zlib': $fp = @gzopen($filename, $mode); break;
@@ -99,17 +105,14 @@ function my_fopen($filename, $mode, &$compression) { return($fp);
}
-
function my_fclose($fp, $compression) {
switch($compression) {
case 'bz2': return(@bzclose($fp));
case 'zlib': return(@gzclose($fp));
default: return(@fclose($fp));
}
-
}
-
// Small query
function small_query($query) {
$sql_small = "$query";
@@ -127,22 +130,21 @@ function small_count($query) { }
// uid generator
-function str_rand($length = 8, $seeds = 'abcdefghijklmnopqrstuvwxyz0123456789')
-{
- $str = '';
- $seeds_count = strlen($seeds);
-
- // Seed
- list($usec, $sec) = explode(' ', microtime());
- $seed = (float) $sec + ((float) $usec * 100000);
- mt_srand($seed);
-
- // Generate
- for ($i = 0; $length > $i; $i++) {
- $str .= $seeds{mt_rand(0, $seeds_count - 1)};
- }
+function str_rand($length = 8, $seeds = 'abcdefghijklmnopqrstuvwxyz0123456789') {
+ $str = '';
+ $seeds_count = strlen($seeds);
+
+ // Seed
+ list($usec, $sec) = explode(' ', microtime());
+ $seed = (float) $sec + ((float) $usec * 100000);
+ mt_srand($seed);
+
+ // Generate
+ for ($i = 0; $length > $i; $i++) {
+ $str .= $seeds{mt_rand(0, $seeds_count - 1)};
+ }
- return $str;
+ return $str;
}
function zero_out($data) {
@@ -192,7 +194,6 @@ function mtimestamp($date) { }
function mdate($date) {
-
$ourdate = date('D, M j Y \a\t g:i a', mtimestamp($date));
return ($ourdate);
}
@@ -229,7 +230,7 @@ function btcaptime($time) { }
if ($time < 0) {
return "-:--";
- }
+ }
$minutes = intval($time / 60);
$seconds = intval($time % 60);
$hundreds = substr($time, -2, 2);
@@ -240,31 +241,25 @@ function btcaptime($time) { $hundreds = "00";
}
if ($seconds < 10) {
- $seconds = "0" . $seconds;
- }
+ $seconds = "0" . $seconds;
+ }
return $minutes . ":" . $seconds . ":" . $hundreds;
}
// UT Server Query Functions
-function GetItemInfo ($itemname, $itemchunks)
-{
-
+function GetItemInfo ($itemname, $itemchunks) {
$retval = "N/A";
for ($i = 0; $i < count($itemchunks); $i++) {
//Found this item
-
if (strcasecmp($itemchunks[$i], $itemname) == 0) {
$retval = $itemchunks[$i+1];
-
}
}
- //Return value
- return $retval;
+ return $retval;
}
-function GetMinutes($seconds)
-{
+function GetMinutes($seconds) {
$timemins = intval($seconds / 60);
$timesecs = ($seconds % 60);
@@ -274,7 +269,6 @@ function GetMinutes($seconds) return $timemins . ":" . $timesecs;
}
-
function FlagImage($country, $mini = true) {
global $a_countries;
$width = ($mini) ? 15 : 18;
@@ -285,7 +279,6 @@ function FlagImage($country, $mini = true) { return('<img src="images/flags/'. $country .'.png" width="'.$width.'" height="'.$height.'" style="border:0;" alt="'. $country .'" title="'. $countryname .'">');
}
-
function RankMovement($diff) {
$diff = round($diff, 2);
if ($diff == 0) {
@@ -310,9 +303,7 @@ function RankMovement($diff) { return($moveimg);
}
-
function ordinal($number) {
-
// when fed a number, adds the English ordinal suffix. Works for any
// number, even negatives
@@ -347,7 +338,6 @@ function ordinal($number) { return $suffix;
}
-
function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $format = NULL, $rankchange = NULL) {
$points = 0;
@@ -371,7 +361,6 @@ function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $for if ($rankchange !== NULL) {
$moveimg = ' '. RankMovement($rankchange);
}
-
if (empty($format)) {
if ($img) {
@@ -386,7 +375,6 @@ function RankImageOrText($pid, $name, $rank, $gid, $gamename, $mini = true, $for return(str_replace($search, $replace, $format));
}
-
function FormatPlayerName($country, $pid, $name, $gid = NULL, $gamename = NULL, $mini = true, $rankchange = NULL) {
static $cache = array();
@@ -410,7 +398,6 @@ function QuoteHintText($text) { return(str_replace($search, $replace, $text));
}
-
function OverlibPrintHint($name, $text = NULL, $caption = NULL) {
include(dirname(__FILE__) .'/hints.php');
if (!isset($hint[$name]) and empty($text)) return('');
@@ -481,7 +468,6 @@ function compress_file($method, $in, $out, $stripx00) { if ($bytes === false) return(false);
}
-
@fclose($fp_in);
switch($method) {
case 'bz2': @bzclose($fp_out); break;
@@ -513,7 +499,7 @@ function backup_logfile($method, $filename, $backupfilename, $stripx00) { default:
if ($stripx00) {
- if (compress_file('none', $filename, $backupfilename, $stripx00)) {
+ if (compress_file('none', $filename, $backupfilename, $stripx00)) {
return('Succeeded (uncompressed)');
} else {
return('FAILED' . (!empty($php_errormsg) ? ': '. $php_errormsg : ''));
@@ -549,7 +535,6 @@ function purge_backups($dir, $maxage) { return($deleted);
}
-
function file_size_info($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
@@ -570,13 +555,13 @@ function GetCurrentWatchlist() { }
function PlayerOnWatchlist($pid) {
- $watchlist = GetCurrentWatchlist();
+ $watchlist = GetCurrentWatchlist();
return(in_array($pid, $watchlist));
}
function ToggleWatchStatus($pid) {
$watchlist = GetCurrentWatchlist();
-
+
if (in_array($pid, $watchlist)) {
$key = array_search($pid, $watchlist);
unset($watchlist[$key]);
|