Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16747 | Rev 16768 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16747 Rev 16766
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea 5...
5
namespace LeadersLinked\Library;
5
namespace LeadersLinked\Library;
6
 
6
 
-
 
7
abstract class Functions
-
 
8
{
-
 
9
    
-
 
10
    
-
 
11
    /**
-
 
12
     * @param string $value
-
 
13
     * @param array $flags
-
 
14
     * @return string
-
 
15
     */
-
 
16
    public static function sanitizeFilterString($value, array $flags = []): string
-
 
17
    {
-
 
18
        if(empty($value)) {
-
 
19
            return '';
-
 
20
        }
-
 
21
        
-
 
22
        $value = strval($value);
-
 
23
        
-
 
24
        
-
 
25
        
-
 
26
        $noQuotes = in_array(FILTER_FLAG_NO_ENCODE_QUOTES, $flags);
-
 
27
        $options = ($noQuotes ? ENT_NOQUOTES : ENT_QUOTES) | ENT_SUBSTITUTE;
-
 
28
        $optionsDecode = ($noQuotes ? ENT_QUOTES : ENT_NOQUOTES) | ENT_SUBSTITUTE;
-
 
29
        
-
 
30
        // Strip the tags
-
 
31
        $value = strip_tags($value);
-
 
32
        
-
 
33
        $value = htmlspecialchars($value, $options);
-
 
34
        
-
 
35
        // Fix that HTML entities are converted to entity numbers instead of entity name (e.g. ' -> " and not ' -> &quote;)
-
 
36
        // https://stackoverflow.com/questions/64083440/use-php-htmlentities-to-convert-special-characters-to-their-entity-number-rather
-
 
37
        $value = str_replace([""", "'"], [""", "'"], $value);
-
 
38
        
-
 
39
        // Decode all entities
-
 
40
        $value = html_entity_decode($value, $optionsDecode);
-
 
41
        
-
 
42
        return trim($value);
-
 
43
        
7
abstract class Functions
44
    }
8
{
45
    
9
    public static function getUserIP()
46
    public static function getUserIP()
10
    {
47
    {
11
        $client  = isset($_SERVER['HTTP_CLIENT_IP'])  ? $_SERVER['HTTP_CLIENT_IP'] : '';
48
        $client  = isset($_SERVER['HTTP_CLIENT_IP'])  ? $_SERVER['HTTP_CLIENT_IP'] : '';