IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

phpBB2 : Partager une base de données entre plusieurs forums

Image non disponible


précédentsommairesuivant

IV. Les scripts à retoucher

Ces modifications doivent être apportées aux scripts de chacun des sites concernés !

IV-A. config.php

Pensez à mettre l'identifiant du site en cours (pas nécessairement « 1 »).

Ajouter :
Sélectionnez
$common_prefix = 'forums_';
$site_id = 1;

IV-B. includes/constants.php

Les « tables de partage » n'utilisent pas le préfixe normal du site, mais un préfixe global, défini plus haut comme « forums_ ».

Trouver :
Sélectionnez
// Table names
define('CONFIRM_TABLE', $table_prefix.'confirm');
define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');
define('BANLIST_TABLE', $table_prefix.'banlist');
define('CATEGORIES_TABLE', $table_prefix.'categories');
define('CONFIG_TABLE', $table_prefix.'config');
define('DISALLOW_TABLE', $table_prefix.'disallow');
define('FORUMS_TABLE', $table_prefix.'forums');
define('GROUPS_TABLE', $table_prefix.'groups');
define('POSTS_TABLE', $table_prefix.'posts');
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore');
define('PRUNE_TABLE', $table_prefix.'forum_prune');
define('RANKS_TABLE', $table_prefix.'ranks');
define('SEARCH_TABLE', $table_prefix.'search_results');
define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist');
define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch');
define('SESSIONS_TABLE', $table_prefix.'sessions');
define('SESSIONS_KEYS_TABLE', $table_prefix.'sessions_keys');
define('SMILIES_TABLE', $table_prefix.'smilies');
define('THEMES_TABLE', $table_prefix.'themes');
define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
define('TOPICS_TABLE', $table_prefix.'topics');
define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
define('USER_GROUP_TABLE', $table_prefix.'user_group');
define('USERS_TABLE', $table_prefix.'users');
define('WORDS_TABLE', $table_prefix.'words');
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
Remplacer par :
Sélectionnez
// Table names
define('CONFIRM_TABLE', $common_prefix.'confirm');
define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');
define('BANLIST_TABLE', $common_prefix.'banlist');
define('CATEGORIES_TABLE', $common_prefix.'categories');
define('ALL_CATEGORIES_TABLE', $common_prefix.'categories');
define('CONFIG_TABLE', $table_prefix.'config');
define('DISALLOW_TABLE', $common_prefix.'disallow');
define('FORUMS_TABLE', $table_prefix.'forums');
define('ALL_FORUMS_TABLE', $common_prefix.'forums');
define('GROUPS_TABLE', $table_prefix.'groups');
define('POSTS_TABLE', $table_prefix.'posts');
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
define('PRIVMSGS_TABLE', $common_prefix.'privmsgs');
define('PRIVMSGS_TEXT_TABLE', $common_prefix.'privmsgs_text');
define('PRIVMSGS_IGNORE_TABLE', $common_prefix.'privmsgs_ignore');
define('PRUNE_TABLE', $table_prefix.'forum_prune');
define('RANKS_TABLE', $table_prefix.'ranks');
define('SEARCH_TABLE', $common_prefix.'search_results');
define('SEARCH_WORD_TABLE', $common_prefix.'search_wordlist');
define('SEARCH_MATCH_TABLE', $common_prefix.'search_wordmatch');
define('SESSIONS_TABLE', $table_prefix.'sessions');
define('SESSIONS_KEYS_TABLE', $table_prefix.'sessions_keys');
define('SMILIES_TABLE', $table_prefix.'smilies');
define('THEMES_TABLE', $table_prefix.'themes');
define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
define('TOPICS_TABLE', $table_prefix.'topics');
define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
define('USER_GROUP_TABLE', $table_prefix.'user_group');
define('USERS_TABLE', $table_prefix.'users');
define('ALL_USERS_TABLE', $common_prefix.'users');
define('USERS_CONFIG_TABLE', $table_prefix.'users_config');
define('WORDS_TABLE', $common_prefix.'words');
define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
define('ALL_SITES_TABLE', $common_prefix.'sites');

IV-C. admin/admin_forums.php

Occupons-nous maintenant de corriger le script d'administration standard des forums.

IV-C-1. Ajout de forum

Pour une raison que j'ignore (ou à laquelle je n'adhère pas), phpBB ne laisse pas l'identifiant de forum en AUTO_INCREMENT : il utilise plutôt l'identifiant maximum et ajoute 1. Il nous faut modifier ce comportement pour utiliser la table de partage plutôt que la vue SQL, sans quoi nous aurions fréquemment des « duplicate key ».

Trouver :
Sélectionnez
            $sql = "SELECT MAX(forum_id) AS max_id
                FROM " . FORUMS_TABLE;
Remplacer par :
Sélectionnez
            $sql = "SELECT MAX(forum_id) AS max_id
                FROM " . ALL_FORUMS_TABLE;

IV-C-2. Ajout de catégorie

Toute nouvelle catégorie doit contenir l'identifiant du site où elle apparaîtra.

Trouver :
Sélectionnez
            $sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
                VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $next_order)";
Remplacer par :
Sélectionnez
            $sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, site_id, cat_order)
                VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $site_id, $next_order)";

IV-C-3. Suppression de forum

La suppression d'un forum doit être opérée sur la table partagée et non sur les vues.

Trouver :
Sélectionnez
"DELETE FROM " . FORUMS_TABLE . "
Remplacer par :
Sélectionnez
"DELETE FROM " . ALL_FORUMS_TABLE . "

IV-D. includes/prune.php

IV-D-1. La surveillance des sujets

Trouver :
Sélectionnez
"DELETE FROM " . TOPICS_WATCH_TABLE . "
Remplacer par :
Sélectionnez
"DELETE FROM " . ALL_TOPICS_WATCH_TABLE . "

IV-D-2. Les sujets

Trouver :
Sélectionnez
"DELETE FROM " . TOPICS_TABLE . "
Remplacer par :
Sélectionnez
"DELETE FROM " . ALL_TOPICS_TABLE . "

IV-D-3. Les messages

Trouver :
Sélectionnez
"DELETE FROM " . POSTS_TABLE . "
Remplacer par :
Sélectionnez
"DELETE FROM " . ALL_POSTS_TABLE . "

IV-D-4. Le contenu des messages

Trouver :
Sélectionnez
"DELETE FROM " . POSTS_TEXT_TABLE . "
Remplacer par :
Sélectionnez
"DELETE FROM " . ALL_POSTS_TEXT_TABLE . "

IV-E. Le cas des Utilisateurs

Il y a deux manières de modifier explicitement un profil d'utilisateur : l'internaute lui-même avec le script usercp_register.php, ou bien un administrateur au moyen des scripts admin/admin_users.php et admin/admin_ug_auth.php.

Mais ce n'est pas tout : il y a également tous les scripts qui mettent à jour en arrière-plan, par exemple pour les sessions.

IV-E-1. includes/usercp_register.php

IV-E-1-a. Ajout d'un utilisateur
Trouver :
Sélectionnez
            //
            // Get current date
            //
            $sql = "INSERT INTO " . USERS_TABLE . "    (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
                VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
            if ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa )
            {
                $user_actkey = gen_rand_string(true);
                $key_len = 54 - (strlen($server_url));
                $key_len = ( $key_len > 6 ) ? $key_len : 6;
                $user_actkey = substr($user_actkey, 0, $key_len);
                $sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
            }
            else
            {
                $sql .= "1, '')";
            }

            if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
            {
                message_die(GENERAL_ERROR, 'Could not insert data into users table', '', __LINE__, __FILE__, $sql);
            }

            $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator)
                VALUES ('', 'Personal User', 1, 0)";
            if ( !($result = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
            }

            $group_id = $db->sql_nextid();

            $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
                VALUES ($user_id, $group_id, 0)";
            if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
            {
                message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);
            }
Remplacer par :
Sélectionnez
            $sql = 'SELECT site_users_config_table, site_groups_table, site_user_groups_table, site_config_table
                    FROM ' . ALL_SITES_TABLE;
            if ( !($q_sites = $db->sql_query($sql, BEGIN_TRANSACTION)) )
            {
                message_die(GENERAL_ERROR, 'Could not get Sites data', '', __LINE__, __FILE__, $sql);
            }

            //
            // We need to insert the user config for each site
            //
            if($db->sql_numrows($q_sites))
            {
                $site_rows = $db->sql_fetchrowset($q_sites);
                foreach($site_rows as $site_row)
                {
                    //
                    // We don't know if the lang & style chosen by the user
                    // will be available for all the sites,
                    // so let's take the board default lang & style instead
                    //
                    $sql = "REPLACE INTO " . $site_row['site_users_config_table'] . "    (user_id, user_dateformat, user_lang, user_style)
                        VALUES ($user_id, '" . str_replace("\'", "''", $user_dateformat) . "',
                        (
                            SELECT MAX(config_value)
                            FROM " . $site_row['site_config_table'] . "
                            WHERE config_name = 'default_lang'
                        ),
                        (
                            SELECT MAX(config_value)
                            FROM " . $site_row['site_config_table'] . "
                            WHERE config_name = 'default_style'
                        ))";
                    if ( !($result = $db->sql_query($sql)) )
                    {
                        message_die(GENERAL_ERROR, 'Could not insert data into users config table', '', __LINE__, __FILE__, $sql);
                    }

                    $sql = "REPLACE INTO " . $site_row['site_groups_table'] . " (group_name, group_description, group_single_user, group_moderator)
                        VALUES ('', 'Personal User', 1, 0)";
                    if ( !($result = $db->sql_query($sql)) )
                    {
                        message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
                    }

                    $group_id = $db->sql_nextid();

                    $sql = "REPLACE INTO " . $site_row['site_user_groups_table'] . " (user_id, group_id, user_pending)
                        VALUES ($user_id, $group_id, 0)";
                    if( !($result = $db->sql_query($sql)) )
                    {
                        message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);
                    }
                }
            }

            $sql = "INSERT INTO " . ALL_USERS_TABLE . "    (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_level, user_allow_pm, user_active, user_actkey)
                VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, 0, 1, ";
            if ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa )
            {
                $user_actkey = gen_rand_string(true);
                $key_len = 54 - (strlen($server_url));
                $key_len = ( $key_len > 6 ) ? $key_len : 6;
                $user_actkey = substr($user_actkey, 0, $key_len);
                $sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
            }
            else
            {
                $sql .= "1, '')";
            }

            if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
            {
                message_die(GENERAL_ERROR, 'Could not insert data into global users table', '', __LINE__, __FILE__, $sql);
            }
