<?php
    $imgurl = IMAGESERVE_DIR . "/images/$type/$file.$type";
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
    $stylesheetDir = IMAGESERVE_DIR . "/assets/css/style.css";
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title><?php echo APP_NAME . " - $file.$type"; ?></title>
        <link rel="stylesheet" href="<?php echo $stylesheetDir; ?>">
<?php if (TWITTER_CARDS) { ?>
        <meta name="twitter:card" content="photo" />
        <meta name="twitter:site" content="<?php echo TWITTER_HANDLE; ?>" />
        <meta name="twitter:title" content="<?php echo $file . '.' . $type; ?>" />
        <meta name="twitter:image" content="<?php echo $protocol; ?>://<?php echo $_SERVER['SERVER_NAME'] . $imgurl; ?>" />
        <meta name="twitter:url" content="<?php echo $protocol; ?>://<?php echo $_SERVER['SERVER_NAME'] . htmlspecialchars($_SERVER['REQUEST_URI']); ?>" />
<?php } ?>
    </head>

    <body>
        <h1>
            <?php echo "$file.$type"; ?> &middot;

            <abbr title="Value rounded to the nearest kb.">
                ~<?php echo round($filesize / 1024, 0); ?>kb
            </abbr>
        </h1>

        <div class="container">
            <?php if ($type != "webm"): ?>
            <a href="<?php echo $imgurl; ?>">
                <img src="<?php echo $imgurl; ?>" alt="<?php echo "$file.$type"; ?>">
            </a>
            <?php else: ?>
            <video width="1280" height="720" controls>
                <source src="<?php echo $imgurl; ?>" type="video/webm">
            </video>
            <?php endif; ?>
        </div>

        <?php
            $time = microtime();
            $time = explode(' ', $time);
            $time = $time[1] + $time[0];
            $finish = $time;
            $total_time = round(($finish - $start), 4);
        ?>

        <p>
            <a href="https://github.com/aerouk/imageserve">
                Powered by <b>imageserve</b>
            </a>

            &middot; Page generated in <?php echo $total_time; ?> seconds
        </p>
    </body>
</html>
