Вход Регистрация
Файл: admin/users_manage.php
Строк: 1175
<?php
/***************************************************************************
 *                              users.php
 *                            -------------------
 *      ����������: phpBB Group.
 *      ����������� ��� WAP: ������ ����� ( ��� ).
 *          2008 ���
 ***************************************************************************/

define('IN_PHPBB'1);

if( !empty(
$setmodules) )
{
    
$filename basename(__FILE__);
    
$module['Users']['Manage'] = $filename;

    return;
}

$phpbb_root_path './../';
require(
$phpbb_root_path 'extension.inc');
require(
'./pagestart.' $phpEx);
require(
$phpbb_root_path 'includes/bbcode.'.$phpEx);
require(
$phpbb_root_path 'includes/functions_post.'.$phpEx);
require(
$phpbb_root_path 'includes/functions_selects.'.$phpEx);
require(
$phpbb_root_path 'includes/functions_validate.'.$phpEx);

$html_entities_match = array('#<#''#>#');
$html_entities_replace = array('&lt;''&gt;');

if( isset( 
$HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) )
{
    
$mode = ( isset( $HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
    
$mode htmlspecialchars($mode);
}
else
{
    
$mode '';
}

if ( 
$mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) || isset($HTTP_GET_VARS[POST_USERS_URL]) || isset( $HTTP_POST_VARS[POST_USERS_URL]) ) )
{
        
attachment_quota_settings('user'$HTTP_POST_VARS['submit'], $mode);

    if ( ( 
$mode == 'save' && isset( $HTTP_POST_VARS['submit'] ) ) || isset( $HTTP_POST_VARS['avatargallery'] ) || isset( $HTTP_POST_VARS['submitavatar'] ) || isset( $HTTP_POST_VARS['cancelavatar'] ) )
    {
        
$user_id intval($HTTP_POST_VARS['id']);

        if (!(
$this_userdata get_userdata($user_id)))
        {
            
message_die(GENERAL_MESSAGE$lang['No_user_id_specified'] );
        }

        if( 
$HTTP_POST_VARS['deleteuser'] && ( $userdata['user_id'] != $user_id ) )
        {
            
$sql "SELECT g.group_id 
                FROM " 
USER_GROUP_TABLE " ug, " GROUPS_TABLE " g  
                WHERE ug.user_id = 
$user_id 
                    AND g.group_id = ug.group_id 
                    AND g.group_single_user = 1"
;
            if( !(
$result $db->sql_query($sql)) )
            {
                
message_die(GENERAL_ERROR'Could not obtain group information for this user'''__LINE____FILE__$sql);
            }

            
$row $db->sql_fetchrow($result);
            
            
$sql "UPDATE " POSTS_TABLE "
                SET poster_id = " 
DELETED ", post_username = '" str_replace("\'""''"addslashes($this_userdata['username'])) . "' 
                WHERE poster_id = 
$user_id";
            if( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not update posts for this user'''__LINE____FILE__$sql);
            }

            
$sql "UPDATE " TOPICS_TABLE "
                SET topic_poster = " 
DELETED 
                WHERE topic_poster = 
$user_id";
            if( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not update topics for this user'''__LINE____FILE__$sql);
            }
            
            
$sql "UPDATE " VOTE_USERS_TABLE "
                SET vote_user_id = " 
DELETED "
                WHERE vote_user_id = 
$user_id";
            if( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not update votes for this user'''__LINE____FILE__$sql);
            }
            
            
$sql "UPDATE " GROUPS_TABLE "
                SET group_moderator = " 
$userdata['user_id'] . "
                WHERE group_moderator = 
$user_id";
            if( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not update group moderators'''__LINE____FILE__$sql);
            }

            
$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);
            }

            
$sql "DELETE FROM " AUTH_ACCESS_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);
            }

            
$sql "DELETE FROM " TOPICS_WATCH_TABLE "
                WHERE user_id = 
$user_id";
            if ( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not delete user from topic watch table'''__LINE____FILE__$sql);
            }
            
            
$sql "DELETE FROM " BANLIST_TABLE "
                WHERE ban_userid = 
$user_id";
            if ( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not delete user from banlist table'''__LINE____FILE__$sql);
            }

            
$sql "DELETE FROM " SESSIONS_TABLE "
                WHERE session_user_id = 
$user_id";
            if ( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not delete sessions for this user'''__LINE____FILE__$sql);
            }
            
            
$sql "DELETE FROM " SESSIONS_KEYS_TABLE "
                WHERE user_id = 
$user_id";
            if ( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR'Could not delete auto-login keys for this user'''__LINE____FILE__$sql);
            }

            
$sql "SELECT privmsgs_id
                FROM " 
PRIVMSGS_TABLE "
                WHERE privmsgs_from_userid = 
$user_id 
                    OR privmsgs_to_userid = 
$user_id";
            if ( !(
$result $db->sql_query($sql)) )
            {
                
message_die(GENERAL_ERROR'Could not select all users private messages'''__LINE____FILE__$sql);
            }

            while ( 
$row_privmsgs $db->sql_fetchrow($result) )
            {
                
$mark_list[] = $row_privmsgs['privmsgs_id'];
            }
            
            if ( 
count($mark_list) )
            {
                
$delete_sql_id implode(', '$mark_list);
                
                
$delete_text_sql "DELETE FROM " PRIVMSGS_TEXT_TABLE "
                    WHERE privmsgs_text_id IN (
$delete_sql_id)";
                
$delete_sql "DELETE FROM " PRIVMSGS_TABLE "
                    WHERE privmsgs_id IN (
$delete_sql_id)";
                
                if ( !
$db->sql_query($delete_sql) )
                {
                    
message_die(GENERAL_ERROR'Could not delete private message info'''__LINE____FILE__$delete_sql);
                }
                
                if ( !
$db->sql_query($delete_text_sql) )
                {
                    
message_die(GENERAL_ERROR'Could not delete private message text'''__LINE____FILE__$delete_text_sql);
                }
            }

            
$message $lang['User_deleted'] . '<br /><br />' sprintf($lang['Click_return_useradmin'], '<a href="' append_sid("users_manage.$phpEx") . '">''</a>') . '<br /><br />' sprintf($lang['Click_return_admin_index'], '<a href="' append_sid("index.$phpEx?pane=users") . '">''</a>');

            
message_die(GENERAL_MESSAGE$message);
        }

        
$username = ( !empty($HTTP_POST_VARS['username']) ) ? phpbb_clean_username($HTTP_POST_VARS['username']) : '';
        
$email = ( !empty($HTTP_POST_VARS['email']) ) ? trim(strip_tags(htmlspecialchars$HTTP_POST_VARS['email'] ) )) : '';
        
$nic_color = ( !empty($HTTP_POST_VARS['nic_color']) ) ? trim(strip_tags(htmlspecialchars$HTTP_POST_VARS['nic_color'] ) )) : '';

        
$password = ( !empty($HTTP_POST_VARS['password']) ) ? trim(strip_tags(htmlspecialchars$HTTP_POST_VARS['password'] ) )) : '';
        
$password_confirm = ( !empty($HTTP_POST_VARS['password_confirm']) ) ? trim(strip_tags(htmlspecialchars$HTTP_POST_VARS['password_confirm'] ) )) : '';
                
        
$allow_points = ( !empty($HTTP_POST_VARS['allow_points']) ) ? intval$HTTP_POST_VARS['allow_points'] ) : 0;
        
$icq = ( !empty($HTTP_POST_VARS['icq']) ) ? trim(strip_tags$HTTP_POST_VARS['icq'] ) ) : '';
        
