This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "quickfw".
The branch, master has been updated
via c430200b547ae5480b26ea387d427a09eb17325c (commit)
via b4c34313d3047e4e22ae7b3fb8144dbd798ba561 (commit)
from c8e7843959370e2207228f2760c5552ee29b5feb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c430200b547ae5480b26ea387d427a09eb17325c
Author: Ivan1986 <iva...@li...>
Date: Tue Jun 22 11:35:43 2010 +0400
Контроллер для авторизации по OpenID (пока базовая реализация)
diff --git a/application/default/controllers/OidController.php b/application/default/controllers/OidController.php
new file mode 100644
index 0000000..1eeee69
--- /dev/null
+++ b/application/default/controllers/OidController.php
@@ -0,0 +1,131 @@
+<?php
+
+require_once "Auth/OpenID/Consumer.php";
+require_once "Auth/OpenID/FileStore.php";
+require_once "Auth/OpenID/SReg.php";
+require_once "Auth/OpenID/PAPE.php";
+
+require_once QFWPATH.'/QuickFW/Auth.php';
+
+class OidController extends QuickFW_Auth
+{
+
+ public function __construct()
+ {
+ QFW::$view->mainTemplate='';
+ $this->session();
+ }
+
+ public function indexAction($clean = false)
+ {
+ if ($clean == 1)
+ {
+ unset($_SESSION['openID']);
+ QFW::$router->redirect(Url::A());
+ }
+ if (!empty($_SESSION['openID']))
+ {
+ var_dump($_SESSION['openID']);
+ }
+ ?>
+<form method="get" action="<?php echo Url::C('try') ?>">
+<input type="text" name="openid_identifier" value="<?php echo QFW::$view->esc(
+ 'http://quickfw.ib.br/openid/server.php/idpage?user=ivan') ?>" />
+<input type="submit" value="Verify" />
+</form>
+<a href="<?php echo Url::A('1') ?>">выйти</a>
+ <?php
+ }
+
+ /* array(
+ 'fullname' => 'Full Name',
+ 'nickname' => 'Nickname',
+ 'dob' => 'Date of Birth',
+ 'email' => 'E-mail Address',
+ 'gender' => 'Gender',
+ 'postcode' => 'Postal Code',
+ 'country' => 'Country',
+ 'language' => 'Language',
+ 'timezone' => 'Time Zone',
+ ); */
+
+ public function tryAction()
+ {
+ if (empty($_GET['openid_identifier']))
+ $this->err('Expected an OpenID URL');
+ $consumer = $this->getConsumer();
+ $auth_request = $consumer->begin($_GET['openid_identifier']);
+ if (!$auth_request)
+ $this->err('Authentication error; not a valid OpenID');
+
+ $sreg_request = Auth_OpenID_SRegRequest::build(
+ array('nickname'), // Required
+ array('fullname', 'email') // Optional
+ );
+ if ($sreg_request)
+ $auth_request->addExtension($sreg_request);
+
+ $redirect = $auth_request->shouldSendRedirect();
+
+ $server = $this->getServer();
+ $trustRoot = $server.Url::C('');
+ echo $trustRoot;
+
+ $query = $redirect ?
+ $auth_request->redirectURL($server.Url::C(''), $server.Url::C('finish')) :
+ $auth_request->htmlMarkup($server.Url::C(''),
+ $server.Url::C('finish'), false, array('id' => 'openid_message'));
+ if (Auth_OpenID::isFailure($query))
+ $this->err("Could not redirect to server: " . $query->message);
+
+ if ($redirect)
+ QFW::$router->redirect((string)$query);
+ else
+ die($query);
+ }
+
+ public function finishAction()
+ {
+ if (empty($_GET['openid_identity']))
+ $this->err('Expected an OpenID URL');
+ $consumer = $this->getConsumer();
+ $response = $consumer->complete($this->getServer().Url::A());
+ if ($response->status == Auth_OpenID_CANCEL)
+ $this->err('Verification cancelled.');
+ else if ($response->status == Auth_OpenID_FAILURE)
+ $this->err('OpenID authentication failed: ' . $response->message);
+ else if ($response->status == Auth_OpenID_SUCCESS)
+ {
+ $openid = $response->getDisplayIdentifier();
+
+ $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
+ $sreg = $sreg_resp->contents();
+
+ $_SESSION['openID'] = $sreg + array('id' => $openid);
+ QFW::$router->redirect(Url::C('index'));
+ }
+ }
+
+ private function err($msg)
+ {
+ die($msg);
+ }
+
+ private function getConsumer()
+ {
+ $path = TMPPATH.'/openid';
+ if (!is_dir($path))
+ mkdir($path);
+ $store = new Auth_OpenID_FileStore($path);
+ return new Auth_OpenID_Consumer($store);
+ }
+
+ private function getServer()
+ {
+ return 'http://'.$_SERVER['HTTP_HOST'].
+ ($_SERVER['SERVER_PORT']==80?'':$_SERVER['SERVER_PORT']);
+ }
+
+}
+
+?>
commit b4c34313d3047e4e22ae7b3fb8144dbd798ba561
Author: Ivan1986 <iva...@li...>
Date: Tue Jun 22 11:35:01 2010 +0400
Недокомичен лог xmpp
diff --git a/lib/jabber/XMPPHP/Log.php b/lib/jabber/XMPPHP/Log.php
new file mode 100644
index 0000000..a9bce3d
--- /dev/null
+++ b/lib/jabber/XMPPHP/Log.php
@@ -0,0 +1,119 @@
+<?php
+/**
+ * XMPPHP: The PHP XMPP Library
+ * Copyright (C) 2008 Nathanael C. Fritz
+ * This file is part of SleekXMPP.
+ *
+ * XMPPHP is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XMPPHP is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XMPPHP; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category xmpphp
+ * @package XMPPHP
+ * @author Nathanael C. Fritz <JID: fr...@ne...>
+ * @author Stephan Wentz <JID: st...@ja...>
+ * @author Michael Garvin <JID: ga...@ne...>
+ * @copyright 2008 Nathanael C. Fritz
+ */
+
+/**
+ * XMPPHP Log
+ *
+ * @package XMPPHP
+ * @author Nathanael C. Fritz <JID: fr...@ne...>
+ * @author Stephan Wentz <JID: st...@ja...>
+ * @author Michael Garvin <JID: ga...@ne...>
+ * @copyright 2008 Nathanael C. Fritz
+ * @version $Id$
+ */
+class XMPPHP_Log {
+
+ const LEVEL_ERROR = 0;
+ const LEVEL_WARNING = 1;
+ const LEVEL_INFO = 2;
+ const LEVEL_DEBUG = 3;
+ const LEVEL_VERBOSE = 4;
+
+ /**
+ * @var array
+ */
+ protected $data = array();
+
+ /**
+ * @var array
+ */
+ protected $names = array('ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE');
+
+ /**
+ * @var integer
+ */
+ protected $runlevel;
+
+ /**
+ * @var boolean
+ */
+ protected $printout;
+
+ /**
+ * Constructor
+ *
+ * @param boolean $printout
+ * @param string $runlevel
+ */
+ public function __construct($printout = false, $runlevel = self::LEVEL_INFO) {
+ $this->printout = (boolean)$printout;
+ $this->runlevel = (int)$runlevel;
+ }
+
+ /**
+ * Add a message to the log data array
+ * If printout in this instance is set to true, directly output the message
+ *
+ * @param string $msg
+ * @param integer $runlevel
+ */
+ public function log($msg, $runlevel = self::LEVEL_INFO) {
+ $time = time();
+ #$this->data[] = array($this->runlevel, $msg, $time);
+ if($this->printout and $runlevel <= $this->runlevel) {
+ $this->writeLine($msg, $runlevel, $time);
+ }
+ }
+
+ /**
+ * Output the complete log.
+ * Log will be cleared if $clear = true
+ *
+ * @param boolean $clear
+ * @param integer $runlevel
+ */
+ public function printout($clear = true, $runlevel = null) {
+ if($runlevel === null) {
+ $runlevel = $this->runlevel;
+ }
+ foreach($this->data as $data) {
+ if($runlevel <= $data[0]) {
+ $this->writeLine($data[1], $runlevel, $data[2]);
+ }
+ }
+ if($clear) {
+ $this->data = array();
+ }
+ }
+
+ protected function writeLine($msg, $runlevel, $time) {
+ //echo date('Y-m-d H:i:s', $time)." [".$this->names[$runlevel]."]: ".$msg."\n";
+ echo $time." [".$this->names[$runlevel]."]: ".$msg."\n";
+ flush();
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
application/default/controllers/OidController.php | 131 +++++++++++++++++++++
lib/jabber/XMPPHP/Log.php | 119 +++++++++++++++++++
2 files changed, 250 insertions(+), 0 deletions(-)
create mode 100644 application/default/controllers/OidController.php
create mode 100644 lib/jabber/XMPPHP/Log.php
hooks/post-receive
--
quickfw
|