예제 #1
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);
 }
예제 #2
0
파일: base.php 프로젝트: VOLKERMORD/phpbb
 /**
  * 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;
 }
예제 #3
0
파일: plupload.php 프로젝트: kilianr/phpbb
 /**
  * Checks various php.ini values and the maximum file size to determine
  * the maximum size chunks a file can be split up into for upload
  *
  * @return int
  */
 public function get_chunk_size()
 {
     $max = min($this->php_ini->getBytes('upload_max_filesize'), $this->php_ini->getBytes('post_max_size'), max(1, $this->php_ini->getBytes('memory_limit')), $this->config['max_filesize']);
     // Use half of the maximum possible to leave plenty of room for other
     // POST data.
     return floor($max / 2);
 }
예제 #4
0
파일: remote.php 프로젝트: tqangxl/phpbb
 /**
  * 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;
 }
예제 #5
0
파일: setup.php 프로젝트: kenwi/core
 /**
  * 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);
 }
예제 #6
0
파일: config.php 프로젝트: hybiepoo/phpbb
 /**
  * Filling up system_data array
  */
 protected function setup_system_data()
 {
     // Query maximum runtime from php.ini
     $execution_time = $this->php_ini->getNumeric('max_execution_time');
     $execution_time = min(15, $execution_time / 2);
     $this->system_data['max_execution_time'] = $execution_time;
     // Set start time
     $this->system_data['start_time'] = microtime(true);
     // Get memory limit
     $this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit');
 }
예제 #7
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);
 }
예제 #8
0
 /**
  * アップロードできるファイルの最大バイト数を取得します。
  * @return int
  */
 protected function getMaxFileBytes() : int
 {
     $iniGetWrapper = new IniGetWrapper();
     return min($iniGetWrapper->getBytes('upload_max_filesize'), $iniGetWrapper->getBytes('post_max_size'), $iniGetWrapper->getBytes('memory_limit'));
 }
예제 #9
0
 /**
  * @return array (string => string|int)
  */
 public function getData()
 {
     return ['version' => $this->cleanVersion(PHP_VERSION), 'memory_limit' => $this->phpIni->getBytes('memory_limit'), 'max_execution_time' => $this->phpIni->getNumeric('max_execution_time'), 'upload_max_filesize' => $this->phpIni->getBytes('upload_max_filesize')];
 }