PHP name2key
This script searches the w-hat name2key database from any webpage using file();
Use:
http:
www.example.com/name2key.php?name=Firstname%20Surname
where %20 represents a space.
//Made by Greblak Whitfield
//2. august 2007
function name2key($name)
{
define(NULL_KEY, "00000000-0000-0000-0000-000000000000");
$key = file('http://w-hat.com/name2key/?terse=1&name=' . urlencode( $name ));
if($key[0] != NULL_KEY)
{
//Happens if it is a valid key
echo "Your name is in the database";
//You can also delete the above and only use the following (See use example 2 for information on how to use it)
return $key[0];
}
else
{
//Happens if the request returns NULL_KEY
echo "Your name was not found in the database";
return NULL_KEY;
}
}
You can put this function into a class, or another file
There are several ways to use this. Either just return true/false with the echos, or return the key which can be much more useful.
//In order to get the name variable from the URL use the following code:
//Example 1
name2key($_GET['name']);
//To return the key, use example 2:
$key = name2key($_GET['name']);
Here are some modifications to this script to see them in action go to http:www.sltrinkets.com/key/key.php In this example you type the name of the avatar in the box and press go. It returns their key. Mods by Draco Kamachi.
<?php
?>
//Script wrote by Draco Kamachi Free for anyone to use however they want
<!-- key.php will be the page we will send the data to. -->
<form action="key.php" method="post">
Full Second Life Name:<br>
<input type="text" name="avatar" size="20"><br>
<input type="submit" value="Go!" name="go">
</form>
<?
$button = $_POST["go"];
$avatar = $_POST["avatar"];
$key = file_get_contents('http://w-hat.com/name2key/?terse=1&name=' .urlencode( $avatar));
if (isset($_POST['go']))
{
echo $key;
}
?>
Script Library |
Examples