At any rate, I first posted my questions and then posted what I have, if anyone has the time and the patients, I would be very appreciative of any guidance. Of course, by posting this and fixing it, I am hoping others will benefit from the code as I will post the final product. I know there are a lot of joomla sites out there.I think the script and php are pretty solid, here is what I don't know what to do:
1) In the php, I don't know how to querry the table jos_users to see if the user already exists. If so, I want to send a message back into second life stating that (you will see an example message in the script). If the user doesn't exist, I want to go ahead and complete the registration.
2) I don't know how to work with http response, so I need to add the proper code in the php and in the script. The two choices are in the script - 1) they are already registered and the object tells them that or 2) give the registration information.
3) If someone could double check the script to make sure it is clean.
4) if there are any security measures I should add, that would be cool.
Script (with personal information removed)
[begin script code]
key http_request_id;
default
{
state_entry()
{
string name;
string uuid;
string eemail;
string pass;
string born;
string payment;
name = llRequestAgentData( Avatar, DATA_NAME);
uuid = llDetectedKey(0);
integer randChan = (integer)(llFrand(831)+123);
eemail = llDetectedKey(0)+"@lsl.secondlife.com";
pass = (string)randChan;
born = llRequestAgentData( llDetectedKey(0), DATA_BORN);
payment = llRequestAgentData( llDetectedKey(0), DATA_PAYINFO);
llInstantMessage(llDetectedKey(0), pass)
{
http_request_id = llHTTPRequest( "http://url.com/register.php", [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"], "name=" + name + "&pass=" + pass + "&eemail=" + eemail + "&uuid=" + uuid + "&born=" + born + "&payment=" + payment);
}
http_response(key id, integer status, list meta, string body) {
if ( body == 0 )
llInstantMessage(llDetectedKey(0), "You are already registered at url. If you feel this is an error, or have forgotten your login information, please contact us at [email]email@url.com[/email]."
;else
llInstantMessage(llDetectedKey(0), "Your Login name is your Second Life Name, " + name + ". Your password is in your 'Local Chat.' Simply press control-h or open your 'Local Chat' and log in to url"
;}
}
[/end script code]
[begin php]
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$hostname='xxxxxxxxx';
$username='xxxxxx';
$password='xxxxxx';
$dbname='xxxxxxxx';
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$headers = apache_request_headers();
$objectName = $headers["X-SecondLife-Object-Name"];
$objectKey = $headers["X-SecondLife-Object-Key"];
$ownerKey = $headers["X-SecondLife-Owner-Key"];
$ownerName = $headers["X-SecondLife-Owner-Name"];
$region = $headers["X-SecondLife-Region"];
$slVersion = $headers["User-Agent "];
$simPosition = $headers["X-SecondLife-Local-Position"];
$user = $_POST["user"]
$uuid = $_POST["uuid"]
$pass = $_POST["pass"]
$born = $_POST["born"]
$payment = $_POST["payment"]
$eemail = $_POST["eemail"]
$salt = pass(16);
$crypt = md5($newpass.$salt);
$newpass = $crypt.':'.$salt;
$query =
$query = "INSERT INTO `table1` (`name`, `username`, `password`, `usertype`, 'gid', 'params') VALUES ('".$user."', '".$user."', '".$newpass."','Registered','18','language=en-GB')";
$lastid = mysql_insert_id;
$query = "INSERT INTO `table2` (`id`, `user_id`, `cb_uuid`, `cb_lslemail`, 'cb_born', 'cb_paymentinfo') VALUES ('".$lastid."', '".$lastid."', '".$uuid."','".$eemail."','".$born."','".$payment."')";
$query = "INSERT INTO `table3` (`value`, `name`) VALUES ('".$lastid."', '".$name."')";
$lastid2 = mysql_insert_id;
$query = "INSERT INTO `table4` (`group_id`, `aro_id`) VALUES ('18', '".$lastid2."')";
$query = "INSERT INTO `table4` (`uuid`, `name`,'objectkey','objectregion') VALUES ('".$uuid."', '".$name."', '".$objectKey."', '".$region."')";
mysql_query($query) or die(mysql_error());
mysql_close();
?>
[/end php]
Thanks again in advance.
Web