first push for test | try to create archi

WORK-DDA
David D'ALMEIDA 2 years ago
parent a7449f01a2
commit 55beea56d0

@ -0,0 +1,114 @@
kind: pipeline
type: docker
name: HeartWave
# dev is DMZ
trigger:
event:
- push
steps:
- name: test
image: php:7.4
commands:
- cd Sources
# Installe les dépendances PHP si nécessaire
- composer install
# - composer require phpunit/phpunit
- vendor/bin/phpunit common/Tests
# build CONTAINER for app-build on flutter IMAGE
- name: docker-build
build: Sources/src/config
ports:
- "8080:80"
volumes:
- ./php/vhosts:/etc/apache2/sites-enabled
- ./:/var/www
restart: always
- name: code-analysis
image: #####
environment:
SONAR_TOKEN:
from_secret: SONAR_TOKEN
commands:
- export SONAR_SCANNER_VERSION=4.7.0.2747
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -D sonar.projectKey=Bowl_in -D sonar.sources=./Sources/bowlin_project -D sonar.host.url=https://codefirst.iut.uca.fr/sonar -D sonar.flutter.coverage.reportPath=./Sources/bowlin_project/coverage/lcov.info
depends_on: [ test ]
# database container deployment
- name: container-mysql
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
volumes:
- db-data:/var/lib/mysql
environment:
IMAGENAME: mariadb:10
CONTAINERNAME: mysql
COMMAND: create
# OVERWRITE: false
# should be true
PRIVATE: false
CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD:
from_secret: db_root_password
CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE:
from_secret: db_database
CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER:
from_secret: db_user
CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD:
from_secret: db_password
ADMINS: antoineperederii,antoinepinagot,kevinmonteiro,paullevrault,davidd_almeida
- name: phpmyadmin-container
# should find a goog version
image: phpmyadmin
restart: always
ports:
- 8082:80
environment:
PMA_HOST: container-mysql
depends_on:
-container-mysql
networks:
- admin
- name: docker-push
image: plugins/docker
settings:
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
repo: myusername/my-php-app
tags: latest
auto_tag: true
registry: docker.io
- name: deploy-container
image: docker
commands:
- docker stop my-php-container || true
- docker rm my-php-container || true
- docker run -d --name my-php-container -p 80:80 myusername/my-php-app
- name: notify
image: ruby:2.1
rules:
- if: "$CI_COMMIT_TAG =~ /^.*-demo$/"
when: on_success
script:
- sh ./notifymail.sh
volumes:
db-data:
networks:
admin:

24
.gitignore vendored

@ -0,0 +1,24 @@
.idea
node_modules
.vscode
*.swp
*.swo
.env
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
*.sublime-project
# SFTP configuration file
sftp-config.json
sftp-config-alt*.json
*.log*
coverage/

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@ -0,0 +1,93 @@
# HeartTrack
## Présentation
**Nom de l'application :** HeartTrack
### Contexte
HeartTrack est une application web PHP et mobile Android destinée aux sportifs pour l'analyse de courbes cardiaques. L'objectif principal de cette application est de récupérer les données de fréquence cardiaque à partir d'une montre, de les afficher sous forme de courbes, d'identifier des patterns, de fournir des statistiques et de réaliser des prédictions liées à l'effort physique, à la chaleur, à la récupération, etc.
## Récapitulatif du Projet
Le projet HeartTrack, avec son application HeartTrack, vise à offrir une solution complète pour l'analyse des données de fréquence cardiaque, en mettant l'accent sur les besoins des sportifs. L'application sera capable de traiter et d'interpréter les données de manière intelligente, fournissant ainsi des informations précieuses pour optimiser les performances sportives et la santé.
## Répartition du Git
[**Sources**](Sources) : **Code de l'application**
[**Documents**](Documents) : **Documentation de l'application**
--
<img src="Documents/Images/Gitflow.png" />
Le projet HeartTrack utilise un modèle de flux de travail Git (Gitflow) pour organiser le développement. Voici une brève explication des principales branches :
- **branche prod** : Cette branche contient la version de production stable de l'application. Les modifications sur cette branche sont généralement destinées à des mises en production.
- **branche master** : La branche master est similaire à la branche de production, mais elle peut contenir des fonctionnalités en cours de développement qui sont presque prêtes pour une mise en production.
- **branche test** : Cette branche est utilisée pour déployer une version démo de l'application. Elle est mise à jour avec les dernières fonctionnalités et surtout la totalité de leurs test en développement.
- **branche issue** : Pour chaque problème (issue) que vous résolvez, vous devez créer une branche portant le nom de l'issue, par exemple, "issue_#32_nom" où 32 est le numéro de l'issue et nom est une description courte de l'issue. Une fois l'issue résolue, assurez-vous de mettre à jour le changelog et de créer une merge request.
## Développement
### Travailler sur une Issue
Si vous êtes amené à travailler sur une issue, suivez ces principes :
1. Les issues sont créées dans le système de gestion de versions (Git), chaque issue ayant un numéro unique.
2. Lorsque vous décidez de travailler sur une issue, attribuez-vous l'issue et créez une branche avec un nom correspondant à l'issue sous la forme suivante : "issue_#32_nom" où 32 est le numéro de l'issue et nom est son libellé.
3. Une fois que vous avez résolu l'issue dans votre branche, assurez-vous de mettre à jour le changelog avec les modifications apportées.
4. Ensuite, poussez votre branche sur le référentiel distant et créez une merge request pour que vos modifications soient examinées par les autres membres de l'équipe.
## Prérequis
Avant de commencer à travailler sur le projet HeartTrack, assurez-vous d'avoir les prérequis suivants installés :
- Serveur web (par exemple, Apache)
- PHP (version recommandée)
- Base de données (par exemple, MySQL)
- Git
## Installation
Pour installer et exécuter le projet HeartTrack, suivez ces étapes :
1. Clonez ce référentiel sur votre machine locale en utilisant la commande suivante :
`git clone https://codefirst.iut.uca.fr/git/FitDev/Projet_fit_web`
2. Configurez votre environnement de développement avec les prérequis mentionnés ci-dessus.
3. Copiez le fichier de configuration d'exemple et configurez les paramètres de l'application :
cp config/config.example.php config/config.php
4. Importez la structure de la base de données à partir du fichier SQL fourni :
mysql -u votre_nom_utilisateur -p < db_schema.sql
5. Démarrez votre serveur web et accédez à l'application via le navigateur.
## Exécution
Pour exécuter l'application, suivez les instructions d'installation ci-dessus. Une fois l'application configurée et le serveur web en cours d'exécution, accédez à l'application via votre navigateur web.
## Déploiement en Démo
Pour déployer une version de démonstration de l'application, utilisez la branche "demo" du référentiel. Cette branche est généralement mise à jour avec les dernières fonctionnalités en développement.
## Déploiement en Production
Pour déployer la version de production de l'application, utilisez la branche "prod" du référentiel.
---
N'hésitez pas à contribuer au développement de HeartTrack en résolvant des issues ou en ajoutant de nouvelles fonctionnalités. Nous vous encourageons à suivre les principes et les pratiques décrites dans ce document pour un développement efficace et collaboratif.

@ -0,0 +1,3 @@
vendor/
node_modules/
.env

@ -0,0 +1,17 @@
# Utilisez une image de base PHP
FROM php:7.4-apache
# Définissez le répertoire de travail dans le conteneur
WORKDIR /var/www/
# Copiez les fichiers de votre projet dans le conteneur
COPY . /var/www/
# Installez les dépendances PHP (par exemple, si vous utilisez Composer)
RUN composer install
# Exposez le port 80 (port par défaut d'Apache)
EXPOSE 80
# Commande pour démarrer Apache (vous pouvez également utiliser d'autres serveurs web comme Nginx)
CMD ["apache2-foreground"]

