mphp
New member
Sorry bit of a noob. I have this code that does something for me when it finds a website that is on the list under $allowed_domains
Once the code finds a listed site I just need code to echo which site it found (echo it or save it to a variable)
How can I add the echo of the found website?
Once the code finds a listed site I just need code to echo which site it found (echo it or save it to a variable)
How can I add the echo of the found website?
Code:
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = '';
}
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
} else {
$uri = '';
}
$allowed_domains = [
'site1.com',
'cool.com',
'exmaple.com',
// Add more domains here as needed
];
// Function to check if uri contains any
function checkUri($uri, $domains) {
if (empty($uri)) {
return false;
}
foreach ($domains as $domain) {
if (strpos($uri, $domain) !== false) {
return true;
}
}
return false;
}
if (checkUri($uri, $allowed_domains)) {
// DO SOMETHING HERE IF FOUND
// echo "Need to echo which domain was found";
} else {
echo "not found";
}
?>