[svn r12385] Added file_to_array() function and used as a replacement to core file() which doesn't handle Windows line endings very well.

skala
Yannick Warnier 18 years ago
parent 132632e539
commit 3235f82300
  1. 19
      main/install/install_functions.inc.php

@ -103,6 +103,21 @@ function trueFalse($var)
return $var?'true':'false';
}
/**
* This function is similar to the core file() function, except that it
* works with line endings in Windows (which is not the case of file())
* @param string File path
* @return array The lines of the file returned as an array
*/
function file_to_array($filename)
{
$fp = fopen($filename, "rb");
$buffer = fread($fp, filesize($filename));
fclose($fp);
$result = preg_split("/r?n|r/", $buffer);
return $result;
}
/**
* This function returns the value of a parameter from the configuration file
*
@ -151,11 +166,11 @@ function get_config_param($param)
elseif(file_exists($updatePath.$updateFromConfigFile))
{
$configFile=array();
$temp=file($updatePath.$updateFromConfigFile);
$temp=file_to_array($updatePath.$updateFromConfigFile);
$val='';
if(file_exists($updatePath.$updateFromInstalledVersionFile))
{
$temp2 = file($updatePath.$updateFromInstalledVersionFile);
$temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
$temp = array_merge($temp,$temp2);
}

Loading…
Cancel
Save