corrade-lsl-templates – Diff between revs 11 and 12
?pathlinks?
Rev 11 | Rev 12 | |||
---|---|---|---|---|
Line 174... | Line 174... | |||
174 | // configuration data |
174 | // configuration data |
|
175 | string configuration = ""; |
175 | string configuration = ""; |
|
176 | // callback URL |
176 | // callback URL |
|
177 | string URL = ""; |
177 | string URL = ""; |
|
178 | // store message over state. |
178 | // store message over state. |
|
179 | string data = ""; |
- | ||
180 | string path = ""; |
179 | string path = ""; |
|
- | 180 | string data = ""; |
||
- | 181 | string action = ""; |
||
- | 182 | string statement = ""; |
||
181 | string jump_state = ""; |
183 | string parameters = ""; |
|
Line 182... | Line 184... | |||
182 | |
184 | |
|
183 | default { |
185 | default { |
|
184 | state_entry() { |
186 | state_entry() { |
|
185 | llOwnerSay("[Wiki] Starting..."); |
187 | llOwnerSay("[Wiki] Starting..."); |
|
186 | llSetTimerEvent(10); |
188 | llSetTimerEvent(10); |
|
187 | } |
189 | } |
|
188 | link_message(integer sender, integer num, string message, key id) { |
190 | link_message(integer sender, integer num, string message, key id) { |
|
189 | if(id != "configuration") return; |
191 | if(id != "configuration") return; |
|
190 | llOwnerSay("[Wiki] Got configuration..."); |
192 | llOwnerSay("[Wiki] Got configuration..."); |
|
191 | configuration = message; |
193 | configuration = message; |
|
192 | jump_state = "create_database"; |
194 | action = "create"; |
|
193 | state url; |
195 | state url; |
|
194 | } |
196 | } |
|
195 | timer() { |
197 | timer() { |
|
196 | llOwnerSay("[Wiki] Requesting configuration..."); |
198 | llOwnerSay("[Wiki] Requesting configuration..."); |
|
Line 219... | Line 221... | |||
219 | } |
221 | } |
|
220 | http_request(key id, string method, string body) { |
222 | http_request(key id, string method, string body) { |
|
221 | if(method != URL_REQUEST_GRANTED) return; |
223 | if(method != URL_REQUEST_GRANTED) return; |
|
222 | URL = body; |
224 | URL = body; |
|
223 | // DEBUG |
225 | // DEBUG |
|
224 | llOwnerSay("[Wiki] Got URL..."); |
226 | llOwnerSay("[Wiki] Got URL."); |
|
225 | if(jump_state == "create_database") |
- | ||
226 | state create_database; |
- | ||
227 | if(jump_state == "get") |
- | ||
228 | state get; |
- | ||
229 | if(jump_state == "set") |
- | ||
230 | state set; |
- | ||
231 | if(jump_state == "dir") |
- | ||
232 | state dir; |
- | ||
233 | if(jump_state == "listen_group") |
- | ||
234 | state listen_group; |
- | ||
Line 235... | Line -... | |||
235 | |
- | ||
236 | // DEBUG |
- | ||
237 | llOwnerSay("[Wiki] Jump table corrupted, please contact creator..."); |
- | ||
238 | llResetScript(); |
- | ||
239 | } |
- | ||
240 | on_rez(integer num) { |
- | ||
241 | llResetScript(); |
- | ||
242 | } |
227 | |
|
243 | changed(integer change) { |
228 | if(action == "create") { |
|
244 | if((change & CHANGED_INVENTORY) || |
229 | statement = wasURLEscape("CREATE TABLE IF NOT EXISTS \"" + |
|
245 | (change & CHANGED_REGION_START) || |
230 | wasKeyValueGet("wiki table", configuration) + |
|
246 | (change & CHANGED_OWNER)) { |
231 | "\" (path text unique collate nocase, data text)"); |
|
247 | llResetScript(); |
232 | state query; |
|
248 | } |
- | ||
249 | } |
- | ||
250 | } |
233 | } |
|
251 | |
- | ||
252 | state create_database { |
234 | |
|
253 | state_entry() { |
- | ||
254 | // DEBUG |
235 | if(action == "get") { |
|
255 | llOwnerSay("[Wiki] Creating database."); |
- | ||
256 | llInstantMessage( |
- | ||
257 | wasKeyValueGet( |
- | ||
258 | "corrade", |
236 | statement = wasURLEscape("SELECT data FROM \"" + |
|
259 | configuration |
- | ||
260 | ), |
- | ||
261 | wasKeyValueEncode( |
- | ||
262 | [ |
237 | wasKeyValueGet("wiki table", configuration) + |
|
263 | "command", "database", |
238 | "\" WHERE path=:path"); |
|
264 | "group", wasURLEscape( |
- | ||
265 | wasKeyValueGet( |
- | ||
266 | "group", |
- | ||
267 | configuration |
239 | parameters = wasURLEscape( |
|
268 | ) |
240 | wasListToCSV( |
|
269 | ), |
- | ||
270 | "password", wasURLEscape( |
- | ||
271 | wasKeyValueGet( |
- | ||
272 | "password", |
- | ||
273 | configuration |
241 | [ |
|
274 | ) |
- | ||
275 | ), |
- | ||
276 | "SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS \"" + |
- | ||
277 | wasKeyValueGet("wiki table", configuration) + |
- | ||
278 | "\" (path text unique collate nocase, data text)"), |
242 | "path", |
|
279 | "callback", wasURLEscape(URL) |
243 | wasURLEscape(path) |
|
280 | ] |
- | ||
281 | ) |
- | ||
282 | ); |
- | ||
283 | llSetTimerEvent(60); |
- | ||
284 | } |
- | ||
285 | http_request(key id, string method, string body) { |
- | ||
286 | llHTTPResponse(id, 200, "OK"); |
- | ||
287 | llReleaseURL(URL); |
- | ||
288 | if(wasKeyValueGet("command", body) != "database" || |
- | ||
289 | wasKeyValueGet("success", body) != "True") { |
- | ||
290 | // DEBUG |
- | ||
291 | llOwnerSay("[Wiki] Unable modify database: " + |
- | ||
292 | wasURLUnescape( |
- | ||
293 | wasKeyValueGet("error", body) |
244 | ] |
|
294 | ) |
245 | ) |
|
295 | ); |
246 | ); |
|
296 | state listen_group; |
247 | state query; |
|
- | 248 | } |
||
- | 249 | |
||
- | 250 | if(action == "set") { |
||
- | 251 | if(data == "") { |
||
- | 252 | statement = wasURLEscape("DELETE FROM \"" + |
||
297 | } |
253 | wasKeyValueGet("wiki table", configuration) + |
|
- | 254 | "\" WHERE path=:path"); |
||
- | 255 | parameters = wasURLEscape( |
||
- | 256 | wasListToCSV( |
||
- | 257 | [ |
||
- | 258 | "path", |
||
- | 259 | wasURLEscape(path) |
||
- | 260 | ] |
||
- | 261 | ) |
||
- | 262 | ); |
||
- | 263 | state query; |
||
- | 264 | } |
||
- | 265 | statement = wasURLEscape("REPLACE INTO \"" + |
||
- | 266 | wasKeyValueGet("wiki table", configuration) + |
||
- | 267 | "\" (path, data) VALUES (:path, :data)"); |
||
- | 268 | parameters = wasURLEscape( |
||
- | 269 | wasListToCSV( |
||
- | 270 | [ |
||
- | 271 | "path", |
||
- | 272 | wasURLEscape(path), |
||
- | 273 | "data", |
||
- | 274 | wasURLEscape(data) |
||
- | 275 | ] |
||
- | 276 | ) |
||
298 | llOwnerSay("[Wiki] Database created!"); |
277 | ); |
|
299 | state listen_group; |
278 | state query; |
|
- | 279 | } |
||
- | 280 | |
||
- | 281 | if(action == "dir") { |
||
- | 282 | if(path == "/") { |
||
- | 283 | path = ""; |
||
- | 284 | statement = wasURLEscape("SELECT DISTINCT SUBSTR(path, 1, LENGTH(path) - LENGTH(LTRIM(SUBSTR(path,2), 'abcdefghijklmnopqrstuvwxyz'))) AS path FROM \"" + wasKeyValueGet("wiki table", configuration) + "\" WHERE path LIKE '/%'"); |
||
300 | } |
285 | state query; |
|
301 | timer() { |
286 | } |
|
- | 287 | statement = wasURLEscape("SELECT DISTINCT SUBSTR(REPLACE(path, :base, ''),1, LENGTH(REPLACE(path, :base, '')) - LENGTH(LTRIM(REPLACE(path, :base, ''), 'abcdefghijklmnopqrstuvwxyz'))) AS path FROM \"" + wasKeyValueGet("wiki table", configuration) + "\" WHERE path LIKE :path"); |
||
- | 288 | parameters = wasURLEscape( |
||
- | 289 | wasListToCSV( |
||
- | 290 | [ |
||
- | 291 | "path", |
||
- | 292 | wasURLEscape(path + "/" + "%"), |
||
- | 293 | "base", |
||
- | 294 | wasURLEscape("/" + llDumpList2String(llParseString2List(path, ["/"], []), "/") + "/") |
||
- | 295 | ] |
||
- | 296 | ) |
||
302 | llReleaseURL(URL); |
297 | ); |
|
- | 298 | state query; |
||
- | 299 | } |
||
- | 300 | |
||
- | 301 | // DEBUG |
||
- | 302 | llOwnerSay("[Wiki] Jump table corrupted, please contact creator..."); |
||
303 | state listen_group; |
303 | llResetScript(); |
|
304 | } |
304 | } |
|
305 | on_rez(integer num) { |
305 | on_rez(integer num) { |
|
306 | llResetScript(); |
306 | llResetScript(); |
|
307 | } |
307 | } |
|
Line 310... | Line 310... | |||
310 | (change & CHANGED_REGION_START) || |
310 | (change & CHANGED_REGION_START) || |
|
311 | (change & CHANGED_OWNER)) { |
311 | (change & CHANGED_OWNER)) { |
|
312 | llResetScript(); |
312 | llResetScript(); |
|
313 | } |
313 | } |
|
314 | } |
314 | } |
|
315 | state_exit() { |
- | ||
316 | llSetTimerEvent(0); |
- | ||
317 | } |
- | ||
318 | } |
315 | } |
|
Line 319... | Line 316... | |||
319 | |
316 | |
|
320 | state listen_group { |
317 | state listen_group { |
|
321 | state_entry() { |
318 | state_entry() { |
|
Line 343... | Line 340... | |||
343 | if(llGetSubString(data, 0, 0) != |
340 | if(llGetSubString(data, 0, 0) != |
|
344 | wasKeyValueGet("command", configuration)) |
341 | wasKeyValueGet("command", configuration)) |
|
345 | return; |
342 | return; |
|
Line 346... | Line 343... | |||
346 | |
343 | |
|
347 | // Check if the command matches the current module. |
344 | // Check if the command matches the current module. |
|
348 | list command = llParseString2List(data, |
345 | list command = llParseString2List(data, [" "], []); |
|
349 | [wasKeyValueGet("command", configuration), " "], ["@"]); |
346 | if(llList2String(command, 0) != |
|
350 | if(llList2String(command, 0) != "wiki") |
347 | wasKeyValueGet("command", configuration) + "wiki") |
|
Line 351... | Line 348... | |||
351 | return; |
348 | return; |
|
352 | |
349 | |
|
Line 360... | Line 357... | |||
360 | data = "Subcommands are: get, set, dir"; |
357 | data = "Subcommands are: get, set, dir"; |
|
361 | state tell; |
358 | state tell; |
|
362 | } |
359 | } |
|
Line 363... | Line 360... | |||
363 | |
360 | |
|
364 | // Get the sub-command and store it as a jump state. |
361 | // Get the sub-command and store it as a jump state. |
|
Line 365... | Line 362... | |||
365 | jump_state = llList2String(command, 0); |
362 | action = llList2String(command, 0); |
|
366 | |
363 | |
|
Line 367... | Line 364... | |||
367 | // Remove sub-command. |
364 | // Remove sub-command. |
|
Line 413... | Line 410... | |||
413 | llResetScript(); |
410 | llResetScript(); |
|
414 | } |
411 | } |
|
415 | } |
412 | } |
|
416 | } |
413 | } |
|
Line 417... | Line 414... | |||
417 | |
414 | |
|
418 | state set { |
415 | state query { |
|
419 | state_entry() { |
- | ||
420 | if(data == "") { |
- | ||
421 | // DEBUG |
- | ||
422 | llOwnerSay("[Wiki] Removing from database."); |
- | ||
423 | llInstantMessage( |
- | ||
424 | wasKeyValueGet( |
- | ||
425 | "corrade", |
- | ||
426 | configuration |
- | ||
427 | ), |
- | ||
428 | wasKeyValueEncode( |
- | ||
429 | [ |
- | ||
430 | "command", "database", |
- | ||
431 | "group", wasURLEscape( |
- | ||
432 | wasKeyValueGet( |
- | ||
433 | "group", |
- | ||
434 | configuration |
- | ||
435 | ) |
- | ||
436 | ), |
- | ||
437 | "password", wasURLEscape( |
- | ||
438 | wasKeyValueGet( |
- | ||
439 | "password", |
- | ||
440 | configuration |
- | ||
441 | ) |
- | ||
442 | ), |
- | ||
443 | "SQL", wasURLEscape("DELETE FROM \"" + |
- | ||
444 | wasKeyValueGet("wiki table", configuration) + |
- | ||
445 | "\" WHERE path=:path"), |
- | ||
446 | "data", wasURLEscape( |
- | ||
447 | wasListToCSV( |
- | ||
448 | [ |
- | ||
449 | "path", |
- | ||
450 | wasURLEscape("path") |
- | ||
451 | ] |
- | ||
452 | ) |
- | ||
453 | ), |
- | ||
454 | "callback", wasURLEscape(URL) |
- | ||
455 | ] |
- | ||
456 | ) |
- | ||
457 | ); |
- | ||
458 | llSetTimerEvent(60); |
- | ||
459 | return; |
- | ||
460 | } |
416 | state_entry() { |
|
461 | // DEBUG |
417 | // DEBUG |
|
462 | llOwnerSay("[Wiki] Adding to database."); |
418 | llOwnerSay("[Wiki] Executing action: " + action); |
|
463 | llInstantMessage( |
419 | llInstantMessage( |
|
464 | wasKeyValueGet( |
420 | wasKeyValueGet( |
|
465 | "corrade", |
421 | "corrade", |
|
466 | configuration |
422 | configuration |
|
Line 478... | Line 434... | |||
478 | wasKeyValueGet( |
434 | wasKeyValueGet( |
|
479 | "password", |
435 | "password", |
|
480 | configuration |
436 | configuration |
|
481 | ) |
437 | ) |
|
482 | ), |
438 | ), |
|
483 | "SQL", wasURLEscape("REPLACE INTO \"" + |
- | ||
484 | wasKeyValueGet("wiki table", configuration) + |
- | ||
485 | "\" (path, data) VALUES (:path, :data)"), |
- | ||
486 | "data", wasURLEscape( |
439 | "SQL", statement, |
|
487 | wasListToCSV( |
- | ||
488 | [ |
- | ||
489 | "path", |
- | ||
490 | wasURLEscape(path), |
- | ||
491 | "data", |
440 | "data", parameters, |
|
492 | wasURLEscape(data) |
- | ||
493 | ] |
- | ||
494 | ) |
- | ||
495 | ), |
- | ||
496 | "callback", wasURLEscape(URL) |
441 | "callback", wasURLEscape(URL) |
|
497 | ] |
442 | ] |
|
498 | ) |
443 | ) |
|
499 | ); |
444 | ); |
|
500 | llSetTimerEvent(60); |
445 | llSetTimerEvent(60); |
|
Line 503... | Line 448... | |||
503 | llHTTPResponse(id, 200, "OK"); |
448 | llHTTPResponse(id, 200, "OK"); |
|
504 | llReleaseURL(URL); |
449 | llReleaseURL(URL); |
|
505 | if(wasKeyValueGet("command", body) != "database" || |
450 | if(wasKeyValueGet("command", body) != "database" || |
|
506 | wasKeyValueGet("success", body) != "True") { |
451 | wasKeyValueGet("success", body) != "True") { |
|
507 | // DEBUG |
452 | // DEBUG |
|
508 | llOwnerSay("[Wiki] Unable modify database: " + |
453 | llOwnerSay("[Wiki] Unable query database: " + |
|
509 | wasURLUnescape( |
454 | wasURLUnescape( |
|
510 | wasKeyValueGet("error", body) |
455 | wasKeyValueGet("error", body) |
|
511 | ) |
456 | ) |
|
512 | ); |
457 | ); |
|
513 | state listen_group; |
458 | state listen_group; |
|
514 | } |
459 | } |
|
- | 460 | |
||
- | 461 | // Process actions. |
||
- | 462 | |
||
- | 463 | if(action == "set") { |
||
515 | if(data == "") { |
464 | if(data == "") { |
|
516 | data = "Deleted from " + path; |
465 | data = "Deleted from " + path; |
|
- | 466 | state tell; |
||
- | 467 | } |
||
- | 468 | data = "Stored into " + path; |
||
517 | state tell; |
469 | state tell; |
|
518 | } |
470 | } |
|
519 | data = "Stored into " + path; |
- | ||
520 | state tell; |
- | ||
521 | } |
- | ||
522 | timer() { |
- | ||
523 | llReleaseURL(URL); |
- | ||
524 | state listen_group; |
- | ||
525 | } |
- | ||
526 | on_rez(integer num) { |
- | ||
527 | llResetScript(); |
- | ||
528 | } |
- | ||
529 | changed(integer change) { |
- | ||
530 | if((change & CHANGED_INVENTORY) || |
- | ||
531 | (change & CHANGED_REGION_START) || |
- | ||
532 | (change & CHANGED_OWNER)) { |
- | ||
533 | llResetScript(); |
- | ||
534 | } |
- | ||
535 | } |
- | ||
536 | state_exit() { |
- | ||
537 | llSetTimerEvent(0); |
- | ||
538 | } |
- | ||
539 | } |
- | ||
540 | |
471 | |
|
541 | state get { |
- | ||
542 | state_entry() { |
- | ||
543 | // DEBUG |
- | ||
544 | llOwnerSay("[Wiki] Retrieving from database."); |
- | ||
545 | llInstantMessage( |
472 | if(action == "get") { |
|
546 | wasKeyValueGet( |
473 | data = llDumpList2String( |
|
547 | "corrade", |
- | ||
548 | configuration |
474 | llDeleteSubList( |
|
549 | ), |
- | ||
550 | wasKeyValueEncode( |
- | ||
551 | [ |
- | ||
552 | "command", "database", |
- | ||
553 | "group", wasURLEscape( |
- | ||
554 | wasKeyValueGet( |
475 | wasCSVToList( |
|
555 | "group", |
- | ||
556 | configuration |
- | ||
557 | ) |
- | ||
558 | ), |
- | ||
559 | "password", wasURLEscape( |
476 | wasURLUnescape( |
|
560 | wasKeyValueGet( |
477 | wasKeyValueGet("data", body) |
|
561 | "password", |
- | ||
562 | configuration |
- | ||
563 | ) |
- | ||
564 | ), |
- | ||
565 | "SQL", wasURLEscape("SELECT data FROM \"" + |
- | ||
566 | wasKeyValueGet("wiki table", configuration) + |
- | ||
567 | "\" WHERE path=:path"), |
- | ||
568 | "data", wasURLEscape( |
- | ||
569 | wasListToCSV( |
- | ||
570 | [ |
- | ||
571 | "path", |
- | ||
572 | wasURLEscape(path) |
- | ||
573 | ] |
- | ||
574 | ) |
478 | ) |
|
575 | ), |
479 | ), |
|
576 | "callback", wasURLEscape(URL) |
- | ||
577 | ] |
480 | 0, |
|
578 | ) |
481 | 0 |
|
579 | ); |
- | ||
580 | llSetTimerEvent(60); |
- | ||
581 | } |
- | ||
582 | http_request(key id, string method, string body) { |
- | ||
583 | llHTTPResponse(id, 200, "OK"); |
- | ||
584 | llReleaseURL(URL); |
- | ||
585 | if(wasKeyValueGet("command", body) != "database" || |
- | ||
586 | wasKeyValueGet("success", body) != "True") { |
- | ||
587 | // DEBUG |
482 | ), |
|
588 | llOwnerSay("[Wiki] Unable retrieve from database: " + |
- | ||
589 | wasURLUnescape( |
- | ||
590 | wasKeyValueGet("error", body) |
- | ||
591 | ) |
483 | "" |
|
592 | ); |
484 | ); |
|
593 | state listen_group; |
- | ||
594 | } |
- | ||
Line 595... | Line -... | |||
595 | |
- | ||
596 | data = llDumpList2String( |
- | ||
597 | llDeleteSubList( |
485 | |
|
598 | wasCSVToList( |
- | ||
599 | wasURLUnescape( |
486 | if(data == "") { |
|
600 | wasKeyValueGet("data", body) |
487 | data = "Sorry, that path contains no data."; |
|
601 | ) |
- | ||
602 | ), |
- | ||
603 | 0, |
- | ||
604 | 0 |
- | ||
605 | ), |
488 | state tell; |
|
606 | "" |
- | ||
Line 607... | Line -... | |||
607 | ); |
- | ||
608 | |
489 | } |
|
609 | if(data == "") { |
490 | |
|
610 | data = "Sorry, that path contains no data."; |
491 | data = path + ": " + data; |
|
Line 611... | Line -... | |||
611 | state tell; |
- | ||
612 | } |
- | ||
613 | |
- | ||
614 | data = path + ": " + data; |
- | ||
615 | state tell; |
- | ||
616 | } |
492 | state tell; |
|
617 | timer() { |
- | ||
618 | llReleaseURL(URL); |
- | ||
619 | state listen_group; |
- | ||
620 | } |
- | ||
621 | on_rez(integer num) { |
- | ||
622 | llResetScript(); |
- | ||
623 | } |
- | ||
624 | changed(integer change) { |
493 | } |
|
625 | if((change & CHANGED_INVENTORY) || |
- | ||
626 | (change & CHANGED_REGION_START) || |
- | ||
627 | (change & CHANGED_OWNER)) { |
- | ||
628 | llResetScript(); |
- | ||
629 | } |
- | ||
630 | } |
- | ||
631 | state_exit() { |
- | ||
632 | llSetTimerEvent(0); |
- | ||
633 | } |
- | ||
634 | } |
- | ||
635 | |
- | ||
636 | state dir { |
- | ||
637 | state_entry() { |
- | ||
638 | // DEBUG |
494 | |
|
639 | llOwnerSay("[Wiki] Listing paths from database."); |
495 | if(action == "dir") { |
|
640 | llInstantMessage( |
496 | llOwnerSay(wasURLUnescape( |
|
641 | wasKeyValueGet( |
- | ||
642 | "corrade", |
497 | wasKeyValueGet("data", body) |
|
643 | configuration |
- | ||
644 | ), |
498 | )); |
|
645 | wasKeyValueEncode( |
499 | list paths = llList2ListStrided( |
|
646 | [ |
500 | llDeleteSubList( |
|
647 | "command", "database", |
- | ||
648 | "group", wasURLEscape( |
- | ||
649 | wasKeyValueGet( |
501 | wasCSVToList( |
|
650 | "group", |
502 | wasURLUnescape( |
|
651 | configuration |
- | ||
652 | ) |
- | ||
653 | ), |
- | ||
654 | "password", wasURLEscape( |
- | ||
655 | wasKeyValueGet( |
- | ||
656 | "password", |
503 | wasKeyValueGet("data", body) |
|
657 | configuration |
- | ||
658 | ) |
- | ||
659 | ), |
- | ||
660 | "SQL", wasURLEscape("SELECT path FROM \"" + |
- | ||
661 | wasKeyValueGet("wiki table", configuration) + |
- | ||
662 | "\" WHERE path like :path"), |
- | ||
663 | "data", wasURLEscape( |
- | ||
664 | wasListToCSV( |
- | ||
665 | [ |
- | ||
666 | "path", |
- | ||
667 | wasURLEscape(path + "%") |
- | ||
668 | ] |
- | ||
669 | ) |
- | ||
670 | ), |
- | ||
671 | "callback", wasURLEscape(URL) |
- | ||
672 | ] |
- | ||
673 | ) |
- | ||
674 | ); |
- | ||
675 | llSetTimerEvent(60); |
- | ||
676 | } |
- | ||
677 | http_request(key id, string method, string body) { |
- | ||
678 | llHTTPResponse(id, 200, "OK"); |
- | ||
679 | llReleaseURL(URL); |
- | ||
680 | if(wasKeyValueGet("command", body) != "database" || |
- | ||
681 | wasKeyValueGet("success", body) != "True") { |
- | ||
682 | // DEBUG |
- | ||
683 | llOwnerSay("[Wiki] Unable retrieve from database: " + |
- | ||
684 | wasURLUnescape( |
- | ||
685 | wasKeyValueGet("error", body) |
- | ||
686 | ) |
- | ||
687 | ); |
- | ||
688 | state listen_group; |
- | ||
689 | } |
- | ||
690 | |
- | ||
691 | list paths = llList2ListStrided( |
- | ||
692 | llDeleteSubList( |
- | ||
693 | wasCSVToList( |
504 | ) |
|
694 | wasURLUnescape( |
505 | ), |
|
695 | wasKeyValueGet("data", body) |
506 | 0, |
|
696 | ) |
507 | 0 |
|
697 | ), |
- | ||
698 | 0, |
- | ||
699 | 0 |
508 | ), |
|
700 | ), |
509 | 0, |
|
701 | 0, |
- | ||
Line 702... | Line 510... | |||
702 | -1, |
510 | -1, |
|
703 | 2 |
511 | 2 |
|
704 | ); |
512 | ); |
|
705 | |
513 | |
|
Line 706... | Line 514... | |||
706 | if(llGetListLength(paths) == 0) { |
514 | if(llGetListLength(paths) == 0) { |
|
707 | data = "Sorry, that path contains no sub-paths."; |
515 | data = "Sorry, that path contains no sub-paths."; |
|
708 | state tell; |
516 | state tell; |
|
709 | } |
517 | } |
|
710 | |
518 | |
|
711 | // Eliminate path component. |
519 | // Eliminate path component. |
|
712 | if(path == "/") |
520 | if(path == "/") |
|
713 | path = ""; |
521 | path = ""; |
|
Line 714... | Line 522... | |||
714 | |
522 | |
|
715 | list sibling = []; |
523 | list sibling = []; |
|
716 | do { |
524 | do { |
|
717 | // Get the path part. |
525 | // Get the path part. |
|
718 | string part = llList2String(paths, 0); |
526 | string part = llList2String(paths, 0); |
|
719 | |
527 | |
|
- | 528 | // Remove the path component. |
||
720 | // Remove the path component. |
529 | string child = llStringTrim( |
|
- | 530 | llDumpList2String( |
||
721 | string child = llStringTrim( |
531 | llParseString2List( |
|
722 | llDumpList2String( |
- | ||
723 | llParseString2List( |
- | ||
724 | part, |
532 | part, |
|
Line 725... | Line 533... | |||
725 | [path, "/"], |
533 | [path, "/"], |
|
Line 726... | Line 534... | |||
726 | [] |
534 | [] |
|
727 | ), |
535 | ), |
|
728 | "/" |
536 | "/" |
|
729 | ), |
537 | ), |
|
730 | STRING_TRIM |
538 | STRING_TRIM |
|
731 | |
539 | |
|
732 | ); |
540 | ); |
|
733 | |
541 | |
|
734 | integer i = llSubStringIndex(child, "/"); |
542 | integer i = llSubStringIndex(child, "/"); |
|
735 | if(i == -1) { |
543 | if(i == -1) { |
|
736 | sibling += path + "/" + child; |
544 | sibling += path + "/" + child; |
|
737 | jump continue; |
545 | jump continue_dir; |
|
738 | } |
546 | } |
|
739 | child = path + "/" + llDeleteSubString(child, i, -1) + "/"; |
547 | child = path + "/" + llDeleteSubString(child, i, -1) + "/"; |
|
740 | if(llListFindList(sibling, (list)child) == -1) |
548 | if(llListFindList(sibling, (list)child) == -1) |
|
Line 741... | Line 549... | |||
741 | sibling += child; |
549 | sibling += child; |
|
- | 550 | @continue_dir; |
||
- | 551 | paths = llDeleteSubList(paths, 0, 0); |
||
- | 552 | } while(llGetListLength(paths) != 0); |
||
- | 553 | |
||
- | 554 | data = llList2CSV(sibling); |
||
- | 555 | // GC |
||
- | 556 | sibling = []; |
||
- | 557 | |
||
- | 558 | state tell; |
||
742 | @continue; |
559 | } |
|
743 | paths = llDeleteSubList(paths, 0, 0); |
560 | |
|
744 | } while(llGetListLength(paths) != 0); |
561 | // Don't announce creating table. |
|
745 | |
562 | if(action == "create") |
|
746 | data = llList2CSV(sibling); |
563 | state listen_group; |