clockwerk-www – Blame information for rev 50

Subversion Repositories:
Rev:
Rev Author Line No. Line
47 eva 1 <?php
2  
3 ///////////////////////////////////////////////////////////////////////////
4 // Copyright (C) Wizardry and Steamworks 2014 - License: MIT //
5 ///////////////////////////////////////////////////////////////////////////
6  
50 zed 7 ///////////////////////////////////////////////////////////////////////////
8 // Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 //
9 ///////////////////////////////////////////////////////////////////////////
10 function wasChown($path, $uid, $gid) {
11 switch(filetype($path)) {
12 case 'dir':
13 if(($dir = opendir($path)) === false) break;
14 while(false !== ($file = readdir($dir))) {
15 if($file == '.' || $file == '..') continue;
16 wasChown($path.'/'.$file, $uid, $gid);
17 }
18 case 'file':
19 chown($path, $uid);
20 chgrp($path, $gid);
21 break;
22 }
23 }
24  
47 eva 25 // Hostname or IP of your OpenSim MySQL server.
26 $MYSQL_HOSTNAME='localhost';
27 // Username of the OpenSim MySQL user.
28 $MYSQL_USERNAME='opensim';
29 // Password of the OpenSim MySQL user.
30 $MYSQL_PASSWORD='***';
31 // Name of the OpenSim database on the MySQL server.
32 $MYSQL_DATABASE='opensim';
33  
34 require_once 'lib/recaptchalib.php';
35 require_once 'lib/wasRemoteAdmin.php';
36  
37 define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr');
38  
39 $first = $_POST["first"];
40 $last = $_POST["last"];
41 $region = $_POST["region"];
42 $file = $_FILES["file"]["tmp_name"];
43 $password = $_POST["password"];
44  
45 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
46 $_SERVER["REMOTE_ADDR"],
47 $_POST["recaptcha_challenge_field"],
48 $_POST["recaptcha_response_field"]);
49  
50 if ($resp->is_valid) {
51 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim');
52 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1');
53 $rep = new SimpleXMLElement($ret);
54 foreach($rep->params->param->value->struct->member as $member) {
55 if ($member->name == "success" && $member->value->boolean == "0") {
56 echo 'Sorry, wrong password.';
57 exit;
58 }
59 }
60 try {
61 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD);
62 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
63 $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)");
64 $query->bindParam(':first', $first);
65 $query->bindParam(':last', $last);
66 $query->execute();
67 }
68 catch(PDOException $e) {
69 print 'The given agent is not the owner of the region to download.';
70 return 1;
71 }
72 while ($result = $query->fetchObject()) {
73 if ($result->RegionName == $region) {
74 if (file_exists($file)) {
75 $req->admin_console_command('change region '.$region);
50 zed 76 wasChown($file, 'opensim', 'opensim');
47 eva 77 $req->admin_console_command('load oar '.$file);
50 zed 78 wasChown($file, 'www-data', 'www-data');
47 eva 79 header('Location: welcome.php');
80 exit;
81 }
82 }
83 }
84 }
85  
86 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';