[Piwik-svn] r533 - trunk/modules
svnmaster at piwik.org
svnmaster at piwik.org
Fri Jun 27 01:41:27 CEST 2008
Author: matt
Date: 2008-06-27 01:41:26 +0200 (Fri, 27 Jun 2008)
New Revision: 533
Modified:
trunk/modules/Config.php
trunk/modules/FrontController.php
trunk/modules/Piwik.php
Log:
- config directory should be writable only when making configuration changes
Modified: trunk/modules/Config.php
===================================================================
--- trunk/modules/Config.php 2008-06-26 23:08:14 UTC (rev 532)
+++ trunk/modules/Config.php 2008-06-26 23:41:26 UTC (rev 533)
@@ -33,7 +33,6 @@
protected $urlToPiwikHelpMissingValueInConfigurationFile =
'http://dev.piwik.org/trac/browser/trunk/config/global.ini.php?format=raw';
-
protected $defaultConfig = null;
protected $userConfig = null;
protected $pathIniFileUserConfig = null;
@@ -97,22 +96,16 @@
*/
function __destruct()
{
- // saves the config file if changed
if($this->configFileUpdated === true
&& $this->doWriteFileWhenUpdated === true)
{
-
$configFile = "; <?php exit; ?> DO NOT REMOVE THIS LINE\n";
$configFile .= "; file automatically generated during the piwik installation process (and updated later by some other modules)\n";
foreach($this->userConfig as $section => $arraySection)
{
$arraySection = $arraySection->toArray();
-// print("<pre>saving $section => ".var_export($arraySection,true)." <br>");
-
$configFile .= "[$section]\n";
- //echo "array section"; var_dump($arraySection);
-
foreach($arraySection as $name => $value)
{
if(is_numeric($name))
@@ -130,8 +123,7 @@
}
else
{
- // hack
- // we add " " around the password because when requesting this data using Zend_Config
+ // hack: we add " " around the password because when requesting this data using Zend_Config
// the toArray removes the " around the value
if( ($section == 'database' || $section == 'database_tests')
&& $name == 'password')
@@ -174,6 +166,7 @@
*/
public function __set($name, $value)
{
+ $this->checkWritePermissionOnFile();
if(!is_null($this->userConfig))
{
if($this->userConfig->$name != $value)
@@ -188,6 +181,21 @@
}
}
+ protected function checkWritePermissionOnFile()
+ {
+ static $enoughPermission = null;
+
+ if(is_null($enoughPermission))
+ {
+ if($this->doWriteFileWhenUpdated)
+ {
+ Piwik_FrontController::checkDirectoriesWritableOrDie(array( $this->getDefaultUserConfigPath()) );
+ }
+ $enoughPermission = true;
+ }
+ return $enoughPermission;
+ }
+
/**
* Called when getting a configuration value, eg. Zend_Registry::get('config')->superuser->login
*
@@ -212,6 +220,4 @@
<br>Try to replace your default configuration file ({$this->pathIniFileDefaultConfig}) with
the <a href='".$this->urlToPiwikHelpMissingValueInConfigurationFile."'>default piwik configuration file</a> ");
}
-
}
-
Modified: trunk/modules/FrontController.php
===================================================================
--- trunk/modules/FrontController.php 2008-06-26 23:08:14 UTC (rev 532)
+++ trunk/modules/FrontController.php 2008-06-26 23:41:26 UTC (rev 533)
@@ -199,9 +199,9 @@
*
* @return void
*/
- protected function checkDirectoriesWritableOrDie()
+ static public function checkDirectoriesWritableOrDie( $directoriesToCheck = null )
{
- $resultCheck = Piwik::checkDirectoriesWritable( );
+ $resultCheck = Piwik::checkDirectoriesWritable( $directoriesToCheck );
if( array_search(false, $resultCheck) !== false )
{
$directoryList = '';
@@ -293,9 +293,14 @@
{
Zend_Registry::set('timer', new Piwik_Timer);
- $this->checkDirectoriesWritableOrDie();
+ $directoriesToCheck = array(
+ '/tmp',
+ '/tmp/templates_c',
+ '/tmp/cache',
+ );
- $this->assignCliParametersToRequest();
+ self::checkDirectoriesWritableOrDie($directoriesToCheck);
+ self::assignCliParametersToRequest();
$exceptionToThrow = false;
@@ -313,19 +318,11 @@
{
throw $exceptionToThrow;
}
- // database object
Piwik::createDatabaseObject();
-
- // Create the log objects
Piwik::createLogObject();
-
-
Piwik::terminateLoadPlugins();
-
Piwik::install();
-// Piwik::printMemoryUsage('Start program');
-
// can be used for debug purpose
$doNotDrop = array(
Piwik::prefixTable('access'),
@@ -372,7 +369,7 @@
*
* @return void
*/
- protected function assignCliParametersToRequest()
+ static protected function assignCliParametersToRequest()
{
if(isset($_SERVER['argc'])
&& $_SERVER['argc'] > 0)
Modified: trunk/modules/Piwik.php
===================================================================
--- trunk/modules/Piwik.php 2008-06-26 23:08:14 UTC (rev 532)
+++ trunk/modules/Piwik.php 2008-06-26 23:41:26 UTC (rev 533)
@@ -108,10 +108,9 @@
$resultCheck[$directory] = true;
}
}
-
return $resultCheck;
}
-
+
static public function getJavascriptCode($idSite, $piwikUrl, $actionName = "''")
{
$jsTag = file_get_contents( "modules/LogStats/javascriptTag.tpl");
More information about the Piwik-svn
mailing list