commit 2312eb0bf32baa6525cae0235c6f8b2e3b0b0ddf
parent aab9aee250cd62fb452110e2851197cd86409714
Author: Felicitus <felicitus@felicitus.org>
Date: Thu, 16 Feb 2012 05:44:14 +0100
Merge branch 'master' of github.com:partkeepr/PartKeepr
Conflicts:
src/setup/tests/check-permissions.php
Diffstat:
3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/build.xml b/build.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="partkeepr" default="test-setup">
+<project name="partkeepr" default="build">
<property file="build.properties" />
<target name="pre-commit">
diff --git a/src/setup/js/SetupWizard.js b/src/setup/js/SetupWizard.js
@@ -90,10 +90,10 @@ Ext.define('PartKeeprSetup.SetupWizard', {
bodyStyle: 'background:none;',
autoScroll: true,
html: "Please set up the following cronjobs:<br/><br/><code>"+
- "0 0,12 * * * /usr/bin/php <path-to-partkeepr>/CreateStatisticSnapshot.php<br/>"+
- "0 0,6,12,18 * * * /usr/bin/php <path-to-partkeepr>/UpdatePartCacheData.php<br/>"+
- "0 0 */2 * * /usr/bin/php <path-to-partkeepr>/CheckForUpdates.php<br/>"+
- "0 0 */2 * * /usr/bin/php <path-to-partkeepr>/UpdateTipsOfTheDay.php<br/>"+
+ "0 0,12 * * * /usr/bin/php <path-to-partkeepr>/cronjobs/CreateStatisticSnapshot.php<br/>"+
+ "0 0,6,12,18 * * * /usr/bin/php <path-to-partkeepr>/cronjobs/UpdatePartCacheData.php<br/>"+
+ "0 0 */2 * * /usr/bin/php <path-to-partkeepr>/cronjobs/CheckForUpdates.php<br/>"+
+ "0 0 */2 * * /usr/bin/php <path-to-partkeepr>/cronjobs/UpdateTipsOfTheDay.php<br/>"+
"</code><br/>If you cannot run cronjobs (e.g. you are on Windows), you can disable the "+
"cronjobs by adding the following line to your config.php file:<br/><br/>"+
'<code>Configuration::setOption("partkeepr.cronjobs.disablecheck", true);</code>'
diff --git a/src/setup/tests/check-permissions.php b/src/setup/tests/check-permissions.php
@@ -1,11 +1,17 @@
<?php
$dataDir = dirname(dirname(dirname(__FILE__)))."/data";
-if (!is_writable_recursive($dataDir)) {
- echo json_encode(array("error" => true, "message" => "The directory /data is not writable<br/>Please adjust the filesystem permissions so that your webserver can write into that directory."));
+try {
+ is_writable_recursive($dataDir);
+} catch (\Exception $e) {
+ echo json_encode(array("error" => true, "errormessage" => $e->getMessage() . "<br/>Please adjust the filesystem permissions so that your webserver can write into that directory."));
exit;
}
+/**
+ * Checks if the given directory and all contained files within it is writable by the current user.
+ * @param string $dir The directory to check
+ */
function is_writable_recursive($dir)
{
if (!is_writable($dir)) {
@@ -14,18 +20,17 @@ function is_writable_recursive($dir)
$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;
+ if($file != '.' && $file != '..') {
+ if (!is_writable( $dir."/".$file )) {
+ closedir($folder);
+ throw new \Exception($dir."/".$file." is not writable.");
+ } else {
+ if (is_dir($dir."/".$file)) {
+ if (!is_writable_recursive($dir."/".$file)) {
+ closedir($folder);
+ throw new \Exception($dir."/".$file." is not writable.");
}
}
-
}
}
}