[Piwik-svn] r149 - in trunk: modules modules/API modules/DataTable plugins plugins/Installation tests/modules
svnmaster at piwik.org
svnmaster at piwik.org
Sat Jan 12 04:20:03 CET 2008
Author: matt
Date: 2008-01-12 04:20:02 +0100 (Sat, 12 Jan 2008)
New Revision: 149
Modified:
trunk/modules/API/Request.php
trunk/modules/Common.php
trunk/modules/DataTable/Renderer.php
trunk/modules/Piwik.php
trunk/modules/PluginsManager.php
trunk/modules/Translate.php
trunk/plugins/Installation.php
trunk/plugins/Installation/Controller.php
trunk/plugins/Installation/FormFirstWebsiteSetup.php
trunk/tests/modules/Common.test.php
trunk/tests/modules/Piwik.test.php
Log:
- fixed bugs here and there after all these modifications, some side effects on the installation process + tracking module piwik.php
Modified: trunk/modules/API/Request.php
===================================================================
--- trunk/modules/API/Request.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/API/Request.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -182,6 +182,12 @@
// NB: null value is already handled by the isset() test above
else
{
+ // original data structure requested, we return without process
+ if( $outputFormatRequested == 'original' )
+ {
+ return $toReturn;
+ }
+
if( $toReturn === true )
{
$toReturn = 'true';
Modified: trunk/modules/Common.php
===================================================================
--- trunk/modules/Common.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/Common.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -552,7 +552,21 @@
}
return $nameToValue;
}
-
+
+ /**
+ * Returns true if the string is a valid filename
+ * File names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), and dot(.) will be accepted.
+ * File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example).
+ * File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
+ *
+ * @param string filename
+ * @return bool
+ *
+ */
+ static public function isValidFilename($filename)
+ {
+ return (false !== ereg("(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$" , $filename));
+ }
}
Modified: trunk/modules/DataTable/Renderer.php
===================================================================
--- trunk/modules/DataTable/Renderer.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/DataTable/Renderer.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -53,7 +53,7 @@
$path = PIWIK_INCLUDE_PATH . "/modules/DataTable/Renderer/".$name.".php";
$className = 'Piwik_DataTable_Renderer_' . $name;
- if( Piwik::isValidFilename($name)
+ if( Piwik_Common::isValidFilename($name)
&& is_file($path)
)
{
Modified: trunk/modules/Piwik.php
===================================================================
--- trunk/modules/Piwik.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/Piwik.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -735,22 +735,8 @@
{
return (preg_match('/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]{2,4}$/', $email) > 0);
}
-
- /**
- * Returns true if the string is a valid filename
- * File names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), and dot(.) will be accepted.
- * File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example).
- * File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
- *
- * @param string filename
- * @return bool
- *
- */
- static public function isValidFilename($filename)
- {
- return (false !== ereg("(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$" , $filename));
- }
+
static public function createTables()
{
$db = Zend_Registry::get('db');
Modified: trunk/modules/PluginsManager.php
===================================================================
--- trunk/modules/PluginsManager.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/PluginsManager.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -102,7 +102,7 @@
$pluginFileName = $pluginName . ".php";
$pluginClassName = "Piwik_".$pluginName;
- if( !Piwik::isValidFilename($pluginName))
+ if( !Piwik_Common::isValidFilename($pluginName))
{
throw new Exception("The plugin filename '$pluginFileName' is not valid");
}
Modified: trunk/modules/Translate.php
===================================================================
--- trunk/modules/Translate.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/modules/Translate.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -44,7 +44,7 @@
{
$language = Zend_Registry::get('config')->Language->current;
- if( Piwik::isValidFilename($language))
+ if( Piwik_Common::isValidFilename($language))
{
return $language;
}
Modified: trunk/plugins/Installation/Controller.php
===================================================================
--- trunk/plugins/Installation/Controller.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/plugins/Installation/Controller.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -232,7 +232,7 @@
// API authentication process
Zend_Registry::get('config')->superuser = $_SESSION['superuser_infos'];
- $name = urlencode($form->getSubmitValue('name'));
+ $name = urlencode($form->getSubmitValue('siteName'));
$url = urlencode($form->getSubmitValue('url'));
$this->initObjectsToCallAPI();
@@ -240,7 +240,7 @@
require_once "API/Request.php";
$request = new Piwik_API_Request("
method=SitesManager.addSite
- &name=$name
+ &siteName=$name
&urls=$url
&format=original
");
Modified: trunk/plugins/Installation/FormFirstWebsiteSetup.php
===================================================================
--- trunk/plugins/Installation/FormFirstWebsiteSetup.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/plugins/Installation/FormFirstWebsiteSetup.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -10,7 +10,7 @@
$javascriptOnClickUrlExample = "\"javascript:if(this.value=='$urlExample'){this.value='http://';} this.style.color='black';\"";
$formElements = array(
- array('text', 'name', 'website name'),
+ array('text', 'siteName', 'website name'),
array('text', 'url', 'website URL', "style='color:rgb(153, 153, 153);' value=$urlExample onfocus=".$javascriptOnClickUrlExample." onclick=".$javascriptOnClickUrlExample),
);
$this->addElements( $formElements );
Modified: trunk/plugins/Installation.php
===================================================================
--- trunk/plugins/Installation.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/plugins/Installation.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -59,7 +59,7 @@
{
Piwik::exitWithErrorMessage("
The Piwik configuration file couldn't be found and you are trying to access a Piwik page.<br>
- <b> » You can <a href='index.php'>install Piwik now</a></b>
+ <b> » You can <a href='index.php'>install Piwik now</a></b>
<br><small>If you installed Piwik before and have some tables in your DB, don't worry,
you can reuse the same tables and keep your existing data!</small>");
}
Modified: trunk/tests/modules/Common.test.php
===================================================================
--- trunk/tests/modules/Common.test.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/tests/modules/Common.test.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -409,6 +409,31 @@
$expectedResult = 'ÐоиÑк в ÐнÑеÑнеÑе ÐоиÑк ÑÑÑÐ°Ð½Ð¸Ñ Ð½Ð° ÑÑÑÑком _*()!$!£$^!£$%';
$expectedResult = htmlentities($expectedResult);
$this->assertEqual($result, $expectedResult);
- }
+ }
+
+
+ public function test_isValidFilenameValidValues()
+ {
+
+ $valid = array(
+ "test", "test.txt","test.......", "en-ZHsimplified",
+ );
+ foreach($valid as $toTest)
+ {
+ $this->assertTrue(Piwik_Common::isValidFilename($toTest), $toTest." not valid!");
+ }
+ }
+ public function test_isValidFilenameNotValidValues()
+ {
+
+ $notvalid = array(
+ "../test", "/etc/htpasswd", '$var', ';test', '[bizarre]', '', ".htaccess", "very long long eogaioge ageja geau ghaeihieg heiagie aiughaeui hfilename",
+ );
+ foreach($notvalid as $toTest)
+ {
+ $this->assertFalse(Piwik_Common::isValidFilename($toTest), $toTest." valid but shouldn't!");
+ }
+ }
+
}
Modified: trunk/tests/modules/Piwik.test.php
===================================================================
--- trunk/tests/modules/Piwik.test.php 2008-01-12 02:51:17 UTC (rev 148)
+++ trunk/tests/modules/Piwik.test.php 2008-01-12 03:20:02 UTC (rev 149)
@@ -50,29 +50,6 @@
}
}
- public function test_isValidFilenameValidValues()
- {
-
- $valid = array(
- "test", "test.txt","test.......", "en-ZHsimplified",
- );
- foreach($valid as $toTest)
- {
- $this->assertTrue(Piwik::isValidFilename($toTest), $toTest." not valid!");
- }
- }
- public function test_isValidFilenameNotValidValues()
- {
-
- $notvalid = array(
- "../test", "/etc/htpasswd", '$var', ';test', '[bizarre]', '', ".htaccess", "very long long eogaioge ageja geau ghaeihieg heiagie aiughaeui hfilename",
- );
- foreach($notvalid as $toTest)
- {
- $this->assertFalse(Piwik::isValidFilename($toTest), $toTest." valid but shouldn't!");
- }
- }
-
public function test_secureDiv()
{
$this->assertTrue( Piwik::secureDiv( 9,3 ) === 3 );
More information about the Piwik-svn
mailing list