import freemarker.template.utility.*;
import mir.misc.*;
import mir.entity.*;
+import mir.util.*;
import mircoders.module.*;
import mircoders.storage.*;
import mircoders.localizer.*;
Map configMap = new HashMap();
Map utilityMap = new HashMap();
- configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
- configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
+ configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
+ configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
configMap.put("productionHost", MirGlobal.getConfigProperty("Producer.ProductionHost"));
- configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
- configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
- configMap.put("now", StringUtil.date2readableDateTime(new GregorianCalendar()));
- configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
- configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
- configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
- configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
- configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
- configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
-
- utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+ configMap.put("openAction", MirGlobal.getConfigProperty("Producer.OpenAction"));
+ configMap.put("docRoot", MirGlobal.getConfigProperty("RootUri"));
+ configMap.put("now", new DateToMapAdapter((new GregorianCalendar()).getTime()));
+ configMap.put("videoHost", MirGlobal.getConfigProperty("Producer.Video.Host"));
+ configMap.put("audioHost", MirGlobal.getConfigProperty("Producer.Audio.Host"));
+ configMap.put("imageHost", MirGlobal.getConfigProperty("Producer.Image.Host"));
+ configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
+ configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
+ configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
+
+ utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
aValueSet.put("config", configMap);
aValueSet.put("utility", utilityMap);
postingFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDoneTemplate");
postingFormDupeTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDupeTemplate");
directOp = MirConfig.getProp("DirectOpenposting").toLowerCase();
- passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
+ passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
mainModule = new ModuleComment(DatabaseComment.getInstance());
contentModule = new ModuleContent(DatabaseContent.getInstance());
themenModule = new ModuleTopics(DatabaseTopics.getInstance());
public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
{
String aid = req.getParameter("aid"); // the article id the comment will belong to
+ String language = req.getParameter("language");
+
if (aid!=null && !aid.equals(""))
{
- SimpleHash mergeData = new SimpleHash();
+ SimpleHash mergeData = new SimpleHash();
+
+ // onetimepasswd
+ if(passwdProtection.equals("yes")){
+ String passwd = this.createOneTimePasswd();
+ System.out.println(passwd);
+ HttpSession session = req.getSession(false);
+ session.setAttribute("passwd",passwd);
+ mergeData.put("passwd", passwd);
+ }
- // onetimepasswd
- if(passwdProtection.equals("yes")){
- String passwd = this.createOneTimePasswd();
- System.out.println(passwd);
- HttpSession session = req.getSession(false);
- session.setAttribute("passwd",passwd);
- mergeData.put("passwd", passwd);
- }
+ if (language!=null) {
+ HttpSession session = req.getSession(false);
+ session.setAttribute("Locale", new Locale(language, ""));
+ session.setAttribute("passwd",language);
+ }
mergeData.put("aid", aid);
deliver(req, res, mergeData, commentFormTemplate);
*/
public void inscomment(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException,ServletModuleUserException
+ throws ServletModuleException,ServletModuleUserException
{
String aid = req.getParameter("to_media"); // the article id the comment will belong to
if (aid!=null && !aid.equals(""))
}
withValues.put("is_published","1");
- //checking the onetimepasswd
- if(passwdProtection.equals("yes")){
- HttpSession session = req.getSession(false);
- String sessionPasswd = (String)session.getAttribute("passwd");
- if ( sessionPasswd == null){
- throw new ServletModuleUserException("Lost password");
- }
- String passwd = req.getParameter("passwd");
- if ( passwd == null || (!sessionPasswd.equals(passwd))) {
- throw new ServletModuleUserException("Missing password");
- }
- session.invalidate();
- }
+ //checking the onetimepasswd
+ if(passwdProtection.equals("yes")){
+ HttpSession session = req.getSession(false);
+ String sessionPasswd = (String)session.getAttribute("passwd");
+ if ( sessionPasswd == null){
+ throw new ServletModuleUserException("Lost password");
+ }
+ String passwd = req.getParameter("passwd");
+ if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+ throw new ServletModuleUserException("Missing password");
+ }
+ session.invalidate();
+ }
// inserting into database
String id = mainModule.add(withValues);
throws ServletModuleException {
SimpleHash mergeData = new SimpleHash();
- // onetimepasswd
- if(passwdProtection.equals("yes")){
- String passwd = this.createOneTimePasswd();
- System.out.println(passwd);
- HttpSession session = req.getSession(false);
- session.setAttribute("passwd",passwd);
- mergeData.put("passwd", passwd);
- }
+ // onetimepasswd
+ if(passwdProtection.equals("yes")){
+ String passwd = this.createOneTimePasswd();
+ System.out.println(passwd);
+ HttpSession session = req.getSession(false);
+ session.setAttribute("passwd",passwd);
+ mergeData.put("passwd", passwd);
+ }
String maxMedia = MirConfig.getProp("ServletModule.OpenIndy.MaxMediaUploadItems");
String numOfMedia = req.getParameter("medianum");
{
SimpleHash mergeData = new SimpleHash();
boolean setMedia=false;
- boolean setTopic = false;
+ boolean setTopic = false;
try {
WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
HashMap withValues = mp.getParameters();
- //checking the onetimepasswd
- if(passwdProtection.equals("yes")){
- HttpSession session = req.getSession(false);
- String sessionPasswd = (String)session.getAttribute("passwd");
- if ( sessionPasswd == null){
- throw new ServletModuleUserException("Lost password");
- }
- String passwd = (String)withValues.get("passwd");
- if ( passwd == null || (!sessionPasswd.equals(passwd))) {
- throw new ServletModuleUserException("Missing password");
- }
- session.invalidate();
- }
+ //checking the onetimepasswd
+ if(passwdProtection.equals("yes")){
+ HttpSession session = req.getSession(false);
+ String sessionPasswd = (String)session.getAttribute("passwd");
+ if ( sessionPasswd == null){
+ throw new ServletModuleUserException("Lost password");
+ }
+ String passwd = (String)withValues.get("passwd");
+ if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+ throw new ServletModuleUserException("Missing password");
+ }
+ session.invalidate();
+ }
if ((((String)withValues.get("title")).length() == 0) ||
(((String)withValues.get("description")).length() == 0) ||
String[] to_topicsArr = mp.getParameterValues("to_topic");
- if (to_topicsArr != null && to_topicsArr.length > 0) {
+ if (to_topicsArr != null && to_topicsArr.length > 0) {
try{
DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
setTopic = true;
+"Error One or more files of unrecognized type. Sorry");
}
- protected String createOneTimePasswd(){
- Random r = new Random();
- int random = r.nextInt();
- long l = System.currentTimeMillis();
- l = (l*l*l*l)/random;
- if(l<0) l = l * -1;
- String returnString = ""+l;
- return returnString.substring(5);
- }
+ protected String createOneTimePasswd(){
+ Random r = new Random();
+ int random = r.nextInt();
+ long l = System.currentTimeMillis();
+ l = (l*l*l*l)/random;
+ if(l<0) l = l * -1;
+ String returnString = ""+l;
+ return returnString.substring(5);
+ }
}