Merged upstream/master
This commit is contained in:
commit
3a3264ae0d
12
README.md
12
README.md
|
@ -28,3 +28,15 @@ as well as the [repository license](LICENSE).
|
|||
`<iframe src="https://tilde.team/~barrow/loop/frame.php?id=3" style="width: 100%; max-width: 400px;" />`
|
||||
|
||||
The ID number that you use in the src URL is the ID number you receive when you get approved.
|
||||
|
||||
### What if I don't want the widget?
|
||||
|
||||
If the widget doesn't fit your branding you can make your own and use the new link.php routing page.
|
||||
|
||||
Your previous link URL will be
|
||||
|
||||
`https://tilde.team/~barrow/loop/link.php?id=YOURID&go=p`
|
||||
|
||||
Your next link URL will be
|
||||
|
||||
`https://tilde.team/~barrow/loop/link.php?id=YOURID&go=n`
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
$id_key = "id";
|
||||
$go_key = "go";
|
||||
$id = 0;
|
||||
$go = "e";
|
||||
|
||||
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 {
|
||||
// ID is not valid
|
||||
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 "i01. ";
|
||||
exit();
|
||||
}
|
||||
// ID is too small
|
||||
if( $id < 0 ) {
|
||||
print "i03. ";
|
||||
exit();
|
||||
}
|
||||
|
||||
// Now get load the data
|
||||
require( 'ring.php' );
|
||||
|
||||
// ID is too large
|
||||
if( $id >= $ring_size ) {
|
||||
print "i04. ";
|
||||
exit();
|
||||
}
|
||||
|
||||
$last = $ring_size - 1;
|
||||
$index = array_keys( $web_ring );
|
||||
|
||||
/* =============================================================================== */
|
||||
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
header( "Location: $go_url" );
|
||||
|
||||
?>
|
Loading…
Reference in New Issue