Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.volley92.asso.fr
/
htdocs
/
functions
/
/srv/data/web/vhosts/www.volley92.asso.fr/htdocs/functions/functions.php
<?php /** * Contants * ================ * */ define('_2_CHARS_REGEX_', '/^.{2,}$/'); define('_EMAIL_REGEX_','/^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-zA-Z]{2,4}$/'); define('_PHONE_REGEX_','/^(0|33)[1-9]([-. ]?[0-9]{2}){4}$/'); define('_ZIPCODE_REGEX_','/^[0-9]{4,7}$/'); define('_AMOUNT_REGEX_','/^[0-9]+[.,]?[0-9]{0,2}$/'); define('_DATE_REGEX_','/^([0-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/'); define('_MESSAGE_REGEX_','/^[a-zA-Z0-9?$@#()\'!,+\-=_:.&€£*%\s]+$/'); define('_MAX_FILE_SIZE_','2000000'); /** * Validation rules * ================ * */ function validate_status($field){ } function file_is_uploaded($file) { if(!file_exists($file['tmp_name']) || !is_uploaded_file($file['tmp_name'])){ return false; }elseif($file['size'] > _MAX_FILE_SIZE_){ return false; }else{ return true; } } function validate($regex,$field){ if (is_null($regex)){ return true; }else{ return (preg_match($regex,$field))?true:false; } } /** * Form Helpers * ============ * form_open() * form_close() * */ function attributes($options = array()){ $html=''; foreach($options as $attribute => $value) { $html .= $attribute . '="'.$value.'" '; } return $html; } function form_open($route,$options = array()){ return '<form role="form" method="post" action="'. $route.'" '.attributes($options).'>'; } function form_close(){ return '</form>'; } function form_label($field,$for = NULL){ return (!$for==NULL)?'<label for="form_'. $for.'">'.$field.'</label>':'<label>'.$field.'</label>'; } //for after function autofocus($form_is_submitted) { return (!$form_is_submitted)?'autofocus':''; } function form_text($name,$value,$options = array()){ return '<input type="text" name="'.$name.'" id="form_'.$name.'" value="'.$value.'" '. attributes($options) .'>'; } function form_feedback($form_is_submitted,$field_status) { return ($form_is_submitted)?'<span class="fa '.(($field_status == 'has-success')?'fa-check':'fa-times' ).' form-control-feedback"></span>':''; } function form_textarea($name,$value,$options = array()){ return '<textarea name="'.$name.'" id="form_'.$name.'" '.attributes($options).'>'.$value.'</textarea>'; } function form_select($name,$value,$list,$options = array()){ $select_options = ''; foreach((array) $list as $option) { $select_options .= '<option '. (($value==$option)?'selected="selected"':'') .'>'.$option.'</option>'; } return '<select name="'.$name.'" id="form_'.$name.'" '.attributes($options).'>'.$select_options.'</select>'; } function form_checkbox($name,$value,$label,$options = array()){ return '<label><input type="checkbox" name="'.$name.'" '. attributes($options).' '.(($value)?'checked':'').'>'.$label. '</label>'; } function form_radio($name,$radio,$value,$label,$form_is_submitted = TRUE,$options = array()){ /*if(!$form_is_submitted){ //return '<label><input type="radio" name="'.$name.'" value="'.$value.'" '.attributes($options).' checked'.'>'.$label.'</label>'; }else{ //return '<label><input type="radio" name="'.$name.'" value="'.$value.'" '.attributes($options).' '.($radio == $value)?'checked':''.'>'.$label.'</label>'; }*/ return '<label><input type="radio" name="'.$name.'" value="'.$value.'" '.attributes($options).' '.((!$form_is_submitted OR $radio == $value)?'checked':'').'>'.$label.'</label>'; } function form_file($name){ return '<input type="file" name="'.$name.'" id="form_'.$name. '">'; } /* fixing $title issue with news(actualites) */ function start_block($page_title,$page_keywords,$page_description){ global $conf_title; global $conf_keywords; global $conf_description; if(!empty($page_title)) { $conf_title = $page_title; } if(!empty($page_keywords)) { $conf_keywords = $page_keywords; } if(!empty($page_description)) { $conf_description = $page_description; } ob_start(); } // FONCTION URL ENCODE function myUrlEncode($text) { // replace non letter or digits by - $text = preg_replace('~[^\pL\d]+~u', '-', $text); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); // trim $text = trim($text, '-'); // remove duplicate - $text = preg_replace('~-+~', '-', $text); // lowercase $text = strtolower($text); if (empty($text)) { return 'n-a'; } return $text; } function end_block(){ global $content; $content = ob_get_contents(); ob_end_clean(); } function suppr_accents($str, $encoding='utf-8') { // transformer les caractères accentués en entités HTML $str = htmlentities($str, ENT_NOQUOTES, $encoding); // remplacer les entités HTML pour avoir juste le premier caractères non accentués // Exemple : "&ecute;" => "e", "&Ecute;" => "E", "à" => "a" ... $str = preg_replace('#&([A-za-z])(?:acute|grave|cedil|circ|orn|ring|slash|th|tilde|uml);#', '\1', $str); // Remplacer les ligatures tel que : , Æ ... // Exemple "œ" => "oe" $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // Supprimer tout le reste $str = preg_replace('#&[^;]+;#', '', $str); return $str; } function nameUrl($str) { $url = suppr_accents($str); $url = strtolower($url); $url = str_replace(array('/', '-', ':','\'',',','(',')'), '', $url); $url = str_replace(array(' '), ' ', $url); $url = str_replace(array(' '), '-', $url); return urlencode($url); } // FONCTION LIMITE WORD function limit_text($text, $limit) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); if (strlen($text) > $limit) { // truncate string $stringCut = substr($text, 0, $limit); $endPoint = strrpos($stringCut, ' '); //if the string doesn't contain any space then it will cut without word basis. $text = $endPoint? substr($stringCut, 0, $endPoint):substr($stringCut, 0); $text .= '...'; } return $text; } // FONCTION GENERATE TOKEN function getToken($length) { $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function dump($text){ echo '<pre>'; var_dump($text); echo '</pre>'; return $text; } function printR($text){ echo '<pre>'; print_r($text); echo '</pre>'; return $text; }