Your IP : 216.73.217.77


Current Path : /home/users/unlimited/www/facebook.codeskitter.site/themes/wowonder/layout/setting/
Upload File :
Current File : /home/users/unlimited/www/facebook.codeskitter.site/themes/wowonder/layout/setting/two-factor.phtml

<div class="wo_settings_page wow_content">
	<div class="avatar-holder two_factor">
		<img src="<?php echo $wo['setting']['avatar']?>" alt="<?php echo $wo['setting']['name']?> Profile Picture" class="avatar">
		<div class="infoz">
			<h5 title="<?php echo $wo['setting']['name']?>"><a href="<?php echo Wo_SeoLink('index.php?link1=timeline&u=' . $wo['setting']['username'] . '');?>" data-ajax="?link1=timeline&u=<?php echo $wo['setting']['username'] ?>"><?php echo $wo['setting']['name']?></a></h5>
			<p><?php echo $wo['lang']['two_factor']; ?></p>
		</div>
	</div>
	<hr>

	<form class="form-horizontal setting-change-password-form" method="post">
		<div class="setting-password-alert setting-update-alert"></div>


		<?php if ($wo['setting']['two_factor'] == '0') { ?>
        
			<div class="wow_form_fields">
				<label for="two_factor_method"><?php echo $wo['lang']['two_factor_method'] ?></label>
				<select id="two_factor_method" name="two_factor_method" class="form-control" onchange="showMethod(this)">
					<?php if ($wo['config']['two_factor'] == '1') { ?>
						<option value="two_factor" <?php echo ($wo['setting']['two_factor_method'] == 'two_factor') ? 'selected': '';?>><?php echo getTwoFactorText(); ?></option>
					<?php } ?>
					<?php if ($wo['config']['google_authenticator'] == '1') { ?>
					<option value="google" <?php echo ($wo['setting']['two_factor_method'] == 'google') ? 'selected': '';?>><?php echo $wo['lang']['google_authenticator']; ?></option>
					<?php } ?>
					<?php if ($wo['config']['authy_settings'] == '1') { ?>
					<option value="authy" <?php echo ($wo['setting']['two_factor_method'] == 'authy') ? 'selected': '';?>><?php echo $wo['lang']['authy_app']; ?></option>
					<?php } ?>
				</select>
			</div>
			<?php if ($wo['config']['google_authenticator'] == '1') { ?>
				<div class="google_authenticator" <?php if ($wo['setting']['two_factor_method'] != 'google') { ?>style="display:none;"<?php } ?>>
					<div class="wo_google_auth">
						<img src="<?php echo $wo['googleQR']; ?>">
						<div class="wow_form_fields">
							<label for="verify_google_code"><?php echo $wo['lang']['confirm_code'] ?></label>
							<input id="verify_google_code" type="text" placeholder="">
						</div>
					</div>
					<div class="wo_google_auth_info">
						<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7 4V20H17V4H7ZM6 2H18C18.5523 2 19 2.44772 19 3V21C19 21.5523 18.5523 22 18 22H6C5.44772 22 5 21.5523 5 21V3C5 2.44772 5.44772 2 6 2ZM12 17C12.5523 17 13 17.4477 13 18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18C11 17.4477 11.4477 17 12 17Z"></path></svg> <span><?php echo $wo['lang']['authenticator_download']; ?></span></p>
						<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M3 4.99509C3 3.89323 3.89262 3 4.99509 3H19.0049C20.1068 3 21 3.89262 21 4.99509V19.0049C21 20.1068 20.1074 21 19.0049 21H4.99509C3.89323 21 3 20.1074 3 19.0049V4.99509ZM5 5V19H19V5H5ZM7.97216 18.1808C7.35347 17.9129 6.76719 17.5843 6.22083 17.2024C7.46773 15.2753 9.63602 14 12.1022 14C14.5015 14 16.6189 15.2071 17.8801 17.0472C17.3438 17.4436 16.7664 17.7877 16.1555 18.0718C15.2472 16.8166 13.77 16 12.1022 16C10.3865 16 8.87271 16.8641 7.97216 18.1808ZM12 13C10.067 13 8.5 11.433 8.5 9.5C8.5 7.567 10.067 6 12 6C13.933 6 15.5 7.567 15.5 9.5C15.5 11.433 13.933 13 12 13ZM12 11C12.8284 11 13.5 10.3284 13.5 9.5C13.5 8.67157 12.8284 8 12 8C11.1716 8 10.5 8.67157 10.5 9.5C10.5 10.3284 11.1716 11 12 11Z"></path></svg> <span><?php echo $wo['lang']['authenticator_set']; ?></span></p>
						<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M6.99979 7V3C6.99979 2.44772 7.4475 2 7.99979 2H20.9998C21.5521 2 21.9998 2.44772 21.9998 3V16C21.9998 16.5523 21.5521 17 20.9998 17H17V20.9925C17 21.5489 16.551 22 15.9925 22H3.00728C2.45086 22 2 21.5511 2 20.9925L2.00276 8.00748C2.00288 7.45107 2.4518 7 3.01025 7H6.99979ZM8.99979 7H15.9927C16.549 7 17 7.44892 17 8.00748V15H19.9998V4H8.99979V7ZM15 9H4.00255L4.00021 20H15V9ZM8.50242 18L4.96689 14.4645L6.3811 13.0503L8.50242 15.1716L12.7451 10.9289L14.1593 12.3431L8.50242 18Z"></path></svg> <span><?php echo $wo['lang']['authenticator_verify']; ?></span></p>
						<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M18 8H20C20.5523 8 21 8.44772 21 9V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V9C3 8.44772 3.44772 8 4 8H6V7C6 3.68629 8.68629 1 12 1C15.3137 1 18 3.68629 18 7V8ZM5 10V20H19V10H5ZM11 14H13V16H11V14ZM7 14H9V16H7V14ZM15 14H17V16H15V14ZM16 8V7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7V8H16Z"></path></svg> <span><?php echo $wo['lang']['authenticator_otp']; ?></span></p>
					</div>
				</div>
			<?php } ?>
			<?php if ($wo['config']['authy_settings'] == '1') { ?>
				<?php //if (!empty($pt->settings->authy_id)) { ?>
					<div class="authy_auth" <?php if ($wo['setting']['two_factor_method'] != 'authy') { ?>style="display:none;"<?php } ?>>
						<img src="{{authyQR}}">
					</div>
				<?php //} ?>
			<?php } ?>
		<?php }else{ ?>
			<div class="empty_state">
				<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M2,7V9H6V11H4A2,2 0 0,0 2,13V17H8V15H4V13H6A2,2 0 0,0 8,11V9C8,7.89 7.1,7 6,7H2M9,7V17H11V13H14V11H11V9H15V7H9M18,7A2,2 0 0,0 16,9V17H18V14H20V17H22V9A2,2 0 0,0 20,7H18M18,9H20V12H18V9Z"></path></svg> <?php echo(str_replace('{method}', $wo['factor_used'], $wo['lang']['two_auth_currenly_enabled'])) ?>
				<input type="hidden" name="two_factor" value="0">
			</div>
		<?php } ?>

        
		<?php if ($wo['config']['two_factor_type'] == 'both' || $wo['config']['two_factor_type'] == 'phone') { ?>
			<div class="wow_form_fields">
				<label for="phone_number"><?php echo $wo['lang']['phone_number']; ?></label>  
				<input name="phone_number" id="phone_number" type="text" class="form-control input-md" autocomplete="off" placeholder="+15417543010" value="<?php echo $wo['setting']['phone_number']?>">
			</div>
		<?php } ?>
		<input type="hidden" name="" id="two_factor_value">
		
		<div class="text-center">
      <?php if ($wo['setting']['two_factor'] == '0') { ?>
        <button type="button" id="request_code" class="btn btn-main setting-panel-mdbtn" onclick="requestCode()"><?php echo $wo['lang']['save']; ?></button>
        <?php }else{ ?>
          <input type="hidden" name="two_factor" value="disable">
            <?php if ($wo['setting']['two_factor_method'] == 'authy' || $wo['setting']['two_factor_method'] == 'google') { ?>
               <button type="button" class="btn btn-main btn-mat btn-mat-raised" id="download_backup_codes_btn" onclick="downloadBackup()"><?php echo $wo['lang']['download_backup_codes']; ?></button>
           <?php } ?>
			<button type="button" class="btn btn-main btn-mat btn-mat-raised add_wow_loader" id="submit_two_factor_btn"><?php echo $wo['lang']['deactivate']; ?></button>
         <?php } ?>
		</div>
		
         <input type="hidden" name="user_id" value="<?php echo $wo['setting']['user_id'];?>">
         <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
   </form>
