PARAGRAPHES if('nl2p' === $typ && !strchr($return,''; } elseif(is_object($val)){ $r = 'object('.count(get_object_vars($val)).')'; } else $r = gettype($val).'('.strlen($val).') "'.$val.'"'; if(!$sup) $r .= ''; $return = $r; } ## MISE EN FORME D'UNE REQUETE SQL elseif('sql' === $typ){ $return = htmlentities($return); $return = preg_replace('/(from|order by|limit|inner join|left join|where|having|group by)/i','
\\1',$return); } return $return; } } #[F]# X_writeLogs # @param $file string Url du fichier de logs # @param $logs array tableau de logs if(!function_exists('X_writeLogs')){ function X_writeLogs($file, $logs){ if(is_array($logs)) foreach($logs as $key => $log) X_writeLogs($file, $log); else @file_put_contents(realpath(dirname(__FILE__)).'/debug/logs.txt', $logs."\n", FILE_APPEND); } } #[F]# X_dateformat ex : X_dateformat("19/09/2011", "d/m/Y", "y/m/d") # @param $date string Date au format str (selon la liste des paramètres de formatage acceptés) # @param $inFormat string Format d'entrée (selon la liste des paramètres de formatage acceptés) # @param $outFormat string Format de sortie # @return string Retourne la date formatée au format souhaité # PARAMETRES DU FORMAT D'ENTREE ACCEPTES # d Jour du mois, sur deux chiffres (avec un zéro initial) 01 à 31 # j Jour du mois sans les zéros initiaux 1 à 31 # m Mois au format numérique, avec zéros initiaux 01 à 12 # n Mois sans les zéros initiaux 1 à 12 # Y Année sur 4 chiffres Exemples : 1999 ou 2003 # y Année sur 2 chiffres Exemples : 99 ou 03 if(!function_exists('X_dateformat')){ function X_dateformat($date, $inFormat, $outFormat){ $tab_out = array('m' => NULL, 'd' => NULL, 'y' => NULL); $param_formats = array('d','j','m','n','y','Y'); for ($i=0; $i $val){ switch ($val) { case "d": $tab_out['d'] = $tab_date[$key]; break; case "j": $tab_out['d'] = $tab_date[$key]; break; case "m": $tab_out['m'] = $tab_date[$key]; break; case "n": $tab_out['m'] = $tab_date[$key]; break; case "Y": $tab_out['y'] = $tab_date[$key]; break; case "y": $tab_out['y'] = $tab_date[$key]; break; } } $outDate = date($outFormat, strtotime($tab_out['y'].'-'.$tab_out['m'].'-'.$tab_out['d'])); if ($outDate == False) $outDate = date($outFormat, strtotime($tab_out['y'].'\\'.$tab_out['m'].'\\'.$tab_out['d'])); $return = (!$outDate) ? false : $outDate; return $return; } } # Autres fonctions if(!function_exists('couper_texte_html')){ function couper_texte_html($text, $length, $ending = '...', $exact = false) { if(strlen(preg_replace('/<.*?>/', '', $text)) <= $length) { return $text; } preg_match_all('/(<.+?>)?([^<>]*)/is', $text, $matches, PREG_SET_ORDER); $total_length = 0; $arr_elements = array(); $truncate = ''; foreach($matches as $element) { if(!empty($element[1])) { if(preg_match('/^<\s*.+?\/\s*>$/s', $element[1])) { } else if(preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $element[1], $element2)) { $pos = array_search($element2[1], $arr_elements); if($pos !== false) { unset($arr_elements[$pos]); } } else if(preg_match('/^<\s*([^\s>!]+).*?>$/s', $element[1], $element2)) { array_unshift($arr_elements, strtolower($element2[1])); } $truncate .= $element[1]; } $content_length = strlen(preg_replace('/(&[a-z]{1,6};|&#[0-9]+;)/i', ' ', $element[2])); if($total_length >= $length) { break; } elseif ($total_length+$content_length > $length) { $left = $total_length>$length?$total_length-$length:$length-$total_length; $entities_length = 0; if(preg_match_all('/&[a-z]{1,6};|&#[0-9]+;/i', $element[2], $element3, PREG_OFFSET_CAPTURE)) { foreach($element3[0] as $entity) { if($entity[1]+1-$entities_length <= $left) { $left--; $entities_length += strlen($entity[0]); } else break; } } $truncate .= substr($element[2], 0, $left+$entities_length); break; } else { $truncate .= $element[2]; $total_length += $content_length; } } if(!$exact) { $spacepos = strrpos($truncate, ' '); if(isset($spacepos)) { $truncate = substr($truncate, 0, $spacepos); } } $truncate .= $ending; foreach($arr_elements as $element) { $truncate .= ''; } return $truncate; } } if(!function_exists('secondMinute')){ function secondMinute($seconds){ return date(($seconds < 0 ? '- ' : '')."H:i:s",(abs($seconds)-3600)); } } ?>