User:Qwerty Venom

From Second Life Wiki
Jump to navigation Jump to search

This can return either the key of an avatar, or the name of a group by it's key.

To get the avatar key by it' name, call search.php?name2Key=Qwerty Venom

Or to get the group name from it's key, call search.php?key2group=d5c0b1c4-e495-ce10-7c89-576eec42c98a


To use this, create two php files, search.php and process.php, then paste the following into each of them:


search.php <php> <? require_once('process.php');

if (isset($_GET["name2key"])) { print name2key($_GET["name2key"]); } else if (isset($_GET["key2group"])) { print key2Group($_GET["key2group"]); } else { print "Avalible functions are name2key and key2group"; } ?>

</php>

process.php <php> <?php // PHP name2Key by Jor3l Boa // Updated by Qwerty Venom // ------------------------- // PHP key2Group by Qwerty Venom // ------------------------- // Released under Creative Commons 3.0 // - devi@foravatars.com // ------------------------- // Updated: 08/31/2010

       function getPage($web)

{ $html = ""; $ch = curl_init($web); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $html = curl_exec($ch); if(curl_errno($ch)) { $html = ""; } curl_close ($ch); return $html; }

       function getBetween($content,$start,$end)

{ //by Jor3l :) $a1 = strrpos($content,$start); $content = substr($content,$a1 + strlen($start)); while($a2 = strrpos($content,$end)) { $content = substr($content,0,$a2); } return $content; }

function name2Key($name) { $SL_SEARCH = 'http://search.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q='; $sName = explode(' ',$name); //Qwerty changed split to explode $data = getPage($SL_SEARCH.$sName[0].'+'.$sName[1]); $uuid = getBetween($data,'http://world.secondlife.com/resident/','"');

               if(!preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/",$uuid)) $uuid = '00000000-0000-0000-0000-000000000000';

return $uuid; }

function key2Group($uuid) { //By Qwerty Venom if(!preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/",$uuid)) { $name = 'Invalid uuid'; } else { $SL_SEARCH = 'http://search.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&s=Groups&q='; $data = getPage($SL_SEARCH . $uuid); $name = getBetween($data,'<a href="http://world.secondlife.com/group/' . $uuid . '" >','</a>'); } return $name; } ?> </php>