Compare commits
14 Commits
975d9ee310
...
65fe6498cd
| Author | SHA1 | Date | |
|---|---|---|---|
| 65fe6498cd | |||
| ddcb146952 | |||
| 6155890816 | |||
| afbf168bd8 | |||
| 91e8b21d39 | |||
| ec85845d9e | |||
| 5a6b47e788 | |||
| 5cca3481c4 | |||
| 9d0332d2ee | |||
| 8952eb375d | |||
| d9e5677a8c | |||
| 0b5903938c | |||
| 21df97b853 | |||
| 93650e9d1a |
@ -1,4 +1,4 @@
|
||||
package com.geovizor.monitoring; //Главная 2
|
||||
package dbms; //package org.ccalm.monitoring; //Главная 2
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
@ -8,29 +8,36 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
//import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jws;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
@ -48,26 +55,27 @@ import javax.xml.xpath.XPathFactory;
|
||||
//import org.apache.commons.fileupload.FileItem;
|
||||
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.w3c.dom.CharacterData;
|
||||
@ -81,47 +89,100 @@ import org.w3c.dom.ls.LSSerializer;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import tctable.Tools;
|
||||
import tools.DBTools;
|
||||
import tools.EmailUtility;
|
||||
import tools.Translation;
|
||||
import tools.User;
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes( { "user" }) //Сесионный объект
|
||||
public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
//private static final Logger logger = LoggerFactory.getLogger(Translation.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DBMSRecords.class);
|
||||
private static final Logger logger = LogManager.getLogger(DBMSRecords.class);
|
||||
|
||||
private final NamedParameterJdbcTemplate jdbcTemplate;
|
||||
private ServletContext context;
|
||||
private Properties m_props=null;
|
||||
private String m_props_loc="";
|
||||
|
||||
//If not created object "user", create him.
|
||||
@ModelAttribute("user")
|
||||
public User populatePerson() {
|
||||
return new User("none");
|
||||
|
||||
@Value("${public.key}")
|
||||
String key_a_txt="";
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Autowired
|
||||
public DBMSRecords(NamedParameterJdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public String sendError(int code, String message) {
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
public String sendError(int code, String message,String marker) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("error_code",code);
|
||||
json.put("error_message",message);
|
||||
json.put("error_marker",marker);
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
private PublicKey getPublicKey(){
|
||||
try {
|
||||
byte[] keyBytes = Base64.getDecoder().decode(key_a_txt);
|
||||
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
PublicKey key = keyFactory.generatePublic(spec);
|
||||
return key;
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Документация по @RequestBody http://javastudy.ru/spring-mvc/json-xml/ application/xml
|
||||
@RequestMapping(value = "/api/dbms/records.xyz",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
|
||||
//Обычно мантирую в: /api/dbms/v09/
|
||||
@RequestMapping(value = "/dbms",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> ajaxTamer(@ModelAttribute User user, @RequestBody(required = false) byte[] reqData, @RequestParam(required=false,name="lng") String language_id) {
|
||||
public ResponseEntity<String> ajaxRecords(
|
||||
@ModelAttribute User user,
|
||||
@RequestBody(required = false) byte[] reqData,
|
||||
@CookieValue(value = "jwt_a", defaultValue = "") String jwt_a,
|
||||
@RequestParam(required=false,name="lng") String language_id
|
||||
) {
|
||||
final HttpHeaders httpHeaders= new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
String result=sendError(10000,"Request_not_processed",null);
|
||||
|
||||
if(language_id!=null && !language_id.equals(""))
|
||||
if(user.id==null || user.id.equals("null")) { //
|
||||
if (jwt_a.equals("") || Tools.countOccurrences(jwt_a, '.') != 2) {
|
||||
result = sendError(10000, "Please_send_a_valid_JWT_token",null);
|
||||
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
//Проверяю подпись токена
|
||||
Jws<Claims> claims = null;
|
||||
PublicKey key_a = getPublicKey(); //SecretKey key_a = new SecretKeySpec(Base64.getDecoder().decode(env.getProperty("access.key")), "HmacSHA256");
|
||||
try {
|
||||
claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key_a)
|
||||
.build()
|
||||
.parseClaimsJws(jwt_a);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<String>("JWT_token_verification_error", httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
user.id = claims.getBody().get("user_id").toString();
|
||||
}
|
||||
|
||||
|
||||
if(language_id!=null && !language_id.equals(""))
|
||||
user.language_id=language_id;
|
||||
logger.info("user.id="+user.id+" user.name="+user.name+" user.language_id="+user.language_id+" user.country_id="+user.country_id);
|
||||
|
||||
boolean error=false;
|
||||
String result=sendError(1,"Request not processed!");
|
||||
result=sendError(10000,"Request not processed!",null);
|
||||
if(reqData==null)
|
||||
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
|
||||
|
||||
@ -129,62 +190,27 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
//response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
//Thread.sleep(5000); // sleep 5 seconds
|
||||
//String metadata_file = "";
|
||||
String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
try {
|
||||
prop.load(new FileInputStream("monitoring.properties")); // load a properties file
|
||||
//Читаю настройки базы
|
||||
db_url = prop.getProperty("db.url");
|
||||
System.out.println("db.url = " + db_url);
|
||||
//dbSchema = prop.getProperty("db.schema");
|
||||
//System.out.println("db.schema = " + dbSchema);
|
||||
db_login = prop.getProperty("db.login");
|
||||
System.out.println("db.login = " + db_login);
|
||||
db_password = prop.getProperty("db.password");
|
||||
//System.out.println("db.password = " + db_password);
|
||||
data_dir = prop.getProperty("data-dir");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
/*if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
String mail_host = "";
|
||||
String mail_port = "";
|
||||
String mail_login = "";
|
||||
String mail_password = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
/*try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("mail-host"))
|
||||
mail_host = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-port"))
|
||||
mail_port = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-login"))
|
||||
mail_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-password"))
|
||||
mail_password = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}*/
|
||||
try {
|
||||
db_url = env.getProperty("spring.datasource.url");
|
||||
db_login = env.getProperty("spring.datasource.username");
|
||||
db_password = env.getProperty("spring.datasource.password");
|
||||
data_dir = env.getProperty("data.dir");
|
||||
mail_host = env.getProperty("mail.host");
|
||||
mail_port = env.getProperty("mail.port");
|
||||
mail_login = env.getProperty("mail.login");
|
||||
mail_password = env.getProperty("mail.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
String jspPath = context.getRealPath("/");
|
||||
|
||||
@ -205,7 +231,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//return "<metadata fn=\"-1\"><![CDATA[Parsing request error!]]></metadata>";
|
||||
return new ResponseEntity<String>(sendError(1,"Parsing request error!"), httpHeaders, HttpStatus.OK);
|
||||
return new ResponseEntity<String>(sendError(10000,"Parsing request error!",null), httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
|
||||
if (doc != null) {
|
||||
@ -222,17 +248,17 @@ public class DBMSRecords implements ServletContextAware {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
conn = DriverManager.getConnection(db_url, db_login, db_password);
|
||||
if (conn != null) {
|
||||
logger.info("Connect is OK!");
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Marker marker = MarkerManager.getMarker(uuid);
|
||||
logger.info(marker,"Connect is OK!");
|
||||
} else {
|
||||
error=true;
|
||||
//result="<metadata fn=\"-1\"><![CDATA[An error occurred while connecting to the database!]]></metadata>";
|
||||
result=sendError(1,"An error occurred while connecting to the database!");
|
||||
result=sendError(10000,"An error occurred while connecting to the database!",null);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
error=true;
|
||||
//result="<metadata fn=\"-1\"><![CDATA[An error occurred while connecting to the database!]]></metadata>";
|
||||
result=sendError(1,"An error occurred while connecting to the database!");
|
||||
result=sendError(10000,"An error occurred while connecting to the database!",null);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -243,8 +269,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
error=true;
|
||||
//result="<metadata fn=\"-1\"><![CDATA[An set TYPE_SCROLL_SENSITIVE!]]></metadata>";
|
||||
result=sendError(1,"An set TYPE_SCROLL_SENSITIVE!");
|
||||
result=sendError(10000,"An set TYPE_SCROLL_SENSITIVE!",null);
|
||||
}
|
||||
|
||||
//response.getWriter().append("fn="+fn);
|
||||
@ -318,7 +343,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
allow = "1";
|
||||
try {
|
||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
sql_query = "select main.p_getAccess(" + user.id + ", 'Select_" + name + "') as acc;";
|
||||
sql_query = "select main.get_Access(" + user.id + ", 'Select_" + name + "') as acc;";
|
||||
rs = stt.executeQuery(sql_query);
|
||||
if (rs != null) {
|
||||
try {
|
||||
@ -334,8 +359,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage() + " SQL=" + sql_query);
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}finally {
|
||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
||||
@ -347,7 +371,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
allow = "1";
|
||||
try {
|
||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
rs = stt.executeQuery("select main.p_getAccess(" + user.id + ", 'Insert_" + name + "') as acc;");
|
||||
rs = stt.executeQuery("select main.get_Access(" + user.id + ", 'Insert_" + name + "') as acc;");
|
||||
if (rs != null) {
|
||||
try {
|
||||
if (rs.next())
|
||||
@ -362,8 +386,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}finally {
|
||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
||||
@ -375,7 +398,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
allow = "1";
|
||||
try {
|
||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
rs = stt.executeQuery("select main.p_getAccess(" + user.id + ", 'Update_" + name + "') as acc;");
|
||||
rs = stt.executeQuery("select main.get_Access(" + user.id + ", 'Update_" + name + "') as acc;");
|
||||
if (rs != null) {
|
||||
try {
|
||||
if (rs.next())
|
||||
@ -390,8 +413,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}finally {
|
||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
||||
@ -403,7 +425,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
allow = "1";
|
||||
try {
|
||||
stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
rs = stt.executeQuery("select main.p_getAccess(" + user.id + ", 'Delete_" + name + "') as acc;");
|
||||
rs = stt.executeQuery("select main.get_Access(" + user.id + ", 'Delete_" + name + "') as acc;");
|
||||
if (rs != null) {
|
||||
try {
|
||||
if (rs.next())
|
||||
@ -418,8 +440,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}finally {
|
||||
if(rs!=null) try{rs.close();}catch(SQLException ex){}
|
||||
@ -433,7 +454,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
xml += "<metadata fn=\"0\"></metadata>";
|
||||
}
|
||||
|
||||
result=getText(conn,xml,user);
|
||||
result=trts(conn,xml,user);
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
|
||||
} else if (fn != null && fn.equals("1")) {
|
||||
@ -516,7 +537,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", getSQLValue(vt, val));
|
||||
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", DBTools.getSQLValue(vt, val));
|
||||
|
||||
}
|
||||
if(user.id==null) sql_query = Tools.replaceAll(sql_query,"${_user_id}", "null");
|
||||
@ -538,7 +559,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
result=xmlstring;
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
//logger.info("xmlstring = " + xmlstring);
|
||||
}
|
||||
stt.close();
|
||||
rs.close();
|
||||
@ -546,8 +566,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
rs=null;
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -632,7 +651,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
}
|
||||
sql_query=Tools.replaceAll(sql_query,"${" + vn + "}", getSQLValue(vt, val));
|
||||
sql_query=Tools.replaceAll(sql_query,"${" + vn + "}", DBTools.getSQLValue(vt, val));
|
||||
}
|
||||
if(user.id==null) sql_query = Tools.replaceAll(sql_query,"${_user_id}", "null");
|
||||
else sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id);
|
||||
@ -654,14 +673,12 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
result=xmlstring;
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
//logger.info("xmlstring = " + xmlstring);
|
||||
}
|
||||
rs.close();
|
||||
stt.close();
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -723,10 +740,10 @@ public class DBMSRecords implements ServletContextAware {
|
||||
vt=nodeList.item(0).getAttributes().getNamedItem("vt").getNodeValue();
|
||||
}
|
||||
|
||||
sql_query=Tools.replaceAll(sql_query,"${"+vn+"}",getSQLValue(vt,val));
|
||||
sql_query=Tools.replaceAll(sql_query,"${"+vn+"}",DBTools.getSQLValue(vt,val));
|
||||
} */
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${id}", getSQLValue("string", obj_id)); //string а не i4 так как некоторые таблицы с uuid
|
||||
sql_query = Tools.replaceAll(sql_query,"${id}", DBTools.getSQLValue("string", obj_id)); //string а не i4 так как некоторые таблицы с uuid
|
||||
if(user.id==null) sql_query = Tools.replaceAll(sql_query,"${_user_id}", "null");
|
||||
else sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id);
|
||||
|
||||
@ -746,14 +763,12 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
result=xmlstring;
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
//logger.info("xmlstring = " + xmlstring);
|
||||
}
|
||||
rs.close();
|
||||
stt.close();
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -834,7 +849,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
String vt = nextnode.getAttributes().getNamedItem("vt").getNodeValue();
|
||||
String val = getCharacterDataFromElement((Element) nextnode);
|
||||
|
||||
val = getSQLValue(vt, val);
|
||||
val = DBTools.getSQLValue(vt, val);
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", val);
|
||||
} catch (Exception ex) {
|
||||
@ -860,8 +875,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
pagecount = (int) Math.ceil((double) pagecount / (double) rowspagecount);
|
||||
@ -1005,18 +1019,18 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
|
||||
result=json.toString();
|
||||
//logger.info("json = " + json);
|
||||
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
rs=null;
|
||||
stmt=null;
|
||||
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Marker marker = MarkerManager.getMarker(uuid);
|
||||
logger.error(marker,ex.getMessage(),ex);
|
||||
ex.printStackTrace();
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,trt(conn,"Error_executing_SQL_query",user),uuid);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -1061,7 +1075,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${"+idname+"}", getSQLValue("string", id));
|
||||
sql_query = Tools.replaceAll(sql_query,"${"+idname+"}", DBTools.getSQLValue("string", id));
|
||||
if(user.id==null) sql_query = Tools.replaceAll(sql_query,"${_user_id}", "null");
|
||||
else sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id);
|
||||
|
||||
@ -1104,7 +1118,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
result=xmlstring;
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
//logger.info("xmlstring = " + xmlstring);
|
||||
}
|
||||
rs.close();
|
||||
stt.close();
|
||||
@ -1112,8 +1125,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
stt=null;
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -1201,7 +1213,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
String vt = nextnode.getAttributes().getNamedItem("vt").getNodeValue();
|
||||
String val = getCharacterDataFromElement((Element) nextnode);
|
||||
|
||||
val = getSQLValue(vt, val);
|
||||
val = DBTools.getSQLValue(vt, val);
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", val);
|
||||
} catch (Exception ex) {
|
||||
@ -1241,7 +1253,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
result=xmlstring;
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
//logger.info("xmlstring = " + xmlstring);
|
||||
}
|
||||
rs.close();
|
||||
stt.close();
|
||||
@ -1249,16 +1260,14 @@ public class DBMSRecords implements ServletContextAware {
|
||||
stt=null;
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Could not find the requested node!]]></metadata>";
|
||||
result=sendError(1,"Could not find the requested node!");
|
||||
result=sendError(10000,"Could not find the requested node!",null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -1323,7 +1332,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage());
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1360,14 +1369,14 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage());
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
}
|
||||
}
|
||||
|
||||
xmlstring = "<metadata fn=\"7\"><![CDATA[" + answer + "]]></metadata>";
|
||||
} else {
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[This email address was not registered!]]></metadata>";
|
||||
xmlstring=sendError(1,"This email address was not registered!");
|
||||
xmlstring=sendError(10000,"This email address was not registered!",null);
|
||||
}
|
||||
|
||||
} else if (cmd.equals("1")) //Logout
|
||||
@ -1385,7 +1394,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query);
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1429,17 +1438,17 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
|
||||
String val;
|
||||
val = getSQLValue("i4", user_id);
|
||||
val = DBTools.getSQLValue("i4", user_id);
|
||||
sql_query = Tools.replaceAll(sql_query,"${user_id}", val);
|
||||
val = getSQLValue("string", login);
|
||||
val = DBTools.getSQLValue("string", login);
|
||||
sql_query = Tools.replaceAll(sql_query,"${login}", val);
|
||||
val = getSQLValue("string", password);
|
||||
val = DBTools.getSQLValue("string", password);
|
||||
sql_query = Tools.replaceAll(sql_query,"${password}", val);
|
||||
val = getSQLValue("string", hash);
|
||||
val = DBTools.getSQLValue("string", hash);
|
||||
sql_query = Tools.replaceAll(sql_query,"${hash}", val);
|
||||
val = getSQLValue("string", ""/*request.getSession().getId()*/);
|
||||
val = DBTools.getSQLValue("string", ""/*request.getSession().getId()*/);
|
||||
sql_query = Tools.replaceAll(sql_query,"${sessionid}", val);
|
||||
val = getSQLValue("string", ""/*request.getRemoteAddr()*/);
|
||||
val = DBTools.getSQLValue("string", ""/*request.getRemoteAddr()*/);
|
||||
sql_query = Tools.replaceAll(sql_query,"${ip}", val);
|
||||
|
||||
//logger.info("sql_query = " + sql_query);
|
||||
@ -1469,7 +1478,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}else
|
||||
{
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA["+trt(conn,"Error_in_login_or_password",user)+"]]></metadata>";
|
||||
xmlstring=sendError(1,trt(conn,"Error_in_login_or_password",user));
|
||||
xmlstring=sendError(10000,trt(conn,"Error_in_login_or_password",user),null);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
@ -1479,7 +1488,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query);
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1493,7 +1502,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
//Check exists user by email email
|
||||
sql_query = "select id from main._users where email=LOWER(TRIM(${email}))";
|
||||
val = getSQLValue("string", email);
|
||||
val = DBTools.getSQLValue("string", email);
|
||||
sql_query = Tools.replaceAll(sql_query,"${email}", val);
|
||||
try {
|
||||
Statement stt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
@ -1502,7 +1511,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
try {
|
||||
if (rs.next()) {
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA["+trt(conn,"E_mail_already_exists_in_the_database",user)+"]]></metadata>";
|
||||
xmlstring=sendError(1,trt(conn,"E_mail_already_exists_in_the_database",user));
|
||||
xmlstring=sendError(10000,trt(conn,"E_mail_already_exists_in_the_database",user),null);
|
||||
error=true;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@ -1514,7 +1523,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage());
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1522,21 +1531,21 @@ public class DBMSRecords implements ServletContextAware {
|
||||
String newPass = getRandomString(8);
|
||||
sql_query = "select * from main.p__Users_1(4,${country_id},${surname},${name},${company},${position},${phone},${email},${password});";
|
||||
|
||||
val = getSQLValue("i4", country_id);
|
||||
val = DBTools.getSQLValue("i4", country_id);
|
||||
sql_query = Tools.replaceAll(sql_query,"${country_id}", val);
|
||||
val = getSQLValue("string", lastname);
|
||||
val = DBTools.getSQLValue("string", lastname);
|
||||
sql_query = Tools.replaceAll(sql_query,"${surname}", val);
|
||||
val = getSQLValue("string", firstname);
|
||||
val = DBTools.getSQLValue("string", firstname);
|
||||
sql_query = Tools.replaceAll(sql_query,"${name}", val);
|
||||
val = getSQLValue("string", company);
|
||||
val = DBTools.getSQLValue("string", company);
|
||||
sql_query = Tools.replaceAll(sql_query,"${company}", val);
|
||||
val = getSQLValue("string", position);
|
||||
val = DBTools.getSQLValue("string", position);
|
||||
sql_query = Tools.replaceAll(sql_query,"${position}", val);
|
||||
val = getSQLValue("string", phone);
|
||||
val = DBTools.getSQLValue("string", phone);
|
||||
sql_query = Tools.replaceAll(sql_query,"${phone}", val);
|
||||
val = getSQLValue("string", email);
|
||||
val = DBTools.getSQLValue("string", email);
|
||||
sql_query = Tools.replaceAll(sql_query,"${email}", val);
|
||||
val = getSQLValue("string", newPass);
|
||||
val = DBTools.getSQLValue("string", newPass);
|
||||
sql_query = Tools.replaceAll(sql_query,"${password}", val);
|
||||
|
||||
//logger.info("sql_query = " + sql_query);
|
||||
@ -1580,7 +1589,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//xmlstring = "<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
xmlstring=sendError(1,"Error: " + ex.getMessage());
|
||||
xmlstring=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -1590,7 +1599,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
|
||||
} else if (fn != null && fn.equals("8")) {
|
||||
//Select information about the current user
|
||||
//Select information about the current user for generated report
|
||||
String uName = "<br>";
|
||||
|
||||
try {
|
||||
@ -1611,8 +1620,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
stt=null;
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1707,7 +1715,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
String vt = nextnode.getAttributes().getNamedItem("vt").getNodeValue();
|
||||
String val = getCharacterDataFromElement((Element) nextnode);
|
||||
|
||||
val = getSQLValue(vt, val);
|
||||
val = DBTools.getSQLValue(vt, val);
|
||||
|
||||
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", val);
|
||||
} catch (Exception ex) {
|
||||
@ -1759,7 +1767,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
expr = xpath.compile("objects-list/@d");
|
||||
|
||||
writer.write(" <table border=\"1\" cellspacing=\"0\">\n");
|
||||
writer.write(" <caption><b>" + getText(conn,"" + expr.evaluate(nTypeS, XPathConstants.STRING),user) + "</b></caption>\n");
|
||||
writer.write(" <caption><b>" + trts(conn,"" + expr.evaluate(nTypeS, XPathConstants.STRING),user) + "</b></caption>\n");
|
||||
writer.write(" <thead>\n");
|
||||
writer.write(" <tr>");
|
||||
|
||||
@ -1767,7 +1775,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
Object exprResult = expr.evaluate(nTypeS, XPathConstants.NODESET);
|
||||
nodeList = (NodeList) exprResult;
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
writer.write("<td bgcolor=\"#d1d1d1\" width=\"" + nodeList.item(i).getAttributes().getNamedItem("width").getNodeValue() + "px\"><b>" + getText(conn,nodeList.item(i).getAttributes().getNamedItem("d").getNodeValue(),user)
|
||||
writer.write("<td style=\"background-color:#d1d1d1;\" width=\"" + nodeList.item(i).getAttributes().getNamedItem("width").getNodeValue() + "px\"><b>" + trts(conn,nodeList.item(i).getAttributes().getNamedItem("d").getNodeValue(),user)
|
||||
+ "</b></td>");
|
||||
}
|
||||
writer.write(" </tr>\n");
|
||||
@ -1793,8 +1801,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage());
|
||||
result=sendError(10000,"Error: " + ex.getMessage(),null);
|
||||
error=true;
|
||||
} finally {
|
||||
try {
|
||||
@ -1802,8 +1809,9 @@ public class DBMSRecords implements ServletContextAware {
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
//Отправляем название файла на сервер
|
||||
//Отправляем название файла клиенту
|
||||
result="<metadata fn=\"8\"><file><![CDATA[" + tmpName + "]]></file></metadata>";
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
||||
}
|
||||
rs.close();
|
||||
stt.close();
|
||||
@ -1811,8 +1819,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
stt=null;
|
||||
} catch (SQLException ex) {
|
||||
logger.info(ex.getMessage());
|
||||
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
||||
result=sendError(1,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query);
|
||||
result=sendError(10000,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query,null);
|
||||
error=true;
|
||||
}
|
||||
}
|
||||
@ -1909,7 +1916,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
*/
|
||||
|
||||
} else {
|
||||
result=sendError(1,"Unknown function \"" + fn + "\" !");
|
||||
result=sendError(10000,"Unknown function \"" + fn + "\" !",null);
|
||||
error=true;
|
||||
}
|
||||
|
||||
@ -1918,11 +1925,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Example request: http://localhost:8080/CCALM/download?t=FrmLocust&f=image_name1&i=1298
|
||||
*/
|
||||
@ -1931,63 +1933,17 @@ public class DBMSRecords implements ServletContextAware {
|
||||
public FileSystemResource home(HttpServletResponse response,@ModelAttribute User user,@RequestParam(required=false,name="t") String typename,@RequestParam(required=false,name="f") String field,@RequestParam(required=false,name="i") String id) {
|
||||
|
||||
String metadata_file = "";
|
||||
/*String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
//String data_dir = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("db-url"))
|
||||
db_url = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-login"))
|
||||
db_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-password"))
|
||||
db_password = nl.item(i).getTextContent();
|
||||
|
||||
if (nl.item(i).getNodeName().equals("metadata"))
|
||||
metadata_file = nl.item(i).getTextContent();
|
||||
|
||||
//if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
// data_dir = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}*/
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
try {
|
||||
prop.load(new FileInputStream("monitoring.properties")); // load a properties file
|
||||
//Читаю настройки базы
|
||||
db_url = prop.getProperty("db.url");
|
||||
System.out.println("db.url = " + db_url);
|
||||
//dbSchema = prop.getProperty("db.schema");
|
||||
//System.out.println("db.schema = " + dbSchema);
|
||||
db_login = prop.getProperty("db.login");
|
||||
System.out.println("db.login = " + db_login);
|
||||
db_password = prop.getProperty("db.password");
|
||||
//System.out.println("db.password = " + db_password);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
/*if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
db_url = env.getProperty("spring.datasource.url");
|
||||
db_login = env.getProperty("spring.datasource.username");
|
||||
db_password = env.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
|
||||
@ -1996,7 +1952,9 @@ public class DBMSRecords implements ServletContextAware {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
conn = DriverManager.getConnection(db_url, db_login, db_password);
|
||||
if (conn != null) {
|
||||
logger.info("Connect is OK!");
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Marker marker = MarkerManager.getMarker(uuid);
|
||||
logger.info(marker,"Connect is OK!");
|
||||
} else {
|
||||
logger.info("An error occurred while connecting to the database!");
|
||||
}
|
||||
@ -2095,29 +2053,18 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/upload", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public String uploadFile(HttpServletResponse response,@RequestParam(required=false,name="file") MultipartFile file) {
|
||||
|
||||
String result="";
|
||||
String data_dir="";
|
||||
|
||||
String data_dir = "";
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
data_dir = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
data_dir = env.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
|
||||
@ -2188,25 +2135,14 @@ public class DBMSRecords implements ServletContextAware {
|
||||
@RequestMapping(value = "/reports",method = RequestMethod.GET, produces = "application/octet-stream")
|
||||
@ResponseBody
|
||||
public FileSystemResource sendReport(HttpServletResponse response,@RequestParam(required=true,name="file") String fileName) {
|
||||
|
||||
String data_dir = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
data_dir = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
data_dir = env.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
|
||||
File file = new File(data_dir + "temp" + File.separator + fileName);
|
||||
if(file.exists())
|
||||
@ -2224,43 +2160,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
String getSQLValue(String t, String v) {
|
||||
//if($t=='object' && (strtoupper($v)!='NULL' && gettype($v)=='string')) $t='string'; //Если id шники uuid
|
||||
|
||||
if (t.equals("object") || t.equals("uid")) {
|
||||
if (v.equals(""))
|
||||
v = "NULL";
|
||||
} else if (t.equals("i4") || t.equals("integer")) {
|
||||
if (v.equals(""))
|
||||
v = "NULL";
|
||||
} else if (t.equals("f8")) {
|
||||
if (v.equals(""))
|
||||
v = "NULL";
|
||||
v = Tools.replaceAll(v,",", "."); //The decimal part: point.
|
||||
} else if (t.equals("f4")) {
|
||||
if (v.equals(""))
|
||||
v = "NULL";
|
||||
v = Tools.replaceAll(v,",", "."); //The decimal part: point.
|
||||
} else if (t.equals("b")) {
|
||||
if (v.equals(""))
|
||||
v = "NULL";
|
||||
else if (v.equals("1"))
|
||||
v = "true";
|
||||
else if (v.equals("0"))
|
||||
v = "false";
|
||||
} else if (t.equals("string") || t.equals("text") || t.equals("dateTime") || t.equals("date")) {
|
||||
if (v.equals("")) {
|
||||
v = "NULL";
|
||||
} else {
|
||||
v = Tools.replaceAll(v,"'", "''");
|
||||
v = "'" + v + "'";
|
||||
}
|
||||
} else {
|
||||
v = "'" + v + "'";
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
private String nodeToString(Node node) {
|
||||
StringWriter sw = new StringWriter();
|
||||
try {
|
||||
@ -2369,7 +2268,7 @@ public class DBMSRecords implements ServletContextAware {
|
||||
}
|
||||
|
||||
//Translate text by patterns
|
||||
public String getText(Connection conn,String text,User user) {
|
||||
public String trts(Connection conn,String text,User user) {
|
||||
int pos1 = 0;
|
||||
while (true) {
|
||||
pos1 = text.indexOf("trt('", pos1);
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
package kz.goodssales.GoodsSales.dbms;
|
||||
package dbms;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
//import javax.servlet.ServletContext;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
@ -18,6 +20,7 @@ import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@ -37,22 +40,17 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import tctable.Tools;
|
||||
import tools.User;
|
||||
import tools.DBTools;
|
||||
import tools.XMLTools;
|
||||
import tools.User;
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes( { "user" }) //Сесионный объект!
|
||||
public class DBMSTree implements ServletContextAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(kz.goodssales.GoodsSales.dbms.DBMSTree.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DBMSTree.class);
|
||||
private ServletContext context;
|
||||
|
||||
//If not created object "user", create him.
|
||||
@ModelAttribute("user")
|
||||
public User populatePerson() {
|
||||
return new User("none");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tree",method = RequestMethod.POST,produces = "application/xml; charset=utf-8")
|
||||
@ResponseBody
|
||||
public Object ajaxTamer(@ModelAttribute User user,@RequestBody byte[] reqData,@RequestParam(required=false,name="lng") String language_id) {
|
||||
@ -66,30 +64,18 @@ public class DBMSTree implements ServletContextAware {
|
||||
String result="<metadata fn=\"-1\"><![CDATA[Request not processed!]]></metadata>";
|
||||
|
||||
String jspPath = context.getRealPath("/");
|
||||
String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("db-url"))
|
||||
db_url = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-login"))
|
||||
db_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-password"))
|
||||
db_password = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
@ -198,7 +184,7 @@ public class DBMSTree implements ServletContextAware {
|
||||
{
|
||||
String vt = nF.getAttributes().getNamedItem("vt").getNodeValue();
|
||||
String val= XMLTools.getCDATAValue(nF);
|
||||
sql = sql.replace("${" + nF.getAttributes().getNamedItem("n").getNodeValue() + "}", Tools.getSQLValue(vt, val));
|
||||
sql = sql.replace("${" + nF.getAttributes().getNamedItem("n").getNodeValue() + "}", DBTools.getSQLValue(vt, val));
|
||||
}
|
||||
nF=nF.getNextSibling();
|
||||
}
|
||||
@ -228,9 +214,9 @@ public class DBMSTree implements ServletContextAware {
|
||||
String iid="";
|
||||
String val="";
|
||||
|
||||
if(Tools.hasColumn(rs,"id")) fid=rs.getString("id"); else fid=""; //Уникальный id записи
|
||||
if(Tools.hasColumn(rs,"icon_id")) iid=rs.getString("icon_id"); else iid=""; //id значка
|
||||
if(Tools.hasColumn(rs,caption)) val=rs.getString(caption); else val=""; //Заголовок
|
||||
if(DBTools.hasColumn(rs,"id")) fid=rs.getString("id"); else fid=""; //Уникальный id записи
|
||||
if(DBTools.hasColumn(rs,"icon_id")) iid=rs.getString("icon_id"); else iid=""; //id значка
|
||||
if(DBTools.hasColumn(rs,caption)) val=rs.getString(caption); else val=""; //Заголовок
|
||||
|
||||
String visible = "";
|
||||
if(tmpNode.getAttributes().getNamedItem("visible").getNodeValue().equals("0")) visible=" visible=\"0\" ";
|
||||
@ -258,7 +244,7 @@ public class DBMSTree implements ServletContextAware {
|
||||
String fval="";
|
||||
try
|
||||
{
|
||||
if(Tools.hasColumn(rs,fname))
|
||||
if(DBTools.hasColumn(rs,fname))
|
||||
{
|
||||
fval=rs.getString(fname);
|
||||
}else
|
||||
@ -442,17 +428,16 @@ public class DBMSTree implements ServletContextAware {
|
||||
{
|
||||
if(nF.getNodeName().equals("column"))
|
||||
{
|
||||
sql = sql.replace("{"+nF.getAttributes().getNamedItem("n").getNodeValue()+"}", Tools.getSQLValue(nF.getAttributes().getNamedItem("vt").getNodeValue(),XMLTools.getCDATAValue(nF)));
|
||||
sql = sql.replace("{"+nF.getAttributes().getNamedItem("n").getNodeValue()+"}", DBTools.getSQLValue(nF.getAttributes().getNamedItem("vt").getNodeValue(),XMLTools.getCDATAValue(nF)));
|
||||
}
|
||||
nF=nF.getNextSibling();
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
if(!isset($_SESSION['USER_ID'])) { $_SESSION['USER_ID']=null; }
|
||||
if(!isset($_COOKIE['GUID'])) { $_COOKIE['GUID']=null; }
|
||||
|
||||
//include("../include/xmltools.php");
|
||||
//include("../include/xmltools.xyz");
|
||||
//include("../include/toExcell.php");
|
||||
//require_once("config.xyz");
|
||||
|
||||
@ -272,7 +272,7 @@
|
||||
$allow_ins=false;
|
||||
$allow_upd=false;
|
||||
$allow_del=false;
|
||||
$sql_query='select '.$Schema.'p_getaccess(:user_id1,:action_insert) as ins,'.$Schema.'p_getaccess(:user_id2,:action_update) as upd,'.$Schema.'p_getaccess(:user_id3,:action_delete) as del;';
|
||||
$sql_query='select '.$Schema.'get_access(:user_id1,:action_insert) as ins,'.$Schema.'get_access(:user_id2,:action_update) as upd,'.$Schema.'get_access(:user_id3,:action_delete) as del;';
|
||||
$stmt = $db->prepare($sql_query);
|
||||
$stmt->bindValue(':user_id1', $_SESSION['USER_ID'], PDO::PARAM_INT); //getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID'])
|
||||
$stmt->bindValue(':user_id2', $_SESSION['USER_ID'], PDO::PARAM_INT); //getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID'])
|
||||
@ -1038,7 +1038,7 @@
|
||||
echo $xs;
|
||||
exit();
|
||||
|
||||
}elseif ($cmd==3) //Авторизация по логину и паролю
|
||||
}elseif ($cmd==3) //Авторизация по логину и паролю (везде где используется JWT этот код не нужен)
|
||||
{
|
||||
//По идентификатору выбираем информацию о пользователе
|
||||
$ans='0';
|
||||
@ -1247,12 +1247,12 @@
|
||||
fwrite($fh, ' <caption><b>'.findNode($currNode,'objects-list')->getAttribute("d").'</b></caption>'."\n");
|
||||
fwrite($fh, ' <thead>'."\n");
|
||||
fwrite($fh, ' <tr>');
|
||||
fwrite($fh, '<td bgcolor="#d1d1d1">№</td>');
|
||||
fwrite($fh, '<td style="background-color:#d1d1d1;">№</td>');
|
||||
$nextnode=findNode($currNode,'objects-list')->firstChild;
|
||||
$col=0;
|
||||
while ($nextnode)
|
||||
{ if ($nextnode->nodeName=='column')
|
||||
{ fwrite($fh, '<td bgcolor="#d1d1d1" width="'.$nextnode->getAttribute("width").'px"><b>'.$nextnode->getAttribute("d")."</b></td>");
|
||||
{ fwrite($fh, '<td style="background-color:#d1d1d1;" width="'.$nextnode->getAttribute("width").'px"><b>'.$nextnode->getAttribute("d")."</b></td>");
|
||||
}
|
||||
$nextnode = $nextnode->nextSibling;
|
||||
}
|
||||
@ -1343,7 +1343,7 @@
|
||||
print ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
|
||||
print ' </head>';
|
||||
print ' <body>';
|
||||
print ' <form name="form" enctype="multipart/form-data" action="records.php?fn=9" method="post">';
|
||||
print ' <form name="form" enctype="multipart/form-data" action="/api/dbms/v09/upload" method="post">';
|
||||
print ' <input type="hidden" name="state" value=""/>';
|
||||
print ' <input type="file" name="file"><br/>';
|
||||
print ' <input type="submit" value="Send File">';
|
||||
|
||||
@ -36,8 +36,6 @@ class EdtRec
|
||||
this.pBarCnt=0; //Progress Bar
|
||||
this.pBarDiv=null; //Progress Bar
|
||||
|
||||
this.request = new TRequest(this);
|
||||
|
||||
//this.fields = new Array();
|
||||
|
||||
ERec_mas[this.uid]=this;
|
||||
@ -82,10 +80,24 @@ class EdtRec
|
||||
this.f_TypeName=typeName;
|
||||
this.f_Settings=settings;
|
||||
this.record_id=id;
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+typeName+'"></type></metadata>'))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+typeName+'"></type></metadata>',
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.eRecNo(data,this.record_id);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
};
|
||||
|
||||
//Задать CDATA значение для узла "type->properties->prop" по "n"
|
||||
@ -140,17 +152,17 @@ class EdtRec
|
||||
//Записываю record_id в соответствующее XML поле
|
||||
this.setPropCdata(nodeType.getAttribute("ObjectID"),record_id);
|
||||
|
||||
let str='';
|
||||
str+=' <table class="SEdit" id="eTable'+this.uid+'" border="0px" cellspacing="1" cellpadding="1" style="width: 100%; height: 100%;">';
|
||||
str+=' <caption><b id="caption'+this.uid+'"></b></caption>';
|
||||
str+=' <thead>';
|
||||
str+=' <tr bgcolor="#dadada">';
|
||||
str+=' <th style="width:20%">'+trt('Name')+'</th>';
|
||||
str+=' <th style="width:80%">'+trt('Value')+'</th>';
|
||||
str+=' </tr>';
|
||||
str+=' </thead>';
|
||||
str+=' <tbody></tbody>';
|
||||
str+=' </table>';
|
||||
let str=`
|
||||
<table class="SEdit" id="eTable`+this.uid+`" border="0px" cellspacing="1" cellpadding="1" style="width: 100%; height: 100%;">
|
||||
<caption><b id="caption`+this.uid+`"></b></caption>
|
||||
<thead>
|
||||
<tr style="background-color:#dadada;">
|
||||
<th style="width:20%">`+trt('Name')+`</th>
|
||||
<th style="width:80%">`+trt('Value')+`</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>`;
|
||||
document.getElementById('eDiv'+this.uid).innerHTML=str;
|
||||
//this.win.setContent(str);
|
||||
|
||||
@ -236,14 +248,9 @@ class EdtRec
|
||||
}
|
||||
nP=nP.nextSibling;
|
||||
}
|
||||
subSRec.f_Settings=nodeProp;
|
||||
|
||||
subSRec.f_State='0';
|
||||
if(subSRec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+nodeProp.getAttribute("n")+'"></type></metadata>'))
|
||||
{
|
||||
//obj.showProgressBar();
|
||||
}
|
||||
|
||||
subSRec.callData(nodeProp.getAttribute("n"),nodeProp);
|
||||
|
||||
}else
|
||||
if (nodeProp.nodeName=="divide") //Grouping fields.
|
||||
{
|
||||
@ -673,7 +680,7 @@ class EdtRec
|
||||
}else
|
||||
if(vt==="blob" || vt==="file")
|
||||
{
|
||||
let ifr=createIFrame("prop_"+this.uid+"_"+nodeProp.getAttribute("n")+'_frm', ScriptUName+"?fn=9", td2, false); //IFrame to send the file to the server.
|
||||
let ifr=createIFrame("prop_"+this.uid+"_"+nodeProp.getAttribute("n")+'_frm', ScriptUName, td2, false); //IFrame to send the file to the server.
|
||||
document.body.appendChild(ifr);
|
||||
|
||||
let tbl_b=document.createElement('table');
|
||||
@ -865,10 +872,21 @@ class EdtRec
|
||||
this.fillGUIFromXML();
|
||||
}else
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="5"><type id="'+this.record_id+'" n="'+type_name+'" ObjectID="'+nodeType.getAttribute("ObjectID")+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="5"><type id="'+this.record_id+'" n="'+type_name+'" ObjectID="'+nodeType.getAttribute("ObjectID")+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setData(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
};
|
||||
|
||||
@ -914,11 +932,26 @@ class EdtRec
|
||||
let option=document.getElementById("prop_"+this.uid+"_"+node.getAttribute("n"));
|
||||
setCdataValue(node,0,option.value);
|
||||
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
|
||||
//if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
@ -935,7 +968,7 @@ class EdtRec
|
||||
let win=new TWin();
|
||||
win.BuildGUI(pageX-10,pageY-10);
|
||||
let str=`
|
||||
<table id="thetable`+win+`" bgcolor="SlateGrey" style="border: 1px solid rgb(99, 99, 99);" width="100%">
|
||||
<table id="thetable`+win+`" style="background-color:SlateGrey;border: 1px solid rgb(99, 99, 99);" width="100%">
|
||||
<caption></caption>
|
||||
<thead><tr><th></th></tr></thead>
|
||||
<tbody><tr><td></td></tr></tbody>
|
||||
@ -988,14 +1021,9 @@ class EdtRec
|
||||
rec.create(null);
|
||||
rec.f_State=1;
|
||||
rec.f_PropName=nodeProp.getAttribute("n");
|
||||
rec.f_Settings=settings;
|
||||
rec.f_TypeName=TypeName;
|
||||
rec.win.setLeftTop(pageX-250,pageY-10);
|
||||
rec.win.setParent(this.win);
|
||||
if(rec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+TypeName+'"></type></metadata>'))
|
||||
{
|
||||
rec.showProgressBar();
|
||||
}
|
||||
rec.callData(TypeName,settings)
|
||||
};
|
||||
|
||||
//Запросить данные для выпадающих списков и других объектов (только после загрузки данных полей)
|
||||
@ -1029,18 +1057,46 @@ class EdtRec
|
||||
}
|
||||
nColF = nColF.nextSibling;
|
||||
}
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}else
|
||||
{
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'"></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
}else
|
||||
{
|
||||
@ -1168,7 +1224,7 @@ class EdtRec
|
||||
}else
|
||||
if(count>1) //Display the item selection window.
|
||||
{
|
||||
let htmlString='<table width="100%" bgcolor="whitesmoke">';
|
||||
let htmlString='<table width="100%" style="background-color:whitesmoke;">';
|
||||
nodeProp=nodeType.firstChild;
|
||||
let i=0;
|
||||
while (nodeProp!=null)
|
||||
@ -1182,7 +1238,7 @@ class EdtRec
|
||||
value=value.replace(/"/g, """);
|
||||
value=value.replace(/'/g, "\\'");
|
||||
value=value.replace(/\n/g, " ");
|
||||
htmlString+='<tr><td bgColor="'+bgColor+'" onClick="setPropVal('+this.uid+',\''+id+'\',\''+value+'\',\''+prop_name+'\');" style="cursor: pointer;">'+findFirstNode(nodeProp, '#cdata-section').nodeValue+'</td></tr>'+"\n";
|
||||
htmlString+='<tr><td onClick="setPropVal('+this.uid+',\''+id+'\',\''+value+'\',\''+prop_name+'\');" style="background-color:"'+bgColor+'";cursor: pointer;">'+findFirstNode(nodeProp, '#cdata-section').nodeValue+'</td></tr>'+"\n";
|
||||
i++;
|
||||
}
|
||||
nodeProp=nodeProp.nextSibling;
|
||||
@ -1199,39 +1255,6 @@ class EdtRec
|
||||
}
|
||||
};
|
||||
|
||||
applyReq(req,fn,node,xmldoc,win)
|
||||
{
|
||||
this.hideProgressBar();
|
||||
|
||||
if(node.error_code>0) {
|
||||
alert2(trt('Alert'), node.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fn==0) {
|
||||
this.eRecNo(node,this.record_id);
|
||||
} else
|
||||
if (fn==1) { //returned id
|
||||
this.insertRows(node);
|
||||
} else
|
||||
if (fn==2) { //Returned id and type of updated record
|
||||
this.updateRows(node);
|
||||
} else
|
||||
if (fn==3) { //Returned id of deleted record
|
||||
this.deleteRows(node);
|
||||
} else
|
||||
if (fn==5) {
|
||||
this.setData(node);
|
||||
} else
|
||||
if (fn==6) { //Fill in the drop-down lists.
|
||||
this.setDataSelect(node);
|
||||
} else
|
||||
if (fn==7) {
|
||||
this.setData(node);
|
||||
} else {
|
||||
alert2(trt('Alert'),"Unknown function! fn=\""+fn+"\"" );
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Request data to fill in the field with the button
|
||||
*
|
||||
@ -1267,10 +1290,25 @@ class EdtRec
|
||||
'</type></metadata>';
|
||||
}
|
||||
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),'Field "'+prop_id+'" not find!');
|
||||
@ -1291,10 +1329,25 @@ class EdtRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+typeName+'" c="'+name+'" pn="'+htmlid+'"><objects-list><filter>';
|
||||
xml+='<column n="'+filterName+'"><![CDATA['+value+']]></column>';
|
||||
xml+='</filter></objects-list></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1377,10 +1430,25 @@ class EdtRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+nodeProp.getAttribute("ot")+'" c="'+nodeProp.getAttribute("FieldCaption")+'" pn="'+nodeProp.getAttribute("n")+'" fn="'+nodeProp.getAttribute("fn")+'" id="'+value+'">';
|
||||
xml+='<objects-list><filter><column n="'+findFirstNode(this.nodeMetadata, 'type').getAttribute('ObjectID')+'"><![CDATA['+value+']]></column></filter></objects-list>';
|
||||
xml+='</type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,xml,(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
//if(this.request.callServer(ScriptName,xml,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1459,11 +1527,41 @@ class EdtRec
|
||||
s+=' </properties>\n';
|
||||
s+='</type>\n';
|
||||
s+='</metadata>';
|
||||
//alert2(trt('Alert'),s);
|
||||
if(this.request.callServer(ScriptName,s,true))
|
||||
{
|
||||
|
||||
if (this.record_id!=-1) {
|
||||
postXMLData(ScriptName, s, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.updateRows(data);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}else{
|
||||
postXMLData(ScriptName, s, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.insertRows(data);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
//if(this.request.callServer(ScriptName,s,true))
|
||||
//{
|
||||
// this.showProgressBar();
|
||||
//}
|
||||
};
|
||||
//Check the field according to its type
|
||||
checkData(value,type,maybenull)
|
||||
|
||||
@ -223,27 +223,25 @@ class DBMSUser
|
||||
//Функция запрашивает информацию о текущем пользователе с сервера
|
||||
LoadData()
|
||||
{
|
||||
var r = new TRequest(this);
|
||||
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
|
||||
let r = new TRequest(this);
|
||||
let xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
|
||||
if(r.callServer(ScriptName,xs))
|
||||
{
|
||||
this.showShadow(true);
|
||||
}
|
||||
};
|
||||
//Check whether the already authorized (+ attempt to log in through "hash").
|
||||
isLogined()
|
||||
/*isLogined()
|
||||
{
|
||||
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
|
||||
var request=new TRequest(this);
|
||||
let xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
|
||||
let request=new TRequest(this);
|
||||
if(request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.showShadow(true);
|
||||
|
||||
alert(ScriptName+" = "+xs);
|
||||
|
||||
//m_winPP.showProgressBar();
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
addListener(l)
|
||||
{ if(l.OnLogin==null) alert('Object does not have the function "OnLogin()"!');
|
||||
|
||||
@ -1,26 +1,31 @@
|
||||
<?php
|
||||
use lfkeitel\phptotp\{Base32,Totp};
|
||||
use lfkeitel\phptotp\{Base32,Totp};
|
||||
|
||||
//ini_set('display_errors','Off'); //Чтоб ошибки не отправлялись клиентам
|
||||
//ini_set("error_log", "php_error.log"); //Чтоб ошибки сохранялись в локальную папку
|
||||
//ini_set('display_errors','Off'); //Чтоб ошибки не отправлялись клиентам
|
||||
//ini_set("error_log", "php_error.log"); //Чтоб ошибки сохранялись в локальную папку
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$host = '.'.cutAfterLast($host,'.',2);
|
||||
ini_set('session.cookie_domain', $host);
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$host = '.'.cutAfterLast($host,'.',2);
|
||||
ini_set('session.cookie_domain', $host);
|
||||
|
||||
//if(isset($_GET[session_name()]) && $_GET[session_name()]!='') //Чтоб сессия переданная гетом была главней
|
||||
// session_id($_GET[session_name()]);
|
||||
//Сессию не убирать! (Если что нужно без сессии то этот файл следует разбить на части!)
|
||||
//@session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
|
||||
startSession(true); //Для ручного определения времени жизни сесии
|
||||
|
||||
startSession(true); //Для ручного определения времени жизни сесии
|
||||
$language_id=1;
|
||||
if(filter_has_var(INPUT_COOKIE, 'lng'))
|
||||
{
|
||||
$language_id=filter_input(INPUT_COOKIE, 'lng', FILTER_VALIDATE_INT);
|
||||
if($_COOKIE["lng"]=='ru') $language_id=1;
|
||||
if($_COOKIE["lng"]=='kz' || $_COOKIE["lng"]=='kk') $language_id=2;
|
||||
if($_COOKIE["lng"]=='en') $language_id=3;
|
||||
if($_COOKIE["lng"]=='uz') $language_id=4;
|
||||
}
|
||||
|
||||
if(isset($_SESSION['REMOTE_ADDR']) && $_SESSION['REMOTE_ADDR'] != $_SERVER['REMOTE_ADDR']) unset($_SESSION['USER_ID']); //Делаемся не авторизованным если зашли с другого ip адреса
|
||||
if(!isset($_SESSION['USER_ID'])) { $_SESSION['USER_ID']=null; }
|
||||
if(!isset($_COOKIE['GUID'])) { $_COOKIE['GUID']=null; }
|
||||
|
||||
//include("../include/xmltools.php");
|
||||
//include("../include/toExcell.php");
|
||||
//require_once("config.xyz");
|
||||
|
||||
function getCurrentDirectory() {
|
||||
$path = dirname($_SERVER['PHP_SELF']);
|
||||
$position = strrpos($path,'/') + 1;
|
||||
@ -223,7 +228,8 @@
|
||||
}
|
||||
}*/
|
||||
|
||||
$fn=filter_input(INPUT_GET, 'fn', FILTER_VALIDATE_INT, array('options'=>array('default'=>-1)));
|
||||
if(!isset($fn))
|
||||
$fn=filter_input(INPUT_GET, 'fn', FILTER_VALIDATE_INT, array('options'=>array('default'=>-1)));
|
||||
|
||||
$HTTP_INPUT=file_get_contents("php://input");
|
||||
if($HTTP_INPUT)
|
||||
@ -240,7 +246,7 @@
|
||||
|
||||
if ($reqNode)
|
||||
{
|
||||
$fn = $reqNode->getAttribute("fn"); //Номер функции
|
||||
$fn = $reqNode->getAttribute("fn"); //Номер функции из XML
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +278,7 @@
|
||||
$allow_ins=false;
|
||||
$allow_upd=false;
|
||||
$allow_del=false;
|
||||
$sql_query='select '.$Schema.'p_getaccess(:user_id1,:action_insert) as ins,'.$Schema.'p_getaccess(:user_id2,:action_update) as upd,'.$Schema.'p_getaccess(:user_id3,:action_delete) as del;';
|
||||
$sql_query='select '.$Schema.'get_access(:user_id1,:action_insert) as ins,'.$Schema.'get_access(:user_id2,:action_update) as upd,'.$Schema.'get_access(:user_id3,:action_delete) as del;';
|
||||
$stmt = $db->prepare($sql_query);
|
||||
$stmt->bindValue(':user_id1', $_SESSION['USER_ID'], PDO::PARAM_INT); //getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID'])
|
||||
$stmt->bindValue(':user_id2', $_SESSION['USER_ID'], PDO::PARAM_INT); //getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID'])
|
||||
@ -924,7 +930,7 @@
|
||||
header('Content-type: text/xml');
|
||||
echo $xmlstring;
|
||||
}else
|
||||
if ($fn==7)//Залогинеться
|
||||
if ($fn==7)//Залогинеться (TODO логин происходит через JWT в другом коде на java)
|
||||
{
|
||||
$cmd=getCdataValue(findFirstNode($reqNode,"cmd"));
|
||||
$login=getCdataValue(findFirstNode($reqNode,"login"));
|
||||
@ -1028,7 +1034,7 @@
|
||||
$xs.=' <patronymic><![CDATA['.$row['patronymic'].']]></patronymic>'."\n";
|
||||
$xs.=' <company_id><![CDATA['.$row['company_id'].']]></company_id>'."\n";
|
||||
$xs.=' <expiration><![CDATA['.$row['expiration'].']]></expiration>'."\n";
|
||||
$xs.=' <overdue><![CDATA['.$row['overdue'].']]></overdue>'."\n";
|
||||
//$xs.=' <overdue><![CDATA['.$row['overdue'].']]></overdue>'."\n";
|
||||
}
|
||||
}
|
||||
$xs.='</metadata>';
|
||||
@ -1252,7 +1258,7 @@
|
||||
$col=0;
|
||||
while ($nextnode)
|
||||
{ if ($nextnode->nodeName=='column')
|
||||
{ fwrite($fh, '<td bgcolor="#d1d1d1" width="'.$nextnode->getAttribute("width").'px"><b>'.$nextnode->getAttribute("d")."</b></td>");
|
||||
{ fwrite($fh, '<td style="background-color:#d1d1d1;" width="'.$nextnode->getAttribute("width").'px"><b>'.$nextnode->getAttribute("d")."</b></td>");
|
||||
}
|
||||
$nextnode = $nextnode->nextSibling;
|
||||
}
|
||||
@ -1343,7 +1349,7 @@
|
||||
print ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
|
||||
print ' </head>';
|
||||
print ' <body>';
|
||||
print ' <form name="form" enctype="multipart/form-data" action="records.php?fn=9" method="post">';
|
||||
print ' <form name="form" enctype="multipart/form-data" action="/api/dbms/v09/upload" method="post">';
|
||||
print ' <input type="hidden" name="state" value=""/>';
|
||||
print ' <input type="file" name="file"><br/>';
|
||||
print ' <input type="submit" value="Send File">';
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
//http://leopard.in.ua/2008/09/20/otslezhivanie-istecheniya-sroka-dejstviya-sessij/
|
||||
//session_save_path('C:\ses');
|
||||
|
||||
require_once("../include/tools.php");
|
||||
require_once("../include/tools.xyz");
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$host = '.'.cutAfterLast($host,'.',2);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
//var ScriptName='../records'; //POST
|
||||
//var ScriptName='../api/dbms/v09/records.xyz'; //POST
|
||||
//var ScriptDName='../download';
|
||||
//var ScriptUName='../upload';
|
||||
//var ScriptRName='../reports'; //GET For download reports (?file=name)
|
||||
|
||||
@ -31,7 +31,6 @@ class SRec
|
||||
this.masCL=new Array();//node table column
|
||||
this.masVis=new Array(); //Whether to display a column
|
||||
this.masChBox=new Array(); //Checkboxes
|
||||
this.xmldoc=null; //accepted XML document (for CDATA creation)
|
||||
this.pagepos=0; //current data page
|
||||
|
||||
this.pBarCnt=0; //Progress bar
|
||||
@ -40,57 +39,12 @@ class SRec
|
||||
this.name="";
|
||||
|
||||
this.uid=getUID();
|
||||
this.request = new TRequest(this);
|
||||
SRec_mas[this.uid]=this;
|
||||
|
||||
this.onUpdate=null; //For call set function
|
||||
this.onInsert=null; //For call set function
|
||||
}
|
||||
|
||||
applyReq(req,fn,node,xmldoc)
|
||||
{
|
||||
this.hideProgressBar();
|
||||
|
||||
if(node.error_code>0) {
|
||||
alert2(trt('Alert'), node.error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
this.xmldoc=node.ownerDocument; //xmldoc;
|
||||
|
||||
if (fn==0)
|
||||
{
|
||||
//alert2(trt('Alert'),getXMLNodeSerialisation(node));
|
||||
this.setMetadata(node);
|
||||
this.updateSize();
|
||||
}else
|
||||
if (fn==11) //Update record after editing, 1 entry has come.
|
||||
{
|
||||
this.updateRows(node);
|
||||
}else
|
||||
if (fn==3) //Information which record or records were deleted.
|
||||
{
|
||||
this.ApplyDelRec(node);
|
||||
}else
|
||||
if (fn==4) //Data after the selection of records, replacement of existing ones.
|
||||
{
|
||||
this.insertRows(node,true);
|
||||
}else
|
||||
if (fn==6) //Fill in the drop-down lists.
|
||||
{
|
||||
this.setDataSelect(node);
|
||||
}else
|
||||
if (fn==8) //There was a link to the report.
|
||||
{
|
||||
if(this.rwin!=null)
|
||||
{
|
||||
this.rwin.hideProgressBar();
|
||||
this.rwin.setContent('<table border="0px" style="width: 100%; height: 100%; background-color: var(--back-color-1);"><tr><td align="center"><a href="'+ScriptRName+(ScriptRName.indexOf('?')!=-1 ? '&file=' : '?file=')+findFirstNode(node,'#cdata-section').nodeValue+'" target="_blank">'+trt('Download_report')+': "'+this.win.getCaption().innerHTML+'".</a></td></tr></table>');
|
||||
}
|
||||
}else
|
||||
alert2(trt('Alert'),"Unknown function! fn=\""+fn+"\"" );
|
||||
}
|
||||
|
||||
//Edit the GUI filter from the xml string.
|
||||
setGUISettings(xmlStr)
|
||||
{
|
||||
@ -166,7 +120,7 @@ class SRec
|
||||
<td><img src="../resources/metadata/dbms/images/refresh.png" alt="`+trt('Refresh')+`" id="SRec_Rfr_`+this.uid+`" title="`+trt('Update')+`" style="cursor: pointer;"/></td></tr>
|
||||
</table>
|
||||
</td></tr><tr><td id="tblContainer_`+this.uid+`" style="vertical-align:top; overflow:hidden; width:100%; height:100%; text-align:center;">
|
||||
<div id="tblSContainer_`+this.uid+`" style="position: absolute; overflow:scroll; width: 400px; height: 400px;">
|
||||
<div id="tblSContainer_`+this.uid+`" style="background-color: var(--back-color2); position: absolute; overflow:scroll; width: 400px; height: 400px;">
|
||||
<table id="thetable`+this.uid+`" class="SShow">
|
||||
<caption></caption>
|
||||
<thead><tr><th></th></tr></thead>
|
||||
@ -360,7 +314,8 @@ class SRec
|
||||
id=nodeProp.getAttribute("id");
|
||||
value=getCdataValue(nodeProp);
|
||||
value=value.replace(/"/g, """); value=value.replace(/'/g, "\\'");
|
||||
htmlString+='<tr><td bgColor="'+bgColor+'" onClick="setFilterVal('+this.uid+',\''+id+'\',\''+value+'\',\''+prop_id+'\')" style="cursor: pointer;">'+findFirstNode(nodeProp, '#cdata-section').nodeValue+' </td></tr>'+"\n";
|
||||
|
||||
htmlString+='<tr><td onClick="setFilterVal('+this.uid+',\''+id+'\',\''+value+'\',\''+prop_id+'\')" style="cursor:pointer;background-color:'+bgColor+';">'+findFirstNode(nodeProp, '#cdata-section').nodeValue+' </td></tr>'+"\n";
|
||||
i++;
|
||||
}
|
||||
nodeProp=nodeProp.nextSibling;
|
||||
@ -429,11 +384,7 @@ class SRec
|
||||
'<objects-list><filter><column n="id"><![CDATA[' + id + ']]></column></filter></objects-list>' +
|
||||
'</type></metadata>';
|
||||
}
|
||||
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(xml);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),'Filter "'+column_n+'" not find!');
|
||||
@ -511,12 +462,34 @@ class SRec
|
||||
xs+='</filter></objects-list></type>\n';
|
||||
xs+='</metadata>';
|
||||
|
||||
//alert2(trt('Alert'),xs);
|
||||
|
||||
if(this.request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.showProgressBar();
|
||||
if(id!=-1) {
|
||||
postXMLData(ScriptName, xs, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.updateRows(data);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
}else{
|
||||
postXMLData(ScriptName, xs, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == '0') {
|
||||
this.insertRows(data, true);
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
}
|
||||
} else {
|
||||
alert2(trt('Error'), data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
}
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
//Get metadata records and break them into global variables.
|
||||
@ -531,6 +504,7 @@ class SRec
|
||||
let tablefilter=document.getElementById('idfilter'+this.uid);
|
||||
if (tablefilter==null || tablefilter.tBodies==null) alert2(trt('Alert'),'tablefilter=null');
|
||||
let nodeType=findFirstNode(node, "type");
|
||||
if (nodeType==null) alert2(trt('Alert'),'Not_find_data');
|
||||
this.f_pI=nodeType.getAttribute("ins");//access rights
|
||||
this.f_pU=nodeType.getAttribute("upd");
|
||||
this.f_pD=nodeType.getAttribute("del");
|
||||
@ -889,17 +863,10 @@ class SRec
|
||||
nColF = nColF.nextSibling;
|
||||
}
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(strXMLF);
|
||||
}else
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+object+'" c="'+fc+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect('<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+object+'" c="'+fc+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"></type></metadata>');
|
||||
}
|
||||
}else
|
||||
{
|
||||
@ -944,10 +911,7 @@ class SRec
|
||||
if ((value!="")&&(value!=-1))
|
||||
{
|
||||
let xmlString='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+columnNode.getAttribute("object")+'" c="'+columnNode.getAttribute("FieldCaption")+'" pn="'+columnNode.getAttribute("n")+'" fn="'+columnNode.getAttribute("n")+'"><objects-list><filter><column n="id"><![CDATA['+value+']]></column></filter></objects-list></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xmlString,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(xmlString);
|
||||
}
|
||||
}
|
||||
td2.appendChild( table );
|
||||
@ -1053,10 +1017,7 @@ class SRec
|
||||
}
|
||||
|
||||
strXMLF='<?xml version="1.0" encoding="utf-8"?><metadata fn="6">'+strXMLF+'</metadata>';
|
||||
if(this.request.callServer(ScriptName,strXMLF,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(strXMLF);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1065,6 +1026,26 @@ class SRec
|
||||
}
|
||||
}
|
||||
|
||||
callDataSelect(data) {
|
||||
postXMLData(ScriptName,data,
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setDataSelect(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
//We ask the server for a list of values almost like a drop-down list.
|
||||
//typeName - The name of the object (TODO if the current is the variable f TypeName)
|
||||
//name - the name of the column for selecting the values (must match the name of any filter in typeName)
|
||||
@ -1078,10 +1059,7 @@ class SRec
|
||||
let xml='<?xml version="1.0" encoding="utf-8"?><metadata fn="6"><type n="'+typeName+'" c="'+name+'" pn="'+htmlid+'" id="'+id+'"><objects-list><filter>';
|
||||
xml+='<column n="'+filterName+'"><![CDATA['+value+']]></column>';
|
||||
xml+='</filter></objects-list></type></metadata>';
|
||||
if(this.request.callServer(ScriptName,xml,true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
this.callDataSelect(xml);
|
||||
}else
|
||||
{
|
||||
document.getElementById("filter_"+this.uid+"_"+htmlid).value='';
|
||||
@ -1280,8 +1258,8 @@ class SRec
|
||||
if(node.data[i].row[j]!=null) textNode=document.createTextNode(node.data[i].row[j]);
|
||||
else textNode=document.createTextNode("");
|
||||
|
||||
//td.setAttribute("id",id+this.masCL[colN].getAttribute("n")); //so that you can identify each record when you update
|
||||
td.setAttribute("id",id+this.masCL[colN].n); //so that you can identify each record when you update
|
||||
td.setAttribute("id",id+this.masCL[colN].getAttribute("n")); //so that you can identify each record when you update
|
||||
//td.setAttribute("id",id+this.masCL[colN].n); //so that you can identify each record when you update
|
||||
td.appendChild(textNode);
|
||||
//if in the metadata for this column there is a reference object then add a link
|
||||
if (this.masCT[colN]!=null)
|
||||
@ -1296,9 +1274,9 @@ class SRec
|
||||
};
|
||||
//when you click on a cell, the sent filter is prefilled with variables in accordance with the id of the pressed line
|
||||
//in the function we pass the cell id and the column number
|
||||
td.onclick=function(obj,val1,val2){
|
||||
td.onclick=function(thiz,val1,val2){
|
||||
return function(){
|
||||
obj.callWindow(val1,val2);
|
||||
thiz.callWindow(val1,val2);
|
||||
}
|
||||
}(this,id,colN);
|
||||
}else
|
||||
@ -1400,14 +1378,9 @@ class SRec
|
||||
rec.create(null);
|
||||
rec.f_State=1; //Зачем коментил?
|
||||
rec.f_PropName=nodeColu.getAttribute("n"); //Зачем коментил?
|
||||
rec.f_Settings=settings;
|
||||
rec.f_TypeName=TypeName;
|
||||
rec.win.setLeftTop(pageX-250,pageY-10);
|
||||
rec.win.setParent(this.win);
|
||||
if(rec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+TypeName+'"></type></metadata>'))
|
||||
{
|
||||
rec.showProgressBar();
|
||||
}
|
||||
rec.callData(TypeName,settings);
|
||||
};
|
||||
//Call the ShowRecord window with the parameters for the filter (not just the object name)
|
||||
//id - id records from the database
|
||||
@ -1431,16 +1404,9 @@ class SRec
|
||||
//wishWin = window.open("showrecord.html?name="+typeName,typeName,"width=800,height=600,menubar=no,location=no,resizable=yes,scrollbars=yes");
|
||||
let rec=new SRec();
|
||||
rec.create(null);
|
||||
//rec.f_State=1; not used
|
||||
//rec.f_PropName=propname; not used
|
||||
rec.f_Settings=xmlString;
|
||||
rec.f_TypeName=typeName;
|
||||
rec.win.setLeftTop(pageX-250,pageY-10);
|
||||
rec.win.setParent(this.win);
|
||||
if(rec.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="0"><type n="'+rec.f_TypeName+'"></type></metadata>'))
|
||||
{
|
||||
rec.showProgressBar();
|
||||
}
|
||||
rec.callData(typeName,xmlString);
|
||||
}
|
||||
|
||||
//Get column number by name
|
||||
@ -1453,10 +1419,10 @@ class SRec
|
||||
{
|
||||
if(nodeCol.nodeName=="column")
|
||||
{
|
||||
i++;
|
||||
if(nodeCol.getAttribute("n")==name){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
nodeCol = nodeCol.nextSibling;
|
||||
}
|
||||
@ -1565,10 +1531,28 @@ class SRec
|
||||
xs+=' </filter></objects-list>\n';
|
||||
xs+=' </type>\n';
|
||||
xs+='</metadata>';
|
||||
if(this.request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.rwin.showProgressBar();
|
||||
}
|
||||
|
||||
postXMLData(ScriptName,xs,
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
if(this.rwin!=null)
|
||||
{
|
||||
this.rwin.hideProgressBar();
|
||||
this.rwin.setContent('<table border="0px" style="width: 100%; height: 100%; background-color: var(--back-color-1);"><tr><td align="center"><a href="'+ScriptRName+(ScriptRName.indexOf('?')!=-1 ? '&file=' : '?file=')+findFirstNode(node,'#cdata-section').nodeValue+'" target="_blank">'+trt('Download_report')+': "'+this.win.getCaption().innerHTML+'".</a></td></tr></table>');
|
||||
}
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
chp(page)
|
||||
@ -1638,10 +1622,23 @@ class SRec
|
||||
{
|
||||
if(this.masChBox[i].checked)
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="3"><type n="'+this.f_TypeName+'" id="'+this.masChBox[i].value+'"></type></metadata>',true))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="3"><type n="'+this.f_TypeName+'" id="'+this.masChBox[i].value+'"></type></metadata>',
|
||||
(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.ApplyDelRec(data);
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
}
|
||||
);
|
||||
this.showProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1671,13 +1668,23 @@ class SRec
|
||||
{
|
||||
this.f_TypeName=typeName;
|
||||
this.f_Settings=settings;
|
||||
|
||||
if(this.request.callServer(ScriptName,'<metadata fn="0"><type n="'+this.f_TypeName+'"></type></metadata>'))
|
||||
{
|
||||
this.showProgressBar();
|
||||
}
|
||||
postXMLData(ScriptName,'<metadata fn="0"><type n="'+this.f_TypeName+'"></type></metadata>',(ok,data)=>{
|
||||
if(ok){
|
||||
if(data.error_code=='0')
|
||||
{
|
||||
this.setMetadata(data);
|
||||
this.updateSize();
|
||||
}else
|
||||
{
|
||||
alert2(trt('Alert'),data.error_message);
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
}
|
||||
this.hideProgressBar();
|
||||
});
|
||||
this.showProgressBar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Convert XML to array
|
||||
|
||||
@ -1,14 +1,29 @@
|
||||
/*jshint esversion: 6 */
|
||||
"use strict";
|
||||
|
||||
//var g_translations = {'':''};
|
||||
function strToInt(str){
|
||||
if(str==null) return null;
|
||||
const match = str.trim().match(/[-+]?\d+(\.\d+)?/);
|
||||
if (match) {
|
||||
const number = Number(match[0]);
|
||||
return isNaN(number) ? null : number;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeChild(parent){
|
||||
if(parent==null) return;
|
||||
while (parent.firstChild) {
|
||||
parent.removeChild(parent.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
//Массив g_translations подгружается отдельно
|
||||
function trt(key)
|
||||
{
|
||||
if(key==null || key===undefined) return '';
|
||||
let val=null;
|
||||
if(g_translations !== undefined){
|
||||
if(typeof g_translations !== 'undefined'){
|
||||
val=g_translations[key];
|
||||
if(val==null || val===undefined)
|
||||
{
|
||||
@ -21,7 +36,10 @@ function trt(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(val==null || val===undefined) return (''+key).replace(/_/g, ' ');
|
||||
if(val==null || val===undefined) {
|
||||
|
||||
return ('' + key).replace(/_/g, ' ');
|
||||
}
|
||||
else return val;
|
||||
}
|
||||
|
||||
@ -237,7 +255,7 @@ function loadContent(url,obj)
|
||||
req.send( null );
|
||||
}
|
||||
|
||||
//POST Json Data to server and Json in result
|
||||
//POST Json Data to server
|
||||
function postJsonData(url,data,fun){
|
||||
if(typeof data !== 'string') {
|
||||
data = JSON.stringify(data);
|
||||
@ -248,15 +266,21 @@ function postJsonData(url,data,fun){
|
||||
return function(){
|
||||
if(req.readyState == 4 || typeof(req.readyState)=='undefined'){
|
||||
if(req.status == 200) {
|
||||
let json = null;
|
||||
try {
|
||||
json = JSON.parse(req.responseText);
|
||||
} catch (e) {
|
||||
if(req.responseXML!=null) {
|
||||
let node = req.responseXML.documentElement;
|
||||
node.error_code='0';
|
||||
fun(true, node);
|
||||
}else {
|
||||
let json = null;
|
||||
try {
|
||||
json = JSON.parse(req.responseText);
|
||||
} catch (e) {
|
||||
}
|
||||
if (json != null)
|
||||
fun(true, json);
|
||||
else
|
||||
fun(false, req.responseText);
|
||||
}
|
||||
if (json != null)
|
||||
fun(true, json);
|
||||
else
|
||||
fun(false, req.responseText);
|
||||
}else{
|
||||
fun(false,trt('Failed_to_receive_data'));
|
||||
}
|
||||
@ -267,17 +291,60 @@ function postJsonData(url,data,fun){
|
||||
req.setRequestHeader("Content-type", "application/json");
|
||||
req.send(data);
|
||||
}
|
||||
//POST Json Data to server
|
||||
function postXMLData(url,data,fun){
|
||||
if(typeof data !== 'string') {
|
||||
let serializer = new XMLSerializer();
|
||||
data = serializer.serializeToString(data);
|
||||
}
|
||||
let req=createRequestObject();
|
||||
req.onreadystatechange = function(req)
|
||||
{
|
||||
return function(){
|
||||
if(req.readyState == 4 || typeof(req.readyState)=='undefined'){
|
||||
if(req.status == 200) {
|
||||
if(req.responseXML!=null) {
|
||||
let node = req.responseXML.documentElement;
|
||||
node.error_code='0';
|
||||
fun(true, node);
|
||||
}else {
|
||||
let json = null;
|
||||
try {
|
||||
json = JSON.parse(req.responseText);
|
||||
} catch (e) {
|
||||
}
|
||||
if (json != null)
|
||||
fun(true, json);
|
||||
else
|
||||
fun(false, req.responseText);
|
||||
}
|
||||
}else{
|
||||
fun(false,trt('Failed_to_receive_data'));
|
||||
}
|
||||
}
|
||||
};
|
||||
}(req);
|
||||
req.open( "POST", url, true );
|
||||
req.setRequestHeader("Content-type", "application/xml");
|
||||
req.send(data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Вывести текст поверх окон с кнопочкой OK
|
||||
function alert2(title,smallText,fullText,okFunc=null)
|
||||
{
|
||||
if(fullText === undefined) fullText='';
|
||||
if(smallText === undefined || smallText==''){
|
||||
smallText=fullText;
|
||||
fullText='';
|
||||
}
|
||||
let pos1=smallText.indexOf('[[');
|
||||
let pos2=smallText.indexOf(']]');
|
||||
if(pos1>=0 && pos2>=0 && pos1<pos2) smallText=smallText.substring(pos1+2, pos2);
|
||||
if(pos1>=0 && pos2>=0 && pos1<pos2) {
|
||||
fullText = smallText;
|
||||
smallText = smallText.substring(pos1 + 2, pos2);
|
||||
}
|
||||
|
||||
let win=new TWin(true);
|
||||
win.BuildGUI(10,10);
|
||||
@ -1305,7 +1372,7 @@ alert(JSON.stringify(xmlHttpRequest));
|
||||
}*/
|
||||
};
|
||||
|
||||
/** Класс асинхронных запросов к серверу
|
||||
/** Класс асинхронных запросов к серверу (TODO удалить его и не использовать)
|
||||
*/
|
||||
class myXMLHttpRequest
|
||||
{
|
||||
|
||||
@ -120,7 +120,7 @@ class TWin
|
||||
hd+='<table style="width: 100%;">';
|
||||
hd+=' <tr>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H1_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t1.gif" style="width: 20px; height: 20px; display: block;" alt="" border="0px" draggable="false"/></td>';
|
||||
hd+=' <td align="center" width="100%" bgcolor="#3366CC" style="font-weight: bold; cursor:move; background: #92b5df url('+this.path+'/metadata/dbms/form/1.gif) repeat-x top;" id="TWin_H2_'+this.tWinId+'"><nobr id="TWin_Ca_'+this.tWinId+'"></nobr></td>';
|
||||
hd+=' <td align="center" width="100%" style="background-color:#3366CC;font-weight: bold; cursor:move; background: #92b5df url('+this.path+'/metadata/dbms/form/1.gif) repeat-x top;" id="TWin_H2_'+this.tWinId+'"><nobr id="TWin_Ca_'+this.tWinId+'"></nobr></td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H3_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t2.gif" alt="" style="width: 20px; height: 20px; display: block;" border="0px" draggable="false"/></td>';
|
||||
//hd+=' <td width="100%"> </td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||||
@ -359,9 +359,14 @@ class TWin
|
||||
//json - объект который передастца в виде JSON строки по URL
|
||||
//func - функция которая выполниться после загрузки данных в форму
|
||||
load(url,json,func,tr)
|
||||
{
|
||||
this.loadBody(url,"POST",json,func,tr);
|
||||
console.error('Please use the "loadBody" function.');
|
||||
};
|
||||
loadBody(url,method,json,func,tr)
|
||||
{
|
||||
this.showProgressBar();
|
||||
var r=createRequestObject();
|
||||
let r=createRequestObject();
|
||||
r.onreadystatechange = function(r,w,thiz,func)
|
||||
{
|
||||
return function(){
|
||||
@ -370,20 +375,25 @@ class TWin
|
||||
else w.innerHTML=r.responseText;
|
||||
thiz.hideProgressBar();
|
||||
if(func !== undefined && func!=null) func();
|
||||
|
||||
|
||||
//Для подстройки формы под новый размер, а то showProgressBar не по размеру было
|
||||
thiz.div.style.width=thiz.tbl.offsetWidth+"px"
|
||||
thiz.div.style.height=thiz.tbl.offsetHeight+"px";
|
||||
|
||||
|
||||
thiz.setCenter();
|
||||
}
|
||||
}
|
||||
}(r,this.co,this,func,tr)
|
||||
r.open( "POST", url, true );
|
||||
r.open( method, url, true );
|
||||
r.setRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
r.setRequestHeader("Pragma", "no-cache");
|
||||
r.setRequestHeader("Expires", "0");
|
||||
if(json!=null)
|
||||
r.send(JSON.stringify(json));
|
||||
else
|
||||
}else {
|
||||
r.open( "GET", url, true );
|
||||
r.send();
|
||||
}
|
||||
};
|
||||
|
||||
//Переместить окно на передний план (Обычно при щелчке на нём)
|
||||
@ -435,12 +445,13 @@ class TWin
|
||||
this.pBarCnt++;
|
||||
if(this.pBarDiv==null)
|
||||
{
|
||||
var img='loading.gif';
|
||||
let img='loading.gif';
|
||||
if(this.getWidth()<230) img='loading3.gif';
|
||||
|
||||
this.pBarDiv=document.createElement('div');
|
||||
this.pBarDiv.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1; width:100%; height: 100%; margin-top:30px; padding-bottom:30px;';
|
||||
this.pBarDiv.innerHTML='<table style="background-color: rgba(0,0,0,0.5);" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" style="vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/images/'+img+'" alt=""></td></tr></table>';
|
||||
this.pBarDiv.innerHTML='<table style="background-color: rgba(0,0,0,0.5); width: 100%; height: 100%; border-collapse: collapse;"><tr><td align="center" style="vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/images/'+img+'" alt=""></td></tr></table>';
|
||||
|
||||
|
||||
//var eDiv=document.getElementById('eDiv'+this.uid);
|
||||
this.div.appendChild(this.pBarDiv);
|
||||
|
||||
@ -322,7 +322,7 @@ Bidi override codes supported - Right-to-Left Embedding [RLE] U+202B, Left-to-Ri
|
||||
U+202C POP DIRECTIONAL FORMATTING (PDF)
|
||||
Support for <base href=""> in HTML - uses it to SetBasePath for relative URLs.
|
||||
HTML tag - added support for <wbr> or <wbr /> - converted to a soft-hyphen
|
||||
CSS now takes precedence over HTML attribute e.g. <table bgcolor="black" style="background-color:yellow">
|
||||
CSS now takes precedence over HTML attribute e.g. <table style="background-color:yellow">
|
||||
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,8 @@
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
"classmap": ["mpdf.php", "classes"]
|
||||
"classmap": [
|
||||
"mpdf.php", "classes"]
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
*
|
||||
.gitignore
|
||||
!.gitignore
|
||||
|
||||
2
metadata/include/mpdf-6.1/tmp/.gitignore
vendored
2
metadata/include/mpdf-6.1/tmp/.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
*
|
||||
.gitignore
|
||||
!.gitignore
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
*
|
||||
.gitignore
|
||||
!.gitignore
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
// Из файла file.js делаем file_v123456789.js добавив время
|
||||
function getScript($path)
|
||||
function getScript($path,$pathURL="")
|
||||
{
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].$path))
|
||||
{
|
||||
return '<script src="'.beforeLast($path,'.').'_v'.filectime($_SERVER['DOCUMENT_ROOT'].$path).'.'.afterLast($path,'.').'"></script>'."\n";
|
||||
if($pathURL!="")
|
||||
{
|
||||
return '<script src="' . $pathURL.'?v='.filectime($_SERVER['DOCUMENT_ROOT'] . $path). '"></script>' . "\n";
|
||||
}else {
|
||||
return '<script src="' . beforeLast($path, '.') . '_v' . filectime($_SERVER['DOCUMENT_ROOT'] . $path) . '.' . afterLast($path, '.') . '"></script>' . "\n";
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@ -102,7 +107,7 @@ function getAccess($key)
|
||||
global $db;
|
||||
|
||||
$result=false;
|
||||
$sql="select main.p_getaccess(:user_id,:key) as acc;";
|
||||
$sql="select main.get_access(:user_id,:key) as acc;";
|
||||
$stmt = $db->prepare($sql);
|
||||
if(isset($_SESSION['USER_ID']))
|
||||
$stmt->bindValue(':user_id', $_SESSION['USER_ID'], PDO::PARAM_INT);
|
||||
@ -512,3 +517,11 @@ function cutBeforeFirst(&$sstr,$fstr)
|
||||
return $sub;
|
||||
}
|
||||
}
|
||||
|
||||
function getUID()
|
||||
{
|
||||
$data = openssl_random_pseudo_bytes(16);
|
||||
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
@ -61,6 +61,8 @@
|
||||
*/
|
||||
function findFirstNode($node, $nodename)
|
||||
{
|
||||
if($node==null) return null;
|
||||
|
||||
$mas=array();
|
||||
$pos=0;
|
||||
$mas[$pos] = $node->firstChild;
|
||||
|
||||
@ -13,13 +13,13 @@
|
||||
<table class="SEdit" id="app0" border="0px" cellspacing="1" cellpadding="1" style="width: 100%; height: 100%;">
|
||||
<caption><b id="caption'+this.uid+'"></b></caption>
|
||||
<thead>
|
||||
<tr bgcolor="#dadada">
|
||||
<tr style="background-color:#dadada;">
|
||||
<th style="width:20%">trt('Name')</th>
|
||||
<th style="width:80%">trt('Value')</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr bgcolor="#dadada">
|
||||
<tr style="background-color:#dadada;">
|
||||
<td style="width:20%">trt('Name')</td>
|
||||
<td style="width:80%">trt('Value')</td>
|
||||
</tr>
|
||||
|
||||
@ -285,7 +285,7 @@ function TMenu(v_obj,v_scr,v_treepath) //Горизонтальное меню
|
||||
pn=pn.parent;
|
||||
}
|
||||
//Шаблон кнопки по умолчанию
|
||||
if(str=='') str='<div style="border: 1px solid #dddddd;" onClick="window.location.href = \'./?path=${path}\'" onMouseOver="this.style.backgroundColor=\'#ffffff\'; this.style.textDecoration=\'underline\';" onMouseOut="this.style.backgroundColor=\'#dddddd\'; this.style.textDecoration=\'none\';"><table style="width: 100%;"><tr><td style="vertical-align: middle;"><nobr> <a href="./?path=${path}" style="${select}">${name}</a> </nobr></td><td style="vertical-align: middle; width: 10px; padding-right: 4px;"><img src="./img/next.gif" alt="" align="right" style="vertical-align: middle; display: ${none};"></td></tr></table></div>';
|
||||
if(str=='') str='<div style="border: 1px solid #dddddd;" onClick="window.location.href = \'./?path=${path}\'" onMouseOver="this.style.backgroundColor=\'#ffffff\'; this.style.textDecoration=\'underline\';" onMouseOut="this.style.backgroundColor=\'#dddddd\'; this.style.textDecoration=\'none\';"><table style="width: 100%;"><tr><td style="vertical-align: middle;"><nobr> <a href="?path=${path}" style="${select}">${name}</a> </nobr></td><td style="vertical-align: middle; width: 10px; padding-right: 4px;"><img src="./img/next.gif" alt="" align="right" style="vertical-align: middle; display: ${none};"></td></tr></table></div>';
|
||||
|
||||
str=str.replace(/\${path}/g, tn.getTreePath());
|
||||
str=str.replace(/\${hash}/g, crc32(tn.getTreePath()));
|
||||
@ -417,7 +417,7 @@ function TMenu(v_obj,v_scr,v_treepath) //Горизонтальное меню
|
||||
if(str!='') break;
|
||||
nTmp=nTmp.parentNode;
|
||||
}
|
||||
if(str=='') str='<div style="border: 1px solid #dddddd;" onClick="window.location.href = \'./?path=${path}\'" onMouseOver="this.style.backgroundColor=\'#ffffff\'; this.style.textDecoration=\'underline\';" onMouseOut="this.style.backgroundColor=\'#dddddd\'; this.style.textDecoration=\'none\';"><table style="width: 100%;"><tr><td style="vertical-align: middle;"><nobr> <a href="./?path=${path}">${name}</a> </nobr></td><td style="vertical-align: middle; width: 10px; padding-right: 4px;"><img src="./img/next.gif" alt="" align="right" style="vertical-align: middle; display: ${none};"></td></tr></table></div>';
|
||||
if(str=='') str='<div style="border: 1px solid #dddddd;" onClick="window.location.href = \'./?path=${path}\'" onMouseOver="this.style.backgroundColor=\'#ffffff\'; this.style.textDecoration=\'underline\';" onMouseOut="this.style.backgroundColor=\'#dddddd\'; this.style.textDecoration=\'none\';"><table style="width: 100%;"><tr><td style="vertical-align: middle;"><nobr> <a href="?path=${path}">${name}</a> </nobr></td><td style="vertical-align: middle; width: 10px; padding-right: 4px;"><img src="./img/next.gif" alt="" align="right" style="vertical-align: middle; display: ${none};"></td></tr></table></div>';
|
||||
str=str.replace(/\${path}/g, this.m_tn[this.m_tn.length-1].getTreePath());
|
||||
str=str.replace(/\${name}/g, getCdataValue(nodeTree));
|
||||
str=str.replace(/\${none}/g, nodeTree.getAttribute("c")=='1' ? 'block' : 'none');
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<title>Синхронизация</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
</head>
|
||||
<body bgColor="#FFFFDD">
|
||||
<body style="background-color:#FFFFDD;">
|
||||
<?php
|
||||
//Для переодического запрашивания данных с другого сервера и обновления локальной базы
|
||||
//ini_set('max_execution_time',600);//устанавливаем время работы скрипта
|
||||
|
||||
@ -10,10 +10,10 @@
|
||||
<proc n="Cities"/><!--Процедура для выборки данных-->
|
||||
<presentation>
|
||||
<head><![CDATA[
|
||||
<table id="table0" width="100%" border="0px" cellspacing="1px" cellpadding="2px" bgcolor="#000000" style="border: 0px solid rgb(0, 0, 0);">
|
||||
<table id="table0" width="100%" border="0px" cellspacing="1px" cellpadding="2px" style="border: 0px solid rgb(0, 0, 0);background-color:#000000;">
|
||||
<caption></caption>
|
||||
<thead>
|
||||
<tr bgcolor="#AAAAFF">
|
||||
<tr style="background-color:#AAAAFF;">
|
||||
<th width="40%">ПАСПОРТНЫЕ ДАННЫЕ</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user