<?php
/*
This file is part of EdLite.
Copyright (C) 2005 Philip Spears and Philip Allen
Edlite 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.
Edlite 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 EdLite; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version: 2005081900
*/
$student_name = str_replace(dirname(dirname(dirname(getcwd())))."/", "", dirname(dirname(getcwd())));
$course_name = str_replace(dirname(dirname(dirname(dirname(getcwd()))))."/", "", dirname(dirname(dirname(getcwd()))));
$folder_name = str_replace(dirname(getcwd())."/", "", getcwd());
if (file_exists("./header.html")) { include ("./header.html"); }
?>
<div class="box_noborder"><?php printf($student_name."'s ".$course_name." ".$folder_name); ?> files</div><br />
<?php
if ($HTTP_POST_VARS['post'] == "upload") {
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
$userfile_name = $HTTP_POST_FILES['userfile']['name'];
$userfile_size = $HTTP_POST_FILES['userfile']['size'];
$userfile_type = $HTTP_POST_FILES['userfile']['type'];
$userfile_error = $HTTP_POST_FILES['userfile']['error'];
if ($userfile_error > 0){echo 'problem'; exit;}
$upfile = './files/'.$userfile_name;
if (is_uploaded_file($userfile)) {
if (!move_uploaded_file($userfile, $upfile)) {
echo 'Problem: directory issue';
exit;
}
} else {
echo 'Problem: possible file attack upload filename : '.$userfile_name;
exit;
}
} elseif ($HTTP_POST_VARS['post'] == "delete") {
$delete = $HTTP_POST_VARS['delete'];
foreach ($delete as &$delete_file) {
unlink("./files/".$delete_file);
}// loop foreach delete[#] check box
?>
<?php
}// end if post
?>
<form action="index.php" method="post">
<div class="box">
<table cellpadding="1" cellspacing="0" width="100%">
<tr class="titlebar">
<td colspan="2"> </td><td><span class="white">Name</span></td><td><span class="white">Size</span></td><td><span class="white">Last Updated</span></td>
</tr>
<?php
$row_color = "light";
$i = "0";
$directories = dir("./files");
while (false !== ($directory_entry = $directories->read())) {
if ($directory_entry != "." && $directory_entry != "..") {
if ($directory_entry == $userfile_name) {
$highlight = "true";
$td_highlight = " class=\"highlight\"";
} else {
$highlight = "false";
$td_highlight = "";
}
if ($highlight == "true") {
?>
<tr class="highlight">
<?php
} else {
?>
<tr class="<?php printf($row_color); ?>">
<?php
}//end if highlight
?>
<td<?php printf($td_highlight); ?>><input name="delete[<?php printf($i); ?>]" value="<?php printf ($directory_entry); ?>" type="checkbox"></td>
<td<?php printf($td_highlight); ?>><a href="files/<?php printf ($directory_entry); ?>"><img alt="file" src="../../../../../images/file_icon.gif" title="file"></a></td>
<td<?php printf($td_highlight); ?>><a<?php printf($td_highlight); ?> href="files/<?php printf ($directory_entry); ?>"><?php printf ($directory_entry);?></a></td>
<td<?php printf($td_highlight); ?>><?php printf(filesize("./files/".$directory_entry)); ?>bytes</td>
<td<?php printf($td_highlight); ?>><?php printf(date ("F d Y H:i:s", filemtime("./files/".$directory_entry))); ?></td>
</tr>
<?
if ($row_color == "light") { $row_color = "white"; } else { $row_color = "light"; };
$i++;
} //end if dir "." and ".." checks
}//end while
$directories->close();
if ($i == "0") {
?>
<tr class="highlight">
<td class="highlight" colspan="5">
No files have been uploaded.
</td>
</tr>
<?php
}// end if i="0" aka if no files exist!
?>
</table>
<input type="hidden" name="post" value="delete">
</div>
<div class="box_noborder">
<input type="submit" value="Delete">
</div>
</form>
<form action="index.php" enctype="multipart/form-data" method="post">
<div class="box">
<div class="titlebar"> Select and Upload a file.</div><br />
<input name="userfile" type="file">
<input name="post" type="hidden" value="upload">
<input name="MAX_FILE_SIZE" type="hidden" value="500000">
<input type="submit" value="Upload">
<br /><br />
</div>
</form>
<br />
<?php
if (file_exists("./footer.html")) { include ("./footer.html"); }
?>