made a start
This commit is contained in:
parent
264fe683d5
commit
01f162945c
11 changed files with 100 additions and 194 deletions
24
libraries/Controllers/Auth.php
Normal file
24
libraries/Controllers/Auth.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the auth controllers.
|
||||||
|
*
|
||||||
|
* @package Sakura
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Sakura\Controllers;
|
||||||
|
|
||||||
|
use Sakura\Template;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication controllers.
|
||||||
|
*
|
||||||
|
* @package Sakura
|
||||||
|
* @author Julian van de Groep <me@flash.moe>
|
||||||
|
*/
|
||||||
|
class Auth
|
||||||
|
{
|
||||||
|
public static function login()
|
||||||
|
{
|
||||||
|
return Template::render('main/login');
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,23 +62,23 @@ class Urls
|
||||||
'/faq',
|
'/faq',
|
||||||
],
|
],
|
||||||
'SITE_LOGIN' => [
|
'SITE_LOGIN' => [
|
||||||
'/authenticate.php',
|
'/authenticate.php?ref=login',
|
||||||
'/login',
|
'/login',
|
||||||
],
|
],
|
||||||
'SITE_LOGOUT' => [
|
'SITE_LOGOUT' => [
|
||||||
'/authenticate.php',
|
'/authenticate.php?ref=logout',
|
||||||
'/logout',
|
'/logout',
|
||||||
],
|
],
|
||||||
'SITE_REGISTER' => [
|
'SITE_REGISTER' => [
|
||||||
'/authenticate.php',
|
'/authenticate.php?ref=register',
|
||||||
'/register',
|
'/register',
|
||||||
],
|
],
|
||||||
'SITE_FORGOT_PASSWORD' => [
|
'SITE_FORGOT_PASSWORD' => [
|
||||||
'/authenticate.php',
|
'/authenticate.php?ref=forgotpassword',
|
||||||
'/forgotpassword',
|
'/forgotpassword',
|
||||||
],
|
],
|
||||||
'SITE_ACTIVATE' => [
|
'SITE_ACTIVATE' => [
|
||||||
'/authenticate.php',
|
'/authenticate.php?ref=activate',
|
||||||
'/activate',
|
'/activate',
|
||||||
],
|
],
|
||||||
'INFO_PAGE' => [
|
'INFO_PAGE' => [
|
||||||
|
|
|
@ -1,75 +1,20 @@
|
||||||
# Set Error documents
|
<IfModule mod_rewrite.c>
|
||||||
ErrorDocument 404 /404.php
|
<IfModule mod_negotiation.c>
|
||||||
ErrorDocument 403 /404.php
|
Options -MultiViews
|
||||||
ErrorDocument 401 /404.php
|
</IfModule>
|
||||||
|
|
||||||
# Rewrite Stuff
|
RewriteEngine On
|
||||||
RewriteEngine on
|
|
||||||
RewriteBase /
|
|
||||||
Options +FollowSymLinks -Indexes
|
|
||||||
|
|
||||||
# Rewrite Rules
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
RewriteRule ^login/?$|^logout/?$|^activate/?$|^register/?$|^forgotpassword/?|^authenticate/?$ authenticate.php [L,QSA]
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteRule ^support/?$ support.php [L,QSA]
|
RewriteRule ^(.*)/$ /$1 [L,R=301]
|
||||||
RewriteRule ^support/tracker/?$ support.php?tracker=true [L,QSA]
|
|
||||||
RewriteRule ^faq/?$ faq.php [L,QSA]
|
|
||||||
RewriteRule ^search/?$ search.php [L,QSA]
|
|
||||||
|
|
||||||
# Info pages
|
# Handle Front Controller...
|
||||||
RewriteRule ^p/([a-z]+)/?$ index.php?p=$1 [L,QSA]
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
|
||||||
# News
|
# Handle Authorization Header
|
||||||
RewriteRule ^news/?$ news.php [L,QSA]
|
RewriteCond %{HTTP:Authorization} .
|
||||||
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [L,QSA]
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
RewriteRule ^news/([a-z\-]+)/?$ news.php?cat=$1 [L,QSA]
|
</IfModule>
|
||||||
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]
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
|
|
||||||
RewriteRule ^(.*)$ api.php [QSA,L]
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
* Sakura API
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Declare Namespace
|
|
||||||
namespace Sakura;
|
|
||||||
|
|
||||||
// Define that this page won't require templating
|
|
||||||
define('SAKURA_NO_TPL', true);
|
|
||||||
|
|
||||||
// Include components
|
|
||||||
require_once str_replace(basename(__DIR__), '../', dirname(__FILE__)) . 'sakura.php';
|
|
||||||
|
|
||||||
// Change to content type to text/plain and set the charset to UTF-8
|
|
||||||
header('Content-Type: text/plain; charset=utf-8');
|
|
||||||
|
|
||||||
// Trim leading slashes
|
|
||||||
$path = ltrim($_SERVER['REQUEST_URI'], '/');
|
|
||||||
|
|
||||||
// Explode the elements
|
|
||||||
$elems = explode('/', $path);
|
|
||||||
|
|
||||||
// Correct the path if mod_rewrite isn't used
|
|
||||||
if ($elems[0] == explode('/', ltrim($_SERVER['PHP_SELF'], '/'))[0]) {
|
|
||||||
// Remove the entry
|
|
||||||
unset($elems[0]);
|
|
||||||
|
|
||||||
// Resort the array
|
|
||||||
$elems = array_values($elems);
|
|
||||||
|
|
||||||
// Make sure there's at least one entry (even if empty)
|
|
||||||
if (!isset($elems[0])) {
|
|
||||||
$elems[] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the GET requests aren't present in the last entry
|
|
||||||
if (strpos($elems[max(array_keys($elems))], '?')) {
|
|
||||||
// If there are cut them all
|
|
||||||
$elems[max(array_keys($elems))] = strstr($elems[max(array_keys($elems))], '?', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Predefine the return variable
|
|
||||||
$return = [];
|
|
||||||
|
|
||||||
// Select API version
|
|
||||||
switch (isset($elems[0]) ? $elems[0] : false) {
|
|
||||||
// API Version 1
|
|
||||||
case 'v1':
|
|
||||||
switch (isset($elems[1]) ? $elems[1] : false) {
|
|
||||||
// Authentication
|
|
||||||
case 'authenticate':
|
|
||||||
switch (isset($elems[2]) ? $elems[2] : false) {
|
|
||||||
case 'login':
|
|
||||||
$return = ['success' => '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));
|
|
|
@ -257,7 +257,7 @@ a.default:active {
|
||||||
.viewforum .head,
|
.viewforum .head,
|
||||||
.viewtopic .head,
|
.viewtopic .head,
|
||||||
.posting .head,
|
.posting .head,
|
||||||
.loginPage > .loginCont .head,
|
.loginPage .head,
|
||||||
.messages .head {
|
.messages .head {
|
||||||
margin: -1px -2px;
|
margin: -1px -2px;
|
||||||
padding: 4px 5px 5px;
|
padding: 4px 5px 5px;
|
||||||
|
@ -269,8 +269,7 @@ a.default:active {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-right .head,
|
.content-right .head {
|
||||||
.loginPage > .registerCont .head {
|
|
||||||
margin: -1px -2px -1px;
|
margin: -1px -2px -1px;
|
||||||
padding: 4px 5px 5px;
|
padding: 4px 5px 5px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
@ -792,8 +791,7 @@ a.default:active {
|
||||||
max-width: 825px;
|
max-width: 825px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loginPage > .registerCont > *,
|
.loginPage > * {
|
||||||
.loginPage > .loginCont > * {
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
padding: 2px 3px;
|
padding: 2px 3px;
|
||||||
|
@ -805,32 +803,9 @@ a.default:active {
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 430px) {
|
@media (max-width: 430px) {
|
||||||
|
.loginPage > * {
|
||||||
.loginPage > .registerCont > *,
|
|
||||||
.loginPage > .loginCont > * {
|
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginPage > .loginCont {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginPage > .registerCont {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 820px) {
|
|
||||||
|
|
||||||
.loginPage > .loginCont {
|
|
||||||
float: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginPage > .registerCont {
|
|
||||||
float: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loginPage .head {
|
.loginPage .head {
|
||||||
|
|
|
@ -12,6 +12,9 @@ Router::get('/faq', 'Sakura\Controllers\Meta@faq', 'main.faq');
|
||||||
Router::get('/search', 'Sakura\Controllers\Meta@search', 'main.search');
|
Router::get('/search', 'Sakura\Controllers\Meta@search', 'main.search');
|
||||||
Router::get('/p/{id}', 'Sakura\Controllers\Meta@infoPage', 'main.infopage');
|
Router::get('/p/{id}', 'Sakura\Controllers\Meta@infoPage', 'main.infopage');
|
||||||
|
|
||||||
|
// Auth
|
||||||
|
Router::get('/login', 'Sakura\Controllers\Auth@login', 'auth.login');
|
||||||
|
|
||||||
// News
|
// News
|
||||||
Router::get('/news', 'Sakura\Controllers\Meta@news', 'news.index');
|
Router::get('/news', 'Sakura\Controllers\Meta@news', 'news.index');
|
||||||
Router::get('/news/{category}', 'Sakura\Controllers\Meta@news', 'news.category');
|
Router::get('/news/{category}', 'Sakura\Controllers\Meta@news', 'news.category');
|
||||||
|
|
|
@ -59,6 +59,7 @@ require_once ROOT . 'libraries/Users.php';
|
||||||
require_once ROOT . 'libraries/Utils.php';
|
require_once ROOT . 'libraries/Utils.php';
|
||||||
require_once ROOT . 'libraries/Whois.php';
|
require_once ROOT . 'libraries/Whois.php';
|
||||||
require_once ROOT . 'libraries/Console/Application.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/Forums.php';
|
||||||
require_once ROOT . 'libraries/Controllers/Meta.php';
|
require_once ROOT . 'libraries/Controllers/Meta.php';
|
||||||
require_once ROOT . 'libraries/Controllers/User.php';
|
require_once ROOT . 'libraries/Controllers/User.php';
|
||||||
|
|
|
@ -159,6 +159,7 @@
|
||||||
{% if sakura.lockAuth %}
|
{% if sakura.lockAuth %}
|
||||||
<div class="menu-item fa-lock" style="padding-left: 10px; padding-right: 10px;" title="Authentication is locked"></div>
|
<div class="menu-item fa-lock" style="padding-left: 10px; padding-right: 10px;" title="Authentication is locked"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<a class="menu-item fa-magic" href="{{ urls.format('SITE_REGISTER') }}" title="Login"></a>
|
||||||
<a class="menu-item fa-sign-in" href="{{ urls.format('SITE_LOGIN') }}" title="Login"></a>
|
<a class="menu-item fa-sign-in" href="{{ urls.format('SITE_LOGIN') }}" title="Login"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Authentication is currently disallowed, try again later.</h1>
|
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Authentication is currently disallowed, try again later.</h1>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="loginPage">
|
<div class="loginPage">
|
||||||
<div class="loginCont">
|
|
||||||
<div class="loginForm">
|
<div class="loginForm">
|
||||||
<div class="head">
|
<div class="head">
|
||||||
Login to {{ sakura.siteName }}
|
Login to {{ sakura.siteName }}
|
||||||
|
@ -65,8 +64,6 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="registerCont">
|
|
||||||
<div class="registerForm">
|
<div class="registerForm">
|
||||||
<div class="head">
|
<div class="head">
|
||||||
Register on {{ sakura.siteName }}
|
Register on {{ sakura.siteName }}
|
||||||
|
@ -177,8 +174,6 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
41
templates/yuuno/main/login.twig
Normal file
41
templates/yuuno/main/login.twig
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{% extends 'global/master.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Authentication{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if sakura.lockAuth %}
|
||||||
|
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Authentication is currently disallowed, try again later.</h1>
|
||||||
|
{% else %}
|
||||||
|
<div class="loginPage">
|
||||||
|
<div class="loginForm">
|
||||||
|
<div class="head">
|
||||||
|
Login to {{ sakura.siteName }}
|
||||||
|
</div>
|
||||||
|
<form method="post" action="{{ urls.format('AUTH_ACTION') }}" id="loginForm">
|
||||||
|
<input type="hidden" name="redirect" value="{{ auth.redirect }}" />
|
||||||
|
<input type="hidden" name="session" value="{{ php.sessionid }}" />
|
||||||
|
<input type="hidden" name="time" value="{{ php.time }}" />
|
||||||
|
<input type="hidden" name="mode" value="login" />
|
||||||
|
<div class="leftAlign">
|
||||||
|
<label for="loginUserName">Username:</label>
|
||||||
|
</div>
|
||||||
|
<div class="centreAlign">
|
||||||
|
<input class="inputStyling" type="text" id="loginUserName" name="username" autofocus="true" />
|
||||||
|
</div>
|
||||||
|
<div class="leftAlign">
|
||||||
|
<label for="loginPassword">Password:</label>
|
||||||
|
</div>
|
||||||
|
<div class="centreAlign">
|
||||||
|
<input class="inputStyling" type="password" id="loginPassword" name="password" />
|
||||||
|
</div>
|
||||||
|
<div class="subLinks centreAlign">
|
||||||
|
<input class="inputStyling" name="remember" type="checkbox" class="ignore-css" id="loginRemember" /><label for="loginRemember">Remember Me</a>
|
||||||
|
</div>
|
||||||
|
<div class="centreAlign">
|
||||||
|
<input class="inputStyling" type="submit" id="loginButton" name="submit" value="Login" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
Reference in a new issue