File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/update-agent.php
<?php
include "../../../wp-load.php";
if ($_REQUEST["action"] === "") {
echo "<script>alert('Invalid data!');window.location.href='" .
get_site_url() .
"'</script>";
}
if ($_REQUEST["action"] == "update-personal-info") {
$agent_id = $_POST["agent_id"];
$agent_fname = $_POST["agent_fname"];
$agent_lname = $_POST["agent_lname"];
$agent_phone = $_POST["agent_phone"];
$agent_address = $_POST["agent_address"];
if ($_POST["agent_fname"] && $_POST["agent_lname"]) {
$userdata = [
"ID" => $agent_id,
"first_name" => $agent_fname,
"last_name" => $agent_lname,
];
wp_update_user($userdata);
update_user_meta($agent_id, "phone_number", $agent_phone);
update_user_meta($agent_id, "address", $agent_address);
echo "updatepf";
}
}
if ($_REQUEST["action"] == "update-bank-info") {
$agent_id = $_POST["agent_id"];
$agent_bank = $_POST["agent_bank"];
$agent_branch = $_POST["agent_branch"];
$agent_ifsc_code = $_POST["agent_ifsc_code"];
$agent_account_number = $_POST["agent_account_number"];
// Store the cipher method
$ciphering = "AES-128-CTR";
// Use OpenSSl Encryption method
$iv_length = openssl_cipher_iv_length($ciphering);
$options = 0;
// Non-NULL Initialization Vector for encryption
$encryption_iv = "1234567891011121";
// Store the encryption key
$encryption_key = "kochikids";
// Use openssl_encrypt() function to encrypt the data
$agent_bank = openssl_encrypt(
$agent_bank,
$ciphering,
$encryption_key,
$options,
$encryption_iv
);
$agent_branch = openssl_encrypt(
$agent_branch,
$ciphering,
$encryption_key,
$options,
$encryption_iv
);
$agent_ifsc_code = openssl_encrypt(
$agent_ifsc_code,
$ciphering,
$encryption_key,
$options,
$encryption_iv
);
$agent_account_number = openssl_encrypt(
$agent_account_number,
$ciphering,
$encryption_key,
$options,
$encryption_iv
);
update_user_meta($agent_id, "bank", $agent_bank);
update_user_meta($agent_id, "branch", $agent_branch);
update_user_meta($agent_id, "ifsc_code", $agent_ifsc_code);
update_user_meta($agent_id, "account_number", $agent_account_number);
echo "updatebank";
}
if ($_REQUEST["action"] == "update-password") {
$agent_id = $_POST["agent_id"];
$current_password = $_POST["current_password"];
$new_password = $_POST["new_password"];
$user = get_user_by("id", $agent_id);
if (
$user &&
wp_check_password($current_password, $user->data->user_pass, $agent_id)
) {
wp_set_password($new_password, $agent_id);
echo "Password Updated Successfully.";
} else {
echo "Current Password is incorrect";
}
}
?>