Try this.
Change Where I marked.
<?php
function get_pic_url(&$pic_row)
{
$fn=$pic_row['filename'];
$fp="thumb_";//change if you edit it ..
$fpath="../albums/userpics/10001/";//change to link your cpg's album path
return $fpath.$fp.$fn;
}
function template_eval(&$template, &$vars)
{
return strtr($template, $vars);
}
// HTML template for thumbnails display
$template_thumbnail_view = <<<EOT
<!-- BEGIN header -->
<tr>
<!-- END header -->
<!-- BEGIN thumb_cell -->
<td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<a href="{LINK_TGT}">{THUMB}<br /></a>
{CAPTION}
{ADMIN_MENU}
</td>
</tr>
</table>
</td>
<!-- END thumb_cell -->
<!-- BEGIN empty_cell -->
<td valign="top" class="thumbnails" align="center"> </td>
<!-- END empty_cell -->
<!-- BEGIN row_separator -->
</tr>
<tr>
<!-- END row_separator -->
<!-- BEGIN footer -->
</tr>
<!-- END footer -->
<!-- BEGIN tabs -->
<tr>
<td colspan="{THUMB_COLS}" style="padding: 0px;">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
{TABS}
</tr>
</table>
</td>
</tr>
<!-- END tabs -->
<!-- BEGIN spacer -->
<img src="images/spacer.gif" width="1" height="7" border="" alt="" /><br />
<!-- END spacer -->
EOT;
function localised_timestamp($timestamp = -1)
{
if ($timestamp == -1) {
$timestamp = time();
}
$diff_to_GMT = date("O") / 100;
//change 8 to youe timestamp
$timestamp += (8 - $diff_to_GMT) * 3600;
return $timestamp;
}
function localised_date($timestamp = -1, $datefmt)
{
global $lang_month, $lang_day_of_week, $CONFIG;
$timestamp = localised_timestamp($timestamp);
$date = ereg_replace('%[aA]', $lang_day_of_week[(int)strftime('%w', $timestamp)], $datefmt);
$date = ereg_replace('%[bB]', $lang_month[(int)strftime('%m', $timestamp)-1], $date);
return strftime($date, $timestamp);
}
function compute_img_size($width, $height, $max)
{
global $CONFIG;
$thumb_use=$CONFIG['thumb_use'];
if($thumb_use=='ht') {
$ratio = $height / $max;
} elseif($thumb_use=='wd') {
$ratio = $width / $max;
} else {
$ratio = max($width, $height) / $max;
}
if ($ratio > 1.0) {
$image_size['reduced'] = true;
}
$ratio = max($ratio, 1.0);
$image_size['width'] = (int) ($width / $ratio);
$image_size['height'] = (int) ($height / $ratio);
$image_size['whole'] = 'width="'.$image_size['width'].'" height="'.$image_size['height'].'"';
if($thumb_use=='ht') {
$image_size['geom'] = ' height="'.$image_size['height'].'"';
} elseif($thumb_use=='wd') {
$image_size['geom'] = 'width="'.$image_size['width'].'"';
} else {
$image_size['geom'] = 'width="'.$image_size['width'].'" height="'.$image_size['height'].'"';
}
return $image_size;
}
function bb_decode($text)
{
$text = nl2br($text);
static $bbcode_tpl = array();
static $patterns = array();
static $replacements = array();
if ((strpos($text, "[") === false || strpos($text, "]") === false)) {
return $text;
}
$text = str_replace("[b]", '<b>', $text);
$text = str_replace("[/b]", '</b>', $text);
$text = str_replace("[u]", '<u>', $text);
$text = str_replace("[/u]", '</u>', $text);
$text = str_replace("[i]", '<i>', $text);
$text = str_replace("[/i]", '</i>', $text);
$text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/", '<span style="color:$1">', $text);
$text = str_replace("[/color]", '</span>', $text);
if (!count($bbcode_tpl)) {
$bbcode_tpl['url'] = '{DESCRIPTION}<img src="images/descending.gif" alt="" title="' . $url_removed . '" />';
$bbcode_tpl['email'] = '<span class="bblink"><a href="mailto:{EMAIL}">{EMAIL}</a></span>';
$bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']);
$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);
$bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']);
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']);
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
$patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[1] = $bbcode_tpl['url1'];
$patterns[2] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[2] = $bbcode_tpl['url2'];
$patterns[3] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[3] = $bbcode_tpl['url3'];
$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[4] = $bbcode_tpl['url4'];
$patterns[5] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[5] = $bbcode_tpl['email'];
$bbcode_tpl['img'] = '<img src="images/thumbnails.gif" alt="" title="' . $img_removed . '" />';
$bbcode_tpl['img'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['img']);
$patterns[6] = "#\[img\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/img\]#si";
$replacements[6] = $bbcode_tpl['img'];
}
$text = preg_replace($patterns, $replacements, $text);
return $text;
}
function template_extract_block(&$template, $block_name, $subst='')
{
$pattern = "#(<!-- BEGIN $block_name -->)(.*?)(<!-- END $block_name -->)#s";
if ( !preg_match($pattern, $template, $matches)){
//die('<b>Template error<b><br />Failed to find block \''.$block_name.'\'('.htmlspecialchars($pattern).') in :<br /><pre>'.htmlspecialchars($template).'</pre>');
}
$template = str_replace($matches[1].$matches[2].$matches[3], $subst, $template);
return $matches[2];
}
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
global $CONFIG;
global $template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;
static $header = '';
static $thumb_cell = '';
static $empty_cell = '';
static $row_separator = '';
static $footer = '';
static $tabs = '';
static $spacer = '';
if ($header == '') {
$thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
$tabs = template_extract_block($template_thumbnail_view, 'tabs');
$header = template_extract_block($template_thumbnail_view, 'header');
$empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
$row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
$footer = template_extract_block($template_thumbnail_view, 'footer');
$spacer = template_extract_block($template_thumbnail_view, 'spacer');
}
$cat_link = is_numeric($aid) ? '' : '&cat=' . $cat;
$uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&uid=' . $_GET['uid'] : '';
$thumbcols = 4;//change 4 to your thumbcols
$cell_width = ceil(100 / 4) . '%';//change 4 to your thumbcols
$title = $album_name;
starttable('100%', $title, $thumbcols);
echo $header;
$i = 0;
foreach($thumb_list as $thumb) {
$i++;
$params = array('{CELL_WIDTH}' => $cell_width,
'{LINK_TGT}' => "../displayimage.php?album=lastup&pos={$thumb['pos']}$uid_link",//change path!
'{THUMB}' => $thumb['image'],
'{CAPTION}' => $thumb['caption'],
'{ADMIN_MENU}' => $thumb['admin_menu']
);
echo template_eval($thumb_cell, $params);
if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
echo $row_separator;
}
}
for (;($i % $thumbcols); $i++) {
echo $empty_cell;
}
echo $footer;
endtable();
echo $spacer;
}
function starttable($width = '-1', $title = '', $title_colspan = '1')
{
global $CONFIG;
if ($width == '-1') $width = $CONFIG['picture_table_width'];
if ($width == '100%') $width = $CONFIG['main_table_width'];
echo <<<EOT
<!-- Start standard table -->
<table align="center" width="$width" cellspacing="1" cellpadding="0" class="maintable">
EOT;
if ($title) {
echo <<<EOT
<tr>
<td class="tableh1" colspan="$title_colspan">$title</td>
</tr>
EOT;
}
}
function endtable()
{
echo <<<EOT
</table>
<!-- End standard table -->
EOT;
}
//===============================
//main begin
//===============================
//change!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_connect("localhost","root","root");
mysql_select_db("cpg");
$query="SELECT * FROM cpg14x_pictures ORDER BY pid DESC LIMIT 0 ,8 ";
//////
$result=mysql_query($query);
$rowset = array();
while ($row = mysql_fetch_array($result)) $rowset[] = $row;
mysql_free_result($result);
//print_r($rowset);
foreach ($rowset as $key => $row) {
$i++;
$pic_title ="Filename:".$row['filename']."\n".
"FileSize:".($row['filesize'] >> 10).$lang_byte_units[1]."\n".
"dimensions:".$row['pwidth']."x".$row['pheight'];/*."\n".
"date_added:".localised_date($row['ctime'], $album_date_fmt);*/
$pic_url = get_pic_url($row);
//if (!is_image($row['filename'])) {
$image_info = getimagesize(urldecode($pic_url));
$row['pwidth'] = $image_info[0];
$row['pheight'] = $image_info[1];
//}
$image_size = compute_img_size($row['pwidth'], $row['pheight'], 100);//change 100 to your max thumb width
$thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit;
$thumb_list[$i]['pid'] = $row['pid'];
$thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\"/>";
$thumb_list[$i]['caption'] = bb_decode($row['caption_text']);
$thumb_list[$i]['admin_menu'] = '';
$thumb_list[$i]['aid'] = $row['aid'];
}
theme_display_thumbnails($thumb_list, $thumb_count-$notshow, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs);
?>