<?php
session_start();
include_once 'src/combox.php';
include_once 'config.php';
include_once 'src/clicktoconnect.php';
$url='connexion.php';
if(!isset($_SESSION['connected'])){
echo '<script type="text/javascript">window.location="'.$url.'";</script>';
header('location: connexion.php');
exit();
}
$new=new usepictures($bdd,$_SESSION['user_id']);
$ar=$new->returnpictures();
$ct=count($ar);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Connexion preferences</title>
<!--<script src="./jquery-ui-1.12.1/external/jquery/jquery.js"></script>-->
<script src='http://code.jquery.com/jquery.js'></script>
<script src="./assets/js/ahpwcheck.class.min.js"></script>
<link rel="stylesheet" href="./assets/css/style.css">
</head>
<body>
<div id="content">
<p><hr/>| Welcome <span id="pseudo"><?php echo strtoupper($_SESSION["pseudo"]);?></span> | <a href="dologout.php" class="none">Log out</a> |<hr/></p>
<h1> Change Your preferences</h1>
<div class="grid"><h2><a href="ajaxcombox.php" class="none">Add a new click to connect picture</a></h2></div>
<h2>Change a keyboard password</h2>
<div class="grid">
<form id="changepass" method="POST">
<fieldset>
<p><input type="password" id="password" name="password" placeholder="Old password"/><br><br>
<input type="password" id="newpassword" name="newpassword" placeholder="New password"/></p><p>
<div id="score">
Score: <span id="outscore">-</span>
</div>
<input type="submit" value="modify" />
</p><div id="manage" ></div>
</fieldset></form>This is here not as obligation but as a helper...<br>
<div id="outpwcheck"></div>
</div>
<?php if(!empty($ar)){?>
<h2>Default ctc picture and connexion preference</h2>
<div class="grid">
<?php
require('getpreferences.php');
?>
</div>
<?php if($ct>=1){?><h2>Choose a default click to connect picture</h2>
<div class="grid">
<?php
require('besureofsize.php');
?><div id="manage3" ></div>
</div><?php }?>
<h2>Change a click to connect picture password</h2>
<div class="grid">
<?php
foreach($ar as $k=>$v){
echo' <a href="addyourpassnow.php?name='.$v .'"><img src="'.$v.'" class="preview2" /></a>';
}
?>
</div>
<h2>Delete a click to connect picture</h2>
<div class="grid">
<?php
foreach($ar as $k=>$v){
echo' <img src="'.$v.'" class="preview3" />';
}
?>
</div>
<?php if($data['default_ctcpic']||$ct>1
){?>
<h2>Choose a connexion type</h2>
<div class="grid">
<form id="type" method="POST">
<fieldset>
<p><select class="connexion_type">
<option value="none" selected="selected">none</option>
<option value="0" >only keyboard pass</option>
<?php if($data['default_ctcpic']
){?><option value="1" >only picture pass</option>
<option value="2" >both picture and keyboard pass</option>
<?php
}
if($ct>1){?>
<option value="3" >only random picture pass </option>
<option value="4" >both random picture and keyboard pass</option><?php }?>
</select></p><p>
</p><div id="manage2" ></div>
<?php if(!$data['default_ctcpic']){?><p>For more options please choose a default CTC picture...</p><?php
}
if($ct<=1){?><p>For more options please add more CTC pictures...</p><?php
}
?></fieldset></form>
</div><?php
}
}?> <script>
jQuery(document).ready(function($){
$('.connexion_type').change(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('setpreferences.php', { type : $('.connexion_type').val() }, function(data){
if(data.trim() == 'success'){
$("#manage2").html("<p>Your preferences have successfully been changed!Wait while refreshing...</p>");
setInterval(window.location="preferences.php",15000);
// clearInterval(window.location="preferences.php",15000);
}
else{
if(data.trim()=='Failed'){
$("#manage2").html("<p>An error occured please try again later</p>");
}else{
$("#manage2").html('<p id="failed">'+data+'</p>');
}
}
}, 'text' ); });
$('.preview').click(function(e){
var name=$(this).attr('src');
var id=$(this);
$(this).attr({src:'assets/img/loader.gif', alt:'Uploading....'});
$.get('setpreferences.php', { name : name }, function(data){
if(data.trim()=="success") {
$(id).attr({src:'assets/img/DONE.png', alt:'DONE'});
setInterval(function(){$(id).attr({'src':name, alt:''});setInterval(window.location="preferences.php",30000);},3000);
// clearInterval(function(){$(id).attr({'src':name}); setInterval(window.location="preferences.php",30000);},3000);
}else if(data.trim()!="Failed"){
$("#manage3").html('<p id="failed">'+data+'</p>');
// alert('<p id="failed">'+data+'</p>');
setInterval(function(){$(id).attr({'src':name , alt:''});},3000);
}
}, 'text' ); });
$('#changepass').submit(function(e){ e.preventDefault(); $("#manage").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('changepass.php', {
oldpassword : $('#password').val(),
password : $('#newpassword').val()
}, function(data){
if(data.trim() == 'success'){
$("#manage").html("<p id='resultat'>Your password have successfully been changed!Wait while refreshing...</p>");
setInterval(window.location="preferences.php",15000);
}else{
$("#manage").html('<p id="failed">'+data+'</p>');
}
}, 'text' ); });
$('.preview3').click(function(e){
var name=$(this).attr('src');
var id=$(this);
$(this).attr({src:'assets/img/loader.gif', alt:'Uploading....'});
$.get('setpreferences.php', { name : name , deletethis:true}, function(data){
if(data.trim()=="success") {
$(id).attr({src:'assets/img/DONE.png', alt:'DONE'});
setInterval(function(){
// $(id).attr({'src':name});
setInterval(window.location="preferences.php",30000);},3000);
// clearInterval(function(){$(id).attr({'src':name}); setInterval(window.location="preferences.php",30000);},3000);
}
}, 'text' ); });
}
);
var aOptions = {
'callback': 'mycallback()'
};
/**
* custom callback function
*/
function mycallback(){
var sPassword=document.getElementById('newpassword').value;
document.getElementById('outscore').innerHTML=oPwCheck.getScore(sPassword);
}
var oPwCheck = new ahpwcheck(aOptions);
oPwCheck.watch('newpassword', 'outpwcheck');
</script>
</div>
</body>
</html>
|