Still under solve MSN appears offline but online problem

Having under solving MSN appears offline but I am truly online problem. Searched for this problem around 4 hours still no any good news from there, I only can emailed to MSN customer support. Say I want to find the link to the customer support also have find a long time. I now can invite friends into my group, and I may send files to my friend; however, my friend cannot invite me into their group and cannot also send me any files. It is frustrating and inconvenience.

I saw a lot of solution online but there are no clear solutions. One of it is to reinstall MSN messenger, I have using Window Clean Up Installer also cannot used. Later I follow Jonathan posts on somewhere forum said that to delete MSN contact cache, still cannot. I login to meebo or ebuddy, still failed for me. I remember about several days ago, I try to make me offline (before that I always remain busy), then later I change back to busy status, then the problem started to arise. My friend cannot see me online, only can use guessing, to guess me whether I am online or offline. They cannot directly send me file but hopefully Hotmail works.

My email is fyhao@fymcs.com, and using the latest MSN Messenger now, if who are from Microsoft or familiar with it, can you help me how to solve this problem? Thanks.

Java Version of Discuz! authcode()

Discuz! is a forum software developed by Comsenz. authcode is a function that able to encrypt the string into human unreadable form and also can decrypt it. The beauty inside is how many times you make encryption, the encrypted string is not same at all, but when you make decryption it is able to change back to original string. Comsenz had made great contribution to the PHP world by authcode function, whereas nowadays many of the PHP developers are using authcode function in their project, even me.

Now, I would like to find some way using Java to manipulate authcode function. However my skill is not talentable from getting authcode function works. Therefore, I searched online and found that the post rain.xie posted on Javaeye Forum. I changed a little bit from there to be hosted on Google Appengine along with my project. Notice that the implementation of Base64 Decoder I am using Google Appengine Library API.

Here is the code:

AuthCode.java

package com.fyhao.gift.helper;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Calendar;
import java.util.Random;
import com.google.appengine.repackaged.com.google.common.util.Base64;

public class AuthCode {

    public enum DiscuzAuthcodeMode {
        Encode, Decode
    };

    public static String CutString(String str, int startIndex, int length) {
        if (startIndex >= 0) {
            if (length < 0) {
                length = length * -1;
                if (startIndex – length < 0) {
                    length = startIndex;
                    startIndex = 0;
                } else {
                    startIndex = startIndex – length;
                }
            }

            if (startIndex > str.length()) {
                return "";
            }

        } else {
            if (length < 0) {
                return "";
            } else {
                if (length + startIndex > 0) {
                    length = length + startIndex;
                    startIndex = 0;
                } else {
                    return "";
                }
            }
        }

        if (str.length() – startIndex < length) {

            length = str.length() – startIndex;
        }

        return str.substring(startIndex, startIndex + length);
    }

    public static String CutString(String str, int startIndex) {
        return CutString(str, startIndex, str.length());
    }

    public static String MD5(String pass) {
        byte[] defaultBytes = pass.getBytes();
        try{
             MessageDigest algorithm = MessageDigest.getInstance("MD5");
             algorithm.reset();
             algorithm.update(defaultBytes);
             byte messageDigest[] = algorithm.digest();

             StringBuffer hexString = new StringBuffer();
             for (int i=0;i<messageDigest.length;i++) {
            String hex = Integer.toHexString(0xFF & messageDigest[i]);
            if(hex.length()==1)
            hexString.append(‘0’);

            hexString.append(hex);
             }
             return hexString.toString();
        }
        catch(NoSuchAlgorithmException nsae){
        }

        return "";
    }

    public static boolean StrIsNullOrEmpty(String str) {
        //#if NET1
        if (str == null || str.trim().equals("")) {
            return true;
        }

        return false;
    }

    static private byte[] GetKey(byte[] pass, int kLen) {
        byte[] mBox = new byte[kLen];

        for (int i = 0; i < kLen; i++) {
            mBox[i] = (byte) i;
        }

        int j = 0;
        for (int i = 0; i < kLen; i++) {

            j = (j + (int) ((mBox[i] + 256) % 256) + pass[i % pass.length])
                    % kLen;

            byte temp = mBox[i];
            mBox[i] = mBox[j];
            mBox[j] = temp;
        }

        return mBox;
    }

