• [MOD] Lightbox for GUESTs v1.2 4 0 5 1
Currently:  

Author Topic: [MOD] Lightbox for GUESTs v1.2  (Read 106473 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs v1.2
« on: March 27, 2003, 01:44:45 PM »
-------- Overview -----------------
This MOD will let guests add picture to their lightbox, based on sessions + cookies.
u can see it an action here

-------- Known issue -------------
"GUESTs" lightbox is separate from "USERs", that means, that if u add some images to the lightbox, while u are not logged in and then do login, u wont have those images in the lightbox, untill u logged out.

-------- Installation ---------------

1.
Open /includes/functions.php
Find:
Code: [Select]
  if ($user_info['user_level'] != GUEST) {Replace with:
Code: [Select]
  if ($user_info['user_level'] >= GUEST) {
1.2.
Find next:
Code: [Select]
function add_to_lightbox($id) {
  global $user_info, $site_db;
  $id = intval($id);
  if (!$id) {
    return false;
  }
  $lightbox_ids = $user_info['lightbox_image_ids'];
  $lightbox_array = explode(" ", $lightbox_ids);
  if (!in_array($id, $lightbox_array)) {
    $lightbox_ids .= " ".$id;
  }
  $user_info['lightbox_image_ids'] = trim($lightbox_ids);
  $user_info['lightbox_lastaction'] = time();
Replace with:
Code: [Select]
function add_to_lightbox($id) {
  global $user_info, $site_db, $site_sess;
  $id = intval($id);
  if (!$id) {
    return false;
  }
  if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
  }
  $lightbox_ids = $user_info['lightbox_image_ids'];
  $lightbox_array = explode(" ", $lightbox_ids);
  if (!in_array($id, $lightbox_array)) {
    $lightbox_ids .= " ".$id;
  }
  $user_info['lightbox_image_ids'] = trim($lightbox_ids);
  $user_info['lightbox_lastaction'] = time();
  if ($user_info['user_level'] == GUEST) {
    $site_sess->set_cookie_data("lightbox", $user_info['lightbox_image_ids'], 1);
    $site_sess->set_cookie_data("lightbox_lastaction", $user_info['lightbox_lastaction'], 1);
    $site_sess->set_session_var("lightbox", $user_info['lightbox_image_ids']);
    $site_sess->set_session_var("lightbox_lastaction", $user_info['lightbox_lastaction']);
    return 1;
  }

1.3.
Find next:
Code: [Select]
function remove_from_lightbox($id) {
  global $user_info, $site_db;
  $lightbox_array = explode(" ",$user_info['lightbox_image_ids']);
  foreach ($lightbox_array as $key => $val) {
    if ($val == $id) {
      unset($lightbox_array[$key]);
    }
  }
  $user_info['lightbox_image_ids'] = trim(implode(" ", $lightbox_array));
  $user_info['lightbox_lastaction'] = time();
Replace with:
Code: [Select]
function remove_from_lightbox($id) {
  global $user_info, $site_db, $site_sess;
  if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
  }
  $lightbox_array = explode(" ",$user_info['lightbox_image_ids']);
  foreach ($lightbox_array as $key => $val) {
    if ($val == $id) {
      unset($lightbox_array[$key]);
    }
  }
  $user_info['lightbox_image_ids'] = trim(implode(" ", $lightbox_array));
  $user_info['lightbox_lastaction'] = time();
  if ($user_info['user_level'] == GUEST) {
    $site_sess->set_cookie_data("lightbox", $user_info['lightbox_image_ids'], 1);
    $site_sess->set_cookie_data("lightbox_lastaction", $user_info['lightbox_lastaction'], 1);
    $site_sess->set_session_var("lightbox", $user_info['lightbox_image_ids']);
    $site_sess->set_session_var("lightbox_lastaction", $user_info['lightbox_lastaction']);
    return 1;
  }

1.4.
Find next:
Code: [Select]
function clear_lightbox() {
  global $user_info, $site_db;
  $current_time = time();
Replace with:
Code: [Select]
function clear_lightbox() {
  global $user_info, $site_db, $site_sess;
  $current_time = time();
  if ($user_info['user_level'] == GUEST) {
    $user_info['lightbox_image_ids'] = "";
    $user_info['lightbox_lastaction'] = $current_time;
    $site_sess->set_cookie_data("lightbox", "");
    $site_sess->drop_session_var("lightbox");
    $site_sess->set_cookie_data("lightbox_lastaction", $current_time, 1);
    $site_sess->set_session_var("lightbox_lastaction", $current_time);
    return true;
  }

1.5.
Find next:
Code: [Select]
function check_lightbox($id) {
  global $user_info;
Replace with:
Code: [Select]
function check_lightbox($id) {
  global $user_info, $site_sess;
  if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
  }


2.
Open /lightbox.php
Find and remove (or comment):
Code: [Select]
if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
  show_error_page($lang['lightbox_register']);
}

2.1.
Find next:
Code: [Select]
if (!empty($user_info['lightbox_image_ids']))  {Add before:
Code: [Select]
if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
    $lightbox = $site_sess->get_session_var('lightbox_lastaction');
    $user_info['lightbox_lastaction'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox_lastaction");
}

2.2a. (4images v1.7 - 1.7.3)
Find next:
Code: [Select]
  if (!empty($user_info['lightbox_image_ids'])) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
  if (!empty($user_info['lightbox_image_ids']) && $user_info['user_level'] != GUEST) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";

2.2b. (4images v1.7.4 and newer)
Find:
Code: [Select]
  if ($download_allowed && !empty($user_info['lightbox_image_ids'])) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
Replace with:
Code: [Select]
  if ($download_allowed && !empty($user_info['lightbox_image_ids']) && $user_info['user_level'] != GUEST) {
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";

3.
Open /templates/<yourtemplate>/user_loginform.html
Insert:
Code: [Select]
<a href="{url_lightbox}">{lang_lightbox}</a>
4. * Fix
Open /includes/page_header.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Add & Delete from Lists -------------------------
//-----------------------------------------------------
if ($action == "addtolightbox" && $id) {
  if ($user_info['user_level'] >= USER) {
    $msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "removefromlightbox" && $id) {
  if ($user_info['user_level'] >= USER) {
    $msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "clearlightbox") {
  if ($user_info['user_level'] >= USER) {
    $msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
Replace with:
Code: [Select]
//-----------------------------------------------------
//--- Add & Delete from Lists -------------------------
//-----------------------------------------------------
if ($action == "addtolightbox" && $id) {
  if ($user_info['user_level'] >= GUEST) {
    $msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "removefromlightbox" && $id) {
  if ($user_info['user_level'] >= GUEST) {
    $msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "clearlightbox") {
  if ($user_info['user_level'] >= GUEST) {
    $msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}


5. Added 9-23-2003 *optional, only if u want let your guests download the lightbox
Open download.php
Find:
Code: [Select]
if ($action == "lightbox") {

Add after:
Code: [Select]
  if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
  }
« Last Edit: May 12, 2012, 09:11:30 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #1 on: April 05, 2003, 09:47:53 PM »
i've tried this mod but it seems that it's not working cause when i click in "album" button as a guest it doesn't save that info and then i go to the album link and it says that i don't have any images on favs.

should i post my code here?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs
« Reply #2 on: April 13, 2003, 04:36:40 AM »
Ops. sry, forgot add one more step :oops:
Check out step 4.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #3 on: May 13, 2003, 02:08:59 PM »
Everything I had follow.

after result is, I am act as guest, I can select my light boxs, the picture I selected have a "tick" there.

but when I click on lightbox link it give me below message.

Error
--------------------------------------------------------------------------------

In order to use the lightbox, you have to register.

P/s: again, the select picture lightbox is WORKING but just when click on the lightbox link to show the fully selected lightbox is not working

Which file I had to refer back?
What's wrong, huh?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs
« Reply #4 on: May 13, 2003, 10:53:44 PM »
did u do step 2. ? are those three line in your lightbox.php commented (means two forward slashes infront of each line: //) or deleted now?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #5 on: May 14, 2003, 06:29:25 AM »
Dear V@no,

It is done! this mod very peferctly now!

Yes, you are right, I since I check all script I found one / is missing. when replace it, it work perfectly.

V@no, Thank again!

Because of you, our gallery look more advance! nice jobs! Want I spend you a dinner?  :lol:  he he
What's wrong, huh?

Offline hoelzlmani

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • http://www.smssprueche.net
error
« Reply #6 on: May 23, 2003, 12:37:34 PM »
i get an error after install this mod. Warning: Cannot add header information - headers already sent by (output started at /homepages/0/d72423240/htdocs/smssprueche/nuke/homepage/4images/includes/functions.php:2526) in /homepages/0/d72423240/htdocs/smssprueche/nuke/homepage/4images/includes/sessions.php on line 171

this comes 4 times.

this is line 171:
function set_cookie_data($name, $value, $permanent = 1) {

     $cookie_expire = ($permanent) ? $this->current_time + 60 * 60 * 24 * 365 : 0;

     $cookie_name = COOKIE_NAME.$name;

     setcookie($cookie_name, $value, $cookie_expire, COOKIE_PATH,  COOKIE_DOMAIN, COOKIE_SECURE);

   }

i saved the changed files and copy back the original files, but i have still the above error.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: error
« Reply #7 on: May 23, 2003, 01:05:40 PM »
Quote from: hoelzlmani
Warning: Cannot add header information - headers already sent by (output started at /homepages/0/d72423240/htdocs/smssprueche/nuke/homepage/4images/includes/functions.php:2526) in /homepages/0/d72423240/htdocs/smssprueche/nuke/homepage/4images/includes/sessions.php on line 171

usualy this error shows when u have some extra space or new line after closing ?> in .php files. check again every file u edited.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Maxxx

  • Newbie
  • *
  • Posts: 21
    • View Profile
@ V@no
« Reply #8 on: June 18, 2003, 05:07:03 PM »
@ V@no

Hi , I've a problem with your MOD . After all modification , guests are unable to download our choosed images in lightbox ( botton are visible but inactive ) and unable to clear our lightbox..  
 
What happens ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs
« Reply #9 on: June 18, 2003, 05:38:18 PM »
strange, everything works just fine for me...exept download button ;)
to fix that, in lightboxes.php find:
Code: [Select]
 if (!empty($user_info['lightbox_image_ids']) && $user_info['user_level'] != GUEST) {
replace with:
Code: [Select]
 if (!empty($user_info['lightbox_image_ids'])) {
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Maxxx

  • Newbie
  • *
  • Posts: 21
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #10 on: June 18, 2003, 05:58:44 PM »
Quote from: V@no
strange, everything works just fine for me...exept download button ;)
to fix that,...


Thank's , the fix works fine.
But the first problem continue to persist... may be the problem caused by the cookies ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs
« Reply #11 on: June 18, 2003, 06:01:42 PM »
I'm not sure...can I try?  :wink:
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Maxxx

  • Newbie
  • *
  • Posts: 21
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #12 on: June 18, 2003, 06:07:53 PM »
Quote from: V@no
I'm not sure...can I try?  :wink:


Here the  link to my under-construction-website..

http://www.faithhill.it/portal/modules.php?name=TechMedia&file=index

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Lightbox for GUESTs
« Reply #13 on: June 18, 2003, 06:28:26 PM »
at the begining I was getting javascript error messages, and clear lighbox didnt work, then I closed my browser and opened again - no error messages, clear lighbox working now, but download never worked, it just refreshing whole page.
does your download button work for members at all?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Maxxx

  • Newbie
  • *
  • Posts: 21
    • View Profile
[MOD] Lightbox for GUESTs
« Reply #14 on: June 18, 2003, 06:40:40 PM »
Quote from: V@no
..
does your download button work for members at all?


Ya, for members the download through the lightbox page works fine!