Sensation Energy


Sensation Framework

Back End Documentation

Introduction

Back End serves to control the site. serves to control the site. It was made as a MVC (Model, View Controller).Very easy to program and use.

Back End or Application can be used with or without databases. It is made to show the values that are displayed from the database via the model and without the database also from the model, but in this case the data is entered ugly in the model.

Database backup can be performed in backup\backup.json in JSON format.

Install

It is also very simple, insert the Sensation Framework in the web folder and call it in the browser. example: http: //localhost/sensation/instal/indes.php

After that, follow the instructions and click on someone to go to the next step. Those are:

  • Database confing
  • Form for entering data on MySql database. You must first create a database name in PHPMyAdmin.

    
    <?php
    $HOST_name = "<input class='form-input' type='text' name='dbhost' placeholder='Enter Host Name' />";
    $DB_username = "<input class='form-input' type='text' name='dbuser' placeholder='Enter DB User Name' />";
    $DB_password = "<input class='form-input' type='password' name='dbpass' placeholder='***********' />";
    $DB_name = "<input class='form-input' type='text' name='dbname' placeholder='Enter DB Name' /><br> <br>";
    echo "<div class='box' >
    <form class='ins' method='post' action='installing.php' >
    <p>Enter Host Name:<p>
    $HOST_name
    <p>Enter DB User Name:<p>
    $DB_username
    <p>Enter DB PassWord:<p>
    $DB_password
    <p>Enter DB Name:<p>
    $DB_name
    <input class='btn-10' type='submit'name='install' value='NEXT' />
    </form>
    </div>";
    ?>
    
    
  • User confing
  • Form for create user (admin)

        
    <form action="o.php" method="post">
    <label>Name</label>
    <input type="text" name="name" class="form-input">
    </div>
    <div class="form-group">
    <label>Age</label>
    <input type="text" name="age" class="form-input">
    </div>
    <div class="form-group">
    <label>User</label>
    <input type="text" name="user" class="form-input">
    </div>
    <div class="form-group">
    <label>Password</label>
    <input type="text" name="password" class="form-input">
    </div>
    <div class="form-group">
    <label>Email</label>
    <input type="text" name="email" class="form-input">
    </div>
    <div class="form-group">
    <label>Role</label>
    <select  name="role" class="form-input">
    <option value='admin'>Admin</option>;
    <option value='user'>User</option>;
    </select>
    </div>
    <input type="submit" class="btn-6" value="Add" name="ubaci">
    </form>
    
    
  • Website confing
  • Form for confing dwebsite (name, title, header, footer,...).

    
    <form action="u.php" method="post">
    <label>Site name</label>
    <input type="text" name="site_name" class="form-input">
    </div>
    <div class="form-group">
    <label>Name</label>
    <input type="text" name="name" class="form-input">
    </div>
    <div class="form-group">
    <label for="user">User</label>
    <div>
    <select name="user" id="user"  class="form-input">
    <?php
    include 'dbconnect.php';
    $query = "SELECT * FROM users";
    $select_categories = mysqli_query($link,$query);
    while($row = mysqli_fetch_assoc($select_categories)){
    $user =  $row['user'];
    echo "<option value='$user'>$user</option>";
    }
    ?>
    </select>
    </div>
    </div>
    <div class="form-group">
    <label>Title</label>
    <input type="text" name="title" class="form-input">
    </div>
    <div class="form-group">
    <label>Header</label>
    <input type="text" name="header" class="form-input">
    </div>
    <div class="form-group">
    <label>Footer</label>
    <input type="text" name="footer" class="form-input">
    </div>
    
    

When you have completed all this and successfully completed it, then you can use this Sensation Framework, Note: The database is in the application itself so you don't have to specialize it.

Uses - more extensively

They are used when the frontend page appears, it is necessary to log in as admi / admin (unasername / password). This is set by default. After that it is necessary to go to the menu on the Chonfig button. This is where the application is set up. You also have a User button in the menu where you are shown a logged in user.

MVC

MVC is given as an example that does not contain a database. It is designed to show you how Sensation Framework works without a database. Prints only the name Sensation Energy.

Model /index.php


<?php
class Model {
function mod() {
echo ('Sensation Energy');
echo "<br><br>";
echo ('Sensation Framework');
}
}
?>

Controller /index.php


<?php
class Con {
function control() {
include "app/model/index.php";
$link = new Model();
$link->mod();
}
}
?>

View /index.php


<?php
include "app/controller/index.php";
$link = new Con();
$link->control();
?>

