<?php
/***************************************************************************
* mides.ru
* -------------------
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = '../';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
{
$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
}
else
{
$sid = '';
}
$page_title = 'Профиль';
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
$server_url = $server_protocol . $server_name . $server_port . $script_name;
function gen_rand_string($hash)
{
$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');
$max_chars = count($chars) - 1;
srand( (double) microtime()*1000000);
$rand_str = '';
for($i = 0; $i < 8; $i++)
{
$rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
}
return ( $hash ) ? md5($rand_str) : $rand_str;
}
$id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : $HTTP_POST_VARS['id'];
$mode = $HTTP_GET_VARS['mode'];
$id = intval($id);
if ( $mode == 'addfriend' )
{
add_friend($userdata['user_id'], $id);
message_die(GENERAL_MESSAGE, $lang['friend_suc_added']);
}
if ( $mode == 'addfoe' )
{
add_foe($userdata['user_id'], $id);
message_die(GENERAL_MESSAGE, $lang['foe_suc_added']);
}
if($HTTP_GET_VARS['mode'] == 'delet') {
$HTTP_GET_VARS['foes'] = ( $HTTP_GET_VARS['foes'] == 0 ) ? NULL : ( $HTTP_GET_VARS['foes'] );
$HTTP_GET_VARS['friends'] = ( $HTTP_GET_VARS['friends'] == 0 ) ? NULL : ( $HTTP_GETPOST_VARS['friends'] );
if ( isset($HTTP_GET_VARS['friend']) )
{
$friend = $HTTP_GET_VARS['friend'];
if ( $friend != 0 )
{
$sql = 'DELETE
FROM '.FRIENDS_TABLE.'
WHERE user_id = '.$userdata['user_id'] .'
AND friend_id = '.intval($friend);
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete friend', '', __LINE__, __FILE__, $sql);
} elseif( !isset($HTTP_POST_VARS['foes']) )
{
message_die(GENERAL_MESSAGE, $lang['Succesfull_delete_friend']);
}
}
}
if ( isset($HTTP_GET_VARS['foe']) )
{
$foe = $HTTP_GET_VARS['foe'];
if ( $foe != 0 )
{
$sql = 'DELETE FROM '.FOES_TABLE.'
WHERE user_id = '.$userdata['user_id'] .'
AND friend_id = '.intval($foe);
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete foe', '', __LINE__, __FILE__, $sql);
} elseif( !isset($HTTP_POST_VARS['friends']) )
{
message_die(GENERAL_MESSAGE, $lang['Succesfull_delete_foe']);
}
}
}
message_die(GENERAL_MESSAGE, $lang['Succesfull_delete_friend_and_foe']);
}
if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
$mode = htmlspecialchars($mode);
if ( $mode == 'viewprofile' )
{
include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
exit;
}
else if ( $mode == 'viewfiles' )
{
include($phpbb_root_path . 'includes/usercp_viewfiles.'.$phpEx);
exit;
}
else if ( $mode == 'viewfriends' )
{
include($phpbb_root_path . 'includes/friends_foes.'.$phpEx);
exit;
}
else if ( $mode == 'medals' )
{
include($phpbb_root_path . 'includes/usercp_viewmedals.'.$phpEx);
exit;
}
else if ( $mode == 'editprofile' || $mode == 'register' )
{
if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
}
include($phpbb_root_path . 'includes/usercp_register.'.$phpEx);
exit;
}
else if ( $mode == 'editstyle' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editstyle", true));
}
include($phpbb_root_path . 'includes/usercp_editstyle.'.$phpEx);
exit;
}
else if ( $mode == 'money' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=money", true));
}
include($phpbb_root_path . 'includes/usercp_money.'.$phpEx);
exit;
}
else if ( $mode == 'editconfig' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editconfig", true));
}
include($phpbb_root_path . 'includes/usercp_editconfig.'.$phpEx);
exit;
}
else if ( $mode == 'sendicq' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx", true));
}
include($phpbb_root_path . 'includes/usercp_sendicq.'.$phpEx);
exit;
}
else if ( $mode == 'delete' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx", true));
}
include($phpbb_root_path . 'includes/usercp_delete.'.$phpEx);
exit;
}
else if ( $mode == 'editprofileinfo' )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofileinfo", true));
}
include($phpbb_root_path . 'includes/usercp_editprofileinfo.'.$phpEx);
exit;
}
else if ( $mode == 'reputation' || $mode == 'given' || $mode == 'warnings' || $mode == 'expired' )
{
include($phpbb_root_path . 'includes/usercp_reputation.'.$phpEx);
exit;
}
else if ( $mode == 'confirm' )
{
if ( $userdata['session_logged_in'] )
{
exit;
}
include($phpbb_root_path . 'includes/usercp_confirm.'.$phpEx);
exit;
}
else if ( $mode == 'sendpassword' )
{
include($phpbb_root_path . 'includes/usercp_sendpasswd.'.$phpEx);
exit;
}
else if ( $mode == 'activate' )
{
include($phpbb_root_path . 'includes/usercp_activate.'.$phpEx);
exit;
}
else if ( $mode == 'email' )
{
include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
exit;
}
else if ( $mode == 'clone' )
{
include($phpbb_root_path . 'includes/usercp_clone.'.$phpEx);
exit;
}
elseif ($mode == 'lock')
{
include($phpbb_root_path . 'includes/usercp_lock.php');
exit;
}
elseif ($mode == 'wall')
{
include($phpbb_root_path . 'includes/usercp_wall.php');
exit;
}
}
redirect(append_sid("index.$phpEx", true));
?>