diff --git a/config/config.php b/config/config.php index afd40b4df8..a0a0d7f39a 100644 --- a/config/config.php +++ b/config/config.php @@ -17,12 +17,12 @@ if(!function_exists('getWebRoot')){function getWebRoot(){}} /* Basic settings. */ $config = new config(); -$config->version = '4.0.1'; // The version of zentaopms. Don't change it. -$config->encoding = 'UTF-8'; // The encoding of zentaopms. -$config->cookieLife = time() + 2592000; // The cookie life time. -$config->timezone = 'Asia/Shanghai'; // The time zone setting, for more see http://www.php.net/manual/en/timezones.php -$config->webRoot = ''; // The root path of the pms. -$config->checkVersion= true; // Auto check for new version or not. +$config->version = '4.0.1'; // The version of zentaopms. Don't change it. +$config->charset = 'UTF-8'; // The encoding of zentaopms. +$config->cookieLife = time() + 2592000; // The cookie life time. +$config->timezone = 'Asia/Shanghai'; // The time zone setting, for more see http://www.php.net/manual/en/timezones.php +$config->webRoot = ''; // The root path of the pms. +$config->checkVersion = true; // Auto check for new version or not. /* The request settings. */ $config->requestType = 'PATH_INFO'; // The request type: PATH_INFO|GET, if PATH_INFO, must use url rewrite. @@ -44,6 +44,13 @@ $config->langs['zh-cn'] = '中文简体'; $config->langs['zh-tw'] = '中文繁體'; $config->langs['en'] = 'English'; +/* Supported charsets. */ +$config->charsets['zh-cn']['utf-8'] = 'UTF-8'; +$config->charsets['zh-cn']['gbk'] = 'GBK'; +$config->charsets['zh-tw']['utf-8'] = 'UTF-8'; +$config->charsets['zh-tw']['big5'] = 'BIG5'; +$config->charsets['en']['utf-8'] = 'UTF-8'; + /* Default settings. */ $config->default = new stdclass(); $config->default->view = 'html'; // Default view. diff --git a/module/common/model.php b/module/common/model.php index 4e61bb0f55..2a5cda6f4c 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -32,7 +32,7 @@ class commonModel extends model */ public function sendHeader() { - header("Content-Type: text/html; Language={$this->config->encoding}"); + header("Content-Type: text/html; Language={$this->config->charset}"); header("Cache-control: private"); } diff --git a/module/mail/config.php b/module/mail/config.php index 4ef86305fd..f74f812848 100644 --- a/module/mail/config.php +++ b/module/mail/config.php @@ -10,6 +10,7 @@ $config->mail->fromAddress = ''; // The from address. $config->mail->fromName = 'zentao'; // The from name. $config->mail->mta = 'smtp'; // The send mail type. $config->mail->smtp->debug = 0; // Debug level, 0,1,2. +$config->mail->smtp->charset = 'utf-8'; // Charset $config->mail->smtp->auth = true; // Need auth or not. true|false $config->mail->smtp->host = 'localhost';// The smtp server host address. $config->mail->smtp->port = '25'; // The smtp server host port. diff --git a/module/mail/control.php b/module/mail/control.php index 3d0723d20c..8cb0090239 100755 --- a/module/mail/control.php +++ b/module/mail/control.php @@ -111,6 +111,7 @@ class mail extends control $mailConfig->smtp->password = $this->post->password; $mailConfig->smtp->secure = $this->post->secure; $mailConfig->smtp->debug = $this->post->debug; + $mailConfig->smtp->charset = $this->post->charset; $this->loadModel('setting')->setItems('system.mail', $mailConfig); if(dao::isError()) die(js::error(dao::getError())); diff --git a/module/mail/lang/en.php b/module/mail/lang/en.php index 2d371be2a9..71cb2304b4 100755 --- a/module/mail/lang/en.php +++ b/module/mail/lang/en.php @@ -17,6 +17,7 @@ $lang->mail->username = 'SMTP account'; $lang->mail->password = 'SMTP password'; $lang->mail->secure = 'Secure'; $lang->mail->debug = 'Debug'; +$lang->mail->charset = 'Charset'; $lang->mail->turnonList[1] = 'on'; $lang->mail->turnonList[0] = 'off'; diff --git a/module/mail/lang/zh-cn.php b/module/mail/lang/zh-cn.php index d653db622a..496819986d 100755 --- a/module/mail/lang/zh-cn.php +++ b/module/mail/lang/zh-cn.php @@ -17,6 +17,7 @@ $lang->mail->username = 'smtp帐号'; $lang->mail->password = 'smtp密码'; $lang->mail->secure = '是否加密'; $lang->mail->debug = '调试级别'; +$lang->mail->charset = '编码'; $lang->mail->turnonList[1] = '打开'; $lang->mail->turnonList[0] = '关闭'; diff --git a/module/mail/model.php b/module/mail/model.php index 62e0111e5e..eb7a0eee1c 100644 --- a/module/mail/model.php +++ b/module/mail/model.php @@ -162,7 +162,7 @@ class mailModel extends model { if(self::$instance == null) self::$instance = new phpmailer(true); $this->mta = self::$instance; - $this->mta->CharSet = $this->config->encoding; + $this->mta->CharSet = $this->config->charset; $funcName = "set{$this->config->mail->mta}"; if(!method_exists($this, $funcName)) $this->app->error("The MTA {$this->config->mail->mta} not supported now.", __FILE__, __LINE__, $exit = true); $this->$funcName(); @@ -182,6 +182,7 @@ class mailModel extends model $this->mta->SMTPAuth = $this->config->mail->smtp->auth; $this->mta->Username = $this->config->mail->smtp->username; $this->mta->Password = $this->config->mail->smtp->password; + if(isset($this->config->mail->smtp->charset)) $this->mta->CharSet = $this->config->mail->smtp->charset; if(isset($this->config->mail->smtp->port)) $this->mta->Port = $this->config->mail->smtp->port; if(isset($this->config->mail->smtp->secure) and !empty($this->config->mail->smtp->secure))$this->mta->SMTPSecure = strtolower($this->config->mail->smtp->secure); } @@ -265,11 +266,11 @@ class mailModel extends model try { - $this->mta->setFrom($this->config->mail->fromAddress, $this->config->mail->fromName); - $this->setSubject($subject); + $this->mta->setFrom($this->config->mail->fromAddress, $this->convertCharset($this->config->mail->fromName)); + $this->setSubject($this->convertCharset($subject)); $this->setTO($toList, $emails); $this->setCC($ccList, $emails); - $this->setBody($body); + $this->setBody($this->convertCharset($body)); $this->setErrorLang(); $this->mta->send(); } @@ -297,7 +298,7 @@ class mailModel extends model foreach($toList as $account) { if(!isset($emails[$account]) or isset($emails[$account]->sended) or strpos($emails[$account]->email, '@') == false) continue; - $this->mta->addAddress($emails[$account]->email, $emails[$account]->realname); + $this->mta->addAddress($emails[$account]->email, $this->convertCharset($emails[$account]->realname)); $emails[$account]->sended = true; } } @@ -317,7 +318,7 @@ class mailModel extends model foreach($ccList as $account) { if(!isset($emails[$account]) or isset($emails[$account]->sended) or strpos($emails[$account]->email, '@') == false) continue; - $this->mta->addCC($emails[$account]->email, $emails[$account]->realname); + $this->mta->addCC($emails[$account]->email, $this->convertCharset($emails[$account]->realname)); $emails[$account]->sended = true; } } @@ -346,6 +347,19 @@ class mailModel extends model $this->mta->msgHtml("$body"); } + /** + * Convert charset. + * + * @param string $string + * @access public + * @return string + */ + public function convertCharset($string) + { + if($this->config->mail->smtp->charset != strtolower($this->config->charset)) return iconv($this->config->charset, $this->config->mail->smtp->charset, $string); + return $string; + } + /** * Set error lang. * diff --git a/module/mail/view/edit.html.php b/module/mail/view/edit.html.php index 51b7587a25..183ed34e2f 100755 --- a/module/mail/view/edit.html.php +++ b/module/mail/view/edit.html.php @@ -54,6 +54,10 @@ include '../../common/view/header.html.php'; mail->debug; ?> mail->debugList, $mailConfig->debug);?> + + mail->charset; ?> + charsets[$this->cookie->lang], zget($config->charsets[$this->cookie->lang], $mailConfig->charset, 'utf-8', $mailConfig->charset));?> +