MastodonStartpage/web/admin/instancesh.php

50 lines
4 KiB
PHP
Raw Normal View History

2020-01-08 14:52:20 +01:00
<?php
2020-01-11 00:51:02 +01:00
header('Content-Type: application/json; charset=utf-8');
2020-01-08 14:52:20 +01:00
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
$cols=array(
2020-01-11 20:05:15 +01:00
2020-04-03 10:59:02 +02:00
'Instances.LocalityID'=>array('select'=>'SELECT Localities.ID AS Lid, CONCAT(NameOrig,\' (\',State,\') (\',COUNT(Localities.ID),\')\') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID LEFT JOIN States ON States.ID=Localities.StateID WHERE Instances.LocalityID IS NOT NULL GROUP BY Lid ORDER BY States.State ASC, Localities.NameOrig ASC','optcol'=>'Lid','txtcol'=>'Txt'),
2020-01-13 17:16:33 +01:00
2020-03-24 23:22:07 +01:00
'States.ID'=>array('select'=>"SELECT States.ID AS Sid, CONCAT(State,' (',COUNT(States.ID),')') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID LEFT JOIN States ON States.ID=Localities.StateID WHERE Instances.LocalityID IS NOT NULL GROUP BY Sid ORDER BY States.State ASC",'optcol'=>'Sid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstLangs.LangID'=>array('select'=>'SELECT Languages.ID AS Lid, CONCAT(Code, \' [\', NameIT, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID GROUP BY Languages.ID ORDER BY Code ASC','optcol'=>'Lid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstLangs.LangID.First'=>array('select'=>'SELECT Languages.ID AS Lid, CONCAT(Code, \' [\', NameIT, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstLangs.Pos=1 GROUP BY Languages.ID ORDER BY Code ASC','optcol'=>'Lid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstOurLangs.OurLangID'=>array('select'=>'SELECT Languages.ID AS Lid, CONCAT(Code, \' [\', NameIT, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID GROUP BY Languages.ID ORDER BY Code ASC','optcol'=>'Lid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstOurLangs.OurLangID.First'=>array('select'=>'SELECT Languages.ID AS Lid, CONCAT(Code, \' [\', NameIT, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Code ASC','optcol'=>'Lid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstFinancing.FinID'=>array('select'=>'SELECT Financing.ID AS Fid, CONCAT(Type,\' (\',COUNT(Financing.ID),\')\') AS Txt FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID GROUP BY Financing.ID ORDER BY Type ASC','optcol'=>'Fid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstFinancing.FinID.First'=>array('select'=>'SELECT Financing.ID AS Fid, CONCAT(Type,\' (\',COUNT(Financing.ID),\')\') AS Txt FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstFinancing.Pos=1 GROUP BY Financing.ID ORDER BY Type ASC ','optcol'=>'Fid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstPolicies.PolID'=>array('select'=>'SELECT Policies.ID AS Pid, CONCAT(Name,\' (\',COUNT(Policies.ID),\')\') AS Txt FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID GROUP BY Policies.ID ORDER BY Name ASC','optcol'=>'Pid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstPolicies.PolID.First'=>array('select'=>'SELECT Policies.ID AS Pid, CONCAT(Name,\' (\',COUNT(Policies.ID),\')\') AS Txt FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstPolicies.Pos=1 GROUP BY Policies.ID ORDER BY Name ASC','optcol'=>'Pid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstTags.TagID'=>array('select'=>'SELECT Tags.ID AS Tid, CONCAT(Name,\' (\',COUNT(Tags.ID),\')\') AS Txt FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID GROUP BY (Tags.ID) ORDER BY Name ASC','optcol'=>'Tid','txtcol'=>'Txt'),
2020-01-11 20:05:15 +01:00
'InstTags.TagID.First'=>array('select'=>'SELECT Tags.ID AS Tid, CONCAT(Name,\' (\',COUNT(Tags.ID),\')\') AS Txt FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstTags.Pos=1 GROUP BY (Tags.ID) ORDER BY Name ASC','optcol'=>'Tid','txtcol'=>'Txt'),
2020-01-08 14:52:20 +01:00
);
if (array_key_exists('key',$_GET) && array_key_exists($_GET['key'],$cols)) {
2020-01-08 14:52:20 +01:00
require('include/myconn.php');
$res=mysqli_query($link,$cols[$_GET['key']]['select'])
or muoribene(mysqli_error($link),true);
mysqli_close($link);
$buf=array();
while ($row=mysqli_fetch_assoc($res))
$buf[]=array($row[$cols[$_GET['key']]['optcol']],$row[$cols[$_GET['key']]['txtcol']]);
echo(json_encode($buf));
2020-01-08 14:52:20 +01:00
}
exit(0);
2020-01-08 14:52:20 +01:00
?>