Move router.php to root; use realpath for file refs

This commit is contained in:
Robbie Antenesse 2019-06-06 13:14:46 -06:00 committed by Robbie Antenesse
parent 41c6322477
commit 7c5c33c54f
2 changed files with 11 additions and 10 deletions

View File

@ -1,12 +1,12 @@
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^view/([0-9]+)/([0-9]+)/?$ api/router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids.
RewriteRule ^view/([0-9]+)/([0-9]+)/?$ router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids.
RewriteRule ^([0-9]+)/([0-9]+)/?$ api/router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids.
RewriteRule ^([0-9]+)/([0-9]+)/?$ router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids.
RewriteRule ^view/([0-9]+)/?$ api/router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids.
RewriteRule ^view/([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids.
RewriteRule ^([0-9]+)/?$ api/router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids.
RewriteRule ^([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids.
#RewriteRule ^issues/?$ https://github.com/Alamantus/Lexiconga/issues [R=301,L] # Shorten issues url.

View File

@ -1,12 +1,13 @@
<?php
require_once(realpath(dirname(__FILE__) . '/./api/Response.php'));
$view = isset($_GET['view']) ? $_GET['view'] : false;
switch ($view) {
case 'dictionary': {
$html = file_get_contents('../template-view.html');
$html = file_get_contents(realpath(dirname(__FILE__) . '/./template-view.html'));
$dict = isset($_GET['dict']) ? $_GET['dict'] : false;
if ($dict !== false) {
require_once('./Dictionary.php');
require_once(realpath(dirname(__FILE__) . '/./api/Dictionary.php'));
$dictionary = new Dictionary();
$dictionary_data = $dictionary->getPublicDictionaryDetails($dict);
if ($dictionary_data !== false) {
@ -22,16 +23,16 @@ switch ($view) {
$html = str_replace('{{public_name}}', 'Error', $html);
$html = str_replace('{{dict_json}}', '{"name": "Error:", "specification": "Dictionary Not Found", "words": []}', $html);
}
echo $html;
return Response::html($html);
}
break;
}
case 'word': {
$html = file_get_contents('../template-view.html');
$html = file_get_contents(realpath(dirname(__FILE__) . '/./template-view.html'));
$dict = isset($_GET['dict']) ? $_GET['dict'] : false;
$word = isset($_GET['word']) ? $_GET['word'] : false;
if ($dict !== false && $word !== false) {
require_once('./Dictionary.php');
require_once(realpath(dirname(__FILE__) . '/./api/Dictionary.php'));
$dictionary = new Dictionary();
$dictionary_data = $dictionary->getPublicDictionaryDetails($dict);
if ($dictionary_data !== false) {
@ -61,7 +62,7 @@ switch ($view) {
$html = str_replace('{{public_name}}', 'Error', $html);
$html = str_replace('{{dict_json}}', '{"name": "Error:", "specification": "Dictionary Not Found", "words": []}', $html);
}
echo $html;
return Response::html($html);
}
break;
}