This commit is contained in:
2024-03-25 23:12:10 +05:00
parent dd0a3f17ea
commit ba933a0712
18 changed files with 194 additions and 2951 deletions

View File

@ -56,6 +56,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
@ -105,10 +109,13 @@ public class DBMSRecords implements ServletContextAware {
}
//Документация по @RequestBody http://javastudy.ru/spring-mvc/json-xml/ application/xml
@RequestMapping(value = "/monitoring/records.php",method = {RequestMethod.POST,RequestMethod.GET},produces = "text/plain; charset=utf-8")
@RequestMapping(value = "/api/dbms/records.xyz",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
@ResponseBody
public Object ajaxTamer(@ModelAttribute User user,@RequestBody(required = false) byte[] reqData,@RequestParam(required=false,name="lng") String language_id) {
public ResponseEntity<String> ajaxTamer(@ModelAttribute User user, @RequestBody(required = false) byte[] reqData, @RequestParam(required=false,name="lng") String language_id) {
final HttpHeaders httpHeaders= new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
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);
@ -116,7 +123,7 @@ public class DBMSRecords implements ServletContextAware {
boolean error=false;
String result=sendError(1,"Request not processed!");
if(reqData==null)
return result;
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
//response.setCharacterEncoding("UTF-8");
@ -198,7 +205,7 @@ public class DBMSRecords implements ServletContextAware {
} catch (Exception ex) {
logger.info(ex.getMessage());
//return "<metadata fn=\"-1\"><![CDATA[Parsing request error!]]></metadata>";
return sendError(1,"Parsing request error!");
return new ResponseEntity<String>(sendError(1,"Parsing request error!"), httpHeaders, HttpStatus.OK);
}
if (doc != null) {
@ -427,6 +434,7 @@ public class DBMSRecords implements ServletContextAware {
}
result=getText(conn,xml,user);
httpHeaders.setContentType(MediaType.APPLICATION_XML);
} else if (fn != null && fn.equals("1")) {
String typename = "";
@ -511,7 +519,8 @@ public class DBMSRecords implements ServletContextAware {
sql_query = Tools.replaceAll(sql_query,"${" + vn + "}", getSQLValue(vt, val));
}
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
logger.info("sql_query22 = " + sql_query);
@ -528,7 +537,8 @@ public class DBMSRecords implements ServletContextAware {
String xmlstring = "<metadata fn=\"1\"><type n=\"" + typename + "\" id=\"" + obj_id + "\"></type></metadata>";
result=xmlstring;
logger.info("xmlstring = " + xmlstring);
httpHeaders.setContentType(MediaType.APPLICATION_XML);
//logger.info("xmlstring = " + xmlstring);
}
stt.close();
rs.close();
@ -624,7 +634,8 @@ public class DBMSRecords implements ServletContextAware {
}
sql_query=Tools.replaceAll(sql_query,"${" + vn + "}", getSQLValue(vt, val));
}
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
logger.info("sql_query = " + sql_query);
@ -642,7 +653,8 @@ public class DBMSRecords implements ServletContextAware {
String xmlstring = "<metadata fn=\"2\"><type n=\"" + typename + "\" id=\"" + obj_id + "\"></type></metadata>";
result=xmlstring;
logger.info("xmlstring = " + xmlstring);
httpHeaders.setContentType(MediaType.APPLICATION_XML);
//logger.info("xmlstring = " + xmlstring);
}
rs.close();
stt.close();
@ -715,7 +727,8 @@ public class DBMSRecords implements ServletContextAware {
} */
sql_query = Tools.replaceAll(sql_query,"${id}", getSQLValue("string", obj_id)); //string а не i4 так как некоторые таблицы с uuid
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
//logger.info("sql_query = " + sql_query);
@ -732,6 +745,7 @@ public class DBMSRecords implements ServletContextAware {
String xmlstring = "<metadata fn=\"3\"><type n=\"" + typename + "\" id=\"" + obj_id + "\"></type></metadata>";
result=xmlstring;
httpHeaders.setContentType(MediaType.APPLICATION_XML);
//logger.info("xmlstring = " + xmlstring);
}
rs.close();
@ -830,7 +844,8 @@ public class DBMSRecords implements ServletContextAware {
}
nextnode = nextnode.getNextSibling();
}
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
//logger.info("sql_query = " + sql_query);
@ -930,8 +945,8 @@ public class DBMSRecords implements ServletContextAware {
xmlstring += "</type></metadata>\n";
result=xmlstring;*/
JSONObject json = new JSONObject();
json.put("errorCode",0);
json.put("errorMessage","");
json.put("error_code",0);
json.put("error_message","");
json.put("fn",fn);
json.put("n",typename);
json.put("pc",pagecount);
@ -1010,6 +1025,7 @@ public class DBMSRecords implements ServletContextAware {
String sql_query = "";
String typename = "";
String idname = "";
String id = "";
Node nTypeR = null;
if (doc != null) {
@ -1024,7 +1040,8 @@ public class DBMSRecords implements ServletContextAware {
if (nodeList.getLength() > 0) {
nTypeR = nodeList.item(0);
typename = "" + nTypeR.getAttributes().getNamedItem("n").getNodeValue();
idname = "" + nTypeR.getAttributes().getNamedItem("id").getNodeValue();
idname = "" + nTypeR.getAttributes().getNamedItem("ObjectID").getNodeValue();
id = "" + nTypeR.getAttributes().getNamedItem("id").getNodeValue();
}
}
@ -1044,8 +1061,9 @@ public class DBMSRecords implements ServletContextAware {
logger.info(ex.getMessage());
}
sql_query = Tools.replaceAll(sql_query,"${id}", getSQLValue("string", idname)); //Set current record id into sql query.
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id into sql query.
sql_query = Tools.replaceAll(sql_query,"${"+idname+"}", 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);
//logger.info("sql_query = " + sql_query);
@ -1058,7 +1076,7 @@ public class DBMSRecords implements ServletContextAware {
if (rs != null) {
//Выбираем данные и строим XML для отправки клиенту
String xmlstring = "";
xmlstring += "<metadata fn=\"" + fn + "\"><type n=\"" + typename + "\" id=\"" + idname + "\"><properties>\n";
xmlstring += "<metadata fn=\"" + fn + "\"><type n=\"" + typename + "\" id=\"" + id + "\"><properties>\n";
NodeList nodeList=null;
try {
nodeList = (NodeList) xpath.compile("properties/prop").evaluate(nTypeS, XPathConstants.NODESET);
@ -1085,6 +1103,7 @@ public class DBMSRecords implements ServletContextAware {
xmlstring += "</properties></type></metadata>\n";
result=xmlstring;
httpHeaders.setContentType(MediaType.APPLICATION_XML);
//logger.info("xmlstring = " + xmlstring);
}
rs.close();
@ -1193,7 +1212,8 @@ public class DBMSRecords implements ServletContextAware {
nextnode = nextnode.getNextSibling();
}
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
//logger.info("sql_query = " + sql_query);
@ -1220,6 +1240,7 @@ public class DBMSRecords implements ServletContextAware {
xmlstring += "</type></metadata>\n";
result=xmlstring;
httpHeaders.setContentType(MediaType.APPLICATION_XML);
//logger.info("xmlstring = " + xmlstring);
}
rs.close();
@ -1566,7 +1587,7 @@ public class DBMSRecords implements ServletContextAware {
}
result=xmlstring;
//logger.info("xmlstring = " + xmlstring);
httpHeaders.setContentType(MediaType.APPLICATION_XML);
} else if (fn != null && fn.equals("8")) {
//Select information about the current user
@ -1695,7 +1716,8 @@ public class DBMSRecords implements ServletContextAware {
}
nextnode = nextnode.getNextSibling();
}
sql_query = Tools.replaceAll(sql_query,"${_user_id}", (String) user.id); //Set current user id in sql query.
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);
//logger.info("sql_query2 = " + sql_query);
@ -1890,14 +1912,10 @@ public class DBMSRecords implements ServletContextAware {
result=sendError(1,"Unknown function \"" + fn + "\" !");
error=true;
}
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
try { if(conn!=null) conn.close(); } catch (SQLException e) { throw new RuntimeException(e); }
//return body content
return result;
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
}
@Override
@ -2064,7 +2082,7 @@ public class DBMSRecords implements ServletContextAware {
}
}
if(conn!=null){try{conn.close();}catch(SQLException ex){}}
try { if(conn!=null) conn.close(); } catch (SQLException e) { throw new RuntimeException(e); }
if(file!=null) {
response.setContentType("application/octet-stream");

View File

@ -8,11 +8,10 @@ function setPropVal(uid,id,c,p){
var ERec_mas = new Array(); //List of all ERec objects (TODO then you better come up with something).
class EdtRec extends TWin
class EdtRec
{
constructor(caption,dialog,path)
constructor(caption)
{
super(dialog,path);
this.uid=getUID();
this.record_id=null;
@ -20,7 +19,6 @@ class EdtRec extends TWin
this.win.BuildGUI(pageX-10,pageY-10);
this.win.setSize("500px","150px");
this.win.setContent('<div id="eDiv'+this.uid+'" style="width: 100%; /*height: 100%;*/ position: relative;"></div>');
this.win.obj=this;
let eDiv=document.getElementById('eDiv'+this.uid);
eDiv.innerHTML = '<table style="width:100%;height:100%"><tr><td style="vertical-align:middle;background-color:#F1F1F1"><center><IMG src="../resources/metadata/dbms/images/loading.gif"></center></td></tr></table>'
@ -28,6 +26,7 @@ class EdtRec extends TWin
this.caption=caption;
if(this.caption!='')
this.win.setCaption(this.caption);
this.win.obj=this;
this.win.hide(false);
this.name="name"+this.uid;
@ -831,7 +830,7 @@ class EdtRec extends TWin
button.setAttribute("value",trt('Apply'));
button.onclick=()=>this.sendData();
td.appendChild( button );
button = document.createElement('input'); //Button cancel
button.classList.add('button-secondary');
button.setAttribute("type","button");
@ -1038,7 +1037,7 @@ class EdtRec extends TWin
}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));
if(this.request.callServer(ScriptName,xml,true))
{
this.showProgressBar();
}
@ -1204,8 +1203,8 @@ class EdtRec extends TWin
{
this.hideProgressBar();
if(node.errorCode>0) {
alert2(trt('Alert'), node.errorMessage);
if(node.error_code>0) {
alert2(trt('Alert'), node.error_message);
return;
}

View File

@ -20,8 +20,8 @@ class DBMSUser
{
this.showShadow(false);
if(node.errorCode>0) {
alert2(trt('Alert'), node.errorMessage);
if(node.error_code>0) {
alert2(trt('Alert'), node.error_message);
return;
}
@ -98,28 +98,28 @@ class DBMSUser
this.win.setSize("350px","184px");
var str='<div style="width: 100%; height: 100%; padding: 3px; text-align: left;">\n\
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">\n\
<tbody>\n\
<tr><td>\n\
<table style="width: 100%; height: 100%;">\n\
<tr>\n\
<td style="padding: 2px; width: 30%; white-space: nowrap"><b>'+trt('Login')+' (E-mail):</b></td>\n\
<td style="padding: 2px;"><input type="text" maxlength="50" style="width: 100%; padding: 2px; display: inline;" id="tcLogin'+this.uid+'" name="login"><br></td>\n\
</tr>\n\
<tr>\n\
<td style="padding: 2px;"><b>Password:</b></td>\n\
<td style="padding: 2px;"><input type="password" maxlength="33" style="width: 100%; padding: 2px; display: inline;" id="tcPassword'+this.uid+'" name="password"><br></td>\n\
</tr>\n\
<tr>\n\
<td style="padding: 2px;" colspan="2"><table style="width: 100%;"><tr><td><label for="save0" style="white-space: nowrap;"><input id="save_'+this.uid+'" type="checkbox" style="display: inline;" checked/>&nbsp;Remember&nbsp;(<a href="#" onclick="g_user.showRestoreForm();">Forgot your password?</a>)</label></td></tr></table></td>\n\
</tr>\n\
<tr><td colspan="2" style="text-align: right;"><input class="button-secondary" id="TLogin_E'+this.uid+'" type="button" style="display: inline;" value="'+trt('Log_in')+'"></td></tr>\n\
</table>\n\
</td></tr>\n\
</tbody>\n\
</table>\n\
</div>';
let str=`<div style="width: 100%; height: 100%; padding: 3px; text-align: left;">
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">
<tbody>
<tr><td>
<table style="width: 100%; height: 100%;">
<tr>
<td style="padding: 2px; width: 30%; white-space: nowrap"><b>`+trt('Login')+` (E-mail):</b></td>
<td style="padding: 2px;"><input type="text" maxlength="50" style="width: 100%; padding: 2px; display: inline;" id="tcLogin`+this.uid+`" name="login"><br></td>
</tr>
<tr>
<td style="padding: 2px;"><b>Password:</b></td>
<td style="padding: 2px;"><input type="password" maxlength="33" style="width: 100%; padding: 2px; display: inline;" id="tcPassword`+this.uid+`" name="password"><br></td>
</tr>
<tr>
<td style="padding: 2px;" colspan="2"><table style="width: 100%;"><tr><td><label for="save0" style="white-space: nowrap;"><input id="save_`+this.uid+`" type="checkbox" style="display: inline;" checked/>&nbsp;Remember&nbsp;(<a href="#" onclick="g_user.showRestoreForm();">Forgot your password?</a>)</label></td></tr></table></td>
</tr>
<tr><td colspan="2" style="text-align: right;"><input class="button-secondary" id="TLogin_E`+this.uid+`" type="button" style="display: inline;" value="`+trt('Log_in')+`"></td></tr>
</table>
</td></tr>
</tbody>
</table>
</div>`;
this.win.setContent(str);
@ -137,14 +137,14 @@ class DBMSUser
{
obj.onclick=()=>
{
var xs='<?xml version="1.0" encoding="utf-8"?>\
<metadata fn="7">\
<cmd><![CDATA[3]]></cmd>\n\
<login><![CDATA['+document.getElementById('tcLogin'+this.uid).value+']]></login>\
<password><![CDATA['+document.getElementById('tcPassword'+this.uid).value+']]></password>\
</metadata>';
let xs=`<?xml version="1.0" encoding="utf-8"?>
<metadata fn="7">
<cmd><![CDATA[3]]></cmd>
<login><![CDATA[`+document.getElementById('tcLogin'+this.uid).value+`]]></login>
<password><![CDATA[`+document.getElementById('tcPassword'+this.uid).value+`]]></password>
</metadata>`;
var request=new TRequest(this);
let request=new TRequest(this);
if(request.callServer(ScriptName,xs))
{
this.win.showProgressBar();
@ -260,21 +260,21 @@ class DBMSUser
//Display password recovery form
showRestoreForm()
{
var win=new TWin(true);
let win=new TWin(true);
win.BuildGUI(10,10);
win.setCaption(trt("Password_recovery"));
let str='<div style="width: 100%; height: 100%; padding: 4px; text-align: left;">\n\
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%; padding: 0px;">\n\
<tr>\n\
<td style="padding: 2px; white-space: nowrap"><b>'+trt('Login')+' (E-mail)</b></td>\n\
<td style="padding: 2px;"><input type="text" maxlength="40" style="width: 100%; display: inline;" id="'+win.uid+'_email" name="login">\n\
<table id="'+win.uid+'_phone" style="width: 100%; display: none;" cellpadding="0" cellspacing="0"><tr><td style="white-space: nowrap;"><b>+7 ( </b><input type="text" maxlength="3" onkeydown="this.value = this.value.replace(/[^0-9]/g, \'\')" onkeyup="this.value = this.value.replace(/[^0-9]/g, \'\')" style="width: 35px; display: inline;" id="'+win.uid+'_phone0" value=""><b> ) </b></td><td style="width: 90%;"><input type="text" onkeydown="this.value = this.value.replace(/[^0-9]/g, \'\')" onkeyup="this.value = this.value.replace(/[^0-9]/g, \'\')" maxlength="7" style="width: 100%;display: inline;" id="'+win.uid+'_phone1" value=""></td></tr></table><br></td>\n\
</tr>\n\
<tr><td colspan="2" style="text-align: right; padding: 2px;"><input class="button-secondary" id="'+win.uid+'_restore" type="button" style="display: inline;" value="'+trt('Restore')+'"></td></tr>\n\
</table>\n\
</td></tr>\n\
</div>';
let str=`<div style="width: 100%; height: 100%; padding: 4px; text-align: left;">
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%; padding: 0px;">
<tr>
<td style="padding: 2px; white-space: nowrap"><b>`+trt('Login')+` (E-mail)</b></td>
<td style="padding: 2px;"><input type="text" maxlength="40" style="width: 100%; display: inline;" id="`+win.uid+`_email" name="login">
<table id="`+win.uid+`_phone" style="width: 100%; display: none;" cellpadding="0" cellspacing="0"><tr><td style="white-space: nowrap;"><b>+7 ( </b><input type="text" maxlength="3" onkeydown="this.value = this.value.replace(/[^0-9]/g, \'\')" onkeyup="this.value = this.value.replace(/[^0-9]/g, \'\')" style="width: 35px; display: inline;" id="`+win.uid+`_phone0" value=""><b> ) </b></td><td style="width: 90%;"><input type="text" onkeydown="this.value = this.value.replace(/[^0-9]/g, \'\')" onkeyup="this.value = this.value.replace(/[^0-9]/g, \'\')" maxlength="7" style="width: 100%;display: inline;" id="`+win.uid+`_phone1" value=""></td></tr></table><br></td>
</tr>
<tr><td colspan="2" style="text-align: right; padding: 2px;"><input class="button-secondary" id="`+win.uid+`_restore" type="button" style="display: inline;" value="`+trt('Restore')+`"></td></tr>
</table>
</td></tr>
</div>`;
win.setContent(str);
//Центрируем окно и отображаем тень
@ -294,18 +294,18 @@ class DBMSUser
{
win.showProgressBar();
var em=document.getElementById(win.uid+'_email').value;
let em=document.getElementById(win.uid+'_email').value;
if(em==''){ document.getElementById(win.uid+'_email').select(); alert(trt('Not_filled_Email_address')); win.hideProgressBar(); return; }
if(! isEmail(em)){ document.getElementById(win.uid+'_email').select(); alert(trt('Please_enter_a_valid_email_address')); win.hideProgressBar(); return; }
//Send AJAX reqwest to server
var xml='<?xml version="1.0" encoding="utf-8"?>\
<metadata fn="7">\
<cmd><![CDATA[0]]></cmd>\
<login><![CDATA['+em+']]></login>\
<captcha><![CDATA[]]></captcha>\
</metadata>';
let xml=`<?xml version="1.0" encoding="utf-8"?>
<metadata fn="7">
<cmd><![CDATA[0]]></cmd>
<login><![CDATA[`+em+`]]></login>
<captcha><![CDATA[]]></captcha>
</metadata>`;
//Anonymous object
obj=new function(win)

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
<?
//Скрипт должен возвращять время в секундах когда умрёт сесия
//Скрипт работающий как AJAX в связке с javascript функцией 1 после загрузки выдать наименование сессионной переменной потом проверять на существование соответствующего файла в базе данных
//Проверить обновляется ли файлик сесии
//http://leopard.in.ua/2008/09/20/otslezhivanie-istecheniya-sroka-dejstviya-sessij/
//session_save_path('C:\ses');
require_once("../include/tools.php");
$host = $_SERVER['HTTP_HOST'];
$host = '.'.cutAfterLast($host,'.',2);
ini_set('session.cookie_domain', $host);
error_reporting(E_ALL);
if(isset($_GET['fn'])) $fn=$_GET['fn']; else $fn='';
if($fn=='0')
{
echo session_name();
exit;
}else
if($fn=='1')
{
@session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
echo session_id();
exit;
}else
if($fn=='2') //Вернуть время до смерти сесии в секундах
{
if(isset($_GET[session_name()])) $id=$_GET[session_name()]; else exit;
$sessionfile = ini_get('session.save_path') . DIRECTORY_SEPARATOR . 'sess_'.$id;
if ( file_exists($sessionfile) )
{
//echo ini_get('session.gc_maxlifetime') - (time() - filemtime($sessionfile));
echo '1'; //Чтоб только если файл удалился
}else echo '-1';
exit;
}else
{
echo 'error';
}

View File

@ -11,11 +11,10 @@ function setFilterVal(uid,id,c,p)
var SRec_mas = new Array(); //List of all objects "EdtRec" (then something better to think of)
class SRec extends TWin
class SRec
{
constructor(dialog,path)
constructor()
{
super(dialog,path);
this.win=null;
this.rwin=null;
@ -46,19 +45,14 @@ class SRec extends TWin
this.onUpdate=null; //For call set function
this.onInsert=null; //For call set function
//TODO сделать наследование из класса TWin
this.parent=null; //родительское окно
this.childs=new Array(); //Подчинёные окна
}
applyReq(req,fn,node,xmldoc)
{
this.hideProgressBar();
if(node.errorCode>0) {
alert2(trt('Alert'), node.errorMessage);
if(node.error_code>0) {
alert2(trt('Alert'), node.error_message);
return;
}
@ -156,34 +150,34 @@ class SRec extends TWin
create(htmlElement)
{
let str='\
<div id="eDiv'+this.uid+'" style="width: 100%; height: 100%; position: relative;">\
<table class="SFilter" style="width: 100%; height: 100%;"><tr><td>\
<table id="idfilter'+this.uid+'" cellspacing="2" cellpadding="0" style="border: 1px solid rgb(99, 99, 99); table-layout: auto;background-color: var(--row-color-2);" width="100%">\
<caption></caption><tbody></tbody>\
</table>\
</td></tr><tr><td>\
<table style="width:100%;"><tr><td><img src="../resources/metadata/dbms/images/rplus.png" alt="add" id="SRec_Add_'+this.uid+'" title="'+trt('Add_record')+'" style="cursor: pointer;"/></td>\
<td><img src="../resources/metadata/dbms/images/rdel.png" alt="del" id="SRec_Del_'+this.uid+'" title="'+trt('Delete_record')+'" style="cursor: pointer;"/></td>\
<td><img src="../resources/metadata/dbms/images/excel.png" alt="excel" id="SRec_Exc_'+this.uid+'" title="'+trt('Export_to_Excel')+'" style="cursor: pointer;"/></td>\
<td style="white-space: nowrap; padding-left: 10px;"><label style="display:none;"><input type="checkbox" id="Selection_'+this.uid+'" checked> '+trt('Selection_mode')+'</label></td>\
<td style="width: 99%;">&nbsp;</td>\
<td><img src="../resources/metadata/dbms/images/config.png" alt="'+trt('Settings')+'" id="SRec_Cnf_'+this.uid+'" title="'+trt('Settings')+'" style="cursor: pointer;"/></td>\
<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;">\
<table id="thetable'+this.uid+'" class="SShow">\
<caption></caption>\
<thead><tr><th></th></tr></thead>\
<tbody><tr><td></td></tr></tbody>\
</table>\
</div>\
</td></tr><tr><td>\
<center><table id="pages_'+this.uid+'"><tbody><tr><td>&nbsp;</td></tr></tbody></table></center>\
</td></tr></table>\
</div>\
';
let str=`
<div id="eDiv`+this.uid+`" style="width: 100%; height: 100%; position: relative;">
<table class="SFilter" style="width: 100%; height: 100%;"><tr><td>
<table id="idfilter`+this.uid+`" cellspacing="2" cellpadding="0" style="border: 1px solid rgb(99, 99, 99); table-layout: auto;background-color: var(--row-color-2);" width="100%">
<caption></caption><tbody></tbody>
</table>
</td></tr><tr><td>
<table style="width:100%;"><tr><td><img src="../resources/metadata/dbms/images/rplus.png" alt="add" id="SRec_Add_`+this.uid+`" title="`+trt('Add_record')+`" style="cursor: pointer;"/></td>
<td><img src="../resources/metadata/dbms/images/rdel.png" alt="del" id="SRec_Del_`+this.uid+`" title="`+trt('Delete_record')+`" style="cursor: pointer;"/></td>
<td><img src="../resources/metadata/dbms/images/excel.png" alt="excel" id="SRec_Exc_`+this.uid+`" title="`+trt('Export_to_Excel')+`" style="cursor: pointer;"/></td>
<td style="white-space: nowrap; padding-left: 10px;"><label style="display:none;"><input type="checkbox" id="Selection_`+this.uid+`" checked> `+trt('Selection_mode')+`</label></td>
<td style="width: 99%;">&nbsp;</td>
<td><img src="../resources/metadata/dbms/images/config.png" alt="`+trt('Settings')+`" id="SRec_Cnf_`+this.uid+`" title="`+trt('Settings')+`" style="cursor: pointer;"/></td>
<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;">
<table id="thetable`+this.uid+`" class="SShow">
<caption></caption>
<thead><tr><th></th></tr></thead>
<tbody><tr><td></td></tr></tbody>
</table>
</div>
</td></tr><tr><td>
<center><table id="pages_`+this.uid+`"><tbody><tr><td>&nbsp;</td></tr></tbody></table></center>
</td></tr></table>
</div>
`;
if(htmlElement==null || typeof(htmlElement) == "undefined")
{
@ -829,7 +823,7 @@ class SRec extends TWin
{
let input = document.createElement('input');
input.setAttribute("type","text");
button.classList.add('DBMS');
input.classList.add('DBMS');
input.style.cssText="width: 100%;";
input.onkeydown=(e)=>{ if(e==null) e=window.event; if(e.keyCode==13) { this.appendFilter(); this.sendFilter(-1,0); }};
input.setAttribute("name",columnNode.getAttribute("n"));
@ -1243,7 +1237,7 @@ class SRec extends TWin
let tr = document.createElement('tr');
tr.onmouseover=function(){ this.style.backgroundColor="var(--btn-color2)"; };
tr.onmouseout=function(val1,val2){return function(){val1.style.backgroundColor=val2;}}(tr,bgColor);
tr.setAttribute("id",''+id+'_'+this.uid);
tr.setAttribute("id",id+'_'+this.uid);
tr.style.backgroundColor=bgColor;
//sequential record number
@ -1287,7 +1281,7 @@ class SRec extends TWin
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].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)
@ -1449,11 +1443,10 @@ class SRec extends TWin
}
}
//Get column number by name, if result=-1 then not find else find
//Get column number by name
getColN(name){
let result=-1;
let i=-1;
//determine the sequence number of the column
let pos=0;
let node=findNodeOnPath(this.nodeMetadata,"type/objects-list");
let nodeCol = node.firstChild;
while (nodeCol != null)
@ -1461,14 +1454,13 @@ class SRec extends TWin
if(nodeCol.nodeName=="column")
{
if(nodeCol.getAttribute("n")==name){
result=pos;
break;
}
pos++;
i++;
}
nodeCol = nodeCol.nextSibling;
}
return result;
return i;
}
//find the value in the result set by the id of the record and the name of the column
@ -1479,7 +1471,7 @@ class SRec extends TWin
let pos=this.getColN(col);
if(pos>=0){
for(let i=0;i<this.f_nodeData.data.length;i++){
if(this.f_nodeData.data[i].id==id){
if(this.f_nodeData.data[i].id=id){
return this.f_nodeData.data[i].row[pos];
}
}

View File

@ -3,13 +3,6 @@
//var g_translations = {'':''};
function removeChild(parent){
if(parent==null) return;
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
}
//Массив g_translations подгружается отдельно
function trt(key)
{
@ -133,8 +126,8 @@ function MMove(e)
let obj=document.getElementById("pBarIco");
if(obj!=null)
{
obj.style.left=(pageX+10)+'px';
obj.style.top=(pageY-20)+'px';
obj.style.left=(pageX+15)+'px';
obj.style.top=(pageY)+'px';
}
}
document.onmousemove = MMove;
@ -205,9 +198,11 @@ function showProgressBarIco()
let img=document.createElement("img");
img.id='pBarIco';
img.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1000;';
img.style.left=(pageX+10)+'px';
img.style.top=(pageY-20)+'px';
img.src = "../resources/images/loader3.gif";
img.style.left=(pageX+15)+'px';
img.style.top=(pageY)+'px';
img.style.width = "32px";
img.style.height = "32px";
img.src = "../resources/images/loader3.svg";
document.body.appendChild(img);
}
cntShPrBICnt++;
@ -336,20 +331,20 @@ function confirm2(title,smallText,fullText,okFunc,cancelFunc)
let win=new TWin();
win.BuildGUI(10,10);
win.setCaption(document.createTextNode(title));
let html='\n\
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">\n\
<tr id="smallText_'+win.uid+'" style="width: 100%;">\n\
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">'+smallText+'</td>\n\
</tr>\n\
<tr id="fullText_'+win.uid+'" style="width: 100%; display: none;">\n\
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">'+fullText+'</td>\n\
</tr>\n\
<tr style="height: 10px;">\n\
<td style="width: 100%;">'+(fullText === undefined || fullText == '' ? '' : '<label><input type="checkbox" id="show_'+win.uid+'" name="scales"> '+trt('Full_text')+'</label>')+'&nbsp;</td>\n\
<td><button class="button-secondary" id="'+win.uid+'_ok" style="width: 80px;margin:1px;">'+trt('Ok')+'</button></td>\n\
\<td><button class="button-secondary" id="'+win.uid+'_cancel" style="width: 80px;margin:1px;">'+trt('Cancel')+'</button></td>\n\
</tr>\n\
</table>';
let html=`
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">
<tr id="smallText_`+win.uid+`" style="width: 100%;">
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">`+smallText+`</td>
</tr>
<tr id="fullText_`+win.uid+`" style="width: 100%; display: none;">
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">`+fullText+`</td>
</tr>
<tr style="height: 10px;">
<td style="width: 100%;">`+(fullText === undefined || fullText == '' ? '' : '<label><input type="checkbox" id="show_'+win.uid+'" name="scales"> '+trt('Full_text')+'</label>')+`&nbsp;</td>
<td><button class="button-secondary" id="`+win.uid+`_ok" style="width: 80px;margin:1px;">`+trt('Ok')+`</button></td>
<td><button class="button-secondary" id="`+win.uid+`_cancel" style="width: 80px;margin:1px;">`+trt('Cancel')+`</button></td>
</tr>
</table>`;
win.setContent(html);
@ -398,23 +393,23 @@ function prompt2(title,smallText,fieldText,defaultText,okFunc,cancelFunc){
let win=new TWin();
win.BuildGUI(10,10);
win.setCaption(document.createTextNode(title));
let html='\n\
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">\n\
<tr style="width: 100%;">\n\
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">'+smallText+'</td>\n\
</tr>\n\
<tr style="width: 100%;">\n\
<td colspan="3" style="width: 100%;">'+fieldText+'</td>\n\
</tr>\n\
<tr style="width: 100%;">\n\
<td colspan="3" style="width: 100%;"><textarea rows="5" style="width: 100%;" id="text_'+win.uid+'">'+defaultText+'</textarea></td>\n\
</tr>\n\
<tr style="height: 10px;">\n\
<td style="width: 100%;">&nbsp;</td>\n\
<td><button class="button-secondary" id="'+win.uid+'_ok" style="width: 80px;margin:1px;">'+trt('Ok')+'</button></td>\n\
<td><button class="button-secondary" id="'+win.uid+'_cancel" style="width: 80px;margin:1px;">'+trt('Cancel')+'</button></td>\n\
</tr>\n\
</table>';
let html=`
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">
<tr style="width: 100%;">
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">`+smallText+`</td>
</tr>
<tr style="width: 100%;">
<td colspan="3" style="width: 100%;">`+fieldText+`</td>
</tr>
<tr style="width: 100%;">
<td colspan="3" style="width: 100%;"><textarea rows="5" style="width: 100%;" id="text_`+win.uid+`">`+defaultText+`</textarea></td>
</tr>
<tr style="height: 10px;">
<td style="width: 100%;">&nbsp;</td>
<td><button class="button-secondary" id="`+win.uid+`_ok" style="width: 80px;margin:1px;">`+trt('Ok')+`</button></td>
<td><button class="button-secondary" id="`+win.uid+`_cancel" style="width: 80px;margin:1px;">`+trt('Cancel')+`</button></td>
</tr>
</table>`;
win.setContent(html);
@ -638,7 +633,7 @@ function getCookie(c_name)
//expires - Сколько дней хранить куки
//path - Путь куда разрешено пересылать куки (по умолчанию текущий)
function setCookie(name, value, expires, path, domain, secure)
function setCookie (name, value, expires, path, domain, secure)
{
let exDate=new Date();
exDate.setDate(exDate.getDate() + expires);
@ -648,8 +643,8 @@ function setCookie(name, value, expires, path, domain, secure)
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "") +
"; SameSite=Strict";
((secure) ? "; secure" : "");
document.cookie = str;
}
@ -1208,7 +1203,7 @@ class TRequest
{
if(typeof(xmlHttpRequest.status)=='undefined' || xmlHttpRequest.status == 200)
{
//console.log()
//console.log(JSON.stringify(xmlHttpRequest));
if(xmlHttpRequest.responseXML!=null) {
//if(typeof(xmlHttpRequest.responseXML)=='undefined' && xmlHttpRequest.contentType.match(/\/xml/)) //For IE XDomainRequest
// xmlHttpRequest.responseXML=CreateXMLDOC(xmlHttpRequest.responseText);
@ -1368,494 +1363,6 @@ class myXMLHttpRequest
}
}
//Класс окна
class TWin
{
constructor(dialog,path)
{
this.uid=getUID(); //Уникальныйидентификатор
this.dialog=dialog; //Показывать окно как диалог (без возможности изменения размеров)
if(typeof path !== 'undefined')
this.path=path;
else
this.path='../resources';
this.disableClosing=false;
this.closed=false; //Закрыли (те. удалили из родителя и детей и из DOM)
this.onClose=null; //слушатель закрытия окна
this.childs=new Array(); //Подчинёные окна
this.parent=null; //родительское окно
this.name="TWin";
this.tWinId=0;
this.dx=0;
this.dy=0;
this.sel=false;
this.obj=null; //user data
this.div=document.createElement('div'); //Окно
this.divsh=document.createElement('div'); //Тень для модального окна
this.tbl=null;
this.h0=null;
this.ca=null;
this.co=null;
this.shadow = false; //Показывать ли тень вокруг окошка
this.pBarCnt=0; //Прогресс бар
this.pBarDiv=null; //Прогресс бар
this.fnResizeListener=null;
}
addResizeListener(func)
{
this.fnResizeListener=func;
this.fnResizeListener();
}
onResize(x,y)
{
let win=this;
return function(e){
if(!e) e = window.event;
win.dx=e.pageX || e.x
win.dy=e.pageY || e.y
document.onmousedown = function() {
if(win.fnResizeListener!=null) win.fnResizeListener();
return false;
};
document.onmousemove = function(e) {
if(!e) e = window.event;
let x2 = e.pageX || e.x;
let y2 = e.pageY || e.y;
let w=parseInt(win.div.style.width)-(win.dx-x2)*x;
let h=parseInt(win.div.style.height)-(win.dy-y2)*y;
if(w<0)w=0;
if(h<0)h=0;
win.setWidth(w+"px");
win.setHeight(h+"px");
if(x<0)win.div.style.left=parseInt(win.div.style.left)-(win.dx-x2)+"px";
if(y<0)win.div.style.top=parseInt(win.div.style.top)-(win.dy-y2)+"px";
win.dx=x2;
win.dy=y2;
if(win.fnResizeListener!=null) win.fnResizeListener();
return false;
};
document.onmouseup = function() {
document.onmousedown = null;
document.onmousemove = MMove//null;
if(win.fnResizeListener!=null) win.fnResizeListener();
return false;
};
return false;
};
}
Close() //Закрыть и удалить окно из родителя и менеджера
{
if(this.disableClosing)
return;
//Переместил перед удалением компонент так как бывает нужно поработать с ними перед удалением
if(this.onClose!=null)
{
this.onClose();
}
this.hide(true);
this.setParent(null);
for(let i=0;i<this.childs.length;i++) if(this.childs[i]!=null) this.childs[i].parent=null
//??? зачем коментил (пояснение не понятное)? раскоментил потому что после пересоздания формы HTML id сохранялись (Вот непонятный комент: Закоментил потому что в магазине могут закрыть окно а оно больше не появится...)
if(this.div.parentNode!=null) this.div.parentNode.removeChild(this.div);
if(this.divsh.parentNode!=null) this.divsh.parentNode.removeChild(this.divsh);
this.closed=true;
};
//Типа конструктор создать окно с заданой позицией
BuildGUI(x,y)
{
this.tWinId=Wins.add(this);
/*
let hd='';
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 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%">&nbsp;</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>';
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>';
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/close.gif" alt="X" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false" id="TWin_CL_'+this.tWinId+'"/></td>';
hd+=' <td style="vertical-align:bottom;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
hd+=' </tr>';
hd+='</table>';
let str='';
str+='<table id="TWin_TBL_'+this.tWinId+'" border="0px" style="width: 100%; height: 100%;">';
str+=' <tr id="TWin_H0_'+this.tWinId+'"><td colspan=3>'+hd+'</td></tr>';
str+=' <tr>';
str+=' <td style="width: 10px; height: 10px; cursor:nw-resize;"><img src="'+this.path+'/metadata/dbms/form/_t-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false" id="TWin_TL_'+this.tWinId+'"></td>';
str+=' <td style="vertical-align:top; height: 10px; cursor:n-resize;" background="'+this.path+'/metadata/dbms/form/t.gif" id="TWin_T_'+this.tWinId+'"></td>';
str+=' <td style="width: 10px; height: 10px; cursor:ne-resize;" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+=' <tr style="height: 100%">';
str+=' <td style="vertical-align:top;height: 10px; cursor:w-resize;" background="'+this.path+'/metadata/dbms/form/l.gif" id="TWin_L_'+this.tWinId+'"></td>';
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;">&nbsp;</td></tr></table></td>';
str+=' <td style="vertical-align: top; height: 10px; cursor:e-resize;" background="'+this.path+'/metadata/dbms/form/r.gif" id="TWin_R_'+this.tWinId+'"></td>';
str+=' </tr>';
str+=' <tr>';
str+=' <td style="width: 10px; height: 10px; cursor:sw-resize;" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
str+=' <td style="vertical-align: top; height: 10px; cursor:s-resize;" background="'+this.path+'/metadata/dbms/form/b.gif" id="TWin_B_'+this.tWinId+'"></td>';
str+=' <td style="width: 10px; height: 10px; cursor:se-resize;" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+='</table>';
*/
/*
let str='';
str+='<table id="TWin_TBL_'+this.tWinId+'" class="TWin">';
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="border-bottom: 1px solid #b3b3b3;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/form/x.gif" id="TWin_CL_'+this.tWinId+'" style="cursor:pointer;"></td></tr></table></td><td></td></tr>';
str+=' <tr>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' <td style="vertical-align: top; height: 5px;'+(!this.dialog ? ' cursor: n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+=' <tr style="height: 100%">';
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
str+=' <td style="vertical-align:top; cursor: default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
str+=' </tr>';
str+=' <tr>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor: s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+='</table>';
*/
let str='';
str+='<table id="TWin_TBL_'+this.tWinId+'" class="DBMSShadow" style="width: 100%; height: 100%; border: 1px solid #000000;">';
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="background: var(--path-grad) repeat-x;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;">'+(this.disableClosing ? '' : '<div id="TWin_CL_'+this.tWinId+'" style="display: inline-block; width: 10px; height: 10px; background-image: var(--path-X); background-repeat: no-repeat; cursor:pointer;padding-right: 5px;"></div>')+'</td></tr></table></td><td></td></tr>';
str+=' <tr>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor:n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+=' <tr style="height: 100%">';
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
str+=' </tr>';
str+=' <tr>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' <td style="vertical-align:top; height: 5px;'+(!this.dialog ? ' cursor:s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
str+=' </tr>';
str+='</table>';
//создаём невидемую тень
this.divsh.style.cssText="display: none; position: fixed; top:0; left:0; height: 100%; width: 100%; background: rgba(0,0,0,0.3);";
this.divsh.onclick=function(win){return function(){ win.Close(); };}(this);
document.body.appendChild( this.divsh );
//Создаём родительский элемент для окна
this.div = document.createElement('div');
this.div.setAttribute("id","TWin_"+this.tWinId);
this.div.style.cssText="position:absolute; height:50px; width:640px;";
this.div.innerHTML=str;
document.body.appendChild( this.div );
this.tbl=document.getElementById('TWin_TBL_'+this.tWinId);
this.h0=document.getElementById('TWin_H0_'+this.tWinId);
this.co=document.getElementById('TWin_Co_'+this.tWinId);
this.ca=document.getElementById('TWin_Ca_'+this.tWinId);
this.setSel();
this.div.onmousedown=(e)=>this.setSel();
//Кнопка закрыть окно
let obj=document.getElementById('TWin_CL_'+this.tWinId);
if(obj!=null){
//obj.onclick=function(win){return function(){ win.Close(); };}(this);
obj.onclick=(function(){ this.Close(); }).bind(this);
}
if(!this.dialog)
{
document.getElementById('TWin_B_'+this.tWinId).onmousedown=this.onResize(0,1);
document.getElementById('TWin_T_'+this.tWinId).onmousedown=this.onResize(0,-1);
document.getElementById('TWin_BR_'+this.tWinId).onmousedown=this.onResize(1,1);
document.getElementById('TWin_TL_'+this.tWinId).onmousedown=this.onResize(-1,-1);
document.getElementById('TWin_BL_'+this.tWinId).onmousedown=this.onResize(-1,1);
document.getElementById('TWin_R_'+this.tWinId).onmousedown=this.onResize(1,0);
document.getElementById('TWin_L_'+this.tWinId).onmousedown=this.onResize(-1,0);
document.getElementById('TWin_TR_'+this.tWinId).onmousedown=this.onResize(1,-1);
}
this.setMove(document.getElementById('TWin_H0_'+this.tWinId));
//this.setMove(document.getElementById('TWin_H1_'+this.tWinId));
//this.setMove(document.getElementById('TWin_H2_'+this.tWinId));
//this.setMove(document.getElementById('TWin_H3_'+this.tWinId));
this.setLeftTop(x,y);
}
getCaption()
{
return document.getElementById('TWin_Ca_'+this.tWinId);
}
setCaption(val)
{
if(val==null) val='';
let obj=document.getElementById('TWin_Ca_'+this.tWinId);
if (typeof val === 'string' || val instanceof String)
obj.innerHTML=val;
else
obj.appendChild(val);
}
//Присвоить содержимое в виде строки
setContent(html)
{
let obj=document.getElementById('TWin_Co_'+this.tWinId);
if(obj!=null)
{
obj.innerHTML=html;
if(this.tbl.offsetHeight>this.div.offsetHeight) this.div.style.height=this.tbl.offsetHeight+"px";
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px";
}
}
//Выбрать (активизировать) окно
setSel()
{
for(let i=0;i<Wins.mas.length;i++) if(Wins.mas[i]!=null)
{
Wins.mas[i].sel=false;
Wins.mas[i].ca.style.color="var(--inactive-font-color)";
}
this.sel=true;
this.ca.style.color="var(--main-font-color)";
this.setWinZ(true);
}
//Получить значение Z индекса TODO сделать через геттер
getZ()
{
return parseInt(this.div.style.zIndex);
}
//Установить значение Z индекса TODO сделать через setter
setZ(z)
{
this.div.style.zIndex=z;
this.divsh.style.zIndex=z-1;
};
setMove(elm)
{
elm.onmousedown=function(win){
return function(event){
move_me(event,win);
};
}(this);
};
//В центр видимой части экрана
setCenter()
{
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
this.div.style.left=(scrollLeft+((document.documentElement.clientWidth || document.body.clientWidth)-parseInt(this.div.style.width))/2)+"px"
this.div.style.top=(scrollTop+((document.documentElement.clientHeight || document.body.clientHeight)-parseInt(this.div.style.height))/2)+"px"
if(parseInt(this.div.style.top)<0) this.div.style.top="1px";
if(parseInt(this.div.style.left)<0) this.div.style.left="1px";
};
setLeftTop(x,y)
{
this.div.style.left=x+"px"
if(y<0) y=0;this.div.style.top=y+"px"
};
setTop(y){if(y<0) y=0;this.div.style.top=y+"px"};
getTop(){return parseInt(this.div.style.top)};
getLeft(){return parseInt(this.div.style.left)};
setSize(w,h)
{
this.setWidth(w)
this.setHeight(h)
};
//Где w вида '100px' или '100%'
setWidth(w)
{ if(w==null || w=='') return;
w=''+w;
if(w.indexOf('px')<0 && w.indexOf('%')<0) w+='px'; //По умолчанию пиксели
this.div.style.width=w
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px"
};
getWidth(){
if(this.tbl!=null)
return parseInt(this.tbl.offsetWidth);
else
return 0;
};
setHeight(h)
{
if(h==null || h=='') return;
h=''+h;
if(h.indexOf('%')>-1) h=(this.div.parentNode.offsetHeight/100*parseInt(h));
this.co.style.height=(parseInt(h)-20-this.h0.offsetHeight)+"px";
this.div.style.height=parseInt(h)+'px';
if(this.tbl.offsetHeight>this.div.offsetHeight)
this.div.style.height=this.tbl.offsetHeight+"px";
};
//Подстроить размер окна по содержимому
/*adjustHeight()
{
}*/
//Подгрузить содержимое окна из указаного места
//json - объект который передастца в виде JSON строки по URL
//func - функция которая выполниться после загрузки данных в форму
load(url,json,func,tr)
{
this.showProgressBar();
var r=createRequestObject();
r.onreadystatechange = function(r,w,thiz,func)
{
return function(){
if(r.readyState == 4){
if(tr) w.innerHTML=trts(r.responseText);
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 );
if(json!=null)
r.send(JSON.stringify(json));
else
r.send();
};
//Переместить окно на передний план (Обычно при щелчке на нём)
setWinZ(s)
{
let i;
this.setZ(Wins.getMaxZ()+2); //+2 это для тени
if(s && this.parent!=null) //Переносим текущий элемент в 0й элемент массива детей родительского
{
var tmp=this.parent.childs[0];
for(i=1;i<this.parent.childs.length;i++)
{
if(tmp==this) break;
let t=this.parent.childs[i];
this.parent.childs[i]=tmp;
tmp=t;
}
this.parent.childs[0]=tmp;
}
for(i=this.childs.length;i>0;i--) if(this.childs[i-1]!=null) this.childs[i-1].setWinZ(false) //Забыл зачем это делаю
}
setParent(w)
{
if(this.parent!=null)
{
for(let i=0;i<this.parent.childs.length;i++) if(this.parent.childs[i]==this) this.parent.childs[i]=null;
}
if(typeof w !== 'undefined' && w!=null)
{
this.parent=w;
w.childs[w.childs.length]=this;
}
}
hide(val)
{
if(val)
{ this.div.style.display='none';
this.divsh.style.display='none';
}else
{
this.div.style.display='inline';
if(this.shadow) this.divsh.style.display='block';
}
}
//Показать прогрес бар
showProgressBar()
{
this.pBarCnt++;
if(this.pBarDiv==null)
{
var 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>';
//var eDiv=document.getElementById('eDiv'+this.uid);
this.div.appendChild(this.pBarDiv);
}
}
//Спрятать прогрес бар
hideProgressBar()
{
this.pBarCnt--;
if(this.pBarCnt<=0)
{
if(this.pBarDiv!==null) deleteHTML(this.pBarDiv);
this.pBarCnt=0;
this.pBarDiv=null;
}
}
}
class TWins
{
constructor()
{
this.mas = new Array();
}
add(win) //Добавить окно в список
{
this.mas.push(win);
return this.mas.length-1;
};
getMaxZ() //Получить максимальный Z индекс
{
var z=100; //По умолчанию
for(var i=0;i<this.mas.length;i++) if(this.mas[i]!==null && this.mas[i].getZ()>z) z=this.mas[i].getZ();
return z;
};
getSel() //Получить выделенное окно
{
for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i];
return null;
};
}
var Wins=new TWins(); //Global object
//список параметров (TODO для чего использую?)
class TSettings
{

View File

@ -1,68 +0,0 @@
<?php
@session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
//if(isset($_SESSION['REMOTE_ADDR']) && $_SESSION['REMOTE_ADDR'] != $_SERVER['REMOTE_ADDR']) unset($_SESSION["USER_ID"]); //Делаемся не авторизованным если зашли с другого ip адреса
if (isset($_REQUEST['id'])) $id = $_REQUEST['id']; else $id = '';
$width = 115; //Ширина изображения
$height = 40; //Высота изображения
$font_size = 14; //Размер шрифта
$let_amount = 5; //Количество символов, которые нужно набрать
$fon_let_amount = 40; //Количество символов, которые находятся на фоне
$path_fonts = getcwd().'/fonts/'; //Путь к шрифтам
//$letters = array('a','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','w','x','y','z','2','3','4','5','6','7','9');
$letters = array('0','1','2','3','4','5','6','7','8','9');
//$colors = array('100','200','150','170','190','210','190','160','170','190','210'); //для тёмного стиля
$colors = array('50','100','75','85','95','105','90','80','85','95','105'); //Для светлого стиля
$src = imagecreatetruecolor($width,$height);
//$fon = imagecolorallocate($src,58,58,58); //Для тёмного стиля
$fon = imagecolorallocate($src,241,241,241); //Для светлого стиля
imagefill($src,0,0,$fon);
$fonts = array();
$dir=opendir($path_fonts);
while($fontName = readdir($dir))
{
if($fontName != "." && $fontName != ".." && pathinfo($fontName, PATHINFO_EXTENSION)=='ttf')
{
$fonts[] = $fontName;
}
}
closedir($dir);
for($i=0;$i<$fon_let_amount;$i++)
{
$color = imagecolorallocatealpha($src,rand(0,255),rand(0,255),rand(0,255),100);
$font = $path_fonts.$fonts[rand(0,sizeof($fonts)-1)];
$letter = $letters[rand(0,sizeof($letters)-1)];
$size = rand($font_size-2,$font_size+2);
imagettftext(
$src,
$size,
rand(0,45),
rand((int)($width*0.1),(int)($width-$width*0.1)),
rand((int)($height*0.2),$height),
$color,
$font,
$letter
);
}
for($i=0;$i<$let_amount;$i++)
{
$color = imagecolorallocatealpha($src,$colors[rand(0,sizeof($colors)-1)],$colors[rand(0,sizeof($colors)-1)],$colors[rand(0,sizeof($colors)-1)],rand(20,40));
$font = $path_fonts.$fonts[rand(0,sizeof($fonts)-1)];
$letter = $letters[rand(0,sizeof($letters)-1)];
$size = rand((int)($font_size*2.1-2),(int)($font_size*2.1+2));
$x = (int)(($i+0.9)*$font_size + rand(4,7));
$y = (int)((($height*2.3)/3) + rand(0,5));
$cod[] = $letter;
imagettftext($src,$size,rand(0,15),$x,$y,$color,$font,$letter);
}
$_SESSION['secpic'.$id] = implode('',$cod);
header ("Content-type: image/gif");
imagegif($src);

View File

@ -1,25 +0,0 @@
<?php
//Для одностраничного приложения с AJAX запросами для определения времени жизни сесии
//$prolong==true для продления виртуальной сессии
function startSession($prolong=true)
{
$sessionLifetime = 3600; //В секундах (время жизни должно быть меньше чем session.gc_maxlifetime там значение по умолчанию: 1440/60=24 минутs (60*60=3600 то это час))
if (!@session_start()){
return false;
}
$t = time();
if(!isset($_SESSION['lastactivity']) || $prolong){
$_SESSION['lastactivity']=$t;
}
if ( $t-$_SESSION['lastactivity'] >= $sessionLifetime )
{
$t=$_SESSION['lastactivity'];
//session_unset(); Удалить все переменные сессии (устарела)
//$_SESSION = array();
session_reset(); // Удалить все переменные сессии
$_SESSION['lastactivity']=$t;
return false;
}
return true;
}

View File

@ -24,7 +24,7 @@ $(document).ready(function() {
var swfu = new SWFUpload(
{
upload_url : "upload.php",
upload_url : "upload.xyz",
flash_url : "swfupload.swf",
button_placeholder_id : "uploadButton",

View File

@ -1,514 +0,0 @@
<?php
// Из файла file.js делаем file_v123456789.js добавив время
function getScript($path)
{
if (file_exists($_SERVER['DOCUMENT_ROOT'].$path))
{
return '<script src="'.beforeLast($path,'.').'_v'.filectime($_SERVER['DOCUMENT_ROOT'].$path).'.'.afterLast($path,'.').'"></script>'."\n";
}
return '';
}
//Функция для перевода текста без применения GetText "trt("
function trt($text)
{
global $db,$Schema;
$result='';
$sql='select translation from '.$Schema.'_translations where del=false and language_id='.$_SESSION["LNG"].' and identifier=\''.$text.'\';';
//$sql='select translation from main._translations where del=false and language_id=(select id from main._languages where short_name=\''.$_SESSION["LNG"].'\') and identifier=\''.$text.'\';';
$res = NULL;
try
{
$res = $db->query($sql);
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res!=NULL && $res->rowCount()>0)
{
while ($row = $res->fetch(PDO::FETCH_NUM))
{
$result=$row[0];
}
}else
{
$result=str_replace("_", " ", $text);
}
return $result;
}
//Перевод для строки в которой встречаются подстроки вида: trt('')
function trts($text)
{
$result='';
$pLen=4; //Длина преамбулы trt(
$cut=0;
$from = 0; // Позиция поиска для итерации
while (true)
{
$pos1 = strpos($text, 'trt(', $from); //')
if($pos1 !== false)
{
$from = $pos1+$pLen+1;
$pos2 = false;
if($text[$pos1+$pLen] == '"') $pos2 = strpos($text, '")', $from);
if($text[$pos1+$pLen] == '\'') $pos2 = strpos($text, '\')', $from);
if($pos2 !== false)
{
$result.=substr($text, $cut, $pos1 - $cut );
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
$result.=trt($toTranslate);
$cut=$pos2+2;
$from = $pos2;
}
}else break;
}
$result.=substr($text, $cut); //Копируем остатки
return $result;
}
//Выбираю из текста ${конкретные} слова для перевода
function trs($text)
{
if(!$text) return '';
$pos1=0;
while(true)
{
$pos1 = strpos($text, '${',$pos1);
if($pos1 !== false)
{
$pos2 = strpos($text, '}', $pos1);
if($pos1 !== false)
{
$sub=substr($text,$pos1+2,$pos2-$pos1-2);
$text=substr($text,0, $pos1).trt($sub).substr($text,$pos2+1);
}else
{
break;
}
}else
{
break;
}
}
return $text;
}
//Получить разрешения для текущего пользователя
function getAccess($key)
{
global $db;
$result=false;
$sql="select main.p_getaccess(:user_id,:key) as acc;";
$stmt = $db->prepare($sql);
if(isset($_SESSION['USER_ID']))
$stmt->bindValue(':user_id', $_SESSION['USER_ID'], PDO::PARAM_INT);
else
$stmt->bindValue(':user_id', 0, PDO::PARAM_INT);
$stmt->bindValue(':key', $key, PDO::PARAM_STR);
$res=null;
try
{
$res=$stmt->execute();
}catch (Exception $e)
{
echo $e->getMessage();
}
if($res && $stmt->rowCount()>0)
{
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
$result=$row[0];
}
}
return $result;
}
function delPHPExt($fName)
{
$pos = strrpos($fName, '.')+1;
if(strtolower(substr($fName,$pos))=='php')
{
return substr($fName,0,$pos).'VIRUS';
}else {
return $fName;
}
}
function getURLText($url,$data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, trim($url));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_HEADER,0); //Change this to a 1 to return headers
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = trim(curl_exec($ch));
curl_close($ch);
return $data;
}
// array imageResize (string $src, string $dest, integer $width, integer $height);
// $src - имя исходного файла
// $dest - имя генерируемого файла
// $width, $height - максимальные ширина и высота генерируемого изображения
// возвращает массив (0=>$width, 1=>$height) с шириной и высотой получившегося изображения
function imageResize ($src, $dest, $width, $height)
{
if (!file_exists($src)) return false;
if (($size=getimagesize($src))===false) return false;
$format=strtolower(substr($size['mime'],strpos($size['mime'],'/')+1));
$icfunc='imagecreatefrom'.$format;
if (!function_exists($icfunc)) return false;
$x_ratio=$width/$size[0];
$y_ratio=$height/$size[1];
$ratio=min($x_ratio, $y_ratio);
$use_x_ratio=($x_ratio==$ratio);
$new_width=$use_x_ratio?$width:floor($size[0]*$ratio);
$new_height=!$use_x_ratio?$height:floor($size[1]*$ratio);
$new_left=$use_x_ratio?0:floor(($width-$new_width)/2);
$new_top=!$use_x_ratio?0:floor(($height-$new_height)/2);
$isrc=$icfunc($src);
$idest=imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($idest, $isrc, 0, 0, 0, 0, $new_width, $new_height, $size[0], $size[1]);
//Пишем в файл
if ($format=='jpeg') imagejpeg($idest, $dest, 70);
else if ($format=='gif') imagegif($idest, $dest);
else imagepng($idest, $dest, 7);
imagedestroy($isrc);
imagedestroy($idest);
return array($new_width, $new_height);
}
//Залить недостающие края заданным цветом (использую для фото без прозрачности для удобства в HTML верстке)
function imageFillBorder($src, $dest, $width, $height){
if (!file_exists($src)) return false;
if (($size=getimagesize($src))===false) return false;
$format=strtolower(substr($size['mime'],strpos($size['mime'],'/')+1));
// создание jpg изображения
if ($format=='jpeg')
{
if(!$oldImg = imagecreatefromjpeg($src))
{
error_log('Error imagecreatefromjpeg '.$_SERVER['REQUEST_URI']);
}
}else if ($format=='gif') $oldImg = imagecreatefromgif($src);
else $oldImg = imagecreatefrompng($src);
//Создаю новое изображение
$newImg=imagecreatetruecolor($width, $height);
$background_color = imagecolorallocate($newImg, 255, 255, 255);
imagefill($newImg, 0, 0, $background_color);
//Ищем центр
$x = ($width - imagesx($oldImg)) / 2;
$y = ($height - imagesy($oldImg)) / 2;
imagecopy($newImg, $oldImg, $x, $y, 0, 0, imagesx($oldImg), imagesy($oldImg));
//Пишем в файл
if ($format=='jpeg') imagejpeg($newImg,$dest);
else if ($format=='gif') imagegif($newImg,$dest);
else imagepng($newImg,$dest);
// освобождаем память
imagedestroy($oldImg);
imagedestroy($newImg);
}
//Водяной знак (размножит по поверхности одного изображения другое)
function watermark($src,$stm)
{
if (!file_exists($src) || !file_exists($stm)) return false;
if (($size=getimagesize($src))===false) return false;
$format=strtolower(substr($size['mime'],strpos($size['mime'],'/')+1));
// создание водяного знака в формате png
$watermark = imagecreatefrompng($stm);
// получаем ширину и высоту
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
// создание jpg изображения
if ($format=='jpeg')
{
if(!$image = imagecreatefromjpeg($src))
{
error_log('Error imagecreatefromjpeg '.$_SERVER['REQUEST_URI']);
}
}else if ($format=='gif') $image = imagecreatefromgif($src);
else $image = imagecreatefrompng($src);
//Выясняем количество повторов по оси X и по Y
$dx=ceil($size[0] / $watermark_width);
$dy=ceil($size[1] / $watermark_height);
imagealphablending($image, true);
imagealphablending($watermark, true);
// создаём новое изображение
for($y=0;$y<$dy;$y++)
for($x=0;$x<$dx;$x++)
imagecopy($image, $watermark, $x * $watermark_width, $y * $watermark_height, 0, 0, $watermark_width, $watermark_height);
//Пишем в файл
if ($format=='jpeg') imagejpeg($image,$src);
else if ($format=='gif') imagegif($image,$src);
else imagepng($image,$src);
// освобождаем память
imagedestroy($image);
imagedestroy($watermark);
}
//вернёт только цифры
function getInt($str)
{
$res='';
for($i=0;$i<strlen($str);$i++)
{
if($str[$i]=='-'||$str[$i]=='0'||$str[$i]=='1'||$str[$i]=='2'||$str[$i]=='3'||$str[$i]=='4'||$str[$i]=='5'||$str[$i]=='6'||$str[$i]=='7'||$str[$i]=='8'||$str[$i]=='9')
$res.=$str[$i];
}
return $res;
}
//вернёт только цифры
function getUInt($str)
{
$res='';
for($i=0;$i<strlen($str);$i++)
{
if($str[$i]=='0'||$str[$i]=='1'||$str[$i]=='2'||$str[$i]=='3'||$str[$i]=='4'||$str[$i]=='5'||$str[$i]=='6'||$str[$i]=='7'||$str[$i]=='8'||$str[$i]=='9')
$res.=$str[$i];
}
return $res;
}
//вернёт только цифры
function getPhoneNum($str)
{
$res='';
for($i=0;$i<strlen($str);$i++)
{
if($str[$i]=='+'||$str[$i]=='0'||$str[$i]=='1'||$str[$i]=='2'||$str[$i]=='3'||$str[$i]=='4'||$str[$i]=='5'||$str[$i]=='6'||$str[$i]=='7'||$str[$i]=='8'||$str[$i]=='9')
$res.=$str[$i];
}
return $res;
}
function translit($str)
{
$rus = array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я');
$lat = array('A', 'B', 'V', 'G', 'D', 'E', 'E', 'Gh', 'Z', 'I', 'Y', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Ch', 'Sh', 'Sch', 'Y', 'Y', 'Y', 'E', 'Yu', 'Ya', 'a', 'b', 'v', 'g', 'd', 'e', 'e', 'gh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', 'y', 'y', 'y', 'e', 'yu', 'ya');
return str_replace($rus, $lat, $str);
}
//Расширение файла транслитерованное в строчных буквах
function getExtension($fileName)
{
return strtolower(translit(substr($fileName, strrpos($fileName, '.') + 1)));
}
//Проверка емайла на валидность
function is_email($email)
{
if (function_exists("filter_var"))
{
$s=filter_var($email, FILTER_VALIDATE_EMAIL);
return !empty($s);
}
$p = '/^[a-z0-9!#$%&*+-=?^_`{|}~]+(\.[a-z0-9!#$%&*+-=?^_`{|}~]+)*';
$p.= '@([-a-z0-9]+\.)+([a-z]{2,3}';
$p.= '|info|arpa|aero|coop|name|museum|mobi)$/ix';
return preg_match($p, $email);
}
function deleteTempFiles($dir)
{
$time_sec=time(); // текущее время
if (is_dir($dir))
{
$dh = opendir($dir);
if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if($file == '..' || $file == '.') continue;
$time_file=filemtime($dir.$file); // время изменения файла
$time=$time_sec-$time_file; // тепрь узнаем сколько прошло времени (в секундах)
if($time>24*60*60) unlink($dir.$file);
}
closedir($dh);
}
}
}
function getFilesTree($dir,$cut="",$result = null){
if($result==null)
$result = new stdClass();
if (is_dir($dir))
{
$result->list = array();
$dh = opendir($dir);
if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if($file == '..' || $file == '.') continue;
if(is_dir($dir.DIRECTORY_SEPARATOR.$file)){
$sub = new stdClass();
$sub->name=$file;
$sub->path=$dir.DIRECTORY_SEPARATOR.$file;
if($cut) $sub->path = str_replace($cut, "",$sub->path);
array_push($result->list, $sub);
getFilesTree($dir.DIRECTORY_SEPARATOR.$file, $cut, $sub);
}else{
$sub = new stdClass();
$sub->name=$file;
$sub->path=$dir.DIRECTORY_SEPARATOR.$file;
if($cut) $sub->path = str_replace($cut, "",$sub->path);
array_push($result->list, $sub);
}
}
closedir($dh);
}
}
return $result;
}
//Генерация пароля
function getPassword($max)
{
$chars="qazxswedcvfrtgbnhyujmkiolp1234567890";
$size=StrLen($chars)-1;
$password='';
while($max--)
$password.=$chars[rand(0,$size)];
return $password;
}
//Полный путь к текущему URL включая http и название скрипта
function selfURL()
{
if(!isset($_SERVER['REQUEST_URI'])){ $suri = $_SERVER['PHP_SELF']; }
else { $suri = $_SERVER['REQUEST_URI']; }
$s = empty($_SERVER["HTTPS"]) ? '' : (($_SERVER["HTTPS"] == "on") ? "s" : "");
$sp=strtolower($_SERVER["SERVER_PROTOCOL"]);
$pr = substr($sp,0,strpos($sp,"/")).$s;
$pt = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $pr."://".$_SERVER['SERVER_NAME'].$pt.$suri;
}
//Путь без файла пример: http://truemisha.ru
function selfDomain()
{
//if(!isset($_SERVER['REQUEST_URI'])) $suri = $_SERVER['PHP_SELF'];
//else $suri = $_SERVER['REQUEST_URI'];
$s = empty($_SERVER["HTTPS"]) ? '' : (($_SERVER["HTTPS"] == "on") ? "s" : "");
$sp=strtolower($_SERVER["SERVER_PROTOCOL"]);
$pr = substr($sp,0,strpos($sp,"/")).$s;
$pt = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $pr."://".$_SERVER['SERVER_NAME'].$pt;//.$suri;
}
//Строка до последнего найденого символа если символа нет то всю строку
function beforeLast(&$str,$ch)
{
return substr($str, 0, strrpos($str, $ch));
}
//Строка после последнего найденого символа если символа нет то всю строку
function afterLast(&$str,$ch)
{
return substr($str, strrpos($str, $ch)+strlen($ch));
}
//Строка до первого попавшегося символа
function beforeFirst(&$str,$ch)
{
return substr($str, 0, strpos($str, $ch));
}
//Строка после первого попавшегося символа
function afterFirst(&$str,$ch)
{
return substr($str, strpos($str, $ch)+strlen($ch));
}
/**
* Вернёт подстроку если символа нет то всю строку
* @param string $str
* @param string $chr
* @return string Подстрока
*/
function cutStr(&$str,$chr)
{
$pos = strpos($str, $chr);
if($pos===false)
{
return $str;
}else
{
$buf = substr($str, 0, $pos);
$str = substr($str, $pos + strlen($chr));
return $buf;
}
}
//Вырезаеи всё после заданого разделителя удаляя разделитель если разделителя нет возвращает всю строку
//$fstr - Разделитель
//$num - На каком разделителе остановиться
function cutAfterLast(&$sstr,$fstr,$num = 1)
{
$sub='';
$pos=strlen($sstr);
for($i=0;$i<$num;$i++)
{
$pos = strripos($sstr, $fstr, $pos-strlen($sstr)-1);
if($pos === false) { break; }
}
if($pos === false)
{
$sub=$sstr;
$sstr='';
return $sub;
}else
{
$sub = substr( $sstr , $pos + strlen($fstr));
$sstr = substr( $sstr , 0, $pos);
return $sub;
}
}
//Зачем коментил?
//Отрезаем от строки всё до заданой подстроки если подстроки нет отрезается вся строка
function cutBeforeFirst(&$sstr,$fstr)
{
$sub='';
$pos = strpos($sstr, $fstr);
if($pos === false)
{
$sub=$sstr;
$sstr='';
return $sub;
}else
{
$sub = substr( $sstr , 0, $pos);
$sstr = substr( $sstr , $pos + strlen($fstr));
return $sub;
}
}

View File

@ -1,172 +0,0 @@
<?php
/**
* Вернуть строку по DOMNode
* @param DOMNode $node Узел XML
* @return string
*/
function getXML($node)
{
if($node==null) return '';
return $node->ownerDocument->saveXML($node);
}
/**
* Найти первый попавшийся узел с заданным именем nodeName.
* @param DOMNode $node Узел.
* @param string $nodename Название узла.
* @return DOMNode Найденный узел либо null.
*/
function findNode($node, $nodename)
{
if($node==null) return null;
$nextNode = $node->firstChild;
while ($nextNode != null)
{
if($nextNode->nodeName==$nodename)
{
return $nextNode;
}
$nextNode=$nextNode->nextSibling;
}
return null;
}
/**
* Найти первый попавшийся узел с заданным именем nodeName и атрибутом $attribute со значением $val.
* @param <type> $node
* @param <type> $nodename
* @param <type> $attribute
* @param <type> $val
* @return <type>
*/
function findNodeOnAttribute($node, $nodename,$attribute,$val)
{
if($node==null) return null;
$nextNode = $node->firstChild;
while ($nextNode != null)
{
if(($nextNode->nodeName==$nodename)&&($nextNode->getAttribute($attribute)==$val))
{
return $nextNode;
}
$nextNode=$nextNode->nextSibling;
}
return null;
}
/**
* Вернуть первый попавшийся узел среди всех дочерних (без рекурсии).
* @param XMLNode $node Родительский узел.
* @param String $nodename Название узла.
* @return XMLNode Найденный узел
*/
function findFirstNode($node, $nodename)
{
$mas=array();
$pos=0;
$mas[$pos] = $node->firstChild;
while ($mas[$pos])
{
if($mas[$pos]->nodeName==$nodename)
{
return $mas[$pos];
}
if($mas[$pos]->firstChild)
{
$pos++;
$mas[$pos]=$mas[$pos-1]->firstChild;
}else
{
//если не идёт дальше пытаемся подняться в верх по дереву
while (true)
{
$mas[$pos] = $mas[$pos]->nextSibling;
if (!$mas[$pos])
{
if($pos>0){ $pos--; }else{ break; }
}else
{
break;
}
}
}
}
return '';
}
//рекурсию не буду использовать, обойдусь массивом вложенности
function findFirstNodeOnAttribute($node, $nodename,$attribute,$val)
{
$mas=array();
$pos=0;
$mas[$pos] = $node->firstChild;
while ($mas[$pos])
{
if(($mas[$pos]->nodeName==$nodename)&&($mas[$pos]->getAttribute($attribute)==$val))
{
return $mas[$pos];
}
if($mas[$pos]->firstChild)
{
$pos++;
$mas[$pos]=$mas[$pos-1]->firstChild;
}else
{
//если не идёт дальше пытаемся подняться в верх по дереву
while (true)
{
$mas[$pos] = $mas[$pos]->nextSibling;
if (!$mas[$pos])
{
if($pos>0){ $pos--; }else{ break; }
}else
{
break;
}
}
}
}
return '';
}
//найти узелы по пути "node1->node2"
function findNodeOnPath($node, $path)
{
if($node==null) return null;
$params=explode("/",$path);
for($i=0;$i<count($params);$i++)
{
if($node==null) return null;
$node=findNode($node,$params[$i]);
}
return $node;
}
/**
* Вернёт первую CDATA секцию если её нет то создаст.
* @param DOMNode $node Узел XML.
* @return DOMCdataSection Узел CDATA либо null.
*/
function getCdata($node)
{
if($node==null) return null;
$result=findNode($node,'#cdata-section');
if($result==null)
{
$result=$node->ownerDocument->createCDATASection('');
$node->appendChild($result);
}
return $result;
}
/**
* Получить строку данных из первой попавшейся CDATA.
* @param DOMNode $node Узел XML.
* @return String Строка результата
*/
function getCdataValue($node)
{
$n=findNode($node,'#cdata-section');
if($n!=null)
{ return $n->nodeValue;
}
return '';
}

View File

@ -9,7 +9,7 @@
margin:0px;
padding:0px;
font-size: 14px;
font-family: Arial;
font-family: Open Sans,-apple-system,Segoe UI,system-ui,Roboto,Helvetica Neue,Arial;
text-align: left;
}
</style>
@ -18,7 +18,7 @@
<script>//<![CDATA[
function onloadpage()
{
tree=new TTree(document.getElementById("maintree"),"tr_","tree.php","./",24);
tree=new TTree(document.getElementById("maintree"),"tr_","tree.xyz","./",24);
tree.Start();
}
//]]></script>

View File

@ -11,7 +11,7 @@
//sleep(1); //Тестирование с задержкой
//require_once("../../config.php"); Должно быть обьявлено во внешнем файле
//require_once("../../config.xyz"); Должно быть обьявлено во внешнем файле
require_once("treetools.php");
/**

View File

@ -1,5 +1,5 @@
<?php
require_once("../../config.php");
require_once("../../config.xyz");
require_once("../include/xmltools.php");
$treexml='tree.xml';
require_once("tree.php");

View File

@ -9,7 +9,7 @@
//ini_set('max_execution_time',600);//устанавливаем время работы скрипта
require_once("../include/class_table.php");
require_once("../../config.php");
require_once("../../config.xyz");
try
{ $db = new PDO($db_connection, $db_login, $db_password);

View File

@ -11,7 +11,7 @@
require_once("../include/zip.lib.php");
require_once("../include/class_table.php");
require_once("../../config.php");
require_once("../../config.xyz");
function findFirstNode($node, $nodename)
{

View File

@ -3,7 +3,7 @@
//ini_set('max_execution_time',600);//устанавливаем время работы скрипта
require_once("../include/class_table.php");
require_once("../../config.php");
require_once("../../config.xyz");
try
{ $db = new PDO($db_connection, $db_login, $db_password);