Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 3.146.255.135
<?php
//###################################
// DEPRECATED FUNCTIONS
//###################################
function getteamname($useless1, $useless2, $useless3, $useless4, $useless5) {
trigger_error('Function decrecated, use: <I>team_get_data($mysql_link, $id_equipe, $ondate)</I> instead', E_USER_ERROR);
}
function getteamdata($useless1, $useless2, $useless3, $useless4, $useless5) {
trigger_error('Function decrecated, use: <I>team_get_data($mysql_link, $id_equipe, $ondate)</I> instead', E_USER_ERROR);
}
//###################################
// OFFICIAL FUNCTIONS
//###################################
function team_get_data($mysql_link, $id_equipe, $ondate) {
if (is_array($id_equipe) && count($id_equipe) > 0) {
$res = mysql_query($sql = 'SELECT * FROM equipes_hist AS eh WHERE hist_parent IN ('.implode(', ', $id_equipe).') AND sys_date <= "'.$ondate.'" and id <> 100 AND id <> 98 AND id <> 99 ORDER BY eh.sys_date asc, eh.id asc', $mysql_link);
} else {
$res = mysql_query($sql = 'SELECT * FROM equipes_hist AS eh WHERE hist_parent = "'.$id_equipe.'" AND sys_date <= "'.$ondate.'" and id <> 100 AND id <> 98 AND id <> 99 ORDER BY eh.sys_date asc, eh.id asc', $mysql_link);
//SELECT * FROM equipes_hist AS eh WHERE hist_parent = "15" AND sys_date <= "2006-06-27" ORDER BY eh.sys_date, eh.id
//echo $sql;
}
global $appSettings;
if (isset($appSettings)) {
$appSettings->logInfo( 'team_get_data(' . $id_equipe . ', \'' . $ondate . '\') [' . $sql . ']');
}
$data = $ids = array();
while ($row = mysql_fetch_assoc($res)) {
$data[$row['hist_parent']] = $row;
if ($row['hist_arena'] > 0) { $ids[] = $row['hist_arena']; }
}
$arenas = arena_get_data($mysql_link, $ids);
foreach ($data as $row) {
$data[$row['hist_parent']]['sys_arena_data'] = $arenas[$row['hist_arena']];
}
return $data;
}
function &get_teams($mysql_link, $id_ligue, $date_start /*Not used anymore*/, $on_date, $returnmode = FILTER_MODE_IGNORE, $filterarray = array()) {
//Get the current structure
global $struct_tree;
if (!isset($struct_tree[$on_date])) { $struct_tree[$on_date] = struct_get_tree($mysql_link, NULL, $on_date); }
if ($id_ligue != -1) {
if (!isset($struct_tree[$on_date]['leagues'][$id_ligue])) { trigger_error('Fatal error id_ligue = '.$id_ligue.' not found in structure tree on date '.$on_date); }
$tree = &$struct_tree[$on_date]['leagues'][$id_ligue];
//Requires special action to extract all teams under this tree (There may be several number of nodes to pass thru)
$teams_tree_fetched = array();
struct_explore_nodes($tree, $teams_tree_fetched, STRUCT_LIGUE_TEAM_NODE, 'sys_node_data');
} else {
//Requires special action to extract all teams under this tree (There may be several number of nodes to pass thru)
$teams_tree_fetched = array();
struct_explore_nodes($struct_tree[$on_date], $teams_tree_fetched, STRUCT_LIGUE_TEAM_NODE, 'sys_node_data');
}
//Check the structure for leagues and add them according to the filter params
if (!is_array($filterarray)) { trigger_error('Fatal error, passing a non array to get_teams::filterarray'); }
$teams = array();
foreach ($teams_tree_fetched as $team) {
if ($returnmode == FILTER_MODE_IGNORE) {
$teams[$team['hist_parent']] = $team;
} else if ($returnmode == FILTER_MODE_TAKE && in_array($team['hist_parent'], $filterarray)) {
$teams[$team['hist_parent']] = $team;
} else if ($returnmode == FILTER_MODE_REMOVE && !in_array($team['hist_parent'], $filterarray)) {
$teams[$team['hist_parent']] = $team;
}
}
return $teams;
}
function team_get_list($mysql_link, $returnmode = FILTER_MODE_IGNORE, $filterarray = array()) {
//Get the list of leagues
$teams_res = mysql_query('SELECT * FROM equipes AS e ORDER BY e.name', $mysql_link);
//Check the structure for leagues and add them according to the filter params
if (!is_array($filterarray)) { trigger_error('Fatal error, passing a non array to team_get_list::filterarray'); }
$teams = array();
while ($team = mysql_fetch_assoc($teams_res)) {
if ($returnmode == FILTER_MODE_IGNORE) {
$teams[$team['id_equipe']] = $team;
} else if ($returnmode == FILTER_MODE_TAKE && in_array($league['id_equipe'], $filterarray)) {
$teams[$team['id_equipe']] = $team;
} else if ($returnmode == FILTER_MODE_REMOVE && !in_array($league['id_equipe'], $filterarray)) {
$teams[$team['id_equipe']] = $team;
}
}
return $teams;
}
function &get_teams_for_id_list($mysql_link, $id_league, $id_list = array()) {
//Get the current structure
global $struct_tree, $current_season;
if (!isset($current_season)) { $current_season = season_get_current($mysql_link); }
if (!isset($struct_tree[$current_season['date_start'].'-'.$current_season['date_end']])) { $struct_tree[$current_season['date_start'].'-'.$current_season['date_end']] = struct_get_tree($mysql_link, $current_season['date_start'], $current_season['date_end']); }
if (!isset($struct_tree[$current_season['date_start'].'-'.$current_season['date_end']]['leagues'][$id_league])) {
trigger_error('Fatal error, id_league = '.$id_league.' doesn\'t exist in structure tree for dates: '.$current_season['date_start'].'-'.$current_season['date_end']);
}
$tree = &$struct_tree[$current_season['date_start'].'-'.$current_season['date_end']]['leagues'][$id_league];
//Explore recursively the nodes
$teams = array();
struct_explore_nodes($tree, $teams, STRUCT_LIGUE_TEAM_NODE, 'sys_node_data');
//Make the filter list
if (is_array($id_list)) {
foreach ($id_list as $team => $additionnaldata) {
$filterlist[] = $team;
}
//Filter the list to the id_list
foreach ($teams as $key => $teamdata) {
if (!in_array($teamdata['hist_parent'], $filterlist)) { unset($teams[$key]); }
}
return $teams;
}
}
?>
|