更新webERP 3.11.4 Windows UTF-8 安装

ㄚ琪没碰webERP好久了,不过最近碰上一位叫凯凯的网友留言询问我这个软体的问题,我也是有碰到类似的问题,所以重新测试安装,然后修改一些档案,原则跟Windows weberp 3.11 utf-8 安装,所以我就不会再赘述!

首先碰到的问题就是,安装的画面会出现

2010-09-20_115423

这个Unwriteable真的很诡异,以前在Windows weberp 3.11时不会这样,去查一下权限,发现

2010-09-20_140832

这个资料夹的唯读属性,一直被打上方块,不死心拼命地改,就是改不掉,Google找了很多方法,原因可能说是中毒之类的,但无论怎样就是无法改,后来只好接受,这是微软针对安全性跟档案的创作所做的更新造成的,好吧,我就劝凯凯先不用管这个问题直接安装,确实还是可以安装的!

但是后来还是发现中文化还是有乱码的情形,嗯!我想凯凯的问题,跟我碰到的有所不同,因为我发现将sql的编码改成UTF-8好像无法安装,不知哪里错,不过更新后的webERP要更换到106个编码,也是挺累的,还是来个工具程式好了,这次Fanrien’s blogMysql latin1_swedish_ci 转 UTF-8,可以很快地将你的资料表转换成UTF-8编码,不错用!

贴上程式码如下:

<?php
define('DB_NAME', 'putyourdbnamehere');    // 数据库名
define('DB_USER', 'usernamehere');     // MySQL用户名
define('DB_PASSWORD', 'yourpasswordhere'); // 密码
define('DB_HOST', 'localhost');    // 很大可能你无需修改此项

function UTF8_DB_Converter_DoIt() {
 $tables = array();
 $tables_with_fields = array();

 // Since we cannot use the WordPress Database Abstraction Class (wp-db.php),
 // we have to make an a stand-alone/direct connection to the database.
 $link_id = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Error establishing a database connection');
 mysql_select_db(DB_NAME, $link_id);

 // Gathering information about tables and all the text/string fields that can be affected
 // during the conversion to UTF-8.
 $resource = mysql_query("SHOW TABLES", $link_id);
 while ( $result = mysql_fetch_row($resource) )
  $tables[] = $result[0];

 if ( !empty($tables) ) {
  foreach ( (array) $tables as $table ) {
   $resource = mysql_query("EXPLAIN $table", $link_id);
   while ( $result = mysql_fetch_assoc($resource) ) {
    if ( preg_match('/(char)|(text)|(enum)|(set)/', $result['Type']) )
     $tables_with_fields[$table][$result['Field']] = $result['Type'] . " " . ( "YES" == $result['Null'] ? "" : "NOT " ) . "NULL " .  ( !is_null($result['Default']) ? "DEFAULT '". $result['Default'] ."'" : "" );
   }
  }

  // Change all text/string fields of the tables to their corresponding binary text/string representations.
  foreach ( (array) $tables as $table )
   mysql_query("ALTER TABLE $table CONVERT TO CHARACTER SET binary", $link_id);

  // Change database and tables to UTF-8 Character set.
  mysql_query("ALTER DATABASE " . DB_NAME . " CHARACTER SET utf8", $link_id);
  foreach ( (array) $tables as $table )
   mysql_query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8", $link_id);

  // Return all binary text/string fields previously changed to their original representations.
  foreach ( (array) $tables_with_fields as $table => $fields ) {
   foreach ( (array) $fields as $field_type => $field_options ) {
    mysql_query("ALTER TABLE $table MODIFY $field_type $field_options", $link_id);
   }
  }

  // Optimize tables and finally close the mysql link.
  foreach ( (array) $tables as $table )
   mysql_query("OPTIMIZE TABLE $table", $link_id);
  mysql_close($link_id);
 } else {
  die('<strong>There are no tables?</strong>');
 }

 return true;
}
UTF8_DB_Converter_DoIt();
?>

好了,虽然如此,你可以在安装后用上面那只程式帮你UTF-8化,但是可能使用上会发现,不能自动转为UTF-8的中文画面,我后来再一次追踪程式,发现webERP真是够乱的,这一次竟然又发现有

header(‘Content-type: text/html; charset=’ . _(‘iso-8859-1’));

echo ‘<meta http-equiv=”Content-Type” content=”text/html; charset=’ . _(‘ISO-8859-1’) . ‘” />’;

这样的程式码,有点火大了,

只好再更新语系档一次!zh_TW,直接将档案解压缩在locale下即可。
好了,如果你嫌登录的画面是英文的不高兴,也可以改,就将config.php的$DefaultLanguage =’en_GB’;里的en_GB改成zh_TW即可!
这样应该就可以有中文化的webERP了!