@Soki Sokrates: Die Umsetzung der Tendenz hat mich gereizt. Die anderen beiden Statistik Add-ons werde ich wahrscheinlnich Do nachreichen....
Habe nun umgesetzt, dass man die Tendenz sieht:
[ externes Bild ]
(die Lupe ist ein weiteres Addon das ich ev. am Do poste)
ACHTUNG:
Für die Ermittlung der Ränge wird die Aufsplittung der Punkte benutztm daher sollte die Anzeige auch demenstprechend aussehen. Hier das Addon:
http://www.phpbb.de/viewtopic.php?p=715103#715103
Features:
- zum Vergleich wird der Rang des letzten Tages mit einem Spiel verwendet
- unabhängig davon ob vorne bspw. (1, -, -, 2, -, 3,...) oder (1,2,3,4,5,...) angezeigt wird wird mit der absoluten Platzierung (1,2,3,4,5,...) verglichen
ACHTUNG:
- Ob die Tendenz tatsächlich richtig angezeigt wird muss die nächsten Tage noch überprft werden.
Hier die benötigten Grafiken (falls jemand schönere, ev rot grün hat, bitte melden):
http://wiwico.de/images/wm/stay.gif
http://wiwico.de/images/wm/up.gif
http://wiwico.de/images/wm/down.gif
Hier die Änderungen (von mehreren Personen bestätigt, siehe folgenden Posts):
Code: Alles auswählen
#
#-----[ COPY ]------------------------------------------
#
images/wm/up.gif
images/wm/stay.gif
images/wm/down.gif
#
#-----[ OPEN ]------------------------------------------
#
include/functions_wm.php
#
#-----[ FIND ]------------------------------------------
#
$db->sql_freeresult($result);
return $wm_users;
}
#
#-----[ ADD, AFTER ]------------------------------------------
#
// Get wm users data and points up to yesterday
// for historical information
function get_wm_user_points_up_to_yesterday() {
global $db;
// Load Config
$wm_config = array(); // Config values
$wm_config = get_wm_config();
$timestamp_last_game_before_this_day = get_timestamp_for_ranking_history();
//
// Get users data
//
$sql = "SELECT A.tipp_user , sum( A.tipp_points ) AS user_points, count( A.tipp_points ) AS user_total_tipps, count( B.tipp_points ) AS user_points_tendency, count( C.tipp_points ) AS user_points_difference, count( D.tipp_points ) AS user_points_result
FROM " . WM_TIPPS_TABLE . " A
LEFT JOIN " . WM_TIPPS_TABLE . " B ON A.tipp_id = B.tipp_id
AND A.tipp_points = " . $wm_config['points_tendency'] . "
LEFT JOIN " . WM_TIPPS_TABLE . " C ON A.tipp_id = C.tipp_id
AND A.tipp_points = " . $wm_config['points_tordiff'] . "
LEFT JOIN " . WM_TIPPS_TABLE . " D ON A.tipp_id = D.tipp_id
AND A.tipp_points = " . $wm_config['points_match'] . "
WHERE A.tipp_time < ". $timestamp_last_game_before_this_day ."
GROUP BY A.tipp_user
ORDER BY user_points DESC, user_points_result DESC, user_points_difference DESC, user_points_tendency DESC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get historical user tipps data', '', __LINE__, __FILE__, $sql);
}
$wm_user_points_up_to_yesterday = array();
while ( $row = $db->sql_fetchrow($result) )
{
// $wm_users[][$row['tipp_user']] = $row;
$wm_user_points_up_to_yesterday[] = $row['tipp_user'];
}
$db->sql_freeresult($result);
return $wm_user_points_up_to_yesterday;
}
function get_timestamp_for_ranking_history(){
global $db;
$timestamp_now=time();
$month = strftime("%m",$timestamp_now);
$day = strftime("%d",$timestamp_now);
$year = strftime("%Y",$timestamp_now);
$timestamp_today_begin = mktime(0,0,0,$month,$day,$year);
$timestamp_today_end = mktime(23,59,0,$month,$day,$year);
$timestamp_first_game_of_today;
$timestamp_first_game_of_last_day_with_a_game;
$timestamp_last_game_of_last_day_with_a_game;
// get playing times of today
$sql = "SELECT game_time
FROM " . WM_GAMES_TABLE . "
WHERE game_time > ". $timestamp_today_begin ."
AND game_time < ". $timestamp_today_end ."
ORDER BY game_time ASC";
if( !($result_times = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get playing times of today', '', __LINE__, __FILE__, $sql);
}
$row_times = $db->sql_fetchrow($result_times);
$timestamp_first_game_of_today = $row_times['game_time'];
if($timestamp_first_game_of_today < $timestamp_now){
// first game of today has started -> use all results before this game
return $timestamp_first_game_of_today;
}else{
// first game of today is not started
// saerch the first game of last playing day
$sql = "SELECT game_time
FROM " . WM_GAMES_TABLE . "
WHERE game_time < ". $timestamp_today_begin ."
ORDER BY game_time DESC";
if( !($result_times = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get playing times of today', '', __LINE__, __FILE__, $sql);
}
$row_times = $db->sql_fetchrow($result_times);
$timestamp_last_game_of_last_day_with_a_game = $row_times['game_time'];
$month_last_day_with_a_game = strftime("%m",$timestamp_last_game_of_last_day_with_a_game);
$day_last_day_with_a_game = strftime("%d",$timestamp_last_game_of_last_day_with_a_game);
$year_last_day_with_a_game = strftime("%Y",$timestamp_last_game_of_last_day_with_a_game);
$timestamp_last_day_with_a_game_begin = mktime(0,0,0,$month_last_day_with_a_game,$day_last_day_with_a_game,$year_last_day_with_a_game);
$timestamp_last_day_with_a_game_end = mktime(23,59,0,$month_last_day_with_a_game,$day_last_day_with_a_game,$year_last_day_with_a_game);
$sql = "SELECT game_time
FROM " . WM_GAMES_TABLE . "
WHERE game_time > ". $timestamp_last_day_with_a_game_begin ."
AND game_time < ". $timestamp_last_day_with_a_game_end ."
ORDER BY game_time ASC";
if( !($result_times = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get playing times of today', '', __LINE__, __FILE__, $sql);
}
$row_times = $db->sql_fetchrow($result_times);
$timestamp_first_game_of_last_day_with_a_game = $row_times['game_time'];
return $timestamp_first_game_of_last_day_with_a_game+1; // +1 becaouse of the < comparison
}
}
function get_rank_of_yesterday($userid){
$wm_user_points_up_to_yesterday = get_wm_user_points_up_to_yesterday();
$rank_of_yesterday = array_search($userid, $wm_user_points_up_to_yesterday) + 1; // +1 because erray starts with index 0
return $rank_of_yesterday;
}
#
#-----[ OPEN ]------------------------------------------
#
wm_stats.php
#
#-----[ FIND ]------------------------------------------
#
for ( $i = 0; $i < count($wm_users_data); $i++ )
{
#
#-----[ ADD, AFTER ]------------------------------------------
#
// absolute position now
$int_userpos_absolute = $i+1;
// user position yesterday
$int_userpos_yesterday = get_rank_of_yesterday($wm_users_data[$i]['tipp_user']);
// compare the absolute positions
if($int_userpos_yesterday < $int_userpos_absolute ){
$userpos_change = '<img src="./images/wm/down.gif" alt="Down" border="0" />';
}else if ($int_userpos_yesterday == $int_userpos_absolute ){
$userpos_change = '<img src="./images/wm/stay.gif" alt="Stay" border="0" />';
}else if ($int_userpos_yesterday > $int_userpos_absolute ){
$userpos_change = '<img src="./images/wm/up.gif" alt="Up" border="0" />';
}
#
#-----[ FIND ]------------------------------------------
#
'USER_WM_MADE' => $wm_users_data[$i]['user_total_tipps'],
#
#-----[ ADD, AFTER ]------------------------------------------
#
'USER_WM_POS_CHANGE' => $userpos_change,
#
#-----[ OPEN ]------------------------------------------
#
wm_stats_body.tpl
#
#-----[ FIND ]------------------------------------------
#
><span class="cattitle"><a href="#">{L_WM_TITLE}</a></span></td>
#
#-----[ ATTENTION - special change ]------------------------------------------
#
Count up the colspan, for example
CHANGE <td class="cat" colspan="8">
TO <td class="cat" colspan="9">
#
#-----[ FIND ]------------------------------------------
#
<td class="row2" align="center" nowrap="nowrap" valign="middle"> <strong><span class="genmed">{L_WM_STATS_POS}</span></strong> </td>
#
#-----[ ADD, AFTER ]------------------------------------------
#
<td class="row2" align="center" nowrap="nowrap" valign="middle"> </td>
#
#-----[ FIND ]------------------------------------------
#
<td class="row1" align="center" nowrap="nowrap" valign="middle"> <strong><span class="genmed">{userrow.USER_POS}</span></strong> </td>
#
#-----[ ADD, AFTER ]------------------------------------------
#
<td class="row1" align="center" nowrap="nowrap" valign="middle"> {userrow.USER_WM_POS_CHANGE}</td>