} if (isset($_REQUEST['searchPattern'])) { $downloadArchiveName .= '.' . get_lang('Search') . '.' . $_REQUEST['searchPattern']; } $downloadArchiveName .= '.zip'; $downloadArchiveName = str_replace('/', '', $downloadArchiveName); if ($downloadArchiveName == '.zip') { $downloadArchiveName = get_lang('Documents and Links') . '.zip'; } $downloadArchive = new PclZip($downloadArchiveFile); $downloadArchive->add($filePathList, PCLZIP_OPT_REMOVE_PATH, $requestDownloadPath); if (file_exists($downloadArchiveFile)) { /* * SEND THE ZIP ARCHIVE FOR DOWNLOAD */ claro_send_file($downloadArchiveFile, $downloadArchiveName); unlink($downloadArchiveFile); exit; } else { $dialogBox->error(get_lang('Unable to create zip file')); } } else { $dialogBox->error(get_lang('Not allowed')); } } /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = DEFINE CURRENT DIRECTORY = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ if (in_array($cmd, array('rqMv', 'exRm', 'rqEdit', 'exEdit', 'exEditHtml', 'exChVis', 'rqComment', 'exComment', 'submitImage'))) { $curDirPath = claro_dirname(isset($_REQUEST['file']) ? $_REQUEST['file'] : $_REQUEST['relatedFile']); } elseif (in_array($cmd, array('rqMkDir', 'exMkDir', 'rqUpload', 'exUpload', 'rqMkUrl', 'exMkUrl', 'reqMkHtml', 'exMkHtml', 'rqSearch'))) {
$quId = null; } if (isset($item_list['2']) && is_numeric($item_list['2'])) { $exId = (int) $item_list['2']; } else { $exId = null; } if ($cmd == 'download') { // find exercise informations $exercise = new Exercise(); if ($exercise->load($exId) || $is_allowedToEdit) { if ($exercise->getVisibility() == 'VISIBLE' || $is_allowedToEdit) { $question = new Question(); if ($question->load($quId)) { $attachmentFile = $question->getQuestionDirSys() . $question->getAttachment(); if (claro_send_file($attachmentFile)) { die; } else { $dialogBox->error(get_lang('Not found')); } } else { $dialogBox->error(get_lang('Not found')); } } else { $dialogBox->error(get_lang('Not allowed')); } } else { $dialogBox->error(get_lang('Not found')); } } // Not Found 404
$calType = array_key_exists('calFormat', $_REQUEST) && array_key_exists($_REQUEST['calFormat'], $formatList) ? $_REQUEST['calFormat'] : get_conf('calType', 'ics'); // need to be in a course if (!claro_is_in_a_course()) { die('<form >cidReq = <input name="cidReq" type="text" /><input type="submit" /></form>'); } if (!$_course['visibility'] && !claro_is_course_allowed()) { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="' . get_lang('iCal feed for %course', array('%course' => $_course['name'])) . '"'); header('HTTP/1.0 401 Unauthorized'); echo '<h2>' . get_lang('You need to be authenticated with your %sitename account', array('%sitename' => $siteName)) . '</h2>' . '<a href="index.php?cidReq=' . claro_get_current_course_id() . '">' . get_lang('Retry') . '</a>'; exit; } else { if (get_magic_quotes_gpc()) { $_REQUEST['login'] = stripslashes($_SERVER['PHP_AUTH_USER']); $_REQUEST['password'] = stripslashes($_SERVER['PHP_AUTH_PW']); } else { $_REQUEST['login'] = $_SERVER['PHP_AUTH_USER']; $_REQUEST['password'] = $_SERVER['PHP_AUTH_PW']; } require '../inc/claro_init_local.inc.php'; if (!$_course['visibility'] && !claro_is_course_allowed()) { header('WWW-Authenticate: Basic realm="' . get_lang('iCal feed for %course', array('%course' => $_course['name'])) . '"'); header('HTTP/1.0 401 Unauthorized'); echo '<h2>' . get_lang('You need to be authenticated with your %sitename account', array('%sitename' => $siteName)) . '</h2>' . '<a href="index.php?cidReq=' . claro_get_current_course_id() . '">' . get_lang('Retry') . '</a>'; exit; } } } // OK TO SEND FEED claro_send_file(buildICal(array(CLARO_CONTEXT_COURSE => claro_get_current_course_id()), $calType));
$uid = $row['userId']; $canRetry = $row['canRetry']; $wasFolder = $row['wasFolder']; $extension = get_file_extension($pathInfo); $mimeType = get_mime_on_ext($pathInfo); if ($canRetry) { $sql = 'UPDATE `' . $tableName . '` SET `canRetry` = \'0\' WHERE token = \'' . claro_sql_escape($token) . '\''; Claroline::getDatabase()->exec($sql); } if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { $rootSys = str_replace('//', '/', strtolower(str_replace('\\', '/', $rootSys))); $pathInfo = strtolower(str_replace('\\', '/', $pathInfo)); } $document_url = str_replace($rootSys, $urlAppend . '/', $pathInfo); if (get_conf('useSendfile', true) && ($mimeType != 'text/html' || $extension == 'url') || $wasFolder) { if (claro_send_file($pathInfo) !== false) { $claroline->notifier->event('download', array('data' => array('url' => $document_url))); if ($wasFolder) { unlink($pathInfo); } if (!$canRetry) { $sql = 'DELETE FROM `' . $tableName . '` WHERE token = \'' . claro_sql_escape($token) . '\''; Claroline::getDatabase()->exec($sql); } } else { header('HTTP/1.1 404 Not Found'); claro_die(get_lang('File download failed : %failureMSg%', array('%failureMsg%' => claro_failure::get_last_failure()))); } } else { $sql = 'DELETE FROM `' . $tableName . '` WHERE token = \'' . claro_sql_escape($token) . '\''; Claroline::getDatabase()->exec($sql);
/** * Send a zip file for download, * * @param string name of the downloaded file (without extension) * @param * * @return boolean result of operation */ function sendZip($archiveName, $archiveContent, $removedPath) { // TODO find a better solution for removedPath if (!is_array($archiveContent) || empty($archiveContent)) { return false; } $downloadPlace = get_path('rootSys') . get_conf('tmpPathSys'); $downloadArchivePath = $downloadPlace . '' . uniqid('') . '.zip'; $downloadArchiveName = empty($archiveName) ? 'archive' : $archiveName; $downloadArchiveName = str_replace(',', '_', replace_dangerous_char($downloadArchiveName)); $downloadArchiveName = $downloadArchiveName . '.zip'; $downloadArchive = new PclZip($downloadArchivePath); $downloadArchive->add($archiveContent, PCLZIP_OPT_REMOVE_PATH, $removedPath); if (file_exists($downloadArchivePath)) { if (claro_send_file($downloadArchivePath, $downloadArchiveName)) { unlink($downloadArchivePath); return true; } else { unlink($downloadArchivePath); return false; } } else { return false; } }
if ($cmd == 'exDownload') { $workId = isset($_REQUEST['workId']) ? $_REQUEST['workId'] : null; $submission = new Submission(); if ($submission->load($workId)) { $submissionUserId = $submission->getUserId(); $submissionGroupId = $submission->getGroupId(); $userGroupList = array(); if ($assignment->getAssignmentType() == 'GROUP') { $userGroupList = get_user_group_list(claro_get_current_user_id()); } $is_allowedToDownload = (bool) $is_allowedToEditAll || $submissionUserId == claro_get_current_user_id() || isset($userGroupList[$submissionGroupId]); // check permission if ($submission->getVisibility() == 'VISIBLE' || $is_allowedToDownload) { // read file $filePath = $assignment->getAssigDirSys() . $submission->getSubmittedFilename(); if (claro_send_file($filePath)) { die; } else { $dialogBox->error(get_lang('Not found')); } } else { $dialogBox->error(get_lang('Not allowed')); } } else { $dialogBox->error(get_lang('Not found')); } // Submission not found or not allowed header('HTTP/1.1 404 Not Found'); $interbredcrump[] = array('url' => Url::Contextualize("../work/work.php"), 'name' => get_lang('Assignments')); $interbredcrump[] = array('url' => Url::Contextualize("../work/work_list.php?authId=" . $_REQUEST['authId'] . "&assigId=" . $assignmentId), 'name' => get_lang('Assignment')); $claroline->display->body->appendContent($dialogBox->render());
$thumbnailsDirectory = get_path('coursesRepositorySys') . claro_get_course_path() . '/tmp/thumbs/' . claro_get_current_group_data('directory'); } elseif (claro_is_in_a_course() && claro_is_course_allowed()) { $documentRootDir = get_path('coursesRepositorySys') . claro_get_course_path() . '/document'; $thumbnailsDirectory = get_path('coursesRepositorySys') . claro_get_course_path() . '/tmp/thumbs'; } else { header('HTTP/1.1 403 Forbidden'); exit; } $image = array_key_exists('img', $_REQUEST) ? secure_file_path($_REQUEST['img']) : null; if (is_null($image)) { header('HTTP/1.1 403 Forbidden'); exit; } $imagePath = $documentRootDir . $image; if (file_exists($imagePath)) { list($width, $height, $type, $attr) = getimagesize($imagePath); $thumbWidth = 75; $newHeight = round($height * $thumbWidth / $width); $thumbnailer = new Thumbnailer($thumbnailsDirectory, $documentRootDir); $thumbPath = $thumbnailer->getThumbnail($image, $newHeight, $thumbWidth); if (!$thumbPath) { $thumbPath = $imagePath; } // end session to avoid lock session_write_close(); claro_send_file($thumbPath); exit; } else { header('HTTP/1.1 404 Not Found'); exit; }