clockwerk-www – Blame information for rev 72
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
7 | vero | 1 | <?php |
2 | |||
44 | vero | 3 | /////////////////////////////////////////////////////////////////////////// |
4 | // Copyright (C) Wizardry and Steamworks 2014 - License: MIT // |
||
5 | /////////////////////////////////////////////////////////////////////////// |
||
6 | |||
7 | vero | 7 | // Hostname or IP of your OpenSim MySQL server. |
44 | vero | 8 | $MYSQL_HOSTNAME='localhost'; |
7 | vero | 9 | // Username of the OpenSim MySQL user. |
44 | vero | 10 | $MYSQL_USERNAME='opensim'; |
7 | vero | 11 | // Password of the OpenSim MySQL user. |
44 | vero | 12 | $MYSQL_PASSWORD='***'; |
7 | vero | 13 | // Name of the OpenSim database on the MySQL server. |
44 | vero | 14 | $MYSQL_DATABASE='opensim'; |
7 | vero | 15 | |
16 | require_once 'lib/recaptchalib.php'; |
||
17 | require_once 'lib/wasRemoteAdmin.php'; |
||
18 | |||
19 | define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr'); |
||
20 | |||
46 | vero | 21 | $first = $_POST["first"]; |
22 | $last = $_POST["last"]; |
||
23 | $region = $_POST["region"]; |
||
24 | $password = $_POST["password"]; |
||
7 | vero | 25 | |
26 | $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, |
||
27 | $_SERVER["REMOTE_ADDR"], |
||
28 | $_POST["recaptcha_challenge_field"], |
||
29 | $_POST["recaptcha_response_field"]); |
||
30 | |||
57 | vero | 31 | ?> |
32 | |||
33 | <!DOCTYPE html> |
||
34 | <html> |
||
35 | <head> |
||
36 | <title>Clockwerk</title> |
||
37 | <link rel="stylesheet" href="css/gray.css" type="text/css" /> |
||
38 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
||
39 | </head> |
||
40 | <body class=dark-grey> |
||
41 | <div class="center"> |
||
42 | <img src="img/clockwerk-logo.png" alt="logo"> |
||
43 | <h1><?php print gethostname(); ?></h1> |
||
44 | <hr> |
||
45 | |||
46 | <?php |
||
47 | |||
7 | vero | 48 | if ($resp->is_valid) { |
44 | vero | 49 | $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); |
50 | $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); |
||
51 | $rep = new SimpleXMLElement($ret); |
||
52 | foreach($rep->params->param->value->struct->member as $member) { |
||
53 | if ($member->name == "success" && $member->value->boolean == "0") { |
||
54 | echo 'Sorry, wrong password.'; |
||
58 | vero | 55 | goto last; |
7 | vero | 56 | } |
44 | vero | 57 | } |
72 | eva | 58 | try { |
44 | vero | 59 | $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); |
60 | $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
72 | eva | 61 | $query = $mysql->prepare("SELECT UserLevel FROM UserAccounts WHERE FirstName=:first AND LastName=:last"); |
44 | vero | 62 | $query->bindParam(':first', $first); |
63 | $query->bindParam(':last', $last); |
||
64 | $query->execute(); |
||
72 | eva | 65 | $result=$query->fetch(PDO::FETCH_ASSOC); |
44 | vero | 66 | } |
67 | catch(PDOException $e) { |
||
72 | eva | 68 | print '<p>Sorry, a database error occurred.</p>'; |
69 | goto last; |
||
44 | vero | 70 | } |
72 | eva | 71 | if($result['UserLevel'] < 100) { |
72 | print '<p>Sorry, the authenticated agent does not have the necessary level to download OARs.</p>'; |
||
73 | goto last; |
||
74 | } |
||
75 | $oar_path = '/var/lib/oar/'.$region.'/'.$region.'.oar'; |
||
76 | if (file_exists($oar_path)) { |
||
77 | header('Content-Description: File Transfer'); |
||
78 | header('Content-Type: application/x-gzip-compressed'); |
||
79 | header('Content-Disposition: attachment; filename='.basename($oar_path)); |
||
80 | header('Content-Transfer-Encoding: binary'); |
||
81 | header('Expires: 0'); |
||
82 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||
83 | header('Pragma: public'); |
||
84 | header('Content-Length: '.filesize($oar_path)); |
||
85 | readfile($oar_path); |
||
86 | goto last; |
||
87 | } |
||
88 | echo '<p>Sorry, the OAR file is not available yet.</p>'; |
||
89 | goto last; |
||
7 | vero | 90 | } |
91 | |||
44 | vero | 92 | echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; |
57 | vero | 93 | |
60 | vero | 94 | last: |
58 | vero | 95 | |
57 | vero | 96 | ?> |
97 | |||
67 | vero | 98 | <form class="dark-grey"> |
99 | <input type="button" onclick="parent.location='welcome.php'" value="Main Page"> |
||
100 | </form> |
||
57 | vero | 101 | </div> |
102 | </body> |
||
103 | </html> |