This is a url hider/cloaker/redirect..whatever you want to call it
you can see it in action at http://url.omfgesad.com this is a very simple concept, i just didn't want something that uses base encoding...and i like using databases.
just use the installer and please don't edit my code :)
to use the administrator feature just go to
http://domain.com/?pass=password
and you'll see a delete link for each url.
go through the installer..its 2 steps..have fun :D
comments suggestions appreciated :D
###################################################################
###################################################################
The actual script...name it whatever you want
###################################################################
###################################################################
<?php
if (is_file("install.php")) {
header("Location: install.php");
} else {
if (is_file("config.php")) {
include('config.php');
$conn = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_touse,$conn) or die(mysql_error());
$site = $_SERVER['HTTP_HOST'];
$this_file = $_SERVER['SCRIPT_NAME'];
function banwords($text)
{
$badword = array("nimp", "lemonparty", "tubgirl",
"meatspin", "myspace",
"facebook");
$rep = array("qwerty", "qwerty", "O_O",
"spinningmeat", "facebook",
"myspace");
$newtext = str_replace($badword, $rep, $text);
return $newtext;
}
if (!$_GET[u]) {
if ($_POST[url1]) {
function create_ran_url($length) {
$possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890=-";
$string = "";
while(strlen($string)<$length) {
$string .= substr($possible_charactors, rand()%(strlen($possible_charactors)),1);
}
return($string);
}
$ranurl = create_ran_url (24);
$uslstg1 = strip_tags($_POST[url1]);
$uslstg1 = banwords($uslstg1);
if (strlen($uslstg1) > 8) {
$addurltodb = "INSERT INTO urlbase VALUES ('', '$ranurl', '$uslstg1')";
mysql_query($addurltodb,$conn);
echo "Added!<br />" . $uslstg1 . "<br /><a href='?u=" . $ranurl . "'>Link</a>";
} else { echo "Invalid Link"; }
} else {
echo "<form method='post'><input type='text' name='url1' value='http://' /><input type='submit' value='Add' /></form><br />";
$getlist = mysql_query("SELECT * FROM urlbase ORDER BY id");
while($row = mysql_fetch_array($getlist))
{
$encodedlink = $row['ranhash'];
$actuallink = $row['url'];
$urlid = $row['id'];
if ($_GET[pass] == $pw) {
$show_list .= "<a href='?u=$encodedlink'>$actuallink</a> - http://" . $site . $this_file . "/?u=$encodedlink - <a href='?id=$urlid&p=$pw'>Delete</a><br />";
} else {
$show_list .= "<a href='?u=$encodedlink'>$actuallink</a> - http://" . $site . $this_file . "/?u=$encodedlink<br />";
}
}
echo "<br /><br />Links in the database:<br />" . $show_list;
}
} else {
$get_link = "SELECT url FROM urlbase WHERE ranhash='$_GET[u]'";
$get_link_res = mysql_query($get_link);
// $link = stripslashes(mysql_result($get_link_res,0,'url')); //if you prefer to use this, comment lines 60-63
while($row = mysql_fetch_array($get_link_res))
{
$link = $row['url'];
}
if (strlen($link) > 8) {
header("Location: $link");
} else {
echo "Invalid Link";
}
}
if (($_GET[p] == $pw) && ($_GET[id])) {
mysql_query("DELETE FROM urlbase WHERE id='$_GET[id]'");
echo "<meta http-equiv="refresh" content="0;url=http://$site$this_file?pass=$pw">";
}
mysql_close($conn);
} else { echo "There is a problem, make sure 'config.php' is in the same directory as this file or try reinstalling using 'install.php'"; }
}
?>
###################################################################
###################################################################
INSTALLER...MUST be named install.php and put in the same directory as the url script.
###################################################################
###################################################################
<?php
if (is_file("config.php")) {
include('config.php');
$conn = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_touse,$conn) or die(mysql_error());
$message = "<h1>Step 2 of 2</h1><br /><form method='post'>Password: <input type='text' name='installpass' /><input type='hidden' name='op' value='install' /><input type='submit' value='Install' /></form>if you did this already, delete this file.<br /><small>looking for step 1? - delete 'config.php'</small>";
if ($_POST[op] == "install") {
if ($_POST[installpass] == $pw) {
$sql = 'CREATE TABLE `urlbase` ('
. ' `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, '
. ' `ranhash` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, '
. ' `url` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,'
. ' FULLTEXT (`ranhash`, `url`)'
. ' )'
. ' ENGINE = myisam;';
mysql_query($sql,$conn);
$addurltodb = "INSERT INTO urlbase VALUES ('', '11y2VgS9dDWA1TYdb6IOT9LM', 'http://omfgesad.com')";
mysql_query($addurltodb,$conn);
$message = "Installed, please delete this file.";
mysql_close($conn);
} else { $message = "Incorrect password"; }
}
echo $message;
} else {
echo "<h1>Step 1 of 2</h1><br /><form method='post'>mysql host: <input type='text' name='sqlhost' /><br />mysql username: <input type='text' name='sqlusername' /><br />mysql password: <input type='text' name='sqlpass' /><br />mysql database to install required tables: <input type='text' name='sqldb' /><br />password for deleting links(also used in step 2 of install): <input type='text' name='delpass' /><br /><input type='submit' value='Create config file' /></form>";
if ($_POST[sqlhost]) {
if ($_POST[sqlusername]) {
if ($_POST[sqlpass]) {
if ($_POST[sqldb]) {
if ($_POST[delpass]) {
$config_file = fopen("config.php","w+");
$contents = "<?phpn$db_host = "$_POST[sqlhost]"; //server hostn$db_username = "$_POST[sqlusername]"; //server usernamen$db_password = "$_POST[sqlpass]"; //server passwordn$db_touse = "$_POST[sqldb]"; //databasen$pw = "$_POST[delpass]"; //password to delete url'sn?>";
fwrite($config_file,$contents);
fclose($config_file);
echo "<meta http-equiv="refresh" content="0;url=install.php">";
}
}
}
}
}
}
?>
you also can use the cloaked links to embed objects. for example:
convert the url
http://music.armopride.com/Pink%20Floyd/1969%20-%20More/The%20Nile%20Song.mp3
when converted (in this case) its,
http://url.omfgesad.com/?u=PWyYC8c6LAXj2MEW-hj54q-x
you can embed that and it works as if it were using the actual link.(works for images too)
:D.......this seems a bit long for a simple explanation