From 5318a90e4a4fddfb7762feb2bb8bc6dc4802fb7d Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 8 May 2008 06:44:22 +0000 Subject: add in functionality to reset db charset also updated the update function to take into account the collation --- admin/system.php | 48 +++++++----------------------- docs/CHANGELOG | 3 ++ lib/class/access.class.php | 2 +- lib/class/dba.class.php | 70 ++++++++++++++++++++++++++++++++++++++++++++ lib/class/update.class.php | 16 +++++++++- lib/gettext.php | 2 +- templates/show_debug.inc.php | 49 +++++++++++++++++++++++++++++-- 7 files changed, 146 insertions(+), 44 deletions(-) diff --git a/admin/system.php b/admin/system.php index 3b338346..52d84b4c 100644 --- a/admin/system.php +++ b/admin/system.php @@ -28,6 +28,7 @@ if (!Access::check('interface',100)) { exit(); } +show_header(); /* Switch on action boys */ switch ($_REQUEST['action']) { @@ -35,57 +36,28 @@ switch ($_REQUEST['action']) { * /config/ampache.cfg to .cfg.dist */ case 'generate_config': + ob_end_clean(); $current = parse_ini_file(Config::get('prefix') . '/config/ampache.cfg.php'); $final = generate_config($current); $browser = new Browser(); $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(Config::get('prefix') . '/config/ampache.cfg.php.dist')); echo $final; - + exit; break; + case 'reset_db_charset': + Dba::reset_db_charset(); + show_confirmation(_('Database Charset Updated'),_('Your Database and assoicated tables have been updated to match your currently configured charset'),'/admin/system.php?action=show_debug'); + break; case 'show_debug': - show_header(); $configuration = Config::get_all(); require_once Config::get('prefix') . '/templates/show_debug.inc.php'; - show_footer(); break; - case 'check_php_settings': - - break; - case 'check_iconv': - - break; - /* Check this version against ampache.org's record */ - case 'check_version': - - - break; - /* Export Catalog to ItunesDB */ - case 'export': - $catalog = new Catalog(); - switch ($_REQUEST['export']) { - case 'itunes': - header("Cache-control: public"); - header("Content-Disposition: filename=itunes.xml"); - header("Content-Type: application/itunes+xml; charset=utf-8"); - echo xml_get_header('itunes'); - echo $catalog->export($_REQUEST['export']); - echo xml_get_footer('itunes'); - break; - default: - $url = conf('web_path') . '/admin/index.php'; - $title = _('Export Failed'); - $body = ''; - show_template('header'); - show_confirmation($title,$body,$url); - show_template('footer'); - break; - } - - break; - default: // Rien a faire break; } // end switch + +show_footer(); + ?> diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 42cc54fc..88f361a2 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.4 + - Add Debug page with current configuration and php state information + as well as links to generate new config file and reset database + charset - Relaxed Charset restrictions on catalog add filename with invalid characters is now a warning, not a fatal error - Fixed lack of loading indication during catalog processes diff --git a/lib/class/access.class.php b/lib/class/access.class.php index 734c7d76..64719141 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -1,7 +1,7 @@ diff --git a/lib/class/update.class.php b/lib/class/update.class.php index e40c9336..1a96b978 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1211,24 +1211,34 @@ class Update { switch (strtoupper(Config::get('site_charset'))) { case 'EUC-KR': $target_charset = 'euckr'; + $target_collation = 'euckr_korean_ci'; break; case 'CP932': $target_charset = 'sjis'; + $target_collation = 'sjis_japanese_ci'; break; case 'KOI8-U': $target_charset = 'koi8u'; + $target_collation = 'koi8u_general_ci'; break; case 'KOI8-R': $target_charset = 'koi8r'; + $target_collation = 'koi8r_general_ci'; break; case 'ISO-8859': $target_charset = 'latin2'; + $target_collation = 'latin2_general_ci'; break; default; case 'UTF-8': $target_charset = 'utf8'; + $target_collation = 'utf8_unicode_ci'; break; } // end mysql charset translation + + // Alter the charset for the entire database + $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $db_results = Dba::query($sql); $sql = "SHOW TABLES"; $db_results = Dba::query($sql); @@ -1238,9 +1248,13 @@ class Update { $sql = "DESCRIBE `" . $row['0'] . "`"; $describe_results = Dba::query($sql); + // Change the tables default charset and colliation + $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $alter_table = Dba::query($sql); + // Itterate through the columns of the table while ($table = Dba::fetch_assoc($describe_results)) { - if (strstr($table['Type'],'varchar')) { + if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) { $sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset; $charset_results = Dba::query($sql); if (!$charset_results) { diff --git a/lib/gettext.php b/lib/gettext.php index 810b9664..083c4919 100644 --- a/lib/gettext.php +++ b/lib/gettext.php @@ -1,7 +1,7 @@ + + ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Open Basedir
+ -- cgit