BIOS
ಠ‿ಠ
- Apr 25, 2012
- 906
- 247
Nano is a lightweight, clean & fast Content Management System (CMS) which follows the MVC architecure and is based on a modern, stable and extensible base.
Features:
- Secure - Prepared statements, validated data & sanitized output, CSRF protection (A secure token is generated and restricted, can only be used for the form which it was generated for & only valid for one use), Bot/brute-force protection (A user can only attempt to login once every so interval otherwise a short suspension will be given which isn't really recognizable to legitimate users but will have a big impact on bots, also uses Google reCaptcha for registration and such), secure password hashing, protection for session-based attacks, click-jacking protection, plus other useful basic measures.
- Native language system - No requests to external services, all major site content can be modified on a per language level.
- Session manager - A very simple and clean wrapper to interact with session data.
- Extensions - Easily add extensions to the CMS and utilize functionality on either a global scale or per request.
- Themes - Multiple theme support, all functionality will be available regardless of theme in-use as this logic is separated and maintained.
- Advanced logging - Extremely useful logging, error/warning/notice stack traces will be logged to a local file and the user will be displayed a friendly message.
- Events - Trigger & fire user defined callback events, useful for things like proxy/ban checking.
- Base functionality - Routing, user system, language system, error/success flash messages + more.
- Articles - Toggle categories, likes, responses.
- Mail integration - Can be used to send account activation/forgot password e-mails to users.
- Logging system - Can be used to log errors/warnings of the CMS or even log misc information such as attack attempts or visits to certain pages containing useful information of the request such as user agent, IP, time, etc.
- Various pages - A number of pages have been implemented such as me, account settings, articles, staff and client.
PHP:
/**
* [authenticate is a function to validate user credentials]
* @param string $username [The username to attempt]
* @param string $password [The password to attempt]
* @return bool [Whether or not the combination was correct]
*/
public function authenticate(string $username, string $password): bool {
if($this->usernameTaken($username)){
$hash = $this->engine->fetch("SELECT password FROM users WHERE username = ?", array($username))->password;
if($this->secure->basicVerify($password, $hash)){
return true;
}else{
$this->session->increment('security', 'attempts');
$this->session->set('time', time(), 'security');
return false;
}
}else{
return false;
}
}
/**
* [usernameTaken is a function to check if a username is in-use]
* @param string $username [The username to check]
* @return bool [Whether or not the username is in-use]
*/
public function usernameTaken(string $username): bool {
$checkUsername = $this->engine->fetch("SELECT null FROM users WHERE username = ?", array($username));
if($checkUsername){
return true;
}else{
return false;
}
/**
* [getStaff is a function to get the list of staff members]
* @return array [All staff ranks and their respective members]
*/
public function getStaff(){
$ranks = \Flight::engine()->fetchAll(
"SELECT
r.id, r.name
FROM
ranks r
CROSS JOIN
site_permissions p
WHERE
p.permission = ?
AND
r.id >= p.min_rank
ORDER BY
r.id
DESC",
array('display_staff')
);
$rank = [];
foreach($ranks as $r){
$staff = \Flight::engine()->fetchAll("SELECT id, username, motto, look, online FROM users WHERE rank = ?", array($r->id));
$rank[$r->name] = $staff;
}
return $rank;
}
PHP:
namespace Acme\Controllers;
use Library\Extensions\{IndexUserMessage, Ext};
class IndexController extends Controller {
public function __construct(){
parent::__construct();
self::$event->register('checkBan');
self::$event->fire();
}
public static function show(){
if(!self::$user->active()){
return \Flight::view()->display('index.tpl', [
'error' => self::$session->getFlash('error'),
'success' => self::$session->getFlash('success'),
'form_token_login' => self::$secure->macGenerate('/'),
'locale' => self::$locale->get('index')
]);
}else{
\Flight::redirect('me');
exit();
}
}
}
Libraries currently in use: Mailgun, Twig, Flight, and Monolog.
Credits:
Geo - Developer
@Brought & @Sex - Moral support
@cammex - Cammex theme (Default theme I used to develop alongside Nano)
Last edited: