Skip to content

Commit

Permalink
Redirect to viewprofile.php if profile.php hasn't arguments (#202)
Browse files Browse the repository at this point in the history
* Redirect to viewprofile.php if profile.php hasn't arguments

* Update CHANGELOG.md
  • Loading branch information
belomaxorka committed Jun 29, 2023
1 parent a349479 commit 690f34d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**Merged pull requests:**

- Release v2.1.5-2023.06 🎉
- Redirect to viewprofile.php if profile.php hasn't arguments [\#202](https://github.com/torrentpier/torrentpier-lts/pull/202) ([belomaxorka](https://github.com/belomaxorka))
- Show smilies in post for guests [\#196](https://github.com/torrentpier/torrentpier-lts/pull/196) ([belomaxorka](https://github.com/belomaxorka))
- Added showing PM counter in page title [\#193](https://github.com/torrentpier/torrentpier-lts/pull/193) ([belomaxorka](https://github.com/belomaxorka))
- Corrected translations [\#183](https://github.com/torrentpier/torrentpier-lts/pull/183) ([belomaxorka](https://github.com/belomaxorka))
Expand Down
17 changes: 10 additions & 7 deletions library/includes/ucp/viewprofile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
'ranks',
));

if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == GUEST_UID)
if (!$userdata['session_logged_in'])
{
bb_die($lang['NO_USER_ID_SPECIFIED']);
redirect(LOGIN_URL . "?redirect={$_SERVER['REQUEST_URI']}");
}
if (!$profiledata = get_userdata($_GET[POST_USERS_URL]))
else
{
bb_die($lang['NO_USER_ID_SPECIFIED']);
if (empty($_GET[POST_USERS_URL]))
{
$_GET[POST_USERS_URL] = $userdata['user_id'];
}
}

if (!$userdata['session_logged_in'])
if (!$profiledata = get_userdata($_GET[POST_USERS_URL]))
{
redirect(LOGIN_URL . "?redirect={$_SERVER['REQUEST_URI']}");
bb_die($lang['NO_USER_ID_SPECIFIED']);
}

if (!$ranks = $datastore->get('ranks'))
Expand Down Expand Up @@ -220,4 +223,4 @@

$template->assign_var('USER_RESTRICTIONS', join('</li><li>', $user_restrictions));

print_page('usercp_viewprofile.tpl');
print_page('usercp_viewprofile.tpl');
4 changes: 2 additions & 2 deletions profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$user->session_start();

set_die_append_msg();
$mode = request_var('mode', '');
$mode = request_var('mode', 'viewprofile');

switch ($mode)
{
Expand Down Expand Up @@ -47,4 +47,4 @@

default:
bb_die('Invalid mode');
}
}

0 comments on commit 690f34d

Please sign in to comment.