fapfapfap.phps

<?
//
// fapfapfap.php - not much of explaination needed, it displays images
// Erik Andersson (2007) - http://packy.se/
// [email protected]
//
$dir = "/home/hellfairy/www-imageboard/gallery/mmm/";
$thumbdir = "/home/hellfairy/www-imageboard/.mmm/"; // this needs to be writable
$webdir = "/gallery/mmm/";
$thumbs = array(
  'height' => '450',
  'width' => '450',
  'quality' => '60');
$faps = array(
    '15',
    '30',
    '45',
    '60',
    '90');

if(isset($_GET['fap'])) {
    if(in_array($_GET['fap'],$faps)) {
        $fap = $_GET['fap'];
    }
}
  
function timer_start()
{
   global $starttime;
   $m_time = explode(" ",microtime());
   $m_time = $m_time[0] + $m_time[1];
   $starttime = $m_time;
   return;
}

function timer_end()
{
   global $starttime;
   $round = 3;// The number of decimal places to round the micro time to.
   $m_time = explode(" ",microtime());
   $m_time = $m_time[0] + $m_time[1];
   $endtime = $m_time;
   $totaltime = ($endtime - $starttime);
   return "Time to generate page: ". round($totaltime,$round) ." seconds";
}
timer_start();
?>
<html>
<head>
<title>*fapfapfap*</title>
<style>
a {
    text-decoration: none;
    color: #dd0000;
}
p {
    font-family: sans-serif,verdana;
}
img {
    border: none;
}
body {
    background-color: #eaeaea;
    font-family: sans-serif,verdana;
    font-size: 80%;
}
</style>
<?
if($fap)
{
    ?>
<script language="JavaScript"><!--
if(document.images)
 setTimeout('location.reload(true)',1000*<?=$fap?>);
else
 setTimeout('location.ref = location.href',1000*<?=$fap?>);
//--></script>
    <?
}
?>
</head>
<body>
<div style="text-align: center">
<?
$files = scandir($dir);
unset($files[0],$files[1]);
$pic = $files[array_rand($files, 1)];
if(!is_readable($thumbdir.$pic)) {
    $gen = "Generating resized version, hang on...<br>";
    exec('convert -size '.$thumbs['width'].'x'.$thumbs['height'].' -geometry '.$thumbs['width'].'x'.$thumbs['height'].' -quality '.$thumbs['quality'].' "'.$dir.$pic.'" "'.$thumbdir.$pic.'"');
}
echo "<p>Now viewing: <b><a style=\"text-decoration: none; color: #000000\" href=\"".$webdir.rawurlencode($pic)."\" target=\"_NEW\">$pic</a></b><br>$gen</p><p><a href=\"javascript:window.location.reload()\"><img src=\"/.mmm/".rawurlencode($pic)."\"></a></p>";

echo "Fap-modes: ";
foreach($faps as $key) {
    if($key === $fap) {
        echo "<b>$key</b> | ";
    } else {
        echo "<a href=\"/fapfapfap.php?fap=$key\">$key</a> | ";
    }
}
if($fap) {
    echo "<a href=\"/fapfapfap.php\">Off</a><br>";
} else {
    echo "Off<br>";
}

echo timer_end();
?>
</div>
</body>
</html>