+ $password = $_GET['password'];
+
+ // Check compatibility of password? TODO...
+ // Fetch old password for rollback? TODO...
+ // Verify that user exists for provisioning
+ if ( ! is_provision_user( $username, $domain ) )
+ {
+ print json_encode( array ( 'response' => 'failed', 'cause' => 'nonexistant', 'detail' => '' . $username . '@' . $domain . ' does not exist.'));
+ break;
+ }
+ if ( is_provision_user( $username, $domain ) )
+ {
+ print "WTF";
+ // Update provisioning password
+ if (! update_provision_pw( $username, $domain, $password ) )
+ {
+ print json_encode( array( 'response' => 'failed', 'cause' => 'dbfail', 'detail' => 'Failed to update provisioning password' ) );
+ break;
+ }
+ }
+ // Check for user in kamailio
+ if ( is_kamailio_subscriber( $username, $domain ) )
+ {
+ // Update kamailio password
+ if (! update_kamailio_pw( $username, $domain, $password ) )
+ {
+ print json_encode( array( 'response' => 'failed', 'cause' => 'dbfail', 'detail' => 'Failed to update kamailio password' ) );
+ break;
+ }
+ }
+ print json_encode( array ( 'response' => 'ok', 'detail' => 'Password changed for user '.$username.'@'.$domain.'.'));
+ break;