Browse Source

Lista istanze più compatta

pezcurrel 4 years ago
parent
commit
b8e9218112
3 changed files with 176 additions and 23 deletions
  1. 1 1
      web/admin/include/glob.php
  2. 99 11
      web/admin/instances.php
  3. 76 11
      web/admin/theme.css

+ 1 - 1
web/admin/include/glob.php

@@ -3,7 +3,7 @@
 header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
 header("Pragma: no-cache"); // HTTP 1.0.
 header("Expires: 0"); // Proxies.
-
+setlocale(LC_ALL,'it','it_IT','it_IT.UTF-8');
 define('N',"\n");
 $cjrand=rand(0,999999);
 

+ 99 - 11
web/admin/instances.php

@@ -8,17 +8,43 @@ buildmenu($menu);
 
 require('include/myconn.php');
 
-function nully($val,$filter='') {
+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 {
-		return('<span class="nully">Non definito</span>');
+		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>');
+		}
 	}
 }
 
@@ -68,36 +94,98 @@ $cols=array(
 	'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'=>'image'),
+	'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'),
-
+	'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 dell’admin','text'),
+	'AdmAvatar'=>array('name'=>'Avatar admin','text'),
+	'AdmNote'=>array('name'=>'Note dell’admin','text')
 );
 
-$res=mysqli_query($link,'SELECT * FROM Instances LEFT JOIN Places ON Places.ID=PlaceID ORDER BY URI ASC')
+$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);
-mysqli_close($link);
 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>'.$cols['URI']['name'].'</th><th>'.$cols['Title']['name'].'</th><th>'.$cols['OurDesc']['name'].'</th><th>'.$cols['ShortDesc']['name'].'</th><th>'.$cols['LongDesc']['name'].'</th></tr></thead>'.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;
-		$out.='<tr><td class="tdattr">'.$attr.'</td><td><a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></td><td>'.nully($row['Title'],'strip').'</td><td>'.nully($row['OurDesc'],'htmlent').'</td><td>'.nully($row['ShortDesc'],'strip').'</td><td>'.nully($row['LongDesc'],'strip').'</td></tr>'.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>

+ 76 - 11
web/admin/theme.css

@@ -21,7 +21,7 @@ h1,h2,h3,h4,h5,h6 {
 }
 a {
 	text-decoration: none;
-	color: red;
+	color: blue;
 }
 a:hover {
 	text-decoration: underline;
@@ -31,14 +31,21 @@ ul {
 	padding-left: 0;
 	margin-left: 14pt;
 }
+p {
+	margin-bottom: 10px;
+}
 #bigtab {
 	background-color: white;
 	font-size: 10pt;
+	margin-left: auto;
+	margin-right: auto;
+	max-width: 100%;
+	margin-bottom: 40px;
 }
 #bigtab thead {
 	padding: 3px;
-	position: sticky;
-	top: 40px;
+/*	position: sticky;
+	top: 40px;*/
 	color: white;
 	height: 30px;
 }
@@ -46,24 +53,39 @@ ul {
 	background-color: #916f6f;
 	border-radius: 5px;
 }
+#bigtab .insthead {
+	padding: 3px;
+	color: white;
+	height: 30px;
+	background-color: #916f6f;
+	border-radius: 5px;
+	text-align: center;
+	vertical-align: middle;
+	color: white;
+	font-size: 12pt;
+	font-weight: bold;
+}
 #bigtab td {
 	padding: 3px;
 	text-align: left;
 	vertical-align: top;
-	word-wrap: break-word;
-	max-width: 300px;
-	min-width: 200px;
+	word-break: break-word;
+	width: 300px;
 	background-color: lightgrey;
 	border-radius: 5px;
 }
+#bigtab td p {
+	margin-bottom: 3px;
+	padding-bottom: 3px;
+	border-bottom: 1px solid grey;
+}
 #bigtab .tdattr {
-	min-width: 130px;
-	max-width: 130px;
+	width: 110px;
 }
 .good, .bad, .neut {
-	padding: 3px;
+	padding: 1px;
 	margin-bottom: 3px;
-	border-radius: 5px;
+	border-radius: 3px;
 }
 .good {
 	background-color: #87DE87;
@@ -74,6 +96,49 @@ ul {
 .neut {
 	background-color: #FFCCAA;
 }
+.field {
+	padding: 1px;
+	border-radius: 3px;
+	background-color: #FFEEAA;
+	color: black;
+}
+.percstatuses, .perclogins, .percregs {
+	height: 12px;
+	line-height: 12px;
+	vertical-align: middle;
+	font-size: 6pt;
+	word-break: keep-all;
+	overflow-x: visible;
+}
+.percstatuses {
+	background-color: #FF8080;
+}
+.perclogins {
+	background-color: #99FF55;
+}
+.percregs {
+	background-color: #80B3FF;
+}
+.colsectheader, .colsectcont {
+	width: 100%;
+	font-size: 6pt;
+	text-align: center;
+}
+.colsectheader {
+	border-top: 1px solid grey;
+	margin-top: 5px;
+	padding-top: 3px;
+	font-weight: bold;
+}
+.percbg, .percfg {
+	margin-top: 2px;
+	width: 100%;
+	height: 16px;
+	background-color: #C83737;
+}
+.percfg {
+	background-color: #44AA00;
+}
 #fullscreen, #fullscreenm {
 	width: 100%;
 	height: 100%;
@@ -177,7 +242,7 @@ input {
 }
 .nully {
 	font-style: italic;
-	color: #333333;
+	color: #666666;
 }
 
 #hmenu {