clockwerk-www – Blame information for rev 72
?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" /> |
||
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: |
||
72 | eva | 59 | try { |
55 | vero | 60 | $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); |
61 | $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
72 | eva | 62 | $query = $mysql->prepare("SELECT UserLevel FROM UserAccounts WHERE FirstName=:first AND LastName=:last"); |
55 | vero | 63 | $query->bindParam(':first', $first); |
64 | $query->bindParam(':last', $last); |
||
65 | $query->execute(); |
||
72 | eva | 66 | $result=$query->fetch(PDO::FETCH_ASSOC); |
55 | vero | 67 | } |
68 | catch(PDOException $e) { |
||
72 | eva | 69 | print '<p>Sorry, a database error occurred.</p>'; |
55 | vero | 70 | goto last; |
71 | } |
||
72 | eva | 72 | if($result['UserLevel'] < 100) { |
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>'; |
||
82 | goto last; |
||
83 | } |
||
55 | vero | 84 | goto last; |
85 | default: |
||
86 | echo '<p>Sorry, wrong password.</p>'; |
||
87 | goto last; |
||
88 | } |
||
89 | break; |
||
90 | } |
||
91 | } |
||
92 | default: |
||
93 | echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; |
||
47 | eva | 94 | } |
95 | |||
55 | vero | 96 | last: |
97 | |||
98 | ?> |
||
99 | |||
67 | vero | 100 | <form class="dark-grey"> |
101 | <input type="button" onclick="parent.location='welcome.php'" value="Main Page"> |
||
102 | </form> |
||
55 | vero | 103 | </div> |
104 | </body> |
||
105 | </html> |