@ -0,0 +1,11 @@
<?php
// bdd var => should use .env var
const DB_HOST = 'londres';
const DB_DATABASE = 'dbdadalmeida1';
const DB_USER = 'dadalmeida1';
const DB_PASSWORD = 'achanger';
$dsn ='mysql:host=londres.uca.local;dbname=dbdadalmeida1';
const VIEW_PATH = 'views';

@ -0,0 +1 @@
<!-- IDataManager is a DAO interfaces -->

@ -0,0 +1,8 @@
<?php
class UserManager {
}
?>

@ -0,0 +1,302 @@
<?php
/*
MIT License
Copyright (c) 2012 Danny van Kooten <hi@dannyvankooten.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
class AltoRouter
{
/**
* @var array Array of all routes (incl. named routes).
*/
protected $routes = [];
/**
* @var array Array of all named routes.
*/
protected $namedRoutes = [];
/**
* @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
*/
protected $basePath = '';
/**
* @var array Array of default match types (regex helpers)
*/
protected $matchTypes = [
'i' => '[0-9]++',
'a' => '[0-9A-Za-z]++',
'h' => '[0-9A-Fa-f]++',
'*' => '.+?',
'**' => '.++',
'' => '[^/\.]++'
];
/**
* Create router in one call from config.
*
* @param array $routes
* @param string $basePath
* @param array $matchTypes
* @throws Exception
*/
public function __construct(array $routes = [], $basePath = '', array $matchTypes = [])
{
$this->addRoutes($routes);
$this->setBasePath($basePath);
$this->addMatchTypes($matchTypes);
}
/**
* Retrieves all routes.
* Useful if you want to process or display routes.
* @return array All routes.
*/
public function getRoutes()
{
return $this->routes;
}
/**
* Add multiple routes at once from array in the following format:
*
* $routes = [
* [$method, $route, $target, $name]
* ];
*
* @param array $routes
* @return void
* @author Koen Punt
* @throws Exception
*/
public function addRoutes($routes)
{
if (!is_array($routes) && !$routes instanceof Traversable) {
throw new RuntimeException('Routes should be an array or an instance of Traversable');
}
foreach ($routes as $route) {
call_user_func_array([$this, 'map'], $route);
}
}
/**
* Set the base path.
* Useful if you are running your application from a subdirectory.
* @param string $basePath
*/
public function setBasePath($basePath)
{
$this->basePath = $basePath;
}
/**
* Add named match types. It uses array_merge so keys can be overwritten.
*
* @param array $matchTypes The key is the name and the value is the regex.
*/
public function addMatchTypes(array $matchTypes)
{
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
}
/**
* Map a route to a target
*
* @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
* @param mixed $target The target where this route should point to. Can be anything.
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
* @throws Exception
*/
public function map($method, $route, $target, $name = null)
{
$this->routes[] = [$method, $route, $target, $name];
if ($name) {
if (isset($this->namedRoutes[$name])) {
throw new RuntimeException("Can not redeclare route '{$name}'");
}
$this->namedRoutes[$name] = $route;
}
return;
}
/**
* Reversed routing
*
* Generate the URL for a named route. Replace regexes with supplied parameters
*
* @param string $routeName The name of the route.
* @param array @params Associative array of parameters to replace placeholders with.
* @return string The URL of the route with named parameters in place.
* @throws Exception
*/
public function generate($routeName, array $params = [])
{
// Check if named route exists
if (!isset($this->namedRoutes[$routeName])) {
throw new RuntimeException("Route '{$routeName}' does not exist.");
}
// Replace named parameters
$route = $this->namedRoutes[$routeName];
// prepend base path to route url again
$url = $this->basePath . $route;
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
foreach ($matches as $index => $match) {
list($block, $pre, $type, $param, $optional) = $match;
if ($pre) {
$block = substr($block, 1);
}
if (isset($params[$param])) {
// Part is found, replace for param value
$url = str_replace($block, $params[$param], $url);
} elseif ($optional && $index !== 0) {
// Only strip preceding slash if it's not at the base
$url = str_replace($pre . $block, '', $url);
} else {
// Strip match block
$url = str_replace($block, '', $url);
}
}
}
return $url;
}
/**
* Match a given Request Url against stored routes
* @param string $requestUrl
* @param string $requestMethod
* @return array|boolean Array with route information on success, false on failure (no match).
*/
public function match($requestUrl = null, $requestMethod = null)
{
$params = [];
// set Request Url if it isn't passed as parameter
if ($requestUrl === null) {
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
}
// strip base path from request url
$requestUrl = substr($requestUrl, strlen($this->basePath));
// Strip query string (?a=b) from Request Url
if (($strpos = strpos($requestUrl, '?')) !== false) {
$requestUrl = substr($requestUrl, 0, $strpos);
}
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';
// set Request Method if it isn't passed as a parameter
if ($requestMethod === null) {
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
}
foreach ($this->routes as $handler) {
list($methods, $route, $target, $name) = $handler;
$method_match = (stripos($methods, $requestMethod) !== false);
// Method did not match, continue to next route.
if (!$method_match) {
continue;
}
if ($route === '*') {
// * wildcard (matches all)
$match = true;
} elseif (isset($route[0]) && $route[0] === '@') {
// @ regex delimiter
$pattern = '`' . substr($route, 1) . '`u';
$match = preg_match($pattern, $requestUrl, $params) === 1;
} elseif (($position = strpos($route, '[')) === false) {
// No params in url, do string comparison
$match = strcmp($requestUrl, $route) === 0;
} else {
// Compare longest non-param string with url before moving on to regex
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
continue;
}
$regex = $this->compileRoute($route);
$match = preg_match($regex, $requestUrl, $params) === 1;
}
if ($match) {
if ($params) {
foreach ($params as $key => $value) {
if (is_numeric($key)) {
unset($params[$key]);
}
}
}
return [
'target' => $target,
'params' => $params,
'name' => $name
];
}
}
return false;
}
/**
* Compile the regex for a given route (EXPENSIVE)
* @param $route
* @return string
*/
protected function compileRoute($route)
{
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
$matchTypes = $this->matchTypes;
foreach ($matches as $match) {
list($block, $pre, $type, $param, $optional) = $match;
if (isset($matchTypes[$type])) {
$type = $matchTypes[$type];
}
if ($pre === '.') {
$pre = '\.';
}
$optional = $optional !== '' ? '?' : null;
//Older versions of PCRE require the 'P' in (?P<named>)
$pattern = '(?:'
. ($pre !== '' ? $pre : null)
. '('
. ($param !== '' ? "?P<$param>" : null)
. $type
. ')'
. $optional
. ')'
. $optional;
$route = str_replace($block, $pattern, $route);
}
}
return "`^$route$`u";
}
}

