Forum Moderators: coopster
I know it was the 26th but I didn't see it friday and didn't go on the site over the weekend strangely enough.
Lots of bug fixes. We put on all of our servers today.
This is primarily a bug fix release, without any new features or additions. PHP 4.3.5 is by far the most stable release of PHP to date and it is recommended that all users upgrade to this release whenever possible.
So I guess line by line. We use a shell script to update servers. OS patches, apache, ssl, php and maybe some other things too, can't remember off the top of my head. The script just does the whole thing for us, very simple.
I'm just trying to make life a bit easier for myself when it's time to upgrade servers, and especially configuration files like .conf, .ini, etc. I never thought of scripting it (duh, what a brilliant analyst we have here).
Makes me think, though...how would one read the file, find existing directive settings and change them to the directive settings I have changed from defaults...but what if the developers changed the defaults (has happened before,
register_globalsfor example). Hmmm, anybody else got any ideas on this...?
Neither do I, that's why I do the line-by-line thing. However, if I could read and compare the two (current .ini versus brand-new .ini), it might be worth the time to develop a nice little script that prints out the info. I know that certain platforms (IBM's AS400, for example) have some compare utilities built in for this type of requirement. Well, we'll see if anybody else has any input.
class compare_ini_files_class {
var $params, $line_nr;
function compare_ini_files_class ($filename1, $filename2) {
//read files into arrays
$this->file1=$filename1;
$this->file2=$filename2;
$lines[1]=file($this->file1);
$lines[2]=file($this->file2);
//extract values of configuration parameters
for ($i=1;$i<=2;$i++) {
foreach ($lines[$i] as $key=>$val) {
unset($temp);
//find and strip ";" and everything after it, because it's a comment
$pos = strpos($val, ";");
if ($pos===false) {
//no comments found
$line=$val;
}
else $line=substr($val,0,$pos+1); //line is everything up to ";"
ereg('(.*)[ ]*=[ ]*(.*)',$line,$temp);
$this->params[$i]["$temp[1]"]="$temp[2]"; //put extracted value into table
$this->line_nr[$i]["$temp[1]"]=$key; // save line number where this value as in file
}
}
}
function compare() {
foreach ($this->params[1] as $key=>$val) {
if ($val!=$this->params[2][$key]) {
echo $this->file1,':',$this->line_nr[1]["$key"],' ',$key,'=',$val,'<br>';
echo $this->file2,':',$this->line_nr[2]["$key"],' ',$key,'=',$this->params[2][$key],'<br><br>';
}
}
}
}
$ini_files=new compare_ini_files_class('php1.ini','php2.ini');
echo 'The differences in the INI files are:<br>',$ini_files->compare();
?>
It might have some bugs, I haven't really tested it much.
I had a lot of trouble getting the indents to show, so they're in spaces and not tabs
I like the idea of the script to at least highlight the areas I need to look at. A script would work cross platform as well, you know, in case a diff or other file comparison utility wasn't available for the OS hosting the servers.
Thanks for the start mykel79. I haven't had a chance to poke through the code yet and test it, but will give it a closer look once PHP 5 has stabilized and server upgrade decisions are being considered. Or hopefully long before that.