本文整理汇总了PHP中wfSetupSession函数的典型用法代码示例。如果您正苦于以下问题:PHP wfSetupSession函数的具体用法?PHP wfSetupSession怎么用?PHP wfSetupSession使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfSetupSession函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
protected function __construct()
{
// Make sure the session is started
if (session_id() === '') {
wfSetupSession();
}
}
示例2: startExperiment
/**
* Initialize the experiment and set all required tracking things
*
* @param string $experimentName
* @param array $experimentConfig
*/
private static function startExperiment($experimentName, array $experimentConfig)
{
wfDebug(sprintf("%s[%s] using %s class with %s params\n", __METHOD__, $experimentName, $experimentConfig['handler'], json_encode($experimentConfig['params'])));
new $experimentConfig['handler']($experimentConfig['params'] ?: []);
// mark a transaction with an experiment name
\Transaction::getInstance()->set(\Transaction::PARAM_AB_PERFORMANCE_TEST, $experimentName);
// set a global JS variable with an experiment name
global $wgHooks;
$wgHooks['WikiaSkinTopScripts'][] = function (array &$vars, &$scripts) use($experimentName) {
$vars['wgABPerformanceTest'] = $experimentName;
return true;
};
/*
* Start the session to bypass CDN cache
*
* We don't want to polute the CDN cache with the A/B performance testing tracking data.
* As the test are run for only a small subset of the traffic, start the session for client
* that are in the test groups to bypass the CDN cache.
*/
if (session_id() == '') {
wfSetupSession();
wfDebug(__METHOD__ . " - session started\n");
// log started sessions
global $wgUser;
WikiaLogger::instance()->info(__METHOD__, ['experiment' => $experimentName, 'session_id' => session_id(), 'is_anon' => $wgUser->isAnon()]);
}
}
示例3: execute
function execute($par)
{
global $wgOut, $wgRequest, $wgUser, $wgFBAppId, $wgFBAppSecret, $wgLanguageCode, $wgContLang, $IP;
require_once "{$IP}/extensions/wikihow/common/facebook-platform/facebook-php-sdk-771862b/src/facebook.php";
wfLoadExtensionMessages('FBLogin');
if (session_id() == '') {
wfSetupSession();
}
$this->returnto = $wgLanguageCode == 'en' ? wfMsg('fbc_returnto') : "/" . $wgContLang->getNSText(NS_PROJECT) . ":" . wfMsg('communityportal');
//$this->returnto = $_COOKIE['wiki_returnto'] ? $_COOKIE['wiki_returnto'] : "/Special:CommunityDashboard";
$this->userid = $_COOKIE['wiki_fbuser'];
$userid = $this->userid;
if (!$userid) {
$wgOut->addHTML("An error occurred.<!--" . print_r($_COOKIE, true) . "-->");
return;
}
$this->setWgUser();
$this->facebook = new Facebook(array('appId' => $wgFBAppId, 'secret' => $wgFBAppSecret));
$accessToken = $_COOKIE['wiki_fbtoken'];
$this->facebook->setAccessToken($accessToken);
$result = $this->facebook->api('/me');
if (!$wgRequest->wasPosted()) {
// If they still have the FB_* name, show them the registration form with a proposed name
if (strpos($wgUser->getName(), "FB_") !== false) {
$this->printRegForm($result);
} else {
$this->updateAvatar($result);
// All logged in. Return them to wherever they're supposed to go
$this->setCookies();
$wgOut->redirect($this->returnto);
}
} else {
$this->processRegForm($result);
}
}
示例4: startSession
static function startSession()
{
if (session_id() == '') {
wfSetupSession();
}
self::clearCollection();
}
示例5: execute
function execute($par)
{
global $wgRequest, $wgUser, $wgLanguageCode, $wgContLang, $wgOut;
wfLoadExtensionMessages('GPlusLogin');
if (session_id() == '') {
wfSetupSession();
}
//disconnecting?
if ($wgRequest->getVal('disconnect')) {
self::userDisco();
return;
}
//returning to the community dashboard
$this->returnto = $wgLanguageCode == 'en' ? wfMsg('gpl_returnto') : "/" . $wgContLang->getNSText(NS_PROJECT) . ":" . wfMsg('communityportal');
//set that user (if we can)
$this->userid = $wgRequest->getVal('gplus_id') ? $wgRequest->getVal('gplus_id') : $wgRequest->getVal('user_id');
if ($this->userid) {
$this->setWgUser();
}
if ($wgRequest->wasPosted() && $wgRequest->getVal('gplus_id')) {
self::processForm();
return;
}
//get user's G+ info
$gp_id = $wgRequest->getVal('user_id');
$gp_name = $wgRequest->getVal('user_name');
$gp_email = $wgRequest->getVal('user_email');
$gp_avatar = $wgRequest->getVal('user_avatar');
self::showForm($gp_id, $gp_name, $gp_email, $gp_avatar);
}
示例6: attemptAddUser
/**
* @param $user User
* @param $mungedUsername String
* @return bool
*/
public static function attemptAddUser($user, $mungedUsername)
{
/**
* @var $wgAuth LdapAuthenticationPlugin
*/
global $wgAuth;
if (!$wgAuth->autoCreate()) {
$wgAuth->printDebug("Cannot automatically create accounts.", NONSENSITIVE);
return false;
}
$wgAuth->printDebug("User does not exist in local database; creating.", NONSENSITIVE);
// Checks passed, create the user
$user->loadDefaults($mungedUsername);
$status = $user->addToDatabase();
if ($status !== null && !$status->isOK()) {
$wgAuth->printDebug("Creation failed: " . $status->getWikiText(), NONSENSITIVE);
return false;
}
$wgAuth->initUser($user, true);
$user->setCookies();
wfSetupSession();
# Update user count
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
# Notify hooks (e.g. Newuserlog)
wfRunHooks('AuthPluginAutoCreate', array($user));
return true;
}
示例7: setUp
/**
* Fixture -- run before every test
*/
protected function setUp()
{
parent::setUp();
$this->setMwGlobals(array('wgEnableUploads' => true, 'wgEnableAPI' => true));
wfSetupSession();
$this->clearFakeUploads();
}
示例8: newFromToken
/**
* Creates a MediaWiki User object based on the token given in the HTTP request.
*
* @param \WebRequest $request the HTTP request data as an object
*
* @return \User on successful authentication
*/
public static function newFromToken(\WebRequest $request)
{
// Extract access token from HTTP request data.
$token = self::getAccessToken($request);
// Authenticate with the token, if present.
if ($token) {
global $wgHeliosBaseUri, $wgHeliosClientId, $wgHeliosClientSecret;
$heliosClient = new Client($wgHeliosBaseUri, $wgHeliosClientId, $wgHeliosClientSecret);
// start the session if there's none so far
// the code is borrowed from SpecialUserlogin
// @see PLATFORM-1261
if (session_id() == '') {
wfSetupSession();
WikiaLogger::instance()->debug(__METHOD__ . '::startSession');
}
try {
$tokenInfo = $heliosClient->info($token);
if (!empty($tokenInfo->user_id)) {
$user = \User::newFromId($tokenInfo->user_id);
// dont return the user object if it's disabled
// @see SERVICES-459
if ((bool) $user->getGlobalFlag('disabled')) {
self::clearAccessTokenCookie();
return null;
}
// return a MediaWiki's User object
return $user;
}
} catch (ClientException $e) {
WikiaLogger::instance()->error(__METHOD__, ['exception' => $e]);
}
}
return null;
}
示例9: execute
/**
* Executes the log-in attempt using the parameters passed. If
* the log-in succeeeds, it attaches a cookie to the session
* and outputs the user id, username, and session token. If a
* log-in fails, as the result of a bad password, a nonexistant
* user, or any other reason, the host is cached with an expiry
* and no log-in attempts will be accepted until that expiry
* is reached. The expiry is $this->mLoginThrottle.
*
* @access public
*/
public function execute()
{
$name = $password = $domain = null;
extract($this->extractRequestParams());
$result = array();
// Make sure noone is trying to guess the password brut-force
$nextLoginIn = $this->getNextLoginTimeout();
if ($nextLoginIn > 0) {
$result['result'] = 'NeedToWait';
$result['details'] = "Please wait {$nextLoginIn} seconds before next log-in attempt";
$result['wait'] = $nextLoginIn;
$this->getResult()->addValue(null, 'login', $result);
return;
}
$params = new FauxRequest(array('wpName' => $name, 'wpPassword' => $password, 'wpDomain' => $domain, 'wpRemember' => ''));
// Init session if necessary
if (session_id() == '') {
wfSetupSession();
}
$loginForm = new LoginForm($params);
switch ($loginForm->authenticateUserData()) {
case LoginForm::SUCCESS:
global $wgUser, $wgCookiePrefix;
$wgUser->setOption('rememberpassword', 1);
$wgUser->setCookies();
$result['result'] = 'Success';
$result['lguserid'] = $_SESSION['wsUserID'];
$result['lgusername'] = $_SESSION['wsUserName'];
$result['lgtoken'] = $_SESSION['wsToken'];
$result['cookieprefix'] = $wgCookiePrefix;
$result['sessionid'] = session_id();
break;
case LoginForm::NO_NAME:
$result['result'] = 'NoName';
break;
case LoginForm::ILLEGAL:
$result['result'] = 'Illegal';
break;
case LoginForm::WRONG_PLUGIN_PASS:
$result['result'] = 'WrongPluginPass';
break;
case LoginForm::NOT_EXISTS:
$result['result'] = 'NotExists';
break;
case LoginForm::WRONG_PASS:
$result['result'] = 'WrongPass';
break;
case LoginForm::EMPTY_PASS:
$result['result'] = 'EmptyPass';
break;
default:
ApiBase::dieDebug(__METHOD__, 'Unhandled case value');
}
if ($result['result'] != 'Success') {
$result['wait'] = $this->cacheBadLogin();
$result['details'] = "Please wait " . self::THROTTLE_TIME . " seconds before next log-in attempt";
}
// if we were allowed to try to login, memcache is fine
$this->getResult()->addValue(null, 'login', $result);
}
示例10: __construct
function __construct()
{
SpecialPage::__construct('PromoterAds');
// Make sure we have a session
wfSetupSession();
// Load things that may have been serialized into the session
$this->adFilterString = $this->getPRSessionVar('adFilterString', '');
}
示例11: show
public function show()
{
if (session_id() === '') {
// Send a cookie so anons get talk message notifications
wfSetupSession();
}
parent::show();
}
示例12: execute
/**
* Executes the log-in attempt using the parameters passed. If
* the log-in succeeeds, it attaches a cookie to the session
* and outputs the user id, username, and session token. If a
* log-in fails, as the result of a bad password, a nonexistent
* user, or any other reason, the host is cached with an expiry
* and no log-in attempts will be accepted until that expiry
* is reached. The expiry is $this->mLoginThrottle.
*
* @access public
*/
public function execute()
{
$params = $this->extractRequestParams();
$result = array();
$req = new FauxRequest(array('wpName' => $params['name'], 'wpPassword' => $params['password'], 'wpDomain' => $params['domain'], 'wpRemember' => ''));
// Init session if necessary
if (session_id() == '') {
wfSetupSession();
}
$loginForm = new LoginForm($req);
switch ($authRes = $loginForm->authenticateUserData()) {
case LoginForm::SUCCESS:
global $wgUser, $wgCookiePrefix;
$wgUser->setOption('rememberpassword', 1);
$wgUser->setCookies();
// Run hooks. FIXME: split back and frontend from this hook.
// FIXME: This hook should be placed in the backend
$injected_html = '';
wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
$result['result'] = 'Success';
$result['lguserid'] = intval($wgUser->getId());
$result['lgusername'] = $wgUser->getName();
$result['lgtoken'] = $wgUser->getToken();
$result['cookieprefix'] = $wgCookiePrefix;
$result['sessionid'] = session_id();
break;
case LoginForm::NO_NAME:
$result['result'] = 'NoName';
break;
case LoginForm::ILLEGAL:
$result['result'] = 'Illegal';
break;
case LoginForm::WRONG_PLUGIN_PASS:
$result['result'] = 'WrongPluginPass';
break;
case LoginForm::NOT_EXISTS:
$result['result'] = 'NotExists';
break;
case LoginForm::WRONG_PASS:
$result['result'] = 'WrongPass';
break;
case LoginForm::EMPTY_PASS:
$result['result'] = 'EmptyPass';
break;
case LoginForm::CREATE_BLOCKED:
$result['result'] = 'CreateBlocked';
$result['details'] = 'Your IP address is blocked from account creation';
break;
case LoginForm::THROTTLED:
global $wgPasswordAttemptThrottle;
$result['result'] = 'Throttled';
$result['wait'] = intval($wgPasswordAttemptThrottle['seconds']);
break;
default:
ApiBase::dieDebug(__METHOD__, "Unhandled case value: {$authRes}");
}
$this->getResult()->addValue(null, 'login', $result);
}
示例13: wfSpecialUserlogin
/**
* constructor
*/
function wfSpecialUserlogin($par = '')
{
global $wgRequest;
if (session_id() == '') {
wfSetupSession();
}
$form = new LoginForm($wgRequest, $par);
$form->execute();
}
示例14: setUp
/**
* Fixture -- run before every test
*/
public function setUp()
{
global $wgEnableUploads, $wgEnableAPI;
parent::setUp();
$wgEnableUploads = true;
$wgEnableAPI = true;
wfSetupSession();
$this->clearFakeUploads();
}
示例15: wfSpecialUserlogin
/**
* constructor
*/
function wfSpecialUserlogin($par = '')
{
global $wgRequest, $wgHooks;
if (session_id() == '') {
wfSetupSession();
}
$form = new LoginForm($wgRequest, $par);
$form->execute();
$wgHooks['BeforeTabsLine'][] = array('LoginForm::topContent', $form);
}