mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Renormalized all text file line endings
This commit is contained in:
@@ -1,185 +1,185 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Front page controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_index_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Do frontpage checks
|
||||
* Valid formats for frontpage preference value:
|
||||
* - url:Blog/My Blog Title.html (no redirect)
|
||||
* - url:news.php?extend.2 (no redirect)
|
||||
* - route:news/view/item?id=2 (no redirect)
|
||||
* - news.php?extend.2 (no redirect)
|
||||
* - http://mysite.com/news.php?extend.2 (redirect)
|
||||
* - http://mysite.com/Blog/My Blog Title.html (redirect)
|
||||
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$pref = eFront::app()->getPref();
|
||||
$tp = e107::getParser();
|
||||
$indexRoute = 'index/index/index';
|
||||
|
||||
if (file_exists(e_BASE.'index_include.php'))
|
||||
{
|
||||
include (e_BASE.'index_include.php');
|
||||
}
|
||||
|
||||
$location = '';
|
||||
$class_list = explode(',', USERCLASS_LIST);
|
||||
|
||||
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
|
||||
{ // 0.7 method
|
||||
$location = $pref['frontpage']['all'];
|
||||
}
|
||||
else
|
||||
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
|
||||
if(vartrue($pref['frontpage']))
|
||||
{
|
||||
foreach ($pref['frontpage'] as $fk=>$fp)
|
||||
{
|
||||
if (in_array($fk, $class_list))
|
||||
{
|
||||
$location = $fp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$location)
|
||||
{ // Try and use the 'old' method (this bit can go later)
|
||||
if (ADMIN)
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_ADMIN];
|
||||
}
|
||||
elseif (USER)
|
||||
{ // This is the key bit - what to do for a 'normal' logged in user
|
||||
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
|
||||
foreach ($class_list as $fp_class)
|
||||
{
|
||||
$inclass = false;
|
||||
if (!$inclass && check_class($fp_class['userclass_id']))
|
||||
{
|
||||
$location = $pref['frontpage'][$fp_class['userclass_id']];
|
||||
$inclass = true;
|
||||
}
|
||||
}
|
||||
$location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_GUEST];
|
||||
}
|
||||
}
|
||||
|
||||
$location = trim($location);
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Defaults to news
|
||||
if(!$location) $location = 'url:/news';
|
||||
// Former Welcome Message front-page. Should be handled by current theme layout
|
||||
elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
|
||||
{
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward('front');
|
||||
return;
|
||||
}
|
||||
elseif($location[0] === '{')
|
||||
{
|
||||
$location = $tp->replaceConstants($location, true);
|
||||
}
|
||||
|
||||
// new url format; if set to 'url:' only it'll resolve current main module (if any)
|
||||
if(strpos($location, 'url:') === 0)
|
||||
{
|
||||
$url = substr($location, 4);
|
||||
$request->setPathInfo($url)->setRequestParams(array());
|
||||
$router = eFront::instance()->getRouter();
|
||||
|
||||
if($router->route($request, true))
|
||||
{
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward($request->getRoute());
|
||||
return;
|
||||
}
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
// route is provided
|
||||
elseif(strpos($location, 'route:') === 0)
|
||||
{
|
||||
list($route, $qstr) = explode('?', substr($location, 6).'?');
|
||||
|
||||
if(!$qstr) $qstr = array();
|
||||
else parse_str($qstr, $qstr);
|
||||
|
||||
$request->setRoute($route);
|
||||
$request->setRequestParams($qstr);
|
||||
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward($request->getRoute(), $qstr);
|
||||
|
||||
return;
|
||||
}
|
||||
// redirect to this address
|
||||
elseif(strpos($location, 'http://') === 0 || strpos($location, 'https://') === 0)
|
||||
{
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// Enter in legacy mod, include the front page
|
||||
elseif(strpos($location, '.php') !== false)
|
||||
{
|
||||
list($page, $qstr) = explode("?", $location."?");
|
||||
|
||||
$request->setLegacyPage($page)
|
||||
->setLegacyQstring($qstr);
|
||||
|
||||
$request->routed = true;
|
||||
define('e_FRONTPAGE', true);
|
||||
eFront::isLegacy('{e_BASE}'.$page);
|
||||
return $this;
|
||||
}
|
||||
// Redirect
|
||||
else
|
||||
{
|
||||
$location = SITEURL.$location;
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// we can't do much
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
|
||||
public function actionFront()
|
||||
{
|
||||
// we could notify current theme we are in front page controlled by the theme layout only...
|
||||
// switch off tablerender
|
||||
$this->getResponse()->setParam('render', false);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Front page controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_index_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Do frontpage checks
|
||||
* Valid formats for frontpage preference value:
|
||||
* - url:Blog/My Blog Title.html (no redirect)
|
||||
* - url:news.php?extend.2 (no redirect)
|
||||
* - route:news/view/item?id=2 (no redirect)
|
||||
* - news.php?extend.2 (no redirect)
|
||||
* - http://mysite.com/news.php?extend.2 (redirect)
|
||||
* - http://mysite.com/Blog/My Blog Title.html (redirect)
|
||||
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$pref = eFront::app()->getPref();
|
||||
$tp = e107::getParser();
|
||||
$indexRoute = 'index/index/index';
|
||||
|
||||
if (file_exists(e_BASE.'index_include.php'))
|
||||
{
|
||||
include (e_BASE.'index_include.php');
|
||||
}
|
||||
|
||||
$location = '';
|
||||
$class_list = explode(',', USERCLASS_LIST);
|
||||
|
||||
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
|
||||
{ // 0.7 method
|
||||
$location = $pref['frontpage']['all'];
|
||||
}
|
||||
else
|
||||
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
|
||||
if(vartrue($pref['frontpage']))
|
||||
{
|
||||
foreach ($pref['frontpage'] as $fk=>$fp)
|
||||
{
|
||||
if (in_array($fk, $class_list))
|
||||
{
|
||||
$location = $fp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$location)
|
||||
{ // Try and use the 'old' method (this bit can go later)
|
||||
if (ADMIN)
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_ADMIN];
|
||||
}
|
||||
elseif (USER)
|
||||
{ // This is the key bit - what to do for a 'normal' logged in user
|
||||
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
|
||||
foreach ($class_list as $fp_class)
|
||||
{
|
||||
$inclass = false;
|
||||
if (!$inclass && check_class($fp_class['userclass_id']))
|
||||
{
|
||||
$location = $pref['frontpage'][$fp_class['userclass_id']];
|
||||
$inclass = true;
|
||||
}
|
||||
}
|
||||
$location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_GUEST];
|
||||
}
|
||||
}
|
||||
|
||||
$location = trim($location);
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Defaults to news
|
||||
if(!$location) $location = 'url:/news';
|
||||
// Former Welcome Message front-page. Should be handled by current theme layout
|
||||
elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
|
||||
{
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward('front');
|
||||
return;
|
||||
}
|
||||
elseif($location[0] === '{')
|
||||
{
|
||||
$location = $tp->replaceConstants($location, true);
|
||||
}
|
||||
|
||||
// new url format; if set to 'url:' only it'll resolve current main module (if any)
|
||||
if(strpos($location, 'url:') === 0)
|
||||
{
|
||||
$url = substr($location, 4);
|
||||
$request->setPathInfo($url)->setRequestParams(array());
|
||||
$router = eFront::instance()->getRouter();
|
||||
|
||||
if($router->route($request, true))
|
||||
{
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward($request->getRoute());
|
||||
return;
|
||||
}
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
// route is provided
|
||||
elseif(strpos($location, 'route:') === 0)
|
||||
{
|
||||
list($route, $qstr) = explode('?', substr($location, 6).'?');
|
||||
|
||||
if(!$qstr) $qstr = array();
|
||||
else parse_str($qstr, $qstr);
|
||||
|
||||
$request->setRoute($route);
|
||||
$request->setRequestParams($qstr);
|
||||
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
define('e_FRONTPAGE', true);
|
||||
$this->_forward($request->getRoute(), $qstr);
|
||||
|
||||
return;
|
||||
}
|
||||
// redirect to this address
|
||||
elseif(strpos($location, 'http://') === 0 || strpos($location, 'https://') === 0)
|
||||
{
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// Enter in legacy mod, include the front page
|
||||
elseif(strpos($location, '.php') !== false)
|
||||
{
|
||||
list($page, $qstr) = explode("?", $location."?");
|
||||
|
||||
$request->setLegacyPage($page)
|
||||
->setLegacyQstring($qstr);
|
||||
|
||||
$request->routed = true;
|
||||
define('e_FRONTPAGE', true);
|
||||
eFront::isLegacy('{e_BASE}'.$page);
|
||||
return $this;
|
||||
}
|
||||
// Redirect
|
||||
else
|
||||
{
|
||||
$location = SITEURL.$location;
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// we can't do much
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
|
||||
public function actionFront()
|
||||
{
|
||||
// we could notify current theme we are in front page controlled by the theme layout only...
|
||||
// switch off tablerender
|
||||
$this->getResponse()->setParam('render', false);
|
||||
}
|
||||
}
|
||||
|
@@ -1,62 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* @file
|
||||
* System error controller.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class core_system_error_controller.
|
||||
*/
|
||||
class core_system_error_controller extends eController
|
||||
{
|
||||
|
||||
/**
|
||||
* Pre-action callback, fired only if dispatch status is still true
|
||||
* and action method is found.
|
||||
*/
|
||||
public function preAction()
|
||||
{
|
||||
e107::coreLan('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for "Error 403".
|
||||
*/
|
||||
public function action403()
|
||||
{
|
||||
$this->_forward('forbidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for "Error 404".
|
||||
*/
|
||||
public function action404()
|
||||
{
|
||||
$this->_forward('notfound');
|
||||
}
|
||||
|
||||
/**
|
||||
* Error 403.
|
||||
*/
|
||||
public function actionForbidden()
|
||||
{
|
||||
e107::getError()->render(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error 404.
|
||||
*/
|
||||
public function actionNotfound()
|
||||
{
|
||||
e107::getError()->render(404);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* @file
|
||||
* System error controller.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class core_system_error_controller.
|
||||
*/
|
||||
class core_system_error_controller extends eController
|
||||
{
|
||||
|
||||
/**
|
||||
* Pre-action callback, fired only if dispatch status is still true
|
||||
* and action method is found.
|
||||
*/
|
||||
public function preAction()
|
||||
{
|
||||
e107::coreLan('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for "Error 403".
|
||||
*/
|
||||
public function action403()
|
||||
{
|
||||
$this->_forward('forbidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for "Error 404".
|
||||
*/
|
||||
public function action404()
|
||||
{
|
||||
$this->_forward('notfound');
|
||||
}
|
||||
|
||||
/**
|
||||
* Error 403.
|
||||
*/
|
||||
public function actionForbidden()
|
||||
{
|
||||
e107::getError()->render(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error 404.
|
||||
*/
|
||||
public function actionNotfound()
|
||||
{
|
||||
e107::getError()->render(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System index controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_system_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Redirect to site Index
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$this->_redirect('/', false, 301);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System index controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_system_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Redirect to site Index
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$this->_redirect('/', false, 301);
|
||||
}
|
||||
}
|
||||
|
@@ -1,164 +1,164 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System XUP controller
|
||||
*
|
||||
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/update_routines.php $
|
||||
* $Revision: 12933 $
|
||||
* $Id: update_routines.php 12933 2012-08-06 08:55:51Z e107coders $
|
||||
* $Author: e107coders $
|
||||
*/
|
||||
|
||||
e107::coreLan('user');
|
||||
|
||||
class core_system_xup_controller extends eController
|
||||
{
|
||||
|
||||
var $backUrl = null;
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
//$back = 'system/xup/test';
|
||||
$this->backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true;
|
||||
}
|
||||
|
||||
public function actionSignup()
|
||||
{
|
||||
$allow = true;
|
||||
$session = e107::getSession();
|
||||
if($session->get('HAuthError'))
|
||||
{
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->signup($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$allow = true;
|
||||
$session = e107::getSession();
|
||||
if($session->get('HAuthError'))
|
||||
{
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
echo '<h3>'.LAN_XUP_ERRM_07.'</h3>';
|
||||
|
||||
if(getperms('0'))
|
||||
{
|
||||
echo e107::getMessage()->addError(LAN_XUP_ERRM_08)->render();
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($_GET['lgt']))
|
||||
{
|
||||
e107::getUser()->logout();
|
||||
}
|
||||
|
||||
$profileData = null;
|
||||
$provider = e107::getUser()->getProvider();
|
||||
if($provider)
|
||||
{
|
||||
$profileData = $provider->getUserProfile();
|
||||
|
||||
if(!empty($profileData))
|
||||
{
|
||||
print_a($profileData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo ' '.LAN_XUP_ERRM_11.' '.(e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
|
||||
|
||||
|
||||
$testUrl = SITEURL."?route=system/xup/test";
|
||||
$providers = e107::getPref('social_login', array());
|
||||
|
||||
foreach($providers as $key=>$var)
|
||||
{
|
||||
if($var['enabled'] == 1)
|
||||
{
|
||||
echo '<h3>'.$key.'</h3><ul>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/login?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/signup?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
|
||||
|
||||
echo "</ul>";
|
||||
}
|
||||
|
||||
// print_a($var);
|
||||
}
|
||||
|
||||
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?lgt').'">'.LAN_XUP_ERRM_12.'</a>';
|
||||
|
||||
/*
|
||||
echo '<h3>Facebook</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
|
||||
|
||||
echo '<h3>Twitter</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionEndpoint()
|
||||
{
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
|
||||
require_once( e_HANDLER."hybridauth/vendor/autoload.php");
|
||||
|
||||
try
|
||||
{
|
||||
Hybrid_Endpoint::process();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
$session = e107::getSession();
|
||||
$session->set('HAuthError', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System XUP controller
|
||||
*
|
||||
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/update_routines.php $
|
||||
* $Revision: 12933 $
|
||||
* $Id: update_routines.php 12933 2012-08-06 08:55:51Z e107coders $
|
||||
* $Author: e107coders $
|
||||
*/
|
||||
|
||||
e107::coreLan('user');
|
||||
|
||||
class core_system_xup_controller extends eController
|
||||
{
|
||||
|
||||
var $backUrl = null;
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
//$back = 'system/xup/test';
|
||||
$this->backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true;
|
||||
}
|
||||
|
||||
public function actionSignup()
|
||||
{
|
||||
$allow = true;
|
||||
$session = e107::getSession();
|
||||
if($session->get('HAuthError'))
|
||||
{
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->signup($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$allow = true;
|
||||
$session = e107::getSession();
|
||||
if($session->get('HAuthError'))
|
||||
{
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
echo '<h3>'.LAN_XUP_ERRM_07.'</h3>';
|
||||
|
||||
if(getperms('0'))
|
||||
{
|
||||
echo e107::getMessage()->addError(LAN_XUP_ERRM_08)->render();
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($_GET['lgt']))
|
||||
{
|
||||
e107::getUser()->logout();
|
||||
}
|
||||
|
||||
$profileData = null;
|
||||
$provider = e107::getUser()->getProvider();
|
||||
if($provider)
|
||||
{
|
||||
$profileData = $provider->getUserProfile();
|
||||
|
||||
if(!empty($profileData))
|
||||
{
|
||||
print_a($profileData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo ' '.LAN_XUP_ERRM_11.' '.(e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
|
||||
|
||||
|
||||
$testUrl = SITEURL."?route=system/xup/test";
|
||||
$providers = e107::getPref('social_login', array());
|
||||
|
||||
foreach($providers as $key=>$var)
|
||||
{
|
||||
if($var['enabled'] == 1)
|
||||
{
|
||||
echo '<h3>'.$key.'</h3><ul>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/login?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/signup?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
|
||||
|
||||
echo "</ul>";
|
||||
}
|
||||
|
||||
// print_a($var);
|
||||
}
|
||||
|
||||
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?lgt').'">'.LAN_XUP_ERRM_12.'</a>';
|
||||
|
||||
/*
|
||||
echo '<h3>Facebook</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
|
||||
|
||||
echo '<h3>Twitter</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionEndpoint()
|
||||
{
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
|
||||
require_once( e_HANDLER."hybridauth/vendor/autoload.php");
|
||||
|
||||
try
|
||||
{
|
||||
Hybrid_Endpoint::process();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
$session = e107::getSession();
|
||||
$session->set('HAuthError', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user