@Ghazascanner
_2019runbot
Ghazascanner File Manager
server :Linux www.thesweb.ru 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64
Current Path :
/
var
/
www
/
www-root
/
data
/
www
/
thesweb.ru
/
sci_thes
/
Path :
Upload File :
New :
File
Dir
/var/www/www-root/data/www/thesweb.ru/sci_thes/edit_copy2other_form.php
<? include_once "login.php"; if ($usr_id == -1) { header('HTTP/1.0 401 Unauthorized'); die(); } if ($_SESSION[LoginURI]['usertypeid'] == 30) { header('HTTP/1.0 401 Unauthorized'); die(); } function get_session($conn, $thesname) { if (!isset($_SESSION[LoginURI]['copy2Thes'])) $_SESSION[LoginURI]['copy2Thes'] = Array(); if (!isset($_SESSION[LoginURI]['copy2Thes'][$thesname])) $_SESSION[LoginURI]['copy2Thes'][$thesname] = Array(); unset($_SESSION[LoginURI]['copy2Thes'][$thesname]['ssid']); if (isset($_SESSION[LoginURI]['copy2Thes'][$thesname]['ssid'])) { //print_r($_SESSION[LoginURI]['copy2Thes']); $ss = $_SESSION[LoginURI]['copy2Thes'][$thesname]['ssid']; $q = 'UPDATE session SET dateend = current_date, timeend = current_time WHERE sessionid = ' . $ss; exec_sql ($conn, $q); } else { $usr_id2 = get_data_one_val($conn, 'SELECT userid FROM users WHERE login=' . sstr($_SESSION[LoginURI]['username'])); $sql = "INSERT INTO session(sessionid, userid, datestart, timestart, dateend, timeend, dateload, timeload, copyid) " . "VALUES (nextval('sequence_session'), " . $usr_id2 . ", current_date, current_time, current_date, current_time, NULL, NULL, (SELECT valueid FROM sequence where fieldstr = 'CopyId')) RETURNING sessionid"; $ss = get_data_one_val($conn, $sql); $_SESSION[LoginURI]['copy2Thes'][$thesname]['ssid'] = $ss; $_SESSION[LoginURI]['copy2Thes'][$thesname]['usr_id'] = $usr_id2; } return $ss; } function insert_synonym($conn, $ssid, $si, $langid, $concid) { if (true) { $testr = $si['textentrystr']; $c2 = get_data_one_val($conn, "SELECT count(1) as val FROM " . ($langid==20 ? "e_texent": "textentr") . " WHERE textentrystr = " . sstr($testr)); if (!$c2) { $lestr = $si['lementrystr']; $te_isarguable = '0'; $status = 0; if ($si['isarguable']) $te_isarguable = '1'; $te_isambig = '0'; if ($si['isambig'] == 'true') $te_isambig = '1'; if($langid==20) { $te_id = get_data_one_val($conn, "SELECT nextval('sequence_e_texent')"); $q = "UPDATE sequence SET valueid = " . $te_id . " WHERE fieldstr = 'MaxUnusedE_TextEntryId'"; } else { $te_id = get_data_one_val($conn, "SELECT nextval('sequence_textentr')"); $q = "UPDATE sequence SET valueid = " . $te_id . " WHERE fieldstr = 'MaxUnusedTextEntryId'"; } exec_sql($conn, $q); if ($te_id == -1) { //$data['error'] = 'Ошибка дабавления текстового входа! Не удалось получить уникальный ключ для TextEntryId!'; } else { $q = "INSERT INTO " . ($langid==20 ? "e_texent": "textentr") . "(textentryid, textentrystr, languageid, lementrystr, sessionident, sessionid, isambig, status, isarguable)" . "VALUES ($te_id, " . sstr($testr) . ", " . ($langid==20 ? "20": "10") . ", " . sstr($lestr) . ", $ssid, $ssid, '$te_isambig', '$status', '$te_isarguable')"; exec_sql($conn, $q); foreach($si['lems'] as $li) { $isbend = '0'; if ($li['isbend']) $isbend = '1'; $q = "INSERT INTO " . ($langid==20 ? "e_lemmas": "lemmas") . "(textentryid, lemmapos, lemmastr, isambig, isbend)" . "VALUES ($te_id, " . $li['lemmapos'] . ", " . sstr($li['lemmastr']) . ", '$te_isambig', '$isbend')"; //echo $q; $res = pg_query ($conn, $q); pg_free_result ($res); } } } else { $te_id = get_data_one_val($conn, 'SELECT textentryid as val FROM ' . ($langid==20 ? "e_texent": "textentr") . " WHERE textentrystr = " . sstr($testr)); } $c2 = get_data_one_val($conn, "SELECT count(1) as val FROM " . ($langid==20 ? "e_synons": "synonyms") . " WHERE textentryid = " . $te_id . ' AND conceptid = ' . $concid); if (!$c2) { $tecutstr = $testr; if (mb_strlen($tecutstr, "UTF-8") > 30) $tecutstr = mb_substr($tecutstr, 0, 30, "UTF-8"); $isarguable = '0'; if ($si['syn_isarguable']) $isarguable = '1'; $q = "INSERT INTO " . ($langid==20 ? "e_synons": "synonyms") . "(conceptid, textentryid, textentrycutstr, sessionident, sessionid, domainmask, isarguable)" . "VALUES ('" . $concid . "', " . $te_id . ", " . sstr($tecutstr) . ", $ssid, $ssid, " . $si['syn_domainmask'] . ", '$isarguable')"; exec_sql($conn, $q); } } } function insert_conc($conn, $ssid, $conc, $synonyms, $e_synonyms, $add_syn_if_conc_exists){ $concid = get_data_one_val($conn, 'SELECT conceptid FROM concepts WHERE conceptstr = ' . sstr(trim($conc['conceptstr']))); $concadd = 0; if ($concid === '') { $concadd = 1; $q = "SELECT nextval('sequence_concepts') AS val"; $concid = get_data_one_val($conn, $q); $isarg = '0'; if ($conc['isarguable']) $isarg = '1'; $isabs = '0'; if ($conc['isabstract']) $isabs = '1'; $q = 'INSERT INTO concepts(conceptid, conceptstr, conceptengstr, sessionid, sessionident, isabstract, shortcomments, domainmask, isarguable)' . 'VALUES (' . $concid . ',' . sstr(trim($conc['conceptstr'])) . ',' . sstr(trim($conc['conceptengstr'])) . ', '.$ssid.','.$ssid.',\'' . $isabs . '\',' . sstr(trim($conc['shortcomments'])) . ',' . $conc['domainmask'] . ',\'' . $isarg . '\')'; exec_sql($conn, $q); } if ($concadd || $add_syn_if_conc_exists) { if ($synonyms) { foreach($synonyms as $si) { insert_synonym($conn, $ssid, $si, 10, $concid); } } if ($e_synonyms) { foreach($e_synonyms as $si) { insert_synonym($conn, $ssid, $si, 20, $concid); } } } return $concid; } function insert_rel($conn, $ssid, $relinfo) { $cutstr = ''; $rel1 = $relinfo['relationid']; $currrels = get_data_array($conn, "SELECT r.relationid, n.relationstr, r.aspect FROM relats r JOIN relnames n ON n.relationid=r.relationid WHERE r.concept1id = " . $relinfo['concept1id'] . " AND r.concept2id = " . $relinfo['concept2id'] . " AND ((r.relationid = " . $rel1 . ") OR ((r.relationid = 33) AND (" . $rel1 . " = 67)) OR ((r.relationid = 67) AND (" . $rel1 . " = 33)) OR ((" . $rel1 . " != 33) AND (" . $rel1 . " != 67) AND (r.relationid != 33) AND (r.relationid != 67)))"); //print_r( $currrels); if (count($currrels) > 0) { return false; } else if ($relinfo['concept2id'] == $relinfo['concept1id']) { return false; } else { $isarg = '0'; if ($relinfo['isarguable'] == 'true') $isarg = '1'; $transrel = get_trans_rel_data($conn, $relinfo['relationid'], $relinfo['aspect']); $q = 'INSERT INTO relats(concept1id, concept2id, relationid, sessionid, sessionident, aspect, concept2cutstr, isarguable)' . 'VALUES (' . $relinfo['concept1id'] . ',' . $relinfo['concept2id'] . ',' . $relinfo['relationid'] . ','.$ssid.','.$ssid.',\'' . $relinfo['aspect'] . '\',\'' . $cutstr . '\',\'' . $isarg . '\')' . ', (' . $relinfo['concept2id'] . ',' . $relinfo['concept1id'] . ',' . $transrel['relationid'] . ','.$ssid.','.$ssid.',\'' . $transrel['aspect'] . '\',\'' . $cutstr . '\',\'' . $isarg . '\')'; //echo($q); $res = exec_sql($conn, $q); } return true; } $userCopyThesInst = copyThesInst_get4user($copyThesInst, $_SESSION[LoginURI]['username']); if (isset($_GET['action']) ) { if ($_GET['action'] == 'copy2thes') { $d = $_POST['copydata']; $dest = null; foreach($userCopyThesInst as $i) { if ($i['name'] == $d['dest']) { $dest = $i; break; } } $connTo = copyThesInst_getConn($dest); $q = 'SELECT * FROM concepts WHERE conceptid=' . $d['conceptid']; $src = Array(); $src['conc'] = get_data_one_row($conn, $q); $src['synonyms'] = Array(); if (isset($d['te'])) foreach($d['te'] as $te) { //$q = 'SELECT * FROM textentr WHERE textentryid=' . $te['textentryid']; $q = 'SELECT t.*,s.domainmask AS syn_domainmask, s.isarguable AS syn_isarguable FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid AND s.conceptid=' . $d['conceptid'] . ' AND s.textentryid = ' . $te['textentryid']; $tei = get_data_one_row($conn, $q); $tei['lems'] = get_data_array($conn, "SELECT * FROM lemmas WHERE textentryid = " . $te['textentryid']); $src['synonyms'][] = $tei; } $src['e_synonyms'] = Array(); if (isset($d['ete'])) foreach($d['ete'] as $te) { //$q = 'SELECT * FROM e_texent WHERE textentryid=' . $te['textentryid']; $q = 'SELECT t.*,s.domainmask AS syn_domainmask, s.isarguable AS syn_isarguable FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid AND s.conceptid=' . $d['conceptid'] . ' AND s.textentryid = ' . $te['textentryid']; $tei = get_data_one_row($conn, $q); $tei['lems'] = get_data_array($conn, "SELECT * FROM e_lemmas WHERE textentryid = " . $te['textentryid']); $src['e_synonyms'][] = $tei; } $src['rels'] = Array(); if (isset($d['rel'])) foreach($d['rel'] as $rel) { $q = 'SELECT * FROM concepts WHERE conceptid=' . $rel['concept2id']; $rc = Array(); $rc['conc'] = get_data_one_row($conn, $q); if ($rc['conc']['conceptid']) { $q = 'SELECT * FROM relats WHERE concept1id=' . $rel['concept1id'] . ' AND concept2id = ' . $rel['concept2id'] . ' AND relationid = ' . $rel['relationid']; $rc['relinfo'] = get_data_one_row($conn, $q); $q = 'SELECT t.*,s.domainmask AS syn_domainmask, s.isarguable AS syn_isarguable FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid AND s.conceptid=' . $rel['concept2id'] . ''; $rc['synonyms'] = get_data_array($conn, $q); for($i = 0; $i < count($rc['synonyms']); $i++) $rc['synonyms'][$i]['lems'] = get_data_array($conn, "SELECT * FROM lemmas WHERE textentryid = " . $rc['synonyms'][$i]['textentryid']); $q = 'SELECT t.*,s.domainmask AS syn_domainmask, s.isarguable AS syn_isarguable FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid AND s.conceptid=' . $rel['concept2id'] . ''; $rc['e_synonyms'] = get_data_array($conn, $q); for($i = 0; $i < count($rc['e_synonyms']); $i++) $rc['e_synonyms'][$i]['lems'] = get_data_array($conn, "SELECT * FROM e_lemmas WHERE textentryid = " . $rc['e_synonyms'][$i]['textentryid']); } $src['rels'][] = $rc; } //print_r($src); $ss = get_session($connTo, $d['dest']); $c0 = insert_conc($connTo, $ss, $src['conc'], $src['synonyms'], $src['e_synonyms'], true); foreach($src['rels'] as $rel) { $ci = insert_conc($connTo, $ss, $rel['conc'], $rel['synonyms'], $rel['e_synonyms'], false); $rel['conc_new_id'] = $ci; $rel['relinfo']['concept1id'] = $c0; $rel['relinfo']['concept2id'] = $ci; $rel['rel_append_res'] = insert_rel($connTo, $ss, $rel['relinfo']); //print_r($rel); } $res = Array('errno' => 0, 'error' => ''); header('Content-type: application/json; charset=utf-8'); echo json_encode($res); exit(); } else { /*$q = "SELECT conceptid, conceptstr, conceptengstr, shortcomments, domainmask, isabstract, isarguable, sessionid, sessionident FROM concepts WHERE conceptid=" . $conceptid; $res = pg_query ($conn, $q); if ($row = pg_fetch_array($res)) { $relurl = "url: 'json/getjson.php?type=relconc&showtype=1&conceptid=" . $conceptid . "', "; if ($row['isabstract'] === null) $isabstract = 'true'; else if (!$row['isabstract']) $isabstract = 'false'; if ($row['isarguable']) $isarguable = 'true'; $ss_add = get_user_ss_info($conn, $row['sessionident']); $ss_edit = get_user_ss_info($conn, $row['sessionid']); }*/ } } else { $conceptid = $_GET['conceptid']; $q = "SELECT conceptid, conceptstr, conceptengstr, shortcomments, domainmask, isabstract, isarguable, sessionid, sessionident FROM concepts WHERE conceptid=" . $conceptid; $res = pg_query ($conn, $q); if ($row = pg_fetch_array($res)) { $concname = $row['conceptstr']; $relurl = "url: 'json/getjson.php?type=relconc&showtype=1&withtotal=0&astree=1&conceptid=" . $conceptid . "', "; $teurl = "url: 'json/getjson.php?type=telist&conceptid=" . $conceptid . "', "; $teurl_eng = "url: 'json/getjson.php?type=telist&conceptid=" . $conceptid . "&langid=20', "; if ($row['isabstract'] === null) $isabstract = 'true'; else if (!$row['isabstract']) $isabstract = 'false'; if ($row['isarguable']) $isarguable = 'true'; $ss_add = get_user_ss_info($conn, $row['sessionident']); $ss_edit = get_user_ss_info($conn, $row['sessionid']); } pg_free_result ($res); } ?> <div class="dialogtext"> <table border="0" width="100%" cellpadding="0" cellspacing="0"> <tr><td style="width: 208px"> <label for="nthes_copy" class="label-top">Перенести в:</label> <select id="nthes_copy" class="easyui-combobox" data-options="panelHeight: 'auto', value: null, width: 200, editable: false"> <? foreach($userCopyThesInst as $t) { echo "<option value=\"" . $t['name'] . "\">" . $t['name'] . "</option>\n"; } ?> </select> </td><td style="width: 108px"> <label for="nconceptid" class="label-top">Код концепта:</label> <input id="nconceptid" class="easyui-textbox" data-options="readonly: true" style="width: 100px" value="<? echo $conceptid;?>"> </td><td style="width: 208px"> <label for="nadded" class="label-top">Добавлено:</label> <input id="nadded" class="easyui-textbox" data-options="readonly: true" style="width: 200px" value="<? echo $ss_add; ?>"> </td><td style="width: 208px"> <label for="nedited" class="label-top">Изменено:</label> <input id="nedited" class="easyui-textbox" data-options="readonly: true" style="width: 200px" value="<? echo $ss_edit; ?>"> </td></tr> </table> <p> <div style="margin-bottom:7px"> <input id="nconceptstr" class="easyui-textbox" data-options="label: 'Наименование концепта', labelPosition: 'before', labelWidth: 150, readonly: true, required:true, tipPosition: 'top'" style="width: 100%" value="<? echo xml_entities($concname); ?>"> </div> <label for="nrel_concepts" class="label-top">Отношения</label> <table id="nrel_concepts" class="easyui-datagrid" data-options="<?echo $relurl;?>height: 302, width:'100%', striped: true, singleSelect: true, pagination: false, fitColumns: false, rownumbers: true, checkbox: true, lines: true, idField: 'concept2id', treeField: 'relationstr', selectOnCheck: false, checkOnSelect: false, onLoadSuccess: function(d) { console.log(d); $(this).datagrid('checkAll'); }"> <thead> <tr> <th data-options="field:'en', width: 20, checkbox: true"></th> <th data-options="field:'relationstr', width: '120'">Отношение</th> <th data-options="field:'aspect', width: '40'">Асп.</th> <th data-options="field:'concept2str', width: '450'">Наименование концепта</th> <th data-options="field:'exist', width: '40'">Нал.</th> <th data-options="field:'concept2id', width: 80">ID</th> </tr> </thead> <tbody> </tbody> </table> <label for="nte4concepts_tabs" class="label-top">Текстовые входы</label> <div id="nte4concepts_tabs" class="easyui-tabs"> <div title="Русские"> <table id="nte4concepts" class="easyui-datagrid" data-options="<?echo $teurl;?>height: 200, width:'100%', striped: true, singleSelect: true, pagination: false, fitColumns: false, rownumbers: true, checkbox: true, selectOnCheck: false, checkOnSelect: false, onLoadSuccess: function(d) { console.log(d); $(this).datagrid('checkAll'); }"> <thead> <tr> <th data-options="field:'en', width: 20, checkbox: true"></th> <th data-options="field:'textentrycutstr', width: 450">Наименование</th> <th data-options="field:'exist', width: '40'">Нал.</th> <th data-options="field:'textentryid', width: 80">ID</th> </tr> </thead> <tbody> </tbody> </table> </div> <div title="Английские"> <table id="nte4concepts_eng" class="easyui-datagrid" data-options="<?echo $teurl_eng;?>height: 200, width:'100%', striped: true, singleSelect: true, pagination: false, fitColumns: false, rownumbers: true, checkbox: true, selectOnCheck: false, checkOnSelect: false, onLoadSuccess: function(d) { console.log(d); $(this).datagrid('checkAll'); }"> <thead> <tr> <th data-options="field:'en', width: 20, checkbox: true"></th> <th data-options="field:'textentrycutstr', width: 450">Наименование</th> <th data-options="field:'exist', width: '40'">Нал.</th> <th data-options="field:'textentryid', width: 80">ID</th> </tr> </thead> <tbody> </tbody> </table> </div> </div> </div> <script type="text/javascript"> $(function () {}); </script>