function eZSetupTestFileUpload($type) { $uploadEnabled = ini_get('file_uploads') != 0; $uploadDir = ini_get('upload_tmp_dir'); $uploadDirExists = true; $uploadDirWriteable = true; $uploadDirCreateFile = true; $uploadIsRoot = false; // Empty upload_tmp_dir variable means that the system // default is used. However the system default variable is hidden // from PHP code and must be guessed. // See: http://www.php.net/manual/en/ini.sect.file-uploads.php#ini.upload-tmp-dir if (strlen(trim($uploadDir)) == 0) { $osType = eZSys::osType(); if ($osType == 'win32') { // Windows machines use the TEMP and TMP env variable. // TEMP is checked first. $uploadDir = eZSys::hasEnvironmentVariable('TEMP') ? eZSys::environmentVariable('TEMP') : ''; if ($uploadDir === '') { $uploadDir = eZSys::hasEnvironmentVariable('TMP') ? eZSys::environmentVariable('TMP') : ''; } // When TEMP/TMP is not set we have to guess the directory // The only valid guess is %SYSTEMROOT%/TEMP // If %SYSTEMROOT% is missing we keep the string empty if ($uploadDir === '') { if (eZSys::hasEnvironmentVariable('SYSTEMROOT')) { $uploadDir = eZSys::environmentVariable('SYSTEMROOT') . '/TEMP'; } } } else { if ($osType == 'unix' or $osType == 'mac') { $uploadDir = eZSys::hasEnvironmentVariable('TMPDIR') ? eZSys::environmentVariable('TMPDIR') : ''; // When TMPDIR is not set we have to guess the directory // On Unix systems we expect /tmp to be used if (strlen($uploadDir) == 0) { $uploadDir = '/tmp'; } } } } $uploadDirs = array(); if (strlen($uploadDir) > 0) { $uploadDirExists = file_exists($uploadDir); $uploadDirWriteable = eZDir::isWriteable($uploadDir); if ($uploadDirExists and $uploadDirWriteable) { $uploadDirCreateFile = false; $tmpFile = 'ezsetuptmp_' . md5(microtime()) . '.tmp'; $tmpFilePath = $uploadDir . '/' . $tmpFile; if ($fd = @fopen($tmpFilePath, 'w')) { $uploadDirCreateFile = true; @fclose($fd); unlink($tmpFilePath); } } $splitDirs = explode('/', trim($uploadDir, '/')); $dirPath = ''; foreach ($splitDirs as $splitDir) { $dirPath .= '/' . $splitDir; $uploadDirs[] = $dirPath; } if (substr($uploadDir, 0, 5) == '/root') { $uploadIsRoot = true; } } $result = ($uploadEnabled and $uploadDirExists and $uploadDirWriteable and $uploadDirCreateFile); $userInfo = eZSetupPrvPosixExtension(); return array('result' => $result, 'php_upload_is_enabled' => $uploadEnabled, 'php_upload_is_root' => $uploadIsRoot, 'php_upload_dir' => $uploadDir, 'php_upload_split_dirs' => $uploadDirs, 'upload_dir_exists' => $uploadDirExists, 'upload_dir_writeable' => $uploadDirWriteable, 'upload_dir_create_file' => $uploadDirCreateFile, 'user_info' => $userInfo, 'persistent_data' => array('result' => array('value' => $result))); }