User:Damian Darkwyr

From Second Life Wiki
Jump to navigation Jump to search

I made these contributions.... lol


Specific Contents Giver random giver script

-s8OpenRelay- WHAT IS THE OpenRelay System?

The OpenRelay system is a bounce(proxy) server that bypasses the restrictions set by hosting providers on the required ports for LSL HTTP IN. Linden Lab, by their own admittal think that the restriction on ports is stupid. Kelly Linden has acknowledged on the scripter's email list that this retardation exists but will say no more on the matter except that it's "unfortunate".

What is it exactly that is being blocked? When you open a website with a shared host 90% of the time said host will not allow fsockopen connections on ports 12046 and 12043. They will usually only allow ports 80 and 443. This is an issue because Linden Lab requires ports 12046 and 12043. Else failure to connect and well you end up with a very angry scriptor.

So what are your alternatives? Well it means that if you want your awesome new web page to send info to sl you have to do one or more of the following, Stop using http in from web pages. but that is what we are doing isnt it. Use Email instead. which is slower than molasses. Pay for a VPS or Dedicated server. which could run you upwards of 75-100x dollars a month. add your own alternative here. or.... use s8OpenRelay.

OpenRelay is the cheapest and quickest answer. Its FREE and allows your pages to connect and fire messages to second life without lag, without delay, and without paying hundreds of dollars a month.

OpenRelay acts as a basic proxy for your website to connect to your second life scripts. Your page sends a request to the OpenRelay server and OpenRelay sends the message for you. Either on port 12046 or port 12043 which ever you have configured your prims inworld for.

This removes the headache worry of weither or not your webscripts are going to work with your httpin lsl scripts. They will always work with OpenRelay.


OpenRelay is brought to you by the creators of Carbon8 Android2SL Remote. The first android application that allows you to send AND recieve messages from second life on your android devices. And the Uriel Core AIO(Carbon8) Utility Device which allows you to control your weapons play from anywhere in the world without the teather of your computer.


Developer Damian Darkwyr has multiple patches in production with TPV compliant clients, as well as helped develop many open source projects for Second Life. A college student at the University of Phoenix majoring in Information Systems and Technology with a focus in Software Engineering.

WE HAVE DECIDED TO LAUNCH THIS SERVICE FOR FREE. TO HELP THE MANY PROGRAMMERS OUT THERE WHO COULD BE CAPABLE OF DOING SO MUCH MORE.

􀀀 if this link is invalid we have moved. Please check Damian Darkwyr's profile for the new link.



Usage of the OpenRelay System is simple. Here is a quick and dirty tutorial to get you started.


Step 1.

Use a link similar to the one below in an http request in your webpage. ex. http://s3kshun8.dyndns-remote.com/s8openrelay.php?url=http://sim4414.agni.lindenlab.com:12046/cap/39cb22a8-4e71-97b9-df84-1b688d696162&mes=test


a simple php example.

<?php $returnedstring = file_get_contents("http://s3kshun8.dyndns-remote.com/s8openrelay.php?url=http://sim4414.agni.lindenlab.com:12046/cap/39cb22a8-4e71-97b9-df84-1b688d696162&mes=test") or die("couldnt read file"); echo $returnedstring; ?>

the main url is our personal servers. http://s3kshun8.dyndns-remote.com/s8openrelay.php

? <----- means you are sending arguments

url is your second life prim's url. this is retrieved by using llRequestURL();

mes is all of the data you want to send to that prim. be creative.

THE STRING SENT IN CAN BE DIVIDED ANYWAY YOU LIKE AND PROCESSED LSL SIDE HOWEVER YOU LIKE.

Please enjoy the service if you need help feel free to ask. <lsl> /*Hippo Vendor Crowd Discount Plugin by Damian Darkwyr

*
*Create prim.
*Place this script inside prim.
*Link this prim to your Hippo Vendor
*DONE
*/

