session_begin(); $auth->acl($user->data); $user->setup(); $user->add_lang_ext('football/football', 'info_acp_update'); include('../includes/constants.' . $phpEx); if ($config['board_disable']) { $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; trigger_error($message); } $season = $request->variable('season', 0); $league = $request->variable('league', 0); if (!$season or !$league) { exit; } $download = $request->variable('d', false); $string = xml_data($season, $league); if ( $string == '') { trigger_error('Fehler! Die XML-Datei konnte nicht erzeugt werden.'); } if ($download) { // Download header header('Pragma: no-cache'); header('Content-Type: application/xml name=\"league_' . $season . '_' . $league . '.xml'); header('Content-disposition: attachment; filename=league_' . $season . '_' . $league . '.xml'); } else { // XML header header ("content-type: text/xml"); } echo $string; } function xml_data($season, $league) { global $db, $phpbb_root_path, $phpEx, $table_prefix; $xml_data = ''; $xml_league_data = xml_table($season, $league, 'FOOTB_SEASONS'); $xml_league_data .= xml_table($season, $league, 'FOOTB_LEAGUES'); $xml_league_data .= xml_table($season, $league, 'FOOTB_MATCHDAYS'); $xml_league_data .= xml_table($season, $league, 'FOOTB_TEAMS'); $xml_league_data .= xml_table($season, $league, 'FOOTB_MATCHES'); if ( $xml_league_data <> '' ) { $xml_data = '' . "\n"; $xml_data .= '' . "\n"; $xml_data .= '' . "\n"; $xml_data .= '' . "\n"; $xml_data .= $xml_league_data; $xml_data .= ''; } return $xml_data; } function xml_table($season, $league, $table) { global $db, $phpbb_root_path, $phpEx, $table_prefix; $xml_table = ''; $skip_fields = array("trend", "odd_1", "odd_x", "odd_2", "rating"); $table_name = constant($table); $where_league = ($table == 'FOOTB_SEASONS') ? '' : " AND league = $league"; $sql = 'SELECT * FROM ' . $table_name . " WHERE season = $season $where_league ORDER BY 1, 2, 3;"; if ( $result = $db->sql_query($sql) ) { while($row = $db->sql_fetchrow($result)) { $xml_table .= " <" . strtolower($table) . ">" . "\n"; foreach($row as $fieldname => $value) { switch ($fieldname) { case 'win_result': case 'win_result_02': case 'win_matchday': case 'win_season': case 'points_last': case 'join_by_user': case 'join_in_season': case 'rules_post_id': case 'bet_points': { $value = 0; } break; case 'status': { // only match status 0-3 $value = ($value > 3) ? $value - 3 : $value; } break; } if (!in_array($fieldname, $skip_fields, TRUE) ) { if (!isset($value) || is_null($value)) { $xml_table .= " <$fieldname>'NULL'" . "\n"; } else { $xml_table .= " <$fieldname>" . $value . "" . "\n"; } } } $xml_table .= " " . "\n"; } } return $xml_table; } ?>