forum.coppermine-gallery.net
Support => Older/other versions => cpg1.3.x Support => Topic started by: RockCitySaint on July 13, 2005, 05:17:38 am
-
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.
-
Use CPMfetch - look in the mods board.
-
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($result, MYSQL_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
-
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.