package cn.jcenterhome.web.action;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.phprpc.util.AssocArray;
import org.phprpc.util.PHPSerializer;
import org.wltea.analyzer.lucene.IKAnalyzer;
import org.wltea.analyzer.lucene.IKQueryParser;
import org.wltea.analyzer.lucene.IKSimilarity;
import cn.jcenterhome.service.AdminDeleteService;
import cn.jcenterhome.service.TreeService;
import cn.jcenterhome.util.BBCode;
import cn.jcenterhome.util.Common;
import cn.jcenterhome.util.CookieHelper;
import cn.jcenterhome.util.FileHelper;
import cn.jcenterhome.util.FileUploadUtil;
import cn.jcenterhome.util.JavaCenterHome;
import cn.jcenterhome.util.Serializer;
import cn.jcenterhome.vo.MessageVO;
import cn.jcenterhome.web.servlet.PostHandler;
public class CpAction extends BaseAction {
private String[] acs = {"space", "doing", "upload", "comment", "blog", "album", "relatekw", "common",
"class", "thread", "mtag", "poke", "friend", "avatar", "profile", "theme", "import",
"feed", "privacy", "pm", "share", "invite", "sendmail", "userapp", "task", "credit", "password",
"domain", "event", "poll", "topic", "click", "magic", "top", "videophoto", "gift"};
private final int text_max_size=65535;
@SuppressWarnings("unchecked")
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Map<String, Object> sGlobal = (Map<String, Object>) request.getAttribute("sGlobal");
Map<String, Object> sConfig = (Map<String, Object>) request.getAttribute("sConfig");
String ac = request.getParameter("ac");
if (ac == null || ac.length() == 0 || !Common.in_array(acs, ac)) {
ac = "profile";
}
int supeUID = (Integer) sGlobal.get("supe_uid");
if (supeUID == 0) {
String charset = JavaCenterHome.JCH_CHARSET;
if (request.getMethod().equals("GET")) {
CookieHelper.setCookie(request, response, "_refer", URLEncoder.encode((String) request
.getAttribute("requestURI"), charset));
} else {
CookieHelper.setCookie(request, response, "_refer", URLEncoder.encode("cp.jsp?ac=" + ac,
charset));
}
return showMessage(request, response, "to_login", "do.jsp?ac=" + sConfig.get("login_action"));
}
Map<String, Object> space = Common.getSpace(request, sGlobal, sConfig, supeUID);
if (space == null || space.size() == 0) {
return showMessage(request, response, "space_does_not_exist");
}
if (!ac.equals("common") && !ac.equals("pm")) {
String message = Common.checkClose(request, response, supeUID);
if (message != null) {
return showMessage(request, response, message);
}
if ((Integer) space.get("flag") == -1) {
return showMessage(request, response, "space_has_been_locked");
}
if (Common.checkPerm(request, response, "banvisit")) {
MessageVO msgVO = Common.ckSpaceLog(request);
if (msgVO != null) {
return showMessage(request, response, msgVO);
}
return showMessage(request, response, "you_do_not_have_permission_to_visit");
}
if (ac.equals("userapp") && !Common.checkPerm(request, response, "allowmyop")) {
return showMessage(request, response, "no_privilege");
}
}
Map actives = new HashMap();
actives.put(ac, " class=active");
request.setAttribute("actives", actives);
request.setAttribute("space", space);
return invokeMethod(this, "cp_" + ac, request, response);
}
public ActionForward cp_album(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> sGlobal = (Map<String, Object>) request.getAttribute("sGlobal");
Map<String, Object> sConfig = (Map<String, Object>) request.getAttribute("sConfig");
Map<String, Object> space = (Map<String, Object>) request.getAttribute("space");
int albumid = Common.intval(request.getParameter("albumid"));
int picid = Common.intval(request.getParameter("picid"));
int supe_uid = (Integer) sGlobal.get("supe_uid");
String op = request.getParameter("op");
if ("edit".equals(op)) {
if (albumid < 1) {
return showMessage(request, response, "photos_do_not_support_the_default_settings",
"cp.jsp?ac=album&op=editpic", 0);
}
List<Map<String, Object>> albums = dataBaseService.executeQuery("SELECT * FROM "
+ JavaCenterHome.getTableName("album") + " WHERE albumid='" + albumid + "'");
if (Common.empty(albums)) {
return showMessage(request, response, "no_privilege");
}
Map<String, Object> album = albums.get(0);
if ((Integer) album.get("uid") != supe_uid && !Common.checkPerm(request, response, "managealbum")) {
return showMessage(request, response, "no_privilege");
}
try {
if (submitCheck(request, "editsubmit")) {
String albumname = Common.getStr(request.getParameter("albumname"), 50, true, true, true,
0, 0, request, response);
if (Common.empty(albumname)) {
return showMessage(request, response, "album_name_errors");
}
int friend = Common.intval(request.getParameter("friend"));
String target_ids = "";
String password = request.getParameter("password");
if (friend == 2) {
List<String> uids = null;
String target_names = request.getParameter("target_names");
String[] names = Common.empty(target_names) ? null : target_names.trim().replaceAll(
Common.getMessage(request, "cp_tab_space"), " ").split(" ");
if (!Common.empty(names)) {
uids = dataBaseService.executeQuery("SELECT uid FROM "
+ JavaCenterHome.getTableName("space") + " WHERE username IN ("
+ Common.sImplode(names) + ")", 1);
}
if (Common.empty(uids)) {
friend = 3;
} else {
target_ids = Common.implode(uids, ",");
}
} else if (friend == 4) {
password = Common.trim(password);
if (password.equals("")) {
friend = 0;
- 1
- 2
- 3
- 4
- 5
- 6
前往页