User:Ugleh Ulrik/Name2Key

From Second Life Wiki
Jump to navigation Jump to search

This PHP Code will search Second Lifes database and bring back the persons Key This script uses Curl to grab the data because ive tested and Curl goes much faster.

$p = $_GET['q'];
$user = implode("+", explode(' ', $p));
$url = "$user";
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061204 Firefox/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE ); // return into a variable
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec( $ch ); // run!

$newlines = array(">", "<", "/", "=", "\n");
$content = str_replace($newlines, "", html_entity_decode($result));
$content = stripslashes(preg_replace('/\s\s+/', '', $content));
$html = '/world.secondlife.comresident(.+?)ah/';
$example = $raw[1];
$key = split('"', $example);
echo $key[0];

Upload this PHP file and then go to the url with a GET of q=User Name