Browse Source

Login & logos

Giancarlo Voci 8 years ago
parent
commit
6a46b38433

+ 1 - 0
.gitignore

@@ -43,6 +43,7 @@ Thumbs.db
 # FOLDER TOOLS
 # FOLDER TOOLS
 vendor
 vendor
 node_modules
 node_modules
+tmp
 
 
 # Custom for current project
 # Custom for current project
 assets
 assets

+ 5 - 5
composer.json

@@ -1,7 +1,7 @@
 {
 {
-    "name": "openmind/lamborghini",
-    "type": "project",
-    "require": {
-        "bcosca/fatfree": "^3.6"
-    }
+  "name": "openmind/lamborghini",
+  "type": "project",
+  "require": {
+    "bcosca/fatfree": "^3.6"
+  }
 }
 }

+ 13 - 0
config.ini

@@ -0,0 +1,13 @@
+[globals]
+AUTOLOAD="src/"
+BASEURL = /lamborghini
+;CACHE = "folder=cache/"
+CACHE = false
+CACHE_TTL = 1
+SITENAME = OM-Link Lamborghini
+UI = ui/
+DEBUG = 3
+ENCODING = "UTF-8"
+HIGHLIGHT = false
+JAR.expire = {{time()+31536000}}
+PASSWORD=$2y$10$bW64jQ6UHFiYskofQD29Ku.5dggO5OAS08SgK/BUU50EBb4AQ/T6S

+ 0 - 10
index.htm.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>Title</title>
-</head>
-<body>
-
-</body>
-</html>

+ 32 - 0
index.php

@@ -0,0 +1,32 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 09/04/2018
+ * @time 11:33
+ */
+
+//error_reporting(E_ALL);
+
+require 'vendor/autoload.php';
+require_once 'uglify.php';
+
+$f3 = \Base::instance();
+
+$f3->config('config.ini', true);
+
+
+// Minify
+$f3->route('GET /assets/bundle.css', "UglifyCSS", $f3->get('CACHE_TTL'));
+$f3->route('GET /assets/bundle.js', "UglifyJS", $f3->get('CACHE_TTL'));
+
+// Pages
+$f3->route('GET /', function ($f3, $args) {
+    $f3->set('CONTENT', 'login.tpl');
+    echo Template::instance()->render('masterpage.tpl');
+}, $f3->get('CACHE_TTL'));
+
+// Services
+$f3->route("POST /login", 'Modules\BaseController->Login');
+
+
+$f3->run();

+ 66 - 0
src/Modules/BaseController.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace Modules;
+/**
+ * @author Open Mind
+ * @date 09/04/2018
+ * @time 16:15
+ */
+
+class BaseController
+{
+    protected $db;
+    protected $isLogged;
+
+    public function __construct($f3)
+    {
+//    $this->db = new \DB\SQL($f3->get('DB'), $f3->get('dbuser'), $f3->get('dbpass'), array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => TRUE));
+        $this->isLogged = $this->checkLogin($f3->get('COOKIE.username'), $f3->get('COOKIE.password'));
+
+        if ($this->isLogged)
+            return;
+
+        $f3->clear('COOKIE.username');
+        $f3->clear('COOKIE.password');
+
+        return;
+    }
+
+    /**
+     * Check if login is valid
+     * @param $email
+     * @param $password
+     * @return bool
+     */
+    private function checkLogin($username, $password)
+    {
+        return password_verify("{$username}|{$password}", \F3::get('PASSWORD'));
+    }
+
+    public function Login($f3)
+    {
+        $f3->clear('SESSION');
+
+        $accountData = $f3->clean($f3->get('POST'));
+
+        if (!$this->checkLogin($accountData['username'], $accountData['password'])) {
+            http_response_code(500);
+            echo "Dati di accesso non corretto";
+            return;
+        }
+
+        $f3->set('COOKIE.username', $accountData['username']);
+        $f3->set('COOKIE.password', $accountData['password']);
+        http_response_code(200);
+    }
+
+    public function Logout($f3)
+    {
+        WriteLog("user {$f3->get('COOKIE.username')}");
+        $f3->clear('SESSION');
+        $f3->clear('COOKIE.username');
+        $f3->clear('COOKIE.password');
+        $f3->reroute($f3->get('BASEURL'));
+    }
+
+}

+ 21 - 0
uglify.php

@@ -0,0 +1,21 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 09/04/2018
+ * @time 12:49
+ */
+function UglifyCSS($f3, $args)
+{
+    echo Web::instance()->minify([
+        "node_modules/bootstrap/dist/css/bootstrap.css",
+        "ui/custom.css"
+    ]);
+}
+
+function UglifyJS($f3, $args)
+{
+    echo Web::instance()->minify([
+        "node_modules/jquery/dist/jquery.js",
+        "node_modules/bootstrap/dist/js/bootstrap.bundle.js"
+    ]);
+}

+ 26 - 0
ui/custom.css

@@ -0,0 +1,26 @@
+body {
+    background-color: #1c1c1c !important;
+    color: #c5ac0f;
+}
+
+input[type="text"], input[type="password"] {
+    background-color: #484848 !important;
+    border-color: #C5AC0F
+}
+
+input[type="text"]:focus, input[type="password"]:focus {
+    border-color: #C5AC0F;
+    color: orange;
+}
+.form-control {
+    color: orange;
+}
+
+.form-control:focus {
+    border-color: #c5ac0f;
+    box-shadow: 0 0 0 0.2rem rgba(197, 172, 15, 0.25);
+}
+
+.debugborder {
+    border: 1px solid red;
+}

BIN
ui/img/01-icone-schermata-om-link.png


BIN
ui/img/02-icone-schermata-om-link.png


BIN
ui/img/03-icone-schermata-om-link.png


BIN
ui/img/04-icone-schermata-om-link.png


BIN
ui/img/05-icone-schermata-om-link.png


BIN
ui/img/06-icone-schermata-om-link.png


BIN
ui/img/logo.png


BIN
ui/img/om-link-logo.png


+ 11 - 0
ui/login.tpl

@@ -0,0 +1,11 @@
+<div class="text-center mx-auto col-md-7 mt-5">
+    <img src="{{@BASEURL}}/images/logo.png" alt="" class="img-fluid">
+    <form enctype="multipart/form-data" action="{{@BASEURL}}/login" method="POST">
+        <h1 class="mb-4" style="font-size: 4vw">Login</h1>
+        <label for="username" class="sr-only">username</label>
+        <input type="text" name="username" id="username" class="form-control mb-1" placeholder="Username" required autofocus autocomplete="false">
+        <label for="password" class="sr-only">Password</label>
+        <input type="password" name="password" id="password" class="form-control mb-1" placeholder="Password" required autocomplete="false">
+        <button class="btn btn-lg btn-warning btn-block" type="submit">Invia</button>
+    </form>
+</div>

+ 23 - 0
ui/masterpage.tpl

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="it">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
+    <title>{{@SITENAME}}</title>
+    <link type="text/css" rel="stylesheet" href="{{@BASEURL}}/assets/bundle.css"/>
+    <!-- link href='https://fonts.googleapis.com/css?family=Gloria+Hallelujah%7CLato' rel='stylesheet' type='text/css' -->
+
+    <script type="text/javascript">
+        var BASEURL = '{{@BASEURL}}';
+    </script>
+</head>
+<body>
+
+<div class="container-fluid">
+    <include if="{{ isset(@CONTENT) }}" href="{{@CONTENT}}"/>
+</div>
+
+
+<script src="{{@BASEURL}}/assets/bundle.js"></script>
+</body>
+</html>