From: <ru...@us...> - 2009-06-04 11:31:15
|
Revision: 6868 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6868&view=rev Author: rurban Date: 2009-06-04 11:30:51 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Placeholder for Facebook (almost working) and OpenID auth Added Paths: ----------- trunk/lib/WikiUser/Facebook.php trunk/lib/WikiUser/OpenID.php Added: trunk/lib/WikiUser/Facebook.php =================================================================== --- trunk/lib/WikiUser/Facebook.php (rev 0) +++ trunk/lib/WikiUser/Facebook.php 2009-06-04 11:30:51 UTC (rev 6868) @@ -0,0 +1,64 @@ +<?php //-*-php-*- +rcs_id('$Id: Facebook.php 6184 2008-08-22 10:33:41Z vargenau $'); +/* Copyright (C) 2009 Reini Urban + * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2) + * + * From http://developeronline.blogspot.com/2008/10/using-perl-against-facebook-part-i.html: + * GET 'http://www.facebook.com/login.php', and rest our virtual browser there to collect the cookies + * POST to 'https://login.facebook.com/login.php' with the proper parameters + */ + +// requires the openssl extension +require_once("lib/HttpClient.php"); + +class _FacebookPassUser +extends _PassUser { + /** + * Preferences are handled in _PassUser + */ + function checkPass($password) { + $userid = $this->_userid; + if (!loadPhpExtension('openssl')) { + trigger_error(_("The PECL openssl extension cannot be loaded"), + E_USER_WARNING); + return $this->_tryNextUser(); + } + $web = new HttpClient("www.facebook.com", 80); + if (DEBUG & _DEBUG_LOGIN) $web->setDebug(true); + // collect cookies from http://www.facebook.com/login.php + $firstlogin = $web->get("/login.php"); + if (!$firstlogin) { + trigger_error(_("Facebook connect failed with %d %s", $this->status, $this->errormsg), + E_USER_WARNING); + } + // Switch from http to https://login.facebook.com/login.php + $web->post = 443; + if (!$web->post("/login.php", array('user'=>$userid, 'pass'=>$password))) { + trigger_error(_("Facebook login failed with %d %s", $this->status, $this->errormsg), + E_USER_WARNING); + } + $this->_authmethod = 'Facebook'; + if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => $retval", + E_USER_WARNING); + if ($retval) { + $this->_level = WIKIAUTH_USER; + } else { + $this->_level = WIKIAUTH_ANON; + } + return $this->_level; + } + + function userExists() { + if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => true (dummy)", E_USER_WARNING); + return true; + } +} + +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: +?> \ No newline at end of file Property changes on: trunk/lib/WikiUser/Facebook.php ___________________________________________________________________ Added: svn:executable + * Added: trunk/lib/WikiUser/OpenID.php =================================================================== --- trunk/lib/WikiUser/OpenID.php (rev 0) +++ trunk/lib/WikiUser/OpenID.php 2009-06-04 11:30:51 UTC (rev 6868) @@ -0,0 +1,48 @@ +<?php //-*-php-*- +rcs_id('$Id: OpenID.php,v 1.1 2006/12/24 13:35:43 rurban Exp $'); +/* Copyright (C) 2007 ReiniUrban + * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2) + * + * See http://openid.net/specs/openid-authentication-1_1.html + */ + +class _OpenIDPassUser +extends _PassUser +/** + * Preferences are handled in _PassUser + */ +{ + // This can only be called from _PassUser, because the parent class + // sets the pref methods, before this class is initialized. + function _OpenIDPassUser($UserName='', $prefs=false, $file='') { + if (!$this->_prefs and isa($this, "_OpenIDPassUser")) { + if ($prefs) $this->_prefs = $prefs; + if (!isset($this->_prefs->_method)) + _PassUser::_PassUser($UserName); + } + $this->_userid = $UserName; + return $this; + } + + function userExists() { + if (!$this->isValidName($this->_userid)) { + return $this->_tryNextUser(); + } + $this->_authmethod = 'OpenID'; + // check the prefs for emailVerified + if ($this->_prefs->get('emailVerified')) + return true; + return $this->_tryNextUser(); + } +} + +// $Log: OpenID.php,v $ + +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: +?> \ No newline at end of file Property changes on: trunk/lib/WikiUser/OpenID.php ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |