Source for file auth.php
Documentation is available at auth.php
#################################################
# This file is part of VFront.
# VFront is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# VFront is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
* Classe generica per l'autenticazione a VFront.
* L'accesso può essere in 1 o 2 passi
* In 1 passo se si usa l'autenticazione mediante il database di VFront
* In 2 mediante strumenti esterni (LDAP, altro DB, ecc) per l'autenticazione
* e il DB di VFRont per l'accreditamento dei diritti
* @subpackage Authentication
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007 Mario Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
* @desc Utente oggetto dell'autenticazione
* @desc Password oggetto dell'autenticazione
* Array restituito dalla classe
* 'response' => true | false
* 0 => (array) info_account | null
* Presenza dell'utente nel frontend
* Autenticazione esterna, impostata nel file CONF
* @var string soap | ldap | db | db_ext | null=dbvfront
* Tipo di autenticazione.
* La modalità di accesso può essere in 2 step o 1 step.
* Nella modalità 1 step l'autorizzazione e l'accreditamento sono congiunti,
* nel 2 step sono separati
* Variabile obsoleta, mantenuta per compatibilità
* @var string 1step | 2step
* Autenticazione ed accreditamento dei diritti
* @param string $user Email dell'utente
* @param string $passw Password
function auth($user,$passw){
global $link,$db1,$conf_auth;
// l'uente non esiste, mandalo via
if($this->auth_obj['response']=== false){
// L'utente esiste in autorizzazione, ora esiste anche in DB? (2 passi)
} //-- Fine funzione AUTH
* @desc Funzione di autenticazione basata sul DB di VFront, tabella utenti
// Verifico che esista nel db Frontend
// L'utente esiste anche nel DB!
// prende i dati, li mette in sessione, lo fa andare avanti
* @desc Funzione di accreditamento e inserimento se non esistono i diritti
global $link,$db1,$conf_auth;
// Verifico che esista nel db Frontend
// L'utente esiste anche nel DB!
// prende i dati, li mette in sessione, lo fa andare avanti
// L'utente è autorizzato ma non c'è nel DB.
// Prendo i dati a disposizioni e creo un record nel DB con livello di accesso default
$sql_ins = sprintf("INSERT INTO {$db1['frontend']}.utente
(nick, nome, cognome, email, passwd, gid, livello, data_ins)
VALUES ('%s','%s','%s','%s','%s',%d,%d,'%s')", //,%d)",
$this->auth_obj[0][$conf_auth['campo_email']],
$this->auth_obj[0][$conf_auth['campo_nome']],
$this->auth_obj[0][$conf_auth['campo_cognome']],
$this->auth_obj[0][$conf_auth['campo_email']], // email in questo caso = nick
$this->auth_obj[0][$conf_auth['campo_password']],
0, // Imposta nel gruppo default 0
1, // Imposta il livello di amministrazione a 1 (nessuna amministrazione)
* @param int $tipo_err 0=errore nell'utente password, 1=livello troppo basso per vedere la pagina
case 0: // errore nell'utente password
unset ($_SESSION['user']);
case 1: // livello troppo basso per vedere la pagina
* @desc Cerca l'utente nel DB di VFront
* @param string $user Nome utente
* @param string $passw Password
* @param bool $use_passw Utilizza la password per l'autenticazione (default=true)
* @return array Array con le informazioni sull'utente
// cerca l'utente in database
$sql = "SELECT * FROM {$db1['frontend']}.utente
if($use_passw) $sql. " AND passwd='". md5($passw). "'";
// L'utente esiste anche nel DB!
// prende i dati, li mette in sessione, lo fa andare avanti
return array('response'=> true,$RS);
// L'utente è autorizzato ma non c'è nel DB.
return array('response'=> false);
* @desc Inserisce in sessione le variabili relative all'utente quando autenticato e accreditato
|