/** * CLAROLINE * * @version $Revision: 13511 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @author Piraux S�bastien <*****@*****.**> * @author Lederer Guillaume <*****@*****.**> * @package CLLNP * @since 1.8 */ function lp_display_document($TABLEASSET) { // document browser vars // Update infos about asset $sql = "SELECT `path`\n FROM `" . $TABLEASSET . "`\n WHERE `module_id` = " . (int) $_SESSION['module_id']; $assetPath = claro_sql_query_get_single_value($sql); $courseDir = claro_get_course_path() . '/document'; $baseWorkDir = get_path('coursesRepositorySys') . $courseDir; $file = $baseWorkDir . $assetPath; $fileSize = format_file_size(filesize($file)); $fileDate = format_date(filectime($file)); //####################################################################################\\ //######################## DISPLAY DETAILS ABOUT THE DOCUMENT ########################\\ //####################################################################################\\ $out = ''; $out .= "\n\n" . '<hr noshade="noshade" size="1" />' . "\n\n" . '<h4>' . get_lang('Document in module') . '</h4>' . "\n\n" . '<table class="claroTable" width="100%" border="0" cellspacing="2">' . "\n" . '<thead>' . "\n" . '<tr class="headerX">' . "\n" . '<th>' . get_lang('Filename') . '</th>' . "\n" . '<th>' . get_lang('Size') . '</th>' . "\n" . '<th>' . get_lang('Date') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>' . "\n" . '<tr align="center">' . "\n" . '<td align="left">' . basename($file) . '</td>' . "\n" . '<td>' . $fileSize . '</td>' . "\n" . '<td>' . $fileDate . '</td>' . "\n" . '</tr>' . "\n" . '</tbody>' . "\n" . '</table>' . "\n"; return $out; }
/** * Main page in administration for Incoming Mail * */ function index() { $config_admin_email = ConfigOptions::getValue('notifications_from_email'); $notifications_email = $config_admin_email ? $config_admin_email : ADMIN_EMAIL; $default_mailbox = IncomingMailboxes::findByFromEmail($notifications_email); $add_default_mailbox_url = assemble_url('incoming_mail_admin_add_mailbox', array('default_email_address' => $notifications_email)); if (!instance_of($default_mailbox, 'IncomingMailbox')) { $this->wireframe->addPageMessage(lang('System is not able to receive email messages sent as replies to notifications. If you would like your users to be able to reply to notifications and have their messages automatically submitted as comments please <a href=":add_default_mailbox_url">define an incoming mailbox</a> for <strong>:address</strong>.', array('address' => $notifications_email, 'add_default_mailbox_url' => $add_default_mailbox_url)), PAGE_MESSAGE_WARNING); } elseif (!$default_mailbox->getEnabled()) { $this->wireframe->addPageMessage(lang('System is not able to receive email messages sent as replies to notifications. If you would like your users to be able to reply to notifications and have their messages automatically submitted as comments please <a href=":edit_default_mailbox_url">enable default incoming mailbox</a>.', array('edit_default_mailbox_url' => $default_mailbox->getEditUrl())), PAGE_MESSAGE_WARNING); } // if if (!MM_CAN_DOWNLOAD_LARGE_ATTACHMENTS) { $limited_filesize = format_file_size(FAIL_SAFE_IMAP_ATTACHMENT_SIZE_MAX); if (!function_exists('imap_savebody')) { $this->wireframe->addPageMessage(lang("<b>Your PHP version is obsolete</b> - You won't be able to download attachments larger than <b>:file_size</b>. Please upgrade to latest stable version of PHP to solve this issue.", array('file_size' => $limited_filesize)), PAGE_MESSAGE_WARNING); } else { $this->wireframe->addPageMessage(lang("Importing attachments larger than <b>:file_size</b> is disabled. Module uses failsafe IMAP functions due to platform restrictions.", array('file_size' => $limited_filesize)), PAGE_MESSAGE_WARNING); } // if } // if use_model('incoming_mail_activity_logs', INCOMING_MAIL_MODULE); $per_page = 50; // mailbox activity per page $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if $only_problematic = (bool) array_var($_GET, 'only_problematic', false); if ($only_problematic) { list($activity_history, $pagination) = IncomingMailActivityLogs::paginateConflicts($page, $per_page); } else { list($activity_history, $pagination) = IncomingMailActivityLogs::paginate(array('order' => 'created_on DESC'), $page, $per_page); } // if $activity_history = group_by_date($activity_history); $this->smarty->assign(array('mailboxes' => IncomingMailboxes::find(), 'activity_history' => $activity_history, 'pagination' => $pagination, 'only_problematic' => $only_problematic)); }
/** * Uploads the file * @access public * @params * $uploaddir : Directory Name in which uploaded file is placed * $name : file input type field name * $rename : you may pass string or boolean true : rename the file if it already exists and returns the renamed file name. * String : rename the file to given string. * $replace =true : replace the file if it is already existing * $file_max_size : file size in bytes. 0 for default * $check_type : checks file type exp ."(jpg|gif|jpeg)" * Example upload_file("temp","file",true,true,0,"jpg|jpeg|bmp|gif") * return : On success it will return file name else return (boolean)false */ public function upload_file($uploaddir, $name, $rename = null, $replace = false, $check_type = "") { $this->set_file_size($_FILES[$name]['size']); $this->error = $_FILES[$name]['error']; $this->set_temp_name($_FILES[$name]['tmp_name']); $this->set_directory($uploaddir); $this->check_for_directory(); $this->set_file_name($_FILES[$name]['name']); $file_size = $this->file_type_info[$check_type]['max_file_size'] / 1000000; if ($this->error == 1) { $this->error = sprintf(__("Your file is too large for the web server. The largest file you can upload here is %.1fM. If this is too small, please ask the administrator to increase the <code>upload_max_filesize</code> directive in <code>php.ini</code>."), floatval(parse_file_size_string(ini_get("upload_max_filesize"))) / 1048576.0); } elseif ($this->error == 3) { $this->error = __('The uploaded file was only partially uploaded.'); } elseif ($this->error == 4) { $this->error = __('No file was uploaded'); } elseif (!is_uploaded_file($this->tmp_name)) { $this->error = "File " . $this->tmp_name . " is not uploaded correctly."; } if (empty($this->file_name)) { $this->error = "File is not uploaded correctly."; } if ($this->error != "") { return false; } //check here for valid file if (!empty($check_type)) { // set max upload size if (array_key_exists($check_type, $this->file_type_info)) { $this->set_max_size($this->file_type_info[$check_type]['max_file_size']); } // check file size against maximum if ($this->file_size > $this->max_filesize) { $this->error = sprintf(__("File too large; %s file uploads are limited to %s. If this is too small, please ask the administrator to increase the limit."), $check_type, format_file_size($this->max_filesize)); return false; } //if $check_type is just image then we can check it via getImagesize() function if the file is valid or not // does this check always for image if ($check_type == 'image') { $sizeCheck = @getImagesize($this->tmp_name); if (!$sizeCheck) { $this->error = __("Invalid image file."); return false; } //additional check to see if the image has any extension $ext = explode('.', $this->file_name); $ext = strtolower(end($ext)); $img_mime = explode('/', $sizeCheck['mime']); $img_mime = strtolower(end($img_mime)); //jpeg and jpg may have different extension and mime so handled specially if ($ext == 'jpg' || $ext == 'jpeg') { } else { if ($ext != $img_mime) { //means there is no image extension so lets add it $this->file_name .= '.' . $img_mime; } } } //check for other media types // can be turned of from config.inc define('CHECK_MIME_TYPE',0); if ($check_type == 'audio' || $check_type == 'video') { if (CHECK_MIME_TYPE == 1) { $mime_type = exec('file -bi ' . $this->tmp_name); // TO DO:: enalbe for audio/video //application/octet-stream if (empty($mime_type)) { $this->error = __("Invalid media file."); return false; } if (strstr($mime_type, $check_type)) { } else { if (strstr($mime_type, 'media')) { } else { if (strstr($mime_type, 'octet-stream')) { // Temporarily added for .wav file -- need to do something else } else { $this->error = __("Invalid media file."); return false; } } } } } //special treatment for doc types if ($check_type == 'doc') { if (CHECK_MIME_TYPE == 1) { $mime_type = exec('file -bi ' . $this->tmp_name); if (strstr($mime_type, 'msword') || strstr($mime_type, 'pdf')) { } else { $this->error = sprintf(__("Invalid document type - supported formats are: %s"), ".doc, .pdf"); return false; } } } } //check_type if (!is_bool($rename) && !empty($rename)) { if (preg_match("/\\..*+\$/", $this->file_name, $matches)) { $this->set_file_name($rename . $matches[0]); } } elseif ($rename && file_exists($this->full_name)) { if (preg_match("/\\..*+\$/", $this->file_name, $matches)) { $this->set_file_name(substr_replace($this->file_name, "_" . rand(0, rand(0, 99)), -strlen($matches[0]), 0)); } } if (file_exists($this->full_name)) { if ($replace) { @unlink($this->full_name); } else { $this->error = __("File error: File already exists"); return false; } } $this->start_upload(); if ($this->error != "") { return false; } else { return $this->file_name; } }
$courseInfo = api_get_course_info(); $workInfo = get_work_data_by_id($itemId); $workInfoParent = get_work_data_by_id($workInfo['parent_id']); $resultUpload = uploadWork($workInfoParent, $courseInfo, true, $workInfo); $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); if (isset($resultUpload['url']) && !empty($resultUpload['url'])) { $title = isset($resultUpload['filename']) && !empty($resultUpload['filename']) ? $resultUpload['filename'] : get_lang('Untitled'); $url = Database::escape_string($resultUpload['url']); $title = Database::escape_string($title); $sql = "UPDATE {$work_table} SET\n url_correction = '" . $url . "',\n title_correction = '" . $title . "'\n WHERE iid = {$itemId}"; Database::query($sql); $result['title'] = $resultUpload['filename']; $result['url'] = 'view.php?' . api_get_cidreq() . '&id=' . $itemId; $json = array(); $json['name'] = Display::url(api_htmlentities($result['title']), api_htmlentities($result['url']), array('target' => '_blank')); $json['type'] = api_htmlentities($file['type']); $json['size'] = format_file_size($file['size']); } if (isset($result['url'])) { $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); } else { $json['result'] = Display::return_icon('exclamation.png', get_lang('Error')); } echo json_encode($json); } break; default: echo ''; break; } exit;
/** * Validate memory limit * * @param array $result */ function validate_memory_limit(&$results) { $memory_limit = php_config_value_to_bytes(ini_get('memory_limit')); $formatted_memory_limit = $memory_limit === -1 ? 'unlimited' : format_file_size($memory_limit); if ($memory_limit === -1 || $memory_limit >= 67108864) { $results[] = new TestResult('Your memory limit is: ' . $formatted_memory_limit, STATUS_OK); return true; } else { $results[] = new TestResult('Your memory is too low to complete the installation. Minimal value is 64MB, and you have it set to ' . $formatted_memory_limit, STATUS_ERROR); return false; } // if }
/** * */ function show_form_send_ticket() { global $types, $plugin; echo '<div class="divTicket">'; //Category List $categoryList = array(); foreach ($types as $type) { $categoryList[$type['category_id']] = $type['name'] . ": " . $type['description']; } //End Category List //Status List $statusList = array(); $statusAttributes = array('style' => 'display: none;', 'id' => 'status_id', 'for' => 'status_id'); $statusList[NEWTCK] = $plugin->get_lang('StatusNew'); if (api_is_platform_admin()) { $statusAttributes = array('id' => 'status_id', 'for' => 'status_id', 'style' => 'width: 562px;'); $statusList[PENDING] = $plugin->get_lang('StatusPending'); $statusList[UNCONFIRMED] = $plugin->get_lang('StatusUnconfirmed'); $statusList[CLOSE] = $plugin->get_lang('StatusClose'); $statusList[REENVIADO] = $plugin->get_lang('StatusForwarded'); } //End Status List //Source List $sourceList = array(); $sourceAttributes = array('style' => 'display: none;', 'id' => 'source_id', 'for' => 'source_id'); $sourceList[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform'); if (api_is_platform_admin()) { $sourceAttributes = array('id' => 'source_id', 'for' => 'source_id', 'style' => 'width: 562px;'); $sourceList[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); $sourceList[SRC_PHONE] = $plugin->get_lang('SrcPhone'); $sourceList[SRC_PRESC] = $plugin->get_lang('SrcPresential'); } //End Source List //Priority List $priorityList = array(); $priorityList[NORMAL] = $plugin->get_lang('PriorityNormal'); $priorityList[HIGH] = $plugin->get_lang('PriorityHigh'); $priorityList[LOW] = $plugin->get_lang('PriorityLow'); //End Priority List $form = new FormValidator('send_ticket', 'POST', api_get_self(), "", array('enctype' => 'multipart/form-data', 'onsubmit' => 'return validate()', 'class' => 'span8 offset1 form-horizontal')); $form->addElement('hidden', 'user_id_request', '', array('id' => 'user_id_request')); $form->addElement('hidden', 'project_id', '', array('id' => 'project_id')); $form->addElement('hidden', 'other_area', '', array('id' => 'other_area')); $form->addElement('hidden', 'email', '', array('id' => 'email')); $form->addElement('select', 'category_id', get_lang('Category'), $categoryList, array('onchange' => 'changeType()', 'id' => 'category_id', 'for' => 'category_id', 'style' => 'width: 562px;')); $form->addElement('html', Display::div('', array('id' => 'user_request'))); $form->addElement('select', 'status_id', get_lang('Status'), $statusList, $statusAttributes); $form->addElement('select', 'source_id', $plugin->get_lang('Source'), $sourceList, $sourceAttributes); $form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject', 'style' => 'width: 550px;')); $form->addElement('text', 'personal_email', $plugin->get_lang('PersonalEmail'), array('id' => 'personal_email', 'style' => 'width: 550px;')); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '600', 'Height' => '250')); $form->addElement('text', 'phone', get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')', array('id' => 'phone')); $form->addElement('select', 'priority_id', $plugin->get_lang('Priority'), $priorityList, array('id' => 'priority_id', 'for' => 'priority_id')); $form->addElement('html', '<span id="filepaths">'); $form->addElement('html', '<div id="filepath_1">'); $form->addElement('file', 'attach_1', get_lang('FilesAttachment')); $form->addElement('html', '</div>'); $form->addElement('html', '</span>'); $form->addElement('html', '<div class="controls">'); $form->addElement('html', '<span id="link-more-attach" >'); $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>'); $form->addElement('html', '</span>'); $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); $form->addElement('html', '<br/>'); $form->addElement('button', 'compose', get_lang('SendMessage'), null, null, null, 'save', array('id' => 'btnsubmit')); $form->display(); }
} else { $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; } } } } } } } $result_cache->assign_vars(array('dbsize' => $dbsize)); } else { $dbsize = $result_cache->get_var('dbsize'); } $dbsize = intval($dbsize); if ($dbsize != 0) { $dbsize = format_file_size($dbsize); } else { $dbsize = $lang['Not_available']; } $sql = 'SELECT user_regdate FROM ' . USERS_TABLE . ' WHERE user_id = ' . $newest_uid . ' LIMIT 1'; $result = $stat_db->sql_query($sql); $row = $stat_db->sql_fetchrow($result); $newest_user_date = $row['user_regdate']; // Most Online data $sql = "SELECT *\n\tFROM " . CONFIG_TABLE . "\n\tWHERE config_name = 'record_online_users' OR config_name = 'record_online_date'"; $result = $stat_db->sql_query($sql); $row = $stat_db->sql_fetchrowset($result); $most_users_date = $lang['Not_available'];
$column_show[] = 0; // Here we change the way how the colums are going to be sort // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" $column_order[3] = 8; $column_order[5] = 7; // The content of the sortable table = the received files foreach ($dropbox_person->sentWork as $dropbox_file) { $dropbox_file_data = array(); if ($view_dropbox_category_sent == $dropbox_file->category) { $dropbox_file_data[] = $dropbox_file->id; $link_open = '<a href="' . api_get_path(WEB_CODE_PATH) . 'dropbox/dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '">'; $dropbox_file_data[] = $link_open . DocumentManager::build_document_icon_tag('file', $dropbox_file->title) . '</a>'; $dropbox_file_data[] = '<a href="' . api_get_path(WEB_CODE_PATH) . 'dropbox/dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '&action=download">' . Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>' . $link_open . $dropbox_file->title . '</a><br />' . $dropbox_file->description; $file_size = $dropbox_file->filesize; $dropbox_file_data[] = format_file_size($file_size); $receivers_celldata = null; foreach ($dropbox_file->recipients as $recipient) { $userInfo = api_get_user_info($recipient['user_id']); $receivers_celldata = UserManager::getUserProfileLink($userInfo) . ', ' . $receivers_celldata; } $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. $dropbox_file_data[] = $receivers_celldata; $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); $dropbox_file_data[] = date_to_str_ago($last_upload_date) . '<br /><span class="dropbox_date">' . api_format_date($last_upload_date) . '</span>'; //$dropbox_file_data[] = $dropbox_file->author; $receivers_celldata = ''; $action_icons = check_number_feedback($dropbox_file->id, $number_feedback) . ' ' . get_lang('Feedback') . ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=viewfeedback&id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('discuss.png', get_lang('Comment'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=movesent&move_id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('move.png', get_lang('Move'), '', ICON_SIZE_SMALL) . '</a>
foreach ($files_to_add as $add_file) { ?> <tr> <td><input type="checkbox" name="add[]" value="<?php echo $add_file['name']; ?> " /></td> <td><?php echo $add_file['name']; ?> </td> <td data-value="<?php echo filesize($add_file['path']); ?> "><?php echo format_file_size(filesize($add_file['path'])); ?> </td> <td data-value="<?php echo filemtime($add_file['path']); ?> "> <?php echo date(TIMEFORMAT_USE, filemtime($add_file['path'])); ?> </td> <td> <?php switch ($add_file['reason']) { case 'not_on_db': _e('Never assigned to any user or group', 'cftp_admin');
echo " </tr>\n"; echo " </table>\n"; echo " <table class=\"posthead\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\" width=\"25\"> </td>\n"; echo " <td align=\"left\" valign=\"top\" class=\"postbody\">", gettext("Total Size"), ":</td>\n"; echo " <td align=\"left\" valign=\"top\" class=\"postbody\"> </td>\n"; echo " <td align=\"right\" valign=\"top\" class=\"postbody\">", format_file_size($total_attachment_size), "</td>\n"; echo " <td align=\"left\" width=\"25\"> </td>\n"; echo " </tr>\n"; if ($max_attachment_space > 0) { echo " <tr>\n"; echo " <td align=\"left\" width=\"25\"> </td>\n"; echo " <td align=\"left\" valign=\"top\" class=\"postbody\">", gettext("Free Space"), ":</td>\n"; echo " <td align=\"left\" valign=\"top\" class=\"postbody\"> </td>\n"; echo " <td align=\"right\" valign=\"top\" class=\"postbody\">", format_file_size($users_free_space), "</td>\n"; echo " <td align=\"left\" width=\"25\"> </td>\n"; echo " </tr>\n"; } echo " <tr>\n"; echo " <td align=\"left\" colspan=\"5\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n";
/** * This function checks if the upload succeeded * * @param array $uploaded_file ($_FILES) * @return true if upload succeeded */ function process_uploaded_file($uploaded_file, $show_output = true) { // Checking the error code sent with the file upload. if (isset($uploaded_file['error'])) { switch ($uploaded_file['error']) { case 1: // The uploaded file exceeds the upload_max_filesize directive in php.ini. if ($show_output) { Display::display_error_message(get_lang('UplExceedMaxServerUpload') . ini_get('upload_max_filesize')); } return false; case 2: // The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). $max_file_size = intval($_POST['MAX_FILE_SIZE']); if ($show_output) { Display::display_error_message(get_lang('UplExceedMaxPostSize') . format_file_size($max_file_size)); } return false; case 3: // The uploaded file was only partially uploaded. if ($show_output) { Display::display_error_message(get_lang('UplPartialUpload') . ' ' . get_lang('PleaseTryAgain')); } return false; case 4: // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplNoFileUploaded') . ' ' . get_lang('UplSelectFileFirst')); } return false; } } if (!file_exists($uploaded_file['tmp_name'])) { // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplUploadFailed')); } return false; } if (file_exists($uploaded_file['tmp_name'])) { $filesize = filesize($uploaded_file['tmp_name']); if (empty($filesize)) { // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplUploadFailedSizeIsZero')); } return false; } } $course_id = api_get_course_id(); //Checking course quota if we are in a course if (!empty($course_id)) { $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 ($show_output) { Display::display_error_message(get_lang('UplNotEnoughSpace')); } return false; } } // case 0: default: We assume there is no error, the file uploaded with success. return true; }
function display_my_documents($dialogBox, $style) { global $curDirName; global $curDirPath; global $parentDir; global $langUp; global $langName; global $langSize; global $langDate; global $langAddModulesButton; global $fileList; global $themeimg; global $langSelection, $langDirectory, $course_code; $output = ''; /* * DISPLAY */ $dspCurDirName = htmlspecialchars($curDirName); // $cmdCurDirPath = rawurlencode($curDirPath); $cmdParentDir = rawurlencode($parentDir); $output .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '" method="POST">'; /* -------------------------------------- DIALOG BOX SECTION -------------------------------------- */ $colspan = 5; if (!empty($dialogBox)) { $output .= disp_message_box($dialogBox, $style) . "<br />"; } /* -------------------------------------- CURRENT DIRECTORY LINE -------------------------------------- */ /* CURRENT DIRECTORY */ if ($curDirName) { $output .= ' <table class="table-default"> <tr> <td width="1" class="right">' . icon('fa-folder-o') . '</td> <td>' . $langDirectory . ': <b>' . $dspCurDirName . '</b></td>'; /* GO TO PARENT DIRECTORY */ if ($curDirName) { $linkup = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&openDir={$cmdParentDir}'>"; $output .= "<td width='1'>{$linkup}<img src='{$themeimg}/folder_up.png' " . "hspace='5' alt='{$langUp}' title='langUp' /></a></td>" . "<td width='10' class='right'><small>{$linkup}{$langUp}</a></small></td>"; } $output .= '</tr></table>'; } $output .= ' <div class="table-responsive"> <table class="table-default" >'; $output .= "\n <tr class='list-header'>\n <th colspan='2'><div align='left'> {$langName}</div></th>\n <th>{$langSize}</th>\n <th>{$langDate}</th>\n <th>{$langSelection}</th>\n </tr>"; /* -------------------------------------- DISPLAY FILE LIST -------------------------------------- */ if ($fileList) { $iterator = 0; $ind = 1; while (list($fileKey, $fileName) = each($fileList['name'])) { if ($ind % 2 == 0) { $style = 'class="even"'; } else { $style = 'class="odd"'; } $dspFileName = htmlspecialchars($fileList['filename'][$fileKey]); $cmdFileName = str_replace("%2F", "/", rawurlencode($curDirPath . "/" . $fileName)); if ($fileList['visible'][$fileKey] == 0) { continue; // skip the display of this file } if ($fileList['type'][$fileKey] == A_FILE) { $image = choose_image($fileName); $size = format_file_size($fileList['size'][$fileKey]); $date = nice_format($fileList['date'][$fileKey]); $file_url = file_url($fileList['path'][$fileKey], $dspFileName); $play_url = file_playurl($fileList['path'][$fileKey], $dspFileName); $urlFileName = MultimediaHelper::chooseMediaAhrefRaw($file_url, $play_url, $dspFileName, $dspFileName); } elseif ($fileList['type'][$fileKey] == A_DIRECTORY) { $image = 'fa-folder'; $size = ' '; $date = ' '; $urlFileName = '<a href="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '&openDir=' . $cmdFileName . '">' . $dspFileName . '</a>'; } $output .= ' <tr ' . $style . '> <td class="center" width="1">' . icon($image, '') . '</td> <td align="left">' . $urlFileName . '</td> <td width="80" class="center">' . $size . '</td> <td width="80" class="center">' . $date . '</td>'; if ($fileList['type'][$fileKey] == A_FILE) { $iterator++; $output .= ' <td width="10" class="center"> <input type="checkbox" name="insertDocument_' . $iterator . '" id="insertDocument_' . $iterator . '" value="' . $curDirPath . "/" . $fileName . '" /> <input type="hidden" name="filenameDocument_' . $iterator . '" id="filenameDocument_' . $iterator . '" value="' . $dspFileName . '" /> </td>'; } else { $output .= '<td> </td>'; } $output .= '</tr>'; /* COMMENTS */ if ($fileList['comment'][$fileKey] != "") { $fileList['comment'][$fileKey] = htmlspecialchars($fileList['comment'][$fileKey]); $fileList['comment'][$fileKey] = parse_user_text($fileList['comment'][$fileKey]); $output .= ' <tr class="even"> <td> </td> <td colspan="' . $colspan . '"><span class="comment">' . $fileList['comment'][$fileKey] . '</span></td> </tr>'; } $ind++; } // end each ($fileList) // form button $output .= ' <tr> <th colspan="' . $colspan . '"><div class="pull-right"> <input type="hidden" name="openDir" value="' . $curDirPath . '" /> <input type="hidden" name="maxDocForm" value ="' . $iterator . '" /> <input class="btn btn-primary" type="submit" name="submitInsertedDocument" value="' . $langAddModulesButton . '"> </th> </tr>'; } else { $output .= '<tr><td colspan="4"> </td></tr>'; } $output .= '</table></div></form>'; return $output; }
foreach ($files as $name => $array) { $counter = 0; foreach ($array as $data) { $fileList[$counter][$name] = $data; $counter++; } } $resultList = []; foreach ($fileList as $file) { $globalFile = []; $globalFile['files'] = $file; /** @var Dropbox_SentWork $result */ $result = store_add_dropbox($file); $json = array(); if (!empty($result)) { $json['name'] = Display::url(api_htmlentities($result->title), api_htmlentities(api_get_path(WEB_CODE_PATH) . 'dropbox/index.php?' . api_get_cidreq()), array('target' => '_blank')); $json['url'] = api_get_path(WEB_CODE_PATH) . 'dropbox/index.php?' . api_get_cidreq(); $json['size'] = format_file_size($result->filesize); $json['type'] = api_htmlentities($file['type']); $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); } else { $json['result'] = Display::return_icon('exclamation.png', get_lang('Error')); } $resultList[] = $json; } echo json_encode(['files' => $resultList]); } exit; break; } exit;
function get_remote_file_size($file_path) { if (!CHECK_REMOTE_FILES) { return 'n/a'; } ob_start(); @readfile($file_path); $file_data = ob_get_contents(); ob_end_clean(); return format_file_size(strlen($file_data)); }
$envelove_icon = "fa-envelope-o"; } else { $bold_start = "<strong>"; $bold_end = "</strong>"; $envelove_icon = "fa-envelope"; } $urlstr = ''; if ($course_id != 0) { $urlstr = "&course=".course_id_to_code($course_id); } if (($msg->filename != '') and ($msg->filesize != 0)) { $ahref = "dropbox_download.php?course=".course_id_to_code($msg->course_id)."&id=".$msg->id; $filename = " | <a class='outtabs' href='$ahref' target='_blank'><span class='fa fa-paperclip'></span> </a><span class='smaller'> (".format_file_size($msg->filesize).")</span><br />"; } else { $filename = ''; } $i = 0; if ($mbox_type == 'inbox') { $td[$i++] = "<i class='fa $envelove_icon' title='".q($msg->subject)."' /></i> $bold_start<a href='inbox.php?mid=$msg->id".$urlstr."'>".q($msg->subject)."</a>".$bold_end.$filename; } else { $td[$i++] = "<i class='fa fa-envelope-o' title='".q($msg->subject)."' /></i> <a href='outbox.php?mid=$msg->id".$urlstr."'>".q($msg->subject)."</a>".$filename; } if ($course_id == 0) { if ($msg->course_id != 0) { $td[$i++] = "$bold_start<a class=\"outtabs\" href=\"index.php?course=".course_id_to_code($msg->course_id)."\">".course_id_to_title($msg->course_id)."</a>$bold_end";
echo "<td width=\"16%\"><b>" . $lang['thumb_directory'] . "</b></td><td width=\"16%\">" . format_file_size(get_dir_size(THUMB_PATH)) . "</td>\n"; echo "</tr>"; //3 echo "<tr class=\"" . get_row_bg() . "\">\n"; $sql = "SELECT COUNT(*) as users\n FROM " . USERS_TABLE . "\n WHERE " . get_user_table_field("", "user_id") . " <> " . GUEST; $row = $site_db->query_firstrow($sql); echo "<td width=\"16%\"><b>" . $lang['users'] . "</b></td><td width=\"16%\">" . $row['users'] . "</td>\n"; echo "<td width=\"16%\"><b>" . $lang['database'] . "</b></td><td width=\"16%\">"; include ROOT_PATH . 'includes/db_utils.php'; get_database_size(); if (!empty($global_info['database_size']['total'])) { if (!empty($global_info['database_size']['4images'])) { $db_status = $lang['homestats_total'] . " <b>" . format_file_size($global_info['database_size']['total']) . "</b> / "; $db_status .= "4images: <b>" . format_file_size($global_info['database_size']['4images']) . "</b>"; } else { $db_status = format_file_size(!empty($global_info['database_size']['total'])); } } else { $db_status = "n/a"; } echo $db_status . "</td>\n"; echo "</tr>"; show_table_footer(); $sql = "SELECT SUM(cat_hits) AS sum\n FROM " . CATEGORIES_TABLE; $row = $site_db->query_firstrow($sql); $sum = isset($row['sum']) ? $row['sum'] : 0; show_table_header($lang['top_cat_hits'] . " (" . $lang['homestats_total'] . " " . $sum . ")", 4); $sql = "SELECT cat_id, cat_name, cat_hits\n FROM " . CATEGORIES_TABLE . "\n ORDER BY cat_hits DESC\n LIMIT {$stats_limit}"; $result = $site_db->query($sql); $num = 1; while ($row = $site_db->fetch_array($result)) {
/** * Return an array of prepared attachment data to build forum attachment table * Also, save this array into $_SESSION to do available the attachment data * @param int $forumId * @param int $threadId * @param int $postId * @param int $attachId * @param int $courseId * * @return array */ function getAttachedFiles($forumId, $threadId, $postId = null, $attachId = null, $courseId = null) { $forumId = intval($forumId); $courseId = intval($courseId); $attachId = intval($attachId); $postId = intval($postId); $threadId = !empty($threadId) ? intval($threadId) : isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : ''; if (empty($courseId)) { // $courseId can be null, use api method $courseId = api_get_course_int_id(); } if (empty($forumId)) { if (!empty($_REQUEST['forum'])) { $forumId = intval($_REQUEST['forum']); } else { // if forum ID is empty, cannot generate delete url return array(); } } // Check if exist at least one of them to filter forum attachment select query if (empty($postId) && empty($attachId)) { return array(); } elseif (empty($postId)) { $filter = "AND iid = {$attachId}"; } elseif (empty($attachId)) { $filter = "AND post_id = {$postId}"; } else { $filter = "AND post_id = {$postId} AND iid = {$attachId}"; } $forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT); $sql = "SELECT iid, comment, filename, path, size\n FROM {$forumAttachmentTable}\n WHERE c_id = {$courseId} {$filter}"; $result = Database::query($sql); $json = array(); if ($result !== false && Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result, 'ASSOC')) { // name contains an URL to download attachment file and its filename $json['name'] = Display::url(api_htmlentities($row['filename']), api_get_path(WEB_CODE_PATH) . 'forum/download.php?file=' . $row['path'] . '&' . api_get_cidreq(), array('target' => '_blank', 'class' => 'attachFilename')); $json['id'] = $row['iid']; $json['comment'] = $row['comment']; // Format file size $json['size'] = format_file_size($row['size']); // Check if $row is consistent if (!empty($row) && is_array($row)) { // Set result as success and bring delete URL $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId . '&id_attach=' . $row['iid']; $json['delete'] = Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), $url, array('class' => 'deleteLink')); } else { // If not, set an exclamation result $json['result'] = Display::return_icon('exclamation.png', get_lang('Error')); } // Store array data into $_SESSION $_SESSION['forum']['upload_file'][$courseId][$json['id']] = $json; } } return $json; }
show_form_footer($lang['do_backup'], $lang['reset']); show_table_header($lang['list_backups'], 4); $handle = opendir(ROOT_PATH . DATABASE_DIR); $filelist = array(); while ($file = @readdir($handle)) { if (is_file(ROOT_PATH . DATABASE_DIR . "/" . $file) && $file != "." && $file != ".." && preg_match("/\\.sql/i", $file)) { $filelist[] = $file; } } closedir($handle); if (!empty($filelist)) { rsort($filelist); foreach ($filelist as $key => $file) { echo "<tr class=\"" . get_row_bg() . "\" width=\"30%\">\n<td><p class=\"rowtitle\">{$file}</p></td>\n"; $file_time = format_date($config['date_format'] . " " . $config['time_format'], filemtime(ROOT_PATH . DATABASE_DIR . "/" . $file)); echo "<td>" . $file_time . "</td>"; $file_size = format_file_size(@filesize(ROOT_PATH . DATABASE_DIR . "/" . $file)); echo "<td>" . $file_size . "</td>"; echo "<td>"; echo "<a href=\"javascript:RestoreBackup('" . $file . "')\">[" . $lang['restore_backup'] . "]</a> "; echo "<a href=\"javascript:DeleteBackup('" . $file . "')\">[" . $lang['delete_backup'] . "]</a> "; show_text_link($lang['download_backup'], "backup.php?action=downloadbackup&file={$file}"); show_text_link($lang['show_backup'], "backup.php?action=showbackup&file={$file}"); echo "</td></tr>"; } } else { show_description_row($lang['no_backups'], 4); } show_table_footer(); } show_admin_footer();
* @package PeopleAggregator */ ?> <?php if(!empty($_REQUEST['gid'])) { $query_str = '&gid=' . $_REQUEST['gid']; } else if(!empty($_REQUEST['uid'])) { $query_str = '&uid=' . $_REQUEST['uid']; } else { $query_str = null; } ?> <div id="image_gallery_upload"> <form enctype="multipart/form-data" action="<?= PA::$url . "/ajax/upload_media.php?type=Audios$query_str"?>" method="POST"> <fieldset> <?= __("You can upload an audio file") ?>. (<?= __("Maximum size") ?> <?=format_file_size($GLOBALS['file_type_info']['audio']['max_file_size'])?> <div id="image_gallery"> <div id="block" class="block"> <div class="field_medium start"> <h5><label for="select file"><?= __("Select a file to upload") ?></label></h5> <input name="userfile_audio_0" type="file" id="select_file" class="text long" value="" /> </div> <div class="field"> <h5><label for="audio_title"><?= __("Audio title") ?></label></h5> <input type="text" name="caption_audio[0]" value="" class="text long" id="audio_title" /> </div> <input type="hidden" name="media_type" value="audio" /> <input type="hidden" name="content_type" value="media" />
<?php echo htmlentities($row['filename']); ?> </a> <?php } else { echo htmlentities($row['filename']); } ?> </td> <td data-value="<?php echo get_real_size($this_file_absolute); ?> "><?php $this_file_size = get_real_size($this_file_absolute); echo format_file_size($this_file_size); ?> </td> <?php if ($current_level != '0') { ?> <td><?php echo $row['uploader']; ?> </td> <td> <?php if ($row['public_allow'] == '1') { ?> <a href="javascript:void(0);" class="btn-primary btn btn-small public_link" data-id="<?php echo $row['id'];
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); $tpl->display_one_col_template();
} else { continue; // skip the display of this file } } else { $style = ''; } //modify style if the file is recently added since last login if (claro_is_user_authenticated() && $claro_notifier->is_a_notified_document(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisFile)) { $classItem = ' hot'; } else { $classItem = ''; } if ($thisFile['type'] == A_FILE) { $image = choose_image($thisFile['path']); $size = format_file_size($thisFile['size']); $date = format_date($thisFile['date']); $urlFileName = claro_htmlspecialchars(claro_get_file_download_url($thisFile['path'])); //$urlFileName = "goto/?doc_url=".rawurlencode($cmdFileName); //format_url($baseServUrl.$courseDir.$curDirPath."/".$fileName)); $target = get_conf('openNewWindowForDoc') ? 'target="_blank"' : ''; } elseif ($thisFile['type'] == A_DIRECTORY) { $image = 'folder'; $size = ' '; $date = ' '; $urlFileName = claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exChDir&file=' . $cmdFileName)); $target = ''; } $out .= '<tr align="center">' . "\n" . '<td align="left">'; if (is_image($thisFile['path'])) { $out .= '<a class="' . $style . ' item' . $classItem . '" href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?docView=image&file=' . download_url_encode($thisFile['path']) . '&cwd=' . $curDirPath . $searchCmdUrl)) . '">';
/** * Get array of links (download) for message attachment files * @param int $message_id * @param string $type message list (inbox/outbox) * @return array */ public static function get_links_message_attachment_files($message_id, $type = '') { $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $message_id = intval($message_id); // get file attachments by message id $links_attach_file = array(); if (!empty($message_id)) { $sql = "SELECT * FROM {$tbl_message_attach}\n WHERE message_id = '{$message_id}'"; $rs_file = Database::query($sql); if (Database::num_rows($rs_file) > 0) { $attach_icon = Display::return_icon('attachment.gif', ''); $archiveURL = api_get_path(WEB_CODE_PATH) . 'messages/download.php?type=' . $type . '&file='; while ($row_file = Database::fetch_array($rs_file)) { $archiveFile = $row_file['path']; $filename = $row_file['filename']; $filesize = format_file_size($row_file['size']); $filecomment = Security::remove_XSS($row_file['comment']); $filename = Security::remove_XSS($filename); $links_attach_file[] = $attach_icon . ' <a href="' . $archiveURL . $archiveFile . '">' . $filename . '</a> (' . $filesize . ')' . (!empty($filecomment) ? ' - <i>' . $filecomment . '</i>' : ''); } } } return $links_attach_file; }
$valid = false; } if (session::check_perm(USER_PERM_EMAIL_CONFIRM, 0)) { light_html_email_confirmation_error(); exit; } if (isset($fid) && !session::check_perm(USER_PERM_THREAD_CREATE | USER_PERM_POST_READ, $fid)) { $error_msg_array[] = gettext("You cannot create new threads in this folder"); $valid = false; } if (isset($fid) && sizeof($attachments) > 0 && !session::check_perm(USER_PERM_POST_ATTACHMENTS | USER_PERM_POST_READ, $fid)) { $error_msg_array[] = gettext("You cannot post attachments in this folder. Remove attachments to continue."); $valid = false; } if (sizeof($attachments) > 0 && !attachments_check_post_space($_SESSION['UID'], $attachments)) { $error_msg_array[] = gettext(sprintf("You have too many files attached to this post. Maximum attachment space per post is %s", format_file_size($max_post_attachment_space))); $valid = false; } } } if (!$new_thread) { if (!($reply_message = messages_get($tid, $reply_to_pid))) { light_html_draw_error(gettext("That post does not exist in this thread!")); } if (!($thread_data = thread_get($tid))) { light_html_draw_error(gettext("The requested thread could not be found or access was denied.")); } $reply_message['CONTENT'] = message_get_content($tid, $reply_to_pid); if (perm_get_user_permissions($reply_message['FROM_UID']) & USER_PERM_WORMED && !session::check_perm(USER_PERM_FOLDER_MODERATE, $fid) || (!isset($reply_message['CONTENT']) || $reply_message['CONTENT'] == "") && $thread_data['POLL_FLAG'] != 'Y' && $reply_to_pid != 0) { light_html_draw_error(gettext("Message not found. Check that it hasn't been deleted.")); }
$file_hash = md5(uniqid(mt_rand())); $max_user_attachment_space = forum_get_setting('attachments_max_user_space', 'is_numeric', 1048576); $free_upload_space = attachments_get_free_user_space($_SESSION['UID']); $attachment_mime_types = attachments_get_mime_types(); $total_attachment_size = 0; $attachment_dir = rtrim($attachment_dir, '/'); if (isset($_POST['summary'])) { if (isset($_POST['hashes']) && is_array($_POST['hashes'])) { $hash_array = array_filter($_POST['hashes'], 'is_md5'); } else { $hash_array = array(); } $used_post_space = format_file_size(attachments_get_post_used_space($_SESSION['UID'], $hash_array)); $free_post_space = attachments_get_free_post_space($_SESSION['UID'], $hash_array); $content_type = 'application/json; charset=UTF-8'; $content = json_encode(array('used_post_space' => $used_post_space, 'free_post_space' => $free_post_space > -1 ? format_file_size($free_post_space) : gettext("Unlimited"), 'free_upload_space' => $free_upload_space > -1 ? format_file_size($free_upload_space) : gettext("Unlimited"))); } else { if (isset($_POST['delete'])) { $valid = true; if (isset($_POST['hashes']) && is_array($_POST['hashes'])) { foreach ($_POST['hashes'] as $hash) { if (!attachments_delete($hash)) { $valid = false; } } } $content_type = 'application/json; charset=UTF-8'; $content = json_encode($valid); } else { if (isset($_FILES['upload']) && is_array($_FILES['upload'])) { for ($i = 0; $i < sizeof($_FILES['upload']['name']); $i++) {
$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>');
$tool_content .= "\n <tr>"; $tool_content .= "\n <th width='50'> </th>"; $tool_content .= "\n <th width='10%'><div align='center'><b>{$langType}</b></div></th>"; $tool_content .= "\n <th><div align='left'><b>{$langName}</b></div></th>"; $tool_content .= "\n <th width='15%'><div align='center'><b>{$langSize}</b></div></th>"; $tool_content .= "\n <th width='15%'><div align='center'><b>{$langDate}</b></div></th>"; $tool_content .= "\n </tr>"; foreach ($fileinfo as $entry) { if ($entry['is_dir']) { // do not handle directories continue; } $cmdDirName = $entry['path']; $copyright_icon = ''; $image = choose_image('.' . $entry['format']); $size = format_file_size($entry['size']); $date = nice_format($entry['date'], true, true); if ($entry['visible']) { $style = ''; } else { $style = ' class="invisible"'; } if (empty($entry['title'])) { $link_text = $entry['filename']; } else { $link_text = $entry['title']; } if ($entry['copyrighted']) { $link_text .= " <img src='../document/img/copyrighted.png' />"; } $tool_content .= "\n <tr{$style}>";
$user_info = api_get_user_info($document_data['insert_user_id']); $user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . UserManager::getUserProfileLink($user_info) . '</div>'; } } // Icons (clickable) $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible); $path_info = pathinfo($document_data['path']); if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) { $count++; } // Validation when belongs to a session $session_img = api_get_session_image($document_data['session_id'], $_user['status']); // Document title with link $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link; // Comments => display comment under the document name $display_size = format_file_size($size); $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close; // Last edit date $last_edit_date = api_get_local_time($document_data['lastedit_date']); $display_date = date_to_str_ago($last_edit_date) . ' <div class="muted"><small>' . $last_edit_date . "</small></div>"; $row[] = $invisibility_span_open . $display_date . $invisibility_span_close; // Admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) { $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false; // If readonly, check if it the owner of the file or if the user is an admin if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) { $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, 0, $is_visible); } else { $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible); } $row[] = $edit_icons;
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->addText('id_text_name', get_lang('SendMessageTo'), true, array('id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addLabel(get_lang('SendMessageTo'), $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_users']); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $userGroup = new UserGroup(); $group_info = $userGroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->addText('title', get_lang('Subject'), true); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = api_get_user_info($message_reply_info['user_sender_id']); $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('label', '', '<div id="filepaths" class="form-group"> <div id="filepath_1"> <label>' . get_lang('FilesAttachment') . '</label> <input type="file" name="attach_1"/> <label>' . get_lang('Description') . '</label> <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/> </div> </div>'); $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')'); } $form->addButtonSend(get_lang('SendMessage'), 'compose'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = isset($default['parent_id']) ? $default['parent_id'] : null; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); if ($res) { $html .= MessageManager::display_success_message($user); } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->returnForm(); } return $html; }
<?php echo html_output($row['filename']); ?> </a> <?php } else { echo html_output($row['filename']); } ?> </td> <td data-value="<?php echo get_real_size($this_file_absolute); ?> "><?php $this_file_size = get_real_size($this_file_absolute); echo html_output(format_file_size($this_file_size)); ?> </td> <?php if ($current_level != '0') { ?> <td><?php echo html_output($row['uploader']); ?> </td> <td> <?php if ($row['public_allow'] == '1') { ?> <a href="javascript:void(0);" class="btn-primary btn btn-small public_link" data-id="<?php echo $row['id'];