clockwerk-www – Blame information for rev 55
?pathlinks?
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" /> |
||
39 | </head> |
||
40 | <body class=dark-grey> |
||
41 | <div class="center"> |
||
42 | <img src="img/clockwerk-logo.png"> |
||
43 | <h1><?php print gethostname(); ?></h1> |
||
44 | <hr> |
||
45 | |||
46 | <?php |
||
47 | |||
48 | switch((bool)$resp->is_valid) { |
||
49 | case TRUE: |
||
50 | $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); |
||
51 | $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); |
||
52 | $rep = new SimpleXMLElement($ret); |
||
53 | foreach($rep->params->param->value->struct->member as $member) { |
||
54 | switch($member->name) { |
||
55 | case "success": |
||
56 | switch((bool)$member->value->boolean) { |
||
57 | case TRUE: |
||
58 | try { |
||
59 | $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); |
||
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)"); |
||
62 | $query->bindParam(':first', $first); |
||
63 | $query->bindParam(':last', $last); |
||
64 | $query->execute(); |
||
65 | } |
||
66 | catch(PDOException $e) { |
||
67 | print '<p>Sorry, the authenticated agent is not the owner of the region to download.</p>'; |
||
68 | goto last; |
||
69 | } |
||
70 | while ($result = $query->fetchObject()) { |
||
71 | if ($result->RegionName == $region) { |
||
72 | if (file_exists($file)) { |
||
73 | $req->admin_console_command('change region '.$region); |
||
74 | chmod($file, 0644); |
||
75 | $req->admin_console_command('load oar '.$file); |
||
76 | chmod($file, 0600); |
||
77 | echo '<p>OAR uploaded successfully.</p>'; |
||
78 | goto last; |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | goto last; |
||
83 | default: |
||
84 | echo '<p>Sorry, wrong password.</p>'; |
||
85 | goto last; |
||
86 | } |
||
87 | break; |
||
88 | } |
||
89 | } |
||
90 | default: |
||
91 | echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; |
||
47 | eva | 92 | } |
93 | |||
55 | vero | 94 | last: |
95 | |||
96 | ?> |
||
97 | |||
98 | <p> |
||
99 | <a class="button" href="welcome.php">Main Page</a> |
||
100 | </p> |
||
101 | </div> |
||
102 | </body> |
||
103 | </html> |