AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.137.189.236


Current Path : /var/www/lhjmq-records.qc.ca/public_html/administration/op_resultats/lib/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/administration/op_resultats/lib/goalSave.php

<?php
//Saves a complete goal event and it's sub events
function goalSave($mysql, $id_partie, $nume, $numj, $ass1, $ass2, $gb, $code1, $code2, $code3, $tmp, $per, $p1, $p2, $p3, $p4, $p5, $p6, $m1, $m2, $m3, $m4, $m5, $m6){

	global $session_id_usager, $REMOTE_ADDR;

	//Fix the times
	$tmp = fixTime($tmp);
	
	//Fix the checkbox values
	if($code2 != 2){
		$code2 = 1;
	}
	if($code3 != 2){
		$code3 = 1;
	}
	
	//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 = $nume;
		$scoredTeamId = $id_sv;
	}else{
		$scoringTeamId = $nume;
		$scoredTeamId = $id_sd;
	}
		
	//Get the player 1 (Scorer)
	if(!$numj == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$numj' AND id_equipe = $scoringTeamId";
		$numj_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	
	//Get the player 2 (Assistant 1) Could be a player or goalie
	if(!$ass1 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$ass1' AND id_equipe = $scoringTeamId";
		$ass1_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	
	//Get the player 2 (Assistant 1) Could be a player or goalie
	if(!$ass2 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$ass2' AND id_equipe = $scoringTeamId";
		$ass2_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	
	//Get the goaler 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";
		$gb_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	
	//Get the +/- for all the players: (p|m) & (1|2|3|4|5|6)
	if(!$p1 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p1' AND id_equipe = $scoringTeamId";
		$p1_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$p2 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p2' AND id_equipe = $scoringTeamId";
		$p2_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$p3 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p3' AND id_equipe = $scoringTeamId";
		$p3_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$p4 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p4' AND id_equipe = $scoringTeamId";
		$p4_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$p5 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p5' AND id_equipe = $scoringTeamId";
		$p5_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$p6 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$p6' AND id_equipe = $scoringTeamId";
		$p6_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m1 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m1' AND id_equipe = $scoredTeamId";
		$m1_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m2 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m2' AND id_equipe = $scoredTeamId";
		$m2_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m3 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m3' AND id_equipe = $scoredTeamId";
		$m3_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m4 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m4' AND id_equipe = $scoredTeamId";
		$m4_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m5 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m5' AND id_equipe = $scoredTeamId";
		$m5_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	if(!$m6 == ""){
		$sql = "SELECT id_partie_joueur, id_equipe FROM parties_joueurs WHERE id_partie = $id_partie AND numero = '$m6' AND id_equipe = $scoredTeamId";
		$m6_item = mysql_fetch_array(mysql_query($sql, $mysql));
	}
	
	//Write the main event (Goal)
	mysql_query($sql = "INSERT INTO parties_events (id_partie, code_event, minutes, periode, ip, timestamp, id_usager) VALUES($id_partie, 4, '00:$tmp', $per, '" . $REMOTE_ADDR . "', '" . date("Y-m-d G:i:s") . "', " . $session_id_usager . ")", $mysql);
	$id_event = mysql_insert_id($mysql);
	//Write the Goaler's subevent (Goal and Shot)
	if(isset($numj_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1, param2) VALUES($id_event, $scoringTeamId, $numj_item[id_partie_joueur], 5, $code3, $code1)", $mysql);
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1, param2) VALUES($id_event, $scoringTeamId, $numj_item[id_partie_joueur], 1, $code2, $code1)", $mysql);
	}
	//Write the assist's sub events
	if(isset($ass1_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $ass1_item[id_partie_joueur], 2, 1)", $mysql);
	}
	if(isset($ass2_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $ass2_item[id_partie_joueur], 2, 2)", $mysql);
	}
	//Write the goaler's sub event
	if(isset($gb_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $gb_item[id_partie_joueur], 3, $code3)", $mysql);
	}

	if($code1 == 2){
		$anCode = 0;
	}else{
		$anCode = 1;
	}
	
	//Write the positive +/-
	if(isset($p1_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p1_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	if(isset($p2_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p2_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	if(isset($p3_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p3_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	if(isset($p4_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p4_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	if(isset($p5_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p5_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	if(isset($p6_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoringTeamId, $p6_item[id_partie_joueur], 15, $anCode)", $mysql);
	}
	//Write the negative +/-
	if(isset($m1_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m1_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
	if(isset($m2_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m2_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
	if(isset($m3_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m3_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
	if(isset($m4_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m4_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
	if(isset($m5_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m5_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
	if(isset($m6_item)){
		mysql_query($sql = "INSERT INTO parties_subevents (id_partie_event, id_equipe, id_partie_joueur, code_subevent, param1) VALUES($id_event, $scoredTeamId, $m6_item[id_partie_joueur], 16, $anCode)", $mysql);
	}
}
?>