[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Auth_yahoo:: class checks login credentials against Yahoo! mail 4 * accounts. 5 * 6 * $Horde: framework/Auth/Auth/yahoo.php,v 1.13.12.7 2006/01/01 21:28:07 jan Exp $ 7 * 8 * Copyright 1999-2006 Chuck Hagenbuch <chuck@horde.org> 9 * 10 * See the enclosed file COPYING for license information (LGPL). If you 11 * did not receive this file, see yahoo://www.fsf.org/copyleft/lgpl.html. 12 * 13 * @author Chuck Hagenbuch <chuck@horde.org> 14 * @since Horde 3.0 15 * @package Horde_Auth 16 */ 17 class Auth_yahoo extends Auth { 18 19 /** 20 * @var HTTP_Request 21 */ 22 var $_http; 23 24 /** 25 * Constructs a new Yahoo authentication object. 26 * 27 * @param array $params A hash containing parameters. 28 */ 29 function Auth_yahoo($params = array()) 30 { 31 $this->_params = $params; 32 } 33 34 /** 35 * Find out if a set of login credentials are valid. 36 * 37 * @access private 38 * 39 * @param string $userId The userId to check. 40 * @param array $credentials The credentials to use. 41 * 42 * @return boolean Whether or not the credentials are valid. 43 */ 44 function _authenticate($userId, $credentials) 45 { 46 require_once 'HTTP/Request.php'; 47 48 // Make sure that we have a bare username - strip off anything 49 // after (and including) the first @, if there is one. 50 $pos = strpos($userId, '@'); 51 if ($pos !== false) { 52 $userId = substr($userId, 0, $pos); 53 } 54 55 $options['method'] = HTTP_REQUEST_METHOD_POST; 56 $options['timeout'] = 5; 57 $options['allowRedirects'] = true; 58 59 $this->_http = &new HTTP_Request('http://login.yahoo.com/config/login', $options); 60 $this->_http->addPostData('login', $userId); 61 $this->_http->addPostData('passwd', $credentials['password']); 62 63 $result = $this->_http->sendRequest(); 64 if (is_a($result, 'PEAR_Error')) { 65 $result = $result->getMessage(); 66 } else { 67 $result = $this->_http->getResponseBody(); 68 $cookies = $this->_http->getResponseCookies(); 69 if (is_array($cookies)) { 70 foreach ($cookies as $cookie) { 71 $this->_http->addCookie($cookie['name'], $cookie['value']); 72 } 73 } 74 } 75 76 // This is _such_ a hack, but it works. 77 if (!preg_match('|invalid password|i', $result)) { 78 return true; 79 } else { 80 Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_DEBUG); 81 $this->_setAuthError(AUTH_REASON_BADLOGIN); 82 return false; 83 } 84 } 85 86 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |