Русское сообщество fluxbb

Быстрый лёгкий надёжный форумный движок

Вы не вошли.

Объявление

Вы можете внести свой вклад в содержание сайта. Жертвователи попадут в почетную группу "Спонсоры". Поддержать сайт.

#1 2006-07-22 12:30:27

Mad Chicken
Гость

Рекорд посещаемости

У большенства форумов есть такая фишка: "Наибольшее количество поситителей: 100 было завиксировано такого-то числа" А у punbb есть такая фича?

Редактировался hcs (2009-03-21 08:56:10)

#2 2006-08-15 10:53:20

kisin
Гость

Re: Рекорд посещаемости

я сам делал..вставляешь в index.php где-то недалеко от строки 195, перед выводом списка пользователей онлайн (хотя кто онлайн сейчас по-моему идет тоже как отдельный мод smile ):

    if ($num_users > 0) {
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<d

код:

//////////////
// most online
            $all_users = $num_users + $num_guests;
            $handle = fopen('most_online.txt', "r");
            $countx=fread($handle,3);
            if($all_users > $countx)
            {
                $fp = fopen('most_online.txt', "w");
                $fw = fwrite($fp, $all_users); 
                fclose($fp);
            }
            fclose($handle);
// end most online

и дальше выводишь где-нибудь на странице то, что выделено красным:

if ($num_users > 0) {
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong><a href="online.php">Кто в онлайн</a>:&nbsp;</strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'Максимум Online: <strong>'.$countx.'</strong> ('.date ("d-m-Y, H:i:s", filemtime('most_online.txt')).')'."\n\t\t\t".'</dl>'."\n"; // тут мы смотрим, когда файл был последний раз изменен

Редактировался kisin (2006-08-15 10:56:23)

#3 2006-08-16 16:35:01

OleaMM
Гость

Re: Рекорд посещаемости

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson ([email protected])

  This file is part of PunBB.

  PunBB 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.

  PunBB 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/


define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';


if ($pun_user['g_read_board'] == '0')
    message($lang_common['No view']);


// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';

$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';

// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

$cur_category = 0;
$cat_count = 0;
// stuff for toggling categories
$cat_ids = (isset($_COOKIE['collapseprefs']))? $_COOKIE['collapseprefs'].',': FALSE;

while ($cur_forum = $db->fetch_assoc($result))
{
    $moderators = '';

    if ($cur_forum['cid'] != $cur_category)    // A new category since last iteration?
    {
        if ($cur_category != 0)
            echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";

        ++$cat_count;


        // Setting varibles for toggling categories
        if (strstr($cat_ids, $cat_count.',')){
            $div_ido = "block";    $div_idx = "none";
        }else{
            $div_ido = "none";    $div_idx = "block";
        }
        $exp_up   = (is_file(PUN_ROOT.'img/'.$pun_user['style'].'/exp_up.png'))?  $pun_user['style'].'/exp_up.png': 'exp_up.png';
        $exp_down = (is_file(PUN_ROOT.'img/'.$pun_user['style'].'/exp_down.png'))? $pun_user['style'].'/exp_down.png': 'exp_down.png';
?>
<div id="ido<?php echo $cat_count ?>" class="blocktable" style="display:<?echo $div_ido?>">
    <h2>
        <span style="float:right"><a href="javascript:togglecategory(<?echo $cat_count?>,0);"><img src="img/<?echo $exp_down ?>" alt="Expand" /></a></span>
        <span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span>
    </h2>
</div>

<div id="idx<?php echo $cat_count ?>" class="blocktable" style="display:<?echo $div_idx?>">
    <h2>
        <span style="float:right"><a href="javascript:togglecategory(<?echo $cat_count?>,1);"><img src="img/<?echo $exp_up?>" alt="Collapse" /></a></span>
        <span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span>
    </h2>
   

    <div class="box">
        <div class="inbox">
            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
                    <th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
                    <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
                    <th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
                </tr>
            </thead>
            <tbody>
<?php

        $cur_category = $cur_forum['cid'];
    }

    $item_status = '';
    $icon_text = $lang_common['Normal icon'];
    $icon_type = 'icon';

    // Are there new posts?
    if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
    {
        $item_status = 'inew';
        $icon_text = $lang_common['New icon'];
        $icon_type = 'icon inew';
    }

    // Is this a redirect forum?
    if ($cur_forum['redirect_url'] != '')
    {
        $forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $num_topics = $num_posts = '&nbsp;';
        $item_status = 'iredirect';
        $icon_text = $lang_common['Redirect icon'];
        $icon_type = 'icon';
    }
    else
    {
        $forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
        $num_topics = $cur_forum['num_topics'];
        $num_posts = $cur_forum['num_posts'];
    }

    if ($cur_forum['forum_desc'] != '')
        $forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_forum['forum_desc'];


    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
    else
        $last_post = '&nbsp;';

    if ($cur_forum['moderators'] != '')
    {
        $mods_array = unserialize($cur_forum['moderators']);
        $moderators = array();

        while (list($mod_username, $mod_id) = @each($mods_array))
            $moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';

        $moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
    }

?>
                <tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
                    <td class="tcl">
                        <div class="intd">
                            <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
                            <div class="tclcon">
                                <?php echo $forum_field."\n".$moderators ?>
                            </div>
                        </div>
                    </td>
                    <td class="tc2"><?php echo $num_topics ?></td>
                    <td class="tc3"><?php echo $num_posts ?></td>
                    <td class="tcr"><?php echo $last_post ?></td>
                </tr>
<?php

}

// Did we output any categories and forums?
if ($cur_category > 0)
    echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
else
    echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>';


// Collect some statistics from the database
$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);

$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);

