Skip to content

Commit

Permalink
Merge pull request #134 from startersclan/fix/asp-fix-getawardsinfo.a…
Browse files Browse the repository at this point in the history
…spx-not-logging-to-stderr-in-docker

Fix (ASP): Fix `getawardsinfo.aspx` not logging to stderr in docker
  • Loading branch information
leojonathanoh authored Nov 9, 2023
2 parents 3ff0dda + 17f391e commit 3c7cc05
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/ASP/getawardsinfo.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ require(SYSTEM_PATH . DS . 'functions.php');
// Set Error Reporting
error_reporting(E_ALL);
ini_set("log_errors", "1");
ini_set("error_log", SYSTEM_PATH . DS . 'logs' . DS . 'php_errors.log');
if (!getenv('PHP_VERSION')) {
# Not running in docker. Log errors to file
ini_set("error_log", SYSTEM_PATH . DS . 'logs' . DS . 'php_errors.log');
}
ini_set("display_errors", "0");

//Disable Zlib Compression
Expand All @@ -62,44 +65,44 @@ else
$connection = Database::Connect('bf2stats',
array(
'driver' => 'mysql',
'host' => Config::Get('db_host'),
'port' => Config::Get('db_port'),
'database' => Config::Get('db_name'),
'username' => Config::Get('db_user'),
'host' => Config::Get('db_host'),
'port' => Config::Get('db_port'),
'database' => Config::Get('db_name'),
'username' => Config::Get('db_user'),
'password' => Config::Get('db_pass')
)
);
}
catch( Exception $e ) {
$out = "E\nH\tasof\terr\n" .
$out = "E\nH\tasof\terr\n" .
"D\t" . time() . "\tDatabase Connect Error\n";
$num = strlen(preg_replace('/[\t\n]/', '', $out));
$out .= "$\t$num\t$";
die($out);
}

// Prepare our output header
$out = "O\n" .
"H\tpid\tasof\n" .
"D\t$pid\t" . time() . "\n" .
"H\taward\tlevel\twhen\tfirst\n";

// Query and get all of the Players awards
$query = "SELECT `awd`, `level`, `earned`, `first` FROM `awards` WHERE `id` = :pid ORDER BY `id`";

// Use a prepared statement to prevent Sql Injection (level 1)
$stmt = $connection->prepare($query);
$stmt->bindValue(':pid', intval($pid), PDO::PARAM_INT);

// try and execute the prepared statement
$result = $stmt->execute();
while($row = $stmt->fetch())
{
$first = (($row['awd'] > 2000000) && ($row['awd'] < 3000000)) ? $row['first'] : 0;
$out .= "D\t{$row['awd']}\t{$row['level']}\t{$row['earned']}\t{$first}\n";
}

$num = strlen(preg_replace('/[\t\n]/','',$out));
print $out . "$\t" . $num . "\t$";
}
?>
?>

0 comments on commit 3c7cc05

Please sign in to comment.