$aim = ( !empty($HTTP_POST_VARS['aim']) ) ? trim(strip_tags$HTTP_POST_VARS['aim'] ) ) : '';
        
$msn = ( !empty($HTTP_POST_VARS['msn']) ) ? trim(strip_tags$HTTP_POST_VARS['msn'] ) ) : '';
        
$yim = ( !empty($HTTP_POST_VARS['yim']) ) ? trim(strip_tags$HTTP_POST_VARS['yim'] ) ) : '';

        
$website = ( !empty($HTTP_POST_VARS['website']) ) ? trim(strip_tags$HTTP_POST_VARS['website'] ) ) : '';
        
$location = ( !empty($HTTP_POST_VARS['location']) ) ? trim(strip_tags$HTTP_POST_VARS['location'] ) ) : '';
        
$occupation = ( !empty($HTTP_POST_VARS['occupation']) ) ? trim(strip_tags$HTTP_POST_VARS['occupation'] ) ) : '';
        
$interests = ( !empty($HTTP_POST_VARS['interests']) ) ? trim(strip_tags$HTTP_POST_VARS['interests'] ) ) : '';
        
$number = ( !empty($HTTP_POST_VARS['number']) ) ? trim(strip_tags$HTTP_POST_VARS['number'] ) ) : '';
        
$gender = ( isset($HTTP_POST_VARS['gender']) ) ? intval ($HTTP_POST_VARS['gender']) : 0;

        if (isset(
$HTTP_POST_VARS['birthday']) )
        {
            
$birthday intval ($HTTP_POST_VARS['birthday']);
            
$b_day realdate('j',$birthday);
            
$b_md realdate('n',$birthday);
            
$b_year realdate('Y',$birthday);
        } 
        else
        {
            
$b_day = ( isset($HTTP_POST_VARS['b_day']) ) ? intval ($HTTP_POST_VARS['b_day']) : 0;
            
$b_md = ( isset($HTTP_POST_VARS['b_md']) ) ? intval ($HTTP_POST_VARS['b_md']) : 0;
            
$b_year = ( isset($HTTP_POST_VARS['b_year']) ) ? intval ($HTTP_POST_VARS['b_year']) : 0;
            
$birthday mkrealdate($b_day,$b_md,$b_year);
        }
        
$next_birthday_greeting = ( !empty($HTTP_POST_VARS['next_birthday_greeting']) ) ? intval$HTTP_POST_VARS['next_birthday_greeting'] ) : 0;

        
$signature = ( !empty($HTTP_POST_VARS['signature']) ) ? trim(str_replace('<br />'"n"$HTTP_POST_VARS['signature'] ) ) : '';

        
validate_optional_fields($icq$aim$msn$yim$website$location$occupation$interests$signature);

        
$viewemail = ( isset( $HTTP_POST_VARS['viewemail']) ) ? ( ( $HTTP_POST_VARS['viewemail'] ) ? TRUE ) : 0;
        
$allowviewonline = ( isset( $HTTP_POST_VARS['hideonline']) ) ? ( ( $HTTP_POST_VARS['hideonline'] ) ? TRUE ) : TRUE;
        
$notifyreply = ( isset( $HTTP_POST_VARS['notifyreply']) ) ? ( ( $HTTP_POST_VARS['notifyreply'] ) ? TRUE ) : 0;
        
$notifypm = ( isset( $HTTP_POST_VARS['notifypm']) ) ? ( ( $HTTP_POST_VARS['notifypm'] ) ? TRUE ) : TRUE;
        
$games_block_pm = ( isset($HTTP_POST_VARS['games_block_pm']) ) ? ( ($HTTP_POST_VARS['games_block_pm']) ? TRUE ) : TRUE;
        
$popuppm = ( isset( $HTTP_POST_VARS['popup_pm']) ) ? ( ( $HTTP_POST_VARS['popup_pm'] ) ? TRUE ) : TRUE;
        
$attachsig = ( isset( $HTTP_POST_VARS['attachsig']) ) ? ( ( $HTTP_POST_VARS['attachsig'] ) ? TRUE ) : 0;

        
$allowhtml = ( isset( $HTTP_POST_VARS['allowhtml']) ) ? intval$HTTP_POST_VARS['allowhtml'] ) : $board_config['allow_html'];
        
$allowbbcode = ( isset( $HTTP_POST_VARS['allowbbcode']) ) ? intval$HTTP_POST_VARS['allowbbcode'] ) : $board_config['allow_bbcode'];
        
$allowsmilies = ( isset( $HTTP_POST_VARS['allowsmilies']) ) ? intval$HTTP_POST_VARS['allowsmilies'] ) : $board_config['allow_smilies'];
        
$user_timezone = ( isset( $HTTP_POST_VARS['timezone']) ) ? doubleval$HTTP_POST_VARS['timezone'] ) : $board_config['board_timezone'];
        
$user_dateformat = ( $HTTP_POST_VARS['dateformat'] ) ? trim$HTTP_POST_VARS['dateformat'] ) : $board_config['default_dateformat'];

        
$user_avatar_local = ( isset( $HTTP_POST_VARS['avatarselect'] ) && !empty($HTTP_POST_VARS['submitavatar'] ) && $board_config['allow_avatar_local'] ) ? $HTTP_POST_VARS['avatarselect'] : ( ( isset( $HTTP_POST_VARS['avatarlocal'] )  ) ? $HTTP_POST_VARS['avatarlocal'] : '' );
        
$user_avatar_category = ( isset($HTTP_POST_VARS['avatarcatname']) && $board_config['allow_avatar_local'] ) ? htmlspecialchars($HTTP_POST_VARS['avatarcatname']) : '' ;

        
$user_avatar_remoteurl = ( !empty($HTTP_POST_VARS['avatarremoteurl']) ) ? trim$HTTP_POST_VARS['avatarremoteurl'] ) : '';
        
$user_avatar_url = ( !empty($HTTP_POST_VARS['avatarurl']) ) ? trim$HTTP_POST_VARS['avatarurl'] ) : '';
        
$user_avatar_loc = ( $HTTP_POST_FILES['avatar']['tmp_name'] != "none") ? $HTTP_POST_FILES['avatar']['tmp_name'] : '';
        
$user_avatar_name = ( !empty($HTTP_POST_FILES['avatar']['name']) ) ? $HTTP_POST_FILES['avatar']['name'] : '';
        
$user_avatar_size = ( !empty($HTTP_POST_FILES['avatar']['size']) ) ? $HTTP_POST_FILES['avatar']['size'] : 0;
        
$user_avatar_filetype = ( !empty($HTTP_POST_FILES['avatar']['type']) ) ? $HTTP_POST_FILES['avatar']['type'] : '';

        
$user_avatar = ( empty($user_avatar_loc) ) ? $this_userdata['user_avatar'] : '';
        
$user_avatar_type = ( empty($user_avatar_loc) ) ? $this_userdata['user_avatar_type'] : '';        

        
$user_status = ( !empty($HTTP_POST_VARS['user_status']) ) ? intval$HTTP_POST_VARS['user_status'] ) : 0;
        
$user_allowpm = ( !empty($HTTP_POST_VARS['user_allowpm']) ) ? intval$HTTP_POST_VARS['user_allowpm'] ) : 0;
        
$user_rank = ( !empty($HTTP_POST_VARS['user_rank']) ) ? intval$HTTP_POST_VARS['user_rank'] ) : 0;
        
