note 41053 added to function.get-browser
| From: | meine dot adresse at gmx dot de | Date: | Mon, 29 Mar 2004 01:20:37 +0000 |
| Subject: | note 41053 added to function.get-browser | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67295@lists.php.net to get a copy of this message | ||
Here's a quick and dirty php script, that does the job for me (I have basically no clue of
regular expressions, so the pros might find that the expressions I use leave much to be desired). It
strips carriage returns from the original file and then puts the values of keys into quotation
marks, so Apache won't complain.
Note that the original browscap.ini is read from the directory where the script is located and the
browscap.ini.new is written to that same directory, so rights have to be set to allow Apache writing
to that directory. Or you might add a different path to the $filename variable.
<?php
header('Content-type: text/plain');
$filename = "browscap.ini";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$contents = preg_replace("#\r#", "", $contents);
$contents = preg_replace("#=(.*)#i", "=\"\\1\"", $contents);
// echo $contents;
$filename .= ".new";
$handle = fopen($filename, "w");
fwrite($handle, $contents);
fclose($handle);
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-browser.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41053
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41053&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41053&report=yes
Search -- http://master.php.net/manage/user-notes.php