forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Sweetener on July 07, 2018, 11:09:39 pm

Title: API to fetch last updated albums
Post by: Sweetener 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?
Title: Re: API to fetch last updated albums
Post by: Αndré 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";
Title: Re: API to fetch last updated albums
Post by: Sweetener on August 30, 2019, 12:57:42 am
Which $RESTRICTEDWHERE uses the last updated albums in index.php?
Title: Re: API to fetch last updated albums
Post by: ron4mac on August 30, 2019, 01:20:09 pm
Which $RESTRICTEDWHERE uses the last updated albums in index.php?

"WHERE (1)"

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