|
@@ -21,6 +21,11 @@ use LanguageDetection\Language;
|
|
|
|
|
|
define('N',"\n");
|
|
|
|
|
|
+if (strtoupper(substr(PHP_OS,0,3))==='WIN')
|
|
|
+ $iswin=true;
|
|
|
+else
|
|
|
+ $iswin=false;
|
|
|
+
|
|
|
$link=false;
|
|
|
$logf=false;
|
|
|
$jsonf=false;
|
|
@@ -261,8 +266,10 @@ function flushtronc($id) {
|
|
|
}
|
|
|
|
|
|
function truncs($str,$tab,$col,$ctx) {
|
|
|
- global $tables, $tronconi;
|
|
|
- $size=$tables[strtolower($tab)][$col];
|
|
|
+ global $tables, $tronconi, $iswin;
|
|
|
+ if ($iswin)
|
|
|
+ $tab=strtolower($tab);
|
|
|
+ $size=$tables[$tab][$col];
|
|
|
$len=mb_strlen($str,'UTF-8');
|
|
|
if ($len>$size) {
|
|
|
$tronconi[]=array('id'=>null,'tab'=>$tab,'col'=>$col,'ctx'=>$ctx,'len'=>$len,'size'=>$size);
|
|
@@ -272,14 +279,16 @@ function truncs($str,$tab,$col,$ctx) {
|
|
|
}
|
|
|
|
|
|
function truncn($num,$tab,$col,$ctx) {
|
|
|
- global $tables;
|
|
|
+ global $tables, $iswin;
|
|
|
+ if ($iswin)
|
|
|
+ $tab=strtolower($tab);
|
|
|
if (is_numeric($num)) {
|
|
|
- if ($num>$tables[strtolower($tab)][$col]['max']) {
|
|
|
- notify($ctx.': ho dovuto troncare «'.$num.'» al valore massimo «'.$tables[strtolower($tab)][$col]['max'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
|
|
|
- $num=$tables[strtolower($tab)][$col]['max'];
|
|
|
- } elseif ($num<$tables[strtolower($tab)][$col]['min']) {
|
|
|
- notify($ctx.': ho dovuto troncare «'.$num.'» al valore minimo «'.$tables[strtolower($tab)][$col]['min'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
|
|
|
- $num=$tables[strtolower($tab)][$col]['min'];
|
|
|
+ if ($num>$tables[$tab][$col]['max']) {
|
|
|
+ notify($ctx.': ho dovuto troncare «'.$num.'» al valore massimo «'.$tables[$tab][$col]['max'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
|
|
|
+ $num=$tables[$tab][$col]['max'];
|
|
|
+ } elseif ($num<$tables[$tab][$col]['min']) {
|
|
|
+ notify($ctx.': ho dovuto troncare «'.$num.'» al valore minimo «'.$tables[$tab][$col]['min'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
|
|
|
+ $num=$tables[$tab][$col]['min'];
|
|
|
}
|
|
|
} else {
|
|
|
notify($ctx.': truncn(): mi aspettavo un numero, invece non lo era; ritorno «0».',3);
|
|
@@ -405,8 +414,10 @@ if (!$riprendi) {
|
|
|
}
|
|
|
|
|
|
function willtrunc($str,$tab,$col) {
|
|
|
- global $tables;
|
|
|
- if (mb_strlen($str,'UTF-8')>$tables[strtolower($tab)][$col])
|
|
|
+ global $tables, $iswin;
|
|
|
+ if ($iswin)
|
|
|
+ $tab=strtolower($tab);
|
|
|
+ if (mb_strlen($str,'UTF-8')>$tables[$tab][$col])
|
|
|
return(true);
|
|
|
else
|
|
|
return(false);
|
|
@@ -453,9 +464,12 @@ function subarimp($glue,$key,&$arr) {
|
|
|
}
|
|
|
|
|
|
function notify($msg,$sev) {
|
|
|
- global $link, $tables;
|
|
|
+ global $link, $tables, $iswin;
|
|
|
lecho('NOTIFICAZIÒ: '.strip_tags($msg).N);
|
|
|
- mysqli_query($link,'INSERT INTO Notifications (ID, Notification, Severity, Microtime, Seen) VALUES (NULL, \''.myesc($link,mb_substr($msg,0,$tables['notifications']['Notification'],'UTF-8')).'\', '.$sev.', \''.microtime(true).'\', 0)')
|
|
|
+ $tab='Notifications';
|
|
|
+ if ($iswin)
|
|
|
+ $tab='notifications';
|
|
|
+ mysqli_query($link,'INSERT INTO Notifications (ID, Notification, Severity, Microtime, Seen) VALUES (NULL, \''.myesc($link,mb_substr($msg,0,$tables[$tab]['Notification'],'UTF-8')).'\', '.$sev.', \''.microtime(true).'\', 0)')
|
|
|
or mexit(mysqli_error($link).N,3);
|
|
|
}
|
|
|
|
|
@@ -547,7 +561,13 @@ function summary($detected_langs) {
|
|
|
function sort_weights($entry1, $entry2) {
|
|
|
$w1 = $entry1[0];
|
|
|
$w2 = $entry2[0];
|
|
|
- return $w1 < $w2 ? 1 : $w1 == $w2 ? 0 : -1;
|
|
|
+ if ($w1 < $w2)
|
|
|
+ $ret=1;
|
|
|
+ elseif ($w1 == $w2)
|
|
|
+ $ret=0;
|
|
|
+ else
|
|
|
+ $ret=-1;
|
|
|
+ return $ret;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -611,7 +631,7 @@ function my_ucfirst($string, $e ='utf-8') {
|
|
|
$string = ucfirst($string);
|
|
|
}
|
|
|
return $string;
|
|
|
-}
|
|
|
+}
|
|
|
|
|
|
function langs($instid, $uri) {
|
|
|
global $info, $instrow, $link;
|
|
@@ -620,7 +640,7 @@ function langs($instid, $uri) {
|
|
|
if(count($languages) == 0 && akeavinn('languages',$info)) {
|
|
|
$languages = $info['languages'];
|
|
|
}
|
|
|
- echo "Lingue trovate: " . implode(", ", $languages).N;
|
|
|
+ lecho('Lingue trovate: '.implode(', ',$languages).N);
|
|
|
$pos=0;
|
|
|
foreach($languages as $lang) {
|
|
|
$res=mysqli_query($link,'SELECT * FROM Languages WHERE Code=\''.myesc($link,$lang).'\'')
|
|
@@ -643,7 +663,6 @@ function langs($instid, $uri) {
|
|
|
$pos++;
|
|
|
$instlangs[]=array('InstID'=>$instid,'LangID'=>$langid,'Pos'=>$pos,'Code'=>$lang);
|
|
|
}
|
|
|
- // }
|
|
|
return($instlangs);
|
|
|
}
|
|
|
|
|
@@ -761,7 +780,7 @@ while ($i<$cinsts) {
|
|
|
$ok=false;
|
|
|
lecho('ERRORE :-('.N);
|
|
|
// questo è anche il limbo delle istanze che non rispondono, perciò controlliamo se già esistono nel db e, nel caso, aggiorniamo InstChecks
|
|
|
- $res=mysqli_query($link,'SELECT * FROM Instances WHERE URI=\''.myesc($link,mb_substr($dom,0,$tables['instances']['URI'],'UTF-8')).'\'')
|
|
|
+ $res=mysqli_query($link,'SELECT * FROM Instances WHERE URI=\''.myesc($link,mb_substr($dom,0,$tables[$iswin ? 'instances' : 'Instances']['URI'],'UTF-8')).'\'')
|
|
|
or mexit(mysqli_error($link).N,3);
|
|
|
if (mysqli_num_rows($res)>0) {
|
|
|
lecho('«'.$dom.'» non risponde, ma è presente nel database; aggiorno InstChecks.'.N);
|