addFeedback('CANCELLED');
header('Location: index.php?pathext='.$_POST['pathext'].SEP.'popup='.$_POST['popup'].SEP.'framed='.$_POST['framed'].SEP.'_course_id='.$_course_id);
exit;
}
$path = TR_CONTENT_DIR . $_course_id.'/';
if ($_REQUEST['pathext'] != '') {
$pathext = $_REQUEST['pathext'];
}
if ($_REQUEST['file'] != '') {
$file = $_REQUEST['file'];
}
if (strpos($file, '..') !== false) {
require(TR_INCLUDE_PATH.'header.inc.php');
$msg->printErrors('UNKNOWN');
require(TR_INCLUDE_PATH.'footer.inc.php');
exit;
}
$path_parts = pathinfo($pathext.$file);
$temp_name = substr($file, 0, -strlen('.'.$path_parts['extension']));
$zip = new PclZip($path.$pathext.$file);
if (($list = $zip->listContent()) == 0) {
die("Error : ".$zip->errorInfo(true));
}
/*****************************************************************/
$totalBytes = 0;
$translated_file_names = array();
for ($i=0; $i';
$is_dir = true;
} else if ($ext == 'zip') {
$totalBytes += $list[$i]['size'];
$filename = $list[$i]['stored_filename'];
$fileicon = '';
} else {
$totalBytes += $list[$i]['size'];
$filename = $list[$i]['stored_filename'];
$fileicon = '';
}
if ($is_dir) {
$dirs[strtolower($filename)] .= '
'.$filename.' | ';
$dirs[strtolower($filename)] .= ''.FileUtility::get_human_size($list[$i]['size']).' | ';
$dirs[strtolower($filename)] .= ' ';
$dirs[strtolower($filename)] .= AT_date(_AT('filemanager_date_format'), $filedata[10], TR_DATE_UNIX_TIMESTAMP);
$dirs[strtolower($filename)] .= ' | ';
$dirs[strtolower($filename)] .= '
';
} else {
$files[strtolower($filename)] .= '
';
if (in_array($ext, $IllegalExtentions)) {
$files[strtolower($filename)] .= ''.$filename.'';
} else {
$files[strtolower($filename)] .= $filename;
$trans_name = str_replace(' ', '_', $path_parts['basename']);
$trans_name = preg_replace("/[^A-Za-z0-9._\-]/", '', $trans_name);
if (in_array($path_parts['dirname'].$trans_name, $translated_file_names)) {
$trans_count = 2;
while (in_array($trans_name, $translated_file_names)) {
$part = substr($trans_name, 0, -strlen($ext)- 1 - (2*($trans_count-2)));
$trans_name = $part.'_'.$trans_count.'.'.$ext;
$trans_count++;
if ($trans_count>15){
exit; // INF loop safety thing..
}
}
}
$translated_file_names[$list[$i]['index']] = $path_parts['dirname'].$trans_name;
if ($path_parts['dirname'].$trans_name != $filename) {
$files[strtolower($filename)] .= ' => '.$trans_name;
}
}
$files[strtolower($filename)] .= ' | ';
$files[strtolower($filename)] .= ''.FileUtility::get_human_size($list[$i]['size']).' | ';
$files[strtolower($filename)] .= ' ';
$files[strtolower($filename)] .= AT_date(_AT('filemanager_date_format'), $list[$i]['mtime'], TR_DATE_UNIX_TIMESTAMP);
$files[strtolower($filename)] .= ' | ';
$files[strtolower($filename)] .= '
';
}
}
$row = $coursesDAO->get($_course_id);
$my_MaxCourseSize = $row['max_quota'];
$my_MaxFileSize = $row['max_file_size'];
$course_total = FileUtility::dirsize($path);
if ($my_MaxCourseSize == TR_COURSESIZE_UNLIMITED) {
$total_after = 1;
} else {
$my_MaxCourseSize = $MaxCourseSize;
$total_after = FileUtility::get_human_size($my_MaxCourseSize-$course_total-$totalBytes);
}
// else{
// $total_after = get_human_size($my_MaxCourseSize - $course_total - $totalBytes);
// }
// if $total_after < 0: redirect with error msg
if (isset($_POST['submit']) && ($total_after > 0)) {
$_POST['custom_path'] = trim($_POST['custom_path']);
$_POST['custom_path'] = str_replace(' ', '_', $_POST['custom_path']);
/* anything else should be okay, since we're on *nix.. hopefully */
$_POST['custom_path'] = preg_replace('/[^a-zA-Z0-9._\/]/', '', $_POST['custom_path']);
if (strpos($_POST['pathext'].$_POST['custom_path'], '..') !== false) {
$msg->addError('UNKNOWN');
header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'_course_id='.$_course_id);
exit;
} else if ($zip->extract( PCLZIP_OPT_PATH, $path. $_POST['pathext'] . $_POST['custom_path'],
PCLZIP_CB_PRE_EXTRACT, 'preExtractCallBack') == 0) {
echo ("Error : ".$zip->errorInfo(true));
} else {
$msg->addFeedback('ARCHIVE_EXTRACTED');
header('Location: index.php?pathext='.$_POST['pathext'].SEP.'popup='.$_POST['popup'].SEP.'framed='.$_POST['framed'].SEP.'_course_id='.$_course_id);
exit;
}
header('Location: index.php'.SEP.'_course_id='.$_course_id);
exit;
}
require(TR_INCLUDE_PATH.'header.inc.php');
if ($total_after <= 0) {
$msg->printErrors('NO_SPACE_LEFT');
} else {
?>
|
|
|
$y) {
echo $y;
}
}
if (is_array($files)) {
foreach($files as $x => $y) {
echo $y;
}
}
?>
: |
|
|
: |
|
|
: |
|
|
: |
';
echo $total_after;
echo '';
} else {
echo $total_after;
}
} ?> |
|