But, in the meantime, here's the code for the new User Stats page I did. Beware, it's not very well written. If it was a heavily trafficked page, I'd spend a lot more time optimizing it, but since I designed it mostly for me, I don't really care how horrible the code looks.
- Code: Select all
<?
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$user = $HTTP_POST_VARS['username'];
$time15 = time() - (15*24*60*60);
$time30 = time() - (30*24*60*60);
$time60 = time() - (60*24*60*60);
$time90 = time() - (90*24*60*60);
if ($user!='')
{
$sql = "SELECT user_id, user_reviews, user_lastvisit, user_regdate FROM " . USERS_TABLE . " WHERE username = '" . $user . "'";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$user_reviews = $row['user_reviews'];
$user_regdate = date("F j, Y, g:i a", $row['user_regdate']);
$user_lastvisit = date("F j, Y, g:i a", $row['user_lastvisit']);
$id = $row['user_id'];
$message = "User Information For " . $user;
} else {
$message = "No person by " . $user . ". Did you spell it correctly?";
}
if ($id != '')
{
$sql = "SELECT
COUNT(p.poster_id) as dp_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 8 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$dp_reviews = $row['dp_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as np_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 10 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$np_reviews = $row['np_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as lp_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 9 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$lp_reviews = $row['lp_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as op_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 17 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$op_reviews = $row['op_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as af_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 6 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$af_reviews = $row['af_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as fanf_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 75 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$fanf_reviews = $row['fanf_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as ff_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 16 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$ff_reviews = $row['ff_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as hf_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 61 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$hf_reviews = $row['hf_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as nf_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 18 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$nf_reviews = $row['nf_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as rf_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 2 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$rf_reviews = $row['rf_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as sf_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 3 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$sf_reviews = $row['sf_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as of_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 5 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$of_reviews = $row['of_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as am_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 159 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$am_reviews = $row['am_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as pm_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 27 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$pm_reviews = $row['pm_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as lm_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 41 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$lm_reviews = $row['lm_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as sm_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 24 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$sm_reviews = $row['sm_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as om_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
p.forum_id = 26 AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$om_reviews = $row['om_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as low_reviews
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
(p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10 || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41 || p.forum_id = 26) AND
char_length(t.post_text) < 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$low_reviews = $row['low_reviews'];
}
$sql = "SELECT
COUNT(p.poster_id) as time15
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.post_time >= " . $time15 . " AND
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
(p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10 || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41 || p.forum_id = 26) AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$time15_reviews = $row['time15'];
}
$sql = "SELECT
COUNT(p.poster_id) as time30
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
(p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10 || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41 || p.forum_id = 26) AND
p.post_time >= " . $time30 . " AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$time30_reviews = $row['time30'];
}
$sql = "SELECT
COUNT(p.poster_id) as time60
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
(p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10 || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41 || p.forum_id = 26) AND
p.post_time >= " . $time60 . " AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$time60_reviews = $row['time60'];
}
$sql = "SELECT
COUNT(p.poster_id) as time90
FROM
" . POSTS_TABLE . " AS p,
" . POSTS_TEXT_TABLE . " AS t,
" . TOPICS_TABLE . " as tt
WHERE
p.topic_id = tt.topic_id AND
p.post_id != tt.topic_first_post_id AND
p.post_id = t.post_id AND
p.poster_id = " . $id . " AND
(p.forum_id = 8 || p.forum_id = 9 || p.forum_id = 10 || p.forum_id = 159 || p.forum_id = 17 || p.forum_id = 24 || p.forum_id = 6 || p.forum_id = 75 || p.forum_id = 16 || p.forum_id = 61 || p.forum_id = 18 || p.forum_id = 2 || p.forum_id = 3 || p.forum_id = 5 || p.forum_id = 27 || p.forum_id = 41 || p.forum_id = 26) AND
p.post_time >= " . $time90 . " AND
char_length(t.post_text) >= 250";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$time90_reviews = $row['time90'];
}
$sql = "SELECT
COUNT(poster_id) as greetings
FROM
" . POSTS_TABLE . "
WHERE
poster_id = " . $id . " AND
forum_id = 1";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$greetings = $row['greetings'];
}
$sql = "SELECT
COUNT(poster_id) as greetings15
FROM
" . POSTS_TABLE . "
WHERE
post_time >= $time15 AND
poster_id = " . $id . " AND
forum_id = 1";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$greetings15 = $row['greetings15'];
}
$sql = "SELECT
COUNT(poster_id) as greetings30
FROM
" . POSTS_TABLE . "
WHERE
post_time >= $time30 AND
poster_id = " . $id . " AND
forum_id = 1";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$greetings30 = $row['greetings30'];
}
$sql = "SELECT
COUNT(poster_id) as greetings60
FROM
" . POSTS_TABLE . "
WHERE
post_time >= $time60 AND
poster_id = " . $id . " AND
forum_id = 1";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$greetings60 = $row['greetings60'];
}
$sql = "SELECT
COUNT(poster_id) as greetings90
FROM
" . POSTS_TABLE . "
WHERE
post_time >= $time90 AND
poster_id = " . $id . " AND
forum_id = 1";
if($result = $db->sql_query($sql))
{
$row = $db->sql_fetchrow($result);
$greetings90 = $row['greetings90'];
}
$total = $of_reviews + $sf_reviews + $rf_reviews + $nf_reviews + $hf_reviews + $ff_reviews + $fanf_reviews + $af_reviews + $op_reviews + $np_reviews + $lp_reviews + $dp_reviews + $am_reviews + $sm_reviews + $pm_reviews + $om_reviews + $lm_reviews + $low_reviews;
$total2 = $total - $low_reviews;
}
}
$template->assign_vars(array(
'MESSAGE' => $message,
'LASTVISIT' => $user_lastvisit,
'REGDATE' => $user_regdate,
'REVIEWS' => $user_reviews,
'DP_REVIEWS' => $dp_reviews,
'LP_REVIEWS' => $lp_reviews,
'NP_REVIEWS' => $np_reviews,
'OP_REVIEWS' => $op_reviews,
'AF_REVIEWS' => $af_reviews,
'FANF_REVIEWS' => $fanf_reviews,
'FF_REVIEWS' => $ff_reviews,
'HF_REVIEWS' => $hf_reviews,
'NF_REVIEWS' => $nf_reviews,
'RF_REVIEWS' => $rf_reviews,
'SF_REVIEWS' => $sf_reviews,
'OF_REVIEWS' => $of_reviews,
'AM_REVIEWS' => $am_reviews,
'PM_REVIEWS' => $pm_reviews,
'LM_REVIEWS' => $lm_reviews,
'SM_REVIEWS' => $sm_reviews,
'OM_REVIEWS' => $om_reviews,
'LOW_REVIEWS' => $low_reviews,
'TIME15' => $time15_reviews,
'TIME30' => $time30_reviews,
'TIME60' => $time60_reviews,
'TIME90' => $time90_reviews,
'GREETINGS' => $greetings,
'GREETINGS15' => $greetings15,
'GREETINGS30' => $greetings30,
'GREETINGS60' => $greetings60,
'GREETINGS90' => $greetings90,
'TOTAL' => $total,
'TOTAL2' => $total2,
'USER' => $user
));
//
// Start output of page
//
$page_title = 'User Statistics';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'user_stats_body.tpl')
);
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Gender:
Points: 11417
Reviews: 425