This illustrative example allows you to master the MVC construction yourself.

Config

Config consists of:

  • config.php

    Here the data from the config table in the database is selected

    
    <?php
    global $link;
    $sql = "SELECT * from  confing";
    $result = $link->query($sql);
    $res = $result->fetch_assoc();
    ?>
    
    
  • session.php
  • Seesion serves as a user session

    
    <?php
    session_start();
    $_SESSION['user'];
    ?>
    
    
  • settings.php
  • Settings allows manual filling functionality: index page, language, ...

    
    <?php
    class Settings {
    public function link() {
    $config['index_page'] = 'index.php';
    $config['url_suffix'] = '';
    $config['language']	= 'english';
    $config['composer_autoload'] = TRUE;
    $config['log_date_format'] = 'd-m-Y H:i:s';
    }
    }
    ?>
    
    
  • unset_seesion.php
  • Unset seesion is used to terminate a user session at logout

    
    <?php
    session_start();
    unset($_SESSION["user"]);
    if (!isset($_SESSION)) { session_start(); }
    $_SESSION = array();
    session_destroy();
    header("Location: ../../../../index.php");
    ?>
    
    

Function

Function the following functionalities are found. Api (api.php), Helper. (Helper.php), Loader (loader.php) - autoloader and Route (rute.php).

Loader serves for loading and Route for path where the index is in our example. php and 404.php (not found).

Loader


<?php
spl_autoload_register(function ($main) {
$path = sprintf('%s.php', str_replace('_', DIRECTORY_SEPARATOR, $main) );
if (file_exists($path)) {
include $path;
} else {
echo "Value not found";
}
});
$autoload['packages'] = array();
?>

Route


<?php
class Routers {
protected $index = 'index.php';
public function router() {
$request = $_SERVER['REQUEST_URI'];
if ($request) {
include "app/view/index.php";
}else{
http_response_code(404);
require 'add/404.php';
}
}
}
?>

Login

Login allows users to log in. consists of:

  • controller/login.php
  • User login function

  • view/index.php
  • Login form

  • videw/logout.php
  • User login function

Config Aplication

Config is CRUD function for config application.

Here you can reduce, add, delete:

  • Name:
  • Site title:
  • Site name:
  • Header:
  • Footer:
  • User is session User

Example for MVC Crud можете пронакћи на страници Function 7 OOP MVC PHP MySql:

F 7 OOP MVC PHP MySql

Plugins

Plugins allow other applications to come to our application. Previously, we had to create an application that we would add using our MVC CRUD. In our application plugins us Login and Config.

How to make plugins? First, create a folder in the comet and place the subfolders (modelview view controller).

When you create your plugin and place it in a folder, you also need to call the basic indes.php to show what you have done. You will do this by calling the callus and function from the view of your plugin that you have made.

Example call plugin in index.php


<?php
include 'app/plugins/login/view/index.php';
$call = new Lo();
$call-> login();
?>

You can also use our GRID which we used in this Framework.

Firts create model. Model serves for CRUD functionality. (select, insert, delete). Example:


<?php
class Mycrud {
function crud() {
global $link;
$sql = "SELECT * from confing where id='$id'";
$result = $link->query($sql);
while ($res = $result->fetch_assoc()) {
$array[] = $res;
}
return $array;
}
}
?>

Of course it is necessary to add a link for the connection with the database. Example:

include '../../../install/dbconnect.php';

The controller is used to scroll through the data that we previously selected in the model. We need to give both the class and the function from the model.

Example:

<?php
require_once 'model.php';
class listarController{
private $lista;
protected $id;
public function vlada(){
$lista = new Config();
$lista->getMe();
$res = $lista->getMe();
foreach ($res as $value){
?>
Name: <h2><?php echo $value['name']; ?></h2>
Site title:	<h2><?php echo $value['title']; ?></h2>
Site name:	<h2><?php echo $value['site_name']; ?></h2>
Header:	<h2><?php echo $value['header']; ?></h2>
Footer:	<h2><?php echo $value['footer']; ?></h2>
User:	<h2><?php echo $value['user']; ?></h2>
<?php
}
}
}
?>

View overrides everything we selected in the module and listed in the controller. Of course you need to add class and function from the controller.

Example

<?php
require_once 'controller.php';
$lista1 = new listarController();
$lista1->vlada();
?>

Example

The example I flooded serves to illustrate the functionality I added. Such as: registration, messages. It was also done in Sensation Framework MVC CRUD.


Content


Documentation


Front End Example


Answer the following question:

You must be logged in


Advertising