Source for file file.php
Documentation is available at file.php
* This file is responsible for initiating file compression (if needed) and
* making the file available for download.
* This file is part of HRDIODB.
* HRDIODB 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.
* HRDIODB 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 HRDIODB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** Configuration class */
require_once("conf.php");
/** Debugging functions */
require_once("debugging.php");
require_once("session_class.php");
/** HRDI database class */
require_once("hrdi_db_class.php");
require_once("download_class.php");
require_once("user_class.php");
require_once("common_class.php");
// Create class instances
$user = new user($hdb, $session);
$download = new download($hdb, $session, $user);
// Make sure we're authenticated
if (!$user->authenticated()) {
// Redirect to the login page
// Include the page header
require_once("header.php");
// Get the download file number
// Get the number of days per file
$days_per_file = @$_GET['dpf'];
// Verify the download file number
error("Archive number is not valid");
require_once("footer.php");
// Verify the number of days per file
if (!is_numeric($days_per_file) || ($days_per_file < 1)) {
error("Days per file is not valid");
require_once("footer.php");
// Set the refresh code, we'll use this a couple of times
$refresh_code = '<meta http-equiv="refresh" content="3" url="'. $_SERVER['PHP_SELF']. '">';
// First, make sure that we prepare the download properly
if ($download->prepare($number, $days_per_file)) {
if ($download->is_error()) {
error($download->get_error());
// Assume we're going to refresh
print "<br/><br/><center><table class=\"hrdi\">";
if ($download->is_available()) {
/* The archive is available. This could be because the archiving process
has finished, or it could be because the file has been created from a
// Print out the table with the file size, download link and MD5 sum
print "<tr><td class=\"label\" colspan=\"2\">File is ready ("
. $download->get_file_size()
. $download->get_download_file_path()
. "\">→ Download Zip Archive</a></td></tr>
<tr><td class=\"label\">MD5 Sum</td><td class=\"data\">"
. $download->get_md5_sum()
// Do not refresh this time
} else if ($download->is_compressing()) {
// The archive is still being compressed
// Print out the status message
print "<tr><td class=\"label\">File compression in progress ("
. $download->get_temp_file_size()
. "), please wait...</td></tr>";
// Nothing is going on yet, start the download
// Start the compression process
// Print out the status message
print "<tr><td class=\"label\">File compression has started, please wait...</td></tr>";
print "</table></center>";
// Print out the META refresh tag if we will be refreshing the page
error("Search results were not found, please redo your search");
// Include the page footer
require_once("footer.php");
|