4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)
[MOD] Information if Guest follows direct link to an image/category
martrix:
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.php
open details.php
find:
--- Quote ---if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
--- End quote ---
replace with:
--- Code: ---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;
}
--- End code ---
save and close details.php
open ./lang/<yourlanguage>/main.php
at the end, just before ?> add this line:
--- Code: ---$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.";
--- End code ---
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:
--- Code: ---if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat", $cat_id)) {
header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
exit;
}
--- End code ---
Replace with:
--- Code: ---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;
}
--- End code ---
And in lang/<your language>/main.php at the end, above closing ?> insert:
--- Code: ---$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.";
--- End code ---
Rübe:
Hello matrix - sounds like a very nice mod. Anyone other than matrix tried it out, worked out properly? Can only go for really workable mods as I am a complete nerd re. php and, hence, would not even know where to start if I had an error pop up... :roll:
Big thanks in advance.
Vincent:
when Matrix Publishs - it will work!
sincerly
vincent
martrix:
@Vincent
oh! thank you Vincent
As a human being I'm making also mistakes ;) but this works fine for me, so there's a high possibility, that it will work for others also.
@Rübe
This change was so easy, that even I was able to find out, how to modify the files 8O
If it won't work - ask here... I'll try to help you. ;)
martrix:
Just an additional idea :) to that: if the guest follows a direct link to a picture with acces-rights set to "private" or "admin" then an icon or error picture should be shown instead of the thumbnail :)
Just to eliminate the possibility, that Guests can see thumbnails of pictures which should normally stay hidden even to a registered member (without access-rights) :wink:
I'll republish the mod, if I find out how to do that :D
Navigation
[0] Message Index
[#] Next page
Go to full version