First PUsh
This commit is contained in:
commit
d9e043c468
33 files changed
+8648
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
Options +FollowSymlinks
|
||||||
|
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteBase /
|
||||||
|
|
||||||
|
RewriteCond %{ENV:REDIRECT_END} ^1$
|
||||||
|
RewriteRule ^ - [L]
|
||||||
|
|
||||||
|
# Redirection non-www vers www
|
||||||
|
# RewriteCond %{HTTP_HOST} ^eldotravo.fr$
|
||||||
|
# RewriteRule ^(.*)$ http://www.eldotravo.fr/$1 [R=301,L,E=END:1]
|
||||||
|
|
||||||
|
# Redirection des fichiers static pour contact.sanchez-mathieu.dev
|
||||||
|
RewriteCond %{HTTP_HOST} ^contact.sanchez-mathieu.dev$
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI} -f
|
||||||
|
RewriteRule ^(.*)$ static/$1 [L,E=END:1]
|
||||||
|
|
||||||
|
# RewriteRule ^haute-garonne/toulouse/installation-entretien-climatisation /haute-garonne/toulouse/climatisation.php [L]
|
||||||
|
|
||||||
|
# Redirection de toutes les requêtes vers Index.php
|
||||||
|
RewriteRule ^ index.php [L,E=END:1]
|
||||||
Generated
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="7" />
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Web Project For CAU University 3
|
||||||
|
|
||||||
|
Write a web application My-Contacts satisfying the following requirements.
|
||||||
|
|
||||||
|
- Information to be included: name, e-mail address, phone numbers, etc.
|
||||||
|
- Functions to be supported: insert, delete, update, search, list, etc.
|
||||||
|
- Server side scripting should be used.
|
||||||
|
- All data should be stored in DB.
|
||||||
|
- Build your own web servers.
|
||||||
|
|
||||||
|
Submit the report describing the requirements, design, and testing results with source code.
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact;
|
||||||
|
|
||||||
|
use CAUProject3Contact\API\APIRouter;
|
||||||
|
use CAUProject3Contact\Controller\Error;
|
||||||
|
use CAUProject3Contact\Controller\Site\SiteRouter;
|
||||||
|
use CAUProject3Contact\Model\BDD;
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
date_default_timezone_set( 'Europe/Paris' );
|
||||||
|
setlocale( LC_TIME, "fr_FR.UTF-8" );
|
||||||
|
error_reporting( E_ALL );
|
||||||
|
|
||||||
|
require( 'src/lib/functions.php' );
|
||||||
|
require( 'src/config.php' );
|
||||||
|
|
||||||
|
require 'src/Autoloader.php';
|
||||||
|
Autoloader::register();
|
||||||
|
|
||||||
|
new BDD();
|
||||||
|
|
||||||
|
$parts = explode( '?', $_SERVER['REQUEST_URI'] );
|
||||||
|
$urlA = ltrim( $parts[0], '/' );
|
||||||
|
$pages = explode( '/', $urlA );
|
||||||
|
|
||||||
|
//Si il y a un / en fin d'url on redirige vers la meme page sans le /
|
||||||
|
if ( count( $pages ) > 1 && $pages[ count( $pages ) - 1 ] == '' ) {
|
||||||
|
$args = ( count( $parts ) > 1 ? '?' . $parts[1] : '' );
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently' );
|
||||||
|
header( 'Location: /' . rtrim( $urlA, '/' ) . $args );
|
||||||
|
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] );
|
||||||
|
|
||||||
|
} else if ( preg_match( '#^test\.dev$#', $_SERVER['SERVER_NAME'] ) ) {
|
||||||
|
new SiteRouter( $pages );
|
||||||
|
} else {
|
||||||
|
new Error( 404 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
} elseif (preg_match('#^(www\.)?mvc\.eldotravo\.dev$#', $_SERVER['SERVER_NAME'])) {
|
||||||
|
new SiteRouter($pages);
|
||||||
|
*/
|
||||||
|
?>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\API;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Controller\Controller;
|
||||||
|
|
||||||
|
class API extends Controller {
|
||||||
|
|
||||||
|
private $declaredFunctions = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API constructor.
|
||||||
|
*
|
||||||
|
* @param array $declaredFunctions
|
||||||
|
*/
|
||||||
|
public function __construct( array $declaredFunctions ) {
|
||||||
|
parent::__construct();
|
||||||
|
$this->declaredFunctions = $declaredFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDeclaredFunctions() {
|
||||||
|
return $this->declaredFunctions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\API;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Controller\Controller;
|
||||||
|
|
||||||
|
class APIError extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIError constructor.
|
||||||
|
*
|
||||||
|
* @param int $ErrCode
|
||||||
|
* @param string $devMessage
|
||||||
|
* @param string $publicMessage
|
||||||
|
* @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 = [
|
||||||
|
//Informational 1xx
|
||||||
|
100 => [ 'label' => '100 Continue', 'msg' => '100 Continue' ],
|
||||||
|
101 => [ 'label' => '101 Switching Protocols', 'msg' => '101 Switching Protocols' ],
|
||||||
|
//Successful 2xx
|
||||||
|
200 => [ 'label' => '200 OK', 'msg' => '200 OK' ],
|
||||||
|
201 => [ 'label' => '201 Created', 'msg' => '201 Created' ],
|
||||||
|
202 => [ 'label' => '202 Accepted', 'msg' => '202 Accepted' ],
|
||||||
|
203 => [ 'label' => '203 Non-Authoritative Information', 'msg' => '203 Non-Authoritative Information' ],
|
||||||
|
204 => [ 'label' => '204 No Content', 'msg' => '204 No Content' ],
|
||||||
|
205 => [ 'label' => '205 Reset Content', 'msg' => '205 Reset Content' ],
|
||||||
|
206 => [ 'label' => '206 Partial Content', 'msg' => '206 Partial Content' ],
|
||||||
|
226 => [ 'label' => '226 IM Used', 'msg' => '226 IM Used' ],
|
||||||
|
//Redirection 3xx
|
||||||
|
300 => [ 'label' => '300 Multiple Choices', 'msg' => '300 Multiple Choices' ],
|
||||||
|
301 => [ 'label' => '301 Moved Permanently', 'msg' => '301 Moved Permanently' ],
|
||||||
|
302 => [ 'label' => '302 Found', 'msg' => '302 Found' ],
|
||||||
|
303 => [ 'label' => '303 See Other', 'msg' => '303 See Other' ],
|
||||||
|
304 => [ 'label' => '304 Not Modified', 'msg' => '304 Not Modified' ],
|
||||||
|
305 => [ 'label' => '305 Use Proxy', 'msg' => '305 Use Proxy' ],
|
||||||
|
306 => [ 'label' => '306 (Unused)', 'msg' => '306 (Unused)' ],
|
||||||
|
307 => [ 'label' => '307 Temporary Redirect', 'msg' => '307 Temporary Redirect' ],
|
||||||
|
//Client Error 4xx
|
||||||
|
400 => [ 'label' => '400 Bad Request', 'msg' => '400 Bad Request' ],
|
||||||
|
401 => [ 'label' => '401 Unauthorized', 'msg' => 'Vous n\'êtes pas autorisé à accéder à cette page' ],
|
||||||
|
402 => [ 'label' => '402 Payment Required', 'msg' => '402 Payment Required' ],
|
||||||
|
403 => [ 'label' => '403 Forbidden', 'msg' => '403 Forbidden' ],
|
||||||
|
404 => [ 'label' => '404 Not Found', 'msg' => 'Page non trouvée' ],
|
||||||
|
405 => [ 'label' => '405 Method Not Allowed', 'msg' => '405 Method Not Allowed' ],
|
||||||
|
406 => [ 'label' => '406 Not Acceptable', 'msg' => '406 Not Acceptable' ],
|
||||||
|
407 => [ 'label' => '407 Proxy Authentication Required', 'msg' => '407 Proxy Authentication Required' ],
|
||||||
|
408 => [ 'label' => '408 Request Timeout', 'msg' => '408 Request Timeout' ],
|
||||||
|
409 => [ 'label' => '409 Conflict', 'msg' => '409 Conflict' ],
|
||||||
|
410 => [ 'label' => '410 Gone', 'msg' => '410 Gone' ],
|
||||||
|
411 => [ 'label' => '411 Length Required', 'msg' => '411 Length Required' ],
|
||||||
|
412 => [ 'label' => '412 Precondition Failed', 'msg' => '412 Precondition Failed' ],
|
||||||
|
413 => [ 'label' => '413 Request Entity Too Large', 'msg' => '413 Request Entity Too Large' ],
|
||||||
|
414 => [ 'label' => '414 Request-URI Too Long', 'msg' => '414 Request-URI Too Long' ],
|
||||||
|
415 => [ 'label' => '415 Unsupported Media Type', 'msg' => '415 Unsupported Media Type' ],
|
||||||
|
416 => [ 'label' => '416 Requested Range Not Satisfiable', 'msg' => '416 Requested Range Not Satisfiable' ],
|
||||||
|
417 => [ 'label' => '417 Expectation Failed', 'msg' => '417 Expectation Failed' ],
|
||||||
|
418 => [ 'label' => '418 I\'m a teapot', 'msg' => '418 I\'m a teapot' ],
|
||||||
|
422 => [ 'label' => '422 Unprocessable Entity', 'msg' => '422 Unprocessable Entity' ],
|
||||||
|
423 => [ 'label' => '423 Locked', 'msg' => '423 Locked' ],
|
||||||
|
426 => [ 'label' => '426 Upgrade Required', 'msg' => '426 Upgrade Required' ],
|
||||||
|
428 => [ 'label' => '428 Precondition Required', 'msg' => '428 Precondition Required' ],
|
||||||
|
429 => [ 'label' => '429 Too Many Requests', 'msg' => '429 Too Many Requests' ],
|
||||||
|
431 => [ 'label' => '431 Request Header Fields Too Large', 'msg' => '431 Request Header Fields Too Large' ],
|
||||||
|
//Server Error 5xx
|
||||||
|
500 => [ 'label' => '500 Internal Server Error', 'msg' => 'Une erreur est survenue' ],
|
||||||
|
501 => [ 'label' => '501 Not Implemented', 'msg' => '501 Not Implemented' ],
|
||||||
|
502 => [ 'label' => '502 Bad Gateway', 'msg' => '502 Bad Gateway' ],
|
||||||
|
503 => [ 'label' => '503 Service Unavailable', 'msg' => '503 Service Unavailable' ],
|
||||||
|
504 => [ 'label' => '504 Gateway Timeout', 'msg' => '504 Gateway Timeout' ],
|
||||||
|
505 => [ 'label' => '505 HTTP Version Not Supported', 'msg' => '505 HTTP Version Not Supported' ],
|
||||||
|
506 => [ 'label' => '506 Variant Also Negotiates', 'msg' => '506 Variant Also Negotiates' ],
|
||||||
|
510 => [ 'label' => '510 Not Extended', 'msg' => '510 Not Extended' ],
|
||||||
|
511 => [ 'label' => '511 Network Authentication Required', 'msg' => '511 Network Authentication Required' ]
|
||||||
|
];
|
||||||
|
|
||||||
|
header( 'Content-Type: application/json' );
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[ $ErrCode ]['label'] );
|
||||||
|
echo json_encode( [
|
||||||
|
'status' => 'echec',
|
||||||
|
'msg' => $publicMessage,
|
||||||
|
'devMsg' => $devMessage,
|
||||||
|
'code' => $code
|
||||||
|
], JSON_PRETTY_PRINT );
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\API;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Config;
|
||||||
|
|
||||||
|
class APIRouter {
|
||||||
|
|
||||||
|
//Les méthodes HTTP gérée par l'API
|
||||||
|
const HTTP_METHODS = [ 'GET', 'POST', 'DELETE', 'PUT' ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIRouter constructor.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @param string $action
|
||||||
|
*/
|
||||||
|
public function __construct( string $file, string $action ) {
|
||||||
|
|
||||||
|
//On vérifie que les paramètres ne sont pas vides
|
||||||
|
if ( empty( $file ) || empty( $action ) ) {
|
||||||
|
new APIError();
|
||||||
|
}
|
||||||
|
|
||||||
|
//On vérifie que la classe appelée existe
|
||||||
|
$fileName = 'API' . ucfirst( $file );
|
||||||
|
if ( ! file_exists( 'src/API/' . $fileName . '.php' ) ) {
|
||||||
|
new APIError( 404 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On instancie la classe.
|
||||||
|
$class = '\\' . Config::NAMESPACE . '\\API\\' . $fileName;
|
||||||
|
$class = new $class( $action );
|
||||||
|
|
||||||
|
//On vérifie que l'action demandé est déclarée
|
||||||
|
if ( ! array_key_exists( $action, $class->getDeclaredFunctions() ) ) {
|
||||||
|
new APIError( 404 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On reconstruit le nom de la fonction
|
||||||
|
$array = explode( '-', $action );
|
||||||
|
foreach ( $array as $key => $value ) {
|
||||||
|
if ( $key == 0 ) {
|
||||||
|
$array[ $key ] = $value;
|
||||||
|
} else {
|
||||||
|
$array[ $key ] = ucfirst( $value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$function = implode( '', $array ); //le nom de la fonction
|
||||||
|
|
||||||
|
//On vérifie que la fonction existe dans la classe
|
||||||
|
if ( ! method_exists( $class, $function ) ) {
|
||||||
|
new APIError( 500, 'La fonction ' . $function . ' n\'existe pas dans la classe ' . get_class( $class ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On vérifie que la méthode d'envoie est référencée
|
||||||
|
$method = $class->getDeclaredFunctions()[ $action ]['method'];
|
||||||
|
if ( ! in_array( $method, self::HTTP_METHODS ) ) {
|
||||||
|
new APIError( 500, 'méthode http inconnue' );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On vérifie que la méthode requise et la mathode obtenue sont les même
|
||||||
|
if ( $method != $_SERVER['REQUEST_METHOD'] ) {
|
||||||
|
new APIError( 400, 'La méthode HTTP ne correspond pas à la méthode prévue' );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On met les paramètres dans le tableau $data
|
||||||
|
$params = $class->getDeclaredFunctions()[ $action ]['params'];
|
||||||
|
$data = [];
|
||||||
|
if ( ! empty( $params ) ) {
|
||||||
|
if ( $method == 'DELETE' || $method == 'PUT' ) {
|
||||||
|
parse_str( file_get_contents( 'php://input' ), $data );
|
||||||
|
} else if ( $method == 'POST' ) {
|
||||||
|
$data = $_POST;
|
||||||
|
} else if ( $method == 'GET' ) {
|
||||||
|
$data = $_GET;
|
||||||
|
}
|
||||||
|
|
||||||
|
//On boucle sur les paramètres de la doc de la fonction
|
||||||
|
foreach ( $params as $p => $options ) {
|
||||||
|
if ( ! isset( $options['required'] ) ) {
|
||||||
|
$options['required'] = false;
|
||||||
|
}
|
||||||
|
//Si le paramètre est obligatoire et qu'il est vide ou non fourni on lève une erreur 400 BAD REQUEST
|
||||||
|
if ( $options['required'] && ( ! array_key_exists( $p, $data ) || ( empty( $data[ $p ] ) && $data[ $p ] != '0' ) ) ) {
|
||||||
|
$devMsg = 'Paramètre ' . $p . ' manquant';
|
||||||
|
if ( isset( $options['devMsg'] ) ) {
|
||||||
|
$devMsg = $options['devMsg'];
|
||||||
|
}
|
||||||
|
$publicMsg = 'Des paramètres obligatoires ne sont pas envoyés ou sont vides';
|
||||||
|
if ( isset( $options['publicMsg'] ) ) {
|
||||||
|
$publicMsg = $options['publicMsg'];
|
||||||
|
}
|
||||||
|
$code = '';
|
||||||
|
if ( isset( $options['code'] ) ) {
|
||||||
|
$code = $options['code'];
|
||||||
|
}
|
||||||
|
new APIError( 400, $devMsg, $publicMsg, $code );
|
||||||
|
}
|
||||||
|
|
||||||
|
//On vérifie que le type donné correspond au typage requis
|
||||||
|
if ( isset( $options['type'] ) ) {
|
||||||
|
if ( $options['type'] == 'int' ) {
|
||||||
|
if ( ctype_digit( $data[ $p ] ) ) {
|
||||||
|
$data[ $p ] = (int) $data[ $p ];
|
||||||
|
} else {
|
||||||
|
new APIError( 400, 'Le type donné ne correspond pas au type demandé pour le paramètre ' . $p . ' : string donné, ' . $options['type'] . ' requis' );
|
||||||
|
}
|
||||||
|
} else if ( $options['type'] == 'bool' ) {
|
||||||
|
if ( $data[ $p ] == 'true' || $data[ $p ] == '1' ) {
|
||||||
|
$data[ $p ] = true;
|
||||||
|
} else if ( $data[ $p ] == 'false' || $data[ $p ] == '0' ) {
|
||||||
|
$data[ $p ] = false;
|
||||||
|
} else {
|
||||||
|
new APIError( 400, 'Le type donné ne correspond pas au type demandé pour le paramètre ' . $p . ' : string donné, ' . $options['type'] . ' requis' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Si un paramètre non obligatoire n'est pas donné par l'utilisateur on lui donne la valeur par défaut d'une chaine vide
|
||||||
|
if ( ! array_key_exists( $p, $data ) ) {
|
||||||
|
$data[ $p ] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//On appelle la fonction correspondante pour le traitement
|
||||||
|
$class->$function( $data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact;
|
||||||
|
|
||||||
|
class Autoloader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enregistre notre autoloader
|
||||||
|
*/
|
||||||
|
static function register() {
|
||||||
|
spl_autoload_register( array( __CLASS__, 'autoload' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inclue le fichier correspondant à notre classe
|
||||||
|
*
|
||||||
|
* @param $class string Le nom de la classe à charger
|
||||||
|
*/
|
||||||
|
static function autoload( $class ) {
|
||||||
|
if ( preg_match( '#^' . Config::NAMESPACE . '\\\(.+)$#', $class, $matches ) ) {
|
||||||
|
require 'src/' . str_replace( '\\', '/', $matches[1] ) . '.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact;
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
const SITE_JS_VERSION = '1.00';
|
||||||
|
const SITE_CSS_VERSION = '1.00';
|
||||||
|
|
||||||
|
const TITLE_HEADER = 'Your contact';
|
||||||
|
const DESCRIPTION_HEADER = 'Manage your contact easly';
|
||||||
|
const NAMESPACE = 'CAUProject3Contact';
|
||||||
|
|
||||||
|
const FAVICON_PATH = '/img/favicon.png';
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Config;
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->data = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function view() {
|
||||||
|
ob_start();
|
||||||
|
extract( $this->data );
|
||||||
|
require 'src/View/' . str_replace( '\\', '/', preg_replace( '#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class( $this ) ) ) . '.php';
|
||||||
|
ob_end_flush();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addData( $data ) {
|
||||||
|
$this->data += $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function returnJson( $data ) {
|
||||||
|
header( 'Content-Type: application/json' );
|
||||||
|
echo json_encode( $data );
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function throwError( $msg, $code = '' ) {
|
||||||
|
header( 'Content-Type: application/json' );
|
||||||
|
echo json_encode( [ 'status' => 'echec', 'msg' => $msg, 'code' => $code ], JSON_PRETTY_PRINT );
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Config;
|
||||||
|
|
||||||
|
class ControllerSite {
|
||||||
|
|
||||||
|
private $data;
|
||||||
|
private $head;
|
||||||
|
private $footer;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->data = [];
|
||||||
|
$this->head = [];
|
||||||
|
$this->footer = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function view( $header = true, $footer = true ) {
|
||||||
|
ob_start();
|
||||||
|
extract( $this->data );
|
||||||
|
|
||||||
|
if ( empty( $this->head['title'] ) ) {
|
||||||
|
$this->head['title'] = Config::TITLE_HEADER;
|
||||||
|
}
|
||||||
|
if ( empty( $this->head['description'] ) ) {
|
||||||
|
$this->head['description'] = Config::DESCRIPTION_HEADER;
|
||||||
|
}
|
||||||
|
if ( $header ) {
|
||||||
|
require 'src/View/Site/tpl/head.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
require 'src/View/' . str_replace( '\\', '/', preg_replace( '#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class( $this ) ) ) . '.php';
|
||||||
|
|
||||||
|
if ( $footer ) {
|
||||||
|
require 'src/View/Site/tpl/footer.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_end_flush();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addHead( $head ) {
|
||||||
|
$this->head += $head;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addData( $data ) {
|
||||||
|
$this->data += $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addFooter( $footer ) {
|
||||||
|
$this->footer += $footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
protected function returnJson( $data ) {
|
||||||
|
header( 'Content-Type: application/json' );
|
||||||
|
echo json_encode( $data );
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function throwError( $msg, $code = '' ) {
|
||||||
|
header( 'Content-Type: application/json' );
|
||||||
|
echo json_encode( [ 'status' => 'echec', 'msg' => $msg, 'code' => $code ], JSON_PRETTY_PRINT );
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller;
|
||||||
|
|
||||||
|
class Error extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error constructor.
|
||||||
|
*
|
||||||
|
* @param int $ErrCode
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function __construct( $ErrCode = 500, $message = '' ) {
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$tabCode = [
|
||||||
|
//Informational 1xx
|
||||||
|
100 => [ 'label' => '100 Continue', 'msg' => '100 Continue' ],
|
||||||
|
101 => [ 'label' => '101 Switching Protocols', 'msg' => '101 Switching Protocols' ],
|
||||||
|
//Successful 2xx
|
||||||
|
200 => [ 'label' => '200 OK', 'msg' => '200 OK' ],
|
||||||
|
201 => [ 'label' => '201 Created', 'msg' => '201 Created' ],
|
||||||
|
202 => [ 'label' => '202 Accepted', 'msg' => '202 Accepted' ],
|
||||||
|
203 => [ 'label' => '203 Non-Authoritative Information', 'msg' => '203 Non-Authoritative Information' ],
|
||||||
|
204 => [ 'label' => '204 No Content', 'msg' => '204 No Content' ],
|
||||||
|
205 => [ 'label' => '205 Reset Content', 'msg' => '205 Reset Content' ],
|
||||||
|
206 => [ 'label' => '206 Partial Content', 'msg' => '206 Partial Content' ],
|
||||||
|
226 => [ 'label' => '226 IM Used', 'msg' => '226 IM Used' ],
|
||||||
|
//Redirection 3xx
|
||||||
|
300 => [ 'label' => '300 Multiple Choices', 'msg' => '300 Multiple Choices' ],
|
||||||
|
301 => [ 'label' => '301 Moved Permanently', 'msg' => '301 Moved Permanently' ],
|
||||||
|
302 => [ 'label' => '302 Found', 'msg' => '302 Found' ],
|
||||||
|
303 => [ 'label' => '303 See Other', 'msg' => '303 See Other' ],
|
||||||
|
304 => [ 'label' => '304 Not Modified', 'msg' => '304 Not Modified' ],
|
||||||
|
305 => [ 'label' => '305 Use Proxy', 'msg' => '305 Use Proxy' ],
|
||||||
|
306 => [ 'label' => '306 (Unused)', 'msg' => '306 (Unused)' ],
|
||||||
|
307 => [ 'label' => '307 Temporary Redirect', 'msg' => '307 Temporary Redirect' ],
|
||||||
|
//Client Error 4xx
|
||||||
|
400 => [ 'label' => '400 Bad Request', 'msg' => '400 Bad Request' ],
|
||||||
|
401 => [ 'label' => '401 Unauthorized', 'msg' => 'Vous n\'êtes pas autorisé à accéder à cette page' ],
|
||||||
|
402 => [ 'label' => '402 Payment Required', 'msg' => '402 Payment Required' ],
|
||||||
|
403 => [ 'label' => '403 Forbidden', 'msg' => '403 Forbidden' ],
|
||||||
|
404 => [ 'label' => '404 Not Found', 'msg' => 'Page non trouvée' ],
|
||||||
|
405 => [ 'label' => '405 Method Not Allowed', 'msg' => '405 Method Not Allowed' ],
|
||||||
|
406 => [ 'label' => '406 Not Acceptable', 'msg' => '406 Not Acceptable' ],
|
||||||
|
407 => [ 'label' => '407 Proxy Authentication Required', 'msg' => '407 Proxy Authentication Required' ],
|
||||||
|
408 => [ 'label' => '408 Request Timeout', 'msg' => '408 Request Timeout' ],
|
||||||
|
409 => [ 'label' => '409 Conflict', 'msg' => '409 Conflict' ],
|
||||||
|
410 => [ 'label' => '410 Gone', 'msg' => '410 Gone' ],
|
||||||
|
411 => [ 'label' => '411 Length Required', 'msg' => '411 Length Required' ],
|
||||||
|
412 => [ 'label' => '412 Precondition Failed', 'msg' => '412 Precondition Failed' ],
|
||||||
|
413 => [ 'label' => '413 Request Entity Too Large', 'msg' => '413 Request Entity Too Large' ],
|
||||||
|
414 => [ 'label' => '414 Request-URI Too Long', 'msg' => '414 Request-URI Too Long' ],
|
||||||
|
415 => [ 'label' => '415 Unsupported Media Type', 'msg' => '415 Unsupported Media Type' ],
|
||||||
|
416 => [ 'label' => '416 Requested Range Not Satisfiable', 'msg' => '416 Requested Range Not Satisfiable' ],
|
||||||
|
417 => [ 'label' => '417 Expectation Failed', 'msg' => '417 Expectation Failed' ],
|
||||||
|
418 => [ 'label' => '418 I\'m a teapot', 'msg' => '418 I\'m a teapot' ],
|
||||||
|
422 => [ 'label' => '422 Unprocessable Entity', 'msg' => '422 Unprocessable Entity' ],
|
||||||
|
423 => [ 'label' => '423 Locked', 'msg' => '423 Locked' ],
|
||||||
|
426 => [ 'label' => '426 Upgrade Required', 'msg' => '426 Upgrade Required' ],
|
||||||
|
428 => [ 'label' => '428 Precondition Required', 'msg' => '428 Precondition Required' ],
|
||||||
|
429 => [ 'label' => '429 Too Many Requests', 'msg' => '429 Too Many Requests' ],
|
||||||
|
431 => [ 'label' => '431 Request Header Fields Too Large', 'msg' => '431 Request Header Fields Too Large' ],
|
||||||
|
//Server Error 5xx
|
||||||
|
500 => [ 'label' => '500 Internal Server Error', 'msg' => 'Une erreur est survenue' ],
|
||||||
|
501 => [ 'label' => '501 Not Implemented', 'msg' => '501 Not Implemented' ],
|
||||||
|
502 => [ 'label' => '502 Bad Gateway', 'msg' => '502 Bad Gateway' ],
|
||||||
|
503 => [ 'label' => '503 Service Unavailable', 'msg' => '503 Service Unavailable' ],
|
||||||
|
504 => [ 'label' => '504 Gateway Timeout', 'msg' => '504 Gateway Timeout' ],
|
||||||
|
505 => [ 'label' => '505 HTTP Version Not Supported', 'msg' => '505 HTTP Version Not Supported' ],
|
||||||
|
506 => [ 'label' => '506 Variant Also Negotiates', 'msg' => '506 Variant Also Negotiates' ],
|
||||||
|
510 => [ 'label' => '510 Not Extended', 'msg' => '510 Not Extended' ],
|
||||||
|
511 => [ 'label' => '511 Network Authentication Required', 'msg' => '511 Network Authentication Required' ]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ( isset( $tabCode[ $ErrCode ] ) ) {
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[ $ErrCode ]['label'] );
|
||||||
|
if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
|
||||||
|
$this->throwError( $tabCode[ $ErrCode ]['msg'], 'Erreur_' . $ErrCode );
|
||||||
|
}
|
||||||
|
$erreur = $tabCode[ $ErrCode ]['msg'];
|
||||||
|
$this->addData( [ 'erreur' => $erreur ] );
|
||||||
|
} else {
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[500]['label'] );
|
||||||
|
if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
|
||||||
|
$this->throwError( $tabCode[500]['msg'], 'Erreur_500' );
|
||||||
|
}
|
||||||
|
$erreur = $tabCode[500]['msg'];
|
||||||
|
$this->addData( [ 'erreur' => $erreur ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $message ) ) {
|
||||||
|
$this->addData( [ 'message' => $message ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller\Site;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Controller\ControllerSite;
|
||||||
|
|
||||||
|
class Index extends ControllerSite {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->addHead( [
|
||||||
|
] );
|
||||||
|
|
||||||
|
$this->addFooter( [
|
||||||
|
|
||||||
|
] );
|
||||||
|
|
||||||
|
$this->addData( [] );
|
||||||
|
$this->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller\Site;
|
||||||
|
|
||||||
|
use CAUProject3Contact\Controller\ControllerSite;
|
||||||
|
|
||||||
|
class SiteError extends ControllerSite {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SiteError constructor.
|
||||||
|
*
|
||||||
|
* @param int $ErrCode
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function __construct( $ErrCode = 500, $message = '' ) {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$tabCode = [
|
||||||
|
//Informational 1xx
|
||||||
|
100 => [ 'label' => '100 Continue', 'msg' => '100 Continue' ],
|
||||||
|
101 => [ 'label' => '101 Switching Protocols', 'msg' => '101 Switching Protocols' ],
|
||||||
|
//Successful 2xx
|
||||||
|
200 => [ 'label' => '200 OK', 'msg' => '200 OK' ],
|
||||||
|
201 => [ 'label' => '201 Created', 'msg' => '201 Created' ],
|
||||||
|
202 => [ 'label' => '202 Accepted', 'msg' => '202 Accepted' ],
|
||||||
|
203 => [ 'label' => '203 Non-Authoritative Information', 'msg' => '203 Non-Authoritative Information' ],
|
||||||
|
204 => [ 'label' => '204 No Content', 'msg' => '204 No Content' ],
|
||||||
|
205 => [ 'label' => '205 Reset Content', 'msg' => '205 Reset Content' ],
|
||||||
|
206 => [ 'label' => '206 Partial Content', 'msg' => '206 Partial Content' ],
|
||||||
|
226 => [ 'label' => '226 IM Used', 'msg' => '226 IM Used' ],
|
||||||
|
//Redirection 3xx
|
||||||
|
300 => [ 'label' => '300 Multiple Choices', 'msg' => '300 Multiple Choices' ],
|
||||||
|
301 => [ 'label' => '301 Moved Permanently', 'msg' => '301 Moved Permanently' ],
|
||||||
|
302 => [ 'label' => '302 Found', 'msg' => '302 Found' ],
|
||||||
|
303 => [ 'label' => '303 See Other', 'msg' => '303 See Other' ],
|
||||||
|
304 => [ 'label' => '304 Not Modified', 'msg' => '304 Not Modified' ],
|
||||||
|
305 => [ 'label' => '305 Use Proxy', 'msg' => '305 Use Proxy' ],
|
||||||
|
306 => [ 'label' => '306 (Unused)', 'msg' => '306 (Unused)' ],
|
||||||
|
307 => [ 'label' => '307 Temporary Redirect', 'msg' => '307 Temporary Redirect' ],
|
||||||
|
//Client Error 4xx
|
||||||
|
400 => [ 'label' => '400 Bad Request', 'msg' => '400 Bad Request' ],
|
||||||
|
401 => [ 'label' => '401 Unauthorized', 'msg' => '401 Unauthorized' ],
|
||||||
|
402 => [ 'label' => '402 Payment Required', 'msg' => '402 Payment Required' ],
|
||||||
|
403 => [ 'label' => '403 Forbidden', 'msg' => '403 Forbidden' ],
|
||||||
|
404 => [ 'label' => '404 Not Found', 'msg' => 'Page non trouvée' ],
|
||||||
|
405 => [ 'label' => '405 Method Not Allowed', 'msg' => '405 Method Not Allowed' ],
|
||||||
|
406 => [ 'label' => '406 Not Acceptable', 'msg' => '406 Not Acceptable' ],
|
||||||
|
407 => [ 'label' => '407 Proxy Authentication Required', 'msg' => '407 Proxy Authentication Required' ],
|
||||||
|
408 => [ 'label' => '408 Request Timeout', 'msg' => '408 Request Timeout' ],
|
||||||
|
409 => [ 'label' => '409 Conflict', 'msg' => '409 Conflict' ],
|
||||||
|
410 => [ 'label' => '410 Gone', 'msg' => 'Cet artisan n\'est plus plus référencé sur Eldotravo' ],
|
||||||
|
411 => [ 'label' => '411 Length Required', 'msg' => '411 Length Required' ],
|
||||||
|
412 => [ 'label' => '412 Precondition Failed', 'msg' => '412 Precondition Failed' ],
|
||||||
|
413 => [ 'label' => '413 Request Entity Too Large', 'msg' => '413 Request Entity Too Large' ],
|
||||||
|
414 => [ 'label' => '414 Request-URI Too Long', 'msg' => '414 Request-URI Too Long' ],
|
||||||
|
415 => [ 'label' => '415 Unsupported Media Type', 'msg' => '415 Unsupported Media Type' ],
|
||||||
|
416 => [ 'label' => '416 Requested Range Not Satisfiable', 'msg' => '416 Requested Range Not Satisfiable' ],
|
||||||
|
417 => [ 'label' => '417 Expectation Failed', 'msg' => '417 Expectation Failed' ],
|
||||||
|
418 => [ 'label' => '418 I\'m a teapot', 'msg' => '418 I\'m a teapot' ],
|
||||||
|
422 => [ 'label' => '422 Unprocessable Entity', 'msg' => '422 Unprocessable Entity' ],
|
||||||
|
423 => [ 'label' => '423 Locked', 'msg' => '423 Locked' ],
|
||||||
|
426 => [ 'label' => '426 Upgrade Required', 'msg' => '426 Upgrade Required' ],
|
||||||
|
428 => [ 'label' => '428 Precondition Required', 'msg' => '428 Precondition Required' ],
|
||||||
|
429 => [ 'label' => '429 Too Many Requests', 'msg' => '429 Too Many Requests' ],
|
||||||
|
431 => [ 'label' => '431 Request Header Fields Too Large', 'msg' => '431 Request Header Fields Too Large' ],
|
||||||
|
//Server Error 5xx
|
||||||
|
500 => [ 'label' => '500 Internal Server Error', 'msg' => 'Une erreur est survenue' ],
|
||||||
|
501 => [ 'label' => '501 Not Implemented', 'msg' => '501 Not Implemented' ],
|
||||||
|
502 => [ 'label' => '502 Bad Gateway', 'msg' => '502 Bad Gateway' ],
|
||||||
|
503 => [ 'label' => '503 Service Unavailable', 'msg' => '503 Service Unavailable' ],
|
||||||
|
504 => [ 'label' => '504 Gateway Timeout', 'msg' => '504 Gateway Timeout' ],
|
||||||
|
505 => [ 'label' => '505 HTTP Version Not Supported', 'msg' => '505 HTTP Version Not Supported' ],
|
||||||
|
506 => [ 'label' => '506 Variant Also Negotiates', 'msg' => '506 Variant Also Negotiates' ],
|
||||||
|
510 => [ 'label' => '510 Not Extended', 'msg' => '510 Not Extended' ],
|
||||||
|
511 => [ 'label' => '511 Network Authentication Required', 'msg' => '511 Network Authentication Required' ]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ( isset( $tabCode[ $ErrCode ] ) ) {
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[ $ErrCode ]['label'] );
|
||||||
|
if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
|
||||||
|
$this->throwError( 'Erreur ' . $tabCode[ $ErrCode ]['label'], 'Erreur_' . $ErrCode );
|
||||||
|
}
|
||||||
|
$erreur = $tabCode[ $ErrCode ]['msg'];
|
||||||
|
$this->addData( [ 'erreur' => $erreur ] );
|
||||||
|
} else {
|
||||||
|
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[500]['label'] );
|
||||||
|
if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
|
||||||
|
$this->throwError( 'Erreur ' . $tabCode[500]['label'], 'Erreur_500' );
|
||||||
|
}
|
||||||
|
$erreur = $tabCode[500]['msg'];
|
||||||
|
$this->addData( [ 'erreur' => $erreur ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $message ) ) {
|
||||||
|
$this->addData( [ 'message' => $message ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addHead( [
|
||||||
|
'title' => 'Un erreur est survenue',
|
||||||
|
'description' => 'Oops une erreur est survenue',
|
||||||
|
'robotNoIndex' => true
|
||||||
|
] );
|
||||||
|
|
||||||
|
$this->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Controller\Site;
|
||||||
|
|
||||||
|
class SiteRouter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SiteRouter constructor.
|
||||||
|
*
|
||||||
|
* @param $pages
|
||||||
|
*/
|
||||||
|
public function __construct( $pages ) {
|
||||||
|
|
||||||
|
set_error_handler( 'errorHandler' );
|
||||||
|
|
||||||
|
if ( $pages[0] == '' ) {
|
||||||
|
new Index();
|
||||||
|
} else {
|
||||||
|
new SiteError( 404 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Model;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class BDD {
|
||||||
|
const SQL_SERVER = 'sql.sanchez-mathieu.fr'; // BDD Server
|
||||||
|
const SQL_LOGIN = 'why7n0_contact'; // BDD Login
|
||||||
|
const SQL_PASSWORD = 'fC3c87Gy'; // BDD Password
|
||||||
|
const SQL_DB = 'why7n0_contact'; // BDD Name
|
||||||
|
|
||||||
|
private static $bdd;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
try {
|
||||||
|
$pdo_options = [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
|
||||||
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
|
||||||
|
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 );
|
||||||
|
} catch ( Exception $e ) {
|
||||||
|
die( 'Erreur : ' . $e->getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function instance() {
|
||||||
|
return self::$bdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function lastInsertId() {
|
||||||
|
return self::$bdd->lastInsertId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Model;
|
||||||
|
|
||||||
|
abstract class BDTables {
|
||||||
|
|
||||||
|
// const NOM = 'bd_nom'
|
||||||
|
// Ex : const ABONNEMENT = 'abonnement';
|
||||||
|
|
||||||
|
const LOGS = "logs";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
+1913
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class Logs {
|
||||||
|
|
||||||
|
const ERROR_LEVEL = [
|
||||||
|
1 => 'E_ERROR',
|
||||||
|
2 => 'E_WARNING',
|
||||||
|
4 => 'E_PARSE',
|
||||||
|
8 => 'E_NOTICE',
|
||||||
|
16 => 'E_CORE_ERROR',
|
||||||
|
32 => 'E_CORE_WARNING',
|
||||||
|
64 => 'E_COMPILE_ERROR',
|
||||||
|
128 => 'E_COMPILE_WARNING',
|
||||||
|
256 => 'E_USER_ERROR',
|
||||||
|
512 => 'E_USER_WARNING',
|
||||||
|
1024 => 'E_USER_NOTICE',
|
||||||
|
2048 => 'E_STRICT',
|
||||||
|
4096 => 'E_RECOVERABLE_ERROR',
|
||||||
|
8192 => 'E_DEPRECATED',
|
||||||
|
16384 => 'E_USER_DEPRECATED',
|
||||||
|
32767 => 'E_ALL'
|
||||||
|
];
|
||||||
|
public $id;
|
||||||
|
public $level;
|
||||||
|
public $message;
|
||||||
|
public $file;
|
||||||
|
public $line;
|
||||||
|
public $date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs constructor.
|
||||||
|
*
|
||||||
|
* @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 $level = null, string $message = null, string $file = null, string $line = null, string $date = null ) {
|
||||||
|
if ( $id === null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->id = $id;
|
||||||
|
$this->level = $level;
|
||||||
|
$this->message = $message;
|
||||||
|
$this->file = $file;
|
||||||
|
$this->line = $line;
|
||||||
|
$this->date = $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 ) )
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne un tableau des derniers logs (limite en param)
|
||||||
|
*
|
||||||
|
* @param int $limit
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getLastLogs( int $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['level'], $l['message'], $l['file'], $l['line'], $l['date'] );
|
||||||
|
$return[] = $log;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
public function setId( $id ) {
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLevel() {
|
||||||
|
return $this->level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $level
|
||||||
|
*/
|
||||||
|
public function setLevel( $level ) {
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMessage() {
|
||||||
|
return htmlspecialchars( $this->message );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function setMessage( $message ) {
|
||||||
|
$this->message = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFile() {
|
||||||
|
return htmlspecialchars( $this->file );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $file
|
||||||
|
*/
|
||||||
|
public function setFile( $file ) {
|
||||||
|
$this->file = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLine() {
|
||||||
|
return htmlspecialchars( $this->line );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $line
|
||||||
|
*/
|
||||||
|
public function setLine( $line ) {
|
||||||
|
$this->line = $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDate() {
|
||||||
|
return $this->date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $date
|
||||||
|
*/
|
||||||
|
public function setDate( $date ) {
|
||||||
|
$this->date = $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le type d'erreur en string (label)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getErrorLabel() {
|
||||||
|
return htmlspecialchars( self::ERROR_LEVEL[ $this->level ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace CAUProject3Contact\Model;
|
||||||
|
|
||||||
|
class Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée une reqette d'insertion en base àpartir du nom de la table et d'un tableau associatif et l'exécute
|
||||||
|
*
|
||||||
|
* @param string $tableName
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return int lastInsertId
|
||||||
|
*/
|
||||||
|
public static function insert( string $tableName, array $data ) {
|
||||||
|
$req = BDD::instance()->prepare( 'INSERT INTO ' . $tableName . ' (' . implode( ', ', array_keys( $data ) ) . ')
|
||||||
|
VALUES (' . ':' . implode( ', :', array_keys( $data ) ) . ')' );
|
||||||
|
$req->execute( $data );
|
||||||
|
|
||||||
|
return BDD::lastInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Met à jour les données d'une ligne d'un table données
|
||||||
|
*
|
||||||
|
* @param string $tableName
|
||||||
|
* @param array $data
|
||||||
|
* @param string $idColumn
|
||||||
|
* @param int $idValue
|
||||||
|
*/
|
||||||
|
public static function update( string $tableName, array $data, string $idColumn, int $idValue ) {
|
||||||
|
$reqStr = 'UPDATE ' . $tableName . ' SET ';
|
||||||
|
$lastKey = endKey( $data );
|
||||||
|
foreach ( $data as $key => $value ) {
|
||||||
|
$reqStr .= $key . ' = :' . $key;
|
||||||
|
if ( $key != $lastKey ) {
|
||||||
|
$reqStr .= ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$reqStr .= ' WHERE ' . $idColumn . ' = :' . $idColumn;
|
||||||
|
$data[ $idColumn ] = $idValue;
|
||||||
|
|
||||||
|
//echo $reqStr; exit();
|
||||||
|
|
||||||
|
$req = BDD::instance()->prepare( $reqStr );
|
||||||
|
$req->execute( $data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
echo $erreur;
|
||||||
|
?>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
Bonjour 2
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<div class="content">
|
||||||
|
<div class="error-page-container">
|
||||||
|
<div class="error-title"><?= $erreur ?></div>
|
||||||
|
<div class="error-message">Que voulez-vous faire ?</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<script src="/js/jquery-3.2.1.min.js"></script>
|
||||||
|
<script src="/js/javascript.js?v=<?= CAUProject3Contact\Config::SITE_JS_VERSION ?>"></script>
|
||||||
|
<link href="/css/style.css?v=<?= CAUProject3Contact\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" id="status-bar" content="white-translucent">
|
||||||
|
<meta name="format-detection" content="telephone=no">
|
||||||
|
|
||||||
|
<meta name="author" content="Eldotravo">
|
||||||
|
|
||||||
|
<title><?= $this->head['title'] ?></title>
|
||||||
|
<meta name="description" content="<?= $this->head['description'] ?>">
|
||||||
|
|
||||||
|
<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'] . \CAUProject3Contact\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=<?= CAUProject3Contact\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
|
||||||
|
<link href="/css/select2.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<link rel="image_src" href="<?php \CAUProject3Contact\Config::FAVICON_PATH ?>"/>
|
||||||
|
<link rel="icon" type="image/png" href="<?php \CAUProject3Contact\Config::FAVICON_PATH ?>"/>
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|
||||||
|
<?php if ( isset( $this->head['robotNoIndex'] ) && $this->head['robotNoIndex'] == true ) { ?>
|
||||||
|
<meta name="robots" content="noindex"/>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
@@ -0,0 +1,413 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include( 'src/lib/mail/PHPMailerAutoload.php' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de remplacer les accents et les apostrophes dans l'url
|
||||||
|
*
|
||||||
|
* @param string $str l'url à formater
|
||||||
|
* @param string $encoding
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function formatURL( string $str, $encoding = 'utf-8' ) {
|
||||||
|
|
||||||
|
$str = str_replace( "+", "_plus_", $str );
|
||||||
|
$str = str_replace( "%", "_pourcent_", $str );
|
||||||
|
$str = str_replace( "&", "_et_", $str );
|
||||||
|
|
||||||
|
//on remplace les apotrophes et espaces par des underscore
|
||||||
|
$str = str_replace( array( "'", " ", "," ), "_", $str );
|
||||||
|
|
||||||
|
$str = str_replace( "__", "_", $str );
|
||||||
|
|
||||||
|
// transformer les caractères accentués en entités HTML
|
||||||
|
$str = htmlentities( $str, ENT_NOQUOTES, $encoding );
|
||||||
|
// remplacer les entités HTML pour avoir juste le premier caractères non accentués
|
||||||
|
// Exemple : "&ecute;" => "e", "&Ecute;" => "E", "Ã " => "a" ...
|
||||||
|
$str = preg_replace( '#&([A-za-z])(?:acute|grave|cedil|circ|orn|ring|slash|th|tilde|uml);#', '\1', $str );
|
||||||
|
|
||||||
|
// Remplacer les ligatures tel que : Œ, Æ ...
|
||||||
|
// Exemple "Å“" => "oe"
|
||||||
|
$str = preg_replace( '#&([A-za-z]{2})(?:lig);#', '\1', $str );
|
||||||
|
// Supprimer tout le reste
|
||||||
|
//$str = preg_replace('#&[^;]+;#', '', $str);
|
||||||
|
$str = str_replace( array( "#", "&", "[", "^", ";", "]" ), '', $str );
|
||||||
|
|
||||||
|
//on passe tout en minuscule
|
||||||
|
$str = strtolower( $str );
|
||||||
|
|
||||||
|
if ( substr( $str, - 1 ) == '_' ) {
|
||||||
|
$str = substr( $str, 0, - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* La fonction darkroom() renomme et redimensionne les photos envoyées lors de l'ajout d'un objet.
|
||||||
|
*
|
||||||
|
* @param $img String Chemin absolu de l'image d'origine.
|
||||||
|
* @param $to String Chemin absolu de l'image générée (.jpg).
|
||||||
|
* @param $width Int Largeur de l'image générée. Si 0, valeur calculée en fonction de $height.
|
||||||
|
* @param $height Int Hauteur de l'image génétée. Si 0, valeur calculée en fonction de $width.
|
||||||
|
* Si $height = 0 et $width = 0, dimensions conservées mais conversion en .jpg
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function darkroom( $img, $to, $width = 0, $height = 0, $quality = 100, $useGD = true ) {
|
||||||
|
|
||||||
|
$dimensions = getimagesize( $img );
|
||||||
|
$ratio = $dimensions[0] / $dimensions[1];
|
||||||
|
|
||||||
|
// Calcul des dimensions si 0 passé en paramètre
|
||||||
|
if ( $width == 0 && $height == 0 ) {
|
||||||
|
$width = $dimensions[0];
|
||||||
|
$height = $dimensions[1];
|
||||||
|
} else if ( $height == 0 ) {
|
||||||
|
$height = round( $width / $ratio );
|
||||||
|
} else if ( $width == 0 ) {
|
||||||
|
$width = round( $height * $ratio );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $dimensions[0] > ( $width / $height ) * $dimensions[1] ) {
|
||||||
|
$dimY = $height;
|
||||||
|
$dimX = round( $height * $dimensions[0] / $dimensions[1] );
|
||||||
|
}
|
||||||
|
if ( $dimensions[0] < ( $width / $height ) * $dimensions[1] ) {
|
||||||
|
$dimX = $width;
|
||||||
|
$dimY = round( $width * $dimensions[1] / $dimensions[0] );
|
||||||
|
}
|
||||||
|
if ( $dimensions[0] == ( $width / $height ) * $dimensions[1] ) {
|
||||||
|
$dimX = $width;
|
||||||
|
$dimY = $height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Création de l'image avec la librairie GD
|
||||||
|
if ( $useGD ) {
|
||||||
|
$pattern = imagecreatetruecolor( $width, $height );
|
||||||
|
$type = mime_content_type( $img );
|
||||||
|
switch ( substr( $type, 6 ) ) {
|
||||||
|
case 'jpeg':
|
||||||
|
$image = imagecreatefromjpeg( $img );
|
||||||
|
break;
|
||||||
|
case 'gif':
|
||||||
|
$image = imagecreatefromgif( $img );
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
$image = imagecreatefrompng( $img );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imagecopyresampled( $pattern, $image, 0, 0, 0, 0, $dimX, $dimY, $dimensions[0], $dimensions[1] );
|
||||||
|
imagedestroy( $image );
|
||||||
|
imagejpeg( $pattern, $to, $quality );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redéfini la gestion des erreurs
|
||||||
|
*
|
||||||
|
* @param $errno
|
||||||
|
* @param $errstr
|
||||||
|
* @param $errfile
|
||||||
|
* @param $errline
|
||||||
|
*
|
||||||
|
* @return bool|void
|
||||||
|
*/
|
||||||
|
function errorHandler( $errno, $errstr, $errfile, $errline ) {
|
||||||
|
if ( ! ( error_reporting() & $errno ) ) {
|
||||||
|
// Ce code d'erreur n'est pas inclus dans error_reporting()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insertion des logs
|
||||||
|
\CAUProject3Contact\Model\Logs::insert( $errno, $errstr, $errfile, $errline, date( 'Y-m-d H:i:s' ) );
|
||||||
|
|
||||||
|
ob_clean();
|
||||||
|
new \CAUProject3Contact\Controller\Site\SiteError( 500 );
|
||||||
|
|
||||||
|
/* Ne pas exécuter le gestionnaire interne de PHP */
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* Fonction permettant de récupérer des informations sur le navigateur utiliser par l'utilisateur
|
||||||
|
*/
|
||||||
|
function getBrowser() {
|
||||||
|
|
||||||
|
$u_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
$bname = 'Unknown';
|
||||||
|
$platform = 'Unknown';
|
||||||
|
$ub = "";
|
||||||
|
|
||||||
|
//First get the platform?
|
||||||
|
if ( preg_match( '/android/i', $u_agent ) || preg_match( '/Android/i', $u_agent ) ) {
|
||||||
|
$platform = 'android';
|
||||||
|
} else if ( preg_match( '/linux/i', $u_agent ) ) {
|
||||||
|
$platform = 'linux';
|
||||||
|
} else if ( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
|
||||||
|
$platform = 'mac';
|
||||||
|
} else if ( preg_match( '/windows|win32/i', $u_agent ) ) {
|
||||||
|
$platform = 'windows';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( strstr( $u_agent, 'mobile' ) || strstr( $u_agent, 'Mobile' ) ) {
|
||||||
|
$platform .= ' mobile';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next get the name of the useragent yes seperately and for good reason
|
||||||
|
if ( preg_match( '/MSIE/i', $u_agent ) && ! preg_match( '/Opera/i', $u_agent ) ) {
|
||||||
|
$bname = 'Internet Explorer';
|
||||||
|
$ub = "MSIE";
|
||||||
|
} else if ( preg_match( '/Edge/i', $u_agent ) ) {
|
||||||
|
$bname = 'Microsoft Edge';
|
||||||
|
$ub = "Edge";
|
||||||
|
} else if ( preg_match( '/Trident/i', $u_agent ) ) {
|
||||||
|
$bname = 'Internet Explorer';
|
||||||
|
$ub = "rv";
|
||||||
|
} else if ( preg_match( '/Firefox/i', $u_agent ) ) {
|
||||||
|
$bname = 'Mozilla Firefox';
|
||||||
|
$ub = "Firefox";
|
||||||
|
} else if ( preg_match( '/Chrome/i', $u_agent ) ) {
|
||||||
|
$bname = 'Google Chrome';
|
||||||
|
$ub = "Chrome";
|
||||||
|
} else if ( preg_match( '/Safari/i', $u_agent ) ) {
|
||||||
|
$bname = 'Apple Safari';
|
||||||
|
$ub = "Safari";
|
||||||
|
} else if ( preg_match( '/Opera/i', $u_agent ) ) {
|
||||||
|
$bname = 'Opera';
|
||||||
|
$ub = "Opera";
|
||||||
|
} else if ( preg_match( '/Netscape/i', $u_agent ) ) {
|
||||||
|
$bname = 'Netscape';
|
||||||
|
$ub = "Netscape";
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally get the correct version number
|
||||||
|
// Added "|:"
|
||||||
|
$known = array( 'Version', $ub, 'other' );
|
||||||
|
$pattern = '#(?<browser>' . join( '|', $known ) . ')[/|: ]+(?<version>[0-9.|a-zA-Z.]*)#';
|
||||||
|
if ( ! preg_match_all( $pattern, $u_agent, $matches ) ) {
|
||||||
|
// we have no matching number just continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// see how many we have
|
||||||
|
$i = count( $matches['browser'] );
|
||||||
|
if ( $i != 1 ) {
|
||||||
|
//we will have two since we are not using 'other' argument yet
|
||||||
|
//see if version is before or after the name
|
||||||
|
if ( strripos( $u_agent, "Version" ) < strripos( $u_agent, $ub ) ) {
|
||||||
|
$version = $matches['version'][0];
|
||||||
|
} else {
|
||||||
|
$version = $matches['version'][1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$version = $matches['version'][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we have a number
|
||||||
|
if ( $version == null || $version == "" ) {
|
||||||
|
$version = "?";
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'userAgent' => $u_agent,
|
||||||
|
'platform' => $platform,
|
||||||
|
'version' => $version,
|
||||||
|
'pattern' => $pattern,
|
||||||
|
'name' => $bname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $string
|
||||||
|
* @param $limit
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getLimitWord( $string, $limit ) {
|
||||||
|
$i = $limit;
|
||||||
|
if ( ! isset( $string ) || empty( $string ) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
while ( $i > 0 && $string[ $i ] != ' ' ) {
|
||||||
|
$i --;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $destinataires [nom du destinataire => adresse du destinataire] On peut en ajouter autant que l'on veut
|
||||||
|
* @param string $subject Objet du mail
|
||||||
|
* @param string $body Corp du mail
|
||||||
|
* @param string|null $auteurMail L'auteur du mail Par défaut eldotravo@gmail.com
|
||||||
|
* @param array|null $files [nom du fichier => chemin du fichier] On peut en ajouter autant que l'on veut
|
||||||
|
* @param array|null $cci [nom du cci => adresse du cci] On peut en ajouter autant que l'on veut
|
||||||
|
* @param array|null $cc [nom du cc => adresse du cc] On peut en ajouter autant que l'on veut
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
function email(array $destinataires, string $subject, string $body, string $auteurMail = null, array $files = null, array $cci = null, $cc = null) {
|
||||||
|
date_default_timezone_set('Etc/UTC');
|
||||||
|
|
||||||
|
//Create a new PHPMailer instance
|
||||||
|
$mail = new PHPMailer;
|
||||||
|
$mail->isSMTP();
|
||||||
|
$mail->Host = ""; // Host SMTP du server d'envoi du mail
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->Username = ""; // Identifiant de connection
|
||||||
|
$mail->Password = ""; // Mot de passe de connection
|
||||||
|
$mail->SMTPSecure = 'ssl';
|
||||||
|
$mail->Port = 465; // Port
|
||||||
|
//Enable SMTP debugging (0 = off (for production use), 1 = client messages, 2 = client and server messages)
|
||||||
|
$mail->SMTPDebug = 0;
|
||||||
|
//Ask for HTML-friendly debug output
|
||||||
|
$mail->Debugoutput = 'html';
|
||||||
|
$mail->Sender = ""; // l'email d'envoi
|
||||||
|
if ($auteurMail == 'Marie-Paule'){
|
||||||
|
$mail->setFrom("" , ""); // Mail affiché d'envoi, nom affiché d'envoi
|
||||||
|
$mail->addReplyTo("", ""); // Mail de reply, nom de reply
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajout de tout les utilisateurs
|
||||||
|
foreach ($destinataires as $nom => $adresseMail){
|
||||||
|
if (!empty($adresseMail)) {
|
||||||
|
$mail->addAddress($adresseMail, $nom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajout de pièces jointes
|
||||||
|
if (!empty($files)){
|
||||||
|
foreach ($files as $name => $file){
|
||||||
|
if (file_exists($file)){
|
||||||
|
$mail->addAttachment($file, $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajout des CCI
|
||||||
|
if (!empty($cci)){
|
||||||
|
foreach ($cci as $nom => $adresseMail){
|
||||||
|
if (!empty($adresseMail)){
|
||||||
|
$mail->addBCC($adresseMail, $nom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajout des CC
|
||||||
|
if (!empty($cc)){
|
||||||
|
foreach ($cc as $nom => $adresseMail){
|
||||||
|
if (!empty($adresseMail)){
|
||||||
|
$mail->addCC($adresseMail, $nom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$mail->Subject = $subject;
|
||||||
|
$mail->MsgHTML($body);
|
||||||
|
//Replace the plain text body with one created manually
|
||||||
|
$mail->AltBody = '';
|
||||||
|
|
||||||
|
if (!$mail->send()) {
|
||||||
|
// echo "Mailer Error: " . $mail->ErrorInfo;
|
||||||
|
} else {
|
||||||
|
// echo "Message sent!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $file
|
||||||
|
* @param int $angle
|
||||||
|
* @param string $newName
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function rotateImage( string $file, int $angle, string $newName ) {
|
||||||
|
// Initialisation variable pou test futur
|
||||||
|
$image = null;
|
||||||
|
$type = mime_content_type( $file );
|
||||||
|
// Création ressources en fonction de l'image
|
||||||
|
switch ( substr( $type, 6 ) ) {
|
||||||
|
case 'jpeg':
|
||||||
|
$image = imagecreatefromjpeg( $file );
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
$image = imagecreatefrompng( $file );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Si format image non prit en charge
|
||||||
|
if ( $image == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Rotation de l'image
|
||||||
|
$rotate = imagerotate( $image, $angle, 0 );
|
||||||
|
// On recrée l'image au format de base
|
||||||
|
switch ( substr( $type, 6 ) ) {
|
||||||
|
case 'jpeg':
|
||||||
|
imagejpeg( $rotate, $file );
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
imagepng( $rotate, $file );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imagedestroy( $image );
|
||||||
|
imagedestroy( $rotate );
|
||||||
|
rename( $file, $newName );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* Clean toutes les strings dans array en récursif, et filtre pour n'avoir qu'un espaces entre chaque mot
|
||||||
|
*/
|
||||||
|
function cleanArray( array $data ) {
|
||||||
|
if ( ! empty( $data ) ) {
|
||||||
|
foreach ( $data as $key => $donnée ) {
|
||||||
|
switch ( gettype( $donnée ) ) {
|
||||||
|
case 'string':
|
||||||
|
if ( ! empty( $donnée ) ) {
|
||||||
|
$new_string = '';
|
||||||
|
foreach ( explode( ' ', trim( $donnée ) ) as $str ) {
|
||||||
|
if ( ! empty( $str ) ) {
|
||||||
|
if ( $new_string != '' ) {
|
||||||
|
$new_string .= ' ';
|
||||||
|
}
|
||||||
|
$new_string .= $str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data[ $key ] = $new_string;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'array':
|
||||||
|
if ( ! empty( $donnée ) ) {
|
||||||
|
$data[ $key ] = cleanArray( $donnée );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $array
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function endKey( $array ) {
|
||||||
|
end( $array );
|
||||||
|
|
||||||
|
return key( $array );
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPMailer SPL autoloader.
|
||||||
|
* PHP Version 5
|
||||||
|
* @package PHPMailer
|
||||||
|
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||||
|
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||||
|
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||||
|
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||||
|
* @author Brent R. Matzelle (original founder)
|
||||||
|
* @copyright 2012 - 2014 Marcus Bointon
|
||||||
|
* @copyright 2010 - 2012 Jim Jagielski
|
||||||
|
* @copyright 2004 - 2009 Andy Prevost
|
||||||
|
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||||
|
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHPMailer SPL autoloader.
|
||||||
|
*
|
||||||
|
* @param string $classname The name of the class to load
|
||||||
|
*/
|
||||||
|
function PHPMailerAutoload( $classname ) {
|
||||||
|
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||||
|
$filename = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class.' . strtolower( $classname ) . '.php';
|
||||||
|
if ( is_readable( $filename ) ) {
|
||||||
|
require $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( PHP_VERSION, '5.1.2', '>=' ) ) {
|
||||||
|
//SPL autoloading was introduced in PHP 5.1.2
|
||||||
|
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
|
||||||
|
spl_autoload_register( 'PHPMailerAutoload', true, true );
|
||||||
|
} else {
|
||||||
|
spl_autoload_register( 'PHPMailerAutoload' );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* Fall back to traditional autoload for old PHP versions
|
||||||
|
*
|
||||||
|
* @param string $classname The name of the class to load
|
||||||
|
*/
|
||||||
|
function __autoload( $classname ) {
|
||||||
|
PHPMailerAutoload( $classname );
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//FR" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
</head>
|
||||||
|
<body class="body" style="background-color: whitesmoke !important;padding: 40px 0;line-height: 22px;width: 100%;">
|
||||||
|
<div class="contain"
|
||||||
|
style="background-color: white;font-family: Arial, Helvetica, sans-serif; font-size: 16px;margin: auto;padding: 20px;max-width: 500px;width: 90%">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="margin:20px auto;max-width: 500px;text-align: center;width: 90%;">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
html, body, div, span, applet, object, iframe,
|
||||||
|
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||||
|
a, abbr, acronym, address, big, cite, code,
|
||||||
|
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||||
|
small, strike, sub, sup, tt, var,
|
||||||
|
b, u, i, center,
|
||||||
|
dl, dt, dd, ol, ul, li,
|
||||||
|
fieldset, form, label, legend,
|
||||||
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||||
|
article, aside, canvas, details, embed,
|
||||||
|
figure, figcaption, footer, header, hgroup,
|
||||||
|
menu, nav, output, ruby, section, summary,
|
||||||
|
time, mark, audio, video {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
font: inherit;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HTML5 display-role reset for older browsers */
|
||||||
|
article, aside, details, figcaption, figure,
|
||||||
|
footer, header, hgroup, menu, nav, section {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ol, ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote, q {
|
||||||
|
quotes: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote:before, blockquote:after,
|
||||||
|
q:before, q:after {
|
||||||
|
content: '';
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
Whitespace-only changes.
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||||||
|
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=Array.isArray(d)))?(e?(e=!1,f=c&&Array.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;d<c;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={IDLine truncated
|
||||||
|
a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},U=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function V(){this.expando=r.expando+V.uid++}V.uid=1,V.prototype={cache:function(a){var b=a[this.expando];return b||(b={},U(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){Array.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(L)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var W=new V,X=new V,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Z=/[A-Z]/g;function $(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:Y.test(a)?JSON.parse(a):a)}function _(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Z,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=$(c)}catch(e){}X.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return X.hasData(a)||W.hasData(a)},data:function(a,b,c){return X.access(a,b,c)},removeData:function(a,b){X.remove(a,b)},_data:function(a,b,c){return W.access(a,b,c)},_removeData:function(a,b){W.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=X.get(f),1===f.nodeType&&!W.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),_(f,d,e[d])));W.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){X.set(this,a)}):T(this,function(b){var c;if(f&&void 0===b){if(c=X.get(f,a),void 0!==c)return c;if(c=_(f,a),void 0!==c)return c}else this.each(function(){X.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=W.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var aa=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ba=new RegExp("^(?:([+-])=|)("+aa+")([a-z%]*)$","i"),ca=["Top","Right","Bottom","Left"],da=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},ea=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};function fa(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&ba.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var ga={};function ha(a){var b,c=a.ownerDocument,d=a.nodeName,e=ga[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e=Line truncated
|
||||||
|
null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!B(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){var c,d,e=a.options,f=r.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?bLine truncated
|
||||||
Reference in new issue
Block a user