Advanced search  

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]

Pages: [1]   Go Down

Author Topic: [mod/hack] funzione ultimi 3 album inseriti  (Read 5141 times)

0 Members and 1 Guest are viewing this topic.

technozeus

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
    • ilfra.it
[mod/hack] funzione ultimi 3 album inseriti
« on: December 04, 2007, 03:33:06 pm »

Ho creato una piccola funzione che mi permette di visualizzare in home page (anycontent) gli ultimi 3 album inseriti con la relativa thumb prescelta.
Nulla di che si intende, ma metto il codice, potrebbe interessare a qualcuno :)
In include/function.inc.php, alla fine del file, prima di ?> ho aggiunto la funzione:

Code: [Select]
function get_pic_lastAlbum()
{
global $CONFIG;

$str = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td>
<center><big>Ultimi album inseriti:</big><br><br>
</td>
</tr>
<tr>
<td class=\"tableh2\">";

$query1 = "SELECT a.aid aid
FROM {$CONFIG['TABLE_ALBUMS']} AS a
ORDER BY aid DESC
LIMIT 0 , 3";

$result1 = cpg_db_query($query1);
                 
  while ($rowset1 = mysql_fetch_array($result1)){
  $aid = $rowset1['aid'];

  $query2 = "SELECT a.aid aid, p.filepath ppath, p.filename pname, a.title atitle
FROM {$CONFIG['TABLE_ALBUMS']} AS a, {$CONFIG['TABLE_PICTURES']} AS p
WHERE a.thumb = p.pid
AND
a.thumb =
(SELECT a.thumb
FROM {$CONFIG['TABLE_ALBUMS']} AS a
WHERE a.aid = $aid)";
 
  $result2 = cpg_db_query($query2);
  $rowset2 = cpg_db_fetch_row($result2);
  mysql_free_result($result2);
 
  $a_title = $rowset2['atitle'];
    $a_num = $rowset2['aid'];
$p_name = $rowset2['pname'];
$p_path = $rowset2['ppath'];
$suffix = "thumb_";

$str = "$str
<center><h2><a href=\"{$CONFIG['site_url']}thumbnails.php?album=$a_num\">$a_title</a></h2><br><br>
<center><a href=\"{$CONFIG['site_url']}thumbnails.php?album=$a_num\"><img src=\"{$CONFIG['site_url']}/albums/$p_path$suffix$p_name\"</a><br><br><br>";
               
  }
mysql_free_result($result1);

  $str = "$str
  </td>
</tr>
</table>";

  return $str;
               
}

e in anycontent.php la richiamo con:

Code: [Select]
<?php
$rowsetin 
get_pic_lastAlbum();
echo 
$rowsetin;
?>

credo si possa ottimizzare meglio il codice, per ora mi č venuta cosė.
Ciao a tutti.
« Last Edit: December 04, 2007, 10:30:24 pm by Lontano »
Logged

Davide Renda

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1427
  • aka "Lontano"
    • www.daviderenda.eu
Re: [mod/hack] funzione ultimi 3 album inseriti
« Reply #1 on: December 04, 2007, 10:32:46 pm »

Grazie per il contributo, aggiunto nelle nostre faq in italiano

technozeus

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
    • ilfra.it
Re: [mod/hack] funzione ultimi 3 album inseriti
« Reply #2 on: December 04, 2007, 11:38:50 pm »

grazie a te!
Logged

technozeus

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
    • ilfra.it
Re: [mod/hack] funzione ultimi 3 album inseriti
« Reply #3 on: December 15, 2007, 05:06:07 am »

ho modificato la prima query, quella che ritorna l'elenco degli ultimi 3 album inseriti:
Code: [Select]
$query1 = "SELECT p.aid as aid, max(p.ctime) as maxctime
FROM {$CONFIG['TABLE_PICTURES']} p
GROUP BY p.aid
ORDER BY maxctime
DESC
LIMIT 0,3";

Ora ritorna gli ultimi 3 album a cui sono state aggiunte immagini (quindi se creo un album ma non aggiungo immagini non me lo fa vedere, almeno non dovrebbe :P )
ora sto lavorando ad una paginetta con l'elenco della cronologia degli album inseriti.
Ciao
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 18 queries.