/**
* Method for parsing ini files
*
* @param string $filename Path and name of the ini file to parse
*
* @return array Array of strings found in the file, the array indices will be the keys. On failure an empty array will be returned
*
* @since 2.5
*/
public static function parseFile($filename)
{
if (!Filesystem::exists($filename)) {
return array();
}
// Capture hidden PHP errors from the parsing
$version = phpversion();
$php_errormsg = null;
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
if ($version >= '5.3.1') {
$contents = file_get_contents($filename);
$contents = str_replace('_QQ_', '"\\""', $contents);
$strings = @parse_ini_string($contents);
if ($strings === false) {
return array();
}
} else {
$strings = @parse_ini_file($filename);
if ($strings === false) {
return array();
}
if ($version == '5.3.0' && is_array($strings)) {
foreach ($strings as $key => $string) {
$strings[$key] = str_replace('_QQ_', '"', $string);
}
}
}
return $strings;
}