clockwerk-www – Rev 67

Subversion Repositories:
Rev:
<?php

  require_once 'lib/recaptchalib.php';
  require_once 'lib/wasRemoteAdmin.php';
  require_once 'lib/uuid.php';

  define('RECAPTCHA_PRIVATE_KEY', '6Lcz9ukSAAAAAC3u90rcOIdnNnaK_JgMjrOsSzZr');
  
?>

<!DOCTYPE html>
<html>
<head>
<title>Clockwerk</title>
<link rel="stylesheet" href="css/gray.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class=dark-grey>
<div class="center">
<img src="img/clockwerk-logo.png" alt="logo">
<h1><?php print gethostname(); ?></h1>
<hr>

<?php
  
  $first = $_POST["first"];
  $last = $_POST["last"];
  $oldpassword = $_POST["oldpassword"];
  $newpassword = $_POST["newpassword"];

  $resp=recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
    $_SERVER["REMOTE_ADDR"],
    $_POST["recaptcha_challenge_field"],
    $_POST["recaptcha_response_field"]);
  
  switch((bool)$resp->is_valid) {
    case TRUE:
      $req = new wasRemoteAdmin('http://127.0.0.1:10000', 'opensim');
      $ret = $req->admin_authenticate_user($first, $last, MD5($oldpassword), '1');
      $rep = new SimpleXMLElement($ret);
      foreach($rep->params->param->value->struct->member as $member) {
        switch($member->name) {
          case "success":
            switch((bool)$member->value->boolean) {
              case TRUE:
                $ret = $req->admin_update_user($first, $last, $newpassword, '128', '128');
                $rep = new SimpleXMLElement($ret);
                foreach($rep->params->param->value->struct->member as $member) {
                  switch($member->name) {
                    case "success":
                      switch((bool)$member->value->boolean) {
                        case TRUE:
                          echo '<p>Account updated successfully.</p>';
                          goto last;
                        default:
                          echo '<p>Sorry, the account could not be updated at this time.</p>';
                          goto last;
                      }
                      break;
                  }
                }
                goto last;
              default:
                echo '<p>Sorry, wrong password.</p>';
                goto last;
            }
            break;
          }
        }
    default:
      echo '<p>Sorry, incorrect CAPTCHA. Please try again.</p>';
  }
  
last:

?>

<form class="dark-grey">
<input type="button" onclick="parent.location='reset.php'" value="Reset Password">
<input type="button" onclick="parent.location='welcome.php'" value="Main Page">
</form>
</div>
</body>
</html>