From fdbeac30d106272dd9564eb21b9cd6978e2fc5d2 Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Thu, 21 Nov 2002 15:26:06 +0000 Subject: Moving UCP files to ucp/ directory git-svn-id: file:///svn/phpbb/trunk@3073 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/usercp_activate.php | 106 +++++ phpBB/includes/ucp/usercp_avatar.php | 336 +++++++++++++ phpBB/includes/ucp/usercp_email.php | 179 +++++++ phpBB/includes/ucp/usercp_register.php | 768 ++++++++++++++++++++++++++++++ phpBB/includes/ucp/usercp_sendpasswd.php | 134 ++++++ phpBB/includes/ucp/usercp_viewprofile.php | 240 ++++++++++ phpBB/includes/usercp_activate.php | 106 ----- phpBB/includes/usercp_avatar.php | 336 ------------- phpBB/includes/usercp_email.php | 179 ------- phpBB/includes/usercp_register.php | 768 ------------------------------ phpBB/includes/usercp_sendpasswd.php | 134 ------ phpBB/includes/usercp_viewprofile.php | 240 ---------- 12 files changed, 1763 insertions(+), 1763 deletions(-) create mode 100644 phpBB/includes/ucp/usercp_activate.php create mode 100644 phpBB/includes/ucp/usercp_avatar.php create mode 100644 phpBB/includes/ucp/usercp_email.php create mode 100644 phpBB/includes/ucp/usercp_register.php create mode 100644 phpBB/includes/ucp/usercp_sendpasswd.php create mode 100644 phpBB/includes/ucp/usercp_viewprofile.php delete mode 100644 phpBB/includes/usercp_activate.php delete mode 100644 phpBB/includes/usercp_avatar.php delete mode 100644 phpBB/includes/usercp_email.php delete mode 100644 phpBB/includes/usercp_register.php delete mode 100644 phpBB/includes/usercp_sendpasswd.php delete mode 100644 phpBB/includes/usercp_viewprofile.php diff --git a/phpBB/includes/ucp/usercp_activate.php b/phpBB/includes/ucp/usercp_activate.php new file mode 100644 index 0000000000..e823e4d211 --- /dev/null +++ b/phpBB/includes/ucp/usercp_activate.php @@ -0,0 +1,106 @@ +sql_query($sql)) ) +{ + message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql); +} + +if ( $row = $db->sql_fetchrow($result) ) +{ + if ( $row['user_active'] && $row['user_actkey'] == '' ) + { + $template->assign_vars(array( + 'META' => '') + ); + + message_die(GENERAL_MESSAGE, $lang['Already_activated']); + } + else if ( $row['user_actkey'] == $HTTP_GET_VARS['act_key'] ) + { + $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : ''; + + $sql = "UPDATE " . USERS_TABLE . " + SET user_active = 1, user_actkey = ''" . $sql_update_pass . " + WHERE user_id = " . $row['user_id']; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update); + } + + if ( $config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '' ) + { + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($config['smtp_delivery']); + + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\n"; + + $emailer->use_template('admin_welcome_activated', $row['user_lang']); + $emailer->email_address($row['user_email']); + $emailer->set_subject();//$lang['Account_activated_subject'] + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'USERNAME' => $username, + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig'])) + ); + $emailer->send(); + $emailer->reset(); + + $template->assign_vars(array( + 'META' => '') + ); + + message_die(GENERAL_MESSAGE, $lang['Account_active_admin']); + } + else + { + $template->assign_vars(array( + 'META' => '') + ); + + $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated']; + message_die(GENERAL_MESSAGE, $message); + } + } + else + { + message_die(GENERAL_MESSAGE, $lang['Wrong_activation']); + } +} +else +{ + message_die(GENERAL_MESSAGE, $lang['No_such_user']); +} + +?> \ No newline at end of file diff --git a/phpBB/includes/ucp/usercp_avatar.php b/phpBB/includes/ucp/usercp_avatar.php new file mode 100644 index 0000000000..c7321d758c --- /dev/null +++ b/phpBB/includes/ucp/usercp_avatar.php @@ -0,0 +1,336 @@ +' . $lang['Avatar_filetype'] : $lang['Avatar_filetype']; + break; + } + + return false; +} + +function user_avatar_delete($avatar_type, $avatar_file) +{ + global $config, $userdata; + + if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' ) + { + if ( @file_exists('./' . $config['avatar_path'] . '/' . $avatar_file) ) + { + @unlink('./' . $config['avatar_path'] . '/' . $avatar_file); + } + } + + return ", user_avatar = '', user_avatar_type = " . USER_AVATAR_NONE; +} + +function user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename) +{ + return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY : ''; +} + +function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename) +{ + if ( !preg_match('#^http:\/\/#i', $avatar_filename) ) + { + $avatar_filename = 'http://' . $avatar_filename; + } + + if ( !preg_match('#^(http:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/[^\"]*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) ) + { + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format']; + return; + } + + return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : ''; + +} + +function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype) +{ + global $config, $user_ip, $db, $lang; + + $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; + + if ( $avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $avatar_filename, $url_ary) ) + { + if ( empty($url_ary[4]) ) + { + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Incomplete_URL'] : $lang['Incomplete_URL']; + return; + } + + $base_get = '/' . $url_ary[4]; + $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80; + + if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) ) + { + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['No_connection_URL'] : $lang['No_connection_URL']; + return; + } + + @fputs($fsock, "GET $base_get HTTP/1.1\r\n"); + @fputs($fsock, "HOST: " . $url_ary[2] . "\r\n"); + @fputs($fsock, "Connection: close\r\n\r\n"); + + unset($avatar_data); + while( !@feof($fsock) ) + { + $avatar_data .= @fread($fsock, $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) ) + { + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['File_no_data'] : $lang['File_no_data']; + return; + } + + $avatar_filesize = $file_data1[1]; + $avatar_filetype = $file_data2[1]; + + if ( !$error && $avatar_filesize > 0 && $avatar_filesize < $config['avatar_filesize'] ) + { + $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize); + + $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $config['avatar_path'] . '/tmp'; + $tmp_filename = tempnam($tmp_path, uniqid($user_ip) . '-'); + + $fptr = @fopen($tmp_filename, 'wb'); + $bytes_written = @fwrite($fptr, $avatar_data, $avatar_filesize); + @fclose($fptr); + + if ( $bytes_written != $avatar_filesize ) + { + @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__); + } + + list($width, $height) = @getimagesize($tmp_filename); + } + else + { + $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); + + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; + } + } + else if ( $avatar_mode == 'local' && file_exists($avatar_filename) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) ) + { + if ( $avatar_filesize <= $config['avatar_filesize'] && $avatar_filesize > 0 ) + { + preg_match('#image\/[x\-]*([a-z]+)#', $avatar_filetype, $avatar_filetype); + $avatar_filetype = $avatar_filetype[1]; + } + else + { + $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); + + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; + return; + } + + list($width, $height) = @getimagesize($avatar_filename); + } + + if ( !($imgtype = check_image_type($avatar_filetype, $error, $error_msg)) ) + { + return; + } + + if ( $width <= $config['avatar_max_width'] && $height <= $config['avatar_max_height'] ) + { + $new_filename = uniqid() . $imgtype; + + if ( $mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' ) + { + if ( file_exists('./' . $config['avatar_path'] . '/' . $current_avatar) ) + { + @unlink('./' . $config['avatar_path'] . '/' . $current_avatar); + } + } + + if( $avatar_mode == 'remote' ) + { + @copy($tmp_filename, './' . $config['avatar_path'] . "/$new_filename"); + @unlink($tmp_filename); + } + else + { + if ( @$ini_val('open_basedir') != '' ) + { + if ( @phpversion() < '4.0.3' ) + { + message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__); + } + + $move_file = 'move_uploaded_file'; + } + else + { + $move_file = 'copy'; + } + + $move_file($avatar_filename, './' . $config['avatar_path'] . "/$new_filename"); + } + + @chmod('./' . $config['avatar_path'] . "/$new_filename", 0777); + + $avatar_sql = ( $mode == 'editprofile' ) ? ", user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD : "'$new_filename', " . USER_AVATAR_UPLOAD; + } + else + { + $l_avatar_size = sprintf($lang['Avatar_imagesize'], $config['avatar_max_width'], $config['avatar_max_height']); + + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; + } + + return $avatar_sql; +} + +function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) +{ + global $config, $db, $template, $lang, $images, $theme; + global $phpbb_root_path, $phpEx; + + $dir = @opendir($config['avatar_gallery_path']); + + $avatar_images = array(); + while( $file = @readdir($dir) ) + { + if( $file != '.' && $file != '..' && !is_file($config['avatar_gallery_path'] . '/' . $file) && !is_link($config['avatar_gallery_path'] . '/' . $file) ) + { + $sub_dir = @opendir($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|\.jpeg)$/is', $sub_file) ) + { + $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file; + $avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $sub_file))); + + $avatar_col_count++; + if( $avatar_col_count == 5 ) + { + $avatar_row_count++; + $avatar_col_count = 0; + } + } + } + } + } + + @closedir($dir); + + @ksort($avatar_images); + @reset($avatar_images); + + if( empty($category) ) + { + list($category, ) = each($avatar_images); + } + @reset($avatar_images); + + $s_categories = ''; + + $s_colspan = 0; + for($i = 0; $i < count($avatar_images[$category]); $i++) + { + $template->assign_block_vars("avatar_row", array()); + + $s_colspan = max($s_colspan, count($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" => $config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j], + "AVATAR_NAME" => $avatar_name[$category][$i][$j]) + ); + + $template->assign_block_vars('avatar_row.avatar_option_column', array( + "S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j]) + ); + } + } + + $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); + + $s_hidden_vars = ''; + + for($i = 0; $i < count($params); $i++) + { + $s_hidden_vars .= ''; + } + + $template->assign_vars(array( + 'L_AVATAR_GALLERY' => $lang['Avatar_gallery'], + 'L_SELECT_AVATAR' => $lang['Select_avatar'], + 'L_RETURN_PROFILE' => $lang['Return_profile'], + 'L_CATEGORY' => $lang['Select_category'], + + 'S_CATEGORY_SELECT' => $s_categories, + 'S_COLSPAN' => $s_colspan, + 'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=$mode"), + 'S_HIDDEN_FIELDS' => $s_hidden_vars) + ); + + return; +} + +?> diff --git a/phpBB/includes/ucp/usercp_email.php b/phpBB/includes/ucp/usercp_email.php new file mode 100644 index 0000000000..64f750c09c --- /dev/null +++ b/phpBB/includes/ucp/usercp_email.php @@ -0,0 +1,179 @@ +sql_query($sql); + +if ( $row = $db->sql_fetchrow($result) ) +{ + $username = $row['username']; + $user_email = $row['user_email']; + $user_lang = $row['user_lang']; + + if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN ) + { + if ( time() - $userdata['user_emailtime'] < $config['flood_interval'] ) + { + message_die(MESSAGE, $lang['Flood_email_limit']); + } + + if ( isset($HTTP_POST_VARS['submit']) ) + { + $error = FALSE; + + if ( !empty($HTTP_POST_VARS['subject']) ) + { + $subject = trim(stripslashes($HTTP_POST_VARS['subject'])); + } + else + { + $error = TRUE; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Empty_subject_email'] : $lang['Empty_subject_email']; + } + + if ( !empty($HTTP_POST_VARS['message']) ) + { + $message = trim(stripslashes($HTTP_POST_VARS['message'])); + } + else + { + $error = TRUE; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Empty_message_email'] : $lang['Empty_message_email']; + } + + if ( !$error ) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_emailtime = " . time() . " + WHERE user_id = " . $userdata['user_id']; + $result = $db->sql_query($sql); + + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($config['smtp_delivery']); + + $email_headers = 'From: ' . $userdata['user_email'] . "\n"; + if ( !empty($HTTP_POST_VARS['cc_email']) ) + { + $email_headers .= "Cc: " . $userdata['user_email'] . "\n"; + } + $email_headers .= 'Return-Path: ' . $userdata['user_email'] . "\n"; + $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n"; + $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n"; + $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; + $email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\r\n"; + + $emailer->use_template('profile_send_email', $user_lang); + $emailer->email_address($user_email); + $emailer->set_subject($subject); + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'BOARD_EMAIL' => $config['board_email'], + 'FROM_USERNAME' => $userdata['username'], + 'TO_USERNAME' => $username, + 'MESSAGE' => $message) + ); + $emailer->send(); + $emailer->reset(); + + $template->assign_vars(array( + 'META' => '') + ); + + $message = $lang['Email_sent'] . '

' . sprintf($lang['Click_return_index'], '', ''); + + message_die(MESSAGE, $message); + } + } + + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'body' => 'profile_send_email.html') + ); + make_jumpbox('viewforum.'.$phpEx); + + if ( $error ) + { + $template->set_filenames(array( + 'reg_header' => 'error_body.html') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } + + $template->assign_vars(array( + 'USERNAME' => $username, + + 'S_POST_ACTION' => "profile.$phpEx$SID&mode=email&u=$user_id", + + 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], + 'L_RECIPIENT' => $lang['Recipient'], + 'L_SUBJECT' => $lang['Subject'], + 'L_MESSAGE_BODY' => $lang['Message_body'], + 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], + 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], + 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], + 'L_OPTIONS' => $lang['Options'], + 'L_CC_EMAIL' => $lang['CC_email'], + 'L_SPELLCHECK' => $lang['Spellcheck'], + 'L_SEND_EMAIL' => $lang['Send_email']) + ); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + } + else + { + message_die(MESSAGE, $lang['User_prevent_email']); + } +} +else +{ + message_die(MESSAGE, $lang['User_not_exist']); +} + +?> \ No newline at end of file diff --git a/phpBB/includes/ucp/usercp_register.php b/phpBB/includes/ucp/usercp_register.php new file mode 100644 index 0000000000..1d964ed4e0 --- /dev/null +++ b/phpBB/includes/ucp/usercp_register.php @@ -0,0 +1,768 @@ +set_filenames(array( + 'body' => 'agreement.html') + ); + + $template->assign_vars(array( + 'REGISTRATION' => $user->lang['Registration'], + 'AGREEMENT' => $user->lang['Reg_agreement'], + "AGREE_OVER_13" => $user->lang['Agree_over_13'], + "AGREE_UNDER_13" => $user->lang['Agree_under_13'], + 'DO_NOT_AGREE' => $user->lang['Agree_not'], + + "U_AGREE_OVER13" => "profile.$phpEx$SID&mode=register&agreed=true", + "U_AGREE_UNDER13" => "profile.$phpEx$SID&mode=register&agreed=true&coppa=true") + ); +} +// +// --------------------------------------- + + +// +// +// +if ($mode == 'register' && $config['require_activation'] == USER_ACTIVATION_DISABLE) +{ + trigger_error($user->lang['Cannot_register']); +} + + +// +// +// +$error = FALSE; +$page_title = ($mode == 'editprofile') ? $user->lang['Edit_profile'] : $user->lang['Register']; + +if ($mode == 'register' && !isset($_POST['agreed']) && !isset($_GET['agreed']) && $config['enable_coppa']) +{ + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + show_coppa(); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); +} + +$coppa = (empty($_POST['coppa']) && empty($_GET['coppa'])) ? 0 : TRUE; + +// +// Check and initialize some variables if needed +// +if (isset($_POST['submit']) || $mode == 'register') +{ + if ($mode == 'editprofile') + { + $user_id = intval($_POST['user_id']); + $current_email = trim(strip_tags(htmlspecialchars($_POST['current_email']))); + } + + $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests'); + + foreach ($strip_var_list as $var => $param) + { + if (!empty($_POST[$param])) + { + $$var = trim(strip_tags($_POST[$param])); + } + } + + $trim_var_list = array('password_current' => 'cur_password', 'password' => 'new_password', 'password_confirm' => 'password_confirm', 'signature' => 'signature'); + + foreach ($strip_var_list as $var => $param) + { + if (!empty($_POST[$param])) + { + $$var = trim($_POST[$param]); + } + } + + $username = str_replace(' ', '', $username); + $email = htmlspecialchars($email); + $signature = str_replace('
', "\n", $signature); + + // Run some validation on the optional fields. These are pass-by-ref, so they'll be changed to + // empty strings if they fail. + validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature); + + $viewemail = (isset($_POST['viewemail'])) ? (($_POST['viewemail']) ? TRUE : 0) : 0; + $allowviewonline = (isset($_POST['hideonline'])) ? (($_POST['hideonline']) ? 0 : TRUE) : TRUE; + $notifyreply = (isset($_POST['notifyreply'])) ? (($_POST['notifyreply']) ? TRUE : 0) : 0; + $notifypm = (isset($_POST['notifypm'])) ? (($_POST['notifypm']) ? TRUE : 0) : TRUE; + $popuppm = (isset($_POST['popup_pm'])) ? (($_POST['popup_pm']) ? TRUE : 0) : TRUE; + + if ($mode == 'register') + { + $attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : $config['allow_sig']; + + $allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $config['allow_html']; + $allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $config['allow_bbcode']; + $allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $config['allow_smilies']; + } + else + { + $attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : 0; + + $allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $user->data['user_allowhtml']; + $allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $user->data['user_allowbbcode']; + $allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $user->data['user_allowsmiles']; + } + + $user_style = (isset($_POST['style'])) ? intval($_POST['style']) : $config['default_style']; + + if (!empty($_POST['language'])) + { + if (preg_match('/^[a-z_]+$/i', $_POST['language'])) + { + $user_lang = $_POST['language']; + } + else + { + $error = true; + $error_msg = $user->lang['Fields_empty']; + } + } + else + { + $user_lang = $config['default_lang']; + } + + $user_timezone = (isset($_POST['timezone'])) ? doubleval($_POST['timezone']) : $config['board_timezone']; + $user_dateformat = (!empty($_POST['dateformat'])) ? trim($_POST['dateformat']) : $config['default_dateformat']; + +} + +// +// Did the user submit? In this case build a query to update the users profile in the DB +// +if (isset($_POST['submit'])) +{ + $passwd_sql = ''; + if ($mode == 'editprofile') + { + if ($user_id != $user->data['user_id']) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Wrong_Profile']; + } + } + else if ($mode == 'register') + { + if (empty($username) || empty($password) || empty($password_confirm) || empty($email)) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Fields_empty']; + } + + } + + $passwd_sql = ''; + if (!empty($password) && !empty($password_confirm)) + { + if ($password != $password_confirm) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_mismatch']; + } + else if (strlen($password) > 32) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_long']; + } + else + { + if ($mode == 'editprofile') + { + $sql = "SELECT user_password + FROM " . USERS_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); + + $row = $db->sql_fetchrow($result); + + if ($row['user_password'] != md5($password_current)) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Current_password_mismatch']; + } + } + + if (!$error) + { + $password = md5($password); + $passwd_sql = "user_password = '$password', "; + } + } + } + else if ((empty($password) && !empty($password_confirm)) || (!empty($password) && empty($password_confirm))) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_mismatch']; + } + else + { + $password = $user->data['user_password']; + } + + // + // Do a ban check on this email address + // + if ($email != $user->data['user_email'] || $mode == 'register') + { + if (($result = validate_email($email)) != false) + { + $email = $user->data['user_email']; + + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $result; + } + + if ($mode == 'editprofile') + { + $sql = "SELECT user_password + FROM " . USERS_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); + + $row = $db->sql_fetchrow($result); + + if ($row['user_password'] != md5($password_current)) + { + $email = $user->data['user_email']; + + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Current_password_mismatch']; + } + } + } + + $username_sql = ''; + if ($config['allow_namechange'] || $mode == 'register') + { + if (empty($username)) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Username_disallowed']; + } + else if ($username != $user->data['username'] || $mode == 'register') + { + if (($result = validate_username($username)) != false) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $result; + } + else + { + $username_sql = "username = '" . sql_quote($username) . "', "; + if ($mode != 'register') + { + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_last_poster_name = '" . sql_quote($username) . "' + WHERE forum_last_poster_id = " . $user_id; + $db->sql_query($sql); + } + } + } + } + + if ($signature != '') + { + if (strlen($signature) > $config['max_sig_chars']) + { + $error = TRUE; + $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Signature_too_long']; + } + + if ($signature_bbcode_uid == '') + { +// $signature_bbcode_uid = ($allowbbcode) ? make_bbcode_uid() : ''; + } +// $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid); + } + + if (!$error) + { + if ((($mode == 'editprofile' && $auth->acl_get('a_') && $email != $current_email) || ($mode == 'register' || $coppa)) && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) + { + $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); + $user_active = 0; + + if ($user->data['user_id'] != ANONYMOUS) + { + $user->destroy(); + } + } + else + { + $user_active = 1; + $user_actkey = ''; + } + + $sql_ary = array( + 'username' => $username, + 'user_regdate' => time(), + 'user_password' => $password, + 'user_email' => $email, + 'user_icq' => $icq, + 'user_aim' => $aim, + 'user_yim' => $yim, + 'user_msnm' => $msn, + 'user_website' => $website, + 'user_occ' => $occupation, + 'user_from' => $location, + 'user_interests' => $interests, + 'user_sig' => $signature, + 'user_sig_bbcode_uid' => $signature_bbcode_uid, + 'user_viewemail' => $viewemail, + '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' => $popuppm, + 'user_avatar' => $avatar_sql['data'], + 'user_avatar_type' => $avatar_sql['type'], + 'user_timezone' => (float) $user_timezone, + 'user_dateformat' => $user_dateformat, + 'user_lang' => $user_lang, + 'user_style' => $user_style, + 'user_allow_pm' => 1, + 'user_active' => $user_active, + 'user_actkey' => $user_actkey + ); + + if ($mode == 'editprofile') + { + $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id); + + if ($config['newest_user_id'] == $user_id) + { + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . sql_quote($username) . "' + WHERE config_name = 'newest_username'"; + $db->sql_query($sql); + } + + // Update moderator cache table as appropriate + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET username = '" . sql_quote($username) . "' + WHERE user_id = $user_id"; + $db->sql_query($sql); + + if (!$user_active) + { + // + // The users account has been deactivated, send them an email with a new activation key + // + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($config['smtp_delivery']); + + $email_headers = "From: " . $config['board_email'] . "\r\nReturn-Path: " . $config['board_email'] . "\r\n"; + + $emailer->use_template('user_activate', stripslashes($user_lang)); + $emailer->email_address($email); + $emailer->set_subject();//$user->lang['Reactivate'] + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'USERNAME' => $username, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) + ); + $emailer->send(); + $emailer->reset(); + + $message = $user->lang['Profile_updated_inactive'] . '

' . sprintf($user->lang['Click_return_index'], '', ''); + } + else + { + $message = $user->lang['Profile_updated'] . '

' . sprintf($user->lang['Click_return_index'], '', ''); + } + + $template->assign_vars(array( + "META" => '') + ); + trigger_error($message); + } + else + { + $db->sql_transaction(); + + $db->sql_query_array('INSERT INTO ' . USERS_TABLE, &$sql_ary); + + $user_id = $db->sql_nextid(); + + // Place into appropriate group, either REGISTERED or INACTIVE depending on config + $group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? 'REGISTERED' : 'INACTIVE'; + $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) SELECT $user_id, group_id, 0 FROM " . GROUPS_TABLE . " WHERE group_name = '$group_name'"; + $result = $db->sql_query($sql); + + if ($config['require_activation'] == USER_ACTIVATION_NONE) + { + // Sync config + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = $user_id + WHERE config_name = 'newest_user_id'"; + $db->sql_query($sql); + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$username' + WHERE config_name = 'newest_username'"; + $db->sql_query($sql); + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = " . ($config['num_users'] + 1) . " + WHERE config_name = 'num_users'"; + $db->sql_query($sql); + } + + $db->sql_transaction('commit'); + + if ($coppa) + { + $message = $user->lang['COPPA']; + $email_template = 'coppa_welcome_inactive'; + } + else if ($config['require_activation'] == USER_ACTIVATION_SELF) + { + $message = $user->lang['Account_inactive']; + $email_template = 'user_welcome_inactive'; + } + else if ($config['require_activation'] == USER_ACTIVATION_ADMIN) + { + $message = $user->lang['Account_inactive_admin']; + $email_template = 'admin_welcome_inactive'; + } + else + { + $message = $user->lang['Account_added']; + $email_template = 'user_welcome'; + } + + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($config['smtp_delivery']); + + $email_headers = "From: " . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; + + $emailer->use_template($email_template, stripslashes($user_lang)); + $emailer->email_address($email); + $emailer->set_subject();//sprintf($user->lang['Welcome_subject'], $config['sitename']) + $emailer->extra_headers($email_headers); + + if ($coppa) + { + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), + 'USERNAME' => $username, + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey, + + 'FAX_INFO' => $config['coppa_fax'], + 'MAIL_INFO' => $config['coppa_mail'], + 'EMAIL_ADDRESS' => $email, + 'ICQ' => $icq, + 'AIM' => $aim, + 'YIM' => $yim, + 'MSN' => $msn, + 'WEB_SITE' => $website, + 'FROM' => $location, + 'OCC' => $occupation, + 'INTERESTS' => $interests, + 'SITENAME' => $config['sitename'])); + } + else + { + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), + 'USERNAME' => $username, + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) + ); + } + + $emailer->send(); + $emailer->reset(); + + if ($config['require_activation'] == USER_ACTIVATION_ADMIN) + { + $emailer->use_template("admin_activate", stripslashes($user_lang)); + $emailer->email_address($config['board_email']); + $emailer->set_subject(); //$user->lang['New_account_subject'] + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'USERNAME' => $username, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) + ); + $emailer->send(); + $emailer->reset(); + } + + $message = $message . '

