- md5
- 560c5c2e9baf10c8e14ad3dce66ea38d
- sha1
- 547e5b5e38b6e467fd9cbc18f23740b8a2eeff32
- sha256
- 2931a0bdfea96d827e7a40eb5d05e3abae78dcd9386459a6f3d044c0c5465a09
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Utility;
\defined('JPATH_PLATFORM') or die;
use Joomla\CMS\HTML\HTMLHelper;
/**
* JUtility is a utility functions class
*
* @since 1.7.0
*/
class Utility
{
/**
* Method to extract key/value pairs out of a string with XML style attributes
*
* @param string $string String containing XML style attributes
*
* @return array Key/Value pairs for the attributes
*
* @since 1.7.0
*/
public static function parseAttributes($string)
{
$attr = array();
$retarray = array();
// Let's grab all the key/value pairs using a regular expression
preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);
if (\is_array($attr))
{
$numPairs = \count($attr[1]);
for ($i = 0; $i < $numPairs; $i++)
{
$retarray[$attr[1][$i]] = $attr[2][$i];
}
}
return $retarray;
}
/**
* Method to get the maximum allowed file size for the HTTP uploads based on the active PHP configuration
*
* @param mixed $custom A custom upper limit, if the PHP settings are all above this then this will be used
*
* @return integer Size in number of bytes
*
* @since 3.7.0
*/
public static function getMaxUploadSize($custom = null)
{
if ($custom)
{
$custom = HTMLHelper::_('number.bytes', $custom, '');
if ($custom > 0)
{
$sizes[] = $custom;
}
}
/*
* Read INI settings which affects upload size limits
* and Convert each into number of bytes so that we can compare
*/
$sizes[] = HTMLHelper::_('number.bytes', ini_get('post_max_size'), '');
$sizes[] = HTMLHelper::_('number.bytes', ini_get('upload_max_filesize'), '');
// The minimum of these is the limiting factor
return min($sizes);
}
}
The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.