corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 14  →  ?path2? @ 13
/source/eggdrop/wiki.lsl
@@ -44,6 +44,18 @@
}
 
///////////////////////////////////////////////////////////////////////////
// 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
@@ -269,20 +281,10 @@
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 '/%' LIMIT " +
wasKeyValueGet("wiki results limit", configuration)
);
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 '/%'");
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 LIMIT " +
wasKeyValueGet("wiki results limit", configuration)
);
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");
parameters = wasURLEscape(
wasListToCSV(
[
@@ -289,17 +291,7 @@
"path",
wasURLEscape(path + "/" + "%"),
"base",
wasURLEscape("/" +
llDumpList2String(
llParseString2List(
path,
["/"],
[]
),
"/"
) +
"/"
)
wasURLEscape("/" + llDumpList2String(llParseString2List(path, ["/"], []), "/") + "/")
]
)
);
@@ -306,32 +298,6 @@
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();
@@ -387,9 +353,8 @@
// Check for supported sub-commands.
if(llList2String(command, 0) != "set" &&
llList2String(command, 0) != "get" &&
llList2String(command, 0) != "dir" &&
llList2String(command, 0) != "find") {
data = "Subcommands are: get, set, dir or find";
llList2String(command, 0) != "dir") {
data = "Subcommands are: get, set, dir";
state tell;
}
@@ -449,34 +414,6 @@
 
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(
@@ -484,10 +421,27 @@
"corrade",
configuration
),
message
wasKeyValueEncode(
[
"command", "database",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"SQL", statement,
"data", parameters,
"callback", wasURLEscape(URL)
]
)
);
// GC
message = "";
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
@@ -514,32 +468,7 @@
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(
@@ -682,9 +611,6 @@
]
)
);
// GC
path = "";
data = "";
state listen_group;
}
}