    public static String RandomString(int lens) {
        char[] CharArray = { ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘j’, ‘k’,
                ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’,
                ‘x’, ‘y’, ‘z’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’ };
        int clens = CharArray.length;
        String sCode = "";
        Random random = new Random();
        for (int i = 0; i < lens; i++) {
            sCode += CharArray[Math.abs(random.nextInt(clens))];
        }
        return sCode;
    }

    public static String authcodeEncode(String source, String key, int expiry) {
        return authcode(source, key, DiscuzAuthcodeMode.Encode, expiry);

    }

    public static String authcodeEncode(String source, String key) {
        return authcode(source, key, DiscuzAuthcodeMode.Encode, 0);

    }

    public static String authcodeDecode(String source, String key) {
        return authcode(source, key, DiscuzAuthcodeMode.Decode, 0);

    }

    private static String authcode(String source, String key,
            DiscuzAuthcodeMode operation, int expiry) {
        try {
            if (source == null || key == null) {
                return "";
            }

            int ckey_length = 4;
            String keya, keyb, keyc, cryptkey, result;

            key = MD5(key);

            keya = MD5(CutString(key, 0, 16));

            keyb = MD5(CutString(key, 16, 16));

            keyc = ckey_length > 0 ? (operation == DiscuzAuthcodeMode.Decode ? CutString(
                    source, 0, ckey_length)
                    : RandomString(ckey_length))
                    : "";

            cryptkey = keya + MD5(keya + keyc);

            if (operation == DiscuzAuthcodeMode.Decode) {
                byte[] temp;
                temp = Base64.decode(CutString(source, ckey_length));
                result = new String(RC4(temp, cryptkey));
                if (CutString(result, 10, 16).equals(CutString(MD5(CutString(result, 26) + keyb), 0, 16))) {
                    return CutString(result, 26);
                } else {
                    temp = Base64.decode(CutString(source+"=", ckey_length));
                    result = new String(RC4(temp, cryptkey));
                    if (CutString(result, 10, 16).equals(CutString(MD5(CutString(result, 26) + keyb), 0, 16))) {
                        return CutString(result, 26);
                    } else {
                        temp = Base64.decode(CutString(source+"==", ckey_length));
                        result = new String(RC4(temp, cryptkey));
                        if (CutString(result, 10, 16).equals(CutString(MD5(CutString(result, 26) + keyb), 0, 16))) {
                            return CutString(result, 26);
                        }else{
                            return "2";
                        }
                    }
                }
            } else {
                source = "0000000000" + CutString(MD5(source + keyb), 0, 16)
                        + source;

                byte[] temp = RC4(source.getBytes("GBK"), cryptkey);

                return keyc + Base64.encode(temp);

            }
        } catch (Exception e) {
            return "";
        }

    }

    private static byte[] RC4(byte[] input, String pass) {
        if (input == null || pass == null)
            return null;

        byte[] output = new byte[input.length];
        byte[] mBox = GetKey(pass.getBytes(), 256);

        int i = 0;
        int j = 0;

        for (int offset = 0; offset < input.length; offset++) {
            i = (i + 1) % mBox.length;
            j = (j + (int) ((mBox[i] + 256) % 256)) % mBox.length;

            byte temp = mBox[i];
            mBox[i] = mBox[j];
            mBox[j] = temp;
            byte a = input[offset];

            byte b = mBox[(toInt(mBox[i]) + toInt(mBox[j])) % mBox.length];

            output[offset] = (byte) ((int) a ^ (int) toInt(b));
        }

        return output;
    }

    public static int toInt(byte b) {
        return (int) ((b + 256) % 256);
    }

    public long getUnixTimestamp() {
        Calendar cal = Calendar.getInstance();
        return cal.getTimeInMillis() / 1000;
    }

}

Come back to INTI, Some ideas

Just came back to INTI and I will open school next monday, the next two days. In this semester, it is my begin of third year, and I will have to do the final year project (double module), in order to achieve the honour degree. Next week I think will be busy because need to find lecturer to discuss some ideas. I have a lot of broken ideas, I am unclear what topic to do, so only find lecturer to talk all of my ideas to connect one topic out.

Since holiday, I learnt the Google Appengine and also learnt Business component (EJB), I know the basic servlet and JPA to do the Appengine application. I am learnt using that to develop basic Facebook App. I think if possible develop Facebook App using Java or PHP (my own hosting), to be one of the options.

One year ago, I also think that I can develop a new social networking service. Having a new style, new shape, of the SNS website. Since I learnt the Facebook, Twitter, Google Wave, Plurk; there are different SNS websites with different styles, different specialty, and now to be successful. I think that is it possible to research a new style of SNS that will more suitable to the user. I also think that, from year ago, Web 1.0 emerging into Web 2.0, CMS to SNS, my question is, what is the next step? SNS to WHAT???

After I learnt AI, I also got one ideas, that develop one independent, pluggable components that having mechanisms to translate the user’s mind request, and return the response that the user really want. The result returned by the components is a specific or maybe only one, not like Google give you a lot of options. And this component can be reused by different kinds of website. However, after some months, I found that Baidu.com and some other service already have some development of this kind stuff. Baidu.com of China has one development called Box Computing, heard that it is to be fight with Google Cloud Computing.

I have one friend who working in JB company told me that having one thing that his company is going to develop or research, a distributed commerce using Java. Previously I learnt EJB, but he told me most of the company is not using EJB but using Spring and other lightweight component and using their own custom framework to develop their products. And they want start to change their framework into cluster, he said. He asked me how the Facebook, Google handle the distributed component. Even PHP can use Hadoop like Facebook, when handle distributed photos. What my previous knowledge on distributed components is on EJB, Appengine (Cloud computing), Amazon Web Service. Maybe one of the title is, refine and research a new and better distributed architecture design that can cope the existing problem. Or examine is it CAT is true, this theory said only two of three (CAT) can achieve during development of distributed components.

To be continued….

今天很幸福

虽然只是远远的在一旁看着她,和她少话,心里却觉得已经很满足了,有种难以形容的很幸福的感觉。她还是那么的样子,她全身散发着一种独特的气质。

今天我们几个老人去CS的麦当劳聚聚,只有我们几个人,还以为会有很多我不认识的老人,所以在昨天有和嘉蔚说记得等我,怕他们不知道我所以没等我所以。。。所以。。。竟然,我还不是准时到的。(早了10分钟,呵呵)看着思勇,她,荣伟,嘉蔚,瑞勤在麦当劳的交流,突然想去过了一个人的一年,又回到了小时候,中学的时候,几个电协的人在那里聊天,虽然我没有参与聊天,但至少也有当听众,今年也不例外。看起来和年前一样安静,但其实我心里一直想我应该勇敢的参他们话题。但今天我还是不能参到他们的话题。今天就做了一些研究,研究他们的话题是怎么找出来的。让我发现了一个窍门,就是随兴想到什么就讲什么。

今年,少了群智,小狗的老婆,还有我那届的快讯组组长,就感觉真的少了什么元素,化学反应式不大成立了。但我不知道,到底是什么,我只听他们说他们去马六甲了。

接下来几天就是圣诞节,没有任何决定的话,应该都会留在家,上着清心论坛和Facebook度过圣诞节吧!

fyhao.com upgraded to WordPress 2.8.6

刚把 fyhao.com 升级至最新版 WordPress 2.8.6,并选择自动更新选项。即使是安装插件都能采用自动化,真的是非常的方便。如果 Discuz! 也能这样的话,也就很好了。Discuz! 论坛的新核心插件系统是一个进展,若也能做到自动更新不用用到FTP软件的,但只需输入FTP资料系统就会自动下载,解压,安装,这样就省了很多很多时间了。

Just upgraded fyhao.com into latest version of WordPress 2.8.6, and select the auto upgrade option. Feel that it is very nice to use the auto upgrade option because it reduce the time to access the FTP software and waiting to connect the FTP server. It just requires user entering the FTP information, and it will automatically download the upgraded files and unzip it, then installed selfly…

Simple URL routing in Servlet

I have made a simple URL routing using servlet in Java. Using MainServlet as the front controller, then decide which service to call.

I have defined MainServlet.java as the Front controller, Service.java as the parent base of service, then GiftService.java for the actual service that will be carried out for action. MainServlet.java will be able to examine the URL, for example by the form of /Gift/send , it will call GiftService class and send method in the GiftService.java. Before that it calls the init method inside Service.java to transfer some instance that maybe used by the Services classes, such as HttpServletRequest, HttpServletResponse, and etc.

MainServlet.java

