if the user has entered a link can I use a service to tell this link is safe and trusted or notNo, you cannot. Your strategy is risky and dangerous. It should be avoided. Here's why.
<?php
$sensitivity = 95;
if(empty($_POST['url'])) {
?>
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Demo</title>
</head>
<body>
<h1>Hello</h1>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES, "utf-8"); ?>" method="post" target="f">
URL: <input type="text" name="url" />
<input type="submit" />
</form>
<div>
<iframe width="80%" height="200" name="f"></iframe>
</div>
</body>
</html>
<?php
}
else {
$site = $_POST['url'];
$urlinfo = parse_url($site);
if (!isset($urlinfo['host'])) $urlinfo = parse_url('http://' . $site);
$host = preg_replace('/[^a-z0-9\-\.]/i', '', $urlinfo['host']);
$siteReport = json_decode(file_get_contents('http://api.mywot.com/0.4/public_link_json2?hosts='. $host .'/&key=59e026a43597840e5ddefba4d692be8212926801'));
if( !empty($siteReport->{$host}->categories->{'501'}) && $siteReport->{$host}->categories->{'501'} > $sensitivity ) {
header('Location: ' . $urlinfo['scheme'] . '://' . $host . (empty($urlinfo['path']) ? '' : $urlinfo['path']) . (empty($urlinfo['query']) ? '' : '?' . $urlinfo['query']), TRUE, 307);
exit;
}
else {
echo 'Bad Site!';
}
}
?>