$user_allowavatar = ( !empty($HTTP_POST_VARS['user_allowavatar']) ) ? intval$HTTP_POST_VARS['user_allowavatar'] ) : 0;

        if (isset(
$HTTP_POST_VARS['topics_per_page']) )
        {
            
$user_topics_per_page = ( intval($HTTP_POST_VARS['topics_per_page']) == ) ? $board_config['topics_per_page'] : intval($HTTP_POST_VARS['topics_per_page']);
            
$user_topics_per_page = ( $user_topics_per_page $board_config['max_user_topics_per_page'] ) ? $board_config['topics_per_page'] : $user_topics_per_page;
        }
        if (isset(
$HTTP_POST_VARS['posts_per_page']) )
        {
            
$user_posts_per_page = ( intval($HTTP_POST_VARS['topics_per_page']) == ) ? $board_config['posts_per_page'] : intval($HTTP_POST_VARS['posts_per_page']);
            
$user_posts_per_page = ( $user_topics_per_page $board_config['max_user_posts_per_page'] ) ? $board_config['posts_per_page'] : $user_posts_per_page;
        }


        if( isset( 
$HTTP_POST_VARS['avatargallery'] ) || isset( $HTTP_POST_VARS['submitavatar'] ) || isset( $HTTP_POST_VARS['cancelavatar'] ) )
        {
            
$username stripslashes($username);
            
$email stripslashes($email);
            
$nic_color stripslashes($nic_color);
            
$password '';
            
$password_confirm '';
            
            
$icq stripslashes($icq);
            
$aim htmlspecialchars(stripslashes($aim));
            
$msn htmlspecialchars(stripslashes($msn));
            
$yim htmlspecialchars(stripslashes($yim));
            
$number stripslashes($number);

            
$website htmlspecialchars(stripslashes($website));
            
$location htmlspecialchars(stripslashes($location));
            
$occupation htmlspecialchars(stripslashes($occupation));
            
$interests htmlspecialchars(stripslashes($interests));
            
$user_dateformat htmlspecialchars(stripslashes($user_dateformat));

            if ( !isset(
$HTTP_POST_VARS['cancelavatar'])) 
            {
                
$user_avatar $user_avatar_category '/' $user_avatar_local;
                
$user_avatar_type USER_AVATAR_GALLERY;
            }
        }
    }

    if( isset( 
$HTTP_POST_VARS['submit'] ) )
    {
        include(
$phpbb_root_path 'includes/usercp_avatar.'.$phpEx);

        
$error FALSE;

        if (
stripslashes($username) != $this_userdata['username'])
        {
            unset(
$rename_user);

            if ( 
stripslashes(strtolower($username)) != strtolower($this_userdata['username']) ) 
            {
                
$result validate_username($username);
                if ( 
$result['error'] )
                {
                    
$error TRUE;
                    
$error_msg .= ( ( isset($error_msg) ) ? '<br />' '' ) . $result['error_msg'];
                }
                else if ( 
strtolower(str_replace("\'""''"$username)) == strtolower($userdata['username']) )
                {
                    
$error TRUE;
                    
$error_msg .= ( ( isset($error_msg) ) ? '<br />' '' ) . $lang['Username_taken'];
                }
            }

            if (!
$error)
            {
                
$username_sql "username = '" str_replace("\'""''"$username) . "', ";
                
$rename_user $username;
            }
        }

        
$passwd_sql '';
        if( !empty(
$password) && !empty($password_confirm) )
        {

            if(
$password != $password_confirm)
            {
                
$error TRUE;
                
$error_msg .= ( ( isset($error_msg) ) ? '<br />' '' ) . $lang['Password_mismatch'];
            }
            else
            {
                
$password md5($password);
                
$passwd_sql "user_password = '$password', ";
            }
        }
        else if( 
$password && !$password_confirm )
        {
            
$error TRUE;
            
$error_msg .= ( ( isset($error_msg) ) ? '<br />' '' ) . $lang['Password_mismatch'];
        }
        else if( !
$password && $password_confirm )
        {
            
$error TRUE;
            
$error_msg .= ( ( isset($error_msg) ) ? '<br />' '' ) . $lang['Password_mismatch'];
        }

        
$avatar_sql "";
        if( isset(
$HTTP_POST_VARS['avatardel']) )
        {
            if( 
$this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "" )
            {
                if( @
file_exists(@phpbb_realpath('./../' $board_config['avatar_path'] . "/" $this_userdata['user_avatar'])) )
                {
                    @
unlink('./../' $board_config['avatar_path'] . "/" $this_userdata['user_avatar']);
                }
            }
            
$avatar_sql ", user_avatar = '', user_avatar_type = " USER_AVATAR_NONE;
        }
        else if( ( 
$user_avatar_loc != "" || !empty($user_avatar_url) ) && !$error )
        {

            if( !empty(
$user_avatar_loc) && !empty($user_avatar_url) )
            {
                
$error TRUE;
                if( isset(
$error_msg) )
                {
                    
$error_msg .= "<br />";
                }
                
$error_msg .= $lang['Only_one_avatar'];
            }

            if( 
$user_avatar_loc != "" )
            {
                if( 
file_exists(@phpbb_realpath($user_avatar_loc)) && ereg(".jpg$|.gif$|.png$"$user_avatar_name) )
                {
                    if( 
$user_avatar_size <= $board_config['avatar_filesize'] && $user_avatar_size 0)
                    {
                        
$error_type false;

                        
preg_match("'image/[x-]*([a-z]+)'"$user_avatar_filetype$user_avatar_filetype);
                        
$user_avatar_filetype $user_avatar_filetype[1];

                        switch( 
$user_avatar_filetype )
                        {
                            case 
"jpeg":
                            case 
"pjpeg":
                            case 
"jpg":
                                
$imgtype '.jpg';
                                break;
                            case 
"gif":
                                
$imgtype '.gif';
                                break;
                            case 
"png":
                                
$imgtype '.png';
                                break;
                            default:
                                
$error true;
                                
$error_msg = (!empty($error_msg)) ? $error_msg "<br />" $lang['Avatar_filetype'] : $lang['Avatar_filetype'];
                                break;
                        }

                        if( !
$error )
                        {
                            list(
$width$height) = @getimagesize($user_avatar_loc);

                            if( 
$width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
                            {
                                
$user_id $this_userdata['user_id'];

                                
$avatar_filename $user_id $imgtype;

                                if( 
$this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "" )
                                {
                                    if( @
file_exists(@phpbb_realpath("./../" $board_config['avatar_path'] . "/" $this_userdata['user_avatar'])) )
                                    {
                                        @
unlink("./../" $board_config['avatar_path'] . "/"$this_userdata['user_avatar']);
                                    }
                                }
                                @
copy($user_avatar_loc"./../" $board_config['avatar_path'] . "/$avatar_filename");

                                
$avatar_sql ", user_avatar = '$avatar_filename', user_avatar_type = " USER_AVATAR_UPLOAD;
                            }
                            else
                            {
                                
$l_avatar_size sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);

                                
$error true;
                                
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $l_avatar_size $l_avatar_size;
                            }
                        }
                    }
                    else
                    {
                        
$l_avatar_size sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));

                        
$error true;
                        
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $l_avatar_size $l_avatar_size;
                    }
                }
                else
                {
                    
$error true;
                    
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $lang['Avatar_filetype'] : $lang['Avatar_filetype'];
                }
            }
            else if( !empty(
$user_avatar_url) )
            {

                
preg_match("/^(http://)?([w-.]+):?([0-9]*)/(.*)$/"$user_avatar_url$url_ary);

                if( !empty(
$url_ary[4]) )
                {
                    
$port = (!empty($url_ary[3])) ? $url_ary[3] : 80;

                    
$fsock = @fsockopen($url_ary[2], $port$errno$errstr);
                    if( 
$fsock )
                    {
                        
$base_get "/" $url_ary[4];

                        @
fputs($fsock"GET $base_get HTTP/1.1rn");
                        @
fputs($fsock"HOST: " $url_ary[2] . "rn");
                        @
fputs($fsock"Connection: closernrn");

                        unset(
$avatar_data);
                        while( !@
feof($fsock) )
                        {
                            
$avatar_data .= @fread($fsock$board_config['avatar_filesize']);
                        }
                        @
fclose($fsock);

                        if( 
preg_match("/Content-Length: ([0-9]+)[^/ ][s]+/i"$avatar_data$file_data1) && preg_match("/Content-Type: image/[x-]*([a-z]+)[s]+/i"$avatar_data$file_data2) )
                        {
                            
$file_size $file_data1[1]; 
                            
$file_type $file_data2[1];

                            switch( 
$file_type )
                            {
                                case 
"jpeg":
                                case 
"pjpeg":
                                case 
"jpg":
                                    
$imgtype '.jpg';
                                    break;
                                case 
"gif":
                                    
$imgtype '.gif';
                                    break;
                                case 
"png":
                                    
$imgtype '.png';
                                    break;
                                default:
                                    
$error true;
                                    
$error_msg = (!empty($error_msg)) ? $error_msg "<br />" $lang['Avatar_filetype'] : $lang['Avatar_filetype'];
                                    break;
                            }

                            if( !
$error && $file_size && $file_size $board_config['avatar_filesize'] )
                            {
                                
$avatar_data substr($avatar_datastrlen($avatar_data) - $file_size$file_size);

                                
$tmp_filename tempnam ("/tmp"$this_userdata['user_id'] . "-");
                                
$fptr = @fopen($tmp_filename"wb");
                                
$bytes_written = @fwrite($fptr$avatar_data$file_size);
                                @
fclose($fptr);

                                if( 
$bytes_written == $file_size )
                                {
                                    list(
$width$height) = @getimagesize($tmp_filename);

                                    if( 
$width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
                                    {
                                        
$user_id $this_userdata['user_id'];

                                        
$avatar_filename $user_id $imgtype;

                                        if( 
$this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "")
                                        {
                                            if( 
file_exists(@phpbb_realpath("./../" $board_config['avatar_path'] . "/" $this_userdata['user_avatar'])) )
                                            {
                                                @
unlink("./../" $board_config['avatar_path'] . "/" $this_userdata['user_avatar']);
                                            }
                                        }
                                        @
copy($tmp_filename"./../" $board_config['avatar_path'] . "/$avatar_filename");
                                        @
unlink($tmp_filename);

                                        
$avatar_sql ", user_avatar = '$avatar_filename', user_avatar_type = " USER_AVATAR_UPLOAD;
                                    }
                                    else
                                    {
                                        
$l_avatar_size sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);

                                        
$error true;
                                        
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $l_avatar_size $l_avatar_size;
                                    }
                                }
                                else
                                {

                                    @
unlink($tmp_filename);
                                    
message_die(GENERAL_ERROR"Could not write avatar file to local storage. Please contact the board administrator with this message"""__LINE____FILE__);
                                }
                            }
                        }
                        else
                        {

                            
$error true;
                            
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $lang['File_no_data'] : $lang['File_no_data'];
                        }
                    }
                    else
                    {

                        
$error true;
                        
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $lang['No_connection_URL'] : $lang['No_connection_URL'];
                    }
                }
                else
                {
                    
$error true;
                    
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $lang['Incomplete_URL'] : $lang['Incomplete_URL'];
                }
            }
            else if( !empty(
$user_avatar_name) )
            {
                
$l_avatar_size sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));

                
$error true;
                
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $l_avatar_size $l_avatar_size;
            }
        }
        else if( 
$user_avatar_remoteurl != "" && $avatar_sql == "" && !$error )
        {
            if( !
preg_match("#^http://#i"$user_avatar_remoteurl) )
            {
                
$user_avatar_remoteurl "http://" $user_avatar_remoteurl;
            }

            if( 
preg_match("#^(http://[a-z0-9-]+?.([a-z0-9-]+.)*[a-z]+/.*?.(gif|jpg|png)$)#is"$user_avatar_remoteurl) )
            {
                
$avatar_sql ", user_avatar = '" str_replace("'""''"$user_avatar_remoteurl) . "', user_avatar_type = " USER_AVATAR_REMOTE;
            }
            else
            {
                
$error true;
                
$error_msg = ( !empty($error_msg) ) ? $error_msg "<br />" $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
            }
        }
        else if( 
$user_avatar_local != "" && $avatar_sql == "" && !$error )
        {
            
$avatar_sql ", user_avatar = '" str_replace("'""''"phpbb_ltrim(basename($user_avatar_category), "'") . '/' phpbb_ltrim(basename($user_avatar_local), "'")) . "', user_avatar_type = " USER_AVATAR_GALLERY;
        }

        if (
$b_day || $b_md || $b_year
        {
            
$user_age=(date('md')>=$b_md.(($b_day <= 9) ? '0':'').$b_day) ? date('Y') - $b_year date('Y') - $b_year ;
            if (!
checkdate($b_md,$b_day,$b_year))
            {
                
$error TRUE;
                if( isset(
$error_msg) )$error_msg .= "<br />";
                
$error_msg .= $lang['Wrong_birthday_format'];
            } 
            else if (
$user_age>$board_config['max_user_age'])
            {
                
$error TRUE;
                if( isset(
$error_msg) )$error_msg .= "<br />";
                
$error_msg .= sprintf($lang['Birthday_to_high'],$board_config['max_user_age']);
            } 
            else if (
$user_age<$board_config['min_user_age'])
            {
                
$error TRUE;
                if( isset(
$error_msg) )$error_msg .= "<br />";
                
$error_msg .= sprintf($lang['Birthday_to_low'],$board_config['min_user_age']);
            } 
            else
            {
                
$birthday = ($error) ? $birthday mkrealdate($b_day,$b_md,$b_year);
            }
        } 
        else 
$birthday = ($error) ? '' 999999;

        if( !
$error )
        {
            
$sql "UPDATE " USERS_TABLE "
                SET " 
$username_sql $passwd_sql "user_email = '" str_replace("'""''"$email) . "', user_icq = '" str_replace("'""''"$icq) . "', user_number = '" str_replace("'""''"$number) . "', user_nic_color = '" str_replace("'""''"$nic_color) . "', user_website = '" str_replace("'""''"$website) . "', user_occ = '" str_replace("'""''"$occupation) . "', user_from = '" str_replace("'""''"$location) . "', user_interests = '" str_replace("'""''"$interests) . "', user_topics_per_page = '$user_topics_per_page', user_posts_per_page = '$user_posts_per_page', user_birthday='$birthday', user_next_birthday_greeting=$next_birthday_greeting, 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_dateformat = '" str_replace("'""''"$user_dateformat) . "', user_active = $user_status, user_rank = $user_rank, admin_allow_points = $allow_points, user_gender = '$gender'" $avatar_sql "
                WHERE user_id = 
$user_id";

            if( 
$result $db->sql_query($sql) )
            {
                if( isset(
$rename_user) )
                {
                    
$sql "UPDATE " GROUPS_TABLE "
                        SET group_name = '"
.str_replace("'""''"$rename_user)."'
                        WHERE group_name = '"
.str_replace("'""''"$this_userdata['username'] )."'";
                    if( !
$result $db->sql_query($sql) )
                    {
                        
message_die(GENERAL_ERROR'Could not rename users group'''__LINE____FILE__$sql);
                    }

                        
$sql "UPDATE " POSTS_TABLE "
                                SET post_username = '" 
str_replace("\'""''"addslashes($this_userdata['username'])) . "' 
                                WHERE poster_id = 
$user_id";
                            if( !
$db->sql_query($sql) )
                            {
                                
message_die(GENERAL_ERROR'Could not update posts for this user'''__LINE____FILE__$sql);
                            }    
                }

                if (!
$user_status)
                {
                    
$sql "DELETE FROM " SESSIONS_TABLE 
                        WHERE session_user_id = " 
$user_id;

                    if ( !
$db->sql_query($sql) )
                    {
                        
message_die(GENERAL_ERROR'Error removing user session'''__LINE____FILE__$sql);
                    }
                }                    
                    
                if ( !empty(
$passwd_sql) )
                {
                    
session_reset_keys($user_id$user_ip);
                }
                
                
$message .= $lang['Admin_user_updated'];
            }
            else
            {
                
message_die(GENERAL_ERROR'Admin_user_fail'''__LINE____FILE__$sql);
            }            
            
            
$message .= '<br /><br />' sprintf($lang['Click_return_useradmin'], '<a href="' append_sid("users_manage.$phpEx") . '">''</a>') . '<br /><br />' sprintf($lang['Click_return_admin_index'], '<a href="' append_sid("index.$phpEx?pane=users") . '">''</a>');

            
message_die(GENERAL_MESSAGE$message);
        }
        else
        {
            
$template->set_filenames(array(
                
'reg_header' => 'error_body.tpl')
            );

            
$template->assign_vars(array(
                
'ERROR_MESSAGE' => $error_msg)
            );

            
$template->assign_var_from_handle('ERROR_BOX''reg_header');

            
$username htmlspecialchars(stripslashes($username));
            
$email stripslashes($email);
            
$nic_color stripslashes($nic_color);
            
$password '';
            
$password_confirm '';
            
            
$icq stripslashes($icq);
            
$number stripslashes($number);
            
$aim htmlspecialchars(str_replace('+'' 'stripslashes($aim)));
            
$msn htmlspecialchars(stripslashes($msn));
            
$yim htmlspecialchars(stripslashes($yim));

            
$website htmlspecialchars(stripslashes($website));
            
$location htmlspecialchars(stripslashes($location));
            
$occupation htmlspecialchars(stripslashes($occupation));
            
$interests htmlspecialchars(stripslashes($interests));
            
$user_dateformat htmlspecialchars(stripslashes($user_dateformat));
        }
    }
    else if( !isset( 
$HTTP_POST_VARS['submit'] ) && $mode != 'save' && !isset( $HTTP_POST_VARS['avatargallery'] ) && !isset( $HTTP_POST_VARS['submitavatar'] ) && !isset( $HTTP_POST_VARS['cancelavatar'] ) )
    {
        if( isset( 
$HTTP_GET_VARS[POST_USERS_URL]) || isset( $HTTP_POST_VARS[POST_USERS_URL]) )
        {
            
$user_id = ( isset( $HTTP_POST_VARS[POST_USERS_URL]) ) ? intval$HTTP_POST_VARS[POST_USERS_URL]) : intval$HTTP_GET_VARS[POST_USERS_URL]);
            
