Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: API to fetch last updated albums  (Read 450 times)

0 Members and 1 Guest are viewing this topic.

Sweetener

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
API to fetch last updated albums
« on: July 07, 2018, 11:09:39 pm »

Hello there! I've been trying to do my own api to get some of the last updated albums like coppermine in their index do:
https://i.imgur.com/S9H5ywT.png

Sadly I just have the last created albums
https://i.imgur.com/5jxnZts.png

Code: [Select]
<?php
require_once(
'include/config.inc.php');
header("Content-type: application/x-javascript");

$connect mysql_connect('localhost','dbuser','dbpass') or die('Error conexion server');
$connect_db mysql_select_db('dbname'$connect) or die ('Error conexion base de datos');

$resultado mysql_query("SELECT * FROM cpgq7_albums ORDER BY aid DESC LIMIT 0 ,6"$connect) or die('Ningun album encontrado'); echo 'document.write(\'';

if(mysql_num_rows($resultado) == 0){
echo 'Ningun album obtenido';
} else {

echo 
'<div class="photos">  ';
while($row mysql_fetch_array($resultado)){
echo ' ';
$album_id $row['aid'];
$subresult mysql_query("SELECT * FROM cpgq7_pictures where aid=$album_id order by pid DESC LIMIT 0, 6");

if(mysql_num_rows($subresult) == 0){
$album_img "http://arianagrandechile.net/galeria/thumbs/thumb_nopic.png";
} else {
while($subrow mysql_fetch_array($subresult)){
$album_img "http://arianagrandechile.net/galeria/albums/".$subrow['filepath'].'normal_'.$subrow['filename']  .$subrow['datebrowse'];
}
}
echo '<div class="g-album">';
echo '<a href="http://arianagrandechile.net/galeria/thumbnails.php?album='.$album_id.' " target="_blank"><img src="'.$album_img.'" alt="" /></a>';
echo '<div class="g-title"><a href="http://arianagrandechile.net/galeria/thumbnails.php?album='.$album_id.' " target="_blank">'.$row['title'].'</a></div>';
echo "</div>";
}
echo '</div>';
}
echo '\');';
?>


I know there is something wrong with my code because I'm fetching the last aid, but how do I do something like cpgp do?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15576
Re: API to fetch last updated albums
« Reply #1 on: August 15, 2018, 01:48:21 pm »

This is the code Coppermine uses for the "last updated albums" meta album:
Code: (include/functions.inc.php) [Select]
        $query = "SELECT $select_columns_albums
                FROM {$CONFIG['TABLE_PICTURES']} AS r
                INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = r.aid
                $RESTRICTEDWHERE
                AND approved = 'YES'
                GROUP BY r.aid
                ORDER BY ctime DESC
                $limit";
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.