I have a cronjob that summarize browser statistics. This cronjob loads data and then use the get_browser() PHP function to parse the browser information.
Here's what I did:
cd /etc/php5/cli/conf.d
me@ubutnu:/etc/php5/cli/conf.d$ sudo wget http://browsers.garykeith.com/stream.asp?Lite_PHP_BrowsCapINI -O browscap.ini
2011-09-30 15:14:18 (890 KB/s) - `browscap.ini' saved [185384/185384]
Then the cronjob run:
php /usr/local/cron/summarizeStats.php --option=browserStats --date=yesterday
and I get this error:
PHP: syntax error, unexpected $end, expecting ']' in /etc/php5/cli/conf.d/browscap.ini on line 51
What am I doing wrong? Thanks
A little bit late, but there are still problems with using file without modifications. I'm using following script to download and change browscap.ini so it can work on my server.
#!/bin/sh
url="http://browscap.org/stream?q=PHP_BrowsCapINI"
curl -L -o browscap.ini ${url}
sed -I "" -E 's/;/\\;/g' browscap.ini
sed -I "" -E 's/[\\;]{40}/;;;/g' browscap.ini
sed -I "" -E "s/\'/\\\'/g" browscap.ini
mv browscap.ini /usr/local/etc/php/browscap.ini
Explanation
;
with \'
(;;;;)
. This could be optimised with something like ^\;
in search part, and just single ;
in replace part, need to test that before I put'*'
Don't forget to adjust your browscap.ini finial destination. Also there is no need for Apache or PHP restart after update, so put this script somewhere and setup cron job.
There is seemingly right now an error with those browsecap files. They seem to contain unescaped semicolons ";" in the browser spec. You can fix that using this little script:
<?php
$browsecap = file('browscap.ini');
foreach( $browsecap as &$row )
if ( $row[ 0 ] == '[' )
$row = str_replace( ';', '\\;', $row );
file_put_contents( 'fixed_browscap.ini', $browsecap );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With