Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A cosa serve:
- ========
- - per distribuire in giro oggetti o notecard sempre aggiornati
- - per essere sicuri di distribuire oggetti protetti, consentendo però ad intermediari di distribuirli (esempio helper, mentori etc).
- Problematiche risolte:
- =============
- - fare un cubo che distribuisca il suo inventory ha appunto i due problemi che per potere distribuire le cose devono essere fullpermissions, il che non è bello se si vuole proteggere la proprietà intellettuale e inoltre non viene automaticamente aggiornato
- - fare una distribuzione remota di oggetti con email o xml-rpc è inaffidabile e troppo lenta, in particolare la email risente del problema del ritardo di 20 secondi. Inoltre dipende dalla conoscenza della key dell'oggetto repository, che cambia se l'oggetto viene re-rezzato, cambia di sim etc.
- - la definizione di un "nome distintivo" it.mentors.places consente di avere una sorta di www applicato alle distribuzioni, una volta che sia noto il server php che funga da risolutore dei nomi distintivi e gestisca le code dei messaggi.
- Come funziona:
- ==========
- Bisogna impostare le seguenti cose:
- 1. La piramide che funziona da repository centrale. Deve essere rezzata ed avere il "nome distintivo" come descrizione dell'oggetto. (Esempio di nome distintivo: it.mentors.places) in un posto "sicuro" a cura del distributore di informazioni.
- 2. Il proprietario della piramide deve inserire gli oggetti che intende distribuire dentro l'inventory dell'oggetto. ad esempio oggetto1, oggetto2, oggetto3. Verificate accuratamente le permissions per evitare di distribuire oggetti FULLPERMISSIONS inavvertitamente.
- 3. Il cubo distributore può essere distribuito in centinaia di esemplari. Il nome del cubo deve essere uguale al nome dell'oggetto presente nell'inventory della piramide. La descrizione deve essere uguale al nome distintivo: it.mentors.places. Quindi lo stesso cubo se modify potrebbe ricevere oggetti differenti anche da repository differenti modificando nome e descrizione. Corollario: se modificate il nome/descrizione il cubo non funziona più :(
- Script PHP su un server web esterno (non è usato database):
- =====================================
- **** receiver.php per leggere la coda di messaggi per il nome distintivo (necessaria password)
- **** requester.php per caricare la coda di messaggi per il nome distintivo (necessaria password)
- **** httplog.php per tracciare le transazioni
- Attualmente sono depositati sotto www.salahzar.info/trace/httplog.php e www.salahzar.info/registry/requester.php & receiver.php
- Gli script php servono per gestire una coda di messaggi che fluisce dal "cubo" alla "piramide".
- Ogni volta che si clicca il cubo viene accodato un messaggio per la piramide specificante:
- - la key dell'avatar che ha cliccato
- - il suo nome
- - il nome dell'oggetto cliccato (che serve ad estrarre il corrispondente nome dall'inventory della piramide)
- - la key del box
- - la posizione del box (x,y,z)
- - la regione sim in qui il box è posizionato
- Le transazioni vengono registrate sotto www.salahzar.info/trace/tran_it.mentors.places.txt, accessibili mediante il seguente comando:
- **********************************************************************************
- *** www.salahzar.info/trace/httplog.php?pass=PASS&key=tran_it.mentors.places.txt&action=list ***
- **********************************************************************************
- che fornisce un tabulato come il seguente:
- Sat, 15 Mar 2008 20:35:21 +0100 Requested object for Salahzar Stenvaag Pergola<<87.46574, 124.17912, 150.94661>>
- Sat, 15 Mar 2008 20:35:26 +0100 Gave Elenco posti Italiani to Salahzar Stenvaag
- Sat, 15 Mar 2008 20:36:46 +0100 Requested object for jkxyw Aabye RYUKYU<<217.50352, 103.44170, 22.10040>>
- Sat, 15 Mar 2008 20:36:50 +0100 Gave Elenco posti Italiani to jkxyw Aabye
- Sat, 15 Mar 2008 20:49:45 +0100 Requested object for jkxyw Aabye RYUKYU<<218.69337, 103.73951, 22.10040>>
- Sat, 15 Mar 2008 20:49:51 +0100 Gave Elenco posti Italiani to jkxyw Aabye
- Sat, 15 Mar 2008 20:54:54 +0100 Requested object for Sacha Bowie nephilim<<193.06998, 63.84585, 22.12666>>
- Sat, 15 Mar 2008 20:54:58 +0100 Gave Elenco posti Italiani to Sacha Bowie
- I programmi php sono i seguenti:
- httplog.php:
- ========
- <?
- $file=$_GET["key"];
- $text=$_GET["text"];
- $pass=$_GET["pass"];
- $action=$_GET["action"];
- //echo "file: $file, text: $text, pass: $pass, action: $action ";
- if($pass!="PASS") die();
- if($action=="delete")
- {
- unlink($file);
- return;
- }
- if($action=="log")
- {
- $fh = fopen($file, 'a+') or die("can't open file ".$file);
- fwrite($fh, date("r")." ".$text."\n");
- fclose($fh);
- return;
- }
- if($action=="list")
- {
- header('Content-Type: text/html;charset=UTF-8');
- $fh = fopen($file, 'r') or die("can't open file ".$file);
- $theData = fread($fh, filesize($file));
- fclose($fh);
- echo "<pre>\n$theData</pre>";
- }
- ?>
- requester.php:
- =========
- <?
- $name=$_GET["name"];
- $text=$_GET["text"];
- $pass=$_GET["pass"];
- if($_GET["debug"]==1)
- $key=$_GET["objkey"];
- else
- $key =$_SERVER['HTTP_X_SECONDLIFE_OBJECT_KEY'];
- if($pass!="xxxxxx") die();
- // build directory if not existing
- if(!file_exists($name)) mkdir($name);
- $file="$name/$key";
- $fh = fopen($file, 'w+') or die("can't open file ".$file);
- fwrite($fh, $text);
- fclose($fh);
- ?>Enqueued <?=$file?>
- receiver.php
- ========
- <?
- $name=$_GET["name"];
- $pass=$_GET["pass"];
- if($pass!="xxxxxx") die();
- // build directory if not existing
- if(!file_exists($name)) mkdir($name);
- $open = opendir($name);
- while ( ($file = readdir($open)) !== false )
- {
- if($file=="." || $file=="..") continue;
- // there is at least a file to read
- $fh = fopen("$name/$file", 'r') or die("can't open file ".$file);
- $content = fread($fh, filesize("$name/$file"));
- fclose($fh);
- echo $content;
- unlink("$name/$file");
- break;
- }
- ?>
- I programmi lsl sono i seguenti:
- Piramide:
- ======
- string sNAME="it.mentors.places";
- string sLOG ="http://www.salahzar.info/trace/httplog.php?pass=PASS";
- string sRECEIVER="http://www.salahzar.info/registry/receiver.php?pass=xxxxxx";
- http(string str)
- {
- //llSay(0,"http: "+str);
- llHTTPRequest(str,[],"");
- }
- log_trans(string str)
- {
- string k="tran_"+sNAME+".txt";
- http(sLOG+"&key="+llEscapeURL(k)+"&action=log&text="+llEscapeURL(str));
- }
- string getProperty(list lst,string name)
- {
- integer fnd=llListFindList(lst,[name]);
- if(fnd>=0) return llList2String(lst,fnd+1);
- return "";
- }
- default
- {
- state_entry()
- {
- // every 2 seconds check if something to do
- llSetTimerEvent(2);
- }
- timer() {
- //llOwnerSay("llGetNextEmail");
- http(sRECEIVER+"&name="+llEscapeURL(sNAME));
- }
- touch_start(integer total_number)
- {
- llSay(0, "Touched.");
- }
- http_response(key request_id, integer status, list metadata, string str) {
- if(str=="") return;
- // found something to do avkey| |avname| |objkey| |pos| |region
- list received=llParseStringKeepNulls(str,["|"],[]);
- key avatar=(key)getProperty(received,"avkey");
- string name=getProperty(received,"avname");
- string what=getProperty(received,"what");
- llGiveInventory(avatar,what);
- llDialog(avatar,"Gave you "+what,[],-1);
- log_trans("Gave "+what+" to "+name);
- }
- }
- Cubo:
- ====
- string sNAME="it.mentors.places";
- string sSUBJECT="Elenco posti Italiani";
- key kAVATAR;
- string sLOG ="http://www.salahzar.info/trace/httplog.php?pass=PASS";
- string sREQUEST ="http://www.salahzar.info/registry/requester.php?pass=xxxxxx";
- // general http caller
- key http(string str)
- {
- //llSay(0,"http: "+str);
- return llHTTPRequest(str,[],"");
- }
- log_trans(string str)
- {
- string k="tran_"+sNAME+".txt";
- http(sLOG+"&key="+llEscapeURL(k)+"&action=log&text="+llEscapeURL(str));
- }
- default
- {
- state_entry()
- {
- sNAME=llGetObjectDesc();
- sSUBJECT=llGetObjectName();
- }
- touch_start(integer i)
- {
- kAVATAR=llDetectedKey(0);
- llDialog(kAVATAR,"Riceverai a breve "+sSUBJECT+" da "+sNAME,[],-1);
- http(sREQUEST+"&name="+llEscapeURL(sNAME)+"&text="+llEscapeURL("avkey|"+(string)kAVATAR+"|avname|"+llKey2Name(kAVATAR)+"|objkey|"+(string)llGetKey()+"|pos|"+(string)llGetPos()+"|region|"+llGetRegionName()+"|what|"+sSUBJECT));
- llSetText("Request done for "+llKey2Name(kAVATAR),<0,1,0>,1);
- // log this transaction
- log_trans("Requested object for "+llKey2Name(kAVATAR)+" "+llGetRegionName()+"<"+(string)llGetPos()+">");
- }
- http_response(key request_id, integer status, list metadata, string str)
- {
- // alerts only for errors
- if(str=="") return;
- if(llSubStringIndex(str,"Enqueued")!=0)
- llSay(0,str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement