本文整理汇总了PHP中Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId方法的典型用法代码示例。如果您正苦于以下问题:PHP SettingsPiwik::rewriteTmpPathWithInstanceId方法的具体用法?PHP SettingsPiwik::rewriteTmpPathWithInstanceId怎么用?PHP SettingsPiwik::rewriteTmpPathWithInstanceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\SettingsPiwik
的用法示例。
在下文中一共展示了SettingsPiwik::rewriteTmpPathWithInstanceId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tableInsertBatch
/**
* Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
* as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
*
* @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
* @param array $fields array of unquoted field names
* @param array $values array of data to be inserted
* @param bool $throwException Whether to throw an exception that was caught while trying
* LOAD DATA INFILE, or not.
* @throws Exception
* @return bool True if the bulk LOAD was used, false if we fallback to plain INSERTs
*/
public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
{
$filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
$filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
$loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
try {
$fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
}, 'eol' => "\r\n", 'null' => 'NULL');
// hack for charset mismatch
if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
$fileSpec['charset'] = 'latin1';
}
self::createCSVFile($filePath, $fileSpec, $values);
if (!is_readable($filePath)) {
throw new Exception("File {$filePath} could not be read.");
}
$rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
if ($rc) {
unlink($filePath);
return true;
}
} catch (Exception $e) {
Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
if ($throwException) {
throw $e;
}
}
}
// if all else fails, fallback to a series of INSERTs
@unlink($filePath);
self::tableInsertBatchIterate($tableName, $fields, $values);
return false;
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = sprintf('%s/tmp/logs/', PIWIK_DOCUMENT_ROOT);
$path = SettingsPiwik::rewriteTmpPathWithInstanceId($path);
$cmd = sprintf('tail -f %s*.log', $path);
$output->writeln('Executing command: ' . $cmd);
passthru($cmd);
}
示例3: __construct
/**
* @param string $directory directory to use
* @param int $timeToLiveInSeconds TTL
*/
public function __construct($directory, $timeToLiveInSeconds = 300)
{
$cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/';
$this->cachePath = SettingsPiwik::rewriteTmpPathWithInstanceId($cachePath);
if ($timeToLiveInSeconds < self::MINIMUM_TTL) {
$timeToLiveInSeconds = self::MINIMUM_TTL;
}
$this->ttl = $timeToLiveInSeconds;
}
示例4: __construct
public function __construct()
{
$loader = $this->getDefaultThemeLoader();
$this->addPluginNamespaces($loader);
//get current theme
$manager = Plugin\Manager::getInstance();
$theme = $manager->getThemeEnabled();
$loaders = array();
//create loader for custom theme to overwrite twig templates
if ($theme && $theme->getPluginName() != \Piwik\Plugin\Manager::DEFAULT_THEME) {
$customLoader = $this->getCustomThemeLoader($theme);
if ($customLoader) {
//make it possible to overwrite plugin templates
$this->addCustomPluginNamespaces($customLoader, $theme->getPluginName());
$loaders[] = $customLoader;
}
}
$loaders[] = $loader;
$chainLoader = new Twig_Loader_Chain($loaders);
// Create new Twig Environment and set cache dir
$templatesCompiledPath = PIWIK_USER_PATH . '/tmp/templates_c';
$templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithInstanceId($templatesCompiledPath);
$this->twig = new Twig_Environment($chainLoader, array('debug' => true, 'strict_variables' => true, 'cache' => $templatesCompiledPath));
$this->twig->addExtension(new Twig_Extension_Debug());
$this->twig->clearTemplateCache();
$this->addFilter_translate();
$this->addFilter_urlRewriteWithParameters();
$this->addFilter_sumTime();
$this->addFilter_money();
$this->addFilter_truncate();
$this->addFilter_notification();
$this->addFilter_percentage();
$this->addFilter_prettyDate();
$this->addFilter_safeDecodeRaw();
$this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode'));
$this->twig->addFilter(new Twig_SimpleFilter('ucwords', 'ucwords'));
$this->addFunction_includeAssets();
$this->addFunction_linkTo();
$this->addFunction_sparkline();
$this->addFunction_postEvent();
$this->addFunction_isPluginLoaded();
$this->addFunction_getJavascriptTranslations();
$this->twig->addTokenParser(new RenderTokenParser());
}
示例5: installOrUpdatePluginFromFile
public function installOrUpdatePluginFromFile($pathToZip)
{
$tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
$tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginFolder);
try {
$this->makeSureFoldersAreWritable();
$this->extractPluginFiles($pathToZip, $tmpPluginFolder);
$this->makeSurePluginJsonExists($tmpPluginFolder);
$metadata = $this->getPluginMetadataIfValid($tmpPluginFolder);
$this->makeSureThereAreNoMissingRequirements($metadata);
$this->pluginName = $metadata->name;
$this->fixPluginFolderIfNeeded($tmpPluginFolder);
$this->copyPluginToDestination($tmpPluginFolder);
} catch (\Exception $e) {
$this->removeFileIfExists($pathToZip);
$this->removeFolderIfExists($tmpPluginFolder);
throw $e;
}
$this->removeFileIfExists($pathToZip);
$this->removeFolderIfExists($tmpPluginFolder);
return $metadata;
}
示例6: oneClick_Unpack
private function oneClick_Unpack()
{
$pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION;
$pathExtracted = SettingsPiwik::rewriteTmpPathWithInstanceId($pathExtracted);
$this->pathRootExtractedPiwik = $pathExtracted . 'piwik';
if (file_exists($this->pathRootExtractedPiwik)) {
Filesystem::unlinkRecursive($this->pathRootExtractedPiwik, true);
}
$archive = Unzip::factory('PclZip', $this->pathPiwikZip);
if (0 == ($archive_files = $archive->extract($pathExtracted))) {
throw new Exception(Piwik::translate('CoreUpdater_ExceptionArchiveIncompatible', $archive->errorInfo()));
}
if (0 == count($archive_files)) {
throw new Exception(Piwik::translate('CoreUpdater_ExceptionArchiveEmpty'));
}
unlink($this->pathPiwikZip);
}
示例7: define
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
/**
* Override settings in libs/tcpdf_config.php
*
*/
define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/');
$pathTmpTCPDF = PIWIK_USER_PATH . '/tmp/tcpdf/';
$pathTmpTCPDF = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($pathTmpTCPDF);
define('K_PATH_CACHE', $pathTmpTCPDF);
define('K_PATH_IMAGES', $pathTmpTCPDF);
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
// DOCUMENT_ROOT fix for IIS Webserver
if (!isset($_SERVER['DOCUMENT_ROOT']) or empty($_SERVER['DOCUMENT_ROOT'])) {
if (isset($_SERVER['SCRIPT_FILENAME'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])));
} elseif (isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - strlen($_SERVER['PHP_SELF'])));
} else {
// define here your DOCUMENT_ROOT path if the previous fails
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
}
}
if (!defined('K_PATH_MAIN')) {
示例8: setLogFilePathFromConfig
private function setLogFilePathFromConfig($logConfig)
{
$logPath = $logConfig[self::LOGGER_FILE_PATH_CONFIG_OPTION];
if (!SettingsServer::isWindows() && $logPath[0] != '/') {
$logPath = PIWIK_USER_PATH . DIRECTORY_SEPARATOR . $logPath;
}
$logPath = SettingsPiwik::rewriteTmpPathWithInstanceId($logPath);
if (is_dir($logPath)) {
$logPath .= '/piwik.log';
}
$this->logToFilePath = $logPath;
}
示例9: getOutputPath
/**
* Return $filename with temp directory and delete file
*
* @static
* @param $filename
* @return string path of file in temp directory
*/
protected static function getOutputPath($filename)
{
$outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
$outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
@chmod($outputFilename, 0600);
@unlink($outputFilename);
return $outputFilename;
}
示例10: getTmpPath
public static function getTmpPath()
{
$dir = PIWIK_INCLUDE_PATH . '/tmp/climulti';
return SettingsPiwik::rewriteTmpPathWithInstanceId($dir);
}
示例11: getSessionsDirectory
/**
* Returns the directory session files are stored in.
*
* @return string
*/
public static function getSessionsDirectory()
{
$path = PIWIK_USER_PATH . '/tmp/sessions';
return SettingsPiwik::rewriteTmpPathWithInstanceId($path);
}
示例12: getLogFileLocation
public static function getLogFileLocation()
{
$path = self::getDefaultLogFileLocation();
$path = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($path);
return $path;
}
示例13: getAssetDirectory
/**
* Check if the merged file directory exists and is writable.
*
* @return string The directory location
* @throws Exception if directory is not writable.
*/
public function getAssetDirectory()
{
$mergedFileDirectory = PIWIK_USER_PATH . "/tmp/assets";
$mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithInstanceId($mergedFileDirectory);
if (!is_dir($mergedFileDirectory)) {
Filesystem::mkdir($mergedFileDirectory);
}
if (!is_writable($mergedFileDirectory)) {
throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
}
return $mergedFileDirectory;
}