Select Git revision
check-config.php
check-config.php 7.36 KiB
<?php
/* ######################################################################
IML DEPLOYMENT
CONFIG CHECKER for new setups
---------------------------------------------------------------------
2017-12-01 Axel <axel.hahn@iml.unibe.ch>
###################################################################### */
// ----------------------------------------------------------------------
// functions
// ----------------------------------------------------------------------
/**
* get html code to draw a colored box
* @param string $s message
* @param string $sClass css class; one of ok|info|error
* @return string
*/
function drawbox($s, $sClass) {
return '<div class="box ' . $sClass . '">' . $s . '</div>';
}
/**
* show an alert box with error message
* @param type $s
* @return type
*/
function showerror($s) {
return drawbox($s, 'error');
}
/**
* show green box with ok message
* @param type $s
* @return type
*/
function showok($s) {
return drawbox($s, 'ok');
}
/**
* check a directory if it exists and is writtable
* @global array $aErrors found errors
* @param string $sDir directory to check
* @param string $sKey key in config (for output only)
* @return boolean
*/
function checkdir($sDir, $sKey = false) {
global $aErrors;
echo 'check directory [' . $sDir . '] ';
if (!is_dir($sDir)) {
echo '<span class="error">does not exist</span><br>';
$aErrors[] = "* \$aConfig['$sKey'] points to a non existing directory (" . $sDir . ").\n";
return false;
} else {
if (!is_writable($sDir)) {
echo '<span class="error">not writable</span><br>';
$aErrors[] = "* \$aConfig['$sKey'] = " . $sDir . " is NOT writable.\n";
return false;
} else {
echo '<span class="ok">OK</span> exists and is writable<br>';
return true;
}
}