⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmail.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
字号:
<?php/** * @version		$Id: gmail.php 11236 2008-11-02 02:44:35Z ian $ * @package		Joomla * @subpackage	JFramework * @copyright	Copyright (C) 2005 - 2008 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;		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -