diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-09-30 10:11:35 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-09-30 16:05:47 +0400 |
commit | 494d826ab4874ea85d55ce7e47b432abe35a4a5d (patch) | |
tree | 82d65784b0a509539022d559a45754bcb2f1f208 | |
parent | e2de21361ae1a858e3b339fdb3b040b0429dac4f (diff) |
Refs #4133
57 files changed, 137 insertions, 64 deletions
diff --git a/core/AssetManager.php b/core/AssetManager.php index b5ae6a6a5f..c3c3101762 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -46,6 +46,8 @@ class AssetManager const CSS_IMPORT_EVENT = "AssetManager.getStylesheetFiles"; const JS_IMPORT_EVENT = "AssetManager.getJsFiles"; const MERGED_FILE_DIR = "tmp/assets/"; + const COMPRESSED_FILE_LOCATION = "/tmp/assets/"; + const CSS_IMPORT_DIRECTIVE = "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n"; const JS_IMPORT_DIRECTIVE = "<script type=\"text/javascript\" src=\"%s\"></script>\n"; const GET_CSS_MODULE_ACTION = "index.php?module=Proxy&action=getCss"; @@ -500,8 +502,9 @@ class AssetManager } // Tries to remove compressed version of the merged file. - // See Piwik::serverStaticFile() for more info on static file compression - $compressedFileLocation = PIWIK_USER_PATH . Piwik::COMPRESSED_FILE_LOCATION . $filename; + // See ProxyHttp::serverStaticFile() for more info on static file compression + $compressedFileLocation = PIWIK_USER_PATH . self::COMPRESSED_FILE_LOCATION . $filename; + $compressedFileLocation = SettingsPiwik::rewriteTmpPathWithHostname($compressedFileLocation); @unlink($compressedFileLocation . ".deflate"); @unlink($compressedFileLocation . ".gz"); @@ -538,6 +541,7 @@ class AssetManager private static function getMergedFileDirectory() { $mergedFileDirectory = PIWIK_USER_PATH . '/' . self::MERGED_FILE_DIR; + $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithHostname($mergedFileDirectory); if (!is_dir($mergedFileDirectory)) { Filesystem::mkdir($mergedFileDirectory); diff --git a/core/CacheFile.php b/core/CacheFile.php index 139beeaffc..9ee78168f5 100644 --- a/core/CacheFile.php +++ b/core/CacheFile.php @@ -48,7 +48,9 @@ class CacheFile */ public function __construct($directory, $timeToLiveInSeconds = 300) { - $this->cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/'; + $cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/'; + $this->cachePath = SettingsPiwik::rewriteTmpPathWithHostname($cachePath); + if ($timeToLiveInSeconds < self::MINIMUM_TTL) { $timeToLiveInSeconds = self::MINIMUM_TTL; } diff --git a/core/Config.php b/core/Config.php index d88709379a..c7536ac338 100644 --- a/core/Config.php +++ b/core/Config.php @@ -155,9 +155,41 @@ class Config */ public static function getLocalConfigPath() { + $path = self::getByDomainConfigPath(); + if($path) { + return $path; + } + return PIWIK_USER_PATH . '/config/config.ini.php'; } + public function getConfigHostnameIfSet() + { + if($this->getByDomainConfigPath() === false) { + return false; + } + return $this->getHostname(); + } + + protected static function getByDomainConfigPath() + { + $host = self::getHostname(); + $perHostFilename = $host . '.config.ini.php'; + $pathDomainConfig = PIWIK_USER_PATH . '/config/' . $perHostFilename; + if (Filesystem::isValidFilename($perHostFilename) + && file_exists($pathDomainConfig) + ) { + return $pathDomainConfig; + } + return false; + } + + protected static function getHostname() + { + $host = Url::getHost($checkIfTrusted = false); // Check trusted requires config file which is not ready yet + return $host; + } + /** * Is local configuration file writable? * diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php index 019cd4d51c..cd339e215e 100644 --- a/core/Db/BatchInsert.php +++ b/core/Db/BatchInsert.php @@ -17,6 +17,7 @@ use Piwik\Config; use Piwik\Db; use Piwik\DbHelper; use Piwik\Piwik; +use Piwik\SettingsPiwik; use Piwik\SettingsServer; class BatchInsert @@ -60,6 +61,7 @@ class BatchInsert public static function tableInsertBatch($tableName, $fields, $values, $throwException = false) { $filePath = PIWIK_USER_PATH . '/' . AssetManager::MERGED_FILE_DIR . $tableName . '-' . Common::generateUniqId() . '.csv'; + $filePath = SettingsPiwik::rewriteTmpPathWithHostname($filePath); if (Db::get()->hasBulkLoader()) { try { diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php index 081e4601a8..26ecef6a00 100644 --- a/core/ExceptionHandler.php +++ b/core/ExceptionHandler.php @@ -10,12 +10,8 @@ */ namespace Piwik; -use Piwik\Common; -use Piwik\Piwik; -use Piwik\Plugin; -use Piwik\Log; -use Piwik\FrontController; use Piwik\API\ResponseBuilder; +use Piwik\Plugin; /** * Contains Piwik's uncaught exception handler and log file formatting for exception @@ -62,7 +58,7 @@ class ExceptionHandler } } - public static function exceptionHandler(Exception $exception) + public static function exceptionHandler(\Exception $exception) { Log::error($exception); } diff --git a/core/Filechecks.php b/core/Filechecks.php index 1c15cc5ea8..893e158d62 100644 --- a/core/Filechecks.php +++ b/core/Filechecks.php @@ -40,10 +40,13 @@ class Filechecks { $resultCheck = array(); foreach ($directoriesToCheck as $directoryToCheck) { + if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)) { $directoryToCheck = PIWIK_USER_PATH . $directoryToCheck; } + $directoryToCheck = SettingsPiwik::rewriteTmpPathWithHostname($directoryToCheck); + // Create an empty directory $isFile = strpos($directoryToCheck, '.') !== false; if (!$isFile && !file_exists($directoryToCheck)) { diff --git a/core/Filesystem.php b/core/Filesystem.php index 51bdc5fee8..5c7ea6d868 100644 --- a/core/Filesystem.php +++ b/core/Filesystem.php @@ -194,7 +194,7 @@ class Filesystem * @param boolean $deleteRootToo Delete specified top-level directory as well * @param Closure|false $beforeUnlink A closure to execute before unlinking. */ - public static function unlinkRecursive($dir, $deleteRootToo, $beforeUnlink = false) + public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null) { if (!$dh = @opendir($dir)) { return; diff --git a/core/Log.php b/core/Log.php index 06755e41de..f3e566c12d 100644 --- a/core/Log.php +++ b/core/Log.php @@ -290,7 +290,8 @@ class Log if (is_dir($logPath)) { $logPath .= '/piwik.log'; } - $this->logToFilePath = $logPath; + + $this->logToFilePath = SettingsPiwik::rewriteTmpPathWithHostname($logPath); } private function createWriterByName($writerName) diff --git a/core/Piwik.php b/core/Piwik.php index 0d33e42a06..4977cb1dad 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -34,8 +34,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; */ class Piwik { - const COMPRESSED_FILE_LOCATION = '/tmp/assets/'; - /** * Piwik periods * @var array diff --git a/core/ProxyHttp.php b/core/ProxyHttp.php index 5bcde43de1..030443d801 100644 --- a/core/ProxyHttp.php +++ b/core/ProxyHttp.php @@ -91,7 +91,8 @@ class ProxyHttp // optional compression $compressed = false; $encoding = ''; - $compressedFileLocation = PIWIK_USER_PATH . Piwik::COMPRESSED_FILE_LOCATION . basename($file); + $compressedFileLocation = PIWIK_USER_PATH . AssetManager::COMPRESSED_FILE_LOCATION . basename($file); + $compressedFileLocation = SettingsPiwik::rewriteTmpPathWithHostname($compressedFileLocation); $phpOutputCompressionEnabled = ProxyHttp::isPhpOutputCompressed(); if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !$phpOutputCompressionEnabled) { diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php index 3287a6e97e..18ac8f9c51 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -147,6 +147,8 @@ abstract class ReportRenderer protected static function getOutputPath($filename) { $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename; + $outputFilename = SettingsPiwik::rewriteTmpPathWithHostname($outputFilename); + @chmod($outputFilename, 0600); @unlink($outputFilename); return $outputFilename; diff --git a/core/Session.php b/core/Session.php index 221c62bac2..5f3c765a7a 100644 --- a/core/Session.php +++ b/core/Session.php @@ -128,9 +128,11 @@ class Session extends Zend_Session we recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' target='_blank'>enable database session storage</a>."; } + $pathToSessions = Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/'); + $pathToSessions = SettingsPiwik::rewriteTmpPathWithHostname($pathToSessions); $message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>", Piwik_Translate('General_ExceptionUnableToStartSession'), - Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/'), + $pathToSessions, $enableDbSessions, $e->getMessage() ); @@ -146,6 +148,7 @@ class Session extends Zend_Session */ public static function getSessionsDirectory() { + //tmp return PIWIK_USER_PATH . '/tmp/sessions'; } } diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 19e9233891..51e7c006a8 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -166,4 +166,30 @@ class SettingsPiwik return $result; } + + /** + * If Piwik uses per-domain config file, also make tmp/ folder per-domain + * @param $path + * @return string + * @throws \Exception + */ + public static function rewriteTmpPathWithHostname($path) + { + $configByHost = Config::getInstance()->getConfigHostnameIfSet(); + if(empty($configByHost)) { + return $path; + } + + $tmp = '/tmp/'; + if(($posTmp = strrpos($path, $tmp)) === false) { + throw new Exception("The path $path was expected to contain the string /tmp/ "); + } + + $tmpToReplace = $tmp . $configByHost . '/'; + + // replace only the latest occurrence (in case path contains twice /tmp) + $path = substr_replace($path, $tmpToReplace, $posTmp, strlen($tmp)); + + return $path; + } } diff --git a/core/Twig.php b/core/Twig.php index 59fabb8a2e..0520d242d7 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -46,11 +46,14 @@ class Twig $chainLoader = new Twig_Loader_Chain(array($loader)); // Create new Twig Environment and set cache dir + $templatesCompiledPath = PIWIK_USER_PATH . '/tmp/templates_c'; + $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithHostname($templatesCompiledPath); + $this->twig = new Twig_Environment($chainLoader, array( 'debug' => true, // to use {{ dump(var) }} in twig templates 'strict_variables' => true, // throw an exception if variables are invalid - 'cache' => PIWIK_USER_PATH . '/tmp/templates_c', + 'cache' => $templatesCompiledPath, ) ); $this->twig->addExtension(new Twig_Extension_Debug()); diff --git a/core/functions.php b/core/functions.php index c706a17b6a..a34fdca893 100644 --- a/core/functions.php +++ b/core/functions.php @@ -262,8 +262,7 @@ namespace { // Bridge between pre Piwik2 serialized format and namespaced classes // Do not need to define these classes in tracker or archive - if(empty($GLOBALS['PIWIK_TRACKER_MODE']) - && !defined('PIWIK_MODE_ARCHIVE')) { + if(class_exists('\\Piwik\\DataTable\\Row\\DataTableSummaryRow')) { class Piwik_DataTable_Row_DataTableSummary extends \Piwik\DataTable\Row\DataTableSummaryRow { } diff --git a/js/index.php b/js/index.php index 5d8ec0a41b..b47cc5c2f3 100644 --- a/js/index.php +++ b/js/index.php @@ -25,8 +25,8 @@ define('PIWIK_DOCUMENT_ROOT', '..'); define('PIWIK_USER_PATH', '..'); require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php'; -require_once PIWIK_INCLUDE_PATH . '/core/ProxyHttp.php'; +require_once PIWIK_INCLUDE_PATH . '/core/functions.php'; +require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; $file = '../piwik.js'; diff --git a/lang/ar.json b/lang/ar.json index 8a72d68625..dc5f43d60a 100644 --- a/lang/ar.json +++ b/lang/ar.json @@ -125,7 +125,6 @@ "LogoNotWriteable": "لاستخدام شعار مخصص، ستحتاج إلى صلاحيات الكتابة على ملفات الشعار في مجلد القالب: %s", "LogoUpload": "اختر شعاراً لرفعه", "LogoUploadDescription": "الرجاء رفع ملف بصيغة %s، بدون خلفيات شفافة بارتفاع لا يقل عن %s بكسل.", - "MenuCommunity": "المجتمع", "MenuDiagnostic": "التشخيص", "MenuGeneralSettings": "الإعدادات العامة", "MenuManage": "الإدارة", diff --git a/lang/bg.json b/lang/bg.json index 6ba9bec0c3..29a4868f34 100644 --- a/lang/bg.json +++ b/lang/bg.json @@ -108,7 +108,6 @@ "LogoNotWriteable": "За да използвате изработеното лого Piwik изисква писмен достъп до файловете на логото в тематичната директория: %s", "LogoUpload": "Изберете логото за качване", "LogoUploadDescription": "Моля качвайте файла в %s формати, без прозрачни фонове, с минимална височина от %s пиксела.", - "MenuCommunity": "Общност", "MenuDiagnostic": "Диагностика", "MenuGeneralSettings": "Основни настройки", "MenuManage": "Управление", diff --git a/lang/cs.json b/lang/cs.json index ec8897ae6f..46e6ec7c89 100644 --- a/lang/cs.json +++ b/lang/cs.json @@ -97,7 +97,6 @@ "LatestStableRelease": "Poslední stabilní verze", "LogoUpload": "Vyberte logotyp", "LogoUploadDescription": "Prosím nahrajte soubor ve formátu %s bez transparentního pozadí s minimální výškou %s pixelů.", - "MenuCommunity": "Komunita", "MenuDiagnostic": "Diagnostika", "MenuGeneralSettings": "Hlavní nastavení", "MenuManage": "Správa", diff --git a/lang/da.json b/lang/da.json index fb875862bf..f44d1cdcba 100644 --- a/lang/da.json +++ b/lang/da.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "For at anvende et brugerdefineret logo, kræver Piwik skrive adgang til logofilerne i skabelonmappen: %s", "LogoUpload": "Vælg et logo til overførelse", "LogoUploadDescription": "Overfør en fil i formatet %s, ingen gennemsigtig baggrund og med en højde på minimum %s pixels.", - "MenuCommunity": "Fællesskab", "MenuDiagnostic": "Diagnosticering", "MenuGeneralSettings": "Generelle indstillinger", "MenuManage": "Administrere", diff --git a/lang/de.json b/lang/de.json index 5a8c341647..7df9f42be5 100644 --- a/lang/de.json +++ b/lang/de.json @@ -144,7 +144,6 @@ "LogoNotWriteable": "Um ein eigenes Logo in Piwik verwenden zu können, wird Schreibzugriff auf die Logo Dateien im themes Ordner benötigt: %s", "LogoUpload": "Wählen Sie ein Logo für den Upload", "LogoUploadDescription": "Es werden Logos in %s Formaten, ohne Transparenz und mit einer minimalen Höhe von %s Pixeln unterstützt.", - "MenuCommunity": "Community", "MenuDiagnostic": "Diagnose", "MenuGeneralSettings": "Allgemeine Einstellungen", "MenuManage": "Verwalten", diff --git a/lang/el.json b/lang/el.json index dd70ec246c..3c4c014a54 100644 --- a/lang/el.json +++ b/lang/el.json @@ -141,7 +141,6 @@ "LogoNotWriteable": "Για να χρησιμοποιήσετε ένα προσαρμοσμένο υπόβαθρο, το Piwik απαιτεί δικαιώματα εγγραφής στα αρχεία λογοτύπου μέσα στο φάκελο των θεμάτων: %s", "LogoUpload": "Επιλέξτε ένα Λογότυπο για αποστολή", "LogoUploadDescription": "Αποστείλτε ένα αρχείο σε μορφές %s, χωρίς διάφανο υπόβαθρο, με ελάχιστο ύψος %s εικονοστοιχεία (pixels).", - "MenuCommunity": "Κοινότητα", "MenuDiagnostic": "Διαγνωστικά", "MenuGeneralSettings": "Γενικές ρυθμίσεις", "MenuManage": "Διαχείριση", diff --git a/lang/en.json b/lang/en.json index 10e45ba7b9..e38b5048e2 100644 --- a/lang/en.json +++ b/lang/en.json @@ -508,7 +508,6 @@ }, "CoreAdminHome": { "PluginDescription": "Administration area of Piwik.", - "MenuCommunity": "Community", "MenuDiagnostic": "Diagnostic", "MenuGeneralSettings": "General settings", "MenuManage": "Manage", diff --git a/lang/es.json b/lang/es.json index c972526af1..80c718203b 100644 --- a/lang/es.json +++ b/lang/es.json @@ -119,7 +119,6 @@ "LogoNotWriteable": "Para usar un logo personalizado Piwik necesita acceso de escritura a los archivos de logo en el directorio de temas: %s", "LogoUpload": "Seleccione un logo para subir", "LogoUploadDescription": "Por favor suba un archivo en %s formatos, sin transparencias, con una altura mínima de %s píxeles.", - "MenuCommunity": "comunidad", "MenuDiagnostic": "diagnóstico", "MenuGeneralSettings": "Configuración General", "MenuManage": "gestionar", diff --git a/lang/fa.json b/lang/fa.json index 4a2ded6945..f701b4d4ea 100644 --- a/lang/fa.json +++ b/lang/fa.json @@ -122,7 +122,6 @@ "LatestStableRelease": "آخرین نسخه نهایی", "LogoNotWriteable": "برای استفاده از یک آرم سفارشی پیویک به دسترسی نوشتن به فایل های آرم نیاز دارد که در پوشه ی پوسته ها است: %s", "LogoUpload": "انتخاب آرم برای آپلود", - "MenuCommunity": "انجمن", "MenuDiagnostic": "برشناختی", "MenuGeneralSettings": "تنضیمات اصلی", "MenuManage": "مدیریت", diff --git a/lang/fr.json b/lang/fr.json index e593804035..ac4cd850a9 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "Pour utiliser un logo personnalisé Piwik a besoin d'un accès en écriture aux fichiers de logo dans les répertoires des thèmes: %s", "LogoUpload": "Sélectionnez le logo à télécharger", "LogoUploadDescription": "Veuillez télécharger un fichier dans un de ces formats %s, sans fond transparent et avec une hauteur minimale de %s pixels.", - "MenuCommunity": "Communauté", "MenuDiagnostic": "Diagnostique", "MenuGeneralSettings": "Paramètres généraux", "MenuManage": "Gérer", diff --git a/lang/he.json b/lang/he.json index eff8268d6b..c7c48fed14 100644 --- a/lang/he.json +++ b/lang/he.json @@ -65,7 +65,6 @@ "ImageTracking": "תמונת מעקב", "LatestBetaRelease": "גרסת נסיון אחרונה", "LogoUpload": "בחירת קובץ לוגו", - "MenuCommunity": "קהילה", "MenuDiagnostic": "אבחון", "MenuGeneralSettings": "הגדרות כלליות", "MenuManage": "ניהול", diff --git a/lang/hi.json b/lang/hi.json index a5d8b63a4f..c8a37d292e 100644 --- a/lang/hi.json +++ b/lang/hi.json @@ -140,7 +140,6 @@ "LogoNotWriteable": "एक कस्टम प्रतीक चिन्ह Piwik उपयोग करने के लिए विषयों निर्देशिका के भीतर प्रतीक चिन्ह फाइल करने के लिए उपयोग लिखने की आवश्यकता है: %s", "LogoUpload": "अपलोड करने के लिए किसी लोगो को चुनें", "LogoUploadDescription": "%s पिक्सल के एक न्यूनतम ऊंचाई के साथ %s प्रारूप में एक फ़ाइल, कोई पारदर्शी पृष्ठभूमि, अपलोड करें.", - "MenuCommunity": "सम्प्रदाय", "MenuDiagnostic": "डायग्नोस्टिक", "MenuGeneralSettings": "सामान्य सेटिंग्स", "MenuManage": "नियंत्रित करें", diff --git a/lang/id.json b/lang/id.json index 60bf646282..b95f95746c 100644 --- a/lang/id.json +++ b/lang/id.json @@ -141,7 +141,6 @@ "LogoNotWriteable": "Untuk menggunakan logo kustom, Piwik membutuhkan akses tulis ke file logo dalam direktori tema: %s", "LogoUpload": "Pilih Logo untuk diunggah", "LogoUploadDescription": "Silakan unggah berkas dalam format %s, tanpa latar belakang transparan, dengan ketinggian minimal %s piksel.", - "MenuCommunity": "Komunitas", "MenuDiagnostic": "Diagnosis", "MenuGeneralSettings": "Pengaturan Umum", "MenuManage": "Kelola", diff --git a/lang/it.json b/lang/it.json index 6f28eedd6e..ad0b680e03 100644 --- a/lang/it.json +++ b/lang/it.json @@ -145,7 +145,6 @@ "LogoNotWriteable": "Per usare un logo personalizzato Piwik richiede i permessi di scrittura della cartella dei temi: %s", "LogoUpload": "Seleziona un logo da caricare", "LogoUploadDescription": "Per favore carica un file in formato %s, senza trasparenza, con un minimo di %s pixel.", - "MenuCommunity": "Comunità", "MenuDiagnostic": "Diagnostica", "MenuGeneralSettings": "Impostazioni generali", "MenuManage": "Gestione", diff --git a/lang/ja.json b/lang/ja.json index 79ef4892b2..0b4eaf91cd 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -141,7 +141,6 @@ "LogoNotWriteable": "カスタムロゴを使用するにはthemesディレクトリ:%s の中のロゴファイルへの書き込み権限が必要です。", "LogoUpload": "アップロードするロゴを選択", "LogoUploadDescription": "ファイルは %s フォーマット、透明背景なし、最小高さ %s ピクセルでアップロードしてください。", - "MenuCommunity": "コミュニティ", "MenuDiagnostic": "診断", "MenuGeneralSettings": "全般の設定", "MenuManage": "管理", diff --git a/lang/ko.json b/lang/ko.json index c499967aab..8ef2e41d40 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -108,7 +108,6 @@ "LogoNotWriteable": "로고를 변경하려면 themes 디렉토리의 로고 파일에 쓰기 권한이 있어야합니다: %s", "LogoUpload": "업로드 할 로고 선택", "LogoUploadDescription": "파일을 업로드합니다. %s 포맷이며 투명 배경이 없고 최소 높이가 %s 픽셀이어야 합니다.", - "MenuCommunity": "커뮤니티", "MenuDiagnostic": "진단", "MenuGeneralSettings": "일반 설정", "MenuManage": "관리", diff --git a/lang/nl.json b/lang/nl.json index c5ab4b63fa..6901c666dd 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "Voor het gebruik van een aangepast logo heeft Piwik schrijfrechten nodig in de map met de logo-bestanden in de themes map: %s", "LogoUpload": "Selecteer een logo om te uploaden", "LogoUploadDescription": "Upload een bestand in de formaten %s, geen transparante achtergrond, met een minimum hoogte van %s pixels.", - "MenuCommunity": "Gemeenschap", "MenuDiagnostic": "Diagnose", "MenuGeneralSettings": "Algemene instellingen", "MenuManage": "Beheer", diff --git a/lang/pt-br.json b/lang/pt-br.json index dfb4683557..7d83aa62de 100644 --- a/lang/pt-br.json +++ b/lang/pt-br.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "Para usar um logo personalizado o Piwik requer permissão de gravação ao diretório dos arquivos de temas: %s", "LogoUpload": "Selecione um logotipo para carregar", "LogoUploadDescription": "Faça upload de um arquivo no formato %s, sem nenhum fundo transparente e com uma altura mínima de %s pixels.", - "MenuCommunity": "Comunidade", "MenuDiagnostic": "Diagnostico", "MenuGeneralSettings": "Configurações Gerais", "MenuManage": "Gerenciar", diff --git a/lang/ro.json b/lang/ro.json index 1eb873dd22..860b86960a 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -93,7 +93,6 @@ "LatestBetaRelease": "Ultima versiune beta", "LatestStableRelease": "Ultima versiune stabilă", "LogoUpload": "Alege logo-ul pentru încărcare", - "MenuCommunity": "Comunitate", "MenuDiagnostic": "Diagnosticare", "MenuGeneralSettings": "Setări generale", "MenuManage": "Administrare", diff --git a/lang/ru.json b/lang/ru.json index 6f62b74fb1..17e6073fe9 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -138,7 +138,6 @@ "LogoNotWriteable": "Чтобы использовать пользовательские лого, Piwik трубется права на запись в папку для лого: %s", "LogoUpload": "Выберите лого для загрузки", "LogoUploadDescription": "Пожалуйста, заливайте файлы форматов %s, прозрачный фон недопустим, минимальное ограничение по высоте - %s пикселей.", - "MenuCommunity": "Сообщество", "MenuDiagnostic": "Диагностика", "MenuGeneralSettings": "Основные настройки", "MenuManage": "Управление", diff --git a/lang/sl.json b/lang/sl.json index daaaa2e70b..47024262a3 100644 --- a/lang/sl.json +++ b/lang/sl.json @@ -72,7 +72,6 @@ "CustomLogoHelpText": "Piwik-ov logo lahko prilagodite po vaših željah. Spremembe bodo vidne tako v uporabniškem vmesniku, kot v email poročilih.", "EmailServerSettings": "Nastavitev strežnika za email", "LogoUpload": "Izberite Logo za nalaganje", - "MenuCommunity": "Skupnost", "MenuDiagnostic": "Diagnostika", "MenuGeneralSettings": "Splošne nastavitve", "MenuManage": "Upravljaj", diff --git a/lang/sq.json b/lang/sq.json index 858e797898..f743c859d1 100644 --- a/lang/sq.json +++ b/lang/sq.json @@ -100,7 +100,6 @@ "LogoNotWriteable": "Që të përdorni një logo Piwik të përshtatur ju nevojitet të keni leje shkrimi te kartelat e logos brenda drejtorisë së temës: %s", "LogoUpload": "Përzgjidhni një Logo për ta ngarkuar", "LogoUploadDescription": "Ju lutem, ngarkoni një kartelë në format %s, pa sfond të tejdukshëm, me një lartësi minimale %s piksela.", - "MenuCommunity": "Bashkësi", "MenuDiagnostic": "Diagnostikim", "MenuGeneralSettings": "Rregullime të përgjithshme", "MenuManage": "Administroni", diff --git a/lang/sr.json b/lang/sr.json index 30b2706e15..641123b95e 100644 --- a/lang/sr.json +++ b/lang/sr.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "Da biste koristili svoj logo za Piwik, potrebno je da omogućite prava za pisanje logo fajlovima u okviru foldera za teme: %s", "LogoUpload": "Izaberite logo za kačenje", "LogoUploadDescription": "Molimo vas da datoteka bude u formatima %s, bez transparencije i sa minimalnom visinom od %s piksela.", - "MenuCommunity": "Zajednica", "MenuDiagnostic": "Dijagnostika", "MenuGeneralSettings": "Osnovna podešavanja", "MenuManage": "Upravljanje", diff --git a/lang/sv.json b/lang/sv.json index 711bf52fb1..7e5a0ae448 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -122,7 +122,6 @@ "LogoNotWriteable": "För att kunna använda en anpassad logotyp för Piwik krävs skrivrättigheter till logotypfilerna i temakatalogen: %s", "LogoUpload": "Välj en logotyp att ladda upp", "LogoUploadDescription": "Vänligen ladda upp en fil i %s formatet, ingen transparent bakgrund, med en minsta höjd av %s pixlar.", - "MenuCommunity": "Community", "MenuDiagnostic": "Diagnostik", "MenuGeneralSettings": "Allmänna inställningar", "MenuManage": "Hantera", diff --git a/lang/ta.json b/lang/ta.json index c284eeb8e6..fd1f7ec602 100644 --- a/lang/ta.json +++ b/lang/ta.json @@ -65,7 +65,6 @@ "LatestBetaRelease": "தற்போதைய நிலையற்ற வெளியீடு", "LatestStableRelease": "தற்போதைய நிலையான வெளியீடு", "LogoUpload": "முத்திரையை தேர்வு செய்க", - "MenuCommunity": "சமூகம்", "MenuDiagnostic": "ஆய்ந்தறிதல்", "MenuGeneralSettings": "பொது அமைப்புகள்", "MenuManage": "மேலாண்மை", diff --git a/lang/th.json b/lang/th.json index 2549fc507b..050866113e 100644 --- a/lang/th.json +++ b/lang/th.json @@ -68,7 +68,6 @@ "Administration": "การจัดการระบบ", "EmailServerSettings": "การตั้งค่าเซิร์ฟเวอร์อีเมล์", "LogoUpload": "เลือกรูปโลโก้ที่ต้องการอัพโหลด", - "MenuCommunity": "คอมมูนิตี้", "MenuGeneralSettings": "ตั้งค่าทั่วไป", "MenuManage": "จัดการ", "OptOutComplete": "เลือกที่จะไม่ครบถ้วนเมื่อคุณเยี่ยมชมเว็บไซต์นี้จะไม่ถูกบันทึกโดยเครื่องมือวิเคราะห์เว็บ", diff --git a/lang/tr.json b/lang/tr.json index e92dd5892e..20205b9984 100644 --- a/lang/tr.json +++ b/lang/tr.json @@ -124,7 +124,6 @@ "LogoNotWriteable": "Logoyu değiştirmek için, Piwik için tema dizinindeki logo dosyalarına yazma hakkı gerekir: %s", "LogoUpload": "Yüklemek için logo seçiniz", "LogoUploadDescription": "Arka planı transparan olmayan dosyalarınızı %s formatlarında ve minimum yüksekliği %s olarak yükleyiniz.", - "MenuCommunity": "Topluluk", "MenuDiagnostic": "tehşis", "MenuGeneralSettings": "Genel Ayarlar", "MenuManage": "yönetmek", diff --git a/lang/zh-cn.json b/lang/zh-cn.json index 17e247fde9..ad64ab2f0e 100644 --- a/lang/zh-cn.json +++ b/lang/zh-cn.json @@ -142,7 +142,6 @@ "LogoNotWriteable": "Piwik需要主题文件夹内%s的写权限去自定义您的logo", "LogoUpload": "选择一个图标上传", "LogoUploadDescription": "请上传 %s 格式的文件,不要透明背景,最低高度 %s 像素。", - "MenuCommunity": "社区", "MenuDiagnostic": "检测", "MenuGeneralSettings": "一般设置", "MenuManage": "管理", @@ -42,6 +42,8 @@ require_once PIWIK_INCLUDE_PATH . '/core/Plugin.php'; require_once PIWIK_INCLUDE_PATH . '/core/Common.php'; require_once PIWIK_INCLUDE_PATH . '/core/IP.php'; require_once PIWIK_INCLUDE_PATH . '/core/UrlHelper.php'; +require_once PIWIK_INCLUDE_PATH . '/core/Url.php'; +require_once PIWIK_INCLUDE_PATH . '/core/SettingsPiwik.php'; require_once PIWIK_INCLUDE_PATH . '/core/Tracker.php'; require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php index da1dce264d..3583748b9d 100644 --- a/plugins/CoreAdminHome/CoreAdminHome.php +++ b/plugins/CoreAdminHome/CoreAdminHome.php @@ -81,8 +81,7 @@ class CoreAdminHome extends \Piwik\Plugin function addMenu() { Piwik_AddAdminSubMenu('CoreAdminHome_MenuManage', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 1); - Piwik_AddAdminSubMenu('CoreAdminHome_MenuCommunity', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 3); - Piwik_AddAdminSubMenu('CoreAdminHome_MenuDiagnostic', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 20); + Piwik_AddAdminSubMenu('CoreAdminHome_MenuDiagnostic', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 6); Piwik_AddAdminSubMenu('General_Settings', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 5); Piwik_AddAdminSubMenu('General_Settings', 'CoreAdminHome_MenuGeneralSettings', array('module' => 'CoreAdminHome', 'action' => 'generalSettings'), diff --git a/plugins/CorePluginsAdmin/PluginInstaller.php b/plugins/CorePluginsAdmin/PluginInstaller.php index cd664b3aef..ff58b45d9c 100644 --- a/plugins/CorePluginsAdmin/PluginInstaller.php +++ b/plugins/CorePluginsAdmin/PluginInstaller.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\CorePluginsAdmin; use Piwik\Filechecks; use Piwik\Filesystem; +use Piwik\SettingsPiwik; use Piwik\Unzip; /** @@ -34,6 +35,9 @@ class PluginInstaller $tmpPluginZip = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName . '.zip'; $tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName; + $tmpPluginZip = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginZip); + $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginFolder); + $this->makeSureFoldersAreWritable(); $this->makeSurePluginNameIsValid(); $this->downloadPluginFromMarketplace($tmpPluginZip); diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index c5fd949d40..59b6645af0 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -21,6 +21,7 @@ use Piwik\Filesystem; use Piwik\Http; use Piwik\Piwik; use Piwik\Plugins\LanguagesManager\LanguagesManager; +use Piwik\SettingsPiwik; use Piwik\SettingsServer; use Piwik\Unzip; use Piwik\UpdateCheck; @@ -43,6 +44,7 @@ class Controller extends \Piwik\Controller private $warningMessages = array(); private $errorMessages = array(); private $deactivatedPlugins = array(); + private $pathPiwikZip = false; static protected function getLatestZipUrl($newVersion) { @@ -127,17 +129,22 @@ class Controller extends \Piwik\Controller private function oneClick_Download() { - $this->pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip'; + $pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip'; + $this->pathPiwikZip = SettingsPiwik::rewriteTmpPathWithHostname($pathPiwikZip); + Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_EXTRACT_LATEST_VERSION)); // we catch exceptions in the caller (i.e., oneClickUpdate) $url = self::getLatestZipUrl($this->newVersion) . '?cb=' . $this->newVersion; - $fetched = Http::fetchRemoteFile($url, $this->pathPiwikZip); + + Http::fetchRemoteFile($url, $this->pathPiwikZip); } private function oneClick_Unpack() { $pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION; + $pathExtracted = SettingsPiwik::rewriteTmpPathWithHostname($pathExtracted); + $this->pathRootExtractedPiwik = $pathExtracted . 'piwik'; if (file_exists($this->pathRootExtractedPiwik)) { diff --git a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php index 7e8237a6a3..c57677e3b4 100644 --- a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php +++ b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php @@ -91,9 +91,9 @@ class Evolution extends JqplotGraph $defaultLastN = self::getDefaultLastN($period); $originalDate = Common::getRequestVar('date', 'last' . $defaultLastN, 'string'); - if ($period != 'range') { // show evolution limit if the period is not a range - $view->show_limit_control = true; - + if ($period == 'range') { // show evolution limit if the period is not a range + $view->show_limit_control = false; + } else { // set the evolution_{$period}_last_n query param if (Range::parseDateRange($originalDate)) { // if a multiple period // overwrite last_n param using the date range diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php index ba1dca5fbe..badc024058 100644 --- a/plugins/DBStats/DBStats.php +++ b/plugins/DBStats/DBStats.php @@ -43,7 +43,7 @@ class DBStats extends \Piwik\Plugin Piwik_AddAdminSubMenu('CoreAdminHome_MenuDiagnostic', 'DBStats_DatabaseUsage', array('module' => 'DBStats', 'action' => 'index'), Piwik::isUserIsSuperUser(), - $order = 9); + $order = 6); } /** diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php index cd4786f090..f3be3b18be 100644 --- a/plugins/ImageGraph/StaticGraph.php +++ b/plugins/ImageGraph/StaticGraph.php @@ -16,6 +16,7 @@ use Piwik\Loader; use Piwik\Plugins\ImageGraph\API; use pData; use pImage; +use Piwik\SettingsPiwik; require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pDraw.class.php"; require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pImage.class.php"; @@ -243,6 +244,8 @@ abstract class StaticGraph protected static function getOutputPath($filename) { $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename; + $outputFilename = SettingsPiwik::rewriteTmpPathWithHostname($outputFilename); + @chmod($outputFilename, 0600); @unlink($outputFilename); return $outputFilename; diff --git a/plugins/Live/templates/getVisitorProfilePopup.twig b/plugins/Live/templates/getVisitorProfilePopup.twig index 55625942d6..678edfd039 100644 --- a/plugins/Live/templates/getVisitorProfilePopup.twig +++ b/plugins/Live/templates/getVisitorProfilePopup.twig @@ -38,10 +38,10 @@ {%- if not loop.first %}, {% endif -%}{{- totalConversions }} <span class="visitor-profile-goal-name">{{ goals[idGoal]['name'] -}}</span> {%- endfor -%} ){% endif %}.</p> - {% if visitorData.totalEcommerceConversions is defined or visitorData.totalAbandonedCarts is defined %} + {% if visitorData.totalEcommerceConversions|default(0) > 0 or visitorData.totalAbandonedCarts|default(0) > 0%} <p> {{ 'Goals_Ecommerce'|translate }}: - {%- if visitorData.totalEcommerceConversions is defined %} {{ 'Live_EcommerceSummaryConversions'|translate('<strong>', visitorData.totalEcommerceConversions, visitorData.totalEcommerceRevenue|money(idSite), '</strong>', visitorData.totalEcommerceItems)|raw }} + {%- if visitorData.totalEcommerceConversions|default(0) > 0 %} {{ 'Live_EcommerceSummaryConversions'|translate('<strong>', visitorData.totalEcommerceConversions, visitorData.totalEcommerceRevenue|money(idSite), '</strong>', visitorData.totalEcommerceItems)|raw }} {%- endif -%} {%- if visitorData.totalAbandonedCarts|default(0) > 0 %} {{ 'Live_AbandonedCartSummary'|translate('<strong>', visitorData.totalAbandonedCarts, '</strong>', visitorData.totalAbandonedCartsItems, '<strong>', visitorData.totalAbandonedCartsRevenue|money(idSite), '</strong>')|raw }}{%- endif -%} </p> diff --git a/plugins/PDFReports/config/tcpdf_config.php b/plugins/PDFReports/config/tcpdf_config.php index f9b2de9a6f..3662df3099 100644 --- a/plugins/PDFReports/config/tcpdf_config.php +++ b/plugins/PDFReports/config/tcpdf_config.php @@ -16,8 +16,12 @@ */ define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/'); -define('K_PATH_CACHE', PIWIK_USER_PATH . '/tmp/tcpdf/'); -define('K_PATH_IMAGES', PIWIK_USER_PATH . '/tmp/tcpdf/'); + +$pathTmpTCPDF = PIWIK_USER_PATH . '/tmp/tcpdf/'; +$pathTmpTCPDF = \Piwik\SettingsPiwik::rewriteTmpPathWithHostname($pathTmpTCPDF); + +define('K_PATH_CACHE', $pathTmpTCPDF); +define('K_PATH_IMAGES', $pathTmpTCPDF); if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { diff --git a/tests/PHPUnit/Core/LogTest.php b/tests/PHPUnit/Core/LogTest.php index 1ae78c63a3..e3c3cde4ae 100644 --- a/tests/PHPUnit/Core/LogTest.php +++ b/tests/PHPUnit/Core/LogTest.php @@ -65,7 +65,7 @@ dummy backtrace' parent::setUp(); Config::getInstance()->log['string_message_format'] = self::STRING_MESSAGE_FORMAT; - Config::getInstance()->log['logger_file_path'] = self::getLogFileLocation(); + Config::getInstance()->log['logger_file_path'] = self::getDefaultLogFileLocation(); @unlink(self::getLogFileLocation()); Log::clearInstance(); Error::$debugBacktraceForTests = ExceptionHandler::$debugBacktraceForTests = "dummy backtrace"; @@ -258,6 +258,15 @@ dummy backtrace' public static function getLogFileLocation() { - return PIWIK_INCLUDE_PATH . '/tmp/logs/piwik.test.log'; + $path = self::getDefaultLogFileLocation(); + $path = \Piwik\SettingsPiwik::rewriteTmpPathWithHostname($path); + return $path; } + + protected static function getDefaultLogFileLocation() + { + $path = PIWIK_INCLUDE_PATH . '/tmp/logs/piwik.test.log'; + return $path; + } + }
\ No newline at end of file diff --git a/tests/PHPUnit/Core/ServeStaticFileTest.php b/tests/PHPUnit/Core/ServeStaticFileTest.php index 40a65b02da..0776f1c9aa 100644 --- a/tests/PHPUnit/Core/ServeStaticFileTest.php +++ b/tests/PHPUnit/Core/ServeStaticFileTest.php @@ -477,7 +477,8 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase private function getCompressedFileLocation() { - return PIWIK_PATH_TEST_TO_ROOT . Piwik::COMPRESSED_FILE_LOCATION . basename(TEST_FILE_LOCATION); + $path = PIWIK_PATH_TEST_TO_ROOT . \Piwik\AssetManager::COMPRESSED_FILE_LOCATION . basename(TEST_FILE_LOCATION); + return \Piwik\SettingsPiwik::rewriteTmpPathWithHostname($path); } private function removeCompressedFiles() diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI -Subproject a209d62a45911770c655f879f546a15348bdcaf +Subproject 8b7ead59986b18d2bbc4e0fd097838e5237490f diff --git a/tests/travis/prepare.sh b/tests/travis/prepare.sh index 8ba216da70..93bed0daf7 100755 --- a/tests/travis/prepare.sh +++ b/tests/travis/prepare.sh @@ -30,8 +30,8 @@ fi mkdir ./tmp/assets mkdir ./tmp/cache mkdir ./tmp/latest +mkdir ./tmp/logs mkdir ./tmp/sessions mkdir ./tmp/templates_c mkdir ./tmp/tcpdf -mkdir ./tmp/logs chmod a+rw ./tests/lib/geoip-files |