[ "capture_peer_cert" => true, "verify_peer" => false, "verify_peer_name" => false, ], ]); $client = @stream_socket_client( "ssl://{$domain}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context ); if (!$client) { return [ 'has_ssl' => false, 'expiry' => null, ]; } $params = stream_context_get_params($client); $cert = openssl_x509_parse($params['options']['ssl']['peer_certificate']); return [ 'has_ssl' => true, 'expiry' => date('Y-m-d H:i:s', $cert['validTo_time_t']), ]; } public static function get_domain_whois() { $domainWhois = get_transient('admintosh_domain_whois_info'); $dateTimeFormat = get_option( 'date_format' ); if( empty( $domainWhois ) ) { $settings = get_option( ADMINTOSH_OPTION_NAME ); $api_key = $settings['domain_monitoring_api_key'] ?? ''; if( !empty( $api_key ) ) { $domain = site_url('/'); $url = "https://api.ip2whois.com/v2?key=$api_key&domain=$domain"; $response = wp_remote_get($url); if (is_wp_error($response)) return false; $data = json_decode(wp_remote_retrieve_body($response), true); set_transient( 'admintosh_domain_whois_info', $data, 12 * HOUR_IN_SECONDS ); $domainWhois = get_transient('admintosh_domain_whois_info'); } } return [ 'created' => !empty( $domainWhois['create_date'] ) ? wp_date( $dateTimeFormat, strtotime( $domainWhois['create_date'] ) ) : '', 'updated' => !empty( $domainWhois['update_date'] ) ? wp_date( $dateTimeFormat, strtotime( $domainWhois['update_date'] ) ) : '', 'expires' => !empty( $domainWhois['expire_date'] ) ? wp_date( $dateTimeFormat, strtotime( $domainWhois['expire_date'] ) ) : '', ]; } }