4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: martrix on March 27, 2005, 08:39:14 PM

Title: [MOD] Information if Guest follows direct link to an image/category
Post 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:

Quote
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
  header("Location: ".$site_sess->url($url, "&"));
  exit;
}

replace with:
Code: [Select]
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:

Code: [Select]
$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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
$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.";
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: Rübe on March 28, 2005, 09:10:58 PM
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.
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: Vincent on March 28, 2005, 09:49:53 PM
when Matrix Publishs - it will work!
sincerly
vincent
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: martrix on March 29, 2005, 12:23:15 AM
@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. ;)
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: martrix on March 29, 2005, 01:25:12 PM
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
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: mcdbpas on August 29, 2005, 10:55:59 PM
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:
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: martrix on August 29, 2005, 11:45:45 PM
I'd like to help you, but I'm not really sure, what you do mean with "security mod"... :(

Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: impss on October 04, 2005, 01:10:36 AM
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?

Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: impss on December 13, 2005, 06:11:30 PM
Anyone Figure out how to return them back to where they where after login yet?

Thanks

Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: JensF on January 30, 2006, 08:14:11 PM
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?
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: JensF on January 31, 2006, 03:36:47 PM
No one has this problem or can help me??? :(
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: impss on January 31, 2006, 04:30:05 PM
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
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: TheOracle on January 31, 2006, 04:35:53 PM
Quote

Categorie not for guest (doesn´t work - blank page) -> http://www.terraristik-galerie.de/categories.php?cat_id=116


Quote

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.
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: JensF on January 31, 2006, 05:11:26 PM
Her is my categories.php -> http://www.terraristik-galerie.de/sonstiges/categories.rar
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: TheOracle on January 31, 2006, 05:16:30 PM
@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). ;)
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: JensF on January 31, 2006, 07:17:53 PM
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....
Title: Re: [MOD] Information if Guest follows direct link to an image
Post by: TheOracle on January 31, 2006, 07:34:31 PM
Quote

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.
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: V@no on February 01, 2006, 01:50:12 AM
I've added a solution in the original post for the categories.
Hope martrix dont mind ;)
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: JensF on February 01, 2006, 05:58:35 AM
Thanks V@no....
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: impss on February 01, 2006, 07:23:09 PM
Thanks V@no

 8)
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: Brian2 on February 15, 2006, 05:30:09 PM
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?
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: martrix on February 15, 2006, 06:07:45 PM
martrix doesn't mind... more to the contrary - he appreciates it :D
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: TheOracle on February 15, 2006, 06:49:22 PM
Quote

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  :?:
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: Brian2 on February 15, 2006, 11:29:25 PM
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.
Title: Re: [MOD] Information if Guest follows direct link to an image/category
Post by: TheOracle on February 16, 2006, 12:22:10 AM
I think I get what you're trying to say ...

In your details.php file,

find :

Quote

if (!$cat_id || !isset($cat_cache[$cat_id])) {
header("Location: " .$site_sess->url($url, "&"));
  exit;
}


replace with :

Code: [Select]

if (!$cat_id || !isset($cat_cache[$cat_id])) {
header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
  exit;
}


Then, try again.