2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: profile.php,v 1.193.2.5 2004/11/18 17:49:37 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 ***************************************************************************/
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
29 // Start session management
31 $userdata = session_pagestart($user_ip, PAGE_PROFILE);
32 init_userprefs($userdata);
34 // End session management
38 if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
40 $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
48 // Set default email variables
50 $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
51 $script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx;
52 $server_name = trim($board_config['server_name']);
53 $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
54 $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
56 $server_url = $server_protocol . $server_name . $server_port . $script_name;
58 // -----------------------
59 // Page specific functions
61 function gen_rand_string($hash)
63 $chars = array( 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
65 $max_chars = count($chars) - 1;
66 srand( (double) microtime()*1000000);
69 for($i = 0; $i < 8; $i++)
71 $rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
74 return ( $hash ) ? md5($rand_str) : $rand_str;
77 // End page specific functions
78 // ---------------------------
81 // Start of program proper
83 if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
85 $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
86 $mode = htmlspecialchars($mode);
88 if ( $mode == 'viewprofile' )
90 include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
93 else if ( $mode == 'editprofile' || $mode == 'register' )
95 if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
97 redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
100 include($phpbb_root_path . 'includes/usercp_register.'.$phpEx);
103 else if ( $mode == 'confirm' )
105 // Visual Confirmation
106 if ( $userdata['session_logged_in'] )
111 include($phpbb_root_path . 'includes/usercp_confirm.'.$phpEx);
114 else if ( $mode == 'sendpassword' )
116 include($phpbb_root_path . 'includes/usercp_sendpasswd.'.$phpEx);
119 else if ( $mode == 'activate' )
121 include($phpbb_root_path . 'includes/usercp_activate.'.$phpEx);
124 else if ( $mode == 'email' )
126 include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
131 redirect(append_sid("index.$phpEx", true));