Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Latest Uploaded Pictures  (Read 3741 times)

0 Members and 1 Guest are viewing this topic.

Usually

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Latest Uploaded Pictures
« on: May 16, 2009, 12:47:28 am »

Hi, I've got a problem.
I need my latest uploaded photos to be showing on the main page of my site (not gallery). How can I do this?
Logged

chzuqi

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
    • Puzzz Jigsaw World
Re: Latest Uploaded Pictures
« Reply #1 on: May 16, 2009, 12:31:09 pm »

you can copy all code in index.php

Delete ↓:
Code: [Select]
pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);

Code: [Select]
foreach ($elements as $element) {
        if (preg_match("/(\w+),*(\d+)*/", $element, $matches)){
            if (!isset($matches[2])) { // added to fix notice about undefined index
                $matches[2] = 0;
            }

            $matches = CPGPluginAPI::filter('plugin_block', $matches);

            if (is_array($matches)) {
                switch ($matches[1]) {
                    case 'breadcrumb':
                        // Added breadcrumb as a separate listable block from config
                        if (($breadcrumb != '' || count($cat_data) > 0) && $cat != 0) theme_display_breadcrumb($breadcrumb, $cat_data);
                        break;

                    case 'catlist':
                        if ($breadcrumb != '' || count($cat_data) > 0) theme_display_cat_list($breadcrumb, $cat_data, $statistics);
                        if (isset($cat) && $cat == USER_GAL_CAT) {
                            list_users();
                        }
                        flush();
                        break;

                    case 'alblist':
                        //list_albums();
                        //
                        flush();
                        break;

                    case 'random':
                        display_thumbnails('random', $cat, 1, $CONFIG['thumbcols'], 2, false);
                        flush();
                        break;

                    case 'lastup':
                        display_thumbnails('lastup', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'lastalb':
                        display_thumbnails('lastalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        break;

                    case 'topn':
                        display_thumbnails('topn', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'toprated':
                        display_thumbnails('toprated', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'lastcom':
                        display_thumbnails('lastcom', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'lasthits':
                        display_thumbnails('lasthits', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'anycontent':
                        if ($cat == 0) {
                            ob_start();
                            /**
                             * Any php code or HTML can be put in this file and will be displayed
                             */
                            include('anycontent.php');
                            $anycontent = CPGPluginAPI::filter('anycontent',ob_get_contents());
                            ob_end_clean();
                            echo ($anycontent);
                        }
                        flush();
                        break;
                }
            }
        }
    }

Code: [Select]
pagefooter();

and insert ↓

Code: [Select]
display_thumbnails('lastup', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();

to show 'Latest Uploaded Pictures'
Logged

Usually

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Latest Uploaded Pictures
« Reply #2 on: May 16, 2009, 01:01:30 pm »

Doesn't work(

Actually I have a wordpress theme, and I need to add some (maybe 3 or 4) latest uploaded images in the sidebar, andI don't know how to do it.
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Latest Uploaded Pictures
« Reply #3 on: May 16, 2009, 02:00:49 pm »

chzuqi

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
    • Puzzz Jigsaw World
Re: Latest Uploaded Pictures
« Reply #4 on: May 16, 2009, 03:52:25 pm »

Are you put Wordpress and CPG  in the same folder?
Logged

Usually

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Latest Uploaded Pictures
« Reply #5 on: May 16, 2009, 03:54:32 pm »

no, they're in different folders
Logged

chzuqi

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 22
    • Puzzz Jigsaw World
Re: Latest Uploaded Pictures
« Reply #6 on: May 17, 2009, 09:29:01 am »

Try this.
Change Where I marked.

Code: [Select]
<?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">&nbsp;</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 += ($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($ratio1.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) ? '' '&amp;cat=' $cat;
    
$uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;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 $key $i $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_pagesis_numeric($album), $display_tabs);

?>

Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Latest Uploaded Pictures
« Reply #7 on: May 17, 2009, 09:32:40 am »

or use cpmfetch als already suggested
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.