mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-16 11:27:01 +00:00
feat(config): WIP implement config.ini validator
This commit is contained in:
parent
c6cbed680f
commit
b550efae1f
2 changed files with 44 additions and 0 deletions
|
|
@ -40,6 +40,8 @@ $routes = [
|
||||||
'/post/([a-zA-Z0-9]{7})' => 'post.php', // matches only twtHash of exactly 7 alphanumeric characters
|
'/post/([a-zA-Z0-9]{7})' => 'post.php', // matches only twtHash of exactly 7 alphanumeric characters
|
||||||
'/upload' => 'upload_img.php',
|
'/upload' => 'upload_img.php',
|
||||||
'/webmention' => 'webmention_endpoint.php',
|
'/webmention' => 'webmention_endpoint.php',
|
||||||
|
|
||||||
|
'/admin/config-checker' => 'admin/config_checker.php',
|
||||||
//'/thumb' => 'thumb.php',
|
//'/thumb' => 'thumb.php',
|
||||||
//'/profile/([a-zA-Z0-9_-]+)' => 'profile.php',
|
//'/profile/([a-zA-Z0-9_-]+)' => 'profile.php',
|
||||||
|
|
||||||
|
|
|
||||||
42
views/admin/config_checker.php
Normal file
42
views/admin/config_checker.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function validateConfig($configFile, $templateFile) {
|
||||||
|
$config = parse_ini_file($configFile);
|
||||||
|
$template = parse_ini_file($templateFile);
|
||||||
|
|
||||||
|
$configKeys = array_keys($config);
|
||||||
|
$templateKeys = array_keys($template);
|
||||||
|
|
||||||
|
$missingKeys = array_diff($templateKeys, $configKeys);
|
||||||
|
$extraKeys = array_diff($configKeys, $templateKeys);
|
||||||
|
|
||||||
|
$configIsCorrect = true;
|
||||||
|
if (!empty($missingKeys)) {
|
||||||
|
echo "Missing keys: " . implode(', ', $missingKeys) . "\n";
|
||||||
|
$configIsCorrect = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($extraKeys)) {
|
||||||
|
echo "Extra keys: " . implode(', ', $extraKeys) . "\n";
|
||||||
|
$configIsCorrect = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($configIsCorrect) {
|
||||||
|
echo "Config file $configFile looks OK.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$configFile = 'private/config.ini';
|
||||||
|
$templateFile = 'private/config_template.ini';
|
||||||
|
|
||||||
|
if (!file_exists($configFile)) {
|
||||||
|
echo "Config file $configFile not found.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($templateFile)) {
|
||||||
|
echo "Template file $templateFile not found.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
validateConfig($configFile, $templateFile);
|
||||||
Loading…
Reference in a new issue