This problem has got me perplexed. Any help greatly appreciated!
The problem: running the following code (simple enough)
<?php header('Content-type: text/plain'); echo 'Browser Info: '.$_SERVER['HTTP_USER_AGENT'].PHP_EOL. var_export(get_browser(null, true), true); ?>
get the following error:
PHP Warning: get_browser(): browscap ini directive not set in C:\inetpub\wwwroot\dotTest\test.php on line 4
Here's what I've done
I'm using the full_php_browscap.ini downloaded from the official site: http://tempdownloads.browserscap.com/
Here's the snippet from my php.ini file
[browscap] ; http://php.net/browscap browscap = "C:\inetpub\wwwroot\full_php_browscap.ini"
And I learned I had to use the phpmanager tool to change the setting in IIS to pay attention to changes in php.ini. I had to install it from http://phpmanager.codeplex.com/releases/view/69115 on the windows server but not the windows 7 machine interestingly enough.
and from phpinfo() Core section (can't copy the tabular format but here's the info):
Directive: browscap Local Value: C:\inetpub\wwwroot\full_php_browscap.ini Master Value: C:\inetpub\wwwroot\full_php_browscap.ini
so we can see it's loading the correct ini file (same file for both machines, one works one doesn't)
I tried checking with procmon: http://technet.microsoft.com/en-us/sysinternals/bb896645 and sure enough the browscap file has read process logs when the server is restarted.
I use the following batch script run as an administrator to make sure that permissions are in order on the server
ICACLS C:\inetpub /grant "IIS AppPool\DefaultAppPool":(OI)(CI)F ICACLS C:\inetpub /grant "IUSR":(OI)(CI)F ICACLS C:\Windows\Temp /grant "IIS AppPool\DefaultAppPool":(OI)(CI)F ICACLS C:\Windows\Temp /grant "IUSR":(OI)(CI)F
(why the temp folder? that's where files get uploaded to from a web upload and for the php_move_uploaded_file method to work permissions need to exist there)
As a sanity check I copy pasted the path C:\inetpub\wwwroot\full_php_browscap.ini from the ini file, and from phpinfo() [they are indeed, in fact, the same path, caps and all not that that caps matter on a whindows machine] into notepad's open file dialog. The file does indeed, in fact open.
I should also mention on the windows server machine this error was constant whether or not browscap was set properly and "(none)" was shown on php.ini while on the windows 7 machine the var_dump simply showed the text 'false'. Now the windows 7 machine shows
Browser Info: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0 array ( 'browser_name_regex' => '§^mozilla/5\\.0 \\(.*windows nt 6\\.1.*wow64.*\\).*gecko/.*firefox/20\\..*$§', 'browser_name_pattern' => 'Mozilla/5.0 (*Windows NT 6.1*WOW64*)*Gecko/*Firefox/20.*', 'parent' => 'Firefox 20.0', 'platform' => 'Win7', 'platform_version' => '6.1', 'platform_description' => 'Windows 7', 'win32' => '', 'win64' => '1', 'comment' => 'Firefox 20.0', 'browser' => 'Firefox', 'version' => '20.0', 'majorver' => '20', 'minorver' => '0', 'beta' => '1', 'frames' => '1', 'iframes' => '1', 'tables' => '1', 'cookies' => '1', 'javascript' => '1', 'javaapplets' => '1', 'cssversion' => '3', 'device_name' => 'PC', 'device_maker' => 'Various', 'renderingengine_name' => 'Gecko', 'renderingengine_version' => '20.0', 'renderingengine_description' => 'For Firefox, Camino, K-Meleon, SeaMonkey, Netscape, and other Gecko-based browsers.', 'alpha' => '', 'win16' => '', 'backgroundsounds' => '', 'vbscript' => '', 'activexcontrols' => '', 'ismobiledevice' => '', 'issyndicationreader' => '', 'crawler' => '', 'aolversion' => '0', )
while the windows server machine still shows the error. Any ideas why it wouldn't load? Are there other things I can check? Is this a bug in IIS that only affects WS 2008 R2? I've run out of things I know to check for, all evidence suggests it's not an immediate problem with php. Any feedback appreciated.
Thanks in advance.