1<?php 2/** 3 * Authentication library 4 * 5 * Including this file will automatically try to login 6 * a user by calling auth_login() 7 * 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 * @author Andreas Gohr <andi@splitbrain.org> 10 */ 11 12 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 13 require_once(DOKU_INC.'inc/common.php'); 14 require_once(DOKU_INC.'inc/io.php'); 15 16 if($conf['useacl']){ 17 require_once(DOKU_INC.'inc/blowfish.php'); 18 require_once(DOKU_INC.'inc/mail.php'); 19 20 // load the the backend auth functions and instantiate the auth object 21 if (@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) { 22 require_once(DOKU_INC.'inc/auth/basic.class.php'); 23 require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php'); 24 25 $auth_class = "auth_".$conf['authtype']; 26 if (class_exists($auth_class)) { 27 $auth = new $auth_class(); 28 if ($auth->success == false) { 29 unset($auth); 30 msg($lang['authtempfail'], -1); 31 32 // turn acl config setting off for the rest of this page 33 $conf['useacl'] = 0; 34 } 35 } else { 36 nice_die($lang['authmodfailed']); 37 } 38 } else { 39 nice_die($lang['authmodfailed']); 40 } 41 } 42 43 if (!defined('DOKU_COOKIE')) define('DOKU_COOKIE', 'DW'.md5($conf['title'])); 44 45 // some ACL level defines 46 define('AUTH_NONE',0); 47 define('AUTH_READ',1); 48 define('AUTH_EDIT',2); 49 define('AUTH_CREATE',4); 50 define('AUTH_UPLOAD',8); 51 define('AUTH_DELETE',16); 52 define('AUTH_ADMIN',255); 53 54 // do the login either by cookie or provided credentials 55 if($conf['useacl']){ 56 // if no credentials were given try to use HTTP auth (for SSO) 57 if(!$_REQUEST['u'] && !$_COOKIE[DOKU_COOKIE] && $_SERVER['PHP_AUTH_USER']){ 58 $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; 59 $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; 60 } 61 62 // external trust mechanism in place? 63 if(!is_null($auth) && $auth->canDo('external')){ 64 $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); 65 }else{ 66 auth_login($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); 67 } 68 69 //load ACL into a global array 70 if(is_readable(DOKU_CONF.'acl.auth.php')){ 71 $AUTH_ACL = file(DOKU_CONF.'acl.auth.php'); 72 }else{ 73 $AUTH_ACL = array(); 74 } 75 } 76 77/** 78 * This tries to login the user based on the sent auth credentials 79 * 80 * The authentication works like this: if a username was given 81 * a new login is assumed and user/password are checked. If they 82 * are correct the password is encrypted with blowfish and stored 83 * together with the username in a cookie - the same info is stored 84 * in the session, too. Additonally a browserID is stored in the 85 * session. 86 * 87 * If no username was given the cookie is checked: if the username, 88 * crypted password and browserID match between session and cookie 89 * no further testing is done and the user is accepted 90 * 91 * If a cookie was found but no session info was availabe the 92 * blowfish encrypted password from the cookie is decrypted and 93 * together with username rechecked by calling this function again. 94 * 95 * On a successful login $_SERVER[REMOTE_USER] and $USERINFO 96 * are set. 97 * 98 * @author Andreas Gohr <andi@splitbrain.org> 99 * 100 * @param string $user Username 101 * @param string $pass Cleartext Password 102 * @param bool $sticky Cookie should not expire 103 * @return bool true on successful auth 104*/ 105function auth_login($user,$pass,$sticky=false){ 106 global $USERINFO; 107 global $conf; 108 global $lang; 109 global $auth; 110 $sticky ? $sticky = true : $sticky = false; //sanity check 111 112 if(isset($user)){ 113 //usual login 114 if ($auth->checkPass($user,$pass)){ 115 // make logininfo globally available 116 $_SERVER['REMOTE_USER'] = $user; 117 $USERINFO = $auth->getUserData($user); //FIXME move all references to session 118 119 // set cookie 120 $pass = PMA_blowfish_encrypt($pass,auth_cookiesalt()); 121 $cookie = base64_encode("$user|$sticky|$pass"); 122 if($sticky) $time = time()+60*60*24*365; //one year 123 setcookie(DOKU_COOKIE,$cookie,$time,'/'); 124 125 // set session 126 $_SESSION[$conf['title']]['auth']['user'] = $user; 127 $_SESSION[$conf['title']]['auth']['pass'] = $pass; 128 $_SESSION[$conf['title']]['auth']['buid'] = auth_browseruid(); 129 $_SESSION[$conf['title']]['auth']['info'] = $USERINFO; 130 return true; 131 }else{ 132 //invalid credentials - log off 133 msg($lang['badlogin'],-1); 134 auth_logoff(); 135 return false; 136 } 137 }else{ 138 // read cookie information 139 $cookie = base64_decode($_COOKIE[DOKU_COOKIE]); 140 list($user,$sticky,$pass) = split('\|',$cookie,3); 141 // get session info 142 $session = $_SESSION[$conf['title']]['auth']; 143 144 if($user && $pass){ 145 // we got a cookie - see if we can trust it 146 if(isset($session) && 147 ($session['user'] == $user) && 148 ($session['pass'] == $pass) && //still crypted 149 ($session['buid'] == auth_browseruid()) ){ 150 // he has session, cookie and browser right - let him in 151 $_SERVER['REMOTE_USER'] = $user; 152 $USERINFO = $session['info']; //FIXME move all references to session 153 return true; 154 } 155 // no we don't trust it yet - recheck pass 156 $pass = PMA_blowfish_decrypt($pass,auth_cookiesalt()); 157 return auth_login($user,$pass,$sticky); 158 } 159 } 160 //just to be sure 161 auth_logoff(); 162 return false; 163} 164 165/** 166 * Builds a pseudo UID from browser and IP data 167 * 168 * This is neither unique nor unfakable - still it adds some 169 * security. Using the first part of the IP makes sure 170 * proxy farms like AOLs are stil okay. 171 * 172 * @author Andreas Gohr <andi@splitbrain.org> 173 * 174 * @return string a MD5 sum of various browser headers 175 */ 176function auth_browseruid(){ 177 $uid = ''; 178 $uid .= $_SERVER['HTTP_USER_AGENT']; 179 $uid .= $_SERVER['HTTP_ACCEPT_ENCODING']; 180 $uid .= $_SERVER['HTTP_ACCEPT_LANGUAGE']; 181 $uid .= $_SERVER['HTTP_ACCEPT_CHARSET']; 182 $uid .= substr($_SERVER['REMOTE_ADDR'],0,strpos($_SERVER['REMOTE_ADDR'],'.')); 183 return md5($uid); 184} 185 186/** 187 * Creates a random key to encrypt the password in cookies 188 * 189 * This function tries to read the password for encrypting 190 * cookies from $conf['metadir'].'/_htcookiesalt' 191 * if no such file is found a random key is created and 192 * and stored in this file. 193 * 194 * @author Andreas Gohr <andi@splitbrain.org> 195 * 196 * @return string 197 */ 198function auth_cookiesalt(){ 199 global $conf; 200 $file = $conf['metadir'].'/_htcookiesalt'; 201 $salt = io_readFile($file); 202 if(empty($salt)){ 203 $salt = uniqid(rand(),true); 204 io_saveFile($file,$salt); 205 } 206 return $salt; 207} 208 209/** 210 * This clears all authenticationdata and thus log the user 211 * off 212 * 213 * @author Andreas Gohr <andi@splitbrain.org> 214 */ 215function auth_logoff(){ 216 global $conf; 217 global $USERINFO; 218 global $INFO, $ID; 219 global $auth; 220 221 if(isset($_SESSION[$conf['title']]['auth']['user'])) 222 unset($_SESSION[$conf['title']]['auth']['user']); 223 if(isset($_SESSION[$conf['title']]['auth']['pass'])) 224 unset($_SESSION[$conf['title']]['auth']['pass']); 225 if(isset($_SESSION[$conf['title']]['auth']['info'])) 226 unset($_SESSION[$conf['title']]['auth']['info']); 227 if(isset($_SERVER['REMOTE_USER'])) 228 unset($_SERVER['REMOTE_USER']); 229 $USERINFO=null; //FIXME 230 setcookie(DOKU_COOKIE,'',time()-600000,'/'); 231 232 if($auth && $auth->canDo('logoff')){ 233 $auth->logOff(); 234 } 235} 236 237/** 238 * Convinience function for auth_aclcheck() 239 * 240 * This checks the permissions for the current user 241 * 242 * @author Andreas Gohr <andi@splitbrain.org> 243 * 244 * @param string $id page ID 245 * @return int permission level 246 */ 247function auth_quickaclcheck($id){ 248 global $conf; 249 global $USERINFO; 250 # if no ACL is used always return upload rights 251 if(!$conf['useacl']) return AUTH_UPLOAD; 252 return auth_aclcheck($id,$_SERVER['REMOTE_USER'],$USERINFO['grps']); 253} 254 255/** 256 * Returns the maximum rights a user has for 257 * the given ID or its namespace 258 * 259 * @author Andreas Gohr <andi@splitbrain.org> 260 * 261 * @param string $id page ID 262 * @param string $user Username 263 * @param array $groups Array of groups the user is in 264 * @return int permission level 265 */ 266function auth_aclcheck($id,$user,$groups){ 267 global $conf; 268 global $AUTH_ACL; 269 270 # if no ACL is used always return upload rights 271 if(!$conf['useacl']) return AUTH_UPLOAD; 272 273 $user = auth_nameencode($user); 274 275 //if user is superuser return 255 (acl_admin) 276 if(auth_nameencode($conf['superuser']) == $user) { return AUTH_ADMIN; } 277 278 //make sure groups is an array 279 if(!is_array($groups)) $groups = array(); 280 281 //prepend groups with @ and nameencode 282 $cnt = count($groups); 283 for($i=0; $i<$cnt; $i++){ 284 $groups[$i] = '@'.auth_nameencode($groups[$i]); 285 } 286 //if user is in superuser group return 255 (acl_admin) 287 if(in_array(auth_nameencode($conf['superuser'],true), $groups)) { return AUTH_ADMIN; } 288 289 $ns = getNS($id); 290 $perm = -1; 291 292 if($user){ 293 //add ALL group 294 $groups[] = '@ALL'; 295 //add User 296 $groups[] = $user; 297 //build regexp 298 $regexp = join('|',$groups); 299 }else{ 300 $regexp = '@ALL'; 301 } 302 303 //check exact match first 304 $matches = preg_grep('/^'.preg_quote($id,'/').'\s+('.$regexp.')\s+/',$AUTH_ACL); 305 if(count($matches)){ 306 foreach($matches as $match){ 307 $match = preg_replace('/#.*$/','',$match); //ignore comments 308 $acl = preg_split('/\s+/',$match); 309 if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! 310 if($acl[2] > $perm){ 311 $perm = $acl[2]; 312 } 313 } 314 if($perm > -1){ 315 //we had a match - return it 316 return $perm; 317 } 318 } 319 320 //still here? do the namespace checks 321 if($ns){ 322 $path = $ns.':\*'; 323 }else{ 324 $path = '\*'; //root document 325 } 326 327 do{ 328 $matches = preg_grep('/^'.$path.'\s+('.$regexp.')\s+/',$AUTH_ACL); 329 if(count($matches)){ 330 foreach($matches as $match){ 331 $match = preg_replace('/#.*$/','',$match); //ignore comments 332 $acl = preg_split('/\s+/',$match); 333 if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! 334 if($acl[2] > $perm){ 335 $perm = $acl[2]; 336 } 337 } 338 //we had a match - return it 339 return $perm; 340 } 341 342 //get next higher namespace 343 $ns = getNS($ns); 344 345 if($path != '\*'){ 346 $path = $ns.':\*'; 347 if($path == ':\*') $path = '\*'; 348 }else{ 349 //we did this already 350 //looks like there is something wrong with the ACL 351 //break here 352 msg('No ACL setup yet! Denying access to everyone.'); 353 return AUTH_NONE; 354 } 355 }while(1); //this should never loop endless 356 357 //still here? return no permissions 358 return AUTH_NONE; 359} 360 361/** 362 * Encode ASCII special chars 363 * 364 * Some auth backends allow special chars in their user and groupnames 365 * The special chars are encoded with this function. Only ASCII chars 366 * are encoded UTF-8 multibyte are left as is (different from usual 367 * urlencoding!). 368 * 369 * Decoding can be done with rawurldecode 370 * 371 * @author Andreas Gohr <gohr@cosmocode.de> 372 * @see rawurldecode() 373 */ 374function auth_nameencode($name,$skip_group=false){ 375 if($skip_group && $name{0} =='@'){ 376 return '@'.preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', 377 "'%'.dechex(ord('\\1'))",substr($name,1)); 378 }else{ 379 return preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', 380 "'%'.dechex(ord('\\1'))",$name); 381 } 382} 383 384/** 385 * Create a pronouncable password 386 * 387 * @author Andreas Gohr <andi@splitbrain.org> 388 * @link http://www.phpbuilder.com/annotate/message.php3?id=1014451 389 * 390 * @return string pronouncable password 391 */ 392function auth_pwgen(){ 393 $pw = ''; 394 $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones 395 $v = 'aeiou'; //vowels 396 $a = $c.$v; //both 397 398 //use two syllables... 399 for($i=0;$i < 2; $i++){ 400 $pw .= $c[rand(0, strlen($c)-1)]; 401 $pw .= $v[rand(0, strlen($v)-1)]; 402 $pw .= $a[rand(0, strlen($a)-1)]; 403 } 404 //... and add a nice number 405 $pw .= rand(10,99); 406 407 return $pw; 408} 409 410/** 411 * Sends a password to the given user 412 * 413 * @author Andreas Gohr <andi@splitbrain.org> 414 * 415 * @return bool true on success 416 */ 417function auth_sendPassword($user,$password){ 418 global $conf; 419 global $lang; 420 global $auth; 421 422 $hdrs = ''; 423 $userinfo = $auth->getUserData($user); 424 425 if(!$userinfo['mail']) return false; 426 427 $text = rawLocale('password'); 428 $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text); 429 $text = str_replace('@FULLNAME@',$userinfo['name'],$text); 430 $text = str_replace('@LOGIN@',$user,$text); 431 $text = str_replace('@PASSWORD@',$password,$text); 432 $text = str_replace('@TITLE@',$conf['title'],$text); 433 434 return mail_send($userinfo['name'].' <'.$userinfo['mail'].'>', 435 $lang['regpwmail'], 436 $text, 437 $conf['mailfrom']); 438} 439 440/** 441 * Register a new user 442 * 443 * This registers a new user - Data is read directly from $_POST 444 * 445 * @author Andreas Gohr <andi@splitbrain.org> 446 * 447 * @return bool true on success, false on any error 448 */ 449function register(){ 450 global $lang; 451 global $conf; 452 global $auth; 453 454 if(!$_POST['save']) return false; 455 if(!$auth->canDo('addUser')) return false; 456 457 //clean username 458 $_POST['login'] = preg_replace('/.*:/','',$_POST['login']); 459 $_POST['login'] = cleanID($_POST['login']); 460 //clean fullname and email 461 $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%]+/','',$_POST['fullname'])); 462 $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%]+/','',$_POST['email'])); 463 464 if( empty($_POST['login']) || 465 empty($_POST['fullname']) || 466 empty($_POST['email']) ){ 467 msg($lang['regmissing'],-1); 468 return false; 469 } 470 471 if ($conf['autopasswd']) { 472 $pass = auth_pwgen(); // automatically generate password 473 } elseif (empty($_POST['pass']) || 474 empty($_POST['passchk'])) { 475 msg($lang['regmissing'], -1); // complain about missing passwords 476 return false; 477 } elseif ($_POST['pass'] != $_POST['passchk']) { 478 msg($lang['regbadpass'], -1); // complain about misspelled passwords 479 return false; 480 } else { 481 $pass = $_POST['pass']; // accept checked and valid password 482 } 483 484 //check mail 485 if(!mail_isvalid($_POST['email'])){ 486 msg($lang['regbadmail'],-1); 487 return false; 488 } 489 490 //okay try to create the user 491 if(!$auth->createUser($_POST['login'],$pass,$_POST['fullname'],$_POST['email'])){ 492 msg($lang['reguexists'],-1); 493 return false; 494 } 495 496 if (!$conf['autopasswd']) { 497 msg($lang['regsuccess2'],1); 498 return true; 499 } 500 501 // autogenerated password? then send him the password 502 if (auth_sendPassword($_POST['login'],$pass)){ 503 msg($lang['regsuccess'],1); 504 return true; 505 }else{ 506 msg($lang['regmailfail'],-1); 507 return false; 508 } 509} 510 511/** 512 * Update user profile 513 * 514 * @author Christopher Smith <chris@jalakai.co.uk> 515 */ 516function updateprofile() { 517 global $conf; 518 global $INFO; 519 global $lang; 520 global $auth; 521 522 if(!$_POST['save']) return false; 523 524 // should not be able to get here without Profile being possible... 525 if(!$auth->canDo('Profile')) { 526 msg($lang['profna'],-1); 527 return false; 528 } 529 530 if ($_POST['newpass'] != $_POST['passchk']) { 531 msg($lang['regbadpass'], -1); // complain about misspelled passwords 532 return false; 533 } 534 535 //clean fullname and email 536 $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%]+/','',$_POST['fullname'])); 537 $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%]+/','',$_POST['email'])); 538 539 if (empty($_POST['fullname']) || empty($_POST['email'])) { 540 msg($lang['profnoempty'],-1); 541 return false; 542 } 543 544 if (!mail_isvalid($_POST['email'])){ 545 msg($lang['regbadmail'],-1); 546 return false; 547 } 548 549 if ($_POST['fullname'] != $INFO['userinfo']['name']) $changes['name'] = $_POST['fullname']; 550 if ($_POST['email'] != $INFO['userinfo']['mail']) $changes['mail'] = $_POST['email']; 551 if (!empty($_POST['newpass'])) $changes['pass'] = $_POST['newpass']; 552 553 if (!count($changes)) { 554 msg($lang['profnochange'], -1); 555 return false; 556 } 557 558 if ($conf['profileconfirm']) { 559 if (!auth_verifyPassword($_POST['oldpass'],$INFO['userinfo']['pass'])) { 560 msg($lang['badlogin'],-1); 561 return false; 562 } 563 } 564 565 return $auth->modifyUser($_SERVER['REMOTE_USER'], $changes); 566} 567 568/** 569 * Send a new password 570 * 571 * @author Benoit Chesneau <benoit@bchesneau.info> 572 * @author Chris Smith <chris@jalakai.co.uk> 573 * 574 * @return bool true on success, false on any error 575*/ 576function act_resendpwd(){ 577 global $lang; 578 global $conf; 579 global $auth; 580 581 if(!$_POST['save']) return false; 582 if(!$conf['resendpasswd']) return false; 583 584 // should not be able to get here without modPass being possible... 585 if(!$auth->canDo('modPass')) { 586 msg($lang['resendna'],-1); 587 return false; 588 } 589 590 if (empty($_POST['login'])) { 591 msg($lang['resendpwdmissing'], -1); 592 return false; 593 } else { 594 $user = $_POST['login']; 595 } 596 597 $userinfo = $auth->getUserData($user); 598 if(!$userinfo['mail']) { 599 msg($lang['resendpwdnouser'], -1); 600 return false; 601 } 602 603 $pass = auth_pwgen(); 604 if (!$auth->modifyUser($user,array('pass' => $pass))) { 605 msg('error modifying user data',-1); 606 return false; 607 } 608 609 if (auth_sendPassword($user,$pass)) { 610 msg($lang['resendpwdsuccess'],1); 611 } else { 612 msg($lang['regmailfail'],-1); 613 } 614 return true; 615} 616 617/** 618 * Uses a regular expresion to check if a given mail address is valid 619 * 620 * May not be completly RFC conform! 621 * 622 * @link http://www.webmasterworld.com/forum88/135.htm 623 * 624 * @param string $email the address to check 625 * @return bool true if address is valid 626 */ 627function isvalidemail($email){ 628 return eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email); 629} 630 631/** 632 * Encrypts a password using the given method and salt 633 * 634 * If the selected method needs a salt and none was given, a random one 635 * is chosen. 636 * 637 * The following methods are understood: 638 * 639 * smd5 - Salted MD5 hashing 640 * md5 - Simple MD5 hashing 641 * sha1 - SHA1 hashing 642 * ssha - Salted SHA1 hashing 643 * crypt - Unix crypt 644 * mysql - MySQL password (old method) 645 * my411 - MySQL 4.1.1 password 646 * 647 * @author Andreas Gohr <andi@splitbrain.org> 648 * @return string The crypted password 649 */ 650function auth_cryptPassword($clear,$method='',$salt=''){ 651 global $conf; 652 if(empty($method)) $method = $conf['passcrypt']; 653 654 //prepare a salt 655 if(empty($salt)) $salt = md5(uniqid(rand(), true)); 656 657 switch(strtolower($method)){ 658 case 'smd5': 659 return crypt($clear,'$1$'.substr($salt,0,8).'$'); 660 case 'md5': 661 return md5($clear); 662 case 'sha1': 663 return sha1($clear); 664 case 'ssha': 665 $salt=substr($salt,0,4); 666 return '{SSHA}'.base64_encode(pack("H*", sha1($clear.$salt)).$salt); 667 case 'crypt': 668 return crypt($clear,substr($salt,0,2)); 669 case 'mysql': 670 //from http://www.php.net/mysql comment by <soren at byu dot edu> 671 $nr=0x50305735; 672 $nr2=0x12345671; 673 $add=7; 674 $charArr = preg_split("//", $clear); 675 foreach ($charArr as $char) { 676 if (($char == '') || ($char == ' ') || ($char == '\t')) continue; 677 $charVal = ord($char); 678 $nr ^= ((($nr & 63) + $add) * $charVal) + ($nr << 8); 679 $nr2 += ($nr2 << 8) ^ $nr; 680 $add += $charVal; 681 } 682 return sprintf("%08x%08x", ($nr & 0x7fffffff), ($nr2 & 0x7fffffff)); 683 case 'my411': 684 return '*'.sha1(pack("H*", sha1($clear))); 685 default: 686 msg("Unsupported crypt method $method",-1); 687 } 688} 689 690/** 691 * Verifies a cleartext password against a crypted hash 692 * 693 * The method and salt used for the crypted hash is determined automatically 694 * then the clear text password is crypted using the same method. If both hashs 695 * match true is is returned else false 696 * 697 * @author Andreas Gohr <andi@splitbrain.org> 698 * @return bool 699 */ 700function auth_verifyPassword($clear,$crypt){ 701 $method=''; 702 $salt=''; 703 704 //determine the used method and salt 705 $len = strlen($crypt); 706 if(substr($crypt,0,3) == '$1$'){ 707 $method = 'smd5'; 708 $salt = substr($crypt,3,8); 709 }elseif(substr($crypt,0,6) == '{SSHA}'){ 710 $method = 'ssha'; 711 $salt = substr(base64_decode(substr($crypt, 6)),20); 712 }elseif($len == 32){ 713 $method = 'md5'; 714 }elseif($len == 40){ 715 $method = 'sha1'; 716 }elseif($len == 16){ 717 $method = 'mysql'; 718 }elseif($len == 41 && $crypt[0] == '*'){ 719 $method = 'my411'; 720 }else{ 721 $method = 'crypt'; 722 $salt = substr($crypt,0,2); 723 } 724 725 //crypt and compare 726 if(auth_cryptPassword($clear,$method,$salt) === $crypt){ 727 return true; 728 } 729 return false; 730} 731 732//Setup VIM: ex: et ts=2 enc=utf-8 : 733