diff --git a/metadata/dbms/editrecord.js b/metadata/dbms/editrecord.js index 259d376..caf0f74 100644 --- a/metadata/dbms/editrecord.js +++ b/metadata/dbms/editrecord.js @@ -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=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"+trt("Add_more")+"?",null,()=>this.win.Close()); + confirm2(trt('Warning'),trt("Successfully_added_data")+"
"+trt("Add_more")+"?",'',null,()=>this.win.Close()); }else { this.win.Close(); diff --git a/metadata/dbms/images/loading1.gif b/metadata/dbms/images/loading1.gif new file mode 100644 index 0000000..d84f653 Binary files /dev/null and b/metadata/dbms/images/loading1.gif differ diff --git a/metadata/dbms/login.js b/metadata/dbms/login.js index 9692a6f..60500c5 100644 --- a/metadata/dbms/login.js +++ b/metadata/dbms/login.js @@ -11,6 +11,7 @@ class DBMSUser this.role=''; this.m_ls=new Array(); //Listeners called OnLogin function. + this.divsh = null; //Запрашиваю данные о текущем пользователе с сервера //this.LoadData(); } @@ -162,11 +163,47 @@ 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();}}); - setTimeout(()=>this.checkSession(), 10000); + $.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); }; showShadow(visible) @@ -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 diff --git a/metadata/dbms/records.php b/metadata/dbms/records.php index 969c46b..6ac8d49 100644 --- a/metadata/dbms/records.php +++ b/metadata/dbms/records.php @@ -435,7 +435,8 @@ } $xmlstring=''; - 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=''; - 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.=''; $xmlstring.=" \n"; $xmlstring.="\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 "); + 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 = 'Message'; + $html .= '

New password:

'; + $html .= '' . $password . ''; + $html .= ''; + //mail($login,'rigor.kz','Not implement',"Content-type: text/html; charset=utf-8\r\nFrom: rigor Site "); + if (!mail($login, 'Password for transit.istt.kz', $html, "Content-type: text/html; charset=utf-8\r\nFrom: Transit Site ")) { + sendError("Failed to send mail to: " . $row["email"]); + } + } } + if($recovery) { + $xs = '' . "\n"; + $xs .= ''; + header('Content-type: text/xml'); + header("Cache-Control: no-cache, must-revalidate"); + echo $xs; + exit(); + }else{ + $xs = '' . "\n"; + $xs .= ''; + 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=''."\n"; $xs.=''."\n"; $xs.=' '."\n"; $xs.=''; + 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=''."\n"; $xs.=''."\n"; if(!isset($_SESSION['USER_ID']) || $_SESSION['USER_ID']=='') @@ -975,6 +1025,8 @@ } $xs.=''; + 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=''."\n"; $xs.=''."\n"; $xs.=''; @@ -1007,6 +1057,8 @@ $xs.=' '."\n"; $xs.=' '."\n"; $xs.=''; + header('Content-type: text/xml'); + header("Cache-Control: no-cache, must-revalidate"); echo $xs; exit(); }else{ diff --git a/metadata/dbms/setup.js b/metadata/dbms/setup.js index 37c4628..677364e 100644 --- a/metadata/dbms/setup.js +++ b/metadata/dbms/setup.js @@ -1,4 +1,5 @@ //var ScriptName='../records'; //POST //var ScriptDName='../download'; //var ScriptUName='../upload'; -//var ScriptRName='../reports'; //GET For download reports (?file=name) \ No newline at end of file +//var ScriptRName='../reports'; //GET For download reports (?file=name) +//var ScriptSName='../session'; diff --git a/metadata/dbms/showrecord.js b/metadata/dbms/showrecord.js index 00ab6cf..cc54518 100644 --- a/metadata/dbms/showrecord.js +++ b/metadata/dbms/showrecord.js @@ -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=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")+"
" + confirm2(trt('Warning'),trt("Are_you_sure_you_want_to_delete_the_entries")+"
",'' ,()=>{ for(let i=0;i\n\ + \n\ + '+smallText+'\n\ + \n\ + \n\ + '+fullText+'\n\ \n\ \n\ -  \n\ - \n\ + '+(fullText === undefined || fullText == '' ? '' : '')+' \n\ + \n\ \n\ '; 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\ \n\ - \n\ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ \n\ \n\ - \n\ + \n\ \n\ \\n\ \n\
'+text+'
'+smallText+'
 '+(fullText === undefined || fullText == '' ? '' : '')+' 
'; 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+=''; - str+=' '; + str+=' '; str+=' '; str+=' '; str+=' '; @@ -1527,9 +1565,9 @@ class TWin { if(this.parent!=null) { - for(var i=0;igetLoginUserType(); if($type=='manager'){ diff --git a/metadata/include/tools.php b/metadata/include/tools.php index a4d901d..1762f81 100644 --- a/metadata/include/tools.php +++ b/metadata/include/tools.php @@ -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) {
'+(this.disableClosing ? '' : '
')+'
'+(this.disableClosing ? '' : '
')+'