summaryrefslogtreecommitdiff
path: root/final/app/auth_dialog.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-05 00:34:06 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-05 00:34:06 +0200
commite7cf0e99f41ab8ba3bab8aed516123c6f4ff3979 (patch)
tree979d1bd14bd76882f44704b51873404adf297809 /final/app/auth_dialog.php
parent35a23f6145bb772b9bfa8c8eeb500aa8c02437d3 (diff)
download2007-AWOR-e7cf0e99f41ab8ba3bab8aed516123c6f4ff3979.tar.gz
2007-AWOR-e7cf0e99f41ab8ba3bab8aed516123c6f4ff3979.tar.bz2
2007-AWOR-e7cf0e99f41ab8ba3bab8aed516123c6f4ff3979.zip
Version final-03-27-12h
Diffstat (limited to 'final/app/auth_dialog.php')
-rw-r--r--final/app/auth_dialog.php193
1 files changed, 126 insertions, 67 deletions
diff --git a/final/app/auth_dialog.php b/final/app/auth_dialog.php
index caf3297..fce5948 100644
--- a/final/app/auth_dialog.php
+++ b/final/app/auth_dialog.php
@@ -1,4 +1,117 @@
<?php
+include 'include/ludo/auth.inc.php';
+// Code v&eacute;rifiant que la personne qui tente de se connecter est bien r&eacute;f&eacute;renc&eacute;e dans notre base
+include 'include/ludo/fonctions.inc.php';
+// Connexion &agrave; la base et s&eacute;lection de la database
+include 'include/connect.inc.php';
+
+//Fonction d'authentification
+function authentification($loginP,$pass,$verifAuth="")
+{
+ //~ echo "function authentification($loginP,$pass,$verifAuth='')\n";
+ include 'include/ludo/config.inc.php';
+
+ // Requete SQL
+ $query = "SELECT idP, loginP, nomP, prenomP, methodeAuth FROM AWOR_Personne WHERE loginP='$loginP';";
+ if ( ! $result = @mysql_query($query) )
+ {
+ // Cas d'erreur
+ $errmsg =mysql_generate_errmsg();
+ }
+ else
+ {
+ // Initialisation par d&eacute;faut
+ $methodeAuth='';
+ $existLogin=mysql_num_rows($result);
+ // Chargement des pr&eacute;f&eacute;rences d'authentification de l'utilisateur
+ if ($existLogin === 1)
+ {
+ list($idP, $loginP, $nomP, $prenomP, $methodeAuth) = mysql_fetch_row($result);
+ }
+
+
+ // Si le script est lanc&eacute; en local, on saute l'authentification
+ //~ $a = $CONFIG['AUTH']['bypass_if_local'];
+ //~ $b = $_SERVER['REMOTE_ADDR'];
+
+ //~ echo "if ( ($a === true ) && ( ($b == 'localhost') || ( $b == '127.0.0.1') ) )\n";
+ if ( ($CONFIG['AUTH']['bypass_if_local'] === true )
+ && ( ($_SERVER['REMOTE_ADDR'] == 'localhost') || ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') ) )
+ {
+ //~ echo "VRAI";
+ $methodeAuth='bypass';
+ }
+ //~ else echo "FAUX";
+
+ //~ echo "DEBUG1 : \$methodeAuth==$methodeAuth\n";
+
+ $auth_is_ok=false;
+ if ($verifAuth != "") {$methodeAuth = $verifAuth;} // Pour la vérification d'authentification (monProfil)
+
+ //~ echo "DEBUG2 : \$methodeAuth==$methodeAuth\n";
+ switch ( $methodeAuth )
+ {
+ case 'webetud':
+ // include...
+ $auth_is_ok=VerifOuvertureSession("quelconque");
+ if ( ! $auth_is_ok ) { $errmsg="Authentification WebEtud refus&eacute;e !"; }
+ break;
+ /***************************************************************
+ ** Vous pouvez ajouter d'autres mode d'authentification ici ! **
+ ***************************************************************/
+ case 'bypass':
+ $auth_is_ok=true;
+ break;
+ default:
+ // Tentative d'authentification POP
+ if ( ($errno = pop3_auth_simple($loginP, $pass) ) != 0 )
+ {
+ // Authentification &eacute;chou&eacute;e
+ $errmsg=pop3_generate_errmsg($errno);
+ //~ echo "DEBUG : \$errmsg == $errmsg\n";
+ }
+ else
+ {
+ $auth_is_ok=true;
+ }
+ break;
+ }
+ if ( $auth_is_ok === true )
+ {
+ // Authentification r&eacute;ussie
+ /*Inscription de la personne si elle était inconnue de la base de donnée :*/
+ if ($existLogin === 0 && $verifAuth == "")
+ {
+ $idP_new = new_pers ($loginP);
+ $query = "SELECT idP, loginP, nomP, prenomP, methodeAuth FROM AWOR_Personne WHERE idP='$idP_new';";
+ if ( ! $result = @mysql_query($query) )
+ {
+ // Cas d'erreur
+ $errmsg =mysql_generate_errmsg();
+ }
+ // Chargement des pr&eacute;f&eacute;rences d'authentification de l'utilisateur
+ if (mysql_num_rows($result) === 1)
+ {
+ list($idP, $loginP, $nomP, $prenomP, $methodeAuth) = mysql_fetch_row($result);
+ }
+ }
+
+
+
+ session_start();
+ $_SESSION['session_loginP']=$loginP;
+ $_SESSION['session_nomP']=$nomP;
+ $_SESSION['session_prenomP']=$prenomP;
+ $_SESSION['session_idP']=$idP;
+ }
+ return ($auth_is_ok?true:$errmsg);
+ }
+
+}
+
+if ( (! isset($_POST['action']) ) || ( $_POST['action'] != "maj_profil") )
+{
+
// R&eacute;cup&eacute;ration des param&egrave;tres
if ( isset($_GET['retour']) && $_GET['retour']!='' )
{ $retour=addslashes( $_GET['retour'] ); } else { $retour='index.php'; }
@@ -12,78 +125,21 @@
}
else
{
- $loginP=addslashes( $_POST['loginP'] );
-
-
- include 'include/ludo/auth.inc.php';
-
- // Code v&eacute;rifiant que la personne qui tente de se connecter est bien r&eacute;f&eacute;renc&eacute;e dans notre base
- include 'include/ludo/fonctions.inc.php';
- // Connexion &agrave; la base et s&eacute;lection de la database
- include 'include/connect.inc.php';
- include 'include/ludo/config.inc.php';
+ require ('include/tools.inc.php');
+ $ret=authentification(addslashes_if_needed($_POST['loginP']),addslashes_if_needed($_POST['pass']));
+
+ //~ echo "DEBUG : \$ret==$ret\n";
- // Requete SQL
- $query = "SELECT idP, loginP, nomP, prenomP, methodeAuth FROM AWOR_Personne WHERE loginP='$loginP';";
- if ( ! $result = @mysql_query($query) )
+ if ( $ret === true )
{
- // Cas d'erreur
- $errmsg =mysql_generate_errmsg();
+ //Authentification réussie
+ require('include/ludo/redir.inc.php');
+ //~ echo "DEBUG : html_redir($retour);\n";
+ html_redir($retour);
}
else
{
- // Initialisation par d&eacute;faut
- $methodeAuth='';
- // Chargement des pr&eacute;f&eacute;rences d'authentification de l'utilisateur
- if ( mysql_num_rows($result) === 1)
- {
- list($idP, $loginP, $nomP, $prenomP, $methodeAuth) = mysql_fetch_row($result);
- }
- // Si le script est lanc&eacute; en local, on saute l'authentification
- if ( ($CONFIG['AUTH']['bypass_if_local'] === true )
- && ( ($_SERVER['REMOTE_ADDR'] == 'localhost') || ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') ) )
- {
- $methodeAuth='bypass';
- }
-
- $auth_is_ok=false;
- switch ( $methodeAuth )
- {
- case 'webetud':
- // include...
- $auth_is_ok=VerifOuvertureSession("quelconque");
- if ( ! $auth_is_ok ) { $errmsg="Authentification WebEtud refus&eacute;e !"; }
- break;
- /***************************************************************
- ** Vous pouvez ajouter d'autres mode d'authentification ici ! **
- ***************************************************************/
- case 'bypass':
- $auth_is_ok=true;
- break;
- default:
- // Tentative d'authentification POP
- if ( ($errno = pop3_auth_simple($loginP, $_POST['pass']) ) != 0 )
- {
- // Authentification &eacute;chou&eacute;e
- $errmsg=pop3_generate_errmsg($errno);
- }
- else
- {
- $auth_is_ok=true;
- }
- break;
- }
- if ( $auth_is_ok === true )
- {
- // Authentification r&eacute;ussie
- session_start();
- $_SESSION['session_loginP']=$loginP;
- $_SESSION['session_nomP']=$nomP;
- $_SESSION['session_prenomP']=$prenomP;
- $_SESSION['session_idP']=$idP;
- require('include/ludo/redir.inc.php');
- html_redir($retour);
- }
+ $errmsg = $ret;
}
}
}
@@ -123,3 +179,6 @@ generate_html_div_help();
generate_html_div_footer(); ?>
</body>
</html>
+<?php
+}
+?> \ No newline at end of file