To jest tylko wersja do druku, aby zobaczyć pełną wersję tematu, kliknij TUTAJ
phpBB2 by Przemo
Support forów phpBB2 modified by Przemo

Mod. Gotowe < [ 1.9.5 ] - Color groups

Sylvio - 28-04-2006, 19:03

Tak, wiem, że tam to jest, lecz nie mogę zaaktualizować forum, ponieważ baze mysql mi się gryzą obu wersji, mam już 74 userów i ok. 1600 postów, i nie mogę sobie pozwolić na stratę tych danych. Zresztą nie mogę znaleźć jak dopasować bazę mysql i jej danę do aktualizacji.

--------------
Uff, poradziłem sobie z tym problemem fartem. Najnormalnie zrobiłem tak:
http://nazwa_mojej_strony...?sid=numersesji

Działa!!!
-------------------------------

Plis, powie ktoś, co trzeba zrobić by zmienic te podwójne nalicznaie userów, jest trzech na stronie, a pisze, że jest ich sześciu! Plis, pomóż ktoś, nie wiem co mam z tym zrboić!

vargburzum - 20-02-2007, 01:31

Dobra... Powiedzcie mi jak zrobić żeby w tym chamstwie wyświetlało overliba z czasem jaki user spędził na forum.

DO tego doszłem sam:

Kod:
functions_color_groups.php

<?php
/***************************************************************************
*                    $RCSfile: functions_color_groups.php,v $
*                            -------------------
*   copyright            : (C) 2002-2003 Nivisec.com
*   email                : support@nivisec.com
*
*   $Id: functions_color_groups.php,v 1.3 2003/09/03 02:52:46 nivisec Exp $
*
*
***************************************************************************/

/***************************************************************************
*
*   This program 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.
*
***************************************************************************/
if (!defined('IN_PHPBB') || !IN_PHPBB) die('Invalid Function Include, Hacking Attempt?');

define('RGB_COLOR_LIST', 'aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,white,yellow');
define('COPYRIGHT_NIVISEC_FORMAT',
'<br /><span class="copyright"><center>
    %s
    &#169; %s
    <a href="http://www.nivisec.com" class="copyright">Nivisec.com</a>.
    Version 2.0 dopieszczona by <a href="http://panicz.info" class="copyright">panicz</a>.
    </center></span>'
);


if (!function_exists('copyright_nivisec'))
{
    /**
    * @return void
    * @desc Prints a sytlized line of copyright for module
    */
    function copyright_nivisec($name, $year)
    {
        printf(COPYRIGHT_NIVISEC_FORMAT, $name, $year);
    }
}

if (!function_exists('check_font_color_nivisec'))
{
    /**
    * @return boolean
    * @param item string
    * @desc Checks for a valid color entry in the form of one of default words or #rrggbb.  Assumes $colors is defined already.
    */
    function check_font_color_nivisec($item)
    {
        global $colors;
        //Find out if it's a valid hex or valid word
        if (!preg_match("/#[0-9,A-F,a-f]{6}/", $item) && !in_array($item, explode(",", RGB_COLOR_LIST)))
        {
            return false;
        }
        //If we get this far, it exists and/or is valid
        return true;
    }
}

