|
@@ -16,11 +16,6 @@
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
-/*
|
|
|
-DAFA
|
|
|
-- hardening sull'input: verificare tipi, truncn, truncs
|
|
|
-*/
|
|
|
-
|
|
|
define('N',"\n");
|
|
|
|
|
|
$link=false;
|
|
@@ -136,8 +131,8 @@ if ($opts['log']) {
|
|
|
$inifp=__DIR__.'/../sec/mastostartadmin.ini';
|
|
|
$iniarr=@parse_ini_file($inifp)
|
|
|
or mexit('Impossibile aprire il file di configurazione «'.$inifp.'»'.N,1);
|
|
|
-$link=mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
|
|
|
- or mexit(mysqli_error($link).N,1);
|
|
|
+$link=@mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
|
|
|
+ or mexit('Impossibile connettersi al server MySQL: '.mysqli_connect_error().N,1);
|
|
|
mysqli_set_charset($link,'utf8mb4')
|
|
|
or mexit(mysqli_error($link).N,1);
|
|
|
|
|
@@ -150,68 +145,73 @@ while ($row=mysqli_fetch_row($res)) {
|
|
|
$fields=array();
|
|
|
// lo uso solo per alcuni tipi, quindi non sto a cercare completezza
|
|
|
while ($rowb=mysqli_fetch_assoc($resb)) {
|
|
|
- preg_match('/(\w+)\((.*)\)( unsigned)?/',$rowb['Type'],$buf);
|
|
|
- switch ($buf[1]) {
|
|
|
- case 'char':
|
|
|
- case 'varchar':
|
|
|
- $fields[$rowb['Field']]=$buf[2];
|
|
|
- break;
|
|
|
- case 'tinyint':
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>0,'max'=>255);
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>-128,'max'=>127);
|
|
|
- break;
|
|
|
- case 'smallint':
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>0,'max'=>65535);
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>-32768,'max'=>32767);
|
|
|
- break;
|
|
|
- case 'mediumint':
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>0,'max'=>16777215);
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>-8388608,'max'=>8388607);
|
|
|
- break;
|
|
|
- case 'int':
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>0,'max'=>4294967295);
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>-2147483648,'max'=>2147483647);
|
|
|
- break;
|
|
|
+ if (preg_match('/(\w+)\((.*)\)( unsigned)?/',$rowb['Type'],$buf)===1) {
|
|
|
+ switch ($buf[1]) {
|
|
|
+ case 'char':
|
|
|
+ case 'varchar':
|
|
|
+ $fields[$rowb['Field']]=$buf[2];
|
|
|
+ break;
|
|
|
+ case 'tinyint':
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>0,'max'=>255);
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>-128,'max'=>127);
|
|
|
+ break;
|
|
|
+ case 'smallint':
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>0,'max'=>65535);
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>-32768,'max'=>32767);
|
|
|
+ break;
|
|
|
+ case 'mediumint':
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>0,'max'=>16777215);
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>-8388608,'max'=>8388607);
|
|
|
+ break;
|
|
|
+ case 'int':
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>0,'max'=>4294967295);
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>-2147483648,'max'=>2147483647);
|
|
|
+ break;
|
|
|
// bigint non ci sta in php a meno di usare bcmath o gmp che non è detto siano abilitate sul server, in ogni caso poco importa perché valori bigint vengono usati solo internamente al db, non "vengono da fuori"
|
|
|
- case 'bigint':
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>'0','max'=>'18446744073709551615');
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>'-9223372036854775808','max'=>'9223372036854775807');
|
|
|
- break;
|
|
|
- case 'decimal':
|
|
|
+ case 'bigint':
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>'0','max'=>'18446744073709551615');
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>'-9223372036854775808','max'=>'9223372036854775807');
|
|
|
+ break;
|
|
|
+ case 'decimal':
|
|
|
// questo è da testare contro un decimale vero
|
|
|
// fatto, il risultato è che in mysql devo usare decimal(14,4)
|
|
|
- if (preg_match('/,/',$buf[2])===1) {
|
|
|
- $lim=explode(',',$buf[2]);
|
|
|
- } else {
|
|
|
- $lim[0]=$buf[2];
|
|
|
- $lim[1]=0;
|
|
|
+ if (preg_match('/,/',$buf[2])===1) {
|
|
|
+ $lim=explode(',',$buf[2]);
|
|
|
+ } else {
|
|
|
+ $lim[0]=$buf[2];
|
|
|
+ $lim[1]=0;
|
|
|
+ }
|
|
|
+ $int=$lim[0]-$lim[1];
|
|
|
+ $sint='';
|
|
|
+ for ($i=0; $i<$int; $i++)
|
|
|
+ $sint.='9';
|
|
|
+ $sdec='';
|
|
|
+ for ($i=0; $i<$lim[1]; $i++)
|
|
|
+ $sdec.='9';
|
|
|
+ $max=$sint.'.'.$sdec;
|
|
|
+ if (array_key_exists(3,$buf))
|
|
|
+ $fields[$rowb['Field']]=array('min'=>0,'max'=>floatval($max));
|
|
|
+ else
|
|
|
+ $fields[$rowb['Field']]=array('min'=>floatval('-'.$max),'max'=>floatval($max));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $fields[$rowb['Field']]=$rowb['Type'];
|
|
|
+ break;
|
|
|
}
|
|
|
- $int=$lim[0]-$lim[1];
|
|
|
- $sint='';
|
|
|
- for ($i=0; $i<$int; $i++)
|
|
|
- $sint.='9';
|
|
|
- $sdec='';
|
|
|
- for ($i=0; $i<$lim[1]; $i++)
|
|
|
- $sdec.='9';
|
|
|
- $max=$sint.'.'.$sdec;
|
|
|
- if (array_key_exists(3,$buf))
|
|
|
- $fields[$rowb['Field']]=array('min'=>0,'max'=>floatval($max));
|
|
|
- else
|
|
|
- $fields[$rowb['Field']]=array('min'=>floatval('-'.$max),'max'=>floatval($max));
|
|
|
- break;
|
|
|
- default:
|
|
|
+ } elseif ($rowb['Type']=='text') {
|
|
|
+ $fields[$rowb['Field']]=65535;
|
|
|
+ } else {
|
|
|
$fields[$rowb['Field']]=$rowb['Type'];
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
$tables[$row[0]]=$fields;
|
|
@@ -236,40 +236,49 @@ $tronconi=array();
|
|
|
function flushtronc($id) {
|
|
|
global $tronconi;
|
|
|
foreach ($tronconi as $row) {
|
|
|
- $row['id']=$id;
|
|
|
- if ($row['tab']=='Blacklist')
|
|
|
- $eurl='editblinst.php';
|
|
|
- elseif ($row['tab']=='Instances')
|
|
|
- $eurl='editinst.php';
|
|
|
- elseif ($row['tab']=='Languages')
|
|
|
- $eurl='editlang.php';
|
|
|
+ if (!is_null($id)) {
|
|
|
+ if ($row['tab']=='Blacklist')
|
|
|
+ $eurl='editblinst.php';
|
|
|
+ elseif ($row['tab']=='Instances')
|
|
|
+ $eurl='editinst.php';
|
|
|
+ elseif ($row['tab']=='Languages')
|
|
|
+ $eurl='editlang.php';
|
|
|
// questo qui sotto non è errore: la tabella InstTrends non ha ID perciò non è editabile, il massimo che si può fare è andare a vedere la tabella Instances e i trends collegati (l'id che viene passato è infatti quello della tabella Instances)
|
|
|
- elseif ($row['tab']=='InstTrends')
|
|
|
- $eurl='editinst.php';
|
|
|
- notify('Ho dovuto troncare a '.$row['size'].' caratteri il valore da inserire nella colonna «'.$row['col'].'» della tabella «'.$row['tab'].'» perché troppo lungo ('.$row['len'].' caratteri). Puoi <a href="'.$eurl.'?id='.$row['id'].'">editarlo qui</a>.',2);
|
|
|
+ elseif ($row['tab']=='InstTrends')
|
|
|
+ $eurl='editinst.php';
|
|
|
+ }
|
|
|
+ $msg=$row['ctx'].': ho dovuto troncare a '.$row['size'].' caratteri il valore da inserire nella colonna «'.$row['col'].'» della tabella «'.$row['tab'].'» perché troppo lungo ('.$row['len'].' caratteri).';
|
|
|
+ if (!is_null($id))
|
|
|
+ $msg.=' Puoi <a href="'.$eurl.'?id='.$id.'">editarlo qui</a>.';
|
|
|
+ notify($msg,2);
|
|
|
}
|
|
|
$tronconi=array();
|
|
|
}
|
|
|
|
|
|
-function truncs($str,$tab,$col) {
|
|
|
+function truncs($str,$tab,$col,$ctx) {
|
|
|
global $tables, $tronconi;
|
|
|
$size=$tables[$tab][$col];
|
|
|
$len=mb_strlen($str,'UTF-8');
|
|
|
if ($len>$size) {
|
|
|
- $tronconi[]=array('id'=>null,'tab'=>$tab,'col'=>$col,'len'=>$len,'size'=>$size);
|
|
|
+ $tronconi[]=array('id'=>null,'tab'=>$tab,'col'=>$col,'ctx'=>$ctx,'len'=>$len,'size'=>$size);
|
|
|
$str=mb_substr($str,0,$size-1,'UTF-8').'…';
|
|
|
}
|
|
|
return($str);
|
|
|
}
|
|
|
|
|
|
-function truncn($num,$tab,$col) {
|
|
|
+function truncn($num,$tab,$col,$ctx) {
|
|
|
global $tables;
|
|
|
- if ($num>$tables[$tab][$col]['max']) {
|
|
|
- notify('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('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'];
|
|
|
+ if (is_numeric($num)) {
|
|
|
+ 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);
|
|
|
+ $num=0;
|
|
|
}
|
|
|
return($num);
|
|
|
}
|
|
@@ -362,11 +371,11 @@ if (!$riprendi) {
|
|
|
|
|
|
foreach ($blacklistnew as $row) {
|
|
|
if (!willtrunc($row['Domain'],'Blacklist','Domain')) {
|
|
|
- mysqli_query($link,'INSERT INTO Blacklist (ID, Domain, CreatedAt, ModifiedAt, Severity, RejectMedia, RejectReports, PrivateComment, PublicComment) VALUES (NULL, \''.myesc($link,$row['Domain']).'\', \''.myesc($link,$row['CreatedAt']).'\', \''.myesc($link,$row['ModifiedAt']).'\', \''.myesc($link,$row['Severity']).'\', \''.myesc($link,$row['RejectMedia']).'\', \''.myesc($link,$row['RejectReports']).'\', NULL, \''.myesc($link,truncs($row['PublicComment'],'Blacklist','PublicComment')).'\')')
|
|
|
+ mysqli_query($link,'INSERT INTO Blacklist (ID, Domain, CreatedAt, ModifiedAt, Severity, RejectMedia, RejectReports, PrivateComment, PublicComment) VALUES (NULL, \''.myesc($link,$row['Domain']).'\', \''.myesc($link,$row['CreatedAt']).'\', \''.myesc($link,$row['ModifiedAt']).'\', \''.myesc($link,$row['Severity']).'\', \''.myesc($link,$row['RejectMedia']).'\', \''.myesc($link,$row['RejectReports']).'\', NULL, \''.myesc($link,$row['Domain']).'\')')
|
|
|
or mexit(mysqli_error($link).N,3);
|
|
|
flushtronc(mysqli_insert_id($link));
|
|
|
} else {
|
|
|
- notify('Non ho potuto inserire «'.$row['Domain'].'» nella tabella delle istanze blacklistate perché il dominio è troppo lungo.',2);
|
|
|
+ notify('Non ho potuto inserire «'.$row['Domain'].'» nella tabella delle istanze blacklistate perché il dominio è troppo lungo per il campo corrispondente nel DB.',2);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -390,8 +399,6 @@ if (!$riprendi) {
|
|
|
fclose($instsf);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
function willtrunc($str,$tab,$col) {
|
|
|
global $tables;
|
|
|
if (mb_strlen($str,'UTF-8')>$tables[$tab][$col])
|
|
@@ -456,7 +463,7 @@ function langs($instid) {
|
|
|
$res=mysqli_query($link,'SELECT * FROM Languages WHERE Code=\''.myesc($link,$lang).'\'')
|
|
|
or mexit(mysqli_error($link).N,3);
|
|
|
if (mysqli_num_rows($res)<1) {
|
|
|
- mysqli_query($link,'INSERT INTO Languages (ID, Code, ItName, OwnName) VALUES (NULL, \''.myesc($link,truncs($lang,'Languages','Code')).'\', \''.myesc($link,truncs(ucfirst(locale_get_display_name($lang,'it')),'Languages','ItName')).'\', \''.myesc($link,truncs(ucfirst(locale_get_display_name($lang,$lang)),'Languages','OwnName')).'\')')
|
|
|
+ mysqli_query($link,'INSERT INTO Languages (ID, Code) VALUES (NULL, \''.myesc($link,truncs($lang,'Languages','Code','«'.$instrow['URI'].'»')).'\')')
|
|
|
or mexit(mysqli_error($link).N,3);
|
|
|
$langid=mysqli_insert_id($link);
|
|
|
flushtronc($langid);
|
|
@@ -540,9 +547,17 @@ while ($i<$cinsts) {
|
|
|
// per ora teniamo solo quelle che, se si identificano, si identificano come mastodon o corgidon (derivato di mastodon)
|
|
|
// teniamo d'occhio le notifiche di cui sotto per includere eventualmente altri derivati di mastodon?
|
|
|
// visti fin qui, verificare cosa sono: epicyon
|
|
|
- if (is_array($info['x-nodeinfo']) && array_key_exists('software',$info['x-nodeinfo']) && array_key_exists('name',$info['x-nodeinfo']['software']) && preg_match('/^mastodon|corgidon/',$info['x-nodeinfo']['software']['name'])===0) {
|
|
|
- $ok=false;
|
|
|
- notify('Il software «'.$info['x-nodeinfo']['software']['name'].'» non è mastodon o derivati.',1);
|
|
|
+ if (is_array($info['x-nodeinfo']) && array_key_exists('software',$info['x-nodeinfo']) && array_key_exists('name',$info['x-nodeinfo']['software']) &&!is_null($info['x-nodeinfo']['software']['name'])) {
|
|
|
+ if (preg_match('/^mastodon|corgidon/',$info['x-nodeinfo']['software']['name'])===0)
|
|
|
+ $ok=false;
|
|
|
+ $res=mysqli_query($link,'SELECT Name FROM Platforms WHERE Name=\''.myesc($link,$info['x-nodeinfo']['software']['name']).'\'')
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
+ if (mysqli_num_rows($res)<1) {
|
|
|
+ $res=mysqli_query($link,'INSERT INTO Platforms (Name) VALUES (\''.myesc($link,truncs($info['x-nodeinfo']['software']['name'],'Platforms','Name','«'.$info['uri'].'»')).'\')')
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
+ notify('«'.$info['uri'].'» utilizza come software «'.$info['x-nodeinfo']['software']['name'].'»; lo aggiungo alla tabella delle piattaforme incontrate. Se non si tratta di mastodon o corgidon, che già vengono accettati, sarebbe buona cosa verificare se è una variante di mastodon e quanto è compatibile, per valutare se accettare le istanze che lo utilizzano.',1);
|
|
|
+ flushtronc(null);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
lecho('ERRORE :-('.N);
|
|
@@ -578,12 +593,12 @@ while ($i<$cinsts) {
|
|
|
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')).'\'')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
if (mysqli_num_rows($res)>0) {
|
|
|
lecho('«'.$dom.'» non risponde, ma è presente nel database; aggiorno InstChecks.');
|
|
|
$row=mysqli_fetch_assoc($res);
|
|
|
mysqli_query($link,'INSERT INTO InstChecks (InstID, Time, Status) VALUES ('.$row['ID'].', '.time().', 0)')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
}
|
|
|
}
|
|
|
if (is_array($info) && count($info)>0) {
|
|
@@ -598,55 +613,55 @@ while ($i<$cinsts) {
|
|
|
$instrow['Blacklisted']=1;
|
|
|
$instrow['URI']=$info['uri'];
|
|
|
if (akeavinn('title',$info))
|
|
|
- $instrow['Title']=nempty(truncs($info['title'],'Instances','Title'));
|
|
|
+ $instrow['Title']=nempty(truncs($info['title'],'Instances','Title','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('short_description',$info))
|
|
|
- $instrow['ShortDesc']=nempty(truncs($info['short_description'],'Instances','ShortDesc'));
|
|
|
+ $instrow['ShortDesc']=nempty(truncs($info['short_description'],'Instances','ShortDesc','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('description',$info))
|
|
|
- $instrow['LongDesc']=nempty(truncs($info['description'],'Instances','LongDesc'));
|
|
|
+ $instrow['LongDesc']=nempty(truncs($info['description'],'Instances','LongDesc','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('email',$info))
|
|
|
- $instrow['Email']=nempty(truncs($info['email'],'Instances','Email'));
|
|
|
+ $instrow['Email']=nempty(truncs($info['email'],'Instances','Email','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('version',$info))
|
|
|
- $instrow['Version']=nempty(truncs($info['version'],'Instances','Version'));
|
|
|
+ $instrow['Version']=nempty(truncs($info['version'],'Instances','Version','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('stats',$info)) {
|
|
|
if (akeavinn('user_count',$info['stats']))
|
|
|
- $instrow['UserCount']=truncn($info['stats']['user_count'],'Instances','UserCount');
|
|
|
+ $instrow['UserCount']=truncn($info['stats']['user_count'],'Instances','UserCount','«'.$instrow['URI'].'»');
|
|
|
if (akeavinn('status_count',$info['stats']))
|
|
|
- $instrow['StatusCount']=truncn($info['stats']['status_count'],'Instances','StatusCount');
|
|
|
+ $instrow['StatusCount']=truncn($info['stats']['status_count'],'Instances','StatusCount','«'.$instrow['URI'].'»');
|
|
|
if (akeavinn('domain_count',$info['stats']))
|
|
|
- $instrow['DomainCount']=truncn($info['stats']['domain_count'],'Instances','DomainCount');
|
|
|
+ $instrow['DomainCount']=truncn($info['stats']['domain_count'],'Instances','DomainCount','«'.$instrow['URI'].'»');
|
|
|
}
|
|
|
if (akeavinn('thumbnail',$info))
|
|
|
- $instrow['Thumb']=nempty(truncs($info['thumbnail'],'Instances','Thumb'));
|
|
|
+ $instrow['Thumb']=nempty(truncs($info['thumbnail'],'Instances','Thumb','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('max_toot_chars',$info))
|
|
|
- $instrow['MaxTootChars']=truncn($info['max_toot_chars'],'Instances','MaxTootChars');
|
|
|
+ $instrow['MaxTootChars']=truncn($info['max_toot_chars'],'Instances','MaxTootChars','«'.$instrow['URI'].'»');
|
|
|
if (akeavinn('registrations',$info))
|
|
|
$instrow['RegOpen']=b2i($info['registrations'],'Istanza «'.$instrow['URI'].'»: ');
|
|
|
if (akeavinn('approval_required',$info))
|
|
|
$instrow['RegReqApproval']=b2i($info['approval_required'],'Istanza «'.$instrow['URI'].'»: ');
|
|
|
if (akeavinn('contact_account',$info)) {
|
|
|
if (akeavinn('acct',$info['contact_account']))
|
|
|
- $instrow['AdmAccount']=nempty(truncs($info['contact_account']['acct'],'Instances','AdmAccount'));
|
|
|
+ $instrow['AdmAccount']=nempty(truncs($info['contact_account']['acct'],'Instances','AdmAccount','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('display_name',$info['contact_account']))
|
|
|
- $instrow['AdmDisplayName']=nempty(truncs($info['contact_account']['display_name'],'Instances','AdmAccount'));
|
|
|
+ $instrow['AdmDisplayName']=nempty(truncs($info['contact_account']['display_name'],'Instances','AdmAccount','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('created_at',$info['contact_account']))
|
|
|
$instrow['AdmCreatedAt']=pgdatetomy($info['contact_account']['created_at']);
|
|
|
if (akeavinn('note',$info['contact_account']))
|
|
|
- $instrow['AdmNote']=nempty(truncs(strip_tags($info['contact_account']['note'],'<a>'),'Instances','AdmNote'));
|
|
|
+ $instrow['AdmNote']=nempty(truncs(strip_tags($info['contact_account']['note'],'<a>'),'Instances','AdmNote','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('url',$info['contact_account']))
|
|
|
- $instrow['AdmURL']=nempty(truncs($info['contact_account']['url'],'Instances','AdmURL'));
|
|
|
+ $instrow['AdmURL']=nempty(truncs($info['contact_account']['url'],'Instances','AdmURL','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('avatar',$info['contact_account']))
|
|
|
- $instrow['AdmAvatar']=nempty(truncs($info['contact_account']['avatar'],'Instances','AdmAvatar'));
|
|
|
+ $instrow['AdmAvatar']=nempty(truncs($info['contact_account']['avatar'],'Instances','AdmAvatar','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('header',$info['contact_account']))
|
|
|
- $instrow['AdmHeader']=nempty(truncs($info['contact_account']['header'],'Instances','AdmHeader'));
|
|
|
+ $instrow['AdmHeader']=nempty(truncs($info['contact_account']['header'],'Instances','AdmHeader','«'.$instrow['URI'].'»'));
|
|
|
}
|
|
|
if (akeavinn('x-nodeinfo',$info)) {
|
|
|
if (akeavinn('software',$info['x-nodeinfo']) && akeavinn('name',$info['x-nodeinfo']['software']))
|
|
|
- $instrow['Software']=nempty(truncs($info['x-nodeinfo']['software']['name'],'Instances','Software'));
|
|
|
+ $instrow['Software']=nempty(truncs($info['x-nodeinfo']['software']['name'],'Instances','Software','«'.$instrow['URI'].'»'));
|
|
|
if (akeavinn('usage',$info['x-nodeinfo']) && akeavinn('users',$info['x-nodeinfo']['usage'])) {
|
|
|
if (akeavinn('activeMonth',$info['x-nodeinfo']['usage']['users']))
|
|
|
- $instrow['ActiveUsersMonth']=truncn($info['x-nodeinfo']['usage']['users']['activeMonth'],'Instances','ActiveUsersMonth');
|
|
|
+ $instrow['ActiveUsersMonth']=truncn($info['x-nodeinfo']['usage']['users']['activeMonth'],'Instances','ActiveUsersMonth','«'.$instrow['URI'].'»');
|
|
|
if (akeavinn('activeHalfyear',$info['x-nodeinfo']['usage']['users']))
|
|
|
- $instrow['ActiveUsersHalfYear']=truncn($info['x-nodeinfo']['usage']['users']['activeHalfyear'],'Instances','ActiveUsersHalfYear');
|
|
|
+ $instrow['ActiveUsersHalfYear']=truncn($info['x-nodeinfo']['usage']['users']['activeHalfyear'],'Instances','ActiveUsersHalfYear','«'.$instrow['URI'].'»');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -683,7 +698,7 @@ while ($i<$cinsts) {
|
|
|
}
|
|
|
|
|
|
$res=mysqli_query($link,'SELECT * FROM Instances WHERE URI=\''.myesc($link,$instrow['URI']).'\'')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
|
|
|
if (mysqli_num_rows($res)>0) {
|
|
|
lecho('«'.$instrow['URI'].'» è già presente nel DB, la aggiorno...'.N);
|
|
@@ -700,9 +715,9 @@ while ($i<$cinsts) {
|
|
|
$instrow['Chosen']=$oldinstrow['Chosen'];
|
|
|
$instrow['Visible']=$oldinstrow['Visible'];
|
|
|
if ($instrow['ShortDesc']!=$oldinstrow['ShortDesc'])
|
|
|
- notify('<p>La «Descrizione breve» dell’istanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata. La vecchia era...</p><div class="valdesc">'.$oldinstrow['ShortDesc'].'</div><p>La nuova è...</p><div class="valdesc">«'.$instrow['ShortDesc'].'</div>',1);
|
|
|
+ notify('<p>La «Descrizione breve» dell’istanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata. La vecchia era...</p><div class="valdesc">'.$oldinstrow['ShortDesc'].'</div><p>La nuova è...</p><div class="valdesc">'.$instrow['ShortDesc'].'</div>',1);
|
|
|
if ($instrow['LongDesc']!=$oldinstrow['LongDesc'])
|
|
|
- notify('<p>La «Descrizione lunga» dell’istanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata. La vecchia era...</p><div class="valdesc">'.$oldinstrow['LongDesc'].'</div><p>La nuove è...</p><div class="valdesc">«'.$instrow['LongDesc'].'</div>',1);
|
|
|
+ notify('<p>La «Descrizione lunga» dell’istanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata. La vecchia era...</p><div class="valdesc">'.$oldinstrow['LongDesc'].'</div><p>La nuove è...</p><div class="valdesc">'.$instrow['LongDesc'].'</div>',1);
|
|
|
$instrow['OurDesc']=$oldinstrow['OurDesc'];
|
|
|
$instrow['PlaceID']=$oldinstrow['PlaceID'];
|
|
|
$query='UPDATE Instances SET ';
|
|
@@ -715,10 +730,10 @@ while ($i<$cinsts) {
|
|
|
$query=substr($query,0,-2).' WHERE Instances.ID='.$instrow['ID'];
|
|
|
lecho('QUERONA DI UPDATE: «'.$query.'».'.N);
|
|
|
mysqli_query($link,$query)
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
|
|
|
$res=mysqli_query($link,'SELECT InstID, LangID, Pos, Code FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$instrow['ID'].' ORDER BY Pos ASC')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
$oldinstlangs=array();
|
|
|
while ($row=mysqli_fetch_assoc($res))
|
|
|
$oldinstlangs[]=$row;
|
|
@@ -726,10 +741,10 @@ while ($i<$cinsts) {
|
|
|
if ($instlangs!=$oldinstlangs) {
|
|
|
notify('La lista delle lingue utilizzate dichiarate dall’istanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata da «'.subarimp(', ','Code',$oldinstlangs).'» a «'.subarimp(', ','Code',$instlangs).'».',1);
|
|
|
mysqli_query($link,'DELETE FROM InstLangs WHERE InstID='.$instrow['ID'])
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
foreach ($instlangs as $row) {
|
|
|
mysqli_query($link,'INSERT INTO InstLangs (InstID, LangID, Pos) VALUES ('.$row['InstID'].', '.$row['LangID'].', '.$row['Pos'].')')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -748,7 +763,7 @@ while ($i<$cinsts) {
|
|
|
$query='INSERT INTO Instances ('.implode(', ',$fields).') VALUES ('.$values.')';
|
|
|
lecho('QUERONA DI INSERT: «'.$query.'»'.N);
|
|
|
mysqli_query($link,$query)
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
$instid=mysqli_insert_id($link);
|
|
|
|
|
|
flushtronc($instid);
|
|
@@ -756,11 +771,11 @@ while ($i<$cinsts) {
|
|
|
$instlangs=langs($instid);
|
|
|
foreach ($instlangs as $row) {
|
|
|
mysqli_query($link,'INSERT INTO InstLangs (InstID, LangID, Pos) VALUES ('.$row['InstID'].', '.$row['LangID'].', '.$row['Pos'].')')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
}
|
|
|
|
|
|
if ($instrow['Good']==1)
|
|
|
- notify('La nuova istanza «<a href="editinst.php?id=">'.$info['uri'].'</a>» è papabile!',1);
|
|
|
+ notify('La nuova istanza «<a href="editinst.php?id='.$instid.'">'.$instrow['URI'].'</a>» è papabile!',1);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -770,7 +785,7 @@ while ($i<$cinsts) {
|
|
|
if (akeavinn('week',$buf) && akeavinn('statuses',$buf) && akeavinn('logins',$buf) && akeavinn('registrations',$buf)) {
|
|
|
$query='INSERT INTO InstActivity (InstID, Week, Statuses, Logins, Registrations) VALUES (\''.$instid.'\', \''.myesc($link,$buf['week']).'\', \''.myesc($link,$buf['statuses']).'\', \''.myesc($link,$buf['logins']).'\', \''.myesc($link,$buf['registrations']).'\')';
|
|
|
mysqli_query($link,$query)
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -800,9 +815,9 @@ while ($i<$cinsts) {
|
|
|
$pos=0;
|
|
|
foreach ($trends as $trend) {
|
|
|
$pos++;
|
|
|
- $query='INSERT INTO InstTrends (InstID, LastDay, Name, URL, Pos) VALUES ('.$trend['InstID'].', \''.$trend['LastDay'].'\', \''.myesc($link,truncs($trend['Name'],'InstTrends','Name')).'\', \''.myesc($link,truncs($trend['URL'],'InstTrends','URL')).'\', '.$pos.')';
|
|
|
+ $query='INSERT INTO InstTrends (InstID, LastDay, Name, URL, Pos) VALUES ('.$trend['InstID'].', \''.$trend['LastDay'].'\', \''.myesc($link,truncs($trend['Name'],'InstTrends','Name','«'.$instrow['URI'].'»')).'\', \''.myesc($link,truncs($trend['URL'],'InstTrends','URL','«'.$instrow['URI'].'»')).'\', '.$pos.')';
|
|
|
mysqli_query($link,$query)
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
// questo qui sotto non è errore, vedi il commento relativo nella funzione
|
|
|
flushtronc($instid);
|
|
|
}
|
|
@@ -810,7 +825,7 @@ while ($i<$cinsts) {
|
|
|
}
|
|
|
|
|
|
mysqli_query($link,'INSERT INTO InstChecks (InstID, Time, Status) VALUES ('.$instid.', '.time().', 1)')
|
|
|
- or mexit(mysqli_error($link).N,3,true);
|
|
|
+ or mexit(mysqli_error($link).N,3);
|
|
|
|
|
|
}
|
|
|
}
|