<?php

////////////////////// FUNCTION | MODULE FUNCTION (c) i2d Technologies //////////////////////////////////

if (!function_exists('password_setup')) {
	function password_setup(){
$edit="1";		
   ?>
   <!-- PAGE FUNCTION STARTS (c) i2d Technologies Website Engine -->
   <script>
$( document ).ready(function() {
	$("#btnwait").prop('disabled', true);
	$('#pass_id1').attr('autocomplete', 'off');
	
	$('#pass_id1').bind('cut copy paste', function (e) {
    e.preventDefault(); //disable cut,copy,paste
});
	
	$('#pass_id2').bind('cut copy paste', function (e) {
    e.preventDefault(); //disable cut,copy,paste
});
	
	function doIt(e)
{
    var e = e || event;
    
    if (e.keyCode == 32) return false;
        
}

function pasteIt(e)
{
    var e = e || event;
    
    this.value = this.value.replace(/\s/g,'');
        
}

window.onload = function(){
    var inp = document.getElementById("pass_id1");
    var inp2 = document.getElementById("pass_id2");
    
    inp.onkeydown = doIt;
    inp.oninput = pasteIt;
	inp2.onkeydown = doIt;
    inp2.oninput = pasteIt;
};


$('#pass_id1').keyup(function(e) {
     var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
     var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
     var enoughRegex = new RegExp("(?=.{6,}).*", "g");
     if (false == enoughRegex.test($(this).val())) {
             $('#passstrength').html('More Characters');
     } else if (strongRegex.test($(this).val())) {
             $('#passstrength').className = 'ok';
			 $('#passstrength').css("color", "green");
             $('#passstrength').html('Strong!');
     } else if (mediumRegex.test($(this).val())) {
             $('#passstrength').className = 'alert';
			 $('#passstrength').css("color", "blue");
             $('#passstrength').html('Medium!');
     } else {
             $('#passstrength').className = 'error';
			 $('#passstrength').css("color", "red");
             $('#passstrength').html('Weak!');
     }
     return true;
});
});

function checkPasswordMatch() {
    var password = $("#pass_id1").val();
    var confirmPassword = $("#pass_id2").val();

    if (password != confirmPassword){
        $("#passmatch").html("Passwords do not match!");
        $("#btnwait").html("Passwords do not match!");
		$("#btnwait").prop('disabled', true);
	   }else{
        $("#passmatch").html("Passwords match.");
		$("#btnwait").html("Change Password");
		$("#btnwait").prop('disabled', false);
		
	}
		}

$(document).ready(function () {
   $("#pass_id2").keyup(checkPasswordMatch);
});


$(document).ready(function () {
    $('#clearme').on('click', 'button[data-toggle-password]', function (event) {
        var button = $(event.target);
        var input = $(event.delegateTarget).find('input');
        var type = button.hasClass('active') ? 'password' : 'text';
        
        input.attr('type', type);
        input.focus();

        button.toggleClass('active');
    });
});

</script>


   
<div id="page-right-content">

                    <div class="container">
           
		   <div class="row">
                <div class="col-lg-12">
<p>&nbsp;</p>  
<p>&nbsp;</p>  
<p>&nbsp;</p>  
<p>&nbsp;</p>  
<p>&nbsp;</p>  
  <div>
                        
						
						<div class="panel-body" id="form">
                            <div class="row">
                                <div class="col-md-4" style="float: none;
     margin-left: auto;
     margin-right: auto;">

                                    <form role="form" enctype="multipart/form-data" method="post">
                                        
										
										<div class="form-group">
                                            <label>Current Password</label>
                                            <input type="password" class="form-control input-md" name="pass0" required="required" placeholder="Enter Current Password" autocomplete="off">
                                            <p></p>
                                        </div>
  

										
										<div class="input-group input-group-md" id="clearme">
      <input type="password" class="form-control input-md" placeholder="Enter Password!" name="pass1" id="pass_id1" required="required" readonly  onfocus="this.removeAttribute('readonly');">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button" data-toggle-password>Show</button>
      </span>
	  
    </div>
	<p class="help-block" id="passstrength"></p>
										
	
									        
									  <div class="form-group">
                                            <label>Confirm Password</label>
                                            <input type="password" class="form-control input-md" name="pass2" id="pass_id2" required="required" title="براہ مہربانی اس سیکشن میں تمام تفصیلات بھریں" placeholder="Confirm Password!" autocomplete="off">
                                            <p class="help-block" id="passmatch"></p>
											
											<p id="error" class="text-center" style="color:red;"></p>
                                        </div>
  
									  
	
										
																												<div align="center">
										<?php
																								
										if(isset($edit) && $edit!="0"){
	?>
													
													<button type="submit" name="add_itembtn" id="subbtn" 
													class="btn btn-lg btn-primary waves-effect waves-light">
                                                        Update Item<label><i class="fa fa-tick"></i></label>
                                                    </button>
<?php } 
else { 
?>
													<button type="submit" name="add_itembtn" id="subbtn" 
													class="btn btn-lg btn-primary waves-effect waves-light">
                                                        Insert Item<label><i class="fa fa-tick"></i></label>
                                                    </button>

<?php } ?>
                                                    <input type="hidden" name="add_item" value="add_item">

										
										
										
																				</div>
																				
																				
										
                                    </form>
                                </div>
                               
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>
        </div>
        <!-- /#page-wrapper -->

    
<?php

	if(isset($_POST['add_item'])){	
$pass0=i2d_secured_input($_POST['pass0']);
$pass=i2d_secured_input($_POST['pass2']);

$pass_check=db_ref('logs','id','1','browser');

if($pass0==$pass_check){

$form_data=array(

'browser'=>$pass

);

$rt=db_editdata('logs','id',$form_data,1);

if($rt){
echo "done!";
$redirect="/view/home/";
app_redirect_adv($redirect);
}

}
else{
?>

<script type="text/javascript">
  $(document).ready(function() {

$("#error").text("Old Password is not correct!");

	  });
  </script>
  


<?php	
}

	}
	
	
?>
 <!-- PAGE FUNCTION ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////

















?>