if (!function_exists('find_lang_file_nivisec'))
{
    /**
    * @return boolean
    * @param filename string
    * @desc Tries to locate and include the specified language file.  Do not include the .php extension!
    */
    function find_lang_file_nivisec($filename)
    {
        global $lang, $phpbb_root_path, $board_config, $phpEx;
       
        if (file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/$filename.$phpEx"))
        {
            include_once($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/$filename.$phpEx");
        }
        elseif (file_exists($phpbb_root_path . "language/lang_english/$filename.$phpEx"))
        {
            include_once($phpbb_root_path . "language/lang_english/$filename.$phpEx");
        }
        else
        {
            message_die(GENERAL_ERROR, "Unable to find a suitable language file for $filename!", '');
        }
        return true;
    }
}
if (!function_exists('set_filename_nivisec'))
{
    /**
    * @return boolean
    * @param filename string
    * @param handle string
    * @desc Sets the filename to handle in the $template class.  Saves typing for me :)
    */
    function set_filename_nivisec($handle, $filename)
    {
        global $template;
       
        $template->set_filenames(array(
        $handle => $filename
        ));
       
        return true;
    }
}
if (!function_exists('do_query_nivisec'))
{
    /**
    * @return void
    * @param sql string
    * @param $result_list array
    * @param error string
    * @desc Does $sql query.  If error, prints $error and modifies reference $result_list to be a row set
    */
    function do_query_nivisec($sql, &$result_list, $error)
    {
        global $db;
       
        if (!$result = $db->sql_query($sql))
        {
            message_die(GENERAL_ERROR, $error, '', __LINE__, __FILE__, $sql);
        }
        $result_list = $db->sql_fetchrowset($result);
    }
}

if (!function_exists('do_fast_query_nivisec'))
{
    /**
    * @return void
    * @param sql string
    * @param error string
    * @desc Does $sql query and doesn't bother with results.  If error, prints $error
    */
    function do_fast_query_nivisec($sql, $error)
    {
        global $db;
       
        if (!$db->sql_query($sql))
        {
            message_die(GENERAL_ERROR, $error, '', __LINE__, __FILE__, $sql);
        }
    }
}
function get_color_group_order_max()
{
    global $db, $lang;
   
    $sql = 'SELECT max(order_num) as max FROM ' . COLOR_GROUPS_TABLE;
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
   
    return $row['max'];
}
function get_color_group_order_min()
{
    global $db, $lang;
   
    $sql = 'SELECT MIN(order_num) as min FROM ' . COLOR_GROUPS_TABLE;
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
   
    return $row['min'];
}
/**
* @return void
* @param new string
* @param orig string
* @param type int
* @desc Updates user levels of type based on the difference between new and orig string lists
*/
function color_groups_update_group_id($group_list, $user_list, $group_id)
{
    global $lang, $db, $status_message;
    /* Debugging for this function */
    $debug = false;
   
    $sql = array();
   
    // Set all old user's and groups to "NO COLOR GROUP" to take care of any deletions //
    $sql[] = 'UPDATE ' . USERS_TABLE . "
        SET user_color_group = 0
        WHERE user_color_group = $group_id";
    $sql[] = 'UPDATE ' . GROUPS_TABLE . "
        SET group_color_group = 0
        WHERE group_color_group = $group_id";
    // Set all new list items to have the color group, if we were given a list //
    if (!empty($user_list))
    {
        $sql[] = 'UPDATE ' . USERS_TABLE . "
        SET user_color_group = $group_id
        WHERE user_id IN ($user_list)";
    }
    if (!empty($group_list))
    {
        $sql[] = 'UPDATE ' . GROUPS_TABLE . "
        SET group_color_group = $group_id
        WHERE group_id IN ($group_list)";
    }
   
    // DO the actual SQL commands now //
    foreach($sql as $command)
    {
        if (!$db->sql_query($command))
        {
            message_die(GENERAL_ERROR, $lang['Error_Group_Table'], '', __LINE__, __FILE__, $sql);
        }
    }
   
    $status_message .= $lang['Updated_Group'];
}

function color_groups_setup_list()
{
    global $lang, $template, $db;
   
    $sql = 'SELECT * FROM ' . COLOR_GROUPS_TABLE . '
        WHERE hidden = 0
        ORDER BY order_num ASC';
    if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, $lang['Error_Group_Table'], '', __LINE__, __FILE__, $sql);
    $list = '';
    while ($row = $db->sql_fetchrow($result))
    {
        $list .= '&nbsp;[ <span style="font-weight:bold;color:' . $row['group_color'] . '">' . $row['group_name'] . '</span> ]&nbsp;';
    }
   
    $template->assign_var('COLOR_GROUPS_LIST', $list);
}

function color_group_colorize_name($user_id, $no_profile = false, $addsymb = true)
{
    global $board_config, $phpEx, $db, $phpbb_root_path;
   
$defsymb = ''; // taki symbol beda mieli nie-kolorowani uzyszkodnicy

    // First see if the user is Anon
    if ($user_id != ANONYMOUS)
    {
        // Get the user info and see if they are assigned a color_group //
        $sql = 'SELECT u.user_color_group, u.username, c.* FROM ' . USERS_TABLE . ' u, ' . COLOR_GROUPS_TABLE . " c
            WHERE u.user_id = $user_id
            AND u.user_color_group = c.group_id";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
       
        if (!isset($row['username']))
        {
            //If there was a problem before, we don't want a blank username!
            $sql = 'SELECT username FROM ' . USERS_TABLE . "
            WHERE user_id = $user_id";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
        }
        $username = $row['username'];
       
        if (isset($row['group_color']))
        {
            // WE found the highest level color, head out now //
            $style_color = 'style="font-weight:bold;color:' . $row['group_color'] . '"';
            $symb = $row['symb'];
            $colorized = true;

        }
        else
        {
            // Now start looking for user group memberships //
            $sql = 'SELECT c.* FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u, ' . COLOR_GROUPS_TABLE . ' c, ' . GROUPS_TABLE . ' g
                WHERE ug.user_id = ' . $user_id . '
                AND u.user_id = ug.user_id
                AND ug.group_id = g.group_id
                AND g.group_color_group = c.group_id
                AND g.group_single_user = 0';
            //print $sql;
                $result = $db->sql_query($sql);
                $curr = 10000000000000;
                $style_color = '';
                while ($row = $db->sql_fetchrow($result))
                {
                    // If our new group in the list is a higher order number, it's color takes precedence //
                    if ($row['order_num'] < $curr)
                    {
                        $curr = $row['order_num'];
                        $style_color = 'style="font-weight:bold;color:' . $row['group_color'] . '"';
                        $symb = $row['symb'];
                        $colorized = true;

                    }
                }
        }

        // Add symbol for rank if exists
        if ($addsymb && !empty($symb))
        {
        $username = $symb . $username;
        }
        else if($addsymb && empty($symb) && !$colorized)
        {
            $username = $defsymb . $username;
        }

       
        // Make the profile link or no and return it //
        if ($no_profile)
        {
            $user_link = "<span $style_color>$username</span>";
        }
        else
        {
                $time_online = ((time() - $row['session_start']) < 3600) ? round( (time() - $row['session_start']) / 60, 0 ) : round( (time() - $row['session_start']) / 60 / 60, 1 );
                $lang_online = ((time() - $row['session_start']) < 3600) ? $lang['online_minutes'] : $lang['online_hours'];
                $overlib_online =  'onMouseOver="return overlib(\'<left>' . sprintf($lang_online, $time_online)  . '<br /><b>' . $loc . '</b></left>\', CAPTION, \'<center>' . str_replace("'","`",$row['username']) . '</center>\')" onMouseOut="nd();"';
            $user_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id") . '" class="gensmall" ' . $overlib_online . $style_color .'>' . $username . '</a>';
        }
        return($user_link);
    }
    else
    {
        return false;
    }
}

?>



Overlib mi isę wyświetla ale bez czasu. Jakieś sugestie?
Inaczej zapytam bo z tego co widziałem na tym forum to macie tendencje do udzielania głupich odpowiedzi (pewnie z powodu nieznajomości skryptu) - pytam bo jestem zielony w tych sprawach: jak do tego co dopisałem załączyć czas z page_header.php? I wolałbym żeby funkcja czasu z przyczyn oczywistych została w page_header....


Żeby ułatwić powiem, że dopisałem i pozmieniałem zrąbany kod tutaj:
Kod:

                $time_online = ((time() - $row['session_start']) < 3600) ? round( (time() - $row['session_start']) / 60, 0 ) : round( (time() - $row['session_start']) / 60 / 60, 1 );
                $lang_online = ((time() - $row['session_start']) < 3600) ? $lang['online_minutes'] : $lang['online_hours'];
                $overlib_online =  'onMouseOver="return overlib(\'<left>' . sprintf($lang_online, $time_online)  . '<br /><b>' . $loc . '</b></left>\', CAPTION, \'<center>' . str_replace("'","`",$row['username']) . '</center>\')" onMouseOut="nd();"';
            $user_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id") . '" class="gensmall" ' . $overlib_online . $style_color .'>' . $username . '</a>';
        }
        return($user_link);


Dla tych co mieli problemy z wyłączeniem podkreślenia to właśnie to:

Kod:
            $user_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id") . '" class="gensmall" ' . $overlib_online . $style_color .'>' . $username . '</a>';
        }


jest rozwiązaniem (dziwnym trafem zmiana o której pisało w instrukcji nie śmigała). Tylko bez kitu, że coś źle wyedytowałem ;) Wogóle nic innego mnie nie interesuje tylko ten overlib i komentarze niezwiązane możecie sobie odpuścić.

Radek - 20-02-2007, 12:06

Kod:
SELECT u.user_color_group, u.username, c.* FROM ' . USERS_TABLE . ' u, ' . COLOR_GROUPS_TABLE . " c
            WHERE u.user_id = $user_id

sprobuj zamienic na to:
Kod:
SELECT u.user_color_group, u.username, c.*, s.session_start FROM ' . USERS_TABLE . ' u, ' . COLOR_GROUPS_TABLE . " c, " . SESSIONS_TABLE . " s
            WHERE u.user_id = $user_id
AND s.user_id = u.user_id

a po tym:
Kod:
 $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);

dodaj:
Kod:
$session_start = $row['session_start'];

i teraz zamien wszystkie $row['session_start'] na $session_start w tym kodzie, który sam dopisałeś

