2004-08-02 14:32:04 +00:00
< ? php
2005-04-09 12:26:45 +00:00
/**
*
* @ package ucp
* @ version $Id $
* @ copyright ( c ) 2005 phpBB Group
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
*
*/
/**
2006-05-05 17:56:33 +00:00
* @ ignore
2005-04-09 12:26:45 +00:00
*/
2002-03-18 13:35:43 +00:00
define ( 'IN_PHPBB' , true );
$phpbb_root_path = './' ;
2003-09-07 13:46:51 +00:00
$phpEx = substr ( strrchr ( __FILE__ , '.' ), 1 );
2006-06-06 20:53:46 +00:00
require ( $phpbb_root_path . 'common.' . $phpEx );
require ( $phpbb_root_path . 'includes/functions_user.' . $phpEx );
require ( $phpbb_root_path . 'includes/functions_module.' . $phpEx );
2004-08-02 14:32:04 +00:00
// Basic parameter data
2005-10-04 21:31:35 +00:00
$id = request_var ( 'i' , '' );
2004-08-02 14:32:04 +00:00
$mode = request_var ( 'mode' , '' );
if ( $mode == 'login' || $mode == 'logout' )
2004-06-01 17:02:20 +00:00
{
define ( 'IN_LOGIN' , true );
}
2004-08-02 14:32:04 +00:00
// Start session management
2005-10-04 21:31:35 +00:00
$user -> session_begin ();
2004-08-02 14:32:04 +00:00
$auth -> acl ( $user -> data );
$user -> setup ( 'ucp' );
2006-06-19 21:30:32 +00:00
// Setting a variable to let the style designer know where he is...
$template -> assign_var ( 'S_IN_UCP' , true );
2005-10-04 21:31:35 +00:00
$module = new p_master ();
2003-05-10 17:19:27 +00:00
2003-05-19 15:24:14 +00:00
// Basic "global" modes
2003-05-10 17:19:27 +00:00
switch ( $mode )
2001-10-10 17:27:34 +00:00
{
2003-05-10 17:19:27 +00:00
case 'activate' :
2005-10-04 21:31:35 +00:00
$module -> load ( 'ucp' , 'activate' );
$module -> display ( $user -> lang [ 'UCP_ACTIVATE' ]);
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2005-10-04 21:31:35 +00:00
break ;
2003-03-17 00:53:38 +00:00
2005-04-09 12:26:45 +00:00
case 'resend_act' :
2005-10-04 21:31:35 +00:00
$module -> load ( 'ucp' , 'resend' );
$module -> display ( $user -> lang [ 'UCP_RESEND' ]);
break ;
2005-04-09 12:26:45 +00:00
2003-10-12 15:29:18 +00:00
case 'sendpassword' :
2005-10-04 21:31:35 +00:00
$module -> load ( 'ucp' , 'remind' );
$module -> display ( $user -> lang [ 'UCP_REMIND' ]);
break ;
2003-05-19 15:24:14 +00:00
2003-05-10 17:19:27 +00:00
case 'register' :
2005-04-10 18:07:12 +00:00
if ( $user -> data [ 'is_registered' ] || isset ( $_REQUEST [ 'not_agreed' ]))
2003-05-10 17:19:27 +00:00
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2003-05-10 17:19:27 +00:00
}
2003-03-17 00:53:38 +00:00
2005-10-04 21:31:35 +00:00
$module -> load ( 'ucp' , 'register' );
2005-12-26 21:02:39 +00:00
$module -> display ( $user -> lang [ 'REGISTER' ]);
2005-10-04 21:31:35 +00:00
break ;
2003-03-17 00:53:38 +00:00
2003-05-19 15:24:14 +00:00
case 'confirm' :
2005-10-04 21:31:35 +00:00
$module -> load ( 'ucp' , 'confirm' );
exit ;
break ;
2003-05-19 15:24:14 +00:00
2003-05-10 17:19:27 +00:00
case 'login' :
2005-04-10 18:07:12 +00:00
if ( $user -> data [ 'is_registered' ])
2003-05-10 17:19:27 +00:00
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2003-05-10 17:19:27 +00:00
}
2003-03-17 00:53:38 +00:00
2006-05-04 18:25:01 +00:00
login_box ( " index. $phpEx " );
2006-01-25 21:01:52 +00:00
break ;
2003-05-10 17:19:27 +00:00
case 'logout' :
if ( $user -> data [ 'user_id' ] != ANONYMOUS )
{
2005-07-04 16:54:34 +00:00
$user -> session_kill ();
2006-01-05 21:24:22 +00:00
$user -> session_begin ();
2003-05-10 17:19:27 +00:00
}
2006-06-06 20:53:46 +00:00
meta_refresh ( 3 , append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2004-01-30 11:48:02 +00:00
2006-06-06 20:53:46 +00:00
$message = $user -> lang [ 'LOGOUT_REDIRECT' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_INDEX' ], '<a href="' . append_sid ( " { $phpbb_root_path } index. $phpEx " ) . '">' , '</a> ' );
2004-01-30 11:48:02 +00:00
trigger_error ( $message );
2006-01-25 21:01:52 +00:00
break ;
2004-05-31 18:00:10 +00:00
2006-03-18 12:17:22 +00:00
case 'terms' :
case 'privacy' :
$message = ( $mode == 'terms' ) ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY' ;
$title = ( $mode == 'terms' ) ? 'TERMS_USE' : 'PRIVACY' ;
if ( empty ( $user -> lang [ $message ]))
{
if ( $user -> data [ 'is_registered' ])
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2006-03-18 12:17:22 +00:00
}
2006-06-06 20:53:46 +00:00
2006-05-04 18:25:01 +00:00
login_box ();
2006-03-18 12:17:22 +00:00
}
$template -> set_filenames ( array (
'body' => 'ucp_agreement.html' )
);
2006-06-12 22:16:27 +00:00
// Disable online list
page_header ( $user -> lang [ $title ], false );
2006-03-18 12:17:22 +00:00
$template -> assign_vars ( array (
'S_AGREEMENT' => true ,
'AGREEMENT_TITLE' => $user -> lang [ $title ],
2006-03-18 22:53:14 +00:00
'AGREEMENT_TEXT' => sprintf ( $user -> lang [ $message ], $config [ 'sitename' ], generate_board_url ()),
2006-06-06 20:53:46 +00:00
'U_BACK' => append_sid ( " { $phpbb_root_path } ucp. $phpEx " , 'mode=login' ),
2006-03-18 12:17:22 +00:00
'L_BACK' => $user -> lang [ 'BACK_TO_LOGIN' ])
);
2006-06-06 20:53:46 +00:00
2006-03-18 12:17:22 +00:00
page_footer ();
2006-01-25 21:01:52 +00:00
break ;
2005-04-09 12:26:45 +00:00
2004-05-31 18:00:10 +00:00
case 'delete_cookies' :
2006-03-01 21:48:02 +00:00
2004-05-31 18:00:10 +00:00
// Delete Cookies with dynamic names (do NOT delete poll cookies)
2004-06-06 21:44:49 +00:00
if ( confirm_box ( true ))
2004-05-31 18:00:10 +00:00
{
2004-06-06 21:44:49 +00:00
$set_time = time () - 31536000 ;
2006-06-06 20:53:46 +00:00
2004-06-06 21:44:49 +00:00
foreach ( $_COOKIE as $cookie_name => $cookie_data )
2004-05-31 18:00:10 +00:00
{
2004-06-06 21:44:49 +00:00
$cookie_name = str_replace ( $config [ 'cookie_name' ] . '_' , '' , $cookie_name );
2004-09-16 18:33:22 +00:00
if ( strpos ( $cookie_name , '_poll' ) === false )
2004-06-06 21:44:49 +00:00
{
$user -> set_cookie ( $cookie_name , '' , $set_time );
}
2004-05-31 18:00:10 +00:00
}
2006-06-06 20:53:46 +00:00
2004-06-06 21:44:49 +00:00
$user -> set_cookie ( 'track' , '' , $set_time );
2005-07-08 12:29:45 +00:00
$user -> set_cookie ( 'u' , '' , $set_time );
$user -> set_cookie ( 'k' , '' , $set_time );
2004-06-06 21:44:49 +00:00
$user -> set_cookie ( 'sid' , '' , $set_time );
2004-05-31 18:00:10 +00:00
2004-06-06 21:44:49 +00:00
// We destroy the session here, the user will be logged out nevertheless
2005-08-19 10:48:39 +00:00
$user -> session_kill ();
2006-01-05 21:24:22 +00:00
$user -> session_begin ();
2004-05-31 18:00:10 +00:00
2006-06-06 20:53:46 +00:00
meta_refresh ( 3 , append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2004-05-31 18:00:10 +00:00
2006-06-06 20:53:46 +00:00
$message = $user -> lang [ 'COOKIES_DELETED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_INDEX' ], '<a href="' . append_sid ( " { $phpbb_root_path } index. $phpEx " ) . '">' , '</a>' );
2004-06-06 21:44:49 +00:00
trigger_error ( $message );
}
else
{
confirm_box ( false , 'DELETE_COOKIES' , '' );
}
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2006-03-01 21:48:02 +00:00
2006-01-25 21:01:52 +00:00
break ;
2006-04-17 13:09:50 +00:00
case 'switch_perm' :
$user_id = request_var ( 'u' , 0 );
$sql = ' SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . ( int ) $user_id ;
$result = $db -> sql_query ( $sql );
$user_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
if ( ! $auth -> acl_get ( 'a_switchperm' ) || ! $user_row || $user_id == $user -> data [ 'user_id' ])
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2006-04-17 13:09:50 +00:00
}
include ( $phpbb_root_path . 'includes/acp/auth.' . $phpEx );
$auth_admin = new auth_admin ();
if ( ! $auth_admin -> ghost_permissions ( $user_id , $user -> data [ 'user_id' ]))
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2006-04-17 13:09:50 +00:00
}
2006-06-06 20:53:46 +00:00
add_log ( 'admin' , 'LOG_ACL_TRANSFER_PERMISSIONS' , $user_row [ 'username' ]);
2006-04-17 13:09:50 +00:00
2006-06-06 20:53:46 +00:00
$message = sprintf ( $user -> lang [ 'PERMISSIONS_TRANSFERED' ], $user_row [ 'username' ]) . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_INDEX' ], '<a href="' . append_sid ( " { $phpbb_root_path } index. $phpEx " ) . '">' , '</a>' );
2006-04-17 13:09:50 +00:00
trigger_error ( $message );
break ;
case 'restore_perm' :
if ( ! $user -> data [ 'user_perm_from' ] || ! $auth -> acl_get ( 'a_switchperm' ))
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2006-04-17 13:09:50 +00:00
}
$auth -> acl_cache ( $user -> data );
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_perm_from = 0
WHERE user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
$sql = ' SELECT username
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user->data[' user_perm_from ' ];
$result = $db -> sql_query ( $sql );
$username = $db -> sql_fetchfield ( 'username' );
$db -> sql_freeresult ( $result );
add_log ( 'admin' , 'LOG_ACL_RESTORE_PERMISSIONS' , $username );
2006-06-06 20:53:46 +00:00
$message = $user -> lang [ 'PERMISSIONS_RESTORED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_INDEX' ], '<a href="' . append_sid ( " { $phpbb_root_path } index. $phpEx " ) . '">' , '</a>' );
2006-04-17 13:09:50 +00:00
trigger_error ( $message );
break ;
2003-01-30 20:04:21 +00:00
}
2003-05-10 17:19:27 +00:00
// Only registered users can go beyond this point
2005-04-10 18:07:12 +00:00
if ( ! $user -> data [ 'is_registered' ])
2003-05-10 17:19:27 +00:00
{
2005-04-10 18:07:12 +00:00
if ( $user -> data [ 'is_bot' ])
2004-05-30 19:24:53 +00:00
{
2006-06-06 20:53:46 +00:00
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
2004-05-30 19:24:53 +00:00
}
2004-08-02 14:32:04 +00:00
2004-09-01 15:47:46 +00:00
login_box ( '' , $user -> lang [ 'LOGIN_EXPLAIN_UCP' ]);
2003-05-10 17:19:27 +00:00
}
2003-03-04 17:52:50 +00:00
2003-10-01 17:24:53 +00:00
// Output listing of friends online
2004-01-30 11:48:02 +00:00
$update_time = $config [ 'load_online_time' ] * 60 ;
2006-05-05 22:06:17 +00:00
$sql = $db -> sql_build_query ( 'SELECT_DISTINCT' , array (
2006-10-07 14:12:50 +00:00
'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline' ,
2006-05-05 22:06:17 +00:00
'FROM' => array (
USERS_TABLE => 'u' ,
ZEBRA_TABLE => 'z'
),
'LEFT_JOIN' => array (
array (
'FROM' => array ( SESSIONS_TABLE => 's' ),
'ON' => 's.session_user_id = z.zebra_id'
)
),
'WHERE' => 'z.user_id = ' . $user -> data [ 'user_id' ] . '
2006-06-06 20:53:46 +00:00
AND z . friend = 1
AND u . user_id = z . zebra_id ' ,
2006-05-05 22:06:17 +00:00
2006-05-21 16:54:19 +00:00
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline' ,
'ORDER_BY' => 'u.username ASC' ,
2006-05-05 22:06:17 +00:00
));
2003-03-17 00:53:38 +00:00
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
2003-03-04 17:52:50 +00:00
{
2006-04-23 13:08:48 +00:00
$which = ( time () - $update_time < $row [ 'online_time' ] && $row [ 'viewonline' ] && $row [ 'user_allow_viewonline' ]) ? 'online' : 'offline' ;
2003-05-09 14:11:55 +00:00
2003-10-01 17:24:53 +00:00
$template -> assign_block_vars ( " friends_ { $which } " , array (
2006-06-06 20:53:46 +00:00
'U_PROFILE' => append_sid ( " { $phpbb_root_path } memberlist. $phpEx " , 'mode=viewprofile&u=' . $row [ 'user_id' ]),
2004-08-02 14:32:04 +00:00
2006-10-07 14:12:50 +00:00
'USER_ID' => $row [ 'user_id' ],
'USER_COLOUR' => ( $row [ 'user_colour' ]) ? '#' . $row [ 'user_colour' ] : '' ,
'USERNAME' => $row [ 'username' ])
2003-03-17 00:53:38 +00:00
);
2003-03-04 17:52:50 +00:00
}
2003-03-17 00:53:38 +00:00
$db -> sql_freeresult ( $result );
2003-03-04 17:52:50 +00:00
2004-05-02 13:06:57 +00:00
// Output PM_TO box if message composing
2006-07-09 16:23:57 +00:00
if ( $mode == 'compose' && $auth -> acl_get ( 'u_sendpm' ) && request_var ( 'action' , '' ) != 'edit' )
2004-05-02 13:06:57 +00:00
{
2006-07-09 16:23:57 +00:00
if ( $config [ 'allow_mass_pm' ] && $auth -> acl_get ( 'u_masspm' ))
2004-05-02 13:06:57 +00:00
{
2004-08-02 14:32:04 +00:00
$sql = ' SELECT group_id , group_name , group_type
FROM ' . GROUPS_TABLE . '
2004-05-02 13:06:57 +00:00
WHERE group_type NOT IN ( ' . GROUP_HIDDEN . ' , ' . GROUP_CLOSED . ' )
AND group_receive_pm = 1
ORDER BY group_type DESC ' ;
$result = $db -> sql_query ( $sql );
$group_options = '' ;
while ( $row = $db -> sql_fetchrow ( $result ))
{
$group_options .= '<option' . (( $row [ 'group_type' ] == GROUP_SPECIAL ) ? ' class="blue"' : '' ) . ' value="' . $row [ 'group_id' ] . '">' . (( $row [ 'group_type' ] == GROUP_SPECIAL ) ? $user -> lang [ 'G_' . $row [ 'group_name' ]] : $row [ 'group_name' ]) . '</option>' ;
}
$db -> sql_freeresult ( $result );
}
$template -> assign_vars ( array (
'S_SHOW_PM_BOX' => true ,
2006-07-09 16:23:57 +00:00
'S_ALLOW_MASS_PM' => ( $config [ 'allow_mass_pm' ] && $auth -> acl_get ( 'u_masspm' )) ? true : false ,
'S_GROUP_OPTIONS' => ( $config [ 'allow_mass_pm' ] && $auth -> acl_get ( 'u_masspm' )) ? $group_options : '' ,
2006-06-06 20:53:46 +00:00
'U_SEARCH_USER' => append_sid ( " { $phpbb_root_path } memberlist. $phpEx " , 'mode=searchuser&form=post&field=username_list' ))
2004-05-02 13:06:57 +00:00
);
}
2003-10-01 17:24:53 +00:00
// Instantiate module system and generate list of available modules
2005-10-04 21:31:35 +00:00
$module -> list_modules ( 'ucp' );
// Select the active module
$module -> set_active ( $id , $mode );
2003-10-01 17:24:53 +00:00
// Load and execute the relevant module
2005-10-04 21:31:35 +00:00
$module -> load_active ();
// Assign data to the template engine for the list of modules
2006-06-06 20:53:46 +00:00
$module -> assign_tpl_vars ( append_sid ( " { $phpbb_root_path } ucp. $phpEx " ));
2005-10-04 21:31:35 +00:00
2006-06-12 22:16:27 +00:00
// Generate the page, do not display/query online list
$module -> display ( $module -> get_page_title (), false );
2006-04-08 13:01:04 +00:00
/**
* Function for assigning a template var if the zebra module got included
*/
function _module_zebra ( $mode , & $module_row )
{
global $template ;
$template -> assign_var ( 'S_ZEBRA_ENABLED' , true );
}
2002-07-14 14:45:26 +00:00
?>