Advertisement
salahzar

Central Dispenser v 0.5 15032008

Feb 16th, 2020
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.92 KB | None | 0 0
  1. A cosa serve:
  2. ========
  3.  
  4. - per distribuire in giro oggetti o notecard sempre aggiornati
  5. - per essere sicuri di distribuire oggetti protetti, consentendo però ad intermediari di distribuirli (esempio helper, mentori etc).
  6.  
  7. Problematiche risolte:
  8. =============
  9.  
  10. - 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
  11. - 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.
  12. - 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.
  13.  
  14. Come funziona:
  15. ==========
  16.  
  17. Bisogna impostare le seguenti cose:
  18.  
  19. 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.
  20.  
  21. 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.
  22.  
  23. 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ù :(
  24.  
  25.  
  26.  
  27. Script PHP su un server web esterno (non è usato database):
  28. =====================================
  29. **** receiver.php per leggere la coda di messaggi per il nome distintivo (necessaria password)
  30. **** requester.php per caricare la coda di messaggi per il nome distintivo (necessaria password)
  31. **** httplog.php per tracciare le transazioni
  32.  
  33. Attualmente sono depositati sotto www.salahzar.info/trace/httplog.php e www.salahzar.info/registry/requester.php & receiver.php
  34.  
  35. Gli script php servono per gestire una coda di messaggi che fluisce dal "cubo" alla "piramide".
  36. Ogni volta che si clicca il cubo viene accodato un messaggio per la piramide specificante:
  37. - la key dell'avatar che ha cliccato
  38. - il suo nome
  39. - il nome dell'oggetto cliccato (che serve ad estrarre il corrispondente nome dall'inventory della piramide)
  40. - la key del box
  41. - la posizione del box (x,y,z)
  42. - la regione sim in qui il box è posizionato
  43.  
  44. Le transazioni vengono registrate sotto www.salahzar.info/trace/tran_it.mentors.places.txt, accessibili mediante il seguente comando:
  45. **********************************************************************************
  46. *** www.salahzar.info/trace/httplog.php?pass=PASS&key=tran_it.mentors.places.txt&action=list ***
  47. **********************************************************************************
  48. che fornisce un tabulato come il seguente:
  49. Sat, 15 Mar 2008 20:35:21 +0100 Requested object for Salahzar Stenvaag Pergola<<87.46574, 124.17912, 150.94661>>
  50. Sat, 15 Mar 2008 20:35:26 +0100 Gave Elenco posti Italiani to Salahzar Stenvaag
  51. Sat, 15 Mar 2008 20:36:46 +0100 Requested object for jkxyw Aabye RYUKYU<<217.50352, 103.44170, 22.10040>>
  52. Sat, 15 Mar 2008 20:36:50 +0100 Gave Elenco posti Italiani to jkxyw Aabye
  53. Sat, 15 Mar 2008 20:49:45 +0100 Requested object for jkxyw Aabye RYUKYU<<218.69337, 103.73951, 22.10040>>
  54. Sat, 15 Mar 2008 20:49:51 +0100 Gave Elenco posti Italiani to jkxyw Aabye
  55. Sat, 15 Mar 2008 20:54:54 +0100 Requested object for Sacha Bowie nephilim<<193.06998, 63.84585, 22.12666>>
  56. Sat, 15 Mar 2008 20:54:58 +0100 Gave Elenco posti Italiani to Sacha Bowie
  57.  
  58. I programmi php sono i seguenti:
  59. httplog.php:
  60. ========
  61. <?
  62. $file=$_GET["key"];
  63. $text=$_GET["text"];
  64. $pass=$_GET["pass"];
  65. $action=$_GET["action"];
  66.  
  67. //echo "file: $file, text: $text, pass: $pass, action: $action ";
  68. if($pass!="PASS") die();
  69.  
  70. if($action=="delete")
  71. {
  72. unlink($file);
  73. return;
  74. }
  75. if($action=="log")
  76. {
  77. $fh = fopen($file, 'a+') or die("can't open file ".$file);
  78.  
  79. fwrite($fh, date("r")." ".$text."\n");
  80. fclose($fh);
  81. return;
  82. }
  83. if($action=="list")
  84. {
  85. header('Content-Type: text/html;charset=UTF-8');
  86. $fh = fopen($file, 'r') or die("can't open file ".$file);
  87.  
  88. $theData = fread($fh, filesize($file));
  89. fclose($fh);
  90. echo "<pre>\n$theData</pre>";
  91. }
  92. ?>
  93. requester.php:
  94. =========
  95. <?
  96.  
  97. $name=$_GET["name"];
  98. $text=$_GET["text"];
  99. $pass=$_GET["pass"];
  100. if($_GET["debug"]==1)
  101. $key=$_GET["objkey"];
  102. else
  103. $key =$_SERVER['HTTP_X_SECONDLIFE_OBJECT_KEY'];
  104.  
  105. if($pass!="xxxxxx") die();
  106.  
  107. // build directory if not existing
  108. if(!file_exists($name)) mkdir($name);
  109. $file="$name/$key";
  110.  
  111.  
  112. $fh = fopen($file, 'w+') or die("can't open file ".$file);
  113.  
  114. fwrite($fh, $text);
  115. fclose($fh);
  116.  
  117. ?>Enqueued <?=$file?>
  118.  
  119.  
  120. receiver.php
  121. ========
  122. <?
  123.  
  124. $name=$_GET["name"];
  125. $pass=$_GET["pass"];
  126.  
  127.  
  128. if($pass!="xxxxxx") die();
  129.  
  130. // build directory if not existing
  131. if(!file_exists($name)) mkdir($name);
  132.  
  133. $open = opendir($name);
  134. while ( ($file = readdir($open)) !== false )
  135. {
  136. if($file=="." || $file=="..") continue;
  137. // there is at least a file to read
  138. $fh = fopen("$name/$file", 'r') or die("can't open file ".$file);
  139.  
  140. $content = fread($fh, filesize("$name/$file"));
  141. fclose($fh);
  142. echo $content;
  143. unlink("$name/$file");
  144. break;
  145. }
  146. ?>
  147.  
  148. I programmi lsl sono i seguenti:
  149. Piramide:
  150. ======
  151. string sNAME="it.mentors.places";
  152.  
  153.  
  154.  
  155. string sLOG ="http://www.salahzar.info/trace/httplog.php?pass=PASS";
  156. string sRECEIVER="http://www.salahzar.info/registry/receiver.php?pass=xxxxxx";
  157.  
  158. http(string str)
  159. {
  160. //llSay(0,"http: "+str);
  161. llHTTPRequest(str,[],"");
  162. }
  163.  
  164. log_trans(string str)
  165. {
  166. string k="tran_"+sNAME+".txt";
  167. http(sLOG+"&key="+llEscapeURL(k)+"&action=log&text="+llEscapeURL(str));
  168. }
  169.  
  170. string getProperty(list lst,string name)
  171. {
  172. integer fnd=llListFindList(lst,[name]);
  173. if(fnd>=0) return llList2String(lst,fnd+1);
  174. return "";
  175.  
  176. }
  177.  
  178.  
  179. default
  180. {
  181. state_entry()
  182. {
  183.  
  184.  
  185. // every 2 seconds check if something to do
  186. llSetTimerEvent(2);
  187.  
  188. }
  189.  
  190. timer() {
  191. //llOwnerSay("llGetNextEmail");
  192. http(sRECEIVER+"&name="+llEscapeURL(sNAME));
  193. }
  194.  
  195. touch_start(integer total_number)
  196. {
  197. llSay(0, "Touched.");
  198. }
  199. http_response(key request_id, integer status, list metadata, string str) {
  200.  
  201. if(str=="") return;
  202.  
  203. // found something to do avkey| |avname| |objkey| |pos| |region
  204. list received=llParseStringKeepNulls(str,["|"],[]);
  205. key avatar=(key)getProperty(received,"avkey");
  206. string name=getProperty(received,"avname");
  207. string what=getProperty(received,"what");
  208. llGiveInventory(avatar,what);
  209. llDialog(avatar,"Gave you "+what,[],-1);
  210.  
  211. log_trans("Gave "+what+" to "+name);
  212.  
  213. }
  214.  
  215.  
  216. }
  217. Cubo:
  218. ====
  219. string sNAME="it.mentors.places";
  220. string sSUBJECT="Elenco posti Italiani";
  221.  
  222. key kAVATAR;
  223.  
  224. string sLOG ="http://www.salahzar.info/trace/httplog.php?pass=PASS";
  225. string sREQUEST ="http://www.salahzar.info/registry/requester.php?pass=xxxxxx";
  226.  
  227. // general http caller
  228. key http(string str)
  229. {
  230. //llSay(0,"http: "+str);
  231. return llHTTPRequest(str,[],"");
  232. }
  233.  
  234. log_trans(string str)
  235. {
  236. string k="tran_"+sNAME+".txt";
  237. http(sLOG+"&key="+llEscapeURL(k)+"&action=log&text="+llEscapeURL(str));
  238. }
  239.  
  240.  
  241. default
  242. {
  243. state_entry()
  244. {
  245. sNAME=llGetObjectDesc();
  246. sSUBJECT=llGetObjectName();
  247.  
  248. }
  249. touch_start(integer i)
  250. {
  251.  
  252. kAVATAR=llDetectedKey(0);
  253.  
  254. llDialog(kAVATAR,"Riceverai a breve "+sSUBJECT+" da "+sNAME,[],-1);
  255. http(sREQUEST+"&name="+llEscapeURL(sNAME)+"&text="+llEscapeURL("avkey|"+(string)kAVATAR+"|avname|"+llKey2Name(kAVATAR)+"|objkey|"+(string)llGetKey()+"|pos|"+(string)llGetPos()+"|region|"+llGetRegionName()+"|what|"+sSUBJECT));
  256. llSetText("Request done for "+llKey2Name(kAVATAR),<0,1,0>,1);
  257.  
  258. // log this transaction
  259. log_trans("Requested object for "+llKey2Name(kAVATAR)+" "+llGetRegionName()+"<"+(string)llGetPos()+">");
  260.  
  261.  
  262. }
  263. http_response(key request_id, integer status, list metadata, string str)
  264. {
  265. // alerts only for errors
  266. if(str=="") return;
  267. if(llSubStringIndex(str,"Enqueued")!=0)
  268. llSay(0,str);
  269. }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement