Пример #1
0
 /**
  * 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());
     }
 }
Пример #2
0
    /**
     * 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>';
    }
Пример #3
0
    /**
     * 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>';
    }