exist_table('GridUser')) $ver = '0.7'; else { if ($db->Errno!=0) return null; if ($db->exist_table('users')) $ver = '0.6'; } return $ver; } function opensim_users_update_time(&$db=null) { if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('GridUser')) $table = 'GridUser'; else if ($db->exist_table('users')) $table = 'users'; else return 0; $utime = $db->get_update_time($table); return $utime; } function opensim_get_update_time($table, &$db=null) { if ($table=="") return 0; if (!is_object($db)) $db = & opensim_new_db(); $utime = $db->get_update_time($table); return $utime; } function opensim_check_db(&$db=null) { $ret['grid_status'] = false; $ret['now_online'] = 0; $ret['lastmonth_online'] = 0; $ret['user_count'] = 0; $ret['region_count'] = 0; if (!is_object($db)) $db = & opensim_new_db(3); if ($db->exist_table('regions')) { $db->query('SELECT COUNT(*) FROM regions'); if ($db->Errno==0) { list($ret['region_count']) = $db->next_record(); } } if ($db->exist_table('GridUser')) { // 0.7 $db->query('SELECT COUNT(*) FROM UserAccounts'); list($ret['user_count']) = $db->next_record(); //$db->query("SELECT COUNT(*) FROM GridUser WHERE Online='True' and Login>(unix_timestamp(from_unixtime(unix_timestamp(now())-86400)))"); if ($db->exist_table('Presence')) { // 0.7 $db->query("SELECT COUNT(DISTINCT Presence.UserID) FROM GridUser,Presence ". "WHERE Online='True' and GridUser.UserID=Presence.UserID and RegionID!='00000000-0000-0000-0000-000000000000'"); } else { // 0.7 StandAlone mode $db->query("SELECT COUNT(*) FROM GridUser WHERE Online='True'"); } list($ret['now_online']) = $db->next_record(); $db->query('SELECT COUNT(*) FROM GridUser WHERE Login>unix_timestamp(from_unixtime(unix_timestamp(now())-2419200))'); list($ret['lastmonth_online']) = $db->next_record(); $ret['grid_status'] = true; } else if ($db->exist_table('users')) { // 0.6.x $db->query('SELECT COUNT(*) FROM users'); list($ret['user_count']) = $db->next_record(); //$db->query("SELECT COUNT(*) FROM agents WHERE agentOnline='1' and logintime>(unix_timestamp(from_unixtime(unix_timestamp(now())-86400)))"); $db->query("SELECT COUNT(*) FROM agents WHERE agentOnline='1'"); list($ret['now_online']) = $db->next_record(); $db->query('SELECT COUNT(*) FROM agents WHERE logintime>unix_timestamp(from_unixtime(unix_timestamp(now())-2419200))'); list($ret['lastmonth_online']) = $db->next_record(); $ret['grid_status'] = true; } return $ret; } ///////////////////////////////////////////////////////////////////////////////////// // // for Avatar // function opensim_get_avatars_num(&$db=null) { $num = 0; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('UserAccounts')) { $db->query('SELECT COUNT(*) FROM UserAccounts'); list($num) = $db->next_record(); } else if ($db->exist_table('users')) { $db->query('SELECT COUNT(*) FROM users'); list($num) = $db->next_record(); } else { $num = -1; } return $num; } function opensim_get_avatar_name($uuid, &$db=null) { if (!isGUID($uuid)) return null; $firstname = null; $lastname = null; $fullname = null; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('UserAccounts')) { $db->query("SELECT FirstName,LastName FROM UserAccounts WHERE PrincipalID='$uuid'"); list($firstname, $lastname) = $db->next_record(); } else if ($db->exist_table('users')) { $db->query("SELECT username,lastname FROM users WHERE UUID='$uuid'"); list($firstname, $lastname) = $db->next_record(); } $fullname = $firstname.' '.$lastname; if ($fullname==' ') $fullname = null; $name['firstname'] = $firstname; $name['lastname'] = $lastname; $name['fullname'] = $fullname; return $name; } function opensim_get_avatar_uuid($name, &$db=null) { if (!isAlphabetNumericSpecial($name)) return false; //$avatar_name = explode(' ', $name); $avatar_name = preg_split("/ /", $name, 0, PREG_SPLIT_NO_EMPTY); $firstname = $avatar_name[0]; $lastname = $avatar_name[1]; if ($firstname=='' or $lastname=='') return false; if (!is_object($db)) $db = & opensim_new_db(); $uuid = null; if ($db->exist_table('UserAccounts')) { $db->query("SELECT PrincipalID FROM UserAccounts WHERE FirstName='$firstname' and LastName='$lastname'"); list($uuid) = $db->next_record(); } else if ($db->exist_table('users')) { $db->query("SELECT UUID FROM users WHERE username='$firstname' and lastname='$lastname'"); list($uuid) = $db->next_record(); } return $uuid; } function opensim_get_avatar_session($uuid, &$db=null) { if (!isGUID($uuid)) return null; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('Presence')) { // 0.7 $sql = "SELECT RegionID,SessionID,SecureSessionID FROM Presence WHERE UserID='".$uuid."'"; } else if ($db->exist_table('agents')) { // 0.6x $sql = "SELECT currentRegion,sessionID,secureSessionID FROM agents WHERE UUID='".$uuid."'"; } else { return null; } $db->query($sql); list($RegionID, $SessionID, $SecureSessionID) = $db->next_record(); $avssn['regionID'] = $RegionID; $avssn['sessionID'] = $SessionID; $avssn['secureID'] = $SecureSessionID; //$avssn['lastlogin'] = $LastLogin; return $avssn; } function opensim_get_avatar_info($uuid, &$db=null) { if (!isGUID($uuid)) return null; if (!is_object($db)) $db = & opensim_new_db(); //$online = false; $profileText = ''; $profileImage = ''; $firstText = ''; $firstImage = ''; $partner = ''; if ($db->exist_table('GridUser')) { $db->query('SELECT PrincipalID,FirstName,LastName,HomeRegionID,Created,Login FROM UserAccounts'. " LEFT JOIN GridUser ON PrincipalID=UserID WHERE PrincipalID='$uuid'"); list($UUID, $firstname, $lastname, $regionUUID, $created, $lastlogin) = $db->next_record(); $db->query("SELECT regionName,serverIP,serverHttpPort,serverURI FROM regions WHERE uuid='$regionUUID'"); list($regionName, $serverIP, $serverHttpPort, $serverURI) = $db->next_record(); } else if ($db->exist_table('users')) { $db->query("SELECT UUID,username,lastname,homeRegion,created,lastLogin,profileAboutText,profileFirstText,profileImage,profileFirstImage,partner". " FROM users WHERE uuid='$uuid'"); list($UUID, $firstname, $lastname, $rgnHandle, $created, $lastlogin, $profileText, $firstText, $profileImage, $firstImage, $partner) = $db->next_record(); $db->query("SELECT uuid,regionName,serverIP,serverHttpPort,serverURI FROM regions WHERE regionHandle='$rgnHandle'"); list($regionUUID, $regionName, $serverIP, $serverHttpPort, $serverURI) = $db->next_record(); } else { return null; } $fullname = $firstname.' '.$lastname; if ($fullname==' ') $fullname = null; $avinfo['UUID'] = $UUID; $avinfo['firstname'] = $firstname; $avinfo['lastname'] = $lastname; $avinfo['fullname'] = $fullname; $avinfo['created'] = $created; $avinfo['lastlogin'] = $lastlogin; $avinfo['regionUUID'] = $regionUUID; $avinfo['regionName'] = $regionName; $avinfo['serverIP'] = $serverIP; $avinfo['serverHttpPort'] = $serverHttpPort; $avinfo['serverURI'] = $serverURI; $avinfo['profileText'] = $profileText; $avinfo['profileImage'] = $profileImage; $avinfo['firstText'] = $firstText; $avinfo['firstImage'] = $firstImage; $avinfo['partner'] = $partner; //$avinfo['online'] = $online; return $avinfo; } // // Attention: When call this function, please check $condition for prevention of SQL Injection. // // return: // $avinfos[$UUID]['UUID'] ... UUID // $avinfos[$UUID]['firstname'] ... first name // $avinfos[$UUID]['lastname'] ... lasti name // $avinfos[$UUID]['created'] ... created time // $avinfos[$UUID]['lastlogin'] ... lastlogin time // $avinfos[$UUID]['hmregion'] ... uuid of home region // function opensim_get_avatars_infos($condition='', &$db=null) { if (!is_object($db)) $db = & opensim_new_db(); $avinfos = array(); if ($db->exist_table('GridUser')) { $db->query('SELECT PrincipalID,FirstName,LastName,Created,Login,homeRegionID FROM UserAccounts '. 'LEFT JOIN GridUser ON PrincipalID=UserID '.$condition); } else if ($db->exist_table('users')) { $db->query('SELECT users.UUID,username,lastname,created,lastLogin,regions.uuid FROM users '. 'LEFT JOIN regions ON homeRegion=regionHandle '.$condition); } else { return null; } if ($db->Errno==0) { while (list($UUID,$firstname,$lastname,$created,$lastlogin,$hmregion) = $db->next_record()) { $avinfos[$UUID]['UUID'] = $UUID; $avinfos[$UUID]['firstname'] = $firstname; $avinfos[$UUID]['lastname'] = $lastname; $avinfos[$UUID]['created'] = $created; $avinfos[$UUID]['lastlogin'] = $lastlogin; $avinfos[$UUID]['hmregion'] = $hmregion; } } return $avinfos; } // // Attention: When call this function, please check $condition for prevention of SQL Injection. // function opensim_get_avatars_profiles_from_users($condition='', &$db=null) { if (!is_object($db)) $db = & opensim_new_db(); $profs = null; if ($db->exist_table('users')) { $db->query('SELECT UUID,profileCanDoMask,profileWantDoMask,profileAboutText,'. 'profileFirstText,profileImage,profileFirstImage,partner,email FROM users '.$condition); if ($db->Errno==0) { $profs = array(); while (list($UUID,$skilmask,$wantmask,$abouttext,$firsttext,$image,$firstimage,$partnar,$email) = $db->next_record()) { $profs[$UUID]['UUID'] = $UUID; $profs[$UUID]['SkillsMask'] = $skilmask; $profs[$UUID]['WantToMask'] = $wantmask; $profs[$UUID]['AboutText'] = $abouttext; $profs[$UUID]['FirstAboutText'] = $firsttext; $profs[$UUID]['Image'] = $image; $profs[$UUID]['FirstImage'] = $firstimage; $profs[$UUID]['Partnar'] = $partnar; $profs[$UUID]['Email'] = $email; } } } return $profs; } function opensim_get_avatar_online($uuid, &$db=null) { if (!isGUID($uuid)) return null; if (!is_object($db)) $db = & opensim_new_db(); $online = false; $null_region = '00000000-0000-0000-0000-000000000000'; $region = '00000000-0000-0000-0000-000000000000'; $rgn_name = ''; /* if ($db->exist_field('Presence', 'Online')) { // old 0.7Dev $db->query("SELECT Online,RegionID FROM Presence WHERE UserID='$uuid' and RegionID!='$null_region'"); if ($db->Errno==0) { list($onln, $region) = $db->next_record(); if ($onln=='true') { $rgn_name = opensim_get_region_name($region); if ($rgn_name!='') $online = true; } } } */ if ($db->exist_table('Presence')) { // 0.7 $db->query("SELECT RegionID FROM Presence,GridUser WHERE Presence.UserID='$uuid'". " and RegionID!='$null_region' and Presence.UserID=GridUser.UserID and GridUser.Online='True'"); if ($db->Errno==0) { list($region) = $db->next_record(); $rgn_name = opensim_get_region_name($region); if ($rgn_name!='') $online = true; } } else if ($db->exist_table('GridUser')) { // 0.7 StandAlone mode $db->query("SELECT Online,LastRegionID FROM GridUser WHERE UserID='$uuid'"); if ($db->Errno==0) { list($onln, $region) = $db->next_record(); if ($onln=='True') { $rgn_name = opensim_get_region_name_by_i($region); if ($rgn_name!='') $online = true; } } } else if ($db->exist_table('agents')) { // 0.6.x $db->query("SELECT agentOnline,currentRegion FROM agents WHERE UUID='$uuid' AND logoutTime='0'"); if ($db->Errno==0) { list($onln, $region) = $db->next_record(); if ($onln=='1') { $rgn_name = opensim_get_region_name($region); if ($rgn_name!='') $online = true; } } } $ret['online'] = $online; $ret['region_id'] = $region; $ret['region_name'] = $rgn_name; return $ret; } function opensim_get_avatar_flags($uuid, &$db=null) { if (!isGUID($uuid)) return null; if (!is_object($db)) $db = & opensim_new_db(); // for 0.7 if ($db->exist_table('UserAccounts')) { $db->query("SELECT UserFlags FROM UserAccounts WHERE PrincipalID='$uuid'"); if ($db->Errno==0) { list($flags) = $db->next_record(); return $flags; } } // for 0.6 else if ($db->exist_table('users')) { $db->query("SELECT userFlags FROM users WHERE UUID='$uuid'"); if ($db->Errno==0) { list($flags) = $db->next_record(); return $flags; } } return 0; } function opensim_set_avatar_flags($uuid, $flags=0, &$db=null) { if (!isGUID($uuid)) return false; if (!isNumeric($flags)) return false; if (!is_object($db)) $db = & opensim_new_db(); // for 0.7 if ($db->exist_table('UserAccounts')) { $query_str = "UPDATE UserAccounts SET UserFlags='$flags' WHERE PrincipalID='$uuid'"; $db->query($query_str); if ($db->Errno==0) return true; } // for 0.6 else if ($db->exist_table('users')) { $query_str = "UPDATE users SET userFlags='$flags' WHERE UUID='$uuid'"; $db->query($query_str); if ($db->Errno==0) return true; } return false; } function opensim_create_avatar($UUID, $firstname, $lastname, $passwd, $homeregion, &$db=null) { if (!isGUID($UUID)) return false; if (!isAlphabetNumericSpecial($firstname)) return false; if (!isAlphabetNumericSpecial($lastname)) return false; if (!isAlphabetNumericSpecial($passwd)) return false; if (!isAlphabetNumericSpecial($homeregion)) return false; if (!is_object($db)) $db = & opensim_new_db(); $nulluuid = '00000000-0000-0000-0000-000000000000'; $passwdsalt = make_random_hash(); $passwdhash = md5(md5($passwd).":".$passwdsalt); $db->query("SELECT uuid,regionHandle FROM regions WHERE regionName='$homeregion'"); $errno = $db->Errno; if ($errno==0) { list($regionID,$regionHandle) = $db->next_record(); // for 0.7 if ($db->exist_table('UserAccounts')) { $serviceURLs = 'HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI='; $db->query('INSERT INTO UserAccounts (PrincipalID,ScopeID,FirstName,LastName,Email,ServiceURLs,Created,UserLevel,UserFlags,UserTitle) '. "VALUES ('$UUID','$nulluuid','$firstname','$lastname','','$serviceURLs','".time()."','0','0','')"); $errno = $db->Errno; if ($errno==0) { if ($db->exist_table('GridUser')) { $db->query('INSERT INTO GridUser (UserID,HomeRegionID,HomePosition,HomeLookAt,'. 'LastRegionID,LastPosition,LastLookAt,Online,Login,Logout) '. "VALUES ('$UUID','$regionID','<128,128,0>','<0,0,0>',". "'$regionID','<128,128,0>','<0,0,0>','false','0','0')"); } $errno = $db->Errno; } if ($errno==0) { $db->query('INSERT INTO auth (UUID,passwordHash,passwordSalt,webLoginKey,accountType) '. "VALUES ('$UUID','$passwdhash','$passwdsalt','$nulluuid','UserAccount')"); $errno = $db->Errno; } if ($errno==0) { $errno = opensim_create_inventory_folders($UUID, $db); } if ($errno!=0) { $db->query("DELETE FROM UserAccounts WHERE PrincipalID='$UUID'"); $db->query("DELETE FROM auth WHERE UUID='$UUID'"); $db->query("DELETE FROM inventoryfolders WHERE agentID='$UUID'"); if ($db->exist_table('GridUser')) $db->query("DELETE FROM GridUser WHERE UserID='$UUID'"); } } // for 0.6 else if ($db->exist_table('users')) { $db->query('INSERT INTO users (UUID,username,lastname,passwordHash,passwordSalt,homeRegion,'. 'homeLocationX,homeLocationY,homeLocationZ,homeLookAtX,homeLookAtY,homeLookAtZ,'. 'created,lastLogin,userInventoryURI,userAssetURI,profileCanDoMask,profileWantDoMask,'. 'profileAboutText,profileFirstText,profileImage,profileFirstImage,homeRegionID) '. "VALUES ('$UUID','$firstname','$lastname','$passwdhash','$passwdsalt','$regionHandle',". "'128','128','128','100','100','100',". "'".time()."','0','','','0','0','','','$nulluuid','$nulluuid','$regionID')"); if ($db->Errno!=0) { $db->query("DELETE FROM users WHERE UUID='$UUID'"); if (!$db->exist_table('UserAccounts')) $errno = 99; } } } if ($errno!=0) return false; return true; } // // データベースからアバタ情報を削除する. // function opensim_delete_avatar($uuid, &$db=null) { if (!isGUID($uuid)) return false; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('UserAccounts')) { $db->query("DELETE FROM UserAccounts WHERE PrincipalID='$uuid'"); $db->query("DELETE FROM auth WHERE UUID='$uuid'"); $db->query("DELETE FROM Avatars WHERE PrincipalID='$uuid'"); $db->query("DELETE FROM Friends WHERE PrincipalID='$uuid'"); $db->query("DELETE FROM tokens WHERE UUID='$uuid'"); if ($db->exist_table('Presence')) $db->query("DELETE FROM Presence WHERE UserID='$uuid'"); if ($db->exist_table('GridUser')) $db->query("DELETE FROM GridUser WHERE UserID='$uuid'"); } if ($db->exist_table('users')) { $db->query("DELETE FROM users WHERE UUID='$uuid'"); $db->query("DELETE FROM agents WHERE UUID='$uuid'"); $db->query("DELETE FROM avatarappearance WHERE Owner='$uuid'"); $db->query("DELETE FROM avatarattachments WHERE UUID='$uuid'"); $db->query("DELETE FROM userfriends WHERE ownerID='$uuid'"); } $db->query("DELETE FROM estate_managers WHERE uuid='$uuid'"); $db->query("DELETE FROM estate_users WHERE uuid='$uuid'"); $db->query("DELETE FROM estateban WHERE bannedUUID='$uuid'"); $db->query("DELETE FROM inventoryfolders WHERE agentID='$uuid'"); $db->query("DELETE FROM inventoryitems WHERE avatarID='$uuid'"); $db->query("DELETE FROM landaccesslist WHERE AccessUUID='$uuid'"); $db->query("DELETE FROM regionban WHERE bannedUUID='$uuid'"); // for DTL Money Server if ($db->exist_table('balances')) { //$db->query("DELETE FROM transactions WHERE UUID='$uuid'"); $db->query("DELETE FROM balances WHERE user LIKE '".$uuid."@%'"); $db->query("DELETE FROM userinfo WHERE user LIKE '".$uuid."@%'"); } return true; } ///////////////////////////////////////////////////////////////////////////////////// // // for Region // function opensim_get_regions_num(&$db=null) { $num = 0; if (!is_object($db)) $db = & opensim_new_db(); $db->query('SELECT COUNT(*) FROM regions'); list($num) = $db->next_record(); return $num; } function opensim_get_region_uuid($name, &$db=null) { if (!isAlphabetNumericSpecial($name)) return false; if (!is_object($db)) $db = & opensim_new_db(); $uuid = ''; if ($name!='') { $db->query("SELECT uuid FROM regions WHERE regionName='$name'"); list($uuid) = $db->next_record(); } return $uuid; } function opensim_get_region_name($id, &$db=null) { if (!isGUID($id) and !isNumeric($id)) return null; if (!is_object($db)) $db = & opensim_new_db(); if (isGUID($id)) { $db->query("SELECT regionName FROM regions WHERE uuid='$id'"); list($regionName) = $db->next_record(); } else { $db->query("SELECT regionName FROM regions WHERE regionHandle='$id'"); list($regionName) = $db->next_record(); } return $regionName; } // // Attention: When call this function, please check $condition for prevention of SQL Injection. // function opensim_get_regions_names($condition='', &$db=null) { if (!is_object($db)) $db = & opensim_new_db(); $regions = array(); $db->query("SELECT regionName FROM regions ".$condition); while ($db->Errno==0 and list($region)=$db->next_record()) { $regions[] = $region; } return $regions; } function opensim_get_region_info($region, &$db=null) { if (!isGUID($region)) return null; if ($region=='00000000-0000-0000-0000-000000000000') return null; if (!is_object($db)) $db = & opensim_new_db(); $sql = "SELECT regionHandle,regionName,regionSecret,serverIP,serverHttpPort,serverURI,locX,locY FROM regions WHERE uuid='$region'"; $db->query($sql); list($regionHandle, $regionName, $regionSecret, $serverIP, $serverHttpPort, $serverURI, $locX, $locY) = $db->next_record(); $rginfo = opensim_get_estate_owner($region, $db); $rginfo['regionHandle'] = $regionHandle; $rginfo['regionName'] = $regionName; $rginfo['regionSecret'] = $regionSecret; $rginfo['serverIP'] = $serverIP; $rginfo['serverHttpPort'] = $serverHttpPort; $rginfo['serverURI'] = $serverURI; $rginfo['locX'] = $locX; $rginfo['locY'] = $locY; return $rginfo; } // // Attention: When call this function, please check $condition for prevention of SQL Injection. // // return: // $rginfos[$UUID]['UUID'] ... UUID // $rginfos[$UUID]['regionName'] ... name of region // $rginfos[$UUID]['locX'] ... location X // $rginfos[$UUID]['locY'] ... location Y // $rginfos[$UUID]['serverIP'] ... IP address of server // $rginfos[$UUID]['serverPort'] ... port num of server // $rginfos[$UUID]['serverURI'] ... URI of server // $rginfos[$UUID]['owner_uuid'] ... UUID of region owner // $rginfos[$UUID]['estate_id'] ... ID of estate // $rginfos[$UUID]['estate_owner'] ... UUID of estate owner // $rginfos[$UUID]['est_firstname'] ... first name // $rginfos[$UUID]['est_lastname'] ... last name // $rginfos[$UUID]['est_fullname'] ... full name // function opensim_get_regions_infos($condition='', &$db=null) { if (!is_object($db)) $db = & opensim_new_db(); $rginfos = array(); $items = ' regions.uuid,regionName,locX,locY,serverIP,serverURI,serverHttpPort,owner_uuid,estate_map.EstateID,EstateOwner,'; $join1 = ' FROM regions LEFT JOIN estate_map ON RegionID=regions.uuid '; $join2 = ' LEFT JOIN estate_settings ON estate_map.EstateID=estate_settings.EstateID '; if ($db->exist_table('UserAccounts')) { $uname = 'firstname,lastname '; $join3 = ' LEFT JOIN UserAccounts ON EstateOwner=UserAccounts.PrincipalID '; $frmwh = ' FROM UserAccounts WHERE UserAccounts.PrincipalID='; } else if ($db->exist_table('users')) { $uname = 'username,lastname '; $join3 = ' LEFT JOIN users ON EstateOwner=users.UUID '; $frmwh = ' FROM users WHERE users.UUID='; } else { return null; } $query_str = 'SELECT '.$items.$uname.$join1.$join2.$join3.$condition; $db->query($query_str); if ($db->Errno==0) { while (list($UUID,$regionName,$locX,$locY,$serverIP,$serverURI,$serverPort, $owneruuid,$estateid,$estateowner,$firstname,$lastname) = $db->next_record()) { $rginfos[$UUID]['UUID'] = $UUID; $rginfos[$UUID]['regionName'] = $regionName; $rginfos[$UUID]['locX'] = $locX; $rginfos[$UUID]['locY'] = $locY; $rginfos[$UUID]['serverIP'] = $serverIP; $rginfos[$UUID]['serverPort'] = $serverPort; $rginfos[$UUID]['serverURI'] = $serverURI; $rginfos[$UUID]['owner_uuid'] = $owneruuid; $rginfos[$UUID]['estate_id'] = $estateid; $rginfos[$UUID]['estate_owner'] = $estateowner; $rginfos[$UUID]['est_firstname']= $firstname; $rginfos[$UUID]['est_lastname'] = $lastname; $rginfos[$UUID]['est_fullname'] = null; $fullname = $firstname.' '.$lastname; if ($fullname!=' ') $rginfos[$UUID]['est_fullname'] = $fullname; } } // Region Owner foreach($rginfos as $region) { $rginfos[$region['UUID']]['rgn_firstname'] = null; $rginfos[$region['UUID']]['rgn_lastname'] = null; $rginfos[$region['UUID']]['rgn_fullname'] = null; if ($region['owner_uuid']!=null) { $db->query('SELECT '.$uname.$frmwh."'".$region['owner_uuid']."'"); list($firstname,$lastname) = $db->next_record(); $rginfos[$region['UUID']]['rgn_firstname'] = $firstname; $rginfos[$region['UUID']]['rgn_lastname'] = $lastname; $fullname = $firstname.' '.$lastname; if ($fullname!=' ') $rginfos[$region['UUID']]['rgn_fullname'] = $fullname; } } return $rginfos; } function opensim_set_current_region($uuid, $regionid, &$db=null) { if (!isGUID($uuid) or !isGUID($regionid)) return false; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table("Presence")) { $sql = "UPDATE Presence SET RegionID='".$regionid."' WHERE UserID='". $uuid."'"; } else if ($db->exist_table("agents")) { $sql = "UPDATE agents SET currentRegion='".$regionid."' WHERE UUID='".$uuid."'"; } else { return false; } $db->query($sql); if ($db->Errno!=0) return false; $db->next_record(); return true; } ///////////////////////////////////////////////////////////////////////////////////// // // for Home Region // function opensim_get_home_region($uuid, &$db=null) { if (!isGUID($uuid)) return null; if (!is_object($db)) $db = & opensim_new_db(); $region_name = ''; if ($db->exist_table('GridUser')) { $db->query("SELECT regionName FROM GridUser,regions WHERE HomeRegionID=uuid AND UserID='$uuid'"); list($region_name) = $db->next_record(); } else if ($db->exist_table('users')) { $db->query("SELECT regionName FROM users,regions WHERE homeRegionID=regions.uuid AND users.UUID='$uuid'"); list($region_name) = $db->next_record(); } return $region_name; } function opensim_set_home_region($uuid, $hmregion, $pos_x='128', $pos_y='128', $pos_z='0', &$db=null) { if (!isGUID($uuid)) return false; if (!isAlphabetNumericSpecial($hmregion)) return false; if (!isNumeric($pos_x) or !isNumeric($pos_y) or !isNumeric($pos_z)) return false; if (!is_object($db)) $db = & opensim_new_db(); $db->query("SELECT uuid,regionHandle FROM regions WHERE regionName='$hmregion'"); $errno = $db->Errno; if ($errno==0) { list($regionID, $regionHandle) = $db->next_record(); if ($db->exist_table('GridUser')) { $homePosition = "<$pos_x,$pos_y,$pos_z>"; $db->query("UPDATE GridUser SET HomeRegionID='$regionID',HomePosition='$homePosition' WHERE UserID='$uuid'"); $errno = $db->Errno; } if ($db->exist_table('users') and $errno==0) { $homePosition = "homeLocationX='$pos_x',homeLocationY='$pos_y',homeLocationZ='$pos_z' "; $db->query("UPDATE users SET homeRegion='$regionHandle',homeRegionID='$regionID',$homePosition WHERE UUID='$uuid'"); if ($db->Errno!=0) { if (!$db->exist_table('auth')) $errno = 99; } } } if ($errno!=0) return false; return true; } ///////////////////////////////////////////////////////////////////////////////////// // // for Estate Owner // // // SIMのリージョンIDからオーナーの情報を返す. // function opensim_get_estate_owner($region, &$db=null) { if (!isGUID($region)) return null; $firstname = null; $lastname = null; $fullname = null; $owneruuid = null; if (!is_object($db)) $db = & opensim_new_db(); if ($db->exist_table('UserAccounts')) { $rqdt = 'PrincipalID,FirstName,LastName'; $tbls = 'UserAccounts,estate_map,estate_settings'; $cndn = "RegionID='$region' AND estate_map.EstateID=estate_settings.EstateID AND EstateOwner=PrincipalID"; } else if ($db->exist_table('users')) { $rqdt = 'UUID,username,lastname'; $tbls = 'users,estate_map,estate_settings'; $cndn = "RegionID='$region' AND estate_map.EstateID=estate_settings.EstateID AND EstateOwner=UUID"; } else { return null; } $db->query('SELECT '.$rqdt.' FROM '.$tbls.' WHERE '.$cndn); list($owneruuid, $firstname, $lastname) = $db->next_record(); $fullname = $firstname.' '.$lastname; if ($fullname==' ') $fullname = null; $name['firstname'] = $firstname; $name['lastname'] = $lastname; $name['fullname'] = $fullname; $name['owner_uuid'] = $owneruuid; return $name; } function opensim_set_estate_owner($region, $owner, &$db=null) { if (!isGUID($region)) return false; if (!isGUID($owner)) return false; if (!is_object($db)) $db = & opensim_new_db(); $db->query("UPDATE estate_settings,estate_map SET EstateOwner='$owner' WHERE estate_settings.EstateID=estate_map.EstateID AND RegionID='$region'"); $errno = $db->Errno; if ($errno==0) $db->query("UPDATE regions SET owner_uuid='$owner' WHERE uuid='$region'"); if ($errno!=0) return false; return true; } ///////////////////////////////////////////////////////////////////////////////////// // // for Parcel // function opensim_get_parcel_name($parcel, &$db=null) { if (!isGUID($parcel)) return null; if (!is_object($db)) $db = & opensim_new_db(); $name = null; $db->query("SELECT name FROM land WHERE UUID='$parcel'"); if ($db->Errno==0) list($name) = $db->next_record(); return $name; } function opensim_get_parcel_info($parcel, &$db=null) { if (!isGUID($parcel)) return null; if (!is_object($db)) $db = & opensim_new_db(); $info = array(); $items = "RegionUUID,Name,Description,OwnerUUID,Category,SalePrice,LandStatus,LandFlags,LandingType,Dwell"; $query_str = "SELECT ".$items." FROM land WHERE UUID='".$parcel."'"; $db->query($query_str); if ($db->Errno==0) $info = $db->next_record(); return $info; } ///////////////////////////////////////////////////////////////////////////////////// // // for Assets // function opensim_get_asset_data($uuid, &$db=null) { $asset = array(); if (!isGUID($uuid)) return $asset; if (!is_object($db)) $db = & opensim_new_db(); $db->query("SELECT name,description,assetType,data,asset_flags,CreatorID FROM assets WHERE id='$uuid'"); list($name, $desc, $type, $data, $flag, $creator) = $db->next_record(); $asset['UUID'] = $uuid; $asset['name'] = $name; $asset['desc'] = $desc; $asset['type'] = $type; $asset['data'] = $data; $asset['flag'] = $flag; $asset['creator'] = $creator; return $asset; } function opensim_display_texture_data($uuid, $prog, $xsize='0', $ysize='0', $cachedir='', $use_tga=false) { if (!isGuid($uuid)) return false; if ($prog==null or $prog=='') return false; if ($cachedir=='') $cachedir = '/tmp'; $cachefile = $cachedir.'/'.$uuid; // PHP module $imagick = null; if ($prog=='imagick') { if (class_exists('Imagick')) { $imagick = new Imagick(); } else { echo '