- md5
- da49f2afee46b2c051ecdb6e5d26dbf4
- sha1
- 9cd4bbceb2959aba0293c62d67ba155123c566c5
- sha256
- 4f0ec590f702fa263c04d6b627dd937eaee6f5973052e0a45e66a135fde1d028
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
<?php
/**
* @version $Id: gmail.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage JFramework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* GMail Authentication Plugin
*
* @package Joomla
* @subpackage JFramework
* @since 1.5
*/
class plgAuthenticationGMail extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgAuthenticationGMail(& $subject, $config) {
parent::__construct($subject, $config);
}
/**
* This method should handle any authentication and report back to the subject
*
* @access public
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object $response Authentication response object
* @return boolean
* @since 1.5
*/
function onAuthenticate( $credentials, $options, &$response )
{
$message = '';
$success = 0;
if(function_exists('curl_init'))
{
if(strlen($credentials['username']) && strlen($credentials['password']))
{
$curl = curl_init('https://mail.google.com/mail/feed/atom');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_USERPWD, $credentials['username'].':'.$credentials['password']);
$result = curl_exec($curl);
$code = curl_getinfo ($curl, CURLINFO_HTTP_CODE);
switch($code)
{
case 200:
$message = 'Access Granted';
$success = 1;
break;
case 401:
$message = 'Access Denied';
break;
default:
$message = 'Result unknown, access denied.';
break;
}
}
else {
$message = 'Username or password blank';
}
}
else {
$message = 'curl isn\'t installed';
}
if ($success)
{
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
$response->email = $credentials['username'];
$response->fullname = $credentials['username'];
}
else
{
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Failed to authenticate: ' . $message;
}
}
}
The same content is in 11 releases, Joomla 1.5.16 to 1.5.26. See them all, or every version of this file.