function JLMS_downloadFromBox($id, $option) { global $JLMS_DB, $my, $Itemid; $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0)); // $usertype = JLMS_GetUserType($my->id, $course_id); $JLMS_ACL =& JLMSFactory::getACL(); $flag = false; if ($course_id && $JLMS_ACL->CheckPermissions('dropbox', 'view') && JLMS_GetDropItemCourse($id) == $course_id) { $query = "SELECT file_id, drp_type, drp_name, drp_description FROM #__lms_dropbox" . "\n WHERE id = '" . $id . "' AND course_id = '" . $course_id . "'" . "\n AND (owner_id = '" . $my->id . "' OR recv_id = '" . $my->id . "')"; $JLMS_DB->SetQuery($query); $file_data = $JLMS_DB->LoadObjectList(); if (count($file_data) == 1) { $query = "UPDATE #__lms_dropbox" . "\n SET drp_mark = 0" . "\n WHERE id = '" . $id . "' AND course_id = '" . $course_id . "' AND recv_id = '" . $my->id . "'"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); if ($file_data[0]->drp_type == 1) { if ($file_data[0]->file_id == 0) { $flag = true; } else { JLMS_downloadFile($file_data[0]->file_id, $option, $file_data[0]->drp_name); } } else { if ($file_data[0]->drp_type == 2) { if ($file_data[0]->file_id == 0) { $flag = true; } else { $path_detect = JPATH_SITE . DS . 'components' . DS . 'com_jlms_profile' . DS . 'jlms_profile_detect.php'; if (file_exists($path_detect)) { include_once $path_detect; $detect = COMPONENT_Profile_Detect(); if ($detect) { $TabMyFiles = new TabMyFiles($my->id); $TabMyFiles->DownloadFile($file_data[0]->file_id, $my->id, $my->id, $file_data[0]->drp_name, true, array(), array('view' => 1)); } } } } } } } if ($flag) { JLMS_course_dropbox_html::viewCourseDropBox($file_data[0]->drp_description, $option, $file_data[0]->drp_name); } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}")); } }
function jlms_displayFile($course_id, $option) { global $Itemid, $my, $JLMS_DB; $JLMS_CONFIG =& JLMSFactory::getConfig(); $id = intval(mosGetParam($_REQUEST, 'id', 0)); $filename = mosGetParam($_REQUEST, 'filename', ''); if ($id == -2) { JLMSRedirect($filename); } if ($id == -1) { $file = new stdClass(); $file->filename = "JLMS_intro.swf"; $file->upload_type = 0; } else { /* $query = "ALTER TABLE `#__lms_conference_doc` ADD `upload_type` TINYINT DEFAULT '0' NOT NULL AFTER `owner_id` , ADD `file_id` INT NOT NULL AFTER `upload_type`"; $JLMS_DB->setQuery($query); $JLMS_DB->query();*/ $query = "SELECT * FROM `#__lms_conference_doc` WHERE course_id = {$course_id} AND doc_id={$id} ORDER BY doc_id"; $JLMS_DB->setQuery($query); $file = $JLMS_DB->loadObject(); } //print_r($file); if (is_object($file)) { if ($file->upload_type == 1) { $headers = array(); $headers['Content-Disposition'] = 'inline'; JLMS_downloadFile($file->file_id, $option, '', true, $headers); } else { $file_name = $file->filename; $srv_name = $JLMS_CONFIG->get('absolute_path') . "/components/com_joomla_lms/upload/" . $file_name; if (file_exists($srv_name) && is_readable($srv_name)) { $v_date = date("Y-m-d H:i:s"); if (preg_match('/Opera(\\/| )([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "Opera"; } elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "IE"; } else { $UserBrowser = ''; } $mime_type = $UserBrowser == 'IE' || $UserBrowser == 'Opera' ? 'application/octetstream' : 'application/octet-stream'; header('Content-Type: ' . $mime_type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); if ($UserBrowser == 'IE') { header('Content-Disposition: inline; filename="' . $file_name . '";'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Length: ' . filesize($srv_name)); header('Pragma: public'); } else { header('Content-Disposition: inline; filename="' . $file_name . '";'); header('Content-Length: ' . filesize($srv_name)); header('Pragma: no-cache'); } @ob_end_clean(); readfile($srv_name); exit; } } } }
function JLMS_downloadFileHW($option) { $JLMS_CONFIG =& JLMSFactory::getConfig(); $Itemid = $JLMS_CONFIG->get('Itemid'); $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0)); $hw_id = intval(mosGetParam($_REQUEST, 'hw_id', 0)); $file_id = intval(mosGetParam($_REQUEST, 'file_id', 0)); $user_id = intval(mosGetParam($_REQUEST, 'user_id', 0)); $JLMS_ACL =& JLMSFactory::getACL(); $user = JLMSFactory::getUser(); if ($course_id && ($JLMS_ACL->CheckPermissions('homework', 'manage') || $user_id == $user->get('id')) && ($hw_id && JLMS_GetHWCourse($hw_id) == $course_id)) { JLMS_downloadFile($file_id, $option); } JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=hw_view_result&course_id={$course_id}&hw_id={$hw_id}&user_id={$user_id}")); }