Base d'un site web v2
This commit is contained in:
parent
e761ff7c5a
commit
ec9eb79038
59
base.sql
Normal file
59
base.sql
Normal file
@ -0,0 +1,59 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.4
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Client : 127.0.0.1
|
||||
-- Généré le : Lun 17 Avril 2017 à 21:00
|
||||
-- Version du serveur : 5.7.14
|
||||
-- Version de PHP : 7.0.10
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `base`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `logs`
|
||||
--
|
||||
|
||||
CREATE TABLE `logs` (
|
||||
`id` int(10) NOT NULL,
|
||||
`level` smallint(5) NOT NULL,
|
||||
`message` varchar(2000) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`file` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`line` varchar(6) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`date` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Index pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `logs`
|
||||
--
|
||||
ALTER TABLE `logs`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `logs`
|
||||
--
|
||||
ALTER TABLE `logs`
|
||||
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
@ -32,7 +32,6 @@ if (count($pages) > 1 && $pages[count($pages) - 1] == '')
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if ($pages[0] == 'api' && isset($pages[1]) && preg_match('#^([a-z]+)$#', $pages[1], $api1) && isset($pages[2]) && preg_match('#^([a-z-]+)$#', $pages[2], $api2)) {
|
||||
new APIRouter($api1[0], $api2[0]);
|
||||
|
||||
|
@ -14,7 +14,6 @@ class APIError extends Controller {
|
||||
* @param string $code
|
||||
*/
|
||||
public function __construct(int $ErrCode = 500, string $devMessage = 'Erreur inconnue', string $publicMessage = 'Une erreur inconnue s\'est produite', string $code = '') {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$tabCode = [
|
||||
|
@ -4,8 +4,7 @@ namespace base\API;
|
||||
|
||||
use base\Config;
|
||||
|
||||
class APIRouter
|
||||
{
|
||||
class APIRouter {
|
||||
|
||||
//Les méthodes HTTP gérée par l'API
|
||||
const HTTP_METHODS = ['GET', 'POST', 'DELETE', 'PUT'];
|
||||
|
@ -6,7 +6,9 @@ class Config {
|
||||
const SITE_JS_VERSION = '1.00';
|
||||
const SITE_CSS_VERSION = '1.00';
|
||||
|
||||
const TITLE_HEADER = '';
|
||||
const DESCRIPTION_HEADER = '';
|
||||
const TITLE_HEADER = 'Mon titre de site';
|
||||
const DESCRIPTION_HEADER = 'Ma description pour les robots';
|
||||
const NAMESPACE = 'base';
|
||||
|
||||
const FAVICON_PATH = '/img/favicon.png';
|
||||
}
|
@ -9,10 +9,16 @@ class Index extends ControllerSite {
|
||||
/**
|
||||
* Index constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->addHead([
|
||||
]);
|
||||
|
||||
$this->addFooter([
|
||||
|
||||
]);
|
||||
|
||||
$this->addData([]);
|
||||
$this->view();
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ namespace base\Model;
|
||||
use Exception;
|
||||
use PDO;
|
||||
|
||||
class BDD
|
||||
{
|
||||
const SQL_SERVER = 'localhost';
|
||||
const SQL_LOGIN = 'root';
|
||||
const SQL_PASSWORD = '';
|
||||
const SQL_DB = 'eldotravo';
|
||||
class BDD {
|
||||
const SQL_SERVER = 'localhost'; // BDD Server
|
||||
const SQL_LOGIN = 'root'; // BDD Login
|
||||
const SQL_PASSWORD = ''; // BDD Password
|
||||
const SQL_DB = 'base'; // BDD Name
|
||||
|
||||
private static $bdd;
|
||||
|
||||
@ -22,7 +21,8 @@ class BDD
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
|
||||
];
|
||||
|
||||
self::$bdd = new PDO('mysql:host='.self::SQL_SERVER.';dbname='.self::SQL_DB.';charset=utf8', self::SQL_LOGIN, self::SQL_PASSWORD, $pdo_options);
|
||||
self::$bdd = new PDO('mysql:host=' . self::SQL_SERVER . ';dbname=' . self::SQL_DB.';charset=utf8',
|
||||
self::SQL_LOGIN, self::SQL_PASSWORD, $pdo_options);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
die('Erreur : ' . $e->getMessage());
|
||||
|
@ -6,6 +6,8 @@ abstract class BDTables {
|
||||
|
||||
// const NOM = 'bd_nom'
|
||||
// Ex : const ABONNEMENT = 'abonnement';
|
||||
|
||||
const LOGS = "logs";
|
||||
}
|
||||
|
||||
?>
|
@ -7,12 +7,10 @@ use PDO;
|
||||
class Logs {
|
||||
|
||||
public $id;
|
||||
public $site;
|
||||
public $level;
|
||||
public $message;
|
||||
public $file;
|
||||
public $line;
|
||||
public $user;
|
||||
public $date;
|
||||
|
||||
const ERROR_LEVEL = [
|
||||
@ -36,22 +34,19 @@ class Logs {
|
||||
|
||||
/**
|
||||
* Logs constructor.
|
||||
* @param int $id
|
||||
* @param string $site
|
||||
* @param string $level
|
||||
* @param string $message
|
||||
* @param string $file
|
||||
* @param string $line
|
||||
* @param string $date
|
||||
* @param int|null $id
|
||||
* @param string|null $level
|
||||
* @param string|null $message
|
||||
* @param string|null $file
|
||||
* @param string|null $line
|
||||
* @param string|null $date
|
||||
*/
|
||||
public function __construct(int $id = null, string $site = null, string $level = null, string $message = null,
|
||||
string $file = null, string $line = null, string $date = null)
|
||||
public function __construct(int $id = null, string $level = null, string $message = null, string $file = null, string $line = null, string $date = null)
|
||||
{
|
||||
if ($id === NULL) {
|
||||
return;
|
||||
}
|
||||
$this->id = $id;
|
||||
$this->site = $site;
|
||||
$this->level = $level;
|
||||
$this->message = $message;
|
||||
$this->file = $file;
|
||||
@ -60,10 +55,14 @@ class Logs {
|
||||
}
|
||||
|
||||
|
||||
public static function insert($site, $level, $message, $file, $line, $date) {
|
||||
$user = NULL;
|
||||
$req = BDD::instance()->prepare('INSERT INTO '.BDTables::LOGS.'(site, level, message, date, file, line) VALUES(:site, :level, :message, :date, :file, :line)');
|
||||
$req->execute(['site' => $site, 'level' => $level, 'message' => $message, 'date' => $date, 'file' => $file, 'line' => $line]);
|
||||
public static function insert($level, $message, $file, $line, $date) {
|
||||
Model::insert(BDTables::LOGS, [
|
||||
'level' => $level,
|
||||
'message' => $message,
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
'date' => date("Y-m-d H:i:s", strtotime($date))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,15 +71,16 @@ class Logs {
|
||||
* @return array
|
||||
*/
|
||||
public static function getLastLogs(int $limit){
|
||||
$req = BDD::instance()->prepare('SELECT l.*
|
||||
FROM '.BDTables::LOGS.' l
|
||||
ORDER BY date DESC LIMIT :limit');
|
||||
$req = BDD::instance()->prepare('SELECT *
|
||||
FROM ' . BDTables::LOGS . '
|
||||
ORDER BY date DESC
|
||||
LIMIT :limit');
|
||||
$req->bindValue('limit', $limit, PDO::PARAM_INT);
|
||||
$req->execute();
|
||||
$return = [];
|
||||
|
||||
foreach ($req->fetchAll() as $l){
|
||||
$log = new Logs($l['id'], $l['site'], $l['level'], $l['message'], $l['file'], $l['line'], $l['date']);
|
||||
$log = new Logs($l['id'], $l['level'], $l['message'], $l['file'], $l['line'], $l['date']);
|
||||
$return[] = $log;
|
||||
}
|
||||
|
||||
@ -103,22 +103,6 @@ class Logs {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSite()
|
||||
{
|
||||
return htmlspecialchars($this->site);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $site
|
||||
*/
|
||||
public function setSite($site)
|
||||
{
|
||||
$this->site = $site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -203,7 +187,8 @@ class Logs {
|
||||
* Retourne le type d'erreur en string (label)
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorLabel(){
|
||||
public function getErrorLabel()
|
||||
{
|
||||
return htmlspecialchars(self::ERROR_LEVEL[$this->level]);
|
||||
}
|
||||
}
|
||||
|
3
src/View/Error.php
Normal file
3
src/View/Error.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
echo $erreur;
|
||||
?>
|
@ -1,3 +1,3 @@
|
||||
<div>
|
||||
Bonjour
|
||||
Bonjour 2
|
||||
</div>
|
@ -1,29 +1,6 @@
|
||||
<?php if(!empty($_SESSION['ville_inconue']) && $_SESSION['ville_inconue'] == true){ ?>
|
||||
|
||||
<div class="content">
|
||||
<div class="error-page-container">
|
||||
<div class="error-title"><?= $erreur ?></div>
|
||||
<div class="error-message">La ville saisie est introuvable</div>
|
||||
<div class="error-prestations">
|
||||
Merci d'effectuer une nouvelle recherche avec une autre ville en utilisant les suggestions de la liste.<br><br>
|
||||
Que voulez-vous faire ?<br><br>
|
||||
<a class="error-prestation" href="/ajout-artisan-avis">Evaluer un professionnel</a>
|
||||
<a class="error-prestation" href="/demande-devis">Demander des devis</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php }else{ ?>
|
||||
|
||||
<div class="content">
|
||||
<div class="error-page-container">
|
||||
<div class="error-title"><?= $erreur ?></div>
|
||||
<div class="error-message">Que voulez-vous faire ?</div>
|
||||
<div class="error-prestations">
|
||||
<a class="error-prestation" href="/ajout-artisan-avis">Evaluer un professionnel</a>
|
||||
<a class="error-prestation" href="/demande-devis">Demander des devis</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
@ -18,16 +18,16 @@
|
||||
<meta property="og:title" content="<?= $this->head['title'] ?>" />
|
||||
<meta property="og:description" content="<?= $this->head['description'] ?>" />
|
||||
<meta property="og:url" content="https://<?= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
|
||||
<meta property="og:image" content="https://<?= $_SERVER['SERVER_NAME'] ?>/img/Slogan_Eldo_share.png" />
|
||||
<meta property="fb:app_id" content="1000452166691027" />
|
||||
<meta property="og:image" content="https://<?= $_SERVER['SERVER_NAME'] . \base\Config::FAVICON_PATH ?>" />
|
||||
<!-- <meta property="fb:app_id" content="1000452166691027" /> -->
|
||||
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700%7CRoboto+Condensed:400,700%7CMaterial+Icons' rel='stylesheet' type='text/css'>
|
||||
|
||||
<link href="/css/theme.css?v=<?= base\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
|
||||
<link href="/css/select2.css" rel="stylesheet">
|
||||
|
||||
<link rel="image_src" href="/img/Slogan_Eldo_share.png" />
|
||||
<link rel="icon" type="image/png" href="/img/" />
|
||||
<link rel="image_src" href="<?php \base\Config::FAVICON_PATH ?>" />
|
||||
<link rel="icon" type="image/png" href="<?php \base\Config::FAVICON_PATH ?>" />
|
||||
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
|
@ -118,7 +118,7 @@ function errorHandler($errno, $errstr, $errfile, $errline) {
|
||||
}
|
||||
|
||||
// Insertion des logs
|
||||
// \base\Model\Logs::insert('eldo', $errno, $errstr, $errfile, $errline, date('Y-m-d H:i:s'));
|
||||
\base\Model\Logs::insert($errno, $errstr, $errfile, $errline, date('Y-m-d H:i:s'));
|
||||
|
||||
ob_clean();
|
||||
new \base\Controller\Site\SiteError(500);
|
||||
@ -385,4 +385,13 @@ function cleanArray(array $data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $array
|
||||
* @return mixed
|
||||
*/
|
||||
function endKey($array){
|
||||
end($array);
|
||||
return key($array);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user