Random pictures on my homepage Random pictures on my homepage
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Random pictures on my homepage

Started by RockCitySaint, July 13, 2005, 05:17:38 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

RockCitySaint

I was just wondering if there was a way to put those random pictures on the index of my website instead of the index of my gallery... maybe an iframe or a php include, or something... I was gonna try to do it when I realized I don't really know where to start.

mmm breadcrumbs?

- RCS

P.S. Meant to post this in the theme boards. Sorry.

Nibbler

Use CPMfetch - look in the mods board.

blindrain

heres what i did
<?php
require "../Gallery/include/config.inc.php";
//Select random thumbnail file.
$link mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass'])    or die('Could not connect: ' mysql_error());
mysql_select_db($CONFIG['dbname']) or die('Could not select database');

// Performing SQL query

$query "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures, ".$CONFIG['TABLE_PREFIX']."albums WHERE ".$CONFIG['TABLE_PREFIX']."albums.aid = ".$CONFIG['TABLE_PREFIX']."pictures.aid and ".$CONFIG['TABLE_PREFIX']."albums.visibility ='0'  ORDER BY rand() limit 1";
$result mysql_query($query) or die('Query failed: ' mysql_error());
$line mysql_fetch_array($resultMYSQL_ASSOC);

$addrQuery "SELECT value FROM ".$CONFIG['TABLE_PREFIX']."config WHERE name = 'ecards_more_pic_target'";
$pathQuery "SELECT value FROM ".$CONFIG['TABLE_PREFIX']."config WHERE name = 'fullpath'";
$addrResult mysql_query($addrQuery) or die('Query failed: ' mysql_error());
$pathResult mysql_query($pathQuery) or die('Query failed: ' mysql_error());
$addrLine mysql_fetch_row($addrResult);
$pathLine mysql_fetch_row($pathResult);
mysql_free_result($result);
mysql_close($link);

echo 
"<a href=\"{$addrLine[0]}displayimage.php?pos=-{$line['pid']}\" target=\"_blank\"><img src=\"{$addrLine[0]}{$pathLine[0]}{$line['filepath']}thumb_{$line['filename']}\" alt=\"{$line['title']}\"border=0px></a>";

?>

just change the require line to the correct file

Joachim Müller

Thanks for your contrib. However, the script you have come up with doesn't respect permissions, so if people run a gallery that doesn't permit everybody to see every pic uploaded to it, the use of your custom script is not recommended. It doesn't take into account that fact that there can be other file types than images, so again the script will break if users have non-images in their gallery.

The dev team recommends using cpmFetch.