/source/eggdrop/wiki.lsl |
@@ -44,18 +44,6 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// http://was.fm/secondlife/wanderer |
vector wasCirclePoint(float radius) { |
float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
return <x, y, 0>; |
return wasCirclePoint(radius); |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// escapes a string in conformance with RFC1738 |
@@ -281,10 +269,20 @@ |
if(action == "dir") { |
if(path == "/") { |
path = ""; |
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 '/%'"); |
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 '/%' LIMIT " + |
wasKeyValueGet("wiki results limit", configuration) |
); |
state query; |
} |
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"); |
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 LIMIT " + |
wasKeyValueGet("wiki results limit", configuration) |
); |
parameters = wasURLEscape( |
wasListToCSV( |
[ |
@@ -291,7 +289,17 @@ |
"path", |
wasURLEscape(path + "/" + "%"), |
"base", |
wasURLEscape("/" + llDumpList2String(llParseString2List(path, ["/"], []), "/") + "/") |
wasURLEscape("/" + |
llDumpList2String( |
llParseString2List( |
path, |
["/"], |
[] |
), |
"/" |
) + |
"/" |
) |
] |
) |
); |
@@ -298,6 +306,32 @@ |
state query; |
} |
|
if(action == "find") { |
if(data == "") { |
data = "Command requires two parameters: a path followed by a search term."; |
state tell; |
} |
if(path == "/") |
path = ""; |
statement = wasURLEscape( |
"SELECT DISTINCT path FROM \"" + |
wasKeyValueGet("wiki table", configuration) + |
"\" WHERE path LIKE :path AND ( data LIKE :data OR path LIKE :data ) COLLATE NOCASE LIMIT " + |
wasKeyValueGet("wiki search limit", configuration) |
); |
parameters = wasURLEscape( |
wasListToCSV( |
[ |
"path", |
wasURLEscape(path + "/" + "%"), |
"data", |
wasURLEscape("%" + data + "%") |
] |
) |
); |
state query; |
} |
|
// DEBUG |
llOwnerSay("[Wiki] Jump table corrupted, please contact creator..."); |
llResetScript(); |
@@ -353,8 +387,9 @@ |
// Check for supported sub-commands. |
if(llList2String(command, 0) != "set" && |
llList2String(command, 0) != "get" && |
llList2String(command, 0) != "dir") { |
data = "Subcommands are: get, set, dir"; |
llList2String(command, 0) != "dir" && |
llList2String(command, 0) != "find") { |
data = "Subcommands are: get, set, dir or find"; |
state tell; |
} |
|
@@ -414,6 +449,34 @@ |
|
state query { |
state_entry() { |
// Check messge length. |
string message = wasKeyValueEncode( |
[ |
"command", "database", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
"SQL", statement, |
"data", parameters, |
"callback", wasURLEscape(URL) |
] |
); |
// GC - none of these are needed anymore. |
statement = ""; |
parameters = ""; |
if(llStringLength(message) > 1023) { |
data = "Message length exceeded 1023 characters."; |
state tell; |
} |
// DEBUG |
llOwnerSay("[Wiki] Executing action: " + action); |
llInstantMessage( |
@@ -421,27 +484,10 @@ |
"corrade", |
configuration |
), |
wasKeyValueEncode( |
[ |
"command", "database", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
"SQL", statement, |
"data", parameters, |
"callback", wasURLEscape(URL) |
] |
) |
message |
); |
// GC |
message = ""; |
llSetTimerEvent(60); |
} |
http_request(key id, string method, string body) { |
@@ -468,7 +514,32 @@ |
data = "Stored into " + path; |
state tell; |
} |
|
|
if(action == "find") { |
data = llDumpList2String( |
llList2ListStrided( |
llDeleteSubList( |
wasCSVToList( |
wasURLUnescape( |
wasKeyValueGet("data", body) |
) |
), |
0, |
0 |
), |
0, |
-1, |
2 |
), |
"," |
); |
if(data == "") { |
data = "Sorry, the term was not found."; |
state tell; |
} |
state tell; |
} |
|
if(action == "get") { |
data = llDumpList2String( |
llDeleteSubList( |
@@ -611,6 +682,9 @@ |
] |
) |
); |
// GC |
path = ""; |
data = ""; |
state listen_group; |
} |
} |