partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit e27045d92636296ecb14b19b5f5527503d7ec7f0
parent 325df348a7bfd917572ee28d94ca8f5304b37c63
Author: Felicitus <felicitus@felicitus.org>
Date:   Tue, 20 Dec 2011 05:52:51 +0100

Added filesystem and php settings test

Diffstat:
Msrc/setup/index.html | 2++
Msrc/setup/js/Cards/DatabaseConnectivityTestCard.js | 3+--
Msrc/setup/js/Cards/PrequisitesTestCard.js | 10+++++++++-
Msrc/setup/js/SetupTests/BaseSetupTest.js | 40+++++++++++++++++++++++++++++++++++++++-
Asrc/setup/js/SetupTests/FilesystemPermissionTest.js | 10++++++++++
Asrc/setup/js/SetupTests/PHPSettingsTest.js | 10++++++++++
Asrc/setup/tests/check-permissions.php | 38++++++++++++++++++++++++++++++++++++++
Asrc/setup/tests/check-php-settings.php | 9+++++++++
8 files changed, 118 insertions(+), 4 deletions(-)

diff --git a/src/setup/index.html b/src/setup/index.html @@ -46,6 +46,8 @@ <script type="text/javascript" src="js/SetupTests/PHPPrequisitesTest.js"></script> <script type="text/javascript" src="js/SetupTests/DoctrineTest.js"></script> <script type="text/javascript" src="js/SetupTests/DatabaseConnectivityTest.js"></script> + <script type="text/javascript" src="js/SetupTests/PHPSettingsTest.js"></script> + <script type="text/javascript" src="js/SetupTests/FilesystemPermissionTest.js"></script> <script type="text/javascript" src="js/PartKeeprSetup.js"></script> </head> diff --git a/src/setup/js/Cards/DatabaseConnectivityTestCard.js b/src/setup/js/Cards/DatabaseConnectivityTestCard.js @@ -59,8 +59,8 @@ Ext.define('PartKeeprSetup.DatabaseConnectivityTestCard', { this.runTests(); }, onActivate: function () { - console.log("BAR"); this.ownerCt.ownerCt.nextButton.setDisabled(true); + this.retestButton.hide(); this.runTests(); }, @@ -70,7 +70,6 @@ Ext.define('PartKeeprSetup.DatabaseConnectivityTestCard', { var tests = new Array(); var j = Ext.create("PartKeeprSetup.DatabaseConnectivityTest"); - console.log(Ext.getCmp("database-parameters-card").dbparams); j.params = Ext.getCmp("database-parameters-card").dbparams; j.callback = this.testResultPanel; diff --git a/src/setup/js/Cards/PrequisitesTestCard.js b/src/setup/js/Cards/PrequisitesTestCard.js @@ -59,7 +59,7 @@ Ext.define('PartKeeprSetup.PrequisitesTestCard', { }, onActivate: function () { this.ownerCt.ownerCt.nextButton.setDisabled(true); - + this.retestButton.hide(); this.runTests(); }, runTests: function () { @@ -79,6 +79,14 @@ Ext.define('PartKeeprSetup.PrequisitesTestCard', { j.callback = this.testResultPanel; tests.push(j); + var j = Ext.create("PartKeeprSetup.PHPSettingsTest"); + j.callback = this.testResultPanel; + tests.push(j); + + var j = Ext.create("PartKeeprSetup.FilesystemPermissionTest"); + j.callback = this.testResultPanel; + tests.push(j); + var tr = Ext.create("PartKeeprSetup.TestRunner"); tr.run(tests); tr.on("success", this.onTestSuccessful, this); diff --git a/src/setup/js/SetupTests/BaseSetupTest.js b/src/setup/js/SetupTests/BaseSetupTest.js @@ -1,3 +1,9 @@ +/** + * Represents a test. + * + * Calls a specific PHP file on the server and + * interprets the response. + */ Ext.define('PartKeeprSetup.BaseSetupTest', { extend: 'Ext.util.Observable', @@ -10,9 +16,34 @@ Ext.define('PartKeeprSetup.BaseSetupTest', { * Defines if the call was successful or not. */ success: false, + + /** + * Defines the callback. This needs to be + * an object which implements the "appendTestResult" method. + */ callback: null, + + /** + * Defines the name of this test. + */ name: null, + /** + * Defines additional parameters which are to + * be sent with the request. The format is an object, + * e.g. + * { + * username: "foo", + * password: "bar" + * } + * + * + */ + params: null, + + /** + * Constructs the test + */ constructor: function () { this.addEvents({ "complete" : true @@ -22,7 +53,6 @@ Ext.define('PartKeeprSetup.BaseSetupTest', { * Runs a given test, and processes the response */ run: function () { - console.log(this.params); Ext.Ajax.request({ url: this.url, success: this.onSuccess, @@ -31,6 +61,14 @@ Ext.define('PartKeeprSetup.BaseSetupTest', { }); }, + /** + * Callback for the Ext.Ajax.request method. + * Decodes the response, sets the object + * parameters, fires the "complete" event + * and calls back the test result panel. + * + * @param response + */ onSuccess: function (response) { var obj = Ext.decode(response.responseText); diff --git a/src/setup/js/SetupTests/FilesystemPermissionTest.js b/src/setup/js/SetupTests/FilesystemPermissionTest.js @@ -0,0 +1,9 @@ +/** + * Tests if the filesystem permissions are OK + */ +Ext.define('PartKeeprSetup.FilesystemPermissionTest', { + extend: 'PartKeeprSetup.BaseSetupTest', + url: 'tests/check-permissions.php', + name: "Filesystem", + message: "Testing for proper filesystem permissions" +});+ \ No newline at end of file diff --git a/src/setup/js/SetupTests/PHPSettingsTest.js b/src/setup/js/SetupTests/PHPSettingsTest.js @@ -0,0 +1,9 @@ +/** + * A minimalistic PHP check to make sure PHP is installed on the server and activated as PHP module. + */ +Ext.define('PartKeeprSetup.PHPSettingsTest', { + extend: 'PartKeeprSetup.BaseSetupTest', + url: 'tests/check-php-settings.php', + name: "PHP", + message: "Testing for correct PHP settings" +});+ \ No newline at end of file diff --git a/src/setup/tests/check-permissions.php b/src/setup/tests/check-permissions.php @@ -0,0 +1,37 @@ +<?php +$dataDir = dirname(dirname(dirname(__FILE__)))."/data"; + +if (!is_writable_recursive($dataDir)) { + echo json_encode(array("error" => true, "errormessage" => "The directory /data is not writable<br/>Please adjust the filesystem permissions so that your webserver can write into that directory.")); + exit; +} + +function is_writable_recursive($dir) +{ + if (!is_writable($dir)) { + return false; + } + + $folder = opendir($dir); + while($file = readdir( $folder )) { + if (is_dir($dir."/".$file)) { + if($file != '.' && $file != '..') { + if (!is_writable( $dir."/".$file )) { + closedir($folder); + return false; + } else { + if (!is_writable_recursive($dir."/".$file)) { + closedir($folder); + return false; + } + } + + } + } + } + + return true; +} + +echo json_encode(array("error" => false)); +exit;+ \ No newline at end of file diff --git a/src/setup/tests/check-php-settings.php b/src/setup/tests/check-php-settings.php @@ -0,0 +1,8 @@ +<?php +if (ini_get("safe_mode")) { + echo json_encode(array("error" => true, "errormessage" => "PHP safe_mode is active. This feature is deprecated as of PHP 5.3.0 and causes problems of any kind. Please disable it by setting safe_mode=off in your php.ini file.")); + exit; +} + +echo json_encode(array("error" => false)); +exit;+ \ No newline at end of file