1
0
mirror of https://github.com/pierre42100/ComunicAPI synced 2025-07-10 03:52:54 +00:00

Ready to implement sendMessage method

This commit is contained in:
Pierre
2017-06-23 19:00:40 +02:00
parent be91602277
commit 03392f65a9
4 changed files with 98 additions and 3 deletions

@ -64,4 +64,42 @@ function users_list_to_array($list) : array{
*/
function toInt($input){
return floor($input*1);
}
/**
* Remove HTML markup codes (<, >)
*
* @param String $input The string to change
* @return String The updated string
*/
function removeHTMLnodes($input){
$output = str_replace("<", "&lt;", $input);
return str_replace(">", "&gt;", $output);
}
/**
* Check a string before inserting it
*
* @param String $string The string to check
* @return Boolean True if the string is valid / false else
*/
function check_string_before_insert($string){
//First, empty string are invalid
if($string == "")
return false;
//Remove HTML tags before continuing
$string = str_replace(array("<", ">"), "", $string);
//Check string size
if(strlen($string)<5)
return false;
//Check if the string has at least three different characters
if(strlen(count_chars($string,3)) < 3)
return false;
//Success
return true;
}