$player_id = $row['player_id']; $type = $row['type']; $uploaded = $row['uploaded']; $extension = $row['extension']; $comment = $row['comment']; $name = $row['name']; $rating = $row['rating']; $votes = $row['votes']; if ($rating > 0) { if ($votes > 1) { $s = "s"; } else { $s = ""; } $rateText = "<p>Rated <b>".format2DigitsMax($rating)."</b> of 5 from <b>".$votes."</b> vote$s</p>"; } else { $rateText = "<p>(not rated yet)</p>"; } $fileNameNoExt = $player_id."_".$uploaded; $fileName = $fileNameNoExt.'.'.$extension; $fileUrl = 'files/goals/' . $fileName; $imgSrcStatic = '/files/goals/thumbnails/' . $fileNameNoExt.'_thumb.png'; if (file_exists($wwwroot.$imgSrcStatic)) { $imgSrc = '<img height="96" width="128" src="'.$directory.$imgSrcStatic.'" border="1">'; } else { $imgSrc = '<img height="96" width="128" src="'.$directory.'/gfx/thumb_missing.gif" border="1">'; } $fileLink = '<a href="' . $fileUrl . '">' . $fileName . '</a>';
function getTeamBonus($winteam, $loseteam, $isDraw, $winpoints) { // team bonus $msg = ""; $winteamCategory = getCategoryForTeam($winteam); $loseteamCategory = getCategoryForTeam($loseteam); $categories = getCategoriesArray(); $bonusWinner = 0; if ($winteamCategory == 0 || $loseteamCategory == 0) { $msg .= "<p>Uncategorised team(s), no team bonus</p>"; } else { $winteamPoints = $categories[$winteamCategory]; $loseteamPoints = $categories[$loseteamCategory]; $winteamName = getNameForTeam($winteam); $loseteamName = getNameForTeam($loseteam); if ($winteamPoints < $loseteamPoints) { $msg .= "<p>{$winteamName} team points: <b>{$winteamPoints}</b><br>"; $msg .= "{$loseteamName} team points: <b>{$loseteamPoints}</b><br>"; if ($isDraw > 0) { $normalBonus = abs($loseteamPoints - $winteamPoints); $bonusFactor = format2DigitsMax($winpoints / 30); $bonusWinner = round($normalBonus * $bonusFactor); $msg .= "Team draw bonus using {$winteamName}: {$normalBonus}*{$bonusFactor} ~ <b>{$bonusWinner}</b></p>"; } else { $bonusWinnerDifference = $loseteamPoints - $winteamPoints; $bonusFactor = format2DigitsMax($winpoints / 30); $bonusWinner = round($bonusWinnerDifference * $bonusFactor); $msg .= "Team bonus using {$loseteamName}: {$bonusWinnerDifference}*{$bonusFactor} ~ <b>{$bonusWinner}</b></p>"; } } else { if ($winteamPoints == $loseteamPoints) { $msg .= "<p>Equal teams, no team bonus</p>"; } else { if ($isDraw > 0) { $msg .= "<p>No team bonus</p>"; } else { $msg = "<p>Better team won, no team bonus</p>"; } } } } return array('bonusWinner' => $bonusWinner, 'msg' => $msg); }