Difference between revisions of "User:Ugleh Ulrik/Name2Key"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with ''''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. <php> <...')
 
m
 
Line 2: Line 2:
This script uses Curl to grab the data because ive tested and Curl goes much faster.
This script uses Curl to grab the data because ive tested and Curl goes much faster.


<php>
<source lang="php">
<?php
<?php
$p = $_GET['q'];
$p = $_GET['q'];
Line 24: Line 24:
echo $key[0];
echo $key[0];
?>
?>
</php>
</source>


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

Latest revision as of 09:33, 31 July 2016

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.

<?php
$p = $_GET['q'];
$user = implode("+", explode(' ', $p));
$url = "http://search.secondlife.com/web/search/?q=$user";
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$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!
curl_close($ch);

$newlines = array(">", "<", "/", "=", "\n");
$content = str_replace($newlines, "", html_entity_decode($result));
$content = stripslashes(preg_replace('/\s\s+/', '', $content));
$html = '/world.secondlife.comresident(.+?)ah/';
preg_match($html,$content,$raw);
$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