//JoomlaSL Server Code written by GP Runo //Released under GNU/GPL License //Copyrights J. van Veen/GP Runo //For more information about SL-services, go to http://www.syntheticworlds.eu list entryList; list sessionList; key userkey; key setupID; string initmessage; string operatemessage; string exitmessage; string sitetitle; string url; string setupNotecardName="JoomlaSL Setup"; integer md5key; integer updatedb; string channelnr; integer setupNotecardLine; integer setupInitialized=0; integer stridelengthUser = 6; integer stridelengthSession = 6; integer serverchannel; list allowedTerminals; list allowedAdmins; key authkey=""; initSetup() { llSetStatus(STATUS_BLOCK_GRAB, TRUE); setupNotecardLine = 0; setupID = llGetNotecardLine(setupNotecardName,setupNotecardLine); } integer checkAuth(key id,string type) { if(type=="allowedTerminals") { integer i; for (i=0; i, 1); } touch_start( integer num ) { userkey = llDetectedKey(0); //*******************************************************AUTH2******************************************************* if(checkAuth(userkey,"allowedAdmins")) { llSetText(operatemessage, <1,1,1>, 1); state online; } else { llInstantMessage(userkey,"Only valid administrators may control the JoomlaSL server!"); } } } state online { state_entry() { llListen(serverchannel, "JoomlaSL terminal", NULL_KEY, "" ); } listen( integer channel, string name, key id, string message ) { //*******************************************************AUTH1******************************************************* list elements = llParseString2List(message, [" "], []); string command = llList2String(elements,0); integer nrparams = llGetListLength(elements) - 1; //Initial session command from the console if (command == "startSession") { if(nrparams == 6) { integer i; //Session-entry looks like: [consoleid, userkey, username, born, payinfo, channelid] sessionList += [(string)id]; for(i=1; i <= nrparams;i++) { sessionList +=[llList2String(elements,i)]; } } else { llSay(0,"\nErrorcode 1: Failed to start a new session!\nThe administrator will be informed about the problem..."); } } //Match an incoming request from a console with the available sessiondata list sessionUser = getSession(id); string username = llList2String(sessionUser,2) + " " + llList2String(sessionUser,3); string userkey = llList2String(sessionUser,1); string userborn = llList2String(sessionUser,4); string userpay = llList2String(sessionUser,5); channelnr = llList2String(sessionUser,6); //*******************************************************AUTH2******************************************************* if(checkAuth(userkey,"allowedAdmins")) { if (command == "consoleid") { llInstantMessage(userkey,(string)id); } if (command == "serverid") { llInstantMessage(userkey,llGetKey()); } } //*******************************************************AUTH3******************************************************* if(checkAuth(id,"allowedTerminals")) { if (command =="endSession") { if(!removeEntry("sessionList",(string)id)) { llSay(0,"\nErrorcode 2: Failed to delete session!\nThe administrator will be informed about the problem..."); } } if (command == "help") { string helpString; integer atIndex = entryExists("username",username); helpString = "\n====User options===\n"; helpString+= "/"+ channelnr + " community___________________Go to our community webpage\n"; helpString+= "/"+ channelnr + " avkeyreq___________________Request your personal key\n"; if (atIndex==-1) { helpString+= "/"+ channelnr + " register PARAM1(optional) PARAM2_______Register for our webservices. PARAM1=password, PARAM2=email-address\n"; } else { helpString+= "/"+ channelnr + " update password PARAM1______Change your password. PARAM1 is the new password\n"; helpString+= "/"+ channelnr + " update mail PARAM1___________Changes your email-address. PARAM1 is the new address\n"; } llInstantMessage(userkey,helpString); } else if (command == "register") { if(nrparams == 2) { //username, userkey, password, email, born, payinfo if(addEntry(username, userkey, llList2String(elements,1),llList2String(elements,2), userborn, userpay)) { llInstantMessage(userkey,"\nThank you for registering!\nYour username is: "+username+"\nYour password will be: "+llList2String(elements,1)+"\nYou can use this info to login at our community website now...\n"); llLoadURL(userkey,sitetitle,url); } else { llInstantMessage(userkey,"\nYou are allready registered..."); } } else if(nrparams == 1) { string genPW = generatePW(666); if(addEntry(username, userkey, genPW,llList2String(elements,1), userborn, userpay)) { llInstantMessage(userkey,"\nThank you for registering!\nYour username is: "+username+"\nYour password will be: "+genPW+"\nYou can use this info to login at our community website now...\n"); llLoadURL(userkey,sitetitle,url); } else { llInstantMessage(userkey,"\nYou are allready registered..."); } } else { llInstantMessage(llList2String(sessionUser,1),"Please enter one or two parameters..."); } } else if (command == "update") { if (nrparams == 2) { if (updateEntry(username, llList2String(elements,1),llMD5String(llList2String(elements,2),md5key))) { llInstantMessage(userkey,"Password updated..."); } else { llInstantMessage(userkey,"You have to register first"); } } else { llInstantMessage(userkey,"Please enter a valid password(no spaces)..."); } } else if (command == "community") { if (nrparams == 0) { llLoadURL(userkey, sitetitle, url); } else { llInstantMessage(userkey,"Don't use parameters please..."); } } if(command =="avkeyreq") { llInstantMessage(userkey,(string)userkey); } //*******************************************************AUTH4******************************************************* if(checkAuth(authkey,"allowedAdmins")) { if(command == "members") { integer len = llGetListLength(entryList); integer i; integer j; string memberString; memberString = "\n--- Username --- avkey --- md5pw --- email --- birthdate --- payinfo ---"; for( i = 0; i < len; i=i + stridelengthUser) { for (j = i; j < i+stridelengthUser;j++) { if(j==i) { memberString += "\n--- " + llList2String(entryList, j) + " --- "; } else { memberString += llList2String(entryList, j) + " -- "; } } } llInstantMessage(userkey,memberString+"\nTotal members: " + (string)(len / stridelengthUser) ); } else if(command == "membersreset") { entryList = llDeleteSubList(entryList, 0, llGetListLength(entryList)); llInstantMessage(userkey,"Memberlist is empty now..."); } else if(command == "serverreset") { llInstantMessage(userkey,"Server has been reset"); llResetScript(); } else if(command == "remove") { if(nrparams == 2) { if (removeEntry("entryList",llList2String(elements,1) + " " + llList2String(elements,2))) { llOwnerSay("Entry removed..."); } else { llInstantMessage(userkey,"User not found..."); } } else { llOwnerSay("Enter a valid username please..."); } } else if(command == "find") { if(nrparams == 2) { integer found=entryExists("username",(llList2String(elements,1) + " " + llList2String(elements,2))); if(found >=0) { integer i; string memberstring; for(i = found;i< (found + stridelengthUser); i++) { memberstring += llList2String(entryList, i) + " -- "; } llInstantMessage(userkey,"Entry found:\n" + memberstring); } else { llOwnerSay("User not found..."); } } else { llOwnerSay("Enter a valid username please"); } } //*******************************************************Communication with XMLRPC link******************************************************* else if (command == "channelreq") { llOwnerSay("Retrieving XMLRPC-channel..."); llMessageLinked(LINK_ALL_OTHERS, 0, "channelreq", NULL_KEY); } else if (command == "channelreset") { llOwnerSay("Resetting XMLRPC-channel..."); llMessageLinked(2, 0, "channelreset", NULL_KEY); } else if (command == "linkreq") { llOwnerSay("Retrieving XMLRPC link-number..."); llMessageLinked(LINK_ALL_OTHERS, 0, "linkreq", NULL_KEY); } //******************************************************************************************************************************************** else if (command == "clearbans") { llResetLandBanList(); llInstantMessage(userkey,"All bans removed..."); } else if (command == "clearpass") { llResetLandPassList(); llInstantMessage(userkey,"All passage privileges removed..."); } else if (command == "memoryheap") { llInstantMessage(userkey,(string)llGetFreeMemory()); } //if (command == "tempban") { // if(nrparams == 2) { // llAddToLandBanList(llDetectedKey(i),1.0); // } // else { // // } //} else if (command == "help") { string helpString = "\n====Admin options===\n"; helpString+= "/"+ channelnr + " visitorsreset_________Remove all visitors\n"; helpString+= "/"+ channelnr + " membersreset________Remove all members\n"; helpString+= "/"+ channelnr + " serverreset________Reset all server settings(removes ALL stored data!)\n"; helpString+= "/"+ channelnr + " visitors_____________Show all visitors\n"; helpString+= "/"+ channelnr + " members____________Show all members\n"; helpString+= "/"+ channelnr + " find PARAM1_________Search for specific member\n"; helpString+= "/"+ channelnr + " remove PARAM1______Remove specific member\n"; helpString+= "/"+ channelnr + " channelreq__________Show all available XMLRPC channels\n"; helpString+= "/"+ channelnr + " linkreq__________Show the XMLRPC link-channels\n"; helpString+= "/"+ channelnr + " consoleid__________Show the current console-ID\n"; helpString+= "/"+ channelnr + " serverid__________Show the server-ID\n"; helpString+= "/"+ channelnr + " memoryheap__________Show the memory-heap footprint\n"; helpString+= "/"+ channelnr + " clearbans____________Clear all bans\n"; helpString+= "/"+ channelnr + " clearpass____________Clear all passage privileges\n"; llInstantMessage(userkey,helpString); } } } else { llInstantMessage(userkey,"\nTerminal not authenticated!\nUse \"/" + channelnr + " consoleid\" to identify this console(administrators only)"); } if(command!="endSession") { llInstantMessage(userkey,"\nType '/"+ channelnr + " help' for a list of available commands"); } } //XMLRPC-authentication request link_message(integer sender_num, integer num, string str, key id) { list request= llCSV2List(str); integer userpos = entryExists("username",llList2String(request,0)); if(userpos >= 0) { if(llList2String(request,1) == llList2String(entryList,(userpos + 2))) { string authString="1,"+llList2String(entryList,userpos+1)+","+llList2String(entryList,userpos+3)+","+llList2String(entryList,userpos+4)+","+llList2String(entryList,userpos+5); llMessageLinked(sender_num, 0, authString, NULL_KEY); } else { llMessageLinked(sender_num, 0, "wp", NULL_KEY); } } else { llMessageLinked(sender_num, 0, "wu", NULL_KEY); } } touch_start( integer num ) { userkey = llDetectedKey(0); //*******************************************************AUTH2******************************************************* if(checkAuth(userkey,"allowedAdmins")) { llSetText(exitmessage, <1,1,1>, 1); sessionList=[]; llSleep(1); llSetText(initmessage, <1,1,1>, 1); state default; } else { llInstantMessage(userkey,"Only valid administrators may control the JoomlaSL server!"); } } }