Okay, I needed a
fast and
easy way to make pictures that users put in their lightboxes available for other users browsing their profile (via textlink).
Since on my site everything is public I don't need to bother my users with 100's of options.
If you need a
more complex MOD where users can show/hide/create lightboxes, I suggest using V@no's
[MOD] Multi-Lightboxes v1.03.2Tested with 1.7.10
I didn't use $lang files, but if you want them you should be familiar how to add them if you are using 4images with MOD's.
PS: Modified @ 25.10.2011 due to security reasons (thx to V@no) - Please update your code if you installed the MOD
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Okay, put that beer aside for a moment and tell your wife to cook you something tasty, while you follow my steps
STEP 1open notepad, and insert this:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: lightbox.php *
* Copyright: (C) 2002-2011 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.10 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) fьr weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$templates_used = 'lightbox_member,thumbnail_member_lightbox_bit';
$main_template = 'lightbox_member';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
$imgtable_width .= "%";
}
if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if (!$user_id) {
$user_id = GUEST;
}
}
$sql = "SELECT u.*, l.*
FROM (".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l)
WHERE u.user_id='$user_id' AND l.user_id='$user_id' ";
$user_info_id = $site_db->query_firstrow($sql);
if (!empty($user_info_id['lightbox_image_ids'])) {
$image_id_sql = str_replace(" ", ", ", trim($user_info_id['lightbox_image_ids']));
$sql = "SELECT COUNT(image_id) AS images
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";
$result = $site_db->query_firstrow($sql);
$num_rows_all = $result['images'];
}
$link_arg = $site_sess->url(ROOT_PATH."lightbox_member.php?user_id=$user_id");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => $getpaging->get_paging_stats()
));
if ($num_rows_all) {
$sql = "SELECT COUNT(image_id) AS images
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_download", "NOTIN").")";
$result = $site_db->query_firstrow($sql);
$download_allowed = intval($result['images']) > 0;
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_active = 1 AND i.image_id IN ($image_id_sql) AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
ORDER BY i.".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
}
if (!$num_rows) {
$thumbnails = "";
$msg .= ($msg != "") ? "<p>".$lang['lightbox_no_images'] : $lang['lightbox_no_images'];
}
else {
$user_info_id = $user_id;
$thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)) {
if (!$download_allowed && check_permission("auth_download", $image_row['cat_id'])) {
$download_allowed = true;
}
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
$site_template->register_vars(array(
"huhu" => $user_info_id,
));
}
$thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
show_image($image_row, "lightbox");
$thumbnails .= $site_template->parse_template("thumbnail_lightbox_member_bit");
$thumbnails .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$thumbnails .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover >= 1) {
for ($i = 0; $i < $leftover; $i++){
$thumbnails .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$thumbnails .= "</tr>\n";
}
}
$thumbnails .= "</table>\n";
} // end else
$site_template->register_vars(array(
"thumbnails" => $thumbnails,
));
unset($thumbnails);
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['lightbox']."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"msg" => $msg,
"clickstream" => $clickstream,
"lang_lightbox" => $lang['lightbox'],
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
save it as
lightbox_member.php and upload it to your 4images root folder
STEP 2 open notepad, and insert this:
<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
<a href="details.php?image_id={image_id}&mode=member_lightbox&user_id={huhu}"><img src="data/thumbnails/{cat_id}/{thumbnail_file_name}" width="" height="" border="0"></a>
<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
{lightbox_button}
save it as
thumbnail_lightbox_member_bit.html and upload it to your 4images template folder
STEP 3open notepad and insert this:
{header}
<table width="960" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablehead">
<tr>
<td width="100%" colspan="4"><table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="6"><img src="{template_url}/images/header_top_left.gif" width="6" height="6" alt="" /></td>
<td width="100%"><img src="{template_url}/images/header_top.gif" width="100%" height="6" alt="" /></td>
<td width="6"><img src="{template_url}/images/header_top_right.gif" width="6" height="6" alt="" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="6"><img src="{template_url}/images/header_left.gif" width="6" height="60" alt="" /></td>
<td width="100%"><img src="{template_url}/images/header_logo.gif" width="405" height="60" alt="" /></td>
<td width="225" align="right">
<form method="post" action="{url_search}">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<input type="text" name="search_keywords" size="15" class="searchinput" />
</td>
<td>
<input type="submit" value="{lang_search}" class="button" name="submit" />
</td>
</tr>
<tr valign="top">
<td colspan="2"><a href="{url_search}" class="smalltext">{lang_advanced_search}</a></td>
</tr>
</table>
</form>
</td>
<td align="right" width="6"><img src="{template_url}/images/header_right.gif" width="6" height="60" alt="" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="bordercolor">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="tablebgcolor">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="navbar" height="23">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="{template_url}/images/spacer.gif" width="4" height="4" alt="" />{clickstream}</td>
<td align="right">
<a href="{url_top_images}"><b>{lang_top_images}</b></a>
<a href="{url_new_images}"><b>{lang_new_images}</b></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" class="row2" valign="top">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head2" height="20"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_registered_user}</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td align="center" class="row1">{user_box} </td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
</table>
{if random_image}
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head2" height="20"> <img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_random_image}</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td align="center" class="row1">
<br />
{random_image}
<br />
<br />
</td>
</tr>
<tr>
<td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
</table>
{endif random_image}
</td>
<td width="1" class="bordercolor" valign="top"><img src="{template_url}/images/spacer.gif" width="1" height="1" alt="" /></td>
<td width="18" valign="top"><img src="{template_url}/images/spacer.gif" width="18" height="18" alt="" /></td>
<td width="100%" valign="top"><br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b class="title">{lang_lightbox}</b></td>
</tr>
</table>
<hr size="1" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
{paging_stats}
</td>
</tr>
</table>
<br />
{if msg}<b>{msg}</b><br /><br />{endif msg}
{if thumbnails}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head1">{thumbnails}</td>
</tr>
</table>
{endif thumbnails}
<br />
{paging}
<br />
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>{category_dropdown_form}</td>
<td align="right">{setperpage_dropdown_form}</td>
</tr>
</table>
<p> </p>
</td>
<td width="20" valign="top"><img src="{template_url}/images/spacer.gif" width="19" height="19" alt="" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablebottom">
<tr>
<td width="6" nowrap><img src="{template_url}/images/footer_left.gif" width="6" height="19" alt="" /></td>
<td width="100%"></td>
<td width="6" nowrap><img src="{template_url}/images/footer_right.gif" width="6" height="19" alt="" /></td>
</tr>
</table>
</td>
</tr>
</table>
{footer}
save it as
lightbox_member.html and upload it to your 4images template folder
STEP 4open
details.phpfind:
elseif ($mode == "search") {
insert
above// mod member lightbox easy way
if ($mode == "member_lightbox") {
if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if (!$user_id) {
$user_id = GUEST;
}
}
$huhu= $user_id;
$sql = "SELECT u.*, l.*
FROM (".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l)
WHERE u.user_id = $user_id AND l.user_id = $user_id ";
$user_info_id = $site_db->query_firstrow($sql);
if (!empty($user_info_id['lightbox_image_ids'])) {
$image_id_sql = str_replace(" ", ", ", trim($user_info_id['lightbox_image_ids']));
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
// mod member lightbox easy way
find:
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
replace with:
// member lightbox easy way
if ($mode == "member_lightbox") {
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : "")."&user_id=$huhu");
}
else {
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
}
// member lightbox easy way
find:
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
replace with:
// member lightbox easy way
if ($mode == "member_lightbox") {
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : "")."&user_id=$huhu");
}
else {
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
}
// member lightbox easy way
save it.Thats it. You can now use linking to lightbox images, for example in
member_profile.html<a href="lightbox_member.php?user_id={user_id}">Show lightbox of {user_name}</a>
PS: Change the html files to suit your site design.
PPS: I will extend this little MOD if there are any requests
PPPS: Yes, get that beer again on the table