Add the front-end of the page

This commit is contained in:
Mathieu Sanchez 2018-12-12 15:04:47 +09:00
parent 3dfce942aa
commit 38c619544e
35 changed files with 8044 additions and 7966 deletions

View File

@ -10,11 +10,16 @@ RewriteRule ^ - [L]
# RewriteCond %{HTTP_HOST} ^eldotravo.fr$
# RewriteRule ^(.*)$ http://www.eldotravo.fr/$1 [R=301,L,E=END:1]
# Redirection des fichiers static pour www.eldotravo.fr
# Redirection des fichiers static pour fitness.sanchez-mathieu.fr
RewriteCond %{HTTP_HOST} ^fitness.sanchez-mathieu.fr$
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI} -f
RewriteRule ^(.*)$ static/$1 [L,E=END:1]
# Redirection des fichiers static pour fitness.sanchez-mathieu.test
RewriteCond %{HTTP_HOST} ^fitness.sanchez-mathieu.test$
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

View File

@ -12,30 +12,30 @@ 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/Lib/functions.php' );
require( 'src/Config.php' );
require 'src/Autoloader.php';
Autoloader::register();
new BDD();
$parts = explode( '?', $_SERVER['REQUEST_URI'] );
$urlA = ltrim( $parts[0], '/' );
$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' );
$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] );
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'] ) ) {
} else if ( preg_match( '#^fitness.sanchez-mathieu\.test$#', $_SERVER[ 'SERVER_NAME' ] ) || preg_match( '#^fitness.sanchez-mathieu\.fr$#', $_SERVER[ 'SERVER_NAME' ] ) ) {
new SiteRouter( $pages );
} else {
new Error( 404 );

View File

@ -14,7 +14,8 @@ class APIError extends Controller {
* @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 = '' ) {
public function __construct( int $ErrCode = 500, string $devMessage = 'Erreur inconnue',
string $publicMessage = 'Une erreur inconnue s\'est produite', string $code = '' ) {
parent::__construct();
$tabCode = [
@ -78,7 +79,7 @@ class APIError extends Controller {
];
header( 'Content-Type: application/json' );
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $tabCode[ $ErrCode ]['label'] );
header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' ' . $tabCode[ $ErrCode ][ 'label' ] );
echo json_encode( [
'status' => 'echec',
'msg' => $publicMessage,

View File

@ -24,7 +24,7 @@ class APIRouter {
//On vérifie que la classe appelée existe
$fileName = 'API' . ucfirst( $file );
if ( ! file_exists( 'src/API/' . $fileName . '.php' ) ) {
if ( !file_exists( 'src/API/' . $fileName . '.php' ) ) {
new APIError( 404 );
}
@ -33,7 +33,7 @@ class APIRouter {
$class = new $class( $action );
//On vérifie que l'action demandé est déclarée
if ( ! array_key_exists( $action, $class->getDeclaredFunctions() ) ) {
if ( !array_key_exists( $action, $class->getDeclaredFunctions() ) ) {
new APIError( 404 );
}
@ -49,25 +49,25 @@ class APIRouter {
$function = implode( '', $array ); //le nom de la fonction
//On vérifie que la fonction existe dans la classe
if ( ! method_exists( $class, $function ) ) {
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 ) ) {
$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'] ) {
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'];
$params = $class->getDeclaredFunctions()[ $action ][ 'params' ];
$data = [];
if ( ! empty( $params ) ) {
if ( !empty( $params ) ) {
if ( $method == 'DELETE' || $method == 'PUT' ) {
parse_str( file_get_contents( 'php://input' ), $data );
} else if ( $method == 'POST' ) {
@ -78,47 +78,47 @@ class APIRouter {
//On boucle sur les paramètres de la doc de la fonction
foreach ( $params as $p => $options ) {
if ( ! isset( $options['required'] ) ) {
$options['required'] = false;
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' ) ) ) {
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'];
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'];
if ( isset( $options[ 'publicMsg' ] ) ) {
$publicMsg = $options[ 'publicMsg' ];
}
$code = '';
if ( isset( $options['code'] ) ) {
$code = $options['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 ( isset( $options[ 'type' ] ) ) {
if ( $options[ 'type' ] == 'int' ) {
if ( ctype_digit( $data[ $p ] ) ) {
$data[ $p ] = (int) $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' );
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' ) {
} 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' );
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 ) ) {
if ( !array_key_exists( $p, $data ) ) {
$data[ $p ] = '';
}
}

View File

@ -18,7 +18,7 @@ class Autoloader {
*/
static function autoload( $class ) {
if ( preg_match( '#^' . Config::NAMESPACE . '\\\(.+)$#', $class, $matches ) ) {
require 'src/' . str_replace( '\\', '/', $matches[1] ) . '.php';
require 'src/' . str_replace( '\\', '/', $matches[ 1 ] ) . '.php';
}
}
}

View File

@ -6,9 +6,9 @@ class Config {
const SITE_JS_VERSION = '1.00';
const SITE_CSS_VERSION = '1.00';
const TITLE_HEADER = 'Mon titre de site';
const DESCRIPTION_HEADER = 'Ma description pour les robots';
const TITLE_HEADER = 'Fitness';
const DESCRIPTION_HEADER = 'Site for find all the fitness exercise you need';
const NAMESPACE = 'WebProjectFitness';
const FAVICON_PATH = '/img/favicon.png';
const FAVICON_PATH = '/img/favicon.ico';
}

View File

@ -21,11 +21,11 @@ class ControllerSite {
ob_start();
extract( $this->data );
if ( empty( $this->head['title'] ) ) {
$this->head['title'] = Config::TITLE_HEADER;
if ( empty( $this->head[ 'title' ] ) ) {
$this->head[ 'title' ] = Config::TITLE_HEADER;
}
if ( empty( $this->head['description'] ) ) {
$this->head['description'] = Config::DESCRIPTION_HEADER;
if ( empty( $this->head[ 'description' ] ) ) {
$this->head[ 'description' ] = Config::DESCRIPTION_HEADER;
}
if ( $header ) {
require 'src/View/Site/tpl/head.php';

View File

@ -75,22 +75,22 @@ class Error extends Controller {
];
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 );
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'];
$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' );
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'];
$erreur = $tabCode[ 500 ][ 'msg' ];
$this->addData( [ 'erreur' => $erreur ] );
}
if ( ! empty( $message ) ) {
if ( !empty( $message ) ) {
$this->addData( [ 'message' => $message ] );
}

View File

@ -76,22 +76,22 @@ class SiteError extends ControllerSite {
];
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 );
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'];
$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' );
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'];
$erreur = $tabCode[ 500 ][ 'msg' ];
$this->addData( [ 'erreur' => $erreur ] );
}
if ( ! empty( $message ) ) {
if ( !empty( $message ) ) {
$this->addData( [ 'message' => $message ] );
}

View File

@ -13,7 +13,7 @@ class SiteRouter {
set_error_handler( 'errorHandler' );
if ( $pages[0] == '' ) {
if ( $pages[ 0 ] == '' ) {
new Index();
} else {
new SiteError( 404 );

View File

@ -37,8 +37,8 @@ function formatURL( string $str, $encoding = 'utf-8' ) {
//on passe tout en minuscule
$str = strtolower( $str );
if ( substr( $str, - 1 ) == '_' ) {
$str = substr( $str, 0, - 1 );
if ( substr( $str, -1 ) == '_' ) {
$str = substr( $str, 0, -1 );
}
return $str;
@ -58,27 +58,27 @@ function formatURL( string $str, $encoding = 'utf-8' ) {
function darkroom( $img, $to, $width = 0, $height = 0, $quality = 100, $useGD = true ) {
$dimensions = getimagesize( $img );
$ratio = $dimensions[0] / $dimensions[1];
$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];
$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] ) {
if ( $dimensions[ 0 ] > ( $width / $height ) * $dimensions[ 1 ] ) {
$dimY = $height;
$dimX = round( $height * $dimensions[0] / $dimensions[1] );
$dimX = round( $height * $dimensions[ 0 ] / $dimensions[ 1 ] );
}
if ( $dimensions[0] < ( $width / $height ) * $dimensions[1] ) {
if ( $dimensions[ 0 ] < ( $width / $height ) * $dimensions[ 1 ] ) {
$dimX = $width;
$dimY = round( $width * $dimensions[1] / $dimensions[0] );
$dimY = round( $width * $dimensions[ 1 ] / $dimensions[ 0 ] );
}
if ( $dimensions[0] == ( $width / $height ) * $dimensions[1] ) {
if ( $dimensions[ 0 ] == ( $width / $height ) * $dimensions[ 1 ] ) {
$dimX = $width;
$dimY = $height;
}
@ -98,7 +98,7 @@ function darkroom( $img, $to, $width = 0, $height = 0, $quality = 100, $useGD =
$image = imagecreatefrompng( $img );
break;
}
imagecopyresampled( $pattern, $image, 0, 0, 0, 0, $dimX, $dimY, $dimensions[0], $dimensions[1] );
imagecopyresampled( $pattern, $image, 0, 0, 0, 0, $dimX, $dimY, $dimensions[ 0 ], $dimensions[ 1 ] );
imagedestroy( $image );
imagejpeg( $pattern, $to, $quality );
@ -119,7 +119,7 @@ function darkroom( $img, $to, $width = 0, $height = 0, $quality = 100, $useGD =
* @return bool|void
*/
function errorHandler( $errno, $errstr, $errfile, $errline ) {
if ( ! ( error_reporting() & $errno ) ) {
if ( !( error_reporting() & $errno ) ) {
// Ce code d'erreur n'est pas inclus dans error_reporting()
return;
}
@ -141,7 +141,7 @@ function errorHandler( $errno, $errstr, $errfile, $errline ) {
*/
function getBrowser() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$u_agent = $_SERVER[ 'HTTP_USER_AGENT' ];
$bname = 'Unknown';
$platform = 'Unknown';
$ub = "";
@ -162,7 +162,7 @@ function getBrowser() {
}
// 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 ) ) {
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 ) ) {
@ -192,22 +192,22 @@ function getBrowser() {
// Added "|:"
$known = array( 'Version', $ub, 'other' );
$pattern = '#(?<browser>' . join( '|', $known ) . ')[/|: ]+(?<version>[0-9.|a-zA-Z.]*)#';
if ( ! preg_match_all( $pattern, $u_agent, $matches ) ) {
if ( !preg_match_all( $pattern, $u_agent, $matches ) ) {
// we have no matching number just continue
}
// see how many we have
$i = count( $matches['browser'] );
$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];
$version = $matches[ 'version' ][ 0 ];
} else {
$version = $matches['version'][1];
$version = $matches[ 'version' ][ 1 ];
}
} else {
$version = $matches['version'][0];
$version = $matches[ 'version' ][ 0 ];
}
// check if we have a number
@ -232,11 +232,11 @@ function getBrowser() {
*/
function getLimitWord( $string, $limit ) {
$i = $limit;
if ( ! isset( $string ) || empty( $string ) ) {
if ( !isset( $string ) || empty( $string ) ) {
return 0;
}
while ( $i > 0 && $string[ $i ] != ' ' ) {
$i --;
$i--;
}
return $i;
@ -370,14 +370,14 @@ function rotateImage( string $file, int $angle, string $newName ) {
* 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 ) ) {
if ( !empty( $data ) ) {
foreach ( $data as $key => $donnée ) {
switch ( gettype( $donnée ) ) {
case 'string':
if ( ! empty( $donnée ) ) {
if ( !empty( $donnée ) ) {
$new_string = '';
foreach ( explode( ' ', trim( $donnée ) ) as $str ) {
if ( ! empty( $str ) ) {
if ( !empty( $str ) ) {
if ( $new_string != '' ) {
$new_string .= ' ';
}
@ -388,7 +388,7 @@ function cleanArray( array $data ) {
}
break;
case 'array':
if ( ! empty( $donnée ) ) {
if ( !empty( $donnée ) ) {
$data[ $key ] = cleanArray( $donnée );
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -253,14 +253,14 @@ class SMTP {
);
}
// Verify we connected properly
if ( ! is_resource( $this->smtp_conn ) ) {
if ( !is_resource( $this->smtp_conn ) ) {
$this->setError(
'Failed to connect to server',
$errno,
$errstr
);
$this->edebug(
'SMTP ERROR: ' . $this->error['error']
'SMTP ERROR: ' . $this->error[ 'error' ]
. ": $errstr ($errno)",
self::DEBUG_CLIENT
);
@ -293,7 +293,7 @@ class SMTP {
public function connected() {
if ( is_resource( $this->smtp_conn ) ) {
$sock_status = stream_get_meta_data( $this->smtp_conn );
if ( $sock_status['eof'] ) {
if ( $sock_status[ 'eof' ] ) {
// The socket is valid but we are not connected
$this->edebug(
'SMTP NOTICE: EOF caught while checking if connected',
@ -325,7 +325,7 @@ class SMTP {
return;
}
//Avoid clash with built-in function names
if ( ! in_array( $this->Debugoutput, array(
if ( !in_array( $this->Debugoutput, array(
'error_log',
'html',
'echo'
@ -390,7 +390,7 @@ class SMTP {
*/
protected function get_lines() {
// If the connection is bad, give up straight away
if ( ! is_resource( $this->smtp_conn ) ) {
if ( !is_resource( $this->smtp_conn ) ) {
return '';
}
$data = '';
@ -399,18 +399,18 @@ class SMTP {
if ( $this->Timelimit > 0 ) {
$endtime = time() + $this->Timelimit;
}
while ( is_resource( $this->smtp_conn ) && ! feof( $this->smtp_conn ) ) {
while ( is_resource( $this->smtp_conn ) && !feof( $this->smtp_conn ) ) {
$str = @fgets( $this->smtp_conn, 515 );
$this->edebug( "SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL );
$this->edebug( "SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL );
$data .= $str;
// If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
if ( ( isset( $str[3] ) and $str[3] == ' ' ) ) {
if ( ( isset( $str[ 3 ] ) and $str[ 3 ] == ' ' ) ) {
break;
}
// Timed-out? Log and break
$info = stream_get_meta_data( $this->smtp_conn );
if ( $info['timed_out'] ) {
if ( $info[ 'timed_out' ] ) {
$this->edebug(
'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
self::DEBUG_LOWLEVEL
@ -437,11 +437,11 @@ class SMTP {
* @return boolean
*/
public function startTLS() {
if ( ! $this->sendCommand( 'STARTTLS', 'STARTTLS', 220 ) ) {
if ( !$this->sendCommand( 'STARTTLS', 'STARTTLS', 220 ) ) {
return false;
}
// Begin encrypted connection
if ( ! stream_socket_enable_crypto(
if ( !stream_socket_enable_crypto(
$this->smtp_conn,
true,
STREAM_CRYPTO_METHOD_TLS_CLIENT
@ -463,7 +463,7 @@ class SMTP {
* @return boolean True on success.
*/
protected function sendCommand( $command, $commandstring, $expect ) {
if ( ! $this->connected() ) {
if ( !$this->connected() ) {
$this->setError( "Called $command without being connected" );
return false;
@ -480,8 +480,8 @@ class SMTP {
// Fetch SMTP code and possible error code explanation
$matches = array();
if ( preg_match( "/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches ) ) {
$code = $matches[1];
$code_ex = ( count( $matches ) > 2 ? $matches[2] : null );
$code = $matches[ 1 ];
$code_ex = ( count( $matches ) > 2 ? $matches[ 2 ] : null );
// Cut off error code from each response line
$detail = preg_replace(
"/{$code}[ -]" . ( $code_ex ? str_replace( '.', '\\.', $code_ex ) . ' ' : '' ) . "/m",
@ -497,7 +497,7 @@ class SMTP {
$this->edebug( 'SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER );
if ( ! in_array( $code, (array) $expect ) ) {
if ( !in_array( $code, (array)$expect ) ) {
$this->setError(
"$command command failed",
$detail,
@ -505,7 +505,7 @@ class SMTP {
$code_ex
);
$this->edebug(
'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
'SMTP ERROR: ' . $this->error[ 'error' ] . ': ' . $this->last_reply,
self::DEBUG_CLIENT
);
@ -553,7 +553,7 @@ class SMTP {
$workstation = '',
$OAuth = null
) {
if ( ! $this->server_caps ) {
if ( !$this->server_caps ) {
$this->setError( 'Authentication is not allowed before HELO/EHLO' );
return false;
@ -562,7 +562,7 @@ class SMTP {
if ( array_key_exists( 'EHLO', $this->server_caps ) ) {
// SMTP extensions are available. Let's try to find a proper authentication method
if ( ! array_key_exists( 'AUTH', $this->server_caps ) ) {
if ( !array_key_exists( 'AUTH', $this->server_caps ) ) {
$this->setError( 'Authentication is not allowed at this stage' );
// 'at this stage' means that auth may be allowed after the stage changes
// e.g. after STARTTLS
@ -571,13 +571,13 @@ class SMTP {
self::edebug( 'Auth method requested: ' . ( $authtype ? $authtype : 'UNKNOWN' ), self::DEBUG_LOWLEVEL );
self::edebug(
'Auth methods available on the server: ' . implode( ',', $this->server_caps['AUTH'] ),
'Auth methods available on the server: ' . implode( ',', $this->server_caps[ 'AUTH' ] ),
self::DEBUG_LOWLEVEL
);
if ( empty( $authtype ) ) {
foreach ( array( 'LOGIN', 'CRAM-MD5', 'NTLM', 'PLAIN', 'XOAUTH2' ) as $method ) {
if ( in_array( $method, $this->server_caps['AUTH'] ) ) {
if ( in_array( $method, $this->server_caps[ 'AUTH' ] ) ) {
$authtype = $method;
break;
}
@ -590,7 +590,7 @@ class SMTP {
self::edebug( 'Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL );
}
if ( ! in_array( $authtype, $this->server_caps['AUTH'] ) ) {
if ( !in_array( $authtype, $this->server_caps[ 'AUTH' ] ) ) {
$this->setError( "The requested authentication method \"$authtype\" is not supported by the server" );
return false;
@ -601,11 +601,11 @@ class SMTP {
switch ( $authtype ) {
case 'PLAIN':
// Start authentication
if ( ! $this->sendCommand( 'AUTH', 'AUTH PLAIN', 334 ) ) {
if ( !$this->sendCommand( 'AUTH', 'AUTH PLAIN', 334 ) ) {
return false;
}
// Send encoded username and password
if ( ! $this->sendCommand(
if ( !$this->sendCommand(
'User & Password',
base64_encode( "\0" . $username . "\0" . $password ),
235
@ -616,13 +616,13 @@ class SMTP {
break;
case 'LOGIN':
// Start authentication
if ( ! $this->sendCommand( 'AUTH', 'AUTH LOGIN', 334 ) ) {
if ( !$this->sendCommand( 'AUTH', 'AUTH LOGIN', 334 ) ) {
return false;
}
if ( ! $this->sendCommand( "Username", base64_encode( $username ), 334 ) ) {
if ( !$this->sendCommand( "Username", base64_encode( $username ), 334 ) ) {
return false;
}
if ( ! $this->sendCommand( "Password", base64_encode( $password ), 235 ) ) {
if ( !$this->sendCommand( "Password", base64_encode( $password ), 235 ) ) {
return false;
}
break;
@ -635,7 +635,7 @@ class SMTP {
$oauth = $OAuth->getOauth64();
// Start authentication
if ( ! $this->sendCommand( 'AUTH', 'AUTH XOAUTH2 ' . $oauth, 235 ) ) {
if ( !$this->sendCommand( 'AUTH', 'AUTH XOAUTH2 ' . $oauth, 235 ) ) {
return false;
}
break;
@ -652,11 +652,11 @@ class SMTP {
$temp = new stdClass;
$ntlm_client = new ntlm_sasl_client_class;
//Check that functions are available
if ( ! $ntlm_client->Initialize( $temp ) ) {
if ( !$ntlm_client->Initialize( $temp ) ) {
$this->setError( $temp->error );
$this->edebug(
'You need to enable some modules in your php.ini file: '
. $this->error['error'],
. $this->error[ 'error' ],
self::DEBUG_CLIENT
);
@ -665,7 +665,7 @@ class SMTP {
//msg1
$msg1 = $ntlm_client->TypeMsg1( $realm, $workstation ); //msg1
if ( ! $this->sendCommand(
if ( !$this->sendCommand(
'AUTH NTLM',
'AUTH NTLM ' . base64_encode( $msg1 ),
334
@ -693,7 +693,7 @@ class SMTP {
return $this->sendCommand( 'Username', base64_encode( $msg3 ), 235 );
case 'CRAM-MD5':
// Start authentication
if ( ! $this->sendCommand( 'AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334 ) ) {
if ( !$this->sendCommand( 'AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334 ) ) {
return false;
}
// Get the challenge
@ -766,7 +766,7 @@ class SMTP {
*/
public function data( $msg_data ) {
//This will use the standard timelimit
if ( ! $this->sendCommand( 'DATA', 'DATA', 354 ) ) {
if ( !$this->sendCommand( 'DATA', 'DATA', 354 ) ) {
return false;
}
@ -786,9 +786,9 @@ class SMTP {
* process all lines before a blank line as headers.
*/
$field = substr( $lines[0], 0, strpos( $lines[0], ':' ) );
$field = substr( $lines[ 0 ], 0, strpos( $lines[ 0 ], ':' ) );
$in_headers = false;
if ( ! empty( $field ) && strpos( $field, ' ' ) === false ) {
if ( !empty( $field ) && strpos( $field, ' ' ) === false ) {
$in_headers = true;
}
@ -804,7 +804,7 @@ class SMTP {
//so as to avoid breaking in the middle of a word
$pos = strrpos( substr( $line, 0, self::MAX_LINE_LENGTH ), ' ' );
//Deliberately matches both false and 0
if ( ! $pos ) {
if ( !$pos ) {
//No nice break found, add a hard break
$pos = self::MAX_LINE_LENGTH - 1;
$lines_out[] = substr( $line, 0, $pos );
@ -825,7 +825,7 @@ class SMTP {
//Send the lines to the server
foreach ( $lines_out as $line_out ) {
//RFC2821 section 4.5.2
if ( ! empty( $line_out ) and $line_out[0] == '.' ) {
if ( !empty( $line_out ) and $line_out[ 0 ] == '.' ) {
$line_out = '.' . $line_out;
}
$this->client_send( $line_out . self::CRLF );
@ -857,7 +857,7 @@ class SMTP {
*/
public function hello( $host = '' ) {
//Try extended hello first (RFC 2821)
return (boolean) ( $this->sendHello( 'EHLO', $host ) or $this->sendHello( 'HELO', $host ) );
return (boolean)( $this->sendHello( 'EHLO', $host ) or $this->sendHello( 'HELO', $host ) );
}
/**
@ -901,18 +901,18 @@ class SMTP {
continue;
}
$fields = explode( ' ', $s );
if ( ! empty( $fields ) ) {
if ( ! $n ) {
if ( !empty( $fields ) ) {
if ( !$n ) {
$name = $type;
$fields = $fields[0];
$fields = $fields[ 0 ];
} else {
$name = array_shift( $fields );
switch ( $name ) {
case 'SIZE':
$fields = ( $fields ? $fields[0] : 0 );
$fields = ( $fields ? $fields[ 0 ] : 0 );
break;
case 'AUTH':
if ( ! is_array( $fields ) ) {
if ( !is_array( $fields ) ) {
$fields = array();
}
break;
@ -1051,7 +1051,7 @@ class SMTP {
*/
public function turn() {
$this->setError( 'The SMTP TURN command is not implemented' );
$this->edebug( 'SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT );
$this->edebug( 'SMTP NOTICE: ' . $this->error[ 'error' ], self::DEBUG_CLIENT );
return false;
}
@ -1113,16 +1113,16 @@ class SMTP {
* @return mixed
*/
public function getServerExt( $name ) {
if ( ! $this->server_caps ) {
if ( !$this->server_caps ) {
$this->setError( 'No HELO/EHLO was sent' );
return null;
}
// the tight logic knot ;)
if ( ! array_key_exists( $name, $this->server_caps ) ) {
if ( !array_key_exists( $name, $this->server_caps ) ) {
if ( $name == 'HELO' ) {
return $this->server_caps['EHLO'];
return $this->server_caps[ 'EHLO' ];
}
if ( $name == 'EHLO' || array_key_exists( 'EHLO', $this->server_caps ) ) {
return false;

View File

@ -1,7 +1,7 @@
<!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">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body class="body" style="background-color: whitesmoke !important;padding: 40px 0;line-height: 22px;width: 100%;">
<div class="contain"

View File

@ -6,10 +6,15 @@ use Exception;
use PDO;
class BDD {
const SQL_SERVER = 'http://web3.pulseheberg.net'; // BDD Server
const SQL_LOGIN = 'why7n0_fitness'; // BDD Login
const SQL_PASSWORD = 'KpB728zu'; // BDD Password
const SQL_DB = 'why7n0_fitness'; // BDD Name
// const SQL_SERVER = 'http://web3.pulseheberg.net'; // BDD Server
// const SQL_LOGIN = 'why7n0_fitness'; // BDD Login
// const SQL_PASSWORD = 'KpB728zu'; // BDD Password
// const SQL_DB = 'why7n0_fitness'; // BDD Name
const SQL_SERVER = 'localhost'; // BDD Server
const SQL_LOGIN = 'root'; // BDD Login
const SQL_PASSWORD = ''; // BDD Password
const SQL_DB = 'fitness'; // BDD Name
private static $bdd;

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,8 @@ class Logs {
* @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 ) {
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;
}
@ -74,14 +75,14 @@ class Logs {
public static function getLastLogs( int $limit ) {
$req = BDD::instance()->prepare( 'SELECT *
FROM ' . BDTables::LOGS . '
ORDER BY date DESC
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'] );
$log = new Logs( $l[ 'id' ], $l[ 'level' ], $l[ 'message' ], $l[ 'file' ], $l[ 'line' ], $l[ 'date' ] );
$return[] = $log;
}

View File

@ -1,3 +1,31 @@
<div>
Bonjour 2
<div class="row" style="margin-bottom: 0">
<div class="col s2 green lighten-1 white-text" style="height: 750px;">
<div class="row">
<div class="col s12 center-align">
<h5>Selected part of the body</h5>
</div>
<div class="col s12">
<img src="/img/muscles.jpg" style="width: 100%;">
</div>
<div class="col s12" id="list-exercices-select-part">
<div class="container">
<h5>Exercise List</h5>
<div>Please select a muscle</div>
</div>
</div>
</div>
</div>
<div class="col s10">
<div class="container">
<h2>Title</h2>
<div class="center-align">
<iframe width="560" height="315" src="https://www.youtube.com/embed/1gLmEOSwQMs" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
<div class="exercise-info-container blue-grey lighten-4 left-align">
Test
</div>
</div>
</div>
</div>
</div>

View File

@ -1,6 +1,17 @@
<script src="/js/jquery-3.2.1.min.js"></script>
<script src="/js/javascript.js?v=<?= WebProjectFitness\Config::SITE_JS_VERSION ?>"></script>
<link href="/css/style.css?v=<?= WebProjectFitness\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
</main>
<footer class="page-footer green darken-3">
<div class="footer-copyright">
<div class="container">
Made by <a class="blue-text text-lighten-3" target="_blank" href="https://www.sanchez-mathieu.fr">Mathieu
Sanchez</a>, Pablo Berenguel, Anthony Andrianjatovo and Najib Kardjoudj
</div>
</div>
</footer>
<script src="/js/jquery-3.3.1.min.js"></script>
<script async src="/js/materialize.min.js"></script>
<script async src="/js/javascript.js?v=<?= WebProjectFitness\Config::SITE_JS_VERSION ?>"></script>
</body>
</html>

View File

@ -10,32 +10,60 @@
<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">
<meta name="author" content="Mathieu Sanchez">
<title><?= $this->head['title'] ?></title>
<meta name="description" content="<?= $this->head['description'] ?>">
<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'] . \WebProjectFitness\Config::FAVICON_PATH ?>"/>
<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="//<?= $_SERVER[ 'SERVER_NAME' ] . \WebProjectFitness\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/materialize.min.css" rel="stylesheet">
<link href="/css/theme.css?v=<?= WebProjectFitness\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
<link href="/css/select2.css" rel="stylesheet">
<link href="/css/style.css?v=<?= WebProjectFitness\Config::SITE_CSS_VERSION ?>" rel="stylesheet">
<link rel="image_src" href="<?php \WebProjectFitness\Config::FAVICON_PATH ?>"/>
<link rel="icon" type="image/png" href="<?php \WebProjectFitness\Config::FAVICON_PATH ?>"/>
<link rel="image_src" href="//<?= $_SERVER[ 'SERVER_NAME' ] . \WebProjectFitness\Config::FAVICON_PATH ?>"/>
<link rel="icon" type="image/ico"
href="//<?= $_SERVER[ 'SERVER_NAME' ] . \WebProjectFitness\Config::FAVICON_PATH ?>"/>
<meta name="theme-color" content="#ffffff">
<?php if ( isset( $this->head['robotNoIndex'] ) && $this->head['robotNoIndex'] == true ) { ?>
<?php if ( isset( $this->head[ 'robotNoIndex' ] ) && $this->head[ 'robotNoIndex' ] == true ) { ?>
<meta name="robots" content="noindex"/>
<?php } ?>
</head>
<body>
<body class="grey lighten-4">
<ul id="user" class="dropdown-content">
<li><a>Your Account</a></li>
<li class="divider"></li>
<li><a>Your Saved Exercises</a></li>
<li class="divider"></li>
<li><a>Your Training</a></li>
</ul>
<div class="navbar-fixed">
<nav class="green darken-3" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" class="brand-logo">
<img src="/img/logo.svg" alt="Logo for Your Exercise" height="64px"/>
</a>
<ul class="right hide-on-med-and-down">
<li>
<a class="dropdown-trigger" data-target="user">Name Of The Account<i class="material-icons right">arrow_drop_down</i></a>
</li>
</ul>
</div>
</nav>
</div>
<main>

13
static/css/materialize.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,55 +1,15 @@
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;
#logo-container {
height: 64px;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
#logo-container img {
width: 40px;
}
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;
.exercise-info-container {
width: 560px;
min-height: 100px;
margin: 20px auto 0;
border-radius: 5px;
padding: 10px 15px;
}

BIN
static/img/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

16
static/img/logo.svg Normal file
View File

@ -0,0 +1,16 @@
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
<path d="m512 256c0 141.386719-114.613281 256-256 256s-256-114.613281-256-256 114.613281-256 256-256 256 114.613281 256 256zm0 0"
fill="#00f3ff"/>
<path d="m511.488281 271.984375-73.429687-73.433594-4.605469 6.117188-34.941406-34.941407-94.503907 104.117188-113.820312-113.816406-113.1875 156.417968 195.039062 195.039063c128.625-7.953125 231.523438-110.871094 239.449219-239.5zm0 0"
fill="#00c2ef"/>
<path d="m99.152344 218.707031h311.503906v74.585938h-311.503906zm0 0" fill="#613394"/>
<path d="m255.761719 218.707031h154.894531v74.585938h-154.894531zm0 0" fill="#4b1b7a"/>
<path d="m145.632812 322.320312h-52.28125c-14.183593 0-25.683593-11.5-25.683593-25.683593v-81.273438c0-14.183593 11.5-25.683593 25.683593-25.683593h52.28125zm0 0"
fill="#ff551c"/>
<path d="m190.1875 351.972656h-54.726562c-16.421876 0-29.730469-13.308594-29.730469-29.726562v-132.492188c0-16.417968 13.308593-29.726562 29.730469-29.726562h54.726562zm0 0"
fill="#2864f0"/>
<path d="m366.367188 189.679688h52.28125c14.183593 0 25.683593 11.5 25.683593 25.683593v81.273438c0 14.183593-11.5 25.683593-25.683593 25.683593h-52.28125zm0 0"
fill="#f24500"/>
<path d="m321.8125 160.027344h54.726562c16.421876 0 29.730469 13.308594 29.730469 29.726562v132.492188c0 16.417968-13.308593 29.726562-29.730469 29.726562h-54.726562zm0 0"
fill="#0053bf"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/img/muscles.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,5 @@
$(document).ready(() => {
$(".dropdown-trigger").dropdown();
});

File diff suppressed because one or more lines are too long

2
static/js/jquery-3.3.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

6
static/js/materialize.min.js vendored Normal file

File diff suppressed because one or more lines are too long