Exemple #1
0
 /**
  * Check if upload exceeds maximum file size
  *
  * @param \phpbb\files\filespec $file Filespec object
  *
  * @return \phpbb\files\filespec Returns same filespec instance
  */
 public function check_upload_size($file)
 {
     // PHP Upload filesize exceeded
     if ($file->get('filename') == 'none') {
         $max_filesize = $this->php_ini->getString('upload_max_filesize');
         $unit = 'MB';
         if (!empty($max_filesize)) {
             $unit = strtolower(substr($max_filesize, -1, 1));
             $max_filesize = (int) $max_filesize;
             $unit = $unit == 'k' ? 'KB' : ($unit == 'g' ? 'GB' : 'MB');
         }
         $file->error[] = empty($max_filesize) ? $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_NA') : $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
     }
     return $file;
 }
Exemple #2
0
 /**
  * Get maximum file size for remote uploads
  *
  * @return int Maximum file size
  */
 protected function get_max_file_size()
 {
     $max_file_size = $this->upload->max_filesize;
     if (!$max_file_size) {
         $max_file_size = $this->php_ini->getString('upload_max_filesize');
         if (!empty($max_file_size)) {
             $unit = strtolower(substr($max_file_size, -1, 1));
             $max_file_size = (int) $max_file_size;
             switch ($unit) {
                 case 'g':
                     $max_file_size *= 1024;
                     // no break
                 // no break
                 case 'm':
                     $max_file_size *= 1024;
                     // no break
                 // no break
                 case 'k':
                     $max_file_size *= 1024;
                     // no break
             }
         }
     }
     return $max_file_size;
 }
Exemple #3
0
 /**
  * Gathers system information like database type and does
  * a few system checks.
  *
  * @return array of system info, including an "errors" value
  * in case of errors/warnings
  */
 public function getSystemInfo($allowAllDatabases = false)
 {
     $databases = $this->getSupportedDatabases($allowAllDatabases);
     $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $errors = array();
     // Create data directory to test whether the .htaccess works
     // Notice that this is not necessarily the same data directory as the one
     // that will effectively be used.
     @mkdir($dataDir);
     $htAccessWorking = true;
     if (is_dir($dataDir) && is_writable($dataDir)) {
         // Protect data directory here, so we can test if the protection is working
         \OC\Setup::protectDataDirectory();
         try {
             $util = new \OC_Util();
             $htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig());
         } catch (\OC\HintException $e) {
             $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
             $htAccessWorking = false;
         }
     }
     if (\OC_Util::runningOnMac()) {
         $errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4 GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.'));
     }
     return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'errors' => $errors);
 }
Exemple #4
0
 /**
  * proxy_instantiator constructor
  * @param string $cache_dir Cache dir for fall back when using open_basedir
  */
 public function __construct($cache_dir)
 {
     $config = new Configuration();
     // Prevent trying to write to system temp dir in case of open_basedir
     // restrictions being in effect
     $ini_wrapper = new IniGetWrapper();
     $filesystem = new filesystem();
     $tmp_dir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '';
     if (empty($tmp_dir) || $ini_wrapper->getString('open_basedir') && (!$filesystem->exists($tmp_dir) || !$filesystem->is_writable($tmp_dir))) {
         $config->setProxiesTargetDir($cache_dir);
     }
     $config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
     $this->factory = new LazyLoadingValueHolderFactory($config);
 }
Exemple #5
0
 /**
  * Gathers system information like database type and does
  * a few system checks.
  *
  * @return array of system info, including an "errors" value
  * in case of errors/warnings
  */
 public function getSystemInfo()
 {
     $setup = new \OC_Setup($this->config);
     $databases = $setup->getSupportedDatabases();
     $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $vulnerableToNullByte = false;
     if (@file_exists(__FILE__ . "Nullbyte")) {
         // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
         $vulnerableToNullByte = true;
     }
     $errors = array();
     // Create data directory to test whether the .htaccess works
     // Notice that this is not necessarily the same data directory as the one
     // that will effectively be used.
     @mkdir($dataDir);
     $htAccessWorking = true;
     if (is_dir($dataDir) && is_writable($dataDir)) {
         // Protect data directory here, so we can test if the protection is working
         \OC_Setup::protectDataDirectory();
         try {
             $htAccessWorking = \OC_Util::isHtaccessWorking();
         } catch (\OC\HintException $e) {
             $errors[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
             $htAccessWorking = false;
         }
     }
     if (\OC_Util::runningOnMac()) {
         $errors[] = array('error' => $this->l10n->t('Mac OS X is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', $this->defaults->getName()), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.'));
     }
     if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and the open_basedir has been configured in php.ini. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to  64bit PHP.'));
     }
     if (!function_exists('curl_init') && PHP_INT_SIZE === 4) {
         $errors[] = array('error' => $this->l10n->t('It seems that this %s instance is running on a 32bit PHP environment and cURL is not installed. ' . 'This will lead to problems with files over 4GB and is highly discouraged.', $this->defaults->getName()), 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.'));
     }
     return array('hasSQLite' => isset($databases['sqlite']), 'hasMySQL' => isset($databases['mysql']), 'hasPostgreSQL' => isset($databases['pgsql']), 'hasOracle' => isset($databases['oci']), 'hasMSSQL' => isset($databases['mssql']), 'databases' => $databases, 'directory' => $dataDir, 'htaccessWorking' => $htAccessWorking, 'vulnerableToNullByte' => $vulnerableToNullByte, 'errors' => $errors);
 }