?>
<div id="brdstats" class="block">
    <h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
                <dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
                <dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
                <dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
            </dl>
            <dl class="conl">
                <dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
                <dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>
<?php

if ($pun_config['o_users_online'] == '1')
{
    // Fetch users online info and generate strings for output
    $num_guests = 0;
    $users = array();
    $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
            $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        else
            ++$num_guests;
    }

    $num_users = count($users);
    echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";


    if ($num_users > 0)
         echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<d
    else
        echo "\t\t\t".'<div class="clearer"></div>'."\n";

}
else
    echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";

if ($num_users > 0) {
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong><a href="online.php">Кто в онлайн</a>:&nbsp;</strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'Максимум Online: <strong>'.$countx.'</strong> ('.date ("d-m-Y, H:i:s", filemtime('most_online.txt')).')'."\n\t\t\t".'</dl>'."\n"; // тут мы смотрим, когда файл был последний раз изменен

?>
        </div>
    </div>
</div>
<?php

$footer_style = 'index';
require PUN_ROOT.'footer.php';

#4 2006-08-16 16:35:40

OleaMM
Гость

Re: Рекорд посещаемости

А где тут скрипты изменять подскажите пожалуйста

#5 2006-09-17 18:58:28

2maru
Гость

Re: Рекорд посещаемости

После вывода юзеров за сегодня (или кто актичен, если нет мода - online today) - у меня 230-я строка

в index.php пишем это:


    // most online
        $all_users = $num_users + $num_guests;
        $handle = fopen('most_online.txt', "r");
        $countx=fread($handle,3);
        if($all_users > $countx)
        {
            $fp = fopen('most_online.txt', "w");
            $fw = fwrite($fp, $all_users); 
            fclose($fp);
        }
        fclose($handle);
    echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".$lang_index['Most online1'].' (<strong>'.$countx.'</strong>) '.$lang_index['Most online2'].' '.date ("d-m-Y, H:i:s", filemtime('most_online.txt'))."\n\t\t\t".'</dl>'."\n"; // тут мы смотрим, когда файл был последний раз изменен
    // end most online

еще не забудьте создать текстовый файл most_online.txt в той же директории что и индексный

#6 2006-09-17 18:59:39

2maru
Гость

Re: Рекорд посещаемости

да, - спасибо огромное kisin - я просто поставил его код на место
и немного изменил:

"Больше всего он-лайн посетителей (2) здесь было 17-09-2006, 15:39:52"


ну и в lang/english/index.php наобходимо добавить:

'Most online1'            =>    'Maximum online users',
'Most online2'            =>    'was be there',


а  в lang/russian/index.php наобходимо добавить:

'Most online1'            =>    'Больше всего он-лайн посетителей',
'Most online2'            =>    'здесь было',

Редактировался 2maru (2006-09-17 19:02:06)

#7 2006-10-12 17:03:04

coordinator
Гость

Re: Рекорд посещаемости

Я не понял, учитывается максимальное количество одновременно прибывающих на форуме или максимальное количество посетителей за сутки?

#8 2006-10-12 17:37:08

Mad Chicken
Гость

Re: Рекорд посещаемости

coordinator пишет:

Я не понял, учитывается максимальное количество одновременно прибывающих на форуме или максимальное количество посетителей за сутки?

одновременно прибывающих

#9 2006-10-22 01:57:20

Slavik
Гость

Re: Рекорд посещаемости

Не понравилось решение через файлы. Сделал так:
Добавить после ~206 строки

    $result = $db->query("SELECT conf_value FROM ".$db_prefix."config WHERE conf_name='max_online'") or error('Unable to fetch page information', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_common['Bad request']);
    $dateonline = $db->fetch_assoc($result);
    if ($dateonline['conf_value'] < ($num_users + $num_guests)) {
        $quer = $db->query("UPDATE ".$db_prefix."config SET conf_value = '".($num_users+$num_guests)."' WHERE conf_name = 'max_online'") or error('Unable to fetch page information', __FILE__, __LINE__, $db->error());
        $quer = $db->query("UPDATE ".$db_prefix."config SET conf_value = '".date("j-n-Y h:i:s")."' WHERE conf_name = 'max_online_date'") or error('Unable to fetch page information', __FILE__, __LINE__, $db->error());
       };

Я вынес всю онлайн статистику в отдельный файл, но можно и в index.php, тогда добавлять сразу после предыдущего кода

    $result = $db->query("SELECT conf_value FROM ".$db_prefix."config WHERE conf_name='max_online'") or error('Unable to fetch page information', __FILE__, __LINE__, $db->error());
    $max_online = $db->fetch_assoc($result);
    $result = $db->query("SELECT conf_value FROM ".$db_prefix."config WHERE conf_name='max_online_date'") or error('Unable to fetch page information', __FILE__, __LINE__, $db->error());
    $max_online_date = $db->fetch_assoc($result);

~215 строчку index.php заменить с

    echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";

на

    echo "\t\t\t\t".'<dd>'. $lang_online['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_online['Users today'].': <strong>'.$num_users_today.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_online['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'<dd>'. $lang_online['Max users'].': <strong>'.$max_online['conf_value'].'</strong> '. $lang_online['Registered'].' <strong>'.$max_online_date['conf_value'].'</strong></dd></dl>'."\n";

В lang/[Russian]/online.php (либо index.php):

'Max users'                =>    'Максимальное количество юзеров:,
'Registered'            =>    'было'

#10 2006-10-22 01:59:05

Slavik
Гость

Re: Рекорд посещаемости

Чуть не забыл, выполнить перед всем этим:

INSERT INTO `foo_config` ( `conf_name` , `conf_value` ) VALUES ('max_online', '1'), ('max_online_date', '22-10-2006 03:02:09');

#11 2006-10-22 09:33:57

SDTux
Гость

Re: Рекорд посещаемости

Slavik, да, ваше решение куда как элегантнее, только что за таблица foo_config?

Редактировался SDTux (2006-10-22 09:48:38)

#12 2006-10-22 11:44:41

Slavik
Гость

Re: Рекорд посещаемости

$db_prefix."config";

#13 2006-10-22 13:56:44

SDTux
Гость

Re: Рекорд посещаемости

Да, чето протупил с утра. Еще вопрос - у тебя 206 строка - это которая (приведи код строки)?

#14 2006-10-22 14:45:56

Slavik
Гость

Re: Рекорд посещаемости

У меня вот так:

if ($pun_config['o_users_online'] == '1')
{
    // Fetch users online info and generate strings for output
    $num_guests = 0;
    $users = array();
    $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1)
            $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        else
            ++$num_guests;
    };

[b]206: ->[/b]    $num_users = count($users);

#15 2006-10-22 16:20:19

SDTux
Гость

Re: Рекорд посещаемости

усе, разобрался, у меня конечный вывод не был ничем затронут, поэтому выглядит, как в изначальном варианте punbb:

echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";

поэтому получается:

echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'<dd>'. $lang_index['Max users'].': <strong>'.$max_online['conf_value'].'</strong> '. $lang_index['Registered'].' <strong>'.$max_online_date['conf_value'].'</strong></dd></dl>'."\n";

Единственный косяк - вывод времени у меня происходит в формате am\pm без указания последнего...

Редактировался SDTux (2006-10-22 16:25:25)

#16 2006-10-22 21:43:49

Slavik
Гость

Re: Рекорд посещаемости

Там же date(), измените как угодно. Чтобы было в 24-часовом date("j-n-Y h:i:s") заменить на date("j-n-Y H:i:s")

#17 2008-05-28 19:45:11

NewUser21031972
Гость

Re: Рекорд посещаемости

А как сделать, чтоб выводился рекорд посещаемости за сутки?

Нужно чтоб выводилась надпись типа такой: "Рекорд посещаемости: 500 посетителей, зафиксирован: 29.05.2008"

Т.е. я хочу, чтоб подсчитывалась посещаемость не одновременно online, а за целые сутки, и выводился лучший результат за все время.

Моды типа Most users online at one time 1.2 выводят рекорд посещаемости online, и показывают дату и время рекорда, а нужно за полные сутки.


Может есть какой готовый мод?

Редактировался NewUser21031972 (2008-05-29 20:43:34)

#18 2009-02-21 16:00:17

Visman
Гость

Re: Рекорд посещаемости

Мой вариант MOD Рекорд посещаемости для версии 1.2.
Мод не добавляет ни одного дополнительного запроса к базе smile

1. Языковые файлы index.php в папках \lang\Russian и \lang\English выглядят так:

<?php

// Language definitions used in index.php
$lang_index = array(

'Topics' => 'Темы',
'Moderators' => 'Модераторы',
'Link to' => 'Ссылка на', // As in "Link to http://www.punbb.org/"
'Empty board' => 'Нет форумов.',
'Newest user' => 'Последний зарегистрированный пользователь',
'Users online' => 'Сейчас пользователей',
'Guests online' => 'гостей',
'No of users' => 'Всего зарегистрированных пользователей',
'No of topics' => 'Всего тем',
'No of posts' => 'Всего сообщений',
'Online' => 'Активны', // As in "Online: User A, User B etc."
'Board info' => 'Информация о форуме',
'Board stats' => 'Статистика форума',
'Most online1' => 'Больше всего он-лайн посетителей',
'Most online2' => 'здесь было',
'User info' => 'Информация о пользователе'

);
<?php

// Language definitions used in index.php
$lang_index = array(

'Topics' => 'Topics',
'Moderators' => 'Moderators',
'Link to' => 'Link to',    // As in "Link to http://www.punbb.org/"
'Empty board' => 'Board is empty.',
'Newest user' => 'Newest registered user',
'Users online' => 'Registered users online',
'Guests online' => 'guests online',
'No of users' => 'Total number of registered users',
'No of topics' => 'Total number of topics',
'No of posts' => 'Total number of posts',
'Online' => 'Online',    // As in "Online: User A, User B etc."
'Board info' => 'Board information',
'Board stats' => 'Board statistics',
'Most online1' => 'Maximum online users',
'Most online2' => 'was be there',
'User info' => 'User information'

);

2. Ф-ия update_users_online() в файле \include\functions.php изменена:

function update_users_online()
{
    global $db, $pun_config, $pun_user;

    $now = time();

  $kol = 0;
  $flag = false;
  
    // Fetch all online list entries that are older than "o_timeout_online"
    $result = $db->query('SELECT * FROM '.$db->prefix.'online') or error('Unable to fetch old entries from online list', __FILE__, __LINE__, $db->error());
    while ($cur_user = $db->fetch_assoc($result))
    {
    if ($cur_user['logged'] < ($now-$pun_config['o_timeout_online']))
    {
      // If the entry is a guest, delete it
      if ($cur_user['user_id'] == '1')
        $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($cur_user['ident']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
      else
      {
        // If the entry is older than "o_timeout_visit", update last_visit for the user in question, then delete him/her from the online list
        if ($cur_user['logged'] < ($now-$pun_config['o_timeout_visit']))
        {
          $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$cur_user['logged'].' WHERE id='.$cur_user['user_id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
          $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$cur_user['user_id']) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
        }
        else if ($cur_user['idle'] == '0')
          $db->query('UPDATE '.$db->prefix.'online SET idle=1 WHERE user_id='.$cur_user['user_id']) or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
      }
    }
    else
      $kol++;
    }
    @include PUN_ROOT.'cache/cache_maxusers.php';
    if (!defined('PUN_MAXUSERS_LOADED'))
    $flag = true;
  else
  {
    if ($stats['max_users'] < $kol )
      $flag = true;
  }
  
    if ($flag)
    {
    $fh = @fopen(PUN_ROOT.'cache/cache_maxusers.php', 'wb');
    if (!$fh)
      error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__);

      fwrite($fh, '<?php'."\n\n".'define(\'PUN_MAXUSERS_LOADED\', 1)'.";\n");
    fwrite($fh, '$stats[\'max_users\'] = '.$kol.";\n");
    fwrite($fh, '$stats[\'max_users_time\'] = '.$now.";\n");

    fclose($fh);
  }
}

3. Файл index.php в корне форума изменен.
Это

echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";

меняем на

    echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong>, '.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t\n"; // ".'</dl>'."
  @include PUN_ROOT.'cache/cache_maxusers.php';
  if (defined('PUN_MAXUSERS_LOADED'))
    echo "\t\t\t\t".'<dd>'. $lang_index['Most online1'].' ('.$stats['max_users'].') '.$lang_index['Most online2'].' '.format_time($stats['max_users_time']).'</dd>'."\n\t\t\t".'</dl>'."\n";

Выглядит так 09d9bcbd04a9.png

Редактировался Visman (2009-02-21 16:17:59)

#19 2009-02-21 18:13:49

artoodetoo
Гость

Re: Рекорд посещаемости

Visman, отличная работа!

offtopic: ты в своей подписи антипиаришь сайт? smile)) пару сотен новых посетителей ты им наверняка сделал.

#20 2009-02-21 19:35:40

Visman
Гость

Re: Рекорд посещаемости

artoodetoo
offtopic: антипиарю, а то был бы физ. доступ до серверов, получился бы большой бум smile

#21 2009-03-21 02:38:53

Sten
Гость

Re: Рекорд посещаемости

А на версии 1.3 всё так же прописывать можно? И нет ли отдельного расширения для этой фишки?

#22 2009-03-21 06:45:50

Visman
Гость

Re: Рекорд посещаемости

Sten пишет:

А на версии 1.3 всё так же прописывать можно?

Нельзя! Версия 1.3 несовместима с 1.2.

Подвал доски

Под управлением FluxBB. Хостинг Hostens