$this_userdata get_userdata($user_id);
            if( !
$this_userdata )
            {
                
message_die(GENERAL_MESSAGE$lang['No_user_id_specified'] );
            }
        }
        else
        {
            
$this_userdata get_userdata($HTTP_POST_VARS['username'], true);
            if( !
$this_userdata )
            {
                
message_die(GENERAL_MESSAGE$lang['No_user_id_specified'] );
            }
        }

        
$user_id $this_userdata['user_id'];
        
$username $this_userdata['username'];
        
$email $this_userdata['user_email'];
        
$password '';
        
$password_confirm '';
        
$allow_points $this_userdata['admin_allow_points'];

        
$icq $this_userdata['user_icq'];
        
$aim htmlspecialchars(str_replace('+'' '$this_userdata['user_aim'] ));
        
$msn htmlspecialchars($this_userdata['user_msnm']);
        
$yim htmlspecialchars($this_userdata['user_yim']);
        
$nic_color htmlspecialchars($this_userdata['user_nic_color']);

        
$website htmlspecialchars($this_userdata['user_website']);
        
$location htmlspecialchars($this_userdata['user_from']);
        
$occupation htmlspecialchars($this_userdata['user_occ']);
        
$interests htmlspecialchars($this_userdata['user_interests']);
        
$number $this_userdata['user_number'];
        
$gender $this_userdata['user_gender'];

        
$next_birthday_greeting $this_userdata['user_next_birthday_greeting'];
        if (
$this_userdata['user_birthday']!=999999)
        {
            
$birthday realdate($lang['Submit_date_format'],$this_userdata['user_birthday']);
            
$b_day realdate('j',$this_userdata['user_birthday']);
            
$b_md realdate('n',$this_userdata['user_birthday']);
            
$b_year realdate('Y',$this_userdata['user_birthday']);
        } 
        else
        {
            
$b_day '';
            
$b_md '';
            
$b_year '';
            
$birthday '';
        }

        
$viewemail $this_userdata['user_viewemail'];
        
$notifypm $this_userdata['user_notify_pm'];
        
$games_block_pm $this_userdata['games_block_pm'];
        
$popuppm $this_userdata['user_popup_pm'];
        
$notifyreply $this_userdata['user_notify'];
        
$attachsig $this_userdata['user_attachsig'];
        
$allowhtml $this_userdata['user_allowhtml'];
        
$allowbbcode $this_userdata['user_allowbbcode'];
        
$allowsmilies $this_userdata['user_allowsmile'];
        
$allowviewonline $this_userdata['user_allow_viewonline'];

        
$user_avatar $this_userdata['user_avatar'];
        
$user_avatar_type $this_userdata['user_avatar_type'];
        
$user_timezone $this_userdata['user_timezone'];
        
$user_dateformat htmlspecialchars($this_userdata['user_dateformat']);
        
        
$user_status $this_userdata['user_active'];
        
$user_allowavatar $this_userdata['user_allowavatar'];
        
$user_allowpm $this_userdata['user_allow_pm'];
        
$user_topics_per_page $this_userdata['user_topics_per_page'];
        