@ -0,0 +1,87 @@
<?php
class Router{
private string $path = "/PHP/project/index.php";
private $router;
public function __construct()
{
global $dir,$vues;
try{
session_start();
$tabError = array();
$this->router = new AltoRouter();
$this->router->setBasePath($this->path);
$this->initialiseRoutes();
$match = $this->router->match();
if(!$match){
$tabError[] = 'error : wrong path ';
require($dir . $vues['error']);
}
switch ($match['target']){
case 'UserControler' :
$this->userConnexion('UserControler', $match);
break;
case 'VisteurControler' :
$this->callController('VisteurControler', $match);
break;
case 'any':
VisteurControler::displayView();
break;
default:
$tabError[] = 'error : Wrong call router';
require($dir . $vues['error']);
}
}catch (PDOException $exp){
$tabError[] = 'error data base' . $exp->getMessage();
require($dir . $vues['error']);
} catch (Exception $exp2){
$tabError[] = 'unknow exeption' . $exp2->getMessage();
require($dir . $vues['error']);
}catch (Error $e){
$tabError[] = 'unknow error' . $e->getMessage();
require($dir . $vues['error']);
}
}
private function userConnexion(string $controller, array $match) : void{
global $dir, $vues;
if(ModelUser::isUser() != NULL){
$controller = 'UserControler';
$this->callController($controller, $match);
}
else{
VisteurControler::displayView();
}
}
private function initialiseRoutes() : void{
$this->router->map( 'GET|POST', '/user/[a:action]?/[i:id]?', 'UserControler','user_action');
$this->router->map( 'GET|POST', '/', 'any');
$this->router->map( 'GET|POST', '/[a:action]/[i:id]?', 'VisteurControler','vistor_action');
}
private function callController(string $controller, array $match) : void{
global $dir, $vues;
$action = Validation::val_action($match['params']['action']);
$controller = new $controller;
if(isset($match['params']['id'])){
$param[] = $match['params']['id'];
} else
$param[] = array();
if(is_callable(array($controller, $action)))
call_user_func_array(array($controller, $action), $param);
else{
$tabError[] = 'error : controller ';
require($dir . $vues['error']);
}
}
}

