/**
  * check whether the froxlor database and its tables are in utf-8 character-set
  *
  * @param bool $fix fix db charset/collation if not utf8
  *
  * @return boolean
  */
 public function DatabaseCharset($fix = false)
 {
     // get characterset
     $cs_stmt = Database::prepare('SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = :dbname');
     $resp = Database::pexecute_first($cs_stmt, array('dbname' => Database::getDbName()));
     $charset = isset($resp['default_character_set_name']) ? $resp['default_character_set_name'] : null;
     if (!empty($charset) && strtolower($charset) != 'utf8') {
         $this->_log->logAction(ADM_ACTION, LOG_NOTICE, "database charset seems to be different from UTF-8, integrity-check can fix that");
         if ($fix) {
             // fix database
             Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
             // fix all tables
             $handle = Database::query('SHOW TABLES');
             while ($row = $handle->fetch(PDO::FETCH_ASSOC)) {
                 foreach ($row as $table) {
                     Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
                 }
             }
             $this->_log->logAction(ADM_ACTION, LOG_WARNING, "database charset was different from UTF-8, integrity-check fixed that");
         } else {
             return false;
         }
     }
     if ($fix) {
         return $this->DatabaseCharset();
     }
     return true;
 }
Example #2
0
    if (Settings::Get('panel.default_theme') == 'Classic') {
        $upd_stmt = Database::prepare("\n\t\t\tUPDATE `" . TABLE_PANEL_SETTINGS . "` SET\n\t\t\t\t`value` = :theme\n\t\t\tWHERE `varname` = 'default_theme';");
        Database::pexecute($upd_stmt, array('theme' => $classic_theme_replacement));
    }
    // Updating admin's theme setting
    $upd_stmt = Database::prepare("\n\t\t\tUPDATE `" . TABLE_PANEL_ADMINS . "` SET\n\t\t\t\t`theme` = :theme\n\t\t\tWHERE `theme` = 'Classic';");
    Database::pexecute($upd_stmt, array('theme' => $classic_theme_replacement));
    // Updating customer's theme setting
    $upd_stmt = Database::prepare("\n\t\t\tUPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET\n\t\t\t\t`theme` = :theme\n\t\t\tWHERE `theme` = 'Classic';");
    Database::pexecute($upd_stmt, array('theme' => $classic_theme_replacement));
    // Updating theme setting of active sessions
    $upd_stmt = Database::prepare("\n\t\t\tUPDATE `" . TABLE_PANEL_SESSIONS . "` SET\n\t\t\t\t`theme` = :theme\n\t\t\tWHERE `theme` = 'Classic';");
    Database::pexecute($upd_stmt, array('theme' => $classic_theme_replacement));
    lastStepStatus(0);
    showUpdateStep('Altering Froxlor database and tables to use UTF-8. This may take a while..', true);
    Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
    $handle = Database::query('SHOW TABLES');
    while ($row = $handle->fetch(PDO::FETCH_ASSOC)) {
        foreach ($row as $table) {
            Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
        }
    }
    lastStepStatus(0);
    updateToVersion('0.9.28-svn4');
}
if (isFroxlorVersion('0.9.28-svn4')) {
    showUpdateStep("Updating from 0.9.28-svn4 to 0.9.28-svn5");
    // Catchall functionality (enabled by default) see #1114
    showUpdateStep('Enabling catchall by default');
    Database::query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('catchall', 'catchall_enabled', '1');");
    lastStepStatus(0);