Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/IntegrityCheck/Checker.php34
-rw-r--r--lib/private/legacy/files.php82
-rw-r--r--lib/private/legacy/helper.php26
3 files changed, 1 insertions, 141 deletions
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php
index 44544b6770e..0a8876381f4 100644
--- a/lib/private/IntegrityCheck/Checker.php
+++ b/lib/private/IntegrityCheck/Checker.php
@@ -158,8 +158,6 @@ class Checker {
private function generateHashes(\RecursiveIteratorIterator $iterator,
string $path): array {
$hashes = [];
- $copiedWebserverSettingFiles = false;
- $tmpFolder = '';
$baseDirectoryLength = \strlen($path);
foreach($iterator as $filename => $data) {
@@ -180,36 +178,6 @@ class Checker {
continue;
}
- // The .user.ini and the .htaccess file of ownCloud can contain some
- // custom modifications such as for example the maximum upload size
- // to ensure that this will not lead to false positives this will
- // copy the file to a temporary folder and reset it to the default
- // values.
- if($filename === $this->environmentHelper->getServerRoot() . '/.htaccess'
- || $filename === $this->environmentHelper->getServerRoot() . '/.user.ini') {
-
- if(!$copiedWebserverSettingFiles) {
- $tmpFolder = rtrim($this->tempManager->getTemporaryFolder(), '/');
- copy($this->environmentHelper->getServerRoot() . '/.htaccess', $tmpFolder . '/.htaccess');
- copy($this->environmentHelper->getServerRoot() . '/.user.ini', $tmpFolder . '/.user.ini');
- \OC_Files::setUploadLimit(
- \OCP\Util::computerFileSize('511MB'),
- [
- '.htaccess' => $tmpFolder . '/.htaccess',
- '.user.ini' => $tmpFolder . '/.user.ini',
- ]
- );
- }
- }
-
- // The .user.ini file can contain custom modifications to the file size
- // as well.
- if($filename === $this->environmentHelper->getServerRoot() . '/.user.ini') {
- $fileContent = file_get_contents($tmpFolder . '/.user.ini');
- $hashes[$relativeFileName] = hash('sha512', $fileContent);
- continue;
- }
-
// The .htaccess file in the root folder of ownCloud can contain
// custom content after the installation due to the fact that dynamic
// content is written into it at installation time as well. This
@@ -218,7 +186,7 @@ class Checker {
// "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####" and have the
// hash generated based on this.
if($filename === $this->environmentHelper->getServerRoot() . '/.htaccess') {
- $fileContent = file_get_contents($tmpFolder . '/.htaccess');
+ $fileContent = file_get_contents($filename);
$explodedArray = explode('#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####', $fileContent);
if(\count($explodedArray) === 2) {
$hashes[$relativeFileName] = hash('sha512', $explodedArray[0]);
diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php
index 159e18c7754..577392f1edc 100644
--- a/lib/private/legacy/files.php
+++ b/lib/private/legacy/files.php
@@ -379,88 +379,6 @@ class OC_Files {
}
/**
- * set the maximum upload size limit for apache hosts using .htaccess
- *
- * @param int $size file size in bytes
- * @param array $files override '.htaccess' and '.user.ini' locations
- * @return bool|int false on failure, size on success
- */
- public static function setUploadLimit($size, $files = []) {
- //don't allow user to break his config
- $size = (int)$size;
- if ($size < self::UPLOAD_MIN_LIMIT_BYTES) {
- return false;
- }
- $size = OC_Helper::phpFileSize($size);
-
- $phpValueKeys = array(
- 'upload_max_filesize',
- 'post_max_size'
- );
-
- // default locations if not overridden by $files
- $files = array_merge([
- '.htaccess' => OC::$SERVERROOT . '/.htaccess',
- '.user.ini' => OC::$SERVERROOT . '/.user.ini'
- ], $files);
-
- $updateFiles = [
- $files['.htaccess'] => [
- 'pattern' => '/php_value %1$s (\S)*/',
- 'setting' => 'php_value %1$s %2$s'
- ],
- $files['.user.ini'] => [
- 'pattern' => '/%1$s=(\S)*/',
- 'setting' => '%1$s=%2$s'
- ]
- ];
-
- $success = true;
-
- foreach ($updateFiles as $filename => $patternMap) {
- // suppress warnings from fopen()
- $handle = @fopen($filename, 'r+');
- if (!$handle) {
- \OCP\Util::writeLog('files',
- 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions',
- ILogger::WARN);
- $success = false;
- continue; // try to update as many files as possible
- }
-
- $content = '';
- while (!feof($handle)) {
- $content .= fread($handle, 1000);
- }
-
- foreach ($phpValueKeys as $key) {
- $pattern = vsprintf($patternMap['pattern'], [$key]);
- $setting = vsprintf($patternMap['setting'], [$key, $size]);
- $hasReplaced = 0;
- $newContent = preg_replace($pattern, $setting, $content, 2, $hasReplaced);
- if ($newContent !== null) {
- $content = $newContent;
- }
- if ($hasReplaced === 0) {
- $content .= "\n" . $setting;
- }
- }
-
- // write file back
- ftruncate($handle, 0);
- rewind($handle);
- fwrite($handle, $content);
-
- fclose($handle);
- }
-
- if ($success) {
- return OC_Helper::computerFileSize($size);
- }
- return false;
- }
-
- /**
* @param string $dir
* @param $files
* @param integer $getType
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index d9aa22e2935..a5ed3a3e24b 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -87,32 +87,6 @@ class OC_Helper {
}
/**
- * Make a php file size
- * @param int $bytes file size in bytes
- * @return string a php parseable file size
- *
- * Makes 2048 to 2k and 2^41 to 2048G
- */
- public static function phpFileSize($bytes) {
- if ($bytes < 0) {
- return "?";
- }
- if ($bytes < 1024) {
- return $bytes . "B";
- }
- $bytes = round($bytes / 1024, 1);
- if ($bytes < 1024) {
- return $bytes . "K";
- }
- $bytes = round($bytes / 1024, 1);
- if ($bytes < 1024) {
- return $bytes . "M";
- }
- $bytes = round($bytes / 1024, 1);
- return $bytes . "G";
- }
-
- /**
* Make a computer file size
* @param string $str file size in human readable format
* @return float|bool a file size in bytes