Dropped Instances.Dead, using Instances.LastOkCheckTS now instead
This commit is contained in:
parent
9b3cca9a45
commit
1e1b2a99e9
8 changed files with 67 additions and 61 deletions
|
@ -23,6 +23,7 @@ define('CHILD','getinstinfo.php');
|
|||
define('LIBDP','/../site/mustard/include');
|
||||
|
||||
require(__DIR__.LIBDP.'/ght.php');
|
||||
require(__DIR__.LIBDP.'/gracetime.php');
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
|
||||
|
@ -40,6 +41,7 @@ if (function_exists('pcntl_signal')) {
|
|||
$msglevs=['debug', 'info', 'warning', 'error', 'none'];
|
||||
|
||||
$opts=[
|
||||
'gracetime'=>$gracetime,
|
||||
'poolsize'=>20,
|
||||
'moreclauses'=>'',
|
||||
'peersfp'=>null,
|
||||
|
@ -66,6 +68,10 @@ OPTIONS
|
|||
|
||||
-
|
||||
Everything after a single dash will be passed to '.CHILD.' processes as is.
|
||||
-g, --gracetime <time>
|
||||
If an instance has not been responding for longer than this time, consider
|
||||
it dead. See section «TIME SPECIFICATION» below to see how to specify time.
|
||||
DEFAULT: '.ght($opts['gracetime'],$ghtsa).'
|
||||
-p, --peersfp <file>
|
||||
Defines the path to a file containing a list of instances to consider in
|
||||
addition to those which are already present in the database. Note that this
|
||||
|
@ -88,7 +94,7 @@ OPTIONS
|
|||
-m, --moreclauses <more SQL clauses>
|
||||
If this option is set, whatever one writes as argument to the option will
|
||||
be added to the main query for instances’ records, which is «SELECT URI FROM
|
||||
Instances WHERE Dead=0».
|
||||
Instances WHERE LastOkCheckTS>=[variable]».
|
||||
-L, --logminmsglev <«debug»|«info»|«warning»|«error»|«none»>
|
||||
Defines the minimum “importance level” of messages to be written into the
|
||||
log file «run/[instance hostname].log». There are 4 “importance levels”, in
|
||||
|
@ -104,6 +110,13 @@ OPTIONS
|
|||
-h, --help
|
||||
When this option is specified, the script will show this help text and exit.
|
||||
|
||||
TIME SPECIFICATION
|
||||
|
||||
An example is better than ~5148 words :-)
|
||||
To specify 1 year, 6 months (made of 31 days), 2 weeks, 3 days, 5 hours,
|
||||
7 minutes and 12 seconds you can use «1y,6M,2w,3d,5h,7m,12s»; but you can
|
||||
also use «12s,7m,5h,3d,2w,6M,1y», or even «18M,1w,1w,2d,1d,3h,2h,7m,12s».
|
||||
|
||||
LICENSE
|
||||
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details see the source.
|
||||
|
@ -123,6 +136,11 @@ for ($i=1; $i<$argc; $i++) {
|
|||
} else {
|
||||
eecho(2,'you have specified «-» as last argument...'.N);
|
||||
}
|
||||
} elseif ($argv[$i]=='-g' || $argv[$i]=='--gracetime') {
|
||||
if ($i+1>=$argc || ($time=parsetime($argv[$i+1]))===false)
|
||||
mexit('option «'.$argv[$i].'» requires a valid time specification as an argument (use «-h» to read help).'.N,1,false);
|
||||
$i++;
|
||||
$opts['gracetime']=$time;
|
||||
} elseif ($argv[$i]=='-p' || $argv[$i]=='--peersfp') {
|
||||
if ($i+1>=$argc || !file_exists($argv[$i+1]) || !is_file($argv[$i+1]) || !is_readable($argv[$i+1]))
|
||||
mexit('option «'.$argv[$i].'» requires an existing and readable file as an argument (use «-h» to read help).'.N,1,false);
|
||||
|
@ -162,6 +180,8 @@ for ($i=1; $i<$argc; $i++) {
|
|||
|
||||
foreach ($msglevs as $key=>$val) $msglevs[$key]=ucfirst($val);
|
||||
|
||||
$graceline=time()-$opts['gracetime'];
|
||||
|
||||
$rundirpath=__DIR__.'/run';
|
||||
|
||||
$lockfp=$rundirpath.'/'.FNAME.'.lock';
|
||||
|
@ -243,7 +263,7 @@ if ($restore) {
|
|||
|
||||
$insts=[];
|
||||
eecho(0,'loading known, alive instances from the database...'.N);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE Dead=0'.$opts['moreclauses'],__LINE__);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS>='.$graceline.$opts['moreclauses'],__LINE__);
|
||||
while($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['URI'],$insts))
|
||||
$insts[]=$row['URI'];
|
||||
|
@ -251,7 +271,7 @@ if ($restore) {
|
|||
|
||||
if (!is_null($opts['peersfp'])) {
|
||||
eecho(0,'loading dead instances from the database...'.N);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE Dead=1',__LINE__);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND InsertTS<'.$graceline.')',__LINE__);
|
||||
$deadinsts=[];
|
||||
while($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['URI'],$deadinsts))
|
||||
|
|
|
@ -48,7 +48,6 @@ if (function_exists('pcntl_signal')) {
|
|||
$opts=[
|
||||
'hostname'=>null,
|
||||
'timeout'=>10,
|
||||
'deadline'=>31*24*60*60,// if an instance has not been responding for more than this value of seconds, declare it dead
|
||||
'ldtoots'=>40,// number of toots to check with the automatic language detection function
|
||||
'dryrun'=>false,
|
||||
'fetchusers'=>false,
|
||||
|
@ -73,10 +72,6 @@ DESCRIPTION
|
|||
|
||||
OPTIONS
|
||||
|
||||
-D, --deadline <time>
|
||||
If an instance has not been responding for longer than this time, declare
|
||||
it dead. See section «TIME SPECIFICATION» below to see how to specify time.
|
||||
DEFAULT: '.ght($opts['deadline'],$ghtsa).'
|
||||
-l, --ldtoots <number>
|
||||
This option defines the number of toots the script will try to fetch from
|
||||
the local public timelines, to try and guess the most used languages of each
|
||||
|
@ -146,11 +141,6 @@ for ($i=1; $i<$argc; $i++) {
|
|||
mexit('option «'.$argv[$i].'» requires a time specification as an argument (use «-h» to read help).'.N,1);
|
||||
$i++;
|
||||
$opts['timeout']=parsetime($argv[$i]);
|
||||
} elseif ($argv[$i]=='-D' || $argv[$i]=='--deadline') {
|
||||
if ($i+1>=$argc || parsetime($argv[$i+1])===false)
|
||||
mexit('option «'.$argv[$i].'» requires a time specification as an argument (use «-h» to read help).'.N,1);
|
||||
$i++;
|
||||
$opts['deadline']=parsetime($argv[$i]);
|
||||
} elseif ($argv[$i]=='-l' || $argv[$i]=='--ldtoots') {
|
||||
if ($i+1>=$argc || preg_match('/^\d+$/',$argv[$i+1])!==1 || $argv[$i+1]+0>40 || $argv[$i+1]+0<10)
|
||||
mexit('option «'.$argv[$i].'» requires a number >= 10 and <= 40 as an argument (use «-h» to read help).'.N,1);
|
||||
|
@ -211,7 +201,7 @@ if ($opts['logminmsglev']<4) {
|
|||
if ($logf===false) mexit('could not open file «'.$logfp.'» in write mode.'.N,1);
|
||||
}
|
||||
|
||||
$instints=['ID', 'FirstSeen', 'IsMastodon', 'Dead', 'Priority', 'Visible', 'Noxious', 'NoxLastModTS', 'LocalityID', 'OurLangsLock', 'UserCount', 'StatusCount', 'DomainCount', 'ActiveUsersMonth', 'ActiveUsersHalfYear', 'RegOpen', 'RegReqApproval', 'MaxTootChars', 'AdmCreatedAt', 'WasLastCheckOk', 'GuestID', 'LastGuestEdit', 'InsertTS', 'RPos'];
|
||||
$instints=['ID', 'FirstSeen', 'IsMastodon', 'Priority', 'Visible', 'Noxious', 'NoxLastModTS', 'LocalityID', 'OurLangsLock', 'UserCount', 'StatusCount', 'DomainCount', 'ActiveUsersMonth', 'ActiveUsersHalfYear', 'RegOpen', 'RegReqApproval', 'MaxTootChars', 'AdmCreatedAt', 'WasLastCheckOk', 'GuestID', 'LastGuestEdit', 'InsertTS', 'RPos'];
|
||||
|
||||
$idata=[];
|
||||
$res=myq($link,'SHOW COLUMNS FROM Instances',__FILE__);
|
||||
|
@ -493,34 +483,18 @@ if ($idata['IsMastodon'] && !is_null($idata['Version']) && $idata['Version']>='3
|
|||
|
||||
if (!is_null($idata['IsMastodon'])) $idata['IsMastodon']=b2i($idata['IsMastodon']);
|
||||
($instanswered) ? $idata['WasLastCheckOk']=1 : $idata['WasLastCheckOk']=0;
|
||||
}
|
||||
if (is_null($oidata)) {
|
||||
$query='INSERT INTO Instances SET ';
|
||||
$idata['InsertTS']=$now;
|
||||
if ($instanswered) {
|
||||
$idata['FirstSeen']=$now;
|
||||
$idata['InsertTS']=$now;
|
||||
$idata['LastOkCheckTS']=$now;
|
||||
}
|
||||
} else {
|
||||
$query='UPDATE Instances SET ';
|
||||
$idata['FirstSeen']=$oidata['FirstSeen'];
|
||||
if ($instanswered && is_null($oidata['FirstSeen'])) $idata['FirstSeen']=$now;
|
||||
if (!$instanswered && $oidata['Dead']==0) {
|
||||
// we check the last time instance responded, if ever
|
||||
$res=myq($link,'SELECT Time FROM InstChecks WHERE InstID='.$oidata['ID'].' AND Status=1 ORDER BY Time DESC LIMIT 1',__LINE__);
|
||||
// if instance never responded we consider the time of first check
|
||||
if (mysqli_num_rows($res)==0)
|
||||
$res=myq($link,'SELECT Time FROM InstChecks WHERE InstID='.$oidata['ID'].' ORDER BY Time ASC LIMIT 1',__LINE__);
|
||||
if (mysqli_num_rows($res)>0) {
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
if ($now-$row['Time']>$opts['deadline']) {
|
||||
$idata['Dead']=1;
|
||||
notify('«<a href="viewinst.php?id='.$instid.'">'.$opts['hostname'].'</a>» just died!',2);
|
||||
}
|
||||
}/* else {// disabled since now we insert instances from peerscrawl.php directly
|
||||
eecho(2,'«'.$opts['hostname'].'»: it exists in Instances table but there’s no data about it in InstChecks!'.N);
|
||||
}*/
|
||||
} else {
|
||||
$idata['Dead']=$oidata['Dead'];
|
||||
}
|
||||
($instanswered && is_null($oidata['FirstSeen'])) ? $idata['FirstSeen']=$now : $idata['FirstSeen']=$oidata['FirstSeen'];
|
||||
($instanswered) ? $idata['LastOkCheckTS']=$now : $idata['LastOkCheckTS']=$oidata['LastOkCheckTS'];
|
||||
$idata['Priority']=$oidata['Priority'];
|
||||
$idata['Visible']=$oidata['Visible'];
|
||||
$idata['Noxious']=$oidata['Noxious'];
|
||||
|
|
|
@ -23,6 +23,7 @@ define('BNAME',preg_replace('/\.[^.]*$/','',SNAME));
|
|||
require(__DIR__.'/../site/mustard/include/gurl.php');
|
||||
require(__DIR__.'/../site/mustard/include/ghs.php');
|
||||
require(__DIR__.'/../site/mustard/include/ght.php');
|
||||
require(__DIR__.'/../site/mustard/include/gracetime.php');
|
||||
require(__DIR__.'/../site/mustard/include/parsetime.php');
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
|
@ -30,7 +31,7 @@ use function mysqli_real_escape_string as myesc;
|
|||
$opts=[
|
||||
'inifp'=>__DIR__.'/../conf/mustard.ini',
|
||||
'startinst'=>'mastodon.social',
|
||||
'deadline'=>31*24*60*60,
|
||||
'gracetime'=>$gracetime,
|
||||
'peersfp'=>__DIR__.'/peers',
|
||||
'apeersfp'=>__DIR__.'/peers.all',
|
||||
'cpeersfp'=>__DIR__.'/peers.checked',
|
||||
|
@ -63,10 +64,17 @@ OPTIONS
|
|||
-s, --startinst <domain>
|
||||
Defines the first instance to crawl.
|
||||
DEFAULT: «'.$opts['startinst'].'»
|
||||
-d, --deadline <time>
|
||||
If an instance has not been responding for longer than this time, declare
|
||||
-e, --excludefp <file>
|
||||
Defines a file containing exclusion rules: one regular expression per
|
||||
line (empty lines are ignored). Any instance matching any defined regex
|
||||
will be ignored by the program. Changes made to this file during program
|
||||
execution will be taken into account.
|
||||
-g, --gracetime <time>
|
||||
If an instance has not been responding for longer than this time, consider
|
||||
it dead. See section «TIME SPECIFICATION» below to see how to specify time.
|
||||
DEFAULT: '.ght($opts['deadline'],$ghtsa).'
|
||||
DEFAULT: '.ght($opts['gracetime'],$ghtsa).'
|
||||
-E, --excludedead
|
||||
Exclude instances marked considered dead (see previous option).
|
||||
-p, --peersfp <file>
|
||||
Defines the file into which the ordered list of responding instances
|
||||
will be saved.
|
||||
|
@ -83,13 +91,6 @@ OPTIONS
|
|||
Normally, if its lockfile exists, the program exits with an error before
|
||||
doing anything. With this option the lockfile is ignored. Please verify
|
||||
that the program is not already running before using it.
|
||||
-e, --excludefp <file>
|
||||
Defines a file containing exclusion rules: one regular expression per
|
||||
line (empty lines are ignored). Any instance matching any defined regex
|
||||
will be ignored by the program. Changes made to this file during program
|
||||
execution will be taken into account.
|
||||
-E, --excludedead
|
||||
Exclude instances marked as “Dead” in the database.
|
||||
-t, --timeout <time>
|
||||
Defines the timeout in seconds for every connection attempt. See section
|
||||
«TIME SPECIFICATION» below to see how to specify time.
|
||||
|
@ -126,11 +127,11 @@ for ($i=1; $i<$argc; $i++) {
|
|||
mexit(3,'option «'.$argv[$i].'» has to be followed by a domain name (use «-h» for more info).'.N,1,false);
|
||||
$i++;
|
||||
$opts['startinst']=$argv[$i];
|
||||
} elseif ($argv[$i]=='-d' || $argv[$i]=='--deadline') {
|
||||
} elseif ($argv[$i]=='-g' || $argv[$i]=='--gracetime') {
|
||||
if ($i+1>=$argc || ($time=parsetime($argv[$i+1]))===false)
|
||||
mexit(3,'option «'.$argv[$i].'» requires a valid time specification as an argument (use «-h» to read help).'.N,1,false);
|
||||
$i++;
|
||||
$opts['deadline']=$time;
|
||||
$opts['gracetime']=$time;
|
||||
} elseif ($argv[$i]=='-p' || $argv[$i]=='--peersfp') {
|
||||
if ($i+1>=$argc)
|
||||
mexit(3,'option «'.$argv[$i].'» has to be followed by a file’s path (use «-h» for more info).'.N,1,false);
|
||||
|
@ -201,13 +202,13 @@ if ($res===false) mexit(3,'couldn’t set «utf8mb4» charset for MySQL: '.mysql
|
|||
|
||||
$deadinsts=[];
|
||||
if ($opts['excludedead']) {
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE Dead=1');
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND InsertTS<'.$graceline.')');
|
||||
lecho(0,'got '.mysqli_num_rows($res).' dead instances from Instances table.'.N);
|
||||
while ($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['URI'],$deadinsts))
|
||||
$deadinsts[]=$row['URI'];
|
||||
$deadline=time()-$opts['deadline'];
|
||||
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS<='.$deadline.' OR (LastOkCheckTS IS NULL AND FirstCheckTS<='.$deadline.')');
|
||||
$graceline=time()-$opts['gracetime'];
|
||||
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND FirstCheckTS<'.$graceline.')');
|
||||
lecho(0,'got '.mysqli_num_rows($res).' dead instances from Peers table.'.N);
|
||||
while ($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['Hostname'],$deadinsts))
|
||||
|
@ -292,6 +293,7 @@ function crawl($list,$id) {
|
|||
if (mysqli_num_rows($res)==0) {
|
||||
lecho(1,'instance «'.$inst.'» is new :-)'.N);
|
||||
myq($link,'INSERT INTO Instances SET URI=\''.myesc($link,$inst).'\', InsertTS='.time());
|
||||
$newc++;
|
||||
}
|
||||
}
|
||||
foreach ($peers as $peer) {
|
||||
|
|
|
@ -5,6 +5,7 @@ $bt=microtime(true);
|
|||
$dlanguc=strtoupper($dlang);
|
||||
|
||||
require('mustard/include/n2es.php');
|
||||
require('mustard/include/gracetime.php');
|
||||
require('lib/fnum.php');
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
|
@ -20,6 +21,10 @@ $debug.='LOCALE: '.$locale.N;
|
|||
// an instance is displayed as "New" if its age, relative to the InsertTS field, is less or equal than this (currently 31 days)
|
||||
$oldline=31*24*60*60;
|
||||
|
||||
// an instance is considered dead if the last time it responded is before the graceline (see code below)
|
||||
// $gracetime is defined in mustard/include/gracetime.php
|
||||
$graceline=time()-$gracetime;
|
||||
|
||||
if (array_key_exists('id',$_GET) && preg_match('/^\d+$/',$_GET['id'])) {
|
||||
$_GET['id']+=0;
|
||||
$single=true;
|
||||
|
@ -217,7 +222,7 @@ function strip($str,$uri) {
|
|||
$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);
|
||||
$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.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL AND Instances.LastOkCheckTS>='.$graceline) 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, and we try to exclude 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, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||
|
@ -347,8 +352,8 @@ echo('<form method="get" id="searchf" class="sdbox" onsubmit="document.getElemen
|
|||
<div class="sdinput">
|
||||
<select id="lang" name="lang" class="sselect">
|
||||
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N);
|
||||
$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' [\', Code, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.Dead=0 AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlanguc.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
//$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' (\', Code, \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.Dead=0 AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlanguc.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' [\', Code, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.LastOkCheckTS>='.$graceline.' AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlanguc.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
//$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' (\', Code, \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.LastOkCheckTS>='.$graceline.' AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlanguc.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
while ($row=mysqli_fetch_assoc($res)) {
|
||||
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
|
||||
echo('<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N);
|
||||
|
@ -445,7 +450,7 @@ swhelp();
|
|||
</script>'.N);
|
||||
$joins=array();
|
||||
$wheres=array();
|
||||
$wheres[]='Instances.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL';
|
||||
$wheres[]='Instances.LastOkCheckTS>='.$graceline.' AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL';
|
||||
if ($_GET['noxious']==1) $wheres[]='Instances.Noxious=0';
|
||||
if ($_GET['creg']==1) $wheres[]='Instances.RegOpen=1';
|
||||
if ($_GET['appr']==1) $wheres[]='Instances.RegReqApproval=0';
|
||||
|
|
|
@ -9,8 +9,7 @@ $cols=array(
|
|||
'Instances.NoxLastModTS'=>array('field'=>'Instances.NoxLastModTS','name'=>'Data ult. modifica motivo nocività','nameEN'=>'Last modification date of noxiousness reason','type'=>'time'),
|
||||
'Instances.Visible'=>array('field'=>'Instances.Visible','name'=>'[Visibile]','nameEN'=>'[Visible]','type'=>'bool'),
|
||||
'Instances.WasLastCheckOk'=>array('field'=>'Instances.WasLastCheckOk','name'=>'[Ha risposto all’ultimo check]','nameEN'=>'[Has answered on last check]','type'=>'bool'),
|
||||
'Instances.Priority'=>array('field'=>'Instances.Priority','name'=>'Priorità','nameEN'=>'Priority','type'=>'int'),
|
||||
'Instances.Dead'=>array('field'=>'Instances.Dead','name'=>'[“Morta”]','nameEN'=>'[“Dead”]','type'=>'bool'),
|
||||
'Instances.LastOkCheckTS'=>array('field'=>'LastOkCheckTS','name'=>'Timestamp dell’ultimo check riuscito','nameEN'=>'Last ok check timestamp','type'=>'int'), 'Instances.Priority'=>array('field'=>'Instances.Priority','name'=>'Priorità','nameEN'=>'Priority','type'=>'int'),
|
||||
'Instances.URI'=>array('field'=>'Instances.URI','name'=>'URI','nameEN'=>'URI','type'=>'text'),
|
||||
'Instances.Title'=>array('field'=>'Instances.Title','name'=>'Titolo','nameEN'=>'Title','type'=>'text'),
|
||||
'Instances.ShortDesc'=>array('field'=>'Instances.ShortDesc','name'=>'Descrizione breve','nameEN'=>'Short description','type'=>'text'),
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
use function mysqli_real_escape_string as myesc;
|
||||
|
||||
require(__DIR__.'/transiten.php');
|
||||
require(__DIR__.'/gracetime.php');
|
||||
|
||||
$graceline=time()-$gracetime;
|
||||
|
||||
function tc($key) {
|
||||
global $english, $cols;
|
||||
|
@ -83,7 +86,7 @@ function trimname($str) {
|
|||
}
|
||||
|
||||
// $row deve essere una riga ritornata da una query tipo "SELECT *, ID AS IID FROM Instances WHERE ..."
|
||||
function dispinst(&$row,&$cols,&$link,&$dlang,&$account,$showcount,$finst,$cinsts) {
|
||||
function dispinst(&$row,&$cols,&$link,&$dlang,&$account,$showcount,$finst,$cinsts,&$graceline) {
|
||||
$out='';
|
||||
$out.='<table class="bigtab">'.N;
|
||||
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
|
||||
|
@ -101,7 +104,7 @@ function dispinst(&$row,&$cols,&$link,&$dlang,&$account,$showcount,$finst,$cinst
|
|||
$out.='<tr><td colspan="2"><input type="button" value="Invita admin" class="btbut" onclick="document.location.href=\'invite.php?id='.$row['IID'].'\'"></td></tr>'.N;
|
||||
}
|
||||
}
|
||||
$attr=booly(trimname(tc('Instances.Dead')).': ',$row['Dead'],false,true).N;
|
||||
$attr=booly('Viva: ',$row['LastOkCheckTS']>=$graceline,false,false).N;
|
||||
$attr.=booly(trimname(tc('Instances.Noxious')).': ',$row['Noxious'],false,true).N;
|
||||
$attr.=booly(trimname(tc('Instances.Visible')).': ',$row['Visible']).N;
|
||||
/*$attr.=booly(tc('Instances.RegOpen')).': ',$row['RegOpen']).N;
|
||||
|
|
|
@ -326,7 +326,7 @@ if (mysqli_num_rows($res)<1) {
|
|||
$i++;
|
||||
$ii++;
|
||||
if ($ii>$iperp) break;
|
||||
$out.=dispinst($row,$cols,$link,$dlang,$account,true,$i,$cinsts);
|
||||
$out.=dispinst($row,$cols,$link,$dlang,$account,true,$i,$cinsts,$graceline);
|
||||
}
|
||||
$out.='<div class="bigtabfoot"></div>'.N;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,11 @@ $dlanguc=strtoupper($dlang);
|
|||
|
||||
require('mustard/include/n2es.php');
|
||||
require('mustard/include/tables.php');
|
||||
require('mustard/include/gracetime.php');
|
||||
require('lib/fnum.php');
|
||||
|
||||
$graceline=time()-$gracetime;
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
/*$dlang='fr';
|
||||
$dtzbl=array('ca'=>'Europe/Madrid','en'=>'Europe/London','es'=>'Europe/Madrid','fr'=>'Europe/Paris','it'=>'Europe/Rome');
|
||||
|
@ -442,7 +445,7 @@ swhelp();
|
|||
</script>'.N);
|
||||
$joins=array();
|
||||
$wheres=array();
|
||||
$wheres[]='Instances.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL';
|
||||
$wheres[]='Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL AND Instances.LastOkCheckTS>='.$graceline;
|
||||
if ($_GET['noxious']==1) $wheres[]='Instances.Noxious=0';
|
||||
if ($_GET['creg']==1) $wheres[]='Instances.RegOpen=1';
|
||||
if ($_GET['appr']==1) $wheres[]='Instances.RegReqApproval=0';
|
||||
|
|
Loading…
Reference in a new issue