Code: Alles auswählen
<?php
/***************************************************************************
*
* 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.
*
***************************************************************************/
//
// Daily Statistics (New: posts, topics and users)
//
// Number of days to display.
$nday = 30;
// New posts by days.
$sql = 'SELECT DAYOFMONTH(FROM_UNIXTIME(post_time)) as day, MONTH(FROM_UNIXTIME(post_time)) as mon, YEAR(FROM_UNIXTIME(post_time)) as year,COUNT(*) AS ant
FROM ' . POSTS_TABLE . '
GROUP BY year,mon,day
ORDER BY year DESC, mon DESC, day DESC
LIMIT 0,'. $nday;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve posts data', '', __LINE__, __FILE__, $sql);
}
$posts_count = $db->sql_numrows($result);
$posts_data = $db->sql_fetchrowset($result);
// New topics by days.
$sql = 'SELECT DAYOFMONTH(FROM_UNIXTIME(topic_time)) as day, MONTH(FROM_UNIXTIME(topic_time)) as mon, YEAR(FROM_UNIXTIME(topic_time)) as year,COUNT(*) AS ant
FROM ' . TOPICS_TABLE . '
GROUP BY year,mon,day
ORDER BY year DESC, mon DESC, day DESC
LIMIT 0,'. $nday;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve topics data', '', __LINE__, __FILE__, $sql);
}
$topics_count = $db->sql_numrows($result);
$topics_data = $db->sql_fetchrowset($result);
// New users by days.
$sql = 'SELECT DAYOFMONTH(FROM_UNIXTIME(user_regdate)) as day, MONTH(FROM_UNIXTIME(user_regdate)) as mon, YEAR(FROM_UNIXTIME(user_regdate)) as year,COUNT(*) AS ant
FROM ' . USERS_TABLE . '
GROUP BY year,mon,day
ORDER BY year DESC, mon DESC, day DESC
LIMIT 0,'. $nday;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve users data', '', __LINE__, __FILE__, $sql);
}
$users_count = $db->sql_numrows($result);
$users_data = $db->sql_fetchrowset($result);
$flag = 1;
$user_con = 0;
$user_sum = 0;
$post_con = 0;
$post_sum = 0;
$topic_con = 0;
$topic_sum = 0;
$top_con = 0;
$top_sum = 0;
for ($i = 0; $i < $nday and $flag; $i=$i+1)
{
$class = ( !($i % 2) ) ? 'row2' : 'row1';
$date = (mktime (0,0,0,date("m"),date("d")-$i,date("Y")));
$dated = date("d",$date);
$datem = date("m",$date);
$datey = date("Y",$date);
// Top date.
$f = 0;
// Posts.
for ($j = 0; $j < $nday; $j=$j+1)
{
if ($posts_data[$j]['day'] == $dated && $posts_data[$j]['mon'] == $datem && $posts_data[$j]['year'] == $datey)
{
$post = $posts_data[$j]['ant'];
$post_sum += $posts_data[$j]['ant'];
$f = 1;
$post_con++;
}
}
if ($f)
$f = 0;
else
$post = '-';
// Topics.
for ($j = 0; $j < $nday; $j=$j+1)
{
if ($topics_data[$j]['day'] == $dated && $topics_data[$j]['mon'] == $datem && $topics_data[$j]['year'] == $datey)
{
$topic = $topics_data[$j]['ant'];
$topic_sum += $topics_data[$j]['ant'];
$f = 1;
$topic_con++;
}
}
if ($f)
$f = 0;
else
$topic = '-';
// Users.
for ($j = 0; $j < $nday; $j=$j+1)
{
if ($users_data[$j]['day'] == $dated && $users_data[$j]['mon'] == $datem && $users_data[$j]['year'] == $datey)
{
$user = $users_data[$j]['ant'];
$user_sum += $users_data[$j]['ant'];
$f = 1;
$user_con++;
}
}
if ($f)
$f = 0;
else
$user = '-';
// Top.
$sql = "SELECT *
FROM forum_stats_rec
WHERE rec_date > ". mktime(0,0,0,date("m"),date("d")-$i,date("y")) ."
AND rec_date < ". mktime(23,59,59,date("m"),date("d")-$i,date("y"));
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not TheWiz Total user.', '', __LINE__, __FILE__, $sql);
}
if ($rowiz = $db->sql_fetchrow($result))
{
$top = $rowiz['rec_value'];
$top_sum += $rowiz['rec_value'];
$top_con++;
$toptime = date("H:i:s",$rowiz['rec_date']);
}
else
{
$top = '-';
$toptime = '-';
}
$date = date("d/m/Y", (mktime (0,0,0,date("m"),date("d")-$i,date("Y"))));
$template->assign_block_vars('dnews', array(
'CLASS' => $class,
'DATE' => $date,
'USER' => $user,
'TOPIC' => $topic,
'POST' => $post,
'TOP' => $top,
'TOPTIME' => $toptime,
)
);
}
$template->assign_block_vars('dnews', array(
'CLASS' => 'row2',
'DATE' => $lang['Sum_Table'],
'USER' => $user_sum,
'TOPIC' => $topic_sum,
'POST' => $post_sum,
'TOP' => "-",
'TOPTIME' => "-"));
$template->assign_block_vars('dnews', array(
'CLASS' => 'row2',
'DATE' => $lang['Avg_Table'],
'USER' => round($user_sum/$user_con,2),
'TOPIC' => round($topic_sum/$topic_con,2),
'POST' => round($post_sum/$post_con,2),
'TOP' => round($top_sum/$top_con,2),
'TOPTIME' => "-"));
$template->assign_vars(array(
'L_DATE' => $lang['Date'],
'L_USERS' => $lang['New_users'],
'L_TOPIC' => $lang['New_topics'],
'L_REPLIE' => $lang['New_replies'],
'L_TOP' => "Top OnLine",
'L_TOPTIME' => "Top OnLine Time",
'MODULE_NAME' => $lang['module_name'])
);
?>
So sieht das ganze aus, liegt aber an der Datenbank, da findet er die Tabelle nicht.