aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/include/functions.php30
-rw-r--r--include/common.inc.php17
-rw-r--r--include/constants.php2
-rw-r--r--include/functions.inc.php209
-rw-r--r--include/functions_user.inc.php11
-rw-r--r--install.php81
-rw-r--r--install/db/65-database.php322
-rw-r--r--install/phpwebgallery_structure.sql2
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php1
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php1
-rw-r--r--plugins/admin_multi_view/controller.php3
11 files changed, 617 insertions, 62 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 23cf41180..b22074d79 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1989,4 +1989,34 @@ UPDATE '.USER_CACHE_TABLE.'
pwg_query($query);
trigger_action('invalidate_user_cache');
}
+
+/**
+ * adds the caracter set to a create table sql query.
+ * all CREATE TABLE queries must call this function
+ * @param string query - the sql query
+ */
+function create_table_add_character_set($query)
+{
+ defined('DB_CHARSET') or die('create_table_add_character_set DB_CHARSET undefined');
+ if ('DB_CHARSET'!='')
+ {
+ if ( version_compare(mysql_get_server_info(), '4.1.0', '<') )
+ {
+ return $query;
+ }
+ $charset_collate = " DEFAULT CHARACTER SET ".DB_CHARSET;
+ if ('DB_COLLATE'!='')
+ {
+ $charset_collate .= " COLLATE ".DB_COLLATE;
+ }
+ $query=trim($query);
+ $query=trim($query, ';');
+ if (preg_match('/^CREATE\s+TABLE/i',$query))
+ {
+ $query.=$charset_collate;
+ }
+ $query .= ';';
+ }
+ return $query;
+}
?> \ No newline at end of file
diff --git a/include/common.inc.php b/include/common.inc.php
index 18053e3ae..50c0d73fa 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -144,6 +144,23 @@ or die ( "Could not connect to database server" );
mysql_select_db( $cfgBase )
or die ( "Could not connect to database" );
+defined('PWG_CHARSET') and defined('DB_CHARSET')
+ or die('PWG_CHARSET and/or DB_CHARSET is not defined');
+if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
+{
+ if (DB_CHARSET!='')
+ {
+ pwg_query('SET NAMES "'.DB_CHARSET.'"');
+ }
+}
+else
+{
+ if ( strtolower(PWG_CHARSET)!='iso-8859-1' )
+ {
+ die('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
+ }
+}
+
//
// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
// since basic gallery information is not available
diff --git a/include/constants.php b/include/constants.php
index 7d955c8f3..c90323414 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -28,7 +28,7 @@
define('PHPWG_VERSION', 'Butterfly');
define('PHPWG_DOMAIN', 'phpwebgallery.net');
define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN);
-define('PHPWG_DEFAULT_LANGUAGE', 'en_UK.iso-8859-1');
+define('PHPWG_DEFAULT_LANGUAGE', 'en_UK');
define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear');
// Error codes
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 4e6b97b02..c12bdcda5 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -476,8 +476,14 @@ function str2url($str)
*
* @returns array
*/
-function get_languages()
+function get_languages($target_charset = null)
{
+ if ( empty($target_charset) )
+ {
+ $target_charset = get_pwg_charset();
+ }
+ $target_charset = strtolower($target_charset);
+
$dir = opendir(PHPWG_ROOT_PATH.'language');
$languages = array();
@@ -487,7 +493,32 @@ function get_languages()
if (is_dir($path) and !is_link($path) and file_exists($path.'/iso.txt'))
{
list($language_name) = @file($path.'/iso.txt');
- $languages[$file] = $language_name;
+
+ $langdef = explode('.',$file);
+ if (count($langdef)>1) // (langCode,encoding)
+ {
+ $langdef[1] = strtolower($langdef[1]);
+
+ if (
+ $target_charset==$langdef[1]
+ or
+ ($target_charset=='utf-8' and $langdef[1]=='iso-8859-1')
+ or
+ ($target_charset=='iso-8859-1' and
+ in_array( substr($langdef[0],2), array('en','fr','de','es','it','nl')))
+ )
+ {
+ $language_name = convert_charset($language_name,
+ $langdef[1], $target_charset);
+ $languages[ $langdef[0] ] = $language_name;
+ }
+ else
+ continue; // the language encoding is not compatible with our charset
+ }
+ else
+ { // probably english that is the same in all ISO-xxx and UTF-8
+ $languages[$file] = $language_name;
+ }
}
}
closedir($dir);
@@ -1429,8 +1460,8 @@ function get_filter_page_value($value_name)
*/
function get_pwg_charset()
{
- //TEMP CODE
- global $lang_info;return $lang_info['charset'];
+ defined('PWG_CHARSET') or die('load_language PWG_CHARSET undefined');
+ return PWG_CHARSET;
}
/**
@@ -1449,18 +1480,166 @@ function get_pwg_charset()
* @return boolean success status or a string if return_content is true
*/
function load_language($filename, $dirname = '', $language = '',
- $return_content=false)
+ $return_content=false, $target_charset=null)
{
- //TEMP CODE
- if (!$return_content) $filename.='.php';
- $f = get_language_filepath($filename, $dirname, $language);
- if ($f === false)
- return false;
- if ($return_content)
- return @file_get_contents($f);
- global $lang, $lang_info;
- @include($f);
- return true;
+ global $user;
+
+ if (!$return_content)
+ {
+ $filename .= '.php'; //MAYBE to do .. load .po and .mo localization files
+ }
+ if (empty($dirname))
+ {
+ $dirname = PHPWG_ROOT_PATH;
+ }
+ $dirname .= 'language/';
+
+ $languages = array();
+ if ( !empty($language) )
+ {
+ $languages[] = $language;
+ }
+
+ if ( !empty($user['language']) )
+ {
+ $languages[] = $user['language'];
+ }
+ $languages[] = PHPWG_DEFAULT_LANGUAGE;
+ $languages = array_unique($languages);
+
+ if ( empty($target_charset) )
+ {
+ $target_charset = get_pwg_charset();
+ }
+ $target_charset = strtolower($target_charset);
+ $source_charset = '';
+ $source_file = '';
+ foreach ($languages as $language)
+ {
+ $dir = $dirname.$language;
+
+ // exact charset match - no conversion required
+ $f = $dir.'.'.$target_charset.'/'.$filename;
+ if (file_exists($f))
+ {
+ $source_file = $f;
+ break;
+ }
+
+ // universal language (like Eng) no conversion required
+ $f = $dir.'/'.$filename;
+ if (file_exists($f))
+ {
+ $source_file = $f;
+ break;
+ }
+
+ if ($target_charset=='utf-8')
+ { // we accept conversion from ISO-8859-1 to UTF-8
+ $f = $dir.'.iso-8859-1/'.$filename;
+ if (file_exists($f))
+ {
+ $source_charset = 'iso-8859-1';
+ $source_file = $f;
+ break;
+ }
+ }
+
+ if ($target_charset=='iso-8859-1' and
+ in_array( substr($language,2), array('en','fr','de','es','it','nl') )
+ )
+ { // we accept conversion from UTF-8 to ISO-8859-1 for backward compatibility ONLY
+ $f = $dir.'.utf-8/'.$filename;
+ if (file_exists($f))
+ {
+ $source_charset = 'utf-8';
+ $source_file = $f;
+ break;
+ }
+ }
+ }
+
+ if ( !empty($source_file) )
+ {
+ if (!$return_content)
+ {
+ @include($source_file);
+ $load_lang = @$lang;
+ $load_lang_info = @$lang_info;
+
+ global $lang, $lang_info;
+ if ( !isset($lang) ) $lang=array();
+ if ( !isset($lang_info) ) $lang_info=array();
+
+ if ( !empty($source_charset) and $source_charset!=$target_charset)
+ {
+ if ( is_array($load_lang) )
+ {
+ foreach ($load_lang as $k => $v)
+ {
+ if ( is_array($v) )
+ {
+ $func = create_function('$v', 'return convert_charset($v, "'.$source_charset.'","'.$target_charset.'");' );
+ $lang[$k] = array_map($func, $v);
+ }
+ else
+ $lang[$k] = convert_charset($v, $source_charset, $target_charset);
+ }
+ }
+ if ( is_array($load_lang_info) )
+ {
+ foreach ($load_lang_info as $k => $v)
+ {
+ $lang_info[$k] = convert_charset($v, $source_charset, $target_charset);
+ }
+ }
+ }
+ else
+ {
+ $lang = array_merge( $lang, $load_lang );
+ $lang_info = array_merge( $lang_info, $load_lang_info );
+ }
+ return true;
+ }
+ else
+ {
+ $content = @file_get_contents($source_file);
+ if ( !empty($source_charset) and $source_charset!=$target_charset)
+ {
+ $content = convert_charset($content, $source_charset, $target_charset);
+ }
+ return $content;
+ }
+ }
+ return false;
}
+/**
+ * converts a string from a character set to another character set
+ * @param string str the string to be converted
+ * @param string source_charset the character set in which the string is encoded
+ * @param string dest_charset the destination character set
+ */
+function convert_charset($str, $source_charset, $dest_charset)
+{
+ if ($source_charset==$dest_charset)
+ return $str;
+ if ($source_charset=='iso-8859-1' and $dest_charset=='utf-8')
+ {
+ return utf8_encode($str);
+ }
+ if ($source_charset=='utf-8' and $dest_charset=='iso-8859-1')
+ {
+ return utf8_decode($str);
+ }
+ if (function_exists('iconv'))
+ {
+ return iconv($source_charset, $dest_charset, $str);
+ }
+ if (function_exists('mb_convert_encoding'))
+ {
+ return mb_convert_encoding( $str, $dest_charset, $source_charset );
+ }
+ return $str; //???
+}
?> \ No newline at end of file
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 54fab06b5..b6c37cc0f 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -32,13 +32,13 @@
// o check if address could be empty
// o check if address is not used by a other user
// If the mail address doesn't correspond, an error message is returned.
-//
+//
function validate_mail_address($user_id, $mail_address)
{
global $conf;
if (empty($mail_address) and
- !($conf['obligatory_user_mail_address'] and
+ !($conf['obligatory_user_mail_address'] and
in_array(script_basename(), array('register', 'profile'))))
{
return '';
@@ -49,7 +49,7 @@ function validate_mail_address($user_id, $mail_address)
{
return l10n('reg_err_mail_address');
}
-
+
if (defined("PHPWG_INSTALLED") and !empty($mail_address))
{
$query = '
@@ -158,11 +158,6 @@ SELECT id
return $errors;
}
-function setup_style($style)
-{
- return new Template(PHPWG_ROOT_PATH.'template/'.$style);
-}
-
function build_user( $user_id, $use_cache )
{
global $conf;
diff --git a/install.php b/install.php
index cbf4bf12a..38fc56875 100644
--- a/install.php
+++ b/install.php
@@ -27,18 +27,12 @@
//----------------------------------------------------------- include
define('PHPWG_ROOT_PATH','./');
-// Guess an initial language ...
-function guess_lang()
-{
- return 'en_UK.iso-8859-1';
-}
-
//
// Pick a language, any language ...
//
function language_select($default, $select_name = "language")
{
- $available_lang = get_languages();
+ $available_lang = get_languages('utf-8');
$lang_select = '<select name="' . $select_name . '" onchange="document.location = \''.PHPWG_ROOT_PATH.'install.php?language=\'+this.options[this.selectedIndex].value;">';
foreach ($available_lang as $code => $displayname)
@@ -84,6 +78,14 @@ function execute_sqlfile($filepath, $replaced, $replacing)
// we don't execute "DROP TABLE" queries
if (!preg_match('/^DROP TABLE/i', $query))
{
+ global $install_charset_collate;
+ if ( !empty($install_charset_collate) )
+ {
+ if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) )
+ {
+ $query = $matches[1].' '.$install_charset_collate.';';
+ }
+ }
mysql_query($query);
}
$query = '';
@@ -210,30 +212,21 @@ include(PHPWG_ROOT_PATH . 'include/template.php');
// Create empty local files to avoid log errors
create_empty_local_files();
-if ( isset( $_POST['language'] ))
-{
- $language = strip_tags($_POST['language']);
-}
-elseif ( isset( $_GET['language'] ))
+if ( isset( $_REQUEST['language'] ))
{
- $language = strip_tags($_GET['language']);
+ $language = strip_tags($_REQUEST['language']);
}
-else
+else
{
- $language = guess_lang();
+ $language = 'en_UK';
}
-if (!file_exists(PHPWG_ROOT_PATH.'language/'.$language.'/install.lang.php'))
-{
- $language = 'en_UK.iso-8859-1';
-}
+load_language( 'common.lang', '', $language, false, 'utf-8' );
+load_language( 'admin.lang', '', $language, false, 'utf-8' );
+load_language( 'install.lang', '', $language, false, 'utf-8' );
-include( './language/'.$language.'/common.lang.php' );
-// Never: @include( './language/'.$language.'/local.lang.php' );
-include( './language/'.$language.'/admin.lang.php' );
-include( './language/'.$language.'/install.lang.php' );
//----------------------------------------------------- template initialization
-$template=setup_style('yoga');
+$template=new Template(PHPWG_ROOT_PATH.'template/yoga');
$template->set_filenames( array('install'=>'install.tpl') );
$step = 1;
//---------------------------------------------------------------- form analyze
@@ -251,12 +244,28 @@ if ( isset( $_POST['install'] ))
{
array_push( $errors, $lang['step1_err_db'] );
}
+ if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
+ {
+ $pwg_charset='utf-8';
+ $pwg_db_charset='utf8';
+ $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset";
+ }
+ else
+ {
+ $pwg_charset='iso-8859-1';
+ $pwg_db_charset='latin1';
+ $install_charset_collate = '';
+ if ( !array_key_exists($language, get_languages($pwg_charset) ) )
+ {
+ $language='en_UK';
+ }
+ }
}
else
{
array_push( $errors, $lang['step1_err_server'] );
}
-
+
$webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name ));
if ( empty($webmaster))
array_push( $errors, $lang['step2_err_login1'] );
@@ -266,13 +275,13 @@ if ( isset( $_POST['install'] ))
array_push( $errors, $lang['step2_err_pass'] );
if ( empty($admin_mail))
array_push( $errors, $lang['reg_err_mail_address'] );
- else
+ else
{
$error_mail_address = validate_mail_address(null, $admin_mail);
if (!empty($error_mail_address))
array_push( $errors, $error_mail_address );
}
-
+
if ( count( $errors ) == 0 )
{
$step = 2;
@@ -285,8 +294,12 @@ $cfgHote = \''.$dbhost.'\';
$prefixeTable = \''.$table_prefix.'\';
define(\'PHPWG_INSTALLED\', true);
+define(\'PWG_CHARSET\', \''.$pwg_charset.'\');
+define(\'DB_CHARSET\', \''.$pwg_db_charset.'\');
+define(\'DB_COLLATE\', \'\');
+
?'.'>';
-
+
@umask(0111);
// writing the configuration file
if ( !($fp = @fopen( $config_file, 'w' )))
@@ -302,7 +315,7 @@ define(\'PHPWG_INSTALLED\', true);
}
@fputs($fp, $file_content, strlen($file_content));
@fclose($fp);
-
+
// tables creation, based on phpwebgallery_structure.sql
execute_sqlfile(
PHPWG_ROOT_PATH.'install/phpwebgallery_structure.sql',
@@ -324,7 +337,7 @@ define(\'PHPWG_INSTALLED\', true);
'galleries_url' => PHPWG_ROOT_PATH.'galleries/',
);
mass_inserts(SITES_TABLE, array_keys($insert), array($insert));
-
+
// webmaster admin user
$inserts = array(
array(
@@ -370,7 +383,7 @@ define(\'PHPWG_INSTALLED\', true);
$template->assign_vars(
array(
'RELEASE'=>PHPWG_VERSION,
-
+
'L_BASE_TITLE'=>$lang['Initial_config'],
'L_LANG_TITLE'=>$lang['Default_lang'],
'L_DB_TITLE'=>$lang['step1_title'],
@@ -398,7 +411,7 @@ $template->assign_vars(
'L_ERR_COPY'=>$lang['step1_err_copy'],
'L_END_TITLE'=>$lang['install_end_title'],
'L_END_MESSAGE'=>$lang['install_end_message'],
-
+
'F_ACTION'=>'install.php',
'F_DB_HOST'=>$dbhost,
'F_DB_USER'=>$dbuser,
@@ -411,8 +424,8 @@ $template->assign_vars(
'F_ADMIN'=>$admin_name,
'F_ADMIN_EMAIL'=>$admin_mail,
'F_LANG_SELECT'=>language_select($language),
-
- 'T_CONTENT_ENCODING' => $lang_info['charset']
+
+ 'T_CONTENT_ENCODING' => 'utf-8'
));
//------------------------------------------------------ errors & infos display
diff --git a/install/db/65-database.php b/install/db/65-database.php
new file mode 100644
index 000000000..0f4ae0165
--- /dev/null
+++ b/install/db/65-database.php
@@ -0,0 +1,322 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file : $Id$
+// | last update : $Date$
+// | last modifier : $Author$
+// | revision : $Revision$
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+function upgrade65_change_table_to_blob($table, $field_definitions)
+{
+ $types = array('varchar' => 'varbinary',
+ 'text' => 'blob',
+ 'mediumtext' => 'mediumblob',
+ 'longtext' => 'longblob');
+
+ $changes=array();
+ foreach( $field_definitions as $row)
+ {
+ if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
+ continue;
+ list ($type) = explode('(', $row['Type']);
+ if (!isset($types[$type]))
+ continue; // no need
+ $binaryType = preg_replace('/'. $type .'/i', $types[$type], $row['Type'] );
+ $changes[] = 'MODIFY COLUMN '.$row['Field'].' '.$binaryType;
+ }
+ if (count($changes))
+ {
+ $query = 'ALTER TABLE '.$table.' '.implode(', ', $changes);
+ pwg_query($query);
+ }
+}
+
+function upgrade65_change_table_to_charset($table, $field_definitions, $db_charset)
+{
+ $changes=array();
+ foreach( $field_definitions as $row)
+ {
+ if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
+ continue;
+ $query = $row['Field'].' '.$row['Type'];
+ $query .= ' CHARACTER SET '.$db_charset;
+ if (strpos($row['Collation'],'_bin')!==false)
+ {
+ $query .= ' BINARY';
+ }
+ if ($row['Null']!='YES')
+ {
+ $query.=' NOT NULL';
+ if (isset($row['Default']))
+ $query.=' DEFAULT "'.addslashes($row['Default']).'"';
+ }
+ else
+ {
+ if (!isset($row['Default']))
+ $query.=' DEFAULT NULL';
+ else
+ $query.=' DEFAULT "'.addslashes($row['Default']).'"';
+ }
+
+ if ($row['Extra']=='auto_increment')
+ {
+ $query.=' auto_increment';
+ }
+ $changes[] = 'MODIFY COLUMN '.$query;
+ }
+
+ if (count($changes))
+ {
+ $query = 'ALTER TABLE `'.$table.'` '.implode(', ', $changes);
+ pwg_query($query);
+ }
+}
+
+
+$upgrade_description = 'PWG charset migration';
+// +-----------------------------------------------------------------------+
+// | Upgrade content |
+// +-----------------------------------------------------------------------+
+if ( !defined('PWG_CHARSET') )
+{
+ $upgrade_log = '';
+
+// +-----------------------------------------------------------------------+
+// load the config file
+ $config_file = PHPWG_ROOT_PATH.'include/mysql.inc.php';
+ $config_file_contents = @file_get_contents($config_file);
+ if ($config_file_contents === false)
+ {
+ die('CANNOT LOAD '.$config_file);
+ }
+ $php_end_tag = strrpos($config_file_contents, '?'.'>');
+ if ($php_end_tag === false)
+ {
+ die('CANNOT FIND PHP END TAG IN '.$config_file);
+ }
+ if (!is_writable($config_file))
+ {
+ die('FILE NOT WRITABLE '.$config_file);
+ }
+
+
+// +-----------------------------------------------------------------------+
+// load all the user languages
+ $all_langs=array();
+ $query='
+SELECT language, COUNT(user_id) AS count FROM '.USER_INFOS_TABLE.'
+ GROUP BY language';
+ $result = pwg_query($query);
+ while ( $row=mysql_fetch_assoc($result) )
+ {
+ $lang = $row["language"];
+ $lang_def = explode('.', $lang);
+ if ( count($lang_def)==2 )
+ {
+ $new_lang = $lang_def[0];
+ $charset = strtolower($lang_def[1]);
+ }
+ else
+ {
+ $new_lang = 'en_UK';
+ $charset = 'iso-8859-1';
+ }
+ $all_langs[$lang] = array(
+ 'count' => $row['count'],
+ 'new_lang' => $new_lang,
+ 'charset' => $charset,
+ );
+ $upgrade_log .= ">>user_lang\t".$lang."\t".$row['count']."\n";
+ }
+ $upgrade_log .= "\n";
+
+
+// +-----------------------------------------------------------------------+
+// get admin charset
+ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
+ @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
+ $admin_charset='iso-8859-1';
+ $query='
+SELECT language FROM '.USER_INFOS_TABLE.'
+ WHERE user_id='.$conf['webmaster_id'];
+ $result = pwg_query($query);
+ if (mysql_num_rows($result)==0)
+ {
+ $query='
+SELECT language FROM '.USER_INFOS_TABLE.'
+ WHERE status="webmaster" and adviser="false"
+ LIMIT 1';
+ $result = pwg_query($query);
+ }
+
+ if ( $row=mysql_fetch_assoc($result) )
+ {
+ $admin_charset = $all_langs[$row['language']]['charset'];
+ }
+ $upgrade_log .= ">>admin_charset\t".$admin_charset."\n";
+
+
+// +-----------------------------------------------------------------------+
+// get mysql version and structure of tables
+ $mysql_version = mysql_get_server_info();
+ $upgrade_log .= ">>mysql_ver\t".$mysql_version."\n";
+
+ $all_tables = array();
+ $query = 'SHOW TABLES LIKE "'.$prefixeTable.'%"';
+ $result = pwg_query($query);
+ while ( $row=mysql_fetch_array($result) )
+ {
+ array_push($all_tables, $row[0]);
+ }
+
+ $all_tables_definition = array();
+ foreach( $all_tables as $table)
+ {
+ $query = 'SHOW FULL COLUMNS FROM '.$table;
+ $result = pwg_query($query);
+ $field_definitions=array();
+ while ( $row=mysql_fetch_array($result) )
+ {
+ if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
+ continue;
+ array_push($field_definitions, $row);
+ }
+ $all_tables_definition[$table] = $field_definitions;
+ }
+
+// +-----------------------------------------------------------------------+
+// calculate the result and convert the tables
+
+//tables that can be converted without going through binary (they contain only ascii data)
+ $safe_tables=array('history','history_backup','history_summary','old_permalinks','plugins','rate','upgrade','user_cache','user_feed','user_infos','user_mail_notification', 'users', 'waiting','ws_access');
+ $safe_tables=array_flip($safe_tables);
+
+ $pwg_charset = 'iso-8859-1';
+ $db_charset = 'latin1';
+ $db_collate = '';
+ if ( version_compare($mysql_version, '4.1', '<') )
+ { // below 4.1 no charset support
+ $upgrade_log .= "< conversion\tnothing\n";
+ }
+ elseif ($admin_charset=='iso-8859-1')
+ {
+ $pwg_charset = 'utf-8';
+ $db_charset = 'utf8';
+ foreach($all_tables as $table)
+ {
+ upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
+ $query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
+ pwg_query($query);
+ }
+ $upgrade_log .= "< conversion\tchange utf8\n";
+ }
+/*ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; (or change column character set)
+
+Warning: The preceding operation converts column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:
+
+ALTER TABLE t1 CHANGE c1 c1 BLOB;
+ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
+*/
+ elseif ( $admin_charset=='utf-8')
+ {
+ $pwg_charset = 'utf-8';
+ $db_charset = 'utf8';
+ foreach($all_tables as $table)
+ {
+ if ( !isset($safe_tables[ substr($table, strlen($prefixeTable)) ]) )
+ upgrade65_change_table_to_blob($table, $all_tables_definition[$table] );
+ upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
+ $query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
+ pwg_query($query);
+ }
+ $upgrade_log .= "< conversion\tchange binary\n";
+ $upgrade_log .= "< conversion\tchange utf8\n";
+ }
+ elseif ( $admin_charset=='iso-8859-2'/*Central European*/)
+ {
+ $pwg_charset = 'utf-8';
+ $db_charset = 'utf8';
+ foreach($all_tables as $table)
+ {
+ if ( !isset($safe_tables[ substr($table, strlen($prefixeTable)) ]) )
+ {
+ upgrade65_change_table_to_blob($table, $all_tables_definition[$table] );
+ upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'latin2' );
+ }
+ upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
+ $query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
+ pwg_query($query);
+ }
+ $upgrade_log .= "< conversion\tchange binary\n";
+ $upgrade_log .= "< conversion\tchange latin2\n";
+ $upgrade_log .= "< conversion\tchange utf8\n";
+ }
+
+
+// +-----------------------------------------------------------------------+
+// write the result to file and update #user_infos.language
+ $config_file_contents =
+ substr($config_file_contents, 0, $php_end_tag).'
+define(\'PWG_CHARSET\', \''.$pwg_charset.'\');
+define(\'DB_CHARSET\', \''.$db_charset.'\');
+define(\'DB_COLLATE\', \'\');
+'.substr($config_file_contents, $php_end_tag);
+
+ $fp = @fopen( $config_file, 'w' );
+ @fputs($fp, $config_file_contents, strlen($config_file_contents));
+ @fclose($fp);
+
+ foreach ($all_langs as $old_lang=>$lang_data)
+ {
+ $query='
+ UPDATE '.USER_INFOS_TABLE.' SET language="'.$lang_data['new_lang'].'"
+ WHERE language="'.$old_lang.'"';
+ pwg_query($query);
+ }
+
+ define('PWG_CHARSET', $pwg_charset);
+ define('DB_CHARSET', $db_charset);
+ define('DB_COLLATE', '');
+
+ echo $upgrade_log;
+ $fp = @fopen( PHPWG_ROOT_PATH.'upgrade65.log', 'w' );
+ if ($fp)
+ {
+ @fputs($fp, $upgrade_log, strlen($upgrade_log));
+ @fclose($fp);
+ }
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.' ended'
+."\n"
+;
+}
+else
+{
+ echo 'PWG_CHARSET already defined - nada';
+}
+?>
diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql
index 3a086c3c7..bb09e0fd1 100644
--- a/install/phpwebgallery_structure.sql
+++ b/install/phpwebgallery_structure.sql
@@ -382,7 +382,7 @@ CREATE TABLE `phpwebgallery_user_infos` (
`nb_line_page` tinyint(3) unsigned NOT NULL default '3',
`status` enum('webmaster','admin','normal','generic','guest') NOT NULL default 'guest',
`adviser` enum('true','false') NOT NULL default 'false',
- `language` varchar(50) NOT NULL default 'en_UK.iso-8859-1',
+ `language` varchar(50) NOT NULL default 'en_UK',
`maxwidth` smallint(6) default NULL,
`maxheight` smallint(6) default NULL,
`expand` enum('true','false') NOT NULL default 'false',
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index e8ae31a43..1b507ab9e 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -27,7 +27,6 @@
// Langage informations
$lang_info['language_name'] = 'English';
$lang_info['country'] = 'Great Britain';
-$lang_info['charset'] = 'iso-8859-1';
$lang_info['direction'] = 'ltr';
$lang_info['code'] = 'en';
$lang_info['zero_plural'] = true;
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index 70260689d..ce5225b7d 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -27,7 +27,6 @@
// Langage informations
$lang_info['language_name'] = 'Français';
$lang_info['country'] = 'France';
-$lang_info['charset'] = 'iso-8859-1';
$lang_info['direction'] = 'ltr';
$lang_info['code'] = 'fr';
$lang_info['zero_plural'] = false;
diff --git a/plugins/admin_multi_view/controller.php b/plugins/admin_multi_view/controller.php
index 3b694c7e2..f8bc37793 100644
--- a/plugins/admin_multi_view/controller.php
+++ b/plugins/admin_multi_view/controller.php
@@ -120,8 +120,9 @@ if (!$conf['show_queries'])
?>
<html>
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_pwg_charset() ?>">
<title>Controller</title>
-<?php
+<?php
// Controller will be displayed with the **real admin template** (without Any if it has been removed)
if ( $my_template !== '') {
$my_template = get_root_url().'template/'.$my_template.'/theme.css';