A tak przy okazji:
1. Jaką masz wersje forum ? W wersjach 1.12.x jest już mod do kolorowania nickow.
2. Nie radze stosować color groups

vargburzum - 20-02-2007, 15:40

W tym sęk, że mam 1.9... Zmiana na 1.12.5 nie wchodzi w gre bo na tym forum mam:
- Własny system portalowy zintegrowany z forum (wgryza się w niektórych miejscach w kod),
- Coś jak shop mod własnej produkcji ,
- Paski życia, spożycia alkoholu, ekwipunek (forum do gier fabularnych) i takie tam pierdoły wszystko dorabiane własnoręcznie (nie przezemnie ale przez innego administratora ja tylko byłem malutkim suportem),
Tym samym zmiana nie wchodzi w gre jako, że podpięcie tego pod 1.12.5 byłoby zbyt czasochłonne, energochłonne i możliwe, że niemożliwe ;P.
O niesmaowitych zaletach 1.12.5 zdążyłem się przekonac na drugim moim forum także już mocno zmodyfikowanym no ale niestety musze mieć color groups pod 1.9 bo inaczej być nie może.
Już testuje przeróbke Ruska i z góry dziękuje za pomoc.

Radek - 20-02-2007, 17:50

vargburzum, jak nie zadziala to co ja podalem, to nie ma sensu kombinowac - zainstaluj Color Ranks ( jest przerobiony do 1.9 ). Color groups strasznie obciaza forum...
vargburzum - 20-02-2007, 21:20

W color ranks mi coś strasznie nie odpowiadało... Nie pamiętam co bo mi wyszło instalowanie tego nad ranem ale coś tam jednak mi nie odpowiadało... To co mi podałeś nie działa jak narazie ale dam sobie rade nic się nie bójcie. To tylko kwestia czasu. A obciążeniem nie ma się co martwić... Serwek dość sporej gazety nieźle sobie radzi i musze przyznać, że działa nadzwyczaj wydajnie.
3502274 - 20-03-2007, 23:11

Witam,

zlukałem sobie to modyfikację i zabrałem się do pracy...

Ale tutaj jest jakiś błąd:

Kod:

#-----[ OPEN ]------------------------------------------
#
index.php

#-----[ FIND ]------------------------------------------------
#
$birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow[$i]['user_id']) . '" class="gensmall"' . $style_color .'><b>' . $birthdayrow[$i]['username'] . '</a></b>('.$user_age.')';

#
#-----[ REPLACE WITH ]----------------------------------------
#
$birthday_week_list .= color_group_colorize_name($birthdayrow[$i]['user_id']).' ('.$user_age.'),';

#
#-----[ FIND ]------------------------------------------------
#
$birthday_today_list .= ' &nbsp;<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow[$i]['user_id']) . '" class="mainmenu"' . $style_color .'><b>' . $birthdayrow[$i]['username'] . '</a></b> ('.$user_age.')' . $congratulations_link;

#
#-----[ REPLACE WITH ]----------------------------------------
#
$birthday_today_list .=  color_group_colorize_name($birthdayrow[$i]['user_id']).' ('.$user_age.')' . $congratulations_link;
 
#


nic podobnego niema w kodzie tego pliku... sprawdzałem czy niema czegoś na "birthday" i by cokolwiek potym przypominało to co w instrukcji ale niestety nic się nie zgadza...

co może być powodem??

vargburzum - 07-09-2007, 14:32

Nie masz urodzinowych wynalazków to sobie odpuść... Po prostu nie będzie Ci kolorowało czegoś czego i tak nie masz ;)
joli - 07-09-2007, 14:49

3502274, to jets mod do 1.9
pecador - 08-09-2007, 00:12

vargburzum, po co odgrzebujesz stare tematy?


Powered by phpBB modified by Przemo © 2003 phpBB Group