yourdomain.com/go-fuck-yourself.html will become go-fuck-yourself.jpg.
<?php
$myPage = explode('.',strtolower($_SERVER[REQUEST_URI]));
$myImage = trim(preg_replace("/[^a-zA-Z0-9\-]+/", "", $myPage[0]));
$myImage = $myImage . '.jpg';
// can also be: $myImage = 'files/images/' . $myImage . '.jpg';
// or whatever folder or image file format you want...
if (@getimagesize($myImage)) {
echo "<img src='$myImage'>";
} else {
// file doesn't exist, show placeholder
echo "<img src='files/images/placeholder.jpg'>";
}
die();
?>
I got a feeling there's even a faster way, but just like you, I'm too lazy to dive into the PHP docs as well.
