summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-08 06:44:22 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-08 06:44:22 +0000
commit5318a90e4a4fddfb7762feb2bb8bc6dc4802fb7d (patch)
treeb5c890628234e42457dbd18f08feae9ca74081f3
parentefd932b9fde167ec1a54809fe5fd9286f29eda2c (diff)
downloadampache-5318a90e4a4fddfb7762feb2bb8bc6dc4802fb7d.tar.gz
ampache-5318a90e4a4fddfb7762feb2bb8bc6dc4802fb7d.tar.bz2
ampache-5318a90e4a4fddfb7762feb2bb8bc6dc4802fb7d.zip
add in functionality to reset db charset also updated the update function to take into account the collation
-rw-r--r--admin/system.php48
-rwxr-xr-xdocs/CHANGELOG3
-rw-r--r--lib/class/access.class.php2
-rw-r--r--lib/class/dba.class.php70
-rw-r--r--lib/class/update.class.php16
-rw-r--r--lib/gettext.php2
-rw-r--r--templates/show_debug.inc.php49
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 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index e9d0304d..6ead8b8b 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -251,6 +251,76 @@ class Dba {
} // auto_init
+ /**
+ * reset_db_charset
+ * This cruises through the database and trys to set the charset to the current
+ * site charset, this is an admin function that can be run by an administrator
+ * this can mess up data if you switch between charsets that are not overlapping
+ * a catalog verify must be re-run to correct them
+ */
+ public static function reset_db_charset() {
+
+ // MySQL translte real charset names into fancy smancy MySQL land names
+ 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);
+
+ // Go through the tables!
+ while ($row = Dba::fetch_row($db_results)) {
+ $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') 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) {
+ debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3');
+ } // if it fails
+ } // if its a varchar
+ } // end columns
+
+ } // end tables
+
+
+ } // reset_db_charset
+
} // dba class
?>
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 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
diff --git a/templates/show_debug.inc.php b/templates/show_debug.inc.php
index f6dbf7c3..62362908 100644
--- a/templates/show_debug.inc.php
+++ b/templates/show_debug.inc.php
@@ -22,11 +22,54 @@
?>
<?php show_box_top(_('Debug Tools')); ?>
<ul>
- <li><a href="<?php echo Config::get('web_path'); ?>/system.php?action=generate_config"><?php echo _('Generate Configuration'); ?></a></li>
- <li><a href="<?php echo Config::get('web_path'); ?>/system.php?action=check_php_settings"><?php echo _('Check PHP Settings'); ?></a></li>
- <li><a href="<?php echo Config::get('web_path'); ?>/system.php?action=check_iconv"><?php echo _('Check Iconv'); ?></a></li>
+ <li><a href="<?php echo Config::get('web_path'); ?>/admin/system.php?action=generate_config"><?php echo _('Generate Configuration'); ?></a></li>
+ <li><a href="<?php echo Config::get('web_path'); ?>/admin/system.php?action=reset_db_charset"><?php echo _('Set Database Charset'); ?></a></li>
</ul>
<?php show_box_bottom(); ?>
+<?php show_box_top(_('PHP Settings')); ?>
+<table class="tabledata" cellpadding="0" cellspacing="0">
+<colgroup>
+ <col id="col_php_setting">
+ <col id="col_php_value">
+</colgroup>
+<tr class="th-top">
+ <th class="cel_php_setting"><?php echo _('Setting'); ?></th>
+ <th class="cel_php_value"><?php echo _('Value'); ?></th>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Memory Limit'); ?></td>
+ <td><?php echo ini_get('memory_limit'); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Maximum Execution Time'); ?></td>
+ <td><?php echo ini_get('max_execution_time'); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Safe Mode'); ?></td>
+ <td><?php echo print_boolean(ini_get('safe_mode')); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td>Open Basedir</td>
+ <td><?php echo ini_get('open_basedir'); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Zlib Support'); ?></td>
+ <td><?php echo print_boolean(function_exists('gzcompress')); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('GD Support'); ?></td>
+ <td><?php echo print_boolean(function_exists('ImageCreateFromString')); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Iconv Support'); ?></td>
+ <td><?php echo print_boolean(function_exists('iconv')); ?></td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _('Gettext Support'); ?></td>
+ <td><?php echo print_boolean(function_exists('bindtextdomain')); ?></td>
+</tr>
+</table>
+<?php show_box_bottom(); ?>
<?php show_box_top(_('Current Configuration')); ?>
<table class="tabledata" cellpadding="0" cellspacing="0">