1: <?php
  2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14: 
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: 
 19:  20:  21:  22:  23:  24:  25: 
 26: class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
 27: 
 28:      29:  30:  31: 
 32:     protected $_htaccessRestrictive = '';
 33: 
 34:      35:  36:  37: 
 38:     protected $_htaccessSimple = '';
 39: 
 40:      41:  42: 
 43:     public function init() {
 44:         $this->_oView->content_before = '';
 45: 
 46:         $pluginPath = $this->_cfg['path']['contenido'] . $this->_cfg['path']['plugins'] . 'mod_rewrite/';
 47:         $this->_htaccessRestrictive = $pluginPath . 'files/htaccess_restrictive.txt';
 48:         $this->_htaccessSimple = $pluginPath . 'files/htaccess_simple.txt';
 49:     }
 50: 
 51:      52:  53: 
 54:     public function indexAction() {
 55: 
 56:     }
 57: 
 58:      59:  60: 
 61:     public function copyHtaccessAction() {
 62:         $type = $this->_getParam('htaccesstype');
 63:         $copy = $this->_getParam('copy');
 64: 
 65:         if ($type != 'restrictive' && $type != 'simple') {
 66:             return;
 67:         } elseif ($copy != 'contenido' && $copy != 'cms') {
 68:             return;
 69:         }
 70: 
 71:         $aInfo = $this->getProperty('htaccessInfo');
 72: 
 73:         if ($aInfo['has_htaccess']) {
 74:             $this->_oView->content_before = $this->_notifyBox('info', 'Die .htaccess existiert bereits im Contenido-/ oder Mandantenverzeichnis, daher wird es nicht kopiert');
 75:             return;
 76:         }
 77: 
 78:         if ($type == 'restrictive') {
 79:             $source = $this->_htaccessRestrictive;
 80:         } else {
 81:             $source = $this->_htaccessSimple;
 82:         }
 83: 
 84:         if ($copy == 'contenido') {
 85:             $dest = $aInfo['contenido_full_path'] . '.htaccess';
 86:         } else {
 87:             $dest = $aInfo['client_full_path'] . '.htaccess';
 88:         }
 89: 
 90:         if (!$result = @copy($source, $dest)) {
 91:             $this->_oView->content_before = $this->_notifyBox('info', 'Die .htaccess konnte nicht von ' . $source . ' nach ' . $dest . ' kopiert werden!');
 92:             return;
 93:         }
 94: 
 95:         $msg = 'Die .htaccess wurde erfolgreich nach ' . str_replace('.htaccess', '', $dest) . ' kopiert';
 96:         $this->_oView->content_before = $this->_notifyBox('info', $msg);
 97:     }
 98: 
 99:     100: 101: 
102:     public function downloadHtaccessAction() {
103:         $type = $this->_getParam('htaccesstype');
104: 
105:         if ($type != 'restrictive' && $type != 'simple') {
106:             return;
107:         }
108: 
109:         if ($type == 'restrictive') {
110:             $source = $this->_htaccessRestrictive;
111:         } else {
112:             $source = $this->_htaccessSimple;
113:         }
114: 
115:         $this->_oView->content = cFileHandler::read($source);
116: 
117:         header('Content-Type: text/plain');
118:         header('Etag: ' . md5(mt_rand()));
119:         header('Content-Disposition: attachment; filename="' . $type . '.htaccess"');
120:         $this->render('{CONTENT}');
121:     }
122: 
123:     124: 125: 
126:     public function resetAction() {
127:         
128:         ModRewrite::recreateAliases(false);
129:         $this->_oView->content_before = $this->_notifyBox('info', 'Alle Aliase wurden zurückgesetzt');
130:     }
131: 
132:     133: 134: 
135:     public function resetEmptyAction() {
136:         
137:         ModRewrite::recreateAliases(true);
138:         $this->_oView->content_before = $this->_notifyBox('info', 'Nur leere Aliase wurden zurückgesetzt');
139:     }
140: 
141: }
142: