/** * 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>'; }
/** * 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()); } }
/** * 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(); }
/** * 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>'; }
/** * 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); }