本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::fixPermissions方法的具体用法?PHP GeneralUtility::fixPermissions怎么用?PHP GeneralUtility::fixPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::fixPermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateConfiguration
/**
* Generates configuration. Locks configuration file for exclusive access to avoid collisions. Will not be stabe on Windows.
*
* @return void
*/
public function generateConfiguration()
{
$fileName = PATH_site . self::AUTOCONFIGURTION_FILE;
if (class_exists('TYPO3\\CMS\\Core\\Locking\\LockFactory')) {
$lockFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\LockFactory');
$lockObject = $lockFactory->createLocker($fileName, LockingStrategyInterface::LOCK_CAPABILITY_EXCLUSIVE | LockingStrategyInterface::LOCK_CAPABILITY_NOBLOCK);
$lockObject->acquire();
} else {
// @deprecated since 7.6, will be removed once 6.2 support is removed
$lockObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', $fileName, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
$lockObject->setEnableLogging(false);
$lockObject->acquireExclusiveLock();
}
$fd = @fopen($fileName, 'a+');
if ($fd) {
// Check size
fseek($fd, 0, SEEK_END);
if (ftell($fd) == 0) {
$this->doGenerateConfiguration($fd);
}
fclose($fd);
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($fileName);
}
$lockObject->release();
}
示例2: createInstallToolEnableFile
/**
* Creates the INSTALL_TOOL_ENABLE file
*
* @return bool
*/
public static function createInstallToolEnableFile()
{
$installEnableFilePath = self::getInstallToolEnableFilePath();
$result = touch($installEnableFilePath);
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($installEnableFilePath);
return $result;
}
示例3: createInstallToolEnableFile
/**
* Creates the INSTALL_TOOL_ENABLE file
*
* @return bool
*/
public static function createInstallToolEnableFile()
{
$installEnableFilePath = self::getInstallToolEnableFilePath();
if (!is_file($installEnableFilePath)) {
$result = touch($installEnableFilePath);
} else {
$result = true;
self::extendInstallToolEnableFileLifetime();
}
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($installEnableFilePath);
return $result;
}
示例4: getPreviewImage
/**
* Get local absolute file path to preview image
*
* @param File $file
* @return string
*/
public function getPreviewImage(File $file)
{
$videoId = $this->getOnlineMediaId($file);
$temporaryFileName = $this->getTempFolderPath() . 'youtube_' . md5($videoId) . '.jpg';
if (!file_exists($temporaryFileName)) {
$previewImage = GeneralUtility::getUrl(sprintf('https://img.youtube.com/vi/%s/0.jpg', $videoId));
if ($previewImage !== false) {
file_put_contents($temporaryFileName, $previewImage);
GeneralUtility::fixPermissions($temporaryFileName);
}
}
return $temporaryFileName;
}
示例5: getPreviewImage
/**
* Get local absolute file path to preview image
*
* @param File $file
* @return string
*/
public function getPreviewImage(File $file)
{
$soundCloudId = $this->getOnlineMediaId($file);
$temporaryFileName = $this->getTempFolderPath() . 'soundcloud_' . md5($soundCloudId) . '.jpg';
if (!file_exists($temporaryFileName)) {
$oEmbedData = $this->getOEmbedData($soundCloudId);
$previewImage = GeneralUtility::getUrl($oEmbedData['thumbnail_url']);
if ($previewImage !== false) {
file_put_contents($temporaryFileName, $previewImage);
GeneralUtility::fixPermissions($temporaryFileName);
}
}
return $temporaryFileName;
}
示例6: generateConfiguration
/**
* Generates configuration. Locks configuration file for exclusive access to avoid collisions. Will not be stabe on Windows.
*
* @return void
*/
public function generateConfiguration()
{
$fileName = PATH_site . self::AUTOCONFIGURTION_FILE;
$lockObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', $fileName, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
/** @var \TYPO3\CMS\Core\Locking\Locker $lockObject */
$lockObject->setEnableLogging(FALSE);
$lockObject->acquireExclusiveLock();
$fd = @fopen($fileName, 'a+');
if ($fd) {
// Check size
fseek($fd, 0, SEEK_END);
if (ftell($fd) == 0) {
$this->doGenerateConfiguration($fd);
}
fclose($fd);
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($fileName);
}
$lockObject->release();
}
示例7: massSend
/**
* myFunction which is called over cli
*
*/
function massSend()
{
// Check if cronjob is already running:
if (@file_exists(PATH_site . 'typo3temp/tx_directmail_cron.lock')) {
// If the lock is not older than 1 day, skip index creation:
if (filemtime(PATH_site . 'typo3temp/tx_directmail_cron.lock') > time() - 60 * 60 * 24) {
die('TYPO3 Direct Mail Cron: Aborting, another process is already running!' . LF);
} else {
echo 'TYPO3 Direct Mail Cron: A .lock file was found but it is older than 1 day! Processing mails ...' . LF;
}
}
$lockfile = PATH_site . 'typo3temp/tx_directmail_cron.lock';
touch($lockfile);
// Fixing filepermissions
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($lockfile);
/** @var $htmlmail \DirectMailTeam\DirectMail\Dmailer */
$htmlmail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('DirectMailTeam\\DirectMail\\Dmailer');
$htmlmail->start();
$htmlmail->runcron();
unlink($lockfile);
}
示例8: ImageWrite
/**
* Writes the input GDlib image pointer to file
*
* @param resource $destImg The GDlib image resource pointer
* @param string $theImage The filename to write to
* @param int $quality The image quality (for JPEGs)
* @return bool The output of either imageGif, imagePng or imageJpeg based on the filename to write
* @see maskImageOntoImage(), scale(), output()
*/
public function ImageWrite($destImg, $theImage, $quality = 0)
{
imageinterlace($destImg, 0);
$ext = strtolower(substr($theImage, strrpos($theImage, '.') + 1));
$result = false;
switch ($ext) {
case 'jpg':
case 'jpeg':
if (function_exists('imageJpeg')) {
if ($quality == 0) {
$quality = $this->jpegQuality;
}
$result = imageJpeg($destImg, $theImage, $quality);
}
break;
case 'gif':
if (function_exists('imageGif')) {
imagetruecolortopalette($destImg, true, 256);
$result = imageGif($destImg, $theImage);
}
break;
case 'png':
if (function_exists('imagePng')) {
$result = ImagePng($destImg, $theImage);
}
break;
}
if ($result) {
GeneralUtility::fixPermissions($theImage);
}
return $result;
}
示例9: createFile
/**
* Creates a new (empty) file and returns the identifier.
*
* @param string $fileName
* @param string $parentFolderIdentifier
* @return string
* @throws Exception\InvalidFileNameException
* @throws \RuntimeException
*/
public function createFile($fileName, $parentFolderIdentifier)
{
if (!$this->isValidFilename($fileName)) {
throw new Exception\InvalidFileNameException('Invalid characters in fileName "' . $fileName . '"', 1320572272);
}
$parentFolderIdentifier = $this->canonicalizeAndCheckFolderIdentifier($parentFolderIdentifier);
$fileIdentifier = $this->canonicalizeAndCheckFileIdentifier($parentFolderIdentifier . $this->sanitizeFileName(ltrim($fileName, '/')));
$absoluteFilePath = $this->getAbsolutePath($fileIdentifier);
$result = touch($absoluteFilePath);
GeneralUtility::fixPermissions($absoluteFilePath);
clearstatcache();
if ($result !== true) {
throw new \RuntimeException('Creating file ' . $fileIdentifier . ' failed.', 1320569854);
}
return $fileIdentifier;
}
示例10: acquireExclusiveLock
/**
* Try to acquire an exclusive lock
*
* @throws \RuntimeException
* @return bool Returns TRUE if the lock was acquired successfully
*/
public function acquireExclusiveLock()
{
if ($this->isAcquired) {
return true;
}
$this->isAcquired = false;
switch ($this->method) {
case self::LOCKING_METHOD_SIMPLE:
if (file_exists($this->resource)) {
$this->sysLog('Waiting for a different process to release the lock');
$maxExecutionTime = (int) ini_get('max_execution_time');
$maxAge = time() - ($maxExecutionTime ?: 120);
if (@filectime($this->resource) < $maxAge) {
@unlink($this->resource);
$this->sysLog('Unlinking stale lockfile', GeneralUtility::SYSLOG_SEVERITY_WARNING);
}
}
for ($i = 0; $i < $this->loops; $i++) {
$filePointer = @fopen($this->resource, 'x');
if ($filePointer !== false) {
fclose($filePointer);
GeneralUtility::fixPermissions($this->resource);
$this->sysLog('Lock acquired');
$this->isAcquired = true;
break;
}
usleep($this->step * 1000);
}
break;
case self::LOCKING_METHOD_FLOCK:
$this->filePointer = fopen($this->resource, 'c');
if ($this->filePointer === false) {
throw new \RuntimeException('Lock file could not be opened', 1294586099);
}
if (flock($this->filePointer, LOCK_EX)) {
$this->isAcquired = true;
}
break;
case self::LOCKING_METHOD_SEMAPHORE:
$this->getSemaphore();
if (@sem_acquire($this->resource)) {
$this->isAcquired = true;
}
break;
case self::LOCKING_METHOD_DISABLED:
break;
default:
// will never be reached
}
return $this->isAcquired;
}
示例11: main
/**
* Create the thumbnail
* Will exit before return if all is well.
*
* @return void
* @todo Define visibility
*/
public function main()
{
// Clean output buffer to ensure no extraneous output exists
ob_clean();
// If file exists, we make a thumbnail of the file.
if (is_object($this->image)) {
// Check file extension:
if ($this->image->getExtension() == 'ttf') {
// Make font preview... (will not return)
$this->fontGif($this->image);
} elseif ($this->image->getType() != File::FILETYPE_IMAGE && !GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $this->image->getExtension())) {
$this->errorGif('Not imagefile!', 'No ext!', $this->image->getName());
}
// ... so we passed the extension test meaning that we are going to make a thumbnail here:
// default
if (!$this->size) {
$this->size = $this->sizeDefault;
}
// I added extra check, so that the size input option could not be fooled to pass other values.
// That means the value is exploded, evaluated to an integer and the imploded to [value]x[value].
// Furthermore you can specify: size=340 and it'll be translated to 340x340.
// explodes the input size (and if no "x" is found this will add size again so it is the same for both dimensions)
$sizeParts = explode('x', $this->size . 'x' . $this->size);
// Cleaning it up, only two parameters now.
$sizeParts = array(MathUtility::forceIntegerInRange($sizeParts[0], 1, 1000), MathUtility::forceIntegerInRange($sizeParts[1], 1, 1000));
// Imploding the cleaned size-value back to the internal variable
$this->size = implode('x', $sizeParts);
// Getting max value
$sizeMax = max($sizeParts);
// Init
$outpath = PATH_site . $this->outdir;
// Should be - ? 'png' : 'gif' - , but doesn't work (ImageMagick prob.?)
// René: png work for me
$thmMode = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails_png'], 0);
$outext = $this->image->getExtension() != 'jpg' || $thmMode & 2 ? $thmMode & 1 ? 'png' : 'gif' : 'jpg';
$outfile = 'tmb_' . substr(md5($this->image->getName() . $this->mtime . $this->size), 0, 10) . '.' . $outext;
$this->output = $outpath . $outfile;
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
// If thumbnail does not exist, we generate it
if (!file_exists($this->output)) {
$parameters = '-sample ' . $this->size . ' ' . $this->wrapFileName($this->image->getForLocalProcessing(FALSE)) . '[0] ' . $this->wrapFileName($this->output);
$cmd = GeneralUtility::imageMagickCommand('convert', $parameters);
\TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
if (!file_exists($this->output)) {
$this->errorGif('No thumb', 'generated!', $this->image->getName());
} else {
GeneralUtility::fixPermissions($this->output);
}
}
// The thumbnail is read and output to the browser
if ($fd = @fopen($this->output, 'rb')) {
$fileModificationTime = filemtime($this->output);
header('Content-Type: image/' . ($outext === 'jpg' ? 'jpeg' : $outext));
header('Last-Modified: ' . date('r', $fileModificationTime));
header('ETag: ' . md5($this->output) . '-' . $fileModificationTime);
// Expiration time is chosen arbitrary to 1 month
header('Expires: ' . date('r', $fileModificationTime + 30 * 24 * 60 * 60));
fpassthru($fd);
fclose($fd);
} else {
$this->errorGif('Read problem!', '', $this->output);
}
} else {
die;
}
} else {
$this->errorGif('No valid', 'inputfile!', basename($this->image));
}
}
示例12: closeFile
/**
* Closes the file handler and fixes permissions.
*
* @return void
*/
protected function closeFile()
{
fclose($this->filePointer);
$this->filePointer = false;
\TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($this->targetFilePath);
}
示例13: fixPermissionsSetsDefaultPermissionsToDirectory
/**
* @test
*/
public function fixPermissionsSetsDefaultPermissionsToDirectory()
{
if (TYPO3_OS == 'WIN') {
$this->markTestSkipped('fixPermissions() tests not available on Windows');
}
$directory = PATH_site . 'typo3temp/' . $this->getUniqueId('test_');
GeneralUtility::mkdir($directory);
$this->testFilesToDelete[] = $directory;
chmod($directory, 1551);
unset($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']);
$fixPermissionsResult = GeneralUtility::fixPermissions($directory);
clearstatcache();
$this->assertTrue($fixPermissionsResult);
$this->assertEquals('0755', substr(decoct(fileperms($directory)), 1));
}
示例14: imagemake
/**
* Write the icon in $im pointer to $path
*
* @param pointer $im Pointer to GDlib image resource
* @param string $path Absolute path to the filename in which to write the icon.
* @return void
* @access private
*/
public static function imagemake($im, $path)
{
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
@ImagePng($im, $path);
} else {
@ImageGif($im, $path);
}
if (@is_file($path)) {
GeneralUtility::fixPermissions($path);
}
}
示例15: fixPermissionsSetsPermissionsWithRelativeFileReference
/**
* @test
*/
public function fixPermissionsSetsPermissionsWithRelativeFileReference()
{
if (TYPO3_OS === 'WIN') {
$this->markTestSkipped('fixPermissions() tests not available on Windows');
}
$filename = 'typo3temp/' . $this->getUniqueId('test_');
GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filename, '42');
$this->testFilesToDelete[] = PATH_site . $filename;
chmod(PATH_site . $filename, 482);
// Set target permissions and run method
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
$fixPermissionsResult = GeneralUtility::fixPermissions($filename);
clearstatcache();
$this->assertTrue($fixPermissionsResult);
$this->assertEquals('0660', substr(decoct(fileperms(PATH_site . $filename)), 2));
}