# final class \SmartUtils
{ } ::

Class: SmartUtils - provides various utility functions for Smart.Framework

- Language: PHP
- Located at: lib/core/lib_utils.php
- Package: Application:Utils
- Namespace: \
- Class Name: SmartUtils
- Version: v.20241108
- Depends: classes: Smart, SmartUnicode, SmartValidator, SmartHashCrypto, SmartAuth, SmartFileSysUtils, SmartFileSystem, SmartFrameworkSecurity, SmartFrameworkRegistry, SmartValidator, SmartParser ; optional-constants: SMART_FRAMEWORK_SECURITY_CRYPTO, SMART_FRAMEWORK_COOKIES_DEFAULT_LIFETIME, SMART_FRAMEWORK_COOKIES_DEFAULT_DOMAIN, SMART_FRAMEWORK_COOKIES_DEFAULT_SAMESITE, SMART_FRAMEWORK_SRVPROXY_ENABLED, SMART_FRAMEWORK_SRVPROXY_CLIENT_IP, SMART_FRAMEWORK_SRVPROXY_CLIENT_PROXY_IP, SMART_FRAMEWORK_SRVPROXY_SERVER_PROTO, SMART_FRAMEWORK_SRVPROXY_SERVER_IP, SMART_FRAMEWORK_SRVPROXY_SERVER_DOMAIN, SMART_FRAMEWORK_SRVPROXY_SERVER_PORT, SMART_FRAMEWORK_ALLOW_UPLOAD_EXTENSIONS, SMART_FRAMEWORK_DENY_UPLOAD_EXTENSIONS, SMART_FRAMEWORK_IDENT_ROBOTS
- Usage: static object: Class::method() - This class provides only STATIC methods

## class Methods

