create_user($name, $pwd)) { log_error("successfully created user"); exit(json_encode(strtolower($name))); } else { log_error("create user failed"); report_problem(WEAVE_ERROR_NO_OVERWRITE, 503); } } catch(Exception $e) { log_error("db exception create user"); header("X-Weave-Backoff: 1800"); report_problem($e->getMessage(), $e->getCode()); } } else { log_error("register not enabled"); report_problem(WEAVE_ERROR_FUNCTION_NOT_SUPPORTED,400); } } // ende put else if($_SERVER['REQUEST_METHOD'] == 'POST') { if($username == '') { log_error("user.php : Post no username"); report_problem(WEAVE_ERROR_INVALID_USERNAME, 400); } $db = new WeaveStorage($username); log_error("user.php: POST"); if($function == "password") { #Auth the user verify_user($username, $db); $new_pwd = get_phpinput(); log_error("user.php: POST password "); //to do // change pw in db $hash = WeaveHashFactory::factory(); if($db->change_password($hash->hash($new_pwd))) exit("success"); else report_problem(WEAVE_ERROR_INVALID_PROTOCOL, 503); //server db messed up somehow // return success // report_problem(7, 400); } else if($function == "email") { //change email adr } else if($function == "delete_account") { //remove account and data from sync server // 1. verify user auth, needs $auth_pw passed to function. if($auth_pw == '') { log_error("user.php : delete account, no auth password given"); report_problem(WEAVE_ERROR_MISSING_PASSWORD, 400); } try { $existingHash = $db->get_password_hash(); //passes $username internally $hash = WeaveHashFactory::factory(); if ( ! $hash->verify(fix_utf8_encoding($auth_pw), $existingHash) ) { log_error("Auth failed 2 {"); log_error(" User pw: ". $auth_user ."|".$auth_pw ."|md5:". md5($auth_pw) ."|fix:". fix_utf8_encoding($auth_pw) ."|fix md5 ". md5(fix_utf8_encoding($auth_pw))); log_error(" Url_user: ".$url_user); log_error(" Existing hash: ".$existingHash); log_error("}"); report_problem('Authentication failed', '401'); } else { // 2. get collections + data and remove data // 3. remove user account } } catch(Exception $e) { header("X-Weave-Backoff: 1800"); log_error($e->getMessage(), $e->getCode()); report_problem($e->getMessage(), $e->getCode()); } } else { report_problem(WEAVE_ERROR_INVALID_PROTOCOL, 400); } // exit('success'); } } catch(Exception $e) { report_problem($e->getMessage(), $e->getCode()); } #The datasets we might be dealing with here are too large for sticking it all into an array, so #we need to define a direct-output method for the storage class to use. If we start producing multiples #(unlikely), we can put them in their own class. #include_once "WBOJsonOutput.php"; ?>