OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('No file was uploaded. Unknown error')), $storageStats))); exit; } foreach ($_FILES['files']['error'] as $error) { if ($error != 0) { $errors = array(UPLOAD_ERR_OK => $l->t('There is no error, the file uploaded with success'), UPLOAD_ERR_INI_SIZE => $l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ') . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => $l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), UPLOAD_ERR_PARTIAL => $l->t('The uploaded file was only partially uploaded'), UPLOAD_ERR_NO_FILE => $l->t('No file was uploaded'), UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk')); $errorMessage = $errors[$error]; \OC::$server->getLogger()->alert("Upload error: {$error} - {$errorMessage}", array('app' => 'files')); OCP\JSON::error(array('data' => array_merge(array('message' => $errorMessage), $storageStats))); exit; } } $files = $_FILES['files']; $error = false; $maxUploadFileSize = $storageStats['uploadMaxFilesize']; $maxHumanFileSize = OCP\Util::humanFileSize($maxUploadFileSize); $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) { OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'), 'uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize))); exit; } $result = array(); if (strpos($dir, '..') === false) { $fileCount = count($files['name']); for ($i = 0; $i < $fileCount; $i++) { // target directory for when uploading folders $relativePath = ''; if (!empty($_POST['file_directory'])) {
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); if ($_POST && OC_Util::isCallRegistered()) { if (isset($_POST['maxUploadSize'])) { if (($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } } } OCP\App::setActiveNavigationEntry("files_administration"); $htaccessWritable = is_writable(OC::$SERVERROOT . '/.htaccess'); $tmpl = new OCP\Template('files', 'admin'); /* * extended version * + only users with permission can delete files(in the files app only) * + file type restriction */ $filetyprestriction = \OC_Appconfig::getValue('core', 'filetyperes_enabled', 'no'); $allowed_types = \OC_Appconfig::getValue('core', 'allowed_filetypes', ''); $deleteGroupsList = \OC_Appconfig::getValue('core', 'delete', ''); $deleteGroupsList = explode(',', $deleteGroupsList); $tmpl->assign('deleteGroupsList', implode('|', $deleteGroupsList)); $tmpl->assign('fileTypeRes', $filetyprestriction); $tmpl->assign('allowed_filetypes', $allowed_types); $tmpl->assign('uploadChangable', $htaccessWorking and $htaccessWritable); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // max possible makes only sense on a 32 bit system $tmpl->assign('displayMaxPossibleUploadSize', PHP_INT_SIZE === 4); $tmpl->assign('maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX)); return $tmpl->fetchPage();
$ctx = stream_context_create(\OC::$server->getHTTPHelper()->getDefaultContextArray(), array('notification' => 'progress')); $sourceStream = @fopen($source, 'rb', false, $ctx); $result = 0; if (is_resource($sourceStream)) { $meta = stream_get_meta_data($sourceStream); if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data'])) { //check stream size $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); $freeSpace = $storageStats['freeSpace']; foreach ($meta['wrapper_data'] as $header) { list($name, $value) = explode(':', $header); if ('content-length' === strtolower(trim($name))) { $length = (int) trim($value); if ($length > $freeSpace) { $delta = $length - $freeSpace; $humanDelta = OCP\Util::humanFileSize($delta); $eventSource->send('error', array('message' => (string) $l10n->t('The file exceeds your quota by %s', array($humanDelta)))); $eventSource->close(); fclose($sourceStream); exit; } } } } $result = \OC\Files\Filesystem::file_put_contents($target, $sourceStream); } if ($result) { $meta = \OC\Files\Filesystem::getFileInfo($target); $data = \OCA\Files\Helper::formatFileInfo($meta); $eventSource->send('success', $data); } else {
OCP\Util::addScript('files', 'filelist'); OCP\Util::addscript('files', 'keyboardshortcuts'); $files = array(); $rootLength = strlen($basePath) + 1; $maxUploadFilesize = OCP\Util::maxUploadFilesize($path); $freeSpace = OCP\Util::freeSpace($path); $uploadLimit = OCP\Util::uploadLimit(); $folder = new OCP\Template('files', 'list', ''); $folder->assign('dir', $getPath); $folder->assign('dirToken', $linkItem['token']); $folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic', true); $folder->assign('publicUploadEnabled', 'no'); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('freeSpace', $freeSpace); $folder->assign('uploadLimit', $uploadLimit); // PHP upload limit $folder->assign('usedSpacePercent', 0); $folder->assign('trash', false); $tmpl->assign('folder', $folder->fetchPage()); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } else { $tmpl->assign('dir', $dir); // Show file preview if viewer is available if ($type == 'file') { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download'); } else { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); }
$categories = OC_Contacts_App::getCategories(); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace = OC_Filesystem::free_space('/'); $freeSpace = max($freeSpace, 0); $maxUploadFilesize = min($maxUploadFilesize, $freeSpace); OCP\Util::addscript('', 'jquery.multiselect'); OCP\Util::addscript('', 'oc-vcategories'); OCP\Util::addscript('contacts', 'contacts'); OCP\Util::addscript('contacts', 'expanding'); OCP\Util::addscript('contacts', 'jquery.combobox'); OCP\Util::addscript('files', 'jquery.fileupload'); OCP\Util::addscript('core', 'jquery.inview'); OCP\Util::addscript('contacts', 'jquery.Jcrop'); OCP\Util::addscript('contacts', 'jquery.multi-autocomplete'); OCP\Util::addStyle('', 'jquery.multiselect'); OCP\Util::addStyle('contacts', 'jquery.combobox'); OCP\Util::addStyle('contacts', 'jquery.Jcrop'); OCP\Util::addStyle('contacts', 'contacts'); $tmpl = new OCP\Template("contacts", "index", "user"); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize, false); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize), false); $tmpl->assign('phone_types', $phone_types, false); $tmpl->assign('email_types', $email_types, false); $tmpl->assign('impp_types', $impp_types, false); $tmpl->assign('categories', $categories, false); $tmpl->assign('im_protocols', $im_protocols, false); $tmpl->assign('has_contacts', $has_contacts, false); $tmpl->assign('id', $id); $tmpl->printPage();
echo OCP\Util::imagePath('mail', 'person.png'); ?> " /> </td> <td> <?php echo $_['message']['from']; ?> <br/> <?php echo $_['message']['subject']; ?> <br/> <?php foreach ($_['message']['attachments'] as $a) { p($a['filename'] . " (" . OCP\Util::humanFileSize($a['size']) . ")"); } ?> </td> <td> <img src="<?php echo OCP\Util::imagePath('mail', 'reply.png'); ?> " /> <img src="<?php echo OCP\Util::imagePath('mail', 'reply-all.png'); ?> " /> <img src="<?php echo OCP\Util::imagePath('mail', 'forward.png'); ?>
$upload_max_filesize_possible = OCP\Util::computerFileSize(get_cfg_var('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $post_max_size_possible = OCP\Util::computerFileSize(get_cfg_var('post_max_size')); $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); $maxUploadFilesizePossible = OCP\Util::humanFileSize(min($upload_max_filesize_possible, $post_max_size_possible)); if ($_POST && OC_Util::isCallRegistered()) { if (isset($_POST['maxUploadSize'])) { if (($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } } if (isset($_POST['maxZipInputSize'])) { $maxZipInputSize = $_POST['maxZipInputSize']; OCP\Config::setSystemValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize)); } if (isset($_POST['submitFilesAdminSettings'])) { OCP\Config::setSystemValue('allowZipDownload', isset($_POST['allowZipDownload'])); } } $maxZipInputSizeDefault = OCP\Util::computerFileSize('800 MB'); $maxZipInputSize = OCP\Util::humanFileSize(OCP\Config::getSystemValue('maxZipInputSize', $maxZipInputSizeDefault)); $allowZipDownload = intval(OCP\Config::getSystemValue('allowZipDownload', true)); OCP\App::setActiveNavigationEntry("files_administration"); $htaccessWritable = is_writable(OC::$SERVERROOT . '/.htaccess'); $tmpl = new OCP\Template('files', 'admin'); $tmpl->assign('uploadChangable', $htaccessWorking and $htaccessWritable); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('maxPossibleUploadSize', $maxUploadFilesizePossible); $tmpl->assign('allowZipDownload', $allowZipDownload); $tmpl->assign('maxZipInputSize', $maxZipInputSize); return $tmpl->fetchPage();