float setting = 0.5;//change this to effect the amount of discount. it will be 0.5*0.numberofscanned avatars integer i; integer fil; list keys; key buyer; default {

   state_entry()
   {
       llSetText("Earn a (0.5*x) discount for each person you get within 25m of this vendor when you make your purchase.",<1,1,1>,1);
       llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
   }
   run_time_permissions(integer p)
   {
       if(p & PERMISSION_DEBIT)
       {
           
       }else
       {
           llResetScript();
       }
   }
   link_message(integer s,integer r,string str,key id)
   {
       if(r == -147900)
       {
           list d = llParseString2List(str,["^"],[]);
           buyer = (key)llList2String(d,0);
           llSetObjectDesc(llList2String(d,2));
           llSensor("","",AGENT,25,PI);
       }
   }
   sensor(integer x)
   {
       keys = [];
       i = 0;
       do
       {
           fil = llListFindList(keys,[(string)llDetectedKey(i)]);
           if(fil == -1)
           {
               keys += [(string)llDetectedKey(i)];
           }
           i++;
       }while(i < x);
       string avcount = "0."+(string)llGetListLength(keys);
       float pS = setting * (float)avcount;
       if(pS >= 0.86)pS = 0.85;
       integer pricepaid = (integer)llGetObjectDesc();
       float client_rake = (float)pricepaid * pS;
       integer owner_rake = pricepaid - (integer)client_rake;
       pricepaid = pricepaid - owner_rake;
       //llOwnerSay((string)pricepaid);
       llInstantMessage(buyer,"thank you for bringing a crowd. Here is you discount.");
       llGiveMoney(buyer,pricepaid);
   }
   no_sensor()
   {
       
   }

} </lsl>


Key2Name

<lsl> /* PHP-LSL HTTPRequest Key2Name by: Damian Darkwyr This script is OPEN SOURCE Please keep it that way. I only ask that I get my cookies. ;)


This can also be called from any webscript. Or Mobile app to translate a key to a name.



What are cookies? Credits. I made this. I expect to be given credit as the creator. You can use it however you want. But please dont claim you wrote it.

  • /



/*PHP SOURCE <?php $inkey = $_GET["key"]; $f = file_get_contents("http://search.secondlife.com/web/search/people/?q=".$inkey) or die("could not find server"); $search = "<a href=\"http://my.secondlife.com/"; $search2 = "\">"; $a1 = explode($search,$f); $f = $a1[1]; $a1 = explode($search2,$f); $f = $a1[0]; echo $f; ?>

  • /

default {

   touch_start(integer x)
   {
       integer i = 0;
       do{
           llHTTPRequest("http://www.nanocat.co.cc/sl/key2name.php?key="+(string)llDetectedKey(i),[],"");
           i++;
       }while(i < x);
   }
   http_response(key id,integer s,list data,string body)
   {
       llOwnerSay("Your Name as detected by HTTPRequest is: "+body);
   }

}

</lsl>









Transaction History Checker

<lsl> /* This combo lets you test a sale in your transaction history. This can be used for vending systems that want to make sure a transaction has been validated before sending items to customers.

I used various forum entries, and with the help of hundreds of websites and with the help from resident Jones Limondi I was able to complete the scripts.

  • /



<?php date_default_timezone_set('America/Los_Angeles'); $USE_APACHE_HEADERS = TRUE; // switch to false if you need cgi methods if ($USE_APACHE_HEADERS) { $headers = apache_request_headers(); $objectgrid = $headers["X-SecondLife-Shard"]; $objectname = $headers["X-SecondLife-Object-Name"]; $objectkey = $headers["X-SecondLife-Object-Key"]; $objectpos = $headers["X-SecondLife-Local-Position"]; $ownerkey = $headers["X-SecondLife-Owner-Key"]; $ownername = $headers["X-SecondLife-Owner-Name"]; $regiondata = $headers["X-SecondLife-Region"]; $regiontmp = explode ("(",$regiondata); // cut cords off $regionpos = explode (")",$regiontmp[1]); // $regionname = substr($regiontmp[0],0,-1); // cut last space from simname } else { $db = $GLOBALS; $headers = $db['HTTP_ENV_VARS']; $objectgrid = $headers["HTTP_X_SECONDLIFE_SHARD"]; $objectname = $headers["HTTP_X_SECONDLIFE_OBJECT_NAME"]; $objectkey = $headers["HTTP_X_SECONDLIFE_OBJECT_KEY"]; $ownerkey = $headers["HTTP_X_SECONDLIFE_OWNER_KEY"]; $objectpos = $headers["HTTP_X_SECONDLIFE_LOCAL_POSITION"]; $ownername = $headers["HTTP_X_SECONDLIFE_OWNER_NAME"]; $regiondata = $headers["HTTP_X_SECONDLIFE_REGION"]; $regiontmp = explode ("(",$regiondata); $regionpos = explode (")",$regiontmp[1]); $regionname = substr($regiontmp[0],0,-1); } $fname = "yourfirstname"; $lname = "yourlastname"; $pwd = 'yourslpassword'; $startingdate = date("Y-m-d", strtotime("-1 day")); $endingdate = date('Y-m-d'); $stime = date('h:i:s'); $coretime = $stime; $stimear = explode(":",$stime); $stime = $stimear[0].":".$stimear[1]; function update_cookie($cookie,$newcookie) { $x=explode(";",$cookie); $n=Array(); $returncookie=""; foreach($x as $y) { $z=explode("=",$y); $n[$z[0]]=$z[1]; }

$x=explode(";",$newcookie); foreach($x as $y) { $z=explode("=",$y); $n[$z[0]]=$z[1]; } reset($n); for($a=0;$a<count($n);$a++) { $returncookie.=key($n)."=".$n[key($n)].";"; next($n); } return $returncookie; } function get_params($c) { preg_match_all('/type\="hidden" name\="([^"]+)" value\="([^"]+)"/',$c,$regs, PREG_SET_ORDER); $params=Array(); foreach ($regs as $r) $params[$r[1]]=$r[2];

return $params; } /**

* Send a POST requst using cURL
* @param string $url to request
* @param array $post values to send
* @param array $options for cURL
* @return string
*/

function curl_post_head($url, array $post = NULL, array $options = array()) {

   $defaults = array(
       CURLOPT_POST => 1,
       CURLOPT_HEADER => 1,
       CURLOPT_URL => $url,
       CURLOPT_FRESH_CONNECT => 1,
       CURLOPT_RETURNTRANSFER => 1,
       CURLOPT_FORBID_REUSE => 1,
       CURLOPT_TIMEOUT => 4,

CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CAINFO => getcwd()."/cacert.pem",

       CURLOPT_POSTFIELDS => http_build_query($post)
   );
   $ch = curl_init();
   curl_setopt_array($ch, ($options + $defaults));
   if( ! $result = curl_exec($ch))
   {
       trigger_error(curl_error($ch));
   }
   curl_close($ch);
   return $result;

} function curl_post($url, array $post = NULL, array $options = array()) {

   $defaults = array(
       CURLOPT_POST => 1,
       CURLOPT_HEADER => 0,
       CURLOPT_URL => $url,
       CURLOPT_FRESH_CONNECT => 1,
       CURLOPT_RETURNTRANSFER => 1,
       CURLOPT_FORBID_REUSE => 1,
       CURLOPT_TIMEOUT => 4,

CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CAINFO => getcwd()."/cacert.pem",

       CURLOPT_POSTFIELDS => http_build_query($post)
   );
   $ch = curl_init();
   curl_setopt_array($ch, ($options + $defaults));
   if( ! $result = curl_exec($ch))
   {
       trigger_error(curl_error($ch));
   }
   curl_close($ch);
   return $result;

}

/**

* Send a GET requst using cURL
* @param string $url to request
* @param array $get values to send
* @param array $options for cURL
* @return string
*/

