[Pro] PHP, cURL and Cookies

Walter, thank you for your tips.


First, there is no browser sniffing to determine the language. MacUSA is running FileMaker Server Advanced 11 on Macintosh hardware, used to share multiple FileMaker databases (including mine). There is a setting within FileMaker server that controls language. If you set it to English, it uses the English string file. If you change the setting to Japanese, it uses the Japanese string file. But it will not use both, and it will not switch.

Here’s a screenshot of the FileMaker Server Language setting:

http://cl.ly/image/462w2N050q2L/FMserver_IWP_StatusAreaLang.jpg

And here’s the text description from the FM Server manual:

For Status Area Language, select the language for the labels
displayed in the status area of the Instant Web Publishing page.
This setting changes the language for all text in the Instant Web
Publishing user interface — for example, the status area, Instant
Web Publishing homepage, forms- based authentication, dialog
boxes, and error messages.  The status area language setting does
not change the language of data stored in databases.

Since MacUSA is hosted in the USA, their target audience is English, not Japanese. That’s why they have their setting on English. And when the Server setting is English, then everyone who hosts a FileMaker database on that server will get the Login page, errors, etc. in English.

If FileMaker server had been more intelligently designed to sniff the client’s browser and send the appropriate language strings to the browser, I wouldn’t have any problem at all. But sadly, that is not the case.


Next, I tried your code, saving it and running it from off my ServerLogistics web server.

The first code block I tried was your first suggestion, modified only to swap in the correct address for the Login page:

<?php
$source = file_get_contents('http://hartford.macusa.net/fmi/iwp/cgi?-db=Install_Info.fp7&-startsession');
// do things to the source with string manipulation here
$source = str_replace('/fmi/iwp/cgi?-getstrings', '/fmi/iwp/res/jpn/strings.js', $source);
header('Content-type: text/html; charset=utf-8');
print $source;
?>

When I try to execute the above PHP file from Safari, it displays nothing for about 20 seconds and then I get a 404 Not Found error page.


Next, I added the line in your last post, swapping out example.com for the BASE URL of MacUSA, as follows:

<?php
$source = file_get_contents('http://hartford.macusa.net/fmi/iwp/cgi?-db=Install_Info.fp7&-startsession');
// do things to the source with string manipulation here
$source = str_replace('/fmi/iwp/cgi?-getstrings', '/fmi/iwp/res/jpn/strings.js', $source);
header('Content-type: text/html; charset=utf-8');
// on another line, before the output, and replace the URL with the correct base
$source = str_replace('<head>', '<head><base href="http://hartford.macusa.net/">', $source);
print $source;
?>

That takes me to the “You have logged out.” page, which resides at “iwp_home.html”. The remains true even if I try it again adding “/fmi/iwp/” to the end of that base URL. I still get the “You have logged out.” page.

NOTE:

iwp_auth.html is the Login page.

iwp_home.html is the “You have logged off.” page.


dynamo mailing list
email@hidden
Update your subscriptions at: