亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? converturl.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/i18n/tool/ConvertURL.java,v 1.9 2004/04/08 19:28:11 minhnn Exp $
 * $Revision: 1.9 $
 * $Date: 2004/04/08 19:28:11 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002, 2003 by MyVietnam.net
 *
 * 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; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding MyVietnam and MyVietnam CoreLib
 * MUST remain intact in the scripts and source code.
 *
 * 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.
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Minh Nguyen  minhnn@MyVietnam.net
 * @author: Mai  Nguyen  mai.nh@MyVietnam.net
 */
//package test;
import java.io.*;
import java.util.*;

public class ConvertURL {

    static String convertURL(String href) {
        StringBuffer output = new StringBuffer();

        if (href.startsWith("http") == false &&
            href.startsWith("javascript:") == false &&
            href.startsWith("mailto:") == false &&
            href.startsWith("aim:") == false &&
            href.startsWith("<%=response.encodeURL") == false) {
            href = href.replaceAll("<%=", "\" + ");
            href = href.replaceAll("%>", " + \"");

            boolean redundantEnd = false;
            if (href.endsWith(" + \"")) {
                redundantEnd = true;
                //System.out.println("redundantEnd = true");
                href = href.substring(0, href.length()-4);
            }

            boolean redundantBegin = false;
            if (href.startsWith("\" + ")) {
                redundantBegin = true;
                //System.out.println("redundantBegin = true");
                href = href.substring(4);
            }

            if (redundantBegin) {
                output.append("<%=response.encodeURL(");
            }
            else {
                output.append("<%=response.encodeURL(\"");
            }

            output.append(href);

            if (redundantEnd) {
                output.append(")%>");
            } else {
                output.append("\")%>");
            }
        } else {
            return href;
        }
        return output.toString();
    }

    static String convertTagA(String tagA) throws IllegalArgumentException {
        String output = "";
        if (tagA.startsWith("<a ") == false) {
            throw new IllegalArgumentException();
        }
        if (tagA.endsWith(">") == false) {
            throw new IllegalArgumentException();
        }

        if (tagA.indexOf('>') != tagA.lastIndexOf('>')) {
            //throw new IllegalArgumentException();
        }
        int firstIndex = tagA.indexOf("href=\"");
        if (firstIndex == -1) {
            System.out.println("WARNING: TagA does not have href: " + tagA);
            return tagA;
        }
        int lastIndex = tagA.indexOf("\"", firstIndex + 6);

        String begin = tagA.substring(0, firstIndex + 6);
        String href = tagA.substring(firstIndex + 6, lastIndex);
        String end = tagA.substring(lastIndex);

//        System.out.println("begin = " + begin);
//        System.out.println("href = " + href);
//        System.out.println("end = " + end);

        output = begin + convertURL(href) + end;

        return output;
    }

    static String convertTagForm(String tagForm) throws IllegalArgumentException {
        String output = "";
        if (tagForm.startsWith("<form ") == false) {
            throw new IllegalArgumentException();
        }
        if (tagForm.endsWith(">") == false) {
            throw new IllegalArgumentException();
        }

        if (tagForm.indexOf('>') != tagForm.lastIndexOf('>')) {
            //throw new IllegalArgumentException();
        }
        int firstIndex = tagForm.indexOf("action=\"");
        if (firstIndex == -1) {
            System.out.println("WARNING: TagForm does not have action: " + tagForm);
            return tagForm;
        }
        int lastIndex = tagForm.indexOf("\"", firstIndex + 8);

        String begin = tagForm.substring(0, firstIndex + 8);
        String href = tagForm.substring(firstIndex + 8, lastIndex);
        String end = tagForm.substring(lastIndex);

//        System.out.println("begin = " + begin);
//        System.out.println("action = " + href);
//        System.out.println("end = " + end);

        output = begin + convertURL(href) + end;

        return output;
    }

    static String convertTagMeta(String tagMeta) throws IllegalArgumentException {
        String output = "";
        if (tagMeta.startsWith("<meta ") == false) {
            throw new IllegalArgumentException();
        }
        if (tagMeta.endsWith(">") == false) {
            throw new IllegalArgumentException();
        }

        if (tagMeta.indexOf('>') != tagMeta.lastIndexOf('>')) {
            //throw new IllegalArgumentException();
        }
        int firstIndex = tagMeta.indexOf("url=");
        if (firstIndex == -1) {
            System.out.println("WARNING: TagMeta does not have url=: " + tagMeta);
            return tagMeta;
        }
        int lastIndex = tagMeta.indexOf("'", firstIndex + 4);

        String begin = tagMeta.substring(0, firstIndex + 4);
        String href = tagMeta.substring(firstIndex + 4, lastIndex);
        String end = tagMeta.substring(lastIndex);

//        System.out.println("begin = " + begin);
//        System.out.println("action = " + href);
//        System.out.println("end = " + end);

        output = begin + convertURL(href) + end;

        return output;
    }

    static String convertLine(String line, String startToken, String endToken) throws IllegalArgumentException {
        int startIndex = -1;
        int endIndex = -1;
outer:
        while (true) {
            startIndex = line.indexOf(startToken, endIndex + 1);
            if (startIndex < 0 || startIndex + 1 >= line.length()) {
                break;
            }
            int beginSearchEndIndex = startIndex + 1;
            while (true) {
                endIndex = line.indexOf(endToken, beginSearchEndIndex);
                if (endIndex < 0) break;
                char charBefore = line.charAt(endIndex - 1);
                if (charBefore == '%') {
                    beginSearchEndIndex = endIndex + 1;
                } else {
                    break;
                }
            }
            if (endIndex < 0) {
                break;
            }
            String matches = line.substring(startIndex, endIndex+1);
            //log("match = " + matches + " resource = " + (String) resourceMap.get(matches), Project.MSG_WARN);
            //If there is a white space or = or :, then
            //it isn't to be treated as a valid key.
            for (int k = 0; k < matches.length(); k++) {
                /*
                char c = matches.charAt(k);
                if (c == ':' ||
                    c == '=' ||
                    Character.isSpaceChar(c)) {
                    endIndex = endIndex - 1;
                    continue outer;
                }
            */
            }
            String replace = null;
            if (startToken.equals("<a ")) {
                replace = (String) convertTagA(matches);
            } else if (startToken.equals("<form ")) {
                replace = (String) convertTagForm(matches);
            } else if (startToken.equals("<meta ")) {
                replace = (String) convertTagMeta(matches);
            } else {
                throw new IllegalArgumentException();
            }

            //If the key hasn't been loaded into resourceMap,
            //use the key itself as the value also.
            if (replace == null) {
                //log("Warning: The key: " + matches + " hasn't been defined.", Project.MSG_WARN);
                replace = matches;
            }
            line = line.substring(0, startIndex)
                + replace
                + line.substring(endIndex + 1);
            // minhnn: I dont know if the original code has bug
            // I changed from "+ 1" to "- 1" and it works well
            endIndex = startIndex + replace.length() - 1;
            if (endIndex + 1 >= line.length()) {
                break;
            }
        }
        return line;
    }

    static String convertLine(String line) throws Exception {
        try {
            String linewithA = convertLine(line, "<a ", ">");
            String linewithAandForm = convertLine(linewithA, "<form ", ">");
            String linewithAandFormAndMeta = convertLine(linewithAandForm, "<meta ", ">");
            return linewithAandFormAndMeta;
        } catch (Exception ex) {
            System.out.println("line = " + line);
            throw ex;
        }
    }

    /**
     * @todo: return ArrayList of String
     */
    public static ArrayList getContent(String fileName) {
        ArrayList arrLine= new ArrayList();
        File file = new File(fileName);
        if (!file.exists()) {
            return null;
        } else {
            try {
                BufferedReader reader = new BufferedReader(new FileReader(file));
                String inLine = reader.readLine();
                while (inLine != null) {
                    arrLine.add(inLine + "\n");
                    //content += inLine + "\n";
                    inLine = reader.readLine();
                }
                reader.close();
                return arrLine;
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    }

    public static void convertFile(String srcFilename, String descFilename)
        throws Exception {
        ArrayList descArr = new ArrayList();
        Collection tempArr = getContent(srcFilename);
        for (Iterator iterator = tempArr.iterator(); iterator.hasNext(); ) {
            descArr.add(convertLine((String) iterator.next()));
        }
        ExportContentToFile(descArr, descFilename);
    }

    public static void ExportContentToFile(ArrayList lines, String fileName) {
        String curDir = System.getProperty("user.dir"); //Get Current dir
        try {
            BufferedWriter out = new BufferedWriter(new FileWriter(curDir + "/out/" + fileName));
            for (Iterator iterator = lines.iterator(); iterator.hasNext(); ) {
                //System.out.print(convertLine((String)iterator.next()));
                out.write((String) iterator.next());
            }
            out.close();
        } catch (IOException e) {
            System.out.print(e);
        }
    }

    public static void main(String[] args) throws Exception {
        //String href = "index";
        //String href = "index?forum=<%=forumid%>&a=true";
        //String correctOutput = "<%=response.encodeURL(context + \"index\")%>";

//        String tagA = "<a href=\"index?forum=<%=forumid%>&a=true\" class=\"topmenu\">";
//        String tagA = "<a href=\"listmembers\" class=\"topmenu\">";
//        String tagA = "<a href=\"<%=filename%>\" class=\"topmenu\">";
//        String tagA = "<a href=\"#\">";
//        String tagA = "<a href=\"javascript:smilie('[:&quot;>]')\">";
//        System.out.println("tagA = " + tagA);
//        System.out.println("output = " + convertTagA(tagA));

//        String tagMeta = "<meta http-equiv='refresh' content='3; url=viewthread?thread=<%=   threadID    %>&offset=<%=offset%>'>";
//        System.out.println("tagMeta = " + tagMeta);
//        System.out.println("output = " + convertTagMeta(tagMeta));

//        String tagForm = "<form action=\"addattachmentprocess\" method=\"post\" enctype=\"multipart/form-data\" name=\"submitform\">";
//        System.out.println("tagForm = " + tagForm);
//        System.out.println("output = " + convertTagForm(tagForm));


        //String line = "link 1 <a href=\"listmembers\" class=\"topmenu\"> link 2 <a href=\"index?forum=<%=forumid%>&a=true\" class=\"topmenu\"> form ne` <form action=\"addattachmentprocess\" method=\"post\" enctype=\"multipart/form-data\" name=\"submitform\">";
//        String line = "<td><a href=\"javascript:smilie('[:&quot;&gt;]')\"><img src=\"<%=contextPath%>/mvnplugin/mvnforum/images/emotion/blushing.gif\" alt=\"blushing\" border=\"0\"></a>&nbsp;</td>";
//        System.out.println("line = " + line);
//        System.out.println("output = " + convertLine(line));
        //convertFile("listmembers.jsp","b.txt");

        //convertFile("listrecentthreads.jsp","listrecentthreads.jsp");

        try {
            if (args[0].equals("all")) {
                String curDir = System.getProperty("user.dir"); //Get Current dir
                File dir = new File(curDir);
                if (dir.isFile()) throw new IOException("IOException -> BadInputException: not a directory.");
                File[] files = dir.listFiles();
                if (files != null) {
                    for (int i = 0; i < files.length; i++) {
                        File file = files[i];
                        if (file.isFile()) {
                            String absPath = file.getAbsolutePath();
                            if (absPath.endsWith(".jsp")) {
                                int lastIndex = absPath.lastIndexOf('\\');
                                String name = absPath.substring(lastIndex + 1);
                                System.out.println("name = " + name);
                                convertFile(name, name);
                            }
                        } else {
                            System.out.println("get folder = " + file);
                        }
                    }
                }//if
                dir.delete();
            } else {
                convertFile(args[0], args[0]);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三区在线观看| 国产精一区二区三区| 久久久综合精品| 日韩免费电影网站| 欧美一区二区精品在线| 99综合电影在线视频| 91猫先生在线| 5858s免费视频成人| 精品人在线二区三区| 亚洲精品一区二区三区精华液| 欧美一级夜夜爽| 国产人成一区二区三区影院| 国产人成亚洲第一网站在线播放| 国产精品国产三级国产普通话99| 中文字幕精品三区| 日韩精彩视频在线观看| 美女网站一区二区| 99re在线精品| 欧美三级韩国三级日本一级| 欧美精品一区二区久久婷婷| 国产精品国产三级国产a| 亚洲影视资源网| 国产毛片精品视频| 在线免费观看不卡av| 欧美一区二区在线视频| 中文字幕免费不卡| 日本大胆欧美人术艺术动态| 成人精品在线视频观看| 91精品久久久久久久99蜜桃| 国产欧美va欧美不卡在线| 蜜桃av一区二区| 欧美曰成人黄网| 亚洲视频资源在线| 国产成人av电影在线观看| 欧美图片一区二区三区| 国产精品美女www爽爽爽| 美女被吸乳得到大胸91| 欧美视频精品在线观看| 亚洲欧美日韩在线| 91啦中文在线观看| 国产精品无遮挡| 国产成人午夜精品5599| 久久婷婷色综合| 精彩视频一区二区三区| 久久综合成人精品亚洲另类欧美 | 日本一区二区三区dvd视频在线| 亚洲国产精品一区二区www在线| 91久久久免费一区二区| 一区二区三区四区高清精品免费观看| 成人午夜电影网站| 欧美激情一区二区三区在线| 国产精品一区二区果冻传媒| 国产欧美视频一区二区| 成人午夜视频福利| 亚洲美女在线国产| 欧美一区二区三区视频在线 | 久久亚洲欧美国产精品乐播 | 日韩情涩欧美日韩视频| 日本中文一区二区三区| 欧美精品一区二区三区一线天视频| 欧美日韩国产综合草草| 精品国产亚洲在线| 91理论电影在线观看| 男人的天堂亚洲一区| 国产午夜精品一区二区三区嫩草 | 欧美日韩mp4| 国产一区二区按摩在线观看| 最新成人av在线| 日韩一区二区三区在线观看| 成人一级片在线观看| 午夜欧美电影在线观看| 日韩一区有码在线| 欧美久久久一区| 99re成人在线| 成人免费av资源| 老司机午夜精品99久久| 午夜国产不卡在线观看视频| 国产精品乱码久久久久久| 欧美成人一区二区三区在线观看| 91在线免费视频观看| 国产一区二区在线观看免费| 日韩成人一级大片| 亚洲国产精品久久久久婷婷884 | 久久99深爱久久99精品| 亚洲成人你懂的| 午夜亚洲国产au精品一区二区| 中文字幕中文乱码欧美一区二区| 精品国产人成亚洲区| 欧美成人a∨高清免费观看| 欧美精品久久99| 欧美一卡二卡在线| 日韩午夜精品视频| 久久精品一区二区三区四区| 亚洲精品在线免费观看视频| 久久伊人蜜桃av一区二区| 精品久久久久久综合日本欧美| 日韩午夜中文字幕| 久久众筹精品私拍模特| 中文字幕高清不卡| 最好看的中文字幕久久| 又紧又大又爽精品一区二区| 亚洲成a人v欧美综合天堂下载 | 91福利国产成人精品照片| 欧美日韩在线综合| 日韩欧美美女一区二区三区| 久久女同精品一区二区| 亚洲激情自拍视频| 美女视频第一区二区三区免费观看网站| 激情欧美日韩一区二区| 色av综合在线| 久久综合一区二区| 综合久久久久久| 久久99国产精品久久99果冻传媒| 国产成人综合在线| 欧美一区二区视频免费观看| 国产三级精品视频| 亚洲电影中文字幕在线观看| 粉嫩13p一区二区三区| 777久久久精品| 亚洲激情第一区| 丁香桃色午夜亚洲一区二区三区| 欧洲国产伦久久久久久久| 欧美国产激情二区三区| 另类小说综合欧美亚洲| 欧美日韩一区在线| 亚洲观看高清完整版在线观看| 国产精品性做久久久久久| 国产亚洲一二三区| 在线视频综合导航| 看片的网站亚洲| 成人性视频免费网站| 日韩精品一区二区三区四区| 亚洲综合久久av| 欧美视频一区二区三区| 亚洲乱码国产乱码精品精小说| 成人性生交大合| 亚洲色图第一区| 91亚洲资源网| 亚洲成av人影院| 日本精品一区二区三区四区的功能| 欧美精品一区二区三区在线播放| 久久成人免费日本黄色| 日韩欧美国产午夜精品| 国内精品久久久久影院薰衣草| 久久久国产综合精品女国产盗摄| 久久99精品国产91久久来源| 久久午夜电影网| 99re成人在线| 欧美aⅴ一区二区三区视频| 26uuu亚洲综合色欧美| 成人网页在线观看| 日日摸夜夜添夜夜添精品视频| 欧美电视剧在线观看完整版| 国产69精品久久久久毛片| 亚洲欧美福利一区二区| 欧美一级片在线观看| 粉嫩高潮美女一区二区三区| 亚洲成人手机在线| 欧美经典一区二区| 欧美日韩黄视频| 成人h动漫精品一区二区| 亚洲成人一区二区在线观看| 精品国内二区三区| 91精品一区二区三区在线观看| 国产99一区视频免费| 久久国产婷婷国产香蕉| 自拍偷拍国产亚洲| 久久久99精品免费观看不卡| 欧美日韩综合在线| 91黄色激情网站| 成人h动漫精品一区二区| 国产精品一品二品| 久久99久久99精品免视看婷婷 | 国产成人亚洲综合a∨婷婷| 日本欧美肥老太交大片| 亚洲mv在线观看| 亚洲午夜av在线| 亚洲成a人片综合在线| 亚洲第一狼人社区| 日韩中文字幕麻豆| 日韩不卡一区二区三区| 琪琪久久久久日韩精品| 日本一区中文字幕| 久久精品国产精品亚洲红杏| 日本亚洲一区二区| 国内偷窥港台综合视频在线播放| 韩国欧美一区二区| 成人中文字幕合集| 99re热这里只有精品免费视频| 在线看一区二区| 欧美精品1区2区| 日本一区二区三区dvd视频在线| 国产精品乱码人人做人人爱 | 91丝袜美女网| 欧美日韩亚洲综合在线| 久久久综合九色合综国产精品| 国产欧美一区二区精品秋霞影院| 尤物av一区二区| 国产精品69毛片高清亚洲| 日本高清免费不卡视频|