clockwerk-www – Blame information for rev 57

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  
7 // Hostname or IP of your OpenSim MySQL server.
8 $MYSQL_HOSTNAME='localhost';
9 // Username of the OpenSim MySQL user.
10 $MYSQL_USERNAME='opensim';
11 // Password of the OpenSim MySQL user.
12 $MYSQL_PASSWORD='***';
13 // Name of the OpenSim database on the MySQL server.
14 $MYSQL_DATABASE='opensim';
15  
16 require_once 'lib/recaptchalib.php';
17 require_once 'lib/wasRemoteAdmin.php';
18  
19 define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr');
20  
21 $first = $_POST["first"];
22 $last = $_POST["last"];
23 $region = $_POST["region"];
24 $file = $_FILES["file"]["tmp_name"];
25 $password = $_POST["password"];
26  
27 $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
28 $_SERVER["REMOTE_ADDR"],
29 $_POST["recaptcha_challenge_field"],
30 $_POST["recaptcha_response_field"]);
31  
55 vero 32 ?>
33  
34 <!DOCTYPE html>
35 <html>
36 <head>
37 <title>Clockwerk</title>
38 <link rel="stylesheet" href="css/gray.css" type="text/css" />
57 vero 39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
55 vero 40 </head>
41 <body class=dark-grey>
42 <div class="center">
57 vero 43 <img src="img/clockwerk-logo.png" alt="logo">
55 vero 44 <h1><?php print gethostname(); ?></h1>
45 <hr>
46  
47 <?php
48  
49 switch((bool)$resp->is_valid) {
50 case TRUE:
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 switch($member->name) {
56 case "success":
57 switch((bool)$member->value->boolean) {
58 case TRUE:
59 try {
60 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD);
61 $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
62 $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)");
63 $query->bindParam(':first', $first);
64 $query->bindParam(':last', $last);
65 $query->execute();
66 }
67 catch(PDOException $e) {
68 print '<p>Sorry, the authenticated agent is not the owner of the region to download.</p>';
69 goto last;
70 }
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 default:
85 echo '<p>Sorry, wrong password.</p>';
86 goto last;
87 }
88 break;
89 }
90 }
91 default:
92 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';
47 eva 93 }
94  
55 vero 95 last:
96  
97 ?>
98  
99 <p>
100 <a class="button" href="welcome.php">Main Page</a>
101 </p>
102 </div>
103 </body>
104 </html>