<commit_before><?
/**
 * member settings
 *
 * @author <NAME> <<EMAIL>>
 * @package Basisentscheid
 */


require "inc/common.php";

Login::access("member");

if ($action) {
	switch ($action) {
	case "save":
		action_required_parameters('username', 'password', 'password2', 'mail', 'profile');
		if (GNUPG_SIGN_KEY) action_required_parameters('fingerprint', 'key');

		$save_fields = array();
		$success_msgs = array();

		// save username
		$username = trim($_POST['username']);
		if ( $username != Login::$member->username and Login::check_username($username) ) {
			Login::$member->username = $username;
			$save_fields[] = "username";
			$success_msgs[] = _("The new username has been saved.");
		}

		// save password
		$password  = trim($_POST['password']);
		$password2 = trim($_POST['password2']);
		if ( ($password or $password2) and Login::check_password($password, $password2) ) {
			Login::$member->set_new_password($password);
			$save_fields[] = "password";
			$success_msgs[] = _("The new password has been saved.");
		}

		// save fingerprint
		if (GNUPG_SIGN_KEY) {
			$fingerprint = trim($_POST['fingerprint']);
			if ( $fingerprint != Login::$member->fingerprint ) {
				Login::$member->set_fingerprint($fingerprint);
				$save_fields[] = "fingerprint";
				$success_msgs[] = _("The PGP public key fingerprint has been saved.");
			}
		}

		// save profile
		$profile = trim($_POST['profile']);
		if ( $profile != Login::$member->profile ) {
			Login::$member->set_profile($profile);
			$save_fields[] = "profile";
			$success_msgs[] = _("The profile has been saved.");
		}

		Login::$member->update($save_fields);
		foreach ($success_msgs as $msg) success($msg);

		// save mail
		$mail = trim($_POST['mail']);
		if (
			$mail != Login::$member->mail and
			( $mail != Login::$member->mail_unconfirmed or !empty($_POST['submit_mail']) ) and
			Login::check_mail($mail)
		) {
			Login::$member->set_mail($mail);
		}

		// import PGP public key
		if (GNUPG_SIGN_KEY and $_POST['key']) {
			$gnupg = new_gnupg();
			$import = $gnupg->import($_POST['key']);
			if (DEBUG) {
?>
<!--
<?=h(var_dump($import))?>
-->
<?
			}
			if ($import['imported'] + $import['unchanged'] + $import['newuserids'] + $import['newsubkeys'] > 1) {
				notice(sprintf(_("Multiple keys were uploaded at once. %d keys have been imported and %d keys are unchanged."), $import['imported'], $import['unchanged']));
			} elseif ($import['imported'] or $import['newuserids'] or $import['newuserids'] or $import['newsubkeys']) {
				if ($import['fingerprint'] != Login::$member->fingerprint()) {
					notice(_("The key has been imported, but does not match the fingerprint."));
				} else {
					$info = $gnupg->keyinfo($import['fingerprint']);
					if ( !Login::$member->keyinfo_matches_email($info) ) {
						notice(_("The key has been imported, but does not match the email address."));
					} else {
						success(_("The key has been imported."));<commit_msg>fix: var_dump() does not return but display<commit_after><?
/**
 * member settings
 *
 * @author <NAME> <<EMAIL>>
 * @package Basisentscheid
 */


require "inc/common.php";

Login::access("member");

if ($action) {
	switch ($action) {
	case "save":
		action_required_parameters('username', 'password', '<PASSWORD>', 'mail', 'profile');
		if (GNUPG_SIGN_KEY) action_required_parameters('fingerprint', 'key');

		$save_fields = array();
		$success_msgs = array();

		// save username
		$username = trim($_POST['username']);
		if ( $username != Login::$member->username and Login::check_username($username) ) {
			Login::$member->username = $username;
			$save_fields[] = "username";
			$success_msgs[] = _("The new username has been saved.");
		}

		// save password
		$password  = trim($_POST['password']);
		$password2 = trim($_POST['password2']);
		if ( ($password or $password2) and Login::check_password($password, $password2) ) {
			Login::$member->set_new_password($password);
			$save_fields[] = "password";
			$success_msgs[] = _("The new password has been saved.");
		}

		// save fingerprint
		if (GNUPG_SIGN_KEY) {
			$fingerprint = trim($_POST['fingerprint']);
			if ( $fingerprint != Login::$member->fingerprint ) {
				Login::$member->set_fingerprint($fingerprint);
				$save_fields[] = "fingerprint";
				$success_msgs[] = _("The PGP public key fingerprint has been saved.");
			}
		}

		// save profile
		$profile = trim($_POST['profile']);
		if ( $profile != Login::$member->profile ) {
			Login::$member->set_profile($profile);
			$save_fields[] = "profile";
			$success_msgs[] = _("The profile has been saved.");
		}

		Login::$member->update($save_fields);
		foreach ($success_msgs as $msg) success($msg);

		// save mail
		$mail = trim($_POST['mail']);
		if (
			$mail != Login::$member->mail and
			( $mail != Login::$member->mail_unconfirmed or !empty($_POST['submit_mail']) ) and
			Login::check_mail($mail)
		) {
			Login::$member->set_mail($mail);
		}

		// import PGP public key
		if (GNUPG_SIGN_KEY and $_POST['key']) {
			$gnupg = new_gnupg();
			$import = $gnupg->import($_POST['key']);
			if (DEBUG) {
?>
<!--
<?=h(print_r($import, true))?>
-->
<?
			}
			if ($import['imported'] + $import['unchanged'] + $import['newuserids'] + $import['newsubkeys'] > 1) {
				notice(sprintf(_("Multiple keys were uploaded at once. %d keys have been imported and %d keys are unchanged."), $import['imported'], $import['unchanged']));
			} elseif ($import['imported'] or $import['newuserids'] or $import['newuserids'] or $import['newsubkeys']) {
				if ($import['fingerprint'] != Login::$member->fingerprint()) {
					notice(_("The key has been imported, but does not match the fingerprint."));
				} else {
					$info = $gnupg->keyinfo($import['fingerprint']);
					if ( !Login::$member->keyinfo_matches_email($info) ) {
						notice(_("The key has been imported, but does not match the email address."));
					} else {
						success(_("The key has been imported."));
{'fraction_non_alphanumeric': 0.19568151147098514, 'fraction_numerical': 0.001855600539811066, 'mean_word_length': 4.4096715328467155, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5898644', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1899, 'n_words': 436}