loop/frame.php

79 lines
2.3 KiB
PHP

<?php
// Security: don't allow gets or posts for this app to exceed N in size because we just want a number less than 1000, you know??
// todo: .htaccess -- add LimitRequestLine directive
$id_key = "id";
$id = 0;
if( isset( $_GET ) && !empty( $_GET ) ) {
$a_keys = array_keys( $_GET );
if( in_array( $id_key, $a_keys ) && isset($_GET[$id_key]) ) {
$id = $_GET[$id_key] * 1;
} else {
print "e02";
exit();
}
} else {
print "e01";
exit();
}
// Now get load the data
require( 'ring.php' );
$prev = "";
$rand = "";
$next = "";
$last = $ring_size - 1;
$index = array_keys( $web_ring );
if( $id == $last ) { // are we at the end?
$next = $index[0]; // first one
$prev = $index[$id-1]; // previous one
} else if( $id == 0 ) { // are we at the beginning?
$next = $index[$id+1]; // next one
$prev = $index[$last]; // last one
} else { // somewhere in the middle
$next = $index[$id+1];
$prev = $index[$id-1];
}
$rand = $index[rand(0,$last)];
$rand_url = $web_ring[$rand];
$prev_url = $web_ring[$prev];
$next_url = $web_ring[$next]
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>Hackers Town Web Ring</title>
<style>
body { font-size: 1.5em; font-family: monospace; background-color: black; color: lime; text-align: center; }
h1 { font-size: 1.5em; }
ul { margin: 0; padding: 0; list-style-type: none; }
li { display: inline-block; margin: 0 .5em; padding: .5em; }
li a:active, li a:hover { color: lime; }
li a:link { color: aqua; }
li a:visited { color: white; }
h1 a:link, h1 a:visited, h1 a:active, h1 a:hover { color: lime; }
</style>
</head>
<body>
<div>
<h1><a href="https://alicerhodes.com/web-l00p/test.html" target="_parent" title="Webring Home Page">hackers town webring</a></h1> <!-- this should link to web ring home page -->
<ul>
<li><a href="<?php print $prev_url; ?>" target="_parent" title="Previous Website">&lt;&lt; Prev</a></li>
<li><a href="<?php print $rand_url; ?>" target="_parent" title="Random Website">Rand</a></li>
<li><a href="<?php print $next_url; ?>" target="_parent" title="Next Website">Next &gt;&gt;</a></li>
</ul>
</div>
</body>
</html>