$url = “https://monURL”; $orignal_parse = parse_url($url, PHP_URL_HOST); $get = stream_context_create(array(“ssl” => array(“capture_peer_cert” => TRUE))); $read = stream_socket_client(“ssl://”.$orignal_parse.”:443″, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get); $cert = stream_context_get_params($read); $certinfo = openssl_x509_parse($cert[‘options’][‘ssl’][‘peer_certificate’]); $nowLess7Days= date(DATE_RFC2822,strtotime(‘+ 7 day’)); $valid_to = date(DATE_RFC2822,$certinfo[‘validTo_time_t’]); echo “Now less 7 days :”.$nowLess7Days.”\r\n”; echo “Valid To :”.$valid_to.”\r\n”; if( $valid_to < $nowLess7Days) { echo ‘ALERT : certificat will be expired in less 7 days !!!!’; } else { echo ‘INFO : no Problem’; }
Tag: php
PHP : convertir date 2018-08-03T15:21:28+00:00 (exemple) pour insertion dans DB Mysql (datetime)PHP : convertir date 2018-08-03T15:21:28+00:00 (exemple) pour insertion dans DB Mysql (datetime)
// 2018-08-03T15:21:28+00:00$date = date_create_from_format(‘Y-m-d\TH:i:sT‘, ‘ 2018-08-03T15:21:28+00:00 ‘);echo date_format($date, ‘Y-m-d H:i:s‘); Le format mysql est bien Y-m-d H:i:s pour le type datetime /
PHP : Convertir un chaine (string) possédant des sauts de lignes en tableau (array)PHP : Convertir un chaine (string) possédant des sauts de lignes en tableau (array)

1er méthode si vous connaissez le caractére de séparation 2ème méthode si vous connaissez pas le caractére de séparation preg_match_all("/[\S ]+/", $monString, $match)print_r($match);
PHP FAILLE XSS ASTUCEPHP FAILLE XSS ASTUCE

Mettez cette fonction en début de code et cela devrait vous protéger un minimum // FILTERING VALUES FROM USER, PREVENTING XSS INJECTIONS if(!empty($_POST)) { function filter_xss(&$value) { if(is_array($value)) { array_walk_recursive($value,
PHP : fonction pour déterminer si un jour est un WEEKENDPHP : fonction pour déterminer si un jour est un WEEKEND
//Date in YYYY-MM-DD format.$dateToSet = '2020-02-08';//Output for testing purposes.if(isWeekend($dateToSet)){echo $dateToSet . ' it's a weekend.';} else{echo $dateToSet . ' it's on a weekday.';}function isWeekend($date){//Set this to FALSE until proven otherwise.$weekendDay
PHP : PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.))PHP : PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.))
PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/project/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.)) Vérifier que vous
PHP : WINDOWS Call to undefined function ldap_connect()PHP : WINDOWS Call to undefined function ldap_connect()

Bien vérifier la configuration de votre php.ini avec “extension=ldap” bien décommenté et la présence de la dll “php_ldap.dll” dans le répertoire ext PHP. Ensuite veiller à ce que PHP soit
PHP : Fonction pour CURL (avec authentification Bearer si besoin)PHP : Fonction pour CURL (avec authentification Bearer si besoin)

Curl php avec authentification Bearer au besoin function callAPI($method, $url, $data ,$sessionIdToPut ){ $curl = curl_init(); switch ($method){ case "POST": curl_setopt($curl, CURLOPT_POST, 1); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; case
PHP : Effacer des vieux fichiersPHP : Effacer des vieux fichiers
function deleteOldFile( $filename) { // in seconde ici 600 secondes soit 10 minute if (time()-filemtime($filename) > 600) { unlink($filename); } }
PHP : récupérer l’IP d’un utilisateurPHP : récupérer l’IP d’un utilisateur
function getIP() { if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; } $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if(filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif(filter_var($forward,