Jump to content
shymus Roffo

HTTP Name2Key Server w/ LSL

Recommended Posts

Now with the new functions that were released onto the Wiki, a lot of my web servers used a Name2Key service(Such as W-Hat, or similar). One problem we were having is some services are not 100% reliable. Every now and then, we had NULL_KEYs returned. These scripts we made; we used as a backup when the online services were not working or did not produce the desired result.

This is not meant to be used as an alternative to Name2Key with LSL scripts, it is used for websites that need Name2Key and are looking for a backup to their current Name2Key. This could obviously be expanded and is very basic. I would expand on this to allow multiple in-world servers in case of an outage and make it update to the prim's URLs into a database and not a text file.

Server Directory/Structure

| - .htaccess
| - index.php

Once your directory is set up on your server, here are the files!


RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?name=$1 [L,QSA]



if(!empty($_GET['name'])) {
	if($_GET['name'] == "update_url") {
		$fh = fopen("server_url.txt","w");
	} else {
		header("Content-Type: text/plain");
		$fh = fopen("server_url.txt","r");
		$url = fread($fh, filesize("server_url.txt"));
		$ch = curl_init($url);
		$data = curl_exec($ch);
		echo $data;

Now for the in-world scripts. This is meant to go into a single prim and be left to sit there.


string update_url = "http://WebsiteName.com/Name2Key/update_url&url=";
string url;
key urlRequestId;
key selfCheckRequestId;
key name_query;
key return_key;
request_url() {
    url = "";
    urlRequestId = llRequestURL();

throw_exception(string inputString) {
    llInstantMessage(llGetOwner(), inputString);

default {
    state_entry() { request_url(); }
    on_rez(integer start_param) { llResetScript(); }
    changed(integer change) {
    timer() {
        selfCheckRequestId = llHTTPRequest(url,[HTTP_METHOD, "GET",HTTP_VERBOSE_THROTTLE, FALSE,HTTP_BODY_MAXLENGTH, 16384],"");
    dataserver(key i, string d) {
        if(i == name_query) {
            if(d != NULL_KEY) {
            } else {
    http_request(key id, string method, string body) {
        integer responseStatus = 400;
        string responseBody = "Unsupported method";
        if (method == URL_REQUEST_DENIED)
            throw_exception("The following error occurred while attempting to get a free URL for this device:\n \n" + body);
        else if (method == URL_REQUEST_GRANTED) {
            url = body;
        else if (method == "GET") {
            llHTTPResponse(id, 400, "Unsupported Method");
        else if (method == "POST") {
            body = llBase64ToString(body);
            name_query = llRequestUserKey(body);
            return_key = id;
    http_response(key id, integer status, list metaData, string body) {
        if (id == selfCheckRequestId) {
            selfCheckRequestId = NULL_KEY;
            if (status != 200)
        else if (id == NULL_KEY)
            throw_exception("Too many HTTP requests too fast!");


As I said, this is not a "finished" product, as it still needs some upgrades. We highly recommend that you use it as a backup to other online Name2Key Services when you get a NULL_KEY. Hope this helps out other users!

Share this post

Link to post
Share on other sites

Yes, it is for an apache set up. It could be modified to work with other systems. I'm not that familiar with other languages or servers, so this is what I made it for. If anyone else makes the server code with a different language, let me know and I'll put it onto the thread.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...