`
天梯梦
  • 浏览: 13634325 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

Zimbra系统资料

 
阅读更多

 目录

 

Zimbra系统资料

zimbra结构

14机器结构如下:

/opt/zimbra:

bin/启动zimbra的文件

jetty:zimbraWeb服务器

java:zimbraJava环境

memcache:缓存

httpd:apache httpd服务器

mysql:数据库

等。

 

启动zimbra命令

/opt/zimbra/bin/zmcontrol stop
/opt/zimbra/bin/zmcontrol start
 

邮件系统的启动

/opt/zimbra/bin/zmmailboxdctl stop
/opt/zimbra/bin/zmmailboxdctl start
/opt/zimbra/bin/zmmailboxdctl restart

 

2.zimbra修改内容

 

2.1 jsp文件:目录为/opt/zimbra/jetty/webapps/zimbra/public/

如修改login.jsp,将图片和商标的html去掉。

其他jsp文件暂时还没细读。

 

2.2 修改国际化中文编码

 

编码文件路径:zimbra/WEB-INF/classes/messages/*_zh_CN.properties

操作,先将unicode编码的文件转为中文,然后修改后再进行编码
native2ascii -reverse ZaMsg_zh_CN.properties a.txt
修改完a.txt后:
native2ascii a.txt ZaMsg_zh_CN.properties

 

2.3 linux下修改全部文件内容(此文件会替换全部文件夹下的文字。不能在类文件夹上使用,会把class文件的内容也替换掉。导致类文件检验出错):

 

http://www.zimbra.com替换为http://www.logerp.com
find -type f | xargs perl -i -pe s%http://www.zimbra.com%http://www.logerp.com%g

 

2.4 skin的修改

 

对应skin文件夹下,图标在skin/yahoo/logos,(其中yahoo为你选择的页面样式),每个样式下都有logos文件夹,可以进行替换图片。

 

Skybookzimbra注册流程

 

1.注册流程:

 

skybook新增用户 --> 发送https post请求到zimbra注册 --> 完成注册

其中发送https post注册流程:

a.java导入证书

b.编写post请求代码

 

2.登陆流程:

 

http://172.17.1.14/zimbra/public/skyBookLogin.html?name=nick&psw=asdfyozc

其中:psw是密码,通过DES加密后传输(密钥magenta)。

LogLogin.jsp将通过des解密,并得到原来数据

 

详细请求数据

 

创建用户Post请求

 

响应头信息
Date Mon, 28 Dec 2009 02:41:08 GMT
Content-Type text/javascript; charset=utf-8
Content-Length 12941

 

请求头信息
Host 172.17.1.14:7071
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 GTBDFff GTB7.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Content-Type application/soap+xml; charset=utf-8
Referer 
https://172.17.1.14:7071/zimbraAdmin/
Content-Length 955
Cookie ZM_ADMIN_AUTH_TOKEN=0_58592829c6d70d9bf2299e8e17611b2b406635a5_69643d33363a33636639643738382d316536632d343737372d623335372d3632353733303365366463333b6578703d31333a313236323031303734353231363b61646d696e3d313a313b747970653d363a7a696d6272613b
Pragma no-cache
Cache-Control no-cache

 

请求数据
http://www.w3.org/2003/05/soap-envelope'><CONTEXT< A> xmlns='urn:zimbra'>

0_58592829c6d70d9bf2299e8e17611b2b406635a5_69643d33363a33636639643738382d316536632d343737372d623335372d3632353733303365366463333b6578703d31333a313236323031303734353231363b61646d696e3d313a313b747970653d363a7a696d6272613b
asdf@magenta.hk123456active
ming zhongjian. xingmingzhongjian
xingmiaoshubeizhu

 

java证书导入
1.keytool -import -file myca.cert -keystore %JAVA_HOME%\jre\lib\security\cacerts -file myca.cert -alias tomcat
2.
此时命令行会提示你输入cacerts证书库的密码,你敲入changeit就行了,这是javacacerts证书库的默认密码,

 

zimbra请求处理流程

1.进入/zimbra/进入SetHeadFilter,并转发到/service/user/service/home请求

2./service/home对应UserServlet

3.UserServlet处理完毕后,调用不同的formater,对应网站就是HtmlFormater,跳转/zimbra/h/rest路径下

4./zimbra/h/rest不是jsp页面,内容是大量jstl,包括自定义jstl,这块代码难以阅读。

5.jstl处理完后返回html,css,js,其中js,css会通过SkinFilter进行替换,支持不同样式与中文

 

zimbra自行实现的jstl难以阅读。如以下的app:keyboard,zm:bindKey

<%@ tag body-content="empty" %>
<%@ attribute name="context" rtexprvalue="true" required="true" type="com.zimbra.cs.taglib.tag.SearchContext"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="com.zimbra.i18n" %>
<%@ taglib prefix="app" uri="com.zimbra.htmlclient" %>
<%@ taglib prefix="zm" uri="com.zimbra.zm" %>

<app:keyboard cache="mail.convView" globals="true" mailbox="${mailbox}" folders="true" tags="true">
        <zm:bindKey message="mail.MarkAllRead" func="zmarkall"/>
        <c:if test="${mailbox.features.flagging}">
        <zm:bindKey message="mail.Flag" func="zflag"/>
        <zm:bindKey message="mail.UnFlag" func="zunflag"/>
        </c:if>
        <zm:bindKey message="mail.MarkRead" func="zread"/>
        <zm:bindKey message="mail.MarkUnread" func="zunread"/>
        <zm:bindKey message="mail.Spam" func="zjunk"/>
        <zm:bindKey message="mail.Delete" func="function() { zclick('SOPDELETE')}"/>
        <zm:bindKey message="global.CheckCheckBox" func="zcs"/>
        <zm:bindKey message="global.SelectAllCheckBoxes" func="function() { zclick('OPCHALL')}"/>

        <zm:bindKey message="mail.ShowExternalImages" id="DISPEXTIMG"/>
        <zm:bindKey message="mail.GoToInbox" id="FLDR2"/>
        <zm:bindKey message="mail.GoToDrafts" id="FLDR6"/>
        <zm:bindKey message="mail.GoToSent" id="FLDR5"/>
        <zm:bindKey message="mail.GoToTrash" id="FLDR3"/>
        <zm:bindKey message="mail.Reply" id="OPREPLY"/>
        <zm:bindKey message="mail.ReplyAll" id="OPREPLYALL"/>
        <zm:bindKey message="mail.Forward" id="OPFORW"/>
        <zm:bindKey message="mail.Close" id="CLOSE_ITEM"/>
        <zm:bindKey message="mail.Open" id="CURR_ITEM"/>

 

未读邮件数

传入name和密码,获得未读邮件数代码如下:

public int getInbox(String name, String password) throws Exception {
  // 构造请求参数
  HashMap<String, String> map = new HashMap<String, String>();
  map.put("client", "adsf");// 此处不能设置mobile,原因未明
  map.put("loginOp", "login");
  map.put("password", password);
  map.put("username", name);

  StringBuffer bf = new StringBuffer();
  for (Map.Entry<String, String> entry : map.entrySet()) {
   bf.append("&" + entry.getKey() + "="
     + URLEncoder.encode(entry.getValue(), "UTF-8"));
  }
  String query = bf.toString().substring(1);

  // 创建url连接
  URL url = new URL("http://172.17.1.14/zimbra/");
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setDoInput(true);
  connection.setDoOutput(true);
  connection.setRequestProperty("Host", "172.17.1.14");
  connection
    .setRequestProperty(
      "User-Agent",
      "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 GTBDFff GTB7.0");
  connection
    .setRequestProperty("Accept",
      "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  connection.setRequestProperty("Accept-Language", "zh-cn,zh;q=0.5");
  connection.setRequestProperty("Accept-Encoding", "deflate");
  connection.setRequestProperty("Accept-Charset",
    "GB2312,utf-8;q=0.7,*;q=0.7");
  connection.setRequestProperty("Keep-Alive", "300");
  connection.setRequestProperty("Connection", "keep-alive");
  connection.setRequestProperty("Referer",
    "http://172.17.1.14/zimbra/?loginOp=logout&client=mobile");
  connection.setRequestProperty("Cookie", "ZM_TEST=true");
  connection.setRequestMethod("POST");

  // 输出数据
  DataOutputStream output = new DataOutputStream(connection
    .getOutputStream());
  output.write(query.getBytes("UTF-8"));
  output.flush();
  output.close();

  // 读取信息
  InputStream in = connection.getInputStream();
  BufferedReader bufferedReader = new BufferedReader(
    new InputStreamReader(in));
  StringBuffer temp = new StringBuffer();
  String line = bufferedReader.readLine();

  while (line != null) {
   temp.append(line).append("\r\n");
   line = bufferedReader.readLine();
  }
  bufferedReader.close();

  String ecod = connection.getContentEncoding();
  if (ecod == null)
   ecod = "UTF-8";

  // 设置cookie
  String cookie = "";
  Map<String, List<String>> headerFields = connection.getHeaderFields();
  for (Map.Entry<String, List<String>> entry : headerFields.entrySet()) {
   if ("Set-Cookie".equals(entry.getKey())) {
    for (String s : entry.getValue()) {
     cookie = s.substring(0, s.indexOf(";"));
     break;
    }
   }
  }

  // 请求mobile页面
  URL url2 = new URL("http://172.17.1.14/zimbra/m/mofolders");
  HttpURLConnection connection2 = (HttpURLConnection) url2
    .openConnection();
  connection2.setDoInput(true);
  connection2.setDoOutput(true);
  connection2.setRequestProperty("Cookie", "ZM_TEST=true;" + cookie);
  connection2.setRequestMethod("GET");
  // read in each character until end-of-stream is detected
  InputStream in2 = connection2.getInputStream();
  BufferedReader bufferedReader2 = new BufferedReader(
    new InputStreamReader(in2));
  StringBuffer temp2 = new StringBuffer();
  String line2 = bufferedReader2.readLine();

  String info = "";
  while (line2 != null) {
   if (!"".equals(line2.trim())) {
    line2 = new String(line2.trim().getBytes(), ecod);
    // 截取收件箱行
    if (line2.trim().startsWith("收件"))
     info = line2;
    temp2.append(line2).append("\r\n");
   }
   line2 = bufferedReader2.readLine();
  }
  bufferedReader2.close();

  // info = 收件箱(1)
  // 其中1为收件箱未读数
  if (info.indexOf("(") > 0) {
   String num = info.substring(info.indexOf("(") + 1, info
     .indexOf(")"));
   return Integer.parseInt(num);
  } else
   return 0;
 }

 

Skybook部署到14路径

web服务器:

jetty路径:/opt/zimbra/jetty

 

应用路径

/opt/zimbra/jetty/webapps/skyBook
/opt/zimbra/jetty/webapps/chat
 

配置路径

/opt/zimbra/jetty/etc/jetty.xml.in(修改此文件,启动后会自动生成jetty.xml

/opt/zimbra/jetty/etc/jetty.xml

 

日志文件

/opt/zimbra/log/mailbox.log(程序运行期出错,请查看此文件,如今天的ProductImageVo ClassCastException

/opt/zimbra/log/zmmailboxd.out(程序启动时如果出错,请查看此log文件,web.xml配置错误启动出错)

 

启动

skybook由于与zimbra一同启动,故用此命令启动:

/opt/zimbra/bin/zmmailboxdctl restart #重启
/opt/zimbra/bin/zmmailboxdctl stop #停止
/opt/zimbra/bin/zmmailboxdctl start #启动

 

Mysql数据备份与恢复

 

导入导出数据
数据导出:mysqldump --default-character-set=gbk db > db.sql
数据导入:mysql --default-character-set=gbk db < db.sql

修改字符集
alter database da_name default character set 'gbk'
set names 'gbk'

set names gbk告诉mysql,接下来的数据将以该编码方式传输,等同于:
SET character_set_client = gbk;
SET character_set_results = gbk;
SET character_set_connection = gbk;

 

查看当前的编码
通过status指令查看当前的编码
mysql> status;
    Server characterset:    latin1
    Db     characterset:    gbk
    Client characterset:    gbk
    Conn. characterset:    gbk

导入

 

我们转换成gbk后的文件
mysql> source base_user_gbk.sql;

创建用户

mysql> CREATE USER yy IDENTIFIED BY '123';
yy表示你要建立的用户名,后面的123表示密码
上面建立的用户可以在任何地方登陆。

如果要限制在固定地址登陆,比如localhost 登陆:
mysql> CREATE USER yy@localhost IDENTIFIED BY '123';

mysql> GRANT ALL PRIVILEGES ON *.* TO user@localhost

grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
格式:grant select on 数据库.* to 用户名@登录主机identified by "密码"

修改密码
mysql> grant   all   privileges   on   pureftpd.*   to   koko@localhost   identified   by   'mimi'; 

刷新flush
mysql> flush privileges;



查看用户信息
mysql> select host,user from mysql.user;

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics