Skip to content

Instantly share code, notes, and snippets.

@Madydri
Created April 29, 2022 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Madydri/bce4706634e2f4a19370cf30b814ee4c to your computer and use it in GitHub Desktop.
Save Madydri/bce4706634e2f4a19370cf30b814ee4c to your computer and use it in GitHub Desktop.
<?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