From 90087123ba19823892ebaa278196505662078ad0 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Fri, 28 Apr 2017 17:41:05 +0200 Subject: [PATCH] [fix] Do not create .htaccess with Nginx --- cfg/conf.ini.sample | 4 ++++ lib/Configuration.php | 1 + lib/Persistence/AbstractPersistence.php | 30 +++++++++++++------------ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cfg/conf.ini.sample b/cfg/conf.ini.sample index d457b89..b806f4c 100644 --- a/cfg/conf.ini.sample +++ b/cfg/conf.ini.sample @@ -75,6 +75,10 @@ languageselection = false ; sha256 in HMAC for the deletion token zerobincompatibility = false +; allows you to specify the name of the web server you are using to use ParseBin. +; if you use Nginx, decommente and add nginx. +webserver = "Nginx" + [expire] ; expire value that is selected per default ; make sure the value exists in [expire_options] diff --git a/lib/Configuration.php b/lib/Configuration.php index b6b9f6f..78aeb36 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -54,6 +54,7 @@ class Configuration 'icon' => 'identicon', 'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; referrer no-referrer; sandbox allow-same-origin allow-scripts allow-forms allow-popups', 'zerobincompatibility' => false, + 'webserver' => 'Apache', ), 'expire' => array( 'default' => '1week', diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index 64fb530..65b2c78 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -82,21 +82,23 @@ abstract class AbstractPersistence */ protected static function _initialize() { - // Create storage directory if it does not exist. - if (!is_dir(self::$_path)) { - if (!@mkdir(self::$_path, 0700)) { - throw new Exception('unable to create directory ' . self::$_path, 10); + if (property_exists($data->meta, 'webserver') && $data->meta->webserver && $this->_conf->getKey('webserver') == "Apache") { + // Create storage directory if it does not exist. + if (!is_dir(self::$_path)) { + if (!@mkdir(self::$_path, 0700)) { + throw new Exception('unable to create directory ' . self::$_path, 10); + } } - } - $file = self::$_path . DIRECTORY_SEPARATOR . '.htaccess'; - if (!is_file($file)) { - $writtenBytes = @file_put_contents( - $file, - 'Require all denied' . PHP_EOL, - LOCK_EX - ); - if ($writtenBytes === false || $writtenBytes < 19) { - throw new Exception('unable to write to file ' . $file, 11); + $file = self::$_path . DIRECTORY_SEPARATOR . '.htaccess'; + if (!is_file($file)) { + $writtenBytes = @file_put_contents( + $file, + 'Require all denied' . PHP_EOL, + LOCK_EX + ); + if ($writtenBytes === false || $writtenBytes < 19) { + throw new Exception('unable to write to file ' . $file, 11); + } } } }