本文整理汇总了PHP中eZSys::environmentVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::environmentVariable方法的具体用法?PHP eZSys::environmentVariable怎么用?PHP eZSys::environmentVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::environmentVariable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eZSetupTestFileUpload
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)));
}