001: package www;
002:
003: // welcome.java
004: // -----------------------
005: // part of the AnomicHTTPD caching proxy
006: // (C) by Michael Peter Christen; mc@anomic.de
007: // first published on http://www.anomic.de
008: // Frankfurt, Germany, 2004
009: //
010: // $LastChangedDate: 2008-01-06 19:23:38 +0000 (So, 06 Jan 2008) $
011: // $LastChangedRevision: 4305 $
012: // $LastChangedBy: orbiter $
013: //
014: // This program is free software; you can redistribute it and/or modify
015: // it under the terms of the GNU General Public License as published by
016: // the Free Software Foundation; either version 2 of the License, or
017: // (at your option) any later version.
018: //
019: // This program is distributed in the hope that it will be useful,
020: // but WITHOUT ANY WARRANTY; without even the implied warranty of
021: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022: // GNU General Public License for more details.
023: //
024: // You should have received a copy of the GNU General Public License
025: // along with this program; if not, write to the Free Software
026: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
027: //
028: // Using this software in any meaning (reading, learning, copying, compiling,
029: // running) means that you agree that the Author(s) is (are) not responsible
030: // for cost, loss of data or any harm that may be caused directly or indirectly
031: // by usage of this softare or this documentation. The usage of this software
032: // is on your own risk. The installation and usage (starting/running) of this
033: // software may allow other people or application to access your computer and
034: // any attached devices and is highly dependent on the configuration of the
035: // software which must be done by the user of the software; the author(s) is
036: // (are) also not responsible for proper configuration and usage of the
037: // software, even if provoked by documentation provided together with
038: // the software.
039: //
040: // Any changes to this file according to the GPL as documented in the file
041: // gpl.txt aside this file in the shipment you received can be done to the
042: // lines that follows this copyright notice here, but changes must not be
043: // done inside the copyright notive above. A re-distribution must contain
044: // the intact and unchanged copyright notice.
045: // Contributions and changes to the program code must be marked as such.
046: //
047: // You must compile this file with
048: // javac -classpath .:../classes index.java
049: // if the shell's current path is HTROOT
050:
051: import java.io.File;
052: import java.net.InetAddress;
053: import java.net.UnknownHostException;
054:
055: import de.anomic.http.httpHeader;
056: import de.anomic.server.serverCore;
057: import de.anomic.server.serverDomains;
058: import de.anomic.server.serverObjects;
059: import de.anomic.server.serverSwitch;
060: import de.anomic.yacy.yacyCore;
061: import de.anomic.yacy.yacySeed;
062:
063: public class welcome {
064:
065: public static serverObjects respond(httpHeader header,
066: serverObjects post, serverSwitch env) {
067: // return variable that accumulates replacements
068: final serverObjects prop = new serverObjects();
069:
070: // update seed info
071: yacyCore.peerActions.updateMySeed();
072:
073: prop.putHTML("peername", env
074: .getConfig("peerName", "<nameless>"));
075: prop.putHTML("peerdomain", env.getConfig("peerName",
076: "<nameless>").toLowerCase());
077: prop.putHTML("peeraddress", yacyCore.seedDB.mySeed()
078: .getPublicAddress());
079: prop.put("hostname", serverDomains.myPublicIP());
080: try {
081: prop.put("hostip", InetAddress.getByName(
082: serverDomains.myPublicIP()).getHostAddress());
083: } catch (UnknownHostException e) {
084: prop.put("hostip", "Unknown Host Exception");
085: }
086: prop.put("port", serverCore.getPortNr(env.getConfig("port",
087: "8080")));
088: prop.put("clientip", (String) header.get("CLIENTIP", ""));
089:
090: final String peertype = (yacyCore.seedDB.mySeed() == null) ? yacySeed.PEERTYPE_JUNIOR
091: : yacyCore.seedDB.mySeed().get(yacySeed.PEERTYPE,
092: yacySeed.PEERTYPE_VIRGIN);
093: final boolean senior = (peertype
094: .equals(yacySeed.PEERTYPE_SENIOR))
095: || (peertype.equals(yacySeed.PEERTYPE_PRINCIPAL));
096: if (senior) {
097: prop.put("couldcan", "can");
098: } else {
099: prop.put("couldcan", "could");
100: }
101: if (senior) {
102: prop
103: .put(
104: "seniorinfo",
105: "This peer runs in senior mode which means that your peer can be accessed using the addresses shown above.");
106: } else {
107: prop
108: .putHTML(
109: "seniorinfo",
110: "<b>Nobody can access your peer from the outside of your intranet. You must open your firewall and/or set a 'virtual server' in the settings of your router to enable access to the addresses as shown below.</b>");
111: }
112: File wwwpath = env.getConfigPath("htDocsPath", "DATA/HTDOCS");
113: prop.putHTML("wwwpath", wwwpath.isAbsolute() ? wwwpath
114: .getAbsolutePath() : "<application_root_path>/"
115: + env.getConfig("htDocsPath", "DATA/HTDOCS"));
116:
117: // return rewrite properties
118: return prop;
119: }
120: }
|