91 lines
2.4 KiB
PHP
91 lines
2.4 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;
|
|
$url = "";
|
|
|
|
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;
|
|
$url = $_GET["url"];
|
|
} else {
|
|
// ID is not valid
|
|
print "e02";
|
|
exit();
|
|
}
|
|
} else {
|
|
// ID is not valid
|
|
print "e01";
|
|
exit();
|
|
}
|
|
// ID is too small
|
|
if( $id < 0 ) {
|
|
print "e03";
|
|
exit();
|
|
}
|
|
|
|
// Now get load the data
|
|
require( 'ring.php' );
|
|
|
|
// ID is too large
|
|
if( $id >= $ring_size ) {
|
|
print "e04";
|
|
exit();
|
|
}
|
|
|
|
$last = $ring_size - 1;
|
|
$index = array_keys( $web_ring );
|
|
|
|
// Onward
|
|
|
|
$prev = "";
|
|
$rand = "";
|
|
$next = "";
|
|
|
|
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)];
|
|
|
|
$home_url = $web_ring[$index[0]];
|
|
$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>Tildeverse Web Ring Broken Page</title>
|
|
<link rel="stylesheet" href="style.css" />
|
|
</head>
|
|
<body id="frame">
|
|
<div id="page">
|
|
<a class="title" title="Webring Home Page">Whoops!</a>
|
|
<p><a href="<?php print $url;?>"><?php print $url;?></a> is supposed to be here.</p>
|
|
<p>This page is temporarily offline, disabled, or otherwise removed.</p>
|
|
<p>You can try the link above for a live version of the page.</p>
|
|
<p>Feel free to continue along!</p>
|
|
<ul>
|
|
<li id="prev"><a href="<?php print $prev_url; ?>" target="_top" title="Previous Website"><< Prev</a></li>
|
|
<li id="rand"><a href="<?php print $rand_url; ?>" target="_top" title="Random Website">Rand</a></li>
|
|
<li id="next"><a href="<?php print $next_url; ?>" target="_top" title="Next Website">Next >></a></li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|