diff -rup secondlife/README.txt temp/secondlife/README.txt --- secondlife/README.txt 2007-11-28 16:46:08.000000000 +0100 +++ temp/secondlife/README.txt 2008-12-23 14:21:09.000000000 +0100 @@ -58,7 +58,6 @@ between your web server and your Second TO DO ----- -- Limit IP address range to accept requests from to Linden Labs servers. - Map Second Life users to Drupal users. Bugs/Features/Patches: @@ -66,8 +65,9 @@ Bugs/Features/Patches: If you want to report bugs, feature requests, or submit a patch, please do so at the project page on the Drupal web site. -Author +Authors ------ Khalid Baheyeldin (http://2bits.com) +Drupal6 version : ssm2017 Binder (http://ssm2017.free.fr) -The author can also be contacted for paid customizations of this and other modules. +The authors can also be contacted for paid customizations of this and other modules. diff -rup secondlife/secondlife.module temp/secondlife/secondlife.module --- secondlife/secondlife.module 2008-12-16 17:05:54.000000000 +0100 +++ temp/secondlife/secondlife.module 2008-12-23 15:15:02.000000000 +0100 @@ -61,7 +61,7 @@ function secondlife_settings() { '#type' => 'radios', '#title' => t('Enable timing of requests ?'), '#default_value' => variable_get('secondlife_timer', 0), - '#options' => array( 0 => t('Disabled'), 1 => t('Enabled') ), + '#options' => array(0 => t('Disabled'), 1 => t('Enabled')), '#description' => t('Select whether you want to record timing information for how much it takes to process requests from the clients. A "timer=" is send with the response to the client, and if also writting to the debugging output (if enabled).'), ); @@ -108,17 +108,16 @@ function secondlife_settings() { function secondlife_request() { // check for server ips $is_ll = FALSE; - $ll_subnets = explode(",", variable_get('secondlife_allowed_ips', SECONDLIFE_LINDEN_SERVERS) ); - foreach( $ll_subnets as $network) { - if(secondlife_netmatch($network,$_SERVER['REMOTE_ADDR'] )) { + $ll_subnets = explode(",", variable_get('secondlife_allowed_ips', SECONDLIFE_LINDEN_SERVERS)); + foreach ($ll_subnets as $network) { + if (secondlife_netmatch($network, $_SERVER['REMOTE_ADDR'])) { $is_ll = TRUE; break; } } - if ( !$is_ll ) { + if (!$is_ll) { secondlife_debug("*********************************************************"); - secondlife_debug(" WRONG IP "); - secondlife_debug($_SERVER['REMOTE_ADDR']); + secondlife_debug(" WRONG IP : ". $_SERVER['REMOTE_ADDR']); secondlife_debug("*********************************************************"); secondlife_get_session(); return; @@ -154,11 +153,11 @@ function secondlife_get_session() { secondlife_debug("============================="); secondlife_debug(format_date(time(), 'custom', 'Y-m-d G:i:s')); secondlife_debug("============================="); - foreach($_SERVER as $key => $value) { + foreach ($_SERVER as $key => $value) { secondlife_debug("SERVER: $key: $value"); } - foreach($_POST as $key => $value) { + foreach ($_POST as $key => $value) { secondlife_debug("POST: $key: $value"); } @@ -185,7 +184,7 @@ function secondlife_get_session() { $sl->position_y = $temp[2][0]; $sl->position_z = $temp[3][0]; - secondlife_debug("SL: " . print_r($sl, TRUE) . "\n", FILE_APPEND); + secondlife_debug("SL: ". print_r($sl, TRUE). "\n", FILE_APPEND); return $sl; } @@ -194,7 +193,7 @@ function secondlife_get_session() { */ function secondlife_parse_args($arg) { $args = array(); - foreach(explode(variable_get('secondlife_args_separator', ':'), $arg) as $pair) { + foreach (explode(variable_get('secondlife_args_separator', ':'), $arg) as $pair) { list($key, $value) = explode('=', $pair); $args[$key] = $value; secondlife_debug("ARGS: $key=$value"); @@ -209,20 +208,20 @@ function secondlife_send_response(&$sl) $sl->response['app'] = $sl->app; $sl->response['cmd'] = $sl->cmd; - foreach($sl->response as $key => $value) { + foreach ($sl->response as $key => $value) { secondlife_debug("RESPONSE: $key = $value"); } - switch($sl->output_type) { + switch ($sl->output_type) { default: case 'full': - foreach($sl->response as $key => $value) { + foreach ($sl->response as $key => $value) { print "$key=$value:"; } print "\n"; break; case 'message': - print $sl->response['message']; + print strip_tags($sl->response['message']); break; } @@ -251,7 +250,7 @@ function secondlife_timer() { * Compute milliseconds. */ function _secondlife_getmillisecs() { - list($usec, $sec) = explode (' ', microtime()); + list($usec, $sec) = explode(' ', microtime()); return (double) $sec + $usec; } @@ -277,14 +276,14 @@ function secondlife_netmatch($network, $ */ function secondlife_get_data_between($src, $left, $right) { // function to return the data between two tokens (VERY USEFUL) - $ids = stripos($src,$left) + strlen($left); - if($ids === false) return false; - $ide = stripos($src,$right,$ids); - if($ide === false) return false; - return(substr($src,$ids,$ide - $ids)); + $ids = stripos($src, $left) + strlen($left); + if ($ids === false) return false; + $ide = stripos($src, $right,$ids); + if ($ide === false) return false; + return(substr($src, $ids, $ide - $ids)); } -function secondlife_rpc ($channel, $intVal, $stringVal) { +function secondlife_rpc($channel, $intVal, $stringVal) { // function to emulate xml-rpc for SL remote data connections // encapsulate request data in xml $xml = " @@ -318,3 +317,36 @@ function secondlife_rpc ($channel, $intV // return the response data in an array return array('channel' => $channel, 'string' => $sVal, 'integer' => $iVal); } +/** +* Get the linden user profile +*/ +function secondlife_get_linden_user_profile($user_key) { + $fp = fsockopen("world.secondlife.com", 80, $errno, $errstr, 30); + if (!$fp) { + $result = "$errstr ($errno)
\n"; + } + else { + $out = "GET /resident/".$user_key." HTTP/1.1\r\n"; + $out .= "Host: world.secondlife.com\r\n"; + $out .= "Connection: Close\r\n\r\n"; + fwrite($fp, $out); + $result = ''; + while (!feof($fp)) { + $result .= fgets($fp, 128); + } + fclose($fp); + } + return $result; +} +/** +* Extracts the profile picture key from the linden user profile +*/ +function secondlife_extract_picture_key($profile_page) { + return secondlife_get_data_between($profile_page, 'profile image'); +} +/** +* Extracts the user name from the linden user profile +*/ +function secondlife_extract_username($profile_page) { + return secondlife_get_data_between($profile_page, '',''); +} \ No newline at end of file