clockwerk-www – Blame information for rev 7
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
7 | vero | 1 | <?php |
2 | |||
3 | ///////////////////////////////////////////////////////////// |
||
4 | // Wizardry and Steamworks (c) was.fm - 2014, License: MIT // |
||
5 | // // |
||
6 | // Permission is hereby granted, free of charge, to any // |
||
7 | // person obtaining a copy of this software and associated // |
||
8 | // documentation files (the "Software"), to deal in the // |
||
9 | // Software without restriction, //including without // |
||
10 | // limitation the rights to use, copy, modify, merge, // |
||
11 | // publish, distribute, sublicense, and/or sell copies of // |
||
12 | // the Software, and to permit persons to whom the // |
||
13 | // Software is furnished to do so, subject to the // |
||
14 | // following conditions: // |
||
15 | // // |
||
16 | // The above copyright notice and this permission notice // |
||
17 | // shall be included in all copies or substantial portions // |
||
18 | // of the Software. // |
||
19 | // // |
||
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // |
||
21 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // |
||
22 | // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // |
||
23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO // |
||
24 | // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // |
||
25 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // |
||
26 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // |
||
27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR // |
||
28 | // THE USE OR OTHER DEALINGS IN THE SOFTWARE. // |
||
29 | ///////////////////////////////////////////////////////////// |
||
30 | ///////////////////////////////////////////////////////////// |
||
31 | // CONFIGURATION // |
||
32 | ///////////////////////////////////////////////////////////// |
||
33 | // Hostname or IP of your OpenSim MySQL server. |
||
34 | define("MYSQL_HOSTNAME", "localhost"); |
||
35 | // Username of the OpenSim MySQL user. |
||
36 | define("MYSQL_USERNAME", "opensim"); |
||
37 | // Password of the OpenSim MySQL user. |
||
38 | define("MYSQL_PASSWORD", "***"); |
||
39 | // Name of the OpenSim database on the MySQL server. |
||
40 | define("MYSQL_DATABASE", "opensim"); |
||
41 | |||
42 | require_once 'lib/recaptchalib.php'; |
||
43 | require_once 'lib/wasRemoteAdmin.php'; |
||
44 | |||
45 | define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr'); |
||
46 | |||
47 | $first = $_POST["first"]; |
||
48 | $last = $_POST["last"]; |
||
49 | $region = $_POST["region"]; |
||
50 | $password = $_POST["password"]; |
||
51 | |||
52 | $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, |
||
53 | $_SERVER["REMOTE_ADDR"], |
||
54 | $_POST["recaptcha_challenge_field"], |
||
55 | $_POST["recaptcha_response_field"]); |
||
56 | |||
57 | if ($resp->is_valid) { |
||
58 | $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); |
||
59 | $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); |
||
60 | $rep = new SimpleXMLElement($ret); |
||
61 | foreach($rep->params->param->value->struct->member as $member) { |
||
62 | if ($member->name == "success" && $member->value->boolean == "0") { |
||
63 | echo 'Sorry, wrong password.'; |
||
64 | exit; |
||
65 | } |
||
66 | } |
||
67 | try { |
||
68 | $mysql = new PDO('mysql:host=MYSQL_HOSTNAME;dbname=MYSQL_DATABASE;', 'MYSQL_USERNAME', 'MYSQL_PASSWORD'); |
||
69 | $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
70 | $query = $mysql->prepare("INSERT INTO DB_REALM.account (username,sha_pass_hash,email) VALUES(:username,:password,:email)"); |
||
71 | $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)"); |
||
72 | $query->bindParam(':first', $first); |
||
73 | $query->bindParam(':last', $last); |
||
74 | $query->execute(); |
||
75 | } |
||
76 | catch(PDOException $e) { |
||
77 | print 'The given agent is not the owner of the region to download.'; |
||
78 | return 1; |
||
79 | } |
||
80 | while ($result = $query->fetchObject()) { |
||
81 | if ($result->RegionName == $region) { |
||
82 | $oar_path = '/var/lib/oar/'.$region.'.oar'; |
||
83 | if (file_exists($oar_path)) { |
||
84 | if (false !== ($handler = fopen($oar_path, 'r'))) { |
||
85 | header('Content-Description: File Transfer'); |
||
86 | header('Content-Type: application/x-gzip-compressed'); |
||
87 | header('Content-Disposition: attachment; filename='.basename($oar_path)); |
||
88 | header('Content-Transfer-Encoding: binary'); |
||
89 | header('Expires: 0'); |
||
90 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||
91 | header('Pragma: public'); |
||
92 | header('Content-Length: '.filesize($oar_path)); |
||
93 | while (false !== ($chunk = fread($handler, 4096))) { |
||
94 | echo $chunk; |
||
95 | } |
||
96 | } |
||
97 | exit; |
||
98 | } |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | |||
103 | echo '<p>Sorry, incorrect captcha. Please try again.</p>'; |