1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22: 23:
24: class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
25:
26: 27: 28: 29:
30: protected $_htaccessRestrictive = '';
31:
32: 33: 34: 35:
36: protected $_htaccessSimple = '';
37:
38: 39: 40:
41: public function init() {
42: $this->_oView->content_before = '';
43:
44: $pluginPath = $this->_cfg['path']['contenido'] . $this->_cfg['path']['plugins'] . 'mod_rewrite/';
45: $this->_htaccessRestrictive = $pluginPath . 'files/htaccess_restrictive.txt';
46: $this->_htaccessSimple = $pluginPath . 'files/htaccess_simple.txt';
47: }
48:
49: 50: 51:
52: public function indexAction() {
53: }
54:
55: 56: 57:
58: public function copyHtaccessAction() {
59: $type = $this->_getParam('htaccesstype');
60: $copy = $this->_getParam('copy');
61:
62: if ($type != 'restrictive' && $type != 'simple') {
63: return;
64: } elseif ($copy != 'contenido' && $copy != 'cms') {
65: return;
66: }
67:
68: $aInfo = $this->getProperty('htaccessInfo');
69:
70: if ($aInfo['has_htaccess']) {
71: $this->_oView->content_before = $this->_notifyBox('warning', i18n('.htaccess already exists at CONTENIDO-/or client directory, so it is not copied.', 'mod_rewrite'));
72: return;
73: }
74:
75: if ($type == 'restrictive') {
76: $source = $this->_htaccessRestrictive;
77: } else {
78: $source = $this->_htaccessSimple;
79: }
80:
81: if ($copy == 'contenido') {
82: $dest = $aInfo['contenido_full_path'] . '.htaccess';
83: } else {
84: $dest = $aInfo['client_full_path'] . '.htaccess';
85: }
86:
87: if (!$result = @copy($source, $dest)) {
88: $this->_oView->content_before = $this->_notifyBox('warning', sprintf(i18n('.htaccess could not copy from <strong>%s</strong> to <strong>%s</strong>! Perhaps the target directory has not the required rights to write files at your webserver.', 'mod_rewrite'), $source, $dest));
89: return;
90: }
91:
92: $msg = sprintf(i18n('.htaccess are successfully copied to %s', 'mod_rewrite'), str_replace('.htaccess', '', $dest));
93: $this->_oView->content_before = $this->_notifyBox('info', $msg);
94: }
95:
96: 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: 127: 128:
129: public function resetAction() {
130:
131: ModRewrite::recreateAliases(false);
132: $this->_oView->content_before = $this->_notifyBox('info', i18n('All aliases have been reset.', 'mod_rewrite'));
133: }
134:
135: 136: 137: 138: 139: 140:
141: public function resetEmptyAction() {
142:
143: ModRewrite::recreateAliases(true);
144: $this->_oView->content_before = $this->_notifyBox('info', i18n('Only empty aliases have been reset.', 'mod_rewrite'));
145: }
146:
147: }
148: