- ชื่อ: Users Online Today Mod
- ผู้เขียน: Carceri
- นำเสนอโดย: DexMoreGroup
- ประเภท: New Feature
- รองรับ: SMF 1.1.xx, 2.0.x
- ปรับปรุงล่าสุด: 6 เมษายน 2553
- ต้นฉบับ: Users Online Today Mod
รายละเอียด แสดงชื่อของสมาชิกที่ออนไลน์ประจำวัน
ตัวอย่าง
สำหรับ SMF 1.1.xxแก้ไขไฟล์:file sourcedir/BoardIndex.php
ค้นหา-->>
$context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
เพิ่มไว้หลัง-->>
// Load the users online today.
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$context['num_hidden_users_online_today'] = 0;
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
if (empty($row['showOnline']))
{
$context['num_hidden_users_online_today'] = $context['num_hidden_users_online_today'] + 1;
if (!$user_info['is_admin']) continue;
}
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = ' title="' . $lastLogin . '"';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);
$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($context['users_online_today']);
krsort($context['list_users_online_today']);
$context['num_users_online_today'] = count($context['users_online_today']);
if (!$user_info['is_admin'])
{
$context['num_users_online_today'] = $context['num_users_online_today'] + $context['num_hidden_users_online_today'];
}
file sourcedir/Stats.php
ค้นหา-->>
$context['online_today'] = (int) $context['online_today'];
เพิ่มไว้หลัง-->>
// Total members online today
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);
$result = db_query("
SELECT
COUNT(*)
FROM {$db_prefix}members
WHERE lastLogin >= $midnight", __FILE__, __LINE__);
list ($context['total_users_online_today']) = mysql_fetch_row($result);
file themedir/BoardIndex.template.php
ค้นหา-->>
', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
</span>
</td>
</tr>';
เพิ่มไว้หลัง-->>
// Users online today
echo '
<tr>
<td class="titlebg" colspan="2">', $txt['uot_users_online_today'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt['uot_users_online_today'], '" border="0" />
</td>
<td class="windowbg2" width="100%">';
echo '
<div class="smalltext">';
echo $txt['uot_total'], ': <b>', $context['num_users_online_today'], '</b>';
if (!$context['user']['is_guest'])
echo ' (', $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_hidden_users_online_today']), ', ', $txt['uot_hidden'], ': ', $context['num_hidden_users_online_today'], ')';
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && !$context['user']['is_guest'])
echo '<br />', implode(', ', $context['list_users_online_today']);
echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr>';
file themedir/Stats.template.php
ค้นหา-->>
<td nowrap="nowrap">', $txt['users_online_today'], ':</td>
<td align="right">', $context['online_today'], '</td>';
แก้เป็น -->>
<td nowrap="nowrap">', $txt['users_online_today'], ':</td>
<td align="right">', $context['online_today'], '</td>
</tr><tr>
<td nowrap="nowrap">', $txt['uot_users_online_today'], ':</td>
<td align="right">', $context['total_users_online_today'], '</td>';
file languagedir/Modifications.thai-utf8.php
ค้นหา -->>
?>
เพิ่มไว้ก่อน -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียนfile languagedir/Stats.thai-utf8.php
ค้นหา-->>
$txt['average_members'] = 'สมาชิกเฉลี่ยต่อวัน';
$txt['average_posts'] = 'ตอบกระทู้เฉลี่ยต่อวัน';
$txt['average_topics'] = 'หัวข้อเฉลี่ยต่อวัน';
$txt['average_online'] = 'ออนไลน์เฉลี่ยต่อวัน';
$txt['users_online'] = 'ผู้ใช้งานที่ออนไลน์';
$txt['gender_ratio'] = 'อัตราส่วนระหว่างชายกับหญิง';
เพิ่มไว้หลัง-->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน
สำหรับ SMF 2.0.xแก้ไขไฟล์:file $sourcedir/BoardIndex.php
ค้นหา -->>
$context += getMembersOnlineStats($membersOnlineOptions);
เพิ่มไว้หลัง -->>
// Get the user online today list.
$context += getUsersOnlineTodayStats();
file $themedir/BoardIndex.template.php
ค้นหา -->>
// If they are logged in, but statistical information is off... show a personal message bar.
เพิ่มไว้ก่อน -->>
// Users Online Today
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $txt['uot_users_online_'.$modSettings['uot_setting_period']], '
</span>
</h4>
</div>
<p class="inline smalltext">';
echo
$txt['uot_total'], ': <b>', $context['num_users_online_today'], '</b>';
if ($context['viewing_allowed'])
echo
' (', $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_users_hidden_today']), ', ', $txt['uot_hidden'], ': ', $context['num_users_hidden_today'], ')';
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && $context['viewing_allowed'])
{
echo
'<br />', implode(', ', $context['list_users_online_today']);
}
echo '
</p>';
ดาวน์โหลด: Users_Online_Today_2.rar
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียนแตกไฟล์แล้วอัพโหลดไปไว้ที่
file Subs-UsersOnlineToday.php -->> $sourcedir
file UsersOnlineToday.english.php -->> $languagesdir
file UsersOnlineToday.thai-utf8.php -->> $languagesdir
สร้างไฟล์: install.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/install.php -->> Enter เสร็จแล้วลบทิ้ง
<?php
/* Copyright 2011 Michael Oestergaard Pedersen
This file is part of Users Online Today Mod.
Users Online Today Mod is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Users Online Today Mod is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along
with Users Online Today Mod. If not, see <http://www.gnu.org/licenses/>.
*/
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
global $modSettings;
// Add configuration settings to the database
$uot_variables = array(
array('name' => 'uot_setting_sortby', 'value' => 'login_time'),
array('name' => 'uot_setting_sortorder', 'value' => 'descending'),
array('name' => 'uot_setting_period', 'value' => 'current_day'),
array('name' => 'uot_setting_canview', 'value' => 'registered')
);
foreach ($uot_variables as $uot_var)
if (empty($modSettings[$uot_var['name']]))
updateSettings(array($uot_var['name'] => $uot_var['value']), false);
// Add the integration hooks needed by this mod
add_integration_function('integrate_pre_include', '$sourcedir/Subs-UsersOnlineToday.php',TRUE);
add_integration_function('integrate_general_mod_settings','UsersOnlineToday_settings',TRUE);
if (SMF == 'SSI')
echo 'Installation successful!';
?>
ลิงค์หัวข้อ:
http://dexmore.com/topic/262