35
« on: February 06, 2008, 11:43:59 AM »
This is NOT FINISH mode and it won't work yet!!! DON'T USE IT UNLESS FOR TESTING!!!
I'm trying to create mode to allow users to add / remove / edit their own albums. When user wants to upload image in gallery he will have choice to select default categories and their own albums.
If there is someone who is willing to finish this mod I would be very grateful.
Here we go:
1. Create new tables in phpmyadmin
CREATE TABLE `4images_albums` (
`albums_id` mediumint(10) NOT NULL auto_increment,
`albums_name` varchar(255) collate latin1_general_ci NOT NULL default '',
`albums_owner` mediumint(10) NOT NULL default '0',
`albums_public` smallint(2) NOT NULL default '1',
`albums_active` smallint(2) NOT NULL default '1',
PRIMARY KEY (`albums_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=34 ;
Then create new file called albums.php
WARNING! DO NOT USE THIS FILE BECOUSE THIS MODE IS ONLY IN DEVELOPMENT!
<?php
/*************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: member.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7 *
* *
* 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. *
* *
*************************************************************************/
$main_template = "albums";
$templates_used = 'albums,whos_online,thumbnail_bit';
define('GET_CACHES', 1);
define('ROOT_PATH', 'modules/Galerija/');
define('GET_USER_ONLINE', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
if (isset($HTTP_POST_VARS['user_id']) || isset($HTTP_GET_VARS['user_id'])) {
$user_id2 = (isset($HTTP_POST_VARS['user_id'])) ? trim($HTTP_POST_VARS['user_id']) : urldecode(trim($HTTP_GET_VARS['user_id']));
}
$stevilo = (int)$user_id2;
//------------------------//
// ---- View Albums ------//
//------------------------//
if ($action == "show") {
if ($stevilo == 0) {
} else {
//$sql2 = "SELECT * FROM 4images_albums WHERE albums_owner = ".$user_info['user_id']." ORDER BY albums_name";
$sql = "SELECT * FROM 4images_albums WHERE albums_owner = '$stevilo' ORDER BY albums_name";
$result = mysql_query($sql);
$num_rows = $site_db->get_numrows($result);
$image_row = $site_db->query_firstrow($sql);
$image_albums = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
$count = 0;
while($row = mysql_fetch_array($result)){
$sql2 = "SELECT COUNT(*) AS count FROM 4images_images WHERE albums_id = ".$row[albums_id]."";
$result2 = mysql_query($sql2);
$row2 = mysql_fetch_array($result2);
if ($count == 0) {
$image_albums .= "<tr>\n";
}
$image_albums .= "<td align=\"justify\" style=\"padding-top: 15px\">\n";
if ($row2['count'] >= 1 ) {
$img = "<img src=\"/crop.php?id=".$row[albums_id]."\" class=\"pic\" border=\"0\">"; // THIS IS EXTRA MODIFICATION THAT SHOULDN'T BE USED HERE
} else { $img = "<img src=\"/images/galerija/albums_blank.jpg\" width=\"56\" height=\"56\" border=\"0\" style=\"border: 1px solid #dadada\">";}
if ($user_info['user_id'] == $row['user_id'] || $user_info['user_level'] == ADMIN) {
$clan = "<br /> <a href=\"/modules.php?name=Galerija&file=albums&action=editalbums&id=".$row[albums_id]."\"><img src=\"/images/galerija/edit_albums.png\" border=\"0\" title=\"Uredi album\" alt=\"redi album\" /></a>
<a href=\"/modules.php?name=Galerija&file=albums&action=deletealbums&id=".$row[albums_id]."\"><img src=\"/images/galerija/delete.png\" border=\"0\" title=\"Izbriši album\" alt=\"Izbriši album\" /></a>";
}
$image_albums .= "</div>
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><a href=\"/modules.php?name=Galerija&file=search-albums&camera=".$row[albums_id]."\" class=\"maincat\">$img</a></td><td> <a href=\"/modules.php?name=Galerija&file=search-albums&camera=".$row[albums_id]."\" class=\"maincat\">".$row[albums_name]."</a>
$clan
<br /> <small>(".$row2[count]." fotografij)</small>
</td>
</tr>
</table>";
/*
$image_albums .= "<div style=\"padding-top: 5px; text-align: center\"><a href=\"#\">".$img."".$row[albums_name]."</a> (<a href=\"#\">".$row2[count]."</a>)</div>\n";
$image_albums .= "<div style=\"padding-top: 5px; text-align: center\"><a href=\"/modules.php?name=Galerija&file=albums&action=deletealbums&id=".$row[albums_id]."\">[x]</a></div>\n";
*/
$image_albums .= "\n</td>\n";
$count++;
if ($count == 4) {
$image_albums .= "</tr>\n";
$count = 0;
}
}
$image_albums .= "</table>\n";
$content = $site_template->parse_template("albums_add");
}
}
//------------------------//
// ---- Delete Album ---- //
//------------------------//
if ($action == "deletealbums") {
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$id = intval($_GET["id"]);
if ($id == '0') {
$msg .= "Prosim izberite album, ki ga želite izbrisati. <a href=\"javascript:window.history.go(-1);\">Pojdi nazaj...</a>";
} else {
$sql = "SELECT * FROM 4images_albums WHERE albums_id = ".$id."";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
// if ($user_info['user_id'] == $row['user_id'] || $user_info['user_level'] == ADMIN) {
if ($user_info['user_id'] == $row['albums_owner'] || $user_info['user_level'] == ADMIN) {
$sql = "DELETE FROM 4images_albums WHERE albums_owner = ".$user_info['user_id']." AND albums_id = '$id'";
$site_db->query($sql);
$sql2 = "UPDATE 4images_images SET albums_id = '' WHERE albums_id = '$id'";
$site_db->query($sql2);
$msg .= "Album $row[albums_name] ste uspešno izbrisali. <a href=\"/modules.php?name=Galerija&file=albums&action=show&user_id=".$user_info['user_id']."\">Osveži listo >></a>";
}
}
$content = $site_template->parse_template("albums_add");
}
//------------------------//
// ---- Add Album ---- //
//------------------------//
if ($action == "addalbums") {
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
if (!empty($user_albums_new)) {
$sql = "INSERT INTO 4images_albums
(albums_owner, albums_name)
VALUES
(".$user_info['user_id'].", '$user_albums_new')";
$site_db->query($sql);
$msg .= "Album $user_albums_new ste uspešno dodali. <a href=\"/modules.php?name=Galerija&file=albums&action=show&user_id=".$user_info['user_id']."\">Osveži listo >></a>";
}
$content = $site_template->parse_template("albums_add");
}
//------------------------//
// ---- Edit Album ---- //
//------------------------//
if ($action == "editalbums") {
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$id = intval($_GET["id"]);
if ($id == '0') {
$msg .= "Prosim izberite album, ki ga želite urediti. <a href=\"javascript:window.history.go(-1);\">Pojdi nazaj...</a>";
} else {
$sql = "SELECT * FROM 4images_albums WHERE albums_id = ".$id."";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
// if ($user_info['user_id'] == $row['user_id'] || $user_info['user_level'] == ADMIN) {
if ($user_info['user_id'] == $row['albums_owner']) {
$site_template->register_vars(array(
"url_albums_edit" => $site_sess->url(ROOT_PATH."albums.php&action=editalbumsok&id=$id"),
));
}
$site_template->register_vars(array(
"image_id" => $image_id,
"albums_name" => $row['albums_name'],
));
}
$content = $site_template->parse_template("albums_edit");
}
//------------------------//
// ---- Edit Album OK! -- //
//------------------------//
if ($action == "editalbumsok") {
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$id = intval($_GET["id"]);
if ($id == '0') {
$msg .= "Prosim izberite album, ki ga želite urediti. <a href=\"javascript:window.history.go(-1);\">Pojdi nazaj...</a>";
} else {
if (!empty($albums_name_edit)) {
$sql = "UPDATE 4images_albums SET albums_name = '$albums_name_edit' WHERE albums_id = '$id'";
$site_db->query($sql);
$msg .= "Ime albuma ste uspešno popravili. Novo ime je <b>$albums_name_edit</b>. <a href=\"/modules.php?name=Galerija&file=albums&action=show\">Osveži listo >></a>";
} else {
$msg .= "Ime albuma ne sme biti prazno! <a href=\"javascript:window.history.go(-1);\">Pojdi nazaj...</a>";
}
}
$content = $site_template->parse_template("albums_add");
}
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
$page_title = $config['category_separator'].$txt_clickstream; // MOD: Dynamic page title
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"ncomment_image" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link),
"content" => $content,
"msg" => $msg,
"clickstream" => $clickstream,
"page_title" => $page_title, // MOD: Dynamic page title
"lang_control_panel" => $lang['control_panel'],
"newest_images" => $lang['newest_images'],
"lang_imagecamera" => $lang['imagecamera'],
"lang_comment_lang" => $lang['comment_lang'],
"lang_comment_lang2" => $lang['comment_lang2'],
"lang_photo_modify" => $lang['photo_modify'],
"lang_show" => $lang['show'],
"lang_user_birth" => $lang['user_birth'],
"lang_numcom" => $lang['numcom'],
"lang_numimages" => $lang['numimages'],
"categories_list" => $lang['categories_list'],
"lang_lname" => $lang['lname'],
"lang_fname" => $lang['fname'],
"lang_country" => $lang['country'],
"lang_pprofile" => $lang['pprofile'],
"lang_user_name" => $lang['user_name'],
"lang_full_name" => $lang['full_name'],
"lang_myhomepage" => $lang['myhomepage'],
"lang_author_photos" => $lang['author_photos'],
"lang_author_comments" => $lang['author_comments'],
//"author_comments" => htmlspecialchars($author_comments),
"lang_last_visit" => $lang['last_visit'],
"lang_profile_hits" => $lang['profile_hits'],
"lang_user_points" => $lang['user_points'],
"lang_aboutme" => $lang['aboutme'],
"lang_show" => $lang['show'],
"lang_user_guests" => $lang['user_guests'],
"lang_user_members" => $lang['user_members'],
"lang_field_description" => $lang['field_description'],
"url_sort_date" => $site_sess->url(ROOT_PATH."member.php&action=showcomments&user_id=".$user_row['user_id']),
"url_sort_points" => $site_sess->url(ROOT_PATH."member.phpaction=showcomments&user_id=".$user_row['user_id']."&orderby=1"),
"url_sort_comments" => $site_sess->url(ROOT_PATH."member.phpaction=showcomments&user_id=".$user_row['user_id']."&orderby=2"),
"url_sort_categories" => $site_sess->url(ROOT_PATH."member.phpaction=showcomments&user_id=".$user_row['user_id']."&orderby=3"),
"lang_all_photos" => $lang['all_photos'],
"lang_all_members" => $lang['all_members'],
"lang_all_views" => $lang['all_views'],
"lang_all_votes" => $lang['all_votes'],
"lang_all_comments" => $lang['all_comments'],
"lang_together" => $lang['together'],
"image_albums_add" => $image_albums_add,
"image_albums" => $image_albums,
"image_albums_opt" => $image_albums_opt,
"image_albumsname" => $image_albumsname,
"lang_image_albums" => "Izberite si svoj album:",
"lang_save" => $lang['save'],
"lang_reset" => $lang['reset'],
"url_tnew_images" => $site_sess->url(ROOT_PATH."search.phpsearch_new_images=1"),
"url_top_images" => $site_sess->url(NUKE_PATH."top"),
"url_member_list" => $site_sess->url(NUKE_PATH."memberlist"),
"url_albums" => $site_sess->url(NUKE_PATH."albums&action=addalbums"),
"url_newest_images" => $site_sess->url(NUKE_PATH."search&search_keywords=***"),
"url_user_profile" => $site_sess->url(NUKE_PATH."member&action=showprofile&username="),
"all_images" => "<B>".$all_images."</B>",
"lang_validation" => $lang['awaiting_validation'],
"validation" => "<B>".$valid."</B>",
"lang_new_member" => $lang['new_member_welcome'],
"new_member" => $new_member,
"lang_total_users" => $lang['users'],
"total_users" => $total_users,
"lang_total_hits" => $lang['total_hits'],
"total_hits" => $total_hits,
"lang_total_votes" => $lang['total_votes'],
"total_votes" => $total_votes,
"lang_total_downloads" => $lang['total_downloads'],
"total_downloads" => $total_downloads,
"lang_total_comments" => $lang['total_comments'],
"total_comments" => $total_comments,
"lang_total_postcards" => $lang['total_postcards']
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
3. Create new templates
albums.html
{header}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td>
<!-- TOP -->
<div style="padding-left:10px; padding-right:10px; font:10pt Verdana,sans-serif; vertical-align:top">
<div class="blgabout" style="margin-top: 10px; margin-bottom:10px"><div class="brg"><div class="tlg"><div class="trg">
<table width="100%" border="0" class="head4" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" background="/themes/ExtraLite/images/block-title2.png" ><div id="block-galerija-title">Albumi</div></td>
</tr>
<tr>
<td class="imagerow1">
{if user_loggedin}<div style="text-align:center; padding: 5px"><a href="/modules.php?name=Galerija&file=albums&action=show">Uredi albume</a> | <a href="/modules.php?name=Galerija&file=albums&action=addealbums">Dodaj nov album</a> </div>{endif user_loggedin}
<div style="width: 100%; border-bottom: 3px solid #ffffff"></div>
{if content}
{content}
{endif content}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- END TOP -->{if user_loggedin}
<div style="padding-left:10px; padding-right:10px; font:10pt Verdana,sans-serif; vertical-align:top">
<div class="blgabout" style="margin-top: 10px; margin-bottom:10px"><div class="brg"><div class="tlg"><div class="trg">
<form method="post" action="{url_albums}" name="creator" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="20%"><b>Dodaj nov album:</b></td>
<td width="80%" colspan="2">
<div align="left">
<input type="text" name="user_albums_new" size="50" class="input" /> <input type="submit" value=">>" class="button" />
</div>
</td>
</tr>
<tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
{endif user_loggedin}
<!-- BOTTOM -->
<div style="padding-left:10px; padding-right:10px;">
<div class="blgabout" style="margin-top: 10px; margin-bottom:10px"><div class="brg"><div class="tlg"><div class="trg">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" background="/themes/ExtraLite/images/block-title2.png" ><div id="block-galerija-title">Prisotni</div></td>
</tr>
<tr>
<td>
<div style="padding: 10px; font:10pt Verdana,sans-serif;">{user_online_list2}, {num_guests_online} gostov, (skupaj: {num_total_online})</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- END BOTTOM --></td>
<td valign="top" width="187">
<div style="padding-right:10px">
<div class="blgabout" style="margin-top: 10px; margin-bottom:10px;"><div class="brg"><div class="tlg"><div class="trg">{user_box}
</div>
</div>
</div>
</div>
</div>
<div style="padding-right:10px">
<div class="blgabout" style="margin-top: 10px; margin-bottom:10px;">
<div class="brg">
<div class="tlg">
<div class="trg">
<center>
<script language='JavaScript' type='text/javascript' src='http://www.slo-foto.net/oglasi/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.slo-foto.net/oglasi/adjs.php?n=" + phpAds_random);
document.write ("&what=zone:25");
document.write ("&exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script>
<noscript>
<a href='http://www.slo-foto.net/oglasi/adclick.php?n=adbffcca' target='_blank'><img src='http://www.slo-foto.net/oglasi/adview.php?what=zone:25&n=adbffcca' border='0' alt='' /></a>
</noscript>
</center>
</div>
</div>
</div>
</div>
</div></td>
</tr>
</table>
{footer}
albums_add.html
{if msg}<b>{msg}</b>{endif msg}
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr valign="top">
<td width="100%" class="row2">
<div align="left">
{image_albums}
</div>
</td>
</tr>
</table>
albums_edit.html
{if msg}<b>{msg}</b>{endif msg}
<form method="post" action="{url_albums_edit}" name="creator" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr valign="top">
<td width="20%" class="row2"><b>Popravi ime albuma:</b></td>
<td width="80%" class="row2">
<div align="left">
<input type="text" name="albums_name_edit" size="50" value="{albums_name}" class="input" /> <input type="submit" value=">>" class="button" />
</div>
</td>
</tr>
</table>
</form>
This code still needs LOTS of editing, because guest are allowed to add new albums (?) and many other things...