]> scripts.mit.edu Git - autoinstalls/phpBB.git/blob - profile.php
phpBB 2.0.19-scripts
[autoinstalls/phpBB.git] / profile.php
1 <?php
2 /***************************************************************************
3  *                                profile.php
4  *                            -------------------
5  *   begin                : Saturday, Feb 13, 2001
6  *   copyright            : (C) 2001 The phpBB Group
7  *   email                : support@phpbb.com
8  *
9  *   $Id: profile.php,v 1.193.2.5 2004/11/18 17:49:37 acydburn Exp $
10  *
11  *
12  ***************************************************************************/
13
14 /***************************************************************************
15  *
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.
20  *
21  ***************************************************************************/
22
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
27
28 //
29 // Start session management
30 //
31 $userdata = session_pagestart($user_ip, PAGE_PROFILE);
32 init_userprefs($userdata);
33 //
34 // End session management
35 //
36
37 // session id check
38 if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
39 {
40         $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
41 }
42 else
43 {
44         $sid = '';
45 }
46
47 //
48 // Set default email variables
49 //
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']) . '/' : '/';
55
56 $server_url = $server_protocol . $server_name . $server_port . $script_name;
57
58 // -----------------------
59 // Page specific functions
60 //
61 function gen_rand_string($hash)
62 {
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');
64         
65         $max_chars = count($chars) - 1;
66         srand( (double) microtime()*1000000);
67         
68         $rand_str = '';
69         for($i = 0; $i < 8; $i++)
70         {
71                 $rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
72         }
73
74         return ( $hash ) ? md5($rand_str) : $rand_str;
75 }
76 //
77 // End page specific functions
78 // ---------------------------
79
80 //
81 // Start of program proper
82 //
83 if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
84 {
85         $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
86         $mode = htmlspecialchars($mode);
87
88         if ( $mode == 'viewprofile' )
89         {
90                 include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
91                 exit;
92         }
93         else if ( $mode == 'editprofile' || $mode == 'register' )
94         {
95                 if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
96                 {
97                         redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
98                 }
99
100                 include($phpbb_root_path . 'includes/usercp_register.'.$phpEx);
101                 exit;
102         }
103         else if ( $mode == 'confirm' )
104         {
105                 // Visual Confirmation
106                 if ( $userdata['session_logged_in'] )
107                 {
108                         exit;
109                 }
110
111                 include($phpbb_root_path . 'includes/usercp_confirm.'.$phpEx);
112                 exit;
113         }
114         else if ( $mode == 'sendpassword' )
115         {
116                 include($phpbb_root_path . 'includes/usercp_sendpasswd.'.$phpEx);
117                 exit;
118         }
119         else if ( $mode == 'activate' )
120         {
121                 include($phpbb_root_path . 'includes/usercp_activate.'.$phpEx);
122                 exit;
123         }
124         else if ( $mode == 'email' )
125         {
126                 include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
127                 exit;
128         }
129 }
130
131 redirect(append_sid("index.$phpEx", true));
132
133 ?>