HRDIODB
[ class tree: HRDIODB ] [ index: HRDIODB ] [ all elements ]

Source for file download.php

Documentation is available at download.php

  1. <?php
  2. /**
  3.  * UARS Day file download interface.
  4.  * This file displays a list of links to download a series of archive files
  5.  * for a set of search results..
  6.  * @package HRDIODB
  7.  */
  8.  
  9. /**
  10.  * This file is part of HRDIODB.
  11.  *
  12.  * HRDIODB is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2 of the License, or
  15.  * (at your option) any later version.
  16.  *
  17.  * HRDIODB is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with HRDIODB; if not, write to the Free Software
  24.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25.  */
  26.  
  27. /** Configuration file */
  28. require_once("conf.php");
  29. /** Debugging functions */
  30. require_once("debugging.php");
  31. /** HRDI database class */
  32. require_once("hrdi_db_class.php");
  33. /** PHP session class */
  34. require_once("session_class.php");
  35. /** UARS day class */
  36. require_once("user_class.php");
  37. /** Common Class */
  38. require_once("common_class.php");
  39.  
  40. // Create class instances
  41. $session new session();
  42. $hdb new hrdi_db ($dsn);
  43. $user new user($hdb$session);
  44.  
  45. // Check to make sure we're authenticated
  46. if (!$user->authenticated()) {
  47.   $session->set_var("page"$_SERVER['REQUEST_URI']);
  48.   // Redirect to login page
  49.     common::redirect("login.php");
  50. }
  51.  
  52. // Page title
  53. $page_title "";
  54.  
  55. // Include the header
  56. require_once("header.php");
  57.  
  58. // These session variables are set in {@link search.php}
  59. $days $session->get_var("days");
  60. $types $session->get_var("types");
  61.  
  62. // Initialize size variable
  63. $size 0;
  64.  
  65. /* Figure out the size of the archive for one day by summing up the average
  66.    sizes of all the file types that were requested. */
  67. foreach ($types as $type{
  68.   $s $hdb->get_one("SELECT AverageSize
  69.                       FROM HRDI_FileTypes
  70.                       WHERE ID='$type'");
  71.  
  72.   if ($s == 0{
  73.     error("Average file size for file type id $type is 0");
  74.     require_once("footer.php");
  75.     exit(1);
  76.   }
  77.  
  78.   $size += $s;
  79. }
  80.  
  81. // Make sure we're within allowed maximum archive size
  82. if ($size $max_archive_size{
  83.   error("An archive of files for a sigle day is larger than the maximum allowed archive size");
  84.   require_once("footer.php");
  85.   exit(1);
  86. }
  87.  
  88. // Number of days per archive file
  89. $days_per_file floor($max_archive_size $size);
  90.  
  91. $current 0;
  92. $number 0;
  93. $days_in_file array();
  94.  
  95. print "<center><br/><br/><table class=\"hrdi\"><tr><td class=\"c_label\" colspan=\"2\">File Download</td></tr>";
  96.  
  97. // Display the download links
  98. for ($i 0$i count($days)$i++{
  99.   $days_in_file[$days[$i];
  100.   $current++;
  101.  
  102.   if (($current == $days_per_file||
  103.       ($i == count($days1)) {
  104.     $current 0;
  105.  
  106.     print "<tr><td class=\"data\">";
  107.     
  108.     if (count($days_in_file1{
  109.       print "Days ";
  110.     else {
  111.       print "Day ";
  112.     }
  113.  
  114.     print implode(', '$days_in_file);
  115.  
  116.     print "</td><td class=\"data\" nowrap>
  117.           <a href=\"file.php?dpf=$days_per_file&n=$number\">&rarrDownload Set "
  118.         . ($number 1)
  119.         . "</a></td></tr>";
  120.     $days_in_file array();
  121.     $number++;
  122.   }
  123. }
  124.  
  125. print "</table></center>";
  126.  
  127. // Include the footer
  128. require_once("footer.php");
  129. ?>

Documentation generated on Tue, 23 Jan 2007 22:57:46 -0500 by phpDocumentor 1.3.0RC6