function curl_get($url, array $get = NULL, array $options = array()) {

   $defaults = array(
       CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ). http_build_query($get),
       CURLOPT_HEADER => 0,

CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CAINFO => getcwd()."/cacert.pem",

       CURLOPT_RETURNTRANSFER => TRUE,
       CURLOPT_TIMEOUT => 4
   );
  
   $ch = curl_init();
   curl_setopt_array($ch, ($options + $defaults));
   if( ! $result = curl_exec($ch))
   {
       trigger_error(curl_error($ch));
   }
   curl_close($ch);
   return $result;

} function curl_get_head($url, array $get = NULL, array $options = array()) {

   $defaults = array(
       CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ). http_build_query($get),
       CURLOPT_HEADER => 1,

CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CAINFO => getcwd()."/cacert.pem",

       CURLOPT_RETURNTRANSFER => TRUE,
       CURLOPT_TIMEOUT => 4
   );
  
   $ch = curl_init();
   curl_setopt_array($ch, ($options + $defaults));
   if( ! $result = curl_exec($ch))
   {
       trigger_error(curl_error($ch));
   }
   curl_close($ch);
   return $result;

}


   $url="https://id.secondlife.com/openid/loginsubmit";
   $c=curl_post_head($url,

Array( "first_name"=>$fname, "last_name"=>$lname, "password"=>$pwd, "language"=>'en_US', "Submit"=>, "previous_language"=>'en_US', "return_to"=>"https://secondlife.com/auth/oid_return.php" ) );

$cookie=""; if(preg_match("/Set-Cookie: +(.+)/",$c,$regs))$cookie=update_cookie($cookie,$regs[1]);


preg_match("/Location: +(.+)/",$c,$regs); $location=$regs[1]; $c=curl_get_head($location,Array(), Array(CURLOPT_COOKIE=>$cookie) );

if(preg_match("/Set-Cookie: +(.+)/",$c,$regs))$cookie=update_cookie($cookie,$regs[1]); preg_match("/Location: +(.+)/",$c,$regs); $location=$regs[1]; $c=curl_get_head($location, Array(), Array(CURLOPT_COOKIE=>$cookie) ); $params=get_params($c);

if(preg_match("/Set-Cookie: +(.+)/",$c,$regs))$cookie=update_cookie($cookie,$regs[1]);

$location="https://id.secondlife.com/openid/openidserver"; $c=curl_post_head($location,$params,Array(CURLOPT_COOKIE=>$cookie));

preg_match("/Location: +(.+)/",$c,$regs); $location=$regs[1]; $c=curl_get_head($location,Array(), Array(CURLOPT_COOKIE=>$cookie) ); if(preg_match("/Set-Cookie: +(.+)/",$c,$regs))$cookie=update_cookie($cookie,$regs[1]); ///asdfasdfasdf $location='https://secondlife.com/my/account/download_transactions.php?date_start='.$startingdate.'%20'.date("h:i:s", strtotime("-1 hour")).'&date_end='.$endingdate.'%20'.$coretime.'&type=xml&include_zero=no'; $c=curl_get($location, Array(), Array(CURLOPT_COOKIE=>$cookie) );

file_put_contents("results.xml",$c); //print_r($c);


$output = "NOTFOUND"; $xml = simplexml_load_file("results.xml"); foreach($xml as $ta) { $timeblock = $ta->time; if($ta->type == "Payment" && $ta->region == $regionname && $ta->resident == $ownername) { $pos = strpos($timeblock,$stime); if($pos === false) { }else { $output = "FOUND - ".$ta->id."|".$timeblock; } } } echo $output."|".$coretime."|".date("h:i:s", strtotime("-1 hour")); ?>




integer trys = 0; default {

   money(key id,integer amount)
   {
       
       trys = 0;
       llSleep(15.5);
       llHTTPRequest("http://yourwebsite.com/test.php",[],"");
   }
   http_response(key id,integer status,list data,string body)
   {
      if(llSubStringIndex(body,"NOTFOUND")!=-1)
      {
          if(trys<5)
          {
              trys++;
              llHTTPRequest("http://yourwebsite.com/test.php",[],"");
          }else
          {
              llWhisper(0,"We were unabled to locate your Transaction ID."+body);
          }
      }else
      {
          llOwnerSay(body);
      }
   }

} </lsl>