本文整理汇总了PHP中Piwik\SettingsServer类的典型用法代码示例。如果您正苦于以下问题:PHP SettingsServer类的具体用法?PHP SettingsServer怎么用?PHP SettingsServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SettingsServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate()
{
$inTrackerRequest = SettingsServer::isTrackerApiRequest();
$inConsole = Common::isPhpCliMode();
$this->checkConfigFileExists($this->settingsProvider->getPathGlobal());
$this->checkConfigFileExists($this->settingsProvider->getPathLocal(), $startInstaller = !$inTrackerRequest && !$inConsole);
}
示例2: makeTrackerInstance
private function makeTrackerInstance()
{
SettingsServer::setIsTrackerApiRequest();
$storage = Factory::make('PluginName');
SettingsServer::setIsNotTrackerApiRequest();
return $storage;
}
示例3: updatePiwik
/**
* Update Piwik codebase by downloading and installing the latest version.
*
* @param bool $https Whether to use HTTPS if supported of not. If false, will use HTTP.
* @return string[] Return an array of messages for the user.
* @throws ArchiveDownloadException
* @throws UpdaterException
* @throws Exception
*/
public function updatePiwik($https = true)
{
if (!$this->isNewVersionAvailable()) {
throw new Exception($this->translator->translate('CoreUpdater_ExceptionAlreadyLatestVersion', Version::VERSION));
}
SettingsServer::setMaxExecutionTime(0);
$newVersion = $this->getLatestVersion();
$url = $this->getArchiveUrl($newVersion, $https);
$messages = array();
try {
$archiveFile = $this->downloadArchive($newVersion, $url);
$messages[] = $this->translator->translate('CoreUpdater_DownloadingUpdateFromX', $url);
$extractedArchiveDirectory = $this->decompressArchive($archiveFile);
$messages[] = $this->translator->translate('CoreUpdater_UnpackingTheUpdate');
$this->verifyDecompressedArchive($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles');
$disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
if (!empty($disabledPluginNames)) {
$messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
}
$this->installNewFiles($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion');
} catch (ArchiveDownloadException $e) {
throw $e;
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
return $messages;
}
示例4: getLongErrorMessage
private function getLongErrorMessage()
{
$message = '<p>';
if (SettingsServer::isWindows()) {
$message .= $this->translator->translate(
'Installation_SystemCheckWinPdoAndMysqliHelp',
array('<br /><br /><code>extension=php_mysqli.dll</code><br /><code>extension=php_pdo.dll</code><br /><code>extension=php_pdo_mysql.dll</code><br />')
);
} else {
$message .= $this->translator->translate(
'Installation_SystemCheckPdoAndMysqliHelp',
array(
'<br /><br /><code>--with-mysqli</code><br /><code>--with-pdo-mysql</code><br /><br />',
'<br /><br /><code>extension=mysqli.so</code><br /><code>extension=pdo.so</code><br /><code>extension=pdo_mysql.so</code><br />'
)
);
}
$message .= $this->translator->translate('Installation_RestartWebServer') . '<br/><br/>';
$message .= $this->translator->translate('Installation_SystemCheckPhpPdoAndMysqli', array(
'<a style="color:red" href="http://php.net/pdo">',
'</a>',
'<a style="color:red" href="http://php.net/mysqli">',
'</a>',
));
$message .= '</p>';
return $message;
}
示例5: createWebConfigFiles
/**
* Generate IIS web.config files to restrict access
*
* Note: for IIS 7 and above
*/
public static function createWebConfigFiles()
{
if (!SettingsServer::isIIS()) {
return;
}
@file_put_contents(PIWIK_INCLUDE_PATH . '/web.config', '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="config" />
<add segment="core" />
<add segment="lang" />
<add segment="tmp" />
</hiddenSegments>
<fileExtensions>
<add fileExtension=".tpl" allowed="false" />
<add fileExtension=".twig" allowed="false" />
<add fileExtension=".php4" allowed="false" />
<add fileExtension=".php5" allowed="false" />
<add fileExtension=".inc" allowed="false" />
<add fileExtension=".in" allowed="false" />
<add fileExtension=".csv" allowed="false" />
<add fileExtension=".pdf" allowed="false" />
<add fileExtension=".log" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>');
// deny direct access to .php files
$directoriesToProtect = array('/libs', '/vendor', '/plugins');
foreach ($directoriesToProtect as $directoryToProtect) {
@file_put_contents(PIWIK_INCLUDE_PATH . $directoryToProtect . '/web.config', '<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence=".php" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>');
}
}
示例6: execute
public function execute()
{
$label = $this->translator->translate('Installation_SystemCheckGDFreeType');
if (SettingsServer::isGdExtensionEnabled()) {
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
}
$comment = sprintf('%s<br />%s', $this->translator->translate('Installation_SystemCheckGDFreeType'), $this->translator->translate('Installation_SystemCheckGDHelp'));
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
}
示例7: make
public static function make($pluginName)
{
if (SettingsServer::isTrackerApiRequest()) {
$storage = new SettingsStorage($pluginName);
} else {
$storage = new Storage($pluginName);
}
return $storage;
}
示例8: execute
public function execute()
{
$label = $this->translator->translate('SitesManager_Timezone');
if (SettingsServer::isTimezoneSupportEnabled()) {
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
}
$comment = sprintf('%s<br />%s.', $this->translator->translate('SitesManager_AdvancedTimezoneSupportNotFound'), '<a href="http://php.net/manual/en/datetime.installation.php" rel="noreferrer" target="_blank">Timezone PHP documentation</a>');
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
}
示例9: createHtAccess
/**
* Create .htaccess file in specified directory
*
* Apache-specific; for IIS @see web.config
*
* @param string $path without trailing slash
* @param bool $overwrite whether to overwrite an existing file or not
* @param string $content
*/
public static function createHtAccess($path, $overwrite = true, $content = "<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>\n")
{
if (SettingsServer::isApache()) {
$file = $path . '/.htaccess';
if ($overwrite || !file_exists($file)) {
@file_put_contents($file, $content);
}
}
}
示例10: get
/**
* Returns the database connection and creates it if it hasn't been already.
*
* @return \Piwik\Tracker\Db|\Piwik\Db\AdapterInterface|\Piwik\Db
*/
public static function get()
{
if (SettingsServer::isTrackerApiRequest()) {
return Tracker::getDatabase();
}
if (!self::hasDatabaseObject()) {
self::createDatabaseObject();
}
return self::$connection;
}
示例11: getPythonBinary
/**
* @return string
*/
protected static function getPythonBinary()
{
if (\Piwik\SettingsServer::isWindows()) {
return "C:\\Python27\\python.exe";
}
if (IntegrationTestCase::isTravisCI()) {
return 'python2.6';
}
return 'python';
}
示例12: execute
public function execute()
{
$label = $this->translator->translate('Installation_SystemCheckMemoryLimit');
SettingsServer::raiseMemoryLimitIfNecessary();
$memoryLimit = SettingsServer::getMemoryLimitValue();
$comment = $memoryLimit . 'M';
if ($memoryLimit >= $this->minimumMemoryLimit) {
$status = DiagnosticResult::STATUS_OK;
} else {
$status = DiagnosticResult::STATUS_WARNING;
$comment .= sprintf('<br />%s<br />%s', $this->translator->translate('Installation_SystemCheckMemoryLimitHelp'), $this->translator->translate('Installation_RestartWebServer'));
}
return array(DiagnosticResult::singleResult($label, $status, $comment));
}
示例13: execute
public function execute()
{
$label = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsWritable');
$file = new File(PIWIK_DOCUMENT_ROOT . '/piwik.js');
if ($file->hasWriteAccess()) {
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, ''));
}
$comment = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsNotWritable');
if (!SettingsServer::isWindows()) {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/piwik.js');
$command = "<br/><code> chmod +w {$realpath}<br/> chown " . Filechecks::getUserAndGroup() . " " . $realpath . "</code><br />";
$comment .= $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsMakeWritable', $command);
}
return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
}
示例14: getSelectQueryString
public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
{
$result = parent::getSelectQueryString($segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit);
$prefixParts = array();
if (SettingsServer::isArchivePhpTriggered()) {
$prefixParts[] = 'trigger = CronArchive';
}
$idSegments = $this->getSegmentIdOfExpression($segmentExpression);
if (!empty($idSegments)) {
$prefixParts[] = "idSegments = [" . implode(', ', $idSegments) . "]";
}
if (!empty($prefixParts)) {
$result['sql'] = "/* " . implode(', ', $prefixParts) . " */\n" . $result['sql'];
}
return $result;
}
示例15: index
/**
* Main view showing listing of websites and settings
*/
public function index()
{
$view = new View('@SitesManager/index');
Site::clearCache();
if (Piwik::isUserIsSuperUser()) {
$sitesRaw = API::getInstance()->getAllSites();
} else {
$sitesRaw = API::getInstance()->getSitesWithAdminAccess();
}
// Gets sites after Site.setSite hook was called
$sites = array_values(Site::getSites());
if (count($sites) != count($sitesRaw)) {
throw new Exception("One or more website are missing or invalid.");
}
foreach ($sites as &$site) {
$site['alias_urls'] = API::getInstance()->getSiteUrlsFromId($site['idsite']);
$site['excluded_ips'] = explode(',', $site['excluded_ips']);
$site['excluded_parameters'] = explode(',', $site['excluded_parameters']);
$site['excluded_user_agents'] = explode(',', $site['excluded_user_agents']);
}
$view->adminSites = $sites;
$view->adminSitesCount = count($sites);
$timezones = API::getInstance()->getTimezonesList();
$view->timezoneSupported = SettingsServer::isTimezoneSupportEnabled();
$view->timezones = Common::json_encode($timezones);
$view->defaultTimezone = API::getInstance()->getDefaultTimezone();
$view->currencies = Common::json_encode(API::getInstance()->getCurrencyList());
$view->defaultCurrency = API::getInstance()->getDefaultCurrency();
$view->utcTime = Date::now()->getDatetime();
$excludedIpsGlobal = API::getInstance()->getExcludedIpsGlobal();
$view->globalExcludedIps = str_replace(',', "\n", $excludedIpsGlobal);
$excludedQueryParametersGlobal = API::getInstance()->getExcludedQueryParametersGlobal();
$view->globalExcludedQueryParameters = str_replace(',', "\n", $excludedQueryParametersGlobal);
$globalExcludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
$view->globalExcludedUserAgents = str_replace(',', "\n", $globalExcludedUserAgents);
$view->globalSearchKeywordParameters = API::getInstance()->getSearchKeywordParametersGlobal();
$view->globalSearchCategoryParameters = API::getInstance()->getSearchCategoryParametersGlobal();
$view->isSearchCategoryTrackingEnabled = \Piwik\Plugin\Manager::getInstance()->isPluginActivated('CustomVariables');
$view->allowSiteSpecificUserAgentExclude = API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
$view->globalKeepURLFragments = API::getInstance()->getKeepURLFragmentsGlobal();
$view->currentIpAddress = IP::getIpFromHeader();
$view->showAddSite = (bool) Common::getRequestVar('showaddsite', false);
$this->setBasicVariablesView($view);
return $view->render();
}