clockwerk-www – Diff between revs 60 and 67

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 60 Rev 67
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 $password = $_POST["password"]; 24 $password = $_POST["password"];
25   25  
26 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, 26 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
27 $_SERVER["REMOTE_ADDR"], 27 $_SERVER["REMOTE_ADDR"],
28 $_POST["recaptcha_challenge_field"], 28 $_POST["recaptcha_challenge_field"],
29 $_POST["recaptcha_response_field"]); 29 $_POST["recaptcha_response_field"]);
30   30  
31 ?> 31 ?>
32   32  
33 <!DOCTYPE html> 33 <!DOCTYPE html>
34 <html> 34 <html>
35 <head> 35 <head>
36 <title>Clockwerk</title> 36 <title>Clockwerk</title>
37 <link rel="stylesheet" href="css/gray.css" type="text/css" /> 37 <link rel="stylesheet" href="css/gray.css" type="text/css" />
38 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 38 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
39 </head> 39 </head>
40 <body class=dark-grey> 40 <body class=dark-grey>
41 <div class="center"> 41 <div class="center">
42 <img src="img/clockwerk-logo.png" alt="logo"> 42 <img src="img/clockwerk-logo.png" alt="logo">
43 <h1><?php print gethostname(); ?></h1> 43 <h1><?php print gethostname(); ?></h1>
44 <hr> 44 <hr>
45   45  
46 <?php 46 <?php
47   47  
48 if ($resp->is_valid) { 48 if ($resp->is_valid) {
49 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); 49 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim');
50 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); 50 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1');
51 $rep = new SimpleXMLElement($ret); 51 $rep = new SimpleXMLElement($ret);
52 foreach($rep->params->param->value->struct->member as $member) { 52 foreach($rep->params->param->value->struct->member as $member) {
53 if ($member->name == "success" && $member->value->boolean == "0") { 53 if ($member->name == "success" && $member->value->boolean == "0") {
54 echo 'Sorry, wrong password.'; 54 echo 'Sorry, wrong password.';
55 goto last; 55 goto last;
56 } 56 }
57 } 57 }
58 try { 58 try {
59 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); 59 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD);
60 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 60 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
61 $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)"); 61 $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)");
62 $query->bindParam(':first', $first); 62 $query->bindParam(':first', $first);
63 $query->bindParam(':last', $last); 63 $query->bindParam(':last', $last);
64 $query->execute(); 64 $query->execute();
65 } 65 }
66 catch(PDOException $e) { 66 catch(PDOException $e) {
67 print 'The given agent is not the owner of the region to download.'; 67 print 'The given agent is not the owner of the region to download.';
68 return 1; 68 return 1;
69 } 69 }
70 while ($result = $query->fetchObject()) { 70 while ($result = $query->fetchObject()) {
71 if ($result->RegionName == $region) { 71 if ($result->RegionName == $region) {
72 $oar_path = '/var/lib/oar/'.$region.'/'.$region.'.oar'; 72 $oar_path = '/var/lib/oar/'.$region.'/'.$region.'.oar';
73 if (file_exists($oar_path)) { 73 if (file_exists($oar_path)) {
74 header('Content-Description: File Transfer'); 74 header('Content-Description: File Transfer');
75 header('Content-Type: application/x-gzip-compressed'); 75 header('Content-Type: application/x-gzip-compressed');
76 header('Content-Disposition: attachment; filename='.basename($oar_path)); 76 header('Content-Disposition: attachment; filename='.basename($oar_path));
77 header('Content-Transfer-Encoding: binary'); 77 header('Content-Transfer-Encoding: binary');
78 header('Expires: 0'); 78 header('Expires: 0');
79 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 79 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
80 header('Pragma: public'); 80 header('Pragma: public');
81 header('Content-Length: '.filesize($oar_path)); 81 header('Content-Length: '.filesize($oar_path));
82 readfile($oar_path); 82 readfile($oar_path);
83 goto last; 83 goto last;
84 } 84 }
85 echo '<p>Sorry, the OAR file is not available yet.</p>'; 85 echo '<p>Sorry, the OAR file is not available yet.</p>';
86 goto last; 86 goto last;
87 } 87 }
88 } 88 }
89 } 89 }
90   90  
91 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; 91 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';
92   92  
93 last: 93 last:
94   94  
95 ?> 95 ?>
96   96  
97 <p> 97 <form class="dark-grey">
98 <a class="button" href="welcome.php">Main Page</a> 98 <input type="button" onclick="parent.location='welcome.php'" value="Main Page">
99 </p> 99 </form>
100 </div> 100 </div>
101 </body> 101 </body>
102 </html> 102 </html>
103   103