Jump to content

Search the Community

Showing results for tags 'html'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • People Forum
    • Your Avatar
    • Make Friends
    • Lifestyles and Relationships
    • Role Play
    • General Discussion Forum
    • Forums Feedback
    • Missed Connections
    • Second Life Education
  • Places and Events Forum
    • Favorite Destinations
    • Upcoming Events and Activities
    • Games in Second Life
  • Official Contests & Events
    • Leap Into Love Snapshot Contest
  • Creation Forum
    • Fashion
    • Art, Music and Photography
    • Animation Forum
    • Bakes on Mesh
    • Environmental Enhancement Project
    • Machinima Forum
    • Building and Texturing Forum
    • Mesh
    • LSL Scripting
    • LSL Library
    • Sansar for Second Life Residents
  • Technology Forum
    • Second Life Server
    • Second Life Viewer
    • Second Life Web
    • General Second Life Tech Discussion
  • Commerce Forum
    • Merchants
    • Inworld Employment
    • Wanted
  • Land Forum
    • General Discussion
    • Mainland
    • Linden Homes
    • Regions for Sale: Full Private Island
    • Region for Rent: Full Private Island
    • Regions for Sale: Homesteads
    • Region Rentals: Homestead
    • Parcels for Sale: Mainland
    • Parcels for Rent: Mainland
    • Wanted: Full Private Island
    • Wanted: Homesteads
    • Wanted: Mainland
  • International Forum
    • Deutsches Forum
    • Foro en español
    • Forum in italiano
    • Forum français
    • 日本語フォーラム
    • 한국어 포럼
    • Fórum em português
    • Forum polskie
    • المنتدى العربي
    • Türkçe Forum
    • Форум по-русски
  • Adult Content Forum
    • Highlight Upcoming Events
    • General Discussion
    • General Announcements
  • Answers
    • Abuse and Griefing
    • Account
    • Avatar
    • Creation
    • Inventory
    • Getting Started
    • Controls
    • Land
    • Linden Dollars (L$)
    • Shopping
    • Technical
    • Viewers
    • Everything Else
    • International Answers

Blogs

  • Commerce
  • Featured News
  • Inworld
  • Tools and Technology
  • Tips and Tricks
  • Land

Categories

  • English
  • Deutsch
  • Français
  • Español
  • Português
  • 日本語
  • Italiano
  • Pусский
  • Türkçe

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me

Found 4 results

  1. I am putting this concrete example for an LSL http server up here as a reaction to a forum thread: I have changed an existing script of mine as a proof of concept in order to provide a concrete example how an http bridge could work in this concrete use case. When I learned to script http servers and how to send a php message to an object in Second Life, I found it very tiresome. I have not found one single working concrete example, only code snippets. There are also almost no detailed example how to use the method "POST" with an html request, most use "GET". It was especially hard for me to get my head around the PHP side of things as I had never used php before. (Disclaimer: I have not yet tested these scripts, there might be a showstopping bug somewhere. Also my PHP scripts are very basic. As far as I know they are safe to be used in the presented use case as no one can change the data sent to your SQL database. But in different use cases malicious code could be injected to your database.) A. Let's start with the SQL database and create a table for storing the URL of our server (a scripted object in Second Life): CREATE TABLE SERVERURL ( Instance int, ObjectName varchar(255), ObjectKey varchar(36), URL varchar(255), ); B. Here is the LSL script for the server prim: It does 3 things: (1) Request an URL; (2) It sends the latest URL via a PHP script (see C.) to the SQL database table SERVERURL (see A.); (3) If a client terminal sends a http request to the the server prim, it will send all containing notecards to the clients: string objectName; string objectKey; string url; key requestKey; setup(){ objectName = llGetObjectName(); objectKey = llGetKey(); llRequestURL();} default { state_entry() { setup(); llSetText("Server: Loading", <1.0, 1.0, 1.0>, 1.0); } on_rez(integer n) { setup(); } changed(integer c) { if ((c & ((CHANGED_REGION | CHANGED_REGION_START) | CHANGED_TELEPORT))) { setup(); } } http_request(key id,string method,string body) { /////////////////////////////////////////////////////// //Below we receive the answer for our URL-request. This URL will later be used by the terminals to request the notecards. if ((method == URL_REQUEST_GRANTED)) { url = body; llSay(0, "I received a new URL: " + url); llSetText("Server: Online", <1.0, 1.0, 1.0>, 1.0); //Sending the received URL and other information to SQL database/////////// //Packing info// string URL = "http://your-database-address.com/myURL.php"; list parameters = [HTTP_METHOD,"POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"]; string bodySend = "objectName="+ objectName+"&objectKey="+objectKey+"&Newurl="+url; //End packing information// //send the info requestKey = llHTTPRequest(URL, parameters,bodySend); //llOwnerSay("Debugging: Sending the following information to DB: " + bodySend; //End of sending information to database///////////////// } else if ((method == URL_REQUEST_DENIED)) { llOwnerSay("Something went wrong, no url. " + body); llSetText("Server: Offline", <1.0, 1.0, 1.0>, 1.0); //End of code block for receiving and sending an URL ///////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //The incoming requests of the terminals, to receive notecards will arrive here: } else if ((method == "POST")) { //llOwnerSay("Debugging: I received a message from '" + (string)id + "': " + body); /* I use the following code block if the script receives several information packets in the body of one html request. The information packets are seperated by '&'. As there is only one information sent for the purpouse of this example, it is not needed here. list temp = llParseString2List(body,["&"],[]); string msg1 = llList2String(temp,0); string msg2 = llList2String(temp,1); string msg3 = llList2String(temp,2); */ if (body == "sendmeNotecard") { //llOwnerSay("Debugging: Message 'sendmeNotecard' received."); integer z = llGetInventoryNumber( INVENTORY_NOTECARD ); integer f = (z-1); if (z == 0) { //The server prim does not contain notecards and sends this information to the client terminal llHTTPResponse(id,200,("msg received, server has no NC")); } else if (z > 0) { //The server prim contains z notecards and sends the information to the client terminal that it will receive them. llHTTPResponse(id,200,("The server will now send " + (string)z + " Notecards.")); //Sending z notecards in a loop. integer p; for (p=1;p<=z;p++) { llGiveInventory( id, llGetInventoryName(INVENTORY_NOTECARD, f) ); f +=1; } } } else { //The client terminal or another prim has sent an message to the URL that is different to "sendmeNotecard". llOwnerSay("Debugging : unexpected php message: " + body); llHTTPResponse(id,200,("The server received an unexpected message.")); } } else { llHTTPResponse(id,405,"Method unsupported"); llOwnerSay("Debugging: Method for http_request unsupported"); } } http_response( key request_id, integer status, list metadata, string body ) { // The PHP script will send its response here after it has processed the new URL. if (request_id == requestKey) { llOwnerSay("Debugging: The http_response from the database when registering the url is:" + body); } } } C. This PHP script creates a new entry or sends an update of the URL to the SQL table: <?php //You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE" $con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); //you need to exit the script, if there is an error exit(); } //Set the variables (with incoming information) //Disclaimer: Depending on the use case, this is not a safe method to secure incoming variables from injection $objectName = mysqli_real_escape_string($con, $_POST['objectName']); $objectKey = mysqli_real_escape_string($con, $_POST['objectKey']); $Newurl = mysqli_real_escape_string($con, $_POST['Newurl']); //The following function checks if the object has already been entered in the database table $query = mysqli_query($con,"SELECT * FROM SERVERURL WHERE ObjectName = '$objectName'"); $row_cnt = mysqli_num_rows($query); //Counts the entries: if ($row_cnt == 0) //the object has not been registered in the table so far { //we now create an entry for the object details and the URL $sql="INSERT INTO SERVERURL (ObjectName, ObjectKey, URL) VALUES ('$objectName','$objectKey','$Newurl')"; if (mysqli_query($con, $sql)) { echo "DNS record created."; } else { echo "Error creating DNS record: " . mysqli_error($con); } } else //the object has already been registered in the table, so we only need to update the URL { $query1 = mysqli_query($con, "UPDATE SERVERURL SET URL = '$Newurl', ObjectKey = '$objectKey' WHERE ObjectName = '$objectName' " ); //Response to the server prim. If "0" rows in the database are affected, something has gone wrong... echo "Affected rows: " . mysqli_affected_rows($con); } //close connection to database mysqli_close($con); ?> D. Now that the URL of the server prim is stored in the database the LSL script of the client terminals can (1) ask the database for the URL (see E.) and (2) send a request for the notecards to the server prim: string serverURL; string serverName = "Put the object name of your server here."; key requestKey; key requestKey1; default { state_entry() { llSay(0, "Hello, my friend!"); } touch_start(integer total_number) { //Asking for Server URL at database/////////// //Packing info// string URL = "http://your-database-address.com/getURL.php"; list parameters = [HTTP_METHOD,"POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"]; string bodySend = serverName; //End packing info// //send the request requestKey = llHTTPRequest(URL, parameters,bodySend); //llOwnerSay("Debugging: Send html-request" + (string)URL + (string)hudName); //End of asking for Server URL///////////////// } http_response( key request_id, integer status, list metadata, string body ) { if (request_id == requestKey) { serverURL = body; //llOwnerSay("Debugging: The database gave the following URL for the server prim: " + body + "."); //////////Sending html_request to server prim////////// //Packing info// string URL = serverURL; list parameters = [HTTP_METHOD,"POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"]; string bodySend = "sendmeNotecard"; //End packing info// //send the request// requestKey1 = llHTTPRequest(URL, parameters,bodySend); //llOwnerSay("Debugging: Send html-request" + (string)URL + bodySend); //////////End sending html_request to server//////// } if (request_id == requestKey1) if (body == "msg received, server has no NC") { llOwnerSay("The server has no new notecards."); } else if (body == "The server received an unexpected message.") { llOwnerSay("An error has occured in the communication with the server."); } else { llOwnerSay(body); //the server prim will now send notecards. } } } E. The terminals send their request for the server URL via this php script to the database: <?php //You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE" $con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); //you need to exit the script, if there is an error exit(); } //Set the variables (with incoming data); Disclaimer: For other use cases, this not a secure method against injection. $objectName = mysqli_real_escape_string($con, $_POST['objectName']); //With this function we select the URL for the prim server with the specific object name frotm the database $sql = "SELECT URL FROM SERVERURL WHERE ObjectName = '$objectName' "; $query=mysqli_query($con,$sql); //Fetch the URL from the returned information array while($output = mysqli_fetch_array( $query )) { // send the selected URL in the returned body to the terminal echo $output['URL']; } //close connection to database mysqli_close($con); ?> That's it. A rather basic http server - terminal script environment.
  2. Hi all. I sent the following issue to the Lindens in a ticket. They replied and made a lot of effort to try and solve my problem, but in the end they couldn't solve it and suggested I re-post my issue to the forums. Sorry for the long post. Any guidance hugely appreciated ? ----------------------------------------------------------------- For the last couple of years my students have been using a HUD (see above) I designed to allow chatted text in Chinese characters output by the NPCs in our region to display on a prim face using the following: html = "data:text/html;charset=utf-8," + llEscapeURL(html); llSetPrimMediaParams(0, // Side to display the media on. [ PRIM_MEDIA_AUTO_PLAY,TRUE, // Show this page immediately PRIM_MEDIA_CURRENT_URL,html, // The url currently showing PRIM_MEDIA_HOME_URL,html, // The url if they hit 'home' PRIM_MEDIA_HEIGHT_PIXELS,100, // Height/width of media texture will be //512 PRIM_MEDIA_WIDTH_PIXELS,220]); // rounded up to nearest power of 2.} Up until I installed the latest version of Firestorm (5.1.7 (55786)) yesterday, the prim face was always white, so the text displayed clearly on the HUD. From yesterday, the prim face turns very dark (see attached photos) as soon as the text is sent to the prim face (via llListen). The Chinese character text can still be read, but it is very hard as the prim face is so dark. I did contact the Firestorm help group and they suggested I try the latest SL viewer, which I did. The result was the same as for the Firestorm viewer. They suggested that if this is the case I should contact you to see if you might be able to give me any leads as to what might be suddenly causing this problem. My students will be starting lessons in the next week and I am really concerned that this problem is going to make it difficult for them to complete the tasks set. Any guidance would be hugely appreciated. If you would like to obtain a copy of the HUD (Chinese Island HUD KV21 (WEAR OR ATTACH)) for testing, one can be obtained at the following location by clicking the red sign "Chinese Island HUD": http://maps.secondlife.com/secondlife/Monash%20University%202/116/194/26 To get the NPC there to say something to you, please input the following into chat: /3 你好 This will cause him to respond with 您好. Once again, any guidance you can offer would be hugely appreciated. Thank you! Kaylee
  3. Are you a Second Life hobbyist with a real life technology job that wants to give back in a meaningful way to empower women in the real world through a Seocnd Life venue? Are you fluent in Node, React, or another major commercial web software language, framework, or system? Do you have experience building websites with WordPress? Then you might be a candidate to apply as an instructor at the new Ada Technology and Education Center for women. At this location, we will provide paid courses that our customers have purchased to grow their skills in front and back end website development. Instructors will be paid the same price per class by Ada, regardless of the number of students, and are expected to have a short text outline of each class before teaching it. Each class must contain a complete website project students can creating using free and open source tools on the web. Instructors and all students will have access to our portal for saving class information and distributing other information after class. Payment per class is negotiable. To apply, IM "Lada Charlton" in-world, or visit the Ada Land Offices to drop a notecard with your application and contact information at our "JOBS" board. JOBS Board and notecard drop box: http://maps.secondlife.com/secondlife/Moonstar/217/114/23 Thank you!
  4. I have been tinkering with putting HTML on a prim's face. I was wondering if there is a way to make 'links' that would affect the game itself - as if the link triggered a 'touch_start' or 'listen' event. In-case it is unclear what I mean by putting HTML on a prim, here is a sample from the WIKI. ((The below script places "HTML stuff here!" on a face of a prim.)) string htmlstuff = "HTML"; string moreHTML = " stuff here!"; string usedHTML; default { state_entry() { usedHTML = htmlstuff + moreHTML; llRequestURL(); } http_request(key id, string method, string body) { if (method == URL_REQUEST_GRANTED) { llSay(0,"URL: " + body); } else if (method == "GET") { llHTTPResponse(id,200,usedHTML); } } }
×
×
  • Create New...