<?php
/*
Butterfly Organizer
Copyright (C) 2007-2008 Butterfly Media Romania
This file is part of Butterfly Organizer.
Butterfly Organizer 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; version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include('includes/top.php');
bf_displayText('<h2>Site Organizer</h2>');
$result = mysql_list_tables($dbname); // read all tables in database and assign them to '$result'
$cat_count = 0; // initialize category count variable
$inactive_categories = 0;
// begin sorting results function
$tables_names = array();
while($row = mysql_fetch_array($result)) {
$table_names[] = $row[0];
}
// end sorting results function
// print tables
echo '<table id="tableCategories" class="stripeMe">';
echo '<thead><tr class="alt"><th>Category</th><th>Creation date</th><th>Last modified</th><th>Options</th></tr></thead>';
while (list($key, $val) = each($table_names)) {
if (($val != $excluded_tbl01) && ($val != $excluded_tbl02) && ($val != $excluded_tbl03)) { // do not display if name is excluded
$mycolor = $value_color_used_account;
$rows = "SELECT * FROM ".$val;
// extract information from database for 'creation date' and 'last modified' reference
$result = mysql_query("SELECT * FROM ".$val,$database);
$myrow = mysql_fetch_array($result);
if (isset($myrow['lastmodified'])) // testing for undefined index/variable error
$lm = $myrow['lastmodified'];
if (!isset($myrow['lastmodified'])) // testing for undefined index/variable error
$lm = '';
// end extraction
$query_rows = mysql_query($rows);
$numrows = mysql_num_rows($query_rows);
$cat_count++;
if($numrows == 0) {
$mycolor = $value_color_empty_account;
$inactive_categories++;
}
echo '<tbody><tr>';
echo '<td><a href="viewdb2.php?mytable='.$val.'" style="color:'.$mycolor.'">'.str_replace("_"," ",$val).' ('.$numrows.')</a></td>';
echo '<td class="dataCreationDate">'.$myrow['date'].'</td>';
echo '<td class="dataLastModified">'.$lm.'</td>';
echo '<td><a href="category-rename.php?tablehere='.$val.'"><img src="'.$imagesFolder.'icon_rename.png" alt="Rename this category" title="Rename this category" /></a> <a href="category-delete.php?tablehere='.$val.'" onclick="return confirmLinkDropDB(this, \'delete <'.str_replace('_',' ',$val).'>?\');"><img src="'.$imagesFolder.'icon_delete.png" alt="Delete this category" title="Delete this category" /></a></td>';
echo "</tr></tbody>";
}
}
$active_categories = $cat_count - $inactive_categories;
echo "<tfoot><tr><th colspan='4' class='tableStatus'>".$cat_count." categories (".$active_categories." active, ".$inactive_categories." inactive)</th></tr></tfoot>";
echo "</table>";
echo '<div class="menubar">';
echo '<a href="category-create.php" class="bsButton">Add Category</a>';
echo '</div>';
include('includes/bottom.php');
?>