Changed “echo” to “eecho” where appropriate; changed all “echo('...')” to “echo '...'”

This commit is contained in:
pezcurrel 2023-12-29 13:01:00 +01:00
parent d502fde347
commit ececc8e8c8

View file

@ -73,7 +73,7 @@ $dosome=false;
for ($i=1; $i<$argc; $i++) {
if ($argv[$i]=='-h' || $argv[$i]=='--help') {
echo($help);
echo $help;
exit(0);
} elseif ($argv[$i]=='deleteinstswhere') {
if ($i==$argc-1) mexit('«'.$argv[$i].'» requires a MySQL condition as an argument (use «-h» to read help).'.N,1);
@ -156,10 +156,9 @@ function checkspam(&$res,$idcol,$domcol,$tabnam) {
foreach ($doms as $key=>$arr) {
$carr=count($arr);
if ($carr>$opts['minent']) {
echo $tabnam.': '.$key.': '.$carr.' entries'.N;
eecho('>>> '.$tabnam.': '.$key.': '.$carr.' entries'.N,1);
foreach ($arr as $entry)
echo ' '.$domcol.': '.$entry['dom'].'; '.$idcol.': '.$entry['id'].N;
echo N;
eecho(' '.$domcol.': '.$entry['dom'].'; '.$idcol.': '.$entry['id'].N,1);
}
}
}
@ -178,8 +177,8 @@ if ($opts['deleteinstswhere']) {
while ($row=mysqli_fetch_assoc($res)) $buf[]=$row;
$cbuf=count($buf);
if ($cbuf>0) {
foreach ($buf as $row) echo($row['URI'].' (ID='.$row['ID'].')'.N);
echo('Do you really want to delete those '.$cbuf.' record(s)? Enter «YES» to do it, anything else to not do it: ');
foreach ($buf as $row) eecho($row['URI'].' (ID='.$row['ID'].')'.N,1);
echo 'Do you really want to delete those '.$cbuf.' record(s)? Enter «YES» to do it, anything else to not do it: ';
$inp=rtrim(fgets(STDIN));
if ($inp=='YES') {
$i=0;
@ -237,7 +236,7 @@ if ($opts['updstats']) {
$day=24*60*60;
$now=time();
$tdstart=gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now));
//echo('Today started at '.$tdstart.' ('.gmdate('d M Y H:i:s',$tdstart).').'.N);
//eecho('Today started at '.$tdstart.' ('.gmdate('d M Y H:i:s',$tdstart).').'.N,1);
// this below, if uncommented, populates DESTRUCTIVELY table ZHits for testing purposes
/*myq($link,'DELETE FROM ZHits WHERE TS < '.$tdstart);
@ -263,7 +262,7 @@ if ($opts['updstats']) {
}
$inserts=0;
while ($dstart<$tdstart) {
//echo('-------- '.gmdate('d M Y H:i:s',$dstart).' ---------'.N);
//eecho('-------- '.gmdate('d M Y H:i:s',$dstart).' ---------'.N,1);
$inserts++;
$hits=0;
foreach ($supplangs as $key=>$val)
@ -274,7 +273,7 @@ if ($opts['updstats']) {
$buf=array();
$res=myq($link,'SELECT * FROM ZHits WHERE TS >= '.$dstart.' AND TS < '.($dstart+$day).' ORDER BY TS ASC');
while ($row=mysqli_fetch_assoc($res)) {
//echo($row['UID'].' '.$row['URL'].' '.$row['Lang'].' '.$row['TS'].N);
//eecho($row['UID'].' '.$row['URL'].' '.$row['Lang'].' '.$row['TS'].N,1);
$hits++;
if (array_key_exists($row['Lang'],$supplangs))
$supplangs[$row['Lang']]['hc']++;
@ -290,9 +289,9 @@ if ($opts['updstats']) {
$buf='';
foreach ($hitspage as $key=>$val) $buf.=$key.':'.$val.';';
$hitspage=substr($buf,0,-1);
//echo('>>> hits: '.$hits.', hitslang: '.$hitslang.', hitspage: '.$hitspage.', visits: '.$visits.' <<<'.N);
//eecho('>>> hits: '.$hits.', hitslang: '.$hitslang.', hitspage: '.$hitspage.', visits: '.$visits.' <<<'.N,1);
$query='INSERT INTO ZStats (TS, Hits, HitsLang, HitsPage, Visits) VALUES ('.$dstart.', '.$hits.', "'.$hitslang.'", "'.$hitspage.'", '.$visits.')';
//echo($query.N);
//eecho('QUERY: '.$query.N,1);
myq($link,$query);
$dstart+=$day;
}
@ -312,7 +311,7 @@ if ($opts['clean']) {
$totar=0;
while ($row=mysqli_fetch_assoc($res)) {
$p++;
//echo('Working on instance '.$p.'/'.$nrows.' (ID = '.$row['ID'].')...'.N);
//eecho('working on instance '.$p.'/'.$nrows.' (ID = '.$row['ID'].')...'.N,1);
$rres=myq($link,'SELECT Time FROM InstChecks WHERE InstID='.$row['ID'].' ORDER BY Time DESC');
$instchecks=[];
while ($rrow=mysqli_fetch_assoc($rres)) $instchecks[]=$rrow;
@ -321,10 +320,10 @@ if ($opts['clean']) {
$bef=$bef['Time'];
myq($link,'DELETE FROM InstChecks WHERE InstID='.$row['ID'].' AND Time<='.$bef);
$ar=mysqli_affected_rows($link);
//echo('Deleted '.$ar.' records from InstChecks table.'.N);
//eecho('deleted '.$ar.' records from “InstChecks” table.'.N,1);
$totar+=$ar;
}/* else {
echo('No InstChecks records to delete.'.N);
eecho('no “InstChecks” records to delete.'.N,1);
}*/
}
eecho('done! Total affected rows: '.$totar.'.'.N,1);
@ -376,10 +375,10 @@ function eecho($msg,$lev=1) {
global $levs;
$time=microtime(false);
$time=explode(' ',$time);
$time=date('Y-m-d H:i:s',$time[1]).'.'.substr($time[0],2);
$time=date('Y-m-d H:i:s',$time[1]).'.'.substr($time[0],2,-2);
$msg=$time.' '.$levs[$lev].': '.$msg;
if ($lev<2)
echo($msg);
echo $msg;
else
fwrite(STDERR,$msg);
}