diff --git a/phpBB/includes/usercp_activate.php b/phpBB/includes/usercp_activate.php new file mode 100644 index 0000000000..9c94747e46 --- /dev/null +++ b/phpBB/includes/usercp_activate.php @@ -0,0 +1,96 @@ +sql_query($sql) ) +{ + if ( $row = $db->sql_fetchrow($result) ) + { + $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) ) + { + if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '' ) + { + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($board_config['smtp_delivery']); + + $email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\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" => $board_config['sitename'], + "USERNAME" => $username, + "PASSWORD" => $password_confirm, + "EMAIL_SIG" => str_replace("
", "\n", "-- \n" . $board_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_ERROR, "Couldn't update users table", "", __LINE__, __FILE__, $sql_update); + } + } + else + { + message_die(GENERAL_ERROR, $lang['Wrong_activation']); //wrongactiv + } +} +else +{ + message_die(GENERAL_ERROR, "Couldn't obtain user information", "", __LINE__, __FILE__, $sql); +} + +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_avatar.php b/phpBB/includes/usercp_avatar.php new file mode 100644 index 0000000000..385316dbff --- /dev/null +++ b/phpBB/includes/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 $board_config, $userdata; + + if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' ) + { + if ( @file_exists('./' . $board_config['avatar_path'] . '/' . $avatar_file) ) + { + @unlink('./' . $board_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, $user_id, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype) +{ + global $board_config, $db, $lang, $images; + + $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, $board_config['avatar_filesize']); + } + @fclose($fsock); + + if ( !preg_match('/Content-Length\: ([0-9]+)[^\/ ][\s]+/i', $avatar_data, $file_data1) || !preg_match('/Content-Type\: image\/[x\-]*([a-z]+)[\s]+/i', $avatar_data, $file_data2) ) + { + $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 < $board_config['avatar_filesize'] ) + { + $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize); + + $tmp_path = ( !$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['avatar_path'] . "/tmp"; + $tmp_filename = tempnam($tmp_path, $userdata['user_id'] . '-'); + + $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($board_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 <= $board_config['avatar_filesize'] && $avatar_filesize > 0 ) + { + // + // Opera appends the image name after the type, not big, not clever! + // + preg_match("'image\/[x\-]*([a-z]+)'", $avatar_filetype, $avatar_filetype); + $avatar_filetype = $avatar_filetype[1]; + } + else + { + $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024)); + + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; + return; + } + } + + if ( !($imgtype = check_image_type($avatar_filetype, $error, $error_msg)) ) + { + return; + } + + if ( $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] ) + { + $new_filename = $user_id . $imgtype; + + if ( $mode == 'editprofile' && $userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $userdata['user_avatar'] != '') + { + if ( file_exists('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']) ) + { + @unlink('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']); + } + } + + if( $avatar_mode == 'remote' ) + { + @copy($tmp_filename, './' . $board_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, './' . $board_config['avatar_path'] . "/$new_filename"); + } + + @chmod('./' . $board_config['avatar_path'] . "/$new_filename", 0777); + + $avatar_sql = ( $mode == 'editprofile' ) ? ", user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD : "'$avatar_filename', " . USER_AVATAR_UPLOAD; + } + else + { + $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']); + + $error = true; + $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $l_avatar_size : $l_avatar_size; + } + + return $avatar_sql; +} + +function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) +{ + global $board_config, $db, $template, $lang, $images, $theme; + global $phpbb_root_path, $phpEx; + + $dir = @opendir($board_config['avatar_gallery_path']); + + $avatar_images = array(); + while( $file = @readdir($dir) ) + { + if( $file != '.' && $file != '..' && !is_file($board_config['avatar_gallery_path'] . '/' . $file) && !is_link($board_config['avatar_gallery_path'] . '/' . $file) ) + { + $sub_dir = @opendir($board_config['avatar_gallery_path'] . '/' . $file); + + $avatar_row_count = 0; + $avatar_col_count = 0; + while( $sub_file = @readdir($sub_dir) ) + { + if( preg_match('/(\.gif$|\.png$|\.jpg|\.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 = ''; + while( list($key) = each($avatar_images) ) + { + $selected = ( $key == $category ) ? ' selected="selected"' : ''; + if( count($avatar_images[$key]) ) + { + $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" => $board_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', '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_OPTIONS_CATEGORIES' => $s_categories, + 'S_COLSPAN' => $s_colspan, + 'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=$mode"), + 'S_HIDDEN_FIELDS' => $s_hidden_vars) + ); + + return; +} + +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_email.php b/phpBB/includes/usercp_email.php new file mode 100644 index 0000000000..30facb7324 --- /dev/null +++ b/phpBB/includes/usercp_email.php @@ -0,0 +1,204 @@ +sql_query($sql) ) +{ + $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'] < $board_config['flood_interval'] ) + { + message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']); + } + + if ( isset($HTTP_POST_VARS['submit']) ) + { + $error = FALSE; + + if ( !empty($HTTP_POST_VARS['subject']) ) + { + $subject = trim(strip_tags(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(strip_tags(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']; + if ( $result = $db->sql_query($sql) ) + { + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($board_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 - " . decode_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' => $board_config['sitename'], + 'BOARD_EMAIL' => $board_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(GENERAL_MESSAGE, $message); + } + else + { + message_die(GENERAL_ERROR, 'Could not update last email time', '', __LINE__, __FILE__, $sql); + } + } + } + + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'body' => 'profile_send_email.tpl', + 'jumpbox' => 'jumpbox.tpl') + ); + + $jumpbox = make_jumpbox(); + $template->assign_vars(array( + 'L_GO' => $lang['Go'], + 'L_JUMP_TO' => $lang['Jump_to'], + 'L_SELECT_FORUM' => $lang['Select_forum'], + + 'S_JUMPBOX_LIST' => $jumpbox, + 'S_JUMPBOX_ACTION' => append_sid("viewforum.$phpEx")) + ); + $template->assign_var_from_handle('JUMPBOX', 'jumpbox'); + + if ( $error ) + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } + + if ( $userdata['user_sig'] != '' ) + { + $template->assign_block_vars('signature_checkbox', array()); + } + + $template->assign_vars(array( + 'USERNAME' => $username, + + 'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', + 'S_POST_ACTION' => append_sid("profile.$phpEx?&mode=email&" . POST_USERS_URL . "=$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_OPTIONS' => $lang['Options'], + 'L_CC_EMAIL' => $lang['CC_email'], + 'L_NOTIFY_ON_REPLY' => $lang['Notify'], + 'L_SPELLCHECK' => $lang['Spellcheck'], + 'L_SEND_EMAIL' => $lang['Send_email']) + ); + + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + } + else + { + message_die(GENERAL_MESSAGE, $lang['User_prevent_email']); + } +} +else +{ + message_die(GENERAL_MESSAGE, $lang['User_not_exist']); +} + +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_sendpasswd.php b/phpBB/includes/usercp_sendpasswd.php new file mode 100644 index 0000000000..f38e4169c4 --- /dev/null +++ b/phpBB/includes/usercp_sendpasswd.php @@ -0,0 +1,204 @@ +sql_query($sql) ) +{ + $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'] < $board_config['flood_interval'] ) + { + message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']); + } + + if ( isset($HTTP_POST_VARS['submit']) ) + { + $error = FALSE; + + if ( !empty($HTTP_POST_VARS['subject']) ) + { + $subject = trim(strip_tags(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(strip_tags(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']; + if ( $result = $db->sql_query($sql) ) + { + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($board_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 - " . decode_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" => $board_config['sitename'], + "BOARD_EMAIL" => $board_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(GENERAL_MESSAGE, $message); + } + else + { + message_die(GENERAL_ERROR, "Couldn't update last email time", "", __LINE__, __FILE__, $sql); + } + } + } + + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + "body" => "profile_send_email.tpl", + "jumpbox" => "jumpbox.tpl") + ); + + $jumpbox = make_jumpbox(); + $template->assign_vars(array( + "L_GO" => $lang['Go'], + "L_JUMP_TO" => $lang['Jump_to'], + "L_SELECT_FORUM" => $lang['Select_forum'], + + "S_JUMPBOX_LIST" => $jumpbox, + "S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx")) + ); + $template->assign_var_from_handle("JUMPBOX", "jumpbox"); + + if ( $error ) + { + $template->set_filenames(array( + "reg_header" => "error_body.tpl") + ); + $template->assign_vars(array( + "ERROR_MESSAGE" => $error_msg) + ); + $template->assign_var_from_handle("ERROR_BOX", "reg_header"); + } + + if ( $userdata['user_sig'] != "" ) + { + $template->assign_block_vars("signature_checkbox", array()); + } + + $template->assign_vars(array( + "USERNAME" => $username, + + "S_SIGNATURE_CHECKED" => ( $attach_sig ) ? 'checked="checked"' : '', + "S_POST_ACTION" => append_sid("profile.$phpEx?&mode=email&" . POST_USERS_URL . "=$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_OPTIONS" => $lang['Options'], + "L_CC_EMAIL" => $lang['CC_email'], + "L_NOTIFY_ON_REPLY" => $lang['Notify'], + "L_SPELLCHECK" => $lang['Spellcheck'], + "L_SEND_EMAIL" => $lang['Send_email']) + ); + + $template->pparse("body"); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + } + else + { + message_die(GENERAL_MESSAGE, $lang['User_prevent_email']); + } +} +else +{ + message_die(GENERAL_MESSAGE, $lang['User_not_exist']); +} + +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_viewprofile.php b/phpBB/includes/usercp_viewprofile.php new file mode 100644 index 0000000000..0be6e5feef --- /dev/null +++ b/phpBB/includes/usercp_viewprofile.php @@ -0,0 +1,233 @@ +sql_query($sql)) ) +{ + message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $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.tpl', + 'jumpbox' => 'jumpbox.tpl') +); + +$jumpbox = make_jumpbox(); +$template->assign_vars(array( + 'L_GO' => $lang['Go'], + 'L_JUMP_TO' => $lang['Jump_to'], + 'L_SELECT_FORUM' => $lang['Select_forum'], + + 'S_JUMPBOX_LIST' => $jumpbox, + 'S_JUMPBOX_ACTION' => append_sid("viewforum.$phpEx")) +); +$template->assign_var_from_handle('JUMPBOX', 'jumpbox'); + +// +// 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'] != 0 ) +{ + $total_posts = get_db_stat('postcount'); + $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0; +} +else +{ + $percentage = 0; +} + +if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN ) +{ + $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL . "=" . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email']; + + $email = '' . $lang['Send_email'] . ''; + $email_img = '' . $lang['Send_email'] . ''; +} +else +{ + $email = ''; + $email_img = ''; +} + +$avatar_img = ''; +if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] ) +{ + switch( $profiledata['user_avatar_type'] ) + { + case USER_AVATAR_UPLOAD: + $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '' : ''; + break; + case USER_AVATAR_REMOTE: + $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '' : ''; + break; + case USER_AVATAR_GALLERY: + $avatar_img = ( $board_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 ( !empty($profiledata['user_icq']) ) +{ + $icq_status_img = ''; + $icq_add_img = '' . $lang['ICQ'] . ''; +} +else +{ + $icq_status_img = ' '; + $icq_add_img = ' '; +} + +$aim_img = ( $profiledata['user_aim'] ) ? '' . $lang['AIM'] . '' : ' '; + +$msnm_img = ( $profiledata['user_msnm'] ) ? '' . $lang['MSNM'] . ' ' . $profiledata['user_msnm'] : ' '; + +$yim_img = ( $profiledata['user_yim'] ) ? '' . $lang['YIM'] . '' : ' '; + +$search_img = '' . $lang['Search_user_posts'] . ''; +$search = '' . $lang['Search_user_posts'] . ''; + +$www_img = ( $profiledata['user_website'] ) ? '' . $lang['Visit_website'] . '' : ' '; + +$pm_img = '' . $lang['Send_private_message'] . ''; + +// +// Generate page +// +$page_title = $lang['Viewing_profile']; +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +$template->assign_vars(array( + 'USERNAME' => $profiledata['username'], + 'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']), + 'POSTER_RANK' => $poster_rank, + 'RANK_IMAGE' => $rank_image, + 'POSTS_PER_DAY' => $posts_per_day, + 'POSTS' => $profiledata['user_posts'], + 'PERCENTAGE' => $percentage . '%', + 'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day), + 'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage), + 'EMAIL' => $email, + 'EMAIL_IMG' => $email_img, + 'PM_IMG' => $pm_img, + 'UL_SEARCH' => $search, + 'SEARCH_IMG' => $search_img, + 'ICQ' => ( $profiledata['user_icq'] ) ? $profiledata['user_icq'] : ' ', + 'ICQ_IMG' => ( $profiledata['user_icq'] ) ? $images['icon_icq'] : ' ', + 'ICQ_ADD_IMG' => $icq_add_img, + 'ICQ_STATUS_IMG' => $icq_status_img, + 'AIM' => ( $profiledata['user_aim'] ) ? '' . $profiledata['user_aim'] . '' : ' ', + 'AIM_IMG' => $aim_img, + 'MSN' => ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : ' ', + 'MSN_IMG' => $msnm_img, + 'YIM' => ( $profiledata['user_yim'] ) ? '' . $profiledata['user_yim'] . '' : ' ', + 'YIM_IMG' => $yim_img, + 'WEBSITE' => ( $profiledata['user_website'] ) ? '' . $profiledata['user_website'] . '' : ' ', + 'WEBSITE_IMG' => $www_img, + '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($lang['Viewing_user_profile'], $profiledata['username']), + 'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']), + 'L_AVATAR' => $lang['Avatar'], + 'L_POSTER_RANK' => $lang['Poster_rank'], + 'L_TOTAL_POSTS' => $lang['Total_posts'], + 'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']), + 'L_CONTACT' => $lang['Contact'], + 'L_EMAIL_ADDRESS' => $lang['Email_address'], + 'L_EMAIL' => $lang['Email'], + 'L_PM' => $lang['Private_Message'], + 'L_ICQ_NUMBER' => $lang['ICQ'], + 'L_YAHOO' => $lang['YIM'], + 'L_AIM' => $lang['AIM'], + 'L_MESSENGER' => $lang['MSNM'], + 'L_WEBSITE' => $lang['Website'], + 'L_LOCATION' => $lang['Location'], + 'L_OCCUPATION' => $lang['Occupation'], + 'L_INTERESTS' => $lang['Interests'], + + 'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username'])), + + 'S_PROFILE_ACTION' => append_sid("profile.$phpEx")) +); + +$template->pparse('body'); + +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + +?> \ No newline at end of file