phpDocumentor VFront
Authentication
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file auth.db.php

Documentation is available at auth.db.php

  1. <?php
  2. /**
  3.  * @package VFront
  4.  * @subpackage Authentication
  5.  * @author Mario Marcello Verona <marcelloverona@gmail.com>
  6.  * @copyright 2007 Mario Marcello Verona
  7.  * @version 0.90
  8.  * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  9.  * @see auth
  10.  */
  11.  
  12.     /**
  13.      * Funzione di autenticazione mediante l'uso di un database diverso da VFront
  14.      * ma presente sullo stesso server
  15.      * Viene richiamata dalla classe {@link auth}
  16.      *
  17.      * @param string $user Username (email)
  18.      * @param string $passw Password
  19.      * @return array 
  20.      */
  21.     function auth_db($user$passw){
  22.         
  23.         global $link$db1$conf_auth;
  24.     
  25.     
  26.         $sql_auth=sprintf("SELECT * FROM {$conf_auth['db']['database']}.{$conf_auth['db']['tabella']} 
  27.                            WHERE {$conf_auth['campo_email']}='%sAND {$conf_auth['campo_password']}='%s'",
  28.                         trim(addslashes($user)),
  29.                         personal_hash_db(trim($passw))
  30.                         );
  31.                         
  32.         $q_auth=vmsql_query($sql_auth,$link);
  33.         
  34.         
  35.         if(vmsql_num_rows($q_auth)==1){
  36.             
  37.             $RS=vmsql_fetch_assoc($q_auth);
  38.             
  39.             return array('response'=>true,$RS);
  40.         
  41.         }
  42.         else{
  43.             
  44.             return array('response'=>false);
  45.         }
  46.         
  47.     }
  48.     
  49.     /**
  50.      * Funzione di hash o crypt personalizzata
  51.      * richiama il tipo di codifica impostata nel file CONF
  52.      * per le password in caso di autenticazione esterna tramite database
  53.      *
  54.      * @param string $passw 
  55.      * @return string Stringa codificata con il metodo impostato in $conf_auth['password_crypt']
  56.      */
  57.     function personal_hash_db($passw){
  58.         
  59.         global $conf_auth;
  60.         
  61.         if($conf_auth['password_crypt']=='md5'){
  62.             
  63.             return md5($passw);
  64.         }
  65.         else if($conf_auth['password_crypt']=='sha1'){
  66.             
  67.             return sha1($passw);
  68.         }
  69.         
  70.         // ... altri metodi
  71.         
  72.         else{
  73.             
  74.             return $passw;
  75.         }
  76.     }
  77.  
  78. ?>

Documentation generated on Sat, 22 Sep 2007 11:49:47 +0200 by phpDocumentor 1.4.0a2