Changed “echo” to “eecho” where appropriate; changed all “echo('...')” to “echo '...'”
This commit is contained in:
parent
d502fde347
commit
ececc8e8c8
1 changed files with 15 additions and 16 deletions
|
@ -73,7 +73,7 @@ $dosome=false;
|
||||||
|
|
||||||
for ($i=1; $i<$argc; $i++) {
|
for ($i=1; $i<$argc; $i++) {
|
||||||
if ($argv[$i]=='-h' || $argv[$i]=='--help') {
|
if ($argv[$i]=='-h' || $argv[$i]=='--help') {
|
||||||
echo($help);
|
echo $help;
|
||||||
exit(0);
|
exit(0);
|
||||||
} elseif ($argv[$i]=='deleteinstswhere') {
|
} 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);
|
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) {
|
foreach ($doms as $key=>$arr) {
|
||||||
$carr=count($arr);
|
$carr=count($arr);
|
||||||
if ($carr>$opts['minent']) {
|
if ($carr>$opts['minent']) {
|
||||||
echo $tabnam.': '.$key.': '.$carr.' entries'.N;
|
eecho('>>> '.$tabnam.': '.$key.': '.$carr.' entries'.N,1);
|
||||||
foreach ($arr as $entry)
|
foreach ($arr as $entry)
|
||||||
echo ' '.$domcol.': '.$entry['dom'].'; '.$idcol.': '.$entry['id'].N;
|
eecho(' '.$domcol.': '.$entry['dom'].'; '.$idcol.': '.$entry['id'].N,1);
|
||||||
echo N;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,8 +177,8 @@ if ($opts['deleteinstswhere']) {
|
||||||
while ($row=mysqli_fetch_assoc($res)) $buf[]=$row;
|
while ($row=mysqli_fetch_assoc($res)) $buf[]=$row;
|
||||||
$cbuf=count($buf);
|
$cbuf=count($buf);
|
||||||
if ($cbuf>0) {
|
if ($cbuf>0) {
|
||||||
foreach ($buf as $row) echo($row['URI'].' (ID='.$row['ID'].')'.N);
|
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: ');
|
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));
|
$inp=rtrim(fgets(STDIN));
|
||||||
if ($inp=='YES') {
|
if ($inp=='YES') {
|
||||||
$i=0;
|
$i=0;
|
||||||
|
@ -237,7 +236,7 @@ if ($opts['updstats']) {
|
||||||
$day=24*60*60;
|
$day=24*60*60;
|
||||||
$now=time();
|
$now=time();
|
||||||
$tdstart=gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now));
|
$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
|
// this below, if uncommented, populates DESTRUCTIVELY table ZHits for testing purposes
|
||||||
/*myq($link,'DELETE FROM ZHits WHERE TS < '.$tdstart);
|
/*myq($link,'DELETE FROM ZHits WHERE TS < '.$tdstart);
|
||||||
|
@ -263,7 +262,7 @@ if ($opts['updstats']) {
|
||||||
}
|
}
|
||||||
$inserts=0;
|
$inserts=0;
|
||||||
while ($dstart<$tdstart) {
|
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++;
|
$inserts++;
|
||||||
$hits=0;
|
$hits=0;
|
||||||
foreach ($supplangs as $key=>$val)
|
foreach ($supplangs as $key=>$val)
|
||||||
|
@ -274,7 +273,7 @@ if ($opts['updstats']) {
|
||||||
$buf=array();
|
$buf=array();
|
||||||
$res=myq($link,'SELECT * FROM ZHits WHERE TS >= '.$dstart.' AND TS < '.($dstart+$day).' ORDER BY TS ASC');
|
$res=myq($link,'SELECT * FROM ZHits WHERE TS >= '.$dstart.' AND TS < '.($dstart+$day).' ORDER BY TS ASC');
|
||||||
while ($row=mysqli_fetch_assoc($res)) {
|
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++;
|
$hits++;
|
||||||
if (array_key_exists($row['Lang'],$supplangs))
|
if (array_key_exists($row['Lang'],$supplangs))
|
||||||
$supplangs[$row['Lang']]['hc']++;
|
$supplangs[$row['Lang']]['hc']++;
|
||||||
|
@ -290,9 +289,9 @@ if ($opts['updstats']) {
|
||||||
$buf='';
|
$buf='';
|
||||||
foreach ($hitspage as $key=>$val) $buf.=$key.':'.$val.';';
|
foreach ($hitspage as $key=>$val) $buf.=$key.':'.$val.';';
|
||||||
$hitspage=substr($buf,0,-1);
|
$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.')';
|
$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);
|
myq($link,$query);
|
||||||
$dstart+=$day;
|
$dstart+=$day;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +311,7 @@ if ($opts['clean']) {
|
||||||
$totar=0;
|
$totar=0;
|
||||||
while ($row=mysqli_fetch_assoc($res)) {
|
while ($row=mysqli_fetch_assoc($res)) {
|
||||||
$p++;
|
$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');
|
$rres=myq($link,'SELECT Time FROM InstChecks WHERE InstID='.$row['ID'].' ORDER BY Time DESC');
|
||||||
$instchecks=[];
|
$instchecks=[];
|
||||||
while ($rrow=mysqli_fetch_assoc($rres)) $instchecks[]=$rrow;
|
while ($rrow=mysqli_fetch_assoc($rres)) $instchecks[]=$rrow;
|
||||||
|
@ -321,10 +320,10 @@ if ($opts['clean']) {
|
||||||
$bef=$bef['Time'];
|
$bef=$bef['Time'];
|
||||||
myq($link,'DELETE FROM InstChecks WHERE InstID='.$row['ID'].' AND Time<='.$bef);
|
myq($link,'DELETE FROM InstChecks WHERE InstID='.$row['ID'].' AND Time<='.$bef);
|
||||||
$ar=mysqli_affected_rows($link);
|
$ar=mysqli_affected_rows($link);
|
||||||
//echo('Deleted '.$ar.' records from InstChecks table.'.N);
|
//eecho('deleted '.$ar.' records from “InstChecks” table.'.N,1);
|
||||||
$totar+=$ar;
|
$totar+=$ar;
|
||||||
}/* else {
|
}/* else {
|
||||||
echo('No InstChecks records to delete.'.N);
|
eecho('no “InstChecks” records to delete.'.N,1);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
eecho('done! Total affected rows: '.$totar.'.'.N,1);
|
eecho('done! Total affected rows: '.$totar.'.'.N,1);
|
||||||
|
@ -376,10 +375,10 @@ function eecho($msg,$lev=1) {
|
||||||
global $levs;
|
global $levs;
|
||||||
$time=microtime(false);
|
$time=microtime(false);
|
||||||
$time=explode(' ',$time);
|
$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;
|
$msg=$time.' '.$levs[$lev].': '.$msg;
|
||||||
if ($lev<2)
|
if ($lev<2)
|
||||||
echo($msg);
|
echo $msg;
|
||||||
else
|
else
|
||||||
fwrite(STDERR,$msg);
|
fwrite(STDERR,$msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue