mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
add utility to edit settings from command line (not bundled in release archive)
This commit is contained in:
parent
876b8297e7
commit
a5bf61e176
2 changed files with 49 additions and 0 deletions
|
|
@ -51,6 +51,8 @@ fclose($fh);
|
|||
|
||||
unlink('./docker-config.php');
|
||||
unlink('./content/lang/en-rtl.json');
|
||||
unlink('./mtt-edit-settings.php');
|
||||
|
||||
/*
|
||||
# save only 2 languages
|
||||
$dh = opendir('./content/lang/') or die("Cant opendir lang\n");
|
||||
|
|
|
|||
47
src/mtt-edit-settings.php
Normal file
47
src/mtt-edit-settings.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
if ( !isset($argv) || !isset($argc) || isset($_SERVER['REMOTE_ADDR']) ) {
|
||||
die("Run from command line only!");
|
||||
}
|
||||
if ( $argc < 3 ) {
|
||||
die("Usage:\n".
|
||||
" mtt-edit-settings.php read <parameter> \n".
|
||||
" mtt-edit-settings.php write <parameter> <value>\n".
|
||||
" mtt-edit-settings.php password <password>\n"
|
||||
);
|
||||
}
|
||||
|
||||
$dontStartSession = true;
|
||||
require_once(__DIR__ . '/init.php');
|
||||
|
||||
$cmd = $argv[1];
|
||||
$param = $argv[2];
|
||||
$value = $argc > 3 ? $argv[3] : null;
|
||||
|
||||
|
||||
switch ($cmd) {
|
||||
case 'read': cmd_read($param, $value); break;
|
||||
case 'write': cmd_write($param, $value); break;
|
||||
case 'password': cmd_password($param); break;
|
||||
default: die("Unknown command: $cmd\n");
|
||||
}
|
||||
|
||||
|
||||
function cmd_read($param) {
|
||||
print Config::get($param) . "\n";
|
||||
}
|
||||
|
||||
function cmd_write($param, $value) {
|
||||
if ($value === null) {
|
||||
die("Can not write '$param': value is not specified\n");
|
||||
}
|
||||
print ("Set '$param' to '$value'\n");
|
||||
Config::set($param, $value);
|
||||
Config::save();
|
||||
print ("Done!\n");
|
||||
}
|
||||
|
||||
function cmd_password($value) {
|
||||
$value = passwordHash($value);
|
||||
cmd_write('password', $value);
|
||||
}
|
||||
Loading…
Reference in a new issue