PHP Classes

File: doconnect.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Mo´se  >  PHP Mnemonic Secret Path Login  >  doconnect.php  >  Download  
File: doconnect.php
Role: Auxiliary script
Content type: text/plain
Description: auxilliary script
Class: PHP Mnemonic Secret Path Login
Detect human users telling to click on page places
Author: By
Last change:
Date: 4 years ago
Size: 15,669 bytes
 

Contents

Class file image Download
<?php session_start(); require_once('config.php'); include_once 'src/clicktoconnect.php'; $container="password2"; $message=''; // var_dump($_POST); if( isset($_POST['identity'])&&isset($_POST['password'])&&!isset($_POST['password2'])){ $query=$bdd->prepare('SELECT * FROM users WHERE username =:identity OR mail=:identity OR phone=:identity'); $query->bindValue(':identity',$_POST['identity'],PDO::PARAM_STR); $query->execute(); $data=$query->fetch(); $query->CloseCursor(); if( $data ['password'] == sha1(Salt.$_POST['password'].Salt)) // Acces OK ! { if($data['user_preference']==='0'){ if( $data ['statutvalidation'] ==1){ $_SESSION [ 'pseudo' ] = $data [ 'username' ]; $_SESSION [ 'connected' ] = true; $_SESSION [ 'user_id' ] = $data [ 'user_id' ]; $_SESSION [ 'role' ] = $data [ 'role' ]; $message='ok' ; $query->CloseCursor(); }else{ $message="<p id='resultat'>You have not yet validate your account.Please check your email box and click the validation link to confirm your email address</p> "; } }else{ $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } else // Acces pas OK ! { $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } elseif( isset($_POST['identity']) && isset($_POST['password2'])&& !isset($_POST['password']) ){ $query=$bdd->prepare('SELECT * FROM users WHERE username =:identity OR mail=:identity OR phone=:identity'); $query->bindValue(':identity',$_POST['identity'],PDO::PARAM_STR); $query->execute(); $data=$query->fetch(); $query->CloseCursor(); $query=$bdd->prepare('SELECT password FROM pictures WHERE user_id =:identity AND path=:path' ); $query->bindValue(':identity',$data['user_id'],PDO::PARAM_INT); $query->bindValue(':path',$_POST['picture'],PDO::PARAM_STR); $query->execute(); $data2=$query->fetch(); $query->CloseCursor(); if( $data2 ['password'] == sha1(Salt. trim($_POST['password2']).Salt)) // Acces OK ! { if($data['user_preference']==='1'||$data['user_preference']==='3'){ if( $data ['statutvalidation'] ==1){ $_SESSION [ 'pseudo' ] = $data [ 'username' ]; $_SESSION [ 'connected' ] = true; $_SESSION [ 'user_id' ] = $data [ 'user_id' ]; $_SESSION [ 'role' ] = $data [ 'role' ]; $message='ok' ; $query->CloseCursor(); }else{ $message="<p id='resultat'>You have not yet validate your account.Please check your email box and click the validation link to confirm your email address </p>"; } }else{ $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } else // Acces pas OK ! { $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } elseif( isset($_POST['identity']) && isset($_POST['password'])&& isset($_POST['password2']) ){ $query=$bdd->prepare('SELECT * FROM users WHERE username =:identity OR mail=:identity OR phone=:identity'); $query->bindValue(':identity',$_POST['identity'],PDO::PARAM_STR); $query->execute(); $data=$query->fetch(); $query->CloseCursor(); $query=$bdd->prepare('SELECT password FROM pictures WHERE user_id =:identity AND path=:path' ); $query->bindValue(':identity',$data['user_id'],PDO::PARAM_INT); $query->bindValue(':path',$_POST['picture'],PDO::PARAM_STR); $query->execute(); $data2=$query->fetch(); $query->CloseCursor(); // var_dump( md5($_POST['password'])); // var_dump(sha1(trim($_POST['password2']))); // var_dump( $data ['password'] == md5($_POST['password'])&&$data2 ['password'] == sha1(trim($_POST['password2']))); if( $data ['password'] == sha1(Salt.$_POST['password'].Salt)&&$data2 ['password'] == sha1(Salt. trim($_POST['password2']).Salt)) // Acces OK ! { if($data['user_preference']==='2'||$data['user_preference']==='4'){ if( $data ['statutvalidation'] ==1){ $_SESSION [ 'pseudo' ] = $data [ 'username' ]; $_SESSION [ 'connected' ] = true; $_SESSION [ 'user_id' ] = $data [ 'user_id' ]; $_SESSION [ 'role' ] = $data [ 'role' ]; $message='ok' ; $query->CloseCursor(); }else{ echo"<p id='resultat'>You have not yet validate your account.Please check your email box and click the validation link to confirm your email address "; } }else{ $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } else // Acces pas OK ! { $message='<p id="failed">An error occured during your authentification The pseudo or the password you entered is not correct</p>'; } } elseif (isset($_POST['identity'])&& !isset($_POST['password'])&& !isset($_POST['password2'])) //On check les preferences de connexion, //we check connexion preference { $query=$bdd->prepare('SELECT user_id,user_preference,default_ctcpic FROM users WHERE username =:identity OR mail=:identity OR phone=:identity'); $query->bindValue(':identity',$_POST['identity'],PDO::PARAM_STR); $query->execute(); $data=$query->fetch(); $query->CloseCursor(); // var_dump($data['user_preference']); if($data['default_ctcpic']){ switch($data['user_preference']){ case '1': $userImage=$data['default_ctcpic'];//user personal Image echo'<div class="instruction"><p>Click on picture to connect </p></div>'; require_once('src/ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php break; case '2': echo'<div class="instruction"><p>Enter your password and picture password to connect </p></div>'; echo'<!--<p><label for="password">Password :</label>--><input type="password" id="password" name="password" placeholder="password"/></p> '; $userImage=$data['default_ctcpic']; require_once('src/ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password : $('#password').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php break; case '4': echo'<div class="instruction"><p>Enter your password and picture password to connect </p></div>'; echo'<!--<p><label for="password">Password :</label>--><input type="password" id="password" name="password" placeholder="password"/></p> '; $new=new usepictures($bdd,$data['user_id']); // $ar=$new->returnpictures(); do{ $userImage=$new->apicture(); } while($new->getapass($userImage)==sha1('ctc1_1 1_1 1_1 1_1default')); require_once('src/ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password : $('#password').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php break; case '3': $new=new usepictures($bdd,$data['user_id']); // $ar=$new->returnpictures(); do{ $userImage=$new->apicture(); } while($new->getapass($userImage)==sha1('ctc1_1 1_1 1_1 1_1default')); echo'<div class="instruction"><p>Click on picture to connect </p></div>'; require_once('ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script> <?php break; case '0': echo'<!--<p><label for="password">Password :</label>--><input type="password" id="password" name="password" placeholder="password"/></p> '; echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password : $('#password').val(), }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php break; default: break; } }else{ $new=new usepictures($bdd,$data['user_id']); $ar=$new->returnpictures(); $ct=count($ar); if($data['user_preference']==3&&$ct>=1){ do{ $userImage=$new->apicture(); } while($new->getapass($userImage)==sha1('ctc1_1 1_1 1_1 1_1default')); echo'<div class="instruction"><p>Click on picture to connect </p></div>'; require_once('src/ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script> <?php }elseif($data['user_preference']==4&&$ct>=1){ echo'<div class="instruction"><p>Enter your password and picture password to connect </p></div>'; echo'<!--<p><label for="password">Password :</label>--><input type="password" id="password" name="password" placeholder="password"/></p> '; do{ $userImage=$new->apicture(); } while($new->getapass($userImage)==sha1('ctc1_1 1_1 1_1 1_1default')); require_once('src/ctc.php'); echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password : $('#password').val(), password2 : $('#password2').val(), picture: '<?php echo $userImage;?>' }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php }else{ $req=$bdd->prepare(' UPDATE users SET user_preference=:user_preference WHERE username=:identity OR mail=:identity OR phone=:identity'); $req->bindValue(':identity',$_POST['identity'],PDO::PARAM_STR); $req->bindValue(':user_preference',0,PDO::PARAM_STR); $req->execute(); $req->CloseCursor(); echo'<div id="float"> normal, only keyboard password</div>'; echo'<!--<p><label for="password">Password :</label>--><input type="password" id="password" name="password" placeholder="password"/></p> '; echo'<p><input type="submit" value="Submit"> <input type="reset" value="Reset" id="reset"></p>'; ?><script> $('#connexion').submit(function(e){ e.preventDefault(); $("#manage2").html('<img src="assets/img/loader.gif" alt="Uploading...." class="little"/>'); $.post('doconnect.php', { identity : $('#identity').val(), password : $('#password').val(), }, function(data){ if(data.trim() == 'ok'){ $("#manage2").html("<p id='resultat'>You have successfully been connected!Wait while redirecting...</p>"); setInterval(window.location="preferences.php",15000); }else{ $("#manage2").html('<p id="failed">'+data+'</p>'); } }, 'text' ); }); </script><?php } } }else { //Oublie d'un champ,forget a field $message='<p id="failed">An error occured during your authentification.You must fill in all the fields</p>'; } echo $message; ?>