diff --git a/libraries/Controllers/Auth.php b/libraries/Controllers/Auth.php new file mode 100644 index 0000000..f5f1c09 --- /dev/null +++ b/libraries/Controllers/Auth.php @@ -0,0 +1,24 @@ + + */ +class Auth +{ + public static function login() + { + return Template::render('main/login'); + } +} diff --git a/libraries/Urls.php b/libraries/Urls.php index 2d08f16..bead7c9 100644 --- a/libraries/Urls.php +++ b/libraries/Urls.php @@ -1,7 +1,7 @@ */ @@ -19,7 +19,7 @@ class Urls * Unformatted links * 0 - Plain * 1 - mod_rewrite - * + * * @var array */ protected $urls = [ @@ -62,23 +62,23 @@ class Urls '/faq', ], 'SITE_LOGIN' => [ - '/authenticate.php', + '/authenticate.php?ref=login', '/login', ], 'SITE_LOGOUT' => [ - '/authenticate.php', + '/authenticate.php?ref=logout', '/logout', ], 'SITE_REGISTER' => [ - '/authenticate.php', + '/authenticate.php?ref=register', '/register', ], 'SITE_FORGOT_PASSWORD' => [ - '/authenticate.php', + '/authenticate.php?ref=forgotpassword', '/forgotpassword', ], 'SITE_ACTIVATE' => [ - '/authenticate.php', + '/authenticate.php?ref=activate', '/activate', ], 'INFO_PAGE' => [ @@ -294,11 +294,11 @@ class Urls /** * Format a URL. - * + * * @param string $lid The ID of a URL. * @param array $args Additional arguments. * @param bool $rewrite Toggle mod_rewrite. - * + * * @return null|string The formatted URL. */ public function format($lid, $args = [], $rewrite = null) diff --git a/public/.htaccess b/public/.htaccess index eb3ec8e..903f639 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,75 +1,20 @@ -# Set Error documents -ErrorDocument 404 /404.php -ErrorDocument 403 /404.php -ErrorDocument 401 /404.php + + + Options -MultiViews + -# Rewrite Stuff -RewriteEngine on -RewriteBase / -Options +FollowSymLinks -Indexes + RewriteEngine On -# Rewrite Rules -RewriteRule ^login/?$|^logout/?$|^activate/?$|^register/?$|^forgotpassword/?|^authenticate/?$ authenticate.php [L,QSA] -RewriteRule ^support/?$ support.php [L,QSA] -RewriteRule ^support/tracker/?$ support.php?tracker=true [L,QSA] -RewriteRule ^faq/?$ faq.php [L,QSA] -RewriteRule ^search/?$ search.php [L,QSA] + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] -# Info pages -RewriteRule ^p/([a-z]+)/?$ index.php?p=$1 [L,QSA] + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] -# News -RewriteRule ^news/?$ news.php [L,QSA] -RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [L,QSA] -RewriteRule ^news/([a-z\-]+)/?$ news.php?cat=$1 [L,QSA] -RewriteRule ^news/([a-z\-]+)/([0-9]+)/?$ news.php?cat=$1&id=$2 [L,QSA] -RewriteRule ^news.xml$ news.php?xml [L,QSA] - -# Settings -RewriteRule ^settings/?$ settings.php [L,QSA] -RewriteRule ^settings/([a-z]+)/?$ settings.php?cat=$1 [L,QSA] -RewriteRule ^settings/([a-z]+)/([a-z]+)/?$ settings.php?cat=$1&mode=$2 [L,QSA] -RewriteRule ^friends/?$ settings.php?friend-action=true [L,QSA] -RewriteRule ^notifications/?$ settings.php?request-notifications=true [L,QSA] -RewriteRule ^comments/?$ settings.php?comment-action=true [L,QSA] - -# Members -RewriteRule ^members/?$ members.php [L,QSA] -RewriteRule ^members/([a-z]+)/?$ members.php?sort=$1 [L,QSA] -RewriteRule ^members/([0-9]+)/?$ members.php?rank=$1 [L,QSA] -RewriteRule ^members/([a-z]+)/([0-9]+)/?$ members.php?sort=$1&rank=$2 [L,QSA] - -# Profiles -RewriteRule ^u/?$ profile.php [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/?$ profile.php?u=$1 [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/header/?$ imageserve.php?m=header&u=$1 [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/comments/?$ profile.php?u=$1&view=comments [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/groups/?$ profile.php?u=$1&view=groups [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/friends/?$ profile.php?u=$1&view=friends [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/threads/?$ profile.php?u=$1&view=threads [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/posts/?$ profile.php?u=$1&view=posts [L,QSA] -RewriteRule ^u/([A-Za-z0-9\_\-\s\.]+)/report/?$ report.php?mode=user&id=$1 [L,QSA] - -# Groups -RewriteRule ^g/?$ group.php [L,QSA] -RewriteRule ^g/([0-9]+)/?$ group.php?g=$1 [L,QSA] - -# Serving Images -RewriteRule ^a/([0-9]+)$|a/([0-9]+).png$ imageserve.php?m=avatar&u=$1 [L,QSA] -RewriteRule ^bg/([0-9]+)$|bg/([0-9]+).png$ imageserve.php?m=background&u=$1 [L,QSA] - -# Forum -RewriteRule ^forum/?$ index.php?forum=true [L,QSA] -RewriteRule ^forum/([0-9]+)/?$ viewforum.php?f=$1 [L,QSA] -RewriteRule ^forum/([0-9]+)/new/?$ posting.php?f=$1 [L,QSA] -RewriteRule ^forum/(thread|topic|[0-9+])/([0-9]+)/?$ viewtopic.php?t=$2 [L,QSA] -RewriteRule ^forum/(thread|topic|[0-9+])/([0-9]+)/reply/?$ posting.php?t=$2 [L,QSA] -RewriteRule ^forum/post/([0-9]+)/?$ viewtopic.php?p=$1 [L,QSA] -RewriteRule ^forum/post/([0-9]+)/edit/?$ posting.php?p=$1&edit=$1 [L,QSA] -RewriteRule ^forum/post/([0-9]+)/delete/?$ posting.php?p=$1&delete=$1 [L,QSA] -RewriteRule ^forum/post/([0-9]+)/(quote|reply)/?$ posting.php?p=$1"e=$1 [L,QSA] - -# Management -RewriteRule ^manage/?$ manage.php [L,QSA] -RewriteRule ^manage/([a-z\-]+)/?$ manage.php?cat=$1 [L,QSA] -RewriteRule ^manage/([a-z\-]+)/([a-z\-]+)/?$ manage.php?cat=$1&mode=$2 [L,QSA] + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + diff --git a/public/api/.htaccess b/public/api/.htaccess deleted file mode 100644 index 3511200..0000000 --- a/public/api/.htaccess +++ /dev/null @@ -1,5 +0,0 @@ -RewriteEngine On - -RewriteCond %{REQUEST_FILENAME} !-f - -RewriteRule ^(.*)$ api.php [QSA,L] diff --git a/public/api/api.php b/public/api/api.php deleted file mode 100644 index e3a1de1..0000000 --- a/public/api/api.php +++ /dev/null @@ -1,74 +0,0 @@ - 'LOGIN_PROCESS_HERE']; - break; - - default: - $return = ['error' => ['NO_DATA_REQ']]; - } - break; - - default: - $return = ['error' => ['NO_DATA_REQ']]; - } - break; - - // Default fallback - default: - $return = ['error' => ['NO_API_VERSION']]; -} - -echo json_encode($return, (isset($_GET['pretty']) ? JSON_PRETTY_PRINT : 0)); diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 823efe1..09d4f38 100644 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -257,7 +257,7 @@ a.default:active { .viewforum .head, .viewtopic .head, .posting .head, -.loginPage > .loginCont .head, +.loginPage .head, .messages .head { margin: -1px -2px; padding: 4px 5px 5px; @@ -269,8 +269,7 @@ a.default:active { word-wrap: break-word; } -.content-right .head, -.loginPage > .registerCont .head { +.content-right .head { margin: -1px -2px -1px; padding: 4px 5px 5px; font-weight: 700; @@ -792,8 +791,7 @@ a.default:active { max-width: 825px; } -.loginPage > .registerCont > *, -.loginPage > .loginCont > * { +.loginPage > * { text-align: center; margin: 10px auto; padding: 2px 3px; @@ -805,32 +803,9 @@ a.default:active { } @media (max-width: 430px) { - - .loginPage > .registerCont > *, - .loginPage > .loginCont > * { + .loginPage > * { width: 300px; } - -} - -.loginPage > .loginCont { - float: left; -} - -.loginPage > .registerCont { - float: right; -} - -@media (max-width: 820px) { - - .loginPage > .loginCont { - float: none; - } - - .loginPage > .registerCont { - float: none; - } - } .loginPage .head { diff --git a/routes.php b/routes.php index 968292c..fa6f415 100644 --- a/routes.php +++ b/routes.php @@ -12,6 +12,9 @@ Router::get('/faq', 'Sakura\Controllers\Meta@faq', 'main.faq'); Router::get('/search', 'Sakura\Controllers\Meta@search', 'main.search'); Router::get('/p/{id}', 'Sakura\Controllers\Meta@infoPage', 'main.infopage'); +// Auth +Router::get('/login', 'Sakura\Controllers\Auth@login', 'auth.login'); + // News Router::get('/news', 'Sakura\Controllers\Meta@news', 'news.index'); Router::get('/news/{category}', 'Sakura\Controllers\Meta@news', 'news.category'); diff --git a/sakura.php b/sakura.php index 2a8be6d..8aa1d7f 100644 --- a/sakura.php +++ b/sakura.php @@ -59,6 +59,7 @@ require_once ROOT . 'libraries/Users.php'; require_once ROOT . 'libraries/Utils.php'; require_once ROOT . 'libraries/Whois.php'; require_once ROOT . 'libraries/Console/Application.php'; +require_once ROOT . 'libraries/Controllers/Auth.php'; require_once ROOT . 'libraries/Controllers/Forums.php'; require_once ROOT . 'libraries/Controllers/Meta.php'; require_once ROOT . 'libraries/Controllers/User.php'; diff --git a/templates/yuuno/global/master.twig b/templates/yuuno/global/master.twig index ce89746..c60d500 100644 --- a/templates/yuuno/global/master.twig +++ b/templates/yuuno/global/master.twig @@ -159,6 +159,7 @@ {% if sakura.lockAuth %} {% else %} + {% endif %} {% endif %} diff --git a/templates/yuuno/main/authenticate.twig b/templates/yuuno/main/authenticate.twig index c95779f..a4eb7a6 100644 --- a/templates/yuuno/main/authenticate.twig +++ b/templates/yuuno/main/authenticate.twig @@ -7,7 +7,6 @@

Authentication is currently disallowed, try again later.

{% else %}
-
Login to {{ sakura.siteName }} @@ -65,8 +64,6 @@
-
-
Register on {{ sakura.siteName }} @@ -177,8 +174,6 @@
{% endif %} -
-
{% endif %} {% endblock %} diff --git a/templates/yuuno/main/login.twig b/templates/yuuno/main/login.twig new file mode 100644 index 0000000..f9303e3 --- /dev/null +++ b/templates/yuuno/main/login.twig @@ -0,0 +1,41 @@ +{% extends 'global/master.twig' %} + +{% block title %}Authentication{% endblock %} + +{% block content %} + {% if sakura.lockAuth %} +

Authentication is currently disallowed, try again later.

+ {% else %} +
+
+
+ Login to {{ sakura.siteName }} +
+
+ + + + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+
+
+ {% endif %} +{% endblock %}