$user_posts_per_page $this_userdata['user_posts_per_page'];
        
        
$COPPA false;

        
$html_status =  ($this_userdata['user_allowhtml'] ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF'];
        
$bbcode_status = ($this_userdata['user_allowbbcode'] ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF'];
        
$smilies_status = ($this_userdata['user_allowsmile'] ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
    }

    if( isset(
$HTTP_POST_VARS['avatargallery']) && !$error )
    {
        if( !
$error )
        {
            
$user_id intval($HTTP_POST_VARS['id']);

            
$template->set_filenames(array(
                
"body" => "admin/user_avatar_gallery.tpl")
            );

            
$dir = @opendir("../" $board_config['avatar_gallery_path']);

            
$avatar_images = array();
            while( 
$file = @readdir($dir) )
            {
                if( 
$file != "." && $file != ".." && !is_file(phpbb_realpath("./../" $board_config['avatar_gallery_path'] . "/" $file)) && !is_link(phpbb_realpath("./../" $board_config['avatar_gallery_path'] . "/" $file)) )
                {
                    
$sub_dir = @opendir("../" $board_config['avatar_gallery_path'] . "/" $file);

                    
$avatar_row_count 0;
                    
$avatar_col_count 0;

                    while( 
$sub_file = @readdir($sub_dir) )
                    {
                        if( 
preg_match("/(.gif$|.png$|.jpg)$/is"$sub_file) )
                        {
                            
$avatar_images[$file][$avatar_row_count][$avatar_col_count] = $sub_file;

                            
$avatar_col_count++;
                            if( 
$avatar_col_count == )
                            {
                                
$avatar_row_count++;
                                
$avatar_col_count 0;
                            }
                        }
                    }
                }
            }
    
            @
closedir($dir);

            if( isset(
$HTTP_POST_VARS['avatarcategory']) )
            {
                
$category htmlspecialchars($HTTP_POST_VARS['avatarcategory']);
            }
            else
            {
                list(
$category, ) = each($avatar_images);
            }
            @
reset($avatar_images);

            
$s_categories "";
            while( list(
$key) = each($avatar_images) )
            {
                
$selected = ( $key == $category ) ? "selected="selected"" "";
                if( 
count($avatar_images[$key]) )
                {
                    
$s_categories .= '<option value="' $key '"' $selected '>' ucfirst($key) . '</option>';
                }
            }

            
$s_colspan 0;
            for(
$i 0$i count($avatar_images[$category]); $i++)
            {
                
$template->assign_block_vars("avatar_row", array());

                
$s_colspan max($s_colspancount($avatar_images[$category][$i]));

                for(
$j 0$j count($avatar_images[$category][$i]); $j++)
                {
                    
$template->assign_block_vars("avatar_row.avatar_column", array(
                        
"AVATAR_IMAGE" => "../" $board_config['avatar_gallery_path'] . '/' $category '/' $avatar_images[$category][$i][$j])
                    );

                    
$template->assign_block_vars("avatar_row.avatar_option_column", array(
                        
"S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j])
                    );
                }
            }

            
$coppa = ( ( !$HTTP_POST_VARS['coppa'] && !$HTTP_GET_VARS['coppa'] ) || $mode == "register") ? TRUE;

            
$s_hidden_fields '<input type="hidden" name="mode" value="edit" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' $coppa '" /><input type="hidden" name="avatarcatname" value="' $category '" />';
            
$s_hidden_fields .= '<input type="hidden" name="id" value="' $user_id '" />';

            
$s_hidden_fields .= '<input type="hidden" name="username" value="' str_replace(""", "&quot;", $username) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="email" value="' . str_replace(""""&quot;"$email) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="icq" value="' str_replace(""", "&quot;", $icq) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="aim" value="' . str_replace(""""&quot;"$aim) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="msn" value="' str_replace(""", "&quot;", $msn) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="yim" value="' . str_replace(""""&quot;"$yim) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="website" value="' str_replace(""", "&quot;", $website) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="location" value="' . str_replace(""""&quot;"$location) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="occupation" value="' str_replace(""", "&quot;", $occupation) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="interests" value="' . str_replace(""""&quot;"$interests) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="number" value="' str_replace(""", "&quot;", $number) . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="birthday" value="'.$birthday.'" />';
            $s_hidden_fields .= '
<input type="hidden" name="next_birthday_greeting" value="'.$next_birthday_greeting.'" />';
            $s_hidden_fields .= '
<input type="hidden" name="viewemail" value="' . $viewemail . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="gender" value="' . $gender . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="notifypm" value="' . $notifypm . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="popup_pm" value="' . $popuppm . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="notifyreply" value="' . $notifyreply . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="attachsig" value="' . $attachsig . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="allowhtml" value="' . $allowhtml . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="allowbbcode" value="' . $allowbbcode . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="allowsmilies" value="' . $allowsmilies . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="hideonline" value="' . !$allowviewonline . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="timezone" value="' . $user_timezone . '" />';
            $s_hidden_fields .= '
<input type="hidden" name="dateformat" value="' . str_replace(""""&quot;"$user_dateformat) . '" />';
            
$s_hidden_fields .= '<input type="hidden" name="user_status" value="' $user_status '" />';
            
$s_hidden_fields .= '<input type="hidden" name="user_allowpm" value="' $user_allowpm '" />';
            
$s_hidden_fields .= '<input type="hidden" name="user_allowavatar" value="' $user_allowavatar '" />';
            
$s_hidden_fields .= '<input type="hidden" name="user_rank" value="' $user_rank '" />';
            
$s_hidden_fields .= '<input type="hidden" name="allow_points" value="' $allow_points '" />';
            
$s_hidden_fields .= '<input type="hidden" name="topics_per_page" value="' $user_topics_per_page '" />';
            
$s_hidden_fields .= '<input type="hidden" name="posts_per_page" value="' $user_posts_per_page '" />';

            
$template->assign_vars(array(
                
"L_USER_TITLE" => $lang['User_admin'],
                
"L_USER_EXPLAIN" => $lang['User_admin_explain'],
                
"L_AVATAR_GALLERY" => $lang['Avatar_gallery'], 
                
"L_SELECT_AVATAR" => $lang['Select_avatar'], 
                
"L_RETURN_PROFILE" => $lang['Return_profile'], 
                
"L_CATEGORY" => $lang['Select_category'], 
                
"L_GO" => $lang['Go'],

                
"S_OPTIONS_CATEGORIES" => $s_categories
                
"S_COLSPAN" => $s_colspan
                
"S_PROFILE_ACTION" => append_sid("users_manage.$phpEx?mode=$mode"), 
                
"S_HIDDEN_FIELDS" => $s_hidden_fields)
            );
        }
    }
    else
    {
        
$s_hidden_fields '<input type="hidden" name="mode" value="save" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' $coppa '" />';
        
$s_hidden_fields .= '<input type="hidden" name="id" value="' $this_userdata['user_id'] . '" />';

        if( !empty(
$user_avatar_local) )
        {
            
$s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' $user_avatar_local '" /><input type="hidden" name="avatarcatname" value="' $user_avatar_category '" />';
        }

        if( 
$user_avatar_type )
        {
            switch( 
$user_avatar_type )
            {
                case 
USER_AVATAR_UPLOAD:
                    
$avatar '<img src="../' $board_config['avatar_path'] . '/' $user_avatar '" alt="" />';
                    break;
                case 
USER_AVATAR_REMOTE:
                    
$avatar '<img src="../' $user_avatar '" alt="" />';
                    break;
                case 
USER_AVATAR_GALLERY:
                    
$avatar '<img src="../' $board_config['avatar_gallery_path'] . '/' $user_avatar '" alt="" />';
                    break;
            }
        }
        else
        {
            
$avatar "";
        }

        
$sql "SELECT * FROM " RANKS_TABLE "
            WHERE rank_special = 1
            ORDER BY rank_title"
;
        if ( !(
$result $db->sql_query($sql)) )
        {
            
message_die(GENERAL_ERROR'Could not obtain ranks data'''__LINE____FILE__$sql);
        }

        
$rank_select_box '<option value="0">' $lang['No_assigned_rank'] . '</option>';
        while( 
$row $db->sql_fetchrow($result) )
        {
            
$rank $row['rank_title'];
            
$rank_id $row['rank_id'];
            
            
$selected = ( $this_userdata['user_rank'] == $rank_id ) ? ' selected="selected"' '';
            
$rank_select_box .= '<option value="' $rank_id '"' $selected '>' $rank '</option>';
        }

        
$template->set_filenames(array(
            
"body" => "admin/user_edit_body.tpl")
        );

        
$s_b_day '<span class="genmed">' $lang['Day'] . '&nbsp;</span><select name="b_day" size="1" class="gensmall"> 
        <option value="0">&nbsp;-&nbsp;</option> 
            <option value="1">&nbsp;1&nbsp;</option>
            <option value="2">&nbsp;2&nbsp;</option>
            <option value="3">&nbsp;3&nbsp;</option>
            <option value="4">&nbsp;4&nbsp;</option>
            <option value="5">&nbsp;5&nbsp;</option>
            <option value="6">&nbsp;6&nbsp;</option>
            <option value="7">&nbsp;7&nbsp;</option>
            <option value="8">&nbsp;8&nbsp;</option>
            <option value="9">&nbsp;9&nbsp;</option>
            <option value="10">&nbsp;10&nbsp;</option>
            <option value="11">&nbsp;11&nbsp;</option>
            <option value="12">&nbsp;12&nbsp;</option>
            <option value="13">&nbsp;13&nbsp;</option>
            <option value="14">&nbsp;14&nbsp;</option>
            <option value="15">&nbsp;15&nbsp;</option>
            <option value="16">&nbsp;16&nbsp;</option>
            <option value="17">&nbsp;17&nbsp;</option>
            <option value="18">&nbsp;18&nbsp;</option>
            <option value="19">&nbsp;19&nbsp;</option>
            <option value="20">&nbsp;20&nbsp;</option>
            <option value="21">&nbsp;21&nbsp;</option>
            <option value="22">&nbsp;22&nbsp;</option>
            <option value="23">&nbsp;23&nbsp;</option>
            <option value="24">&nbsp;24&nbsp;</option>
            <option value="25">&nbsp;25&nbsp;</option>
            <option value="26">&nbsp;26&nbsp;</option>
            <option value="27">&nbsp;27&nbsp;</option>
            <option value="28">&nbsp;28&nbsp;</option>
            <option value="29">&nbsp;29&nbsp;</option>
            <option value="30">&nbsp;30&nbsp;</option>
            <option value="31">&nbsp;31&nbsp;</option>
            </select>&nbsp;&nbsp;'
;
        
$s_b_md '<span class="genmed">' $lang['Month'] . '&nbsp;</span><select name="b_md" size="1" class="gensmall"> 
             <option value="0">&nbsp;-&nbsp;</option> 
            <option value="1">&nbsp;'
.$lang['datetime']['January'].'&nbsp;</option>
            <option value="2">&nbsp;'
.$lang['datetime']['February'].'&nbsp;</option>
            <option value="3">&nbsp;'
.$lang['datetime']['March'].'&nbsp;</option>
            <option value="4">&nbsp;'
.$lang['datetime']['April'].'&nbsp;</option>
            <option value="5">&nbsp;'
.$lang['datetime']['May'].'&nbsp;</option>
            <option value="6">&nbsp;'
.$lang['datetime']['June'].'&nbsp;</option>
            <option value="7">&nbsp;'
.$lang['datetime']['July'].'&nbsp;</option>
            <option value="8">&nbsp;'
.$lang['datetime']['August'].'&nbsp;</option>
            <option value="9">&nbsp;'
.$lang['datetime']['September'].'&nbsp;</option>
            <option value="10">&nbsp;'
.$lang['datetime']['October'].'&nbsp;</option>
            <option value="11">&nbsp;'
.$lang['datetime']['November'].'&nbsp;</option>
            <option value="12">&nbsp;'
.$lang['datetime']['December'].'&nbsp;</option>
            </select>&nbsp;&nbsp;'
;
        
$s_b_daystr_replace("value="".$b_day."">""value="".$b_day."" SELECTED>" ,$s_b_day);
        
$s_b_md str_replace("value="".$b_md."">""value="".$b_md."" SELECTED>" ,$s_b_md);
        
$s_b_year '<span class="genmed">' $lang['Year'] . '&nbsp;</span><input type="text" class="post" style="width: 50px" name="b_year" size="4" maxlength="4" value="' $b_year '" />&nbsp;&nbsp;'
        
$i 0;
        
$s_birthday '';
        for (
$i=0;$i<=strlen($lang['Submit_date_format']);$i++)
        {
            switch (
$lang['Submit_date_format'][$i])
            {
                case 
d:  $s_birthday .=$s_b_day;break;
                case 
m:  $s_birthday .=$s_b_md;break;
                case 
Y:  $s_birthday .=$s_b_year;break;
            }
        }

                switch (
$gender
                { 
                        case 
1$gender_male_checked="checked="checked"";break; 
                        case 
2$gender_female_checked="checked="checked"";break; 
                        default:
$gender_no_specify_checked="checked="checked""
                }

        
$ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' 'get_cfg_var';
        
$form_enctype = ( !@$ini_val('file_uploads') || phpversion() == '4.0.4pl1' || !$board_config['allow_avatar_upload'] || ( phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ) ) ? '' 'enctype="multipart/form-data"';

        
$template->assign_vars(array(
            
'USERNAME' => $username,
            
'EMAIL' => $email,
            
'YIM' => $yim,
            
'ICQ' => $icq,
            
'NUMBER' => $number,
            
'MSN' => $msn,
            
'AIM' => $aim,
            
'OCCUPATION' => $occupation,
            
'INTERESTS' => $interests,
            
'NEXT_BIRTHDAY_GREETING' => $next_birthday_greeting,
            
'S_BIRTHDAY' => $s_birthday,
            
'GENDER' => $gender
            
'GENDER_NO_SPECIFY_CHECKED' => $gender_no_specify_checked
            
'GENDER_MALE_CHECKED' => $gender_male_checked
            
'GENDER_FEMALE_CHECKED' => $gender_female_checked,

            
'LOCATION' => $location,
            
'WEBSITE' => $website,
            
'VIEW_EMAIL_YES' => ($viewemail) ? 'checked="checked"' '',
            
'VIEW_EMAIL_NO' => (!$viewemail) ? 'checked="checked"' '',
            
'HIDE_USER_YES' => (!$allowviewonline) ? 'checked="checked"' '',
            
'HIDE_USER_NO' => ($allowviewonline) ? 'checked="checked"' '',
            
'NOTIFY_PM_YES' => ($notifypm) ? 'checked="checked"' '',
            
'NOTIFY_PM_NO' => (!$notifypm) ? 'checked="checked"' '',
            
'BLOCK_PM_YES' => ( $games_block_pm ) ? 'checked="checked"' ''
            
'BLOCK_PM_NO' => ( !$games_block_pm ) ? 'checked="checked"' '',
            
'POPUP_PM_YES' => ($popuppm) ? 'checked="checked"' '',
            
'POPUP_PM_NO' => (!$popuppm) ? 'checked="checked"' '',
            
'ALWAYS_ADD_SIGNATURE_YES' => ($attachsig) ? 'checked="checked"' '',
            
'ALWAYS_ADD_SIGNATURE_NO' => (!$attachsig) ? 'checked="checked"' '',
            
'NOTIFY_REPLY_YES' => ( $notifyreply ) ? 'checked="checked"' '',
            
'NOTIFY_REPLY_NO' => ( !$notifyreply ) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_BBCODE_YES' => ($allowbbcode) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_BBCODE_NO' => (!$allowbbcode) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_HTML_YES' => ($allowhtml) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_HTML_NO' => (!$allowhtml) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_SMILIES_YES' => ($allowsmilies) ? 'checked="checked"' '',
            
'ALWAYS_ALLOW_SMILIES_NO' => (!$allowsmilies) ? 'checked="checked"' '',
            
'AVATAR' => $avatar,
            
'TIMEZONE_SELECT' => tz_select($user_timezone),
            
'DATE_FORMAT' => $user_dateformat,
            
'ALLOW_PM_YES' => ($user_allowpm) ? 'checked="checked"' '',
            
'ALLOW_PM_NO' => (!$user_allowpm) ? 'checked="checked"' '',
            
'ALLOW_AVATAR_YES' => ($user_allowavatar) ? 'checked="checked"' '',
            
'ALLOW_AVATAR_NO' => (!$user_allowavatar) ? 'checked="checked"' '',
            
'USER_ACTIVE_YES' => ($user_status) ? 'checked="checked"' '',
            
'USER_ACTIVE_NO' => (!$user_status) ? 'checked="checked"' ''
            
'RANK_SELECT_BOX' => $rank_select_box,
            
'ALLOW_POINTS_YES' => ($allow_points) ? 'checked="checked"' '',
            
'ALLOW_POINTS_NO' => (!$allow_points) ? 'checked="checked"' '',
            
'TOPICS_PER_PAGE' => $user_topics_per_page,
            
'POSTS_PER_PAGE' => $user_posts_per_page,

            
'L_USERNAME' => $lang['Username'],
            
'L_USER_TITLE' => $lang['User_admin'],
            
'L_USER_EXPLAIN' => $lang['User_admin_explain'],
            
'L_NEW_PASSWORD' => $lang['New_password'], 
            
'L_PASSWORD_IF_CHANGED' => $lang['password_if_changed'],
            
'L_CONFIRM_PASSWORD' => $lang['Confirm_password'],
            
'L_PASSWORD_CONFIRM_IF_CHANGED' => $lang['password_confirm_if_changed'],
            
'L_SUBMIT' => $lang['Submit'],
            
'L_RESET' => $lang['Reset'],
            
'L_ICQ_NUMBER' => $lang['ICQ'],
            
'L_MESSENGER' => $lang['MSNM'],
            
'L_YAHOO' => $lang['YIM'],
            
'L_WEBSITE' => $lang['Website'],
            
'L_AIM' => $lang['AIM'],
            
'L_LOCATION' => $lang['Location'],
            
'L_OCCUPATION' => $lang['Occupation'],
            
'L_BOARD_LANGUAGE' => $lang['Board_lang'],
            
'L_BOARD_STYLE' => $lang['Board_style'],
            
'L_TIMEZONE' => $lang['Timezone'],
            
'L_DATE_FORMAT' => $lang['Date_format'],
            
'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'],
            
'L_YES' => $lang['Yes'],
            
'L_NO' => $lang['No'],
            
'L_INTERESTS' => $lang['Interests'],
            
'L_NUMBER' => $lang['Number'],

            
'L_BIRTHDAY' => $lang['Birthday'],
            
'L_NEXT_BIRTHDAY_GREETING' => $lang['Next_birthday_greeting'],
            
'L_NEXT_BIRTHDAY_GREETING_EXPLAIN' => $lang['Next_birthday_greeting_expain'],

            
'L_GENDER' => $lang['Gender'], 
            
'L_NIC_COLOR' => $lang['Nic_color'], 
            
'NIC_COLOR' => $nic_color
            
'L_GENDER_MALE' =>$lang['Male'], 
            
'L_GENDER_FEMALE' =>$lang['Female'], 
            
'L_GENDER_NOT_SPECIFY' =>$lang['No_gender_specify'],

            
'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'],
            
'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'],
            
'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'],
            
'L_HIDE_USER' => $lang['Hide_user'],
            
'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'],
            
'L_POINTS' => $board_config['points_name'],
            
'L_ALLOW_POINTS' => $lang['Allow_Points'],
            
            
'L_SPECIAL' => $lang['User_special'],
            
'L_SPECIAL_EXPLAIN' => $lang['User_special_explain'],
            
'L_USER_ACTIVE' => $lang['User_status'],
            
'L_ALLOW_PM' => $lang['User_allowpm'],
            
'L_ALLOW_AVATAR' => $lang['User_allowavatar'],
            
            
'L_AVATAR_PANEL' => $lang['Avatar_panel'],
            
'L_AVATAR_EXPLAIN' => $lang['Admin_avatar_explain'],
            
'L_DELETE_AVATAR' => $lang['Delete_Image'],
            
'L_CURRENT_IMAGE' => $lang['Current_Image'],
            
'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'],
            
'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'],
            
'L_AVATAR_GALLERY' => $lang['Select_from_gallery'],
            
'L_SHOW_GALLERY' => $lang['View_avatar_gallery'],
            
'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'],
            
'L_SIGNATURE' => $lang['Signature'],
            
'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars'] ),
            
'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'],
            
'L_BLOCK_ARCADE_PM' => $lang['Block_Arcade_pm'],
            
'L_NOTIFY_ON_REPLY' => $lang['Always_notify'],
            
'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'],            
            
'L_PREFERENCES' => $lang['Preferences'],
            
'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
            
'L_ITEMS_REQUIRED' => $lang['Items_required'],
            
'L_REGISTRATION_INFO' => $lang['Registration_info'],
            
'L_PROFILE_INFO' => $lang['Profile_info'],
            
'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'],
            
'L_EMAIL_ADDRESS' => $lang['Email_address'],
            
'S_FORM_ENCTYPE' => $form_enctype,

            
'HTML_STATUS' => $html_status,
            
'BBCODE_STATUS' => sprintf($bbcode_status'<a href="../' append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">''</a>'), 
            
'SMILIES_STATUS' => $smilies_status,

            
'L_DELETE_USER' => $lang['User_delete'],
            
'L_DELETE_USER_EXPLAIN' => $lang['User_delete_explain'],
            
'L_SELECT_RANK' => $lang['Rank_title'],
            
'L_TOPICS_PER_PAGE' => $lang['Topics_per_page'],
            
'L_POSTS_PER_PAGE' => $lang['Posts_per_page'],

            
'S_HIDDEN_FIELDS' => $s_hidden_fields,
            
'S_PROFILE_ACTION' => append_sid("users_manage.$phpEx"))
        );

        if( 
file_exists(@phpbb_realpath('./../' $board_config['avatar_path'])))
        {
            if ( 
$form_enctype != '' )
            {
                
$template->assign_block_vars('avatar_local_upload', array() );
            }
            
$template->assign_block_vars('avatar_remote_upload', array() );
        }

        if( 
file_exists(@phpbb_realpath('./../' $board_config['avatar_gallery_path'])))
        {
            
$template->assign_block_vars('avatar_local_gallery', array() );
        }
        
        
/*if( $board_config['allow_avatar_remote'] == TRUE )
        {*/
            
$template->assign_block_vars('avatar_remote_link', array() );
        
/*}*/
    
}

    
$template->pparse('body');
}
else
{

    
$template->set_filenames(array(
        
'body' => 'admin/user_select_body.tpl')
    );

    
$template->assign_vars(array(
        
'L_USER_TITLE' => $lang['User_admin'],
        
'L_USER_EXPLAIN' => $lang['User_admin_explain'],
        
'L_USER_SELECT' => $lang['Select_a_User'],
        
'L_LOOK_UP' => $lang['Look_up_user'],
        
'L_FIND_USERNAME' => $lang['Find_username'],

        
'U_SEARCH_USER' => append_sid("./../search.$phpEx?mode=searchuser"), 

        
'S_USER_ACTION' => append_sid("users_manage.$phpEx"),
        
'S_USER_SELECT' => $select_list)
    );
    
$template->pparse('body');

}

include(
'./page_footer_admin.'.$phpEx);

?>
Онлайн: 2
Реклама