From e194bd597f2ace343df49a6867433c8a3116806c Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 1 Dec 2022 17:42:48 +0100 Subject: [PATCH] =?UTF-8?q?Changed=20notifications=20=E2=80=9Clevels?= =?UTF-8?q?=E2=80=9D,=20removed=20=E2=80=9Ceecho=E2=80=9Des=20when=20?= =?UTF-8?q?=E2=80=9Cnotify=E2=80=9D=20is=20used=20since=20it=20=E2=80=9Cee?= =?UTF-8?q?cho=E2=80=9Des=20by=20itself?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/clitools/crawler.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/web/clitools/crawler.php b/web/clitools/crawler.php index 8e7cfdc..bdf7c31 100755 --- a/web/clitools/crawler.php +++ b/web/clitools/crawler.php @@ -213,7 +213,7 @@ function truncs($str,$tab,$col,$ctx) { $size=$tables[$tab][$col]; $len=mb_strlen($str,'UTF-8'); if ($len>$size) { - notify($ctx.': had to truncate to '.$size.' characters the value to be inserted into «'.$col.'» column in «'.$tab.'» table because it was too long ('.$len.' characters).',2); + notify($ctx.': had to truncate to '.$size.' characters the value to be inserted into «'.$col.'» column in «'.$tab.'» table because it was too long ('.$len.' characters).',3); $str=mb_substr($str,0,$size-1,'UTF-8').'…'; } return($str); @@ -225,10 +225,10 @@ function truncn($num,$tab,$col,$ctx) { $tab=strtolower($tab); if (is_numeric($num)) { if ($num>$tables[$tab][$col]['max']) { - notify($ctx.': had to ceil «'.$num.'» to «'.$tables[$tab][$col]['max'].'», ie the maximum value it can have in column «'.$col.'» of table «'.$tab.'».',2); + notify($ctx.': had to ceil «'.$num.'» to «'.$tables[$tab][$col]['max'].'», ie the maximum value it can have in column «'.$col.'» of table «'.$tab.'».',3); $num=$tables[$tab][$col]['max']; } elseif ($num<$tables[$tab][$col]['min']) { - notify($ctx.': had to floor «'.$num.'» to «'.$tables[$tab][$col]['min'].'», ie the minimum value it can have in column «'.$col.'» of table «'.$tab.'»).',2); + notify($ctx.': had to floor «'.$num.'» to «'.$tables[$tab][$col]['min'].'», ie the minimum value it can have in column «'.$col.'» of table «'.$tab.'»).',3); $num=$tables[$tab][$col]['min']; } } else { @@ -358,8 +358,9 @@ function subarimp($glue,$key,&$arr) { } function notify($msg,$sev) { + // notify "Severity" should be called "Importance"; anyway, it is to be thought of as "$lev" param of function "eecho": 0=debug, 1=info, 2=warning, 3=error global $link, $tables, $iswin, $opts; - eecho(1,'*notification*: '.strip_tags($msg).N); + eecho($sev,'*notification*: '.strip_tags($msg).N); $tab='Notifications'; if ($iswin) $tab='notifications'; if (!$opts['dryrun']) mysqli_query($link,'INSERT INTO Notifications (ID, Notification, Severity, Microtime, Seen, Deleted) VALUES (NULL, \''.myesc($link,mb_substr($msg,0,$tables[$tab]['Notification'],'UTF-8')).'\', '.$sev.', \''.microtime(true).'\', 0, 0)') @@ -642,7 +643,7 @@ while ($i<$cinsts) { if (mysqli_num_rows($res)<1) { if (!$opts['dryrun']) mysqli_query($link,'INSERT INTO Platforms (Name) VALUES (\''.myesc($link,truncs($info['x-nodeinfo']['software']['name'],'Platforms','Name','«'.$info['uri'].'»')).'\')') or mexit(__LINE__.': '.mysqli_error($link).N,3); - notify('New software found: «'.$info['uri'].'» runs on «'.$info['x-nodeinfo']['software']['name'].'»; i added it to the table of known softwares. It would be good to check whether it is a Mastodon derivate and how compatible it is, to decide whether to consider instances using it as Mastodon instances.',1); + notify('New software found: «'.$info['uri'].'» runs on «'.$info['x-nodeinfo']['software']['name'].'»; i added it to the table of known softwares. It would be good to check whether it is a Mastodon derivate and how compatible it is, to decide whether to consider instances using it as Mastodon instances.',2); } } } else { @@ -715,7 +716,7 @@ while ($i<$cinsts) { if ($now-$rrow['Time']>$opts['deadline']) { if (!$opts['dryrun']) mysqli_query($link,'UPDATE Instances SET Dead=1 WHERE ID='.$row['ID']) or mexit(__LINE__.': '.mysqli_error($link).N,3); - notify('Instance «'.$row['URI'].'» is dead!',1); + notify('Instance «'.$row['URI'].'» is dead!',2); } } else { eecho(2,'«'.$host.'» exists in the database but there’s no data about it in InstChecks! I’ll remedy.'.N); @@ -733,8 +734,7 @@ while ($i<$cinsts) { $instid=0; } } else { - eecho(3,'table «Instances» has «'.$nrows.'» entries for instance «'.$host.'»!'.N); - notify('Instance «'.$row['URI'].'» has «'.$nrows.'» entries in «Instances» table!',1); + notify('Instance «'.$row['URI'].'» has «'.$nrows.'» entries in «Instances» table!',3); } } else { @@ -863,8 +863,7 @@ while ($i<$cinsts) { $instrow['New']=1; if ($now-$oldinstrow['FirstSeen']>$opts['oldline']) { $instrow['New']=0; - eecho(1,'«'.$row['URI'].'» is no longer new.'.N); - notify('Instance «'.$row['URI'].'» is no longer new.',1); + notify('Instance «'.$row['URI'].'» is no longer new.',2); } } } @@ -984,8 +983,7 @@ while ($i<$cinsts) { notify('New instance «'.$instrow['URI'].'» is suitable!',1); } else { - eecho(3,'table «Instances» has «'.$nrows.'» entries for instance «'.$host.'»!'.N); - notify('Instance «'.$row['URI'].'» has «'.$nrows.'» entries in «Instances» table!',1); + notify('Instance «'.$row['URI'].'» has «'.$nrows.'» entries in «Instances» table!',3); } if (array_key_exists('x-activity',$info) && is_array($info['x-activity'])) {