<?php
/*=======================*\
| CYBER-CITY | Metropolis |
+-------------------------+
| http://cyber-city.ru |
\*=======================*/
/*
+--------------------------------------------------------------------------
| [PZ23] Top 5 Statistics v1.1
| =============================================
| by Elad Nava of Platinum Zone
| (c) 2007 Elad Nava
| http://pznetworks.com
| =============================================
| Web: http://pznetworks.com
+---------------------------------------------------------------------------
| > $Revision: 48 $
| > $Author: John $
+---------------------------------------------------------------------------
|
| > [PZ23] Top 5 Statistics module
| > Module written by Elad Nava of Platinum Zone
| > Date started: 29th June 2008
|
|> Module Version Number: 1.1
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Некорректный адрес</h1>Вы не имеете доступа к этому файлу напрямую. Если вы недавно обновляли форум, вы должны обновить все соответствующие файлы.";
exit();
}
class top5stats
{
function display()
{
//-----------------------------------------
// INIT...
//-----------------------------------------
$dayAgo = time() - (24 * 60 * 60);
//-----------------------------------------
// Link to settings
//-----------------------------------------
$modOn = $this->ipsclass->vars['pz_top5stats'];
$truncateAmount = $this->ipsclass->vars['pz_truncation'];
$excludedGroups = $this->ipsclass->vars['pz_top5exgroups'];
$newsForums = $this->ipsclass->vars['pz_newsforums'] == 'null' ? '' : $this->ipsclass->vars['pz_newsforums'];
//-----------------------------------------
// Set up forum view permissions
//-----------------------------------------
$permittedForums = array();
foreach ( $this->ipsclass->forums->forum_by_id as $forum )
{
if ( $forum['id'] )
{
$permittedForums[] = $forum['id'];
}
}
//-----------------------------------------
// Load our skin templates
//-----------------------------------------
$this->ipsclass->load_template('skin_top5stats');
if ( $modOn && ! in_array( $this->ipsclass->member['mgroup'], explode( ",", $excludedGroups ) ) )
{
//-----------------------------------------
// Output statistics table
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->stats();
//-----------------------------------------
// Select latest news
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 25 );
if ( ! $newsForums )
{
//-----------------------------------------
// Kindly alert the admin of the problem
//-----------------------------------------
$this->output .= "<p class=\"desc\"><span style=\"color:red;font-weight:bold\">Внимание:</span> Выберите разделы последних новостей форума. Для этого пройдите в Админцентр ---> Настройки [вкладка] ---> [PZ23] Статистика Top 5 v1.1 ---> <b>Разделы последних новостей</b>!</p>";
}
else
{
//-----------------------------------------
// Select latest news from news forums
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'tid, last_post, start_date, title', 'from' => 'topics', 'where' => "forum_id IN(".$newsForums.")", 'order' => 'start_date DESC', 'limit' => array(0, 5), ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
//-----------------------------------------
// New post marker
//-----------------------------------------
$marker = $row['last_post'] > $dayAgo ? $this->ipsclass->compiled_templates['skin_top5stats']->link_image( "showtopic={$row['tid']}&view=getlastpost" ) : '';
//-----------------------------------------
// Truncate topic title
//-----------------------------------------
$row['truncated_title'] = $this->ipsclass->txt_truncate( $row['title'], $truncateAmount );
//-----------------------------------------
// Format timestamp into user-friendly time
//-----------------------------------------
$row['start_date'] = $this->ipsclass->get_date( $row['start_date'], 'JOINED', 1, 0 );
//-----------------------------------------
// Form a link to the topic
//-----------------------------------------
$topicLink = $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showtopic={$row['tid']}", $row['truncated_title'], $row['title'] );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_title'],
'content' => $marker . " " . $topicLink
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_title'],
'content' => $row['start_date']
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Select most popular members
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 15 );
//-----------------------------------------
// Base query on profile views
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, mgroup, members_display_name, members_profile_views', 'from' => 'members', 'order' => 'members_profile_views DESC', 'limit' => array(0, 5) ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$memberName = $this->ipsclass->vars['pz_topformatname'] ? $this->ipsclass->make_name_formatted( $row['members_display_name'], $row['mgroup'] ) : $row['members_display_name'];
//-----------------------------------------
// Form a link to the topic
//-----------------------------------------
$memberLink = $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showuser={$row['id']}", $memberName );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_dispyrtxt'],
'content' => $memberLink
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_profies'],
'content' => $this->ipsclass->do_number_format( $row['members_profile_views'] )
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Select most viewed topics
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 25 );
//-----------------------------------------
// Base selection on topic views (duh!)
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'tid, last_post, title, views', 'from' => 'topics', 'order' => 'views DESC', 'limit' => array(0, 5) ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
//-----------------------------------------
// New post marker
//-----------------------------------------
$marker = $row['last_post'] > $dayAgo ? $this->ipsclass->compiled_templates['skin_top5stats']->link_image( "showtopic={$row['tid']}&view=getlastpost" ) : '';
//-----------------------------------------
// Truncate topic title
//-----------------------------------------
$row['truncated_title'] = $this->ipsclass->txt_truncate( $row['title'], $truncateAmount );
//-----------------------------------------
// Form a link to the topic
//-----------------------------------------
$topicLink = $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showtopic={$row['tid']}", $row['truncated_title'], $row['title'] );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_title'],
'content' => "{$marker} {$topicLink}"
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_views'],
'content' => $this->ipsclass->do_number_format( $row['views'] )
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Select last 10 posts
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->latest_posts_td();
//-----------------------------------------
// Label the data (split into two TDs)
//-----------------------------------------
$firstTD = array(
'width' => 65,
'title' => $this->ipsclass->lang['top_ttitle'],
'content' => $this->ipsclass->lang['top_title']
);
$secondTD = array(
'width' => 30,
'title' => $this->ipsclass->lang['top_dispyrtxt'],
'content' => $this->ipsclass->lang['top_postertxt']
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
//-----------------------------------------
// Filter by perms and get group formatting
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, m.mgroup', 'from' => "topics t LEFT JOIN ".SQL_PREFIX."members m ON (m.id=t.last_poster_id)", 'where' => "t.forum_id IN(".implode( ",", $permittedForums ).")", 'order' => 't.last_post DESC', 'limit' => array(0, 10) ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
//-----------------------------------------
// Format the name?
//-----------------------------------------
$memberName = $this->ipsclass->vars['pz_topformatname'] ? $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['prefix'] . $row['last_poster_name'] . $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['suffix'] : '';
//-----------------------------------------
// New post marker
//-----------------------------------------
$marker = $row['last_post'] > $dayAgo ? $this->ipsclass->compiled_templates['skin_top5stats']->link_image( "showtopic={$row['tid']}&view=getlastpost" ) : '';
//-----------------------------------------
// Truncate topic title
//-----------------------------------------
$row['truncated_title'] = $this->ipsclass->txt_truncate( $row['title'], $truncateAmount );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 65,
'title' => $this->ipsclass->lang['top_title'],
'content' => "{$marker} ".$this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showtopic={$row['tid']}&view=getlastpost", $row['truncated_title'], $row['title'] )
);
$secondTD = array(
'width' => 30,
'title' => $this->ipsclass->lang['top_postertxt'],
'content' => $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showuser={$row['last_poster_id']}", $memberName )
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Start row 2
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->stats_2();
//-----------------------------------------
// Select newest members
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 25 );
//-----------------------------------------
// Base selection on joined timestamp
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, mgroup, joined, members_display_name', 'from' => 'members', 'limit' => array(0, 5), 'order' => 'joined DESC' ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$memberName = $this->ipsclass->vars['pz_topformatname'] ? $this->ipsclass->make_name_formatted( $row['members_display_name'], $row['mgroup'] ) : $row['members_display_name'];
//-----------------------------------------
// Format joined date
//-----------------------------------------
$row['joined'] = $this->ipsclass->get_date( $row['joined'], 'JOINED', 1, 0 );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_dispyrtxt'],
'content' => $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showuser={$row['id']}", $memberName )
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_datey'],
'content' => $row['joined']
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Select top posters
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 15 );
//-----------------------------------------
// Base selection on post count
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, posts, members_display_name, mgroup', 'from' => 'members', 'where' => "posts>0", 'order' => 'posts DESC', 'limit' => array(0, 5) ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$memberName = $this->ipsclass->vars['pz_topformatname'] ? $this->ipsclass->make_name_formatted( $row['members_display_name'], $row['mgroup'] ) : $row['members_display_name'];
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_dispyrtxt'],
'content' => $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showuser={$row['id']}", $memberName )
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_nolat_posts'],
'content' => $this->ipsclass->do_number_format( $row['posts'] )
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
//-----------------------------------------
// Select last visitors
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td( 25 );
//-----------------------------------------
// Base selection on last visit to forum
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, members_display_name, mgroup, last_visit', 'from' => 'members', 'order' => 'last_visit DESC', 'limit' => array(0, 5) ) );
$this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$memberName = $this->ipsclass->vars['pz_topformatname'] ? $this->ipsclass->make_name_formatted( $row['members_display_name'], $row['mgroup'] ) : $row['members_display_name'];
//-----------------------------------------
// Format last visit to forum
//-----------------------------------------
$row['last_visit'] = $this->ipsclass->get_date( $row['last_visit'], 'JOINED', 1, 0 );
//-----------------------------------------
// Split the data into two TDs
//-----------------------------------------
$firstTD = array(
'width' => 85,
'title' => $this->ipsclass->lang['top_dispyrtxt'],
'content' => $this->ipsclass->compiled_templates['skin_top5stats']->form_link( "showuser={$row['id']}", $memberName )
);
$secondTD = array(
'width' => 15,
'title' => $this->ipsclass->lang['top_datey'],
'content' => $row['last_visit']
);
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->split_data( $firstTD, $secondTD );
}
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->td_end();
$this->output .= $this->ipsclass->compiled_templates['skin_top5stats']->stats_end();
}
return $this->output;
}
}
?>