mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-18 16:18:04 +00:00
Ready to implement sendMessage method
This commit is contained in:
@ -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("<", "<", $input);
|
||||
return str_replace(">", ">", $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;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* API specific methods
|
||||
* Strings methods
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
@ -22,4 +22,4 @@ function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzAB
|
||||
$str .= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user