opensim-tools – Rev 26
?pathlinks?
#!/usr/bin/php
<?php
/////////////////////////////////////////////////////////////
// Wizardry and Steamworks (c) was.fm - 2013, License: MIT //
// //
// Permission is hereby granted, free of charge, to any //
// person obtaining a copy of this software and associated //
// documentation files (the "Software"), to deal in the //
// Software without restriction, //including without //
// limitation the rights to use, copy, modify, merge, //
// publish, distribute, sublicense, and/or sell copies of //
// the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the //
// following conditions: //
// //
// The above copyright notice and this permission notice //
// shall be included in all copies or substantial portions //
// of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF //
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT //
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS //
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO //
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE //
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER //
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR //
// THE USE OR OTHER DEALINGS IN THE SOFTWARE. //
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// CONFIGURATION //
/////////////////////////////////////////////////////////////
// Hostname or IP of your OpenSim MySQL server.
define("MYSQL_HOSTNAME", "localhost");
// Username of the OpenSim MySQL user.
define("MYSQL_USERNAME", "opensim");
// Password of the OpenSim MySQL user.
define("MYSQL_PASSWORD", "***");
// Name of the OpenSim database on the MySQL server.
define("MYSQL_DATABASE", "opensim");
/////////////////////////////////////////////////////////////
// INTERNALS //
/////////////////////////////////////////////////////////////
require_once('lib/kos.php');
if(!defined('STDIN')) {
print 'This script is meant to be run on the command line.'."\n";
return 1;
}
#if($argc < 2) {
# print 'ERROR: Please specify OARs and IARs to filter on the command line.'."\n";
# print 'Syntax: php '.$argv[0]. ' <First Name> <Last Name>'."\n";
# return 1;
#}
$connection_ok = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
if(!$connection_ok) {
print 'Could not connect to the OpenSim database. Please edit the script and make sure the credentials are correct.'."\n";
return 1;
}
$db_selected = mysql_select_db(MYSQL_DATABASE);
if(!$db_selected) {
print 'Could not select the opensim database. Please edit this script and make sure the credentials are correct.'."\n";
return 1;
}
$query = 'SELECT Concat(FirstName, " ", LastName) FROM UserAccounts';
$result = mysql_query($query);
$users = array();
while($row = mysql_fetch_array($result)) {
array_push($users, $row[0]);
}
// Now we can get rid of the script name.
array_shift($argv);
// Create the request
$req = new KOS('http://localhost:10000', 'opensim');
// ..and dump
foreach($users as $user) {
$_user = preg_replace('/\s/','_',$user);
$USER_FOLDER='/var/lib/iar/'.$_user;
if(!is_dir($USER_FOLDER)) mkdir($USER_FOLDER);
chown($USER_FOLDER, 'opensim');
$req->send('save iar '.$user.' / '.$USER_FOLDER.'/'.$_user.'.iar');
}