With SLX now charging for freebies (d-bags) I was thinking it would be nice to give items right from the web.  The first problem was many web pages limit the code you can put in to a page.  Next issue was keeping it simple so anyone can use it, and this is what I came up with the Web Freebie Giver. This is licensed under GPLv3, please click the link for the details, but basically you are free to use it as you wish, any changes need to be given back to the project.  The code is available at google code, or in world at Fermi Sandbox. If you wish to contribute to this project please contact Arthur Fermi.

WebFreebie Server (In-world)

Now on to how it works. First up is the in-world component as this is needed with the form or email methods.  I’m assuming you are have the packed set and have unpacked it.   Rez the server and open up the zFD_SLWF script, and it will say to the owner only the email address.  You can edit the script and put in your email address and it will email that same information it told you to the email address touching the prim will give the information again. The server in world checks its email every 5 seconds based on my observations its about 0.002ms of script time, so it is as close to lag free as you can get. After that you just need to drop in the objects you want to give.  It will not give scripts directly, you should package those up, and honestly your best bet is to package everything.  You will then need to make note of the exact name of each object in the server that you are giving out, you will need this for the form and the email link.
PHP Script used for the form (on the web server)

Now for the almost complicated part :)   We will discuss the form giver first as there are a few steps.   The form calls the calls a PHP script which is on your web site.  I would recommend putting the full URL to the script in the form since you might not know where your form is going to be on the web site.  The neat part of this is there is very little to configure in the PHP script and once it is configured it will work for any item you have in the server.

Enter the email address your server gives you on the recipient line, you can touch the server to get the email address.
$recipient = “7e8a8456-c866-8c83-7dc8-f236785f18c2@lsl.secondlife.com”;

You don’t have to set headers but I recommend it, I included it as some web hosts don’t allow email to be sent with out header information. The information is not used for anything on the SL side.
$headers = ‘From: myemail@mydomain.com’ . “\r\n” .
‘Reply-To: myemail@mydomain.com’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

The PHP file will display a simple page, the HTML code is just below the PHP script. It will display a screen saying the item was sent to the avatar name.

Form based deliver

This is an example of the form you would put on a web page, or in a post.  It will work pretty much anywhere so long as the page allows aHTML and forms.  Works fine in word press, and should work in most web software.

  1. <table border="0" style="width: 250px;">
  2. <tr valign="top">
  3. <td><strong>Fermi Vendor – 1 Item</strong></td>
  4. </tr>
  5. <tr valign="top">
  6. <td>
  7. <form action="webfreebie.php" method="post">Avatar Name: <input maxlength="50" name="avatar" size="20" />
  8. <input name="objname" type="hidden" value="Fermi Vendor – 1 Item" />
  9. <input name="deliver" type="submit" value="Deliver" /> </form></td>
  10. </tr>
  11. </table>
Fermi Vendor – 1 Item
Avatar Name:

  • Line 5 is where you give a descriptive name, it doesn’t do anything its just the title
  • Line 9 is the path to your webfreebie.php file, I recommend the full path to it for reliability
  • Line 11 is the name of the object to be delivers, it must be an exact match, including case.

That is all of the configuration of the form box that is required. I did not do any formating other than having the table to set things up, and bolding the title. You can easily make changes to this to match your web site. In the case of this site, it just used the styles already configured.

Give Via Email

This is the easiest way to do it, but I suspect it will prove more problematic from a support point of view. All it does is pop up a new email using the mailto: command that is part of HTML. When the new message email pops up it will fill in the email address and subject line and the person will type their name in the body and click send. I know sounds so easy, what is the catch? Well there are two different problems with this.

  1. The person uses web mail (yahoo, msn, gmail) and it opens outlook express, outlook or some other mail client which isn’t setup for email. Now yahoo and msn (now live mail) have apps that run and make this work ok, not sure about google. They would then have to copy the email address and subject to their web mail, then put their name in the body and away it goes.
  2. If they have any additional information in the body of the email, signature, some background formating, it will fail to parse the name. This could probably be fixed in the LSL code, but I’ll leave that for others.

Click for a Fermi Vendor – 1 Item. In the email body type in your avatars name. If you have web based email (yahoo, gmail, hotmail, etc.) this might open outlook express or outlook.

The code for the link looks like this <a href=”mailto:7e8a8456-c866-8c83-7dc8-f236785f18c2@lsl.secondlife.com?subject=Fermi Vendor – 1 Item”>Fermi Vendor – 1 Item</a>

To make this work all you have to do is change the mailto: to the email address of you server, then the subject to the name of the item you are giving, like before it has to match the object name in the box. Thats all there is to it, the rest is up to the person making the request.

Final Comments
I am sure there is ton’s more that could be done to make this better, but the goal was very simple, to provide a free and simple way to give an item in world from a web page. If you have any questions please address them in the forums where I have created a topic just for this, the google code page, or contact me in world!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • blogmarks
  • MySpace
  • PDF
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks