HEX
Server: Apache
System: Linux wyse1.wyseservers.com 4.18.0-553.124.4.el8_10.x86_64 #1 SMP Fri May 15 04:14:14 EDT 2026 x86_64
User: kochikidswysewor (1061)
PHP: 8.3.33
Disabled: NONE
Upload Files
File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/template-profile-agent.php
<?php session_start();
/**
 * @package 	WordPress
 * @subpackage 	Children Charity
 * @version		1.0.7
 * 
 * Template Name: Agent Profile
 * Created by CMSMasters
 * 
 */


get_header();

list($cmsmasters_layout) = children_charity_theme_page_layout_scheme();
$_SESSION['child_id'] = $_POST['child_id'];
$user_id = get_the_ID();
$agent = wp_get_current_user(); 
$agent_id = $agent->ID;
$agent_first_name = get_user_meta( $agent_id, 'first_name', true );
$agent_last_name = get_user_meta( $agent_id, 'last_name', true );
$agent_phone = get_field('phone_number','user_'.$agent_id);
$agent_address = get_field('address','user_'.$agent_id);
$agent_bank = get_field('bank','user_'.$agent_id);
$agent_branch = get_field('branch','user_'.$agent_id);
$agent_ifsc_code = get_field('ifsc_code','user_'.$agent_id);
$agent_account_number = get_field('account_number','user_'.$agent_id);

$decryption_iv = '1234567891011121';
$ciphering = "AES-128-CTR";
$decryption_key = "kochikids";
$options = 0;
// Store the decryption key
$agent_bank=openssl_decrypt ($agent_bank, $ciphering, 
        $decryption_key, $options, $decryption_iv);
$agent_branch=openssl_decrypt ($agent_branch, $ciphering, 
        $decryption_key, $options, $decryption_iv);

$agent_ifsc_code=openssl_decrypt ($agent_ifsc_code, $ciphering, 
        $decryption_key, $options, $decryption_iv);

$agent_account_number=openssl_decrypt ($agent_account_number, $ciphering, 
        $decryption_key, $options, $decryption_iv);



if(!$agent_id || $agent->user_role !='agent') {
  echo "<script>window.location.href='".get_site_url()."/login-register/'</script>";
}
?>
<section class="dashboard_page">
  <div class="container">
    <div class="tw-row v-gap-none">
      <?php include("agent/sidebar.php"); ?>
      <main class="tw-col-md-9 p-l-50 common_sec">
        <header class="dFlex vCenter">
          <h1 class="sec_title">Profile</h1>
          <?php include("agent/popup-btn.php"); ?>
        </header>             
        <section class="profile_wrap">
          <div class="editable_wrapper">
            <form action="javascript:void(0)" method="POST" name="personal-info" id="personal-info">
              <section class="edit_wrap">
                <header class="dFlex p-b-20">
                  <h2 class="p-b-0">Personal Info</h2>
                  <button type="button" class="edit_btn">Edit</button>
                </header>
                <div class="input-holder dFlex">
                  <label>First Name:</label>
                  <input type="hidden" value="<?php echo $agent_id; ?>" name="agent_id" id="agent_id" />
                  <input type="text" class="form-elem required" value="<?php echo $agent_first_name; ?>" name="agent_fname" id="agent_fname" title="First Name" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>Last Name:</label>
                  <input type="text" class="form-elem required" value="<?php echo $agent_last_name; ?>" name="agent_lname" id="agent_lname" title="Last Name" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>Contact No:</label>
                  <input type="text" class="form-elem required tel" value="<?php echo $agent_phone; ?>" name="agent_phone" id="agent_phone" title="Phone Number" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>Address:</label>
                  <textarea rows="5" cols="" class="form-elem required" name="agent_address" id="agent_address" title="Address" readonly><?php echo $agent_address; ?></textarea>
                </div>
                <nav class="input-holder hRight submit_wrap">
                  <input type="submit" id="update-personal-info" value="Update" class="btn btn_sm" />
                </nav>
              </section>
              </form>
              <form action="javascript:void(0)" method="POST" name="bank-info" id="bank-info">
              <section class="edit_wrap">
                <header class="dFlex p-b-20">
                  <h2 class="p-b-0">Banking Info</h2>
                  <button type="button" class="edit_btn">Edit</button>
                </header>
                <div class="input-holder dFlex">
                  <label>Bank:</label>
                  <input type="text" class="form-elem required" value="<?php echo $agent_bank; ?>" name="agent_bank" id="agent_bank" title="Bank" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>Branch:</label>
                  <input type="text" class="form-elem required" value="<?php echo $agent_branch; ?>" name="agent_branch" id="agent_branch" title="Branch" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>IFSC Code:</label>
                  <input type="text" class="form-elem required" value="<?php echo $agent_ifsc_code; ?>" name="agent_ifsc_code" id="agent_ifsc_code" title="IFSC Code" readonly />
                </div>
                <div class="input-holder dFlex">
                  <label>Account No:</label>
                  <input type="text" class="form-elem required" value="<?php echo $agent_account_number; ?>" name="agent_account_number" id="agent_account_number" title="Account No" readonly />
                </div>
                <nav class="input-holder hRight submit_wrap">
                  <input type="submit" id="update-bank-info" value="Update" class="btn btn_sm" />
                </nav>
              </section>
            </form>
            <form action="javascript:void(0)" method="POST" name="change-pwd" id="change-pwd">
              <section class="edit_wrap">
                 <header class="dFlex p-b-20">
                    <h2 class="p-b-0">Change Password</h2>
                    <button type="button" class="edit_btn">Edit</button>
                  </header>
              <div class="input-holder dFlex">
                <label>Current Password</label>
                <input type="password" class="form-elem" value="<?php echo $current_password; ?>" name="current_password" id="current_password" title="Password" readonly />
              </div>
              <div class="input-holder dFlex">
                <label>New Password</label>
                <input type="password" class="form-elem" value="" name="new_password" id="new_password" title="New Password" readonly />
              </div>
              <div class="input-holder dFlex">
                <label>Confirm New Password</label>
                <input type="password" class="form-elem" value="" name="confirm_password" id="confirm_password" title="Confirm Password" readonly />
              </div>
              <nav class="input-holder hRight">
                <input type="submit"  id="update-passsword" value="Update" class="btn btn_sm" />
              </nav>
               </section>
            </form>
          </div>
      </main>
    </div>
  </div>
</section>

<script>
jQuery('#update-personal-info').click(function(e) {
  var $formId = jQuery(this).parents('form');
  var formAction = $formId.attr('action');
  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  var phoneReg = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
  var urlReg = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
  var $error = jQuery('<span class="error"></span>');
  jQuery('span.error').remove();
  jQuery('.input-holder').removeClass('error');
  jQuery('#msghome1').hide();
  jQuery('#msghome1').removeClass('newerror');
  jQuery("#msghome1").html("");
  jQuery('.required', $formId).each(function() {
    var inputVal = jQuery.trim(jQuery(this).val());
    var fieldtitle = jQuery(this).attr("title");
    var fieldname = jQuery(this).attr("name");
    var $parentTag = jQuery(this).parent();
    if (inputVal == '' || inputVal == '-1') {
        $parentTag.addClass('error').append($error.clone().text('Please enter your ' + fieldtitle + '.'));
        jQuery(this).focus();
        return false;
    }

    if (jQuery(this).hasClass('tel') == true) {
        if (!phoneReg.test(inputVal)) {
                $parentTag.addClass('error').append($error.clone().text('Sorry, you have entered an invalid Phone number.'));
                jQuery(this).focus();
                return false;
            }
    }
  });

  if (jQuery('span.error').length > 0) {
    jQuery('span.error').each(function() {

        // Set the distance for the error animation
        var distance = 5;

        // Get the error dimensions
        var width = jQuery(this).outerWidth();

        // Calculate starting position
        var start = width + distance;

        // Set the initial CSS
        jQuery(this).show().css({
                display: 'block',
                opacity: 0
            })

            // Animate the error message
            .animate({
                opacity: 1
            }, 'slow');
          });
  } else {
    var agent_fname = document.getElementById("agent_fname").value;
    var agent_id = document.getElementById("agent_id").value;
    var agent_lname = document.getElementById("agent_lname").value; 
    var agent_phone = document.getElementById("agent_phone").value;
    var agent_address = document.getElementById("agent_address").value;  
      var action = "update-personal-info";
      jQuery.ajax({
          type: "POST",
          url: "<?php echo get_stylesheet_directory_uri(); ?>/update-agent.php",
          data: {
            agent_id: agent_id,
            agent_fname: agent_fname,
            agent_lname: agent_lname,
            action: action,
            agent_phone: agent_phone,
            agent_address: agent_address
          },
          cache: false,
          success: function(data) {
                 // alert(data);
              if (data = "updatepf") {
                  alert("Personal Info Updated Successfully!");
              }
          }
      });
} 
  // Prevent form submission
  e.preventDefault();
});
</script>


