@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
/
thes_test
/
json
/
Path :
Upload File :
New :
File
Dir
/var/www/www-root/data/www/thesweb.ru/thes_test/json/getjson.php
<?PHP header('Content-type: application/json; charset=utf-8'); //include_once "../config.php"; include_once "../login.php"; if ($usr_id == -1) { //header('HTTP/1.0 401 Unauthorized'); //die(); die('{"message": "noauth", "error": "Не авторизовано!", "total": 0, "rows": []}'); } //if (!(isset($ssid))) // die('{"message": "noauth", "error": "Не авторизовано!"}'); $cnt = 0; $srt = ''; $where = ''; $type = $_GET['type']; $big = isset($_SESSION[LoginURI]['bigdata']) && $_SESSION[LoginURI]['bigdata']; $thesver = isset($_SESSION[LoginURI]['version']) ? $_SESSION[LoginURI]['version'] : 1; $usertypeid = $_SESSION[LoginURI]['usertypeid']; session_write_close(); $without_total = false; if (isset($_GET['without_total']) && ($_GET['without_total'] == '1')) $without_total = true; $sql2 = ''; $langid = 10; if (isset($_GET['langid'])) $langid = 0 + $_GET['langid']; $page = -1; $rows = -1; if (isset($_GET['page'])) { $page = $_GET['page']; } else if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_GET['rows'])) { $rows = $_GET['rows']; } else if (isset($_POST['rows'])) { $rows = $_POST['rows']; } if (isset($_GET['sort'])) { $srt = ' ORDER BY ' . $_GET['sort']; if (isset($_GET['order'])) $srt .= ' '. $_GET['order']; //if ($_POST['sort'] != 'wh_id') // $srt .= ', wh_id'; //if ($_POST['sort'] != 'good_id') // $srt .= ', good_id'; } /* if (isset($_POST['filterRules'])) { $filterRules = $_POST['filterRules']; //echo $filterRules; $filterRules = json_decode($filterRules, true); $where = ''; foreach ($filterRules as $row) { $v = $row['value']; $v = str_replace(',', '.', $v); if ($row['op'] == 'less') { $where .= ' AND (' . $row['field'] . ' < ' . $v . ')'; } else if ($row['op'] == 'greater') { $where .= ' AND (' . $row['field'] . ' > ' . $v . ')'; } else { if (($row['field'] == 'wh_id') || ($row['field'] == 'good_id')) $where .= ' AND (substring(convert(varchar(1000), ' . $row['field'] . '), 1, ' . strlen($row['value']) . ') = \'' . $v . '\')'; else $where .= ' AND (' . $row['field'] . ' = ' . $v . ')'; } //echo $where; } } else { //echo '$filterRules'; //[{"field":"good_id","op":"contains","value":"1039286"}] $where = ''; } */ if (($sql2 == '') && ($type == 'langlist')) { if ($srt == '') { $srt = ' ORDER BY languageid'; } $sql2 = "SELECT languageid, languagestr FROM languas"; } if (($sql2 == '') && ($type == 'conclist')) { if ($srt == '') { $srt = ' ORDER BY conceptstr'; } if ($thesver >=20220819) { $sql2 = "SELECT conceptid, domainmask, conceptstr, " . (($langid == 10 || $langid == 20) ? "conceptengstr" : '(SELECT translatestr FROM concepts_translate WHERE conceptid = c.conceptid AND languageid = ' . $langid . ') AS conceptengstr') . ", conceptstr || CASE WHEN coalesce(shortcomments, '') = '' THEN '' ELSE ' (' || shortcomments || ')' END AS extconceptstr, COALESCE(isabstract::int, 1) AS isabstract FROM concepts c"; $where = " WHERE (conceptid > 0)"; } else { $sql2 = "SELECT conceptid, domainmask, conceptstr, conceptengstr, conceptstr || CASE WHEN coalesce(shortcomments, '') = '' THEN '' ELSE ' (' || shortcomments || ')' END AS extconceptstr, COALESCE(isabstract::int, 1) AS isabstract FROM concepts c"; $where = " WHERE (conceptid > 0)"; } $filtertype = "l"; if (isset($_GET['filtertype']) && ($_GET['filtertype'] == 'e')) $filtertype = 'e'; if (isset($_GET['filter']) && (strlen($_GET['filter']) > 0) && ($_GET['filter'][strlen($_GET['filter'])-1] == '!')) { $_GET['filter'] = substr($_GET['filter'], 0, strlen($_GET['filter'])-1); $filtertype = 'e'; } $filterzone = "conc"; if (isset($_GET['filterzone']) && ($_GET['filterzone'] == 'te')) $filterzone = 'te'; if (isset($_GET['filterzone']) && ($_GET['filterzone'] == 'te_like')) $filterzone = 'te_like'; if (isset($_GET['filterzone']) && ($_GET['filterzone'] == 'conc_te_like')) $filterzone = 'conc_te_like'; if (isset($_GET['filterzone']) && ($_GET['filterzone'] == 'conc_te')) $filterzone = 'conc_te'; if (isset($_GET['filterzone']) && ($_GET['filterzone'] == 'conc_like')) $filterzone = 'conc_like'; if (($filterzone == 'conc') or ($filterzone == 'conc_te')) { if (isset($_GET['filter']) && ($_GET['filter'] != '')) { $where .= " AND ( "; $where .= " ((c.conceptstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "'))"; if (is_numeric($_GET['filter'])) $where .= " OR (c.conceptid = " . $_GET['filter'] . ")"; if (($filtertype == "l") && !$big) $where .= " OR (c.conceptstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; else $where .= ')'; if ($filterzone == 'conc') $where .= ')'; } } if (($filterzone == 'conc_like') or ($filterzone == 'conc_te_like')) { if (isset($_GET['filter']) && ($_GET['filter'] != '')) { $where .= " AND ( "; $where .= " ((c.conceptstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "'))"; if (is_numeric($_GET['filter'])) $where .= " OR (c.conceptid = " . $_GET['filter'] . ")"; if ($filtertype == "l") $where .= " OR (c.conceptstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; else $where .= ')'; if ($filterzone == 'conc_like') $where .= ')'; } } if (($filterzone == 'te') or ($filterzone == 'conc_te')) { if (isset($_GET['filter']) && ($_GET['filter'] != '')) { $where .= ($filterzone == 'conc_te' ? " OR " : " AND "); $where .= " ((c.conceptid IN (SELECT s.conceptid FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "')))"; $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "')))"; if ($filtertype == "l") { $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "'))))"; } else $where .= ')'; if ($filterzone == 'conc_te') $where .= " ) "; } } if (($filterzone == 'te_like') or ($filterzone == 'conc_te_like')) { if (isset($_GET['filter']) && ($_GET['filter'] != '')) { $where .= ($filterzone == 'conc_te_like' ? " OR " : " AND "); $where .= " ((c.conceptid IN (SELECT s.conceptid FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "')))"; $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "')))"; if ($filtertype == "l") { $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM textentr t JOIN synonyms s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; $where .= " OR (c.conceptid IN (SELECT s.conceptid FROM e_texent t JOIN e_synons s ON s.textentryid = t.textentryid where t.textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('%" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "'))))"; } else $where .= ')'; if ($filterzone == 'conc_te_like') $where .= " ) "; } } if (isset($_GET['domainmask']) && ($_GET['domainmask'] > 0)) { if (isset($_GET['domainmasktype']) && ($_GET['domainmasktype'] == 'or')) $cond = " > 0 "; else $cond = " = " . $_GET['domainmask']; $where .= " AND (domainmask & " . $_GET['domainmask'] . $cond . ")"; } //echo $where; } if (($sql2 == '') && ($type == 'telist')) { if ($srt == '') { $srt = ' ORDER BY t.textentrystr'; } if ($thesver >=20220819) { $sql2 = "SELECT s.conceptid, s.textentryid, t.textentrystr AS textentrycutstr, s.domainmask, s.isarguable, COALESCE(t.isambig::int, 0) AS isambig, " . ($big ? '0' : " (SELECT COUNT(1) FROM " . ($langid == 20 ? 'e_synons' : 'synonyms' ) . " s1 WHERE s1.textentryid = s.textentryid and s1.conceptid > 0 and s1.conceptid in (SELECT conceptid FROM concepts)) ") . " AS conc_count FROM " . ($langid == 20 ? 'e_synons' : 'synonyms' ) . " s JOIN " . ($langid == 20 ? 'e_texent' : 'textentr' ) . " t ON t.textentryid = s.textentryid"; $where = " WHERE s.conceptid = " . $_GET['conceptid'] . ($langid == 20 ? '' : ' AND languageid = ' . $langid); } else { $sql2 = "SELECT s.conceptid, s.textentryid, t.textentrystr AS textentrycutstr, s.domainmask, s.isarguable, COALESCE(t.isambig::int, 0) AS isambig, " . ($big ? '0' : " (SELECT COUNT(1) FROM " . ($langid == 10 ? 'synonyms' : 'e_synons' ) . " s1 WHERE s1.textentryid = s.textentryid and s1.conceptid > 0 and s1.conceptid in (SELECT conceptid FROM concepts)) ") . " AS conc_count FROM " . ($langid == 10 ? 'synonyms' : 'e_synons' ) . " s JOIN " . ($langid == 10 ? 'textentr' : 'e_texent' ) . " t ON t.textentryid = s.textentryid"; $where = " WHERE s.conceptid = " . $_GET['conceptid']; } } if (($sql2 == '') && ($type == 'conc_clust_list')) { if ($srt == '') { $srt = ' ORDER BY t.clusterstr'; } $sql2 = "SELECT s.conceptid, s.clusterid, t.clusterstr, t.reqstr, t.dt, t.shortcomments FROM cluster2concept s JOIN clusters t ON t.clusterid = s.clusterid"; $where = " WHERE s.conceptid = " . $_GET['conceptid']; } if (($sql2 == '') && ($type == 'conclist4te')) { if ($srt == '') { $srt = ' ORDER BY conceptstr'; } $sql2 = "SELECT conceptid, conceptstr FROM concepts"; $where = " WHERE conceptid IN (SELECT conceptid FROM " . ($langid == 20 ? 'e_synons' : 'synonyms' ) . " s1 WHERE s1.textentryid = " . $_GET['textentryid'] . ")"; } if (($sql2 == '') && ($type == 'textentrylist')) { if ($srt == '') { $srt = ' ORDER BY textentrystr'; } $sql2 = "SELECT textentryid, textentrystr, languageid, lementrystr, sessionid, sessionident, isambig, isarguable FROM " . ($langid == 20 ? 'e_texent' : 'textentr' ); if ($thesver >=20220819) { $where = " WHERE " . ($langid == 20 ? '1=1 ' : ' languageid=' . $langid . ' '); } else { $where = " WHERE 1=1 "; } $filtertype = "l"; if (isset($_GET['filtertype']) && ($_GET['filtertype'] == 'e')) $filtertype = 'e'; if (isset($_GET['filter']) && ($_GET['filter'] != '')) $where .= " AND ((textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "'))"; if (isset($_GET['filter']) && ($_GET['filter'] != '')) { if ($filtertype == "l") $where .= " OR (textentrystr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; else $where .= ')'; } } if (($sql2 == '') && ($type == 'clusterlist')) { if ($srt == '') { $srt = ' ORDER BY clusterstr'; } $sql2 = "SELECT clusterid, clusterstr, shortcomments, reqstr, dt, sessionid, sessionident FROM clusters"; $where = ' WHERE 1=1 '; $filtertype = "l"; if (isset($_GET['filtertype']) && ($_GET['filtertype'] == 'e')) $filtertype = 'e'; if (isset($_GET['filter']) && ($_GET['filter'] != '')) $where .= " AND ((clusterstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . $_GET['filter'] . ($filtertype=='l'?'%':'') . "'))"; if (isset($_GET['filter']) && ($_GET['filter'] != '')) { if ($filtertype == "l") $where .= " OR (clusterstr " . ($filtertype=='l'?'LIKE':'=') . " UPPER('" . correctString($_GET['filter']) . ($filtertype=='l'?'%':'') . "')))"; else $where .= ')'; } } if (($sql2 == '') && ($type == 'clustfrag_list')) { if ($srt == '') { $srt = ' ORDER BY fragmentstr'; } $sql2 = "SELECT clusterid, fragmentid, fragmentstr, textinfo, sessionid, sessionident FROM cluster_frags s "; $where = " WHERE s.clusterid = " . $_GET['clusterid']; } if (($sql2 == '') && ($type == 'clustfragthesis_list')) { if ($srt == '') { $srt = ' ORDER BY thesisstr'; } $sql2 = "SELECT fragmentid, thesisid, thesisstr, textinfo, sessionid, sessionident FROM cluster_frag_thesis s "; $where = " WHERE s.fragmentid = " . $_GET['fragmentid']; } if (($sql2 == '') && ($type == 'relconc')) { //$without_total = true; if ($srt == '') { //$srt = ' ORDER BY r.relationid, r.concept2cutstr'; $srt = ' ORDER BY r.relationid, c.conceptstr'; } if ($thesver >=20220819) { $sql2 = "SELECT conceptid, domainmask, conceptstr, " . (($langid == 10 || $langid == 20) ? "conceptengstr" : '(SELECT translatestr FROM concepts_translate WHERE conceptid = c.conceptid AND languageid = ' . $langid . ') AS conceptengstr') . ", conceptstr || CASE WHEN coalesce(shortcomments, '') = '' THEN '' ELSE ' (' || shortcomments || ')' END AS extconceptstr, COALESCE(isabstract::int, 1) AS isabstract FROM concepts c"; $sql2 = "SELECT " . (isset($_GET['id']) ? "'" . $_GET['id'] . "' AS \"parentId\", " : '') ."'closed' AS state, r.concept1id, r.concept2id, r.relationid, r.concept2cutstr, r.aspect, r.isarguable, c.domainmask, c.conceptstr AS concept2str, c.domainmask AS domainmask2, " . (($langid == 10 || $langid == 20) ? "c.conceptengstr" : '(SELECT translatestr FROM concepts_translate WHERE conceptid = c.conceptid AND languageid = ' . $langid . ')') . " AS concept2engstr, rn.relationstr, " . "c.conceptstr || CASE WHEN coalesce(c.shortcomments, '') = '' THEN '' ELSE ' (' || c.shortcomments || ')' END AS extconcept2str," . "r.auto, CASE WHEN r.auto = 1 THEN '✔' WHEN r.auto = 2 THEN '✘' ELSE NULL END AS autoval" . " FROM relats r JOIN concepts c ON c.conceptid = r.concept2id JOIN relnames rn ON rn.relationid = r.relationid"; } else { $sql2 = "SELECT " . (isset($_GET['id']) ? "'" . $_GET['id'] . "' AS \"parentId\", " : '') ."'closed' AS state, r.concept1id, r.concept2id, r.relationid, r.concept2cutstr, r.aspect, r.isarguable, c.domainmask, c.conceptstr AS concept2str, c.domainmask AS domainmask2, c.conceptengstr AS concept2engstr, rn.relationstr, " . "c.conceptstr || CASE WHEN coalesce(c.shortcomments, '') = '' THEN '' ELSE ' (' || c.shortcomments || ')' END AS extconcept2str," . "r.auto, CASE WHEN r.auto = 1 THEN '✔' WHEN r.auto = 2 THEN '✘' ELSE NULL END AS autoval" . " FROM relats r JOIN concepts c ON c.conceptid = r.concept2id JOIN relnames rn ON rn.relationid = r.relationid"; } if (isset($_GET['id'])) { $where = " WHERE concept1id = " . $_GET['id']; } else { $where = " WHERE concept1id = " . $_GET['conceptid']; set_last_concid_hist($conn, $ssid, $_GET['conceptid']); } if (isset($_GET['showtype']) && ($_GET['showtype'] == '1')) { $where .= " AND (r.relationid in (10, 20, 30, 40, 50))"; } if (isset($_GET['domainmask']) && ($_GET['domainmask'] > 0)) { if (isset($_GET['domainmasktype']) && ($_GET['domainmasktype'] == 'or')) $cond = " > 0 "; else $cond = " = " . $_GET['domainmask']; $where .= " AND (c.domainmask & " . $_GET['domainmask'] . $cond . ")"; } } if (($sql2 == '') && ($type == 'rubcator')) { if ($srt == '') { $srt = ' ORDER BY rubricatorid'; } $sql2 = "SELECT rubricatorid, rubricatorstr, rubrdir FROM rubcator"; $where = ""; } $rubcator_prefix = ''; if (isset($_GET['rubricatorid'])) { $sqlx = "SELECT rubrdir FROM rubcator WHERE rubricatorid = " . $_GET['rubricatorid']; $r = get_data_one_row($conn, $sqlx); //print_r($r); $rubcator_prefix = get_rubricator_prefix($conn, $_GET['rubricatorid']); //echo $rubcator_prefix; /*if (($r != null)&&($r['rubrdir'] != '')) { $r['rubrdir'] = str_replace('/', '_', $r['rubrdir']); $r['rubrdir'] = str_replace('\\', '_', $r['rubrdir']); $r['rubrdir'] = str_replace('RUBRICS_', 'rrr_', $r['rubrdir']); $r['rubrdir'] = str_replace('rubrics_', 'rrr_', $r['rubrdir']); $r['rubrdir'] = str_replace('Rubrics_', 'rrr_', $r['rubrdir']); //die($r['rubrdir'][count($r['rubrdir'])-1]); if (($r['rubrdir'] != '') && ($r['rubrdir'][strlen($r['rubrdir'])-1]) != '_') $r['rubrdir'] .= '_'; $sqlx = "select count(*) as cnt from pg_tables where lower(tablename)=lower('" . $r['rubrdir'] . "rubrics')"; $r2 = get_data_one_row($conn, $sqlx); if ($r2['cnt'] > 0) { $rubcator_prefix = $r['rubrdir']; } }*/ } if (($sql2 == '') && ($type == 'rubrics')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY snumb, rubricstr'; } $sql2 = "SELECT rubricatorid, rubricid, snumb, hostrubricid, rubricstr, rubricengstr, transid, nlevel, treeorderid, rubrictype, round(ves * 100 ) / 100 AS ves FROM " . $rubcator_prefix . "rubrics "; if (isset($_GET['rubricatorid'])) { $where = " WHERE rubricatorid = " . $_GET['rubricatorid']; } //die($sql2); } if (($sql2 == '') && ($type == 'hostrubrics')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY snumb, rubricstr'; } $sql2 = "SELECT 0 AS rubricid,' ' AS snumb, 0 AS hostrubricid, '<Нет главной рубрики>' AS rubricstr UNION SELECT rubricid, snumb, hostrubricid, rubricstr FROM " . $rubcator_prefix . "rubrics "; if (isset($_GET['rubricatorid'])) { $where = " WHERE rubricatorid = " . $_GET['rubricatorid']; } //echo $sql2; } if (($sql2 == '') && ($type == 'disjs')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY disjunctid'; } $sql2 = "SELECT rubricid, rubricatorid, disjunctid, disjunctstr, round(ves * 100 ) / 100 AS ves, disjunctmemo, disjunctengstr FROM " . $rubcator_prefix . "disjunct "; $where = "WHERE 1=1"; if (isset($_GET['rubricatorid'])) { $where .= " AND rubricatorid = " . $_GET['rubricatorid']; } if (isset($_GET['rubricid'])) { $where .= " AND rubricid = " . $_GET['rubricid']; } } if (($sql2 == '') && ($type == 'conjs')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY conjunctid'; } $sql2 = "SELECT conjunctid, rubricid, disjunctid, rubricatorid, conjunctstr, round(ves * 100 ) / 100 AS ves, conjunctmemo, conjunctengstr FROM " . $rubcator_prefix . "conjunct "; $where = "WHERE 1=1"; if (isset($_GET['rubricatorid'])) { $where .= " AND rubricatorid = " . $_GET['rubricatorid']; } if (isset($_GET['rubricid'])) { $where .= " AND rubricid = " . $_GET['rubricid']; } if (isset($_GET['disjunctid'])) { $where .= " AND disjunctid = " . $_GET['disjunctid']; } } if (($sql2 == '') && ($type == 'rubdes')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY orderid, conceptstr'; } $sql2 = "SELECT rd.rubdesid, rd.orderid, rd.rubricatorid, rd.rubricid, rd.disjunctid, rd.conjunctid, rd.conceptid, c.conceptstr, " . " rd.confirmid, cf.confirmname, cf.confirmstr, rd.expandtype, rd.concrubrtypeid, crt.concrubrtypestr, rd.enabled ". " FROM " . $rubcator_prefix . "rubdes rd ". " JOIN concrubrtype crt ON crt.concrubrtypeid = rd.concrubrtypeid ". " JOIN concepts c ON c.conceptid = rd.conceptid ". " JOIN confirm cf ON cf.confirmid = rd.confirmid "; $where = "WHERE 1=1"; if (isset($_GET['rubricatorid'])) { $where .= " AND rubricatorid = " . $_GET['rubricatorid']; } if (isset($_GET['rubricid'])) { $where .= " AND rubricid = " . $_GET['rubricid']; } if (isset($_GET['disjunctid'])) { $where .= " AND disjunctid = " . $_GET['disjunctid']; } if (isset($_GET['conjunctid'])) { $where .= " AND conjunctid = " . $_GET['conjunctid']; } } if (($sql2 == '') && ($type == 'revry')) { //$without_total = true; if ($srt == '') { $srt = ' ORDER BY conceptstr'; } $sql2 = "SELECT rd.rubricatorid, rd.rubricid, rd.disjunctid, rd.conjunctid, rd.conceptid, c.conceptstr, " . " rd.confirmid, cf.confirmname, cf.confirmstr ". " FROM " . $rubcator_prefix . "revry rd " . (isset($_GET['rubdesid']) ? " JOIN " . $rubcator_prefix . "RRDepend rr ON rr.RubDesId=" . $_GET['rubdesid'] . " AND rr.RevRyId=rd.RevRyId " : "") . " JOIN concepts c ON c.conceptid = rd.conceptid ". " JOIN confirm cf ON cf.confirmid = rd.confirmid "; //echo ($sql2); $where = "WHERE 1=1"; if (isset($_GET['rubricatorid'])) { $where .= " AND rubricatorid = " . $_GET['rubricatorid']; } if (isset($_GET['rubricid'])) { $where .= " AND rubricid = " . $_GET['rubricid']; } if (isset($_GET['disjunctid'])) { $where .= " AND disjunctid = " . $_GET['disjunctid']; } if (isset($_GET['conjunctid'])) { $where .= " AND conjunctid = " . $_GET['conjunctid']; } } if (($sql2 == '') && ($type == 'relreport')) { if ($srt == '') { $srt = ' ORDER BY conceptstr'; } $sql2 = "SELECT c.conceptid, c.domainmask, c.conceptstr, c.conceptstr || CASE WHEN coalesce(c.shortcomments, '') = '' THEN '' ELSE ' (' || c.shortcomments || ')' END AS extconceptstr, COALESCE(c.isabstract::int, 1) AS isabstract". " FROM concepts c"; $where = " WHERE (conceptid > 0)"; $cond2 = ''; if (isset($_POST['domainmask']) && ($_POST['domainmask'] > 0)) { if (isset($_POST['domainmasktype']) && ($_POST['domainmasktype'] == 'or')) $cond = " > 0 "; else $cond = " = " . $_POST['domainmask']; $where .= " AND (domainmask & " . $_POST['domainmask'] . $cond . ")"; $cond2 = " AND (c1.domainmask & " . $_POST['domainmask'] . $cond . ")"; } if (isset($_POST['skipdm']) && ($_POST['skipdm'] > 0)) { $where .= " AND (domainmask & " . $_POST['skipdm'] . ' = 0' . ")"; } if (isset($_POST['rel1']) && ($_POST['rel1'] > 0)) { $where .= " AND ((SELECT count(*) FROM relats r1 " . ($_POST['reldomaincheck'] ? " JOIN concepts c1 ON (c1.conceptid=r1.concept2id)" . $cond2 : '') . " where r1.concept1id=c.conceptid AND ((r1.relationid=" . $_POST['rel1'] . ($_POST['rel1asp'] != 'any' ? " AND r1.aspect = '" . $_POST['rel1asp'] . "'" : '') . ((isset($_POST['rel2'])&& ($_POST['rel2'] > 0)) ? ") OR (r1.relationid=" . $_POST['rel2'] . ($_POST['rel2asp'] != 'any' ? " AND r1.aspect = '" . $_POST['rel2asp'] . "'" : '') : '') . "))) " . ($_POST['relcomparetype'] ? '=' : '>=') . $_POST['relcompare'] . ')'; } //echo $where; } if (($sql2 == '') && ($type == 'prerekvizit_report')) { if ((!isset($_POST['group1'])) || (!$_POST['group1']) || (!isset($_POST['group2'])) || (!$_POST['group2'])) { echo '{"total": 0, "rows": []}'; exit(); } if ($srt == '') { $srt = ' ORDER BY conceptstr'; } $sql2 = "SELECT count(*) as freq, c.conceptstr, c.conceptid FROM concepts c JOIN ( " .((isset($_POST['astrees']) && $_POST['astrees']) ? "SELECT concept2id FROM relats WHERE relationid = 67 AND concept1id IN " : "SELECT conceptid as concept2id FROM trees WHERE childid IN " ). " (SELECT childid FROM trees WHERE conceptid in (SELECT conceptid FROM concepts where conceptstr in ('" . implode("', '", explode(';', $_POST['group1'])) . "')) union (SELECT conceptid FROM concepts where conceptstr in ('" . implode("', '", explode(';', $_POST['group1'])) . "')) ) union all SELECT childid FROM trees WHERE conceptid in (SELECT conceptid FROM concepts where conceptstr in ('" . implode("', '", explode(';', $_POST['group1'])) . "')) union all (SELECT conceptid FROM concepts where conceptstr in ('" . implode("', '", explode(';', $_POST['group1'])) . "')) ) x ON x.concept2id = c.conceptid where conceptid in (SELECT childid FROM trees WHERE relationid = 30 and conceptid in (SELECT conceptid FROM concepts where conceptstr in ('" . implode("', '", explode(';', $_POST['group2'])) . "'))) GROUP BY c.conceptid, c.conceptstr"; $where = " "; $cond2 = ''; //echo $sql2; } if (($sql2 == '') && ($type == 'relcheck')) { if ($srt == '') { $srt = ' ORDER BY concept1str'; } $sql2 = "SELECT c1.conceptstr as concept1str, r1.concept1id, r1.relationid, rn.relationstr || CASE WHEN r1.aspect <> '' THEN ' [' || r1.aspect || ']' ELSE '' END as relstr, c2.conceptstr as concept2str, r1.concept2id, (SELECT rn2.relationstr || CASE WHEN r2.aspect <> '' THEN ' [' || r2.aspect || ']' ELSE '' END FROM relats r2 JOIN relnames rn2 on rn2.relationid = r2.relationid WHERE r2.concept1id = r1.concept2id AND r2.concept2id = r1.concept1id limit 1) as relstr2 FROM relats r1 JOIN relnames rn on rn.relationid = r1.relationid JOIN concepts c1 ON c1.conceptid = r1.concept1id JOIN concepts c2 ON c2.conceptid = r1.concept2id"; $where = " WHERE r1.relationid in (10, 20, 30, 40, 50) AND not exists ( SELECT 1 FROM relats r2 WHERE r2.concept1id = r1.concept2id AND r2.concept2id = r1.concept1id AND (r2.relationid = CASE r1.relationid WHEN 10 THEN 30 WHEN 20 THEN 40 WHEN 30 THEN 10 WHEN 40 THEN 20 ELSE 50 END) AND (r2.aspect = CASE r1.aspect WHEN '1' THEN '2' WHEN '2' THEN '1' ELSE r1.aspect END) )"; //echo $where; } if (($sql2 == '') && ($type == 'domains')) { if ($srt == '') { $srt = ' ORDER BY domainmask'; } $sql2 = "SELECT domainmask, domaincodestr, domainstr, domaincolor FROM domains"; $where = ""; } if (($sql2 == '') && ($type == 'findconceptpage')) { $without_total = true; //if ($srt == '') { // $srt = ' ORDER BY conceptstr'; //} $sql2 = "SELECT a.* FROM (SELECT ROW_NUMBER() OVER(ORDER BY conceptstr) AS rn, conceptid FROM concepts d "; $where = " WHERE (conceptid > 0)"; if (isset($_GET['domainmask']) && ($_GET['domainmask'] > 0)) { if (isset($_GET['domainmasktype']) && ($_GET['domainmasktype'] == 'or')) $cond = " > 0 "; else $cond = " = " . $_GET['domainmask']; $where .= " AND (domainmask & " . $_GET['domainmask'] . $cond . ")"; } $sql2 .= $where . ") a WHERE (a.conceptid = " . $_GET['conceptid'] . ")"; $where = ''; } if (($sql2 == '') && ($type == 'userlist')) { if ($srt == '') { $srt = ' ORDER BY userid'; } $sql2 = "SELECT userid, login FROM users "; $where = " WHERE 1=1 "; } if (($sql2 == '') && ($type == 'userhist')) { if ($srt == '') { $srt = ' ORDER BY dt desc'; } $sql2 = "SELECT h.conceptid, c.conceptstr, h.dt FROM user_hist h JOIN concepts c ON c.conceptid = h.conceptid "; $where = " WHERE h.sessionid in (SELECT sessionid FROM session where userid = " . $usr_id . ") "; } if (($sql2 == '') && ($type == 'sessionlist')) { if ($usertypeid == 30) { header('HTTP/1.0 401 Unauthorized'); die(); } if ($srt == '') { $srt = ' ORDER BY sessionid DESC '; } $sql2 = "SELECT *, sessionid AS sessionstr FROM session "; $where = " WHERE userid IN (SELECT userid FROM users WHERE login='" . $_GET['user'] . "') "; } //[{field:'itemid',title:'Item ID', sortable:true}] if (($sql2 == '') && ($type == 'report')) { if ($usertypeid == 30) { header('HTTP/1.0 401 Unauthorized'); die(); } $table = $_GET['t']; $change = ($_GET['change'] === '1'); $user = $_GET['user']; $ss1 = $_GET['ss1'] + 0; $ss2 = $_GET['ss2'] + 0; if ($ss1 > $ss2) { $ssx = $ss2; $ss2 = $ss1; $ss1 = $ssx; } if ($srt == '') { $srt = ' ORDER BY 1'; } if (($table == 'synonyms') || ($table == 'e_synons')) $sql2 = "SELECT t.TextEntryStr as TextEntryStr, c.ConceptStr AS ConceptStr, st.*, s.datestart FROM " . $table . " as st JOIN " . ($table == 'e_synons' ? 'e_texent' : 'textentr') . " t ON st.TextEntryId = t.TextEntryId JOIN Concepts c ON c.ConceptId = st.ConceptId JOIN session AS s ON t.SessionIdEnt = s.SessionId JOIN users AS u ON s.userid = u.userid "; else if ($table == 'relats') $sql2 = "SELECT c1.ConceptStr AS Concept1Str, n.RelationStr, t.aspect, c2.ConceptStr AS Concept2Str, s.datestart, t.* FROM " . $table . " as t JOIN Concepts c1 ON c1.ConceptId=t.Concept1Id AND t.auto=0 JOIN Concepts c2 ON c2.ConceptId=t.Concept2Id JOIN RelNames n ON n.RelationId=t.RelationId JOIN session AS s ON t.SessionIdEnt = s.SessionId JOIN users AS u ON s.userid = u.userid "; else $sql2 = "SELECT t.*, s.datestart FROM " . $table . " as t JOIN session AS s ON t.SessionIdEnt = s.SessionId JOIN users AS u ON s.userid = u.userid "; if ($change) $where = " WHERE (t.sessionid >= $ss1) AND (t.sessionid <= $ss2) AND (t.sessionid <> t.sessionident) AND (u.login = '$user')"; else $where = " WHERE (t.sessionident >= $ss1) AND (t.sessionident <= $ss2) AND (u.login = '$user')"; } //echo $sql2 . $where; if (!$without_total && !$big) { $sql = "SELECT Count(*) AS cnt FROM (" . $sql2 . " " . $where. ") z2323123 "; //echo $sql; $res = pg_query ($conn, $sql); if($row = pg_fetch_assoc($res)) { $cnt = $row['cnt']; } pg_free_result ($res); } if ($page > -1) { $sql2 = "SELECT a.* FROM (SELECT ROW_NUMBER() OVER(" . $srt . ') AS rn, zzz1223.* ' . ' FROM (' . $sql2 . $where . $srt . " LIMIT " . ($rows * $page + ($big ? 1 : 0)) . ' ) AS zzz1223 ' . //' ' . $where . ' ' . ' ) a ' . ' WHERE rn > ' . ($rows * ($page - 1)) . $srt; } else { $sql2 = $sql2 . $where . $srt; } //echo $sql2; $res = pg_query ($conn, $sql2); $data = array(); while($row = pg_fetch_assoc($res)) { if (isset($_GET['astree']) && ($_GET['astree'])) { $row['children'] = Array(); $row['state'] = 'open'; $row['checked'] = true; } $data[] = $row; } if (!$without_total && $big) { if ($page > -1) { $cnt = $rows * ($page - 1) + count($data); if (count($data) > $rows) array_pop($data); } else { $cnt = count($data); } } pg_free_result ( $res); if (!$without_total) { $data = array("total" => $cnt, "rows" => $data); } //print_r($data); $rs = json_encode($data); echo $rs; if ($type == 'telist') { $res = pg_query ($conn, "UPDATE session SET get_te_count = get_te_count + 1 WHERE sessionid = " . $ssid); pg_free_result ($res); } ?>