From 081e26813c8c831a8a69c8aaf067ecf8c50f3bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 25 Apr 2012 14:09:22 +0200 Subject: [PATCH] Working on web admin Former-commit-id: 14ac8dbf01b3a0db4e8c8456b290ef95be093470 --- .../Frameworks/Baikal/Core/Bootstrap.php | 8 ++-- .../Frameworks/Baikal/Core/Tools.php | 48 +++++++++++++++++++ .../Frameworks/Baikal/Model/Config/System.php | 4 +- html/.htaccess | 12 +++++ 4 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 html/.htaccess diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php index b48da1f..9059325 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php @@ -106,6 +106,7 @@ $sDirName = appendSlash(dirname($sScript)); $sBaseUrl = appendSlash(substr($sDirName, 0, -1 * strlen(BAIKAL_CONTEXT_BASEURI))); $aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]); $sProtocol = strtolower(array_shift($aParts)); +define("BAIKAL_BASEURI", $sBaseUrl); define("BAIKAL_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl); unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts); @@ -136,11 +137,8 @@ if( if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) { installTool(); } - - # Check that DB exists - if(!file_exists(BAIKAL_SQLITE_FILE)) { - die("DB file does not exist.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (from 'baikal.empty.sqlite' to 'baikal.sqlite')."); - } + + \Baikal\Core\Tools::assertEnvironmentIsOk(); # Database $pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php index 616d194..ce879cd 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php @@ -31,6 +31,54 @@ class Tools { return $GLOBALS["pdo"]; } + public static function assertEnvironmentIsOk() { + + # Asserting DB file exists + if(!file_exists(BAIKAL_SQLITE_FILE)) { + throw new \Exception("DB file does not exist. To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'."); + } + + # Asserting DB file is readable + if(!is_readable(BAIKAL_SQLITE_FILE)) { + throw new \Exception("DB file is not readable. Please give read permissions to httpd user on file 'Specific/db/baikal.sqlite'."); + } + + # Asserting DB file is writable + if(!is_writable(BAIKAL_SQLITE_FILE)) { + throw new \Exception("DB file is not writable. Please give write permissions to httpd user on file 'Specific/db/baikal.sqlite'."); + } + + # Asserting config file exists + if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.php")) { + throw new \Exception("Specific/config.php does not exist. Please use the Install tool to create it."); + } + + # Asserting config file is readable + if(!is_readable(BAIKAL_PATH_SPECIFIC . "config.php")) { + throw new \Exception("Specific/config.php is not readable. Please give read permissions to httpd user on file 'Specific/config.php'."); + } + + # Asserting config file is writable + if(!is_writable(BAIKAL_PATH_SPECIFIC . "config.php")) { + throw new \Exception("Specific/config.php is not writable. Please give write permissions to httpd user on file 'Specific/config.php'."); + } + + # Asserting system config file exists + if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")) { + throw new \Exception("Specific/config.system.php does not exist. Please use the Install tool to create it."); + } + + # Asserting system config file is readable + if(!is_readable(BAIKAL_PATH_SPECIFIC . "config.system.php")) { + throw new \Exception("Specific/config.system.php is not readable. Please give read permissions to httpd user on file 'Specific/config.system.php'."); + } + + # Asserting system config file is writable + if(!is_writable(BAIKAL_PATH_SPECIFIC . "config.system.php")) { + throw new \Exception("Specific/config.system.php is not writable. Please give write permissions to httpd user on file 'Specific/config.system.php'."); + } + } + public static function getUsers() { $aUsers = array(); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php index 2d0c1e5..859bdba 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php @@ -36,10 +36,10 @@ class System extends \Baikal\Model\Config { "type" => "string", ), "BAIKAL_CARD_BASEURI" => array( - "type" => "string", + "type" => "litteral", ), "BAIKAL_CAL_BASEURI" => array( - "type" => "string", + "type" => "litteral", ), "BAIKAL_SQLITE_FILE" => array( "type" => "litteral", diff --git a/html/.htaccess b/html/.htaccess new file mode 100644 index 0000000..284cb25 --- /dev/null +++ b/html/.htaccess @@ -0,0 +1,12 @@ +# Disabling URL rewrite and cache management +# that could cause problems with DAV requests +# Useful only for Apache servers, with AllowOverride All +# (ie, .htaccess files enabled) + + + RewriteEngine Off + + + + ExpiresActive Off + \ No newline at end of file