[TYPO3-english] Is there a condition to check the OS of the server?

Christopher Christopher at temporaryforwarding.com
Tue Dec 16 23:25:20 CET 2008

Hi Dmitry,

"Dmitry Dulepov" <dmitry at typo3.org> schrieb im Newsbeitrag 
news:mailman.1.1229435902.26710.typo3-english at lists.netfielders.de...
> Hi!
> Christopher wrote:
>> So it should be the following?
>> if (TYPO3_OS == 'WIN') {
>>     return $os == "Windows";
>> }
>> else {
>>     return $os == "different";
>> }
> If you want to check Windows vs anything else, this will do:
> function user_checkOS($os) {
> return $os == 'Windows' && TYPO3_OS == 'WIN';
> }

I got it to work now, but I don't really uinderstand why it in some 
constellations does NOT work... Just read on...

The follwoing works:
Add this to your localconf.php:
function user_checkOS($os) {
    if (TYPO3_OS == 'WIN') {
        # return $os gives back the value,
        # which was used to compare in the Typoscript-Condition
        # (which is "Windows"; see below).
        # So it makes the condition become true.
        return $os;
    # Not needed at all, just to clarify.
    else {
        return FALSE;

And then use the following Typoscript:
# For Windows:
[userFunc = user_checkOS("Windows")]
config.locale_all = german
# For Unix-systems:
config.locale_all = de_DE

But as I noticed, my problem unfortunately is somewhere else:

If I put the code into a file in fileadmin and use includeLibs like this:
includeLibs.user_checkOS = fileadmin/user_checkOS.php
it does not work on Windows.
The condition in TypoScript does not match.
But I think the file is included, because of the following:
If I copy the function to localconf.php AND use includeLibs, I get a "Cannot 
redeclare..."-error, ("previously declared in localconf.php") in FE.

If I only put the php-code into the localconf-file (or include it there), it 
works as expected. (Problem is I didn't try it that way...)

The question is obvious:
Why does the condition not work with includeLibs on Windows?



More information about the TYPO3-english mailing list