02-18-2013, 03:38 AM
Details
This is a great product for you if you are interested in putting up a new feature on your site. This is some of the newest technology on the market. The Inworld server not only has a great design but virtually no lag! This system is also quite easy to setup, it has only 6 steps.
Features
Includes PHP Script
Includes InWorld Server
Full Perms
Professionally Designed
Server.lsl
PHP Code:
// XML Proceed for IM
//
key gChannel; // my llRemoteData channel
key requestid;
string BASE_URL="http://www.renevanasten.net"; // fill in the root of your site
default
{ // initialize XML-RPC
state_entry()
{
llOpenRemoteDataChannel(); // create an XML-RPC channel
// this will raise remote_data event REMOTE_DATA_CHANNEL when created
}
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_CHANNEL) { // channel created
gChannel = channel;
llOwnerSay("Server's Channel: \"" + (string)channel + "\"\nCopy/paste >> " + (string)channel + " << to the php file (SendIM.php), before uploading it to your webserver. ");
state go; // start handling requests
}
}
}
state go
{ // handle requests
remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
{
if (type == REMOTE_DATA_REQUEST) { // handle requests sent to us
if (ival==1)
{
list PARS;
PARS = llParseString2List(sval, ["|"], []);
string response_from = (string)llList2String(PARS, 0);
string response_key = (string)llList2Key(PARS, 1);
string response_text = llList2String(PARS, 2);
llOwnerSay(sval);
llInstantMessage(response_key, "Message received from website "+ BASE_URL +"\nSend by *" + response_from + "* : " + response_text);
llRemoteDataReply(channel, message_id, "", 0);
}
}
}
state_exit()
{
llCloseRemoteDataChannel(gChannel); // clean up when you no longer want to handle requests
}
on_rez(integer start_param)
{
// Restarts the script every time the object is rezzed
llResetScript();
}
}
sendIM.php
PHP Code:
<?php
if ($_GET[aktion]=="send") {
// Fill in channel that server gave after rezzing it inworld.
//
$channel = "fbb43a21-bd9c-8c68-a9c2-5226bfda73d5";
$xmldata = "<?xml version=\"1.0\"?>
<methodCall>
<methodName>llRemoteData</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>Channel</name>
<value><string>".$channel."</string></value>
</member>
<member>
<name>IntValue</name>
<value><int>1</int></value>
</member>
<member>
<name>StringValue</name>
<value><string>$_POST[FROM]|$_POST[KEY]|$_POST[TEXT]</string></value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
";
sendToHost("xmlrpc.secondlife.com", "POST", "/cgi-bin/xmlrpc.cgi", $xmldata);
}
echo "<table>";
echo "<tr>";
echo "<form method='POST' action='$_SERVER[PHP_SELF]?aktion=send'>";
echo "<td><b>From Avatar</b></td>";
echo "<td><b>Your Friend's Key</b></td>";
echo "<td><b>Text</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td><input type='text' name='FROM' value='$_POST[FROM]' size=30></td>";
echo "<td><input type='text' name='KEY' value='$_POST[KEY]' size=40></td>";
echo "<td><input type='text' name='TEXT' size=79></td>";
echo "</tr>";
echo "<tr>";
echo "<td><input type='submit' value='Send IM'></td>";
echo "</tr>";
echo "</table>";
function sendToHost($host,$method,$path,$data,$useragent=0)
{
$buf="";
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if( !$fp )
{
$buf = "$errstr ($errno)<br />\n";
}else
{
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: text/xml\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\r\n");
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
}
return $buf;
}
?>
Readme.txt
PHP Code:
**********************************************************
Send an Instant message to a friend / avatar, straight from your website !
**********************************************************
Within a few steps you are ready to use your new website feature,
your website visitors are able to send Im's straight from your website inworld !
What to do ?
1) Rez the object called: Server.
The Server will say it's channel. Copy this channel.
2) Inside the Server (object), there is a script called: Server.
Open the script and change line number 3.
Example: string BASE_URL="http://www.renevanasten.net"; // fill in the root of your site
3) Open the notecard SendIM.php
Change line number 5.
Example: $channel = "fbb43a21-bd9c-8c68-a9c2-5226bfda73d5";
4) Copy the notecard SendIM.php and create a php file of it.
(example: copy/paste in notepad(texteditor), then save as SendIM.php)
5) Upload the created php file SendIM.php to your website.
Now browse to your websites new feature >> http://www.yoursite.com/SendIM.php
6) You are ready to use your new website feature ! Remember to leave the server rezzed inworld.
After rerezzing the server, the channel changes too, so then you need to re-edit your SendIM.php.