IV-E-1-b. Mise à jour d'un utilisateur
Trouver :
Sélectionnez
            $sql = "UPDATE " . USERS_TABLE . "
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
                WHERE user_id = $user_id";
            if ( !($result = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
            }
Remplacer par :
Sélectionnez
            $sql = "UPDATE " . USERS_CONFIG_TABLE . "
                SET user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style
                WHERE user_id = $user_id";
            if ( !($result = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not update users config table', '', __LINE__, __FILE__, $sql);
            }

            $sql = "UPDATE " . ALL_USERS_TABLE . "
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_timezone = $user_timezone, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
                WHERE user_id = $user_id";
            if ( !($result = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
            }

IV-E-2. admin/admin_users.php

IV-E-2-a. Mise à jour d'un utilisateur
Trouver :
Sélectionnez
            $sql = "UPDATE " . USERS_TABLE . "
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . "
                WHERE user_id = $user_id";
Remplacer par :
Sélectionnez
            $sql = "UPDATE " . USERS_CONFIG_TABLE . "
                SET user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_rank = $user_rank
                WHERE user_id = $user_id";
            if( ! $db->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Admin_user_fail', '', __LINE__, __FILE__, $sql);
            }

            $sql = "UPDATE " . ALL_USERS_TABLE . "
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_timezone = $user_timezone, user_active = $user_status" . $avatar_sql . "
                WHERE user_id = $user_id";
IV-E-2-b. Suppression d'un utilisateur
Trouver :
Sélectionnez
            $sql = "DELETE FROM " . USERS_TABLE . "
                WHERE user_id = $user_id";
            if( !$db->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql);
            }

            $sql = "DELETE FROM " . USER_GROUP_TABLE . "
                WHERE user_id = $user_id";
            if( !$db->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Could not delete user from user_group table', '', __LINE__, __FILE__, $sql);
            }

            $sql = "DELETE FROM " . GROUPS_TABLE . "
                WHERE group_id = " . $row['group_id'];
            if( !$db->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
            }
Remplacer par :
Sélectionnez
            $sql = "DELETE FROM " . ALL_USERS_TABLE . "
                WHERE user_id = $user_id";
            if( !$db->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql);
            }

            $sql = 'SELECT site_users_config_table, site_groups_table, site_user_groups_table
                    FROM ' . ALL_SITES_TABLE;
            if ( !($q_sites = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not get Sites data', '', __LINE__, __FILE__, $sql);
            }

            //
            // We need to delete the user config for each site
            //
            if($db->sql_numrows($q_sites))
            {
                $site_rows = $db->sql_fetchrowset($q_sites);
                foreach($site_rows as $site_row)
                {
                    $sql = "DELETE FROM " . $site_row['site_users_config_table'] . "
                        WHERE user_id = $user_id";
                    if( !$db->sql_query($sql) )
                    {
                        message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql);
                    }

                    $sql = "DELETE FROM " . $site_row['site_user_groups_table'] . "
                        WHERE user_id = $user_id";
                    if( !$db->sql_query($sql) )
                    {
                        message_die(GENERAL_ERROR, 'Could not delete user from user_group table', '', __LINE__, __FILE__, $sql);
                    }

                    $sql = "DELETE FROM " . $site_row['site_groups_table'] . "
                        WHERE group_id = " . $row['group_id'];
                    if( !$db->sql_query($sql) )
                    {
                        message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
                    }
                }
            }

IV-E-3. Champs spécifiques à un site

Dans les scripts suivants :

  • includes/sessions.php
Trouver tous :
Sélectionnez
"UPDATE " . USERS_TABLE . "
Remplacer tous par :
Sélectionnez
"UPDATE " . USERS_CONFIG_TABLE . "

IV-E-4. Champs partagés par tous les sites

Dans les scripts suivants :

  • admin/admin_forums.php
  • admin/admin_groups.php
  • admin/admin_ranks.php
  • admin/admin_styles.php
  • admin/admin_ug_auth.php
  • includes/functions_post.php
  • includes/page_header.php
  • includes/usercp_activate.php
  • includes/usercp_email.php
  • includes/usercp_sendpasswd.php
  • groupcp.php
  • privmsg.php
Trouver tous :
Sélectionnez
$sql = "UPDATE " . USERS_TABLE . "
Remplacer tous par :
Sélectionnez
$sql = "UPDATE " . ALL_USERS_TABLE . "

Dans les scripts suivants :

  • modcp.php
Trouver :
Sélectionnez
$count_sql[] = "UPDATE " . USERS_TABLE . "
Remplacer par :
Sélectionnez
$count_sql[] = "UPDATE " . ALL_USERS_TABLE . "

précédentsommairesuivant

Copyright © 2007 Guillaume Rossolini. Aucune reproduction, même partielle, ne peut être faite de ce site ni de l'ensemble de son contenu : textes, documents, images, etc. sans l'autorisation expresse de l'auteur. Sinon vous encourez selon la loi jusqu'à trois ans de prison et jusqu'à 300 000 € de dommages et intérêts.