public static function get_app_release_hash ( ) {} :: STRING
public static function cookies_current_size_used_on_domain ( ) {} :: INT
public static function cookie_size_max ( ) {} :: INT
public static function cookie_default_expire ( ) {} :: INT
public static function cookie_default_domain ( ) {} :: STRING
public static function cookie_default_samesite_policy ( ) {} :: STRING
public static function get_cookie ( string $cookie_name ) {} :: ?STRING
public static function isset_cookie ( string $cookie_name ) {} :: BOOL
public static function set_cookie ( string $cookie_name, string $cookie_data, int $expire_seconds = 0, string $cookie_path = "/", string $cookie_domain = "@", string $cookie_samesite = "@", bool $cookie_secure = false, bool $cookie_httponly = false ) {} :: BOOL
public static function unset_cookie ( string $cookie_name, string $cookie_path = "/", string $cookie_domain = "@", string $cookie_samesite = "@", bool $cookie_secure = false, bool $cookie_httponly = false ) {} :: BOOL
public static function url_obfs_encode ( string $y_val ) {} :: STRING
public static function url_obfs_decode ( string $y_enc_val ) {} :: STRING
public static function date_interval_days ( string $y_date_now, string $y_date_past ) {} :: INT
public static function datetime_fixed_offset ( string $y_timezone_offset, string $ydate ) {} :: STRING
public static function data_archive ( string $y_str ) {} :: STRING
public static function data_unarchive ( string $y_enc_data ) {} :: STRING
public static function pretty_print_var ( $y_var, int $indent = 0, bool $jsstyle = false ) {} :: STRING
public static function pretty_print_bytes ( int $y_bytes, int $y_decimals = 1, string $y_separator = " ", int $y_base = 1000 ) {} :: STRING
public static function number_to_roman ( int $num ) {} :: STRING
public static function roman_to_number ( string $roman ) {} :: INT
public static function extract_title ( string $ytxt, int $y_limit = 65, bool $clear_numbers = false ) {} :: STRING
public static function extract_description ( string $ytxt, int $y_limit = 155, bool $clear_numbers = false ) {} :: STRING
public static function extract_keywords ( string $ytxt, int $y_count = 97, bool $clear_numbers = true ) {} :: STRING
public static function extract_words_from_text_html ( string $ytxt ) {} :: ARRAY
public static function cleanup_extra_spaces_from_text ( string $ytxt ) {} :: STRING
public static function cleanup_numbers_from_text ( string $ytxt ) {} :: STRING
public static function read_uploaded_file ( string $var_name, int $var_index = -1, int $max_size = 0, string $allowed_extensions = "" ) {} :: ARRAY
@return: {ARRAY} array [ status => 'OK' | 'WARN' | 'ERR', 'message' => '' | 'WARN Message' | 'ERR Message', 'msg-code' => 0..n, 'filename' => '' | 'filename.ext', 'filetype' => '' | 'ext', 'filesize' => Bytes, 'filecontent' => '' | 'the Contents of the file ...' ]
@param: {STRING} $var_name: The HTML Variable Name
@param: {INTEGER} $var_index: The HTML Variable Index: -1 for single file uploads ; 0..n for multi-file uploads ; DEFAULT is -1
@param: {INTEGER} $max_size: The max file size in bytes that would be accepted ; set to zero for allow maximum size supported by PHP via INI settings ; DEFAULT is zero
@param: {STRING} $allowed_extensions: The list of allowed file extensions ; Default is '' ; Example to restrict to several extensions: '<ext1>,<ext2>,...<ext100>,...' ; set to empty string to allow all extenstions supported via Smart.Framework INI: SMART_FRAMEWORK_ALLOW_UPLOAD_EXTENSIONS / SMART_FRAMEWORK_DENY_UPLOAD_EXTENSIONS
Reads and return one Uploaded File
public static function store_uploaded_file ( string $dest_dir, string $var_name, int $var_index = -1, bool $allow_rewrite = true, int $max_size = 0, string $allowed_extensions = "", string $new_name = "", bool $enforce_lowercase = false ) {} :: MIXED
@return: {MIXED} '' (empty string) if all OK ; FALSE (boolean) if upload failed ; otherwise will return a non-empty string with the ERROR / WARNING message if the file was not successfuly stored in the destination directory
@param: {STRING} $dest_dir: The destination directory ; Example: 'wpub/my-test/'
@param: {STRING} $var_name: The HTML Variable Name
@param: {INTEGER} $var_index: The HTML Variable Index: -1 for single file uploads ; 0..n for multi-file uploads
@param: {BOOLEAN} $allow_rewrite: Allow rewrite if already exists that file in the destination directory ; default is TRUE
@param: {INTEGER} $max_size: The max file size in bytes that would be accepted ; set to zero for allow maximum size supported by PHP via INI settings
@param: {STRING} $allowed_extensions: The list of allowed file extensions ; Default is '' ; Example to restrict to several extensions: '<ext1>,<ext2>,...<ext100>,...' ; set to empty string to allow all extenstions supported via Smart.Framework INI: SMART_FRAMEWORK_ALLOW_UPLOAD_EXTENSIONS / SMART_FRAMEWORK_DENY_UPLOAD_EXTENSIONS
@param: {STRING} $new_name: Use a new file name for the uploaded file instead of the original one ; Set to empty string to preserve the uploaded file name ; DEFAULT is ''
@param: {BOOLEAN} $enforce_lowercase: Set to TRUE to enforce lowercase file name ; DEFAULT is FALSE
Store one Uploaded File to a destination directory
public static function client_ident_private_key ( ) {} :: STRING
public static function unique_client_private_key ( ) {} :: STRING
public static function unique_auth_client_private_key ( ) {} :: STRING
public static function get_selfrobot_useragent_name ( ) {} :: STRING
public static function get_visitor_useragent ( ) {} :: STRING
public static function get_visitor_signature ( ) {} :: STRING
public static function get_visitor_tracking_uid ( ) {} :: STRING
public static function get_encoding_charset ( ) {} :: STRING
public static function get_server_current_request_with ( ) {} :: STRING
public static function is_ajax_request ( ) {} :: BOOL
public static function get_server_current_request_method ( ) {} :: STRING
public static function get_server_current_protocol ( ) {} :: STRING
public static function get_server_current_port ( ) {} :: STRING
public static function get_server_current_ip ( ) {} :: STRING
public static function get_server_current_domain_name ( ) {} :: STRING
public static function get_server_current_basedomain_name ( ) {} :: STRING
public static function get_server_current_subdomain_name ( ) {} :: STRING
public static function get_server_current_request_path ( ) {} :: STRING
public static function get_server_current_request_uri ( ) {} :: STRING
public static function get_server_current_request_referer ( ) {} :: STRING
public static function get_server_current_full_script ( ) {} :: STRING
public static function get_server_current_script ( ) {} :: STRING
public static function get_server_current_queryurl ( bool $use_blank_if_empty = false ) {} :: STRING
public static function get_server_current_path ( ) {} :: STRING
public static function get_server_current_url ( bool $skip_port_if_default = true ) {} :: STRING
public static function get_webserver_version ( ) {} :: ARRAY
public static function get_server_os ( ) {} :: STRING
public static function is_ip_client_trusted ( ) {} :: BOOL
@return: {BOOLEAN} TRUE if trusted ; FALSE if not
Check if the Client real IP is trusted
If something fails in the detection of the Client real IP address this will return FALSE
public static function get_ip_client ( ) {} :: STRING
@return: {STRING} IP Address ; if no address detected will RAISE a FATAL ERROR ...
Get the Client real IP ; by default will use $_SERVER['REMOTE_ADDR'] ; but if set in configs can use by example $_SERVER['HTTP_X_FORWARDED_FOR'] or other values (ex: in the case of a reverse proxy)
This function should be used always across the Smart.Framework to get the client's real IP instead using directly the $_SERVER['REMOTE_ADDR'] as the real client IP may change when using apache/php behind haproxy or varnish and in this case by example the $_SERVER['HTTP_X_FORWARDED_FOR'] may return client's real IP address and the $_SERVER['REMOTE_ADDR'] will be in this case the IP of the proxy ...
This can be override if proxy mode enabled, by setting SMART_FRAMEWORK_SRVPROXY_CLIENT_IP
public static function get_ip_proxyclient ( ) {} :: STRING
@return: {STRING} IP Address or a space (if no proxy address detected)
Get the Client Proxy IP if any such as: HTTP_CLIENT_IP or HTTP_X_FORWARDED_FOR
This function should be used always across the Smart.Framework to get the client's proxy IP and never must use directly HTTP_CLIENT_IP or HTTP_X_FORWARDED_FOR or other headers directly as they may change when using apache/php behind haproxy or varnish !
public static function get_os_browser_ip ( string $y_mode = "" ) {} ::

## class Properties

## class Constants

public const GENERIC_VALUE_OS_BROWSER_IP = "[?]" ; ::

documentation generated on: 2024-12-16 16:53:45 +0000

Smart.Framework © 2009-2024 unix-world.org