<?php
if (!isset($_SESSION)) {
    session_start();
}
ob_start();

function check_url(string $url, string $haystack) {

    $input = trim($url, '/');

    if (!preg_match('#^http(s)?://#', $input)) {
        $input = 'http://' . $input;
    }

    $urlParts = parse_url($input);
    $domain_name = preg_replace('/^www\./', '', $urlParts['host']);
    $needle = mb_strtolower($domain_name);
    $pos = strripos($haystack, $needle);
    return $pos;
}