Beispiel #1
0
     message_die(GENERAL_MESSAGE, $message);
 }
 $row['user_level'] = $row['user_level'] == JUNIOR_ADMIN ? ADMIN : $row['user_level'];
 if ($row['user_id'] == ANONYMOUS) {
     $redirect_url = append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id);
     meta_refresh(3, $redirect_url);
     $message = $lang['Could_not_anon_user'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>');
     message_die(GENERAL_MESSAGE, $message);
 }
 $sql = "SELECT ug.user_id, u.user_level, u.group_id, u.user_color, u.user_rank\n\t\t\t\t\tFROM " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u\n\t\t\t\t\tWHERE u.user_id = " . $row['user_id'] . "\n\t\t\t\t\t\tAND ug.user_id = u.user_id\n\t\t\t\t\t\tAND ug.group_id = {$group_id}";
 $result = $db->sql_query($sql);
 if (!$db->sql_fetchrow($result)) {
     $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)\n\t\t\t\t\t\tVALUES (" . $row['user_id'] . ", {$group_id}, 0)";
     $db->sql_query($sql);
     update_user_color($row['user_id'], $group_color, $group_id, false, false);
     update_user_posts_details($row['user_id'], $group_color, '', false, false);
     if ($row['user_rank'] == '0' && $group_rank != '0') {
         $sql_users = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\t\tSET user_rank = '" . $group_rank . "'\n\t\t\t\t\t\t\tWHERE user_id = '" . $row['user_id'] . "'";
         $db->sql_query($sql_users);
     }
     if ($row['user_level'] != ADMIN && $row['user_level'] != MOD && $group_info['auth_mod']) {
         $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\t\tSET user_level = " . MOD . "\n\t\t\t\t\t\t\tWHERE user_id = " . $row['user_id'];
         $db->sql_query($sql);
     }
     $db->clear_cache();
     // Get the group name
     $group_sql = "SELECT group_name\n\t\t\t\t\t\tFROM " . GROUPS_TABLE . "\n\t\t\t\t\t\tWHERE group_id = {$group_id}";
     $result = $db->sql_query($group_sql);
     $group_name_row = $db->sql_fetchrow($result);
     $db->sql_freeresult($result);
     $group_name = $group_name_row['group_name'];
 // PROFILE EDIT BRIDGE - BEGIN
 $target_profile_data['email'] = $email;
 $target_profile_data['user_id'] = $user_id;
 // PROFILE EDIT BRIDGE - END
 $sn_im_sql = '';
 $user_sn_im_array = get_user_sn_im_array();
 foreach ($user_sn_im_array as $k => $v) {
     $sn_im_sql .= ", " . $v['field'] . " = '" . $db->sql_escape(str_replace(' ', '+', trim(${$v}['form']))) . "'";
 }
 // UPI2DB - EDIT
 // IN LINE ADD
 // , user_upi2db_which_system = $upi2db_which_system, user_upi2db_new_word = $upi2db_new_word, user_upi2db_edit_word = $upi2db_edit_word, user_upi2db_unread_color = $upi2db_unread_color
 $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET " . $username_sql . $passwd_sql . "user_email = '" . $db->sql_escape($email) . "', user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "', user_upi2db_which_system = {$upi2db_which_system}, user_upi2db_new_word = {$upi2db_new_word}, user_upi2db_edit_word = {$upi2db_edit_word}, user_upi2db_unread_color = {$upi2db_unread_color}, user_website = '" . $db->sql_escape($website) . "', user_occ = '" . $db->sql_escape($occupation) . "', user_from = '" . $db->sql_escape($location) . "', user_from_flag = '{$user_flag}', user_first_name = '" . $db->sql_escape($user_first_name) . "', user_last_name = '" . $db->sql_escape($user_last_name) . "', user_interests = '" . $db->sql_escape($interests) . "', user_phone = '" . $db->sql_escape($phone) . "', user_selfdes = '" . $db->sql_escape($selfdes) . "'" . $sn_im_sql . ", user_profile_view_popup = {$profile_view_popup}, user_birthday = '{$birthday}', user_birthday_y = '{$birthday_year}', user_birthday_m = '{$birthday_month}', user_birthday_d = '{$birthday_day}', user_next_birthday_greeting = '{$next_birthday_greeting}', user_allow_viewemail = {$viewemail}, user_attachsig = {$attachsig}, user_setbm = {$setbm}, user_allowsmile = {$allowsmilies}, user_showavatars = {$showavatars}, user_showsignatures = {$showsignatures}, user_allowswearywords = {$allowswearywords}, user_allowhtml = {$allowhtml}, user_allowbbcode = {$allowbbcode}, user_allow_mass_email = {$allowmassemail}, user_allow_pm_in = {$allowpmin}, user_allow_viewonline = {$allowviewonline}, user_notify = {$notifyreply}, user_notify_pm = {$notifypm}, user_popup_pm = {$popup_pm}, user_timezone = {$user_timezone}, user_time_mode = {$time_mode}, user_dst_time_lag = {$dst_time_lag}, user_dateformat = '" . $db->sql_escape($user_dateformat) . "', user_posts_per_page = '" . $db->sql_escape($user_posts_per_page) . "', user_topics_per_page = '" . $db->sql_escape($user_topics_per_page) . "', user_hot_threshold = '" . $db->sql_escape($user_hot_threshold) . "', user_topic_show_days = '" . $db->sql_escape($user_topic_show_days) . "', user_topic_sortby_type = '" . $db->sql_escape($user_topic_sortby_type) . "', user_topic_sortby_dir = '" . $db->sql_escape($user_topic_sortby_dir) . "', user_post_show_days = '" . $db->sql_escape($user_post_show_days) . "', user_post_sortby_type = '" . $db->sql_escape($user_post_sortby_type) . "', user_post_sortby_dir = '" . $db->sql_escape($user_post_sortby_dir) . "', user_lang = '" . $db->sql_escape($user_lang) . "', user_style = {$user_style}, user_active = {$user_active}, user_actkey = '{$user_actkey}'" . $avatar_sql . ", user_gender = '" . $gender . "'\n\t\t\t\tWHERE user_id = " . $user_id;
 $result = $db->sql_query($sql);
 if (!empty($username_sql)) {
     update_user_posts_details($user_id, '', '', true, true);
 }
 // Custom Profile Fields - BEGIN
 if ($mode == 'register' || $cpl_mode == 'profile_info') {
     $profile_data = get_fields('WHERE users_can_view = ' . ALLOW_VIEW);
     $profile_names = array();
     $semaphore = 0;
     if (!$profile_data) {
     } else {
         $sql2 = "UPDATE " . USERS_TABLE . " SET ";
         foreach ($profile_data as $fields) {
             $name = text_to_column($fields['field_name']);
             $type = $fields['field_type'];
             $required = $fields['is_required'] == REQUIRED ? true : false;
             if (isset($_POST[$name])) {
                 $temp = $_POST[$name];
Beispiel #3
0
 function autogroup($user_id)
 {
     global $db, $cache, $config, $lang;
     if ($user_id != ANONYMOUS) {
         if (!function_exists('update_user_color') || !function_exists('update_user_posts_details')) {
             include IP_ROOT_PATH . 'includes/functions_groups.' . PHP_EXT;
         }
         $sql = "SELECT ug.user_id, g.group_id as g_id, u.user_posts, u.group_id, u.user_color, g.group_count, g.group_color, g.group_count_max FROM (" . GROUPS_TABLE . " g, " . USERS_TABLE . " u)\n\t\t\t\t\tLEFT JOIN " . USER_GROUP_TABLE . " ug ON g.group_id = ug.group_id AND ug.user_id = '" . $user_id . "'\n\t\t\t\t\tWHERE u.user_id = '" . $user_id . "'\n\t\t\t\t\tAND g.group_single_user = '******'\n\t\t\t\t\tAND g.group_count_enable = '1'\n\t\t\t\t\tAND g.group_moderator <> '" . $user_id . "'";
         $result = $db->sql_query($sql);
         $user_cache_refresh = false;
         while ($group_data = $db->sql_fetchrow($result)) {
             $user_already_added = empty($group_data['user_id']) ? false : true;
             $user_add = $group_data['user_posts'] >= $group_data['group_count'] && $group_data['user_posts'] < $group_data['group_count_max'] ? true : false;
             $user_remove = $group_data['user_posts'] < $group_data['group_count'] || $group_data['user_posts'] >= $group_data['group_count_max'] ? true : false;
             if ($user_add && !$user_already_added) {
                 update_user_color($user_id, $group_data['group_color'], $group_data['g_id'], false, false);
                 update_user_posts_details($user_id, $group_data['group_color'], '', false, false);
                 $user_cache_refresh = true;
                 //user join a autogroup
                 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)\n\t\t\t\t\t\tVALUES (" . $group_data['g_id'] . ", {$user_id}, '0')";
                 $db->sql_query($sql);
             } elseif ($user_already_added && $user_remove) {
                 update_user_color($user_id, $config['active_users_color'], 0);
                 update_user_posts_details($user_id, '', '', false, false);
                 $user_cache_refresh = true;
                 //remove user from auto group
                 $sql = "DELETE FROM " . USER_GROUP_TABLE . "\n\t\t\t\t\t\tWHERE group_id = '" . $group_data['g_id'] . "'\n\t\t\t\t\t\tAND user_id = '" . $user_id . "'";
                 $db->sql_query($sql);
             }
         }
         $db->sql_freeresult($result);
         if (!empty($user_cache_refresh)) {
             empty_cache_folders(USERS_CACHE_FOLDER);
         }
     }
     return;
 }
Beispiel #4
0
    function sync_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
    {
        global $db, $config;
        if (!function_exists('update_user_color') || !function_exists('update_user_posts_details')) {
            include IP_ROOT_PATH . 'includes/functions_groups.' . PHP_EXT;
        }
        $sign = $mode == 'delete' ? '- 1' : '+ 1';
        $forum_update_sql = "forum_posts = forum_posts {$sign}";
        $topic_update_sql = '';
        if ($mode == 'delete') {
            if ($post_data['last_post']) {
                if ($post_data['first_post']) {
                    $forum_update_sql .= ', forum_topics = forum_topics - 1';
                } else {
                    $topic_update_sql .= 'topic_replies = topic_replies - 1';
                    $topic_data = $this->get_first_last_post_id($topic_id);
                    if (!empty($topic_data['last_post_id'])) {
                        $topic_update_sql .= ', topic_last_post_id = ' . $topic_data['last_post_id'];
                    }
                }
                if ($post_data['last_topic']) {
                    $last_post_id = $this->get_forum_last_post_id($forum_id);
                    if (!empty($last_post_id)) {
                        $forum_update_sql .= $row['last_post_id'] ? ', forum_last_post_id = ' . $last_post_id : ', forum_last_post_id = 0';
                    }
                }
            } elseif ($post_data['first_post']) {
                $topic_data = $this->get_first_last_post_id($topic_id);
                if (!empty($topic_data['first_post_id'])) {
                    $topic_update_sql .= 'topic_replies = topic_replies - 1, topic_first_post_id = ' . $topic_data['first_post_id'];
                }
            } else {
                $topic_update_sql .= 'topic_replies = topic_replies - 1';
            }
        } elseif ($mode != 'poll_delete') {
            $forum_update_sql .= ", forum_last_post_id = {$post_id}" . ($mode == 'newtopic' ? ", forum_topics = forum_topics {$sign}" : "");
            $topic_update_sql = "topic_last_post_id = {$post_id}" . ($mode == 'reply' ? ", topic_replies = topic_replies {$sign}" : ", topic_first_post_id = {$post_id}");
        } else {
            // Shall we update poll fields for this topic?
            //$topic_update_sql .= 'topic_vote = 0';
        }
        $db->sql_transaction('begin');
        if ($mode != 'poll_delete') {
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET {$forum_update_sql}\n\t\t\t\tWHERE forum_id = {$forum_id}";
            $db->sql_query($sql);
        }
        if ($topic_update_sql != '') {
            $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\t\tSET {$topic_update_sql}\n\t\t\t\tWHERE topic_id = {$topic_id}";
            $db->sql_query($sql);
        }
        if ($mode != 'poll_delete') {
            // Disable Post count - BEGIN
            $postcount = true;
            $sql = "SELECT forum_postcount\n\t\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\t\tAND forum_postcount = 0";
            $result = $db->sql_query($sql);
            if ($row = $db->sql_fetchrow($result)) {
                $postcount = false;
            }
            // Disable Post count - END
            $this->sync_topic_details($topic_id, $forum_id, false, false);
            if ($postcount) {
                $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\tSET user_posts = user_posts {$sign}\n\t\t\t\t\tWHERE user_id = {$user_id}";
                $db->sql_query($sql);
                $db->sql_transaction('commit');
                if ($config['site_history']) {
                    $current_time = time();
                    $minutes = gmdate('is', $current_time);
                    $hour_now = $current_time - 60 * ($minutes[0] . $minutes[1]) - ($minutes[2] . $minutes[3]);
                    $sql = 'UPDATE ' . SITE_HISTORY_TABLE . ' SET ' . ($mode == 'newtopic' || $post_data['first_post'] ? 'new_topics=new_topics' : 'new_posts=new_posts') . $sign . ' WHERE date=' . $hour_now;
                    $db->sql_return_on_error(true);
                    $result = $db->sql_query($sql);
                    $db->sql_return_on_error(false);
                    if (!$result || !$db->sql_affectedrows()) {
                        $sql = 'INSERT IGNORE INTO ' . SITE_HISTORY_TABLE . ' (date, ' . ($mode == 'newtopic' || $post_data['first_post'] ? 'new_topics' : 'new_posts') . ')
							VALUES (' . $hour_now . ', "1")';
                        $db->sql_query($sql);
                    }
                }
                $sql = "SELECT ug.user_id, g.group_id as g_id, u.user_posts, u.group_id, u.user_color, g.group_count, g.group_color, g.group_count_max FROM (" . GROUPS_TABLE . " g, " . USERS_TABLE . " u)\n\t\t\t\t\t\tLEFT JOIN " . USER_GROUP_TABLE . " ug ON g.group_id = ug.group_id AND ug.user_id = '" . $user_id . "'\n\t\t\t\t\t\tWHERE u.user_id = '" . $user_id . "'\n\t\t\t\t\t\tAND g.group_single_user = '******'\n\t\t\t\t\t\tAND g.group_count_enable = '1'\n\t\t\t\t\t\tAND g.group_moderator <> '" . $user_id . "'";
                $result = $db->sql_query($sql);
                while ($group_data = $db->sql_fetchrow($result)) {
                    $user_already_added = empty($group_data['user_id']) ? false : true;
                    $user_add = $group_data['group_count'] == $group_data['user_posts'] && $user_id != ANONYMOUS ? true : false;
                    $user_remove = $group_data['group_count'] > $group_data['user_posts'] || $group_data['group_count_max'] < $group_data['user_posts'] ? true : false;
                    if ($user_add && !$user_already_added) {
                        update_user_color($user_id, $group_data['group_color'], $group_data['g_id'], false, false);
                        update_user_posts_details($user_id, $group_data['group_color'], '', false, false);
                        empty_cache_folders(USERS_CACHE_FOLDER);
                        //user join a autogroup
                        $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)\n\t\t\t\t\t\t\tVALUES (" . $group_data['g_id'] . ", {$user_id}, '0')";
                        $db->sql_query($sql);
                    } elseif ($user_already_added && $user_remove) {
                        update_user_color($user_id, $config['active_users_color'], 0);
                        update_user_posts_details($user_id, '', '', false, false);
                        empty_cache_folders(USERS_CACHE_FOLDER);
                        //remove user from auto group
                        $sql = "DELETE FROM " . USER_GROUP_TABLE . "\n\t\t\t\t\t\t\tWHERE group_id = '" . $group_data['g_id'] . "'\n\t\t\t\t\t\t\tAND user_id = '" . $user_id . "'";
                        $db->sql_query($sql);
                    }
                }
            }
            $this->sync_cache(0, 0);
            board_stats();
            cache_tree(true);
        }
        return;
    }
Beispiel #5
0
                 }
                 $temp2 = substr($temp2, 0, strlen($temp2) - 1);
             }
             $temp = $temp2;
         } else {
             //$temp = is_numeric($temp) ? intval($temp) : htmlspecialchars($temp);
             $temp = is_numeric($temp) ? intval($temp) : (is_array($temp) ? array_map('htmlspecialchars', $temp) : htmlspecialchars($temp));
         }
         $profile_names[$name] = $temp;
         $sql2 .= $name . " = '" . $db->sql_escape($profile_names[$name]) . "', ";
     }
     $sql2 = substr($sql2, 0, strlen($sql2) - 2) . " WHERE user_id = " . $this_userdata['user_id'];
     $db->sql_query($sql2);
 }
 // Custom Profile Fields - END
 update_user_posts_details($this_userdata['user_id'], $user_color, '', true, true);
 // Delete forums/topics notifications if user has been deactivated
 if (empty($user_status)) {
     if (!class_exists('class_notifications')) {
         include IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT;
         $class_notifications = new class_notifications();
     }
     $class_notifications->delete_user_notifications($poster_id);
 }
 // PROFILE EDIT BRIDGE - BEGIN
 if (!class_exists('class_users')) {
     include_once IP_ROOT_PATH . 'includes/class_users.' . PHP_EXT;
 }
 if (empty($class_users)) {
     $class_users = new class_users();
 }
/**
* Add user(s) to group
*
* @return mixed false if no errors occurred
*/
function group_user_add($group_id, $user_id, $clear_cache = false, $is_autogroup_enable = false)
{
    // 2 => User already member
    // 1 => User added
    // 0 => User not added
    global $db, $cache, $config, $lang;
    $this_userdata = get_userdata($user_id);
    $sql = "SELECT * FROM " . USER_GROUP_TABLE . " ug\n\t\t\tWHERE ug.user_id = '" . (int) $user_id . "'\n\t\t\t\tAND ug.group_id = '" . (int) $group_id . "'";
    $result = $db->sql_query($sql);
    if ($row = $db->sql_fetchrow($result)) {
        $db->sql_freeresult($result);
        return 2;
    }
    $groups_data = get_groups_data(false, false, array($group_id));
    if (empty($groups_data)) {
        return 0;
    }
    $this_group_data = array();
    foreach ($groups_data as $group_data) {
        $this_group_data = $group_data;
        $group_rank = $group_data['group_rank'];
        $group_color = $group_data['group_color'];
    }
    $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (" . (int) $group_id . ", " . (int) $user_id . ", 0)";
    $result = $db->sql_query($sql);
    if (!empty($group_color) && $group_color != $this_userdata['user_color']) {
        update_user_color($user_id, $group_color, $group_id, false, false);
        update_user_posts_details($user_id, $group_color, '', false, false);
    }
    if (!empty($group_rank) && empty($this_userdata['user_rank'])) {
        update_user_rank_simple($user_id, $group_rank, false);
    }
    if ($clear_cache) {
        $db->clear_cache();
    }
    return 1;
}