Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   xBTiT (http://www.bvlist.com/forumdisplay.php?f=30)
-   -   Who can make this work on xbtit? (http://www.bvlist.com/showthread.php?t=7640)

HASU 15th February 2012 13:31

Who can make this work on xbtit?
 
I have 2 weeks work to translate this from tt to xbtit 2.2.2 and results are < nothing so please someone can help ?

Code:

Create Sql

CODE
ALTER TABLE `comments` ADD `photo_gallery` int(11) NOT NULL default '0';

CREATE TABLE `photo_gallery` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL default '0',
`name` varchar(120) NOT NULL default '',
`location` varchar(240) NOT NULL default '',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`numratings` int(10) unsigned NOT NULL default '0',
`ratingsum` int(10) unsigned NOT NULL default '0',
`in_gallery` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
);

CREATE TABLE `my_gallerys` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL default '0',
`gallery_name` varchar(60) NOT NULL default '',
`share_gallery` enum('public','private','friends') NOT NULL default 'public',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=44 DEFAULT CHARSET=latin1 AUTO_INCREMENT=44;

CREATE TABLE `image_ratings` (
`id` int(10) unsigned NOT NULL auto_increment,
`image_id` int(10) unsigned NOT NULL default '0',
`user_id` int(10) unsigned NOT NULL default '0',
`rating` tinyint(3) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `user` (`user_id`)
);

CREATE TABLE `gallery_admin_users` (
`user_class` tinyint(3) NOT NULL default '0',
`gal_per_member` int(4) NOT NULL default '0',
`number_total` int(4) NOT NULL default '0',
`number_of_pics` int(4) NOT NULL default '0',
PRIMARY KEY (`user_class`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `gallery_admin_users` I have ten userclasses, 0 being the lowest... adjust this next bit for how many classes you have
--

INSERT INTO `gallery_admin_users` (`user_class`, `gal_per_member`, `number_total`, `number_of_pics`) VALUES (0, 0, 0, 0),
(1, 2, 20, 1),
(2, 4, 30, 4),
(3, 6, 40, 6),
(4, 8, 50, 8),
(5, 10, 60, 10),
(6, 12, 100, 14),
(7, 14, 100, 14),
(8, 16, 200, 14),
(9, 18, 300, 14),
(10, 3, 400, 14);

CREATE TABLE `gallery_admin` (
`per_page` smallint(4) NOT NULL default '20',
`num_rows` tinyint(2) NOT NULL default '20',
`max_file_size` int(12) NOT NULL default '1048576',
KEY `per_page` (`per_page`),
KEY `num_rows` (`num_rows`),
KEY `max_file_size` (`max_file_size`)
);

INSERT INTO `gallery_admin` (`per_page`, `num_rows`, `max_file_size`) VALUES (20, 5, 1048576);


create

photo_gallery.php new data

CODE
require_once("backend/functions.php");
dbconn(false);
loggedinorreturn();

//=== get info from DB
$res_settings = mysql_query("SELECT * FROM gallery_admin") or sqlerr(__FILE__, __LINE__);
$arr_settings = mysql_fetch_assoc($res_settings);
$max_file_size = $arr_settings['max_file_size']; //1048576;
$perpage = $arr_settings['per_page'];
$num_rows = $arr_settings['num_rows'];

$spacer = '        ';

$page_links = "

view your gallerys | view all galleries | ".
"manage gallerys | upload images".
"".((get_user_class() >= UC_ADMINISTRATOR) ? " | gallery admin" : "")."

";

//=== get defaults from DB
$res_classes = mysql_query("SELECT * FROM gallery_admin_users WHERE user_class = $CURUSER[class]") or sqlerr(__FILE__, __LINE__);
$arr_classes = mysql_fetch_assoc($res_classes);
$number_of_pics = $arr_classes['number_of_pics'];
$number_total = $arr_classes['number_total'];
$gal_per_member = $arr_classes['gal_per_member'];

//=== rating for images function
function ratingpic_image($num) {
global $pic_base_url;
$r = round($num * 2) / 2;
if ($r < 1 || $r > 10)
return;
return "\"rating:";
}

//=== drop down gallery box select and go to gallery
function on_select_gallery_change(){
global $CURUSER;
?>

$res_change = mysql_query("SELECT * FROM my_gallerys WHERE user_id = $CURUSER[id]") or sqlerr(__FILE__, __LINE__);
$galleryz = "";
while ($arr_change = mysql_fetch_assoc($res_change))
$galleryz .= "";
echo "jump to:
";
}

//=== should just add this to css to match the stylesheets :P
?>

//=== drop down gallery select
function gallery_select(){
global $CURUSER;
$res_select = mysql_query("SELECT * FROM `my_gallerys` WHERE `user_id` =$CURUSER[id]") or sqlerr(__FILE__, __LINE__);
$list_select = "";
if (!$res_select)
$list_select .= '';
else
while ($arr_select = mysql_fetch_assoc($res_select))
$list_select .= "";
echo "";
}

//=== galery admin
if ($_GET["gallery_admin"] || $_POST["gallery_admin"]){

if (get_user_class() < UC_ADMINISTRATOR)
stderr("Error", "staff only!");

if ($_POST["edit"]){
mysql_query("UPDATE `gallery_admin` SET `max_file_size` = ".sqlesc(0 + $_POST['max_file_size']).", `per_page` = ".sqlesc(0 + $_POST['per_page']).", `num_rows` = ".sqlesc(0 + $_POST['num_rows']).", `max_file_size` = ".sqlesc(0 + $_POST['max_file_size'])) or sqlerr(__FILE__, __LINE__);
$edited = '

Changes accepted

';
}

//=== update admin settings users
if ($_POST["update_admin_settings"]){

$gal_per_member = $_POST['gal_per_member'];
if (!$gal_per_member)
stderr("Error", "Nothing selected go back.");

foreach ($gal_per_member as $key => $add_it) {

$number_total = $_POST['number_total'];
$number_of_pics = $_POST['number_of_pics'];
$user_class = $_POST['user_class'];
$gal_per_member = sqlesc(0 + $add_it);
$number_total = sqlesc(0 + $number_total[$key]);
$number_of_pics = sqlesc(0 + $number_of_pics[$key]);
$user_class = sqlesc(0 + $user_class[$key]);

mysql_query("UPDATE gallery_admin_users SET gal_per_member = $gal_per_member, number_total = $number_total, number_of_pics = $number_of_pics WHERE user_class = $user_class") or sqlerr(__FILE__, __LINE__);
} //=== end foreach
$edited = '

Changes accepted

';
}//=== update_admin_settings users

$res_settings = mysql_query("SELECT * FROM gallery_admin") or sqlerr(__FILE__, __LINE__);
$arr_settings = mysql_fetch_assoc($res_settings);
//=== make the page
stdhead("Gallery Admin");
begin_table();
echo "

Photo Gallery Admin Page

$page_links$edited\n".
"\n".
"\n".
"\n".
"\n".
"\n".
"";
end_table();
begin_table();
echo "".
"

Photo Gallery Admin Page

general settings:

Max file size: [ in kb ]
Images per page:
Number or rows per page:
".
"\n".
"\n".
"\n";

for ($i = 0; $i <= UC_SYSOP; ++$i){
$res_classes = mysql_query("SELECT * FROM gallery_admin_users WHERE user_class = $i") or sqlerr(__FILE__, __LINE__);
$arr_classes = mysql_fetch_assoc($res_classes);
//=======change colors
$count2= (++$count2)%2;
$class = 'clearalt'.($count2==0?'6':'7');
echo"".
"".
"".
"\n";
}
echo"";

end_table();
stdfoot();
die();
}//=== end galery admin

//=== count of entered images
$res = mysql_query("SELECT COUNT(*) FROM photo_gallery WHERE user_id=" . $CURUSER["id"]) or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_row($res);
$count = $arr[0];

//=== rate image /// will add a change your rating option to this :)
if ($_GET["takerate"]){
$id = isset($_GET['takerate']) ? (int)$_GET['takerate'] : 0;
if(!is_valid_id($id))
stderr("Error", "Bad Id!");

$rate_me = isset($_GET['rate_me']) ? (int)$_GET['rate_me'] : 0;
if ($rate_me <= 0 || $rate_me > 10)
stderr("Error", "invalid rating number");

$res = mysql_query("SELECT image_id, user_id, rating FROM image_ratings WHERE image_id = $id AND user_id = $CURUSER[id]");
$row = mysql_fetch_array($res);

if (!$row){ //=== add new rating
mysql_query("INSERT INTO image_ratings (image_id, user_id, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rate_me, NOW())");
mysql_query("UPDATE photo_gallery SET numratings = numratings + 1, ratingsum = ratingsum + $rate_me WHERE id = $id");
header("Location: photo_gallery.php?info=$id&rated=1");
die();
}
else { //=== change rating
mysql_query("UPDATE image_ratings SET rating = $rate_me WHERE image_id = $id AND user_id = $CURUSER[id]");
mysql_query("UPDATE photo_gallery SET ratingsum = ratingsum + $rate_me - $row[rating] WHERE id = $id");
header("Location: photo_gallery.php?info=$id&rate_changed=1");
die();
}
}

//=== add comment
if ($_GET['comment']){
$photo_id = isset($_GET['comment']) ? (int)$_GET['comment'] : 0;
if(!is_valid_id($photo_id))
stderr("Error", "Bad Id!");

if(isset($_POST['pic_comment']) && $_POST['pic_comment'] == '')
stderr("Error", "comment body can not be empty! use your back button and fill in some text!");

$added = sqlesc(get_date_time());
$pic_comment = sqlesc($_POST["pic_comment"]);

mysql_query("INSERT INTO comments (user, text, ori_text, photo_gallery, added) VALUES(".sqlesc($CURUSER["id"]).", $pic_comment, $pic_comment, $photo_id, $added)") or sqlerr(__FILE__, __LINE__);
header("Location: photo_gallery.php?info=$photo_id&edited=1");
die();
}

//=== edit comment
if ($_GET['edit_comment']){
$edit_comment = isset($_GET['edit_comment']) ? (int)$_GET['edit_comment'] : 0;
if(!is_valid_id($edit_comment))
stderr("Error", "Bad Id!");

$photo_id = isset($_GET['photo_id']) ? (int)$_GET['photo_id'] : 0;
if(!is_valid_id($photo_id))
stderr("Error", "Bad Id!");

if(isset($_POST['pic_comment']) && $_POST['pic_comment'] == '')
stderr("Error", "comment body can not be empty! use your back button and fill in some text!");

$sure = isset($_GET['sure']) ? (int)$_GET['sure'] : 0;
if ($sure === 1){

$res_gal = mysql_query("SELECT text,id FROM comments WHERE id = ".sqlesc($edit_comment)) or sqlerr(__FILE__, __LINE__);
$arr_gal = mysql_fetch_assoc($res_gal);

stdhead("edit comment");
begin_table();

echo "$page_links

user class settings:

more stuff here like stuff about user calsses etc.
user classclass id".
"# of pics at a time
total number of picsnumber of galleries total
" . get_user_class_name($i) . ":$i".
"

Edit comment

".
"

".
"".
"".
"
Edit comment
comment:
";

end_table();
stdfoot();
}
if ($sure === 2){
$added = sqlesc(get_date_time());
$pic_comment = sqlesc($_POST["pic_comment"]);

mysql_query("UPDATE comments SET text = $pic_comment, editedby = ".sqlesc($CURUSER["id"]).", editedat = $added WHERE id = ".sqlesc($edit_comment))or sqlerr(__FILE__, __LINE__);
header("Location: photo_gallery.php?info=$photo_id&edited=1");
}
}

//=== delete comment
if ($_GET['delete_comment']){

$comment_id = isset($_GET['delete_comment']) ? (int)$_GET['delete_comment'] : 0;
if(!is_valid_id($comment_id))
stderr("Error", "Bad Id!");

$photo_id = isset($_GET['photo_id']) ? (int)$_GET['photo_id'] : 0;
if(!is_valid_id($photo_id))
stderr("Error", "Bad Id!");

if (!$_GET['sure'])
stderr("Confirm!", "are you sure you want to delete this comment? YES - NO..");
mysql_query("DELETE FROM comments WHERE id = ".sqlesc($comment_id));
header("Location: photo_gallery.php?info=$photo_id&edited=1");
}

//=== add new gallery
if ($_GET['manage']){

//=== count of entered images
$res_c = mysql_query("SELECT COUNT(*) FROM my_gallerys WHERE user_id=" . $CURUSER["id"]) or sqlerr(__FILE__, __LINE__);
$arr_c = mysql_fetch_row($res_c);
if(($count_c = $arr_c[0]) >= $gal_per_member)
stderr("Error!", "As a ".get_user_class_name($CURUSER['class'])." you may have up to $gal_per_member gallerys, you now have $count_c.");

$need = array('public', 'private', 'friends');
if ($_POST["new_gallery"] === '' || !in_array($_POST["gal_share_new"], $need))
stderr("Error!", "you must enter both a name and a share for your new gallery.");

$name = mysql_real_escape_string(htmlspecialchars($_POST["new_gallery"]));

//=== add check to see if name exists...
$res_gal_name = mysql_query("SELECT gallery_name FROM my_gallerys WHERE user_id = ".sqlesc($CURUSER['id'])." AND gallery_name = '$name'") or sqlerr(__FILE__, __LINE__);
$arr_gal_name = mysql_num_rows($res_gal_name);

if ($arr_gal_name > 0)
stderr("Error", "That gallery name exists.");

$gal_share_new = sqlesc($_POST["gal_share_new"]);

mysql_query("INSERT INTO my_gallerys (user_id, gallery_name, share_gallery) VALUES(".sqlesc($CURUSER["id"]).", '$name', $gal_share_new)") or sqlerr(__FILE__, __LINE__);
header("Location: photo_gallery.php?manage_gallerys=1&edited=1");
}

//=== edit gallery
if ($_GET['edit']){

if ($_POST["gallery_name"] === '')
stderr("Error!", "you must enter a name for your gallery.");

$gallery_name = mysql_real_escape_string(htmlspecialchars($_POST["gallery_name"]));

//=== add check to see if name exists...
$res_gal_name = mysql_query("SELECT gallery_name FROM my_gallerys WHERE user_id = ".sqlesc($CURUSER['id'])." AND gallery_name = '$gallery_name'") or sqlerr(__FILE__, __LINE__);
$arr_gal_name = mysql_num_rows($res_gal_name);

if ($arr_gal_name >= 1)
stderr("Error", "That gallery name exists.");

$gal_share = sqlesc($_POST["gal_share"]);
$id = sqlesc(0 + $_POST["id"]);

mysql_query("UPDATE my_gallerys SET gallery_name = '$gallery_name', share_gallery = $gal_share WHERE user_id = ".sqlesc($CURUSER["id"])." AND id = $id") or sqlerr(__FILE__, __LINE__);
header("Location: photo_gallery.php?manage_gallerys=1&edited=1");
}

//=== delete gallery
if ($_GET['delete_gallery']){
$id = sqlesc(0 + $_GET["id"]);

$res_gal = mysql_query("SELECT user_id FROM my_gallerys WHERE id = $id") or sqlerr(__FILE__, __LINE__);
$arr_gal = mysql_fetch_assoc($res_gal);

if ($arr_gal['user_id'] !== $CURUSER['id'] && get_user_class() < UC_MODERATOR)
stderr("Error", "This is not your gallery to delete!");

mysql_query("DELETE FROM my_gallerys WHERE id = $id");
header("Location: photo_gallery.php?manage_gallerys=1&edited=1");
}

//=== manage galleries
if ($_GET['manage_gallerys']){

$res_mg = mysql_query("SELECT * FROM my_gallerys WHERE user_id=" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__,__LINE__);
?>

stdhead("Manage Gallerys");
begin_table();

echo "

$CURUSER[username]'s Photo Gallery Manager$page_links".
"".($_GET["edited"] == '1' ? "

Update successfull

" : "")."".
"";
while ($row_mg = mysql_fetch_assoc($res_mg)){
$id = 0 + $row_mg['id'];
echo"";
}
echo "
My Gallery Manager

From here you can add new galleries, edit existing ones, and change how you would like to share them...".
" publically, with friends or not at all

".
"add new gallery: share this gallery: ".
" public private".
" friends
".
"
Manage My Gallerys
gallery name:".
" ".
" public ".
" private".
" friends ".
" ".
"
";
on_select_gallery_change();
end_table();
stdfoot();
die();
}

//=== edit multi
if ($_GET["multi_edit"]){

$user_id = 0 + $_POST['user_id'];
if ($user_id != $CURUSER['id'] && get_user_class() < UC_MODERATOR)
stderr("Error", "this in not your gallery to edit!.");
$edit= $_POST['image'];
if (!$edit)
stderr("Error", "Nothing selected go back.");

foreach ($edit as $key => $add_it) {

$image_id = $_POST['image_id'];
$move_to_gallery = $_POST['move_to_gallery'];
$image_id = sqlesc(0 + $image_id[$key]);
$move_to_gallery = sqlesc(0 + $move_to_gallery[$key]);
$name = " name = '".mysql_real_escape_string(htmlspecialchars($add_it))."', ";
mysql_query("UPDATE photo_gallery SET $name in_gallery = $move_to_gallery WHERE user_id = ".sqlesc($user_id)." AND id = $image_id") or sqlerr(__FILE__, __LINE__);
} //=== end foreach

stderr("Sucess!", "
Images have been up-dated. Would you like to  ".
"view your gallerys | view all galleries | ".
"manage gallerys | upload images".
"".((get_user_class() >= UC_ADMINISTRATOR) ? " | gallery admin" : "")."
");
die();
}//=== end edit multi

//=== Delete and edit images
if ($_GET["delete_or_edit"]){

if (!isset($_POST[delete_image]) && !isset($_POST[edit_image]))
stderr("Error", "Nothing selected go back.");
if (isset($_POST[delete_image]) && isset($_GET[edit_image]))
stderr("Error", "you can't both delete AND edit images! go back and make a decision!");

if ($_POST['edit_image']){

//=== make the page
stdhead("Edit image multi");
begin_table();
echo "

Edit Images

$page_links\n".
"\n";

$edit= $_POST['edit_image'];
foreach ($edit as $edit_id) {
//=======change colors
$count2= (++$count2)%2;
$class = 'clearalt'.($count2==0?'6':'7');

$res = mysql_query("SELECT * FROM photo_gallery WHERE id=".sqlesc($edit_id));
$arr = mysql_fetch_assoc($res);

$image = array_values(getimagesize("bitbucket/".htmlentities($arr['location']).""));
list($width, $height) = $image;
$image_size = "bitbucket/".htmlentities($arr_gal['location'])."";

$res_select = mysql_query("SELECT * FROM `my_gallerys` WHERE `user_id` =$arr[user_id]") or sqlerr(__FILE__, __LINE__);
$list_select = "";
if (!$res_select)
$list_select .= '';
else
while ($arr_select = mysql_fetch_assoc($res_select))
$list_select .= "";

$our_image = htmlentities("/bitbucket/thumbs/$arr[location]");
echo"\n";
} //=== end for each
echo"";
end_table();
stdfoot();
die();
} //=== end edit images

if ($_POST['delete_image'])

$checked= $_POST['delete_image'];

foreach ($checked as $delete) {
//=== get file to delete
$res = mysql_query("SELECT location, user_id FROM photo_gallery WHERE id=".sqlesc($delete));
$arr = mysql_fetch_assoc($res);

if ($arr['user_id'] !== $CURUSER['id'] && get_user_class() < UC_MODERATOR)
stderr("Error", "This is not your image to delete!");

//=== delete image and thumb
$filepath_thumb = "./bitbucket/thumbs/$arr[location]";
$filepath = "./bitbucket/$arr[location]";
unlink($filepath);
unlink($filepath_thumb);

//=== remove other stuff
mysql_query ("DELETE FROM photo_gallery WHERE user_id = $arr[user_id] AND id=".sqlesc($delete));
mysql_query ("DELETE FROM image_ratings WHERE image_id=".sqlesc($delete));
mysql_query ("DELETE FROM comments WHERE photo_gallery=".(0 + $delete));
header("Location: ".$_SERVER['HTTP_REFERER']."&deleted=1");
}
}

//=== image info edit
if ($_GET['edit_image_info']){

$photo_id = isset($_GET['edit_image_info']) ? (int)$_GET['edit_image_info'] : 0;
if(!is_valid_id($photo_id))
stderr("Error", "Bad Id!");

$res_gal = mysql_query("SELECT * FROM photo_gallery WHERE id = $photo_id") or sqlerr(__FILE__, __LINE__);
$arr_gal = mysql_fetch_assoc($res_gal);

if ($arr_gal['user_id'] !== $CURUSER['id'] && get_user_class() < UC_MODERATOR)
stderr("Error", "This is not your image to edit!");

if (!$_GET['sure']){

$res_select = mysql_query("SELECT * FROM `my_gallerys` WHERE `user_id` =$arr_gal[user_id]") or sqlerr(__FILE__, __LINE__);
$list_select = "";
if (!$res_select)
$list_select .= '';
else
while ($arr_select = mysql_fetch_assoc($res_select))
$list_select .= "";

stdhead("Edit image info");
begin_table();

$image = array_values(getimagesize("bitbucket/$arr_gal[location]"));
list($width, $height) = $image;
$image_size = "bitbucket/$arr_gal[location]";

if ($width >= "400")
$show_image = "";
else
$show_image = "";

echo "$page_links

Edit image info

".($_GET["edited"] == '1' ? "

Update successfull

" : "")."".
"
Photo Gallery multi edit
".
"$width x $height [ ".mksize(filesize($image_size))." ]
".
"Image title:move to gallery:
".
"".
"
".
"
Edit: $arr_gal[name]
added on: $arr_gal[added]".
"$show_imageImage title: ".
" ".
"file name: ".htmlentities($arr_gal['location'])." dimentions: $width x $height | file size: ".mksize(filesize($image_size))."".
"location: $BASEURL/bitbucket/".htmlspecialchars($arr_gal['location'])." ".
"
";

on_select_gallery_change();
end_table();
stdfoot();
die();
}
//=== make the changes
if($_POST['name'] == '')
stderr("Error", "This image must have a name! use your back button and fill in some text!");

$name = mysql_real_escape_string(htmlspecialchars($_POST["name"]));
$in_gallery = sqlesc(0 + $_POST['gallery']);

mysql_query("UPDATE photo_gallery SET name = '$name', in_gallery = $in_gallery WHERE user_id = ".sqlesc($arr_gal['user_id'])." AND id = $photo_id") or sqlerr(__FILE__, __LINE__);
header("Location: photo_gallery.php?info=$photo_id&edited=1");
}

//=== image info page
if ($_GET['info']){

$photo_id = isset($_GET['info']) ? (int)$_GET['info'] : 0;
if(!is_valid_id($photo_id))
stderr("Error", "Bad Id!");

$res_gal = mysql_query("SELECT p_g.*, m_g.gallery_name, u.username, u.id AS uid FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id LEFT JOIN users AS u ON u.id = p_g.user_id WHERE p_g.id = $photo_id") or sqlerr(__FILE__, __LINE__);
$arr_gal = mysql_fetch_assoc($res_gal);

?>


//=== get image rating
if ($arr_gal["numratings"] != 0)
$rating = ROUND($arr_gal["ratingsum"] / $arr_gal["numratings"], 1);
$rpic = ratingpic_image($rating);

if ($rpic == '')
$rate_first = "Rate Image:";
else
$rate_first = "Rating:";

stdhead("Image Info");
begin_table();

$image = array_values(getimagesize("bitbucket/".htmlentities($arr_gal['location']).""));
list($width, $height) = $image;
$image_size = "bitbucket/".htmlentities($arr_gal['location'])."";
$pop_up_thingie = "bitbucket/".htmlentities($arr_gal['location']);

if ($width >= "500")
$show_image = "".
"
".
"[ this image has been re-sized to fit this window. click the image to view full size ]";
else
$show_image = "".
"
";

echo "

Photo Gallery

$arr_gal[username]'s Photo Gallery

$page_links

".
"back to gallery

".
"".($_GET["edited"] == '1' ? "

Update successfull

" : "").($_GET["rated"] == '1' ? "

Image rated

" : "").($_GET["rate_changed"] == '1' ? "

Image rating changed

" : "")."".
"
".
"
".htmlentities($arr_gal['name'])."
added on: $arr_gal[added] by: $arr_gal[username]".
"$spacer".($arr_gal['user_id'] === $CURUSER['id'] || get_user_class() >= UC_MODERATOR ? "[ edit".
" ] [ delete ]" : "")."$show_image$rate_first $rpic $spacer ".($arr_gal['numratings'] > 0 ? "[ $rating / 10 ]" : "$rating")."".
"title: $arr_gal[name] | file name: $arr_gal[location] | dimentions: $width x $height | file size: ".mksize(filesize($image_size))."".
"in gallery: ".(!$arr_gal['gallery_name'] ? " [ no gallery selected ]" : "".htmlentities($arr_gal['name'])."")." image location: $BASEURL/bitbucket/".htmlentities($arr_gal['location'])." ".
"view comments |".
"add a comment".
"
comment:".
"
";
while ((list($code, $url) = each($smilies)) && $t<25) {
echo"";
$t++;
}
echo "
".
"";

$res_gal = mysql_query("SELECT c.text, c.id, c.added AS c_added, c.editedby, c.ori_text, u.username, u.avatar, u.id AS uid FROM comments AS c LEFT JOIN users AS u ON u.id = c.user WHERE c.photo_gallery = $photo_id ORDER BY c.id DESC $limit") or sqlerr(__FILE__, __LINE__);

while ($arr_gal = mysql_fetch_assoc($res_gal)) {

$avatar = "";
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($arr_gal["avatar"]) : "");
if (!$avatar)
$avatar = "/images/default_avatar.gif";

$added = $arr_gal["c_added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr_gal["c_added"]))) . " ago)";

if ($arr_gal['editedby'] > 0){
$res2 = mysql_query("SELECT username FROM users WHERE id=$arr_gal[editedby]");
$arr2 = mysql_fetch_assoc($res2);
$edited = "


Last edited by $arr2[username] at $arr_gal[editedat] GMT

";
}

//=======change colors
$count2= (++$count2)%2;
$class = 'clearalt'.($count2==0?'6':'7');
echo"";
}
echo '
#$arr_gal[id]$spacer by: $arr_gal[username]".
" $spacer at: $added $spacer$spacer ".($arr_gal['uid'] === $CURUSER['id'] || get_user_class() >= UC_MODERATOR ? "[ delete ] $spacer [ edit ]" : "")."".
" ".(get_user_class() >= UC_MODERATOR && $arr_gal[editedby] > 0 ? "$spacer [ ".
"view original
]" : "")." $spacer [ pm ]".
"
".format_comment($arr_gal["text"])."$edited".
"

original comment:
".format_comment($arr_gal["ori_text"])."
';
on_select_gallery_change();
end_table();
stdfoot();
die();
}

//=== other members gallery pages
if ($_GET['member_gallery']){
?>

$member_id = sqlesc(0 + $_GET['member_gallery']);

//=== get friends
$res_pals = mysql_query("SELECT id FROM friends WHERE $CURUSER[id] = friendid AND $member_id = userid") or sqlerr();
$arr_pals = mysql_num_rows($res_pals);

if ($arr_pals > 0){
$where .= "WHERE p_g.user_id=$member_id AND m_g.share_gallery !='private'";
$res_gal = mysql_query("SELECT DISTINCT p_g.in_gallery, m_g.gallery_name, m_g.share_gallery FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id WHERE m_g.share_gallery != 'private' AND m_g.user_id = $member_id ORDER BY m_g.gallery_name") or sqlerr(__FILE__, __LINE__);
}
else {
$where .= "WHERE p_g.user_id=$member_id AND m_g.share_gallery !='private' AND m_g.share_gallery !='friends'";
$res_gal = mysql_query("SELECT DISTINCT p_g.in_gallery, m_g.gallery_name FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id WHERE m_g.share_gallery = 'public' AND m_g.user_id = $member_id ORDER BY m_g.gallery_name") or sqlerr(__FILE__, __LINE__);
}
while ($arr_gal = mysql_fetch_assoc($res_gal))
$gal_name .= "• ".htmlentities($arr_gal['gallery_name'])."".($arr_gal["share_gallery"] == 'friends' ? "" : '')." ";

//=== if a gallery is selected...
if ($_GET["gallery"]){
$where .= "AND p_g.in_gallery =".sqlesc(( 0 + $_GET["gallery"]));
$get_gallery = "&gallery=".( 0 + $_GET["gallery"]);
}

$page = 0 + $_GET['page'];

$res = mysql_query("SELECT p_g.*, m_g.share_gallery, m_g.gallery_name FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id $where") or sqlerr(__FILE__, __LINE__);
$arr = mysql_num_rows($res);
$gallery_name = mysql_fetch_assoc($res);

$pages = floor($arr / $perpage);
if ($pages * $perpage < $arr)
++$pages;

if ($page < 1)
$page = 1;
else
if ($page > $pages)
$page = $pages;

for ($i = 1; $i <= $pages; ++$i)
if ($i == $page)
$pagemenu .= "$i\n";
else
$pagemenu .= "$i\n";

if ($page == 1)
$browsemenu .= " Prev";
else
$browsemenu .= " Prev";

$browsemenu .= "  $pagemenu  ";

if ($page == $pages)
$browsemenu .= "Next >\">";
else
$browsemenu .= "Next >\">";

$offset = ($page * $perpage) - $perpage;

$res_name = mysql_query("SELECT username FROM users WHERE id=$member_id LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr_name = mysql_fetch_assoc($res_name);
$name = $arr_name['username'];

//=== make the page
stdhead("Photo Gallery");
begin_table();

echo "

$name's Photo Gallery

$page_links".($_GET["deleted"] == '1' ? "

Image deleted

" : "").($_GET["rated"] == '1' ? "

Image rated

" : "")."".
"$browsemenu

$name's other galleries:: $gal_name

".
"";
$c2 = 0;
$c = 1;
$res_gal = mysql_query("SELECT p_g.*, m_g.share_gallery FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id $where LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__);
while ($arr_gal = mysql_fetch_assoc($res_gal)) {
if ($c = $num_rows)
$c = 1;
if ($c2 % $num_rows==0)
echo'';

$image = array_values(getimagesize("bitbucket/".htmlentities($arr_gal['location']).""));
list($width, $height) = $image;
$image_size = "bitbucket/".htmlentities($arr_gal['location'])."";

//=== get image rating
if ($arr_gal["numratings"] != 0)
$rating = ROUND($arr_gal["ratingsum"] / $arr_gal["numratings"], 1);
$rpic = ratingpic_image($rating);
$test = ($c2 % $num_rows==0);
echo"";
$c2++;
$c++;
if ($c2 % $num_rows==0 && $c = $num_rows)
echo'';
}
if ($c < $num_rows){
while ($c < $num_rows){
echo '';
$c++;
}
echo '';
}

echo "
Gallery :: ".htmlentities($gallery_name[gallery_name])." $spacer[ $arr images]
".
"".($arr_gal["numratings"] != 0 ? "rating: $rpic" : "")."".htmlentities($arr_gal['name'])."
".
"$width x $height [ ".mksize(filesize($image_size))." ]".
"".($CURUSER['id'] === $arr_gal['user_id'] || get_user_class() >= UC_MODERATOR ? "[ edit ] ".
" [ delete ]" : "")."
".
"added: $arr_gal[added]
".
"".($CURUSER['id'] === $arr_gal['user_id'] || get_user_class() >= UC_MODERATOR ? "select all delete - ".
"un-select all delete$spacer $spacer".
"select all edit - ".
"un-select all edit".
"$spacer $spacer".
"" : "Gallery :: ".htmlentities($gallery_name['gallery_name'])." $spacer[ $arr images]")."
$browsemenu";

on_select_gallery_change();
end_table();
stdfoot();
die();
}

//=== members gallery pages
if ($_GET['my_gallery']){

$where .= "WHERE p_g.user_id=".sqlesc($CURUSER['id']);
//=== if a gallery is selected...
if ($_GET["gallery"]){
$where .= " AND p_g.in_gallery =".sqlesc(( 0 + $_GET["gallery"]));
$get_gallery = "&gallery=".( 0 + $_GET["gallery"]);
}

$page = 0 + $_GET['page'];

$res = mysql_query("SELECT p_g.*, m_g.share_gallery, m_g.gallery_name FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id $where") or sqlerr(__FILE__, __LINE__);
$arr = mysql_num_rows($res);
$name = mysql_fetch_assoc($res);

$res_gal = mysql_query("SELECT DISTINCT p_g.in_gallery, m_g.gallery_name FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id WHERE m_g.user_id = $CURUSER[id] ORDER BY m_g.gallery_name") or sqlerr(__FILE__, __LINE__);
while ($arr_gal = mysql_fetch_assoc($res_gal))
$gal_name .= "• ".htmlentities($arr_gal['gallery_name'])."".($arr_gal["share_gallery"] == 'friends' ? "" : '')." ";


$pages = floor($arr / $perpage);
if ($pages * $perpage < $arr)
++$pages;

if ($page < 1)
$page = 1;
else
if ($page > $pages)
$page = $pages;

for ($i = 1; $i <= $pages; ++$i)
if ($i == $page)
$pagemenu .= "$i\n";
else
$pagemenu .= "$i\n";

if ($page == 1)
$browsemenu .= " Prev";
else
$browsemenu .= " Prev";

$browsemenu .= "  $pagemenu  ";

if ($page == $pages)
$browsemenu .= "Next >\">";
else
$browsemenu .= "Next >\">";

$offset = ($page * $perpage) - $perpage;

//=== make the page
stdhead("Photo Gallery");
begin_table();

echo "

$CURUSER[username]'s Photo Gallery

$page_links".($_GET["deleted"] == '1' ? "

Image deleted

" : "").($_GET["rated"] == '1' ? "

Image rated

" : "").($_GET["edited"] == '1' ? "

Image edited

" : "")."".
"$browsemenumy galleries: $gal_name
".
"";
$c2 = 0;
$c = 1;
$res_gal = mysql_query("SELECT p_g.*, m_g.share_gallery FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id $where LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__);
while ($arr_gal = mysql_fetch_assoc($res_gal)) {

if ($c = $num_rows)
$c = 1;
if ($c2 % $num_rows==0)
echo'';

$image = array_values(getimagesize("bitbucket/".htmlentities($arr_gal['location']).""));
list($width, $height) = $image;
$image_size = "bitbucket/".htmlentities($arr_gal['location'])."";

//=== get image rating
if ($arr_gal["numratings"] != 0)
$rating = ROUND($arr_gal["ratingsum"] / $arr_gal["numratings"], 1);
$rpic = ratingpic_image($rating);
$test = ($c2 % $num_rows==0);
echo"";
$c2++;
$c++;
if ($c2 % $num_rows==0 && $c = $num_rows)
echo'';
}
if ($c < $num_rows){
while ($c < $num_rows){
echo '';
$c++;
}
echo '';
}

echo "
".(!$_GET["gallery"] ? "My Gallerys " : "My Gallery :: ".htmlentities($name['gallery_name'])."")." $spacer[ $arr images]
".
"".($arr_gal["numratings"] != 0 ? "rating: $rpic" : "")."".htmlentities($arr_gal['name'])."
".
"$width x $height [ ".mksize(filesize($image_size))." ]".
"".($CURUSER['id'] === $arr_gal['user_id'] || get_user_class() >= UC_MODERATOR ? "[ edit ] ".
" [ delete ]" : "")."
".
"added: $arr_gal[added]
select all delete - ".
"un-select all delete$spacer $spacer".
"select all edit - ".
"un-select all edit".
"$spacer $spacer".
"
$browsemenu";

on_select_gallery_change();
end_table();
stdfoot();
die();
}

//=== enter the images into the DB with user ID names and comments
if ($_GET['name_images']) {

$added = sqlesc(get_date_time());
$image= $_POST['image'];

foreach ($image as $key => $add_it) {

$location = $_POST['location'];
$pic_comment = $_POST['pic_comment'];
$add_to_gallery = $_POST['add_to_gallery'];

$name = mysql_real_escape_string(htmlspecialchars($add_it));
$location = sqlesc(str_replace(" ", "%20", htmlentities($location[$key])));
if ($pic_comment[$key] != '')
$pic_comment = sqlesc($pic_comment[$key]);
else
$no_comment = 1;
$add_to_gallery = sqlesc(0 + $add_to_gallery[$key]);

mysql_query("INSERT INTO photo_gallery (user_id, name, location, in_gallery, added) VALUES(".sqlesc($CURUSER["id"]).", '$name', $location, $add_to_gallery, $added)") or sqlerr(__FILE__, __LINE__);
$photo_gallery = mysql_insert_id();
if(!$no_comment)
mysql_query("INSERT INTO comments (user, text, photo_gallery, added) VALUES(".sqlesc($CURUSER["id"]).", $pic_comment, $photo_gallery, $added)") or sqlerr(__FILE__, __LINE__);
}
stderr("Sucess!", "
all images have been placed. Would you like to  ".
"view your gallerys | view all galleries | ".
"manage gallerys | upload images".
"".((get_user_class() >= UC_ADMINISTRATOR) ? " | gallery admin" : "")."
");
}

//=== if post
if ($_SERVER["REQUEST_METHOD"] === "POST"){

if ($count >= $number_total)
stderr("Error", "You have reached the max number of images to upload. Your total number of allowed images are ".
"$number_total and you have uploaded $count$page_links");

$image_count = 0;
$size_error_count = 0;
$file_exists_error_count = 0;
while(list($key,$value) = each($_FILES[images][name]))
{
if(!empty($value)){
$filename = htmlentities($value);
$add = "bitbucket/$filename";
$file_type = $_FILES[images][type][$key];

if (!($file_type =="image/jpeg" OR $file_type=="image/gif" OR $file_type=="image/png"))
stderr("Error", "Image MUST be in jpg, gif or png format.");

//=== get image size
$file_size = $_FILES[images][size][$key];
//=== error if file too big
if ($file_size > $max_file_size){
$size_error_count = + 1;
$size_error[] = array ('image' => $filename, 'size' => $file_size);
}
elseif (file_exists($add)){
$file_exists_error_count = + 1;
$file_exists_error[] = array ('image' => $filename);
}
else {
copy($_FILES[images][tmp_name][$key], $add);
chmod("$add",0777);

if($filename)
$image_count = (++$image_count);

//=== make thumbnails
$thumb_dir="bitbucket/thumbs/$filename";
//=== gif
if (@$file_type=="image/gif"){
$im=ImageCreateFromGIF($add);
$width=ImageSx($im);
$height=ImageSy($im);
//=== lets do some math :P
if ($height > 99 || $width > 99){
if ($height >= $width){
$thumb_height=100;
$thumb_width = ($thumb_height / $height * $width);
}
else {
$thumb_width=100;
$thumb_height = ($thumb_width / $width * $height);
}
}
else {
$thumb_width=$width;
$thumb_height =$height;
}
$newimage=imagecreatetruecolor($thumb_width,$thumb_height);
imageCopyResized($newimage,$im,0,0,0,0,$thumb_width,$thumb_height,$width,$height);

if (function_exists("imagegif"))
ImageGIF($newimage,$thumb_dir);
elseif (function_exists("imagejpeg"))
ImageJPEG($newimage,$thumb_dir);

chmod("$thumb_dir",0777);
}
//=== jpg
if($file_type=="image/jpeg"){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im);
$height=ImageSy($im);
//=== lets do some math :P
if ($height > 99 || $width > 99){
if ($height >= $width){
$thumb_height=100;
$thumb_width = ($thumb_height / $height * $width);
}
else {
$thumb_width=100;
$thumb_height = ($thumb_width / $width * $height);
}
}
else {
$thumb_width=$width;
$thumb_height =$height;
}
$newimage=imagecreatetruecolor($thumb_width,$thumb_height);
imageCopyResized($newimage,$im,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
ImageJpeg($newimage,$thumb_dir);
chmod("$thumb_dir",0777);
}
//=== png
if (@$file_type=="image/png"){
$im=ImageCreateFrompng($add);
$width=ImageSx($im);
$height=ImageSy($im);
//=== lets do some math :P
if ($height > 99 || $width > 99){
if ($height >= $width){
$thumb_height=100;
$thumb_width = ($thumb_height / $height * $width);
}
else {
$thumb_width=100;
$thumb_height = ($thumb_width / $width * $height);
}
}
else {
$thumb_width=$width;
$thumb_height =$height;
}
$newimage=imagecreatetruecolor($thumb_width,$thumb_height);
imageCopyResized($newimage,$im,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
ImagePNG($newimage,$thumb_dir);
chmod("$thumb_dir",0777);
}

}
}//=== end if image exists

//==== let's put all the info into an array, thanks Laffin! :P
if (!empty($value))
$image_info[] = array ( 'location' => $thumb_dir, 'image' => $filename, 'size' => $file_size, 'width' => $width, 'height' => $height);
}//=== end while

$res_select = mysql_query("SELECT * FROM `my_gallerys` WHERE `user_id` =$CURUSER[id]") or sqlerr(__FILE__, __LINE__);
$list_select = "";
while ($arr_select = mysql_fetch_assoc($res_select))
$list_select .= "";

if (mysql_num_rows($res_select) === 0){
$list_select = "";
mysql_query("INSERT INTO my_gallerys (user_id, gallery_name, share_gallery) VALUES(".sqlesc($CURUSER["id"]).", 'Default', 'public')") or sqlerr(__FILE__, __LINE__);
$gallery_id = mysql_insert_id();
$list_select .= "";
}

stdhead("Names and comments");
begin_table();
echo "

$SITENAME Photo Gallery

$page_links".
"
";

if ($image_count > 0){
echo"";
$button = "";
}

$count_image = count($image_info);
for ($i=0;$i<$count_image;$i++) {
$image_size = "".mksize($image_info[$i]['size'])." ".$image_info[$i]['width']." x ".$image_info[$i]['height'];
//=== set stuff for loop
if($image_info[$i]['width'] > 0)
echo"";
}

//=== file_exists_error
if ($file_exists_error_count > 0){
$file_exists_error_count = count($file_exists_error);
echo"";
}//=== end file exists error

//=== file too big error //== not totally tested...
if ($size_error_count > 0){
$size_error_count = count($size_error);
echo"";
}//=== end file too big error

echo $button;

echo'
Photo Gallery upload
If you wish to give your images titles, or add comments to them, ".
"do it now. If not just click the add to gallery button below.
$image_size".
"Add to gallery: ".
"Image title: [ default is the image name ]Comment:".
" [ BBcode is ok ]

File name error!

".
"The following file".($file_exists_error_count > 1 ? "s were" : " was")." not uploaded!";

for ($i=0;$i<$file_exists_error_count;$i++) {
echo "".htmlentities($file_exists_error[$i]['image'])."";
}
echo"".($file_exists_error_count > 1 ? " Files with the same names exist on the server. Re-name the files and try again." : " a file with that name exists on the server. Re-name the file and try again.")."

File size error!

".
"The following file".($size_error_count > 1 ? "s were" : " was")." not uploaded!";

for ($i=0;$i<$size_error_count;$i++) {
echo "".htmlentities($size_error[$i]['image'])." size was ".mksize($size_error[$i]['size'])."";
}
echo"Maximum file size is: ".mksize($max_file_size).".
';
on_select_gallery_change();
end_table();
stdfoot();
die();
}//=== end if $_POST

if ($_GET['upload']){
//=== the upload page
stdhead("Photo Gallery upload");
begin_table();

echo "

$SITENAME Photo Gallery$page_links".
"

" : "

The maximum file size to upload is: ".mksize($max_file_size).". [ per file ]".
"Allowed formats are .jpg .gif .pngAs a ".get_user_class_name($CURUSER['class'])." you may upload up to $number_of_pics images at a time. ".
"You may also have up to $number_total images in the gallery.Currently you have $count images in the gallery.Before uploading anything please read the Rules".
"
and FAQ

")."";
for($i=1; $i<=$number_of_pics; $i++){
echo "";
}

echo "".
"
Photo Gallery upload
".
"".($number_total == 0 ? "

Sorry, you do not have access to this feature

Upload photo $i:

".
"Disclaimer: Do not upload unauthorized or illegal pictures. Please see the ".
"FAQ for details.
";
on_select_gallery_change();
end_table();
stdfoot();
die();
}

//=== list public galleries
$search = trim($HTTP_GET_VARS['search']);

if ($search = '*')
{
$query = "u.status='confirmed' AND p_g.user_id > '0'";

if ($search)
$q = "search=" . htmlspecialchars($search);
}
elseif ($_GET["letter"])
{
$letter = trim($_GET["letter"]);
if (strlen($letter) > 1)
die;

if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
$letter = "a";
$query = "username LIKE '$letter%' AND u.status='confirmed' AND p_g.user_id > '0'";
$q = "letter=$letter";
}
else
{
$query = "u.username LIKE " . sqlesc("%$search%") . " AND u.status='confirmed' AND p_g.user_id > '0'";

if ($search)
$q = "search=" . htmlspecialchars($search);
}

stdhead("Members public galleries");

echo("

Members public galleries

$page_links
\n".
"Search: \n".
"

\n");

for ($i = 97; $i < 123; ++$i){
$l = chr($i);
$L = chr($i - 32);
if ($l == $letter)
echo("$L\n");
else
echo("$L\n");
}

echo("

\n");

$page = 0 + $_GET['page'];

$res = mysql_query("SELECT DISTINCT u.id AS uid FROM users AS u LEFT JOIN photo_gallery AS p_g ON u.id = p_g.user_id WHERE $query");
$arr = mysql_num_rows($res);
$pages = floor($arr / $perpage);
if ($pages * $perpage < $arr)
++$pages;

if ($page < 1)
$page = 1;
else
if ($page > $pages)
$page = $pages;

for ($i = 1; $i <= $pages; ++$i)
if ($i == $page)
$pagemenu .= "$i\n";
else
$pagemenu .= "$i\n";

if ($page == 1)
$browsemenu .= " Prev";
else
$browsemenu .= " Prev";

$browsemenu .= "  $pagemenu  ";

if ($page == $pages)
$browsemenu .= "Next >\">";
else
$browsemenu .= "Next >\">";

$offset = ($page * $perpage) - $perpage;

$res = mysql_query("SELECT DISTINCT u.id AS uid, u.username, u.donated, u.added, u.last_access, u.class, u.country, u.avatar FROM users AS u LEFT JOIN photo_gallery AS p_g ON u.id = p_g.user_id WHERE $query ORDER BY username LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__);
$num = mysql_num_rows($res);

if($num > 0){
echo("

$browsemenu

");
echo("\n".
"".
"\n");
for ($i = 0; $i < $num; ++$i){
$count= (++$count)%2;
$class = 'clearalt'.($count==0?'6':'7');

$arr = mysql_fetch_assoc($res);

//=== get friends
$res_pals = mysql_query("SELECT id FROM friends WHERE $CURUSER[id] = friendid AND $arr[uid] = userid") or sqlerr(__FILE__, __LINE__);
$arr_pals = mysql_num_rows($res_pals);

if ($arr_pals > 0)
$res_gal = mysql_query("SELECT DISTINCT p_g.in_gallery, m_g.gallery_name, m_g.share_gallery FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id WHERE m_g.share_gallery != 'private' AND m_g.user_id = $arr[uid] ORDER BY m_g.gallery_name") or sqlerr(__FILE__, __LINE__);
else
$res_gal = mysql_query("SELECT DISTINCT p_g.in_gallery, m_g.gallery_name FROM photo_gallery AS p_g LEFT JOIN my_gallerys AS m_g ON p_g.in_gallery = m_g.id WHERE m_g.share_gallery = 'public' AND m_g.user_id = $arr[uid] ORDER BY m_g.gallery_name") or sqlerr(__FILE__, __LINE__);
while ($arr_gal = mysql_fetch_assoc($res_gal)){
$avatar = htmlspecialchars($arr['avatar']);
if (!$avatar)
$avatar = 'images/default_avatar.gif';
//=== hide offencive avatars
//if ($arr['offensive_avatar']==='yes' && $CURUSER['view_offensive_avatar'] === 'no')
//$avatar = 'images/fuzzybunny.gif';

$gal_name .= "• ".htmlentities($arr_gal['gallery_name'])."".($arr_gal["share_gallery"] == 'friends' ? "" : '')."";
}

if ($arr['country'] > 0){
$cres = mysql_query("SELECT name,flagpic FROM countries WHERE id=$arr[country]");
if (mysql_num_rows($cres) == 1){
$carr = mysql_fetch_assoc($cres);
$country = "";
}
}
else
$country = "";
if ($arr['added'] == '0000-00-00 00:00:00')
$arr['added'] = '-';
if ($arr['last_access'] == '0000-00-00 00:00:00')
$arr['last_access'] = '-';
echo("" .
"".
"$country\n");
$gal_name = '';
}
echo("
Member nameGallerysRegisteredLast accessClassCountry
\"$carr[name]\"---
$arr[username]" .($arr["donated"] > 0 ? "Donor" : "")."$gal_name$arr[added]$arr[last_access]" . get_user_class_name($arr["class"]) . "
\n");

echo("

$browsemenu

");
}
else
echo '

nothing found. select a letter or enter a username.

';

stdfoot();
die;
?>

and the pop-up window...
photo_popup.htm
CODE


Gallery Image


marginheight="0" leftmargin="0" marginwidth="0">





and that nifty javascript thing... you need to make a folder called javascripts/ and put the following in that folder...

cleartext.js
CODE
/*
* Cross-browser event handling, by Scott Andrew
*/
function addEvent(element, eventType, lamdaFunction, useCapture) {
if (element.addEventListener) {
element.addEventListener(eventType, lamdaFunction, useCapture);
return true;
} else if (element.attachEvent) {
var r = element.attachEvent('on' + eventType, lamdaFunction);
return r;
} else {
return false;
}
}

/*
* Kills an event's propagation and default action
*/
function knackerEvent(eventObject) {
if (eventObject && eventObject.stopPropagation) {
eventObject.stopPropagation();
}
if (window.event && window.event.cancelBubble ) {
window.event.cancelBubble = true;
}

if (eventObject && eventObject.preventDefault) {
eventObject.preventDefault();
}
if (window.event) {
window.event.returnValue = false;
}
}

/*
* Safari doesn't support canceling events in the standard way, so we must
* hard-code a return of false for it to work.
*/
function cancelEventSafari() {
return false;
}

/*
* Cross-browser style extraction, from the JavaScript & DHTML Cookbook
*
*/
function getElementStyle(elementID, CssStyleProperty) {
var element = document.getElementById(elementID);
if (element.currentStyle) {
return element.currentStyle[toCamelCase(CssStyleProperty)];
} else if (window.getComputedStyle) {
var compStyle = window.getComputedStyle(element, '');
return compStyle.getPropertyValue(CssStyleProperty);
} else {
return '';
}
}

/*
* CamelCases CSS property names. Useful in conjunction with 'getElementStyle()'
* From
*/
function toCamelCase(CssProperty) {
var stringArray = CssProperty.toLowerCase().split('-');
if (stringArray.length == 1) {
return stringArray[0];
}
var ret = (CssProperty.indexOf("-") == 0)
? stringArray[0].charAt(0).toUpperCase() + stringArray[0].substring(1)
: stringArray[0];
for (var i = 1; i < stringArray.length; i++) {
var s = stringArray[i];
ret += s.charAt(0).toUpperCase() + s.substring(1);
}
return ret;
}

/*
* Disables all 'test' links, that point to the href '#', by Ross Shannon
*/
function disableTestLinks() {
var pageLinks = document.getElementsByTagName('a');
for (var i=0; i if (pageLinks[i].href.match(/[^#]#$/)) {
addEvent(pageLinks[i], 'click', knackerEvent, false);
}
}
}

/*
* Cookie functions
*/
function createCookie(name, value, days) {
var expires = '';
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = '; expires=' + date.toGMTString();
}
document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
var cookieCrumbs = document.cookie.split(';');
var nameToFind = name + '=';
for (var i = 0; i < cookieCrumbs.length; i++) {
var crumb = cookieCrumbs[i];
while (crumb.charAt(0) == ' ') {
crumb = crumb.substring(1, crumb.length); /* delete spaces */
}
if (crumb.indexOf(nameToFind) == 0) {
return crumb.substring(nameToFind.length, crumb.length);
}
}
return null;
}

function eraseCookie(name) {
createCookie(name, '', -1);
}

/*
* Clear Default Text: functions for clearing and replacing default text in
* elements.
*
* by Ross Shannon, http://www.yourhtmlsource.com/
*/

addEvent(window, 'load', init, false);

function init() {
var formInputs = document.getElementsByTagName('input');
for (var i = 0; i < formInputs.length; i++) {
var theInput = formInputs[i];

if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {
/* Add event handlers */
addEvent(theInput, 'focus', clearDefaultText, false);
addEvent(theInput, 'blur', replaceDefaultText, false);

/* Save the current value */
if (theInput.value != '') {
theInput.defaultText = theInput.value;
}
}
}
}

function clearDefaultText(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target) return;

if (target.value == target.defaultText) {
target.value = '';
}
}

function replaceDefaultText(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target) return;

if (target.value == '' && target.defaultText) {
target.value = target.defaultText;
}
}

be wary of the board borking code...

now you need some folders...
bitbucket/thumbs/
and set permissions to 777 for both... I'll post a nifty htaccess script to not let other sites hotlink to the gallery

also, you need to add a folder in your pic folder:
/pic/image_ratings/
and put the attached rating pics in it


moon 14th April 2012 19:49

This mod was already done.
Try on xbtit forum (hacks-gallery)
It's free
:hello:


All times are GMT +2. The time now is 06:39.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.