Mở file ./sources/classes/class_session.php
Tìm:
CODE
// No last visit set, do so now!
$DB->simple_construct( array( 'update' => 'members',
'lowpro' => 1,
'set' => "last_visit=".$this->time_now.", last_activity=".$this->time_now,
'where' => "id=".$this->member['id']
) );
Thay bằng:
CODE
// No last visit set, do so now!
//wwo
$DB->simple_construct( array( 'update' => 'members',
'lowpro' => 1,
'set' => "last_visit=".$this->time_now.", last_activity=".$this->time_now.", last_ip='".$this->ip_address."'",
'where' => "id=".$this->member['id']
) );
//wwo
Tìm:
CODE
list( $be_anon, $loggedin ) = explode( '&', $this->member['login_anonymous'] );
$DB->simple_construct( array( 'update' => 'members',
'set' => "login_anonymous='$be_anon&1', last_visit=last_activity, last_activity=".$this->time_now,
'where' => "id=".$this->member['id']
) );
Thay bằng:
CODE
list( $be_anon, $loggedin ) = explode( '&', $this->member['login_anonymous'] );
//wwo
$DB->simple_construct( array( 'update' => 'members',
'set' => "login_anonymous='$be_anon&1', last_visit=last_activity, last_activity=".$this->time_now.", last_ip='".$this->ip_address."'",
'where' => "id=".$this->member['id']
) );
//wwo
Tìm:
CODE
function create_bot_session($bot, $name="")
{
global $DB, $std, $ibforums;
Thêm bên dưới:
CODE
//wwo
//--------------------------------
// Lets update log
//--------------------------------
if (($ibforums->vars['log_wwo_spider']) and ($ibforums->vars['enable_wwo']))
{
$realtimestamp = mktime(0,0,0,date("m,d,Y"));
$DB->simple_construct( array( 'select' => '*',
'from' => 'wwo_days',
'where' => "day_id = $realtimestamp" ) );
$DB->simple_exec();
if ( $DB->get_num_rows() != 0 )
{
$DB->simple_construct( array( 'update' => 'wwo_days', 'set' => 'spiders = spiders + 1', 'where' => "day_id = ".$realtimestamp) );
$DB->simple_shutdown_exec();
}
else
{
$DB->do_insert( 'wwo_days', array( 'day_id' => $realtimestamp,
'spiders' => "1" ) );
}
}
//wwo
Tìm:
CODE
function create_guest_session()
{
global $DB, $std, $ibforums;
Thêm bên dưới:
CODE
//wwo
//--------------------------------
// Lets update log
//--------------------------------
if (($ibforums->vars['log_wwo_guest']) and ($ibforums->vars['enable_wwo']))
{
$realtimestamp = mktime(0,0,0,date("m,d,Y"));
$DB->simple_construct( array( 'select' => '*',
'from' => 'wwo_days',
'where' => "day_id = $realtimestamp" ) );
$DB->simple_exec();
if ( $DB->get_num_rows() != 0 )
{
$DB->simple_construct( array( 'update' => 'wwo_days', 'set' => 'guests = guests + 1', 'where' => "day_id = ".$realtimestamp) );
$DB->simple_shutdown_exec();
}
else
{
$DB->do_insert( 'wwo_days', array( 'day_id' => $realtimestamp,
'guests' => "1" ) );
}
}
//wwo
Mở file ./sources/admin/admin_pages.php
Tìm:
CODE
5 => array( 'Topic Views' , 'act=stats&code=views' ),
Thêm bên dưới:
CODE
6 => array( 'Members Were Online', 'act=stats&code=online'),
Mở file ./sources/admin/ad_statistics.php
Tìm:
CODE
case 'show_views':
$this->show_views();
break;
case 'views':
$this->main_screen('views');
break;
//-----------------------
Thêm bên dưới:
CODE
//wwo
case 'show_online':
$this->show_online();
break;
case 'online':
$this->main_screen('online');
break;
//wwo
//-----------------------
Tìm:
CODE
default:
$this->main_screen('reg');
break;
}
}
Thêm bên dưới:
CODE
//---------------------------------------------------------------------------------
//| Results screen for Members were online
//---------------------------------------------------------------------------------
function show_online()
{
global $ibforums, $DB, $std;
$ibforums->admin->page_title = "Statistic Center Results";
$ibforums->admin->page_detail = "Showing members were online statistics";
//+---------------------
if ( ! checkdate($ibforums->input['to_month'] ,$ibforums->input['to_day'] ,$ibforums->input['to_year']) )
{
$ibforums->admin->error("The 'Date To:' time is incorrect, please check the input and try again");
}
if ( ! checkdate($ibforums->input['from_month'] ,$ibforums->input['from_day'] ,$ibforums->input['from_year']) )
{
$ibforums->admin->error("The 'Date From:' time is incorrect, please check the input and try again");
}
//+---------------------
$to_time = mktime(12 ,0 ,0 ,$ibforums->input['to_month'] ,$ibforums->input['to_day'] ,$ibforums->input['to_year'] );
$from_time = mktime(12 ,0 ,0 ,$ibforums->input['from_month'] ,$ibforums->input['from_day'] ,$ibforums->input['from_year']);
$human_to_date = getdate($to_time);
$human_from_date = getdate($from_time);
$DB->simple_construct( array( 'select' => '*', 'from' => 'wwo_days', 'where' => "day_id BETWEEN $from_time AND $to_time ", 'order' => "day_id ".$ibforums->input['sortby'] ) );
$DB->simple_exec();
$running_total = 0;
$guests_total = 0;
$spiders_total = 0;
$max_result = 0;
$results = array();
$ibforums->adskin->td_header[] = array( "Date" , "20%" );
if (($ibforums->vars['log_wwo_guest']) and ($ibforums->vars['log_wwo_spider']))
{
$ibforums->adskin->td_header[] = array( "Result" , "50%" );
}
elseif (($ibforums->vars['log_wwo_guest']) or ($ibforums->vars['log_wwo_spider']))
{
$ibforums->adskin->td_header[] = array( "Result" , "60%" );
}
else
{
$ibforums->adskin->td_header[] = array( "Result" , "70%" );
}
$ibforums->adskin->td_header[] = array( "Count" , "10%" );
if ($ibforums->vars['log_wwo_guest'])
{
$ibforums->adskin->td_header[] = array( "Guests" , "10%" );
}
if ($ibforums->vars['log_wwo_spider'])
{
$ibforums->adskin->td_header[] = array( "Spiders" , "10%" );
}
//-------------------------------
$ibforums->html .= $ibforums->adskin->start_table( "Members Were Online"
." ({$human_from_date['mday']} {$this->month_names[$human_from_date['mon']]} {$human_from_date['year']} to"
." {$human_to_date['mday']} {$this->month_names[$human_to_date['mon']]} {$human_to_date['year']})"
);
if ( $DB->get_num_rows() )
{
while ($row = $DB->fetch_row() )
{
if ( $row['was_online'] > $max_result )
{
$max_result = $row['was_online'];
}
$running_total += $row['was_online'];
$guests_total += $row['guests'];
$spiders_total += $row['spiders'];
$results[] = array(
'result_name' => date('F jS - Y',$row['day_id']),
'result_count' => $row['was_online'],
'result_guests' => $row['guests'],
'result_spiders' => $row['spiders'],
);
}
foreach( $results as $pOOp => $data )
{
$img_width = intval( ($data['result_count'] / $max_result) * 100 - 8);
if ($img_width < 1)
{
$img_width = 1;
}
$img_width .= '%';
unset ($res);
$res = array ( $data['result_name'],
"<img src='{$ibforums->adskin->img_url}/bar_left.gif' border='0' width='4' height='11' align='middle' alt=''><img src='{$ibforums->adskin->img_url}/bar.gif' border='0' width='$img_width' height='11' align='middle' alt=''><img src='{$ibforums->adskin->img_url}/bar_right.gif' border='0' width='4' height='11' align='middle' alt=''>",
"<center>".$data['result_count']."</center>", );
$ub = count($res);
if ($ibforums->vars['log_wwo_guest'])
{
$res[$ub] = "<center>".$data['result_guests']."</center>";
$ub++;
}
if ($ibforums->vars['log_wwo_spider'])
{
$res[$ub] = "<center>".$data['result_spiders']."</center>";
}
$ibforums->html .= $ibforums->adskin->add_td_row( $res );
}
unset ($res);
$res = array( ' ',
"<div align='right'><b>Total</b></div>",
"<center><b>".$running_total."</b></center>");
$ub = count($res);
if ($ibforums->vars['log_wwo_guest'])
{
$res[$ub] = "<center><b>".$guests_total."</b></center>";
$ub++;
}
if ($ibforums->vars['log_wwo_spider'])
{
$res[$ub] = "<center><b>".$spiders_total."</b></center>";
}
$ibforums->html .= $ibforums->adskin->add_td_row( $res );
}
else
{
$ibforums->html .= $ibforums->adskin->add_td_basic( "No results found", "center" );
}
$ibforums->html .= $ibforums->adskin->end_table();
$ibforums->admin->output();
}
Tìm:
CODE
else if ($mode == 'views')
{
$form_code = 'show_views';
$table = 'Topic View Statistics';
}
Thêm bên dưới:
CODE
else if ($mode == 'online')
{
$form_code = 'show_online';
$table = 'Members Were Online';
}
Tìm:
CODE
if ($mode != 'views')
Thay bằng:
[/code]if (($mode != 'views') and ($mode != 'online'))
CODE
Mở file ./sources/admin/ad_groups.php
Tìm:
[code]$prefix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['prefix']) );
$prefix = preg_replace( "/</" , "<" , $prefix );
$suffix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['suffix']) );
$suffix = preg_replace( "/</" , "<" , $suffix );
Thêm bên dưới:
CODE
//wwo
$wwo_prefix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['g_wwo_prefix']) );
$wwo_prefix = preg_replace( "/</" , "<" , $wwo_prefix );
$wwo_suffix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['g_wwo_suffix']) );
$wwo_suffix = preg_replace( "/</" , "<" , $wwo_suffix );
$wwo_post_prefix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['g_wwo_post_prefix']) );
$wwo_post_prefix = preg_replace( "/</" , "<" , $wwo_post_prefix );
$wwo_post_suffix = preg_replace( "/'/", "'" , $std->txt_safeslashes($_POST['g_wwo_post_suffix']) );
$wwo_post_suffix = preg_replace( "/</" , "<" , $wwo_post_suffix );
//wwo
Tìm:
CODE
'g_attach_per_post' => $ibforums->input['g_attach_per_post'],
Thêm bên dưới:
CODE
//wwo
'g_can_view_wwo' => $ibforums->input['g_can_view_wwo'],
'g_wwo_prefix' => $wwo_prefix,
'g_wwo_suffix' => $wwo_suffix,
'g_wwo_post_prefix' => $wwo_post_prefix,
'g_wwo_post_suffix' => $wwo_post_suffix,
//wwo
Tìm:
CODE
$prefix = preg_replace( "/'/", "'", $group['prefix'] );
$prefix = preg_replace( "/</", "<" , $prefix );
$suffix = preg_replace( "/'/", "'", $group['suffix'] );
$suffix = preg_replace( "/</", "<" , $suffix );
Thêm bên dưới:
//wwo
$wwo_prefix = preg_replace( "/'/", "'", $group['g_wwo_prefix'] );
$wwo_prefix = preg_replace( "/</", "<" , $wwo_prefix );
$wwo_suffix = preg_replace( "/'/", "'", $group['g_wwo_suffix'] );
$wwo_suffix = preg_replace( "/</", "<" , $wwo_suffix );
$wwo_post_prefix = preg_replace( "/'/", "'", $group['g_wwo_post_prefix'] );
$wwo_post_prefix = preg_replace( "/</", "<" , $wwo_post_prefix );
$wwo_post_suffix = preg_replace( "/'/", "'", $group['g_wwo_post_suffix'] );
$wwo_post_suffix = preg_replace( "/</", "<" , $wwo_post_suffix );
//wwo
Tìm:
CODE
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Online List Format [Suffix]</b><br>(Can be left blank)<br>(Example:</span>)" ,
$ibforums->adskin->form_input("suffix", $suffix )
) );
Thêm bên dưới:
CODE
//wwo
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Who Was Online List Format [Prefix]</b><br>(Can be left blank)<br>(Example:<span style='color:red'>)" ,
$ibforums->adskin->form_input("g_wwo_prefix", $wwo_prefix )
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Who Was Online List Format [Suffix]</b><br>(Can be left blank)<br>(Example:</span>)" ,
$ibforums->adskin->form_input("g_wwo_suffix", $wwo_suffix )
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Who Was Online List Already Posted Format [Prefix]</b><br>(Can be left blank)<br>(Example:<i><span style='color:red'>)" ,
$ibforums->adskin->form_input("g_wwo_post_prefix", $wwo_post_prefix )
) );
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Who Was Online List Already Posted Format [Suffix]</b><br>(Can be left blank)<br>(Example:</span></i>)" ,
$ibforums->adskin->form_input("g_wwo_post_suffix", $wwo_post_suffix )
) );
//wwo
Tìm:
CODE
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Can view OFFLINE board?</b>" ,
$ibforums->adskin->form_yes_no("g_access_offline", $group['g_access_offline'] )
) );
Thêm bên dưới:
CODE
//wwo
$ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Can view who was online today?</b>" ,
$ibforums->adskin->form_yes_no("g_can_view_wwo", $group['g_can_view_wwo'] )
) );
//wwo
Mở file ./sources/admin/ad_administration.php
Tìm:
CODE
$ibforums->main_msg = 'Moderators Updated';
break;
//-------------------------------------------------------------
// Stats
//-------------------------------------------------------------
case 'stats':
Thêm bên dưới:
CODE
//wwo
//lets get most online during day from database, if we have log of course
if (($ibforums->vars['show_most_wwo']) and ($ibforums->vars['log_wwo']) and ($ibforums->vars['enable_wwo']))
{
$DB->simple_construct( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key = 'stats' " ) );
$DB->simple_exec();
while ( $r = $DB->fetch_row() )
{
if ( $r['cs_array'] )
{
$ibforums->cache[ $r['cs_key'] ] = unserialize(stripslashes($r['cs_value']));
}
else
{
$ibforums->cache[ $r['cs_key'] ] = $r['cs_value'];
}
}
$max_count = $DB->simple_exec_query( array( 'select' => 'MAX(was_online) as max_online', 'from' => 'wwo_days' ) );
if ($max_count['max_online'] > $ibforums->cache['stats']['wwo_most_count'])
{
$ibforums->cache['stats']['wwo_most_count'] = $max_count['max_online'];
$day = $DB->simple_exec_query( array( 'select' => 'day_id', 'from' => 'wwo_days', 'where' => "was_online = ".$max_count['max_online'], 'limit' => array("0","1") ) );
$ibforums->cache['stats']['wwo_most_date'] = $day['day_id'];
$std->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) );
}
}
//wwo
Bước 2 (Skins and langs):
Mở file ./lang/*/lang_board.php
Tìm:
CODE
$lang = array (
Thêm bên dưới:
CODE
//wwo
'today_online' => "member(s) online today",
'last_activity' => "last online: ",
'wwo_ip_address' => "IP: ",
'wwo_posts' => "posts: ",
'wwo_last_post' => "last post: ",
'wwo_spiders' => "spider bots",
'wwo_most_online' => "Most users during day was <b><#NUM#></b> on <b><#DATE#></b>",
'wwo_posted' => "have posted",
'wwo_empty' => "None",
'wwo_filter' => "Show:",
'wwo_all' => "All",
'wwo_none' => "None",
'wwo_marker' => "> ",
'wwo_g_info' => "<#MARK#><b><#NUM#></b> <#NAME#> (<#PMARK#><b><#PNUM#></b> <#POSTED#>)",
//wwo
Thêm new template bit:
ACP -> Skin Manager -> *skin* -> Edit Skin Template HTML -> Board Index -> Add Template Bit
Name: online_today
Incoming Data Variables: $data
Value:
CODE
<tr>
<td class='pformstrip' colspan='2'>$data[TOTAL] {ipb.lang['today_online']}</td>
</tr>
<tr>
<td width="2%" class='row2'><{F_ACTIVE}></td>
<td class='row4' width='95%'>
<b>{$data[GUESTS]}</b> {$data[T_GUESTS]} <b>{$data[SPIDERS]}</b> {$data[T_SPIDERS]} <b>{$data[MEMBERS]}</b> {ipb.lang['public_members']} <b>{$data[ANON]}</b> {ipb.lang['anon_members']}
<div class='thin'>{$data[NAMES]}</div>
{ipb.lang['wwo_filter']} {$data[LINKS]} {$data[GROUPS]}
</td>
</tr>
Bước 3 (Database modification):
Upload wwo_db.php vào thư mục gốc diễn đàn & chạy bằng browser
(ví dụ:
http://yoursite.com/forums/wwo_db.php).
Bước 4 (importing settings):
Vào ACP -> View All General Settings -> Import an XML settings file
--> import wwo_settings.xml
Vào ACP & enable mod trong "CPU Saving", edit nhóm nào có thể xem được số người online
Done!
Chúc vui!!!