This is a damn handy script!!!
Here's a copy of the script with all the needed changes in it, or at least all the ones that need to make it work on newer versions.
<?php
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');
header('content-type: image/jpeg');
$mlink=mysql_connect('localhost','dcclorvv_gallery', '6iuni2fr');
mysql_select_db('your gallery database', $mlink);
$sum_x=4;
$pos=4;
if(isset($_GET['q'])) {
$q=$_GET['q'];
} else {
$q=3;
}
if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from {$CONFIG['TABLE_PICTURES']} where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q");
} else {
$pics=cpg_db_query("select filepath, filename from {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} where {$CONFIG['TABLE_ALBUMS']}.aid={$CONFIG['TABLE_PICTURES']}.aid and pwidth>0 and visibility=0 order by rand() limit 0,$q");
}
if(isset($_GET['txt'])) {
$txt=$_GET['txt'];
} else {
$txt="www.dc-6.com/gallery/";
}
while($pr=mysql_fetch_array($pics)) {
$fname[]="albums/".$pr['filepath']."thumb_".$pr['filename'];
list($width, $height, $type, $attr) = getimagesize("albums/".$pr['filepath']."thumb_".$pr['filename']);
$sum_x+=$width+4;
$ix[]=$width;
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."thumb_".$pr['filename']); //echo "albums/".$pr['filepath']."thumb_".$pr['filename']."--";
}
$im_total = @imagecreatetruecolor($sum_x, 128);
for($pn=0; $pn<$q; $pn++) {
imagecopy($im_total, $im[$pn], $pos, 4, 0, 0, $ix[$pn], 120);
$pos=$pos+$ix[$pn]+4;
}
$pos=$pos-$ix[$pn]-4;
//imagecopy($im_total, $im[1], $pos, 4, 0, 0, $ix[1], 120);
//$pos=$pos+$ix[1]+4;
//imagecopy($im_total, $im[2], $pos, 4, 0, 0, $ix[2], 120);
$textcolor = imagecolorallocate($im_total, 255, 255, 255);
$last_x=max($pos,168);
imagefilledrectangle($im_total, $last_x-168, 111, $last_x+2, 126, 0);
imagestring($im_total, 4, $last_x-166, 111, $txt, $textcolor);
imagejpeg($im_total);
?>
.htaccess
RewriteEngine on
RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3