Add the front-end of the page
This commit is contained in:
parent
3dfce942aa
commit
38c619544e
@ -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
|
||||
|
@ -13,7 +13,7 @@ setlocale( LC_TIME, "fr_FR.UTF-8" );
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require( 'src/Lib/functions.php' );
|
||||
require( 'src/config.php' );
|
||||
require( 'src/Config.php' );
|
||||
|
||||
require 'src/Autoloader.php';
|
||||
Autoloader::register();
|
||||
@ -35,7 +35,7 @@ if ( count( $pages ) > 1 && $pages[ count( $pages ) - 1 ] == '' ) {
|
||||
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 );
|
||||
|
@ -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 = [
|
||||
|
@ -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';
|
||||
}
|
@ -964,6 +964,106 @@ class PHPMailer {
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a string looks like an email address.
|
||||
*
|
||||
* @param string $address The email address to check
|
||||
* @param string $patternselect A selector for the validation pattern to use :
|
||||
* * `auto` Pick best pattern automatically;
|
||||
* * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
|
||||
* * `pcre` Use old PCRE implementation;
|
||||
* * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
|
||||
* * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
|
||||
* * `noregex` Don't use a regex: super fast, really dumb.
|
||||
*
|
||||
* @return boolean
|
||||
* @static
|
||||
* @access public
|
||||
*/
|
||||
public static function validateAddress( $address, $patternselect = 'auto' ) {
|
||||
//Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
|
||||
if ( strpos( $address, "\n" ) !== false or strpos( $address, "\r" ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
if ( !$patternselect or $patternselect == 'auto' ) {
|
||||
//Check this constant first so it works when extension_loaded() is disabled by safe mode
|
||||
//Constant was added in PHP 5.2.4
|
||||
if ( defined( 'PCRE_VERSION' ) ) {
|
||||
//This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
|
||||
if ( version_compare( PCRE_VERSION, '8.0.3' ) >= 0 ) {
|
||||
$patternselect = 'pcre8';
|
||||
} else {
|
||||
$patternselect = 'pcre';
|
||||
}
|
||||
} elseif ( function_exists( 'extension_loaded' ) and extension_loaded( 'pcre' ) ) {
|
||||
//Fall back to older PCRE
|
||||
$patternselect = 'pcre';
|
||||
} else {
|
||||
//Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
|
||||
if ( version_compare( PHP_VERSION, '5.2.0' ) >= 0 ) {
|
||||
$patternselect = 'php';
|
||||
} else {
|
||||
$patternselect = 'noregex';
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ( $patternselect ) {
|
||||
case 'pcre8':
|
||||
/**
|
||||
* Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
|
||||
* @link http://squiloople.com/2009/12/20/email-address-validation/
|
||||
* @copyright 2009-2010 Michael Rushton
|
||||
* Feel free to use and redistribute this code. But please keep this copyright notice.
|
||||
*/
|
||||
return (boolean)preg_match(
|
||||
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
|
||||
'((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
|
||||
'(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
|
||||
'([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
|
||||
'(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
|
||||
'(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
|
||||
'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
|
||||
'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
|
||||
'|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
|
||||
$address
|
||||
);
|
||||
case 'pcre':
|
||||
//An older regex that doesn't need a recent PCRE
|
||||
return (boolean)preg_match(
|
||||
'/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
|
||||
'[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
|
||||
'(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
|
||||
'@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
|
||||
'(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
|
||||
'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
|
||||
'::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
|
||||
'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
|
||||
'::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
|
||||
'|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
|
||||
$address
|
||||
);
|
||||
case 'html5':
|
||||
/**
|
||||
* This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
|
||||
* @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
|
||||
*/
|
||||
return (boolean)preg_match(
|
||||
'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
|
||||
'[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
|
||||
$address
|
||||
);
|
||||
case 'noregex':
|
||||
//No PCRE! Do something _very_ approximate!
|
||||
//Check the address is 3 chars or longer and contains an @ that's not the first or last char
|
||||
return ( strlen( $address ) >= 3
|
||||
and strpos( $address, '@' ) >= 1
|
||||
and strpos( $address, '@' ) != strlen( $address ) - 1 );
|
||||
case 'php':
|
||||
default:
|
||||
return (boolean)filter_var( $address, FILTER_VALIDATE_EMAIL );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the From and FromName properties.
|
||||
*
|
||||
@ -1536,6 +1636,176 @@ class PHPMailer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Word-wrap message.
|
||||
* For use with mailers that do not automatically perform wrapping
|
||||
* and for quoted-printable encoded messages.
|
||||
* Original written by philippe.
|
||||
*
|
||||
* @param string $message The message to wrap
|
||||
* @param integer $length The line length to wrap to
|
||||
* @param boolean $qp_mode Whether to run in Quoted-Printable mode
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function wrapText( $message, $length, $qp_mode = false ) {
|
||||
if ( $qp_mode ) {
|
||||
$soft_break = sprintf( ' =%s', $this->LE );
|
||||
} else {
|
||||
$soft_break = $this->LE;
|
||||
}
|
||||
// If utf-8 encoding is used, we will need to make sure we don't
|
||||
// split multibyte characters when we wrap
|
||||
$is_utf8 = ( strtolower( $this->CharSet ) == 'utf-8' );
|
||||
$lelen = strlen( $this->LE );
|
||||
$crlflen = strlen( self::CRLF );
|
||||
|
||||
$message = $this->fixEOL( $message );
|
||||
//Remove a trailing line break
|
||||
if ( substr( $message, -$lelen ) == $this->LE ) {
|
||||
$message = substr( $message, 0, -$lelen );
|
||||
}
|
||||
|
||||
//Split message into lines
|
||||
$lines = explode( $this->LE, $message );
|
||||
//Message will be rebuilt in here
|
||||
$message = '';
|
||||
foreach ( $lines as $line ) {
|
||||
$words = explode( ' ', $line );
|
||||
$buf = '';
|
||||
$firstword = true;
|
||||
foreach ( $words as $word ) {
|
||||
if ( $qp_mode and ( strlen( $word ) > $length ) ) {
|
||||
$space_left = $length - strlen( $buf ) - $crlflen;
|
||||
if ( !$firstword ) {
|
||||
if ( $space_left > 20 ) {
|
||||
$len = $space_left;
|
||||
if ( $is_utf8 ) {
|
||||
$len = $this->utf8CharBoundary( $word, $len );
|
||||
} elseif ( substr( $word, $len - 1, 1 ) == '=' ) {
|
||||
$len--;
|
||||
} elseif ( substr( $word, $len - 2, 1 ) == '=' ) {
|
||||
$len -= 2;
|
||||
}
|
||||
$part = substr( $word, 0, $len );
|
||||
$word = substr( $word, $len );
|
||||
$buf .= ' ' . $part;
|
||||
$message .= $buf . sprintf( '=%s', self::CRLF );
|
||||
} else {
|
||||
$message .= $buf . $soft_break;
|
||||
}
|
||||
$buf = '';
|
||||
}
|
||||
while ( strlen( $word ) > 0 ) {
|
||||
if ( $length <= 0 ) {
|
||||
break;
|
||||
}
|
||||
$len = $length;
|
||||
if ( $is_utf8 ) {
|
||||
$len = $this->utf8CharBoundary( $word, $len );
|
||||
} elseif ( substr( $word, $len - 1, 1 ) == '=' ) {
|
||||
$len--;
|
||||
} elseif ( substr( $word, $len - 2, 1 ) == '=' ) {
|
||||
$len -= 2;
|
||||
}
|
||||
$part = substr( $word, 0, $len );
|
||||
$word = substr( $word, $len );
|
||||
|
||||
if ( strlen( $word ) > 0 ) {
|
||||
$message .= $part . sprintf( '=%s', self::CRLF );
|
||||
} else {
|
||||
$buf = $part;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$buf_o = $buf;
|
||||
if ( !$firstword ) {
|
||||
$buf .= ' ';
|
||||
}
|
||||
$buf .= $word;
|
||||
|
||||
if ( strlen( $buf ) > $length and $buf_o != '' ) {
|
||||
$message .= $buf_o . $soft_break;
|
||||
$buf = $word;
|
||||
}
|
||||
}
|
||||
$firstword = false;
|
||||
}
|
||||
$message .= $buf . self::CRLF;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure consistent line endings in a string.
|
||||
* Changes every end of line from CRLF, CR or LF to $this->LE.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str String to fixEOL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fixEOL( $str ) {
|
||||
// Normalise to \n
|
||||
$nstr = str_replace( array( "\r\n", "\r" ), "\n", $str );
|
||||
// Now convert LE as needed
|
||||
if ( $this->LE !== "\n" ) {
|
||||
$nstr = str_replace( "\n", $this->LE, $nstr );
|
||||
}
|
||||
|
||||
return $nstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the last character boundary prior to $maxLength in a utf-8
|
||||
* quoted-printable encoded string.
|
||||
* Original written by Colin Brown.
|
||||
* @access public
|
||||
*
|
||||
* @param string $encodedText utf-8 QP text
|
||||
* @param integer $maxLength Find the last character boundary prior to this length
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function utf8CharBoundary( $encodedText, $maxLength ) {
|
||||
$foundSplitPos = false;
|
||||
$lookBack = 3;
|
||||
while ( !$foundSplitPos ) {
|
||||
$lastChunk = substr( $encodedText, $maxLength - $lookBack, $lookBack );
|
||||
$encodedCharPos = strpos( $lastChunk, '=' );
|
||||
if ( false !== $encodedCharPos ) {
|
||||
// Found start of encoded character byte within $lookBack block.
|
||||
// Check the encoded byte value (the 2 chars after the '=')
|
||||
$hex = substr( $encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2 );
|
||||
$dec = hexdec( $hex );
|
||||
if ( $dec < 128 ) {
|
||||
// Single byte character.
|
||||
// If the encoded char was found at pos 0, it will fit
|
||||
// otherwise reduce maxLength to start of the encoded char
|
||||
if ( $encodedCharPos > 0 ) {
|
||||
$maxLength = $maxLength - ( $lookBack - $encodedCharPos );
|
||||
}
|
||||
$foundSplitPos = true;
|
||||
} elseif ( $dec >= 192 ) {
|
||||
// First byte of a multi byte character
|
||||
// Reduce maxLength to split at start of character
|
||||
$maxLength = $maxLength - ( $lookBack - $encodedCharPos );
|
||||
$foundSplitPos = true;
|
||||
} elseif ( $dec < 192 ) {
|
||||
// Middle byte of a multi byte character, look further back
|
||||
$lookBack += 3;
|
||||
}
|
||||
} else {
|
||||
// No encoded character found
|
||||
$foundSplitPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a string contains a line longer than the maximum line length allowed.
|
||||
*
|
||||
@ -1772,6 +2042,196 @@ class PHPMailer {
|
||||
return implode( '', $mime );
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a header string optimally.
|
||||
* Picks shortest of Q, B, quoted-printable or none.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeHeader( $str, $position = 'text' ) {
|
||||
$matchcount = 0;
|
||||
switch ( strtolower( $position ) ) {
|
||||
case 'phrase':
|
||||
if ( !preg_match( '/[\200-\377]/', $str ) ) {
|
||||
// Can't use addslashes as we don't know the value of magic_quotes_sybase
|
||||
$encoded = addcslashes( $str, "\0..\37\177\\\"" );
|
||||
if ( ( $str == $encoded ) && !preg_match( '/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str ) ) {
|
||||
return ( $encoded );
|
||||
} else {
|
||||
return ( "\"$encoded\"" );
|
||||
}
|
||||
}
|
||||
$matchcount = preg_match_all( '/[^\040\041\043-\133\135-\176]/', $str, $matches );
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'comment':
|
||||
$matchcount = preg_match_all( '/[()"]/', $str, $matches );
|
||||
// Intentional fall-through
|
||||
case 'text':
|
||||
default:
|
||||
$matchcount += preg_match_all( '/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches );
|
||||
break;
|
||||
}
|
||||
|
||||
//There are no chars that need encoding
|
||||
if ( $matchcount == 0 ) {
|
||||
return ( $str );
|
||||
}
|
||||
|
||||
$maxlen = 75 - 7 - strlen( $this->CharSet );
|
||||
// Try to select the encoding which should produce the shortest output
|
||||
if ( $matchcount > strlen( $str ) / 3 ) {
|
||||
// More than a third of the content will need encoding, so B encoding will be most efficient
|
||||
$encoding = 'B';
|
||||
if ( function_exists( 'mb_strlen' ) && $this->hasMultiBytes( $str ) ) {
|
||||
// Use a custom function which correctly encodes and wraps long
|
||||
// multibyte strings without breaking lines within a character
|
||||
$encoded = $this->base64EncodeWrapMB( $str, "\n" );
|
||||
} else {
|
||||
$encoded = base64_encode( $str );
|
||||
$maxlen -= $maxlen % 4;
|
||||
$encoded = trim( chunk_split( $encoded, $maxlen, "\n" ) );
|
||||
}
|
||||
} else {
|
||||
$encoding = 'Q';
|
||||
$encoded = $this->encodeQ( $str, $position );
|
||||
$encoded = $this->wrapText( $encoded, $maxlen, true );
|
||||
$encoded = str_replace( '=' . self::CRLF, "\n", trim( $encoded ) );
|
||||
}
|
||||
|
||||
$encoded = preg_replace( '/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded );
|
||||
$encoded = trim( str_replace( "\n", $this->LE, $encoded ) );
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string contains multi-byte characters.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str multi-byte text to wrap encode
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasMultiBytes( $str ) {
|
||||
if ( function_exists( 'mb_strlen' ) ) {
|
||||
return ( strlen( $str ) > mb_strlen( $str, $this->CharSet ) );
|
||||
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and wrap long multibyte strings for mail headers
|
||||
* without breaking lines within a character.
|
||||
* Adapted from a function by paravoid
|
||||
* @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
|
||||
* @access public
|
||||
*
|
||||
* @param string $str multi-byte text to wrap encode
|
||||
* @param string $linebreak string to use as linefeed/end-of-line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function base64EncodeWrapMB( $str, $linebreak = null ) {
|
||||
$start = '=?' . $this->CharSet . '?B?';
|
||||
$end = '?=';
|
||||
$encoded = '';
|
||||
if ( $linebreak === null ) {
|
||||
$linebreak = $this->LE;
|
||||
}
|
||||
|
||||
$mb_length = mb_strlen( $str, $this->CharSet );
|
||||
// Each line must have length <= 75, including $start and $end
|
||||
$length = 75 - strlen( $start ) - strlen( $end );
|
||||
// Average multi-byte ratio
|
||||
$ratio = $mb_length / strlen( $str );
|
||||
// Base64 has a 4:3 ratio
|
||||
$avgLength = floor( $length * $ratio * .75 );
|
||||
|
||||
for ( $i = 0; $i < $mb_length; $i += $offset ) {
|
||||
$lookBack = 0;
|
||||
do {
|
||||
$offset = $avgLength - $lookBack;
|
||||
$chunk = mb_substr( $str, $i, $offset, $this->CharSet );
|
||||
$chunk = base64_encode( $chunk );
|
||||
$lookBack++;
|
||||
} while ( strlen( $chunk ) > $length );
|
||||
$encoded .= $chunk . $linebreak;
|
||||
}
|
||||
|
||||
// Chomp the last linefeed
|
||||
$encoded = substr( $encoded, 0, -strlen( $linebreak ) );
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a string using Q encoding.
|
||||
* @link http://tools.ietf.org/html/rfc2047
|
||||
*
|
||||
* @param string $str the text to encode
|
||||
* @param string $position Where the text is going to be used, see the RFC for what that means
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function encodeQ( $str, $position = 'text' ) {
|
||||
// There should not be any EOL in the string
|
||||
$pattern = '';
|
||||
$encoded = str_replace( array( "\r", "\n" ), '', $str );
|
||||
switch ( strtolower( $position ) ) {
|
||||
case 'phrase':
|
||||
// RFC 2047 section 5.3
|
||||
$pattern = '^A-Za-z0-9!*+\/ -';
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'comment':
|
||||
// RFC 2047 section 5.2
|
||||
$pattern = '\(\)"';
|
||||
// intentional fall-through
|
||||
// for this reason we build the $pattern without including delimiters and []
|
||||
case 'text':
|
||||
default:
|
||||
// RFC 2047 section 5.1
|
||||
// Replace every high ascii, control, =, ? and _ characters
|
||||
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
|
||||
break;
|
||||
}
|
||||
$matches = array();
|
||||
if ( preg_match_all( "/[{$pattern}]/", $encoded, $matches ) ) {
|
||||
// If the string contains an '=', make sure it's the first thing we replace
|
||||
// so as to avoid double-encoding
|
||||
$eqkey = array_search( '=', $matches[ 0 ] );
|
||||
if ( false !== $eqkey ) {
|
||||
unset( $matches[ 0 ][ $eqkey ] );
|
||||
array_unshift( $matches[ 0 ], '=' );
|
||||
}
|
||||
foreach ( array_unique( $matches[ 0 ] ) as $char ) {
|
||||
$encoded = str_replace( $char, '=' . sprintf( '%02X', ord( $char ) ), $encoded );
|
||||
}
|
||||
}
|
||||
|
||||
// Replace every spaces to _ (more readable than =20)
|
||||
return str_replace( ' ', '_', $encoded );
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip newlines to prevent header injection.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function secureHeader( $str ) {
|
||||
return trim( str_replace( array( "\r", "\n" ), '', $str ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an error occurred.
|
||||
* @access public
|
||||
@ -2595,366 +3055,6 @@ class PHPMailer {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip newlines to prevent header injection.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function secureHeader( $str ) {
|
||||
return trim( str_replace( array( "\r", "\n" ), '', $str ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a header string optimally.
|
||||
* Picks shortest of Q, B, quoted-printable or none.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeHeader( $str, $position = 'text' ) {
|
||||
$matchcount = 0;
|
||||
switch ( strtolower( $position ) ) {
|
||||
case 'phrase':
|
||||
if ( ! preg_match( '/[\200-\377]/', $str ) ) {
|
||||
// Can't use addslashes as we don't know the value of magic_quotes_sybase
|
||||
$encoded = addcslashes( $str, "\0..\37\177\\\"" );
|
||||
if ( ( $str == $encoded ) && ! preg_match( '/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str ) ) {
|
||||
return ( $encoded );
|
||||
} else {
|
||||
return ( "\"$encoded\"" );
|
||||
}
|
||||
}
|
||||
$matchcount = preg_match_all( '/[^\040\041\043-\133\135-\176]/', $str, $matches );
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'comment':
|
||||
$matchcount = preg_match_all( '/[()"]/', $str, $matches );
|
||||
// Intentional fall-through
|
||||
case 'text':
|
||||
default:
|
||||
$matchcount += preg_match_all( '/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches );
|
||||
break;
|
||||
}
|
||||
|
||||
//There are no chars that need encoding
|
||||
if ( $matchcount == 0 ) {
|
||||
return ( $str );
|
||||
}
|
||||
|
||||
$maxlen = 75 - 7 - strlen( $this->CharSet );
|
||||
// Try to select the encoding which should produce the shortest output
|
||||
if ( $matchcount > strlen( $str ) / 3 ) {
|
||||
// More than a third of the content will need encoding, so B encoding will be most efficient
|
||||
$encoding = 'B';
|
||||
if ( function_exists( 'mb_strlen' ) && $this->hasMultiBytes( $str ) ) {
|
||||
// Use a custom function which correctly encodes and wraps long
|
||||
// multibyte strings without breaking lines within a character
|
||||
$encoded = $this->base64EncodeWrapMB( $str, "\n" );
|
||||
} else {
|
||||
$encoded = base64_encode( $str );
|
||||
$maxlen -= $maxlen % 4;
|
||||
$encoded = trim( chunk_split( $encoded, $maxlen, "\n" ) );
|
||||
}
|
||||
} else {
|
||||
$encoding = 'Q';
|
||||
$encoded = $this->encodeQ( $str, $position );
|
||||
$encoded = $this->wrapText( $encoded, $maxlen, true );
|
||||
$encoded = str_replace( '=' . self::CRLF, "\n", trim( $encoded ) );
|
||||
}
|
||||
|
||||
$encoded = preg_replace( '/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded );
|
||||
$encoded = trim( str_replace( "\n", $this->LE, $encoded ) );
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string contains multi-byte characters.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str multi-byte text to wrap encode
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasMultiBytes( $str ) {
|
||||
if ( function_exists( 'mb_strlen' ) ) {
|
||||
return ( strlen( $str ) > mb_strlen( $str, $this->CharSet ) );
|
||||
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and wrap long multibyte strings for mail headers
|
||||
* without breaking lines within a character.
|
||||
* Adapted from a function by paravoid
|
||||
* @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
|
||||
* @access public
|
||||
*
|
||||
* @param string $str multi-byte text to wrap encode
|
||||
* @param string $linebreak string to use as linefeed/end-of-line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function base64EncodeWrapMB( $str, $linebreak = null ) {
|
||||
$start = '=?' . $this->CharSet . '?B?';
|
||||
$end = '?=';
|
||||
$encoded = '';
|
||||
if ( $linebreak === null ) {
|
||||
$linebreak = $this->LE;
|
||||
}
|
||||
|
||||
$mb_length = mb_strlen( $str, $this->CharSet );
|
||||
// Each line must have length <= 75, including $start and $end
|
||||
$length = 75 - strlen( $start ) - strlen( $end );
|
||||
// Average multi-byte ratio
|
||||
$ratio = $mb_length / strlen( $str );
|
||||
// Base64 has a 4:3 ratio
|
||||
$avgLength = floor( $length * $ratio * .75 );
|
||||
|
||||
for ( $i = 0; $i < $mb_length; $i += $offset ) {
|
||||
$lookBack = 0;
|
||||
do {
|
||||
$offset = $avgLength - $lookBack;
|
||||
$chunk = mb_substr( $str, $i, $offset, $this->CharSet );
|
||||
$chunk = base64_encode( $chunk );
|
||||
$lookBack ++;
|
||||
} while ( strlen( $chunk ) > $length );
|
||||
$encoded .= $chunk . $linebreak;
|
||||
}
|
||||
|
||||
// Chomp the last linefeed
|
||||
$encoded = substr( $encoded, 0, - strlen( $linebreak ) );
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a string using Q encoding.
|
||||
* @link http://tools.ietf.org/html/rfc2047
|
||||
*
|
||||
* @param string $str the text to encode
|
||||
* @param string $position Where the text is going to be used, see the RFC for what that means
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function encodeQ( $str, $position = 'text' ) {
|
||||
// There should not be any EOL in the string
|
||||
$pattern = '';
|
||||
$encoded = str_replace( array( "\r", "\n" ), '', $str );
|
||||
switch ( strtolower( $position ) ) {
|
||||
case 'phrase':
|
||||
// RFC 2047 section 5.3
|
||||
$pattern = '^A-Za-z0-9!*+\/ -';
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'comment':
|
||||
// RFC 2047 section 5.2
|
||||
$pattern = '\(\)"';
|
||||
// intentional fall-through
|
||||
// for this reason we build the $pattern without including delimiters and []
|
||||
case 'text':
|
||||
default:
|
||||
// RFC 2047 section 5.1
|
||||
// Replace every high ascii, control, =, ? and _ characters
|
||||
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
|
||||
break;
|
||||
}
|
||||
$matches = array();
|
||||
if ( preg_match_all( "/[{$pattern}]/", $encoded, $matches ) ) {
|
||||
// If the string contains an '=', make sure it's the first thing we replace
|
||||
// so as to avoid double-encoding
|
||||
$eqkey = array_search( '=', $matches[0] );
|
||||
if ( false !== $eqkey ) {
|
||||
unset( $matches[0][ $eqkey ] );
|
||||
array_unshift( $matches[0], '=' );
|
||||
}
|
||||
foreach ( array_unique( $matches[0] ) as $char ) {
|
||||
$encoded = str_replace( $char, '=' . sprintf( '%02X', ord( $char ) ), $encoded );
|
||||
}
|
||||
}
|
||||
|
||||
// Replace every spaces to _ (more readable than =20)
|
||||
return str_replace( ' ', '_', $encoded );
|
||||
}
|
||||
|
||||
/**
|
||||
* Word-wrap message.
|
||||
* For use with mailers that do not automatically perform wrapping
|
||||
* and for quoted-printable encoded messages.
|
||||
* Original written by philippe.
|
||||
*
|
||||
* @param string $message The message to wrap
|
||||
* @param integer $length The line length to wrap to
|
||||
* @param boolean $qp_mode Whether to run in Quoted-Printable mode
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function wrapText( $message, $length, $qp_mode = false ) {
|
||||
if ( $qp_mode ) {
|
||||
$soft_break = sprintf( ' =%s', $this->LE );
|
||||
} else {
|
||||
$soft_break = $this->LE;
|
||||
}
|
||||
// If utf-8 encoding is used, we will need to make sure we don't
|
||||
// split multibyte characters when we wrap
|
||||
$is_utf8 = ( strtolower( $this->CharSet ) == 'utf-8' );
|
||||
$lelen = strlen( $this->LE );
|
||||
$crlflen = strlen( self::CRLF );
|
||||
|
||||
$message = $this->fixEOL( $message );
|
||||
//Remove a trailing line break
|
||||
if ( substr( $message, - $lelen ) == $this->LE ) {
|
||||
$message = substr( $message, 0, - $lelen );
|
||||
}
|
||||
|
||||
//Split message into lines
|
||||
$lines = explode( $this->LE, $message );
|
||||
//Message will be rebuilt in here
|
||||
$message = '';
|
||||
foreach ( $lines as $line ) {
|
||||
$words = explode( ' ', $line );
|
||||
$buf = '';
|
||||
$firstword = true;
|
||||
foreach ( $words as $word ) {
|
||||
if ( $qp_mode and ( strlen( $word ) > $length ) ) {
|
||||
$space_left = $length - strlen( $buf ) - $crlflen;
|
||||
if ( ! $firstword ) {
|
||||
if ( $space_left > 20 ) {
|
||||
$len = $space_left;
|
||||
if ( $is_utf8 ) {
|
||||
$len = $this->utf8CharBoundary( $word, $len );
|
||||
} elseif ( substr( $word, $len - 1, 1 ) == '=' ) {
|
||||
$len --;
|
||||
} elseif ( substr( $word, $len - 2, 1 ) == '=' ) {
|
||||
$len -= 2;
|
||||
}
|
||||
$part = substr( $word, 0, $len );
|
||||
$word = substr( $word, $len );
|
||||
$buf .= ' ' . $part;
|
||||
$message .= $buf . sprintf( '=%s', self::CRLF );
|
||||
} else {
|
||||
$message .= $buf . $soft_break;
|
||||
}
|
||||
$buf = '';
|
||||
}
|
||||
while ( strlen( $word ) > 0 ) {
|
||||
if ( $length <= 0 ) {
|
||||
break;
|
||||
}
|
||||
$len = $length;
|
||||
if ( $is_utf8 ) {
|
||||
$len = $this->utf8CharBoundary( $word, $len );
|
||||
} elseif ( substr( $word, $len - 1, 1 ) == '=' ) {
|
||||
$len --;
|
||||
} elseif ( substr( $word, $len - 2, 1 ) == '=' ) {
|
||||
$len -= 2;
|
||||
}
|
||||
$part = substr( $word, 0, $len );
|
||||
$word = substr( $word, $len );
|
||||
|
||||
if ( strlen( $word ) > 0 ) {
|
||||
$message .= $part . sprintf( '=%s', self::CRLF );
|
||||
} else {
|
||||
$buf = $part;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$buf_o = $buf;
|
||||
if ( ! $firstword ) {
|
||||
$buf .= ' ';
|
||||
}
|
||||
$buf .= $word;
|
||||
|
||||
if ( strlen( $buf ) > $length and $buf_o != '' ) {
|
||||
$message .= $buf_o . $soft_break;
|
||||
$buf = $word;
|
||||
}
|
||||
}
|
||||
$firstword = false;
|
||||
}
|
||||
$message .= $buf . self::CRLF;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure consistent line endings in a string.
|
||||
* Changes every end of line from CRLF, CR or LF to $this->LE.
|
||||
* @access public
|
||||
*
|
||||
* @param string $str String to fixEOL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fixEOL( $str ) {
|
||||
// Normalise to \n
|
||||
$nstr = str_replace( array( "\r\n", "\r" ), "\n", $str );
|
||||
// Now convert LE as needed
|
||||
if ( $this->LE !== "\n" ) {
|
||||
$nstr = str_replace( "\n", $this->LE, $nstr );
|
||||
}
|
||||
|
||||
return $nstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the last character boundary prior to $maxLength in a utf-8
|
||||
* quoted-printable encoded string.
|
||||
* Original written by Colin Brown.
|
||||
* @access public
|
||||
*
|
||||
* @param string $encodedText utf-8 QP text
|
||||
* @param integer $maxLength Find the last character boundary prior to this length
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function utf8CharBoundary( $encodedText, $maxLength ) {
|
||||
$foundSplitPos = false;
|
||||
$lookBack = 3;
|
||||
while ( ! $foundSplitPos ) {
|
||||
$lastChunk = substr( $encodedText, $maxLength - $lookBack, $lookBack );
|
||||
$encodedCharPos = strpos( $lastChunk, '=' );
|
||||
if ( false !== $encodedCharPos ) {
|
||||
// Found start of encoded character byte within $lookBack block.
|
||||
// Check the encoded byte value (the 2 chars after the '=')
|
||||
$hex = substr( $encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2 );
|
||||
$dec = hexdec( $hex );
|
||||
if ( $dec < 128 ) {
|
||||
// Single byte character.
|
||||
// If the encoded char was found at pos 0, it will fit
|
||||
// otherwise reduce maxLength to start of the encoded char
|
||||
if ( $encodedCharPos > 0 ) {
|
||||
$maxLength = $maxLength - ( $lookBack - $encodedCharPos );
|
||||
}
|
||||
$foundSplitPos = true;
|
||||
} elseif ( $dec >= 192 ) {
|
||||
// First byte of a multi byte character
|
||||
// Reduce maxLength to split at start of character
|
||||
$maxLength = $maxLength - ( $lookBack - $encodedCharPos );
|
||||
$foundSplitPos = true;
|
||||
} elseif ( $dec < 192 ) {
|
||||
// Middle byte of a multi byte character, look further back
|
||||
$lookBack += 3;
|
||||
}
|
||||
} else {
|
||||
// No encoded character found
|
||||
$foundSplitPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of strings for the current language.
|
||||
* @return array
|
||||
@ -3537,7 +3637,8 @@ class PHPMailer {
|
||||
*
|
||||
* @return boolean True on successfully adding an attachment
|
||||
*/
|
||||
public function addEmbeddedImage( $path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline' ) {
|
||||
public function addEmbeddedImage( $path, $cid, $name = '', $encoding = 'base64', $type = '',
|
||||
$disposition = 'inline' ) {
|
||||
if ( !@is_file( $path ) ) {
|
||||
$this->setError( $this->lang( 'file_access' ) . $path );
|
||||
|
||||
@ -3777,106 +3878,6 @@ class PHPMailer {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a string looks like an email address.
|
||||
*
|
||||
* @param string $address The email address to check
|
||||
* @param string $patternselect A selector for the validation pattern to use :
|
||||
* * `auto` Pick best pattern automatically;
|
||||
* * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
|
||||
* * `pcre` Use old PCRE implementation;
|
||||
* * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
|
||||
* * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
|
||||
* * `noregex` Don't use a regex: super fast, really dumb.
|
||||
*
|
||||
* @return boolean
|
||||
* @static
|
||||
* @access public
|
||||
*/
|
||||
public static function validateAddress( $address, $patternselect = 'auto' ) {
|
||||
//Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
|
||||
if ( strpos( $address, "\n" ) !== false or strpos( $address, "\r" ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! $patternselect or $patternselect == 'auto' ) {
|
||||
//Check this constant first so it works when extension_loaded() is disabled by safe mode
|
||||
//Constant was added in PHP 5.2.4
|
||||
if ( defined( 'PCRE_VERSION' ) ) {
|
||||
//This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
|
||||
if ( version_compare( PCRE_VERSION, '8.0.3' ) >= 0 ) {
|
||||
$patternselect = 'pcre8';
|
||||
} else {
|
||||
$patternselect = 'pcre';
|
||||
}
|
||||
} elseif ( function_exists( 'extension_loaded' ) and extension_loaded( 'pcre' ) ) {
|
||||
//Fall back to older PCRE
|
||||
$patternselect = 'pcre';
|
||||
} else {
|
||||
//Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
|
||||
if ( version_compare( PHP_VERSION, '5.2.0' ) >= 0 ) {
|
||||
$patternselect = 'php';
|
||||
} else {
|
||||
$patternselect = 'noregex';
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ( $patternselect ) {
|
||||
case 'pcre8':
|
||||
/**
|
||||
* Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
|
||||
* @link http://squiloople.com/2009/12/20/email-address-validation/
|
||||
* @copyright 2009-2010 Michael Rushton
|
||||
* Feel free to use and redistribute this code. But please keep this copyright notice.
|
||||
*/
|
||||
return (boolean) preg_match(
|
||||
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
|
||||
'((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
|
||||
'(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
|
||||
'([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
|
||||
'(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
|
||||
'(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
|
||||
'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
|
||||
'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
|
||||
'|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
|
||||
$address
|
||||
);
|
||||
case 'pcre':
|
||||
//An older regex that doesn't need a recent PCRE
|
||||
return (boolean) preg_match(
|
||||
'/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
|
||||
'[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
|
||||
'(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
|
||||
'@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
|
||||
'(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
|
||||
'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
|
||||
'::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
|
||||
'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
|
||||
'::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
|
||||
'|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
|
||||
$address
|
||||
);
|
||||
case 'html5':
|
||||
/**
|
||||
* This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
|
||||
* @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
|
||||
*/
|
||||
return (boolean) preg_match(
|
||||
'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
|
||||
'[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
|
||||
$address
|
||||
);
|
||||
case 'noregex':
|
||||
//No PCRE! Do something _very_ approximate!
|
||||
//Check the address is 3 chars or longer and contains an @ that's not the first or last char
|
||||
return ( strlen( $address ) >= 3
|
||||
and strpos( $address, '@' ) >= 1
|
||||
and strpos( $address, '@' ) != strlen( $address ) - 1 );
|
||||
case 'php':
|
||||
default:
|
||||
return (boolean) filter_var( $address, FILTER_VALIDATE_EMAIL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,7 +75,7 @@ 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();
|
||||
|
@ -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>
|
@ -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>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<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' ] ?>">
|
||||
@ -18,17 +18,19 @@
|
||||
<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: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">
|
||||
|
||||
@ -38,4 +40,30 @@
|
||||
|
||||
</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
13
static/css/materialize.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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
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
16
static/img/logo.svg
Normal 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
BIN
static/img/muscles.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,5 @@
|
||||
$(document).ready(() => {
|
||||
|
||||
$(".dropdown-trigger").dropdown();
|
||||
|
||||
});
|
4
static/js/jquery-3.2.1.min.js
vendored
4
static/js/jquery-3.2.1.min.js
vendored
File diff suppressed because one or more lines are too long
2
static/js/jquery-3.3.1.min.js
vendored
Normal file
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
6
static/js/materialize.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user