updates and new router( link.php )
This commit is contained in:
parent
8ba91010d8
commit
4cbdc3c185
|
@ -13,9 +13,11 @@
|
|||
<h1>hackers.town L00p</h1>
|
||||
<p>The return of the webring</p>
|
||||
<p><a class="title" href="https://git.hackers.town/c0debabe/web-l00p/issues/new">Add Your Website</a></p>
|
||||
<iframe src="https://l00p.hackers.town/frame.php?id=0" style="width: 100%; border: 0;" />
|
||||
<iframe src="https://l00p.hackers.town/frame.php?id=0" style="width: 100%; border: 0;"></iframe>
|
||||
</div>
|
||||
|
||||
<p><a href="link.php" style="color: black;">dev link</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
$id_key = "id";
|
||||
$go_key = "go";
|
||||
$id = 0;
|
||||
$go = "e";
|
||||
|
||||
if( isset( $_GET ) && !empty( $_GET ) ) {
|
||||
$a_keys = array_keys( $_GET );
|
||||
|
@ -9,17 +11,29 @@ if( isset( $_GET ) && !empty( $_GET ) ) {
|
|||
$id = $_GET[$id_key] * 1;
|
||||
} else {
|
||||
// ID is not valid
|
||||
print "e02";
|
||||
print "i02. ";
|
||||
exit();
|
||||
}
|
||||
if( in_array( $go_key, $a_keys ) && isset($_GET[$go_key]) ) {
|
||||
// first character of what should be a string
|
||||
$go = $_GET[$go_key][0];
|
||||
if( $go != "n" && $go != "p" && $go != "r" ) {
|
||||
print "g02. ";
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
// ID is not valid
|
||||
print "g01. ";
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
// ID is not valid
|
||||
print "e01";
|
||||
print "i01. ";
|
||||
exit();
|
||||
}
|
||||
// ID is too small
|
||||
if( $id < 0 ) {
|
||||
print "e03";
|
||||
print "i03. ";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -28,46 +42,39 @@ require( 'ring.php' );
|
|||
|
||||
// ID is too large
|
||||
if( $id >= $ring_size ) {
|
||||
print "e04";
|
||||
print "i04. ";
|
||||
exit();
|
||||
}
|
||||
|
||||
$last = $ring_size - 1;
|
||||
$index = array_keys( $web_ring );
|
||||
|
||||
$expected_domain = $web_ring[ $index[$id] ];
|
||||
$frame_parent = $_SERVER['HTTP_REFERER']."";
|
||||
/* =============================================================================== */
|
||||
|
||||
if( $expected_domain != $frame_parent ) {
|
||||
$position = strpos( $frame_parent, $expected_domain );
|
||||
if( $position != 0 ) {
|
||||
print "e05";
|
||||
exit();
|
||||
$go_url = "";
|
||||
|
||||
if( $go == "r") {
|
||||
$go_url = $web_ring[$index[rand(0,$last)]];
|
||||
} else {
|
||||
$prev = "";
|
||||
$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];
|
||||
}
|
||||
if( $go == "p" ) {
|
||||
$go_url = $web_ring[$prev];
|
||||
} else if( $go == "n" ) {
|
||||
$go_url = $web_ring[$next];
|
||||
}
|
||||
}
|
||||
|
||||
// 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]
|
||||
header( "Location: $go_url" );
|
||||
|
||||
?>
|
Loading…
Reference in New Issue