mode = $mode; // } // // public function validateUserPass($username,$password){ // global $webdav_current_user_id,$webdav_current_user_name; // // switch($this->mode){ // case "gestion" : // if($username && $password){ // $query = "SELECT userid, username FROM users WHERE username='$username' AND pwd=password('$password') "; // $result = mysql_query($query); // if(mysql_num_rows($result) && mysql_result($result,0,0)>0){ // $webdav_current_user_id= mysql_result($result,0,0); // $webdav_current_user_name = mysql_result($result,0,1); // return true; // } // } // break; // case "opac" : // //TODO vérification abonnement... // if($username && $password){ // $query ="select id_empr, concat(empr_nom,' ',empr_prenom) from empr where empr_login='".$username."' and empr_password='".$password."'"; // $result = mysql_query($query); // if(mysql_num_rows($result) && mysql_result($result,0,0)>0){ // $webdav_current_user_id= mysql_result($result,0,0); // $webdav_current_user_name = mysql_result($result,0,1); // return true; // } // } // break; // } // return false; // } //} class Sabre_PMB_Auth extends Sabre_DAV_Auth_Backend_AbstractDigest { protected $mode; public function __construct($mode){ $this->mode = $mode; } public function getDigestHash($realm,$username) { global $webdav_current_user_id,$webdav_current_user_name; switch($this->mode){ case "gestion" : $query = "SELECT user_digest, userid, username FROM users WHERE username='$username'"; $result = mysql_query($query); if(mysql_num_rows($result)){ $webdav_current_user_id= mysql_result($result,0,1); $webdav_current_user_name = mysql_result($result,0,2); return mysql_result($result,0,0); } break; case "opac" : $query ="select empr_password, id_empr, concat(empr_nom,' ',empr_prenom) from empr where empr_login='".$username."'"; $result = mysql_query($query); if(mysql_num_rows($result)){ $webdav_current_user_id= mysql_result($result,0,1); $webdav_current_user_name = mysql_result($result,0,2); return md5($username.":".$realm.":".mysql_result($result,0,0)); } break; } return false; } }