top five

Discuţii legate de instalarea şi funcţionarea unor MODificări vechi sau noi ale forumului phpBB 3.0.x.
Reguli forum
Aveti o problema si vreti sa primiti ajutor? Click aici ! Nu uitati si de regulamentul forumului !
Închis
alex2209
Utilizator înregistrat
Mesaje: 13
Membru din: 16-Noi-2015, 18:25:47
Versiune: 3.0.5
Ext: Da
Server: Windows
Nivel phpBB: Mediu
Nivel php: Mediu

top five

Mesaj de alex2209 »

URL forum: http://metin2elyas.ro/board
Versiunea phpbb 3: 3.0.14
Daca forumul a fost instalat recent sau reprezinta un update/upgrade/conversie? -
Ati folosit un wizard de instalare furnizat de firma de gazduire pentru instalare? Nu
MODurile instalate: Top five, mchat.
De cand a aparut problema semnalata? Astazi
Nivelul vostru de experienta in instalarea/utilizarea/administrarea phpbb (fiti sinceri, raspunsul ar putea fi formulat pe intelesul vostru daca sunteti la inceput). Mediu.
Template-ul folosit: we_clearblue
Limba/limbile instalate: Romana/Engleza

La mine arata asa momentan : http://i.imgur.com/rJRkmAi.png
Doresc sa adaug in topfive.php un cod care sa imi puna si locul in care s-a postat topicul respectiv.
Exemplu : http://i.imgur.com/PnigyDX.png
Avatar utilizator
Anișor
AdministratorAdministrator
Mesaje: 2987
Membru din: 08-Aug-2012, 20:46:05
Versiune: 4.0.0-a1
Ext: Da
Server: UNIX/Linux
Nivel phpBB: Experimentat
Nivel php: Mediu
Localitate: Arbroath, Angus
Contact:

Re: top five

Mesaj de Anișor »

Uf ...
Să zicem ...

Fișierul includes/top_five.php

Cod: Selectaţi tot

