Browse Source

Remove URL rewriting support in Movim

pull/90/head
Jaussoin Timothée 10 years ago
parent
commit
ca67e8965c
  1. 20
      .htaccess
  2. 4
      app/models/config/Config.php
  3. 5
      app/models/config/ConfigDAO.php
  4. 11
      app/widgets/AdminMain/AdminMain.php
  5. 26
      app/widgets/AdminMain/adminmain.tpl
  6. 4
      app/widgets/AdminMain/locales.ini
  7. 9
      app/widgets/AdminTest/admintest.tpl
  8. 1
      app/widgets/AdminTest/locales.ini
  9. 9
      app/widgets/Api/Api.php
  10. 7
      app/widgets/Infos/Infos.php
  11. 27
      system/Route.php

20
.htaccess

@ -1,22 +1,2 @@
Options -Indexes
AddType application/x-web-app-manifest+json .webapp
<IfModule mod_rewrite.c>
# Tell PHP that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE 1
# If you have troubles or use VirtualDocumentRoot
# uncomment this and set it to the path where your Movim installation is
# i.e.:
# Movim url: http://example.com
# RewriteBase /
# Movim url: http://some.example.com/movim
# RewriteBase /movim/
RewriteBase /0.9/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?query=$1 [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

4
app/models/config/Config.php

@ -14,7 +14,6 @@ class Config extends Model {
public $unregister;
public $username;
public $password;
public $rewrite;
public $sizelimit;
public function __construct() {
@ -42,8 +41,6 @@ class Config extends Model {
{"type":"string", "size":32, "mandatory":true },
"password" :
{"type":"string", "size":64, "mandatory":true },
"rewrite" :
{"type":"int", "size":1 },
"sizelimit" :
{"type":"int", "size":16 }
}';
@ -61,7 +58,6 @@ class Config extends Model {
$this->unregister = false;
$this->username = 'admin';
$this->password = sha1('password');
$this->rewrite = false;
$this->sizelimit = 20240001;
}
}

5
app/models/config/ConfigDAO.php

@ -17,7 +17,6 @@ class ConfigDAO extends SQL {
unregister = :unregister,
username = :username,
password = :password,
rewrite = :rewrite,
sizelimit = :sizelimit';
$this->prepare(
@ -34,7 +33,6 @@ class ConfigDAO extends SQL {
'unregister' => $c->unregister,
'username' => $c->username,
'password' => $c->password,
'rewrite' => $c->rewrite,
'sizelimit' => $c->sizelimit
)
);
@ -67,7 +65,6 @@ class ConfigDAO extends SQL {
unregister,
username,
password,
rewrite,
sizelimit
)
values
@ -83,7 +80,6 @@ class ConfigDAO extends SQL {
:unregister,
:username,
:password,
:rewrite,
:sizelimit
)
';
@ -102,7 +98,6 @@ class ConfigDAO extends SQL {
'unregister' => $c->unregister,
'username' => $c->username,
'password' => $c->password,
'rewrite' => $c->rewrite,
'sizelimit' => $c->sizelimit
)
);

11
app/widgets/AdminMain/AdminMain.php

@ -35,12 +35,6 @@ class AdminMain extends WidgetBase
unset($form['repassword']);
if(isset($form['rewrite']) && $form['rewrite'] == 'on') {
$form['rewrite'] = 1;
} else {
$form['rewrite'] = 0;
}
foreach($form as $key => $value) {
$config->$key = $value;
}
@ -92,11 +86,6 @@ class AdminMain extends WidgetBase
$this->view->assign('websockets', $json);
}
$this->view->assign('server_rewrite', false);
if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
$this->view->assign('server_rewrite', true);
}
$this->view->assign('timezones', getTimezoneList());
$this->view->assign('langs', $l->getList());
}

26
app/widgets/AdminMain/adminmain.tpl

@ -102,32 +102,6 @@
</li>
</ul>
{if="$server_rewrite"}
<br />
<h3>{$c->__('rewrite.title')}</h3>
<div>
<ul class="thick simple">
<li class="action">
<div class="control action">
<div class="checkbox">
<input
type="checkbox"
id="rewrite"
name="rewrite"
{if="$conf->rewrite"}
checked
{/if}>
<label for="rewrite"></label>
</div>
</div>
<span>{$c->__('rewrite.info')}</span>
</li>
</ul>
</div>
{/if}
<br />
<h3>{$c->__('credentials.title')}</h3>

4
app/widgets/AdminMain/locales.ini

@ -39,7 +39,3 @@ label = Information Message
empty = Empty
syslog = Syslog
syslog_files = Syslog and files
[rewrite]
title = URL Rewriting
info = The URL Rewriting can be enabled

9
app/widgets/AdminTest/admintest.tpl

@ -109,14 +109,5 @@
</li>
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!$_SERVER['HTTP_MOD_REWRITE']"}
<li>
<span class="icon bubble color orange">
<i class="zmdi zmdi-edit"></i>
</span>
<span>{$c->__('compatibility.rewrite')}</span>
</li>
{/if}
</ul>
</div>

1
app/widgets/AdminTest/locales.ini

@ -9,7 +9,6 @@ curl = Install the php5-curl library
imagick = Install the php5-imagick library
gd = Install the php5-gd library
rights = "Read and write rights for the webserver in Movims root directory"
rewrite = The URL Rewriting support is currently disabled
db = The database need to be updated, go to the database panel to fix this
websocket = WebSocket connection error, check if the Movim Daemon is running and is reachable
xmpp_websocket = XMPP Websocket connection error, please check the validity of the URL given in the General Configuration

9
app/widgets/Api/Api.php

@ -54,22 +54,15 @@ class Api extends WidgetBase {
function ajaxRegister()
{
$rewrite = false;
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($config->rewrite/*isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']*/) {
$rewrite = true;
}
$json = requestURL(
MOVIM_API.'register',
1,
array(
'uri' => BASE_URI,
'rewrite' => $rewrite));
'rewrite' => false));
$json = json_decode($json);

7
app/widgets/Infos/Infos.php

@ -36,12 +36,6 @@ class Infos extends WidgetBase
$sd = new \Modl\SessionxDAO();
// We see if we have the url rewriting
$rewrite = false;
if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
$rewrite = true;
}
$infos = array(
'url' => BASE_URI,
'language' => $config->locale,
@ -50,7 +44,6 @@ class Infos extends WidgetBase
'description' => $config->description,
'unregister' => $config->unregister,
'php_version' => phpversion(),
'rewrite' => $rewrite,
'version' => APP_VERSION,
'population' => $pop,
'connected' => $sd->getConnected()

27
system/Route.php

@ -34,22 +34,11 @@ class Route extends \BaseController {
public function find() {
$this->fix($_GET, $_SERVER['QUERY_STRING']);
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($config->rewrite == true
&& isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']) {
$request = explode('/', $this->fetchGet('query'));
$this->_page = $request[0];
array_shift($request);
} else {
$uri = reset(array_keys($_GET));
unset($_GET[$uri]);
$request = explode('/', $uri);
$uri = reset(array_keys($_GET));
unset($_GET[$uri]);
$request = explode('/', $uri);
$this->_page = array_shift($request);
}
$this->_page = array_shift($request);
if(isset($this->_routes[$this->_page]))
$route = $this->_routes[$this->_page];
@ -77,19 +66,13 @@ class Route extends \BaseController {
$r = new Route();
$routes = $r->_routes;
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($page === 'root')
return BASE_URI;
if(isset($routes[$page])) {
if($tab != false)
$tab = '#'.$tab;
// Here we got a beautiful rewriten URL !
if($config->rewrite == true) {
$uri = BASE_URI . $page;
}
//We construct a classic URL if the rewriting is disabled
else {
$uri = BASE_URI . '?'. $page;

Loading…
Cancel
Save