Working on web admin

This commit is contained in:
Jérôme Schneider 2012-04-25 14:09:22 +02:00
parent 0333e937ed
commit 14ac8dbf01
4 changed files with 65 additions and 7 deletions

View file

@ -106,6 +106,7 @@ $sDirName = appendSlash(dirname($sScript));
$sBaseUrl = appendSlash(substr($sDirName, 0, -1 * strlen(BAIKAL_CONTEXT_BASEURI))); $sBaseUrl = appendSlash(substr($sDirName, 0, -1 * strlen(BAIKAL_CONTEXT_BASEURI)));
$aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]); $aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]);
$sProtocol = strtolower(array_shift($aParts)); $sProtocol = strtolower(array_shift($aParts));
define("BAIKAL_BASEURI", $sBaseUrl);
define("BAIKAL_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl); define("BAIKAL_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl);
unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts); unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts);
@ -136,11 +137,8 @@ if(
if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) { if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
installTool(); installTool();
} }
# Check that DB exists \Baikal\Core\Tools::assertEnvironmentIsOk();
if(!file_exists(BAIKAL_SQLITE_FILE)) {
die("DB file does not exist.<br />To create it, please copy '<b>Core/Resources/baikal.empty.sqlite</b>' to '<b>Specific/db/baikal.sqlite</b>'.<br /><span style='color: red; font-weight: bold'>Please note the change in the file name while doing so</span> (from 'baikal.empty.sqlite' to 'baikal.sqlite').");
}
# Database # Database
$pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE); $pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE);

View file

@ -31,6 +31,54 @@ class Tools {
return $GLOBALS["pdo"]; 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() { public static function getUsers() {
$aUsers = array(); $aUsers = array();

View file

@ -36,10 +36,10 @@ class System extends \Baikal\Model\Config {
"type" => "string", "type" => "string",
), ),
"BAIKAL_CARD_BASEURI" => array( "BAIKAL_CARD_BASEURI" => array(
"type" => "string", "type" => "litteral",
), ),
"BAIKAL_CAL_BASEURI" => array( "BAIKAL_CAL_BASEURI" => array(
"type" => "string", "type" => "litteral",
), ),
"BAIKAL_SQLITE_FILE" => array( "BAIKAL_SQLITE_FILE" => array(
"type" => "litteral", "type" => "litteral",

12
html/.htaccess Normal file
View file

@ -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)
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>