clockwerk-www – Blame information for rev 47

Subversion Repositories:
Rev:
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  
32 if ($resp->is_valid) {
33 $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim');
34 $ret = $req->admin_authenticate_user($first, $last, MD5($password), '1');
35 $rep = new SimpleXMLElement($ret);
36 foreach($rep->params->param->value->struct->member as $member) {
37 if ($member->name == "success" && $member->value->boolean == "0") {
38 echo 'Sorry, wrong password.';
39 exit;
40 }
41 }
42 try {
43 $mysql = new PDO('mysql:host='.$MYSQL_HOSTNAME.';dbname='.$MYSQL_DATABASE.';', $MYSQL_USERNAME, $MYSQL_PASSWORD);
44 $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)");
46 $query->bindParam(':first', $first);
47 $query->bindParam(':last', $last);
48 $query->execute();
49 }
50 catch(PDOException $e) {
51 print 'The given agent is not the owner of the region to download.';
52 return 1;
53 }
54 while ($result = $query->fetchObject()) {
55 if ($result->RegionName == $region) {
56 if (file_exists($file)) {
57 $req->admin_console_command('change region '.$region);
58 $req->admin_console_command('load oar '.$file);
59 header('Location: welcome.php');
60 exit;
61 }
62 }
63 }
64 }
65  
66 echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';