</div>
<div class="modal fade" id="verify_modal" role="dialog">
    <div class="modal-dialog modal-md wow_mat_mdl">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span></button>
            <h5 class="modal-title"><?php echo $wo['lang']['confirm_code']; ?></h5>
          </div>
            
            <div class="modal-body">
                <div id="verify_alert" style="color: red;"></div>
                <form id="verify_form" method="post">
                    <div class="authy_qr"></div>
                    <div class="wow_form_fields">
                        <input id="verify_authy_code" type="text" placeholder="<?php echo $wo['lang']['confirm_code']; ?>">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-main" onclick="verifyCode()" id="verify_code_button"><?php echo $wo['lang']['send']; ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="authy_modal" role="dialog">
    <div class="modal-dialog modal-md wow_mat_mdl">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span></button>
            <h5 class="modal-title"><?php echo $wo['lang']['authy_register']; ?></h5>
          </div>
            <div class="modal-body">
                <div id="authy_alert" style="color: red;"></div>
                <form id="authy_form" method="post">
                    <div class="wow_form_fields">
                        <input id="authy_email" type="text" placeholder="<?php echo $wo['lang']['email']; ?>" value="<?php echo $wo['setting']['email'];?>">
                    </div>
                    <div class="wow_form_fields">
                        <div class="col-md-4">
                            <label for="country_code"><?php echo $wo['lang']['country_code']; ?></label>
                            <select id="country_code" name="country_code">
                                <?php foreach ($wo['countries_codes'] as $key => $value) { ?>
                                    <option value="<?php echo($key) ?>"><?php echo($value) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="col-md-8">
                            <label for="authy_phone"><?php echo $wo['lang']['phone_number']; ?></label>
                            <input id="authy_phone" type="text" placeholder="<?php echo $wo['lang']['phone_number']; ?>" value="<?php echo $wo['setting']['phone_number'];?>">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <br>
                      <div class="ball-pulse"><div></div><div></div><div></div></div>
                        <button type="button" class="btn btn-main" onclick="authyRegister()" id="authy_button"><?php echo $wo['lang']['send']; ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function downloadBackup() {
        $('#download_backup_codes_btn').text("<?php echo $wo['lang']['please_wait']; ?>");
        $.post(Wo_Ajax_Requests_File() + '?f=update_two_factor&s=backup_codes', {user_id: "<?php echo $wo['setting']['user_id'];?>"}, function(data, textStatus, xhr) {
            $('#download_backup_codes_btn').text("<?php echo $wo['lang']['download_backup_codes']; ?>");

            var blob = new Blob([data], {type: 'text/plain'});
            var url = URL.createObjectURL(blob);
            var a = document.createElement('a');
            a.href = url;
            a.download = 'backup-codes.txt';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(url);
        });
    }
  <?php if ($wo['setting']['two_factor'] == '0') { ?>
	var submitgooogle = document.getElementById("verify_google_code");
		submitgooogle.addEventListener("keydown", function (e) {
			if (e.code === "Enter") {  //checks whether the pressed key is "Enter"
				event.preventDefault();
				verifyGoogleCode();
				return false;
			}
		});
		
    function verifyCode() {
        $('#verify_code_button').text("<?php echo $wo['lang']['please_wait']; ?>");
        $.post(Wo_Ajax_Requests_File() + '?f=update_two_factor&s=verify_code', {user_id: "<?php echo $wo['setting']['user_id'];?>", code: $('#verify_authy_code').val(), factor_method: $('#two_factor_method').val()}, function(data, textStatus, xhr) {
            $('#verify_code_button').text("<?php echo $wo['lang']['send']; ?>");
            if (data.status == 200) {
                $('#verify_alert').html('<div class="alert alert-success">' + data.message + '</div>');
                setTimeout(() => {
                    $('#verify_alert').html('');
                    window.location.reload();
                },2000);
            }
            else{
                $('#verify_alert').html('<div class="alert alert-danger">' + data.message + '</div>');
                setTimeout(() => {
                    $('#verify_alert').html('');
                },2000);
            }
        });
    }
    function authyRegister() {
        $('#authy_button').text("<?php echo $wo['lang']['please_wait']; ?>");
        $.post(Wo_Ajax_Requests_File() + '?f=update_two_factor&s=authy_register', {user_id: "<?php echo $wo['setting']['user_id'];?>", email: $('#authy_email').val(), phone: $('#authy_phone').val(), country_code: $('#country_code').val()}, function(data, textStatus, xhr) {
            $('#authy_button').text("<?php echo $wo['lang']['send']; ?>");
            if (data.status == 200) {
                $('#authy_alert').html('<div class="alert alert-success">' + data.message + '</div>');
                setTimeout(() => {
                    $('#authy_alert').html('');
                    $('#authy_modal').modal('hide');
                    
                    if (typeof data.qr != 'undefined' && data.qr != '') {
                        $('#verify_modal').modal({
                         show: true
                        });
                        $('.authy_qr').html('<img src="'+data.qr+'">');
                    }
                    else{
                        window.location.reload();
                    }
                },2000);
            }
            else{
                $('#authy_alert').html('<div class="alert alert-danger">' + data.message + '</div>');
                setTimeout(() => {
                    $('#authy_alert').html('');
                },2000);
            }
        });
    }
    function verifyGoogleCode() {
        $('#request_code').text("<?php echo $wo['lang']['please_wait']; ?>");
        $.post(Wo_Ajax_Requests_File() + '?f=update_two_factor&s=verify_code', {user_id: "<?php echo $wo['setting']['user_id'];?>", code: $('#verify_google_code').val(), factor_method: $('#two_factor_method').val()}, function(data, textStatus, xhr) {
            $('#request_code').text("<?php echo $wo['lang']['save']; ?>");
            if (data.status == 200) {
                $('.setting-password-alert').html('<div class="alert alert-success">' + data.message + '</div>');
                setTimeout(() => {
                    $('.setting-password-alert').html('');
                    window.location.reload();
                },2000);
            }
            else{
                $('.setting-password-alert').html('<div class="alert alert-danger">' + data.message + '</div>');
                setTimeout(() => {
                    $('.setting-password-alert').html('');
                },2000);
            }
        });
    }
    function requestCode() {
        if ($('#two_factor_method').val() == 'google') {
            verifyGoogleCode();
            return false;
        }
        
        if ($('#two_factor_method').val() == 'authy') {
            <?php if (empty($wo['setting']['authy_id'])) { ?>
              $('#authy_modal').modal({
               show: true
              });
            <?php }else{ ?>
              $('#verify_modal').modal({
                         show: true
                        });
            <?php } ?>
            return false;
        }
        
        $('#request_code').text("<?php echo $wo['lang']['please_wait']; ?>");
        $.post(Wo_Ajax_Requests_File() + '?f=update_two_factor&s=enable', {user_id: "<?php echo $wo['setting']['user_id'];?>", factor_method: $('#two_factor_method').val(), phone_number: $('#phone_number').val()}, function(data, textStatus, xhr) {
            $('#request_code').text("<?php echo $wo['lang']['save']; ?>");
            if (data.status == 200) {
                $('.setting-password-alert').html('<div class="alert alert-success">' + data.message + '</div>');
                $('.alert-success').fadeIn(300);
                $('#verify_code').modal('show');
            }
            else{
                $('.setting-password-alert').html('<div class="alert alert-danger">' + data.message + '</div>');
                $('.alert-danger').fadeIn(300);
            }
        });
    }
  <?php } ?>
  $(document).ready(function() {
    showMethod('#two_factor_method');
  });
  function showMethod(self) {
        if ($(self).val() == 'google') {
            $('.google_authenticator').slideDown();
            $('.authy_auth').slideUp();
        }
        else if($(self).val() == 'authy') {
            $('.authy_auth').slideDown();
            $('.google_authenticator').slideUp();
        }
        else{
            $('.google_authenticator').slideUp();
            $('.authy_auth').slideUp();
        }
    }
  
  $(document).on('click', '#submit_two_factor_btn', function(event) {
    $.ajax({
    url: Wo_Ajax_Requests_File() + '?f=update_two_factor&s=disable',
    type: 'POST',
    data:$('form.setting-change-password-form').serialize(),
    beforeSend: function() {
      $('.wo_settings_page').find('.add_wow_loader').addClass('btn-loading');
    },
    success: function(data) {
      if (data.status == 200) {
        $('.setting-password-alert').html('<div class="alert alert-success">' + data.message + '</div>');
        $('.alert-success').fadeIn('fast', function() {
          $(this).delay(2000).slideUp(500, function() {
              location.reload();
          });
        });
      } else if (data.status == 400) {
        $('.setting-password-alert').html('<div class="alert alert-danger">' + data.message + '</div>');
        $('.alert-danger').fadeIn(300);
      }
      $('.wo_settings_page').find('.add_wow_loader').removeClass('btn-loading');
    }
  });
    
  });
$(function() {

  $('form.confirmation_code_form').ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=update_two_factor&s=verify',
    beforeSend: function() {
      $('#confirmation_code_form_btn').text('<?php echo($wo['lang']['please_wait']) ?>');
    },
    success: function(data) {
      if (data.status == 200) {
        $('#confirmation_code_form_alert').html('<div class="alert alert-success">' + data.message + '</div>');
        $('#confirmation_code_form_alert').fadeIn('fast', function() {
          $(this).delay(2500).slideUp(500, function() {
              $(this).remove();
              $('#verify_code').modal('hide');
              location.reload();
          });
        });
      } else if (data.status == 400) {
        $('#confirmation_code_form_alert').html('<div class="alert alert-danger">' + data.message + '</div>');
        $('.alert-danger').fadeIn(300);
      }
      $('#confirmation_code_form_btn').text('<?php echo($wo['lang']['send']) ?>');
    }
  });



});
// $(function() {
//   $('form.setting-change-password-form').ajaxForm({
//     url: Wo_Ajax_Requests_File() + '?f=update_two_factor',
//     beforeSend: function() {
//       $('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeIn(100);
//     },
//     success: function(data) {
//       if (data.status == 200) {
//         $('.setting-password-alert').html('<div class="alert alert-success">' + data.message + '</div>');
//         $('.alert-success').fadeIn('fast', function() {
//           $(this).delay(2500).slideUp(500, function() {
//               $(this).remove();
//           });
//         });
//       } else if (data.errors) {
//         var errors = data.errors.join("<br>");
//         $('.setting-password-alert').html('<div class="alert alert-danger">' + errors + '</div>');
//         $('.alert-danger').fadeIn(300);
//       }
//       $('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeOut(100);
//     }
//   });
// });
</script>