API to fetch last updated albums API to fetch last updated albums
 

News:

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

Main Menu

API to fetch last updated albums

Started by Sweetener, July 07, 2018, 11:09:39 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Sweetener

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


<?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?

ΑndrĂ©

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";

Sweetener

Which $RESTRICTEDWHERE uses the last updated albums in index.php?

ron4mac

Quote from: Sweetener on August 30, 2019, 12:57:42 AM
Which $RESTRICTEDWHERE uses the last updated albums in index.php?

"WHERE (1)"

So really ... just don't use it.