# Conflicts:
#	metadata/dbms/records.php
This commit is contained in:
2022-08-31 01:04:11 +06:00
10 changed files with 279 additions and 96 deletions

View File

@ -1,4 +1,4 @@
//Copyright (C) Ivanov I.M. irigm@mail.ru +77051809750 file created in 2008
//Copyright (C) Ivanov I.M. file created in 2008
//For find non english chars: [^\x00-\x7F]+
//Заглушки
@ -1182,51 +1182,53 @@ class EdtRec
};
applyReq(req,fn,node,xmldoc,win)
{ //alert2(trt('Alert'),"erec XML=\n"+getXMLNodeSerialisation(node));
if (fn==-1)
{
alert2(trt('Alert'),findFirstNode(node,'#cdata-section').nodeValue);
//this.pBarCnt=0;
this.hideProgressBar();
}else
if (fn==0)
{
this.hideProgressBar();
{
this.hideProgressBar();
if (fn==-1) {
let fullText = findFirstNode(node,'#cdata-section').nodeValue;
let smallText = '';
let pos1=fullText.indexOf('[[');
let pos2=fullText.indexOf(']]');
if(pos1>0 && pos2>0 && pos1<pos2) smallText=fullText.substring(pos1+2, pos2);
if(fullText.indexOf("id456[[")>=0){ //Если есть идентификатор того что это перезапись
let okFunc=()=>{
this.setValue('seq',0);
this.sendData(); //Применить ещё раз
};
if (smallText != '')
confirm2(trt('Warning'),smallText, fullText, okFunc, null);
else
confirm2(trt('Warning'),smallText, '', okFunc, null);
}else {
if (smallText != '')
alert2(trt('Alert'), smallText, fullText);
else
alert2(trt('Alert'), fullText);
}
} else
if (fn==0) {
this.eRecNo(node,this.record_id);
}else
if (fn==1) //returned id
{
this.hideProgressBar();
} else
if (fn==1) { //returned id
this.insertRows(node);
}else
if (fn==2) //Returned id and type of updated record
{
this.hideProgressBar();
} else
if (fn==2) { //Returned id and type of updated record
this.updateRows(node);
}else
if (fn==3) //Returned id of deleted record
{
this.hideProgressBar();
} else
if (fn==3) { //Returned id of deleted record
this.deleteRows(node);
}else
if (fn==5)
{
this.hideProgressBar();
} else
if (fn==5) {
this.setData(node);
}else
if (fn==6) //Fill in the drop-down lists.
{
this.hideProgressBar();
} else
if (fn==6) { //Fill in the drop-down lists.
this.setDataSelect(node);
}else
if (fn==7) //
{
this.hideProgressBar();
} else
if (fn==7) {
this.setData(node);
}else
{
} else {
alert2(trt('Alert'),"Unknown function! fn=\""+fn+"\"" );
this.hideProgressBar();
}
};
/**
@ -1359,8 +1361,6 @@ class EdtRec
{
if(nodeProp.getAttribute("selector")=="combo")
{
//console.log("++++++++++field.options.length = "+field.options.length);
//We sort out the elements of the list (options) and set it to the desired value (the snake is not automatically exposed by the automaton).
for(let i=0;i<field.options.length;i++)
{
@ -1518,7 +1518,7 @@ class EdtRec
let readd=document.getElementById("readd_"+this.uid);
if(readd!==null && readd.checked){
confirm2(trt('Warning'),trt("Successfully_added_data")+"<br>"+trt("Add_more")+"?",null,()=>this.win.Close());
confirm2(trt('Warning'),trt("Successfully_added_data")+"<br>"+trt("Add_more")+"?",'',null,()=>this.win.Close());
}else
{
this.win.Close();

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -11,6 +11,7 @@ class DBMSUser
this.role='';
this.m_ls=new Array(); //Listeners called OnLogin function.
this.divsh = null;
//Запрашиваю данные о текущем пользователе с сервера
//this.LoadData();
}
@ -162,10 +163,46 @@ class DBMSUser
}
};
showLock(visible) {
if(this.divsh==null) {
this.divsh = document.createElement('div'); //Shadow
this.divsh.style.cssText = "display: none; position: fixed; z-index: 1000; top:0; left:0; height: 100%; width: 100%; background: rgba(0,0,0,0.3);";
document.body.append(this.divsh);
}
if(!visible)
this.divsh.style.display='none';
else
this.divsh.style.display='block';
}
//Checking the session without its extension, if it is completed, we display the authorization window.
checkSession()
{
$.getJSON('../session',{},(data)=>{if(data.result=='ERROR'){this.showLoginForm();}});
$.ajax({
url: '../session',
data: "{}",
type: "POST",
dataType: "json",
success: (data,status) => {
if(status=='success')
{
if(data.result=='ERROR'){
this.showLoginForm();
}else
if(data.result=='OK'){
this.id=data.user_id;
}
this.showLock(false);
}else
{
this.showLock(true);
}
},
error: (jqXHR, exception)=>
{
this.showLock(true);
}
});
setTimeout(()=>this.checkSession(), 10000);
};
@ -280,27 +317,22 @@ class DBMSUser
xmlHttpRequest.responseXML=CreateXMLDOC(xmlHttpRequest.responseText);
//загрузился xml документ начинаем его разбирать (по id функции в документе)
var xmldoc = xmlHttpRequest.responseXML
let xmldoc = xmlHttpRequest.responseXML
if(xmldoc==null) {
alert2(trt('Alert'), trt('Wrong_XML_document') + "!\n" + xmlHttpRequest.responseText);
return;
}
var node = xmldoc.documentElement;
if((node==null)||(node.getAttribute("fn")==null)) alert(trt('Error')+"\n "+trt("No_data")+"!\n"+xmlHttpRequest.responseText);
else
{
//alert("Принятый браузером XML=\n"+getXMLNodeSerialisation(node));
var fn = node.getAttribute("fn");
if (fn==-1)
{
alert(findFirstNode(node,'#cdata-section').nodeValue);
this.win.hideProgressBar();
}else
if(fn==7)
{
alert(findFirstNode(node,'#cdata-section').nodeValue);
this.win.Close();
}else {
var node = xmldoc.documentElement;
if ((node == null) || (node.getAttribute("fn") == null)) alert(trt('Error') + "\n " + trt("No_data") + "!\n" + xmlHttpRequest.responseText);
else {
//alert("Принятый браузером XML=\n"+getXMLNodeSerialisation(node));
var fn = node.getAttribute("fn");
if (fn == -1) {
alert(findFirstNode(node, '#cdata-section').nodeValue);
this.win.hideProgressBar();
} else if (fn == 7) {
alert(findFirstNode(node, '#cdata-section').nodeValue);
this.win.Close();
}
}
}
}else

View File

@ -435,7 +435,8 @@
}
$xmlstring='<?xml version="1.0" encoding="utf-8"?><metadata fn="1"><type n="'.$typename.'" id="'.$result[0].'"></type></metadata>';
header('Content-type: text/xml');
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xmlstring;
Exit();
}else
@ -544,7 +545,8 @@
$result = $stmt->fetch(PDO::FETCH_NUM); //$obj_id
if($result[0]==''){ $result[0]=$obj_id; }
$xmlstring='<?xml version="1.0" encoding="utf-8"?><metadata fn="2"><type n="'.$typename.'" id="'.$result[0].'"></type></metadata>';
header('Content-type: text/xml');
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xmlstring;
Exit();
}else
@ -582,7 +584,8 @@
$xmlstring.='<metadata fn="3">';
$xmlstring.=" <type n=\"".$typename."\" id=\"".$obj_id."\"></type>\n";
$xmlstring.="</metadata>\n";
header('Content-type: text/xml');
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xmlstring;
Exit();
}else
@ -926,11 +929,62 @@
if($cmd==0) //Restore password by email
{
$res = $db->query("select 1 from '.$Schema.'_Users where del=false and email = '$login';");
$recovery=false;
$res = $db->query("select email from ".$Schema."_Users where del=false and (email = '$login' or login = '$login');");
if($res->rowCount()>0)
{
mail($login,'pal.kz','Not implement',"Content-type: text/html; charset=utf-8\r\nFrom: smartpal Site <info@pal.kz>");
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
/*$pos++;
if (($pagepos!=-1)&&(($pos<($pagepos*$rowspagecount))||($pos>=$pagepos*$rowspagecount+$rowspagecount))) { continue; }
//разрешать или запрещять редактировать запись надо проверять в хранимке а также запрещять либо разрешать редактировать колонку
//для каждой записи формируеться строка настроек со значениями что нужно запретить в таком виде "iuds"
//$access=$row["access"];
$access=''; //u = enable update field, d = enable delete field
if(!array_key_exists("_u",$row)) { $access.="u"; } else { $access.=$row["email"]; }*/
$password = getPassword(6);
$sql = 'update ' . $Schema . '_users set password=md5(:password) where email=:email';
$stmt = $db->prepare($sql);
$stmt->bindValue(':password', $password, PDO::PARAM_STR);
$stmt->bindValue(':email', $row["email"], PDO::PARAM_STR);
try {
$stmt->execute();
if ($stmt->rowCount() > 0) {
//$result = $stmt->fetch(PDO::FETCH_NUM);
$recovery = true;
}
} catch (Exception $e) {
$db->rollBack();
sendError(1, $e->getMessage());
}
$html = '<html><head><title>Message</title></head><body>';
$html .= '<h1>New password:</h1>';
$html .= '<b>' . $password . '</b>';
$html .= '</body></html>';
//mail($login,'rigor.kz','Not implement',"Content-type: text/html; charset=utf-8\r\nFrom: rigor Site <info@rigor.kz>");
if (!mail($login, 'Password for transit.istt.kz', $html, "Content-type: text/html; charset=utf-8\r\nFrom: Transit Site <no-reply@istt.kz>")) {
sendError("Failed to send mail to: " . $row["email"]);
}
}
}
if($recovery) {
$xs = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$xs .= '<metadata fn="7"><![CDATA[OK]]></metadata>';
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xs;
exit();
}else{
$xs = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$xs .= '<metadata fn="7"><![CDATA[ERROR]]></metadata>';
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xs;
exit();
}
}elseif($cmd==1) //Logout
{
$sql='delete from '.$Schema.'_Logins where sessionid='.getSQLValue('string',$_COOKIE['GUID']).' and user_id='.getSQLValue('object',$_SESSION['USER_ID']).';';
@ -941,21 +995,17 @@
}
unset($_SESSION['USER_ID']);
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
$xs='<?xml version="1.0" encoding="utf-8"?>'."\n";
$xs.='<metadata fn="7">'."\n";
$xs.=' <cmd><![CDATA['.$cmd.']]></cmd><login><![CDATA[0]]></login><sesid><![CDATA['.session_id().']]></sesid><sesname><![CDATA['.session_name().']]></sesname>'."\n";
$xs.='</metadata>';
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xs;
exit();
}elseif($cmd==2) //Проверить залогинен ли пользователь
{
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
$xs='<?xml version="1.0" encoding="utf-8"?>'."\n";
$xs.='<metadata fn="7">'."\n";
if(!isset($_SESSION['USER_ID']) || $_SESSION['USER_ID']=='')
@ -975,6 +1025,8 @@
}
$xs.='</metadata>';
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xs;
exit();
@ -996,8 +1048,6 @@
$patronymic=$result['patronymic'];
}
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
$xs='<?xml version="1.0" encoding="utf-8"?>'."\n";
$xs.='<metadata fn="7">'."\n";
$xs.='<![CDATA['.$ans.']]>';
@ -1007,6 +1057,8 @@
$xs.=' <sesid><![CDATA['.session_id().']]></sesid>'."\n";
$xs.=' <sesname><![CDATA['.session_name().']]></sesname>'."\n";
$xs.='</metadata>';
header('Content-type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo $xs;
exit();
}else{

View File

@ -2,3 +2,4 @@
//var ScriptDName='../download';
//var ScriptUName='../upload';
//var ScriptRName='../reports'; //GET For download reports (?file=name)
//var ScriptSName='../session';

View File

@ -1,4 +1,4 @@
//Copyright (C) 2008 Ivanov I.M. irigm@mail.ru +77051809750
//Copyright (C) 2008 Ivanov I.M. ivanov.i@istt.kz
//For find non english chars: [^\x00-\x7F]+
function callWindow(uid,id,i)
@ -50,9 +50,29 @@ class SRec
this.hideProgressBar();
this.xmldoc=node.ownerDocument; //xmldoc;
if (fn==-1) //Information menu
if (fn==-1) //Information alert
{
alert2(trt('Alert'),findFirstNode(node,'#cdata-section').nodeValue);
let fullText = findFirstNode(node,'#cdata-section').nodeValue;
let smallText = '';
let pos1=fullText.indexOf('[[');
let pos2=fullText.indexOf(']]');
if(pos1>0 && pos2>0 && pos1<pos2) smallText=fullText.substring(pos1+2, pos2);
if(fullText.indexOf("id456[[")>=0){ //Если есть идентификатор того что это перезапись
let okFunc=()=>{
this.setValue('seq',0);
this.sendData(); //Применить ещё раз
};
if (smallText != '')
confirm2(trt('Warning'),smallText, fullText, okFunc, null);
else
confirm2(trt('Warning'),smallText, '', okFunc, null);
}else {
if (smallText != '')
alert2(trt('Alert'), smallText, fullText);
else
alert2(trt('Alert'), fullText);
}
}else
if (fn==0)
{
@ -1608,7 +1628,7 @@ class SRec
//We run through the marked records and request their removal
deleteRecord(recordid)
{
confirm2(trt('Warning'),trt("Are_you_sure_you_want_to_delete_the_entries")+"<br>"
confirm2(trt('Warning'),trt("Are_you_sure_you_want_to_delete_the_entries")+"<br>",''
,()=>{
for(let i=0;i<this.masChBox.length;i++)
{

View File

@ -86,6 +86,7 @@ class tcTab
this.par=null;
this.sel=false;
this.con=null; //Элемент с содержимым
this.display = 'block'; //Для сохранения старого значения
this.href='';
//Сам таб на который нажимаем (ушко)
@ -116,6 +117,9 @@ class tcTab
val=document.getElementById(val);
if(val===null || typeof(val)=='undefined') return;
this.con=val;
this.display = this.con.style.display;
if(!this.sel) this.con.style.display='none';
this.par.ctt.appendChild(this.con);
return val;
@ -131,8 +135,7 @@ class tcTab
}
this.div.style.background = 'var(--row-color-2)';
this.div.style.borderBottom = '1px solid var(--back-color)'
//this.con.style.display='inline'
this.con.style.display='block';
this.con.style.display = this.display; //this.con.style.display='block'; //this.con.style.display='inline'
this.sel=true
}
}

View File

@ -191,24 +191,45 @@ function loadContent(url,obj)
}
//Вывести текст поверх окон с кнопочкой OK
function alert2(title,text,okFunc=null)
function alert2(title,smallText,fullText,okFunc=null)
{
if(smallText === undefined || smallText==''){
smallText=fullText;
fullText='';
}
let win=new TWin(true);
win.BuildGUI(10,10);
win.setCaption(document.createTextNode(title));
let html='\n\
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">\n\
<tr>\n\
<td colspan="2" style="text-align: center; vertical-align: middle;">'+text+'</td>\n\
<tr id="smallText_'+win.uid+'">\n\
<td colspan="2" style="text-align: center; vertical-align: middle;">'+smallText+'</td>\n\
</tr>\n\
<tr id="fullText_'+win.uid+'" style="display: none;">\n\
<td colspan="2" style="text-align: center; vertical-align: middle;">'+fullText+'</td>\n\
</tr>\n\
<tr style="width: 100%;height: 10px;">\n\
<td>&nbsp;</td>\n\
<td style="width: 80px;"><button class="button-secondary" id="'+win.uid+'_close" style="width: 100%;">'+trt('OK')+'</button></td>\n\
<td>'+(fullText === undefined || fullText == '' ? '' : '<label><input type="checkbox" id="show_'+win.uid+'" name="scales"> '+trt('Full_text')+'</label>')+'&nbsp;</td>\n\
<td style="width: 80px;"><button class="button-secondary" id="close_'+win.uid+'" style="width: 100%;">'+trt('OK')+'</button></td>\n\
</tr>\n\
</table>';
win.setContent(html);
let obj=document.getElementById(win.uid+'_close');
let obj=document.getElementById('show_'+win.uid);
if(obj!=null) obj.onclick=function(win){
return function(){
if(document.getElementById('show_'+win.uid).checked) {
document.getElementById('smallText_' + win.uid).style.display = "none";
document.getElementById('fullText_' + win.uid).style.display = "table-row";
}else{
document.getElementById('smallText_' + win.uid).style.display = "table-row";
document.getElementById('fullText_' + win.uid).style.display = "none";
}
};
}(win);
obj=document.getElementById('close_'+win.uid);
obj.focus();
if(obj!=null) obj.onclick=function(win,okFunc){return function(){ win.Close(); if(okFunc!=null) okFunc(); };}(win,okFunc);
win.setSize("300px","150px");
@ -219,24 +240,41 @@ function alert2(title,text,okFunc=null)
}
//Вывести текст поверх окон с кнопочкой OK
function confirm2(title,text,okFunc,cancelFunc)
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 style="width: 100%;">\n\
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">'+text+'</td>\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%;">&nbsp;</td>\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>';
win.setContent(html);
let obj=document.getElementById('show_'+win.uid);
if(obj!=null) obj.onclick=function(win){
return function(){
if(document.getElementById('show_'+win.uid).checked) {
document.getElementById('smallText_' + win.uid).style.display = "none";
document.getElementById('fullText_' + win.uid).style.display = "table-row";
}else{
document.getElementById('smallText_' + win.uid).style.display = "table-row";
document.getElementById('fullText_' + win.uid).style.display = "none";
}
};
}(win);
let btnO=document.getElementById(win.uid+'_ok');
btnO.focus();
if(btnO!=null){
@ -1293,7 +1331,7 @@ class TWin
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); cursor:pointer;padding-right: 5px;"></div>')+'</td></tr></table></td><td></td></tr>';
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>';
@ -1527,9 +1565,9 @@ class TWin
{
if(this.parent!=null)
{
for(var i=0;i<this.parent.childs.length;i++) if(this.parent.childs[i]==this) this.parent.childs[i]=null;
for(let i=0;i<this.parent.childs.length;i++) if(this.parent.childs[i]==this) this.parent.childs[i]=null;
}
if(w!=null)
if(typeof w !== 'undefined' && w!=null)
{
this.parent=w;
w.childs[w.childs.length]=this;

View File

@ -18,7 +18,7 @@ class BolmerCMS{
if ( ! self::$authenticated) {
define('BOLMER_API_MODE', true);
define('IN_MANAGER_MODE', true);
$init = realpath(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))."/index.php");
$init = realpath(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))."/login.php");
include_once($init);
$type = getService('user', true)->getLoginUserType();
if($type=='manager'){

View File

@ -352,6 +352,43 @@ function deleteTempFiles($dir)
}
}
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)
{