saving php5 version
This commit is contained in:
commit
c2c1ee7b9b
46 changed files with 817 additions and 0 deletions
168
functions.php
Executable file
168
functions.php
Executable file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
function add_icon ($icon) {
|
||||
$path = "./icons/$icon.png";
|
||||
$size = getimagesize($path);
|
||||
$width = $size[0];
|
||||
$height = $size[1];
|
||||
return "<img src=\"$path\" width=\"$width\" height=\"$height\" alt=\"$icon\" border=\"0\">";
|
||||
}
|
||||
|
||||
function print_percent ($percent) {
|
||||
while (strlen($percent)<2) $percent="0".$percent;
|
||||
$return=($percent) ? substr($percent,0,strlen($percent)-1).",".substr($percent,strlen($percent)-1,1)."%" : "0€";
|
||||
return ($return);
|
||||
}
|
||||
|
||||
function print_bill ($bill) {
|
||||
while (strlen($bill)<3) $bill="0".$bill;
|
||||
$return=($bill) ? substr($bill,0,strlen($bill)-2).",".substr($bill,strlen($bill)-2,2)."€" : "0€";
|
||||
return ($return);
|
||||
}
|
||||
|
||||
function money_to_bill($money) {
|
||||
$money=str_replace("€","",$money);
|
||||
$money=str_replace(",",".",$money);
|
||||
return ($money*100);
|
||||
}
|
||||
|
||||
function user_id_to_alias($id) {
|
||||
$query=mysql_query("SELECT * FROM `player` WHERE `id` = $id LIMIT 0 , 30",DB);
|
||||
$data=mysql_fetch_array($query);
|
||||
return ($data['alias']);
|
||||
}
|
||||
|
||||
function count_games () {
|
||||
$query=mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||
return (mysql_num_rows($query));
|
||||
}
|
||||
|
||||
function user_count_last_missed_games($id)
|
||||
{
|
||||
$games = 0;
|
||||
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC",DB);
|
||||
while ($data=mysql_fetch_array($query)) {
|
||||
$player_array = array();
|
||||
$player_array = player_of_game($data['id']);
|
||||
$deposition=0;
|
||||
foreach ($player_array as $player)
|
||||
if ($player==$id) $deposition++;
|
||||
if (!$deposition) $games++;
|
||||
else break;
|
||||
}
|
||||
return ($games);
|
||||
}
|
||||
|
||||
function user_count_games($id) { //counts the games wich are played by the user $id
|
||||
$games = 0;
|
||||
$query = mysql_query("SELECT `id` FROM `games`",DB);
|
||||
while ($data=mysql_fetch_array($query)) {
|
||||
$player_array = array();
|
||||
$player_array = player_of_game($data['id']);
|
||||
$deposition = 0;
|
||||
foreach ($player_array as $player)
|
||||
if ($player==$id) $deposition++;
|
||||
if ($deposition) $games++;
|
||||
}
|
||||
return ($games);
|
||||
}
|
||||
|
||||
function user_count_point_games($id) { //counts the games wich are played by the user $id
|
||||
$games = 0;
|
||||
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||
while ($data=mysql_fetch_array($query)) {
|
||||
$player_array = array();
|
||||
$player_array = player_of_game($data['id']);
|
||||
$deposition = 0;
|
||||
foreach ($player_array as $player)
|
||||
if ($player==$id) $deposition++;
|
||||
if ($deposition) $games++;
|
||||
}
|
||||
return ($games);
|
||||
}
|
||||
|
||||
function user_count_place($id,$place) { //counts how often a user ($id) has made the place ($place)
|
||||
$games = 0;
|
||||
$query = mysql_query("SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||
while ($data=mysql_fetch_row($query)) {
|
||||
if ($data[0]==$id) $games++;
|
||||
}
|
||||
return ($games);
|
||||
}
|
||||
|
||||
function user_min_bill() {
|
||||
$minbill=0;
|
||||
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
||||
while ($data=mysql_fetch_row($query)){
|
||||
$helpvar=user_count_bill($data[0]);
|
||||
if ($helpvar<$minbill) $minbill=$helpvar;
|
||||
}
|
||||
return ($minbill);
|
||||
}
|
||||
|
||||
function user_max_bill() {
|
||||
$maxbill=0;
|
||||
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
||||
while ($data=mysql_fetch_row($query)){
|
||||
$helpvar=user_count_bill($data[0]);
|
||||
if ($helpvar>$maxbill) $maxbill=$helpvar;
|
||||
}
|
||||
return ($maxbill);
|
||||
}
|
||||
|
||||
function user_count_bill($id) {
|
||||
$bill=0;
|
||||
$query=mysql_query("SELECT * FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||
while ($data=mysql_fetch_array($query)) {
|
||||
$playerlist=player_of_game($data['id']);
|
||||
foreach ($playerlist as $player) {
|
||||
if ($player==$id) $bill-=$data['base_bill'];
|
||||
}
|
||||
if ($data['first_id']==$id) $bill+=$data['first_bill'];
|
||||
if ($data['second_id']==$id) $bill+=$data['second_bill'];
|
||||
if ($data['third_id']==$id) $bill+=$data['third_bill'];
|
||||
}
|
||||
return ($bill);
|
||||
}
|
||||
|
||||
function player_of_game($game_id) {
|
||||
$player_array=array();
|
||||
|
||||
$query =mysql_query("SELECT `player` FROM `games` WHERE `id` = $game_id",DB);
|
||||
$data =mysql_fetch_array($query);
|
||||
$player=$data['player'];
|
||||
|
||||
while (strlen($player)>0) {
|
||||
while (substr($player,0,1)==",") $player=substr($player,1,strlen($player)-1); //delete leading commata
|
||||
$position=0;
|
||||
$deposition="";
|
||||
for ($position=0;substr($player,$position,1)!="," && $position<strlen($player);$position++);
|
||||
$deposition=trim(substr($player,0,$position));
|
||||
if ($deposition) $player_array[count($player_array)]=$deposition;
|
||||
$player=((strlen($player)-$position-1)>0) ? substr($player,$position,strlen($player)-$position):"";
|
||||
}
|
||||
return ($player_array);
|
||||
}
|
||||
|
||||
function gibmirzeit_von_datetime($format,$datetime) {
|
||||
$yyyy= substr($datetime,0,4);
|
||||
$yy = substr($datetime,2,2);
|
||||
$mm = substr($datetime,5,2);
|
||||
$dd = substr($datetime,8,2);
|
||||
$HH = substr($datetime,11,2);
|
||||
$MM = substr($datetime,14,2);
|
||||
$SS = substr($datetime,17,2);
|
||||
|
||||
$format=str_replace("yyyy",$yyyy,$format);
|
||||
$format=str_replace("jjjj",$yyyy,$format);
|
||||
$format=str_replace("yy" ,$yy ,$format);
|
||||
$format=str_replace("jj" ,$yy ,$format);
|
||||
$format=str_replace("mm" ,$mm ,$format);
|
||||
$format=str_replace("dd" ,$dd ,$format);
|
||||
$format=str_replace("tt" ,$dd ,$format);
|
||||
$format=str_replace("HH" ,$HH ,$format);
|
||||
$format=str_replace("MM" ,$MM ,$format);
|
||||
$format=str_replace("SS" ,$SS ,$format);
|
||||
|
||||
return ($format);
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue