当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik_Common::getRandomString方法代码示例

本文整理汇总了PHP中Piwik_Common::getRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::getRandomString方法的具体用法?PHP Piwik_Common::getRandomString怎么用?PHP Piwik_Common::getRandomString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik_Common的用法示例。


在下文中一共展示了Piwik_Common::getRandomString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: define

<?php
// Script that creates 100 websites, then outputs a IMG that records a pageview in each website
// Used initially to test how to handle cookies for this use case (see http://dev.piwik.org/trac/ticket/409)
exit;

define('PIWIK_INCLUDE_PATH', '..');
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php";

Piwik_FrontController::getInstance()->init();
Piwik::setUserIsSuperUser();
$count = 100;
for($i = 0; $i <= $count; $i++)
{
	$id = Piwik_SitesManager_API::getInstance()->addSite(Piwik_Common::getRandomString(), 'http://piwik.org');
    $t = new PiwikTracker($id, 'http://localhost/trunk/piwik.php');
    echo $id . " <img width=100 height=10 border=1 src='".$t->getUrlTrackPageView('title') ."'><br/>";
}

开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:22,代码来源:test_cookies_GenerateHundredsWebsitesAndVisits.php

示例2: lostPasswordFormValidated

 protected function lostPasswordFormValidated($loginMail, $urlToRedirect)
 {
     Piwik::setUserIsSuperUser();
     $user = null;
     $isSuperUser = false;
     if ($loginMail == Zend_Registry::get('config')->superuser->email || $loginMail == Zend_Registry::get('config')->superuser->login) {
         $isSuperUser = true;
         $user = array('login' => Zend_Registry::get('config')->superuser->login, 'email' => Zend_Registry::get('config')->superuser->email);
     } else {
         if (Piwik_UsersManager_API::userExists($loginMail)) {
             $user = Piwik_UsersManager_API::getUser($loginMail);
         } else {
             if (Piwik_UsersManager_API::userEmailExists($loginMail)) {
                 $user = Piwik_UsersManager_API::getUserByEmail($loginMail);
             }
         }
     }
     if ($user === null) {
         $messageNoAccess = Piwik_Translate('Login_InvalidUsernameEmail');
     } else {
         $view = new Piwik_View('Login/templates/passwordsent.tpl');
         $login = $user['login'];
         $email = $user['email'];
         $randomPassword = Piwik_Common::getRandomString(8);
         if ($isSuperUser) {
             $user['password'] = md5($randomPassword);
             Zend_Registry::get('config')->superuser = $user;
         } else {
             Piwik_UsersManager_API::updateUser($login, $randomPassword);
         }
         // send email with new password
         try {
             $mail = new Piwik_Mail();
             $mail->addTo($email, $login);
             $mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery'));
             $mail->setBodyText(str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $randomPassword, Piwik_Url::getCurrentUrlWithoutQueryString())));
             $piwikHost = $_SERVER['HTTP_HOST'];
             if (strlen($piwikHost) == 0) {
                 $piwikHost = 'piwik.org';
             }
             $fromEmailName = Zend_Registry::get('config')->General->login_password_recovery_email_name;
             $fromEmailAddress = Zend_Registry::get('config')->General->login_password_recovery_email_address;
             $fromEmailAddress = str_replace('{DOMAIN}', $piwikHost, $fromEmailAddress);
             $mail->setFrom($fromEmailAddress, $fromEmailName);
             @$mail->send();
         } catch (Exception $e) {
             $view->ErrorString = $e->getMessage();
         }
         $view->linkTitle = Piwik::getRandomTitle();
         $view->urlToRedirect = $urlToRedirect;
         echo $view->render();
     }
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:53,代码来源:Controller.php


注:本文中的Piwik_Common::getRandomString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。