@ -0,0 +1,208 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/psr-0-final-proposal?pli=1
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
* $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
* $classLoader->register();
*
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman S. Borschel <roman@code-factory.org>
* @author Matthew Weier O'Phinney <matthew@zend.com>
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
*/
class SplClassLoader
{
private $_fileExtension = '.php';
private $_namespace;
private $_includePath;
private $_namespaceSeparator = '\\';
/**
* Creates a new <tt>SplClassLoader</tt> that loads classes of the
* specified namespace.
*
* @param string $ns The namespace to use.
*/
public function __construct(string $ns = null, string $includePath = null)
{
$this->_namespace = $ns;
$this->_includePath = $includePath;
}
/**
* Sets the namespace separator used by classes in the namespace of this class loader.
*
* @param string $sep The separator to use.
*/
public function setNamespaceSeparator(string $sep)
{
$this->_namespaceSeparator = $sep;
}
/**
* Gets the namespace seperator used by classes in the namespace of this class loader.
*
* @return void
*/
public function getNamespaceSeparator()
{
return $this->_namespaceSeparator;
}
/**
* Sets the base include path for all class files in the namespace of this class loader.
*
* @param string $includePath
*/
public function setIncludePath(string $includePath)
{
$this->_includePath = $includePath;
}
/**
* Gets the base include path for all class files in the namespace of this class loader.
*
* @return string $includePath
*/
public function getIncludePath()
{
return $this->_includePath;
}
/**
* Sets the file extension of class files in the namespace of this class loader.
*
* @param string $fileExtension
*/
public function setFileExtension($fileExtension)
{
$this->_fileExtension = $fileExtension;
}
/**
* Gets the file extension of class files in the namespace of this class loader.
*
* @return string $fileExtension
*/
public function getFileExtension()
{
return $this->_fileExtension;
}
/**
* Installs this class loader on the SPL autoload stack.
*/
public function register()
{
spl_autoload_register(array($this, 'loadClass'));
}
/**
* Uninstalls this class loader from the SPL autoloader stack.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $className The name of the class to load.
* @return void
*/
public function loadClass(string $className)
{
if (null === $this->_namespace || $this->_namespace . $this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace . $this->_namespaceSeparator))) {
$fileName = '';
$namespace = '';
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
}
}
}
// <?php
// class Autoload
// {
// private static $_instance = null;
// public static function charger()
// {
// if(null !== self::$_instance) {
// throw new RuntimeException(sprintf('%s is already started', __CLASS__));
// }
// self::$_instance = new self();
// if(!spl_autoload_register(array(self::$_instance, '_autoload'), false)) {
// throw RuntimeException(sprintf('%s : Could not start the autoload', __CLASS__));
// }
// }
// public static function shutDown()
// {
// if(null !== self::$_instance) {
// if(!spl_autoload_unregister(array(self::$_instance, '_autoload'))) {
// throw new RuntimeException('Could not stop the autoload');
// }
// self::$_instance = null;
// }
// }
// private static function _autoload($class)
// {
// global $rep;
// $filename = $class.'.php';
// $dir =array('modeles/','./','config/','controleur/router');
// foreach ($dir as $d){
// $file=$rep.$d.$filename;
// //echo $file;
// if (file_exists($file))
// {
// include $file;
// }
// }
// }
// }
// ?>

@ -0,0 +1,109 @@
<?php
class Validation {
/**
* Valide une action passée en paramètre.
*
* @param string $action L'action à valider.
* @return string L'action validée si elle est conforme.
* @throws Exception Si l'action n'est pas valide.
*/
public static function val_action($action) {
if (!isset($action) || !Validation::val_string($action)) {
throw new Exception("Pas d'action spécifiée.");
} else {
return $action;
}
}
/**
* Valide une chaîne de caractères.
*
* @param string $string La chaîne à valider.
* @return bool True si la chaîne est valide, sinon false.
* @throws Exception Si la chaîne n'est pas valide (tentative d'injection de code).
*/
public static function val_string(string $string) : bool {
if (filter_var($string, FILTER_SANITIZE_STRING) !== $string) {
throw new Exception("$string n'est pas valide. Tentative d'injection de code (attaque sécurité)!");
} else {
return true;
}
}
/**
* Valide un entier.
*
* @param int $int L'entier à valider.
* @return bool True si l'entier est valide, sinon false.
* @throws Exception Si l'entier n'est pas valide (tentative d'injection de code).
*/
public static function val_int(int $int) : bool {
if (filter_var($int, FILTER_SANITIZE_NUMBER_INT) !== $int) {
throw new Exception("$int n'est pas valide. Tentative d'injection de code (attaque sécurité)!");
} else {
return true;
}
}
/**
* Valide un mot de passe.
*
* @param string $password Le mot de passe à valider.
* @return bool True si le mot de passe est valide, sinon false.
* @throws Exception Si le mot de passe n'est pas valide.
*/
public static function val_password(string $password) : bool {
if ($password === null) {
throw new Exception("Le mot de passe ne peut être vide.");
} else {
if (!preg_match('/^.{6,}$/', $password)) {
throw new Exception("Le mot de passe n'est pas valide : au moins 6 caractères requis.");
}
return Validation::val_string($password);
}
}
/**
* Valide un booléen.
*
* @param bool $done La valeur booléenne à valider.
* @return bool True si la valeur booléenne est définie, sinon false.
*/
public static function val_bool(bool $done) : bool {
return isset($done);
}
/**
* Nettoie une chaîne de caractères.
*
* @param string $string La chaîne à nettoyer.
* @return string La chaîne nettoyée.
*/
public static function clean_string(string $string) : string {
return filter_var($string, FILTER_SANITIZE_STRING);
}
/**
* Nettoie un entier.
*
* @param int $int L'entier à nettoyer.
* @return int L'entier nettoyé.
*/
public static function clean_int(int $int) : int {
return filter_var($int, FILTER_SANITIZE_NUMBER_INT);
}
/**
* Nettoie une valeur booléenne.
*
* @param bool $bool La valeur booléenne à nettoyer.
* @return bool La valeur booléenne nettoyée.
*/
public static function clean_bool(bool $bool) : bool {
return filter_var($bool, FILTER_VALIDATE_BOOLEAN);
}
}
?>

@ -0,0 +1,11 @@
#!/bin/bash
changelog="$(base64 -w 0 CHANGELOG)"
# This call sends a message to the given recipient with vars and custom vars.
curl -s \
-X POST \
--user "46cb7f286b30df20369be709a91424a9:957e3ac14b3b106331ccd9dfe07f67fd" \
https://api.mailjet.com/v3.1/send \
-H 'Content-Type: application/json' \
-d '{ "Messages":[ { "From": { "Email": "contact@lamsterpilotage.fr", "Name": "Equipe de développement" }, "To": [ { { "Email": "equipedev@waveheart.fr", "Name": "dev" } ], "TemplateID": 2687222, "TemplateLanguage": true, "Subject": "Nouvelle version démo", "Variables": {}, "Attachments": [ { "ContentType": "text/plain", "Filename": "changelog.md", "Base64Content": "'"$changelog"'" } ] } ] }'
Loading…
Cancel
Save