clockwerk-www – Diff between revs 47 and 50
?pathlinks?
Rev 47 | Rev 50 | |||
---|---|---|---|---|
1 | <?php |
1 | <?php |
|
2 | |
2 | |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // Copyright (C) Wizardry and Steamworks 2014 - License: MIT // |
4 | // Copyright (C) Wizardry and Steamworks 2014 - License: MIT // |
|
5 | /////////////////////////////////////////////////////////////////////////// |
5 | /////////////////////////////////////////////////////////////////////////// |
|
- | 6 | |
||
- | 7 | /////////////////////////////////////////////////////////////////////////// |
||
- | 8 | // Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 // |
||
- | 9 | /////////////////////////////////////////////////////////////////////////// |
||
- | 10 | function wasChown($path, $uid, $gid) { |
||
- | 11 | switch(filetype($path)) { |
||
- | 12 | case 'dir': |
||
- | 13 | if(($dir = opendir($path)) === false) break; |
||
- | 14 | while(false !== ($file = readdir($dir))) { |
||
- | 15 | if($file == '.' || $file == '..') continue; |
||
- | 16 | wasChown($path.'/'.$file, $uid, $gid); |
||
- | 17 | } |
||
- | 18 | case 'file': |
||
- | 19 | chown($path, $uid); |
||
- | 20 | chgrp($path, $gid); |
||
- | 21 | break; |
||
- | 22 | } |
||
- | 23 | } |
||
6 | |
24 | |
|
7 | // Hostname or IP of your OpenSim MySQL server. |
25 | // Hostname or IP of your OpenSim MySQL server. |
|
8 | $MYSQL_HOSTNAME='localhost'; |
26 | $MYSQL_HOSTNAME='localhost'; |
|
9 | // Username of the OpenSim MySQL user. |
27 | // Username of the OpenSim MySQL user. |
|
10 | $MYSQL_USERNAME='opensim'; |
28 | $MYSQL_USERNAME='opensim'; |
|
11 | // Password of the OpenSim MySQL user. |
29 | // Password of the OpenSim MySQL user. |
|
12 | $MYSQL_PASSWORD='***'; |
30 | $MYSQL_PASSWORD='***'; |
|
13 | // Name of the OpenSim database on the MySQL server. |
31 | // Name of the OpenSim database on the MySQL server. |
|
14 | $MYSQL_DATABASE='opensim'; |
32 | $MYSQL_DATABASE='opensim'; |
|
15 | |
33 | |
|
16 | require_once 'lib/recaptchalib.php'; |
34 | require_once 'lib/recaptchalib.php'; |
|
17 | require_once 'lib/wasRemoteAdmin.php'; |
35 | require_once 'lib/wasRemoteAdmin.php'; |
|
18 | |
36 | |
|
19 | define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr'); |
37 | define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr'); |
|
20 | |
38 | |
|
21 | $first = $_POST["first"]; |
39 | $first = $_POST["first"]; |
|
22 | $last = $_POST["last"]; |
40 | $last = $_POST["last"]; |
|
23 | $region = $_POST["region"]; |
41 | $region = $_POST["region"]; |
|
24 | $file = $_FILES["file"]["tmp_name"]; |
42 | $file = $_FILES["file"]["tmp_name"]; |
|
25 | $password = $_POST["password"]; |
43 | $password = $_POST["password"]; |
|
26 | |
44 | |
|
27 | $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, |
45 | $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, |
|
28 | $_SERVER["REMOTE_ADDR"], |
46 | $_SERVER["REMOTE_ADDR"], |
|
29 | $_POST["recaptcha_challenge_field"], |
47 | $_POST["recaptcha_challenge_field"], |
|
30 | $_POST["recaptcha_response_field"]); |
48 | $_POST["recaptcha_response_field"]); |
|
31 | |
49 | |
|
32 | if ($resp->is_valid) { |
50 | if ($resp->is_valid) { |
|
33 | $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); |
51 | $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim'); |
|
34 | $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); |
52 | $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1'); |
|
35 | $rep = new SimpleXMLElement($ret); |
53 | $rep = new SimpleXMLElement($ret); |
|
36 | foreach($rep->params->param->value->struct->member as $member) { |
54 | foreach($rep->params->param->value->struct->member as $member) { |
|
37 | if ($member->name == "success" && $member->value->boolean == "0") { |
55 | if ($member->name == "success" && $member->value->boolean == "0") { |
|
38 | echo 'Sorry, wrong password.'; |
56 | echo 'Sorry, wrong password.'; |
|
39 | exit; |
57 | exit; |
|
40 | } |
58 | } |
|
41 | } |
59 | } |
|
42 | try { |
60 | try { |
|
43 | $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); |
61 | $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD); |
|
44 | $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
62 | $mysql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
45 | $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)"); |
63 | $query = $mysql->prepare("SELECT RegionName FROM regions WHERE owner_uuid=(SELECT PrincipalID FROM UserAccounts WHERE FirstName=:first AND LastName=:last)"); |
|
46 | $query->bindParam(':first', $first); |
64 | $query->bindParam(':first', $first); |
|
47 | $query->bindParam(':last', $last); |
65 | $query->bindParam(':last', $last); |
|
48 | $query->execute(); |
66 | $query->execute(); |
|
49 | } |
67 | } |
|
50 | catch(PDOException $e) { |
68 | catch(PDOException $e) { |
|
51 | print 'The given agent is not the owner of the region to download.'; |
69 | print 'The given agent is not the owner of the region to download.'; |
|
52 | return 1; |
70 | return 1; |
|
53 | } |
71 | } |
|
54 | while ($result = $query->fetchObject()) { |
72 | while ($result = $query->fetchObject()) { |
|
55 | if ($result->RegionName == $region) { |
73 | if ($result->RegionName == $region) { |
|
56 | if (file_exists($file)) { |
74 | if (file_exists($file)) { |
|
57 | $req->admin_console_command('change region '.$region); |
75 | $req->admin_console_command('change region '.$region); |
|
- | 76 | wasChown($file, 'opensim', 'opensim'); |
||
58 | $req->admin_console_command('load oar '.$file); |
77 | $req->admin_console_command('load oar '.$file); |
|
- | 78 | wasChown($file, 'www-data', 'www-data'); |
||
59 | header('Location: welcome.php'); |
79 | header('Location: welcome.php'); |
|
60 | exit; |
80 | exit; |
|
61 | } |
81 | } |
|
62 | } |
82 | } |
|
63 | } |
83 | } |
|
64 | } |
84 | } |
|
65 | |
85 | |
|
66 | echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; |
86 | echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>'; |
|
67 | |
87 | |