tagging as ATutor 1.5.4-release
[atutor.git] / tools / prog.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2004 by Greg Gay & Joel Kronenberg        */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14 sleep(1);
15 $_user_location = 'prog';
16 define('AT_INCLUDE_PATH', '../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 session_write_close();
19 if ($_GET['tile']) {
20         $lang_variable = 'tile_progress';
21 } else {
22         $lang_variable = 'upload_progress';
23 }
24
25 ?>
26 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
27 <html lang="<?php echo $myLang->getCode(); ?>">
28 <head>
29         <title><?php echo _AT($lang_variable); ?></title>
30         <?php if ($_GET['frame']) { ?>
31                 <META HTTP-EQUIV="refresh" content="3;URL=prog.php?frame=1"> 
32         <?php } ?>
33         <link rel="stylesheet" href="<?php echo $_base_path; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/styles.css" type="text/css" />
34         <meta http-equiv="Content-Type" content="text/html; <?php echo $myLang->getCharacterSet(); ?>" />
35 </head>
36 <body <?php
37         if ($_SESSION['done']) {
38                 echo 'onload="parent.window.close();"';
39         }
40 ?>>
41 <?php 
42 if (!$_GET['frame']) {  ?>
43 &nbsp;<a href="javascript:window.close();"><?php echo _AT('close'); ?></a>
44 <h3><?php echo _AT($lang_variable); ?></h3>
45 <p><small><?php echo _AT('window_auto_close'); ?></small></p>
46
47 <br /><br />
48 <table border="0" align="center">
49 <tr>
50         <td><img src="<?php echo AT_BASE_HREF; ?>images/transfer.gif" height="20" width="90" alt="<?php echo _AT($lang_variable); ?>"></td>
51         <td valign="middle"><iframe src="prog.php?frame=1" width="100" height="25" frameborder="0" scrolling="no" marginwidth="0" marginheight="1">
52 </iframe>
53 <?php } else { 
54         $tmp_dir = ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR;
55         if (!$_GET['t']) {
56                 $newest_file_name = '';
57                 $newest_file_time = 0;
58                 // get the name of the temp file.
59                 if ($dir = @opendir($tmp_dir)) {
60                         while (($file = readdir($dir)) !== false) {
61                                 if ((strlen($file) == 9) && (substr($file, 0, 3) == 'php')) {
62                                         $filedata = stat($tmp_dir . $file);
63                                         if ($filedata['mtime'] > $newest_file_time) {
64                                                 $newest_file_time = $filedata['mtime'];
65                                                 $newest_file_name = $file;
66                                                 $size = $filedata['size'] / 1024;
67                                         }
68                                 }
69                         }
70                         closedir($dir);
71                 }
72         } else {
73                 $filedata = stat($tmp_dir . $_GET['t']);
74                 $size = $filedata['size'] / AT_KBYTE_SIZE;
75         }
76
77         echo '<small>';
78         if ($size == '') {
79                 echo '<em>'._AT('unknown').'</em> KB';
80         } else {
81                 echo number_format($size, 2).' KB';
82         }
83         echo '</small>';
84 } ?></td>
85 </tr>
86 </table>
87 </body>
88 </html>