| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | 	namespace core\functions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 	 * Class ChaineCaractere qui contient des fonctions pour des traitements sur des chaies de caracteres | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 	 * @package core\functions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 	class ChaineCaractere { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		 * créer une chaine de caractere aléatoire suivant une logneur donnée | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 		 * @param $longueur | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 		public static function random($longueur) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 			$string = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 			$chaine = "abcdefghijklmnpqrstuvwxyz0123456789"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 			srand((double)microtime() * 1000000); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 			for ($i = 0; $i < $longueur; $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 				$string .= $chaine[rand() % strlen($chaine)]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 			return $string; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		 * enleve les accents les espace guillement.. pour une url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		 * @param $url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		 * @return mixed | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 29 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 		public static function setUrl($url) { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 			$search = array(' ', 'é', '"\"', 'è', '"', 'ê', '@', '&', '(', ')', '[', ']', '?', '*', "'", '@', ':', '&', '#', 'à', '=', '+', '°', '!', '%', '|', '$', '£'); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 			$replace = array('-', 'e', '-', 'e', '-', 'e', 'a', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 'a', '-', '-', '-', '-', '%', '-', '-', '-'); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 			return strtolower(str_replace($search, $replace, $url)); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		 * rechercher une chaine de caracatere dans une autre | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		 * renvoi true si elle est trouvée | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		 * @param $string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		 * @param $find | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		public static function FindInString($string, $find) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 			if (strpos($string, $find) !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		 * fonction qui test si on a que des carac | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		 * @param $string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		public static function alphaNumeric($string) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 			if (!preg_match('/^[a-zA-Z0-9]+$/', $string)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		 * @param $string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		 * @param int $lenght | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		 * fonction qui test si la taille minimale de | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		public static function testMinLenght($string, $lenght = 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			if (strlen($string) > $lenght) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			return false; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 80 |  |  | 		} | 
            
                                                        
            
                                    
            
            
                | 81 |  |  | 	} |