If a visitor follows a direct link to a picture
(like yourdomain.com/details.php?image_id=nnn for example from a search-engine, from the Favourities-Tab...) but is not authorized, 4images redirects the visitor automaticaly to the index page...
This insignificant modification tells the visitor that he's not authorized first and after 6 seconds he's redirected to the index page...
------------------
Files changed:
------------------
./details.php./lang/<yourlanguage>/main.phpopen
details.phpfind:
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
replace with:
if (!$image_row) {
header("Location: " .$site_sess->url($url, "&"));
exit;
}
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
header("Refresh: 6; url=".$site_sess->url($url, "&"));
if($user_info['user_level'] == GUEST) {
$error_msg = $lang['guest_not_authorized'];
}
else{ $error_msg = $lang['not_authorized'];
}
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
$clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
$clickstream .= $image_id."</span>";
show_error_page($error_msg, $clickstream);
exit;
}
save and close
details.phpopen ./lang/
<yourlanguage>/
main.phpat the end, just before
?> add this line:
$lang['guest_not_authorized'] = "You're not authorized to view this picture. <br>Try to register or log-in";
$lang['not_authorized'] = "You're not authorized to view this image.";
That's it.
Not the best way, how to do that, but the only way I'm able to and at least
a solution
Woud be great, if somebody could help me with a little addition to this: if a GUEST sees this error-message and logs-in directly from this error-page, he comes back to the picture (if authorized...)
[NEW]
And if you would like to show error page if visitor tryed to open category page whithout permission then in categories.php find:
if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat", $cat_id)) {
header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
exit;
}
Replace with:
if (!$cat_id || !isset($cat_cache[$cat_id])) {
header("Location: " .$site_sess->url($url, "&"));
exit;
}
if (!check_permission("auth_viewcat", $cat_id))
{
header("Refresh: 6; url=".$site_sess->url($url, "&"));
if($user_info['user_level'] == GUEST)
{
$error_msg = $lang['cat_guest_not_authorized'];
}
else
{
$error_msg = $lang['cat_not_authorized'];
}
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a></span>";
show_error_page($error_msg, $clickstream);
exit;
}
And in lang/<your language>/main.php at the end, above closing
?> insert:
$lang['cat_guest_not_authorized'] = "You're not authorized to view this category. <br>Try to register or log-in";
$lang['cat_not_authorized'] = "You're not authorized to view this category.";