Random Block for Gallery 2

DJB31st

Joined: 2005-08-14
Posts: 4
Posted: Sun, 2005-08-14 18:14

Well its not exactly anything spectacular but it works and as far as i can tell shouldn't put much load on the server at all.

Basically just install as you would any other block, although you'll first have to change the following parameters in the source code.

$db_host = 'localhost';					//chage to your database hostname
$db_user = 'my_user';				    //change to your database username
$db_pass = 'mypas5';					//change to your database password
$db_data = 'datbase_name'; 			    //change to your gallery2 database name
$url 	 = 'www.djb31st.co.uk/gallery2';//change to the full URL of your gallery 2 install without the http
$nuke 	 = '1';							//set to 1 for code to act as a PHPnuke block, or 0 as a stand alone page

Comments appreciated as i'm aware this probably isn't the best method of doing it.

have fun with it :D

Working version in stand alone mode.
http://djb31st.co.uk/block-randomdavepic.php

I suppose a version could also be very easily made to give the option of displaying the full random image rather than simply a thumbnail?

as a final note, if your gallery 2 install is anything other than standard it may not work, this code tested with Release Candidate 1

AttachmentSize
block-randomdavepic.zip1.28 KB
 
DJB31st

Joined: 2005-08-14
Posts: 4
Posted: Sun, 2005-08-14 18:17

ok after a quick look around, i spotted that gallery 2 has a very usefull random thing already installed, so i suppose using this to get the link to the image would make a lot more sence than the above option...

just goes to show your though doesn't it!

http://www.djb31st.co.uk/gallery2/main.php?g2_view=imageblock.External&g2_blocks=randomImage

So a bit later on...

here is a new version, maybe someones already made one cos there isn't much to it anymore, but anyway for what its worth.

Enjoy version 2 of the random phpnuke block for gallery 2.

heres a link to a standalone version.. surprisingly similar to the last version :lol:
http://www.djb31st.co.uk/block-randompicgallery2.php