Added fnum function to improve localized numeric representations
This commit is contained in:
parent
e4b7aa2367
commit
adbdac96c8
1 changed files with 7 additions and 20 deletions
|
@ -3,6 +3,7 @@
|
|||
$bt=microtime(true);
|
||||
|
||||
require('mustard/include/n2es.php');
|
||||
require('lib/fnum.php');
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
/*$dlang='fr';
|
||||
|
@ -153,27 +154,13 @@ function strip($str,$uri) {
|
|||
return($str);
|
||||
}
|
||||
|
||||
function pnum($num) {
|
||||
$num.='';
|
||||
$pnum='';
|
||||
$li=strlen($num)-1;
|
||||
$cc=1;
|
||||
for ($i=$li; $i>=0; $i--) {
|
||||
$pnum=$num[$i].$pnum;
|
||||
if ($cc==3 && $i>0) $pnum='.'.$pnum;
|
||||
$cc++;
|
||||
if ($cc==4) $cc=1;
|
||||
}
|
||||
return($pnum);
|
||||
}
|
||||
|
||||
$link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muorimeglio(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||||
mysqli_set_charset($link,'utf8mb4');
|
||||
|
||||
$res=mysqli_query($link,'SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE Instances.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
echo(_('<div id="help" class="helpd"><p class="intro">This is our search engine for Mastodon instances. It works this way: data of already indexed instances gets updated every night, and a shuffling occurs for the “random ordering”; also, once a week, during the night between Tuesday and Wednesday, new instances get searched for and added to the database.</p><p class="intro">Advanced search criteria are customizable, but by default they reflect our fondness for a decentralized and egalitarian Fediverse; with our blacklist we try to not give visibility to instances accepting fascist, racist, sexist, ableist, sovereignist contents.</p></div>').N);
|
||||
printf(_('<p class="introe">We currently count <span class="statd">%s</span> Mastodon instances, with <span class="statd">%s</span> users (<span class="statd">%s</span> active during last month) and <span class="statd">%s</span> published statuses.</p>').N, pnum($row['tinsts']), pnum($row['tusers']), pnum($row['tactusers']), pnum($row['tstatuses']));
|
||||
printf(_('<p class="introe">We currently count <span class="statd">%s</span> Mastodon instances, with <span class="statd">%s</span> users (<span class="statd">%s</span> active during last month) and <span class="statd">%s</span> published statuses.</p>').N, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||
|
||||
// <p class="intro">Nella prima versione stabile daremo a* admin delle istanze compatibili con questa politica la possibilità di descrivere ulteriormente la propria istanza con questi campi, tutti facoltativi: “Descrizione in inglese” (per le istanze la cui descrizione è in altre lingue), “Località” (se l’istanza è particolarmente legata a un territorio), “Lingue” (se le lingue utilizzate prevalentemente sull’istanza non corrispondono a quelle rilevate automaticamente dal nostro crawler), “Modalità di copertura dei costi” (per esempio “Autonoma”, “Sottoscrizioni volontarie degli utenti”, “Iniziative benefit”), “Regole sui contenuti” (per esempio “Tag NSFW per i nudi”, “No link a siti di partiti politici”, “No pubblicità”, “Content Warning prima degli spoiler”), e “Categorie” (per esempio “Generalista”, “Astronomia”, “Politica”, “Musica folk”).</p>
|
||||
// daremo la possibilità di segnalarci le istanze su cui sono accettati contenuti di questo tipo
|
||||
|
@ -472,15 +459,15 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
|||
(!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
|
||||
$out.='</div>'.N;*/
|
||||
$out.='<div><span class="ilab">'._('Languages').'</span> '.nully(implode(', ',$buf)).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Users').'</span> '.nully($row['UserCount']).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Active users (last month)').'</span> '.nully($row['ActiveUsersMonth']).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Active users (last six months)').'</span> '.nully($row['ActiveUsersHalfYear']).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Known instances').'</span> '.nully($row['DomainCount']).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Users').'</span> '.nully(fnum($row['UserCount'],0,$dlang)).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Active users (last month)').'</span> '.nully(fnum($row['ActiveUsersMonth'],0,$dlang)).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Active users (last six months)').'</span> '.nully(fnum($row['ActiveUsersHalfYear'],0,$dlang)).'</div>'.N;
|
||||
$out.='<div><span class="ilab">'._('Known instances').'</span> '.nully(fnum($row['DomainCount'],0,$dlang)).'</div>'.N;
|
||||
$out.='</div>'.N;
|
||||
|
||||
$out.='<div class="icol">'.N;
|
||||
$out.='<div><span class="ilab">'._('Characters per toot (max)').'</span> ';
|
||||
if (nullemp($row['MaxTootChars']))
|
||||
if (nullemp(fnum($row['MaxTootChars'],0,$dlang)))
|
||||
$out.='<span class="null">500</span>';
|
||||
else
|
||||
$out.=$row['MaxTootChars'];
|
||||
|
|
Loading…
Reference in a new issue