1
0
Fork 0
MastodonStartpage/web/admin/instances.php
2020-01-02 22:03:34 +01:00

256 lines
11 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/menu.php');
buildmenu($menu);
require('include/myconn.php');
function nully($val,$fem,$filter,$ntext=null) {
if (!is_null($val)) {
if ($filter=='strip') {
return(strip_tags($val,'<a><br><ol><ul><li>'));
} elseif ($filter=='htmlent') {
return(htmlentities($val));
} 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)).'" width="294">');
} 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>');
} else {
return($val);
}
} else {
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>');
}
}
}
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>');
}
}
$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'),
'PlaceID'=>array('name'=>'Località','type'=>'select'),
'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'=>'number'),
'StatusCount'=>array('name'=>'Stati','type'=>'number'),
'DomainCount'=>array('name'=>'Istanze note','type'=>'number'),
'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'number'),
'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'number'),
'Thumb'=>array('name'=>'Logo','type'=>'text'),
'RegOpen'=>array('name'=>'Registrazioni aperte','type'=>'bool'),
'RegReqApproval'=>array('name'=>'Approvazione registrazioni','type'=>'bool'),
'MaxTootChars'=>array('name'=>'Limite caratteri','type'=>'number'),
'AdmAccount'=>array('name'=>'Account admin','type'=>'text'),
'AdmDisplayName'=>array('name'=>'Nome account admin','type'=>'text'),
'AdmCreatedAt'=>array('name'=>'Data creazione account admin','type'=>'timestamp'),
'AdmURL'=>array('name'=>'Pagina delladmin','text'),
'AdmAvatar'=>array('name'=>'Avatar admin','text'),
'AdmNote'=>array('name'=>'Note delladmin','text')
);
$res=mysqli_query($link,'SELECT *, Instances.ID AS IID FROM Instances LEFT JOIN Places ON Places.ID=PlaceID ORDER BY URI ASC LIMIT 50')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($res)<1) {
$out='<p>Nessuna istanza da mostrare.</p>'.N;
} else {
$out='<table id="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
while ($row=mysqli_fetch_assoc($res)) {
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].'</td></tr>'.N;
$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;
/* $attr.=booly($cols['RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
or muoribene(mysqli_error($link),false);
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
$attr.='<div class="colsectcont">Totale stati: '.$tot['tstatuses'].'<br>Totale accessi: '.$tot['tlogins'].'<br>Totale registrazioni: '.$tot['tregs'].'</div>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcont"> '.strftime('%a %d %b %Y',$srow['Week']).' </div>'.N;
($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;
}
}
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
or muoribene(mysqli_error($link),false);
$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;
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
$out.='<p><span class="field">'.$cols['URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></p>'.N;
$out.='<p><span class="field">'.$cols['Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['OurDesc']['name'].':</span> '.nully($row['OurDesc'],true,'htmlent').'</p>'.N;
$out.='<p><span class="field">'.$cols['ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['PlaceID']['name'].':</span> '.nully($row['PlaceID'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Email']['name'].':</span> '.nully($row['Email'],true,'email').'</p>'.N;
$out.='<p><span class="field">'.$cols['Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</p>'.N;
$out.='<p><span class="field">'.$cols['RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</p>'.N;
$out.='<p><span class="field">'.$cols['RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</p>'.N;
$out.='<p><span class="field">'.$cols['MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],true,'image').'</p>'.N;
$out.='<p style="border: none; margin: 0; padding: 0;"><span class="field">'.$cols['AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</p>'.N;
$out.='</td></tr>'.N;
}
$out.='</tbody>'.N;
$out.='</table>'.N;
}
mysqli_close($link);
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Main Menu</title>
<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">
<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);
}
}
//-->
</script>
</head>
<body>
<nav>
<div id="hmenu">
<ul>
<?php echo($menuout); ?>
</ul>
</div>
</nav>
<div id="fullscreenm">
<div id="middlerow">
<?php echo($out); ?>
</div>
</div>
<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>
</body>
</html>