<?
$words = explode(" ", $message);
foreach ($words as $key => $word)
{
if (filter_var($word, FILTER_VALIDATE_URL) !== false) // Is valid url
{
if (stripos($word, "google") === false && stripos($word, "youtu") === false) // Google & YouTube sometimes redirect so we don't want it looking for them
{
$headers = get_headers($word, true);
$url = "";
while (array_key_exists('Location', $headers)) // While loop in case they're using shortened links within shortened links. Should work for inf layers of them.
{
if (filter_var($headers['Location'], FILTER_VALIDATE_URL) !== false) // If redirect is valid
{
$url = htmlspecialchars($headers['Location']);
$words[$key] = "[Link Shorten Attempt]: {$url}";
}
else if (is_array($headers['Location'])) // If redirect is an array of multiple locations just grab the first
{
$url = htmlspecialchars($headers['Location'][0]);
$words[$key] = "[Link Shorten Attempt]: {$url}";
}
else
{
$words[$key] = "FAULTY SHORTENED LINK REMOVED";
continue;
}
$headers = get_headers($url, true);
}
}
}
}
$message = implode(" ", $words);
?>
Copyright © 2024, NextGenUpdate.
All Rights Reserved.