Changeset 14524 for greenstone3/trunk


Ignore:
Timestamp:
2007-09-17T15:18:14+12:00 (17 years ago)
Author:
qq6
Message:

the web page is redirect to an external link of "el=" is found from the querystring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r14498 r14524  
    162162     
    163163      message_router.setSiteName(site_name);
     164      message_router.setLibraryName(library_name);
    164165      message_router.configure();
    165166      this.recept.setMessageRouter(message_router);
     
    272273    throws ServletException, IOException {
    273274    logUsageInfo (request);
    274     //logger.info("---------------------------------------------------");
     275
     276    String query_string = request.getQueryString();
     277    if (query_string!=null){
     278    String[] query_arr = query_string.split("&");
     279    boolean redirect = false;
     280    String href = null;
     281    String rl = null;
     282    for (int i=0;i<query_arr.length;i++){
     283        if (query_arr[i].startsWith("el")){
     284        redirect = true;
     285        }else if(query_arr[i].startsWith("href")){
     286        href = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length());
     287        href = href.replaceAll("%2f", "/");
     288        href = href.replaceAll("%7e", "~");
     289        href = href.replaceAll("%3f", "?");
     290        href = href.replaceAll("%3A", "\\:");
     291        }else if(query_arr[i].startsWith("rl")){
     292        rl = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length());
     293        }
     294    }
     295    //if query_string contains "el=", the web page will be redirected to the external URl, otherwise a greenstone page with an external URL will be displayed
     296    //"rl=0" this is an external link
     297    //"rl=1" this is an internal link
     298    if ((redirect) && (href != null) && (rl.equals("0"))){// This is an external link, the web page is re-directed to the external URL (&el=&rl=0&href="http://...")
     299        response.setContentType("text/xml");
     300        response.sendRedirect(href);
     301    }
     302    }
    275303    // Nested Diagnostic Configurator to identify the client for
    276304   
Note: See TracChangeset for help on using the changeset viewer.