Profile based on mysqli

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "__NOTOC__ {{Quicklinks}} The OpenProfileModule makes it possible to create your own Profile and see other peoples' Profiles as well.<br> This script is useing mysqli that replac...")
 
(STEP 2: profile.php)
Line 177: Line 177:
  
 
define("C_DB_HOST"      ,"localhost");  
 
define("C_DB_HOST"      ,"localhost");  
define("C_DB_DATABASE"  ,"userprofiles");  
+
define("C_DB_DATABASE"  ,"");  
define("C_DB_USER"      ,"profileuser");  
+
define("C_DB_USER"      ,"");  
define("C_DB_PASS"      ,"#pro4grd#");
+
define("C_DB_PASS"      ,"");  
define("C_DB_TABLE"    ,"offline");
+
 
   
 
   
 
$zeroUUID = "00000000-0000-0000-0000-000000000000";
 
$zeroUUID = "00000000-0000-0000-0000-000000000000";
Line 826: Line 825:
 
?>
 
?>
 
</source >
 
</source >
 
  
 
=== STEP 3: OpenProfileModule ===
 
=== STEP 3: OpenProfileModule ===

Revision as of 05:07, 27 March 2013

The OpenProfileModule makes it possible to create your own Profile and see other peoples' Profiles as well.
This script is useing mysqli that replace the deprecated mysql commands with PHP 5.5.0

Disclaimer

Please note that these are third party modules which you use at your own risk!
OpenSimulator takes no responsibility for these modules.

OpenProfileModule Configuration Steps

The OpenProfileModule is already compiled and ready for use in current versions of OpenSimulator.

However, you will need to setup the "back-end" database and PHP connector scripts to support the OpenProfileModule.

  1. Upload the profile.sql (below) to your database server
  2. Upload the profile.php (below) to your web server
  3. Enable the OpenProfileModule in your OpenSim.ini file

STEP 1: profile.sql

Save these SQL commands to a profile.sql file on your MySQL database server.

CREATE TABLE IF NOT EXISTS `profile_classifieds` 
(
 
`classifieduuid` char(36) NOT NULL,
  `creatoruuid` char(36) NOT NULL,
 
`creationdate` int(20) NOT NULL,
  `expirationdate` int(20) NOT NULL,
 
`category` varchar(20) NOT NULL,
  `name` varchar(255) NOT NULL,
 
`description` text NOT NULL,
  `parceluuid` char(36) NOT NULL,
 
`parentestate` int(11) NOT NULL,
  `snapshotuuid` char(36) NOT NULL,
 
`simname` varchar(255) NOT NULL,
  `posglobal` varchar(255) NOT NULL,
 
`parcelname` varchar(255) NOT NULL,
  `classifiedflags` int(8) NOT NULL,
 
`priceforlisting` int(5) NOT NULL,
  PRIMARY KEY (`classifieduuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 
 
CREATE TABLE IF NOT EXISTS `profile_notes` (
 
`useruuid` varchar(36) NOT NULL,
 
`targetuuid` varchar(36) NOT NULL,
 
`notes` text NOT NULL,
  UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`)
)
 ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 
 
CREATE TABLE IF NOT EXISTS `profile_picks` (
 
`pickuuid` varchar(36) NOT NULL,
  `creatoruuid` varchar(36) NOT NULL,
 
`toppick` enum('true','false') NOT NULL,
  `parceluuid` varchar(36) NOT NULL,
 
`name` varchar(255) NOT NULL,
 
`description` text NOT NULL,
 
`snapshotuuid` varchar(36) NOT NULL,
 
`user` varchar(255) NOT NULL,
 
`originalname` varchar(255) NOT NULL,
 
`simname` varchar(255) NOT NULL,
 
`posglobal` varchar(255) NOT NULL,
 
`sortorder` int(2) NOT NULL,
 
`enabled` enum('true','false') NOT NULL,
  PRIMARY KEY (`pickuuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 
 
CREATE TABLE IF NOT EXISTS `profile` (
 
`useruuid` varchar(36) NOT NULL,
 
`profilePartner` varchar(36) NOT NULL,
 
`profileAllowPublish` BINARY(1) NOT NULL,
 
`profileMaturePublish` BINARY(1) NOT NULL,
 
`profileURL` varchar(255) NOT NULL,
 
`profileWantToMask` int(3) NOT NULL,
 
`profileWantToText` text NOT NULL,
 
`profileSkillsMask` int(3) NOT NULL,
 
`profileSkillsText` text NOT NULL,
 
`profileLanguages` text NOT NULL,
 
`profileImage` varchar(36) NOT NULL,
 
`profileAboutText` text NOT NULL,
 
`profileFirstImage` varchar(36) NOT NULL,
 
`profileFirstText` text NOT NULL,
  PRIMARY KEY (`useruuid`)
) 
ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 
CREATE TABLE IF NOT EXISTS `profile_settings` (
 
`useruuid` varchar(36) NOT NULL,
 
`imviaemail` enum('true','false') NOT NULL,
 
`visible` enum('true','false') NOT NULL,
 
`email` varchar(254) NOT NULL,
  PRIMARY KEY (`useruuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Connect to your MySQL (Linux commands shown):

$ mysql --user=$mysqluser --password=$mysqlpassword $databasename

Replace $mysqluser, $mysqlpassword, and $databasename with your specific configuration.

At the mysql prompt, source the profile.sql file to configure your database to hold additional profile information:

mysql> source profile.sql
... ensure no error messages appear here ...
mysql> quit

STEP 2: profile.php

Copy this PHP script to a file called profile.php and edit the following parameters in the script.
C_DB_HOST, C_DB_DATABASE, C_DB_USER, C_DB_PASS, Add the required data between the ""

C_DB_HOST = the hostname of the server thats running mysql
C_DB_DATABASE = is the database where the profile tables are stored
C_DB_USER = database user you are useing for accesing the profile database
C_DB_PASS = user passwd that belongs to the use that you set in C_DB_USER
<?php
 
/* Script based on the code you can find at http://opensimulator.org/wiki/Profile */
 
define("C_DB_HOST"      ,"localhost"); 
define("C_DB_DATABASE"  ,""); 
define("C_DB_USER"      ,""); 
define("C_DB_PASS"      ,""); 
 
$zeroUUID = "00000000-0000-0000-0000-000000000000";
$xmlrpc_server = xmlrpc_server_create();
 
/*-------------------------*/ 
function openDB($dbHost,$dbUser,$dbPassword,$dbName)
{
    /*Open database*/
    $link = mysqli_connect($dbHost,$dbUser,$dbPassword,$dbName);
    if (!$link) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); exit; } 
    mysqli_set_charset($link, "utf8");
 
    return $link;
}
 
/*-------------------------*/ 
function closeDB($link)
{
    /*Close database*/
    mysqli_close($link); 
}
 
/*-------------------------*/ 
function avatarclassifiedsrequest($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['uuid'];
 
    $result = mysqli_query($link,"SELECT * FROM profile_classifieds WHERE ".
            "creatoruuid = '". mysqli_real_escape_string($link,$uuid) ."'");
 
    $data = array();
 
    while (($row = mysqli_fetch_assoc($result)))
    {
        $data[] = array(
                "classifiedid" => $row["classifieduuid"],
                "name" => $row["name"]);
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Classifieds Update */
function classified_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    global $zeroUUID;
    $req            = $params[0];
 
    $classifieduuid = $req['classifiedUUID'];
    $creator        = $req['creatorUUID'];
    $category       = $req['category'];
    $name           = $req['name'];
    $description    = $req['description'];
    $parceluuid     = $req['parcelUUID'];
    $parentestate   = $req['parentestate'];
    $snapshotuuid   = $req['snapshotUUID'];
    $simname        = $req['sim_name'];
    $globalpos      = $req['globalpos'];
    $parcelname     = $req['parcelname'];
    $classifiedflag = $req['classifiedFlags'];
    $priceforlist   = $req['classifiedPrice'];
 
    /* Check if we already have this one in the database */
    $check = mysqli_query($link,"SELECT COUNT(*) FROM profile_classifieds WHERE ".
            "classifieduuid = '". mysqli_real_escape_string($link,$classifieduuid) ."'");
 
    while ($row = mysqli_fetch_row($check))
    {
        $ready = $row[0];
    }
 
    if ($ready == 0)
    {
        /* Doing some late checking */
        /* Should be done by the module but let's see what happens when */
        /* I do it here */
 
        if($parcelname == "")
            $parcelname = "Unknown";
 
        if($parceluuid == "")
            $parceluuid = $zeroUUID;
 
        if($description == "")
            $description = "No Description";
 
        if($classifiedflag == 2)
        {
            $creationdate = time();
            $expirationdate = time() + (7 * 24 * 60 * 60);
        }
        else
        {
            $creationdate = time();
            $expirationdate = time() + (365 * 24 * 60 * 60);
        }
 
        $insertquery = "INSERT INTO profile_classifieds VALUES ".
            "('". mysqli_real_escape_string($link,$classifieduuid) ."',".
            "'". mysqli_real_escape_string($link,$creator) ."',".
            "". mysqli_real_escape_string($link,$creationdate) .",".
            "". mysqli_real_escape_string($link,$expirationdate) .",".
            "'". mysqli_real_escape_string($link,$category) ."',".
            "'". mysqli_real_escape_string($link,$name) ."',".
            "'". mysqli_real_escape_string($link,$description) ."',".
            "'". mysqli_real_escape_string($link,$parceluuid) ."',".
            "". mysqli_real_escape_string($link,$parentestate) .",".
            "'". mysqli_real_escape_string($link,$snapshotuuid) ."',".
            "'". mysqli_real_escape_string($link,$simname) ."',".
            "'". mysqli_real_escape_string($link,$globalpos) ."',".
            "'". mysqli_real_escape_string($link,$parcelname) ."',".
            "". mysqli_real_escape_string($link,$classifiedflag) .",".
            "". mysqli_real_escape_string($link,$priceforlist) .")";
 
        // Create a new record for this classified
        $result = mysqli_query($link,$insertquery);
    }
    else
    {
 
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Classifieds Delete */
function classified_delete($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
    $req            = $params[0];
 
    $classifieduuid = $req['classifiedID'];
 
    $result = mysqli_query($link,"DELETE FROM profile_classifieds WHERE ".
            "classifieduuid = '".mysqli_real_escape_string($link,$classifieduuid) ."'");
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Avatar Picks Request */
function avatarpicksrequest($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['uuid'];
    $data = array();
    $result = mysqli_query($link,"SELECT `pickuuid`,`name` FROM profile_picks WHERE ". "creatoruuid = '". mysqli_real_escape_string($link,$uuid) ."'");
 
    while (($row = mysqli_fetch_assoc($result)))
    {
        $data[] = array(
                "pickid" => $row["pickuuid"],
                "name" => $row["name"]);
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Request Picks for User */
function pickinforequest($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $pick           = $req['pick_id'];
 
    $data = array();
 
    $result = mysqli_query($link,"SELECT * FROM profile_picks WHERE ".
            "creatoruuid = '". mysqli_real_escape_string($link,$uuid) ."' AND ".
            "pickuuid = '". mysqli_real_escape_string($link,$pick) ."'");
 
    $row = mysqli_fetch_assoc($result);
    if ($row != False)
    {
        if ($row["description"] == null || $row["description"] == "")
            $row["description"] = "No description given";
 
        $data[] = array(
                "pickuuid" => $row["pickuuid"],
                "creatoruuid" => $row["creatoruuid"],
                "toppick" => $row["toppick"],
                "parceluuid" => $row["parceluuid"],
                "name" => $row["name"],
                "description" => $row["description"],
                "snapshotuuid" => $row["snapshotuuid"],
                "user" => $row["user"],
                "originalname" => $row["originalname"],
                "simname" => $row["simname"],
                "posglobal" => $row["posglobal"],
                "sortorder"=> $row["sortorder"],
                "enabled" => $row["enabled"]);
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Picks Update */
function picks_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    global $zeroUUID;
    $req            = $params[0];
 
    $pickuuid       = $req['pick_id'];
    $creator        = $req['creator_id'];
    $toppick        = $req['top_pick'];
    $name           = $req['name'];
    $description    = $req['desc'];
    $parceluuid     = $req['parcel_uuid'];
    $snapshotuuid   = $req['snapshot_id'];
    $user           = $req['user'];
    $simname        = $req['sim_name'];
    $posglobal      = $req['pos_global'];
    $sortorder      = $req['sort_order'];
    $enabled        = $req['enabled'];
 
    if($parceluuid == "")
        $parceluuid = $zeroUUID;
 
    if($description == "")
        $description = "No Description";
 
    /* Check if we already have this one in the database */
    $check = mysqli_query($link,"SELECT COUNT(*) FROM profile_picks WHERE ".
            "pickuuid = '". mysqli_real_escape_string($link,$pickuuid) ."'");
 
    $row = mysqli_fetch_row($check);
 
    if ($row[0] == 0)
    {
        if($user == null || $user == "")
            $user = "Unknown";
 
        /* The original parcel name is the same as the name of the */
        /* profile pick when a new profile pick is being created. */
        $original = $name;
 
        $query = "INSERT INTO profile_picks VALUES ".
            "('". mysqli_real_escape_string($link,$pickuuid) ."',".
            "'". mysqli_real_escape_string($link,$creator) ."',".
            "'". mysqli_real_escape_string($link,$toppick) ."',".
            "'". mysqli_real_escape_string($link,$parceluuid) ."',".
            "'". mysqli_real_escape_string($link,$name) ."',".
            "'". mysqli_real_escape_string($link,$description) ."',".
            "'". mysqli_real_escape_string($link,$snapshotuuid) ."',".
            "'". mysqli_real_escape_string($link,$user) ."',".
            "'". mysqli_real_escape_string($link,$original) ."',".
            "'". mysqli_real_escape_string($link,$simname) ."',".
            "'". mysqli_real_escape_string($link,$posglobal) ."',".
            "'". mysqli_real_escape_string($link,$sortorder) ."',".
            "'". mysqli_real_escape_string($link,$enabled) ."')";
    }
    else
    {
        $query = "UPDATE profile_picks SET " .
            "parceluuid = '". mysqli_real_escape_string($link,$parceluuid) . "', " .
            "name = '". mysqli_real_escape_string($link,$name) . "', " .
            "description = '". mysqli_real_escape_string($link,$description) . "', " .
            "snapshotuuid = '". mysqli_real_escape_string($link,$snapshotuuid) . "' WHERE ".
            "pickuuid = '". mysqli_real_escape_string($link,$pickuuid) ."'";
    }
 
    $result = mysqli_query($link,$query);
    if ($result != False)
        $result = True;
 
    $response_xml = xmlrpc_encode(array(
        'success' => $result,
        'errorMessage' => mysqli_error($link)
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Picks Delete */
function picks_delete($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $pickuuid       = $req['pick_id'];
 
    $result = mysqli_query($link,"DELETE FROM profile_picks WHERE ".
            "pickuuid = '".mysqli_real_escape_string($link,$pickuuid) ."'");
 
    if ($result != False)
        $result = True;
 
    $response_xml = xmlrpc_encode(array(
        'success' => $result,
        'errorMessage' => mysqli_error($link)
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Avatar Notes Request */
function avatarnotesrequest($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $targetuuid     = $req['uuid'];
 
    $result = mysqli_query($link,"SELECT notes FROM profile_notes WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."' AND ".
            "targetuuid = '". mysqli_real_escape_string($link,$targetuuid) ."'");
 
    $row = mysqli_fetch_row($result);
    if ($row == False)
        $notes = "";
    else
        $notes = $row[0];
 
    $data[] = array(
            "targetid" => $targetuuid,
            "notes" => $notes);
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Avatar Notes Update */
function avatar_notes_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $targetuuid     = $req['target_id'];
    $notes          = $req['notes'];
 
    /* Check if we already have this one in the database */
    $check = mysqli_query($link,"SELECT COUNT(*) FROM profile_notes WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."' AND ".
            "targetuuid = '". mysqli_real_escape_string($link,$targetuuid) ."'");
 
    $row = mysqli_fetch_row($check);
 
    if ($row[0] == 0)
    {
        /* Create a new record for this avatar note */
        $result = mysqli_query($link,"INSERT INTO profile_notes VALUES ".
            "('". mysqli_real_escape_string($link,$uuid) ."',".
            "'". mysqli_real_escape_string($link,$targetuuid) ."',".
            "'". mysqli_real_escape_string($link,$notes) ."')");
    }
    else if ($notes == "")
    {
        /* Delete the record for this avatar note */
        $result = mysqli_query($link,"DELETE FROM profile_notes WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."' AND ".
            "targetuuid = '". mysqli_real_escape_string($link,$targetuuid) ."'");
    }
    else
    {
        /* Update the existing record */
        $result = mysqli_query($link,"UPDATE profile_notes SET ".
            "notes = '". mysqli_real_escape_string($link,$notes) ."' WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."' AND ".
            "targetuuid = '". mysqli_real_escape_string($link,$targetuuid) ."'");
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => $result,
        'errorMessage' => mysqli_error($link)
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Profile bits */ 
function avatar_properties_request($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    global $zeroUUID;
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
 
    $result = mysqli_query($link,"SELECT * FROM profile WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."'");
    $row = mysqli_fetch_assoc($result);
 
    if ($row != False)
    {
        $data[] = array(
                "ProfileUrl" => $row["profileURL"],
                "Image" => $row["profileImage"],
                "AboutText" => $row["profileAboutText"],
                "FirstLifeImage" => $row["profileFirstImage"],
                "FirstLifeAboutText" => $row["profileFirstText"],
                "Partner" => $row["profilePartner"],
 
                //Return interest data along with avatar properties
                "wantmask"   => $row["profileWantToMask"],
                "wanttext"   => $row["profileWantToText"],
                "skillsmask" => $row["profileSkillsMask"],
                "skillstext" => $row["profileSkillsText"],
                "languages"  => $row["profileLanguages"]);
    }
    else
    {
        //Insert empty record for avatar.
        //FIXME: Should this only be done when asking for ones own profile?
        $sql = "INSERT INTO profile VALUES ( ".
                "'". mysqli_real_escape_string($link,$uuid) ."', ".
                "'$zeroUUID', 0, 0, '', 0, '', 0, '', '', ".
                "'$zeroUUID', '', '$zeroUUID', '')";
        $result = mysqli_query($link,$sql);
 
        $data[] = array(
                "ProfileUrl" => "",
                "Image" => $zeroUUID,
                "AboutText" => "",
                "FirstLifeImage" => $zeroUUID,
                "FirstLifeAboutText" => "",
                "Partner" => $zeroUUID,
 
                "wantmask"   => 0,
                "wanttext"   => "",
                "skillsmask" => 0,
                "skillstext" => "",
                "languages"  => "");
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
function avatar_properties_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $profileURL     = $req['ProfileUrl'];
    $image          = $req['Image'];
    $abouttext      = $req['AboutText'];
    $firstlifeimage = $req['FirstLifeImage'];
    $firstlifetext  = $req['FirstLifeAboutText'];
 
    $result=mysqli_query($link,"UPDATE profile SET ".
            "profileURL='". mysqli_real_escape_string($link,$profileURL) ."', ".
            "profileImage='". mysqli_real_escape_string($link,$image) ."', ".
            "profileAboutText='". mysqli_real_escape_string($link,$abouttext) ."', ".
            "profileFirstImage='". mysqli_real_escape_string($link,$firstlifeimage) ."', ".
            "profileFirstText='". mysqli_real_escape_string($link,$firstlifetext) ."' ".
            "WHERE useruuid='". mysqli_real_escape_string($link,$uuid) ."'"
        );
 
    $response_xml = xmlrpc_encode(array(
        'success' => $result,
        'errorMessage' => mysqli_error($link)
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
/* Profile Interests */
function avatar_interests_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $wanttext       = $req['wanttext'];
    $wantmask       = $req['wantmask'];
    $skillstext     = $req['skillstext'];
    $skillsmask     = $req['skillsmask'];
    $languages      = $req['languages'];
 
    $result = mysqli_query($link,"UPDATE profile SET ".
            "profileWantToMask = ". mysqli_real_escape_string($link,$wantmask) .",".
            "profileWantToText = '". mysqli_real_escape_string($link,$wanttext) ."',".
            "profileSkillsMask = ". mysqli_real_escape_string($link,$skillsmask) .",".
            "profileSkillsText = '". mysqli_real_escape_string($link,$skillstext) ."',".
            "profileLanguages = '". mysqli_real_escape_string($link,$languages) ."' ".
            "WHERE useruuid = '". mysqli_real_escape_string($link,$uuid) ."'"
        );
 
    $response_xml = xmlrpc_encode(array(
        'success' => True
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/
/* User Preferences */
function user_preferences_request($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
 
    $result = mysqli_query($link,"SELECT imviaemail,visible,email FROM profile_settings WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."'");
 
    $row = mysqli_fetch_assoc($result);
 
    if ($row != False)
    {
        $data[] = array(
                "imviaemail" => $row["imviaemail"],
                "visible" => $row["visible"],
                "email" => $row["email"]);
    }
    else
    {
        //Insert empty record for avatar.
        //NOTE: The 'false' values here are enums defined in database
        $sql = "INSERT INTO profile_settings VALUES ".
                "('". mysqli_real_escape_string($link,$uuid) ."', ".
                "'false', 'false', '')";
        $result = mysqli_query($link,$sql);
 
        $data[] = array(
                "imviaemail" => False,
                "visible" => False,
                "email" => "");
    }
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/ 
function user_preferences_update($method_name, $params, $app_data)
{
    $link=$link=openDB(C_DB_HOST, C_DB_USER, C_DB_PASS, C_DB_DATABASE);    
 
    $req            = $params[0];
    $uuid           = $req['avatar_id'];
    $wantim         = $req['imViaEmail'];
    $directory      = $req['visible'];
 
    $result = mysqli_query($link,"UPDATE profile_settings SET ".
            "imviaemail = '".mysqli_real_escape_string($link,$wantim) ."', ".
            "visible = '".mysqli_real_escape_string($link,$directory) ."' WHERE ".
            "useruuid = '". mysqli_real_escape_string($link,$uuid) ."'");
 
    $response_xml = xmlrpc_encode(array(
        'success' => True,
        'data' => $data
    ));
 
    print $response_xml;
    closeDB($link);
}
 
/*-------------------------*/
xmlrpc_server_register_method($xmlrpc_server, "avatarclassifiedsrequest","avatarclassifiedsrequest");       
xmlrpc_server_register_method($xmlrpc_server, "classified_update","classified_update");             
xmlrpc_server_register_method($xmlrpc_server, "classified_delete","classified_delete");        
xmlrpc_server_register_method($xmlrpc_server, "avatarpicksrequest", "avatarpicksrequest");               
xmlrpc_server_register_method($xmlrpc_server, "pickinforequest","pickinforequest");               
xmlrpc_server_register_method($xmlrpc_server, "picks_update","picks_update");              
xmlrpc_server_register_method($xmlrpc_server, "picks_delete","picks_delete");                
xmlrpc_server_register_method($xmlrpc_server, "avatarnotesrequest","avatarnotesrequest");               
xmlrpc_server_register_method($xmlrpc_server, "avatar_notes_update", "avatar_notes_update");        
xmlrpc_server_register_method($xmlrpc_server, "avatar_properties_request","avatar_properties_request");        
xmlrpc_server_register_method($xmlrpc_server, "avatar_properties_update","avatar_properties_update");        
xmlrpc_server_register_method($xmlrpc_server, "avatar_interests_update","avatar_interests_update");                   
xmlrpc_server_register_method($xmlrpc_server, "user_preferences_request","user_preferences_request");        
xmlrpc_server_register_method($xmlrpc_server, "user_preferences_update","user_preferences_update");
 
/* Process the request */ 
$request_xml = $HTTP_RAW_POST_DATA;
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
xmlrpc_server_destroy($xmlrpc_server);
?>

STEP 3: OpenProfileModule

Shutdown your simulator.

Edit the OpenSim.ini [Profile] block.

An example configuration is shown below:

[Profile]
    Module = "OpenProfileModule"
    ProfileURL = "http://yourwebserverdomainname/pathto/profile.php"

Once the edits are made, save your OpenSim.ini and restart your simulator.

Using the OpenProfileModule

Login to your simulator and try to create your profile.

Check the database profile table to verify whether or not profile.php has written a record there.

P.D: OpenProfileModule only works while you are on your home grid, not when you are connected to other grids over hypergrid.

Troubleshooting

Error shown in Apache error_log:

PHP Fatal error:  Call to undefined function xmlrpc_server_create() in /var/www/html/opensim/profile.php

Cause:

Many Linux distributions may not ship with PHP XML RPC extensions.

Steps to Fix:

  • Fedora 17:
# yum install php-xmlrpc
Personal tools
General
About This Wiki