4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: martrix on March 27, 2005, 08:39:14 PM
-
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:
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.php
open ./lang/<yourlanguage>/main.php
at 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.";
-
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.
-
when Matrix Publishs - it will work!
sincerly
vincent
-
@Vincent
oh! thank you Vincent (http://photo.overlord.cz/templates/blue_wonder/smiles/embarrassed.gif)
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. ;)
-
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
-
Nice Mod!
I think this mod can used as security mod.
If anyone modder can change this code to an security script, how can permit the view of thumbnail in all category when user not loged in.
Please tell me are you see a chance?
Sorry my english is not verry good
Im verry happen when a modder can post this code :mrgreen:
-
I'd like to help you, but I'm not really sure, what you do mean with "security mod"... :(
-
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...)
I would love this added to this mod also
Anyone know how to do this?
-
Anyone Figure out how to return them back to where they where after login yet?
Thanks
-
Hi,
i found a problem.
When i have an image not for guest the mod works and say me you are not authorized.
But when i have a categorie not for guest then i get a blank page.
And the redirct doesn´t work :(
Test it here:
Image not for guests (works) -> http://www.terraristik-galerie.de/details.php?image_id=1785
Categorie not for guest (doesn´t work - blank page) -> http://www.terraristik-galerie.de/categories.php?cat_id=116
What must i change to have it for categories, too?
-
No one has this problem or can help me??? :(
-
This modification isnt by default suppose to work on catogories, but it would be a nice addition :mrgreen:
JensF , I find it interesting you get a blank page, mine automatically redirects the them to the front page
-
Categorie not for guest (doesn´t work - blank page) -> http://www.terraristik-galerie.de/categories.php?cat_id=116
No one has this problem or can help me???
@JensF:
How can you get any assistance if you're not going to post the categories.php's file content in order to see, more closely, what might be wrong in your codings ? ;)
Meaning, please post your categories.php file and I will take a look at it. It might simply be a header redirection coding issue.
-
Her is my categories.php -> http://www.terraristik-galerie.de/sonstiges/categories.rar
-
@JensF:
The answers are quite clear here. You installed several MODs into that file and you might of had faced some conflicts (or some required modules that has been un-commented and are required to be used). Unfortunitely, some MODs must of had required removal of these modules (which is not a good idea anyway). ;)
I'd suggest restoring your backup and try to implement your MODs again and, this time, WITHOUT requiring any un-commenting over the core modules of 4images (or as less as possible). ;)
-
hhmm, thanks for the answer. Then i must see what i can do...
*edit*
can you say me what conflicts are in the file??? I mean, all other works....
-
can you say me what conflicts are in the file??? I mean, all other works....
Sorry. There are too many MODs to describe in your file to see what might be the relative source of the problem.
-
I've added a solution in the original post for the categories.
Hope martrix dont mind ;)
-
Thanks V@no....
-
Thanks V@no
8)
-
When you click on a link to a category that you're not allowed to view now, you get redirected to news.php. I don't have news.php. Shouldn't it redirect to index.php?
-
martrix doesn't mind... more to the contrary - he appreciates it :D
-
When you click on a link to a category that you're not allowed to view now, you get redirected to news.php. I don't have news.php. Shouldn't it redirect to index.php?
I don't see any readings, from the first post, that indicates news.php file for redirecting ... perhaps it was modified before I posted this note :?:
-
I duplicated index.php and called it news.php, redirecting works now but I still find it weird and this can't be how it was meant to work.
-
I think I get what you're trying to say ...
In your details.php file,
find :
if (!$cat_id || !isset($cat_cache[$cat_id])) {
header("Location: " .$site_sess->url($url, "&"));
exit;
}
replace with :
if (!$cat_id || !isset($cat_cache[$cat_id])) {
header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
exit;
}
Then, try again.