• [MOD] Information if Guest follows direct link to an image/category 5 0 5 1
Currently:  

Author Topic: [MOD] Information if Guest follows direct link to an image/category  (Read 38038 times)

0 Members and 1 Guest are viewing this topic.

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
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.";
« Last Edit: February 01, 2006, 01:49:00 AM by V@no »
MAяTRIX


Offline Rübe

  • Newbie
  • *
  • Posts: 28
  • Life sucks, but the graphics are great!
    • View Profile
    • DDR-Bild: Das große DDR-Fotoalbum im Netz!
Re: [MOD] Information if Guest follows direct link to an image
« Reply #1 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.
My site runs on 4images v1.7 - stable

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: [MOD] Information if Guest follows direct link to an image
« Reply #2 on: March 28, 2005, 09:49:53 PM »
when Matrix Publishs - it will work!
sincerly
vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods


Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Information if Guest follows direct link to an image
« Reply #3 on: March 29, 2005, 12:23:15 AM »
@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. ;)
MAяTRIX


Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Information if Guest follows direct link to an image
« Reply #4 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
MAяTRIX


Offline mcdbpas

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: [MOD] Information if Guest follows direct link to an image
« Reply #5 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:

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Information if Guest follows direct link to an image
« Reply #6 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"... :(

MAяTRIX


Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: [MOD] Information if Guest follows direct link to an image
« Reply #7 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?


Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: [MOD] Information if Guest follows direct link to an image
« Reply #8 on: December 13, 2005, 06:11:30 PM »
Anyone Figure out how to return them back to where they where after login yet?

Thanks


Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Information if Guest follows direct link to an image
« Reply #9 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?
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Information if Guest follows direct link to an image
« Reply #10 on: January 31, 2006, 03:36:47 PM »
No one has this problem or can help me??? :(
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline impss

  • Sr. Member
  • ****
  • Posts: 382
    • View Profile
    • Cusstom.net
Re: [MOD] Information if Guest follows direct link to an image
« Reply #11 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

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [MOD] Information if Guest follows direct link to an image
« Reply #12 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.

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Information if Guest follows direct link to an image
« Reply #13 on: January 31, 2006, 05:11:26 PM »
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [MOD] Information if Guest follows direct link to an image
« Reply #14 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). ;)