'video/quicktime' => 'mov',
'video/webm' => 'webm',
),
- 'file_quota' => 5000000,
+ 'file_quota' => common_get_preferred_php_upload_limit(),
'user_quota' => 50000000,
'monthly_quota' => 15000000,
'uploads' => true,
define('GNUSOCIAL_ENGINE', 'GNU social');
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
-define('GNUSOCIAL_BASE_VERSION', '1.21.2');
+define('GNUSOCIAL_BASE_VERSION', '1.21.3');
define('GNUSOCIAL_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
/**
* The maximum allowed file size, as an int
*/
- public static function maxFileSizeInt()
+ public static function maxFileSizeInt() : int
{
- return min(
- self::sizeStrToInt(ini_get('post_max_size')),
- self::sizeStrToInt(ini_get('upload_max_filesize')),
- self::sizeStrToInt(ini_get('memory_limit'))
- );
- }
-
- /**
- * Convert a string representing a file size (with units), to an int
- * @param $str
- * @return bool|int|string
- */
- public static function sizeStrToInt($str)
- {
- $unit = substr($str, -1);
- $num = substr($str, 0, -1);
- switch (strtoupper($unit)) {
- case 'G':
- $num *= 1024;
- // no break
- case 'M':
- $num *= 1024;
- // no break
- case 'K':
- $num *= 1024;
- }
- return $num;
+ return common_config('attachments', 'file_quota');
}
/**
return $trim ? trim($text) : $text;
}
+/**
+ * An internal helper function that converts a $size from php.ini for
+ * file size limit from the 'human-readable' shorthand into a int. If
+ * $size is empty (the value is not set in php.ini), returns a default
+ * value (5000000)
+ *
+ * @param string|bool $size
+ * @return int the php.ini upload limit in machine-readable format
+ */
+function _common_size_str_to_int($size) : int
+{
+ if (empty($size)) {
+ return 5000000;
+ }
+
+ $suffix = substr($size, -1);
+ $size = substr($size, 0, -1);
+ switch (strtoupper($suffix)) {
+ case 'P':
+ $size *= 1024;
+ // no break
+ case 'T':
+ $size *= 1024;
+ // no break
+ case 'G':
+ $size *= 1024;
+ // no break
+ case 'M':
+ $size *= 1024;
+ // no break
+ case 'K':
+ $size *= 1024;
+ break;
+ }
+ return $size;
+}
+
+/**
+ * Uses `_common_size_str_to_int()` to find the smallest value for uploads in php.ini
+ *
+ * @returns int
+ */
+function common_get_preferred_php_upload_limit() {
+ return min(_common_size_str_to_int(ini_get('post_max_size')),
+ _common_size_str_to_int(ini_get('upload_max_filesize')),
+ _common_size_str_to_int(ini_get('memory_limit')));
+}
+
function html_sprintf()
{
$args = func_get_args();