Home » PEAR » PEAR_Frontend_Web » Bug #8731
Path Separators in pear.ini after Config Change
Details
| Submitted | 2006-09-19 08:07 UTC |
|---|---|
| From | joachim dot werner at diggin-data dot de |
| Status | No Feedback |
| Package | PEAR_Frontend_Web |
| PHP Version | 4.4.1 |
| OS | Windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2006-09-19 08:07 UTC] joachim dot werner at diggin-data dot de
Description:
------------
Hello,
after changing a setting in the web frontend, all path config settings in the pear.ini get double backslashes ('\\') on my Windows 2000 server.
This leaves the pear.ini unuseable for pear commandline useage!
On a Windows 2000 machine, it is no problem to have paths like C:/php/pear instead of C:\php\pear.
Please find a script below to fix the slashes.
Best regards,
Joachim Werner
Wiesbaden
Germany
Test script:
---------------
<pre>
<?
/**
* Clears path separators in a pear.ini file
* for Windows servers
*
* Joachim Werner <joachim.werner@diggin-data.de>
*/
$pear_ini_file = '../../pear.ini';
$pear_ini_file_new = '../../pear_new.ini';
$pearini = file( $pear_ini_file );
print_r( $pearini );
// Get the serialized PEAR object
$aPear = unserialize( $pearini[1] );
print_r( $aPear );
// Substitute backslashes in settings
foreach( $aPear as $k=>$v ) {
if( !is_array( $k ) ) {
$aPear[$k] = str_replace( "\\\\", "/", $v );
}
}
print_r( $aPear );
// Write back pear.ini to a new file
$fp = fopen( $pear_ini_file_new, "wb" );
fwrite( $fp, $pearini[0] );
fwrite( $fp, serialize( $aPear ) );
fclose( $fp );
print_r( "File $pear_ini_file_new written\n" );
// vim: ai sw=4 sts=4 expandtab fdm=marker fdc=4
?>
</pre>
Expected result:
----------------
- Shows the PEAR settings object before and after fixed path slashes
- Writes the PEAR settings to a new pea_new.ini file
- Place it in php/pear/docs or adapt the ini file variables $pear_ini_file and $pear_ini_file_new.