You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
5.1 KiB
124 lines
5.1 KiB
19 years ago
|
// EditProfile_p.java
|
||
|
// -----------------------
|
||
|
// part of YACY
|
||
17 years ago
|
// (C) by Michael Peter Christen; mc@yacy.net
|
||
19 years ago
|
// first published on http://www.anomic.de
|
||
|
// Frankfurt, Germany, 2004, 2005
|
||
20 years ago
|
//
|
||
19 years ago
|
// This File is contributed by Alexander Schier
|
||
20 years ago
|
//
|
||
19 years ago
|
// $LastChangedDate$
|
||
|
// $LastChangedRevision$
|
||
|
// $LastChangedBy$
|
||
20 years ago
|
//
|
||
19 years ago
|
// 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
|
||
|
// (at your option) any later version.
|
||
20 years ago
|
//
|
||
19 years ago
|
// 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.
|
||
20 years ago
|
//
|
||
19 years ago
|
// 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
|
||
20 years ago
|
|
||
19 years ago
|
// You must compile this file with
|
||
|
// javac -classpath .:../classes EditProfile_p.java
|
||
|
// if the shell's current path is HTROOT
|
||
20 years ago
|
|
||
2 years ago
|
package net.yacy.htroot;
|
||
|
|
||
20 years ago
|
import java.io.File;
|
||
|
import java.io.FileInputStream;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.util.Properties;
|
||
18 years ago
|
|
||
14 years ago
|
import net.yacy.cora.protocol.RequestHeader;
|
||
13 years ago
|
import net.yacy.peers.NewsPool;
|
||
13 years ago
|
import net.yacy.search.Switchboard;
|
||
12 years ago
|
import net.yacy.server.serverObjects;
|
||
|
import net.yacy.server.serverSwitch;
|
||
20 years ago
|
|
||
19 years ago
|
public class ConfigProfile_p {
|
||
19 years ago
|
|
||
13 years ago
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
||
16 years ago
|
final Switchboard sb = (Switchboard) env;
|
||
19 years ago
|
final serverObjects prop = new serverObjects();
|
||
|
final Properties profile = new Properties();
|
||
20 years ago
|
FileInputStream fileIn = null;
|
||
19 years ago
|
try {
|
||
20 years ago
|
fileIn = new FileInputStream(new File("DATA/SETTINGS/profile.txt"));
|
||
19 years ago
|
profile.load(fileIn);
|
||
17 years ago
|
} catch(final IOException e) {
|
||
20 years ago
|
} finally {
|
||
17 years ago
|
if (fileIn != null) try { fileIn.close(); } catch (final Exception e) {}
|
||
20 years ago
|
}
|
||
19 years ago
|
|
||
|
if (post != null && post.containsKey("set")) {
|
||
17 years ago
|
profile.setProperty("name", post.get("name"));
|
||
|
profile.setProperty("nickname", post.get("nickname"));
|
||
|
profile.setProperty("homepage", post.get("homepage"));
|
||
|
profile.setProperty("email", post.get("email"));
|
||
19 years ago
|
|
||
17 years ago
|
profile.setProperty("icq", post.get("icq"));
|
||
|
profile.setProperty("jabber", post.get("jabber"));
|
||
|
profile.setProperty("yahoo", post.get("yahoo"));
|
||
|
profile.setProperty("msn", post.get("msn"));
|
||
|
profile.setProperty("skype", post.get("skype"));
|
||
19 years ago
|
|
||
17 years ago
|
profile.setProperty("comment", post.get("comment"));
|
||
19 years ago
|
|
||
19 years ago
|
|
||
17 years ago
|
prop.putHTML("name", profile.getProperty("name", ""));
|
||
|
prop.putHTML("nickname", profile.getProperty("nickname", ""));
|
||
16 years ago
|
prop.putHTML("homepage", profile.getProperty("homepage", ""));
|
||
|
prop.putHTML("email", profile.getProperty("email", ""));
|
||
19 years ago
|
|
||
16 years ago
|
prop.putHTML("icq", profile.getProperty("icq", ""));
|
||
|
prop.putHTML("jabber", profile.getProperty("jabber", ""));
|
||
|
prop.putHTML("yahoo", profile.getProperty("yahoo", ""));
|
||
|
prop.putHTML("msn", profile.getProperty("msn", ""));
|
||
|
prop.putHTML("skype", profile.getProperty("skype", ""));
|
||
19 years ago
|
|
||
17 years ago
|
prop.putHTML("comment", profile.getProperty("comment", ""));
|
||
19 years ago
|
|
||
20 years ago
|
// write new values
|
||
|
FileOutputStream fileOut = null;
|
||
19 years ago
|
try {
|
||
20 years ago
|
fileOut = new FileOutputStream(new File("DATA/SETTINGS/profile.txt"));
|
||
|
profile.store(fileOut , null );
|
||
19 years ago
|
|
||
20 years ago
|
// generate a news message
|
||
17 years ago
|
final Properties news = profile;
|
||
19 years ago
|
news.remove("comment");
|
||
13 years ago
|
sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_PROFILE_UPDATE, news);
|
||
18 years ago
|
//yacyCore.newsPool.publishMyNews(new yacyNewsRecord(yacyNewsRecord.CATEGORY_PROFILE_UPDATE, profile));
|
||
17 years ago
|
} catch(final IOException e) {
|
||
20 years ago
|
} finally {
|
||
17 years ago
|
if (fileOut != null) try { fileOut.close(); } catch (final Exception e) {}
|
||
20 years ago
|
}
|
||
20 years ago
|
}
|
||
19 years ago
|
|
||
19 years ago
|
else{
|
||
17 years ago
|
prop.putHTML("name", profile.getProperty("name", ""));
|
||
|
prop.putHTML("nickname", profile.getProperty("nickname", ""));
|
||
16 years ago
|
prop.putHTML("homepage", profile.getProperty("homepage", ""));
|
||
|
prop.putHTML("email", profile.getProperty("email", ""));
|
||
|
|
||
|
prop.putHTML("icq", profile.getProperty("icq", ""));
|
||
|
prop.putHTML("jabber", profile.getProperty("jabber", ""));
|
||
|
prop.putHTML("yahoo", profile.getProperty("yahoo", ""));
|
||
|
prop.putHTML("msn", profile.getProperty("msn", ""));
|
||
|
prop.putHTML("skype", profile.getProperty("skype", ""));
|
||
19 years ago
|
|
||
17 years ago
|
prop.putHTML("comment", profile.getProperty("comment", ""));
|
||
19 years ago
|
}
|
||
19 years ago
|
|
||
20 years ago
|
return prop;
|
||
20 years ago
|
}
|
||
19 years ago
|
|
||
|
}
|