Anbei die an den geänderten Regeln für 2010 angepassten Dateien. Das betrifft die neue Punktevergabe (25-20-15-10-8-6-5-3-2-1) und 13 statt 10 Teams mit 26 Fahrer am Start. Dafür muss doch etwas mehr angepasst werden. Also schön ein Backup der alten Dateien machen und durch diese neuen ersetzen.
formel.php
Code: Alles auswählen
<?php
/***************************************************************************
* formel.php
* -------------------
* title : Formula 1 WebTipp
* version : 1.0.1 incl. FaceLift 3.1.fixed
* begin : Saturday, Jul 30, 2005
* copyright : (C) 2005 AceVentura
* email : 2714323@web.de
* email : 2714323@web.de
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
define('ON_FORMEL', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_formel.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_FORMEL);
init_userprefs($userdata);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_formel.' . $phpEx);
//
// Check login status
//
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx"));
}
//
// Set template vars
//
$page_title = $lang['formel_title'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'formel_body.tpl')
);
//
// Get config values
//
$formel_config = get_formel_config();
$formel_forum_id = $formel_config['forum_id'];
$formel_group_id = $formel_config['restrict_to'];
$formel_mod_id = $formel_config['mod_id'];
//
// Check auth status
//
if ( $formel_group_id != 0 && !get_formel_auth() && $userdata['user_level'] != ADMIN && $userdata['user_id'] != $formel_mod_id )
{
$auth_msg = sprintf($lang['formel_access_denied'], '<a href="' . append_sid("groupcp.$phpEx?g=$formel_group_id") . '" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $auth_msg);
}
//
// Check buttons & data
//
$race_offset = ( isset($HTTP_POST_VARS['race_offset']) ) ? intval ($HTTP_POST_VARS['race_offset']) : 0;
$race_id = ( isset($HTTP_POST_VARS['race_id']) ) ? intval ($HTTP_POST_VARS['race_id']) : 0;
$next = ( isset($HTTP_POST_VARS['next']) ) ? $HTTP_POST_VARS['next'] : $HTTP_GET_VARS['next'];
$prev = ( isset($HTTP_POST_VARS['prev']) ) ? $HTTP_POST_VARS['prev'] : $HTTP_GET_VARS['prev'];
$place_my_tipp = ( isset($HTTP_POST_VARS['place_my_tipp']) ) ? $HTTP_POST_VARS['place_my_tipp'] : $HTTP_GET_VARS['place_my_tipp'];
$edit_my_tipp = ( isset($HTTP_POST_VARS['edit_my_tipp']) ) ? $HTTP_POST_VARS['edit_my_tipp'] : $HTTP_GET_VARS['edit_my_tipp'];
$del_tipp = ( isset($HTTP_POST_VARS['del_tipp']) ) ? $HTTP_POST_VARS['del_tipp'] : $HTTP_GET_VARS['del_tipp'];
$user_id = $userdata['user_id'];
$my_tipp_array = array();
$my_tipp = '';
$tipp_time = ( isset($HTTP_POST_VARS['tipp_time']) ) ? intval ($HTTP_POST_VARS['tipp_time']) : 0;
//
// Check if the user want to see prev/next race
//
if ($next)
{
$race_offset++;
}
else if ($prev)
{
$race_offset--;
}
//
// Delete a tipp
//
if ( $del_tipp )
{
formel_del_tip($user_id,$race_id);
}
//
// Add/edit a tipp
//
//if ( ($place_my_tipp || $edit_my_tipp) && $tipp_time > time() - $formel_config['deadline_offset'] )
if ( ($place_my_tipp || $edit_my_tipp) && $tipp_time - $formel_config['deadline_offset'] >= time() )
{
for ($i = 0; $i < 10; $i++)
{
$value = $HTTP_POST_VARS['place'.($i+1)];
if (checkarrayforvalue($value,$my_tipp_array))
{
$tipp_msg = sprintf($lang['formel_doublicate_values'], '<a href="javascript:history.back()" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $tipp_msg);
}
$my_tipp_array[$i] = $value;
}
$my_tipp_array[11] = $HTTP_POST_VARS['place11'];
$my_tipp_array[12] = $HTTP_POST_VARS['place12'];
$my_tipp = implode(",",$my_tipp_array);
if ($place_my_tipp)
{
$sql = "INSERT INTO " . FORMEL_TIPPS_TABLE . "
(tipp_id,tipp_user,tipp_race,tipp_result,tipp_points)
VALUES
('',$user_id,$race_id,'$my_tipp',0)";
}
else
{
$sql = "UPDATE " . FORMEL_TIPPS_TABLE . " SET tipp_result = '$my_tipp'
WHERE tipp_user = $user_id
AND tipp_race = $race_id";
}
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$tipp_msg = sprintf($lang['formel_accepted_tipp'], '<a href="'.append_sid("formel.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $tipp_msg);
}
//
// Get all races
//
$races = get_formel_races();
$current_time = time();
//
// Get all teams
//
$teams = get_formel_teams();
//
// Get all drivers
//
$drivers = get_formel_drivers();
$driversCOMBODATA = get_formel_drivers_data();
//
// Get all tipps and fill Top10
//
$sql = "SELECT sum(tipp_points) AS total_points, tipp_user FROM " . FORMEL_TIPPS_TABLE . "
GROUP BY tipp_user
ORDER BY total_points DESC LIMIT 6";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query tipps', '', __LINE__, __FILE__, $sql);
}
$first_rank = $phpbb_root_path . "images/formel/goldpokal.gif";
$secound_rank = $phpbb_root_path . "images/formel/silberpokal.gif";
$third_rank = $phpbb_root_path . "images/formel/bronzepokal.gif";
$rank = $real_rank = 0;
$previous_points = false;
while ($row = $db->sql_fetchrow($result))
{
$real_rank++;
if($row['total_points'] != $previous_points)
{
$rank = $real_rank;
$previous_points = $row['total_points'];
}
if ($rank === 1)
{
$rank_img = '<img src="' . $first_rank . '" alt="1. Platz" title="1. Platz" />';
}
elseif ($rank === 2)
{
$rank_img = '<img src="' . $secound_rank . '" alt="2. Platz" title="2. Platz" />';
}
elseif ($rank === 3)
{
$rank_img = '<img src="' . $third_rank . '" alt="3. Platz" title="3. Platz" />';
}
else
{
$rank_img = $rank;
}
$tipp_user_row = get_userdata($row['tipp_user']);
$tipp_username = $tipp_user_row['username'];
$template->assign_block_vars('top_tippers', array(
'RANK' => $rank_img,
'TIPPER_NAME' => $tipp_username,
'TIPPER_POINTS' => $row['total_points'])
);
}
$db->sql_freeresult($result);
//
// Get all wm points and fill Top10 drivers
//
$sql = "SELECT sum(wm_points) AS total_points, wm_driver FROM " . FORMEL_WM_TABLE . "
GROUP BY wm_driver
ORDER BY total_points DESC LIMIT 6";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query drivers', '', __LINE__, __FILE__, $sql);
}
$first_rank = $phpbb_root_path . "images/formel/goldpokal.gif";
$secound_rank = $phpbb_root_path . "images/formel/silberpokal.gif";
$third_rank = $phpbb_root_path . "images/formel/bronzepokal.gif";
$rank = $real_rank = 0;
$previous_points = false;
while ($row = $db->sql_fetchrow($result))
{
$real_rank++;
if($row['total_points'] != $previous_points)
{
$rank = $real_rank;
$previous_points = $row['total_points'];
}
if ($rank === 1)
{
$rank_img = '<img src="' . $first_rank . '" alt="1. Platz" title="1. Platz" />';
}
elseif ($rank === 2)
{
$rank_img = '<img src="' . $secound_rank . '" alt="2. Platz" title="2. Platz" />';
}
elseif ($rank === 3)
{
$rank_img = '<img src="' . $third_rank . '" alt="3. Platz" title="3. Platz" />';
}
else
{
$rank_img = $rank;
}
$wm_drivername = $drivers[$row['wm_driver']]['driver_name'];
$template->assign_block_vars('top_drivers', array(
'RANK' => $rank_img,
'WM_DRIVERNAME' => $wm_drivername,
'WM_POINTS' => $row['total_points'])
);
}
$db->sql_freeresult($result);
//
// Get all wm points and fill Top10 teams
//
$sql = "SELECT sum(wm_points) AS total_points, wm_team FROM " . FORMEL_WM_TABLE . "
GROUP BY wm_team
ORDER BY total_points DESC LIMIT 6";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query teams', '', __LINE__, __FILE__, $sql);
}
$first_rank = $phpbb_root_path . "images/formel/goldpokal.gif";
$secound_rank = $phpbb_root_path . "images/formel/silberpokal.gif";
$third_rank = $phpbb_root_path . "images/formel/bronzepokal.gif";
$rank = $real_rank = 0;
$previous_points = false;
while ($row = $db->sql_fetchrow($result))
{
/* //FIA Urteil McLaren
if($row['wm_team'] == 1) // Die Team ID von McLaren Mercedes
{
continue; // Es wird keine Berechnung für dieses Team durchgefuehrt.
}
// ENDE FIA Urteil McLaren
*/
$real_rank++;
if($row['total_points'] != $previous_points)
{
$rank = $real_rank;
$previous_points = $row['total_points'];
}
if ($rank === 1)
{
$rank_img = '<img src="' . $first_rank . '" alt="1. Platz" title="1. Platz" />';
}
elseif ($rank === 2)
{
$rank_img = '<img src="' . $secound_rank . '" alt="2. Platz" title="2. Platz" />';
}
elseif ($rank === 3)
{
$rank_img = '<img src="' . $third_rank . '" alt="3. Platz" title="3. Platz" />';
}
else
{
$rank_img = $rank;
}
$wm_teamname = $teams[$row['wm_team']]['team_name'];
$template->assign_block_vars('top_teams', array(
'RANK' => $rank_img,
'WM_TEAMNAME' => $wm_teamname,
'WM_POINTS' => $row['total_points'])
);
}
$db->sql_freeresult($result);
//
// Find current race
//
for ($i = 0; $i < count($races); $i++)
{
if ($races[$i]['race_time'] > $current_time - $formel_config['event_change'])
{
// Check for a overflow
$race_offset = ($i + $race_offset == count($races)) ? 0-$i : $race_offset;
$race_offset = ($i + $race_offset < 0) ? count($races)-1-$i : $race_offset;
// Define current race incl. user given offset
$chosen_race = $i + $race_offset;
$user_tipp_points = 0;
$race_id = $races[$chosen_race]['race_id'];
$user_id = $userdata['user_id'];
// Get race image and data
$race_img = $races[$chosen_race]['race_img'];
$race_img_full = $races[$chosen_race]['race_img'];
$race_img = ($race_img == '') ? '<img src="' . $phpbb_root_path . 'images/formel/' . $formel_config['no_race_img'] . '" width="' . $formel_config['race_img_width'] . '" height="' . $formel_config['race_img_height'] . '" alt="" />' : '<img src="' . $phpbb_root_path . 'images/formel/' . $race_img . '" width="' . $formel_config['race_img_width'] . '" height="' . $formel_config['race_img_height'] . '" alt="" />';
$template->assign_block_vars('racerow', array(
'RACEIMG' => $race_img,
'RACEIMG_FULL' => $race_img_full,
'RACENAME' => $races[$chosen_race]['race_name'],
'RACELENGTH' => $races[$chosen_race]['race_length'] . ' km',
'RACEDEBUT' => $races[$chosen_race]['race_debut'],
'RACEDISTANCE' => $races[$chosen_race]['race_distance'] . ' km',
'RACELAPS' => $races[$chosen_race]['race_laps'],
'RACETIME' => create_date($board_config['default_dateformat'], $races[$chosen_race]['race_time'], $board_config['board_timezone'], 0),
'RACEDEAD' => create_date($board_config['default_dateformat'], $races[$chosen_race]['race_time'] - $formel_config['deadline_offset'], $board_config['board_timezone'], 0))
);
if ( $formel_config['show_gfxr'] == 1 )
{
$template->assign_block_vars('racerow.racegfx', array());
}
// Find current tippers and their points
// Get tipp data
$sql = "SELECT * FROM " . FORMEL_TIPPS_TABLE . "
WHERE tipp_race = $race_id
ORDER BY tipp_points DESC";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query tipp data', '', __LINE__, __FILE__, $sql);
}
$tippers_active = $db->sql_numrows($result);
$cur_counter = 1;
while ($row = $db->sql_fetchrow($result))
{
$current_tippers_userdata = get_userdata($row['tipp_user']);
$current_tipp_id = $row['tipp_id'];
$current_tippers_username = $current_tippers_userdata['username'] . ' (' . $row['tipp_points'] . ')';
$separator = ( $cur_counter == $tippers_active ) ? '': ', ';
$template->assign_block_vars('tipps_made', array(
'USERTIPP' => append_sid("./usertipp.$phpEx?tipp=$current_tipp_id&race=$chosen_race"),
'SEPARATOR' => $separator,
'USERNAME' => $current_tippers_username)
);
$cur_counter++;
}
if ( $tippers_active == 0 )
{
$template->assign_block_vars('no_tipps_made', array(
'NOTIPPS' => $lang['formel_no_players'])
);
}
$db->sql_freeresult($result);
// Get tipp data
$sql = "SELECT * FROM " . FORMEL_TIPPS_TABLE . "
WHERE tipp_race = $race_id
AND tipp_user = $user_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query tipp data', '', __LINE__, __FILE__, $sql);
}
$tipp_active = $db->sql_numrows($result);
$delete_button = '';
$tipp_button = $lang['formel_add_tipp'];
$tipp_button_name = 'place_my_tipp';
$tipp_data = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Check if a tip has been made before
if ($tipp_active > 0)
{
$tipp_button = $lang['formel_edit_tipp'];
$tipp_button_name = 'edit_my_tipp';
$delete_button = ' <input class="mainoption" type="submit" name="del_tipp" value="' . $lang['formel_del_tipp'] . '" />';
$tipp_array = explode(",",$tipp_data[0]['tipp_result']);
$user_tipp_points = $tipp_data[0]['tipp_points'];
for ($i = 0; $i < count($tipp_array) - 2; $i++)
{
$results = explode(",",$races[$chosen_race]['race_result']);
$position = ($i == 0) ? $lang['formel_race_winner'] : $i+1 . '. ' . $lang['formel_place'];
$box_name = 'place' . ($i+1);
$single_points = '';
if ($races[$chosen_race]['race_time'] - $formel_config['deadline_offset'] < $current_time)
{
//actual Race is over
$driverid = $drivers[$tipp_array[$i]]['driver_id'];
$drivercombo = $drivers[$tipp_array[$i]]['driver_name'];
$driverteamname = $drivers[$tipp_array[$i]]['driver_team_name'];
$gfxdrivercar = $drivers[$tipp_array[$i]]['driver_car'];
$gfxdrivercombo = $drivers[$tipp_array[$i]]['driver_img'];
//Recalc Tipp Points for every single placed Tipp
if ($driverid == $results[$i])
{
$single_points += $formel_config['points_placed'];
}
for ($j = 0; $j < count($tipp_array) - 2; $j++)
{
if ($driverid == $results[$j])
{
$single_points += $formel_config['points_mentioned'];
}
}
if ($single_points == 0) $single_points='';
// End Recalc
}
else
{
$drivercombo = '<select name="' . $box_name . '" size="1">';
for ($k = 0; $k < count($driversCOMBODATA); $k++)
{
$this_driver_id = $driversCOMBODATA[$k]['driver_id'];
$this_driver_name = $driversCOMBODATA[$k]['driver_name'];
$selected = ( $this_driver_id == $tipp_array[$i]) ? 'selected="selected"' : '';
$drivercombo .= '<option value="' . $this_driver_id . '" ' . $selected . '>' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
}
if ( $formel_config['show_gfx'] == 1 )
{
//Layout Cosmetic
if ($races[$chosen_race]['race_time'] - $formel_config['deadline_offset'] < $current_time)
{
//Race is over - Show Driverimage and so on
$template->assign_block_vars('gfx_users_tipp', array(
'L_PLACE' => ' ' . $position . '<br />',
'DRIVERCOMBO' => $drivercombo . '<br />',
'DRIVERTEAMNAME' => ' ' . $driverteamname,
'GFXDRIVERCOMBO' => $gfxdrivercombo,
'GXFDRIVERCAR' => $gfxdrivercar,
'SINGLE_POINTS' => $single_points)
);
}
else
{
// Race is not over - Show Position instead of Driver Image
$template->assign_block_vars('gfx_users_tipp', array(
'L_PLACE' => '',
'DRIVERCOMBO' => $drivercombo,
'DRIVERTEAMNAME' => $driverteamname,
'GFXDRIVERCOMBO' => $position,
'GXFDRIVERCAR' => $gfxdrivercar,
'SINGLE_POINTS' => $single_points)
);
}
}
else
{
$template->assign_block_vars('users_tipp', array(
'L_PLACE' => $position,
'DRIVERCOMBO' => $drivercombo,
'SINGLE_POINTS' => $single_points)
);
}
}
if ($races[$chosen_race]['race_time'] - $formel_config['deadline_offset'] < $current_time)
{
//actual Race is over
$single_fastest = '';
$single_tired = '';
$drivercombo = $drivers[$tipp_array[10]]['driver_name'];
$tiredcombo = $tipp_array[11];
//Recalc Tipp Points for Tipp Fastest Driver and Tired
if ($tipp_array[10] == $results[10])
{
$single_fastest += $formel_config['points_fastest'];
}
if ($tipp_array[11] == $results[11])
{
$single_tired += $formel_config['points_tired'];
}
//End Recalc
}
else
{
$drivercombo = '<select name="place11" size="1">';
for ($k = 0; $k < count($driversCOMBODATA); $k++)
{
$this_driver_id = $driversCOMBODATA[$k]['driver_id'];
$this_driver_name = $driversCOMBODATA[$k]['driver_name'];
$selected = ( $this_driver_id == $tipp_array[10]) ? 'selected="selected"' : '';
$drivercombo .= '<option value="' . $this_driver_id . '" ' . $selected .'>' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
$tiredcombo = '<select name="place12" size="1">';
for ($k = 0; $k < 26; $k++)
{
$selected = ( $k == $tipp_array[11]) ? 'selected="selected"' : '';
$tiredcombo .= '<option value="' . $k . '" ' . $selected . '>' . $k . '</option>';
}
$tiredcombo .= '</select>';
}
if ( $formel_config['show_gfx'] == 1 )
{
$template->assign_block_vars('extended_users_tipp_gfx', array(
'L_PACE' => $lang['formel_pace'],
'L_TIRED' => $lang['formel_tired'],
'TIREDCOMBO' => $tiredcombo,
'DRIVERCOMBO' => $drivercombo,
'GFXDRIVERCOMBO' => $gfxdrivercombo,
'SINGLE_FASTEST' => $single_fastest,
'SINGLE_TIRED' => $single_tired)
);
}
else
{
$template->assign_block_vars('extended_users_tipp', array(
'L_PACE' => $lang['formel_pace'],
'L_TIRED' => $lang['formel_tired'],
'TIREDCOMBO' => $tiredcombo,
'DRIVERCOMBO' => $drivercombo,
'GFXDRIVERCOMBO' => $gfxdrivercombo,
'SINGLE_FASTEST' => $single_fastest,
'SINGLE_TIRED' =>$single_tired)
);
}
}
//
// What to do if the user has no tip so far
//
else
{
if ($races[$chosen_race]['race_time'] - $formel_config['deadline_offset'] > $current_time)
{
for ($i = 0; $i < 10; $i++)
{
$position = ($i == 0) ? $lang['formel_race_winner'] : $i+1 . '. ' . $lang['formel_place'];
$box_name = 'place' . ($i+1);
$drivercombo = '<select name="' . $box_name . '" size="1">';
for ($k = 0; $k < count($driversCOMBODATA); $k++)
{
$this_driver_id = $driversCOMBODATA[$k]['driver_id'];
$this_driver_name = $driversCOMBODATA[$k]['driver_name'];
$drivercombo .= '<option value="' . $this_driver_id . '">' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
$template->assign_block_vars('add_tipp', array(
'L_PLACE' => $position,
'DRIVERCOMBO' => $drivercombo)
);
}
$drivercombo = '<select name="place11" size="1">';
for ($k = 0; $k < count($driversCOMBODATA); $k++)
{
$this_driver_id = $driversCOMBODATA[$k]['driver_id'];
$this_driver_name = $driversCOMBODATA[$k]['driver_name'];
$drivercombo .= '<option value="' . $this_driver_id . '">' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
$tiredcombo = '<select name="place12" size="1">';
for ($k = 0; $k < 26; $k++)
{
$tiredcombo .= '<option value="' . $k . '">' . $k . '</option>';
}
$tiredcombo .= '</select>';
$template->assign_block_vars('extended_add_tipp', array(
'L_PACE' => $lang['formel_pace'],
'L_TIRED' => $lang['formel_tired'],
'TIREDCOMBO' => $tiredcombo,
'DRIVERCOMBO' => $drivercombo)
);
}
}
//
// Checks for a saved quali
//
if ( $races[$chosen_race]['race_quali'] != '0' )
{
// Get the driver ids
$quali = explode(",",$races[$chosen_race]['race_quali']);
// Start output
for ($j = 0; $j < count($quali); $j++)
{
$current_driver_id = $quali[$j];
$position = ($j == 0) ? $lang['formel_pole'].': ' : $j+1 . '. ' . $lang['formel_place'] . ': ';
if ( $formel_config['show_gfx'] == 1 )
{
$template->assign_block_vars('qualirow_gfx', array(
'L_PLACE' => $position,
'DRIVERIMG' => $drivers[$current_driver_id]['driver_img'],
'DRIVERCAR' => $drivers[$current_driver_id]['driver_car'],
'DRIVERNAME' => $drivers[$current_driver_id]['driver_name'],
'DRIVERTEAMNAME' => $drivers[$current_driver_id]['driver_team_name'])
);
}
else
{
$template->assign_block_vars('qualirow', array(
'L_PLACE' => $position,
'DRIVERNAME' => $drivers[$current_driver_id]['driver_name'])
);
}
}
}
//
// If no quali was found
//
else
{
$template->assign_block_vars('no_quali', array(
'NO_QUALI' => $lang['formel_no_quali'])
);
}
//
// Checks for a saved result
//
if ( $races[$chosen_race]['race_result'] != '0' )
{
// Get the driver ids
$results = explode(",",$races[$chosen_race]['race_result']);
// Start output
for ($j = 0; $j < count($results)-2; $j++)
{
$current_driver_id = $results[$j];
$position = ($j == 0) ? $lang['formel_race_winner'].': ' : $j+1 . '. ' . $lang['formel_place'] . ': ';
if ( $formel_config['show_gfx'] == 1 )
{
$template->assign_block_vars('resultsrow_gfx', array(
'L_PLACE' => $position,
'DRIVERIMG' => $drivers[$current_driver_id]['driver_img'],
'DRIVERCAR' => $drivers[$current_driver_id]['driver_car'],
'DRIVERNAME' => $drivers[$current_driver_id]['driver_name'],
'DRIVERTEAMNAME' => $drivers[$current_driver_id]['driver_team_name'])
);
}
else
{
$template->assign_block_vars('resultsrow', array(
'L_PLACE' => $position,
'DRIVERNAME' => $drivers[$current_driver_id]['driver_name'])
);
}
}
if ( $formel_config['show_gfx'] == 1 )
{
$template->assign_block_vars('extended_results_gfx', array(
'L_PACE' => $lang['formel_pace'],
'L_TIRED' => $lang['formel_tired'],
'L_YOUR_POINTS' => $lang['formel_your_points'],
'PACE' => $drivers[$results[10]]['driver_name'],
'TIRED' => $results[11],
'YOUR_POINTS' => $user_tipp_points)
);
}
else
{
$template->assign_block_vars('extended_results', array(
'L_PACE' => $lang['formel_pace'],
'L_TIRED' => $lang['formel_tired'],
'L_YOUR_POINTS' => $lang['formel_your_points'],
'PACE' => $drivers[$results[10]]['driver_name'],
'TIRED' => $results[11],
'YOUR_POINTS' => $user_tipp_points)
);
}
}
//
// If no result was found
//
else
{
$template->assign_block_vars('no_results', array(
'NO_RESULTS' => $lang['formel_no_result'])
);
}
//
// Game over
//
if ($races[$chosen_race]['race_time'] - $formel_config['deadline_offset'] < $current_time)
{
$template->assign_block_vars('game_over', array(
'GAME_OVER' => $lang['formel_game_over'])
);
}
else
{
$template->assign_block_vars('place_tipp', array(
'DELETE_TIPP' => $delete_button,
'L_PLACE_TIPP' => $tipp_button,
'PLACE_TIPP' => $tipp_button_name)
);
}
break;
}
}
//
// Forum button
//
$discuss_button = '';
if ( $formel_forum_id )
{
$formel_forum_url = append_sid("viewforum.$phpEx?f=$formel_forum_id");
$formel_forum_name = $lang['formel_forum'];
$discuss_button = '<input class="mainoption" type="button" onclick="window.location.href=\'' . $formel_forum_url . '\'" value="' . $formel_forum_name . '" /> ';
}
//
// Moderator switch and options
//
$u_call_mod = append_sid("privmsg.$phpEx?mode=post&u=$formel_mod_id");
$l_call_mod = $lang['formel_call_mod'];
if ($user_id == $formel_config['mod_id'] || $userdata['user_level'] == ADMIN)
{
$u_call_mod = append_sid("./formel_results.$phpEx");
$l_call_mod = $lang['formel_mod_button_text'];
$template->assign_block_vars('tipp_moderator', array());
}
//
// Show headerbanner ?
//
if ( $formel_config['show_headbanner'] )
{
$template->assign_block_vars('head_on', array());
}
$template->assign_vars(array(
'S_FORM_ACTION' => append_sid("./formel.$phpEx"),
'U_FORMEL' => append_sid("./formel.$phpEx"),
'RACE_OFFSET' => $race_offset,
'HEADER_IMG' => $formel_config['headbanner1_img'],
'HEADER_URL' => $formel_config['headbanner1_url'],
'HEADER_HEIGHT' => $formel_config['head_height'],
'HEADER_WIDTH' => $formel_config['head_width'],
'RACE_ID' => $races[$chosen_race]['race_id'],
'RACE_TIME' => $races[$chosen_race]['race_time'],
'L_CURRENT_RACE' => $lang['formel_current_race'],
'L_NEXT_RACE' => $lang['formel_next_race'],
'L_PREV_RACE' => $lang['formel_prev_race'],
'L_YOUR_TIPP' => $lang['formel_your_tipp'],
'L_CURRENT_QUALI' => $lang['formel_current_quali'],
'L_CURRENT_RESULT' => $lang['formel_current_result'],
'L_RACENAME' => $lang['formel_racename'],
'L_RACEDEBUT' => $lang['formel_racedebut'],
'L_RACELENGTH' => $lang['formel_racelength'],
'L_RACELAPS' => $lang['formel_racelaps'],
'L_RACEDISTANCE' => $lang['formel_racedistance'],
'L_RACETIME' => $lang['formel_racetime'],
'L_TOP_NAME' => $lang['formel_top_name'],
'L_TIPPS_MADE' => $lang['formel_tipps_made'],
'L_TOP_DRIVER' => $lang['formel_top_driver'],
'L_TOP_TEAMS' => $lang['formel_top_teams'],
'L_TOP_MORE' => $lang['formel_top_more'],
'U_TOP_MORE_USERS' => append_sid("formel_stats.$phpEx?show_users=1"),
'U_TOP_MORE_DRIVERS' => append_sid("formel_stats.$phpEx?show_drivers=1"),
'U_TOP_MORE_TEAMS' => append_sid("formel_stats.$phpEx?show_teams=1"),
'L_TOP_POINTS' => $lang['formel_top_points'],
'L_RACEDEAD' => $lang['formel_racedead'],
'L_FORMEL_TITLE' => $lang['formel_title'],
'U_FORMEL_RULES' => append_sid("formel_rules.$phpEx"),
'U_FORMEL_FORUM' => $discuss_button,
'U_FORMEL_STATISTICS' => append_sid("formel_stats.$phpEx"),
'U_FORMEL_CALL_MOD' => $u_call_mod,
'L_FORMEL_RULES' => $lang['formel_rules'],
'L_FORMEL_STATISTICS' => $lang['formel_statistics'],
'L_FORMEL_CALL_MOD' => $l_call_mod)
);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Code: Alles auswählen
<?php
/***************************************************************************
* formel_addresults.php
* -------------------
* title : Formula 1 WebTipp
* version : 0.2.2
* begin : Saturday, Jul 30, 2005
* copyright : (C) 2005 AceVentura
* email : 2714323@web.de
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_formel.'.$phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_formel.' . $phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_FORMEL);
init_userprefs($userdata);
//
// End session management
//
if (!$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=formel_addresults.$phpEx", true));
}
$page_title = $lang['formel_title'];
//
// Check login status
//
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx", true) . '');
}
//
// Get config values
//
$formel_config = get_formel_config();
//
// Check auth
//
if ( $userdata['user_id'] != $formel_config['mod_id'] && $userdata['user_level'] != ADMIN )
{
$message = $lang['Not_Authorised'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_ERROR, $message);
}
//
// Check buttons & data
//
$results = ( isset($HTTP_POST_VARS['result']) ) ? $HTTP_POST_VARS['result'] : $HTTP_GET_VARS['result'];
$addresult = ( isset($HTTP_POST_VARS['addresult']) ) ? $HTTP_POST_VARS['addresult'] : $HTTP_GET_VARS['addresult'];
$addeditresult = ( isset($HTTP_POST_VARS['addeditresult']) ) ? $HTTP_POST_VARS['addeditresult'] : $HTTP_GET_VARS['addeditresult'];
$editresult = ( isset($HTTP_POST_VARS['editresult']) ) ? $HTTP_POST_VARS['editresult'] : $HTTP_GET_VARS['editresult'];
$addquali = ( isset($HTTP_POST_VARS['addquali']) ) ? $HTTP_POST_VARS['addquali'] : $HTTP_GET_VARS['addquali'];
$editquali = ( isset($HTTP_POST_VARS['editquali']) ) ? $HTTP_POST_VARS['editquali'] : $HTTP_GET_VARS['editquali'];
$quali = ( isset($HTTP_POST_VARS['quali']) ) ? $HTTP_POST_VARS['quali'] : $HTTP_GET_VARS['quali'];
$resetquali = ( isset($HTTP_POST_VARS['resetquali']) ) ? $HTTP_POST_VARS['resetquali'] : $HTTP_GET_VARS['resetquali'];
$resetresult = ( isset($HTTP_POST_VARS['resetresult']) ) ? $HTTP_POST_VARS['resetresult'] : $HTTP_GET_VARS['resetresult'];
$race_id = ( isset($HTTP_POST_VARS['race_id']) ) ? intval($HTTP_POST_VARS['race_id']) : 0;
$quali_array = array();
$result_array = array();
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'formel_addresults_body.tpl')
);
//
// Reset a quali
//
if ( $resetquali && $race_id != 0 )
{
$sql = "UPDATE " . FORMEL_RACES_TABLE . " SET race_quali = '0' WHERE race_id = " . $race_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$tipp_msg = sprintf($lang['formel_results_deleted'], '<a href="'.append_sid("formel_results.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $tipp_msg);
}
//
// Reset a result
//
if ( $resetresult && $race_id != 0 )
{
$sql = "DELETE FROM " . FORMEL_WM_TABLE . " WHERE wm_race = " . $race_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . FORMEL_RACES_TABLE . " SET race_result = '0' WHERE race_id = " . $race_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . FORMEL_TIPPS_TABLE . " SET tipp_points = 0 WHERE tipp_race = " . $race_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$tipp_msg = sprintf($lang['formel_results_deleted'], '<a href="'.append_sid("formel_results.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $tipp_msg);
}
if ( ( $reset || $resetresult || $resetquali ) && $race_id == 0 )
{
$reset_msg = sprintf($lang['formel_results_error'], '<a href="'.append_sid("formel_results.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $reset_msg);
}
//
// Add a quali
//
if ( $addquali )
{
if ( $race_id != 0 )
{
for ($i = 0; $i < 26; $i++)
{
$value = $HTTP_POST_VARS['place'.($i+1)];
if (checkarrayforvalue($value,$quali_array))
{
$quali_msg = sprintf($lang['formel_results_double'], '<a href="javascript:history.back()" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $quali_msg);
}
$quali_array[$i] = $value;
}
$new_quali = implode(",",$quali_array);
$sql = "UPDATE " . FORMEL_RACES_TABLE . " SET race_quali = '$new_quali' WHERE race_id = $race_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
$quali_msg = sprintf($lang['formel_results_accepted'], '<a href="'.append_sid("formel_results.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $quali_msg);
}
}
//
// Add a result
//
if ( $addresult || $addeditresult )
{
if ( $race_id != 0 )
{
if ( $addeditresult )
{
$sql = "DELETE FROM " . FORMEL_WM_TABLE . " WHERE wm_race = " . $race_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
}
for ($i = 0; $i < 10; $i++)
{
$value = $HTTP_POST_VARS['place'.($i+1)];
if (checkarrayforvalue($value,$result_array))
{
$result_msg = sprintf($lang['formel_results_double'], '<a href="javascript:history.back()" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $result_msg);
}
$result_array[$i] = $value;
}
$result_array[10] = $HTTP_POST_VARS['place11'];
$result_array[11] = $HTTP_POST_VARS['place12'];
$new_result = implode(",",$result_array);
$sql = "UPDATE " . FORMEL_RACES_TABLE . " SET race_result = '$new_result' WHERE race_id = $race_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
// START points calc
// Get tipp data and calc user points
$sql = "SELECT * FROM " . FORMEL_TIPPS_TABLE . " WHERE tipp_race = $race_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query tipp data', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result))
{
$user_tipp_points = 0;
$current_user = $row['tipp_user'];
$current_tipp_array = explode(',',$row['tipp_result']);
$temp_results_array = array();
for ( $i=0; $i < count($current_tipp_array)-2; $i++ )
{
$temp_results_array[$i] = $result_array[$i];
}
for ( $i=0; $i < count($current_tipp_array)-2; $i++ )
{
if ( $current_tipp_array[$i] != '0' )
{
if ( checkarrayforvalue($current_tipp_array[$i],$temp_results_array) )
{
$user_tipp_points += $formel_config['points_mentioned'];
if ( $current_tipp_array[$i] == $result_array[$i] )
{
$user_tipp_points += $formel_config['points_placed'];
}
}
}
}
if ( $current_tipp_array[10] == $result_array[10] && $current_tipp_array[10] != 0)
{
$user_tipp_points += $formel_config['points_fastest'];
}
if ( $current_tipp_array[11] == $result_array[11] )
{
$user_tipp_points += $formel_config['points_tired'];
}
$sql = "UPDATE " . FORMEL_TIPPS_TABLE . " SET tipp_points = '$user_tipp_points' WHERE tipp_race = $race_id AND tipp_user = $current_user";
if (!$update = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
}
$db->sql_freeresult($result);
// Calc wm points
// Get drivers data
$sql = "SELECT * FROM " . FORMEL_DRIVERS_TABLE;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not get driver information', '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$teams[$row['driver_id']] = $row['driver_team'];
}
$db->sql_freeresult($result);
$wm = array();
$wm[0] = 25;
$wm[1] = 20;
$wm[2] = 15;
$wm[3] = 10;
$wm[4] = 8;
$wm[5] = 6;
$wm[6] = 5;
for ( $i=7; $i < 10; $i++ )
{
$wm[$i] = ( 10 - $i );
}
for ( $i=0; $i < count($result_array)-2; $i++ )
{
$current_driver = $result_array[$i];
if ( $current_driver != '0' )
{
$current_team = $teams[$current_driver];
$wm_points = $wm[$i];
$sql = "INSERT INTO " . FORMEL_WM_TABLE . " (wm_id,wm_race,wm_driver,wm_team,wm_points) VALUES ('',$race_id,$current_driver,$current_team,$wm_points)";
if (!$update = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update database', '', __LINE__, __FILE__, $sql);
}
}
}
// END points calc
$result_msg = sprintf($lang['formel_results_accepted'], '<a href="'.append_sid("formel_results.$phpEx").'" class="gen">', '</a>', '<a href="'.append_sid("index.$phpEx").'" class="gen">', '</a>');
message_die(GENERAL_MESSAGE, $result_msg);
}
}
//
// Load add/edit quali
//
if ( ( $quali || $editquali ) && $race_id != 0 )
{
if ( $editquali )
{
// Get the race
$sql = "SELECT * FROM " . FORMEL_RACES_TABLE . " WHERE race_id = $race_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query drivers', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$quali_array = explode(',',$row['race_quali']);
$db->sql_freeresult($result);
}
// Fetch all drivers
$sql = "SELECT * FROM " . FORMEL_DRIVERS_TABLE . " ORDER BY driver_name ASC";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query drivers', '', __LINE__, __FILE__, $sql);
}
$counter=1;
while ($row = $db->sql_fetchrow($result))
{
$drivers[$counter] = $row;
$counter++;
}
$db->sql_freeresult($result);
$drivers[0]['driver_id'] = '0';
$drivers[0]['driver_name'] = $lang['formel_define'];
for ($i = 0; $i < 26; $i++)
{
$position = ($i == 0) ? $lang['formel_pole'] : $i+1 . '. ' . $lang['formel_place'];
$box_name = 'place' . ($i+1);
$drivercombo = '<select name="' . $box_name . '" size="1">';
for ($k = 0; $k < count($drivers); $k++)
{
$this_driver_id = $drivers[$k]['driver_id'];
$this_driver_name = $drivers[$k]['driver_name'];
$selected = ( $this_driver_id == $quali_array[$i]) ? 'selected="selected"' : '';
$drivercombo .= '<option value="' . $this_driver_id . '" ' . $selected . '>' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
$template->assign_block_vars('qualirow', array(
'L_PLACE' => $position,
'DRIVERCOMBO' => $drivercombo)
);
}
$template->assign_block_vars('quali', array(
'L_TITLE' => $lang['formel_results_qualititle'],
'L_ADD' => $lang['formel_results_add'])
);
}
//
// Load add/edit result
//
if ( ( $results || $editresult ) && $race_id != 0 )
{
if ( $editresult )
{
// Get the race
$sql = "SELECT * FROM " . FORMEL_RACES_TABLE . " WHERE race_id = $race_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query drivers', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$result_array = explode(',',$row['race_result']);
$db->sql_freeresult($result);
}
// Fetch all drivers
$sql = "SELECT * FROM " . FORMEL_DRIVERS_TABLE . " ORDER BY driver_id ASC";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query drivers', '', __LINE__, __FILE__, $sql);
}
$counter=1;
while ($row = $db->sql_fetchrow($result))
{
$drivers[$counter] = $row;
$counter++;
}
$db->sql_freeresult($result);
$drivers[0]['driver_id'] = '0';
$drivers[0]['driver_name'] = $lang['formel_define'];
for ($i = 0; $i < 10; $i++)
{
$position = ($i == 0) ? $lang['formel_race_winner'] : $i+1 . '. ' . $lang['formel_place'];
$box_name = 'place' . ($i+1);
$drivercombo = '<select name="' . $box_name . '" size="1">';
for ($k = 0; $k < count($drivers); $k++)
{
$this_driver_id = $drivers[$k]['driver_id'];
$this_driver_name = $drivers[$k]['driver_name'];
$selected = ( $this_driver_id == $result_array[$i]) ? 'selected="selected"' : '';
$drivercombo .= '<option value="' . $this_driver_id . '" ' . $selected . '>' . $this_driver_name . '</option>';
}
$drivercombo .= '</select>';
$template->assign_block_vars('resultrow', array(
'L_PLACE' => $position,
'DRIVERCOMBO' => $drivercombo)
);
}
$drivercombo_pace = '<select name="place11" size="1">';
for ($k = 0; $k < count($drivers); $k++)
{
$this_driver_id = $drivers[$k]['driver_id'];
$this_driver_name = $drivers[$k]['driver_name'];
$selected = ( $this_driver_id == $result_array[10]) ? 'selected="selected"' : '';
$drivercombo_pace .= '<option value="' . $this_driver_id . '" ' . $selected . '>' . $this_driver_name . '</option>';
}
$drivercombo_pace .= '</select>';
$combo_tired = '<select name="place12" size="1">';
for ($k = 0; $k < 26; $k++)
{
$selected = ( $k == $result_array[11]) ? 'selected="selected"' : '';
$combo_tired .= '<option value="' . $k . '" ' . $selected . '>' . $k . '</option>';
}
$combo_tired .= '</select>';
$mode = ( $editresult ) ? 'addeditresult' : 'addresult';
$template->assign_block_vars('result', array(
'L_FASTEST' => $lang['formel_pace'],
'PACECOMBO' => $drivercombo_pace,
'L_TIRED' => $lang['formel_tired'],
'MODE' => $mode,
'TIREDCOMBO' => $combo_tired,
'L_TITLE' => $lang['formel_results_resulttitle'],
'L_ADD' => $lang['formel_results_add'])
);
}
$template->assign_vars(array(
'S_FORM_ACTION' => append_sid("./formel_addresults.php"),
'U_FORMEL' => append_sid("./formel.php"),
'U_FORMEL_RESULTS' => append_sid("./formel_results.php"),
'L_FORMEL_RESULT' => $lang['formel_current_result'],
'RACE_ID' => $race_id,
'L_FORMEL_RESULTS_TITLE' => $lang['formel_results_title'],
'L_FORMEL_TITLE' => $lang['formel_title'],
'L_FORMEL_RESULTS_TITLE_EXP' => $lang['formel_results_title_exp'])
);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>