Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 18.117.184.125
<?php
//Saves a complete goal event and it's sub events
function penshotSave($mysql, $id_partie, $nume, $numj1, $numj2, $gb, $group, $code, $tmp, $per, $but, $lan){
global $session_id_usager, $REMOTE_ADDR;
//Fix the times
$tmp = fixTime($tmp);
//Get the team numbers
$sql = "SELECT id_equipe_dom AS sd, id_equipe_vis AS sv FROM parties WHERE id_partie = $id_partie";
$teamIds = mysql_fetch_array(mysql_query($sql, $mysql));
$id_sd = $teamIds[sd];
$id_sv = $teamIds[sv];
if($nume == $id_sd){
$scoringTeamId = $id_sd;
$scoredTeamId = $id_sv;
}else{
$scoringTeamId = $id_sv;
$scoredTeamId = $id_sd;
}
//Get the player 1 (Shooter)
if($numj1 != ""){
$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$numj1' AND id_equipe = $scoringTeamId";
$numj1_item = mysql_fetch_array(mysql_query($sql, $mysql));
}
//Get the player 2 (Goalie shot at)
if($gb != ""){
$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$gb' AND id_equipe = $scoredTeamId";
$numgb_item = mysql_fetch_array(mysql_query($sql, $mysql));
}
//Get the player 3 (Penalized player)
if($numj2 != ""){
$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$numj2' AND id_equipe = $scoredTeamId";
$numj2_item = mysql_fetch_array(mysql_query($sql, $mysql));
}
//Write the main event (PenShot)
mysql_query($sql = "INSERT INTO parties_events (id_partie, code_event, minutes, periode, ip, timestamp, id_usager) VALUES($id_partie, 5, '00:$tmp', $per, '" . $REMOTE_ADDR . "', '" . date("Y-m-d G:i:s") . "', " . $session_id_usager . ")", $mysql);
$id_event = mysql_insert_id($mysql);
//Write the Shooter's sub event(Shot, if goaled, goal & +)
if(isset($numj1_item)){
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1, param2) VALUES($id_event, $scoringTeamId, $numj1_item[id_partie_joueur], 5, $lan, 0)", $mysql);
if($but == 1){
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1, param2) VALUES($id_event, $scoringTeamId, $numj1_item[id_partie_joueur], 1, 1, 0)", $mysql);
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $numj1_item[id_partie_joueur], 15, 1)", $mysql);
}
}
//Write the goalie's event (Allowed Goal or Blocked Shot)
if(isset($numgb_item)){
if($but == 1){
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $numgb_item[id_partie_joueur], 3, $lan)", $mysql);
}else{
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $numgb_item[id_partie_joueur], 4, $lan)", $mysql);
}
}
//Write the penalized players event (Penalty)
if(isset($numj2_item)){
mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1, param2, param3) VALUES($id_event, $scoredTeamId, $numj2_item[id_partie_joueur], 10, 0, $group, $code)", $mysql);
}
}
?>
|