/** * Render attach file to an object control * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_attach_files($params, &$smarty) { static $ids = array(); $id = array_var($params, 'id'); if (empty($id)) { $counter = 1; do { $id = 'attach_files_' . $id++; } while (in_array($id, $ids)); } // if $ids[] = $id; $max_files = (int) array_var($params, 'max_files', 1, true); if ($max_files < 1) { $max_files = 1; } // if require_once SMARTY_PATH . '/plugins/modifier.filesize.php'; if ($max_files == 1) { $max_upload_size_message = lang('Max size of file that you can upload is :size', array('size' => smarty_modifier_filesize(get_max_upload_size()))); } else { $max_upload_size_message = lang('Max total size of files you can upload is :size', array('size' => smarty_modifier_filesize(get_max_upload_size()))); } // if return '<div class="attach_files" id="' . $id . '" max_files="' . $max_files . '"><p class="attach_files_max_size details">' . $max_upload_size_message . '</p></div><script type="text/javascript">App.resources.AttachFiles.init("' . $id . '")</script>'; }
/** * Validate a uploaded file * * @param string $attribute * @param UploadedFile $file * @param string $property * @return bool */ public function validateFile($attribute, UploadedFile $file, $property) { if (is_null($file)) { return false; } if (!$file->isValid()) { return false; } // compare file sizes in kB units if ($file->getClientSize() / 1000 > get_max_upload_size()) { return false; } return true; }
<div id="<?php echo $genid ?>fileUploadDiv"> <?php echo label_tag(lang('file'), $genid . 'fileFormFile', true) ?> <?php Hook::fire('render_upload_control', array( "genid" => $genid, "attributes" => array( "id" => $genid . "fileFormFile", "class" => "title", "size" => "88", "style" => 'width:530px', "tabindex" => "10", "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);" ) ), $ret); ?> <p><?php echo lang('upload file desc', format_filesize(get_max_upload_size())) ?></p> </div> <div id="<?php echo $genid ?>weblinkDiv" style="display:none;"> <?php echo label_tag(lang('weblink'), 'file[url]', true, array('id' => $genid.'weblinkLbl', 'type' => 'text')) ?> <?php echo text_field('file[url]', '', array('id' => $genid.'url', 'style' => 'width:500px;', "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);")) ?> </div> </div> <?php } ?> <?php } // if ?> <div id="<?php echo $genid ?>addFileFilename" style="<?php echo $file->isNew()? 'display:none' : '' ?>"> <?php echo label_tag(lang('new filename'), $genid .'fileFormFilename') ?> <?php echo text_field('file[name]',$file->getFilename(), array("id" => $genid .'fileFormFilename', 'tabindex' => '20', 'class' => 'title', 'onchange' => ($file->getType() == ProjectFiles::TYPE_DOCUMENT? 'javascript:og.checkFileName(\'' . $genid . '\')' : ''))) ?> <?php if ($file->getType() == ProjectFiles::TYPE_WEBLINK){?>
private static function generateErrorMessage($error_code) { Env::useHelper('format'); switch ($error_code) { case UPLOAD_ERR_INI_SIZE: return lang('upload error msg UPLOAD_ERR_INI_SIZE', format_filesize(get_max_upload_size())); case UPLOAD_ERR_FORM_SIZE: return lang('upload error msg UPLOAD_ERR_FORM_SIZE', format_filesize(get_max_upload_size())); case UPLOAD_ERR_PARTIAL: return lang('upload error msg UPLOAD_ERR_PARTIAL'); case UPLOAD_ERR_NO_FILE: return lang('upload error msg UPLOAD_ERR_NO_FILE'); case UPLOAD_ERR_NO_TMP_DIR: return lang('upload error msg UPLOAD_ERR_NO_TMP_DIR'); case UPLOAD_ERR_CANT_WRITE: return lang('upload error msg UPLOAD_ERR_CANT_WRITE'); case UPLOAD_ERR_EXTENSION: return lang('upload error msg UPLOAD_ERR_EXTENSION'); default: return lang('error upload file'); } }
fud_use('users_reg.inc'); fud_use('tz.inc'); function get_max_upload_size() { $us = strtolower(ini_get('upload_max_filesize')); $size = (int) $us; if (strpos($us, 'm') !== false) { $size *= 1024 * 1024; } else { if (strpos($us, 'k') !== false) { $size *= 1024; } } return $size; } $max_attach_size = get_max_upload_size(); if (isset($_POST['CF_PRIVATE_ATTACH_SIZE'])) { if ($_POST['CF_PRIVATE_ATTACH_SIZE'] > $max_attach_size) { $_POST['CF_PRIVATE_ATTACH_SIZE'] = $max_attach_size; } } else { if ($GLOBALS['PRIVATE_ATTACH_SIZE'] > $max_attach_size) { $GLOBALS['PRIVATE_ATTACH_SIZE'] = $max_attach_size; } } $help_ar = read_help(); if (isset($_POST['form_posted'])) { for ($i = 1; $i < 10; $i++) { if (isset($GLOBALS['FUD_OPT_' . $i])) { $GLOBALS['NEW_FUD_OPT_' . $i] = 0; } else {
public function testGetMaxUploadSize() { $this->assertTrue(is_int(get_max_upload_size())); }
$size *= 1024; } } return $size; } require './GLOBALS.php'; fud_egw(); /* this is here so we get the cat_id when cancel button is clicked */ $cat_id = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : (isset($_POST['cat_id']) ? (int) $_POST['cat_id'] : ''); fud_use('adm.inc', true); fud_use('forum_adm.inc', true); fud_use('cat.inc', true); fud_use('widgets.inc', true); fud_use('logaction.inc'); $tbl = $GLOBALS['DBHOST_TBL_PREFIX']; $max_upload_size = get_max_upload_size(); if (!$cat_id || ($cat_name = q_singleval('SELECT name FROM ' . $tbl . 'cat WHERE id=' . $cat_id)) === NULL) { exit('no such category'); } $edit = isset($_GET['edit']) ? (int) $_GET['edit'] : (isset($_POST['edit']) ? (int) $_POST['edit'] : ''); if (isset($_POST['frm_submit'])) { if ($_POST['frm_max_attach_size'] > $max_upload_size) { $_POST['frm_max_attach_size'] = floor($max_upload_size / 1024); } /* (int) $_POST['frm_anon_forum'] is unused */ $_POST['frm_forum_opt'] = (int) $_POST['frm_mod_attach'] | (int) $_POST['frm_moderated'] | (int) $_POST['frm_passwd_posting'] | (int) $_POST['frm_tag_style']; $frm = new fud_forum(); if (!$edit) { fud_use('groups_adm.inc', true); fud_use('groups.inc'); $frm->cat_id = $cat_id;
/** * Upload file document page action * * @param void * @return void */ function upload_file() { $this->wireframe->print_button = false; if (!Document::canAdd($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $file = $_FILES['file']; $file_data = $this->request->post('file'); if (!is_array($file_data)) { $file_data = array('category_id' => $this->active_document_category->getId()); } // if require_once SMARTY_PATH . '/plugins/modifier.filesize.php'; $this->smarty->assign(array('file_data' => $file_data, 'max_upload_size' => smarty_modifier_filesize(get_max_upload_size()))); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_document->setAttributes($file_data); if (is_array($file)) { $destination_file = get_available_uploads_filename(); if (move_uploaded_file($file['tmp_name'], $destination_file)) { if (FIX_UPLOAD_PERMISSION !== false) { @chmod($destination_file, FIX_UPLOAD_PERMISSION); } // if $this->active_document->setName($file['name']); $this->active_document->setBody(basename($destination_file)); $this->active_document->setMimeType($file['type']); } // if } // if $this->active_document->setCreatedBy($this->logged_user); $this->active_document->setType('file'); $save = $this->active_document->save(); if ($save && !is_error($save)) { $notify_user_ids = $this->request->post('notify_users'); if (is_foreachable($notify_user_ids)) { $notify_users = Users::findByIds($notify_user_ids); $owner_company = get_owner_company(); if (is_foreachable($notify_users)) { ApplicationMailer::send($notify_users, 'documents/new_upload_file_document', array('document_name' => $this->active_document->getName(), 'created_by_name' => $this->active_document->getCreatedByName(), 'created_by_url' => $this->logged_user->getViewUrl(), 'document_url' => $this->active_document->getViewUrl(), 'owner_company_name' => $owner_company->getName()), $this->active_document); } // if } // if db_commit(); flash_success('Document ":document_name" has been uploaded', array('document_name' => $this->active_document->getName())); $this->redirectTo('documents'); } else { db_rollback(); $this->smarty->assign('errors', $save); } // if } // if }
public static function get_addform_elements() { return array('startdate' => array('type' => 'text', 'rules' => array('required' => true), 'title' => get_string('startdate', 'artefact.resume'), 'help' => true, 'size' => 20), 'enddate' => array('type' => 'text', 'title' => get_string('enddate', 'artefact.resume'), 'size' => 20), 'title' => array('type' => 'text', 'rules' => array('required' => true), 'title' => get_string('title', 'artefact.resume'), 'size' => 50), 'description' => array('type' => 'textarea', 'rows' => 10, 'cols' => 50, 'resizable' => false, 'title' => get_string('description', 'artefact.resume')), 'attachments' => array('type' => 'files', 'title' => get_string('attachfile', 'artefact.resume'), 'defaultvalue' => array(), 'maxfilesize' => get_max_upload_size(false))); }
/** * This function will process uploaded file * * @param array $uploaded_file * @param boolean $create_revision Create new revision or update last one * @param string $revision_comment Revision comment, if any * @return ProjectFileRevision */ function handleUploadedFile($uploaded_file, $create_revision = true, $revision_comment = '') { $revision = null; if (!$create_revision) { $revision = $this->getLastRevision(); } // if if (!is_array($uploaded_file) || count($uploaded_file) == 0) { throw new Exception(lang('uploaded file bigger than max upload size', format_filesize(get_max_upload_size()))); } if (!$revision instanceof ProjectFileRevision) { $revision = new ProjectFileRevision(); $revision->setFileId($this->getId()); $revision->setRevisionNumber($this->getNextRevisionNumber()); //$revision->setRevisionNumber(78); if (trim($revision_comment) == '' && $this->countRevisions() < 1) { $revision_comment = lang('initial versions'); } // if } // if if (strtolower(substr($uploaded_file['name'], -4)) == '.pdf' && $uploaded_file['type'] != 'application/pdf') { $uploaded_file['type'] = 'application/pdf'; } $revision->deleteThumb(false); // remove thumb // We have a file to handle! //executes only while uploading files if (!is_array($uploaded_file) || !isset($uploaded_file['name']) || !isset($uploaded_file['size']) || !isset($uploaded_file['type']) || (!isset($uploaded_file['tmp_name']) || !is_readable($uploaded_file['tmp_name']))) { throw new InvalidUploadError($uploaded_file); } // if if (isset($uploaded_file['error']) && $uploaded_file['error'] > UPLOAD_ERR_OK) { throw new InvalidUploadError($uploaded_file); } // if //eyedoc MOD $extension = get_file_extension(basename($uploaded_file['name'])); if ($uploaded_file['type'] == 'application/octet-stream' && $extension == 'eyedoc') { $uploaded_file['type'] = 'text/html'; } //eyedoc MOD // calculate hash if ($revision->columnExists('hash')) { $hash = hash_file("sha256", $uploaded_file['tmp_name']); $revision->setColumnValue('hash', $hash); } $repository_id = FileRepository::addFile($uploaded_file['tmp_name'], array('name' => $uploaded_file['name'], 'type' => $uploaded_file['type'], 'size' => $uploaded_file['size'])); $revision->setRepositoryId($repository_id); $revision->deleteThumb(false); $revision->setFilesize($uploaded_file['size']); if ($uploaded_file['type'] == 'application/x-unknown-application') { $type = Mime_Types::instance()->get_type($extension); if ($type) { $revision->setTypeString($type); } else { $revision->setTypeString($uploaded_file['type']); } } else { $revision->setTypeString($uploaded_file['type']); } if (trim($extension)) { $file_type = FileTypes::getByExtension($extension); if ($file_type instanceof Filetype) { if (!$file_type->getIsAllow()) { flash_error(lang('file extension no allow')); return; } else { $revision->setFileTypeId($file_type->getId()); } } // if } // if $revision->setComment($revision_comment); $revision->save(); $this->last_revision = $revision; // update last revision return $revision; }
public static function add_comment_form($defaultprivate = false, $moderate = false) { global $USER; $form = array('name' => 'add_feedback_form', 'method' => 'post', 'plugintype' => 'artefact', 'pluginname' => 'comment', 'jsform' => true, 'autofocus' => false, 'elements' => array(), 'jssuccesscallback' => 'addFeedbackSuccess', 'jserrorcallback' => 'addFeedbackError'); if (!$USER->is_logged_in()) { $form['spam'] = array('secret' => get_config('formsecret'), 'mintime' => 1, 'hash' => array('authorname', 'message', 'message', 'submit')); $form['elements']['authorname'] = array('type' => 'text', 'title' => get_string('name'), 'rules' => array('required' => true)); } $form['elements']['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'class' => 'hide-label', 'rows' => 5, 'cols' => 80, 'rules' => array('maxlength' => 8192)); if (get_config_plugin('artefact', 'comment', 'commentratings')) { $form['elements']['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star'); } $form['elements']['ispublic'] = array('type' => 'switchbox', 'title' => get_string('makepublic', 'artefact.comment'), 'defaultvalue' => !$defaultprivate); if (get_config('licensemetadata')) { $form['elements']['license'] = license_form_el_basic(null); $form['elements']['licensing_advanced'] = license_form_el_advanced(null); } if ($moderate) { $form['elements']['ispublic']['description'] = get_string('approvalrequired', 'artefact.comment'); $form['elements']['moderate'] = array('type' => 'hidden', 'value' => true); } if ($USER->is_logged_in()) { $form['elements']['attachments'] = array('type' => 'files', 'title' => get_string('attachfile', 'artefact.comment'), 'defaultvalue' => array(), 'maxfilesize' => get_max_upload_size(false)); } $form['elements']['submit'] = array('type' => 'submitcancel', 'class' => 'btn-default', 'value' => array(get_string('Comment', 'artefact.comment'), get_string('cancel'))); // This is a placeholder where we can display the parent comment's text // And also the strings we display when we are forcing a reply to be public or private $snippet = smarty_core(); $form['elements']['replytoview'] = array('type' => 'html', 'value' => $snippet->fetch('artefact:comment:replyplaceholder.tpl')); // This is a placeholder for the parent comment's ID. It'll be populated by Javascript if needed. $form['elements']['replyto'] = array('type' => 'hidden', 'dynamic' => 'true', 'value' => null); return $form; }
} // installation completed or not message if (!$errorFound) { $out .= "\n<br /><center><b>" . get_lang('Learning path has been successfully imported.') . "</b></center>"; $out .= "\n<br /><br ><center><a href=\"" . claro_htmlspecialchars(Url::Contextualize("learningPathAdmin.php?path_id=" . $tempPathId)) . "\">" . $lpName . "</a></center>"; } else { $out .= "\n<br /><center><b>" . get_lang('An error occurred. Learning Path import failed.') . "</b></center>"; } $out .= "\n<br /><a href=\"" . claro_htmlspecialchars(Url::Contextualize("learningPathList.php")) . "\"><< " . get_lang('Back') . "</a>"; } else { // don't display the form if user already sent it /*-------------------------------------- UPLOAD FORM --------------------------------------*/ $out .= "\n\n" . get_lang('Imported packages must consist of a zip file and be SCORM 1.2 conformable'); $out .= '<br /><br /> <form enctype="multipart/form-data" action="' . $_SERVER['PHP_SELF'] . '" method="post"> <input type="hidden" name="claroFormId" value="' . uniqid('') . '" /> ' . claro_form_relay_context() . ' <input type="file" name="uploadedPackage" /><br /> <small>' . get_lang('Max file size : %size', array('%size' => format_file_size(get_max_upload_size($maxFilledSpace, $baseWorkDir)))) . '</small> <p> <input type="submit" value="' . get_lang('Import') . '" /> ' . claro_html_button(Url::Contextualize('./learningPathList.php'), get_lang('Cancel')) . "\n" . '</p>' . '</form>'; } // else if method == 'post' $claroline->display->body->appendContent($out); echo $claroline->display->render();
<!-- Upload File --> <input type="radio" id="file_type_1" name="file_type" value="1" /> <label for="file_type_1"><?php _e('Upload File:', 'wp-downloadmanager'); ?> </label> <input type="file" name="file_upload" size="25" onclick="document.getElementById('file_type_1').checked = true;" dir="ltr" /> <?php _e('to', 'wp-downloadmanager'); ?> <select name="file_upload_to" size="1" onclick="document.getElementById('file_type_1').checked = true;" dir="ltr"> <?php print_list_folders($file_path, $file_path); ?> </select> <br /><small><?php printf(__('Maximum file size is %s.', 'wp-downloadmanager'), format_filesize(get_max_upload_size())); ?> </small> <!-- Remote File --> <br /><br /> <input type="radio" id="file_type_2" name="file_type" value="2" /> <label for="file_type_2"><?php _e('Remote File:', 'wp-downloadmanager'); ?> </label> <input type="text" name="file_remote" size="50" maxlength="255" onclick="document.getElementById('file_type_2').checked = true;" value="http://" dir="ltr" /> <br /><small><?php _e('Please include http:// or ftp:// in front.', 'wp-downloadmanager'); ?> </small> </td> </tr>
function handle_upload() { global $bp; //include core files require_once ABSPATH . '/wp-admin/includes/file.php'; $max_upload_size = get_max_upload_size(); $max_upload_size = $max_upload_size * 1024; //convert kb to bytes $file = $_FILES; //I am not changing the domain of erro messages as these are same as bp, so you should have a translation for this $uploadErrors = array(0 => __('There is no error, the file uploaded with success', 'buddypress'), 1 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size), 2 => __('Your image was bigger than the maximum allowed file size of: ', 'buddypress') . size_format($max_upload_size), 3 => __('The uploaded file was only partially uploaded', 'buddypress'), 4 => __('No file was uploaded', 'buddypress'), 6 => __('Missing a temporary folder', 'buddypress')); if (isset($file['error']) && $file['error']) { bp_core_add_message(sprintf(__('Your upload failed, please try again. Error was: %s', 'buddypress'), $uploadErrors[$file['file']['error']]), 'error'); return false; } if (!($file['file']['size'] < $max_upload_size)) { bp_core_add_message(sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format($max_upload_size)), 'error'); return false; } if (!empty($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type']) || !preg_match('/(jpe?g|gif|png)$/i', $file['file']['name'])) { bp_core_add_message(__('Please upload only JPG, GIF or PNG photos.', 'buddypress'), 'error'); return false; } $uploaded_file = wp_handle_upload($file['file'], array('action' => 'bp_upload_profile_bg')); //if file was not uploaded correctly if (!empty($uploaded_file['error'])) { bp_core_add_message(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $uploaded_file['error']), 'error'); return false; } //assume that the file uploaded succesfully //delete any previous uploaded image delete_bg_for_user(); //save in usermeta bp_update_user_meta(bp_loggedin_user_id(), 'profile_bg', $uploaded_file['url']); bp_update_user_meta(bp_loggedin_user_id(), 'profile_bg_file_path', $uploaded_file['file']); do_action('bppg_background_uploaded', $uploaded_file['url']); //allow to do some other actions when a new background is uploaded return true; }
// if the file is required and the text is only a description of the file $out .= get_lang('Upload document') . ' <span class="required">*</span>'; } $out .= '</label></dt>' . "\n"; if (!empty($submitGroupWorkUrl)) { // Secure download $file = $submitGroupWorkUrl; // FIXME : secureDocumentDownload ? if ($GLOBALS['is_Apache'] && get_conf('secureDocumentDownload')) { $groupWorkUrl = Url::Contextualize(get_path('clarolineRepositoryWeb') . 'backends/download.php' . str_replace('%2F', '/', rawurlencode($file)) . '?gidReq=' . claro_get_current_group_id()); } else { $groupWorkUrl = Url::Contextualize(get_path('clarolineRepositoryWeb') . 'backends/download.php?url=' . rawurlencode($file) . '&gidReq=' . claro_get_current_group_id()); } $out .= '<dd>' . '<input type="hidden" name="submitGroupWorkUrl" value="' . claro_htmlspecialchars($submitGroupWorkUrl) . '" />' . '<a href="' . claro_htmlspecialchars($groupWorkUrl) . '">' . basename($file) . '</a>' . '</dd>' . "\n"; } else { $maxFileSize = min(get_max_upload_size($maxFilledSpace, $assignment->getAssigDirSys()), $fileAllowedSize); $out .= '<dd>' . "\n" . '<input type="file" name="wrkFile" id="wrkFile" size="30" /><br />' . '<p class="notice">' . get_lang('Max file size : %size', array('%size' => format_file_size($maxFileSize))) . '</p></td>' . "\n" . '</dd>' . "\n\n"; } } if ($assignmentContent == "FILE" && !$is_feedback) { // display standard html textarea // used for description of an uploaded file $out .= '<dt>' . '<label for="wrkTxt">' . get_lang('File description') . '<br /></label>' . '</dt>' . '<dd>' . "\n" . '<textarea name="wrkTxt" cols="40" rows="10">' . $form['wrkTxt'] . '</textarea>' . '</dd>' . "\n"; } elseif ($assignmentContent == "TEXT" || $assignmentContent == "TEXTFILE" || $is_feedback) { // display enhanced textarea using claro_html_textarea_editor $out .= '<dt>' . '<label for="wrkTxt">' . get_lang('Answer') . ' <span class="required">*</span></label></dt>' . "\n" . '<dd>' . claro_html_textarea_editor('wrkTxt', $form['wrkTxt']) . '</dd>' . "\n\n"; } if ($is_feedback) { $out .= '<dt>' . '<label for="wrkPrivFbk">' . get_lang('Private feedback') . '<br />' . '<small>' . get_lang('Course administrator only') . '</small>' . '</label></dt>' . '<dd>' . "\n" . '<textarea name="wrkPrivFbk" cols="40" rows="10">' . $san->sanitize($form['wrkPrivFbk']) . '</textarea>' . '</dd>' . "\n\n"; // if this is a correction we have to add an input for the score/grade/results/points $wrkScoreField = '<select name="wrkScore" id="wrkScore">' . "\n" . '<option value="-1"';
function image_valid($file, &$error) { $image['temp'] = $file['tmp_name']; $max_upload_size = get_max_upload_size(); if ($image['size'] > $max_upload_size) { $error = 'The image you have chosen to upload is too large, it must be under ' . strip_end($max_upload_size, 3) . 'kB.'; return false; } $dot = strrpos($file['name'], '.'); $image['ext'] = strtolower(substr($file['name'], $dot + 1)); if (image_types($image['ext'])) { return $image; } else { $error = 'The image you have uploaded is the wrong file type (' . $image['ext'] . ') - it must be a JPG or PNG file.'; return false; } }
/** * Show upload form * * @param void * @return null */ function upload() { $this->wireframe->page_actions = array(); // clear page actions if (!File::canAdd($this->logged_user, $this->active_project)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $file_data = array('milestone_id' => $this->request->get('milestone_id'), 'visibility' => $this->active_project->getDefaultVisibility()); if (instance_of($this->active_category, 'Category')) { $file_data['parent_id'] = $this->active_category->getId(); } // if js_assign('files_section_url', files_module_url($this->active_project)); require_once SMARTY_PATH . '/plugins/modifier.filesize.php'; $this->smarty->assign(array('file_data' => $file_data, 'max_upload_size' => smarty_modifier_filesize(get_max_upload_size()), 'upload_single_file_url' => assemble_url('project_files_upload_single', array('project_id' => $this->active_project->getId())))); }
?> <?php echo radio_field($genid . '_rg', false, array('id' => $genid . 'weblinkRadio', 'onchange' => 'og.addDocumentTypeChanged(1, "' . $genid . '")', 'value' => '1')) . ' ' . lang('weblink'); ?> <div id="<?php echo $genid; ?> fileUploadDiv"> <?php echo label_tag(lang('file'), $genid . 'fileFormFile', true); ?> <?php Hook::fire('render_upload_control', array("genid" => $genid, "attributes" => array("id" => $genid . "fileFormFile", "class" => "title", "size" => "50", "tabindex" => "10", "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);")), $ret); ?> <p><?php echo lang('upload file desc', format_filesize(get_max_upload_size())); ?> </p> </div> <div id="<?php echo $genid; ?> weblinkDiv" style="display:none;"> <?php echo label_tag(lang('weblink'), 'file[url]', true, array('id' => $genid . 'weblinkLbl', 'type' => 'text')); ?> <?php echo text_field('file[url]', '', array('id' => $genid . 'url', 'style' => 'width:500px;', "onchange" => "javascript:og.updateFileName('" . $genid . "', this.value);")); ?> </div> </div>
<?php } else { ?> <?php echo lang('footer copy without homepage', date('Y'), clean(owner_company()->getObjectName())) ?> <?php } // if ?> </div> <?php Hook::fire('render_page_footer', null, $ret) ?> <div id="productSignature"><?php echo product_signature() ?></div> </div> <!-- /footer --> <script> // OG config options og.hostName = '<?php echo ROOT_URL ?>'; og.sandboxName = <?php echo defined('SANDBOX_URL') ? "'".SANDBOX_URL."'" : 'false'; ?>; og.maxUploadSize = '<?php echo get_max_upload_size() ?>'; <?php //FIXME initialWS for initialMembers $initialWS = user_config_option('initialWorkspace'); if ($initialWS === "remember") { $initialWS = user_config_option('lastAccessedWorkspace', 0); } ?> og.initialWorkspace = '<?php echo $initialWS ?>'; <?php $qs = (trim($_SERVER['QUERY_STRING'])) ? "&" . $_SERVER['QUERY_STRING'] : ""; ?> og.queryString = '<?php echo $_SERVER['QUERY_STRING'] ?>'; og.initialURL = '<?php echo ROOT_URL ."/?".$_SERVER['QUERY_STRING'] ?>'; <?php if (user_config_option("rememberGUIState")) { ?> og.initialGUIState = <?php echo json_encode(GUIController::getState()) ?>; <?php } if (user_config_option("autodetect_time_zone", null)) {
function pieform_element_filebrowser_delete(Pieform $form, $element, $artefact) { global $USER; $institution = $form->get_property('institution'); $group = $form->get_property('group'); try { $artefact = artefact_instance_from_id($artefact); } catch (ArtefactNotFoundException $e) { $parentfolder = $element['folder'] ? $element['folder'] : null; $result = array('error' => true, 'message' => get_string('deletingfailed', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder)); return $result; } if (!$USER->can_edit_artefact($artefact) || $artefact->get('locked')) { return array('error' => true, get_string('nodeletepermission', 'mahara')); } $parentfolder = $artefact->get('parent'); $artefact->delete(); return array('error' => false, 'deleted' => true, 'message' => get_string('filethingdeleted', 'artefact.file', get_string($artefact->get('artefacttype'), 'artefact.file') . ' ' . $artefact->get('title')), 'quotaused' => $USER->get('quotaused'), 'quota' => $USER->get('quota'), 'maxuploadsize' => display_size(get_max_upload_size(!$institution && !$group)), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder)); }
</div> <!-- /footer --> <script> // OG config options og.hostName = '<?php echo ROOT_URL; ?> '; og.sandboxName = <?php echo defined('SANDBOX_URL') ? "'" . SANDBOX_URL . "'" : 'false'; ?> ; og.maxUploadSize = '<?php echo get_max_upload_size(); ?> '; <?php $initialWS = user_config_option('initialWorkspace'); if ($initialWS === "remember") { $initialWS = user_config_option('lastAccessedWorkspace', 0); } ?> og.initialWorkspace = '<?php echo $initialWS; ?> '; <?php $qs = trim($_SERVER['QUERY_STRING']) ? "&" . $_SERVER['QUERY_STRING'] : ""; ?>
* @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'content/profileicons'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'file'); define('SECTION_PAGE', 'profileicons'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('profileicons', 'artefact.file')); $settingsform = new Pieform(array('name' => 'settings', 'renderer' => 'oneline', 'autofocus' => false, 'presubmitcallback' => '', 'elements' => array('default' => array('type' => 'submit', 'value' => get_string('Default', 'artefact.file')), 'delete' => array('type' => 'submit', 'value' => get_string('Delete', 'artefact.file'))))); $uploadform = pieform(array('name' => 'upload', 'class' => 'form-upload', 'jsform' => true, 'presubmitcallback' => 'preSubmit', 'postsubmitcallback' => 'postSubmit', 'plugintype' => 'artefact', 'pluginname' => 'file', 'elements' => array('file' => array('type' => 'file', 'title' => get_string('profileicon', 'artefact.file'), 'rules' => array('required' => true), 'maxfilesize' => get_max_upload_size(false)), 'title' => array('type' => 'text', 'title' => get_string('imagetitle', 'artefact.file')), 'submit' => array('type' => 'submit', 'class' => 'btn-success', 'value' => get_string('upload'))))); $strnoimagesfound = json_encode(get_string('noimagesfound', 'artefact.file')); $struploadingfile = json_encode(get_string('uploadingfile', 'artefact.file')); $wwwroot = get_config('wwwroot'); $notfound = $THEME->get_image_url('no_userphoto'); if (!get_config('remoteavatars')) { $ravatar = $notfound; } else { $ravatar = remote_avatar($USER->get('email'), array('maxw' => '100', 'maxh' => '100'), $notfound); } $profileiconattachedtoportfolioitems = json_encode(get_string('profileiconattachedtoportfolioitems', 'artefact.file')); $profileiconappearsinviews = json_encode(get_string('profileiconappearsinviews', 'artefact.file')); $profileiconappearsinskins = json_encode(get_string('profileiconappearsinskins', 'artefact.file')); $confirmdeletefile = json_encode(get_string('confirmdeletefile', 'artefact.file')); $setdefault = json_encode(get_string('setdefault', 'artefact.file')); $markfordeletion = json_encode(get_string('markfordeletion', 'artefact.file'));
$dialogBox->form($form); } // end if ($imgFileNb > 0) } // end if (strrchr($fileName) == "htm" } // end if is_uploaded_file } // end if ($cmd == 'exUpload') if ($cmd == 'rqUpload') { /* * Prepare dialog box display */ $spaceAlreadyOccupied = dir_total_space($baseWorkDir); $remainingDiskSpace = $maxFilledSpace - $spaceAlreadyOccupied; $maxUploadSize = get_max_upload_size($maxFilledSpace, $baseWorkDir); if ($remainingDiskSpace < 0) { // Disk quota exceeded $remainingDiskSpace = 0; $adminEmailUrl = '<a href="mailto:' . get_conf('administrator_email') . '">' . get_lang('Platform administrator') . '</a>'; $dialogBox->error('<p>' . get_lang('Disk quota exceeded, please contact the %administrator', array('%administrator' => $adminEmailUrl)) . '<br />' . "\n" . '<small>' . get_lang('Maximum disk space : %size', array('%size' => format_file_size($maxFilledSpace))) . '</small><br />' . "\n" . '<small>' . get_lang('Disk space occupied : %size', array('%size' => format_file_size($spaceAlreadyOccupied))) . '</small><br />' . "\n" . '<small>' . get_lang('Disk space available : %size', array('%size' => format_file_size($remainingDiskSpace))) . '</small>' . '</p>'); } else { /* * Technical note: 'cmd=exUpload' is added into the 'action' * attributes of the form, rather than simply put in a post * hidden input. That way, this parameter is concatenated with * the URL, and it guarantees than it will be received by the * server. The reason of this trick, is because, sometimes, * when file upload fails, no form data are received at all by * the server. For example when the size of the sent file is so * huge that its reception exceeds the max execution time
// Some fields to hide from the default institution config screen if (empty($data->name) || $data->name != 'mahara') { $elements['defaultmembershipperiod'] = array('type' => 'expiry', 'title' => get_string('defaultmembershipperiod', 'admin'), 'description' => get_string('defaultmembershipperioddescription', 'admin'), 'defaultvalue' => $data->defaultmembershipperiod, 'help' => true); $languages = get_languages(); // Get the default language. If the institution has one stored, use that. Otherwise, use 'sitedefault' $defaultlang = false; if (!empty($data->name)) { $defaultlang = get_config_institution($data->name, 'lang'); } // If the defaultlang they provided is no longer valid, use "site default" if (!$defaultlang || !array_key_exists($defaultlang, $languages)) { $defaultlang = 'sitedefault'; } $elements['lang'] = array('type' => 'select', 'defaultvalue' => $defaultlang, 'title' => get_string('institutionlanguage', 'admin'), 'description' => get_string('institutionlanguagedescription', 'admin'), 'options' => array_merge(array('sitedefault' => get_string('sitedefault', 'admin') . ' (' . $languages[get_config('lang')] . ')'), $languages), 'ignore' => count($languages) < 2); } $elements['logo'] = array('type' => 'file', 'title' => get_string('Logo', 'admin'), 'description' => get_string('logodescription', 'admin'), 'maxfilesize' => get_max_upload_size(false)); if (!empty($data->logo)) { $logourl = get_config('wwwroot') . 'thumb.php?type=logobyid&id=' . $data->logo; $elements['logohtml'] = array('type' => 'html', 'value' => '<img src="' . $logourl . '" alt="' . get_string('Logo', 'admin') . '">'); $elements['deletelogo'] = array('type' => 'switchbox', 'title' => get_string('deletelogo', 'admin'), 'description' => get_string('deletelogodescription1', 'admin')); } if (empty($data->name) || $data->name != 'mahara') { if (!empty($data->style)) { $customtheme = get_records_menu('style_property', 'style', $data->style, '', 'field,value'); } $elements['theme'] = array('type' => 'select', 'title' => get_string('theme'), 'description' => get_string('sitethemedescription', 'admin'), 'defaultvalue' => $data->theme ? $data->theme : 'sitedefault', 'collapseifoneoption' => true, 'options' => $themeoptions, 'help' => true); $elements['customthemefs'] = array('type' => 'fieldset', 'class' => 'customtheme' . ($elements['theme']['defaultvalue'] != 'custom' ? ' js-hidden' : ''), 'legend' => get_string('customtheme', 'admin'), 'elements' => array()); foreach ($customthemedefaults as $name => $styledata) { $elements['customthemefs']['elements'][$name] = array('type' => $styledata['type'], 'title' => get_string('customtheme.' . $name, 'admin'), 'defaultvalue' => isset($customtheme[$name]) ? $customtheme[$name] : $styledata['value']); } $elements['customthemefs']['elements']['resetcustom'] = array('type' => 'switchbox', 'class' => 'nojs-hidden-inline', 'title' => get_string('resetcolours', 'admin'), 'description' => get_string('resetcoloursdesc1', 'admin'));
public static function add_comment_form($defaultprivate = false, $moderate = false) { global $USER; $form = array('name' => 'add_feedback_form', 'method' => 'post', 'class' => 'js-hidden', 'plugintype' => 'artefact', 'pluginname' => 'comment', 'jsform' => true, 'autofocus' => false, 'elements' => array(), 'jssuccesscallback' => 'addFeedbackSuccess'); if (!$USER->is_logged_in()) { $form['spam'] = array('secret' => get_config('formsecret'), 'mintime' => 1, 'hash' => array('authorname', 'message', 'ispublic', 'message', 'submit')); $form['elements']['authorname'] = array('type' => 'text', 'title' => get_string('name'), 'rules' => array('required' => true)); } $form['elements']['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'rows' => 5, 'cols' => 80, 'rules' => array('maxlength' => 8192)); if (get_config_plugin('artefact', 'comment', 'commentratings')) { $form['elements']['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star'); } $form['elements']['ispublic'] = array('type' => 'checkbox', 'title' => get_string('makepublic', 'artefact.comment'), 'defaultvalue' => !$defaultprivate); if (get_config('licensemetadata')) { $form['elements']['license'] = license_form_el_basic(null); $form['elements']['licensing_advanced'] = license_form_el_advanced(null); } if ($moderate) { $form['elements']['ispublic']['description'] = get_string('approvalrequired', 'artefact.comment'); $form['elements']['moderate'] = array('type' => 'hidden', 'value' => true); } if ($USER->is_logged_in()) { $form['elements']['attachments'] = array('type' => 'files', 'title' => get_string('attachfile', 'artefact.comment'), 'defaultvalue' => array(), 'maxfilesize' => get_max_upload_size(false)); } $form['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('placefeedback', 'artefact.comment'), get_string('cancel'))); return $form; }
function getSettings() { global $ZendDb, $acl; $settings = new DirectusSettingsTableGateway($acl, $ZendDb); $items = []; foreach ($settings->fetchAll() as $key => $value) { if ($key == 'global') { $value['max_file_size'] = get_max_upload_size(); } $value['id'] = $key; $items[] = $value; } return $items; }
function pieform_element_filebrowser_delete(Pieform $form, $element, $artefact) { global $USER; $institution = $form->get_property('institution'); $group = $form->get_property('group'); try { $artefact = artefact_instance_from_id($artefact); } catch (ArtefactNotFoundException $e) { $parentfolder = $element['folder'] ? $element['folder'] : null; $result = array('error' => true, 'message' => get_string('deletingfailed', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder)); return $result; } if (!$USER->can_edit_artefact($artefact)) { return array('error' => true, 'message' => get_string('nodeletepermission', 'mahara')); } if (!$artefact->can_be_deleted()) { return array('error' => true, 'message' => get_string('cantbedeleted', 'mahara')); } $parentfolder = $artefact->get('parent'); // Remove the skin background and update the skin thumbs require_once get_config('libroot') . 'skin.php'; Skin::remove_background($artefact->get('id')); $artefact->delete(); $result = array('error' => false, 'deleted' => true, 'artefacttype' => $artefact->get('artefacttype'), 'message' => get_string('filethingdeleted', 'artefact.file', get_string($artefact->get('artefacttype'), 'artefact.file') . ' ' . $artefact->get('title')), 'maxuploadsize' => display_size(get_max_upload_size(!$institution && !$group)), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder)); if (defined('GROUP')) { $group = group_current_group(); $result['quota'] = $group->quota; $result['quotaused'] = $group->quotaused; } else { $result['quota'] = $USER->get('quota'); $result['quotaused'] = $USER->get('quotaused'); } return $result; }
} else { $backlog = new Backlog(); $importedExId = import_exercise($_FILES['uploadedExercise']['name'], $backlog); if ($importedExId) { $dialogBox->success('<strong>' . get_lang('Import done') . '</strong>'); } else { $dialogBox->error('<strong>' . get_lang('Import failed') . '</strong>'); $cmd = 'rqImport'; } $dialogBox->info($backlog->output()); } } if ($cmd == 'rqImport') { require_once get_path('incRepositorySys') . '/lib/fileDisplay.lib.php'; require_once get_path('incRepositorySys') . '/lib/fileUpload.lib.php'; $dialogBox->form("\n" . '<strong>' . get_lang('Import exercise') . '</strong><br />' . "\n" . get_lang('Imported exercises must be an ims-qti zip file.') . '<br />' . "\n" . '<form enctype="multipart/form-data" action="./exercise.php" method="post">' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '">' . "\n" . '<input name="cmd" type="hidden" value="exImport" />' . "\n" . claro_form_relay_context() . "\n" . '<input name="uploadedExercise" type="file" /><br />' . "\n" . '<small>' . get_lang('Max file size') . ' : ' . format_file_size(get_max_upload_size($maxFilledSpace, $courseDir)) . '</small>' . "\n" . '<p>' . "\n" . '<input value="' . get_lang('Import exercise') . '" type="submit" /> ' . "\n" . claro_html_button(Url::Contextualize('./exercise.php'), get_lang('Cancel')) . '</p>' . "\n" . '</form>'); } //-- export if ($cmd == 'rqExport' && $exId) { $exercise = new Exercise(); if (!$exercise->load($exId)) { $dialogBox->error(get_lang('Unable to load the exercise')); } else { $dialogBoxContent = "\n" . '<strong>' . get_lang('Export exercise') . '</strong><br />' . "\n" . get_lang('Select the type for your export :') . '<br />' . "\n" . '<ul>' . "\n"; if (get_conf('enableExerciseExportQTI')) { $dialogBoxContent .= '<li>' . "\n" . '<img src="' . get_icon_url('export') . '" alt="' . get_lang('Export in IMS QTI') . '" /> ' . "\n" . '<a href="' . claro_htmlspecialchars(Url::Contextualize('exercise.php?cmd=exExport&exId=' . $exId)) . '">' . get_lang('Export in IMS QTI') . '</a>' . "\n" . '</li>' . "\n"; if ($exercise->getShuffle()) { $dialogBoxContent .= '<li>' . "\n" . '<img src="' . get_icon_url('export') . '" alt="' . get_lang('Export in IMS QTI (Shuffle)') . '" /> ' . "\n" . '<a href="' . claro_htmlspecialchars(Url::Contextualize('exercise.php?cmd=exExport&exId=' . $exId . '&shuffle=1')) . '">' . get_lang('Export in IMS QTI (Shuffle)') . '</a>' . "\n" . '</li>' . "\n"; } } $dialogBoxContent .= '<li>' . "\n" . '<img src="' . get_icon_url('mime/pdf') . '" alt="' . get_lang('Export to PDF') . '" /> ' . "\n" . '<a href="' . claro_htmlspecialchars(Url::Contextualize('exercise.php?cmd=exExportPDF&exId=' . $exId)) . '">' . get_lang('Export to PDF') . '</a>' . "\n" . '</li>' . "\n";