本文整理汇总了PHP中Piwik\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function __construct($processor)
{
parent::__construct($processor);
$this->columnToSortByBeforeTruncation = Metrics::INDEX_NB_VISITS;
$this->maximumRowsInDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_events'];
$this->maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_events'];
}
示例2: update
public static function update()
{
$salt = Common::generateUniqId();
$config = Config::getInstance();
$superuser = $config->superuser;
if (!isset($superuser['salt'])) {
try {
if (is_writable(Config::getLocalConfigPath())) {
$superuser['salt'] = $salt;
$config->superuser = $superuser;
$config->forceSave();
} else {
throw new \Exception('mandatory update failed');
}
} catch (\Exception $e) {
throw new \Piwik\UpdaterErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = {$salt}</code>");
}
}
$plugins = $config->Plugins;
if (!in_array('MultiSites', $plugins)) {
try {
if (is_writable(Config::getLocalConfigPath())) {
$plugins[] = 'MultiSites';
$config->Plugins = $plugins;
$config->forceSave();
} else {
throw new \Exception('optional update failed');
}
} catch (\Exception $e) {
throw new \Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!");
}
}
Updater::updateDatabase(__FILE__, self::getSql());
}
示例3: sendNotificationToAdmin
public static function sendNotificationToAdmin($args)
{
list($idsite, $idvisitor, $message) = $args;
$visitorInfo = ChatPersonnalInformation::get($idvisitor);
$subject = "New message on " . ChatSite::getSiteName($idsite);
$mail = new Mail();
$mail->setFrom(Config::getInstance()->General['noreply_email_address'], "Piwik Chat");
$mail->setSubject($subject);
$mail->setBodyHtml("Name : " . $visitorInfo['name'] . "<br />\n Email : " . $visitorInfo['email'] . "<br />\n Phone : " . $visitorInfo['phone'] . "<br />\n Comments : " . $visitorInfo['comments'] . "<br />\n <br /><br />\n Message:<br />{$message}");
foreach (ChatCommon::getUsersBySite($idsite) as $user) {
if (empty($user['email'])) {
continue;
}
if (ChatPiwikUser::isStaffOnline($user['login'])) {
continue;
}
$mail->addTo($user['email']);
try {
$mail->send();
} catch (Exception $e) {
throw new Exception("An error occured while sending '{$subject}' " . " to " . implode(', ', $mail->getRecipients()) . ". Error was '" . $e->getMessage() . "'");
}
$mail->clearRecipients();
}
}
示例4: setUp
public function setUp()
{
parent::setUp();
Config::getInstance()->setTestEnvironment();
Config::getInstance()->Plugins['Plugins'] = array();
$this->unloadAllPlugins();
}
示例5: execute
public function execute()
{
$isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
if ($isPiwikInstalling) {
// Skip the diagnostic if Piwik is being installed
return array();
}
$label = $this->translator->translate('Installation_DatabaseAbilities');
$optionTable = Common::prefixTable('option');
$testOptionNames = array('test_system_check1', 'test_system_check2');
$loadDataInfile = false;
$errorMessage = null;
try {
$loadDataInfile = Db\BatchInsert::tableInsertBatch($optionTable, array('option_name', 'option_value'), array(array($testOptionNames[0], '1'), array($testOptionNames[1], '2')), $throwException = true);
} catch (\Exception $ex) {
$errorMessage = str_replace("\n", "<br/>", $ex->getMessage());
}
// delete the temporary rows that were created
Db::exec("DELETE FROM `{$optionTable}` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')");
if ($loadDataInfile) {
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, 'LOAD DATA INFILE'));
}
$comment = sprintf('LOAD DATA INFILE<br/>%s<br/>%s', $this->translator->translate('Installation_LoadDataInfileUnavailableHelp', array('LOAD DATA INFILE', 'FILE')), $this->translator->translate('Installation_LoadDataInfileRecommended'));
if ($errorMessage) {
$comment .= sprintf('<br/><strong>%s:</strong> %s<br/>%s', $this->translator->translate('General_Error'), $errorMessage, 'Troubleshooting: <a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org/faq/troubleshooting/%23faq_194">FAQ on piwik.org</a>');
}
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
}
示例6: check
/**
* Check for a newer version
*
* @param bool $force Force check
* @param int $interval Interval used for update checks
*/
public static function check($force = false, $interval = null)
{
if (!self::isAutoUpdateEnabled()) {
return;
}
if ($interval === null) {
$interval = self::CHECK_INTERVAL;
}
$lastTimeChecked = Option::get(self::LAST_TIME_CHECKED);
if ($force || $lastTimeChecked === false || time() - $interval > $lastTimeChecked) {
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
$parameters = array('piwik_version' => Version::VERSION, 'php_version' => PHP_VERSION, 'url' => Url::getCurrentUrlWithoutQueryString(), 'trigger' => Common::getRequestVar('module', '', 'string'), 'timezone' => API::getInstance()->getDefaultTimezone());
$url = Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
$url = 'http://builds.piwik.org/LATEST_BETA';
}
try {
$latestVersion = Http::sendHttpRequest($url, $timeout);
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
$latestVersion = '';
}
} catch (Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
$latestVersion = '';
}
Option::set(self::LATEST_VERSION, $latestVersion);
}
}
示例7: getValueFromConfig
private function getValueFromConfig()
{
$config = Config::getInstance()->{$this->pluginName};
if (!empty($config) && array_key_exists($this->name, $config)) {
return $config[$this->name];
}
}
示例8: makeUpdate
protected function makeUpdate(InputInterface $input, OutputInterface $output, $doDryRun)
{
$this->checkAllRequiredOptionsAreNotEmpty($input);
$updater = $this->makeUpdaterInstance($output);
$componentsWithUpdateFile = $updater->getComponentUpdates();
if (empty($componentsWithUpdateFile)) {
throw new NoUpdatesFoundException("Everything is already up to date.");
}
$output->writeln(array("", " *** " . Piwik::translate('CoreUpdater_UpdateTitle') . " ***"));
// handle case of existing database with no tables
if (!DbHelper::isInstalled()) {
$this->handleCoreError($output, Piwik::translate('CoreUpdater_EmptyDatabaseError', Config::getInstance()->database['dbname']));
return;
}
$output->writeln(array("", " " . Piwik::translate('CoreUpdater_DatabaseUpgradeRequired'), "", " " . Piwik::translate('CoreUpdater_YourDatabaseIsOutOfDate')));
if ($this->isUpdatingCore($componentsWithUpdateFile)) {
$currentVersion = $this->getCurrentVersionForCore($updater);
$output->writeln(array("", " " . Piwik::translate('CoreUpdater_PiwikWillBeUpgradedFromVersionXToVersionY', array($currentVersion, Version::VERSION))));
}
$pluginsToUpdate = $this->getPluginsToUpdate($componentsWithUpdateFile);
if (!empty($pluginsToUpdate)) {
$output->writeln(array("", " " . Piwik::translate('CoreUpdater_TheFollowingPluginsWillBeUpgradedX', implode(', ', $pluginsToUpdate))));
}
$dimensionsToUpdate = $this->getDimensionsToUpdate($componentsWithUpdateFile);
if (!empty($dimensionsToUpdate)) {
$output->writeln(array("", " " . Piwik::translate('CoreUpdater_TheFollowingDimensionsWillBeUpgradedX', implode(', ', $dimensionsToUpdate))));
}
$output->writeln("");
if ($doDryRun) {
$this->doDryRun($updater, $output);
} else {
$this->doRealUpdate($updater, $componentsWithUpdateFile, $output);
}
}
示例9: getActionCategoryDelimiter
private function getActionCategoryDelimiter()
{
if (isset(Config::getInstance()->General['action_category_delimiter'])) {
return Config::getInstance()->General['action_category_delimiter'];
}
return Config::getInstance()->General['action_url_category_delimiter'];
}
示例10: initAuthenticationFromCookie
/**
* @param $auth
*/
public static function initAuthenticationFromCookie(\Piwik\Auth $auth, $activateCookieAuth)
{
if (self::isModuleIsAPI() && !$activateCookieAuth) {
return;
}
$authCookieName = Config::getInstance()->General['login_cookie_name'];
$authCookieExpiry = 0;
$authCookiePath = Config::getInstance()->General['login_cookie_path'];
$authCookie = new Cookie($authCookieName, $authCookieExpiry, $authCookiePath);
$defaultLogin = 'anonymous';
$defaultTokenAuth = 'anonymous';
if ($authCookie->isCookieFound()) {
$defaultLogin = $authCookie->get('login');
$defaultTokenAuth = $authCookie->get('token_auth');
}
$auth->setLogin($defaultLogin);
$auth->setTokenAuth($defaultTokenAuth);
$storage = new Storage($defaultLogin);
if (!$storage->isActive()) {
return;
}
$secret = $storage->getSecret();
$cookieSecret = $authCookie->get('auth_code');
if ($cookieSecret == SessionInitializer::getHashTokenAuth($defaultLogin, $secret)) {
$googleAuth = new PHPGangsta\GoogleAuthenticator();
$auth->setAuthCode($googleAuth->getCode($secret));
$auth->validateAuthCode();
}
}
示例11: create
/**
* @link http://php-di.org/doc/container-configuration.html
* @throws \Exception
* @return Container
*/
public function create()
{
$builder = new ContainerBuilder();
$builder->useAnnotations(false);
$builder->setDefinitionCache(new ArrayCache());
// INI config
$builder->addDefinitions(new IniConfigDefinitionSource(Config::getInstance()));
// Global config
$builder->addDefinitions(PIWIK_USER_PATH . '/config/global.php');
// Plugin configs
$this->addPluginConfigs($builder);
// Development config
if (Development::isEnabled()) {
$builder->addDefinitions(PIWIK_USER_PATH . '/config/environment/dev.php');
}
// User config
if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
$builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
}
// Environment config
$this->addEnvironmentConfig($builder);
if (!empty($this->definitions)) {
$builder->addDefinitions($this->definitions);
}
return $builder->build();
}
示例12: getNonProxyIpFromHeader
/**
* Returns a non-proxy IP address from header.
*
* @param string $default Default value to return if there no matching proxy header.
* @param array $proxyHeaders List of proxy headers.
* @return string
*/
public static function getNonProxyIpFromHeader($default, $proxyHeaders)
{
$proxyIps = array();
$config = Config::getInstance()->General;
if (isset($config['proxy_ips'])) {
$proxyIps = $config['proxy_ips'];
}
if (!is_array($proxyIps)) {
$proxyIps = array();
}
$proxyIps[] = $default;
// examine proxy headers
foreach ($proxyHeaders as $proxyHeader) {
if (!empty($_SERVER[$proxyHeader])) {
// this may be buggy if someone has proxy IPs and proxy host headers configured as
// `$_SERVER[$proxyHeader]` could be eg $_SERVER['HTTP_X_FORWARDED_HOST'] and
// include an actual host name, not an IP
$proxyIp = self::getLastIpFromList($_SERVER[$proxyHeader], $proxyIps);
if (strlen($proxyIp) && stripos($proxyIp, 'unknown') === false) {
return $proxyIp;
}
}
}
return $default;
}
示例13: init
function init()
{
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
$config->log['log_writers'] = array('screen');
$config->log['log_level'] = 'VERBOSE';
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->recreateContainerWithWebEnvironment();
$this->initHostAndQueryString($input);
if ($this->isTestModeEnabled()) {
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php';
Config::unsetInstance();
StaticContainer::clearContainer();
\Piwik_TestingEnvironment::addHooks();
$indexFile = '/tests/PHPUnit/proxy/';
$this->resetDatabase();
} else {
$indexFile = '/';
}
$indexFile .= 'index.php';
if (!empty($_GET['pid'])) {
$process = new Process($_GET['pid']);
if ($process->hasFinished()) {
return;
}
$process->startProcess();
}
require_once PIWIK_INCLUDE_PATH . $indexFile;
if (!empty($process)) {
$process->finishProcess();
}
}
示例15: test_getActiveReleaseChannel_shouldReturnCorrectReleaseChannelForId
/**
* @dataProvider getTestActiveReleaseChannel
*/
public function test_getActiveReleaseChannel_shouldReturnCorrectReleaseChannelForId($expectedId, $activeId)
{
$backupId = Config::getInstance()->General['release_channel'];
$this->channels->setActiveReleaseChannelId($activeId);
$this->assertSame($expectedId, $this->channels->getActiveReleaseChannel()->getId());
$this->channels->setActiveReleaseChannelId($backupId);
}