package com.fyhao.test;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MainServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = request.getPathInfo();
        try {
            String[] parts = path.split("/");
            if(parts.length >= 2) {
                try {
                    Class iClass = Class.forName("com.fyhao.test." + parts[1] + "Service");
                    Method init;
                    Constructor con;
                    Object myClass;
                    try {
                        init = iClass.getMethod("init", new Class[] {HttpServlet.class, HttpServletRequest.class, HttpServletResponse.class, String[].class});
                        con = iClass.getConstructor(new Class[] {});
                        myClass = con.newInstance(new Object[] {});
                        init.invoke(myClass, new Object[]{this, request, response, parts});
                    } catch (NoSuchMethodException ex) {
                        System.err.println("Please define init method on " + parts[1] + "Service");
                        return;
                    } catch (Exception ex) {
                        System.err.println("init exception");
                        return;
                    }
                    Method m;
                    if(parts.length >= 3) {
                        try {
                            m = iClass.getMethod(parts[2], null);
                            m.invoke(myClass);
                        } catch (NoSuchMethodException ex) {
                            try {
                                m = iClass.getMethod("main", null);
                                m.invoke(myClass);
                            } catch (Exception exc) {
                                System.err.println("Please define a main service method on " + parts[1] + "Service");
                                return;
                            }
                        } catch (Exception ex) {
                            System.err.println("service method exception");
                            return;
                        }
                    } else {
                        try {
                            m = iClass.getMethod("main", null);
                            m.invoke(myClass);
                        } catch (Exception exc) {
                            System.err.println("Please define a main service method on " + parts[1] + "Service");
                            return;
                        }
                    }
                } catch (ClassNotFoundException ex) {
                    defaultAction(request, response);
                }
            } else {
                defaultAction(request, response);
            }
        } catch (NullPointerException ex) {
            defaultAction(request, response);
            return;
        }
        //serviceclass("Gift", "send");
    }
    public void defaultAction(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("default action here: " + request.getPathInfo());
    }
    // leave for reference
    public void serviceclass(String c, String service) {
        try {
            Class iClass = Class.forName("com.fyhao.test." + c + "Service");
            Method init = iClass.getMethod("init", null);
            Method m = iClass.getMethod(service, null);
            Constructor con = iClass.getConstructor(new Class[] {});
            Object myClass = con.newInstance(new Object[] {});
            m.invoke(myClass);
        } catch( Exception ex) {}
    }
}

 

Service.java

package com.fyhao.test;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Service {

    HttpServlet servlet;
    HttpServletRequest request;
    HttpServletResponse response;
    String[] parts;
    public void init(HttpServlet servlet, HttpServletRequest request, HttpServletResponse response, String[] parts) {
        this.servlet = servlet;
        this.request = request;
        this.response = response;
        this.parts = parts;
    }
}

GiftService.java

package com.fyhao.test;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GiftService extends Service {

    public void main() {
        System.out.println("default main methods: ");
    }
    public void send() {
        System.out.println("sending");
    }
}

 

All right, this is the coding done by me during first learning of using java reflection API, which is the great API to directly find the class by the full name, and dynamically initializes and calling its methods. However, I think it would have other better ways of doing this. Please tell me if you know. Thanks.

Imgshow 论坛插件是时候做更新了

一年前,写了一个 Imgshow 插件,用来 show 图片的,是时候做一些更新了。在程序后台部分的代码显得太枯燥了,这部分我需要改进一下我的代码,使之更加的严谨。另外,对于我设计的流程,所谓的旋转特效有分google图片索索和自定义选项,但第二版开始就只支持自定义图片。所谓第二版的图片特效将必须收集各种类型的 gallery 放上来,整合进去这个系统。我的问题是,要不把第二版的特效和第一个特效放在一起吧?但是,因为历史原因,很多帖子都这样发出来了,为了兼容现有论坛所发的帖子的 Imgshow 插件的代码可以显示正常,在 Discuz! 代码部分绝对不能大改变。当然他们发的代码是一样,但所显示出来的 Gallery 种类将会改变,因为现有的 Gallery 种类不是太丑就是一堆不解问题,是时候找几个稳定的放上来了。

所谓自定义其实只是停留在自定义图片,文字,甚至链接,但是不至于设定显示的宽度和高度,也就是自定义还不是很开放。希望能够在这点下个功夫。

由于设计太烂的问题,宣传又不好,所以这个插件的发展不是很好,这方面的确,要好好看看了。

说到 imgshow Facebook 版本,我也想要如何改进了,多加一些互动性的元素吧!我打算可以让每一个人打一个关键词,设立一个 Imgshow 页面,然后放一个 description,大家可以来 comment,然后或许可以给他打分。然后那个图片可以是 Google 自动搜索,或者自己自定义。或许在宣传某个网址,以此来当作关键词,或者播放自己相簿里面的照片吧!这方面需要想想,大家有什么意见可以提出哦!