' . sprintf($user->lang['Click_return_index'], '', ''); + + message_die(GENERAL_MESSAGE, $message); + } // if mode == register + } +} // End of submit + + +if ($error) +{ + // + // If an error occured we need to stripslashes on returned data + // + $username = stripslashes($username); + $email = stripslashes($email); + $password = ''; + $password_confirm = ''; + + $icq = stripslashes($icq); + $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)); + $signature = stripslashes($signature); + + $user_lang = stripslashes($user_lang); + $user_dateformat = stripslashes($user_dateformat); +} +else if ($mode == 'editprofile') +{ + $user_id = $user->data['user_id']; + $username = htmlspecialchars($user->data['username']); + $email = $user->data['user_email']; + $password = ''; + $password_confirm = ''; + + $icq = $user->data['user_icq']; + $aim = htmlspecialchars(str_replace('+', ' ', $user->data['user_aim'])); + $msn = htmlspecialchars($user->data['user_msnm']); + $yim = htmlspecialchars($user->data['user_yim']); + + $website = htmlspecialchars($user->data['user_website']); + $location = htmlspecialchars($user->data['user_from']); + $occupation = htmlspecialchars($user->data['user_occ']); + $interests = htmlspecialchars($user->data['user_interests']); + $signature_bbcode_uid = $user->data['user_sig_bbcode_uid']; + $signature = ($signature_bbcode_uid != '') ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $user->data['user_sig']) : $user->data['user_sig']; + + $viewemail = $user->data['user_viewemail']; + $notifypm = $user->data['user_notify_pm']; + $popuppm = $user->data['user_popup_pm']; + $notifyreply = $user->data['user_notify']; + $attachsig = $user->data['user_attachsig']; + $allowhtml = $user->data['user_allowhtml']; + $allowbbcode = $user->data['user_allowbbcode']; + $allowsmilies = $user->data['user_allowsmile']; + $allowviewonline = $user->data['user_allow_viewonline']; + + $user_style = $user->data['user_style']; + $user_lang = $user->data['user_lang']; + $user_timezone = $user->data['user_timezone']; + $user_dateformat = $user->data['user_dateformat']; +} + +// +// Default pages +// + +if ($mode == 'editprofile') +{ + if ($user_id != $user->data['user_id']) + { + $error = TRUE; + $error_msg = $user->lang['Wrong_Profile']; + } +} + + + if (!isset($coppa)) + { + $coppa = FALSE; + } + + if (!isset($user_template)) + { + $selected_template = $config['system_template']; + } + + $signature = preg_replace('/\:[0-9a-z\:]*?\]/si', ']', $signature); + + $s_hidden_fields = ''; + if($mode == 'editprofile') + { + $s_hidden_fields .= ''; + // + // Send the users current email address. If they change it, and account activation is turned on + // the user account will be disabled and the user will have to reactivate their account. + // + $s_hidden_fields .= ''; + } + + if (!empty($user_avatar_local)) + { + $s_hidden_fields .= ''; + } + + $html_status = ($user->data['user_allowhtml'] && $config['allow_html']) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF']; + $bbcode_status = ($user->data['user_allowbbcode'] && $config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF']; + $smilies_status = ($user->data['user_allowsmile'] && $config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF']; + + // + // Let's do an overall check for settings/versions which would prevent + // us from doing file uploads.... + // + $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off'|| !$config['allow_avatar_upload']) ? '' : 'enctype="multipart/form-data"'; + + $template->assign_vars(array( + 'USERNAME' => $username, + 'EMAIL' => $email, + 'YIM' => $yim, + 'ICQ' => $icq, + 'MSN' => $msn, + 'AIM' => $aim, + 'OCCUPATION' => $occupation, + 'INTERESTS' => $interests, + 'LOCATION' => $location, + 'WEBSITE' => $website, + 'SIGNATURE' => str_replace('
', "\n", $signature), + '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"' : '', + '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"' : '', + 'LANGUAGE_SELECT' => language_select($user_lang, 'language'), + 'STYLE_SELECT' => style_select($user_style, 'style'), + 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'), + 'DATE_FORMAT' => $user_dateformat, + 'HTML_STATUS' => $html_status, + 'BBCODE_STATUS' => sprintf($bbcode_status, '', ''), + 'SMILIES_STATUS' => $smilies_status, + + 'L_CURRENT_PASSWORD' => $user->lang['Current_password'], + 'L_NEW_PASSWORD' => ($mode == 'register') ? $user->lang['Password'] : $user->lang['New_password'], + 'L_CONFIRM_PASSWORD' => $user->lang['Confirm_password'], + 'L_CONFIRM_PASSWORD_EXPLAIN' => ($mode == 'editprofile') ? $user->lang['Confirm_password_explain'] : '', + 'L_PASSWORD_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_if_changed'] : '', + 'L_PASSWORD_CONFIRM_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_confirm_if_changed'] : '', + 'L_SUBMIT' => $user->lang['Submit'], + 'L_RESET' => $user->lang['Reset'], + 'L_ICQ_NUMBER' => $user->lang['ICQ'], + 'L_MESSENGER' => $user->lang['MSNM'], + 'L_YAHOO' => $user->lang['YIM'], + 'L_WEBSITE' => $user->lang['Website'], + 'L_AIM' => $user->lang['AIM'], + 'L_LOCATION' => $user->lang['Location'], + 'L_OCCUPATION' => $user->lang['Occupation'], + 'L_BOARD_LANGUAGE' => $user->lang['Board_lang'], + 'L_BOARD_STYLE' => $user->lang['Board_style'], + 'L_TIMEZONE' => $user->lang['Timezone'], + 'L_DATE_FORMAT' => $user->lang['Date_format'], + 'L_DATE_FORMAT_EXPLAIN' => $user->lang['Date_format_explain'], + 'L_YES' => $user->lang['Yes'], + 'L_NO' => $user->lang['No'], + 'L_INTERESTS' => $user->lang['Interests'], + 'L_ALWAYS_ALLOW_SMILIES' => $user->lang['Always_smile'], + 'L_ALWAYS_ALLOW_BBCODE' => $user->lang['Always_bbcode'], + 'L_ALWAYS_ALLOW_HTML' => $user->lang['Always_html'], + 'L_HIDE_USER' => $user->lang['Hide_user'], + 'L_ALWAYS_ADD_SIGNATURE' => $user->lang['Always_add_sig'], + + 'L_SIGNATURE' => $user->lang['Signature'], + 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['Signature_explain'], $config['max_sig_chars']), + 'L_NOTIFY_ON_REPLY' => $user->lang['Always_notify'], + 'L_NOTIFY_ON_REPLY_EXPLAIN' => $user->lang['Always_notify_explain'], + 'L_NOTIFY_ON_PRIVMSG' => $user->lang['Notify_on_privmsg'], + 'L_POPUP_ON_PRIVMSG' => $user->lang['Popup_on_privmsg'], + 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $user->lang['Popup_on_privmsg_explain'], + 'L_PREFERENCES' => $user->lang['Preferences'], + 'L_PUBLIC_VIEW_EMAIL' => $user->lang['Public_view_email'], + 'L_ITEMS_REQUIRED' => $user->lang['Items_required'], + 'L_REGISTRATION_INFO' => $user->lang['Registration_info'], + 'L_PROFILE_INFO' => $user->lang['Profile_info'], + 'L_PROFILE_INFO_NOTICE' => $user->lang['Profile_info_warn'], + 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], + + 'S_PROFILE_EDIT' => ($mode == 'editprofile') ? true : false, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORM_ENCTYPE' => $form_enctype, + 'S_PROFILE_ACTION' => "profile.$phpEx$SID") + ); + +// +// +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +$template->set_filenames(array( + 'body' => 'profile_add_body.html') +); +make_jumpbox('viewforum.'.$phpEx); + +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + +?> \ No newline at end of file diff --git a/phpBB/includes/ucp/usercp_sendpasswd.php b/phpBB/includes/ucp/usercp_sendpasswd.php new file mode 100644 index 0000000000..a59590ad97 --- /dev/null +++ b/phpBB/includes/ucp/usercp_sendpasswd.php @@ -0,0 +1,134 @@ +sql_query($sql) ) + { + if ( $row = $db->sql_fetchrow($result) ) + { + if ( !$row['user_active'] ) + { + message_die(GENERAL_MESSAGE, $lang['No_send_account_inactive']); + } + + $username = $row['username']; + + $user_actkey = gen_rand_string(true); + $key_len = 54 - strlen($server_url); + $key_len = ( $str_len > 6 ) ? $key_len : 6; + $user_actkey = substr($user_actkey, 0, $key_len); + $user_password = gen_rand_string(false); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey' + WHERE user_id = " . $row['user_id']; + if ( !$db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, 'Could not update new password information', '', __LINE__, __FILE__, $sql); + } + + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($config['smtp_delivery']); + + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; + + $emailer->use_template('user_activate_passwd', $row['user_lang']); + $emailer->email_address($row['user_email']); + $emailer->set_subject();//$lang['New_password_activation'] + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'USERNAME' => $username, + 'PASSWORD' => $user_password, + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . "?mode=activate&act_key=$user_actkey") + ); + $emailer->send(); + $emailer->reset(); + + $template->assign_vars(array( + 'META' => '') + ); + + $message = $lang['Password_updated'] . '

' . sprintf($lang['Click_return_index'], '', ''); + + message_die(GENERAL_MESSAGE, $message); + } + else + { + message_die(GENERAL_MESSAGE, $lang['No_email_match']); + } + } + else + { + message_die(GENERAL_ERROR, 'Could not obtain user information for sendpassword', '', __LINE__, __FILE__, $sql); + } +} +else +{ + $username = ''; + $email = ''; +} + +// +// Output basic page +// +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +$template->set_filenames(array( + 'body' => 'profile_send_pass.tpl') +); +make_jumpbox('viewforum.'.$phpEx); + +$template->assign_vars(array( + 'USERNAME' => $username, + 'EMAIL' => $email, + + 'L_SEND_PASSWORD' => $lang['Send_password'], + 'L_ITEMS_REQUIRED' => $lang['Items_required'], + 'L_EMAIL_ADDRESS' => $lang['Email_address'], + 'L_SUBMIT' => $lang['Submit'], + 'L_RESET' => $lang['Reset']) +); + +$template->pparse('body'); + +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + +?> diff --git a/phpBB/includes/ucp/usercp_viewprofile.php b/phpBB/includes/ucp/usercp_viewprofile.php new file mode 100644 index 0000000000..348ce42ed9 --- /dev/null +++ b/phpBB/includes/ucp/usercp_viewprofile.php @@ -0,0 +1,240 @@ +lang['No_user_id_specified']); +} +$profiledata = get_userdata(intval($_GET['u'])); + +$sql = "SELECT * + FROM " . RANKS_TABLE . " + ORDER BY rank_special, rank_min"; +$result = $db->sql_query($sql); + +while ( $row = $db->sql_fetchrow($result) ) +{ + $ranksrow[] = $row; +} +$db->sql_freeresult($result); + +// +// Output page header and profile_view template +// +$template->set_filenames(array( + 'body' => 'profile_view_body.html') +); +make_jumpbox('viewforum.'.$phpEx); + +// +// Calculate the number of days this user has been a member ($memberdays) +// Then calculate their posts per day +// +$regdate = $profiledata['user_regdate']; +$memberdays = max(1, round( ( time() - $regdate ) / 86400 )); +$posts_per_day = $profiledata['user_posts'] / $memberdays; + +// Get the users percentage of total posts +if ( $profiledata['user_posts'] ) +{ + $sql = "SELECT SUM(forum_posts) AS total + FROM " . FORUMS_TABLE; + $result = $db->sql_query($sql); + + $total_posts = ($row = $db->sql_fetchrow($result)) ? $row['total'] : 0; + $db->sql_freeresult($result); + + $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0; +} +else +{ + $percentage = 0; +} + +$avatar_img = ''; +if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] ) +{ + switch( $profiledata['user_avatar_type'] ) + { + case USER_AVATAR_UPLOAD: + $avatar_img = ( $config['allow_avatar_upload'] ) ? '' : ''; + break; + case USER_AVATAR_REMOTE: + $avatar_img = ( $config['allow_avatar_remote'] ) ? '' : ''; + break; + case USER_AVATAR_GALLERY: + $avatar_img = ( $config['allow_avatar_local'] ) ? '' : ''; + break; + } +} + +$poster_rank = ''; +$rank_image = ''; +if ( $profiledata['user_rank'] ) +{ + for($i = 0; $i < count($ranksrow); $i++) + { + if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] ) + { + $poster_rank = $ranksrow[$i]['rank_title']; + $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '' . $poster_rank . '
' : ''; + } + } +} +else +{ + for($i = 0; $i < count($ranksrow); $i++) + { + if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] ) + { + $poster_rank = $ranksrow[$i]['rank_title']; + $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '' . $poster_rank . '
' : ''; + } + } +} + +if ( $profiledata['user_viewemail'] || $auth->acl_get('a_') ) +{ + $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; + + $email_img = '' . $user->img('icon_email', $user->lang['Send_email']) . ''; + $email = '' . $user->lang['Send_email'] . ''; +} +else +{ + $email_img = ' '; + $email = ' '; +} + +$temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; +$profile_img = '' . $user->img('icon_profile', $user->lang['Read_profile']) . ''; +$profile = '' . $user->lang['Read_profile'] . ''; + +$temp_url = "privmsg.$phpEx$SID&mode=post&u=$user_id"; +$pm_img = '' . $user->img('icon_pm', $user->lang['Send_private_message']) . ''; +$pm = '' . $user->lang['Send_private_message'] . ''; + +$www_img = ( $profiledata['user_website'] ) ? '' . $user->img('icon_www', $user->lang['Visit_website']) . '' : ''; +$www = ( $profiledata['user_website'] ) ? '' . $user->lang['Visit_website'] . '' : ''; + +if ( !empty($profiledata['user_icq']) ) +{ + $icq_status_img = ''; + $icq_img = '' . $user->img('icon_icq', $user->lang['ICQ']) . ''; + $icq = '' . $user->lang['ICQ'] . ''; +} +else +{ + $icq_status_img = ''; + $icq_img = ''; + $icq = ''; +} + +$aim_img = ( $profiledata['user_aim'] ) ? '' . $user->img('icon_aim', $user->lang['AIM']) . '' : ''; +$aim = ( $profiledata['user_aim'] ) ? '' . $user->lang['AIM'] . '' : ''; + +$temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; +$msn_img = ( $profiledata['user_msnm'] ) ? '' . $user->img('icon_msnm', $user->lang['MSNM']) . '' : ''; +$msn = ( $profiledata['user_msnm'] ) ? '' . $user->lang['MSNM'] . '' : ''; + +$yim_img = ( $profiledata['user_yim'] ) ? '' . $user->img('icon_yim', $user->lang['YIM']) . '' : ''; +$yim = ( $profiledata['user_yim'] ) ? '' . $user->lang['YIM'] . '' : ''; + +$temp_url = "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']) . "&showresults=posts"; +$search_img = '' . $user->img('icon_search', $user->lang['Search_user_posts']) . ''; +$search = '' . $user->lang['Search_user_posts'] . ''; + +// +// Generate page +// +$page_title = $user->lang['Viewing_profile']; +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +$template->assign_vars(array( + 'USERNAME' => $profiledata['username'], + 'JOINED' => $user->format_date($profiledata['user_regdate'], $user->lang['DATE_FORMAT']), + 'POSTER_RANK' => $poster_rank, + 'RANK_IMAGE' => $rank_image, + 'POSTS_PER_DAY' => $posts_per_day, + 'POSTS' => $profiledata['user_posts'], + 'PERCENTAGE' => $percentage . '%', + 'POST_DAY_STATS' => sprintf($user->lang['User_post_day_stats'], $posts_per_day), + 'POST_PERCENT_STATS' => sprintf($user->lang['User_post_pct_stats'], $percentage), + + 'SEARCH_IMG' => $search_img, + 'SEARCH' => $search, + 'PM_IMG' => $pm_img, + 'PM' => $pm, + 'EMAIL_IMG' => $email_img, + 'EMAIL' => $email, + 'WWW_IMG' => $www_img, + 'WWW' => $www, + 'ICQ_STATUS_IMG' => $icq_status_img, + 'ICQ_IMG' => $icq_img, + 'ICQ' => $icq, + 'AIM_IMG' => $aim_img, + 'AIM' => $aim, + 'MSN_IMG' => $msn_img, + 'MSN' => $msn, + 'YIM_IMG' => $yim_img, + 'YIM' => $yim, + + 'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ', + 'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ', + 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ', + 'AVATAR_IMG' => $avatar_img, + + 'L_VIEWING_PROFILE' => sprintf($user->lang['Viewing_user_profile'], $profiledata['username']), + 'L_ABOUT_USER' => sprintf($user->lang['About_user'], $profiledata['username']), + 'L_AVATAR' => $user->lang['Avatar'], + 'L_POSTER_RANK' => $user->lang['Poster_rank'], + 'L_JOINED' => $user->lang['Joined'], + 'L_TOTAL_POSTS' => $user->lang['Total_posts'], + 'L_SEARCH_USER_POSTS' => sprintf($user->lang['Search_user_posts'], $profiledata['username']), + 'L_CONTACT' => $user->lang['Contact'], + 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], + 'L_EMAIL' => $user->lang['Email'], + 'L_PM' => $user->lang['Private_Message'], + 'L_ICQ_NUMBER' => $user->lang['ICQ'], + 'L_YAHOO' => $user->lang['YIM'], + 'L_AIM' => $user->lang['AIM'], + 'L_MESSENGER' => $user->lang['MSNM'], + 'L_WEBSITE' => $user->lang['Website'], + 'L_LOCATION' => $user->lang['Location'], + 'L_OCCUPATION' => $user->lang['Occupation'], + 'L_INTERESTS' => $user->lang['Interests'], + + 'U_SEARCH_USER' => "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']), + + 'S_PROFILE_ACTION' => "profile.$phpEx$SID") +); + +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_activate.php b/phpBB/includes/usercp_activate.php deleted file mode 100644 index e823e4d211..0000000000 --- a/phpBB/includes/usercp_activate.php +++ /dev/null @@ -1,106 +0,0 @@ -sql_query($sql)) ) -{ - message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql); -} - -if ( $row = $db->sql_fetchrow($result) ) -{ - if ( $row['user_active'] && $row['user_actkey'] == '' ) - { - $template->assign_vars(array( - 'META' => '') - ); - - message_die(GENERAL_MESSAGE, $lang['Already_activated']); - } - else if ( $row['user_actkey'] == $HTTP_GET_VARS['act_key'] ) - { - $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : ''; - - $sql = "UPDATE " . USERS_TABLE . " - SET user_active = 1, user_actkey = ''" . $sql_update_pass . " - WHERE user_id = " . $row['user_id']; - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update); - } - - if ( $config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '' ) - { - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($config['smtp_delivery']); - - $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\n"; - - $emailer->use_template('admin_welcome_activated', $row['user_lang']); - $emailer->email_address($row['user_email']); - $emailer->set_subject();//$lang['Account_activated_subject'] - $emailer->extra_headers($email_headers); - - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'USERNAME' => $username, - 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig'])) - ); - $emailer->send(); - $emailer->reset(); - - $template->assign_vars(array( - 'META' => '') - ); - - message_die(GENERAL_MESSAGE, $lang['Account_active_admin']); - } - else - { - $template->assign_vars(array( - 'META' => '') - ); - - $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated']; - message_die(GENERAL_MESSAGE, $message); - } - } - else - { - message_die(GENERAL_MESSAGE, $lang['Wrong_activation']); - } -} -else -{ - message_die(GENERAL_MESSAGE, $lang['No_such_user']); -} - -?> \ No newline at end of file diff --git a/phpBB/includes/usercp_avatar.php b/phpBB/includes/usercp_avatar.php deleted file mode 100644 index c7321d758c..0000000000 --- a/phpBB/includes/usercp_avatar.php +++ /dev/null @@ -1,336 +0,0 @@ -' . $lang['Avatar_filetype'] : $lang['Avatar_filetype']; - break; - } - - return false; -} - -function user_avatar_delete($avatar_type, $avatar_file) -{ - global $config, $userdata; - - if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' ) - { - if ( @file_exists('./' . $config['avatar_path'] . '/' . $avatar_file) ) - { - @unlink('./' . $config['avatar_path'] . '/' . $avatar_file); - } - } - - return ", user_avatar = '', user_avatar_type = " . USER_AVATAR_NONE; -} - -function user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename) -{ - return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY : ''; -} - -function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename) -{ - if ( !preg_match('#^http:\/\/#i', $avatar_filename) ) - { - $avatar_filename = 'http://' . $avatar_filename; - } - - if ( !preg_match('#^(http:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/[^\"]*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) ) - { - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format']; - return; - } - - return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : ''; - -} - -function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype) -{ - global $config, $user_ip, $db, $lang; - - $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; - - if ( $avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $avatar_filename, $url_ary) ) - { - if ( empty($url_ary[4]) ) - { - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Incomplete_URL'] : $lang['Incomplete_URL']; - return; - } - - $base_get = '/' . $url_ary[4]; - $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80; - - if ( !($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) ) - { - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['No_connection_URL'] : $lang['No_connection_URL']; - return; - } - - @fputs($fsock, "GET $base_get HTTP/1.1\r\n"); - @fputs($fsock, "HOST: " . $url_ary[2] . "\r\n"); - @fputs($fsock, "Connection: close\r\n\r\n"); - - unset($avatar_data); - while( !@feof($fsock) ) - { - $avatar_data .= @fread($fsock, $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) ) - { - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['File_no_data'] : $lang['File_no_data']; - return; - } - - $avatar_filesize = $file_data1[1]; - $avatar_filetype = $file_data2[1]; - - if ( !$error && $avatar_filesize > 0 && $avatar_filesize < $config['avatar_filesize'] ) - { - $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize); - - $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $config['avatar_path'] . '/tmp'; - $tmp_filename = tempnam($tmp_path, uniqid($user_ip) . '-'); - - $fptr = @fopen($tmp_filename, 'wb'); - $bytes_written = @fwrite($fptr, $avatar_data, $avatar_filesize); - @fclose($fptr); - - if ( $bytes_written != $avatar_filesize ) - { - @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__); - } - - list($width, $height) = @getimagesize($tmp_filename); - } - else - { - $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); - - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; - } - } - else if ( $avatar_mode == 'local' && file_exists($avatar_filename) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) ) - { - if ( $avatar_filesize <= $config['avatar_filesize'] && $avatar_filesize > 0 ) - { - preg_match('#image\/[x\-]*([a-z]+)#', $avatar_filetype, $avatar_filetype); - $avatar_filetype = $avatar_filetype[1]; - } - else - { - $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); - - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; - return; - } - - list($width, $height) = @getimagesize($avatar_filename); - } - - if ( !($imgtype = check_image_type($avatar_filetype, $error, $error_msg)) ) - { - return; - } - - if ( $width <= $config['avatar_max_width'] && $height <= $config['avatar_max_height'] ) - { - $new_filename = uniqid() . $imgtype; - - if ( $mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' ) - { - if ( file_exists('./' . $config['avatar_path'] . '/' . $current_avatar) ) - { - @unlink('./' . $config['avatar_path'] . '/' . $current_avatar); - } - } - - if( $avatar_mode == 'remote' ) - { - @copy($tmp_filename, './' . $config['avatar_path'] . "/$new_filename"); - @unlink($tmp_filename); - } - else - { - if ( @$ini_val('open_basedir') != '' ) - { - if ( @phpversion() < '4.0.3' ) - { - message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file', '', __LINE__, __FILE__); - } - - $move_file = 'move_uploaded_file'; - } - else - { - $move_file = 'copy'; - } - - $move_file($avatar_filename, './' . $config['avatar_path'] . "/$new_filename"); - } - - @chmod('./' . $config['avatar_path'] . "/$new_filename", 0777); - - $avatar_sql = ( $mode == 'editprofile' ) ? ", user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD : "'$new_filename', " . USER_AVATAR_UPLOAD; - } - else - { - $l_avatar_size = sprintf($lang['Avatar_imagesize'], $config['avatar_max_width'], $config['avatar_max_height']); - - $error = true; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; - } - - return $avatar_sql; -} - -function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) -{ - global $config, $db, $template, $lang, $images, $theme; - global $phpbb_root_path, $phpEx; - - $dir = @opendir($config['avatar_gallery_path']); - - $avatar_images = array(); - while( $file = @readdir($dir) ) - { - if( $file != '.' && $file != '..' && !is_file($config['avatar_gallery_path'] . '/' . $file) && !is_link($config['avatar_gallery_path'] . '/' . $file) ) - { - $sub_dir = @opendir($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|\.jpeg)$/is', $sub_file) ) - { - $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file; - $avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $sub_file))); - - $avatar_col_count++; - if( $avatar_col_count == 5 ) - { - $avatar_row_count++; - $avatar_col_count = 0; - } - } - } - } - } - - @closedir($dir); - - @ksort($avatar_images); - @reset($avatar_images); - - if( empty($category) ) - { - list($category, ) = each($avatar_images); - } - @reset($avatar_images); - - $s_categories = ''; - - $s_colspan = 0; - for($i = 0; $i < count($avatar_images[$category]); $i++) - { - $template->assign_block_vars("avatar_row", array()); - - $s_colspan = max($s_colspan, count($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" => $config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j], - "AVATAR_NAME" => $avatar_name[$category][$i][$j]) - ); - - $template->assign_block_vars('avatar_row.avatar_option_column', array( - "S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j]) - ); - } - } - - $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); - - $s_hidden_vars = ''; - - for($i = 0; $i < count($params); $i++) - { - $s_hidden_vars .= ''; - } - - $template->assign_vars(array( - 'L_AVATAR_GALLERY' => $lang['Avatar_gallery'], - 'L_SELECT_AVATAR' => $lang['Select_avatar'], - 'L_RETURN_PROFILE' => $lang['Return_profile'], - 'L_CATEGORY' => $lang['Select_category'], - - 'S_CATEGORY_SELECT' => $s_categories, - 'S_COLSPAN' => $s_colspan, - 'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=$mode"), - 'S_HIDDEN_FIELDS' => $s_hidden_vars) - ); - - return; -} - -?> diff --git a/phpBB/includes/usercp_email.php b/phpBB/includes/usercp_email.php deleted file mode 100644 index 64f750c09c..0000000000 --- a/phpBB/includes/usercp_email.php +++ /dev/null @@ -1,179 +0,0 @@ -sql_query($sql); - -if ( $row = $db->sql_fetchrow($result) ) -{ - $username = $row['username']; - $user_email = $row['user_email']; - $user_lang = $row['user_lang']; - - if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN ) - { - if ( time() - $userdata['user_emailtime'] < $config['flood_interval'] ) - { - message_die(MESSAGE, $lang['Flood_email_limit']); - } - - if ( isset($HTTP_POST_VARS['submit']) ) - { - $error = FALSE; - - if ( !empty($HTTP_POST_VARS['subject']) ) - { - $subject = trim(stripslashes($HTTP_POST_VARS['subject'])); - } - else - { - $error = TRUE; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Empty_subject_email'] : $lang['Empty_subject_email']; - } - - if ( !empty($HTTP_POST_VARS['message']) ) - { - $message = trim(stripslashes($HTTP_POST_VARS['message'])); - } - else - { - $error = TRUE; - $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Empty_message_email'] : $lang['Empty_message_email']; - } - - if ( !$error ) - { - $sql = "UPDATE " . USERS_TABLE . " - SET user_emailtime = " . time() . " - WHERE user_id = " . $userdata['user_id']; - $result = $db->sql_query($sql); - - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($config['smtp_delivery']); - - $email_headers = 'From: ' . $userdata['user_email'] . "\n"; - if ( !empty($HTTP_POST_VARS['cc_email']) ) - { - $email_headers .= "Cc: " . $userdata['user_email'] . "\n"; - } - $email_headers .= 'Return-Path: ' . $userdata['user_email'] . "\n"; - $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n"; - $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n"; - $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; - $email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\r\n"; - - $emailer->use_template('profile_send_email', $user_lang); - $emailer->email_address($user_email); - $emailer->set_subject($subject); - $emailer->extra_headers($email_headers); - - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'BOARD_EMAIL' => $config['board_email'], - 'FROM_USERNAME' => $userdata['username'], - 'TO_USERNAME' => $username, - 'MESSAGE' => $message) - ); - $emailer->send(); - $emailer->reset(); - - $template->assign_vars(array( - 'META' => '') - ); - - $message = $lang['Email_sent'] . '

' . sprintf($lang['Click_return_index'], '', ''); - - message_die(MESSAGE, $message); - } - } - - include($phpbb_root_path . 'includes/page_header.'.$phpEx); - - $template->set_filenames(array( - 'body' => 'profile_send_email.html') - ); - make_jumpbox('viewforum.'.$phpEx); - - if ( $error ) - { - $template->set_filenames(array( - 'reg_header' => 'error_body.html') - ); - $template->assign_vars(array( - 'ERROR_MESSAGE' => $error_msg) - ); - $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); - } - - $template->assign_vars(array( - 'USERNAME' => $username, - - 'S_POST_ACTION' => "profile.$phpEx$SID&mode=email&u=$user_id", - - 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], - 'L_RECIPIENT' => $lang['Recipient'], - 'L_SUBJECT' => $lang['Subject'], - 'L_MESSAGE_BODY' => $lang['Message_body'], - 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], - 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], - 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], - 'L_OPTIONS' => $lang['Options'], - 'L_CC_EMAIL' => $lang['CC_email'], - 'L_SPELLCHECK' => $lang['Spellcheck'], - 'L_SEND_EMAIL' => $lang['Send_email']) - ); - - include($phpbb_root_path . 'includes/page_tail.'.$phpEx); - } - else - { - message_die(MESSAGE, $lang['User_prevent_email']); - } -} -else -{ - message_die(MESSAGE, $lang['User_not_exist']); -} - -?> \ No newline at end of file diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php deleted file mode 100644 index 1d964ed4e0..0000000000 --- a/phpBB/includes/usercp_register.php +++ /dev/null @@ -1,768 +0,0 @@ -set_filenames(array( - 'body' => 'agreement.html') - ); - - $template->assign_vars(array( - 'REGISTRATION' => $user->lang['Registration'], - 'AGREEMENT' => $user->lang['Reg_agreement'], - "AGREE_OVER_13" => $user->lang['Agree_over_13'], - "AGREE_UNDER_13" => $user->lang['Agree_under_13'], - 'DO_NOT_AGREE' => $user->lang['Agree_not'], - - "U_AGREE_OVER13" => "profile.$phpEx$SID&mode=register&agreed=true", - "U_AGREE_UNDER13" => "profile.$phpEx$SID&mode=register&agreed=true&coppa=true") - ); -} -// -// --------------------------------------- - - -// -// -// -if ($mode == 'register' && $config['require_activation'] == USER_ACTIVATION_DISABLE) -{ - trigger_error($user->lang['Cannot_register']); -} - - -// -// -// -$error = FALSE; -$page_title = ($mode == 'editprofile') ? $user->lang['Edit_profile'] : $user->lang['Register']; - -if ($mode == 'register' && !isset($_POST['agreed']) && !isset($_GET['agreed']) && $config['enable_coppa']) -{ - include($phpbb_root_path . 'includes/page_header.'.$phpEx); - - show_coppa(); - - include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -} - -$coppa = (empty($_POST['coppa']) && empty($_GET['coppa'])) ? 0 : TRUE; - -// -// Check and initialize some variables if needed -// -if (isset($_POST['submit']) || $mode == 'register') -{ - if ($mode == 'editprofile') - { - $user_id = intval($_POST['user_id']); - $current_email = trim(strip_tags(htmlspecialchars($_POST['current_email']))); - } - - $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests'); - - foreach ($strip_var_list as $var => $param) - { - if (!empty($_POST[$param])) - { - $$var = trim(strip_tags($_POST[$param])); - } - } - - $trim_var_list = array('password_current' => 'cur_password', 'password' => 'new_password', 'password_confirm' => 'password_confirm', 'signature' => 'signature'); - - foreach ($strip_var_list as $var => $param) - { - if (!empty($_POST[$param])) - { - $$var = trim($_POST[$param]); - } - } - - $username = str_replace(' ', '', $username); - $email = htmlspecialchars($email); - $signature = str_replace('
', "\n", $signature); - - // Run some validation on the optional fields. These are pass-by-ref, so they'll be changed to - // empty strings if they fail. - validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature); - - $viewemail = (isset($_POST['viewemail'])) ? (($_POST['viewemail']) ? TRUE : 0) : 0; - $allowviewonline = (isset($_POST['hideonline'])) ? (($_POST['hideonline']) ? 0 : TRUE) : TRUE; - $notifyreply = (isset($_POST['notifyreply'])) ? (($_POST['notifyreply']) ? TRUE : 0) : 0; - $notifypm = (isset($_POST['notifypm'])) ? (($_POST['notifypm']) ? TRUE : 0) : TRUE; - $popuppm = (isset($_POST['popup_pm'])) ? (($_POST['popup_pm']) ? TRUE : 0) : TRUE; - - if ($mode == 'register') - { - $attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : $config['allow_sig']; - - $allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $config['allow_html']; - $allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $config['allow_bbcode']; - $allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $config['allow_smilies']; - } - else - { - $attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : 0; - - $allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $user->data['user_allowhtml']; - $allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $user->data['user_allowbbcode']; - $allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $user->data['user_allowsmiles']; - } - - $user_style = (isset($_POST['style'])) ? intval($_POST['style']) : $config['default_style']; - - if (!empty($_POST['language'])) - { - if (preg_match('/^[a-z_]+$/i', $_POST['language'])) - { - $user_lang = $_POST['language']; - } - else - { - $error = true; - $error_msg = $user->lang['Fields_empty']; - } - } - else - { - $user_lang = $config['default_lang']; - } - - $user_timezone = (isset($_POST['timezone'])) ? doubleval($_POST['timezone']) : $config['board_timezone']; - $user_dateformat = (!empty($_POST['dateformat'])) ? trim($_POST['dateformat']) : $config['default_dateformat']; - -} - -// -// Did the user submit? In this case build a query to update the users profile in the DB -// -if (isset($_POST['submit'])) -{ - $passwd_sql = ''; - if ($mode == 'editprofile') - { - if ($user_id != $user->data['user_id']) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Wrong_Profile']; - } - } - else if ($mode == 'register') - { - if (empty($username) || empty($password) || empty($password_confirm) || empty($email)) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Fields_empty']; - } - - } - - $passwd_sql = ''; - if (!empty($password) && !empty($password_confirm)) - { - if ($password != $password_confirm) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_mismatch']; - } - else if (strlen($password) > 32) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_long']; - } - else - { - if ($mode == 'editprofile') - { - $sql = "SELECT user_password - FROM " . USERS_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - if ($row['user_password'] != md5($password_current)) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Current_password_mismatch']; - } - } - - if (!$error) - { - $password = md5($password); - $passwd_sql = "user_password = '$password', "; - } - } - } - else if ((empty($password) && !empty($password_confirm)) || (!empty($password) && empty($password_confirm))) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Password_mismatch']; - } - else - { - $password = $user->data['user_password']; - } - - // - // Do a ban check on this email address - // - if ($email != $user->data['user_email'] || $mode == 'register') - { - if (($result = validate_email($email)) != false) - { - $email = $user->data['user_email']; - - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $result; - } - - if ($mode == 'editprofile') - { - $sql = "SELECT user_password - FROM " . USERS_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - if ($row['user_password'] != md5($password_current)) - { - $email = $user->data['user_email']; - - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Current_password_mismatch']; - } - } - } - - $username_sql = ''; - if ($config['allow_namechange'] || $mode == 'register') - { - if (empty($username)) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Username_disallowed']; - } - else if ($username != $user->data['username'] || $mode == 'register') - { - if (($result = validate_username($username)) != false) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $result; - } - else - { - $username_sql = "username = '" . sql_quote($username) . "', "; - if ($mode != 'register') - { - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_last_poster_name = '" . sql_quote($username) . "' - WHERE forum_last_poster_id = " . $user_id; - $db->sql_query($sql); - } - } - } - } - - if ($signature != '') - { - if (strlen($signature) > $config['max_sig_chars']) - { - $error = TRUE; - $error_msg .= ((isset($error_msg)) ? '
' : '') . $user->lang['Signature_too_long']; - } - - if ($signature_bbcode_uid == '') - { -// $signature_bbcode_uid = ($allowbbcode) ? make_bbcode_uid() : ''; - } -// $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid); - } - - if (!$error) - { - if ((($mode == 'editprofile' && $auth->acl_get('a_') && $email != $current_email) || ($mode == 'register' || $coppa)) && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) - { - $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); - $user_active = 0; - - if ($user->data['user_id'] != ANONYMOUS) - { - $user->destroy(); - } - } - else - { - $user_active = 1; - $user_actkey = ''; - } - - $sql_ary = array( - 'username' => $username, - 'user_regdate' => time(), - 'user_password' => $password, - 'user_email' => $email, - 'user_icq' => $icq, - 'user_aim' => $aim, - 'user_yim' => $yim, - 'user_msnm' => $msn, - 'user_website' => $website, - 'user_occ' => $occupation, - 'user_from' => $location, - 'user_interests' => $interests, - 'user_sig' => $signature, - 'user_sig_bbcode_uid' => $signature_bbcode_uid, - 'user_viewemail' => $viewemail, - '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' => $popuppm, - 'user_avatar' => $avatar_sql['data'], - 'user_avatar_type' => $avatar_sql['type'], - 'user_timezone' => (float) $user_timezone, - 'user_dateformat' => $user_dateformat, - 'user_lang' => $user_lang, - 'user_style' => $user_style, - 'user_allow_pm' => 1, - 'user_active' => $user_active, - 'user_actkey' => $user_actkey - ); - - if ($mode == 'editprofile') - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id); - - if ($config['newest_user_id'] == $user_id) - { - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . sql_quote($username) . "' - WHERE config_name = 'newest_username'"; - $db->sql_query($sql); - } - - // Update moderator cache table as appropriate - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET username = '" . sql_quote($username) . "' - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if (!$user_active) - { - // - // The users account has been deactivated, send them an email with a new activation key - // - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($config['smtp_delivery']); - - $email_headers = "From: " . $config['board_email'] . "\r\nReturn-Path: " . $config['board_email'] . "\r\n"; - - $emailer->use_template('user_activate', stripslashes($user_lang)); - $emailer->email_address($email); - $emailer->set_subject();//$user->lang['Reactivate'] - $emailer->extra_headers($email_headers); - - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'USERNAME' => $username, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), - - 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) - ); - $emailer->send(); - $emailer->reset(); - - $message = $user->lang['Profile_updated_inactive'] . '

' . sprintf($user->lang['Click_return_index'], '', ''); - } - else - { - $message = $user->lang['Profile_updated'] . '

' . sprintf($user->lang['Click_return_index'], '', ''); - } - - $template->assign_vars(array( - "META" => '') - ); - trigger_error($message); - } - else - { - $db->sql_transaction(); - - $db->sql_query_array('INSERT INTO ' . USERS_TABLE, &$sql_ary); - - $user_id = $db->sql_nextid(); - - // Place into appropriate group, either REGISTERED or INACTIVE depending on config - $group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? 'REGISTERED' : 'INACTIVE'; - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) SELECT $user_id, group_id, 0 FROM " . GROUPS_TABLE . " WHERE group_name = '$group_name'"; - $result = $db->sql_query($sql); - - if ($config['require_activation'] == USER_ACTIVATION_NONE) - { - // Sync config - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = $user_id - WHERE config_name = 'newest_user_id'"; - $db->sql_query($sql); - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '$username' - WHERE config_name = 'newest_username'"; - $db->sql_query($sql); - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = " . ($config['num_users'] + 1) . " - WHERE config_name = 'num_users'"; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - if ($coppa) - { - $message = $user->lang['COPPA']; - $email_template = 'coppa_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_SELF) - { - $message = $user->lang['Account_inactive']; - $email_template = 'user_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - $message = $user->lang['Account_inactive_admin']; - $email_template = 'admin_welcome_inactive'; - } - else - { - $message = $user->lang['Account_added']; - $email_template = 'user_welcome'; - } - - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($config['smtp_delivery']); - - $email_headers = "From: " . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; - - $emailer->use_template($email_template, stripslashes($user_lang)); - $emailer->email_address($email); - $emailer->set_subject();//sprintf($user->lang['Welcome_subject'], $config['sitename']) - $emailer->extra_headers($email_headers); - - if ($coppa) - { - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), - 'USERNAME' => $username, - 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), - - 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey, - - 'FAX_INFO' => $config['coppa_fax'], - 'MAIL_INFO' => $config['coppa_mail'], - 'EMAIL_ADDRESS' => $email, - 'ICQ' => $icq, - 'AIM' => $aim, - 'YIM' => $yim, - 'MSN' => $msn, - 'WEB_SITE' => $website, - 'FROM' => $location, - 'OCC' => $occupation, - 'INTERESTS' => $interests, - 'SITENAME' => $config['sitename'])); - } - else - { - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), - 'USERNAME' => $username, - 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), - - 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) - ); - } - - $emailer->send(); - $emailer->reset(); - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - $emailer->use_template("admin_activate", stripslashes($user_lang)); - $emailer->email_address($config['board_email']); - $emailer->set_subject(); //$user->lang['New_account_subject'] - $emailer->extra_headers($email_headers); - - $emailer->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), - - 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) - ); - $emailer->send(); - $emailer->reset(); - } - - $message = $message . '

' . sprintf($user->lang['Click_return_index'], '', ''); - - message_die(GENERAL_MESSAGE, $message); - } // if mode == register - } -} // End of submit - - -if ($error) -{ - // - // If an error occured we need to stripslashes on returned data - // - $username = stripslashes($username); - $email = stripslashes($email); - $password = ''; - $password_confirm = ''; - - $icq = stripslashes($icq); - $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)); - $signature = stripslashes($signature); - - $user_lang = stripslashes($user_lang); - $user_dateformat = stripslashes($user_dateformat); -} -else if ($mode == 'editprofile') -{ - $user_id = $user->data['user_id']; - $username = htmlspecialchars($user->data['username']); - $email = $user->data['user_email']; - $password = ''; - $password_confirm = ''; - - $icq = $user->data['user_icq']; - $aim = htmlspecialchars(str_replace('+', ' ', $user->data['user_aim'])); - $msn = htmlspecialchars($user->data['user_msnm']); - $yim = htmlspecialchars($user->data['user_yim']); - - $website = htmlspecialchars($user->data['user_website']); - $location = htmlspecialchars($user->data['user_from']); - $occupation = htmlspecialchars($user->data['user_occ']); - $interests = htmlspecialchars($user->data['user_interests']); - $signature_bbcode_uid = $user->data['user_sig_bbcode_uid']; - $signature = ($signature_bbcode_uid != '') ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $user->data['user_sig']) : $user->data['user_sig']; - - $viewemail = $user->data['user_viewemail']; - $notifypm = $user->data['user_notify_pm']; - $popuppm = $user->data['user_popup_pm']; - $notifyreply = $user->data['user_notify']; - $attachsig = $user->data['user_attachsig']; - $allowhtml = $user->data['user_allowhtml']; - $allowbbcode = $user->data['user_allowbbcode']; - $allowsmilies = $user->data['user_allowsmile']; - $allowviewonline = $user->data['user_allow_viewonline']; - - $user_style = $user->data['user_style']; - $user_lang = $user->data['user_lang']; - $user_timezone = $user->data['user_timezone']; - $user_dateformat = $user->data['user_dateformat']; -} - -// -// Default pages -// - -if ($mode == 'editprofile') -{ - if ($user_id != $user->data['user_id']) - { - $error = TRUE; - $error_msg = $user->lang['Wrong_Profile']; - } -} - - - if (!isset($coppa)) - { - $coppa = FALSE; - } - - if (!isset($user_template)) - { - $selected_template = $config['system_template']; - } - - $signature = preg_replace('/\:[0-9a-z\:]*?\]/si', ']', $signature); - - $s_hidden_fields = ''; - if($mode == 'editprofile') - { - $s_hidden_fields .= ''; - // - // Send the users current email address. If they change it, and account activation is turned on - // the user account will be disabled and the user will have to reactivate their account. - // - $s_hidden_fields .= ''; - } - - if (!empty($user_avatar_local)) - { - $s_hidden_fields .= ''; - } - - $html_status = ($user->data['user_allowhtml'] && $config['allow_html']) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF']; - $bbcode_status = ($user->data['user_allowbbcode'] && $config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF']; - $smilies_status = ($user->data['user_allowsmile'] && $config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF']; - - // - // Let's do an overall check for settings/versions which would prevent - // us from doing file uploads.... - // - $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off'|| !$config['allow_avatar_upload']) ? '' : 'enctype="multipart/form-data"'; - - $template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - 'YIM' => $yim, - 'ICQ' => $icq, - 'MSN' => $msn, - 'AIM' => $aim, - 'OCCUPATION' => $occupation, - 'INTERESTS' => $interests, - 'LOCATION' => $location, - 'WEBSITE' => $website, - 'SIGNATURE' => str_replace('
', "\n", $signature), - '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"' : '', - '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"' : '', - 'LANGUAGE_SELECT' => language_select($user_lang, 'language'), - 'STYLE_SELECT' => style_select($user_style, 'style'), - 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'), - 'DATE_FORMAT' => $user_dateformat, - 'HTML_STATUS' => $html_status, - 'BBCODE_STATUS' => sprintf($bbcode_status, '', ''), - 'SMILIES_STATUS' => $smilies_status, - - 'L_CURRENT_PASSWORD' => $user->lang['Current_password'], - 'L_NEW_PASSWORD' => ($mode == 'register') ? $user->lang['Password'] : $user->lang['New_password'], - 'L_CONFIRM_PASSWORD' => $user->lang['Confirm_password'], - 'L_CONFIRM_PASSWORD_EXPLAIN' => ($mode == 'editprofile') ? $user->lang['Confirm_password_explain'] : '', - 'L_PASSWORD_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_if_changed'] : '', - 'L_PASSWORD_CONFIRM_IF_CHANGED' => ($mode == 'editprofile') ? $user->lang['password_confirm_if_changed'] : '', - 'L_SUBMIT' => $user->lang['Submit'], - 'L_RESET' => $user->lang['Reset'], - 'L_ICQ_NUMBER' => $user->lang['ICQ'], - 'L_MESSENGER' => $user->lang['MSNM'], - 'L_YAHOO' => $user->lang['YIM'], - 'L_WEBSITE' => $user->lang['Website'], - 'L_AIM' => $user->lang['AIM'], - 'L_LOCATION' => $user->lang['Location'], - 'L_OCCUPATION' => $user->lang['Occupation'], - 'L_BOARD_LANGUAGE' => $user->lang['Board_lang'], - 'L_BOARD_STYLE' => $user->lang['Board_style'], - 'L_TIMEZONE' => $user->lang['Timezone'], - 'L_DATE_FORMAT' => $user->lang['Date_format'], - 'L_DATE_FORMAT_EXPLAIN' => $user->lang['Date_format_explain'], - 'L_YES' => $user->lang['Yes'], - 'L_NO' => $user->lang['No'], - 'L_INTERESTS' => $user->lang['Interests'], - 'L_ALWAYS_ALLOW_SMILIES' => $user->lang['Always_smile'], - 'L_ALWAYS_ALLOW_BBCODE' => $user->lang['Always_bbcode'], - 'L_ALWAYS_ALLOW_HTML' => $user->lang['Always_html'], - 'L_HIDE_USER' => $user->lang['Hide_user'], - 'L_ALWAYS_ADD_SIGNATURE' => $user->lang['Always_add_sig'], - - 'L_SIGNATURE' => $user->lang['Signature'], - 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['Signature_explain'], $config['max_sig_chars']), - 'L_NOTIFY_ON_REPLY' => $user->lang['Always_notify'], - 'L_NOTIFY_ON_REPLY_EXPLAIN' => $user->lang['Always_notify_explain'], - 'L_NOTIFY_ON_PRIVMSG' => $user->lang['Notify_on_privmsg'], - 'L_POPUP_ON_PRIVMSG' => $user->lang['Popup_on_privmsg'], - 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $user->lang['Popup_on_privmsg_explain'], - 'L_PREFERENCES' => $user->lang['Preferences'], - 'L_PUBLIC_VIEW_EMAIL' => $user->lang['Public_view_email'], - 'L_ITEMS_REQUIRED' => $user->lang['Items_required'], - 'L_REGISTRATION_INFO' => $user->lang['Registration_info'], - 'L_PROFILE_INFO' => $user->lang['Profile_info'], - 'L_PROFILE_INFO_NOTICE' => $user->lang['Profile_info_warn'], - 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], - - 'S_PROFILE_EDIT' => ($mode == 'editprofile') ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORM_ENCTYPE' => $form_enctype, - 'S_PROFILE_ACTION' => "profile.$phpEx$SID") - ); - -// -// -include($phpbb_root_path . 'includes/page_header.'.$phpEx); - -$template->set_filenames(array( - 'body' => 'profile_add_body.html') -); -make_jumpbox('viewforum.'.$phpEx); - -include($phpbb_root_path . 'includes/page_tail.'.$phpEx); - -?> \ No newline at end of file diff --git a/phpBB/includes/usercp_sendpasswd.php b/phpBB/includes/usercp_sendpasswd.php deleted file mode 100644 index a59590ad97..0000000000 --- a/phpBB/includes/usercp_sendpasswd.php +++ /dev/null @@ -1,134 +0,0 @@ -sql_query($sql) ) - { - if ( $row = $db->sql_fetchrow($result) ) - { - if ( !$row['user_active'] ) - { - message_die(GENERAL_MESSAGE, $lang['No_send_account_inactive']); - } - - $username = $row['username']; - - $user_actkey = gen_rand_string(true); - $key_len = 54 - strlen($server_url); - $key_len = ( $str_len > 6 ) ? $key_len : 6; - $user_actkey = substr($user_actkey, 0, $key_len); - $user_password = gen_rand_string(false); - - $sql = "UPDATE " . USERS_TABLE . " - SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey' - WHERE user_id = " . $row['user_id']; - if ( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not update new password information', '', __LINE__, __FILE__, $sql); - } - - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($config['smtp_delivery']); - - $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; - - $emailer->use_template('user_activate_passwd', $row['user_lang']); - $emailer->email_address($row['user_email']); - $emailer->set_subject();//$lang['New_password_activation'] - $emailer->extra_headers($email_headers); - - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'USERNAME' => $username, - 'PASSWORD' => $user_password, - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $config['board_email_sig']), - - 'U_ACTIVATE' => $server_url . "?mode=activate&act_key=$user_actkey") - ); - $emailer->send(); - $emailer->reset(); - - $template->assign_vars(array( - 'META' => '') - ); - - $message = $lang['Password_updated'] . '

' . sprintf($lang['Click_return_index'], '', ''); - - message_die(GENERAL_MESSAGE, $message); - } - else - { - message_die(GENERAL_MESSAGE, $lang['No_email_match']); - } - } - else - { - message_die(GENERAL_ERROR, 'Could not obtain user information for sendpassword', '', __LINE__, __FILE__, $sql); - } -} -else -{ - $username = ''; - $email = ''; -} - -// -// Output basic page -// -include($phpbb_root_path . 'includes/page_header.'.$phpEx); - -$template->set_filenames(array( - 'body' => 'profile_send_pass.tpl') -); -make_jumpbox('viewforum.'.$phpEx); - -$template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - - 'L_SEND_PASSWORD' => $lang['Send_password'], - 'L_ITEMS_REQUIRED' => $lang['Items_required'], - 'L_EMAIL_ADDRESS' => $lang['Email_address'], - 'L_SUBMIT' => $lang['Submit'], - 'L_RESET' => $lang['Reset']) -); - -$template->pparse('body'); - -include($phpbb_root_path . 'includes/page_tail.'.$phpEx); - -?> diff --git a/phpBB/includes/usercp_viewprofile.php b/phpBB/includes/usercp_viewprofile.php deleted file mode 100644 index 348ce42ed9..0000000000 --- a/phpBB/includes/usercp_viewprofile.php +++ /dev/null @@ -1,240 +0,0 @@ -lang['No_user_id_specified']); -} -$profiledata = get_userdata(intval($_GET['u'])); - -$sql = "SELECT * - FROM " . RANKS_TABLE . " - ORDER BY rank_special, rank_min"; -$result = $db->sql_query($sql); - -while ( $row = $db->sql_fetchrow($result) ) -{ - $ranksrow[] = $row; -} -$db->sql_freeresult($result); - -// -// Output page header and profile_view template -// -$template->set_filenames(array( - 'body' => 'profile_view_body.html') -); -make_jumpbox('viewforum.'.$phpEx); - -// -// Calculate the number of days this user has been a member ($memberdays) -// Then calculate their posts per day -// -$regdate = $profiledata['user_regdate']; -$memberdays = max(1, round( ( time() - $regdate ) / 86400 )); -$posts_per_day = $profiledata['user_posts'] / $memberdays; - -// Get the users percentage of total posts -if ( $profiledata['user_posts'] ) -{ - $sql = "SELECT SUM(forum_posts) AS total - FROM " . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $total_posts = ($row = $db->sql_fetchrow($result)) ? $row['total'] : 0; - $db->sql_freeresult($result); - - $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0; -} -else -{ - $percentage = 0; -} - -$avatar_img = ''; -if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] ) -{ - switch( $profiledata['user_avatar_type'] ) - { - case USER_AVATAR_UPLOAD: - $avatar_img = ( $config['allow_avatar_upload'] ) ? '' : ''; - break; - case USER_AVATAR_REMOTE: - $avatar_img = ( $config['allow_avatar_remote'] ) ? '' : ''; - break; - case USER_AVATAR_GALLERY: - $avatar_img = ( $config['allow_avatar_local'] ) ? '' : ''; - break; - } -} - -$poster_rank = ''; -$rank_image = ''; -if ( $profiledata['user_rank'] ) -{ - for($i = 0; $i < count($ranksrow); $i++) - { - if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] ) - { - $poster_rank = $ranksrow[$i]['rank_title']; - $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '' . $poster_rank . '
' : ''; - } - } -} -else -{ - for($i = 0; $i < count($ranksrow); $i++) - { - if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] ) - { - $poster_rank = $ranksrow[$i]['rank_title']; - $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '' . $poster_rank . '
' : ''; - } - } -} - -if ( $profiledata['user_viewemail'] || $auth->acl_get('a_') ) -{ - $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; - - $email_img = '' . $user->img('icon_email', $user->lang['Send_email']) . ''; - $email = '' . $user->lang['Send_email'] . ''; -} -else -{ - $email_img = ' '; - $email = ' '; -} - -$temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; -$profile_img = '' . $user->img('icon_profile', $user->lang['Read_profile']) . ''; -$profile = '' . $user->lang['Read_profile'] . ''; - -$temp_url = "privmsg.$phpEx$SID&mode=post&u=$user_id"; -$pm_img = '' . $user->img('icon_pm', $user->lang['Send_private_message']) . ''; -$pm = '' . $user->lang['Send_private_message'] . ''; - -$www_img = ( $profiledata['user_website'] ) ? '' . $user->img('icon_www', $user->lang['Visit_website']) . '' : ''; -$www = ( $profiledata['user_website'] ) ? '' . $user->lang['Visit_website'] . '' : ''; - -if ( !empty($profiledata['user_icq']) ) -{ - $icq_status_img = ''; - $icq_img = '' . $user->img('icon_icq', $user->lang['ICQ']) . ''; - $icq = '' . $user->lang['ICQ'] . ''; -} -else -{ - $icq_status_img = ''; - $icq_img = ''; - $icq = ''; -} - -$aim_img = ( $profiledata['user_aim'] ) ? '' . $user->img('icon_aim', $user->lang['AIM']) . '' : ''; -$aim = ( $profiledata['user_aim'] ) ? '' . $user->lang['AIM'] . '' : ''; - -$temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$user_id"; -$msn_img = ( $profiledata['user_msnm'] ) ? '' . $user->img('icon_msnm', $user->lang['MSNM']) . '' : ''; -$msn = ( $profiledata['user_msnm'] ) ? '' . $user->lang['MSNM'] . '' : ''; - -$yim_img = ( $profiledata['user_yim'] ) ? '' . $user->img('icon_yim', $user->lang['YIM']) . '' : ''; -$yim = ( $profiledata['user_yim'] ) ? '' . $user->lang['YIM'] . '' : ''; - -$temp_url = "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']) . "&showresults=posts"; -$search_img = '' . $user->img('icon_search', $user->lang['Search_user_posts']) . ''; -$search = '' . $user->lang['Search_user_posts'] . ''; - -// -// Generate page -// -$page_title = $user->lang['Viewing_profile']; -include($phpbb_root_path . 'includes/page_header.'.$phpEx); - -$template->assign_vars(array( - 'USERNAME' => $profiledata['username'], - 'JOINED' => $user->format_date($profiledata['user_regdate'], $user->lang['DATE_FORMAT']), - 'POSTER_RANK' => $poster_rank, - 'RANK_IMAGE' => $rank_image, - 'POSTS_PER_DAY' => $posts_per_day, - 'POSTS' => $profiledata['user_posts'], - 'PERCENTAGE' => $percentage . '%', - 'POST_DAY_STATS' => sprintf($user->lang['User_post_day_stats'], $posts_per_day), - 'POST_PERCENT_STATS' => sprintf($user->lang['User_post_pct_stats'], $percentage), - - 'SEARCH_IMG' => $search_img, - 'SEARCH' => $search, - 'PM_IMG' => $pm_img, - 'PM' => $pm, - 'EMAIL_IMG' => $email_img, - 'EMAIL' => $email, - 'WWW_IMG' => $www_img, - 'WWW' => $www, - 'ICQ_STATUS_IMG' => $icq_status_img, - 'ICQ_IMG' => $icq_img, - 'ICQ' => $icq, - 'AIM_IMG' => $aim_img, - 'AIM' => $aim, - 'MSN_IMG' => $msn_img, - 'MSN' => $msn, - 'YIM_IMG' => $yim_img, - 'YIM' => $yim, - - 'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ', - 'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ', - 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ', - 'AVATAR_IMG' => $avatar_img, - - 'L_VIEWING_PROFILE' => sprintf($user->lang['Viewing_user_profile'], $profiledata['username']), - 'L_ABOUT_USER' => sprintf($user->lang['About_user'], $profiledata['username']), - 'L_AVATAR' => $user->lang['Avatar'], - 'L_POSTER_RANK' => $user->lang['Poster_rank'], - 'L_JOINED' => $user->lang['Joined'], - 'L_TOTAL_POSTS' => $user->lang['Total_posts'], - 'L_SEARCH_USER_POSTS' => sprintf($user->lang['Search_user_posts'], $profiledata['username']), - 'L_CONTACT' => $user->lang['Contact'], - 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], - 'L_EMAIL' => $user->lang['Email'], - 'L_PM' => $user->lang['Private_Message'], - 'L_ICQ_NUMBER' => $user->lang['ICQ'], - 'L_YAHOO' => $user->lang['YIM'], - 'L_AIM' => $user->lang['AIM'], - 'L_MESSENGER' => $user->lang['MSNM'], - 'L_WEBSITE' => $user->lang['Website'], - 'L_LOCATION' => $user->lang['Location'], - 'L_OCCUPATION' => $user->lang['Occupation'], - 'L_INTERESTS' => $user->lang['Interests'], - - 'U_SEARCH_USER' => "search.$phpEx$SID&search_author=" . urlencode($profiledata['username']), - - 'S_PROFILE_ACTION' => "profile.$phpEx$SID") -); - -include($phpbb_root_path . 'includes/page_tail.'.$phpEx); - -?> \ No newline at end of file -- cgit v1.2.1