本文整理汇总了PHP中Folder::protect方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::protect方法的具体用法?PHP Folder::protect怎么用?PHP Folder::protect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::protect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: protectFolder
/**
* Return a checkbox to delete session data
*
* @param DataContainer $dc
*
* @return string
*/
public function protectFolder(DataContainer $dc)
{
$count = 0;
$strPath = $dc->id;
// Check whether the temporary name has been replaced already (see #6432)
if (Input::post('name') && ($strNewPath = str_replace('__new__', Input::post('name'), $strPath, $count)) && $count > 0 && is_dir(TL_ROOT . '/' . $strNewPath)) {
$strPath = $strNewPath;
}
// Only show for folders (see #5660)
if (!is_dir(TL_ROOT . '/' . $strPath)) {
return '';
}
$blnProtected = file_exists(TL_ROOT . '/' . $strPath . '/.htaccess');
// Protect or unprotect the folder
if (Input::post('FORM_SUBMIT') == 'tl_files') {
if (Input::post('protected')) {
if (!$blnProtected) {
$blnProtected = true;
$objFolder = new Folder($strPath);
$objFolder->protect();
}
} else {
if ($blnProtected) {
$blnProtected = false;
$objFolder = new Folder($strPath);
$objFolder->unprotect();
}
}
}
// Show a note for non-Apache servers
if (strpos(Environment::get('serverSoftware'), 'Apache') === false) {
Message::addInfo($GLOBALS['TL_LANG']['tl_files']['htaccessInfo']);
}
return '
<div class="' . $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tl_class'] . ' cbx">
<div id="ctrl_' . $dc->field . '" class="tl_checkbox_single_container">
<input type="hidden" name="' . $dc->inputName . '" value=""><input type="checkbox" name="' . $dc->inputName . '" id="opt_' . $dc->field . '_0" class="tl_checkbox" value="1"' . ($blnProtected ? ' checked="checked"' : '') . ' onfocus="Backend.getScrollOffset()"> <label for="opt_' . $dc->field . '_0">' . $GLOBALS['TL_LANG']['tl_files']['protected'][0] . '</label>
</div>' . (Config::get('showHelp') ? '
<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_files']['protected'][1] . '</p>' : '') . '
</div>';
}
示例2: protect
/**
* Protect a folder
*/
public function protect()
{
if (!is_dir(TL_ROOT . '/' . $this->intId)) {
$this->log('Resource "' . $this->intId . '" is not a directory', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
// Remove the protection
if (file_exists(TL_ROOT . '/' . $this->intId . '/.htaccess')) {
$objFolder = new \Folder($this->intId);
$objFolder->unprotect();
$this->log('The protection from folder "' . $this->intId . '" has been removed', __METHOD__, TL_FILES);
$this->redirect($this->getReferer());
} else {
$objFolder = new \Folder($this->intId);
$objFolder->protect();
$this->log('Folder "' . $this->intId . '" has been protected', __METHOD__, TL_FILES);
$this->redirect($this->getReferer());
}
}
示例3: checkSyncCtoFolders
/**
* Create syncCto folders if not exists
*/
public function checkSyncCtoFolders()
{
$objFile = new Folder($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['tmp']));
$objFile = new Folder($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['db']));
$objFile->protect();
$objFile = new Folder($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['file']));
$objFile->protect();
}
示例4: protectFolder
/**
* Return a checkbox to delete session data
*
* @param DataContainer $dc
*
* @return string
*/
public function protectFolder(DataContainer $dc)
{
$count = 0;
$strPath = $dc->id;
// Check whether the temporary name has been replaced already (see #6432)
if (Input::post('name') && ($strNewPath = str_replace('__new__', Input::post('name'), $strPath, $count)) && $count > 0 && is_dir(TL_ROOT . '/' . $strNewPath)) {
$strPath = $strNewPath;
}
// Only show for folders (see #5660)
if (!is_dir(TL_ROOT . '/' . $strPath)) {
return '';
}
$blnPublic = file_exists(TL_ROOT . '/' . $strPath . '/.public');
// Protect or unprotect the folder
if (Input::post('FORM_SUBMIT') == 'tl_files') {
if (Input::post($dc->inputName)) {
if (!$blnPublic) {
$blnPublic = true;
$objFolder = new Folder($strPath);
$objFolder->unprotect();
$this->import('Automator');
$this->Automator->generateSymlinks();
}
} else {
if ($blnPublic) {
$blnPublic = false;
$objFolder = new Folder($strPath);
$objFolder->protect();
$this->import('Automator');
$this->Automator->generateSymlinks();
}
}
}
$class = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tl_class'] . ' cbx"';
if (Input::get('act') == 'editAll' || Input::get('act') == 'overrideAll') {
$class = str_replace(array('w50', 'clr', 'wizard', 'long', 'm12', 'cbx'), '', $class);
}
return '
<div class="' . $class . '">
<div id="ctrl_' . $dc->field . '" class="tl_checkbox_single_container">
<input type="hidden" name="' . $dc->inputName . '" value=""><input type="checkbox" name="' . $dc->inputName . '" id="opt_' . $dc->field . '_0" class="tl_checkbox" value="1"' . ($blnPublic ? ' checked="checked"' : '') . ' onfocus="Backend.getScrollOffset()"> <label for="opt_' . $dc->field . '_0">' . $GLOBALS['TL_LANG']['tl_files']['protected'][0] . '</label>
</div>' . (Config::get('showHelp') ? '
<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_files']['protected'][1] . '</p>' : '') . '
</div>';
}
示例5: purgeTempFolder
/**
* Purge the temporary directory
*/
public function purgeTempFolder()
{
$arrTmp = scan(TL_ROOT . '/system/tmp', true);
// Remove files
if (is_array($arrTmp)) {
foreach ($arrTmp as $strFile) {
if ($strFile != '.htaccess' && !is_dir(TL_ROOT . '/system/tmp/' . $strFile)) {
@unlink(TL_ROOT . '/system/tmp/' . $strFile);
}
}
}
// Check for .htaccess
if (!file_exists(TL_ROOT . '/system/tmp/.htaccess')) {
$objFolder = new Folder('system/tmp');
$objFolder->protect();
}
// Add log entry
$this->log('Purged the temporary directory', 'Automator purgeTempFolder()', TL_CRON);
}