Welcome to Geeklog, Anonymous Saturday, April 18 2026 @ 10:46 pm EDT
Geeklog Forums
gallery block
Anonymous
Anonymous
have there been any improvements to the gallery block for random pictures?
I have the the code for the block that is supposed to not show the hidden pic, yet it still does.
Also it comes up with an error sometimes... if I click on where the pic is supposed to be it brings up a page that says
ERROR: requested index [] out of bounds [2]
Fatal error: Call to a member function on a non-object in /httpdocs/gallery/classes/Album.php on line 660
Basiclly it is leaving off part of the url when it generates the link and pic (I think)
When I do get the error (no pic pulls up) the url looks something like this
http://somedomain.com/gallery/view_photo.php?set_albumName=album51&id=
When it does work, the link looks something like this
http://somedomain.com/gallery/view_photo.php?set_albumName=album51&id=aak
So I think it is leaving off after the id=
If anyone has it working could you please post your code...???
10
10
Quote
Anonymous
Anonymous
no one? I really need the hidden pic to not show... if you have that working that would be great.... plz plz plz post the code
12
13
Quote
Anonymous
Anonymous
In the lib-custom.php, function phpblock_gallery()
You just need to add the names of the directories (albums) that you want to exclude the 'if stmnt ' check inside the while loop.
while (($f = @readdir($fd)) == TRUE) {
if (is_dir($path_gallery_albums . $f) && $f <> 'Hobbies' && $f <> 'music' && $f <> '.' && $f <> '..' && $f <> 'CVS' && ($f <> '.users')) {
clearstatcache();
$albums[$index] = $f;
$index++;
}
}
In this example above, I added two albums to exclude
To skip empty albums, modify the function phpblock_random_files($g) - set check for index > 2
// Randomly select one of the images if index counter > 2
// Anthing less is an empty album or only the highlight image
// If the album is completely empty, setting the index to 1 will show a empty image but no errors
if ($index > 2) {
mt_srand((double)microtime()*1000000);
Give that a try.
efarmboy
17
11
Quote
Anonymous
Anonymous
this is what I have is this not right?
function phpblock_random_files($g)
{
// Open directory
$fd = opendir($g);
$pics = array();
$index = 1;
// Loop through directory inserting all thumbnails into an array. Do not add
// .gif images because netpbm can't convert them.
while (($f = @readdir($fd)) == TRUE) {
if ($f <> '.' && $f <> '..' && $f <> 'CVS' && strpos($f,'thumb') && !strpos(strtolower($f),'.gif')) {
clearstatcache();
$pics[$index] = $f;
$index++;
}
}
closedir($fd);
if ($index > 2) {
mt_srand((double)microtime()*1000000);
$indexr = (mt_rand(1, count($pics)));
} else {
$indexr = 1;
}
// Return image name
returnLò¬8pics[$indexr];
}
11
12
Quote
Anonymous
Anonymous
Well that depends - are you getting what you want?
You've made a number of changes to the if stmt - why not add some debugging to see what its doing?
10
13
Quote
Anonymous
Anonymous
no it is not doing what I want it to do... I am still getting errors... I guess because of empty albums? I am no programer so how do I debug? I have not edited the code, that was just a copy and paste
could you post your code?
13
11
Quote
Status: offline
efarmboy
Forum User
Moderator
Registered: 02/26/02
Posts: 147
All times are EDT. The time is now 10:46 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content