[TYPO3-core] RFC: Bug / Feature #5838: Get cli_dispatch.phpsh to work on windows platforms

Martin Kutschker martin.kutschker-n0spam at no5pam-blackbox.net
Sat Mar 1 11:31:03 CET 2008


Martin Kutschker schrieb:
> Martin Kutschker schrieb:
>> Andreas Otto schrieb:
>>> Hi Martin,
>>>
>>> Martin Kutschker wrote:
>>>> Please wait a bit, because I'll want to have a closer look a Dmitry's
>>>> getcwd() idea.
>>>
>>> OK.
>>
>> This code works on Windows even with relative paths. Note that 
>> $_SERVER['PWD'] is used because of getcwd() issues on some *nix systems.
>>
>> $relativePath = FALSE;
>> if (stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')) {
>>   if (!preg_match('/^([A-Z]:)?\\/', $temp_PATH_thisScript)) {
>>     $relativePath = TRUE;
>>   }
>> } else {
>>   if ($temp_PATH_thisScript{0} != '/') {
>>     $relativePath = TRUE;
>>   }
>> }
>>
>> if ($relativePath) {
>>   $wd = $_SERVER['PWD'] ? $_SERVER['PWD'] : getcwd();
>>   if ($wd) {
>>     $temp_PATH_thisScript =
>>       $wd.'/'.ereg_replace('\.\/','',$temp_PATH_thisScript);
>>     if (!@is_file($temp_PATH_thisScript)) {
>>       die ('relative path found and an error occured during resolving 
>> of the absolute path. $temp_PATH_thisScript');
>>     }
>>   } else {
>>     die ('relative path found, but resolving absolute path is not 
>> supported on this platform.');
>>   }
>> }
>> define('PATH_thisScript',$temp_PATH_thisScript);
> 
> Here is the change as diff. I have also added a copyright claim and the 
> SVN tag.

Commited to TYPO3_4-2 and TYPO3_4-1 taking into account the comments 
(using \\\ and a split line).

Masi


More information about the TYPO3-team-core mailing list