Improve the INI file parsing mechanism of WampServer
Posted by: skoobiedu (---.austin.res.rr.com)
Date: October 21, 2008 09:08PM

The INI file parser that WampServer uses needs to be improved. It should remove white space and quotation marks, both of which are allowed in INI files, like php.ini. Since it doesn't, it creates a problem with the WampServer's INI file, which then has to be hand fixed. This would increase the stability of WampServer, since it wouldn't cause itself to screw up, and nobody wants a suicidal application.

Timeless Thoughts of Imagination
-----------------------------------------------------
I am pessimistically optimistic.

Options: ReplyQuote
Re: Improve the INI file parsing mechanism of WampServer
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: October 21, 2008 09:09PM

and where exactly is the errors?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Improve the INI file parsing mechanism of WampServer
Posted by: skoobiedu (---.austin.res.rr.com)
Date: October 21, 2008 09:54PM

it's in the '<wamp_directory>/scripts/refresh.php' file, starting on line 145 (it may be different, so the comment says 'on recupere la conf courante').

replace the foreach loop with the following:

foreach($myphpini as $line)
{
$extMatch = array();
$pregPattern = 'extension\s*=\s*\"?([a-zA-Z0-9\._]+)\"?|';
if(preg_match('|^;'.$pregPattern, $line, $extMatch)) {
//if (preg_match('|^;extension=|',$line))
{
//$ext_name=str_replace(';extension=','',$line);
$ext_name=str_replace('.dll
','',/*$ext_name*/$extMatch[1]);
$ext[$ext_name] = '0';
}
elseif(preg_match('|^'.$pregPattern, $line, $extMatch))
//elseif (preg_match('|^extension=|',$line))
{
//$ext_name=str_replace('extension=','',$line);
$ext_name=str_replace('.dll
','',/*$ext_name*/$extMatch[1]);
$ext[$ext_name] = '1';
}
}

(this forum doesn't allow for formatted text, so the indentation is lost)

I commented out the parts that were originally there, that needed to be changed, to preserve integrity.

Timeless Thoughts of Imagination
-----------------------------------------------------
I am pessimistically optimistic.

Options: ReplyQuote
Re: Improve the INI file parsing mechanism of WampServer
Posted by: roms (Moderator)
Date: October 22, 2008 09:14AM

Yes, this could be a small improvement in the refresh.php script. Thanks Skoobiedu (and stevenmartin99). I'll try to add this in the next release of WampServer.

Romain

Options: ReplyQuote
Re: Improve the INI file parsing mechanism of WampServer
Posted by: skoobiedu (---.austin.res.rr.com)
Date: October 23, 2008 10:35PM

Cool. I just improved the parser a little bit more, removed redundancies and repeated code, and made it case-insensitive.
//on recupere la conf courante
foreach($myphpini as $line) {
  $extMatch = array();
  if(preg_match('/^(winking smiley?extension\s*=\s*"?([a-z0-9_]+)\.dll"?/i', $line, $extMatch)) {
    $ext_name = $extMatch[2];
    
    if($extMatch[1] == ';') {
      $ext[$ext_name] = '0';
    } else {
      $ext[$ext_name] = '1';
    }
  }
  /*if(preg_match('|^;extension=|', $line)) {
    $ext_name = str_replace(';extension=', '', $line);
    $ext_name = str_replace('.dll
', '', $ext_name);
    $ext[$ext_name] = '0';
  } elseif(preg_match('|^extension=|', $line)) {
    $ext_name = str_replace('extension=', '', $line);
    $ext_name = str_replace('.dll
', '', $ext_name);
    $ext[$ext_name] = '1';
  }*/
}

Timeless Thoughts of Imagination
-----------------------------------------------------
I am pessimistically optimistic.

Options: ReplyQuote


Sorry, only registered users may post in this forum.