Created
April 29, 2022 21:23
-
-
Save Madydri/bce4706634e2f4a19370cf30b814ee4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// read befor use... | |
$sUnixUser = 'UNIXUSER'; | |
$sDomain = 'DOMAIN.NAME'; | |
// FR here... | |
$sLanguage = 'fr_FR'; | |
$sBasePath = '/home/'.$sUnixUser.'/etc/'.$sDomain.'/'; | |
$aAllFiles = array(); | |
$aAllFiles = scandir($sBasePath); | |
$aDbFiles = array(); | |
$aDbFiles = preg_grep("/^.*\.rcube\.db$/", $aAllFiles); | |
foreach ($aDbFiles as $sOneDbFileName) { | |
echo 'updating Roundcube sqlite db : ', $sBasePath, $sOneDbFileName, PHP_EOL; | |
// backup first | |
copy($sBasePath.$sOneDbFileName, $sBasePath.$sOneDbFileName.'.bak.'.time()); | |
// open | |
$oDb = new SQLite3($sBasePath.$sOneDbFileName, SQLITE3_OPEN_READWRITE); | |
// https://www.php.net/manual/en/sqlite3.exec.php#118837 | |
// WAL mode has better control over concurrency. | |
// Source: https://www.sqlite.org/wal.html | |
$oDb->exec('PRAGMA journal_mode = wal;'); | |
$sSQL = 'UPDATE `users` SET `language`= "'.$sLanguage.'" WHERE 1'; | |
$oDb->exec($sSQL); | |
$oDb->close(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment