Created
August 4, 2012 20:56
-
-
Save AmusableLemur/3259874 to your computer and use it in GitHub Desktop.
Simple clone of StumbleUpon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# javascript:window.location = "<LINK TO FILE>?u="+encodeURIComponent(window.location); | |
require 'rb.php'; | |
function linkExists($url) { | |
$links = R::findAll('link', '1'); | |
foreach ($links as $link) { | |
if ($link->url == $url) { | |
return true; | |
} | |
} | |
return false; | |
} | |
R::setup('sqlite:db.txt'); | |
if (isset($_GET['u']) && !linkExists($_GET['u']) && @fopen($_GET['u'], 'r')) { | |
$link = R::dispense('link'); | |
$link->url = urldecode($_GET['u']); | |
R::store($link); | |
echo "Link submitted successfully"; | |
} else { | |
$links = R::$f->begin()->select('id')->from('link')->get('col'); | |
$link = R::load('link', array_rand($links)); | |
header('Location: ' . $link->url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment