本文整理汇总了PHP中Piwik::createAnonymousUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::createAnonymousUser方法的具体用法?PHP Piwik::createAnonymousUser怎么用?PHP Piwik::createAnonymousUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::createAnonymousUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tablesCreation
/**
* Installation Step 5: Table Creation
*/
function tablesCreation()
{
$this->checkPreviousStepIsValid( __FUNCTION__ );
$view = new Piwik_Installation_View(
$this->pathView . 'tablesCreation.tpl',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep( __FUNCTION__ );
$this->createDbFromSessionInformation();
if(Piwik_Common::getRequestVar('deleteTables', 0, 'int') == 1)
{
Piwik::dropTables();
$view->existingTablesDeleted = true;
// when the user decides to drop the tables then we dont skip the next steps anymore
// workaround ZF-1743
$tmp = $this->session->skipThisStep;
$tmp['firstWebsiteSetup'] = false;
$tmp['displayJavascriptCode'] = false;
$this->session->skipThisStep = $tmp;
}
$tablesInstalled = Piwik::getTablesInstalled();
$tablesToInstall = Piwik::getTablesNames();
$view->tablesInstalled = '';
if(count($tablesInstalled) > 0)
{
// we have existing tables
$view->tablesInstalled = implode(', ', $tablesInstalled);
$view->someTablesInstalled = true;
$minimumCountPiwikTables = 18;
$baseTablesInstalled = preg_grep('/archive_numeric|archive_blob/', $tablesInstalled, PREG_GREP_INVERT);
Piwik::createAccessObject();
Piwik::setUserIsSuperUser();
if(count($baseTablesInstalled) >= $minimumCountPiwikTables &&
count(Piwik_SitesManager_API::getInstance()->getAllSitesId()) > 0 &&
count(Piwik_UsersManager_API::getInstance()->getUsers()) > 0)
{
$view->showReuseExistingTables = true;
// when the user reuses the same tables we skip the website creation step
// workaround ZF-1743
$tmp = $this->session->skipThisStep;
$tmp['firstWebsiteSetup'] = true;
$tmp['displayJavascriptCode'] = true;
$this->session->skipThisStep = $tmp;
}
}
else
{
Piwik::createTables();
Piwik::createAnonymousUser();
$updater = new Piwik_Updater();
$updater->recordComponentSuccessfullyUpdated('core', Piwik_Version::VERSION);
$view->tablesCreated = true;
$view->showNextStep = true;
}
$this->session->currentStepDone = __FUNCTION__;
echo $view->render();
}
示例2: tablesCreation
function tablesCreation()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
$view = new Piwik_Installation_View($this->pathView . 'tablesCreation.tpl', $this->getInstallationSteps(), __FUNCTION__);
$session = new Zend_Session_Namespace("Installation");
$this->skipThisStep(__FUNCTION__);
$this->createDbFromSessionInformation();
if (Piwik_Common::getRequestVar('deleteTables', 0, 'int') == 1) {
Piwik::dropTables();
$view->existingTablesDeleted = true;
// when the user decides to drop the tables then we dont skip the next steps anymore
$session->skipThisStep['firstWebsiteSetup'] = false;
$session->skipThisStep['displayJavascriptCode'] = false;
}
$tablesInstalled = Piwik::getTablesInstalled();
$tablesToInstall = Piwik::getTablesNames();
$view->tablesInstalled = '';
if (count($tablesInstalled) > 0) {
$view->tablesInstalled = implode(", ", $tablesInstalled);
$view->someTablesInstalled = true;
$minimumCountPiwikTables = 14;
if (count($tablesInstalled) >= $minimumCountPiwikTables) {
$view->showReuseExistingTables = true;
// when the user reuses the same tables we skip the website creation step
$session->skipThisStep['firstWebsiteSetup'] = true;
$session->skipThisStep['displayJavascriptCode'] = true;
}
} else {
Piwik::createTables();
Piwik::createAnonymousUser();
require_once "Updater.php";
$updater = new Piwik_Updater();
$updater->recordComponentSuccessfullyUpdated('core', Piwik_Version::VERSION);
$view->tablesCreated = true;
$view->showNextStep = true;
}
if (isset($session->databaseCreated) && $session->databaseCreated === true) {
$view->databaseName = $session->db_infos['dbname'];
$view->databaseCreated = true;
unset($session->databaseCreated);
}
$session->currentStepDone = __FUNCTION__;
echo $view->render();
}
示例3: test_authenticate
public function test_authenticate()
{
// no login; no token auth
$auth = new Piwik_Login_Auth();
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// empty login; no token auth
$auth->setLogin('');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// non-existent user
$auth->setLogin('nobody');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// anonymous user doesn't exist yet
$auth->setLogin('anonymous');
$auth->setTokenAuth('');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// empty login; anonymous user doesn't exist yet
$auth->setLogin('');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// API authentication; anonymous user doesn't exist yet
$auth->setLogin(null);
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// anonymous user doesn't exist yet
$auth->setLogin('anonymous');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
Piwik::createAnonymousUser();
// missing token_auth
$auth->setLogin('anonymous');
$auth->setTokenAuth('');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// empty login
$auth->setLogin('');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not equal
$auth->setLogin('anonymous');
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// API authentication
$auth->setLogin(null);
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::SUCCESS);
// valid login & token auth
$auth->setLogin('anonymous');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::SUCCESS);
$user = array('login' => 'user', 'password' => "geqgeagae", 'email' => "test@test.com", 'alias' => "alias");
Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
$password = md5($user['password']);
$tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
// empty token auth
$auth->setLogin($user['login']);
$auth->setTokenAuth('');
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not a token auth
$auth->setLogin($user['login']);
$auth->setTokenAuth($user['password']);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not a token auth
$auth->setLogin($user['login']);
$auth->setTokenAuth($password);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// empty login
$auth->setLogin('');
$auth->setTokenAuth($tokenAuth);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not equal
$auth->setLogin(0);
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not equal
$auth->setLogin(0);
$auth->setTokenAuth($tokenAuth);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// not equal
$auth->setLogin($user['login']);
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
$this->assertEqual($rc->getCode(), Piwik_Auth_Result::FAILURE);
// API authentication
//.........这里部分代码省略.........
示例4: testAuthenticateSuccessAnonymous
/**
* @group Plugins
* @group Login
*/
public function testAuthenticateSuccessAnonymous()
{
Piwik::createAnonymousUser();
// valid login & token auth
$auth = new Piwik_Login_Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
$this->assertEquals(Piwik_Auth_Result::SUCCESS, $rc->getCode());
}