clockwerk-www – Diff between revs 71 and 72

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 71 Rev 72
1 <?php 1 <?php
2   2  
3 /////////////////////////////////////////////////////////////////////////// 3 ///////////////////////////////////////////////////////////////////////////
4 // Copyright (C) Wizardry and Steamworks 2014 - License: MIT // 4 // Copyright (C) Wizardry and Steamworks 2014 - License: MIT //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6   6  
7 // Hostname or IP of your OpenSim MySQL server. 7 // Hostname or IP of your OpenSim MySQL server.
8 $MYSQL_HOSTNAME='localhost'; 8 $MYSQL_HOSTNAME='localhost';
9 // Username of the OpenSim MySQL user. 9 // Username of the OpenSim MySQL user.
10 $MYSQL_USERNAME='opensim'; 10 $MYSQL_USERNAME='opensim';
11 // Password of the OpenSim MySQL user. 11 // Password of the OpenSim MySQL user.
12 $MYSQL_PASSWORD='***'; 12 $MYSQL_PASSWORD='***';
13 // Name of the OpenSim database on the MySQL server. 13 // Name of the OpenSim database on the MySQL server.
14 $MYSQL_DATABASE='opensim'; 14 $MYSQL_DATABASE='opensim';
15   15  
16 require_once 'lib/recaptchalib.php'; 16 require_once 'lib/recaptchalib.php';
17 require_once 'lib/wasRemoteAdmin.php'; 17 require_once 'lib/wasRemoteAdmin.php';
18   18  
19 define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr'); 19 define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr');
20   20  
21 $first = $_POST["first"]; 21 $first = $_POST["first"];
22 $last = $_POST["last"]; 22 $last = $_POST["last"];
23 $region = $_POST["region"]; 23 $region = $_POST["region"];
24 $file = $_FILES["file"]["tmp_name"]; 24 $file = $_FILES["file"]["tmp_name"];
25 $password = $_POST["password"]; 25 $password = $_POST["password"];
26   26  
27 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, 27 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
28 $_SERVER["REMOTE_ADDR"], 28 $_SERVER["REMOTE_ADDR"],
29 $_POST["recaptcha_challenge_field"], 29 $_POST["recaptcha_challenge_field"],
30 $_POST["recaptcha_response_field"]); 30 $_POST["recaptcha_response_field"]);
31   31  
32 ?> 32 ?>
33   33  
34 <!DOCTYPE html> 34 <!DOCTYPE html>
35 <html> 35 <html>
36 <head> 36 <head>
37 <title>Clockwerk</title> 37 <title>Clockwerk</title>
38 <link rel="stylesheet" href="css/gray.css" type="text/css" /> 38 <link rel="stylesheet" href="css/gray.css" type="text/css" />
39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
40 </head> 40 </head>
41 <body class=dark-grey> 41 <body class=dark-grey>
42 <div class="center"> 42 <div class="center">
43 <img src="img/clockwerk-logo.png" alt="logo"> 43 <img src="img/clockwerk-logo.png" alt="logo">
44 <h1><?php print gethostname(); ?></h1> 44 <h1><?php print gethostname(); ?></h1>
45 <hr> 45 <hr>
46   46  
47 <?php 47 <?php
48   48  
49 switch((bool)$resp->is_valid) { 49 switch((bool)$resp->is_valid) {
50 case TRUE: 50 case TRUE:
51 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); 51 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim');
52 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); 52 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1');
53 $rep = new SimpleXMLElement($ret); 53 $rep = new SimpleXMLElement($ret);
54 foreach($rep->params->param->value->struct->member as $member) { 54 foreach($rep->params->param->value->struct->member as $member) {
55 switch($member->name) { 55 switch($member->name) {
56 case "success": 56 case "success":
57 switch((bool)$member->value->boolean) { 57 switch((bool)$member->value->boolean) {
58 case TRUE: 58 case TRUE:
59 /* try { 59 try {
60 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); 60 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD);
61 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 61 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
62 $query = $mysql->prepare("SELECT Name FROM land WHERE OwnerUUID=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)"); 62 $query = $mysql->prepare("SELECT UserLevel FROM UserAccounts WHERE FirstName=:first AND LastName=:last");
63 $query->bindParam(':first', $first); 63 $query->bindParam(':first', $first);
64 $query->bindParam(':last', $last); 64 $query->bindParam(':last', $last);
65 $query->execute(); 65 $query->execute();
-   66 $result=$query->fetch(PDO::FETCH_ASSOC);
66 } 67 }
67 catch(PDOException $e) { 68 catch(PDOException $e) {
-   69 print '<p>Sorry, a database error occurred.</p>';
-   70 goto last;
-   71 }
-   72 if($result['UserLevel'] < 100) {
68 print '<p>Sorry, the authenticated agent is not the owner of the region to download.</p>'; 73 print '<p>Sorry, the authenticated agent does not have the necessary level to apply OARs.</p>';
-   74 goto last;
-   75 }
-   76 if (file_exists($file)) {
-   77 $req->admin_console_command('change region '.$region);
-   78 chmod($file, 0644);
-   79 $req->admin_console_command('load oar '.$file);
-   80 chmod($file, 0600);
-   81 echo '<p>OAR uploaded successfully.</p>';
69 goto last; 82 goto last;
70 } 83 }
71 while ($result = $query->fetchObject()) { -  
72 if ($result->RegionName == $region) { */ -  
73 if (file_exists($file)) { -  
74 $req->admin_console_command('change region '.$region); -  
75 chmod($file, 0644); -  
76 $req->admin_console_command('load oar '.$file); -  
77 chmod($file, 0600); -  
78 echo '<p>OAR uploaded successfully.</p>'; -  
79 goto last; -  
80 } -  
81 /* } -  
82 } */ -  
83 goto last; 84 goto last;
84 default: 85 default:
85 echo '<p>Sorry, wrong password.</p>'; 86 echo '<p>Sorry, wrong password.</p>';
86 goto last; 87 goto last;
87 } 88 }
88 break; 89 break;
89 } 90 }
90 } 91 }
91 default: 92 default:
92 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; 93 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';
93 } 94 }
94   95  
95 last: 96 last:
96   97  
97 ?> 98 ?>
98   99  
99 <form class="dark-grey"> 100 <form class="dark-grey">
100 <input type="button" onclick="parent.location='welcome.php'" value="Main Page"> 101 <input type="button" onclick="parent.location='welcome.php'" value="Main Page">
101 </form> 102 </form>
102 </div> 103 </div>
103 </body> 104 </body>
104 </html> 105 </html>
105   106