List of usage examples for java.util Calendar setTimeZone
public void setTimeZone(TimeZone value)
From source file:util.Check.java
/** * Prft Datumseingaben und stellt ggf. einen gltigen Datumsbereich von x * Wochen zusammen/*from w ww .jav a2 s.com*/ * * @param of */ public void checkDateRegion(final OverviewForm of, final int defaultPeriod, final String defaultTimezone) { //Lngen Sicherstellen if (this.isExactLength(of.getYfrom(), 4) && this.isExactLength(of.getYto(), 4) && this.isLengthInMinMax(of.getMfrom(), 1, 2) && this.isLengthInMinMax(of.getMto(), 1, 2) && this.isLengthInMinMax(of.getDfrom(), 1, 2) && this.isLengthInMinMax(of.getDto(), 1, 2)) { try { final Calendar calTo = Calendar.getInstance(); final Calendar calFrom = Calendar.getInstance(); calTo.set(Integer.parseInt(of.getYto()), Integer.parseInt(of.getMto()) - 1, Integer.parseInt(of.getDto()), 0, 0, 0); calFrom.set(Integer.parseInt(of.getYfrom()), Integer.parseInt(of.getMfrom()) - 1, Integer.parseInt(of.getDfrom()), 0, 0, 0); final long time = calTo.getTime().getTime() - calFrom.getTime().getTime(); if (time < 0) { // berprfung ob eine negativer Zeitbereicg vorliegt... of.setYfrom(null); // zurckstellen, damit im nchsten Schritt die Default-Werte zum Zug kommen... } else { // System.out.println("Kalender wieder in of setzen, wegen berlufen (31.2.2008)"); of.setYfrom(new SimpleDateFormat("yyyy").format(calFrom.getTime())); of.setMfrom(new SimpleDateFormat("MM").format(calFrom.getTime())); of.setDfrom(new SimpleDateFormat("dd").format(calFrom.getTime())); of.setFromdate(of.getYfrom() + "-" + of.getMfrom() + "-" + of.getDfrom() + " 00:00:00"); of.setYto(new SimpleDateFormat("yyyy").format(calTo.getTime())); of.setMto(new SimpleDateFormat("MM").format(calTo.getTime())); of.setDto(new SimpleDateFormat("dd").format(calTo.getTime())); of.setTodate(of.getYto() + "-" + of.getMto() + "-" + of.getDto() + " 24:00:00"); } } catch (final NumberFormatException e) { LOG.error("checkDateRegion: " + e.toString()); of.setYfrom(null); } } else { //Benutzerangaben falsche anzahl Zeichen // zurckstellen, damit im nchsten Schritt die Default-Werte zum Zug kommen of.setYfrom(null); } // Defaultwerte bei bedarf Setzen if (of.getYfrom() == null || of.getYto() == null || of.getMfrom() == null || of.getMto() == null || of.getDfrom() == null || of.getDto() == null) { final Calendar calTo = Calendar.getInstance(); calTo.setTimeZone(TimeZone.getTimeZone(defaultTimezone)); final Calendar calFrom = Calendar.getInstance(); calFrom.setTimeZone(TimeZone.getTimeZone(defaultTimezone)); calFrom.add(Calendar.MONTH, -defaultPeriod); // bessere Verstndlichkeit wenn Monatsbereiche vorliegen... of.setYfrom(new SimpleDateFormat("yyyy").format(calFrom.getTime())); of.setMfrom(new SimpleDateFormat("MM").format(calFrom.getTime())); of.setDfrom(new SimpleDateFormat("dd").format(calFrom.getTime())); of.setFromdate(of.getYfrom() + "-" + of.getMfrom() + "-" + of.getDfrom() + " 00:00:00"); of.setYto(new SimpleDateFormat("yyyy").format(calTo.getTime())); of.setMto(new SimpleDateFormat("MM").format(calTo.getTime())); of.setDto(new SimpleDateFormat("dd").format(calTo.getTime())); of.setTodate(of.getYto() + "-" + of.getMto() + "-" + of.getDto() + " 24:00:00"); } }
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
public void snoozeAlarm(Command command) { if (isAlarmRunning() && command instanceof DecimalType) { int minutes = ((DecimalType) command).intValue(); Map<String, String> inputs = new HashMap<String, String>(); Calendar snoozePeriod = Calendar.getInstance(); snoozePeriod.setTimeZone(TimeZone.getTimeZone("GMT")); snoozePeriod.setTimeInMillis(0); snoozePeriod.add(Calendar.MINUTE, minutes); SimpleDateFormat pFormatter = new SimpleDateFormat("HH:mm:ss"); pFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); try {/*from w w w. ja va 2 s .co m*/ inputs.put("Duration", pFormatter.format(snoozePeriod.getTime())); } catch (NumberFormatException ex) { logger.error("Action Invalid Value Format Exception {}", ex.getMessage()); } Map<String, String> result = service.invokeAction(this, "AVTransport", "SnoozeAlarm", inputs); for (String variable : result.keySet()) { this.onValueReceived(variable, result.get(variable), "AVTransport"); } } else { logger.warn("There is no alarm running on {}", getUDN()); } }
From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java
public void setAlarm(boolean alarmSwitch) { List<SonosAlarm> sonosAlarms = getCurrentAlarmList(); // find the nearest alarm - take the current time from the Sonos system, // not the system where we are running SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); String currentLocalTime = getTime(); Date currentDateTime = null;/*w w w . j a va 2s.c o m*/ try { currentDateTime = fmt.parse(currentLocalTime); } catch (ParseException e) { logger.error("An exception occurred while formatting a date"); e.printStackTrace(); } if (currentDateTime != null) { Calendar currentDateTimeCalendar = Calendar.getInstance(); currentDateTimeCalendar.setTimeZone(TimeZone.getTimeZone("GMT")); currentDateTimeCalendar.setTime(currentDateTime); currentDateTimeCalendar.add(Calendar.DAY_OF_YEAR, 10); long shortestDuration = currentDateTimeCalendar.getTimeInMillis() - currentDateTime.getTime(); SonosAlarm firstAlarm = null; for (SonosAlarm anAlarm : sonosAlarms) { SimpleDateFormat durationFormat = new SimpleDateFormat("HH:mm:ss"); durationFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date durationDate; try { durationDate = durationFormat.parse(anAlarm.getDuration()); } catch (ParseException e) { logger.error("An exception occurred while parsing a date : '{}'", e.getMessage()); continue; } long duration = durationDate.getTime(); if (duration < shortestDuration && anAlarm.getRoomUUID().equals(getUDN())) { shortestDuration = duration; firstAlarm = anAlarm; } } // Set the Alarm if (firstAlarm != null) { if (alarmSwitch) { firstAlarm.setEnabled(true); } else { firstAlarm.setEnabled(false); } updateAlarm(firstAlarm); } } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void snoozeAlarm(Command command) { if (isAlarmRunning() && command instanceof DecimalType) { int minutes = ((DecimalType) command).intValue(); Map<String, String> inputs = new HashMap<String, String>(); Calendar snoozePeriod = Calendar.getInstance(); snoozePeriod.setTimeZone(TimeZone.getTimeZone("GMT")); snoozePeriod.setTimeInMillis(0); snoozePeriod.add(Calendar.MINUTE, minutes); SimpleDateFormat pFormatter = new SimpleDateFormat("HH:mm:ss"); pFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); try {//from w w w.j a v a 2s . c o m inputs.put("Duration", pFormatter.format(snoozePeriod.getTime())); } catch (NumberFormatException ex) { logger.debug("Action Invalid Value Format Exception {}", ex.getMessage()); } Map<String, String> result = service.invokeAction(this, "AVTransport", "SnoozeAlarm", inputs); for (String variable : result.keySet()) { this.onValueReceived(variable, result.get(variable), "AVTransport"); } } else { logger.debug("There is no alarm running on {}", getUDN()); } }
From source file:org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler.java
public void setAlarm(boolean alarmSwitch) { List<SonosAlarm> sonosAlarms = getCurrentAlarmList(); // find the nearest alarm - take the current time from the Sonos system, // not the system where we are running SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); String currentLocalTime = getTime(); Date currentDateTime = null;//from ww w . j a v a 2 s.c om try { currentDateTime = fmt.parse(currentLocalTime); } catch (ParseException e) { logger.debug("An exception occurred while formatting a date", e); } if (currentDateTime != null) { Calendar currentDateTimeCalendar = Calendar.getInstance(); currentDateTimeCalendar.setTimeZone(TimeZone.getTimeZone("GMT")); currentDateTimeCalendar.setTime(currentDateTime); currentDateTimeCalendar.add(Calendar.DAY_OF_YEAR, 10); long shortestDuration = currentDateTimeCalendar.getTimeInMillis() - currentDateTime.getTime(); SonosAlarm firstAlarm = null; for (SonosAlarm anAlarm : sonosAlarms) { SimpleDateFormat durationFormat = new SimpleDateFormat("HH:mm:ss"); durationFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date durationDate; try { durationDate = durationFormat.parse(anAlarm.getDuration()); } catch (ParseException e) { logger.debug("An exception occurred while parsing a date : '{}'", e.getMessage()); continue; } long duration = durationDate.getTime(); if (duration < shortestDuration && anAlarm.getRoomUUID().equals(getUDN())) { shortestDuration = duration; firstAlarm = anAlarm; } } // Set the Alarm if (firstAlarm != null) { if (alarmSwitch) { firstAlarm.setEnabled(true); } else { firstAlarm.setEnabled(false); } updateAlarm(firstAlarm); } } }
From source file:de.escidoc.core.test.EscidocTestBase.java
/** * Creates a <code>java.util.Calendar</code> object from an xml dateTime string. * /*from w ww . j a v a2 s . com*/ * @param dateTime * The xml dateTime string. * @return The Calendar object. * @throws ParseException * If the dateTime string can not be correctly parsed. */ public static Calendar getCalendarFromXmlDateString(String dateTime) throws ParseException { Calendar cal = null; if (dateTime.length() >= 20 && dateTime.length() <= 23) { // no timezone // ensure 3 digits for millis int add = 23 - dateTime.length(); while (add > 0) { dateTime += "0"; add--; } dateTime += "+0000"; } else if (dateTime.length() == 19) { // no timezone // not 3 digits for millis // no dot dateTime += ".000+0000"; } // else if (dateTime.length() == 18) { // // no timezone // // not 3 digits for millis // // no dot // dateTime += "0.000+0000"; // } // else if (dateTime.length() == 17) { // // no timezone // // not 3 digits for millis // // no dot // dateTime += "00.000+0000"; // } // else if (dateTime.length() == 16) { // // no timezone // // not 3 digits for millis // // no dot // dateTime += ":00.000+0000"; // } TimeZone gmt = TimeZone.getTimeZone("GMT"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); DateFormat tf = new SimpleDateFormat("HH:mm:ss.SSS"); Date oldModDateDate = df.parse(dateTime); Date oldModDateTime = tf.parse(dateTime, new ParsePosition(11)); // DateFormat f = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss.SSS"); // dateTime = dateTime.replace('T', '-'); // dateTime = dateTime.trim(); cal = Calendar.getInstance(); // cal.setTime(f.parse(dateTime)); cal.setTimeZone(gmt); cal.setTime(oldModDateDate); long oldModDateDateMillis = cal.getTimeInMillis(); cal.setTime(oldModDateTime); long oldModDateTimeMillis = cal.getTimeInMillis(); long oldModDateMillis = oldModDateDateMillis + oldModDateTimeMillis; cal.setTimeInMillis(oldModDateMillis); return cal; }
From source file:me.ububble.speakall.fragment.ConversationChatFragment.java
public void contactLastSeen(JSONObject json) { try {/*from w w w .j a v a2s . com*/ boolean isOnline = json.getBoolean("connected"); Log.e("Respuesta lastseen", json.toString()); if (isOnline) { activity.runOnUiThread(new Runnable() { @Override public void run() { if (ConversationChatFragment.this.isVisible()) { ((MainActivity) activity).actionBarDesc.setVisibility(View.VISIBLE); ((MainActivity) activity).actionBarDesc.setText(getString(R.string.online_status)); } } }); } else { String lastSeen = json.getString("last_seen"); SimpleDateFormat formateador1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'", Locale.getDefault()); formateador1.setTimeZone(TimeZone.getTimeZone("UTC")); String tiempo = lastSeen.substring(0, 23) + "Z"; Calendar fecha = Calendar.getInstance(); Date fecha1 = formateador1.parse(tiempo); fecha.setTimeZone(TimeZone.getDefault()); fecha.setTimeInMillis(fecha1.getTime()); String time = timeFormat1.format(fecha.getTime()); String dayMessage = dateDay1.format(fecha.getTime()); String monthMessage = dateMonth1.format(fecha.getTime()); String yearMessage = dateYear1.format(fecha.getTime()); String dayMessageText = dateDayText1.format(fecha.getTime()); char[] caracteres = dayMessageText.toCharArray(); caracteres[0] = Character.toUpperCase(caracteres[0]); dayMessageText = new String(caracteres); Calendar fechaActual = Calendar.getInstance(); String dayActual = dateDay1.format(fechaActual.getTime()); String monthActual = dateMonth1.format(fechaActual.getTime()); String yearActual = dateYear1.format(fechaActual.getTime()); String fechaMostrar = ""; if (dayMessage.equals(dayActual) && monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { fechaMostrar = getString(R.string.messages_today); } else if (monthMessage.equals(monthActual) && yearMessage.equals(yearActual)) { int days = Integer.parseInt(dayActual) - Integer.parseInt(dayMessage); if (days < 7) { switch (days) { case 1: fechaMostrar = getString(R.string.messages_yesterday); break; default: fechaMostrar = dayMessageText; break; } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } } else { fechaMostrar = (dayMessage + " " + monthMessage + " " + yearMessage).toUpperCase(); } final String finalFechaMostrar = fechaMostrar + " (" + time + ")"; activity.runOnUiThread(new Runnable() { @Override public void run() { ((MainActivity) activity).actionBarDesc.setVisibility(View.VISIBLE); ((MainActivity) activity).actionBarDesc.setText(finalFechaMostrar); } }); } } catch (JSONException e) { } catch (ParseException e) { e.printStackTrace(); } }
From source file:com.sonicle.webtop.mail.Service.java
public java.util.Calendar convertTimeZone(String year, String month, String day, String hour, String min, String timezonefrom, String timezoneto) { java.util.TimeZone timeZone1 = java.util.TimeZone.getTimeZone(timezonefrom); java.util.TimeZone timeZone2 = java.util.TimeZone.getTimeZone(timezoneto); java.util.Calendar calendar = new GregorianCalendar(); calendar.setTimeZone(timeZone1); calendar.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), Integer.parseInt(hour), Integer.parseInt(min)); java.util.Calendar calendarout = new GregorianCalendar(); calendarout.setTimeZone(timeZone2);//from www.ja va 2 s .c o m calendarout.setTimeInMillis(calendar.getTimeInMillis()); return calendarout; }
From source file:com.tmwsoft.sns.web.action.MainAction.java
public ActionForward cp_event(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"); Map<Integer, String> sNames = (Map<Integer, String>) request.getAttribute("sNames"); int supe_uid = (Integer) sGlobal.get("supe_uid"); String supe_username = (String) sGlobal.get("supe_username"); int timestamp = (Integer) sGlobal.get("timestamp"); int eventid = 0; String tempS = request.getParameter("id"); if (tempS != null) { eventid = Common.intval(tempS);//from www .java2s. com } tempS = request.getParameter("op"); String op = Common.empty(tempS) ? "edit" : tempS; Map<String, String> menus = new HashMap<String, String>(); menus.put(op, " class='active'"); boolean allowmanage = false; List<Map<String, Object>> query; Map<String, Object> event = null; if (eventid != 0) { query = dataBaseService.executeQuery("SELECT e.*, ef.* FROM sns_event e LEFT JOIN " + " sns_eventfield ef ON e.eventid=ef.eventid WHERE e.eventid='" + eventid + "'"); event = query.size() > 0 ? query.get(0) : null; if (event == null) { return showMessage(request, response, "event_does_not_exist"); } int eventGrade = (Integer) event.get("grade"); int eventUid = (Integer) event.get("uid"); if ((eventGrade == -1 || eventGrade == 0) && eventUid != supe_uid && !Common.checkPerm(request, response, "manageevent")) { return showMessage(request, response, "event_under_verify"); } query = dataBaseService.executeQuery( "SELECT * FROM sns_userevent WHERE eventid='" + eventid + "' AND uid='" + supe_uid + "'"); Map<String, Object> value = query.size() > 0 ? query.get(0) : new HashMap<String, Object>(); sGlobal.put("supe_userevent", value); Integer status = (Integer) value.get("status"); if ((status != null && status >= 3) || Common.checkPerm(request, response, "manageevent")) { allowmanage = true; } } Map<Integer, Map<String, Object>> globalEventClass = Common.getCacheDate(request, response, "cache/cache_eventclass.jsp", "globalEventClass"); if (Common.empty(globalEventClass)) { try { cacheService.eventclass_cache(); } catch (IOException e) { e.printStackTrace(); return showMessage(request, response, e.getMessage()); } globalEventClass = Common.getCacheDate(request, response, "cache/cache_eventclass.jsp", "globalEventClass"); } FileUploadUtil upload; try { upload = getParsedFileUploadUtil(request); if (submitCheckForMulti(request, upload, "eventsubmit")) { if (Common.checkPerm(request, response, "seccode") && !mainService.checkSeccode(request, response, sGlobal, sConfig, upload.getParameter("seccode"))) { return showMessage(request, response, "incorrect_code"); } Map<String, Object> arr1 = new HashMap<String, Object>(); String arr1Title; try { arr1Title = Common.getStr(upload.getParameter("title"), 80, true, true, true, 0, 0, request, response); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } arr1.put("title", arr1Title); arr1.put("classid", Common.intval(upload.getParameter("classid"))); try { arr1.put("province", Common.getStr(upload.getParameter("province"), 20, true, true, false, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } try { arr1.put("city", Common.getStr(upload.getParameter("city"), 20, true, true, false, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } try { arr1.put("location", Common.getStr(upload.getParameter("location"), 80, true, true, true, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } String timeoffset = Common.getTimeOffset(sGlobal, sConfig); int arr1Starttime = Common.strToTime(upload.getParameter("starttime"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("starttime", arr1Starttime); int arr1Endtime = Common.strToTime(upload.getParameter("endtime"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("endtime", arr1Endtime); int arr1Deadline = Common.strToTime(upload.getParameter("deadline"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("deadline", arr1Deadline); arr1.put("public", Common.intval(upload.getParameter("public"))); Map<String, Object> arr2 = new HashMap<String, Object>(); try { arr2.put("detail", Common.getStr(upload.getParameter("detail"), 0, true, true, true, 0, 1, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } arr2.put("limitnum", Common.intval(upload.getParameter("limitnum"))); arr2.put("verify", Common.intval(upload.getParameter("verify"))); arr2.put("allowpost", Common.intval(upload.getParameter("allowpost"))); arr2.put("allowpic", Common.intval(upload.getParameter("allowpic"))); arr2.put("allowfellow", Common.intval(upload.getParameter("allowfellow"))); arr2.put("allowinvite", Common.intval(upload.getParameter("allowinvite"))); try { arr2.put("template", Common.getStr(upload.getParameter("template"), 255, true, true, true, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } if (Common.empty(arr1.get("title"))) { return showMessage(request, response, "event_title_empty"); } else if (Common.empty(arr1.get("classid"))) { return showMessage(request, response, "event_classid_empty"); // } else if (Common.empty(arr1.get("city"))) { // return showMessage(request, response, // "event_city_empty"); } else if (Common.empty(arr2.get("detail"))) { return showMessage(request, response, "event_detail_empty"); } else if (arr1Endtime - arr1Starttime > 60 * 24 * 3600) { return showMessage(request, response, "event_bad_time_range"); } else if (arr1Endtime < arr1Starttime) { return showMessage(request, response, "event_bad_endtime"); } else if (arr1Deadline > arr1Endtime) { return showMessage(request, response, "event_bad_deadline"); } else if (eventid == 0 && arr1Starttime < timestamp) { return showMessage(request, response, "event_bad_starttime"); } Map<String, Object> pic = null; if (upload.isMultipart()) { FileItem fileItem = upload.getFileItem("poster"); Object picob = mainService.savePic(request, response, fileItem, "-1", arr1Title, 0); if (Common.isArray(picob)) { pic = (Map<String, Object>) picob; if (!Common.empty(pic.get("filepath"))) { arr1.put("poster", pic.get("filepath")); arr1.put("thumb", pic.get("thumb")); arr1.put("remote", pic.get("remote")); } } } String tagidString = upload.getParameter("tagid"); int tagid = 0; if (!Common.empty(tagidString) && (eventid == 0 || ((Integer) event.get("uid") == supe_uid) && !tagidString.equals(String.valueOf(event.get("tagid"))))) { tagid = Common.intval(tagidString); query = dataBaseService.executeQuery("SELECT * FROM sns_tagspace WHERE tagid='" + tagid + "' AND uid='" + supe_uid + "' LIMIT 1"); Map<String, Object> value = query.size() > 0 ? query.get(0) : null; if (value != null) { if ((Integer) value.get("grade") == 9) { arr1.put("tagid", value.get("tagid")); } } } if (eventid != 0) { if (allowmanage) { if ((Integer) event.get("grade") == -1 && (Integer) event.get("uid") == supe_uid) { arr1.put("grade", 0); } Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_event", arr1, whereData); dataBaseService.updateTable("sns_eventfield", arr2, whereData); tempS = upload.getParameter("sharepic"); if (!Common.empty(tempS) && pic != null && !Common.empty(pic.get("picid"))) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("picid", pic.get("picid")); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("dateline", timestamp); dataBaseService.insertTable("sns_eventpic", arr, false, false); } return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } else { return showMessage(request, response, "no_privilege_edit_event"); } } else { if (!mainService.checkRealName(request, "event")) { return showMessage(request, response, "no_privilege_realname"); } if (!mainService.checkVideoPhoto(request, response, "event")) { return showMessage(request, response, "no_privilege_videophoto"); } switch (mainService.checkNewUser(request, response)) { case 1: break; case 2: return showMessage(request, response, "no_privilege_newusertime", "", 1, String.valueOf(sConfig.get("newusertime"))); case 3: return showMessage(request, response, "no_privilege_avatar"); case 4: return showMessage(request, response, "no_privilege_friendnum", "", 1, String.valueOf(sConfig.get("need_friendnum"))); case 5: return showMessage(request, response, "no_privilege_email"); } int topicid = mainService.checkTopic(request, Common.intval(upload.getParameter("topicid")), "event"); arr1.put("topicid", topicid); arr1.put("uid", supe_uid); arr1.put("username", supe_username); arr1.put("dateline", timestamp); arr1.put("updatetime", timestamp); arr1.put("membernum", 1); arr1.put("grade", !Common.empty(Common.checkPerm(request, response, sGlobal, "verifyevent")) ? 0 : 1); eventid = dataBaseService.insertTable("sns_event", arr1, true, false); if (eventid == 0) { return showMessage(request, response, "event_create_failed"); } arr2.put("eventid", eventid); arr2.put("hotuser", ""); dataBaseService.insertTable("sns_eventfield", arr2, false, false); tempS = upload.getParameter("sharepic"); if (!Common.empty(tempS) && pic != null && !Common.empty(pic.get("picid"))) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("picid", pic.get("picid")); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("dateline", timestamp); dataBaseService.insertTable("sns_eventpic", arr, false, false); } Map<String, Object> arr3 = new HashMap<String, Object>(); arr3.put("eventid", eventid); arr3.put("uid", supe_uid); arr3.put("username", supe_username); arr3.put("status", 4); arr3.put("fellow", 0); tempS = (String) arr1.get("template"); tempS = tempS == null ? "" : tempS; arr3.put("template", tempS); arr3.put("dateline", timestamp); dataBaseService.insertTable("sns_userevent", arr3, false, false); if ((Integer) arr1.get("grade") > 0) { tempS = upload.getParameter("makefeed"); if (!Common.empty(tempS)) { feedService.feedPublish(request, response, eventid, "eventid", true); } } mainService.updateStat(request, "event", false); String eventnumsql; if (Common.empty(space.get("eventnum"))) { Map<String, Object> whereArr = new HashMap<String, Object>(); whereArr.put("uid", space.get("uid")); space.put("eventnum", Common.getCount("sns_event", whereArr, null)); eventnumsql = "eventnum=" + space.get("eventnum"); } else { eventnumsql = "eventnum=eventnum+1"; } Map<String, Integer> reward = Common.getReward("createevent", false, 0, "", true, request, response); dataBaseService.executeUpdate("UPDATE sns_space SET " + eventnumsql + ", lastpost='" + timestamp + "', updatetime='" + timestamp + "', credit=credit+" + reward.get("credit") + ", experience=experience+" + reward.get("experience") + " WHERE uid='" + supe_uid + "'"); String url; if (topicid != 0) { mainService.topicJoin(request, topicid, supe_uid, supe_username); url = "zone.action?do=topic&topicid=" + topicid + "&view=event"; } else { url = "zone.action?do=event&id=" + eventid; } return showMessage(request, response, "do_success", url, 0); } } if ("invite".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (((event == null || Common.empty(event.get("allowinvite"))) && (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3)) || (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 2)) { return showMessage(request, response, "no_privilege_do_eventinvite"); } if (submitCheck(request, "invitesubmit")) { Map<String, Object> arr = new LinkedHashMap<String, Object>(); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("eventid", eventid); arr.put("dateline", timestamp); List<String> inserts = new ArrayList<String>(); List<Integer> touids = new ArrayList<Integer>(); String[] ids = request.getParameterValues("ids[]"); if (ids != null) { try { StringBuilder builder = new StringBuilder(); int touid; for (int i = 0; i < ids.length; i++) { touid = Common.intval(ids[i]); arr.put("touid", touid); arr.put("tousername", Common.getStr(request.getParameterValues("names[]")[i], 15, true, true, false, 0, 0, request, response)); builder.append("("); builder.append(Common.sImplode(arr)); builder.append(")"); inserts.add(builder.toString()); touids.add(touid); builder.delete(0, builder.length()); } } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } } if (!Common.empty(inserts)) { dataBaseService.execute( "INSERT INTO sns_eventinvite (uid, username, eventid, dateline, touid, tousername) VALUES " + Common.implode(inserts, ",")); dataBaseService .executeUpdate("UPDATE sns_space SET eventinvitenum=eventinvitenum+1 WHERE uid IN (" + Common.sImplode(touids) + ")"); } tempS = request.getParameter("group"); int getGroup = !Common.empty(tempS) ? Common.intval(tempS) : -1; tempS = request.getParameter("page"); int getPage = Common.empty(tempS) ? 0 : Common.intval(tempS); return showMessage(request, response, "do_success", "main.action?ac=event&op=invite&id=" + eventid + "&group=" + getGroup + "&page=" + getPage, 2); } int perpage = 21; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 0 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } List<String> wherearr = new ArrayList<String>(); String key = Common.stripSearchKey(request.getParameter("key")); if (!Common.empty(key)) { wherearr.add(" fusername LIKE '%" + key + "%' "); } tempS = request.getParameter("group"); int group = !Common.empty(tempS) ? Common.intval(tempS) : -1; if (group >= 0) { wherearr.add(" gid='" + group + "'"); } String sql = wherearr.size() > 0 ? "AND" + Common.implode(wherearr, " AND ") : ""; query = dataBaseService.executeQuery("SELECT COUNT(*) AS cont FROM sns_friend WHERE uid='" + supe_uid + "' AND status='1' " + sql); int count = query.size() > 0 ? (Integer) (query.get(0).get("cont")) : 0; List<Integer> fuids = new ArrayList<Integer>(); List<Map<String, Object>> list = null; if (count != 0) { query = dataBaseService .executeQuery("SELECT * FROM sns_friend WHERE uid='" + supe_uid + "' AND status='1' " + sql + " ORDER BY num DESC, dateline DESC LIMIT " + start + "," + perpage); int fuid; for (Map<String, Object> value : query) { fuid = (Integer) value.get("fuid"); fuids.add(fuid); } list = query; } Map<Integer, Integer> joins = new HashMap<Integer, Integer>(); if (fuids.size() > 0) { query = dataBaseService.executeQuery("SELECT uid FROM sns_userevent WHERE eventid='" + eventid + "' AND uid IN (" + Common.sImplode(fuids) + ") AND status > 1"); int vuid; for (Map<String, Object> value : query) { vuid = (Integer) value.get("uid"); joins.put(vuid, vuid); } query = dataBaseService.executeQuery("SELECT touid FROM sns_eventinvite WHERE eventid='" + eventid + "' AND touid IN (" + Common.sImplode(fuids) + ")"); for (Map<String, Object> value : query) { vuid = (Integer) value.get("touid"); joins.put(vuid, vuid); } } Map<Integer, String> groups = Common.getFriendGroup(request); Map<Integer, String> groupselect = new HashMap<Integer, String>(); groupselect.put(group, " selected"); String multi = Common.multi(request, count, perpage, page, maxPage, "main.action?ac=event&op=invite&id=" + eventid + "&group=" + group + "&key=" + key, null, null); request.setAttribute("group", group); request.setAttribute("page", page); request.setAttribute("list", list); request.setAttribute("joins", joins); request.setAttribute("multi", multi); request.setAttribute("groups", groups); } else if ("members".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3) { return showMessage(request, response, "no_privilege_manage_event_members"); } if (submitCheck(request, "memberssubmit")) { String[] ids = request.getParameterValues("ids[]"); boolean rz; if (!Common.empty(ids)) { Object object = verify_eventmembers(request, sGlobal, event, ids, request.getParameter("newstatus")); if (object instanceof MessageVO) { return showMessage(request, response, (MessageVO) object); } rz = !Common.empty(object); } else { rz = false; } String status = request.getParameter("status"); status = status == null ? "" : status; if (rz) { return showMessage(request, response, "do_success", "main.action?ac=event&op=members&id=" + eventid + "&status=" + status, 2); } else { return showMessage(request, response, "choose_right_eventmember", "main.action?ac=event&op=members&id=" + eventid + "&status=" + status, 5); } } int perpage = 24; tempS = request.getParameter("start"); int start = Common.empty(tempS) ? 0 : Common.intval(tempS); int count = 0; String wheresql; String key = request.getParameter("key"); String status = request.getParameter("status"); if (!Common.empty(key)) { key = Common.stripSearchKey(key); wheresql = " AND username LIKE '%" + key + "%' "; } else { status = Common.intval(status) + ""; wheresql = " AND status='" + status + "'"; } int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } query = dataBaseService.executeQuery("SELECT * FROM sns_userevent WHERE eventid='" + eventid + "' " + wheresql + " LIMIT " + start + "," + perpage); for (Map<String, Object> value : query) { tempS = (String) value.get("template"); if (tempS != null) { value.put("template", Common.nl2br(Common.htmlSpecialChars(tempS))); } else { value.put("template", ""); } count++; } List<Map<String, Object>> list = query; if (!Common.empty(key)) { if (list.size() > 0) { status = String.valueOf(list.get(0).get("status")); } else { status = ""; } } String multi; try { multi = Common.smulti(sGlobal, start, perpage, count, "main.action?ac=event&op=members&id=" + eventid + "&status=" + status + "&key=" + key, null); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } request.setAttribute("status", status); request.setAttribute("list", list); request.setAttribute("multi", multi); } else if ("member".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3) { return showMessage(request, response, "no_privilege_manage_event_members"); } try { if (submitCheck(request, "membersubmit")) { String statusString = request.getParameter("status"); int status = Common.intval(statusString); boolean rz; String uid = request.getParameter("uid"); if (!Common.empty(uid)) { Object object = verify_eventmembers(request, sGlobal, event, new String[] { uid }, statusString); if (object instanceof MessageVO) { return showMessage(request, response, (MessageVO) object); } rz = !Common.empty(object); } else { rz = false; } if (rz) { String refer = request.getParameter("refer"); refer = Common.empty(refer) ? "zone.action?do=event&id=" + eventid + "&view=member&status=" + status : refer; return showMessage(request, response, "do_success", refer, 0); } else { return showMessage(request, response, "choose_right_eventmember"); } } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } int uid = Common.intval(request.getParameter("uid")); query = dataBaseService.executeQuery( "SELECT * FROM sns_userevent WHERE uid='" + uid + "' AND eventid='" + eventid + "'"); Map<String, Object> userevent = query.size() > 0 ? query.get(0) : null; if (Common.empty(userevent)) { return showMessage(request, response, "choose_right_eventmember"); } try { tempS = Common.nl2br(Common.getStr((String) userevent.get("template"), 255, true, false, true, 0, 0, request, response)); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } userevent.put("template", tempS); request.setAttribute("uid", uid); request.setAttribute("userevent", userevent); } else if ("pic".equals(op)) { if (!allowmanage) { return showMessage(request, response, "no_privilege_manage_event_pic"); } if (submitCheck(request, "deletepicsubmit")) { String[] ids = request.getParameterValues("ids[]"); if (!Common.empty(ids)) { dataBaseService.execute("DELETE FROM sns_eventpic WHERE eventid='" + eventid + "' AND picid IN (" + Common.sImplode(ids) + ")"); dataBaseService.executeUpdate( "UPDATE sns_event SET picnum = (SELECT COUNT(*) FROM sns_eventpic WHERE eventid='" + eventid + "') WHERE eventid = '" + eventid + "'"); return showMessage(request, response, "do_success", "main.action?ac=event&op=pic&id=" + eventid, 0); } else { return showMessage(request, response, "choose_event_pic"); } } int perpage = 16; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } String theurl = "main.action?ac=event&id=" + eventid + "&op=pic"; List<Map<String, Object>> photolist = null; int count = 0; query = dataBaseService.executeQuery( "SELECT COUNT(*) AS cont FROM sns_eventpic WHERE eventid = '" + eventid + "'"); if (query.size() > 0) { count = (Integer) query.get(0).get("cont"); } if (count != 0) { query = dataBaseService.executeQuery("SELECT pic.* FROM sns_eventpic ep LEFT JOIN " + " sns_pic pic ON ep.picid=pic.picid WHERE ep.eventid='" + eventid + "' ORDER BY ep.picid DESC LIMIT " + start + ", " + perpage); for (Map<String, Object> value : query) { value.put("pic", Common.pic_get(sConfig, (String) value.get("filepath"), (Integer) value.get("thumb"), (Integer) value.get("remote"), true)); } photolist = query; } String multi = Common.multi(request, count, perpage, page, maxPage, theurl, null, null); int photolistSize = photolist == null ? 0 : photolist.size(); request.setAttribute("photolistSize", photolistSize); request.setAttribute("photolist", photolist); request.setAttribute("multi", multi); } else if ("thread".equals(op)) { if (!allowmanage) { return showMessage(request, response, "no_privilege_manage_event_thread"); } if (Common.empty(event.get("tagid"))) { return showMessage(request, response, "event_has_not_mtag"); } try { if (submitCheck(request, "delthreadsubmit")) { String[] ids = request.getParameterValues("ids[]"); if (!Common.empty(ids)) { dataBaseService.execute("DELETE FROM sns_thread WHERE eventid='" + eventid + "' AND tid IN (" + Common.sImplode(ids) + ")"); dataBaseService.executeUpdate( "UPDATE sns_event SET threadnum = (SELECT COUNT(*) FROM sns_thread WHERE eventid='" + eventid + "') WHERE eventid = '" + eventid + "'"); return showMessage(request, response, "do_success", "main.action?ac=event&id=" + eventid + "&op=thread", 0); } else { return showMessage(request, response, "choose_event_thread"); } } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } int perpage = 20; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } List<Map<String, Object>> threadlist = null; int count = 0; query = dataBaseService .executeQuery("SELECT COUNT(*) AS cont FROM sns_thread WHERE eventid = '" + eventid + "'"); if (query.size() > 0) { count = (Integer) query.get(0).get("cont"); } if (count != 0) { query = dataBaseService.executeQuery("SELECT * FROM sns_thread WHERE eventid='" + eventid + "' ORDER BY lastpost DESC LIMIT " + start + ", " + perpage); threadlist = query; } String multi = Common.multi(request, count, perpage, page, maxPage, "main.action?ac=event&id=" + eventid + "&op=thread", null, null); request.setAttribute("threadlist", threadlist); } else if ("join".equals(op)) { boolean popupmenu_box; if (mainService.isBlackList((Integer) event.get("uid"), supe_uid) != 0) { popupmenu_box = true; return showMessage(request, response, "is_blacklist"); } if (Common.empty(sGlobal.get("supe_userevent"))) { popupmenu_box = true; if (timestamp > (Integer) event.get("endtime")) { return showMessage(request, response, "event_is_over"); } if (timestamp > (Integer) event.get("deadline")) { return showMessage(request, response, "event_meet_deadline"); } if ((Integer) event.get("limitnum") > 0 && (Integer) event.get("membernum") >= (Integer) event.get("limitnum")) { return showMessage(request, response, "event_already_full"); } if ((Integer) event.get("public") < 2) { query = dataBaseService.executeQuery("SELECT * FROM sns_eventinvite WHERE eventid = '" + event.get("eventid") + "' AND touid = '" + supe_uid + "' LIMIT 1"); Map<String, Object> value = query.size() > 0 ? query.get(0) : null; if (Common.empty(value)) { return showMessage(request, response, "event_join_limit"); } } } if (submitCheck(request, "joinsubmit")) { Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); boolean supe_usereventNotEmpty = !Common.empty(supe_userevent); Integer supe_usereventStatus = supe_usereventNotEmpty ? (Integer) supe_userevent.get("status") : null; if (supe_usereventStatus != null && supe_usereventStatus == 0) { Map<String, Object> arr = new HashMap<String, Object>(); tempS = request.getParameter("fellow"); if (tempS != null) { arr.put("fellow", Common.intval(tempS)); } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { try { tempS = Common.getStr(tempS, 255, true, true, true, 0, 0, request, response); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } arr.put("template", tempS); } if (!Common.empty(arr)) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); whereData.put("uid", supe_uid); dataBaseService.updateTable("sns_userevent", arr, whereData); } return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 2); } if (supe_usereventStatus != null && supe_usereventStatus > 1) { Map<String, Object> arr = new HashMap<String, Object>(); int num = 0; tempS = request.getParameter("fellow"); if (tempS != null) { int fellow = Common.intval(tempS); arr.put("fellow", fellow); Integer supe_usereventFellow = (Integer) supe_userevent.get("fellow"); supe_usereventFellow = supe_usereventFellow == null ? 0 : supe_usereventFellow; num = fellow - supe_usereventFellow; int eventLimitnum = (Integer) event.get("limitnum"); if (eventLimitnum > 0 && num + (Integer) event.get("membernum") > eventLimitnum) { return showMessage(request, response, "event_already_full"); } } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { arr.put("template", tempS); } if (!Common.empty(arr)) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); whereData.put("uid", supe_uid); dataBaseService.updateTable("sns_userevent", arr, whereData); } if (num != 0) { dataBaseService.executeUpdate("UPDATE sns_event SET membernum = membernum + " + num + " WHERE eventid=" + eventid); } return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } int arrStatus = 2; Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("template", event.get("template")); arr.put("fellow", 0); arr.put("dateline", timestamp); int num = 1; String numsql; tempS = request.getParameter("fellow"); if (!Common.empty(tempS)) { int fellow = Common.intval(tempS); arr.put("fellow", fellow); num += fellow; } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { try { tempS = Common.getStr(tempS, 255, true, true, true, 0, 0, request, response); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } arr.put("template", tempS); } int eventLimitnum = (Integer) event.get("limitnum"); if (eventLimitnum > 0 && num + (Integer) event.get("membernum") > eventLimitnum) { return showMessage(request, response, "event_will_full"); } numsql = " membernum = membernum + " + num + " "; query = dataBaseService.executeQuery("SELECT * FROM sns_eventinvite WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); Map<String, Object> eventinvite = query.size() > 0 ? query.get(0) : null; if (!Common.empty(event.get("verify")) && Common.empty(eventinvite)) { arrStatus = 0; } arr.put("status", arrStatus); if (supe_usereventStatus != null && supe_usereventStatus == 1) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", supe_uid); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_userevent", arr, whereData); numsql += ",follownum = follownum - 1 "; } else { dataBaseService.insertTable("sns_userevent", arr, false, false); } int eventUid = (Integer) event.get("uid"); if (arrStatus == 2) { dataBaseService .execute("UPDATE sns_event SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", sNames.get(eventUid)); mainService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } else if (arrStatus == 0) { if (supe_usereventStatus != null && supe_usereventStatus == 1) { dataBaseService.executeUpdate( "UPDATE sns_event SET follownum = follownum - 1 WHERE eventid = '" + eventid + "'"); } List<Integer> note_ids = new ArrayList<Integer>(); List<String> note_inserts = new ArrayList<String>(); int eventEventid = (Integer) event.get("eventid"); String note_msg = Common.getMessage(request, "cp_event_join_verify", "zone.action?do=event&id=" + eventEventid, event.get("title"), "main.action?ac=event&id=" + eventEventid + "&op=members&status=0&key=" + supe_username); query = dataBaseService.executeQuery( "SELECT ue.*, sf.* FROM sns_userevent ue LEFT JOIN sns_spacefield sf ON ue.uid=sf.uid WHERE ue.eventid='" + eventid + "' AND ue.status >= 3"); Map<String, Object> privacyM; Set<String> filter; Map<String, Object> filter_noteM; Map<String, Object> note = new HashMap<String, Object>(); note.put("type", "eventmember"); note.put("authorid", supe_uid); StringBuilder builder = new StringBuilder(); int valueUid; for (Map<String, Object> value : query) { tempS = (String) value.get("privacy"); privacyM = Common.empty(tempS) ? new HashMap<String, Object>() : (Map<String, Object>) Serializer.unserialize(tempS); value.put("privacy", privacyM); filter_noteM = (Map<String, Object>) privacyM.get("filter_note"); filter = Common.empty(filter_noteM) ? new HashSet<String>() : filter_noteM.keySet(); if (mainService.checkNoteUid(note, filter)) { valueUid = (Integer) value.get("uid"); note_ids.add(valueUid); builder.append("('"); builder.append(valueUid); builder.append("', 'eventmember', '1', '"); builder.append(supe_uid); builder.append("', '"); builder.append(supe_username); builder.append("', '"); builder.append(Common.addSlashes(note_msg)); builder.append("', '"); builder.append(timestamp); builder.append("')"); note_inserts.add(builder.toString()); builder.delete(0, builder.length()); } } if (!Common.empty(note_inserts)) { dataBaseService.execute( "INSERT INTO sns_notification (`uid`, `type`, `new`, `authorid`, `author`, `note`, `dateline`) VALUES " + Common.implode(note_inserts, ",")); dataBaseService.executeUpdate("UPDATE sns_space SET notenum=notenum+1 WHERE uid IN (" + Common.sImplode(note_ids) + ")"); } try { mainService.sendMail(request, response, eventUid, "", Common.getMessage(request, "event_application"), note_msg, "event"); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } } Common.getReward("joinevent", true, 0, eventid + "", true, request, response); mainService.updateStat(request, "eventjoin", false); if (!Common.empty(eventinvite)) { dataBaseService.execute("DELETE FROM sns_eventinvite WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); dataBaseService .executeUpdate("UPDATE sns_space SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); } return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } } else if ("quit".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "quitsubmit")) { String tourl = "zone.action?do=event&id=" + eventid; int uid = supe_uid; Map<String, Object> userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (!Common.empty(userevent) && (Integer) event.get("uid") != uid) { dataBaseService.execute( "DELETE FROM sns_userevent WHERE eventid='" + eventid + "' AND uid='" + uid + "'"); if ((Integer) userevent.get("status") >= 2) { int num = 1 + (Integer) userevent.get("fellow"); dataBaseService.executeUpdate("UPDATE sns_event SET membernum = membernum - " + num + " WHERE eventid='" + eventid + "'"); } return showMessage(request, response, "do_success", tourl, 0); } else { return showMessage(request, response, "cannot_quit_event", tourl, 2); } } } else if ("follow".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); boolean popupmenu_box = false; if (!Common.empty(supe_userevent)) { popupmenu_box = true; if ((Integer) supe_userevent.get("status") <= 1) { return showMessage(request, response, "event_has_followed"); } else { return showMessage(request, response, "event_has_joint"); } } if (submitCheck(request, "followsubmit")) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("status", 1); arr.put("fellow", 0); arr.put("template", event.get("template")); dataBaseService.insertTable("sns_userevent", arr, false, false); dataBaseService.executeUpdate( "UPDATE sns_event SET follownum = follownum + 1 WHERE eventid='" + eventid + "'"); return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } } else if ("cancelfollow".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "cancelfollowsubmit")) { Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (!Common.empty(supe_userevent) && (Integer) supe_userevent.get("status") == 1) { dataBaseService.execute("DELETE FROM sns_userevent WHERE uid='" + supe_uid + "' AND eventid='" + eventid + "'"); dataBaseService.executeUpdate( "UPDATE sns_event SET follownum = follownum - 1 WHERE eventid='" + eventid + "'"); } return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } } else if ("eventinvite".equals(op)) { if (!Common.empty(request.getParameter("r"))) { tempS = request.getParameter("page"); String tourl = "main.action?ac=event&op=eventinvite" + (tempS != null ? "&page=" + Common.intval(tempS) : ""); if (eventid != 0) { dataBaseService.execute("DELETE FROM sns_eventinvite WHERE eventid = '" + eventid + "' AND touid = '" + supe_uid + "'"); dataBaseService .executeUpdate("UPDATE sns_space SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); } else { dataBaseService.execute("DELETE FROM sns_eventinvite WHERE touid = '" + supe_uid + "'"); dataBaseService.executeUpdate( "UPDATE sns_space SET eventinvitenum=0 WHERE uid = '" + supe_uid + "'"); } return showMessage(request, response, "do_success", tourl, 0); } int perpage = 20; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } String theurl = "main.action?ac=event&op=eventinvite"; Map<String, Object> whereArr = new HashMap<String, Object>(); whereArr.put("touid", supe_uid); int count = Common.intval(Common.getCount("sns_eventinvite", whereArr, null)); if (count != (Integer) space.get("eventinvitenum")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("eventinvitenum", count); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", space.get("uid")); dataBaseService.updateTable("sns_space", setData, whereData); } List<Map<String, Object>> eventinvites = null; if (count > 0) { query = dataBaseService.executeQuery( "SELECT ei.*, e.*, ei.dateline as invitetime FROM sns_eventinvite ei LEFT JOIN sns_event e ON ei.eventid=e.eventid WHERE ei.touid='" + supe_uid + "' limit " + start + ", " + perpage); for (Map<String, Object> value : query) { if (!Common.empty(value.get("poster"))) { value.put("pic", Common.pic_get(sConfig, (String) value.get("poster"), (Integer) value.get("thumb"), (Integer) value.get("remote"), true)); } else { value.put("pic", globalEventClass.get(value.get("classid")).get("poster")); } } eventinvites = query; } String multi = Common.multi(request, count, perpage, page, maxPage, theurl, null, null); request.setAttribute("eventinvites", eventinvites); request.setAttribute("multi", multi); } else if ("acceptinvite".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } query = dataBaseService.executeQuery("SELECT * FROM sns_eventinvite WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "' LIMIT 1"); Map<String, Object> eventinvite = query.size() > 0 ? query.get(0) : null; if (Common.empty(eventinvite)) { return showMessage(request, response, "eventinvite_does_not_exist"); } dataBaseService.execute( "DELETE FROM sns_eventinvite WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); dataBaseService.executeUpdate("UPDATE sns_space SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); if (mainService.isBlackList((Integer) event.get("uid"), supe_uid) != 0) { return showMessage(request, response, "is_blacklist"); } if (timestamp > (Integer) event.get("endtime")) { return showMessage(request, response, "event_is_over"); } if (timestamp > (Integer) event.get("deadline")) { return showMessage(request, response, "event_meet_deadline"); } int eventLimitnum = (Integer) event.get("limitnum"); int eventMembernum = (Integer) event.get("membernum"); if (eventLimitnum > 0 && eventMembernum >= eventLimitnum) { return showMessage(request, response, "event_already_full"); } String numsql = "membernum = membernum + 1"; Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (Common.empty(supe_userevent)) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("status", 2); arr.put("template", event.get("template")); arr.put("fellow", 0); arr.put("dateline", timestamp); dataBaseService.insertTable("sns_userevent", arr, false, false); dataBaseService .executeUpdate("UPDATE sns_event SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { int eventUid = (Integer) event.get("uid"); Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", sNames.get(eventUid)); mainService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } else if ((Integer) supe_userevent.get("status") < 2) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("status", 2); if ((Integer) supe_userevent.get("status") == 1) { numsql += ",follownum = follownum - 1 "; } if (eventLimitnum > 0 && eventMembernum + (Integer) supe_userevent.get("fellow") > eventLimitnum) { arr.put("fellow", 0); } Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", supe_uid); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_userevent", arr, whereData); dataBaseService .executeUpdate("UPDATE sns_event SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { int eventUid = (Integer) event.get("uid"); Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", event.get("username")); mainService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } return showMessage(request, response, Common.getMessage(request, "cp_event_accept_success", "zone.action?do=event&id=" + event.get("eventid"))); } else if ("delete".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if (submitCheck(request, "deletesubmit")) { adminDeleteService.deleteEvents(request, response, sGlobal, new Integer[] { eventid }); return showMessage(request, response, "do_success", "zone.action?do=event", 2); } } else if ("print".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "printsubmit")) { List<Map<String, Object>> members; List uid; if (!Common.empty(request.getParameter("admin"))) { query = dataBaseService.executeQuery("SELECT * FROM sns_userevent WHERE eventid='" + eventid + "' AND status > 1 ORDER BY status DESC, dateline ASC"); } else { query = dataBaseService.executeQuery("SELECT * FROM sns_userevent WHERE eventid='" + eventid + "' AND status = 2 ORDER BY dateline ASC"); } for (Map<String, Object> value : query) { value.put("template", Common.nl2br(Common.htmlSpecialChars((String) value.get("template")))); } members = query; request.setAttribute("event", event); request.setAttribute("members", members); return include(request, response, sConfig, sGlobal, "cp_event_sheet.jsp"); } } else if ("close".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if ((Integer) event.get("grade") < 1 || (Integer) event.get("endtime") > timestamp) { return showMessage(request, response, "event_can_not_be_closed"); } if (submitCheck(request, "closesubmit")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("grade", -2); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_event", setData, whereData); return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } } else if ("open".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if ((Integer) event.get("grade") != -2 || (Integer) event.get("endtime") > timestamp) { return showMessage(request, response, "event_can_not_be_opened"); } if (submitCheck(request, "opensubmit")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("grade", 1); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_event", setData, whereData); return showMessage(request, response, "do_success", "zone.action?do=event&id=" + eventid, 0); } } else if ("calendar".equals(op)) { List<String> match = null; String monthGet = request.getParameter("month"); String dateGet = request.getParameter("date"); if (Common.empty(monthGet)) { match = Common.pregMatch(dateGet, "^(\\d{4}-\\d{1,2})"); if (!Common.empty(match)) { monthGet = match.get(1); } } if (monthGet != null) { match = Common.pregMatch(monthGet, "^(\\d{4})-(\\d{1,2})$"); } int year; int month; if (!Common.empty(match)) { year = Common.intval(match.get(1)); month = Common.intval(match.get(2)); } else { year = Common.intval(Common.sgmdate(request, "yyyy", timestamp)); month = Common.intval(Common.sgmdate(request, "MM", timestamp)); } String nextmonth; String premonth; if (month == 12) { nextmonth = (year + 1) + "-1"; premonth = year + "-11"; } else if (month == 1) { nextmonth = year + "-2"; premonth = (year - 1) + "-12"; } else { nextmonth = year + "-" + (month + 1); premonth = year + "-" + (month - 1); } Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.YEAR, year); int daystart = (int) (calendar.getTimeInMillis() / 1000); int week = calendar.get(Calendar.DAY_OF_WEEK) - 1; int dayscount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.add(Calendar.MONTH, 1); int dayend = (int) (calendar.getTimeInMillis() / 1000); Map<Integer, Map<String, Object>> days = new LinkedHashMap<Integer, Map<String, Object>>(); Map<String, Object> subM; for (int i = 1; i <= dayscount; i++) { subM = new HashMap<String, Object>(); subM.put("count", 0); subM.put("events", new ArrayList<Map<String, Object>>()); subM.put("class", ""); days.put(i, subM); } query = dataBaseService.executeQuery("SELECT * FROM sns_event WHERE starttime < " + dayend + " AND endtime > " + daystart + " ORDER BY eventid DESC LIMIT 100"); int tempInt; int start; int end; List<Map<String, Object>> subList; for (Map<String, Object> value : query) { if ((Integer) value.get("public") < 1 || (tempInt = (Integer) value.get("grade")) == 0 || tempInt == -1) { continue; } tempInt = (Integer) value.get("starttime"); if (tempInt < daystart) { start = 1; } else { calendar.setTimeInMillis(tempInt * 1000L); start = calendar.get(Calendar.DAY_OF_MONTH); } tempInt = (Integer) value.get("endtime"); if (tempInt > dayend) { end = dayscount; } else { calendar.setTimeInMillis(tempInt * 1000L); end = calendar.get(Calendar.DAY_OF_MONTH); } for (int i = start; i <= end; i++) { subM = days.get(i); tempInt = (Integer) subM.get("count"); if (tempInt < 10) { subList = (List<Map<String, Object>>) subM.get("events"); subList.add(value); subM.put("count", tempInt + 1); subM.put("class", " on_link"); } } } int d = 0; if (month == Common.intval(Common.sgmdate(request, "MM", timestamp)) && year == Common.intval(Common.sgmdate(request, "yyyy", timestamp))) { d = Common.intval(Common.sgmdate(request, "dd", timestamp)); subM = days.get(d); subM.put("class", "on_today"); } if (!Common.empty(dateGet)) { int t = Common.strToTime(dateGet, Common.getTimeOffset(sGlobal, sConfig)); if (month == Common.intval(Common.sgmdate(request, "MM", t)) && year == Common.intval(Common.sgmdate(request, "yyyy", t))) { d = Common.intval(Common.sgmdate(request, "dd", t)); subM = days.get(d); subM.put("class", "on_select"); } } String url = request.getParameter("url"); url = !Common.empty(url) ? url.replaceAll("date=[\\d\\-]+", "") : "zone.action?do=event"; request.setAttribute("premonth", premonth); request.setAttribute("nextmonth", nextmonth); request.setAttribute("year", year); request.setAttribute("month", month); request.setAttribute("week", week); request.setAttribute("days", days); request.setAttribute("url", url); } else if ("edithot".equals(op)) { if (!Common.checkPerm(request, response, "manageevent")) { return showMessage(request, response, "no_privilege"); } if (submitCheck(request, "hotsubmit")) { int hot = Common.intval(request.getParameter("hot")); Map<String, Object> setData = new HashMap<String, Object>(); setData.put("hot", hot); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("sns_event", setData, whereData); if (hot > 0) { feedService.feedPublish(request, response, eventid, "eventid", false); } else { whereData.clear(); whereData.put("id", eventid); whereData.put("idtype", eventid); dataBaseService.updateTable("sns_feed", setData, whereData); } return showMessage(request, response, "do_success", "zone.action?uid=" + event.get("uid") + "&do=event&id=" + eventid, 0); } } else if ("edit".equals(op)) { if (eventid != 0) { if (!allowmanage) { return showMessage(request, response, "no_privilege_edit_event"); } } else { if (!Common.checkPerm(request, response, "allowevent")) { return showMessage(request, response, "no_privilege_add_event"); } if (!mainService.checkRealName(request, "event")) { return showMessage(request, response, "no_privilege_realname"); } if (!mainService.checkVideoPhoto(request, response, "event")) { return showMessage(request, response, "no_privilege_videophoto"); } switch (mainService.checkNewUser(request, response)) { case 1: break; case 2: return showMessage(request, response, "no_privilege_newusertime", "", 1, String.valueOf(sConfig.get("newusertime"))); case 3: return showMessage(request, response, "no_privilege_avatar"); case 4: return showMessage(request, response, "no_privilege_friendnum", "", 1, String.valueOf(sConfig.get("need_friendnum"))); case 5: return showMessage(request, response, "no_privilege_email"); } event = new HashMap<String, Object>(); event.put("eventid", ""); int starttime = (int) (Math.ceil(timestamp / 3600D) * 3600 + 7200); event.put("starttime", starttime); event.put("endtime", starttime + 14400); event.put("deadline", starttime); event.put("allowinvite", 1); event.put("allowpost", 1); event.put("allowpic", 1); event.put("allowfellow", 0); event.put("verify", 0); event.put("public", 2); event.put("limitnum", 0); event.put("province", space.get("resideprovince")); event.put("city", space.get("residecity")); Map<String, Object> topic = null; int topicid = Common.intval(request.getParameter("topicid")); if (topicid != 0) { topic = Common.getTopic(request, topicid); } Map<String, String> actives = null; if (!Common.empty(topic)) { actives = new HashMap<String, String>(); actives.put("event", " class=\"active\""); } request.setAttribute("topicid", topicid); request.setAttribute("topic", topic); } List<Map<String, Object>> mtags = null; Integer eventUid = (Integer) event.get("uid"); if (eventid == 0 || (eventUid != null && eventUid.intValue() == supe_uid)) { query = dataBaseService.executeQuery("SELECT mtag.* FROM sns_tagspace st LEFT JOIN " + " sns_mtag mtag ON st.tagid=mtag.tagid WHERE st.uid='" + supe_uid + "' AND st.grade=9"); mtags = query; } int tagid = Common.intval(request.getParameter("tagid")); if (tagid != 0 && Common.empty(event.get("tagid"))) { event.put("tagid", tagid); } Map<String, Object> subM; Object tempOb; for (Entry<Integer, Map<String, Object>> entry : globalEventClass.entrySet()) { subM = entry.getValue(); tempOb = subM.get("template"); if (tempOb != null) { subM.put("template", String.valueOf(tempOb).replace("\r\n", "<br>").replace("\r", "<br>") .replace("\n", "<br>")); } } request.setAttribute("globalEventClass", globalEventClass); request.setAttribute("mtags", mtags); request.setAttribute("ckPrivacy", Common.ckPrivacy(sGlobal, sConfig, space, "event", 1)); } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } request.setAttribute("op", op); request.setAttribute("eventid", eventid); request.setAttribute("allowmanage", allowmanage); request.setAttribute("event", event); request.setAttribute("menus", menus); return include(request, response, sConfig, sGlobal, "cp_event.jsp"); }
From source file:cn.jcenterhome.web.action.CpAction.java
public ActionForward cp_event(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"); Map<Integer, String> sNames = (Map<Integer, String>) request.getAttribute("sNames"); int supe_uid = (Integer) sGlobal.get("supe_uid"); String supe_username = (String) sGlobal.get("supe_username"); int timestamp = (Integer) sGlobal.get("timestamp"); int eventid = 0; String tempS = request.getParameter("id"); if (tempS != null) { eventid = Common.intval(tempS);/*ww w. j a va2 s. c o m*/ } tempS = request.getParameter("op"); String op = Common.empty(tempS) ? "edit" : tempS; Map<String, String> menus = new HashMap<String, String>(); menus.put(op, " class='active'"); boolean allowmanage = false; List<Map<String, Object>> query; Map<String, Object> event = null; if (eventid != 0) { query = dataBaseService.executeQuery("SELECT e.*, ef.* FROM " + JavaCenterHome.getTableName("event") + " e LEFT JOIN " + JavaCenterHome.getTableName("eventfield") + " ef ON e.eventid=ef.eventid WHERE e.eventid='" + eventid + "'"); event = query.size() > 0 ? query.get(0) : null; if (event == null) { return showMessage(request, response, "event_does_not_exist"); } int eventGrade = (Integer) event.get("grade"); int eventUid = (Integer) event.get("uid"); if ((eventGrade == -1 || eventGrade == 0) && eventUid != supe_uid && !Common.checkPerm(request, response, "manageevent")) { return showMessage(request, response, "event_under_verify"); } query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' AND uid='" + supe_uid + "'"); Map<String, Object> value = query.size() > 0 ? query.get(0) : new HashMap<String, Object>(); sGlobal.put("supe_userevent", value); Integer status = (Integer) value.get("status"); if ((status != null && status >= 3) || Common.checkPerm(request, response, "manageevent")) { allowmanage = true; } } Map<Integer, Map<String, Object>> globalEventClass = Common.getCacheDate(request, response, "/data/cache/cache_eventclass.jsp", "globalEventClass"); if (Common.empty(globalEventClass)) { try { cacheService.eventclass_cache(); } catch (IOException e) { e.printStackTrace(); return showMessage(request, response, e.getMessage()); } globalEventClass = Common.getCacheDate(request, response, "/data/cache/cache_eventclass.jsp", "globalEventClass"); } FileUploadUtil upload; try { upload = getParsedFileUploadUtil(request); if (submitCheckForMulti(request, upload, "eventsubmit")) { if (Common.checkPerm(request, response, "seccode") && !cpService.checkSeccode(request, response, sGlobal, sConfig, upload.getParameter("seccode"))) { return showMessage(request, response, "incorrect_code"); } Map<String, Object> arr1 = new HashMap<String, Object>(); String arr1Title; try { arr1Title = Common.getStr(upload.getParameter("title"), 80, true, true, true, 0, 0, request, response); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } arr1.put("title", arr1Title); arr1.put("classid", Common.intval(upload.getParameter("classid"))); try { arr1.put("province", Common.getStr(upload.getParameter("province"), 20, true, true, false, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } try { arr1.put("city", Common.getStr(upload.getParameter("city"), 20, true, true, false, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } try { arr1.put("location", Common.getStr(upload.getParameter("location"), 80, true, true, true, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } String timeoffset = Common.getTimeOffset(sGlobal, sConfig); int arr1Starttime = Common.strToTime(upload.getParameter("starttime"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("starttime", arr1Starttime); int arr1Endtime = Common.strToTime(upload.getParameter("endtime"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("endtime", arr1Endtime); int arr1Deadline = Common.strToTime(upload.getParameter("deadline"), timeoffset, "yyyy-MM-dd HH:mm"); arr1.put("deadline", arr1Deadline); arr1.put("public", Common.intval(upload.getParameter("public"))); Map<String, Object> arr2 = new HashMap<String, Object>(); try { arr2.put("detail", Common.getStr(upload.getParameter("detail"), 0, true, true, true, 0, 1, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } arr2.put("limitnum", Common.intval(upload.getParameter("limitnum"))); arr2.put("verify", Common.intval(upload.getParameter("verify"))); arr2.put("allowpost", Common.intval(upload.getParameter("allowpost"))); arr2.put("allowpic", Common.intval(upload.getParameter("allowpic"))); arr2.put("allowfellow", Common.intval(upload.getParameter("allowfellow"))); arr2.put("allowinvite", Common.intval(upload.getParameter("allowinvite"))); try { arr2.put("template", Common.getStr(upload.getParameter("template"), 255, true, true, true, 0, 0, request, response)); } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } if (Common.empty(arr1.get("title"))) { return showMessage(request, response, "event_title_empty"); } else if (Common.empty(arr1.get("classid"))) { return showMessage(request, response, "event_classid_empty"); } else if (Common.empty(arr1.get("city"))) { return showMessage(request, response, "event_city_empty"); } else if (Common.empty(arr2.get("detail"))) { return showMessage(request, response, "event_detail_empty"); } else if (arr1Endtime - arr1Starttime > 60 * 24 * 3600) { return showMessage(request, response, "event_bad_time_range"); } else if (arr1Endtime < arr1Starttime) { return showMessage(request, response, "event_bad_endtime"); } else if (arr1Deadline > arr1Endtime) { return showMessage(request, response, "event_bad_deadline"); } else if (eventid == 0 && arr1Starttime < timestamp) { return showMessage(request, response, "event_bad_starttime"); } Map<String, Object> pic = null; if (upload.isMultipart()) { FileItem fileItem = upload.getFileItem("poster"); Object picob = cpService.savePic(request, response, fileItem, "-1", arr1Title, 0); if (Common.isArray(picob)) { pic = (Map<String, Object>) picob; if (!Common.empty(pic.get("filepath"))) { arr1.put("poster", pic.get("filepath")); arr1.put("thumb", pic.get("thumb")); arr1.put("remote", pic.get("remote")); } } } String tagidString = upload.getParameter("tagid"); int tagid = 0; if (!Common.empty(tagidString) && (eventid == 0 || ((Integer) event.get("uid") == supe_uid) && !tagidString.equals(String.valueOf(event.get("tagid"))))) { tagid = Common.intval(tagidString); query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("tagspace") + " WHERE tagid='" + tagid + "' AND uid='" + supe_uid + "' LIMIT 1"); Map<String, Object> value = query.size() > 0 ? query.get(0) : null; if (value != null) { if ((Integer) value.get("grade") == 9) { arr1.put("tagid", value.get("tagid")); } } } if (eventid != 0) { if (allowmanage) { if ((Integer) event.get("grade") == -1 && (Integer) event.get("uid") == supe_uid) { arr1.put("grade", 0); } Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("event", arr1, whereData); dataBaseService.updateTable("eventfield", arr2, whereData); tempS = upload.getParameter("sharepic"); if (!Common.empty(tempS) && pic != null && !Common.empty(pic.get("picid"))) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("picid", pic.get("picid")); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("dateline", timestamp); dataBaseService.insertTable("eventpic", arr, false, false); } return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } else { return showMessage(request, response, "no_privilege_edit_event"); } } else { if (!cpService.checkRealName(request, "event")) { return showMessage(request, response, "no_privilege_realname"); } if (!cpService.checkVideoPhoto(request, response, "event")) { return showMessage(request, response, "no_privilege_videophoto"); } switch (cpService.checkNewUser(request, response)) { case 1: break; case 2: return showMessage(request, response, "no_privilege_newusertime", "", 1, String.valueOf(sConfig.get("newusertime"))); case 3: return showMessage(request, response, "no_privilege_avatar"); case 4: return showMessage(request, response, "no_privilege_friendnum", "", 1, String.valueOf(sConfig.get("need_friendnum"))); case 5: return showMessage(request, response, "no_privilege_email"); } int topicid = cpService.checkTopic(request, Common.intval(upload.getParameter("topicid")), "event"); arr1.put("topicid", topicid); arr1.put("uid", supe_uid); arr1.put("username", supe_username); arr1.put("dateline", timestamp); arr1.put("updatetime", timestamp); arr1.put("membernum", 1); arr1.put("grade", !Common.empty(Common.checkPerm(request, response, sGlobal, "verifyevent")) ? 0 : 1); eventid = dataBaseService.insertTable("event", arr1, true, false); if (eventid == 0) { return showMessage(request, response, "event_create_failed"); } arr2.put("eventid", eventid); arr2.put("hotuser", ""); dataBaseService.insertTable("eventfield", arr2, false, false); tempS = upload.getParameter("sharepic"); if (!Common.empty(tempS) && pic != null && !Common.empty(pic.get("picid"))) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("picid", pic.get("picid")); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("dateline", timestamp); dataBaseService.insertTable("eventpic", arr, false, false); } Map<String, Object> arr3 = new HashMap<String, Object>(); arr3.put("eventid", eventid); arr3.put("uid", supe_uid); arr3.put("username", supe_username); arr3.put("status", 4); arr3.put("fellow", 0); tempS = (String) arr1.get("template"); tempS = tempS == null ? "" : tempS; arr3.put("template", tempS); arr3.put("dateline", timestamp); dataBaseService.insertTable("userevent", arr3, false, false); if ((Integer) arr1.get("grade") > 0) { tempS = upload.getParameter("makefeed"); if (!Common.empty(tempS)) { feedService.feedPublish(request, response, eventid, "eventid", true); } } cpService.updateStat(request, "event", false); String eventnumsql; if (Common.empty(space.get("eventnum"))) { Map<String, Object> whereArr = new HashMap<String, Object>(); whereArr.put("uid", space.get("uid")); space.put("eventnum", Common.getCount("event", whereArr, null)); eventnumsql = "eventnum=" + space.get("eventnum"); } else { eventnumsql = "eventnum=eventnum+1"; } Map<String, Integer> reward = Common.getReward("createevent", false, 0, "", true, request, response); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET " + eventnumsql + ", lastpost='" + timestamp + "', updatetime='" + timestamp + "', credit=credit+" + reward.get("credit") + ", experience=experience+" + reward.get("experience") + " WHERE uid='" + supe_uid + "'"); String url; if (topicid != 0) { cpService.topicJoin(request, topicid, supe_uid, supe_username); url = "space.jsp?do=topic&topicid=" + topicid + "&view=event"; } else { url = "space.jsp?do=event&id=" + eventid; } return showMessage(request, response, "do_success", url, 0); } } if ("invite".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (((event == null || Common.empty(event.get("allowinvite"))) && (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3)) || (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 2)) { return showMessage(request, response, "no_privilege_do_eventinvite"); } if (submitCheck(request, "invitesubmit")) { Map<String, Object> arr = new LinkedHashMap<String, Object>(); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("eventid", eventid); arr.put("dateline", timestamp); List<String> inserts = new ArrayList<String>(); List<Integer> touids = new ArrayList<Integer>(); String[] ids = request.getParameterValues("ids[]"); if (ids != null) { try { StringBuilder builder = new StringBuilder(); int touid; for (int i = 0; i < ids.length; i++) { touid = Common.intval(ids[i]); arr.put("touid", touid); arr.put("tousername", Common.getStr(request.getParameterValues("names[]")[i], 15, true, true, false, 0, 0, request, response)); builder.append("("); builder.append(Common.sImplode(arr)); builder.append(")"); inserts.add(builder.toString()); touids.add(touid); builder.delete(0, builder.length()); } } catch (Exception exception) { return showMessage(request, response, exception.getMessage()); } } if (!Common.empty(inserts)) { dataBaseService.execute("INSERT INTO " + JavaCenterHome.getTableName("eventinvite") + "(uid, username, eventid, dateline, touid, tousername) VALUES " + Common.implode(inserts, ",")); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET eventinvitenum=eventinvitenum+1 WHERE uid IN (" + Common.sImplode(touids) + ")"); } tempS = request.getParameter("group"); int getGroup = !Common.empty(tempS) ? Common.intval(tempS) : -1; tempS = request.getParameter("page"); int getPage = Common.empty(tempS) ? 0 : Common.intval(tempS); return showMessage(request, response, "do_success", "cp.jsp?ac=event&op=invite&id=" + eventid + "&group=" + getGroup + "&page=" + getPage, 2); } int perpage = 21; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 0 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } List<String> wherearr = new ArrayList<String>(); String key = Common.stripSearchKey(request.getParameter("key")); if (!Common.empty(key)) { wherearr.add(" fusername LIKE '%" + key + "%' "); } tempS = request.getParameter("group"); int group = !Common.empty(tempS) ? Common.intval(tempS) : -1; if (group >= 0) { wherearr.add(" gid='" + group + "'"); } String sql = wherearr.size() > 0 ? "AND" + Common.implode(wherearr, " AND ") : ""; query = dataBaseService .executeQuery("SELECT COUNT(*) AS cont FROM " + JavaCenterHome.getTableName("friend") + " WHERE uid='" + supe_uid + "' AND status='1' " + sql); int count = query.size() > 0 ? (Integer) (query.get(0).get("cont")) : 0; List<Integer> fuids = new ArrayList<Integer>(); List<Map<String, Object>> list = null; if (count != 0) { query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("friend") + " WHERE uid='" + supe_uid + "' AND status='1' " + sql + " ORDER BY num DESC, dateline DESC LIMIT " + start + "," + perpage); int fuid; for (Map<String, Object> value : query) { fuid = (Integer) value.get("fuid"); Common.realname_set(sGlobal, sConfig, sNames, fuid, (String) value.get("fusername"), "", 0); fuids.add(fuid); } list = query; } Map<Integer, Integer> joins = new HashMap<Integer, Integer>(); if (fuids.size() > 0) { query = dataBaseService.executeQuery( "SELECT uid FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' AND uid IN (" + Common.sImplode(fuids) + ") AND status > 1"); int vuid; for (Map<String, Object> value : query) { vuid = (Integer) value.get("uid"); joins.put(vuid, vuid); } query = dataBaseService.executeQuery( "SELECT touid FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid='" + eventid + "' AND touid IN (" + Common.sImplode(fuids) + ")"); for (Map<String, Object> value : query) { vuid = (Integer) value.get("touid"); joins.put(vuid, vuid); } } Map<Integer, String> groups = Common.getFriendGroup(request); Map<Integer, String> groupselect = new HashMap<Integer, String>(); groupselect.put(group, " selected"); String multi = Common.multi(request, count, perpage, page, maxPage, "cp.jsp?ac=event&op=invite&id=" + eventid + "&group=" + group + "&key=" + key, null, null); request.setAttribute("group", group); request.setAttribute("page", page); request.setAttribute("list", list); request.setAttribute("joins", joins); request.setAttribute("multi", multi); request.setAttribute("groups", groups); } else if ("members".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3) { return showMessage(request, response, "no_privilege_manage_event_members"); } if (submitCheck(request, "memberssubmit")) { String[] ids = request.getParameterValues("ids[]"); boolean rz; if (!Common.empty(ids)) { Object object = verify_eventmembers(request, sGlobal, event, ids, request.getParameter("newstatus")); if (object instanceof MessageVO) { return showMessage(request, response, (MessageVO) object); } rz = !Common.empty(object); } else { rz = false; } String status = request.getParameter("status"); status = status == null ? "" : status; if (rz) { return showMessage(request, response, "do_success", "cp.jsp?ac=event&op=members&id=" + eventid + "&status=" + status, 2); } else { return showMessage(request, response, "choose_right_eventmember", "cp.jsp?ac=event&op=members&id=" + eventid + "&status=" + status, 5); } } int perpage = 24; tempS = request.getParameter("start"); int start = Common.empty(tempS) ? 0 : Common.intval(tempS); int count = 0; String wheresql; String key = request.getParameter("key"); String status = request.getParameter("status"); if (!Common.empty(key)) { key = Common.stripSearchKey(key); wheresql = " AND username LIKE '%" + key + "%' "; } else { status = Common.intval(status) + ""; wheresql = " AND status='" + status + "'"; } int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' " + wheresql + " LIMIT " + start + "," + perpage); for (Map<String, Object> value : query) { Common.realname_set(sGlobal, sConfig, sNames, (Integer) value.get("uid"), (String) value.get("username"), "", 0); tempS = (String) value.get("template"); if (tempS != null) { value.put("template", Common.nl2br(Common.htmlSpecialChars(tempS))); } else { value.put("template", ""); } count++; } List<Map<String, Object>> list = query; if (!Common.empty(key)) { if (list.size() > 0) { status = String.valueOf(list.get(0).get("status")); } else { status = ""; } } String multi; try { multi = Common.smulti(sGlobal, start, perpage, count, "cp.jsp?ac=event&op=members&id=" + eventid + "&status=" + status + "&key=" + key, null); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } request.setAttribute("status", status); request.setAttribute("list", list); request.setAttribute("multi", multi); } else if ("member".equals(op)) { Map<String, Object> supeUserEvent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (supeUserEvent == null || (Integer) supeUserEvent.get("status") < 3) { return showMessage(request, response, "no_privilege_manage_event_members"); } try { if (submitCheck(request, "membersubmit")) { String statusString = request.getParameter("status"); int status = Common.intval(statusString); boolean rz; String uid = request.getParameter("uid"); if (!Common.empty(uid)) { Object object = verify_eventmembers(request, sGlobal, event, new String[] { uid }, statusString); if (object instanceof MessageVO) { return showMessage(request, response, (MessageVO) object); } rz = !Common.empty(object); } else { rz = false; } if (rz) { String refer = request.getParameter("refer"); refer = Common.empty(refer) ? "space.jsp?do=event&id=" + eventid + "&view=member&status=" + status : refer; return showMessage(request, response, "do_success", refer, 0); } else { return showMessage(request, response, "choose_right_eventmember"); } } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } int uid = Common.intval(request.getParameter("uid")); query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("userevent") + " WHERE uid='" + uid + "' AND eventid='" + eventid + "'"); Map<String, Object> userevent = query.size() > 0 ? query.get(0) : null; if (Common.empty(userevent)) { return showMessage(request, response, "choose_right_eventmember"); } try { tempS = Common.nl2br(Common.getStr((String) userevent.get("template"), 255, true, false, true, 0, 0, request, response)); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } userevent.put("template", tempS); request.setAttribute("uid", uid); request.setAttribute("userevent", userevent); } else if ("pic".equals(op)) { if (!allowmanage) { return showMessage(request, response, "no_privilege_manage_event_pic"); } if (submitCheck(request, "deletepicsubmit")) { String[] ids = request.getParameterValues("ids[]"); if (!Common.empty(ids)) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("eventpic") + " WHERE eventid='" + eventid + "' AND picid IN (" + Common.sImplode(ids) + ")"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET picnum = (SELECT COUNT(*) FROM " + JavaCenterHome.getTableName("eventpic") + " WHERE eventid='" + eventid + "') WHERE eventid = '" + eventid + "'"); return showMessage(request, response, "do_success", "cp.jsp?ac=event&op=pic&id=" + eventid, 0); } else { return showMessage(request, response, "choose_event_pic"); } } int perpage = 16; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } String theurl = "cp.jsp?ac=event&id=" + eventid + "&op=pic"; List<Map<String, Object>> photolist = null; int count = 0; query = dataBaseService.executeQuery("SELECT COUNT(*) AS cont FROM " + JavaCenterHome.getTableName("eventpic") + " WHERE eventid = '" + eventid + "'"); if (query.size() > 0) { count = (Integer) query.get(0).get("cont"); } if (count != 0) { query = dataBaseService.executeQuery("SELECT pic.* FROM " + JavaCenterHome.getTableName("eventpic") + " ep LEFT JOIN " + JavaCenterHome.getTableName("pic") + " pic ON ep.picid=pic.picid WHERE ep.eventid='" + eventid + "' ORDER BY ep.picid DESC LIMIT " + start + ", " + perpage); for (Map<String, Object> value : query) { value.put("pic", Common.pic_get(sConfig, (String) value.get("filepath"), (Integer) value.get("thumb"), (Integer) value.get("remote"), true)); } photolist = query; } String multi = Common.multi(request, count, perpage, page, maxPage, theurl, null, null); int photolistSize = photolist == null ? 0 : photolist.size(); request.setAttribute("photolistSize", photolistSize); request.setAttribute("photolist", photolist); request.setAttribute("multi", multi); } else if ("thread".equals(op)) { if (!allowmanage) { return showMessage(request, response, "no_privilege_manage_event_thread"); } if (Common.empty(event.get("tagid"))) { return showMessage(request, response, "event_has_not_mtag"); } try { if (submitCheck(request, "delthreadsubmit")) { String[] ids = request.getParameterValues("ids[]"); if (!Common.empty(ids)) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("thread") + " WHERE eventid='" + eventid + "' AND tid IN (" + Common.sImplode(ids) + ")"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET threadnum = (SELECT COUNT(*) FROM " + JavaCenterHome.getTableName("thread") + " WHERE eventid='" + eventid + "') WHERE eventid = '" + eventid + "'"); return showMessage(request, response, "do_success", "cp.jsp?ac=event&id=" + eventid + "&op=thread", 0); } else { return showMessage(request, response, "choose_event_thread"); } } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } int perpage = 20; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } List<Map<String, Object>> threadlist = null; int count = 0; query = dataBaseService.executeQuery("SELECT COUNT(*) AS cont FROM " + JavaCenterHome.getTableName("thread") + " WHERE eventid = '" + eventid + "'"); if (query.size() > 0) { count = (Integer) query.get(0).get("cont"); } if (count != 0) { query = dataBaseService.executeQuery( "SELECT * FROM " + JavaCenterHome.getTableName("thread") + " WHERE eventid='" + eventid + "' ORDER BY lastpost DESC LIMIT " + start + ", " + perpage); for (Map<String, Object> value : query) { Common.realname_set(sGlobal, sConfig, sNames, (Integer) value.get("uid"), (String) value.get("username"), "", 0); Common.realname_set(sGlobal, sConfig, sNames, (Integer) value.get("lastauthorid"), (String) value.get("lastauthor"), "", 0); } threadlist = query; } String multi = Common.multi(request, count, perpage, page, maxPage, "cp.jsp?ac=event&id=" + eventid + "&op=thread", null, null); request.setAttribute("threadlist", threadlist); } else if ("join".equals(op)) { boolean popupmenu_box; if (cpService.isBlackList((Integer) event.get("uid"), supe_uid) != 0) { popupmenu_box = true; return showMessage(request, response, "is_blacklist"); } if (Common.empty(sGlobal.get("supe_userevent"))) { popupmenu_box = true; if (timestamp > (Integer) event.get("endtime")) { return showMessage(request, response, "event_is_over"); } if (timestamp > (Integer) event.get("deadline")) { return showMessage(request, response, "event_meet_deadline"); } if ((Integer) event.get("limitnum") > 0 && (Integer) event.get("membernum") >= (Integer) event.get("limitnum")) { return showMessage(request, response, "event_already_full"); } if ((Integer) event.get("public") < 2) { query = dataBaseService.executeQuery( "SELECT * FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid = '" + event.get("eventid") + "' AND touid = '" + supe_uid + "' LIMIT 1"); Map<String, Object> value = query.size() > 0 ? query.get(0) : null; if (Common.empty(value)) { return showMessage(request, response, "event_join_limit"); } } } if (submitCheck(request, "joinsubmit")) { Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); boolean supe_usereventNotEmpty = !Common.empty(supe_userevent); Integer supe_usereventStatus = supe_usereventNotEmpty ? (Integer) supe_userevent.get("status") : null; if (supe_usereventStatus != null && supe_usereventStatus == 0) { Map<String, Object> arr = new HashMap<String, Object>(); tempS = request.getParameter("fellow"); if (tempS != null) { arr.put("fellow", Common.intval(tempS)); } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { try { tempS = Common.getStr(tempS, 255, true, true, true, 0, 0, request, response); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } arr.put("template", tempS); } if (!Common.empty(arr)) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); whereData.put("uid", supe_uid); dataBaseService.updateTable("userevent", arr, whereData); } return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 2); } if (supe_usereventStatus != null && supe_usereventStatus > 1) { Map<String, Object> arr = new HashMap<String, Object>(); int num = 0; tempS = request.getParameter("fellow"); if (tempS != null) { int fellow = Common.intval(tempS); arr.put("fellow", fellow); Integer supe_usereventFellow = (Integer) supe_userevent.get("fellow"); supe_usereventFellow = supe_usereventFellow == null ? 0 : supe_usereventFellow; num = fellow - supe_usereventFellow; int eventLimitnum = (Integer) event.get("limitnum"); if (eventLimitnum > 0 && num + (Integer) event.get("membernum") > eventLimitnum) { return showMessage(request, response, "event_already_full"); } } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { arr.put("template", tempS); } if (!Common.empty(arr)) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); whereData.put("uid", supe_uid); dataBaseService.updateTable("userevent", arr, whereData); } if (num != 0) { dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET membernum = membernum + " + num + " WHERE eventid=" + eventid); } return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } int arrStatus = 2; Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("template", event.get("template")); arr.put("fellow", 0); arr.put("dateline", timestamp); int num = 1; String numsql; tempS = request.getParameter("fellow"); if (!Common.empty(tempS)) { int fellow = Common.intval(tempS); arr.put("fellow", fellow); num += fellow; } tempS = request.getParameter("template"); if (!Common.empty(tempS)) { try { tempS = Common.getStr(tempS, 255, true, true, true, 0, 0, request, response); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } arr.put("template", tempS); } int eventLimitnum = (Integer) event.get("limitnum"); if (eventLimitnum > 0 && num + (Integer) event.get("membernum") > eventLimitnum) { return showMessage(request, response, "event_will_full"); } numsql = " membernum = membernum + " + num + " "; query = dataBaseService .executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); Map<String, Object> eventinvite = query.size() > 0 ? query.get(0) : null; if (!Common.empty(event.get("verify")) && Common.empty(eventinvite)) { arrStatus = 0; } arr.put("status", arrStatus); if (supe_usereventStatus != null && supe_usereventStatus == 1) { Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", supe_uid); whereData.put("eventid", eventid); dataBaseService.updateTable("userevent", arr, whereData); numsql += ",follownum = follownum - 1 "; } else { dataBaseService.insertTable("userevent", arr, false, false); } int eventUid = (Integer) event.get("uid"); if (arrStatus == 2) { dataBaseService.execute("UPDATE " + JavaCenterHome.getTableName("event") + " SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { Common.realname_set(sGlobal, sConfig, sNames, eventUid, (String) event.get("username"), "", 0); Common.realname_get(sGlobal, sConfig, sNames, space); Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", sNames.get(eventUid)); cpService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } else if (arrStatus == 0) { if (supe_usereventStatus != null && supe_usereventStatus == 1) { dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET follownum = follownum - 1 WHERE eventid = '" + eventid + "'"); } List<Integer> note_ids = new ArrayList<Integer>(); List<String> note_inserts = new ArrayList<String>(); int eventEventid = (Integer) event.get("eventid"); String note_msg = Common.getMessage(request, "cp_event_join_verify", "space.jsp?do=event&id=" + eventEventid, event.get("title"), "cp.jsp?ac=event&id=" + eventEventid + "&op=members&status=0&key=" + supe_username); query = dataBaseService.executeQuery("SELECT ue.*, sf.* FROM " + JavaCenterHome.getTableName("userevent") + " ue LEFT JOIN " + JavaCenterHome.getTableName("spacefield") + " sf ON ue.uid=sf.uid WHERE ue.eventid='" + eventid + "' AND ue.status >= 3"); Map<String, Object> privacyM; Set<String> filter; Map<String, Object> filter_noteM; Map<String, Object> note = new HashMap<String, Object>(); note.put("type", "eventmember"); note.put("authorid", supe_uid); StringBuilder builder = new StringBuilder(); int valueUid; for (Map<String, Object> value : query) { tempS = (String) value.get("privacy"); privacyM = Common.empty(tempS) ? new HashMap<String, Object>() : (Map<String, Object>) Serializer.unserialize(tempS); value.put("privacy", privacyM); filter_noteM = (Map<String, Object>) privacyM.get("filter_note"); filter = Common.empty(filter_noteM) ? new HashSet<String>() : filter_noteM.keySet(); if (cpService.checkNoteUid(note, filter)) { valueUid = (Integer) value.get("uid"); note_ids.add(valueUid); builder.append("('"); builder.append(valueUid); builder.append("', 'eventmember', '1', '"); builder.append(supe_uid); builder.append("', '"); builder.append(supe_username); builder.append("', '"); builder.append(Common.addSlashes(note_msg)); builder.append("', '"); builder.append(timestamp); builder.append("')"); note_inserts.add(builder.toString()); builder.delete(0, builder.length()); } } if (!Common.empty(note_inserts)) { dataBaseService.execute("INSERT INTO " + JavaCenterHome.getTableName("notification") + " (`uid`, `type`, `new`, `authorid`, `author`, `note`, `dateline`) VALUES " + Common.implode(note_inserts, ",")); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET notenum=notenum+1 WHERE uid IN (" + Common.sImplode(note_ids) + ")"); } try { cpService.sendMail(request, response, eventUid, "", Common.getMessage(request, "event_application"), note_msg, "event"); } catch (Exception e) { return showMessage(request, response, e.getMessage()); } } Common.getReward("joinevent", true, 0, eventid + "", true, request, response); cpService.updateStat(request, "eventjoin", false); if (!Common.empty(eventinvite)) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); } return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } } else if ("quit".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "quitsubmit")) { String tourl = "space.jsp?do=event&id=" + eventid; int uid = supe_uid; Map<String, Object> userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (!Common.empty(userevent) && (Integer) event.get("uid") != uid) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' AND uid='" + uid + "'"); if ((Integer) userevent.get("status") >= 2) { int num = 1 + (Integer) userevent.get("fellow"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET membernum = membernum - " + num + " WHERE eventid='" + eventid + "'"); } return showMessage(request, response, "do_success", tourl, 0); } else { return showMessage(request, response, "cannot_quit_event", tourl, 2); } } } else if ("follow".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); boolean popupmenu_box = false; if (!Common.empty(supe_userevent)) { popupmenu_box = true; if ((Integer) supe_userevent.get("status") <= 1) { return showMessage(request, response, "event_has_followed"); } else { return showMessage(request, response, "event_has_joint"); } } if (submitCheck(request, "followsubmit")) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("status", 1); arr.put("fellow", 0); arr.put("template", event.get("template")); dataBaseService.insertTable("userevent", arr, false, false); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET follownum = follownum + 1 WHERE eventid='" + eventid + "'"); return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } } else if ("cancelfollow".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "cancelfollowsubmit")) { Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (!Common.empty(supe_userevent) && (Integer) supe_userevent.get("status") == 1) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("userevent") + " WHERE uid='" + supe_uid + "' AND eventid='" + eventid + "'"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET follownum = follownum - 1 WHERE eventid='" + eventid + "'"); } return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } } else if ("eventinvite".equals(op)) { if (!Common.empty(request.getParameter("r"))) { tempS = request.getParameter("page"); String tourl = "cp.jsp?ac=event&op=eventinvite" + (tempS != null ? "&page=" + Common.intval(tempS) : ""); if (eventid != 0) { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid = '" + eventid + "' AND touid = '" + supe_uid + "'"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); } else { dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE touid = '" + supe_uid + "'"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET eventinvitenum=0 WHERE uid = '" + supe_uid + "'"); } return showMessage(request, response, "do_success", tourl, 0); } int perpage = 20; tempS = request.getParameter("page"); int page = Common.empty(tempS) ? 1 : Common.intval(tempS); if (page < 1) page = 1; int start = (page - 1) * perpage; int maxPage = (Integer) sConfig.get("maxpage"); if ((tempS = Common.ckStart(start, perpage, maxPage)) != null) { return showMessage(request, response, tempS); } String theurl = "cp.jsp?ac=event&op=eventinvite"; Map<String, Object> whereArr = new HashMap<String, Object>(); whereArr.put("touid", supe_uid); int count = Common.intval(Common.getCount("eventinvite", whereArr, null)); if (count != (Integer) space.get("eventinvitenum")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("eventinvitenum", count); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", space.get("uid")); dataBaseService.updateTable("space", setData, whereData); } List<Map<String, Object>> eventinvites = null; if (count > 0) { query = dataBaseService.executeQuery("SELECT ei.*, e.*, ei.dateline as invitetime FROM " + JavaCenterHome.getTableName("eventinvite") + " ei LEFT JOIN " + JavaCenterHome.getTableName("event") + " e ON ei.eventid=e.eventid WHERE ei.touid='" + supe_uid + "' limit " + start + ", " + perpage); for (Map<String, Object> value : query) { Common.realname_set(sGlobal, sConfig, sNames, (Integer) value.get("uid"), (String) value.get("username"), "", 0); if (!Common.empty(value.get("poster"))) { value.put("pic", Common.pic_get(sConfig, (String) value.get("poster"), (Integer) value.get("thumb"), (Integer) value.get("remote"), true)); } else { value.put("pic", globalEventClass.get(value.get("classid")).get("poster")); } } eventinvites = query; } String multi = Common.multi(request, count, perpage, page, maxPage, theurl, null, null); request.setAttribute("eventinvites", eventinvites); request.setAttribute("multi", multi); } else if ("acceptinvite".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } query = dataBaseService.executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "' LIMIT 1"); Map<String, Object> eventinvite = query.size() > 0 ? query.get(0) : null; if (Common.empty(eventinvite)) { return showMessage(request, response, "eventinvite_does_not_exist"); } dataBaseService.execute("DELETE FROM " + JavaCenterHome.getTableName("eventinvite") + " WHERE eventid='" + eventid + "' AND touid='" + supe_uid + "'"); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("space") + " SET eventinvitenum=eventinvitenum-1 WHERE uid = '" + supe_uid + "' AND eventinvitenum>0"); if (cpService.isBlackList((Integer) event.get("uid"), supe_uid) != 0) { return showMessage(request, response, "is_blacklist"); } if (timestamp > (Integer) event.get("endtime")) { return showMessage(request, response, "event_is_over"); } if (timestamp > (Integer) event.get("deadline")) { return showMessage(request, response, "event_meet_deadline"); } int eventLimitnum = (Integer) event.get("limitnum"); int eventMembernum = (Integer) event.get("membernum"); if (eventLimitnum > 0 && eventMembernum >= eventLimitnum) { return showMessage(request, response, "event_already_full"); } String numsql = "membernum = membernum + 1"; Map<String, Object> supe_userevent = (Map<String, Object>) sGlobal.get("supe_userevent"); if (Common.empty(supe_userevent)) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("eventid", eventid); arr.put("uid", supe_uid); arr.put("username", supe_username); arr.put("status", 2); arr.put("template", event.get("template")); arr.put("fellow", 0); arr.put("dateline", timestamp); dataBaseService.insertTable("userevent", arr, false, false); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { int eventUid = (Integer) event.get("uid"); Common.realname_set(sGlobal, sConfig, sNames, (Integer) eventUid, (String) event.get("username"), "", 0); Common.realname_get(sGlobal, sConfig, sNames, space); Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", sNames.get(eventUid)); cpService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } else if ((Integer) supe_userevent.get("status") < 2) { Map<String, Object> arr = new HashMap<String, Object>(); arr.put("status", 2); if ((Integer) supe_userevent.get("status") == 1) { numsql += ",follownum = follownum - 1 "; } if (eventLimitnum > 0 && eventMembernum + (Integer) supe_userevent.get("fellow") > eventLimitnum) { arr.put("fellow", 0); } Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("uid", supe_uid); whereData.put("eventid", eventid); dataBaseService.updateTable("userevent", arr, whereData); dataBaseService.executeUpdate("UPDATE " + JavaCenterHome.getTableName("event") + " SET " + numsql + " WHERE eventid = '" + eventid + "'"); if (Common.ckPrivacy(sGlobal, sConfig, space, "join", 0)) { int eventUid = (Integer) event.get("uid"); Map<String, Object> title_data = new HashMap<String, Object>(); title_data.put("title", event.get("title")); title_data.put("eventid", event.get("eventid")); title_data.put("uid", eventUid); title_data.put("username", event.get("username")); cpService.addFeed(sGlobal, "event", Common.getMessage(request, "cp_event_join"), title_data, "", null, "", null, null, "", 0, 0, 0, "", false); } } return showMessage(request, response, Common.getMessage(request, "cp_event_accept_success", "space.jsp?do=event&id=" + event.get("eventid"))); } else if ("delete".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if (submitCheck(request, "deletesubmit")) { adminDeleteService.deleteEvents(request, response, sGlobal, new Integer[] { eventid }); return showMessage(request, response, "do_success", "space.jsp?do=event", 2); } } else if ("print".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (submitCheck(request, "printsubmit")) { List<Map<String, Object>> members; List uid; if (!Common.empty(request.getParameter("admin"))) { query = dataBaseService.executeQuery( "SELECT * FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' AND status > 1 ORDER BY status DESC, dateline ASC"); } else { query = dataBaseService .executeQuery("SELECT * FROM " + JavaCenterHome.getTableName("userevent") + " WHERE eventid='" + eventid + "' AND status = 2 ORDER BY dateline ASC"); } for (Map<String, Object> value : query) { value.put("template", Common.nl2br(Common.htmlSpecialChars((String) value.get("template")))); Common.realname_set(sGlobal, sConfig, sNames, (Integer) value.get("uid"), (String) value.get("username"), "", 0); } members = query; Common.realname_get(sGlobal, sConfig, sNames, space); request.setAttribute("event", event); request.setAttribute("members", members); return include(request, response, sConfig, sGlobal, "cp_event_sheet.jsp"); } } else if ("close".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if ((Integer) event.get("grade") < 1 || (Integer) event.get("endtime") > timestamp) { return showMessage(request, response, "event_can_not_be_closed"); } if (submitCheck(request, "closesubmit")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("grade", -2); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("event", setData, whereData); return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } } else if ("open".equals(op)) { if (eventid == 0) { return showMessage(request, response, "event_does_not_exist"); } if (!allowmanage) { return showMessage(request, response, "no_privilege"); } if ((Integer) event.get("grade") != -2 || (Integer) event.get("endtime") > timestamp) { return showMessage(request, response, "event_can_not_be_opened"); } if (submitCheck(request, "opensubmit")) { Map<String, Object> setData = new HashMap<String, Object>(); setData.put("grade", 1); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("event", setData, whereData); return showMessage(request, response, "do_success", "space.jsp?do=event&id=" + eventid, 0); } } else if ("calendar".equals(op)) { List<String> match = null; String monthGet = request.getParameter("month"); String dateGet = request.getParameter("date"); if (Common.empty(monthGet)) { match = Common.pregMatch(dateGet, "^(\\d{4}-\\d{1,2})"); if (!Common.empty(match)) { monthGet = match.get(1); } } if (monthGet != null) { match = Common.pregMatch(monthGet, "^(\\d{4})-(\\d{1,2})$"); } int year; int month; if (!Common.empty(match)) { year = Common.intval(match.get(1)); month = Common.intval(match.get(2)); } else { year = Common.intval(Common.sgmdate(request, "yyyy", timestamp)); month = Common.intval(Common.sgmdate(request, "MM", timestamp)); } String nextmonth; String premonth; if (month == 12) { nextmonth = (year + 1) + "-" + "1"; premonth = year + "-11"; } else if (month == 1) { nextmonth = year + "-2"; premonth = (year - 1) + "-12"; } else { nextmonth = year + "-" + (month + 1); premonth = year + "-" + (month - 1); } Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.YEAR, year); int daystart = (int) (calendar.getTimeInMillis() / 1000); int week = calendar.get(Calendar.DAY_OF_WEEK) - 1; int dayscount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.add(Calendar.MONTH, 1); int dayend = (int) (calendar.getTimeInMillis() / 1000); Map<Integer, Map<String, Object>> days = new LinkedHashMap<Integer, Map<String, Object>>(); Map<String, Object> subM; for (int i = 1; i <= dayscount; i++) { subM = new HashMap<String, Object>(); subM.put("count", 0); subM.put("events", new ArrayList<Map<String, Object>>()); subM.put("class", ""); days.put(i, subM); } query = dataBaseService.executeQuery( "SELECT * FROM " + JavaCenterHome.getTableName("event") + " WHERE starttime < " + dayend + " AND endtime > " + daystart + " ORDER BY eventid DESC LIMIT 100"); int tempInt; int start; int end; List<Map<String, Object>> subList; for (Map<String, Object> value : query) { if ((Integer) value.get("public") < 1 || (tempInt = (Integer) value.get("grade")) == 0 || tempInt == -1) { continue; } tempInt = (Integer) value.get("starttime"); if (tempInt < daystart) { start = 1; } else { calendar.setTimeInMillis(tempInt * 1000L); start = calendar.get(Calendar.DAY_OF_MONTH); } tempInt = (Integer) value.get("endtime"); if (tempInt > dayend) { end = dayscount; } else { calendar.setTimeInMillis(tempInt * 1000L); end = calendar.get(Calendar.DAY_OF_MONTH); } for (int i = start; i <= end; i++) { subM = days.get(i); tempInt = (Integer) subM.get("count"); if (tempInt < 10) { subList = (List<Map<String, Object>>) subM.get("events"); subList.add(value); subM.put("count", tempInt + 1); subM.put("class", " on_link"); } } } int d = 0; if (month == Common.intval(Common.sgmdate(request, "MM", timestamp)) && year == Common.intval(Common.sgmdate(request, "yyyy", timestamp))) { d = Common.intval(Common.sgmdate(request, "dd", timestamp)); subM = days.get(d); subM.put("class", "on_today"); } if (!Common.empty(dateGet)) { int t = Common.strToTime(dateGet, Common.getTimeOffset(sGlobal, sConfig)); if (month == Common.intval(Common.sgmdate(request, "MM", t)) && year == Common.intval(Common.sgmdate(request, "yyyy", t))) { d = Common.intval(Common.sgmdate(request, "dd", t)); subM = days.get(d); subM.put("class", "on_select"); } } String url = request.getParameter("url"); url = !Common.empty(url) ? url.replaceAll("date=[\\d\\-]+", "") : "space.jsp?do=event"; request.setAttribute("premonth", premonth); request.setAttribute("nextmonth", nextmonth); request.setAttribute("year", year); request.setAttribute("month", month); request.setAttribute("week", week); request.setAttribute("days", days); request.setAttribute("url", url); } else if ("edithot".equals(op)) { if (!Common.checkPerm(request, response, "manageevent")) { return showMessage(request, response, "no_privilege"); } if (submitCheck(request, "hotsubmit")) { int hot = Common.intval(request.getParameter("hot")); Map<String, Object> setData = new HashMap<String, Object>(); setData.put("hot", hot); Map<String, Object> whereData = new HashMap<String, Object>(); whereData.put("eventid", eventid); dataBaseService.updateTable("event", setData, whereData); if (hot > 0) { feedService.feedPublish(request, response, eventid, "eventid", false); } else { whereData.clear(); whereData.put("id", eventid); whereData.put("idtype", eventid); dataBaseService.updateTable("feed", setData, whereData); } return showMessage(request, response, "do_success", "space.jsp?uid=" + event.get("uid") + "&do=event&id=" + eventid, 0); } } else if ("edit".equals(op)) { if (eventid != 0) { if (!allowmanage) { return showMessage(request, response, "no_privilege_edit_event"); } } else { if (!Common.checkPerm(request, response, "allowevent")) { return showMessage(request, response, "no_privilege_add_event"); } if (!cpService.checkRealName(request, "event")) { return showMessage(request, response, "no_privilege_realname"); } if (!cpService.checkVideoPhoto(request, response, "event")) { return showMessage(request, response, "no_privilege_videophoto"); } switch (cpService.checkNewUser(request, response)) { case 1: break; case 2: return showMessage(request, response, "no_privilege_newusertime", "", 1, String.valueOf(sConfig.get("newusertime"))); case 3: return showMessage(request, response, "no_privilege_avatar"); case 4: return showMessage(request, response, "no_privilege_friendnum", "", 1, String.valueOf(sConfig.get("need_friendnum"))); case 5: return showMessage(request, response, "no_privilege_email"); } event = new HashMap<String, Object>(); event.put("eventid", ""); int starttime = (int) (Math.ceil(timestamp / 3600D) * 3600 + 7200); event.put("starttime", starttime); event.put("endtime", starttime + 14400); event.put("deadline", starttime); event.put("allowinvite", 1); event.put("allowpost", 1); event.put("allowpic", 1); event.put("allowfellow", 0); event.put("verify", 0); event.put("public", 2); event.put("limitnum", 0); event.put("province", space.get("resideprovince")); event.put("city", space.get("residecity")); Map<String, Object> topic = null; int topicid = Common.intval(request.getParameter("topicid")); if (topicid != 0) { topic = Common.getTopic(request, topicid); } Map<String, String> actives = null; if (!Common.empty(topic)) { actives = new HashMap<String, String>(); actives.put("event", " class=\"active\""); } request.setAttribute("topicid", topicid); request.setAttribute("topic", topic); } List<Map<String, Object>> mtags = null; Integer eventUid = (Integer) event.get("uid"); if (eventid == 0 || (eventUid != null && eventUid.intValue() == supe_uid)) { query = dataBaseService.executeQuery("SELECT mtag.* FROM " + JavaCenterHome.getTableName("tagspace") + " st LEFT JOIN " + JavaCenterHome.getTableName("mtag") + " mtag ON st.tagid=mtag.tagid WHERE st.uid='" + supe_uid + "' AND st.grade=9"); mtags = query; } int tagid = Common.intval(request.getParameter("tagid")); if (tagid != 0 && Common.empty(event.get("tagid"))) { event.put("tagid", tagid); } Map<String, Object> subM; Object tempOb; for (Entry<Integer, Map<String, Object>> entry : globalEventClass.entrySet()) { subM = entry.getValue(); tempOb = subM.get("template"); if (tempOb != null) { subM.put("template", String.valueOf(tempOb).replace("\r\n", "<br>").replace("\r", "<br>") .replace("\n", "<br>")); } } request.setAttribute("globalEventClass", globalEventClass); request.setAttribute("mtags", mtags); request.setAttribute("ckPrivacy", Common.ckPrivacy(sGlobal, sConfig, space, "event", 1)); } } catch (Exception e) { return showMessage(request, response, e.getMessage()); } Common.realname_get(sGlobal, sConfig, sNames, space); request.setAttribute("op", op); request.setAttribute("eventid", eventid); request.setAttribute("allowmanage", allowmanage); request.setAttribute("event", event); request.setAttribute("menus", menus); return include(request, response, sConfig, sGlobal, "cp_event.jsp"); }