81 lines
3.4 KiB
PHP
81 lines
3.4 KiB
PHP
<?php
|
|
$request_uri = $_SERVER['REQUEST_URI'];
|
|
$filtered_request = strtok(substr($request_uri, 1), '?');
|
|
$pic_array = glob($filtered_request . 'index/*.jpg');
|
|
if (isset($_GET['id'])) {
|
|
$index = $_GET['id'] - 1;
|
|
} else {
|
|
$index = array_rand($pic_array);
|
|
}
|
|
$pic_href = '/' . $pic_array[$index];
|
|
$sum = count($pic_array);
|
|
$leadingzeros = 3;
|
|
$format_index = str_pad($index + 1, $leadingzeros, '0', STR_PAD_LEFT);
|
|
$format_sum = str_pad($sum, $leadingzeros, '0', STR_PAD_LEFT);
|
|
$comment_file = $filtered_request . "comments/" . $format_index . ".txt";
|
|
$sensitive_file = $filtered_request . "sensitive.txt";
|
|
$sensitive_mode = false;
|
|
if (file_exists($sensitive_file)) {
|
|
foreach (file($sensitive_file) as $lineNumber => $line) {
|
|
if (strpos($line, $format_index) !== false) {
|
|
$sensitive_mode = true;
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf8" />
|
|
<title>mctaylors' toaster - <?php echo $request_uri ?></title>
|
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
<link rel="stylesheet" href="/style.css" />
|
|
<meta name="viewport" content="initial-scale=0.75 user-scalable=no" />
|
|
|
|
<meta property="og:site_name" content="mctaylors' toaster" />
|
|
<meta property="og:title" content="<?php echo $request_uri ?>" />
|
|
<meta property="og:image" content="/favicon.png" />
|
|
<meta property="og:description" content="serving <?php echo $sum ?> images" />
|
|
|
|
<script type="text/javascript" src="/cookie.js"></script>
|
|
<script type="text/javascript" src="/main.js"></script>
|
|
<script type="text/javascript">
|
|
window.onload = function() { <?php echo $sensitive_mode ? "onLoadSensitive();" : "statusNonSensitive();" ?> }
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a href=".."><-</a> <?php echo "/" . $filtered_request ?>
|
|
<span style="float: right; text-align: right">mctaylors' toaster<br />
|
|
<a href="https://mctaylors.ru">mctaylors.ru</a><br />
|
|
<br />
|
|
<span class="interactable" onClick="<?php echo $sensitive_mode ? "toggleSensitive()" : "toggleNonSensitive()" ?>" id="statusSensitive">...</span> enable sensitive content</span>
|
|
<img alt="<?php echo "toast #" . $format_index ?>"
|
|
<?php
|
|
echo 'src="' . $pic_href . '"';
|
|
if ($sensitive_mode) {
|
|
echo 'class="censored" id="censored"';
|
|
}?> />
|
|
<?php if (file_exists($comment_file)) {
|
|
echo '<span class="comment">' . file_get_contents($comment_file) . '</span>';
|
|
}?>
|
|
<?php if ($sensitive_mode) {
|
|
echo '<div class="warning" id="warning"><b>sensitive content warning</b><noscript> - <a href="<?php echo $pic_href ?>">view original</a></noscript>
|
|
<span id="warningSeparator"> - </span>
|
|
<span style="display: none" id="showSensitive" class="interactable" onClick="showSensitive()">show [Backspace]</span>
|
|
<span style="display: none" id="hideSensitive" class="interactable" onClick="hideSensitive()">hide [Backspace]</span>
|
|
</div>';
|
|
} ?>
|
|
<div class="footer">
|
|
<?php
|
|
if ($index > 0) {
|
|
echo '<a href="?id=' . $index . '"><-</a>';
|
|
}
|
|
echo ' <b>' . $format_index . '/' . $format_sum . '</b> ';
|
|
if ($index < $sum - 1) {
|
|
echo '<a href="?id=' . ($index + 2) . '">-></a>';
|
|
}
|
|
?>
|
|
<br /><a href="<?php echo $pic_href ?>">view original</a> - <a href=".">refresh [F5]</a>
|
|
- <a href="mailto:contact@mctaylors.ru?subject=[mctaylors' toaster] Contribution">contribute</a> - <a href="index">open index</a><br /></div>
|
|
</body>
|
|
</html>
|