conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ require_once 'classes/piaApp.php'; $piaApp = new piaApp(); $piaApp->startPage('PiArchive Statistics'); $piaApp->addTableSorter(); $piaApp->showHeader('PiArchive Statistics'); $piaApp->addMenu('stats.php'); # # ----- database version # $version = piaDB::getScalarString('SELECT * FROM pia_version()', array()); echo 'Database version: ', $version, '<p />'; # # ----- total number of items # $num_sources = piaDB::getScalarInteger('SELECT count(rowid) FROM pia.source', array()); echo $num_sources, ' source(s)<p />'; $num_indexed_items = piaDB::getScalarInteger('SELECT count(rowid) FROM pia.index', array());
/** * Show the search results. */ protected function showSearchResults() { global $piaApp; if (strlen($this->searchstr) > 0) { $str = '%' . $this->searchstr . '%'; // // ----- build SQL to read the data // $sql = "SELECT rowid, full_path, filename, extension, size_bytes\n FROM pia.view_full_path\n WHERE full_path ILIKE \$1 ORDER BY full_path LIMIT "; $sql .= piaSearch::MAX_RESULTS; // // ----- connect to the database and read the data // $db = piaDB::connect(); if ($db) { $result = pg_query_params($db, $sql, array($str)); if (!$result) { piaDB::errorWithSQL($sql); } if (pg_num_rows($result) > 0) { $tableId = 'SearchResultsTable'; $piaApp->initTablesorterTable($tableId); piaApp::startTable($tableId, 'tablesorter', False, 'width:100%;'); piaApp::writeTableHeader(array(array('Full Path', '60%'), array('Filename', '20%'), array('Extension', '10%'), array('Size (bytes)', '10%'))); echo '<tbody>'; // // ----- loop through the results // while ($row = pg_fetch_array($result)) { $cur = 0; $rowid = piaDB::cleanDataRead($row[$cur++]); $full_path = piaDB::cleanDataRead($row[$cur++]); $filename = piaDB::cleanDataRead($row[$cur++]); $extension = piaDB::cleanDataRead($row[$cur++]); $size_bytes = piaDB::cleanDataRead($row[$cur++]); echo '<tr>'; piaApp::writeTableData($full_path); piaApp::writeTableData($filename); piaApp::writeTableData($extension); piaApp::writeTableData(piaApp::getFormattedNumber($size_bytes, 0, -9)); echo '</tr>'; } echo '</tbody></table><p />'; } pg_free_result($result); piaDB::close($db); } } }
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ require_once 'classes/piaApp.php'; $piaApp = new piaApp(); $piaApp->startPage('PiArchive Search Results'); $piaApp->addTableSorter(); $piaApp->showHeader('PiArchive Search Results'); $piaApp->addMenu('search_results.php'); $s = new piaSearch(); $s->processSearch(); $piaApp->showFooter(); $piaApp->closePage();
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ require_once 'classes/piaApp.php'; $piaApp = new piaApp(); $piaApp->startPage('PiArchive Home'); $piaApp->showHeader('PiArchive Home'); $piaApp->addMenu('home.php'); $s = new piaSearch(); $s->processSearch(); $piaApp->showFooter(); $piaApp->closePage();
/** * Report indexed sources from pia.source. */ public static function reportSources() { global $piaApp; // // ----- build SQL to read the data // $sql = 'SELECT ' . piaSource::getFields(); $sql .= ', i.num_items, i.size_bytes'; $sql .= piaSource::getJoins(); $sql .= ' INNER JOIN ( SELECT i.source_rowid_fk, COUNT(i.rowid) AS num_items, SUM(i.size_bytes) AS size_bytes FROM pia.index i GROUP BY i.source_rowid_fk ) i ON i.source_rowid_fk = source.rowid'; // // ----- connect to the database and read the data // $db = piaDB::connect(); if ($db) { $result = pg_query($db, $sql); if (!$result) { piaDB::errorWithSQL($sql); } if (pg_num_rows($result) > 0) { $s = new piaSource(); echo '<h2>Sources</h2>'; $tableId = 'SourcesTable'; $piaApp->initTablesorterTable($tableId); piaApp::startTable($tableId, 'tablesorter', False, 'width:70%;'); piaApp::writeTableHeader(array(array('Name', '35%'), array('Description', '35%'), array('Num Items', '15%'), array('Size (bytes)', '15%'))); echo '<tbody>'; // // ----- loop through the results // while ($row = pg_fetch_array($result)) { $cur = $s->readRowFromDatabase($row); $num_items = piaDB::cleanDataRead($row[$cur++]); $size_bytes = piaDB::cleanDataRead($row[$cur++]); echo '<tr>'; piaApp::writeTableData($s->name); piaApp::writeTableData($s->description); piaApp::writeTableData(piaApp::getFormattedNumber($num_items, 0, -9)); piaApp::writeTableData(piaApp::getFormattedNumber($size_bytes, 0, -9)); echo '</tr>'; } echo '</tbody></table><p />'; } pg_free_result($result); piaDB::close($db); } }
/** * Connect to a database utilizing application level settings. * @return The database connection handle, null if not connected. */ public static function connect($database = '', $password = '', $host = '', $port = '', $username = '') { $db = null; $host = 'localhost'; $database = 'piarchive'; $port = 5432; $username = '******'; $password = ''; if (isset($_SERVER['PIA_DATABASE'])) { $database = $_SERVER['PIA_DATABASE']; } if (isset($_SERVER['PIA_DATABASE_PORT'])) { $port = $_SERVER['PIA_DATABASE_PORT']; } if (isset($_SERVER['PIA_DATABASE_USERNAME'])) { $username = $_SERVER['PIA_DATABASE_USERNAME']; } if (isset($_SERVER['PIA_DATABASE_PASSWORD'])) { $password = $_SERVER['PIA_DATABASE_PASSWORD']; } // // ----- connect to the database // if (strlen($database) > 0 && strlen($password) > 0) { $db = pg_connect("host={$host} port={$port} dbname={$database} user={$username} password='******'"); if (!$db) { piaDB::error(); } } else { piaApp::errorMessage("Database or password not specified trying to connect to a database."); } return $db; }
/** * Write a single data value to a table enclosed by <td> tags. * @param string $str The data value to write. * @param string $toHtml True (the default) to convert the strings to html before writing to the page. * @param string $blankSubstitute String to substitude for blank data, empty string by default. * @param string $title Title for the cell, blank no title by default. * @param string $class Class for the cell, no class by default. */ public static function writeTableData($str, $toHtml = True, $blankSubstitute = '', $title = '', $class = '') { echo '<td'; if (strlen($title) > 0) { echo ' title = "', piaApp::toHtml($title), '"'; } if (strlen($class) > 0) { echo ' class = "', $class, '"'; } echo '>'; if (strlen($str) > 0) { if ($toHtml) { echo piaApp::toHtml($str); } else { echo $str; } } else { echo $blankSubstitute; } echo '</td>'; }