format("d/m/Y H:i:s");
} else {
return DateTime::createFromFormat("d/m/Y H:i:s", $_timestampMysql);
}
}
public static function dateFromTimestamp(int $_timestamp = NULL)
{
if ($_timestamp == NULL) {
return NULL;
} else {
return date("Y-m-d H:i:s", $_timestamp);
}
}
public static function formatFileSize(float $_size, int $_decimalplaces = 0)
{
$sizes = array('O', 'Ko', 'Mo', 'Go', 'To');
for ($i = 0; $_size > 1024 && $i < count($sizes) - 1; $i++) {
$_size /= 1024;
}
return round($_size, $_decimalplaces) . ' ' . $sizes[$i];
}
public static function checkStringOnly(string $_string)
{
if (!ctype_alpha($_string)) {
return TRUE;
} else {
return FALSE;
}
}
public static function print_r(array $_array, int $_exit = NULL)
{
echo "
";
print_r($_array);
echo "";
($_exit != NULL) ? exit() : NULL;
}
public static function elementMenu(string $_id, string $_href, string $_titre, string $_feather, string $_style = NULL)
{
($_style != NULL) ? $_style = ' style="' . $_style . '"' : NULL;
echo '
' . $_titre . '
';
}
public static function elementMenuLink(string $_href, string $_titre, string $_feather, string $_style = NULL, string $_target = "_blank")
{
($_style != NULL) ? $_style = ' style="' . $_style . '"' : NULL;
echo '
' . $_titre . '
';
}
public static function elementMenuH6(string $_titre, string $_style = NULL)
{
($_style != NULL) ? $_style = ' style="' . $_style . '"' : NULL;
echo '';
}
public static function filAriane(array $_arbo)
{
$return = '';
return $return;
}
public static function encodeUTF8(string $_data)
{
return (mb_detect_encoding($_data) != "UTF-8") ? mb_convert_encoding($_data, 'UTF-8', mb_list_encodings()) : $_data;
}
public static function testConnexionInternet()
{
$hosts = ['1.1.1.1', '1.0.0.1', '8.8.8.8', '8.8.4.4'];
foreach ($hosts as $host) {
if ($connected = @fsockopen($host, 443)) {
fclose($connected);
return TRUE;
}
}
return FALSE;
}
public static function printDateTxt()
{
$date = new IntlDateFormatter('fr_FR', IntlDateFormatter::LONG, IntlDateFormatter::NONE);
return $date->format(time()) . " à " . date("H:m:s");
}
public static function addFileMaintenance(){
$myfile = fopen(DOCUMENT_ROOT . FILE_MAINTENANCE, "w");
fclose($myfile);
}
public static function removeFileMaintenance(){
unlink(DOCUMENT_ROOT . FILE_MAINTENANCE);
}
public static function isMaintenance(){
return (file_exists(DOCUMENT_ROOT . FILE_MAINTENANCE)) ? TRUE : FALSE;
}
public static function addFileDebug(){
$myfile = fopen(DOCUMENT_ROOT . FILE_DEBUG, "w");
fclose($myfile);
}
public static function removeFileDebug(){
unlink(DOCUMENT_ROOT . FILE_DEBUG);
}
public static function isDebug(){
return (file_exists(DOCUMENT_ROOT . FILE_DEBUG)) ? TRUE : FALSE;
}
public static function checkboxSelecter(bool $_val){
echo ($_val == TRUE) ? "checked" : "";
}
}