coppermine-gallery.com/forum

Support => Older/other versions => cpg1.3.x Support => Topic started by: superstan on May 29, 2005, 09:11:16 AM

Title: how can i list all my files
Post by: superstan on May 29, 2005, 09:11:16 AM
hello

Is there an easy way of listing all my files in the gallery - i tried it with mysql but i dont know how to produce just a single listing of my gallery content
Title: Re: how can i list all my files
Post by: Joachim Müller on May 29, 2005, 11:48:54 AM
Create a file in your coppermine dir, name it "listall.php" or similar with this content:
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
**********************************************/

define('IN_COPPERMINE'true);


require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODE) die('Access denied');

pageheader('All files in my database');

starttable(-2,'All files in my database',4);
print <<< EOT
<tr>
  <td class="tableh1">Picture ID</td>
  <td class="tableh1">Album ID</td>
  <td class="tableh1">File path</td>
  <td class="tableh1">File size</td>
</tr>
EOT;

$result db_query("SELECT pid, aid, filepath, filename, total_filesize  from {$CONFIG['TABLE_PICTURES']} ORDER BY aid");
$rowset db_fetch_rowset($result);
mysql_free_result($result);
$sum_filesize 0;
foreach (
$rowset as $key => $row){
print <<< EOT
<tr>
  <td class="tableb_compact">
{$row['pid']}</td>
  <td class="tableb_compact">
{$row['aid']}</td>
  <td class="tableb_compact">
{$row['filepath']}{$row['filename']}</td>
  <td class="tableb_compact" align="right">
{$row['total_filesize']} Bytes</td>
</tr>
EOT;

$sum_filesize $sum_filesize $row['total_filesize'];
}
$sum_filesize floor($sum_filesize/1000);
print <<< EOT
<tr>
  <td class="tablef">Sum</td>
  <td class="tablef"></td>
  <td class="tablef"></td>
  <td class="tablef" align="right">
$sum_filesize KB</td>
</tr>
EOT;

endtable();
pagefooter();
ob_end_flush();
?>
upload it and run it in your browser.
Title: Re: how can i list all my files
Post by: superstan on May 29, 2005, 12:13:28 PM
thank you for your prompt reply  ;D