<script>
jQuery('#update-bank-info').click(function(e) {
  var $formId = jQuery(this).parents('form');
  var formAction = $formId.attr('action');
  var $error = jQuery('<span class="error"></span>');
  jQuery('span.error').remove();
  jQuery('.input-holder').removeClass('error');
  jQuery('#msghome1').hide();
  jQuery('#msghome1').removeClass('newerror');
  jQuery("#msghome1").html("");
  jQuery('.required', $formId).each(function() {
    var inputVal = jQuery.trim(jQuery(this).val());
    var fieldtitle = jQuery(this).attr("title");
    var fieldname = jQuery(this).attr("name");
    var $parentTag = jQuery(this).parent();
    if (inputVal == '' || inputVal == '-1') {
        $parentTag.addClass('error').append($error.clone().text('Please enter your ' + fieldtitle + '.'));
        jQuery(this).focus();
        return false;
    }
  });

  if (jQuery('span.error').length > 0) {
    jQuery('span.error').each(function() {

        // Set the distance for the error animation
        var distance = 5;

        // Get the error dimensions
        var width = jQuery(this).outerWidth();

        // Calculate starting position
        var start = width + distance;

        // Set the initial CSS
        jQuery(this).show().css({
                display: 'block',
                opacity: 0
            })

            // Animate the error message
            .animate({
                opacity: 1
            }, 'slow');
          });
  } else {
    var agent_id = document.getElementById("agent_id").value;
    var agent_bank = document.getElementById("agent_bank").value;
    var agent_branch = document.getElementById("agent_branch").value; 
    var agent_ifsc_code = document.getElementById("agent_ifsc_code").value;
    var agent_account_number = document.getElementById("agent_account_number").value;  
    console.log(agent_id);
      var action = "update-bank-info";
      jQuery.ajax({
          type: "POST",
          url: "<?php echo get_stylesheet_directory_uri(); ?>/update-agent.php",
          data: {
            agent_id: agent_id,
            agent_bank: agent_bank,
            agent_branch: agent_branch,
            action: action,
            agent_ifsc_code: agent_ifsc_code,
            agent_account_number: agent_account_number
          },
          cache: false,
          success: function(data) {
              if (data = 'updatebank') {
                  alert("Bank Info Updated Successfully!");
              }
          }
      });
} 
  // Prevent form submission
  e.preventDefault();
});
</script>


<script>
jQuery('#update-passsword').click(function(e) {
  var $formId = jQuery(this).parents('form');
  var formAction = $formId.attr('action');
  var $error = jQuery('<span class="error"></span>');
  jQuery('span.error').remove();
  jQuery('.input-holder').removeClass('error');
  jQuery('#msghome1').hide();
  jQuery('#msghome1').removeClass('newerror');
  jQuery("#msghome1").html("");
  jQuery('.required', $formId).each(function() {
    var inputVal = jQuery.trim(jQuery(this).val());
    var fieldtitle = jQuery(this).attr("title");
    var fieldname = jQuery(this).attr("name");
    var $parentTag = jQuery(this).parent();
    if (inputVal == '' || inputVal == '-1') {
        $parentTag.addClass('error').append($error.clone().text('Please enter the' + fieldtitle + '.'));
        jQuery(this).focus();
        return false;
    }
  });

  if (jQuery('span.error').length > 0) {
    jQuery('span.error').each(function() {

        // Set the distance for the error animation
        var distance = 5;

        // Get the error dimensions
        var width = jQuery(this).outerWidth();

        // Calculate starting position
        var start = width + distance;

        // Set the initial CSS
        jQuery(this).show().css({
                display: 'block',
                opacity: 0
            })

            // Animate the error message
            .animate({
                opacity: 1
            }, 'slow');
          });
  } else {
    var agent_id = document.getElementById("agent_id").value;
    var current_password = document.getElementById("current_password").value;
    var new_password = document.getElementById("new_password").value;
    var confirm_password = document.getElementById("confirm_password").value;
    if(new_password.length < 6) {
        var $parentTag = jQuery(document.getElementById("new_password")).parent();
        $parentTag.addClass('error').append($error.clone().text('Passwords must have atleast 6 characters.'));
        document.getElementById("new_password").value = "";
        document.getElementById("confirm_password").value = "";
        jQuery(document.getElementById("new_password")).focus();
        return false;

    }
     if (new_password != confirm_password) { 

                var $parentTag = jQuery(document.getElementById("new_password")).parent();
                $parentTag.addClass('error').append($error.clone().text('Passwords do not match!'));

                document.getElementById("new_password").value = "";
                document.getElementById("confirm_password").value = "";
                jQuery(document.getElementById("new_password")).focus();

            } else { 
              var action = "update-password";
              jQuery.ajax({
                  type: "POST",
                  url: "<?php echo get_stylesheet_directory_uri(); ?>/update-agent.php",
                  data: {
                    agent_id: agent_id,
                     new_password: new_password,
                    current_password: current_password,
                    action: action,
                  },
                  cache: false,
                  success: function(data) {
                    alert(data);
                  }
              });
      } 
}
  // Prevent form submission
  e.preventDefault();
});
</script>


<?php 
$post_id = $_SESSION['child_id'];
$user = wp_get_current_user(); 
$user_id = $user->ID;
if ( ! add_post_meta( $post_id, 'agent', $user_id, true ) ) { 
   update_post_meta ( $post_id, 'agent', $user_id );
}
?>
<?php get_footer();