1
0
Fork 0
MastodonStartpage/web/admin/instances.php

727 lines
30 KiB
PHP
Raw Normal View History

2019-12-26 21:57:36 +01:00
<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
2020-01-08 14:52:20 +01:00
2019-12-26 21:57:36 +01:00
require('include/menu.php');
2020-01-08 14:52:20 +01:00
$menu['istanze']['href']=null;
$menu['istanze']['selected']=true;
2019-12-26 21:57:36 +01:00
buildmenu($menu);
require('include/myconn.php');
2020-01-02 13:19:25 +01:00
2020-01-08 14:52:20 +01:00
$dbg='';
use function mysqli_real_escape_string as myesc;
// praticamente una macro
function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
2020-01-02 22:03:34 +01:00
function nully($val,$fem,$filter,$ntext=null) {
2020-01-02 13:19:25 +01:00
if (!is_null($val)) {
if ($filter=='strip') {
return(strip_tags($val,'<a><br><ol><ul><li><p><i><b><strong><em><small>'));
} elseif ($filter=='htmlchars') {
return(hspech($val));
2020-01-02 22:03:34 +01:00
} elseif ($filter=='timestamp') {
return(strftime('%a %d %b %Y, %T',$val));
} elseif ($filter=='email') {
return('<a href="mailto:'.strip_tags($val).'">'.strip_tags($val).'</a>');
} elseif ($filter=='url') {
return('<a href="'.strip_tags($val).'" target="_blank">'.strip_tags($val).'</a>');
} elseif ($filter=='image') {
return('<img src="'.str_replace('"','\\"',strip_tags($val)).'">');
2020-01-02 22:03:34 +01:00
} elseif ($filter=='boolt') {
if ($val)
return('<span class="good">Si</span>');
else
return('<span class="bad">No</span>');
} elseif ($filter=='boolf') {
if ($val)
return('<span class="bad">Si</span>');
else
return('<span class="good">No</span>');
2020-01-02 13:19:25 +01:00
} else {
return($val);
}
} else {
2020-01-02 22:03:34 +01:00
if (is_null($ntext)) {
if ($fem)
return('<span class="nully">Non definita</span>');
else
return('<span class="nully">Non definito</span>');
}
else {
return('<span class="nully">'.$ntext.'</span>');
}
2020-01-02 13:19:25 +01:00
}
}
function booly($pre,$val,$nottoobad=false,$invcol=false) {
if ($val) {
if (!$invcol) {
$p='<p class="good">';
} else {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
}
return($p.$pre.'SI</p>');
} else {
if (!$invcol) {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
} else {
$p='<p class="good">';
}
return($p.$pre.'NO</p>');
}
}
2020-01-08 14:52:20 +01:00
$dbg.='<pre>'.print_r($_POST,1).'</pre>';
2020-01-02 13:19:25 +01:00
$cols=array(
'New'=>array('name'=>'Nuova','type'=>'bool'),
'Good'=>array('name'=>'Papabile','type'=>'bool'),
'Chosen'=>array('name'=>'Scelta','type'=>'bool'),
'Visible'=>array('name'=>'Visibile','type'=>'bool'),
'Blacklisted'=>array('name'=>'Blacklistata','type'=>'bool'),
'URI'=>array('name'=>'URI','type'=>'text'),
'Title'=>array('name'=>'Titolo','type'=>'text'),
'ShortDesc'=>array('name'=>'Descrizione breve','type'=>'text'),
'LongDesc'=>array('name'=>'Descrizione lunga','type'=>'text'),
'OurDesc'=>array('name'=>'Descrizione nostra','type'=>'text'),
2020-01-08 14:52:20 +01:00
'PlaceID'=>array('name'=>'[Località]','type'=>'join','join'=>array()),
'Places.Locality'=>array('name'=>'Località','type'=>'joini','join'=>array('Places ON Places.ID=Instances.PlaceID'),'subtype'=>'text'),
2020-01-02 13:19:25 +01:00
'Email'=>array('name'=>'Email di contatto','type'=>'text'),
'Software'=>array('name'=>'Software','type'=>'text'),
'Version'=>array('name'=>'Versione','type'=>'text'),
'UserCount'=>array('name'=>'Utenti','type'=>'int'),
'StatusCount'=>array('name'=>'Stati','type'=>'int'),
'DomainCount'=>array('name'=>'Istanze note','type'=>'int'),
'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'int'),
'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'int'),
2020-01-02 22:03:34 +01:00
'Thumb'=>array('name'=>'Logo','type'=>'text'),
2020-01-02 13:19:25 +01:00
'RegOpen'=>array('name'=>'Registrazioni aperte','type'=>'bool'),
'RegReqApproval'=>array('name'=>'Approvazione registrazioni','type'=>'bool'),
'MaxTootChars'=>array('name'=>'Limite caratteri','type'=>'int'),
2020-01-02 22:03:34 +01:00
'AdmAccount'=>array('name'=>'Account admin','type'=>'text'),
'AdmDisplayName'=>array('name'=>'Nome account admin','type'=>'text'),
'AdmCreatedAt'=>array('name'=>'Data creazione account admin','type'=>'time'),
'AdmURL'=>array('name'=>'Pagina delladmin','type'=>'text'),
'AdmAvatar'=>array('name'=>'Avatar admin','type'=>'text'),
'AdmNote'=>array('name'=>'Note delladmin','type'=>'text'),
2020-01-08 14:52:20 +01:00
'LangID'=>array('name'=>'[Lingue dichiarate]','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID')),
'Languages.Code'=>array('name'=>'Lingue dichiarate','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text'),
'OurLangID'=>array('name'=>'[Lingue impostate da noi]','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID')),
'OurLanguages.Code'=>array('name'=>'Lingue impostate da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text'),
'FinID'=>array('name'=>'[Modalità di finanziamento]','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instnces.ID')),
'Financing.Type'=>array('name'=>'Modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instnces.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text'),
'PolID'=>array('name'=>'[Restrizioni sui contenuti]','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID')),
'Policies.Name'=>array('name'=>'Restrizioni sui contenuti','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text'),
'TagID'=>array('name'=>'[Tags]','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID')),
'Tags.Name'=>array('name'=>'Tags','type'=>'join','joini'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text'),
2020-01-08 16:06:09 +01:00
'Statuses'=>array('name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
'Logins'=>array('name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
2020-01-02 13:19:25 +01:00
);
2020-01-08 14:52:20 +01:00
$types=array('bool','int','time','text','join','joini');
$fieldselopts='';
foreach ($cols as $key=>$val) {
2020-01-08 14:52:20 +01:00
if ($val['type']=='joini') {
$fieldselopts.='<option value="'.$key.'§'.$val['type'].'§'.$val['subtype'].'">'.$val['name'].'</option>';
} else {
$fieldselopts.='<option value="'.$key.'§'.$val['type'].'§null">'.$val['name'].'</option>';
}
}
/*
[openpar-1] => null
[fieldsel-1] => New§bool
[condsel-1] => IS
[valuesel-1] => TRUE
[closepar-1] => null
[andor-1] => AND
[openpar-2] => (
[fieldsel-2] => URI§text
[condsel-2] => LIKE
[valueinp-2] => bida
[closepar-2] => null
[andor-2] => OR
[openpar-3] => null
[fieldsel-3] => URI§text
[condsel-3] => IS NULL
[closepar-3] => )
[andor-3] => AND
[openpar-4] => null
[fieldsel-4] => PlaceID§join
[condsel-4] => =
[valuesel-4] => 1
[closepar-4] => null
[andor-4] => AND
[openpar-5] => null
[fieldsel-5] => UserCount§int
[condsel-5] => >=
[valueinp-5] => 123
[closepar-5] => null
[andor-5] => AND
[openpar-6] => null
[fieldsel-6] => LangID§join
[condsel-6] => =
[valuesel-6] => 20
[closepar-6] => null
*/
2020-01-08 16:06:09 +01:00
$sels=array();
2020-01-08 14:52:20 +01:00
$joins=array();
$where='';
foreach ($_POST as $key=>$val) {
if (preg_match('/^openpar-\d+/',$key)===1 && preg_match('/^\(+$/',$val)===1)
$where.=$val;
if (preg_match('/^fieldsel-\d+/',$key)===1 && preg_match('/^(.+)§(.+)§(.+)$/',$val,$buf)===1) {
if (array_key_exists($buf[1],$cols) && in_array($buf[2],$types)) {
$where.=$buf[1];
if ($buf[2]=='join' || $buf[2]=='joini') {
foreach ($cols[$buf[1]]['join'] as $join) {
if (!in_array($join,$joins))
$joins[]=$join;
}
2020-01-08 16:06:09 +01:00
if ($buf[2]=='joini' && array_key_exists('select',$cols[$buf[1]]) && !in_array($cols[$buf[1]]['select'],$sels))
$sels[]=$cols[$buf[1]]['select'];
2020-01-08 14:52:20 +01:00
}
} else {
muoribene($dbg.'<br>Dati POST corrotti.<br>Puoi <a href="instances.php">riprovare</a> o <a href="index.php">tornare al login</a>.',true);
}
}
if (preg_match('/^condsel-\d+/',$key)===1) {
$where.=' '.$val.' ';
$cond=$val;
}
if (preg_match('/^valuesel-\d+/',$key)===1)
$where.=$val;
if (preg_match('/^valueinp-\d+/',$key)===1) {
if (preg_match('/^(LIKE|NOT LIKE)$/',$cond)===1)
$where.='\'%'.myesc($link,$val).'%\'';
else
$where.='\''.myesc($link,$val).'\'';
}
if (preg_match('/^closepar-\d+/',$key)===1 && preg_match('/^\)+$/',$val)===1)
$where.=$val;
if (preg_match('/^andor-\d+/',$key)===1 && preg_match('/^(AND|OR)$/',$val)===1)
$where.=' '.$val.' ';
}
2020-01-08 16:06:09 +01:00
if (count($sels)>0)
$sels=', '.implode(', ',$sels);
else
$sels='';
2020-01-08 14:52:20 +01:00
if ($where!='')
$where='WHERE '.$where;
if (count($joins)>0)
$joins='LEFT JOIN '.implode(' LEFT JOIN ',$joins);
else
$joins='';
2020-01-08 16:06:09 +01:00
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID ORDER BY Instances.URI ASC LIMIT 50';
2020-01-08 14:52:20 +01:00
$dbg.='QUERONA: '.$query.'<br>'.N;
$res=mysqli_query($link,$query)
or muoribene($dbg.'<br>'.$query.': '.mysqli_error($link),true);
2019-12-26 21:57:36 +01:00
if (mysqli_num_rows($res)<1) {
$out='<p>Nessuna istanza da mostrare.</p>'.N;
} else {
$out='';
2019-12-26 21:57:36 +01:00
while ($row=mysqli_fetch_assoc($res)) {
$out.='<table class="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
2020-01-08 14:52:20 +01:00
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].' {'.$row['IID'].'}</td></tr>'.N;
2020-01-02 13:19:25 +01:00
$attr=booly($cols['Blacklisted']['name'].': ',$row['Blacklisted'],false,true).N;
$attr.=booly($cols['New']['name'].': ',$row['New'],true).N;
$attr.=booly($cols['Good']['name'].': ',$row['Good']).N;
$attr.=booly($cols['Chosen']['name'].': ',$row['Chosen']).N;
$attr.=booly($cols['Visible']['name'].': ',$row['Visible']).N;
2020-01-02 22:03:34 +01:00
/* $attr.=booly($cols['RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
$csres=mysqli_num_rows($sres);
if ($csres>0) {
$bene=0;
while ($srow=mysqli_fetch_assoc($sres)) {
if ($srow['Status']==1)
$bene++;
}
$width=str_replace(',','.',100/$csres*$bene);
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check: '.round($width,1).'%</div>';
$attr.='<div class="percbg"><div class="percfg" style="width:'.$width.'%;"></div></div>'.N;
mysqli_data_seek($sres,0);
$srow=mysqli_fetch_assoc($sres);
$attr.='<div class="colsectcont">Ultimo check '.strftime('%e %b %Y, %T',$srow['Time']).': '.(($srow['Status']) ? '<span class="good">OK</span>' : '<span class="bad">KO</span>').'</div>';
} else {
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check</div>';
$attr.='<div class="colsectcont nully">Non disponibile (?!?!?!)</div>'.N;
}
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
2020-01-02 22:03:34 +01:00
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
2020-01-02 22:03:34 +01:00
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
2020-01-02 22:03:34 +01:00
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont">Stati: '.$tot['tstatuses'].'<br>Accessi: '.$tot['tlogins'].'<br>Registrazioni: '.$tot['tregs'].'</div>'.N;
2020-01-02 22:03:34 +01:00
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcontb">'.strftime('%e %b %Y',$srow['Week']).'</div>'.N;
2020-01-02 22:03:34 +01:00
($tot['tstatuses']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tstatuses']*$srow['Statuses']);
$attr.='<div class="percstatuses" style="width:'.$width.'%;">'.$srow['Statuses'].'&nbsp;stati</div>'.N;
($tot['tlogins']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tlogins']*$srow['Logins']);
$attr.='<div class="perclogins" style="width:'.$width.'%;">'.$srow['Logins'].'&nbsp;accessi</div>'.N;
($tot['tregs']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tregs']*$srow['Registrations']);
$attr.='<div class="percregs" style="width:'.$width.'%;">'.$srow['Registrations'].'&nbsp;registrazioni</div>'.N;
}
} else {
$attr.='<div class="colsectcont nully">Non disponibile</div>'.N;
2020-01-02 22:03:34 +01:00
}
$attr.='<div class="colsectheader">Hashtags più usati durante lultima settimana</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstTrends WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont"><ol>'.N;
2020-01-02 22:03:34 +01:00
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<li><a href="'.$srow['URL'].'">'.hspech($srow['Name']).'</a></li>'.N;
2020-01-02 22:03:34 +01:00
}
$attr.='</ol></div>'.N;
} else {
$attr.='<div class="colsectcont nully">Non disponibili</div>'.N;
2020-01-02 22:03:34 +01:00
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</div>'.N;
// 'strip' o 'htmlent' per la descrizione nostra?
$out.='<div class="baloo"><span class="ourfield">'.$cols['OurDesc']['name'].':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.$cols['PlaceID']['name'].':</span> '.nully($row['PlaceID'],true,'strip').'</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Code'].' ['.ucfirst(locale_get_display_name($srow['Code'])).']');
}
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="field">'.$cols['LangID']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="field">'.$cols['LangID']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
2020-01-08 14:52:20 +01:00
$sres=mysqli_query($link,'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Code'].' ['.ucfirst(locale_get_display_name($srow['Code'],'it')).']');
}
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['OurLangID']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['OurLangID']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Type']).' ('.hspech($row['Details']).')';
}
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['FinID']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['FinID']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['PolID']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['PolID']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
2020-01-08 14:52:20 +01:00
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['TagID']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
2020-01-08 14:52:20 +01:00
$out.='<div class="baloo"><span class="ourfield">'.$cols['TagID']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$out.='<div class="baloo"><span class="field">'.$cols['Email']['name'].':</span> '.nully($row['Email'],true,'email').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],false,'image').'</div>'.N;
$out.='<div><span class="field">'.$cols['AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</div>'.N;
2020-01-02 22:03:34 +01:00
$out.='</td></tr>'.N;
$out.='</tbody>'.N;
$out.='</table>'.N;
2019-12-26 21:57:36 +01:00
}
2020-01-08 14:52:20 +01:00
$out.='<div class="bigtabfoot"></div>';
2019-12-26 21:57:36 +01:00
}
2020-01-02 22:03:34 +01:00
mysqli_close($link);
2019-12-26 21:57:36 +01:00
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Istanze</title>
2019-12-26 21:57:36 +01:00
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
2020-01-08 14:52:20 +01:00
<script language="JavaScript" src="js/confirma.js?v=<?php echo($cjrand); ?>"></script>
2019-12-26 21:57:36 +01:00
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript">
<!--
function chulsh(el,sh) {
if (sh)
el.querySelector('ul').style='display:block';
else
el.querySelector('ul').style='display:none';
}
function ulsh(el,sh) {
if (sh)
el.style='display:block';
else
el.style='display:none';
}
function golang(lang) {
var loc=document.location.href;
loc=loc.replace(/#.*$/,'');
loc=loc.replace(/\/$/,'');
if (document.documentElement.lang=='en') {
if (lang!='en')
document.location.href=loc+'/'+lang;
} else {
if (lang!='en')
document.location.href=loc.substr(0,loc.length-3)+'/'+lang;
else
document.location.href=loc.substr(0,loc.length-3);
}
}
2020-01-08 14:52:20 +01:00
function shideplancia() {
var plancia=document.getElementById('plancia');
var rightdiv=document.getElementById('rightdiv');
if (plancia.style.display=='block') {
plancia.style.display='none';
rightdiv.innerHTML='Mostra plancia';
} else {
plancia.style.display='block';
rightdiv.innerHTML='Nascondi plancia';
}
}
function truncsel(el) {
var sel=document.getElementById(el), len=sel.length, i=0;
for (i=len-1; i>=0; i--)
sel.remove(i);
}
function addselopt(el,val,txt) {
2020-01-08 14:52:20 +01:00
option=new Option(txt,val);
el.add(option);
}
function inpdisif(index) {
2020-01-08 14:52:20 +01:00
var source=document.getElementById('condsel-'+index);
2020-01-08 16:06:09 +01:00
var inp=document.getElementById('valueinp-'+index);
var sel=document.getElementById('valuesel-'+index);
var conds=['IS NULL','IS NOT NULL'];
if (conds.includes(source.value)) {
2020-01-08 16:06:09 +01:00
inp.disabled=true;
sel.disabled=true;
} else {
2020-01-08 16:06:09 +01:00
if (inp.style.display!='none') inp.disabled=false;
if (sel.style.display!='none') sel.disabled=false;
}
}
function popusels(index) {
console.log('Index: '+index);
2020-01-08 14:52:20 +01:00
var key=document.getElementById('fieldsel-'+index).value;
var type=key.replace(/^.*§(.*)§.*$/,'$1');
var subtype=key.replace(/^.*§.*§(.*)$/,'$1');
key=key.replace(/^(.*)§.*§.*$/,'$1');
var condsel=document.getElementById('condsel-'+index);
var valsel=document.getElementById('valuesel-'+index);
var valinp=document.getElementById('valueinp-'+index);
if (type=='joini')
type=subtype;
if (type=='bool') {
2020-01-08 14:52:20 +01:00
truncsel('condsel-'+index);
addselopt(condsel,'IS','è');
2020-01-08 14:52:20 +01:00
truncsel('valuesel-'+index);
addselopt(valsel,'TRUE','vero');
addselopt(valsel,'FALSE','falso');
2020-01-08 14:52:20 +01:00
addselopt(valsel,'NOT NULL','definito');
addselopt(valsel,'NULL','non definito');
valinp.style='display:none';
valinp.disabled=true;
valsel.style='display:block';
valsel.disabled=false;
condsel.removeAttribute('onchange');
} else if (type=='text') {
2020-01-08 14:52:20 +01:00
truncsel('condsel-'+index);
addselopt(condsel,'LIKE','contiene');
addselopt(condsel,'NOT LIKE','non contiene');
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è diverso da');
2020-01-08 16:06:09 +01:00
addselopt(condsel,'>=','è maggiore o uguale a');
addselopt(condsel,'<=','è minore o uguale a');
addselopt(condsel,'>','è maggiore di');
addselopt(condsel,'<','è minore di');
addselopt(condsel,'IS NOT NULL','è definito');
addselopt(condsel,'IS NULL','non è definito');
valsel.style='display:none';
valsel.disabled=true;
valinp.style='display:block';
valinp.disabled=false;
condsel.setAttribute('onchange','inpdisif('+index+');');
} else if (type=='int' || type=='time') {
2020-01-08 14:52:20 +01:00
truncsel('condsel-'+index);
2020-01-08 16:06:09 +01:00
addselopt(condsel,'>=','è maggiore o uguale a');
addselopt(condsel,'<=','è minore o uguale a');
addselopt(condsel,'>','è maggiore di');
addselopt(condsel,'<','è minore di');
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è diverso da');
addselopt(condsel,'IS NOT NULL','è definito');
addselopt(condsel,'IS NULL','non è definito');
valsel.style='display:none';
valsel.disabled=true;
valinp.style='display:block';
valinp.disabled=false;
condsel.setAttribute('onchange','inpdisif('+index+');');
2020-01-08 14:52:20 +01:00
} else if (type=='join') {
truncsel('condsel-'+index);
2020-01-08 16:06:09 +01:00
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è diverso da');
2020-01-08 14:52:20 +01:00
addselopt(condsel,'IS NOT NULL','è definito');
addselopt(condsel,'IS NULL','non è definito');
valsel.style='display:block';
valsel.disabled=false;
valinp.style='display:none';
valinp.disabled=true;
condsel.setAttribute('onchange','inpdisif('+index+');');
truncsel('valuesel-'+index);
document.getElementById('helper').setAttribute('src','instancesh.php?key='+key+'&parsel=valuesel-'+index);
} else {
alert('Attenziò: non so che farmene del tipo "'+type+'": diglielo, al programmatore.');
}
}
function addrow(index) {
2020-01-08 14:52:20 +01:00
var table=document.getElementById('planciafil');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
var newcell4=newrow.insertCell(4);
var newcell5=newrow.insertCell(5);
var newcell6=newrow.insertCell(6);
var newcell7=newrow.insertCell(7);
newcell0.innerHTML='<select class="openpar"><option value="null"></option><option value="(">(</option><option value="((">((</option><option value="(((">(((</option></select>';
newcell1.innerHTML='<select class="fieldsel"><?php echo($fieldselopts); ?></select>';
newcell2.innerHTML='<select class="condsel"></select>';
2020-01-08 14:52:20 +01:00
newcell3.innerHTML='<select class="valuesel" style="display:none;"></select><input type="text" class="valueinp" maxlength="256" style="display:none;">';
newcell4.innerHTML='<select class="closepar"><option value="null"></option><option value=")">)</option><option value="))">))</option><option value=")))">)))</option></select>';
newcell5.innerHTML='<select class="andor"><option value="AND">E</option><option value="OR">O</option></select>';
newcell6.innerHTML='<img class="plus" src="imgs/plus.svg">';
newcell7.innerHTML='<img class="minus" src="imgs/minus.svg">';
synctai();
popusels(index);
}
function synctai() {
var i=0;
2020-01-08 14:52:20 +01:00
var table=document.getElementById('planciafil');
var nodes=table.querySelectorAll('.minus');
var cnodes=nodes.length;
for (i=0; i<cnodes; i++)
// +1 sempre per via della row iniziale
nodes[i].setAttribute('onclick','remrow('+(i+1)+');');
nodes=table.querySelectorAll('.plus');
for (i=0; i<cnodes; i++)
// +2 perché la devi aggiungere dopo la corrente
nodes[i].setAttribute('onclick','addrow('+(i+2)+');');
// da qui in poi faccio a scendere per non avere mai id e nomi duplicati
cnodes--;
nodes=table.querySelectorAll('.openpar');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','openpar-'+(i+1));
nodes[i].setAttribute('name','openpar-'+(i+1));
}
nodes=table.querySelectorAll('.fieldsel');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','fieldsel-'+(i+1));
nodes[i].setAttribute('name','fieldsel-'+(i+1));
nodes[i].setAttribute('onchange','popusels('+(i+1)+');');
}
nodes=table.querySelectorAll('.condsel');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','condsel-'+(i+1));
nodes[i].setAttribute('name','condsel-'+(i+1));
}
nodes=table.querySelectorAll('.valuesel');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','valuesel-'+(i+1));
nodes[i].setAttribute('name','valuesel-'+(i+1));
}
nodes=table.querySelectorAll('.valueinp');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','valueinp-'+(i+1));
nodes[i].setAttribute('name','valueinp-'+(i+1));
}
nodes=table.querySelectorAll('.closepar');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','closepar-'+(i+1));
nodes[i].setAttribute('name','closepar-'+(i+1));
}
nodes=table.querySelectorAll('.andor');
for (i=cnodes; i>-1; i--) {
2020-01-08 14:52:20 +01:00
nodes[i].setAttribute('id','andor-'+(i+1));
nodes[i].setAttribute('name','andor-'+(i+1));
nodes[i].disabled=false;
}
2020-01-08 14:52:20 +01:00
if (cnodes>=0)
nodes[cnodes].disabled=true;
}
function remrow(index) {
2020-01-08 14:52:20 +01:00
var table=document.getElementById('planciafil');
table.deleteRow(index);
synctai();
2020-01-08 14:52:20 +01:00
if (table.rows.length<2)
document.getElementById('filbut').value='Aggiungi criteri di ricerca';
}
function truncfil() {
var table=document.getElementById('planciafil');
while (table.rows.length>1)
remrow(1);
}
function manfil() {
var filbut=document.getElementById('filbut');
var table=document.getElementById('planciafil');
var crows=table.rows.length;
if (crows<2) {
addrow(1);
filbut.value='Rimuovi tutti i criteri di ricerca';
} else {
confirma('Confermi di voler rimuovere tutti i criteri di ricerca?','truncfil();filbut.value=\'Aggiungi criteri di ricerca\'');
}
}
function ckf() {
document.getElementById('f').submit();
}
2019-12-26 21:57:36 +01:00
//-->
</script>
</head>
<body>
<nav>
<div id="hmenu">
<ul>
<?php echo($menuout); ?>
</ul>
2020-01-08 14:52:20 +01:00
<div id="rightdiv" onclick="shideplancia();">Mostra plancia</div>
2019-12-26 21:57:36 +01:00
</div>
</nav>
2020-01-08 14:52:20 +01:00
<div id="popup">
<div id="inpopup">
<div id="popupcont">
...
</div>
</div>
</div>
<iframe name="helper" id="helper"></iframe>
2019-12-26 21:57:36 +01:00
<div id="footer">
<form action="edinst.php" name="addinst" method="post">
<table><tr><td>Aggiungi unistanza:</td><td><input type="text" name="URI" maxlength="512"></td><td><input type="button" value="Vai" onClick="ckaif();"></td></tr></table>
</form>
</div>
2020-01-08 14:52:20 +01:00
<div id="debug">
<?php echo($dbg); ?>
</div>
<div id="fullscreen">
<div id="middlerow">
<form method="post" id="f">
2020-01-08 14:52:20 +01:00
<div id="plancia">
<table id="planciafil" class="planciatab">
<tr><td colspan="8"><input type="button" id="filbut" value="Aggiungi criteri di ricerca" class="ctrlbut" onclick="manfil();"></td></tr>
</table>
2020-01-08 14:52:20 +01:00
<table id="planciaord" class="planciatab">
<tr><td colspan="8"><input type="button" id="ordbut" value="Aggiungi criteri di ordinamento" class="ctrlbut" onclick="alert('Aspetta!')"></td></tr>
</table>
<table id="planciaothers" class="planciatab">
<tr><td><input type="button" id="subbut" value="Applica" class="ctrlbut" onclick="ckf();"></td></tr>
</table>
</div>
</form>
<?php echo($out); ?>
</div>
</div>
2019-12-26 21:57:36 +01:00
</body>
</html>