User:Crooked Shim: Difference between revisions
Jump to navigation
Jump to search
Crooked Shim (talk | contribs) Created page with '__NOTOC__ {| cellpadding="10" cellspacing="8" style="width: 100%; background-color: #C0C0C0; border: 1px solid #1234aa; vertical-align: top;" |- | style="width: 68%; background-...' |
Crooked Shim (talk | contribs) m moved User talk:Crooked Shim to User:Crooked Shim: Oops |
(No difference)
| |
Revision as of 19:46, 6 May 2010
Useful PHP FunctionsThese may break at any time, depends on if LL changes SL search too much. Name2Keyfunction get_key($user_name)
{
$url = sprintf('http://search.secondlife.com/web/search/?q=%s', urlencode($user_name));
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>"Madgeek_N2K"));
$output = curl_exec($ch);
curl_close($ch);
$user_name = strtoupper($user_name);
preg_match_all('%<a href="http://world\.secondlife\.com/resident/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})">(?:<b>)?(.+?)(?:</b>)?</a>%', $output, $matches, PREG_SET_ORDER);
foreach ($matches as $val)
{
if (strtoupper($val[2]) == $user_name)
{
return $val[1];
}
}
return 'not_found';
}
Key2Namefunction get_name($user_key)
{
$url = sprintf('http://world.secondlife.com/resident/%s', urlencode($user_key));
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5));
$output = curl_exec($ch);
curl_close($ch);
preg_match('%<title>(.+?)</title>%', $output, $matches);
if (!empty($matches[1])) return $matches[1];
else return 'not_found';
}
Key2Birthdayfunction get_birthday($user_key)
{
$url = sprintf('http://world.secondlife.com/resident/%s', urlencode($user_key));
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>"Madgeek_K2DOB"));
$output = curl_exec($ch);
curl_close($ch);
if (strpos($output, 'AccessDenied') !== false) return 'not_found';
if (preg_match('%<span class="syscat">Resident Since:</span>\s<!--googleon: index-->\s(\d+?)-(\d+?)-(\d+?)\s<!--googleoff: index-->%', $output, $matches)) return array_slice($matches, 1);
else return 'not_found';
}
|