Skip to content

Commit

Permalink
More Fixes -- Some Found, Some Reported
Browse files Browse the repository at this point in the history
Fixes some resource issues.
- Fixes vehicle stats tab in player stats page.
- Fixes possible double forward slashes issue.
- More compatibility solutions for image resources for web servers with .htaccess restrictions.
  • Loading branch information
tyger07 committed Jun 17, 2021
1 parent fdfb3bc commit 047b040
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 74 deletions.
141 changes: 73 additions & 68 deletions common/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,84 +45,87 @@ function Statsout($damagetype,$weapon_array,$PlayerID,$ServerID,$valid_ids,$Game
");
}
// see if we have any records for this player for this category
if(@mysqli_num_rows($Weapon_q) != 0)
if($damagetype != 'VehicleCustom')
{
echo '
<table class="prettytable">
<tr>
<th width="23%" style="text-align:left;padding-left: 10px;">Weapon Name</th>
<th width="19%" style="text-align:left;padding-left: 5px;"><span class="orderedDESCheader">Kills</span></th>
<th width="19%" style="text-align:left;padding-left: 10px;">Deaths</th>
<th width="19%" style="text-align:left;padding-left: 10px;">Headshots</th>
<th width="20%" style="text-align:left;padding-left: 10px;">Headshot Ratio</th>
</tr>
';
// set default count value
$count = 0;
while($Weapon_r = @mysqli_fetch_assoc($Weapon_q))
if(@mysqli_num_rows($Weapon_q) != 0)
{
// show expand/contract if very long
if($count == 5)
echo '
<table class="prettytable">
<tr>
<th width="23%" style="text-align:left;padding-left: 10px;">Weapon Name</th>
<th width="19%" style="text-align:left;padding-left: 5px;"><span class="orderedDESCheader">Kills</span></th>
<th width="19%" style="text-align:left;padding-left: 10px;">Deaths</th>
<th width="19%" style="text-align:left;padding-left: 10px;">Headshots</th>
<th width="20%" style="text-align:left;padding-left: 10px;">Headshot Ratio</th>
</tr>
';
// set default count value
$count = 0;
while($Weapon_r = @mysqli_fetch_assoc($Weapon_q))
{
// show expand/contract if very long
if($count == 5)
{
echo '
</table>
<div>
<span class="expanded' . $ID . '">
<table class="prettytable" style="margin-top: -2px;">
';
}
$count++;
$weapon = $Weapon_r['Friendlyname'];
// rename 'Death'
if($weapon == 'Death')
{
$weapon = 'Machinery';
}
// convert weapon to friendly name
if(in_array($weapon,$weapon_array))
{
$weapon_name = array_search($weapon,$weapon_array);
$weapon_img = './common/images/weapons/' . $weapon . '.png';
}
// this weapon is missing!
else
{
$weapon_name = preg_replace("/_/"," ",$weapon);
$weapon_img = './common/images/weapons/missing.png';
}
$kills = $Weapon_r['Kills'];
$deaths = $Weapon_r['Deaths'];
$headshots = $Weapon_r['Headshots'];
$ratio = round(($Weapon_r['HSR']*100),2);
echo '
</table>
<div>
<span class="expanded' . $ID . '">
<table class="prettytable" style="margin-top: -2px;">
<tr>
<td width="23%" class="tablecontents" style="text-align: left;"><table width="100%" border="0"><tr><td width="120px"><img src="'. $weapon_img . '" style="height: 57px; width: 95px;" alt="' . $weapon_name . '" /></td><td style="text-align: left;" valign="middle"><font class="information">' . $weapon_name . '</font></td></tr></table></td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $kills . '</td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $deaths . '</td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $headshots . '</td>
<td width="20%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $ratio . ' <font class="information">%</font></td>
</tr>
';
}
$count++;
$weapon = $Weapon_r['Friendlyname'];
// rename 'Death'
if($weapon == 'Death')
{
$weapon = 'Machinery';
}
// convert weapon to friendly name
if(in_array($weapon,$weapon_array))
{
$weapon_name = array_search($weapon,$weapon_array);
$weapon_img = './common/images/weapons/' . $weapon . '.png';
}
// this weapon is missing!
else
// finish expand/contract if very long
if($count > 5)
{
$weapon_name = preg_replace("/_/"," ",$weapon);
$weapon_img = './common/images/weapons/missing.png';
$remaining = $count - 5;
echo '
</table>
</span>
<a href="javascript:void(0)" class="collapsed' . $ID . '"><table class="prettytable" style="margin-top: -2px;"><tr><td class="tablecontents" style="text-align: left;padding-left: 15px;"><span class="orderedDESCheader">Show ' . $remaining . ' More</span></td></tr></table></a>
</div>
<table>
<tr>
<td>
</td>
</tr>
';
}
$kills = $Weapon_r['Kills'];
$deaths = $Weapon_r['Deaths'];
$headshots = $Weapon_r['Headshots'];
$ratio = round(($Weapon_r['HSR']*100),2);
echo '
<tr>
<td width="23%" class="tablecontents" style="text-align: left;"><table width="100%" border="0"><tr><td width="120px"><img src="'. $weapon_img . '" style="height: 57px; width: 95px;" alt="' . $weapon_name . '" /></td><td style="text-align: left;" valign="middle"><font class="information">' . $weapon_name . '</font></td></tr></table></td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $kills . '</td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $deaths . '</td>
<td width="19%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $headshots . '</td>
<td width="20%" class="tablecontents" style="text-align: left;padding-left: 10px;">' . $ratio . ' <font class="information">%</font></td>
</tr>
';
}
// finish expand/contract if very long
if($count > 5)
{
$remaining = $count - 5;
echo '
</table>
</span>
<a href="javascript:void(0)" class="collapsed' . $ID . '"><table class="prettytable" style="margin-top: -2px;"><tr><td class="tablecontents" style="text-align: left;padding-left: 15px;"><span class="orderedDESCheader">Show ' . $remaining . ' More</span></td></tr></table></a>
</div>
<table>
<tr>
<td>
</td>
</tr>
';
}
echo '
</table>
';
}
// vehicle stats for 'VehicleCustom' array
elseif($damagetype == 'VehicleCustom')
Expand Down Expand Up @@ -1543,9 +1546,11 @@ function session_count($userip, $ServerID, $valid_ids, $GameID, $BF4stats, $page
{
$host = 'http://' . $_SERVER['HTTP_HOST'];
}
$dir = dirname($_SERVER['PHP_SELF']);
$dir = dirname($_SERVER['PHP_SELF']) . '/index.php';
// remove double slashes
$dir = preg_replace('/(\/+)/', '/', $dir);
// build redirect link
$redirect = $host . $dir . '/index.php';
$redirect = $host . $dir;
if(!empty($ServerID))
{
$redirect .= '?sid=' . $ServerID;
Expand Down
10 changes: 6 additions & 4 deletions common/player/player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,9 @@ function drawVisualization() {
{
$host = 'http://' . $_SERVER['HTTP_HOST'];
}
$dir = dirname($_SERVER['PHP_SELF']);
$dir = dirname($_SERVER['PHP_SELF']) . '/common/signature/';
// remove double slashes
$dir = preg_replace('/(\/+)/', '/', $dir);
$file = $_SERVER['PHP_SELF'];
// show signature images
echo '
Expand All @@ -1339,7 +1341,7 @@ function drawVisualization() {
// include signature.php image
echo '
<br/><br/>
<a href="' . $host . $dir . '/common/signature/signaturepid' . $PlayerID . 'fav0.png" target="_blank"><img src="./common/signature/signature.php?fav=0&amp;pid=' . $PlayerID;
<a href="' . $host . $dir . 'signature.php?fav=0&amp;pid=' . $PlayerID . '" target="_blank"><img src="' . $host . $dir . 'signature.php?fav=0&amp;pid=' . $PlayerID;
if(!empty($cr))
{
echo '&amp;cr=' . $cr;
Expand All @@ -1355,7 +1357,7 @@ function drawVisualization() {
<table class="prettytable">
<tr>
<td class="tablecontents">
<span style="font-size: 10px;">[URL=' . $host . $file . '?p=player&amp;pid=' . $PlayerID . '][IMG]' . $host . $dir . '/common/signature/signaturepid' . $PlayerID . 'fav0.png[/IMG][/URL]</span>
<span style="font-size: 10px;">[URL=' . $host . $file . '?p=player&amp;pid=' . $PlayerID . '][IMG]' . $host . $dir . 'signaturepid' . $PlayerID . 'fav0.png[/IMG][/URL]</span>
</td>
</tr>
</table>
Expand All @@ -1365,7 +1367,7 @@ function drawVisualization() {
<table class="prettytable">
<tr>
<td class="tablecontents">
<span style="font-size: 10px;">[URL=' . $host . $file . '?p=player&amp;pid=' . $PlayerID . '][IMG]' . $host . $dir . '/common/signature/signaturepid' . $PlayerID . 'fav1.png[/IMG][/URL]</span>
<span style="font-size: 10px;">[URL=' . $host . $file . '?p=player&amp;pid=' . $PlayerID . '][IMG]' . $host . $dir . 'signaturepid' . $PlayerID . 'fav1.png[/IMG][/URL]</span>
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion common/server/server-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<tr>
<td class="tablecontents" width="240px">
<br/>
<center><a href="' . $host . $dir . '/server-banner/image-bannersid' . $ServerID . '.png" target="_blank"><img src="./common/server-banner/image-banner.php?sid=' . $ServerID . '" style="width: 560px; height: 95px;" alt="banner"/></a></center>
<center><a href="' . $host . $dir . '/server-banner/image-banner.php?sid=' . $ServerID . '" target="_blank"><img src="./common/server-banner/image-banner.php?sid=' . $ServerID . '" style="width: 560px; height: 95px;" alt="banner"/></a></center>
<br/>
<div class="headline" style="width: 550px; text-align: left;">BBcode</div>
<table class="prettytable" style="width: 550px;">
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
$xmlData = @file_get_contents('https://github.com/tyger07/BF4-Server-Stats/releases.atom');
$xml=@simplexml_load_string($xmlData);
$releaseVersion = $xml->entry[0]->id;
if((!empty($releaseVersion)) && (stripos($releaseVersion, '5-17-21') === false))
if((!empty($releaseVersion)) && (stripos($releaseVersion, '6-16-21') === false))
{
echo '
<div class="subsection">
Expand Down

0 comments on commit 047b040

Please sign in to comment.