<?php
/**
*
* @package phpBB3
* @version $Id:
* @copyright (c) 2013 Rich McGirr
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @ Top five varianta Just4Metin by Animo
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
        exit;
}

/**
* Include only once.
*/
if (!defined('INCLUDES_TOP_FIVE_PHP'))
{
        define('INCLUDES_TOP_FIVE_PHP', true);

        global $auth, $cache, $user, $db, $phpbb_root_path, $phpEx, $template, $config;

    $user->add_lang('mods/top_five');
        $how_many = 5; //change this number if you want more or less to display
        $forum_ary = array();
        $forum_read_ary = $auth->acl_getf('f_read');
        
        foreach ($forum_read_ary as $forum_id => $allowed)
        {
                if ($allowed['f_read'])
                {
                        $forum_ary[] = (int) $forum_id;
                }
        }
        $forum_ary = array_unique($forum_ary);

        if (sizeof($forum_ary))
        {
                /**
                * Select topic_ids
                */
                $sql = 'SELECT forum_id, topic_id, topic_type
                        FROM ' . TOPICS_TABLE . '
                        WHERE ' . $db->sql_in_set('forum_id', $forum_ary) . '
                        ORDER BY topic_last_post_time DESC';
                        
                $result = $db->sql_query_limit($sql, $how_many);
                $forums = $ga_topic_ids = $topic_ids = array();
                while ($row = $db->sql_fetchrow($result))
                {
                        $topic_ids[] = $row['topic_id'];
                        if ($row['topic_type'] == POST_GLOBAL)
                        {
                                $ga_topic_ids[] = $row['topic_id'];
                        }
                        else
                        {
                                $forums[$row['forum_id']][] = $row['topic_id'];
                        }
                }
                $db->sql_freeresult($result);

                // Get topic tracking
                $topic_ids_ary = $topic_ids;
                $topic_tracking_info = array();
                foreach ($forums as $forum_id => $topic_ids)
                {
                        $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $topic_ids, $ga_topic_ids);
                }
                $topic_ids = $topic_ids_ary;
                unset($topic_ids_ary);
                                
                // grab all posts that meet criteria and auths
                $sql_ary = array(
                        'SELECT'        => 'u.user_id, u.username, u.user_colour, t.topic_title, f.forum_name, t.forum_id, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_last_poster_name, p.post_text',
                        'FROM'                => array(TOPICS_TABLE => 't'),
                        'LEFT_JOIN'        => array(
                                array(
                                        'FROM'        => array(USERS_TABLE => 'u'),
                                        'ON'        => 't.topic_last_poster_id = u.user_id',
                                ),
                                array(
                                        'FROM'        => array(POSTS_TABLE => 'p'),
                                        'ON'        => 'p.post_id = t.topic_last_post_id',
                                ), 
								array(
    									'FROM'   =>   array(FORUMS_TABLE   => 'f'),
    									'ON'   => 'f.forum_id = t.forum_id',
                                ),								
                        ),
                        'WHERE'                => $db->sql_in_set('t.topic_id', $topic_ids),
                        'ORDER_BY'        => 't.topic_last_post_time DESC',
                );

                $result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $how_many);
                while( $row = $db->sql_fetchrow($result) )
                {
                        $topic_id = $row['topic_id'];
                        $forum_id = $row['forum_id'];
                        
                        $post_unread = (isset($topic_tracking_info[$forum_id][$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false;
                        $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
						$view_forum_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
                        $topic_title = censor_text($row['topic_title']);
                        if (utf8_strlen($topic_title) >= 60)
                        {
                                $topic_title = (utf8_strlen($topic_title) > 60 + 3) ? utf8_substr($topic_title, 0, 60) . '...' : $topic_title;
                        }
                        $is_guest = $row['user_id'] != ANONYMOUS ? false : true;

                        //BEGIN Topic Text Hover Mod
                        if(!empty($row['post_text']) && !empty($config['hover_active']))
                        {
                                if(!function_exists('bbcode_strip'))
                                {
                                        include($phpbb_root_path . 'includes/topic_text_hover.' . $phpEx);
                                }
                                $text_hover = censor_text(bbcode_strip($row['post_text']));
                                if (utf8_strlen($text_hover) >= $config['hover_char_limit'])
                                {
                                        $text_hover = (utf8_strlen($text_hover) > $config['hover_char_limit'] + 3) ? utf8_substr($text_hover, 0, $config['hover_char_limit']) . '...' : $text_hover;
                                }
                        }
                        // END Topic Text Hover MOD                         
                        $template->assign_block_vars('top_five_topic',array(
                                'U_TOPIC'                        => $view_topic_url,
								'FORUM_TITLE'   => $row['forum_name'],
								'U_FORUM'                        => $view_forum_url,
                                'MINI_POST_IMG'                        => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
                                'POST_TEXT'                        => (isset($text_hover)) ? $text_hover : '',
                                'USERNAME_FULL'                => $is_guest ? $user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $row['topic_last_poster_name']) : $user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
                                'LAST_TOPIC_TIME'        => $user->format_date($row['topic_last_post_time'], '|d M Y|, H:i'),
                                'TOPIC_TITLE'                 => $topic_title,
                        ));
                }

                $db->sql_freeresult($result);
        }
        else
        {
                $template->assign_block_vars('top_five_topic', array(
                        'NO_TOPIC_TITLE'        => $user->lang['NO_TOPIC_EXIST'],
                ));
        }
        // top five posters
        // an array of user types we dont' bother with
        // could add board founder (USER_FOUNDER) if wanted
        $ignore_users = array(USER_IGNORE, USER_INACTIVE);
        
        // top five posters
        if (($user_posts = $cache->get('_top_five_posters')) === false)
        {
                $user_posts = $admin_mod_array = array();
                // quick check for forum moderators and administrators
                // some may not want to show them
                $not_show_admins_mods = false; //change false to true to have moderators and administrators not shown in top five posters

                $sql_and = '';
                if ($not_show_admins_mods)
                {
                        // grab all admins
                        $admin_ary = $auth->acl_get_list(false, 'a_', false);
                        $admin_ary = (!empty($admin_ary[0]['a_'])) ? $admin_ary[0]['a_'] : array();
                        
                        //grab all mods
                        $mod_ary = $auth->acl_get_list(false,'m_', false);
                        $mod_ary = (!empty($mod_ary[0]['m_'])) ? $mod_ary[0]['m_'] : array();
                        $admin_mod_array = array_unique(array_merge($admin_ary,$mod_ary));
                        
                        if(sizeof($admin_mod_array))
                        {
                                $sql_and = ' AND ' . $db->sql_in_set('u.user_id', $admin_mod_array, true);
                        }
                }

                // do the main sql query
                $sql_ary = array(
                 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_posts',
                 'FROM' => array(USERS_TABLE => 'u'),
                 'WHERE' => $db->sql_in_set('u.user_type', $ignore_users, true) . ' ' . $sql_and . '
                         AND u.user_posts <> 0',
                 'ORDER_BY' => 'u.user_posts DESC',
                );
                $result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $how_many);
                while ($row = $db->sql_fetchrow($result))
                {
                        $user_posts[$row['user_id']] = array(
                                'user_id' => $row['user_id'],
                                'username' => $row['username'],
                                'user_colour' => $row['user_colour'],
                                'user_posts' => $row['user_posts'],
                        );
                }
                $db->sql_freeresult($result);

                // cache this data for 5 minutes, this improves performance
                $cache->put('_top_five_posters', $user_posts, 300);
        }

        foreach ($user_posts as $row)
        {
                $username_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

                $template->assign_block_vars('top_five_active',array(
                        'S_SEARCH_ACTION'        => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&sr=posts'),
                        'POSTS'                         => number_format($row['user_posts']),
                        'USERNAME_FULL'                => $username_string,
                ));
    }

    // newest registered users
        if (($newest_users = $cache->get('_top_five_newest_users')) === false)
        {
         $newest_users = array();

         // grab most recent registered users
                $sql = 'SELECT user_id, username, user_colour, user_regdate
                        FROM ' . USERS_TABLE . '
                        WHERE ' . $db->sql_in_set('user_type', $ignore_users, true) . '
                                AND user_inactive_reason = 0
                        ORDER BY user_regdate DESC';
                $result = $db->sql_query_limit($sql, $how_many);

                while ($row = $db->sql_fetchrow($result))
                {
                        $newest_users[$row['user_id']] = array(
                                'user_id'                                => $row['user_id'],
                                'username'                                => $row['username'],
                             'user_colour'                        => $row['user_colour'],
                'user_regdate'                        => $row['user_regdate'],
                        );
                }
         $db->sql_freeresult($result);

                // cache this data for ever, cache is purged when adding or deleting users
                $cache->put('_top_five_newest_users', $newest_users);
        }

        foreach ($newest_users as $row)
        {
                $username_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

                $template->assign_block_vars('top_five_newest',array(
                        'REG_DATE'                        => $user->format_date($row['user_regdate'], '|d M Y|, H:i'),
                        'USERNAME_FULL'                => $username_string,
                ));
        }
}
?>
Animo (Anișor),
Moderator Team Member
Nu ofer ajutor prin intermediul mesageriei private.
Vă rog să postați toate problemele în forumuri.
Închis

Înapoi la “3.0.x Suport pentru MODificări”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Google [Bot] și 5 vizitatori