private static function deleteIfLastModifiedBefore14August2014($path) { $modifiedTime = filemtime($path); if ($modifiedTime && $modifiedTime < 1408000000) { Filesystem::deleteFileIfExists($path); } }
public function removeGoneFiles($source, $target) { Filesystem::unlinkTargetFilesNotPresentInSource($source . '/core', $target . '/core'); foreach ($this->getPluginsFromDirectoy($source) as $pluginDir) { Filesystem::unlinkTargetFilesNotPresentInSource($source . $pluginDir, $target . $pluginDir); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return array * @throws \RunTimeException */ protected function getPluginName(InputInterface $input, OutputInterface $output) { $self = $this; $validate = function ($pluginName) use($self) { if (empty($pluginName)) { throw new \RunTimeException('You have to enter a plugin name'); } if (!Filesystem::isValidFilename($pluginName)) { throw new \RunTimeException(sprintf('The plugin name %s is not valid', $pluginName)); } $pluginPath = $self->getPluginPath($pluginName); if (file_exists($pluginPath)) { throw new \RunTimeException('A plugin with this name already exists'); } return $pluginName; }; $pluginName = $input->getOption('name'); if (empty($pluginName)) { $dialog = $this->getHelperSet()->get('dialog'); $pluginName = $dialog->askAndValidate($output, 'Enter a plugin name: ', $validate); } else { $validate($pluginName); } $pluginName = ucfirst($pluginName); return $pluginName; }
public function dispatch() { $module = Common::getRequestVar('module', '', 'string'); $action = Common::getRequestVar('action', '', 'string'); if ($module == 'CoreUpdater' || $module == 'Proxy' || $module == 'Installation' || $module == 'LanguagesManager' && $action == 'saveLanguage') { return; } $updater = new PiwikCoreUpdater(); $updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION)); if (!empty($updates)) { Filesystem::deleteAllCacheOnUpdate(); } if ($updater->getComponentUpdates() !== null) { if (FrontController::shouldRethrowException()) { throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" . "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n"); } elseif ($module === 'API') { $outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $_GET + $_POST)); $response = new ResponseBuilder($outputFormat); $e = new Exception('Database Upgrade Required. Your Piwik database is out-of-date, and must be upgraded before you can continue.'); echo $response->getResponseException($e); Common::sendResponseCode(503); exit; } else { Piwik::redirectToModule('CoreUpdater'); } } }
protected function execute(InputInterface $input, OutputInterface $output) { $piwikLanguages = \Piwik\Plugins\LanguagesManager\API::getInstance()->getAvailableLanguages(); $aliasesUrl = 'https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/aliases.json'; $aliasesData = Http::fetchRemoteFile($aliasesUrl); $aliasesData = json_decode($aliasesData, true); $aliasesData = $aliasesData['supplemental']['metadata']['alias']['languageAlias']; $writePath = Filesystem::getPathToPiwikRoot() . '/plugins/Intl/lang/%s.json'; foreach ($piwikLanguages as $langCode) { if ($langCode == 'dev') { continue; } $requestLangCode = $transformedLangCode = $this->transformLangCode($langCode); if (array_key_exists($requestLangCode, $aliasesData)) { $requestLangCode = $aliasesData[$requestLangCode]['_replacement']; } // fix some locales $localFixes = array('pt' => 'pt-PT', 'pt-br' => 'pt', 'zh-cn' => 'zh-Hans', 'zh-tw' => 'zh-Hant'); if (array_key_exists($langCode, $localFixes)) { $requestLangCode = $localFixes[$langCode]; } setlocale(LC_ALL, $langCode); $translations = array(); $this->fetchLanguageData($output, $transformedLangCode, $requestLangCode, $translations); $this->fetchTerritoryData($output, $transformedLangCode, $requestLangCode, $translations); $this->fetchCalendarData($output, $transformedLangCode, $requestLangCode, $translations); $this->fetchLayoutDirection($output, $transformedLangCode, $requestLangCode, $translations); $this->fetchUnitData($output, $transformedLangCode, $requestLangCode, $translations); $this->fetchNumberFormattingData($output, $transformedLangCode, $requestLangCode, $translations); ksort($translations['Intl']); file_put_contents(sprintf($writePath, $langCode), json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } }
protected function execute(InputInterface $input, OutputInterface $output) { $commandName = $input->getFirstArgument(); $enable = false !== strpos($commandName, 'enable'); $full = $input->getOption('full'); $config = Config::getInstance(); $development = $config->Development; if ($enable) { $development['enabled'] = 1; if ($full) { $development['disable_merged_assets'] = 1; } $message = 'Development mode enabled'; } else { $development['enabled'] = 0; if ($full) { $development['disable_merged_assets'] = 0; } $message = 'Development mode disabled'; } $config->Development = $development; $config->forceSave(); Filesystem::deleteAllCacheOnUpdate(); $this->writeSuccessMessage($output, array($message)); }
static function update() { $errors = array(); try { $checker = new DoNotTrackHeaderChecker(); // enable DoNotTrack check in PrivacyManager if DoNotTrack plugin was enabled if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('DoNotTrack')) { $checker->activate(); } // enable IP anonymization if AnonymizeIP plugin was enabled if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('AnonymizeIP')) { IPAnonymizer::activate(); } } catch (\Exception $ex) { // pass } // disable & delete old plugins $oldPlugins = array('DoNotTrack', 'AnonymizeIP'); foreach ($oldPlugins as $plugin) { try { \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin); } catch (\Exception $e) { } $dir = PIWIK_INCLUDE_PATH . "/plugins/{$plugin}"; if (file_exists($dir)) { Filesystem::unlinkRecursive($dir, true); } if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): {$dir} \n"; } } if (!empty($errors)) { throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors)); } }
static function update() { Updater::updateDatabase(__FILE__, self::getSql()); $obsoleteDirectories = array('/plugins/AdminHome', '/plugins/Home', '/plugins/PluginsAdmin'); foreach ($obsoleteDirectories as $dir) { if (file_exists(PIWIK_INCLUDE_PATH . $dir)) { Filesystem::unlinkRecursive(PIWIK_INCLUDE_PATH . $dir, true); } } }
public function doUpdate(Updater $updater) { $updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater)); $obsoleteDirectories = array('/plugins/AdminHome', '/plugins/Home', '/plugins/PluginsAdmin'); foreach ($obsoleteDirectories as $dir) { if (file_exists(PIWIK_INCLUDE_PATH . $dir)) { Filesystem::unlinkRecursive(PIWIK_INCLUDE_PATH . $dir, true); } } }
private static function loadCoreTranslationFile($language) { $path = PIWIK_INCLUDE_PATH . '/lang/' . $language . '.json'; if (!Filesystem::isValidFilename($language) || !is_readable($path)) { throw new Exception(Piwik::translate('General_ExceptionLanguageFileNotFound', array($language))); } $data = file_get_contents($path); $translations = json_decode($data, true); self::mergeTranslationArray($translations); self::setLocale(); self::$loadedLanguage = $language; }
public function delete() { if ($this->exists()) { try { Filesystem::remove($this->getAbsoluteLocation()); } catch (Exception $e) { throw new Exception("Unable to delete merged file : " . $this->getAbsoluteLocation() . ". Please delete the file and refresh"); } // try to remove compressed version of the merged file. Filesystem::remove($this->getAbsoluteLocation() . ".deflate", true); Filesystem::remove($this->getAbsoluteLocation() . ".gz", true); } }
/** * Sends an HTTP request using best available transport method. * * @param string $aUrl The target URL. * @param int $timeout The number of seconds to wait before aborting the HTTP request. * @param string|null $userAgent The user agent to use. * @param string|null $destinationPath If supplied, the HTTP response will be saved to the file specified by * this path. * @param int|null $followDepth Internal redirect count. Should always pass `null` for this parameter. * @param bool $acceptLanguage The value to use for the `'Accept-Language'` HTTP request header. * @param array|bool $byteRange For `Range:` header. Should be two element array of bytes, eg, `array(0, 1024)` * Doesn't work w/ `fopen` transport method. * @param bool $getExtendedInfo If true returns the status code, headers & response, if false just the response. * @param string $httpMethod The HTTP method to use. Defaults to `'GET'`. * @throws Exception if the response cannot be saved to `$destinationPath`, if the HTTP response cannot be sent, * if there are more than 5 redirects or if the request times out. * @return bool|string If `$destinationPath` is not specified the HTTP response is returned on success. `false` * is returned on failure. * If `$getExtendedInfo` is `true` and `$destinationPath` is not specified an array with * the following information is returned on success: * * - **status**: the HTTP status code * - **headers**: the HTTP headers * - **data**: the HTTP response data * * `false` is still returned on failure. * @api */ public static function sendHttpRequest($aUrl, $timeout, $userAgent = null, $destinationPath = null, $followDepth = 0, $acceptLanguage = false, $byteRange = false, $getExtendedInfo = false, $httpMethod = 'GET') { // create output file $file = null; if ($destinationPath) { // Ensure destination directory exists Filesystem::mkdir(dirname($destinationPath)); if (($file = @fopen($destinationPath, 'wb')) === false || !is_resource($file)) { throw new Exception('Error while creating the file: ' . $destinationPath); } } $acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : ''; return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod); }
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)); }
public function execute() { $label = $this->translator->translate('Installation_Filesystem'); if (!Filesystem::checkIfFileSystemIsNFS()) { return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK)); } $isPiwikInstalling = !Config::getInstance()->existsLocalConfig(); if ($isPiwikInstalling) { $help = 'Installation_NfsFilesystemWarningSuffixInstall'; } else { $help = 'Installation_NfsFilesystemWarningSuffixAdmin'; } $comment = sprintf('%s<br />%s', $this->translator->translate('Installation_NfsFilesystemWarning'), $this->translator->translate($help)); return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment)); }
public function dispatch() { $module = Common::getRequestVar('module', '', 'string'); $action = Common::getRequestVar('action', '', 'string'); $updater = new PiwikCoreUpdater(); $updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION)); if (!empty($updates)) { Filesystem::deleteAllCacheOnUpdate(); } if ($updater->getComponentUpdates() !== null && $module != 'CoreUpdater' && $module != 'Proxy' && $module != 'Installation' && !($module == 'LanguagesManager' && $action == 'saveLanguage')) { if (FrontController::shouldRethrowException()) { throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" . "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n"); } else { Piwik::redirectToModule('CoreUpdater'); } } }
public function doUpdate(Updater $updater) { $errors = array(); // Deleting old libs $obsoleteDirectories = array(PIWIK_INCLUDE_PATH . '/libs/Smarty', PIWIK_INCLUDE_PATH . '/libs/Event'); foreach ($obsoleteDirectories as $dir) { if (file_exists($dir)) { Filesystem::unlinkRecursive($dir, true); } if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): {$dir} \n"; } } if (!empty($errors)) { throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors)); } }
public static function update() { $errors = array(); // Deleting old plugins $obsoleteDirectories = array(PIWIK_INCLUDE_PATH . '/plugins/Referers', PIWIK_INCLUDE_PATH . '/plugins/PDFReports'); foreach ($obsoleteDirectories as $dir) { if (file_exists($dir)) { Filesystem::unlinkRecursive($dir, true); } if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): {$dir} \n"; } } if (!empty($errors)) { throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors)); } }
protected function getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo) { $pathToPiwikRoot = Filesystem::getPathToPiwikRoot(); $logo = $defaultLogo; $themeName = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled()->getPluginName(); $themeLogo = sprintf($themeLogo, $themeName); if (file_exists($pathToPiwikRoot . '/' . $themeLogo)) { $logo = $themeLogo; } if ($this->isEnabled() && file_exists($pathToPiwikRoot . '/' . $customLogo)) { $logo = $customLogo; } if (!$pathOnly) { return SettingsPiwik::getPiwikUrl() . $logo; } return $pathToPiwikRoot . '/' . $logo; }
/** * Generate Apache .htaccess files to restrict access */ public static function createHtAccessFiles() { // deny access to these folders $directoriesToProtect = array('/config', '/core', '/lang', '/tmp'); foreach ($directoriesToProtect as $directoryToProtect) { Filesystem::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true); } // Allow/Deny lives in different modules depending on the Apache version $allow = "<IfModule mod_access.c>\nAllow from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nAllow from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nAllow from all\n</IfModule>\n"; $deny = "<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"; // more selective allow/deny filters $allowAny = "<Files \"*\">\n" . $allow . "Satisfy any\n</Files>\n"; $allowStaticAssets = "<Files ~ \"\\.(test\\.php|gif|ico|jpg|png|svg|js|css|swf)\$\">\n" . $allow . "Satisfy any\n</Files>\n"; $denyDirectPhp = "<Files ~ \"\\.(php|php4|php5|inc|tpl|in|twig)\$\">\n" . $deny . "</Files>\n"; $directoriesToProtect = array('/js' => $allowAny, '/libs' => $denyDirectPhp . $allowStaticAssets, '/vendor' => $denyDirectPhp . $allowStaticAssets, '/plugins' => $denyDirectPhp . $allowStaticAssets, '/misc/user' => $denyDirectPhp . $allowStaticAssets); foreach ($directoriesToProtect as $directoryToProtect => $content) { Filesystem::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content); } }
static function update() { $obsoleteFiles = array(PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php'); foreach ($obsoleteFiles as $obsoleteFile) { if (file_exists($obsoleteFile)) { @unlink($obsoleteFile); } } $obsoleteDirectories = array(PIWIK_INCLUDE_PATH . '/core/Db/Pdo'); foreach ($obsoleteDirectories as $dir) { if (file_exists($dir)) { Filesystem::unlinkRecursive($dir, true); } } // force regeneration of cache files Piwik::setUserHasSuperUserAccess(); $allSiteIds = API::getInstance()->getAllSitesId(); Cache::regenerateCacheWebsiteAttributes($allSiteIds); }
/** * @param string $templateFolder full path like /home/... * @param string $pluginName * @param array $replace array(key => value) $key will be replaced by $value in all templates * @param array $whitelistFiles If not empty, only given files/directories will be copied. * For instance array('/Controller.php', '/templates', '/templates/index.twig') */ protected function copyTemplateToPlugin($templateFolder, $pluginName, array $replace = array(), $whitelistFiles = array()) { $replace['PLUGINNAME'] = $pluginName; $files = array_merge(Filesystem::globr($templateFolder, '*'), Filesystem::globr($templateFolder, '.*')); foreach ($files as $file) { $fileNamePlugin = str_replace($templateFolder, '', $file); if (!empty($whitelistFiles) && !in_array($fileNamePlugin, $whitelistFiles)) { continue; } if (is_dir($file)) { $this->createFolderWithinPluginIfNotExists($pluginName, $fileNamePlugin); } else { $template = file_get_contents($file); foreach ($replace as $key => $value) { $template = str_replace($key, $value, $template); } foreach ($replace as $key => $value) { $fileNamePlugin = str_replace($key, $value, $fileNamePlugin); } $this->createFileWithinPluginIfNotExists($pluginName, $fileNamePlugin, $template); } } }
/** * 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 = StaticContainer::get('path.tmp') . '/assets'; if (!is_dir($mergedFileDirectory)) { Filesystem::mkdir($mergedFileDirectory); } if (!is_writable($mergedFileDirectory)) { throw new Exception("Directory " . $mergedFileDirectory . " has to be writable."); } return $mergedFileDirectory; }
/** * Deletes all existing .htaccess files and web.config files that Piwik may have created, */ public static function deleteHtAccessFiles() { $files = Filesystem::globr(PIWIK_INCLUDE_PATH, ".htaccess"); // that match the list of directories we create htaccess files // (ie. not the root /.htaccess) $directoriesWithAutoHtaccess = array('/js', '/libs', '/vendor', '/plugins', '/misc/user', '/config', '/core', '/lang', '/tmp'); foreach ($files as $file) { foreach ($directoriesWithAutoHtaccess as $dirToDelete) { // only delete the first .htaccess and not the ones in sub-directories $pathToDelete = $dirToDelete . '/.htaccess'; if (strpos($file, $pathToDelete) !== false) { @unlink($file); } } } }
private function tryToRepairPiwik() { // in case any opcaches etc were not cleared after an update for instance. Might prevent from getting the // error again try { Filesystem::deleteAllCacheOnUpdate(); } catch (Exception $e) { } }
/** * A function to delete all cache entries in the directory */ public function deleteAll() { $self = $this; $beforeUnlink = function ($path) use($self) { $self->opCacheInvalidate($path); }; Filesystem::unlinkRecursive($this->cachePath, $deleteRootToo = false, $beforeUnlink); }
private function doWelcomeUpdates($view, $componentsWithUpdateFile) { $view->new_piwik_version = Version::VERSION; $view->commandUpgradePiwik = "<br /><code>php " . Filesystem::getPathToPiwikRoot() . "/console core:update </code>"; $pluginNamesToUpdate = array(); $dimensionsToUpdate = array(); $coreToUpdate = false; // handle case of existing database with no tables if (!DbHelper::isInstalled()) { $this->errorMessages[] = Piwik::translate('CoreUpdater_EmptyDatabaseError', Config::getInstance()->database['dbname']); $this->coreError = true; $currentVersion = 'N/A'; } else { $this->errorMessages = array(); try { $currentVersion = Option::get('version_core'); } catch (Exception $e) { $currentVersion = '<= 0.2.9'; } foreach ($componentsWithUpdateFile as $name => $filenames) { if ($name == 'core') { $coreToUpdate = true; } elseif (0 === strpos($name, 'log_')) { $dimensionsToUpdate[] = $name; } else { $pluginNamesToUpdate[] = $name; } } } // check file integrity $integrityInfo = Filechecks::getFileIntegrityInformation(); if (isset($integrityInfo[1])) { if ($integrityInfo[0] == false) { $this->warningMessages[] = Piwik::translate('General_FileIntegrityWarningExplanation'); } $this->warningMessages = array_merge($this->warningMessages, array_slice($integrityInfo, 1)); } Filesystem::deleteAllCacheOnUpdate(); $view->coreError = $this->coreError; $view->warningMessages = $this->warningMessages; $view->errorMessages = $this->errorMessages; $view->current_piwik_version = $currentVersion; $view->pluginNamesToUpdate = $pluginNamesToUpdate; $view->dimensionsToUpdate = $dimensionsToUpdate; $view->coreToUpdate = $coreToUpdate; }
/** * Write configuration file from session-store */ private function createConfigFile($dbInfos) { $config = Config::getInstance(); // make sure DB sessions are used if the filesystem is NFS if (Filesystem::checkIfFileSystemIsNFS()) { $config->General['session_save_handler'] = 'dbtable'; } if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) { $config->General['proxy_client_headers'] = $headers; } if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) { $config->General['proxy_host_headers'] = $headers; } if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') { $protocol = 'https'; } else { $protocol = ProxyHeaders::getProtocolInformation(); } if (!empty($protocol) && !\Piwik\ProxyHttp::isHttps()) { $config->General['assume_secure_protocol'] = '1'; } $config->General['salt'] = Common::generateUniqId(); $config->General['installation_in_progress'] = 1; $config->database = $dbInfos; if (!DbHelper::isDatabaseConnectionUTF8()) { $config->database['charset'] = 'utf8'; } $config->forceSave(); }
private function paintReportTable() { //Color and font restoration $this->TCPDF->SetFillColor($this->tableBackgroundColor[0], $this->tableBackgroundColor[1], $this->tableBackgroundColor[2]); $this->TCPDF->SetTextColor($this->reportTextColor[0], $this->reportTextColor[1], $this->reportTextColor[2]); $this->TCPDF->SetFont(''); $fill = true; $url = false; $leftSpacesBeforeLogo = str_repeat(' ', $this->leftSpacesBeforeLogo); $logoWidth = $this->logoWidth; $logoHeight = $this->logoHeight; $rowsMetadata = $this->reportRowsMetadata->getRows(); // Draw a body of report table foreach ($this->report->getRows() as $rowId => $row) { $rowMetrics = $row->getColumns(); $rowMetadata = isset($rowsMetadata[$rowId]) ? $rowsMetadata[$rowId]->getColumns() : array(); if (isset($rowMetadata['url'])) { $url = $rowMetadata['url']; } foreach ($this->reportColumns as $columnId => $columnName) { // Label column if ($columnId == 'label') { $isLogoDisplayable = isset($rowMetadata['logo']); $text = ''; $posX = $this->TCPDF->GetX(); $posY = $this->TCPDF->GetY(); if (isset($rowMetrics[$columnId])) { $text = substr($rowMetrics[$columnId], 0, $this->truncateAfter); if ($isLogoDisplayable) { $text = $leftSpacesBeforeLogo . $text; } } $text = $this->formatText($text); $this->TCPDF->Cell($this->labelCellWidth, $this->cellHeight, $text, 'LR', 0, 'L', $fill, $url); if ($isLogoDisplayable) { if (isset($rowMetadata['logoWidth'])) { $logoWidth = $rowMetadata['logoWidth']; } if (isset($rowMetadata['logoHeight'])) { $logoHeight = $rowMetadata['logoHeight']; } $restoreY = $this->TCPDF->getY(); $restoreX = $this->TCPDF->getX(); $this->TCPDF->SetY($posY); $this->TCPDF->SetX($posX); $topMargin = 1.3; // Country flags are not very high, force a bigger top margin if ($logoHeight < 16) { $topMargin = 2; } $path = Filesystem::getPathToPiwikRoot() . "/" . $rowMetadata['logo']; if (file_exists($path)) { $this->TCPDF->Image($path, $posX + ($leftMargin = 2), $posY + $topMargin, $logoWidth / 4); } $this->TCPDF->SetXY($restoreX, $restoreY); } } else { // No value means 0 if (empty($rowMetrics[$columnId])) { $rowMetrics[$columnId] = 0; } $this->TCPDF->Cell($this->cellWidth, $this->cellHeight, $rowMetrics[$columnId], 'LR', 0, 'L', $fill); } } $this->TCPDF->Ln(); // Top/Bottom grey border for all cells $this->TCPDF->SetDrawColor($this->rowTopBottomBorder[0], $this->rowTopBottomBorder[1], $this->rowTopBottomBorder[2]); $this->TCPDF->Cell($this->totalWidth, 0, '', 'T'); $this->setBorderColor(); $this->TCPDF->Ln(0.2); $fill = !$fill; } }
function validateOwner() { $prefix = $this->owner->getValue(); return empty($prefix) || Filesystem::isValidFilename($prefix); }
/** * Returns the help message when the auto update can't run because of missing permissions * * @return string */ public static function getAutoUpdateMakeWritableMessage() { $realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/'); $message = ''; $message .= "<code>chown -R " . self::getUserAndGroup() . " " . $realpath . "</code><br />"; $message .= "<code>chmod -R 0755 " . $realpath . "</code><br />"; $message .= 'After you execute these commands (or change permissions via your FTP software), refresh the page and you should be able to use the "Automatic Update" feature.'; return $message; }