本文整理汇总了PHP中DocumentManager::get_course_quota方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::get_course_quota方法的具体用法?PHP DocumentManager::get_course_quota怎么用?PHP DocumentManager::get_course_quota使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::get_course_quota方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
foreach ($document_list as $document_data) {
if ($document_data['insert_user_id'] == api_get_user_id() && $document_data['filetype'] == 'file') {
$quota_bytes += $document_data['size'];
}
}
if ($quota_bytes != 0) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
$session[] = array(addslashes(get_lang('Teacher') . ': ' . $user_name) . ' (' . format_file_size($quota_bytes) . ')', $quota_percentage);
//if a sesson is active
if ($session_id != 0) {
if (!empty($course_list)) {
$total_courses_quota = 0;
$total_quota_bytes = 0;
foreach ($course_list as $course_data) {
$total_quota_bytes += DocumentManager::get_course_quota($course_data['id']);
}
if ($quota_bytes != 0) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
}
$session[] = array(addslashes(sprintf(get_lang('TeacherXInSession'), $user_name)), $quota_percentage);
}
}
$quota_percentage = round(($total_quota_bytes - $used_quota_bytes) / $total_quota_bytes, 2) * 100;
$session[] = array(addslashes(get_lang('ShowCourseQuotaUse')) . ' (' . format_file_size($total_quota_bytes - $used_quota_bytes) . ') ', $quota_percentage);
$quota_data = json_encode($session);
$htmlHeadXtra[] = "\n<script>\n\$(document).ready(function(){\n var data = " . $quota_data . ";\n var plot1 = jQuery.jqplot ('chart1', [data], {\n seriesDefaults: {\n // Make this a pie chart\n renderer: jQuery.jqplot.PieRenderer,\n rendererOptions: {\n // Put data labels on the pie slices.\n // By default, labels show the percentage of the slice.\n showDataLabels: true\n }\n },\n legend: { show:true, location: 'e' }\n }\n );\n});\n</script>";
$tpl = new Template($tool_name);
$content = Display::page_subheader(get_lang('ShowCourseQuotaUse')) . '<div id="chart1"></div>';
$tpl->assign('content', $content);
示例2: array
if (!empty($groupId)) {
Display::display_introduction_section(TOOL_DOCUMENT . $groupId);
} else {
Display::display_introduction_section(TOOL_DOCUMENT);
}
$toolbar = Display::toolbarAction('toolbar-document', array(0 => $actionsLeft, 1 => $actionsRight));
echo $toolbar;
echo $templateForm;
echo $moveForm;
echo $dirForm;
echo $selector;
$table->display();
if (count($documentAndFolders) > 1) {
if ($is_allowed_to_edit || $group_member_with_upload_rights) {
// Getting the course quota
$course_quota = DocumentManager::get_course_quota();
// Calculating the total space
$already_consumed_space_course = DocumentManager::documents_total_space(api_get_course_int_id());
// Displaying the quota
DocumentManager::display_simple_quota($course_quota, $already_consumed_space_course);
}
}
if (!empty($table_footer)) {
Display::display_warning_message($table_footer);
}
echo '
<div id="convertModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="text-align: center;">
<button type="button" class="close" data-dismiss="modal" aria-label="' . get_lang('Close') . '">
示例3: get_lang
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
//Extra fields
$extra_field = new ExtraField('course');
$extra = $extra_field->addElements($form, $courseId);
$htmlHeadXtra[] = '
<script>
$(function() {
' . $extra['jquery_ready_content'] . '
});
</script>';
$form->addButtonUpdate(get_lang('ModifyCourseInfo'));
// Set some default values
$courseInfo['disk_quota'] = round(DocumentManager::get_course_quota($courseInfo['code']) / 1024 / 1024, 1);
$courseInfo['real_code'] = $courseInfo['code'];
$courseInfo['add_teachers_to_sessions_courses'] = isset($courseInfo['add_teachers_to_sessions_courses']) ? $courseInfo['add_teachers_to_sessions_courses'] : 0;
$form->setDefaults($courseInfo);
// Validate form
if ($form->validate()) {
$course = $form->getSubmitValues();
$visibility = $course['visibility'];
$visual_code = $course['visual_code'];
$visual_code = CourseManager::generate_course_code($visual_code);
// Check if the visual code is already used by *another* course
$visual_code_is_used = false;
$warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode');
if (!empty($visual_code)) {
$list = CourseManager::get_courses_info_from_visual_code($visual_code);
foreach ($list as $course_temp) {
示例4: check_unzip
//require_once '../inc/global.inc.php';
$htmlHeadXtra[] = "<script type=\"text/javascript\">\n<!-- //\nfunction check_unzip() {\n\tif(document.upload.unzip.checked){\n\tdocument.upload.if_exists[0].disabled=true;\n\tdocument.upload.if_exists[1].checked=true;\n\tdocument.upload.if_exists[2].disabled=true;\n\t}\n\telse {\n\tdocument.upload.if_exists[0].checked=true;\n\tdocument.upload.if_exists[0].disabled=false;\n\tdocument.upload.if_exists[2].disabled=false;\n\t}\n}\n// -->\n</script>";
//$is_allowed_to_edit = api_is_allowed_to_edit();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
/*
Variables
- some need defining before inclusion of libraries
*/
$courseDir = $_course['path'] . "/document";
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path . $courseDir;
$noPHP_SELF = true;
$max_filled_space = DocumentManager::get_course_quota();
//what's the current path?
if (isset($_REQUEST['curdirpath'])) {
$path = $_REQUEST['curdirpath'];
} else {
$path = '/';
}
// set calling tool
if (isset($_REQUEST['tool'])) {
$my_tool = $_REQUEST['tool'];
$_SESSION['my_tool'] = $_REQUEST['tool'];
} elseif (!empty($_SESSION['my_tool'])) {
$my_tool = $_SESSION['my_tool'];
} else {
$my_tool = 'document';
$_SESSION['my_tool'] = $my_tool;
示例5: api_get_cidreq
$actions = '<a href="document.php?id=' . $document_id . '&selectcat=' . $selectcat . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
$actions = '<a href="document.php?id=' . $document_id . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
}
// Link to create a folder
echo $toolbar = Display::toolbarAction('toolbar-upload', array(0 => $actions), 1);
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) {
echo DocumentManager::build_directory_selector($folders, $document_id, isset($group_properties['directory']) ? $group_properties['directory'] : array());
}
$action = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_id;
$form = new FormValidator('upload', 'POST', $action . '#tabs-2', '', array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'id', $document_id);
$form->addElement('hidden', 'curdirpath', $path);
$course_quota = format_file_size(DocumentManager::get_course_quota() - DocumentManager::documents_total_space());
$label = get_lang('MaxFileSize') . ': ' . ini_get('upload_max_filesize') . '<br/>' . get_lang('DocumentQuota') . ': ' . $course_quota;
$form->addElement('file', 'file', array(get_lang('File'), $label), 'style="width: 250px" id="user_upload"');
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'title_file'));
$form->addElement('textarea', 'comment', get_lang('Comment'));
// Advanced parameters
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
// Check box options
$form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress'), 'onclick="javascript: check_unzip();" value="1"');
if (api_get_setting('search.search_enabled') == 'true') {
//TODO: include language file
$supported_formats = get_lang('SupportedFormatsForIndex') . ': HTML, PDF, TXT, PDF, Postscript, MS Word, RTF, MS Power Point';
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument') . '<div style="font-size: 80%" >' . $supported_formats . '</div>');
$form->addElement('html', '<br /><div class="sub-form">');
$form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>');
示例6: verify_document_size
function verify_document_size($s)
{
$post_max = ini_get('post_max_size');
$upl_max = ini_get('upload_max_filesize');
$documents_total_space = DocumentManager::documents_total_space();
$course_max_space = DocumentManager::get_course_quota();
$total_size = filesize($s) + $documents_total_space;
if (filesize($s) > $post_max || filesize($s) > $upl_max || $total_size > $course_max_space) {
return true;
} else {
return false;
}
}
示例7: api_replace_dangerous_char
$filename = Database::escape_string($filename);
$filename = api_replace_dangerous_char($filename, $strict = 'loose');
// or strict
$filename = FileManager::disable_dangerous_file($filename);
$title = trim(str_replace('_chnano_.', '.', $filename));
//hide nanogong wav tag at title
$title = str_replace('_', ' ', $title);
//
$documentPath = $filepath . $filename;
if ($nano_user_id != api_get_user_id() || api_get_user_id() == 0 || $nano_user_id == 0) {
echo 'Not allowed';
exit;
}
//Do not use here check Fileinfo method because return: text/plain
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($_FILES['voicefile']['tmp_name']), DocumentManager::get_course_quota())) {
die(get_lang('UplNotEnoughSpace'));
}
if (!file_exists($documentPath)) {
//add document to disk
move_uploaded_file($_FILES['voicefile']['tmp_name'], $documentPath);
//add document to database
$current_session_id = $nano_session_id;
$groupId = $nano_group_id;
$file_size = filesize($documentPath);
$relativeUrlPath = $dir;
$doc_id = FileManager::add_document($_course, $relativeUrlPath . $filename, 'file', filesize($documentPath), $title);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $nano_user_id, $groupId, null, null, null, $current_session_id);
} else {
return get_lang('FileExistRename');
}
示例8: upload_file
/**
* Uploads the nanogong wav file
* @param bool
*/
public function upload_file($is_nano = false)
{
if (!empty($_FILES)) {
$upload_ok = FileManager::process_uploaded_file($_FILES['file'], false);
if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
return 0;
}
if ($upload_ok) {
// Check if there is enough space to save the file
if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) {
return 0;
}
//first we delete everything before uploading the file
$this->delete_files();
//Reload the filename variable
$file_name = FileManager::add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']);
$file_name = strtolower($file_name);
$file_info = pathinfo($file_name);
if ($is_nano == true) {
$file_info['extension'] = 'wav';
}
$file_name = $this->filename . '.' . $file_info['extension'];
if (in_array($file_info['extension'], $this->available_extensions)) {
if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path . $file_name)) {
$this->store_filename = $this->store_path . $file_name;
return 1;
}
}
}
}
return 0;
}
示例9: get_lang
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$list_course_extra_field = CourseManager::get_course_extra_field_list($course_code);
//@todo this is wrong
foreach ($list_course_extra_field as $extra_field) {
switch ($extra_field['field_type']) {
case CourseManager::COURSE_FIELD_TYPE_CHECKBOX:
$checked = array_key_exists('extra_field_value', $extra_field) && $extra_field['extra_field_value'] == 1 ? array('checked' => 'checked') : '';
$form->addElement('hidden', '_extra_' . $extra_field['field_variable'], 0);
$field_display_text = $extra_field['field_display_text'];
$form->addElement('checkbox', 'extra_' . $extra_field['field_variable'], array(null, get_lang('AllUsersAreAutomaticallyRegistered')), get_lang('SpecialCourse'), $checked);
break;
}
}
$form->addElement('style_submit_button', 'button', get_lang('ModifyCourseInfo'), 'onclick="valide()"; class="save"');
// Set some default values
$course['disk_quota'] = round(DocumentManager::get_course_quota($course_code) / 1024 / 1024, 1);
$course['title'] = api_html_entity_decode($course['title'], ENT_QUOTES, $charset);
$course['real_code'] = $course['code'];
$course['add_teachers_to_sessions_courses'] = isset($course['add_teachers_to_sessions_courses']) ? $course['add_teachers_to_sessions_courses'] : 0;
$form->setDefaults($course);
// Validate form
if ($form->validate()) {
$course = $form->getSubmitValues();
$visibility = $course['visibility'];
global $_configuration;
$urlId = api_get_current_access_url_id();
if (isset($_configuration[$urlId]) && isset($_configuration[$urlId]['hosting_limit_active_courses']) && $_configuration[$urlId]['hosting_limit_active_courses'] > 0) {
// Check if
if ($course_info['visibility'] == COURSE_VISIBILITY_HIDDEN && $visibility != $course_info['visibility']) {
$num = CourseManager::countActiveCourses($urlId);
if ($num >= $_configuration[$urlId]['hosting_limit_active_courses']) {
示例10: handle_uploaded_document
/**
* This function does the save-work for the documents.
* It handles the uploaded file and adds the properties to the database
* If unzip=1 and the file is a zipfile, it is extracted
* If we decide to save ALL kinds of documents in one database,
* we could extend this with a $type='document', 'scormdocument',...
*
* @param array $_course
* @param array $uploaded_file ($_FILES)
* @param string $base_work_dir
* @param string $upload_path
* @param int $user_id
* @param int $to_group_id, 0 for everybody
* @param int $to_user_id, NULL for everybody
* @param int $unzip 1/0
* @param string $what_if_file_exists overwrite, rename or warn if exists (default)
* @param boolean Optional output parameter. So far only use for unzip_uploaded_document function. If no output wanted on success, set to false.
* @return path of the saved file
*/
static function handle_uploaded_document($_course, $uploaded_file, $base_work_dir, $upload_path, $user_id, $to_group_id = 0, $to_user_id = null, $unzip = 0, $what_if_file_exists = '', $output = true)
{
if (!$user_id) {
die('Not a valid user.');
}
// Strip slashes
$uploaded_file['name'] = stripslashes($uploaded_file['name']);
// Add extension to files without one (if possible)
$uploaded_file['name'] = self::add_ext_on_mime($uploaded_file['name'], $uploaded_file['type']);
$current_session_id = api_get_session_id();
//Just in case process_uploaded_file is not called
$max_filled_space = DocumentManager::get_course_quota();
// Check if there is enough space to save the file
if (!DocumentManager::enough_space($uploaded_file['size'], $max_filled_space)) {
if ($output) {
Display::display_error_message(get_lang('UplNotEnoughSpace'));
}
return false;
}
// If the want to unzip, check if the file has a .zip (or ZIP,Zip,ZiP,...) extension
if ($unzip == 1 && preg_match('/.zip$/', strtolower($uploaded_file['name']))) {
return self::unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $max_filled_space, $output, $to_group_id);
//display_message('Unzipping file');
} elseif ($unzip == 1 && !preg_match('/.zip$/', strtolower($uploaded_file['name']))) {
// We can only unzip ZIP files (no gz, tar,...)
if ($output) {
Display::display_error_message(get_lang('UplNotAZip') . " " . get_lang('PleaseTryAgain'));
}
return false;
} else {
// Clean up the name, only ASCII characters should stay. (and strict)
$clean_name = api_replace_dangerous_char($uploaded_file['name'], 'strict');
// No "dangerous" files
$clean_name = self::disable_dangerous_file($clean_name);
if (!self::filter_extension($clean_name)) {
if ($output) {
Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
}
return false;
} else {
// Extension is good
//echo '<br />clean name = '.$clean_name;
//echo '<br />upload_path = '.$upload_path;
// If the upload path differs from / (= root) it will need a slash at the end
if ($upload_path != '/') {
$upload_path = $upload_path . '/';
}
//echo '<br />upload_path = '.$upload_path;
$file_path = $upload_path . $clean_name;
//echo '<br />file path = '.$file_path;
// Full path to where we want to store the file with trailing slash
$where_to_save = $base_work_dir . $upload_path;
// At least if the directory doesn't exist, tell so
if (!is_dir($where_to_save)) {
if ($output) {
Display::display_error_message(get_lang('DestDirectoryDoesntExist') . ' (' . $upload_path . ')');
}
return false;
}
//echo '<br />where to save = '.$where_to_save;
// Full path of the destination
$store_path = $where_to_save . $clean_name;
//echo '<br />store path = '.$store_path;
// Name of the document without the extension (for the title)
$document_name = self::get_document_title($uploaded_file['name']);
// Size of the uploaded file (in bytes)
$file_size = $uploaded_file['size'];
$files_perm = api_get_permissions_for_new_files();
// What to do if the target file exists
switch ($what_if_file_exists) {
// Overwrite the file if it exists
case 'overwrite':
// Check if the target file exists, so we can give another message
$file_exists = file_exists($store_path);
if (self::moveUploadedFile($uploaded_file, $store_path)) {
chmod($store_path, $files_perm);
if ($file_exists) {
// UPDATE DATABASE
$document_id = DocumentManager::get_document_id($_course, $file_path);
if (is_numeric($document_id)) {
// Update filesize
//.........这里部分代码省略.........
示例11: process_uploaded_file
$form->addElement('hidden', 'id', $workId);
$form->addButtonUpload(get_lang('Upload'));
$error_message = null;
$succeed = false;
if ($form->validate()) {
$values = $form->getSubmitValues();
$upload = process_uploaded_file($_FILES['file'], false);
if ($upload) {
$zip = new PclZip($_FILES['file']['tmp_name']);
// Check the zip content (real size and file extension)
$zipFileList = (array) $zip->listContent();
$realSize = 0;
foreach ($zipFileList as &$this_content) {
$realSize += $this_content['size'];
}
$maxSpace = DocumentManager::get_course_quota();
if (!DocumentManager::enough_space($realSize, $maxSpace)) {
Display::addFlash(Display::return_message(get_lang('UplNotEnoughSpace'), 'warning'));
}
$folder = api_get_unique_id();
$destinationDir = api_get_path(SYS_ARCHIVE_PATH) . $folder;
mkdir($destinationDir, api_get_permissions_for_new_directories(), true);
/* Uncompress zip file*/
// We extract using a callback function that "cleans" the path
$zip->extract(PCLZIP_OPT_PATH, $destinationDir, PCLZIP_CB_PRE_EXTRACT, 'clean_up_files_in_zip', PCLZIP_OPT_REPLACE_NEWER);
$result = get_work_user_list(null, null, null, null, $workId);
if (empty($result)) {
Display::addFlash(Display::return_message(get_lang('NoDataAvailable'), 'warning'));
}
$finalResult = [];
foreach ($result as $item) {
示例12: downloadMP3_pediaphon
/**
* This function save a post into a file mp3 from pediaphon services
*
* @param $filepath
* @param $dir
* @author Juan Carlos Raña Trabado <herodoto@telefonica.net>
* @version january 2011, chamilo 1.8.8
*/
function downloadMP3_pediaphon($filepath, $dir)
{
$location = 'create_audio.php?' . api_get_cidreq() . '&id=' . Security::remove_XSS($_POST['document_id']) . '&dt2a=pediaphon';
//security
if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
echo '<script>window.location.href="' . $location . '"</script>';
return;
}
global $_user;
$_course = api_get_course_info();
$clean_title = trim($_POST['title']);
$clean_title = Database::escape_string($clean_title);
$clean_text = trim($_POST['text']);
$clean_voices = Security::remove_XSS($_POST['voices']);
if (empty($clean_title) || empty($clean_text) || empty($clean_voices)) {
echo '<script>window.location.href="' . $location . '"</script>';
return;
}
$clean_title = Security::remove_XSS($clean_title);
$clean_title = Database::escape_string($clean_title);
$clean_title = str_replace(' ', '_', $clean_title);
//compound file names
$clean_text = Security::remove_XSS($clean_text);
$clean_lang = Security::remove_XSS($_POST['lang']);
$clean_speed = Security::remove_XSS($_POST['speed']);
$extension = 'mp3';
$audio_filename = $clean_title . '.' . $extension;
$audio_title = str_replace('_', ' ', $clean_title);
//prevent duplicates
if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
$i = 1;
while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
$i++;
}
$audio_filename = $clean_title . '_' . $i . '.' . $extension;
$audio_title = $clean_title . '_' . $i . '.' . $extension;
$audio_title = str_replace('_', ' ', $audio_title);
}
$documentPath = $filepath . '/' . $audio_filename;
//prev for a fine unicode, borrowed from main api TODO:clean
// Safe replacements for some non-letter characters (whitout blank spaces)
$search = array("", "\t", "\n", "\r", "\v", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%');
$replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
$filename = $clean_text;
// Encoding detection.
$encoding = api_detect_encoding($filename);
// Converting html-entities into encoded characters.
$filename = api_html_entity_decode($filename, ENT_QUOTES, $encoding);
// Transliteration to ASCII letters, they are not dangerous for filesystems.
$filename = api_transliterate($filename, 'x', $encoding);
// Replacing remaining dangerous non-letter characters.
$clean_text = str_replace($search, $replace, $filename);
//adding the file
if ($clean_lang == 'de') {
$url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
$find_t2v = '/http\\:\\/\\/www\\.pediaphon\\.org\\/\\~bischoff\\/radiopedia\\/mp3\\/(.*)\\.mp3\\"/';
} else {
$url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_' . $clean_lang . '.cgi';
//en, es, fr
$find_t2v = '/http\\:\\/\\/www\\.pediaphon\\.org\\/\\~bischoff\\/radiopedia\\/mp3\\/' . $clean_lang . '\\/(.*)\\.mp3\\"/';
}
$data = "stimme=" . $clean_voices . "&inputtext=" . $clean_text . "&speed=" . $clean_speed . "&go=go";
$opts = array('http' => array('method' => 'POST', 'header' => "Content-Type: application/x-www-form-urlencoded\r\n", "Content-Length: " . strlen($data) . "\r\n", 'content' => $data));
$context = stream_context_create($opts);
$previous_returntext2voice = file_get_contents($url_pediaphon, false, $context);
//clean file contents
$search_source = preg_match($find_t2v, $previous_returntext2voice, $hits);
$souce_end = substr($hits[0], 0, -1);
$returntext2voice = file_get_contents($souce_end);
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $returntext2voice);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//save file
file_put_contents($documentPath, $returntext2voice);
//add document to database
$current_session_id = api_get_session_id();
$groupId = $_SESSION['_gid'];
$file_size = filesize($documentPath);
$relativeUrlPath = $dir;
$doc_id = FileManager::add_document($_course, $relativeUrlPath . $audio_filename, 'file', filesize($documentPath), $audio_title);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
Display::display_confirmation_message(get_lang('DocumentCreated'));
//return to location
//.........这里部分代码省略.........
示例13: get_lang
if (api_get_setting('document.pdf_export_watermark_by_course') == 'true') {
$url = PDF::get_watermark($course_code);
$form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>';
$form->addElement('html', '<div class="row"><div class="formw"><a href="' . $url . '">' . $url . ' ' . $delete_url . '</a></div></div>');
}
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
}
if (api_get_setting('course.allow_course_theme') == 'true') {
$group = array();
$group[] = $form->createElement('SelectTheme', 'course_theme', null, array('id' => 'course_theme_id'));
$form->addGroup($group, '', array(get_lang("Stylesheets")), '');
}
$form->addElement('label', get_lang('DocumentQuota'), format_file_size(DocumentManager::get_course_quota()));
$form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
$form->addElement('html', '</div></div>');
// COURSE ACCESS
$form->addElement('html', '<div> <h3>' . Display::return_icon('course.png', Security::remove_XSS(get_lang('CourseAccess')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('CourseAccess')) . '</h3><div>');
$group = array();
$group[] = $form->createElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
// The "hidden" visibility is only available to portal admins
if (api_is_platform_admin()) {
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
}
$form->addGroup($group, '', array(get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")), '');
$url = api_get_path(WEB_CODE_PATH) . "auth/inscription.php?c={$course_code}&e=1";
示例14: verify_document_size
public function verify_document_size($s)
{
$post_max = ini_get('post_max_size');
if (substr($post_max, -1, 1) == 'M') {
$post_max = intval(substr($post_max, 0, -1)) * 1024 * 1024;
} elseif (substr($post_max, -1, 1) == 'G') {
$post_max = intval(substr($post_max, 0, -1)) * 1024 * 1024 * 1024;
}
$upl_max = ini_get('upload_max_filesize');
if (substr($upl_max, -1, 1) == 'M') {
$upl_max = intval(substr($upl_max, 0, -1)) * 1024 * 1024;
} elseif (substr($upl_max, -1, 1) == 'G') {
$upl_max = intval(substr($upl_max, 0, -1)) * 1024 * 1024 * 1024;
}
$documents_total_space = DocumentManager::documents_total_space();
$course_max_space = DocumentManager::get_course_quota();
$total_size = filesize($s) + $documents_total_space;
if (filesize($s) > $post_max || filesize($s) > $upl_max || $total_size > $course_max_space) {
return true;
} else {
return false;
}
}
示例15: str_replace
$title_to_save = str_replace('_', ' ', $title_to_save);
}
$documentPath = $saveDir . '/' . $webcamname_to_save;
//read content
$content = file_get_contents('php://input');
if (!$content) {
print "ERROR: Failed to read data\n";
exit;
}
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $content);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
//add document to database
$doc_id = FileManager::add_document($_course, $webcamdir . '/' . $webcamname_to_save, 'file', filesize($documentPath), $title_to_save);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
///
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/' . $documentPath;
print "{$url}\n";