28 dicembre 2019

This commit is contained in:
pezcurrel 2019-12-28 22:51:41 +01:00
parent 113d3090e7
commit 16f8cdd583
7 changed files with 808 additions and 103 deletions

View file

@ -18,6 +18,10 @@
define('N',"\n");
$link=false;
$logf=false;
$jsonf=false;
declare(ticks=1);
pcntl_signal(SIGTERM,'signalHandler');// Termination ('kill' was called)
pcntl_signal(SIGHUP,'signalHandler');// Terminal log-out
@ -82,11 +86,13 @@ function tosec($str) {
}
}
function mexit($msg,$code,$closemy=false) {
global $link;
function mexit($msg,$code) {
global $link, $jsonf, $logf;
lecho($msg);
if ($closemy)
if ($link)
mysqli_close($link);
if ($jsonf)
fclose($jsonf);
if ($logf)
fclose($logf);
exit($code);
@ -111,7 +117,32 @@ $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);
mysqli_set_charset($link,'utf8');
mysqli_set_charset($link,'utf8mb4')
or mexit(mysqli_error($link).N,1);
$tables=array();
$res=mysqli_query($link,'SHOW TABLES')
or mexit(mysqli_error($link).N,1);
while ($row=mysqli_fetch_row($res)) {
$resb=mysqli_query($link,'SHOW COLUMNS FROM '.$row[0])
or mexit(mysqli_error($link).N,1);
$fields=array();
while ($rowb=mysqli_fetch_assoc($resb)) {
preg_match('/\((.*)\)/',$rowb['Type'],$buf);
$fields[$rowb['Field']]=$buf[1];
}
$tables[$row[0]]=$fields;
}
function trunc($str,$tab,$col) {
global $tables;
$size=$tables[$tab][$col];
if (mb_strlen($str,'UTF-8')>$size) {
$str=mb_substr($str,0,$size-1,'UTF-8').'…';
notify('Ho dovuto troncare a '.$size.' caratteri il valore da inserire nella colonna «'.$col.'» della tabella «'.$tab.'» perché troppo lungo.',2);
}
return($str);
}
$contextopts=array(
'http'=>array(
@ -126,15 +157,18 @@ $context=stream_context_create($contextopts);
$blacklist=array();
lecho('Carico la blacklist dal database...'.N);
$res=mysqli_query($link,'SELECT * FROM Blacklist')
or mexit(mysqli_error($link).N,3,true);
or mexit(mysqli_error($link).N,3);
lecho(mysqli_num_rows($res).' istanze nella blacklist.'.N);
while($row=mysqli_fetch_assoc($res)) {
$blacklist[$row['Domain']]=$row;
}
function pgdatetomy($pgdate) {
if (preg_match('/^(\d+)-(\d+)-(\d+)[ T]{1}(\d+):(\d+):(\d+)\.(\d+)Z?$/',$pgdate,$buf)===1) {
return(mktime($buf[4],$buf[5],$buf[6],$buf[2],$buf[3],$buf[1])+floatval('0.'.$buf[7]));
if (preg_match('/^(\d+)-(\d+)-(\d+)[ T]{1}(\d+):(\d+):(\d+)(\.\d+)?Z?$/',$pgdate,$buf)===1) {
$mtime=mktime($buf[4],$buf[5],$buf[6],$buf[2],$buf[3],$buf[1]);
if (array_key_exists(7,$buf))
$mtime=$mtime+floatval('0'.$buf[7]);
return($mtime);
} else {
return(false);
}
@ -157,7 +191,7 @@ $blacklistnew=array();
$insts=array();
lecho('Carico le istanze di partenza...'.N);
$res=mysqli_query($link,'SELECT Domain FROM StartNodes')
or mexit(mysqli_error($link).N,3,true);
or mexit(mysqli_error($link).N,3);
lecho(mysqli_num_rows($res).' istanze di partenza.'.N);
while($row=mysqli_fetch_assoc($res)) {
$insts[$row['Domain']]=null;
@ -194,7 +228,7 @@ while($row=mysqli_fetch_assoc($res)) {
}
//lecho('Carico le istanze note dal DB e aggiungo alla lista di quelle da controllare quelle che non ci sono già.'.N);
$res=mysqli_query($link,'SELECT URI FROM Instances')
or mexit(mysqli_error($link).N,3,true);
or mexit(mysqli_error($link).N,3);
while($row=mysqli_fetch_assoc($res)) {
if (!array_key_exists($row['URI'],$insts))
$insts[$row['URI']]=null;
@ -208,11 +242,10 @@ lecho('Istanze blacklistate: '.count($blacklist).', di cui '.count($blacklistnew
foreach ($blacklistnew as $row) {
foreach($row as $key=>$val)
$row[$key]=myesc($link,$val);
mysqli_query($link,'INSERT INTO Blacklist (ID, Domain, CreatedAt, ModifiedAt, Severity, RejectMedia, RejectReports, PrivateComment, PublicComment) VALUES (NULL, \''.$row['Domain'].'\', \''.$row['CreatedAt'].'\', \''.$row['ModifiedAt'].'\', \''.$row['Severity'].'\', \''.$row['RejectMedia'].'\', \''.$row['RejectReports'].'\', NULL, \''.$row['PublicComment'].'\')')
or mexit(mysqli_error($link).N,3,true);
mysqli_query($link,'INSERT INTO Blacklist (ID, Domain, CreatedAt, ModifiedAt, Severity, RejectMedia, RejectReports, PrivateComment, PublicComment) VALUES (NULL, \''.trunc($row['Domain'],'Blacklist','Domain').'\', \''.$row['CreatedAt'].'\', \''.$row['ModifiedAt'].'\', \''.$row['Severity'].'\', \''.$row['RejectMedia'].'\', \''.$row['RejectReports'].'\', NULL, \''.trunc($row['PublicComment'],'Blacklist','PublicComment').'\')')
or mexit(mysqli_error($link).N,3);
}
//INSERT INTO `Instances` (`ID`, `New`, `Chosen`, `Visible`, `BlackListed`, `URI`, `Title`, `ShortDesc`, `LongDesc`, `OurDesc`, `PlaceID`, `Email`, `Software`, `Version`, `UserCount`, `StatusCount`, `DomainCount`, `ActiveUsersMonth`, `ActiveUsersHalfYear`, `Thumb`, `RegOpen`, `RegReqApproval`, `MaxTootChars`, `AdmAccount`, `AdmDisplayName`, `AdmCreatedAt`, `AdmNote`, `AdmURL`, `AdmAvatar`, `AdmHeader`) VALUES (NULL, '1', '0', '0', '0', 'pantagruel.dnsup.net', 'Pantagruel', 'Descrizione breve', 'Descrizione lunga', 'Istanza molto carina senza soffitto, senza cucina', '1', 'Graume <graume@inventati.org>', 'mastodon', '3.0.1', '2', '12', '345', '5', '10', 'http://www.iedm.it', '1', '0', '540', 'admin', 'Admin', '2019-12-11', 'Note \'admin\'', 'https://rame.altervista.org', 'http://www.iedm.it', 'http://www.iedm.it');
function b2i($bool) {
if ($bool)
@ -221,9 +254,9 @@ function b2i($bool) {
return(0);
}
//array key exists and value is not null
//is array, array key exists and value is not null
function akeavinn($key,&$arr) {
if (array_key_exists($key,$arr) && !is_null($arr[$key]))
if (is_array($arr) && array_key_exists($key,$arr) && !is_null($arr[$key]))
return(true);
else
return(false);
@ -250,9 +283,59 @@ function subarim($glue,$key,&$arr) {
}
function notify($msg,$sev) {
global $link;
mysqli_query($link,'INSERT INTO Notifications (ID, Notification, Severity, Microtime) VALUES (NULL, \''.myesc($link,$msg).'\', '.$sev.', '.microtime().')')
or mexit(mysqli_error($link).N,3,true);
global $link, $tables;
mysqli_query($link,'INSERT INTO Notifications (ID, Notification, Severity, Microtime) VALUES (NULL, \''.myesc($link,mb_substr($msg,0,$tables['Notifications']['Notification'],'UTF-8')).'\', '.$sev.', \''.microtime(true).'\')')
or mexit(mysqli_error($link).N,3);
}
function langs($isnewinst,$instid) {
global $info, $instrow, $link;
$instlangs=array();
if (akeavinn('languages',$info)) {
$pos=0;
foreach ($info['languages'] as $lang) {
$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, Name) VALUES (NULL, \''.myesc($link,trunc($lang,'Languages','Code')).'\', NULL)')
or mexit(mysqli_error($link).N,3);
$langid=mysqli_insert_id($link);
if ($isnewinst) {
$subj='Linserimento';
} else {
$subj='Laggiornamento';
}
notify($subj.' dei dati relativi allistanza «<a href="editinst.php?id='.$instid.'">'.$instrow['URI'].'</a>» ha aggiunto un codice lingua non ancora noto, «'.$lang.'», di cui non conosco il nome per esteso. Puoi <a href="editlang.php?id='.$langid.'">editarlo qui</a>.',1);
} else {
$row=mysqli_fetch_assoc($res);
$langid=$row['ID'];
}
$pos++;
$instlangs[]=array('InstID'=>$instid,'LangID'=>$langid,'Pos'=>$pos,'Code'=>$lang);
}
}
return($instlangs);
}
function varbdump($var) {
ob_start();
var_dump($var);
$content=ob_get_contents();
ob_end_clean();
return($content);
}
function mdasortbykey(&$arr,$key,$rev=false) {
$karr=array();
foreach ($arr as $akey=>$subarr)
$karr[$subarr[$key]]=array($akey,$subarr);
if (!$rev)
ksort($karr);
else
krsort($karr);
$arr=array();
foreach ($karr as $akey=>$subarr)
$arr[$subarr[0]]=$subarr[1];
}
/*
@ -268,70 +351,90 @@ if ($opts['jsonwrite']) {
}
$cinsts=count($insts);
$i=0;
$ok=0;
$qok=0;
$qgood=0;
foreach ($insts as $dom=>$row) {
$i++;
$ok=true;
$info=null;
lecho('~~~~~~~~~~~~~~~'.N);
lecho('Provo a recuperare info su «'.$dom.'» ['.$i.'/'.$cinsts.' ('.$ok.' OK) - '.round(100/$cinsts*$i).'%]'.N);
lecho('Provo a recuperare info su «'.$dom.'» ['.$i.'/'.$cinsts.' ('.$qok.' OK; '.$qgood.' BUONE) - '.round(100/$cinsts*$i).'%]'.N);
lecho('Provo a recuperare le informazioni API sullistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/api/v1/instance',false,$context);
if ($buf!==false) {
$ok++;
lecho('OK :-)'.N);
$info=json_decode($buf,true);
if (array_key_exists('version',$info)) {
if ($info['version']>='2.1.2') {
lecho('Provo a recuperare le informazioni API sullattività dellistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/api/v1/instance/activity',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-activity']=json_decode($buf,true);
} else {
lecho('ERRORE :-('.N);
}
}
if ($info['version']>='3.0.0') {
lecho('Provo a recuperare le informazioni Nodeinfo sullistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/nodeinfo/2.0',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-nodeinfo']=json_decode($buf,true);
} else {
lecho('ERRORE :-('.N);
}
lecho('Provo a recuperare le informazioni API sui trends dellistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/api/v1/trends',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-trends']=json_decode($buf,true);
} else {
lecho('ERRORE :-('.N);
if (is_array($info)) {
lecho('OK :-)'.N);
lecho('Provo a recuperare le informazioni Nodeinfo sullistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/nodeinfo/2.0',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-nodeinfo']=json_decode($buf,true);
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;
lecho('Il software «'.$info['x-nodeinfo']['software']['name'].'» non è mastodon o derivati.'.N);
}
} else {
lecho('ERRORE :-('.N);
}
if ($ok && array_key_exists('version',$info)) {
if ($info['version']>='2.1.2') {
lecho('Provo a recuperare le informazioni API sullattività dellistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/api/v1/instance/activity',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-activity']=json_decode($buf,true);
} else {
lecho('ERRORE :-('.N);
}
}
if ($info['version']>='3.0.0') {
lecho('Provo a recuperare le informazioni API sui trends dellistanza ... ');
$buf=@file_get_contents('https://'.$dom.'/api/v1/trends',false,$context);
if ($buf!==false) {
lecho('OK :-)'.N);
$info['x-trends']=json_decode($buf,true);
} else {
lecho('ERRORE :-('.N);
}
}
}
} else {
$ok=false;
lecho('ERRORE :-('.N);
}
} else {
$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')).'\'')
or mexit(mysqli_error($link).N,3,true);
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);
}
}
if (!is_null($info) && akeavinn('uri',$info) && !is_null(nempty($info['uri']))) {
if ($ok && !is_null($info) && akeavinn('uri',$info) && !is_null(nempty($info['uri'])) && akeavinn('version',$info) && preg_match('/pleroma|pixelfed/i',$info['version'])===0) {
$qok++;
lecho(json_encode($info,JSON_PRETTY_PRINT).N,true);
if ($opts['jsonwrite'])
fwrite($jsonf,'"'.$info['uri'].'": '.json_encode($info,JSON_PRETTY_PRINT).','.N);
//INSERT INTO `Instances` (`ID`, `New`, `Chosen`, `Visible`, `BlackListed`, `URI`, `Title`, `ShortDesc`, `LongDesc`, `OurDesc`, `PlaceID`, `Email`, `Software`, `Version`, `UserCount`, `StatusCount`, `DomainCount`, `ActiveUsersMonth`, `ActiveUsersHalfYear`, `Thumb`, `RegOpen`, `RegReqApproval`, `MaxTootChars`, `AdmAccount`, `AdmDisplayName`, `AdmCreatedAt`, `AdmNote`, `AdmURL`, `AdmAvatar`, `AdmHeader`) VALUES (NULL, '1', '0', '0', '0', 'pantagruel.dnsup.net', 'Pantagruel', 'Descrizione breve', 'Descrizione lunga', 'Istanza molto carina senza soffitto, senza cucina', '1', 'Graume <graume@inventati.org>', 'mastodon', '3.0.1', '2', '12', '345', '5', '10', 'http://www.iedm.it', '1', '0', '540', 'admin', 'Admin', '2019-12-11', 'Note \'admin\'', 'https://rame.altervista.org', 'http://www.iedm.it', 'http://www.iedm.it');
$instrow=array('ID'=>null, 'New'=>0, 'Chosen'=>0, 'Visible'=>0, 'BlackListed'=>0, 'URI'=>null, 'Title'=>null, 'ShortDesc'=>null, 'LongDesc'=>null, 'OurDesc'=>null, 'PlaceID'=>null, 'Email'=>null, 'Software'=>null, 'Version'=>null, 'UserCount'=>null, 'StatusCount'=>null, 'DomainCount'=>null, 'ActiveUsersMonth'=>null, 'ActiveUsersHalfYear'=>null, 'Thumb'=>null, 'RegOpen'=>null, 'RegReqApproval'=>null, 'MaxTootChars'=>null, 'AdmAccount'=>null, 'AdmDisplayName'=>null, 'AdmCreatedAt'=>null, 'AdmNote'=>null, 'AdmURL'=>null, 'AdmAvatar'=>null, 'AdmHeader'=>null);
$instrow=array('ID'=>null, 'New'=>0, 'Good'=>0, 'Chosen'=>0, 'Visible'=>0, 'BlackListed'=>0, 'URI'=>null, 'Title'=>null, 'ShortDesc'=>null, 'LongDesc'=>null, 'OurDesc'=>null, 'PlaceID'=>null, 'Email'=>null, 'Software'=>null, 'Version'=>null, 'UserCount'=>null, 'StatusCount'=>null, 'DomainCount'=>null, 'ActiveUsersMonth'=>null, 'ActiveUsersHalfYear'=>null, 'Thumb'=>null, 'RegOpen'=>null, 'RegReqApproval'=>null, 'MaxTootChars'=>null, 'AdmAccount'=>null, 'AdmDisplayName'=>null, 'AdmCreatedAt'=>null, 'AdmNote'=>null, 'AdmURL'=>null, 'AdmAvatar'=>null, 'AdmHeader'=>null);
if (array_key_exists($info['uri'],$blacklist))
$instrow['BlackListed']=1;
$instrow['URI']=nempty($info['uri']);
$instrow['URI']=nempty(trunc($info['uri'],'Instances','URI'));
if (akeavinn('title',$info))
$instrow['Title']=nempty($info['title']);
$instrow['Title']=nempty(trunc($info['title'],'Instances','Title'));
if (akeavinn('short_description',$info))
$instrow['ShortDesc']=nempty($info['short_description']);
$instrow['ShortDesc']=nempty(trunc($info['short_description'],'Instances','ShortDesc'));
if (akeavinn('description',$info))
$instrow['LongDesc']=nempty($info['description']);
$instrow['LongDesc']=nempty(trunc($info['description'],'Instances','LongDesc'));
if (akeavinn('email',$info))
$instrow['Email']=nempty($info['email']);
$instrow['Email']=nempty(trunc($info['email'],'Instances','Email'));
if (akeavinn('version',$info))
$instrow['Version']=nempty($info['version']);
$instrow['Version']=nempty(trunc($info['version'],'Instances','Version'));
if (akeavinn('stats',$info)) {
if (akeavinn('user_count',$info['stats']))
$instrow['UserCount']=$info['stats']['user_count'];
@ -341,7 +444,7 @@ foreach ($insts as $dom=>$row) {
$instrow['DomainCount']=$info['stats']['domain_count'];
}
if (akeavinn('thumbnail',$info))
$instrow['Thumb']=nempty($info['thumbnail']);
$instrow['Thumb']=nempty(trunc($info['thumbnail'],'Instances','Thumb'));
if (akeavinn('max_toot_chars',$info))
$instrow['MaxTootChars']=$info['max_toot_chars'];
if (akeavinn('registrations',$info))
@ -350,23 +453,23 @@ foreach ($insts as $dom=>$row) {
$instrow['RegReqApproval']=b2i($info['approval_required']);
if (akeavinn('contact_account',$info)) {
if (akeavinn('acct',$info['contact_account']))
$instrow['AdmAccount']=nempty($info['contact_account']['acct']);
$instrow['AdmAccount']=nempty(trunc($info['contact_account']['acct'],'Instances','AdmAccount'));
if (akeavinn('display_name',$info['contact_account']))
$instrow['AdmDisplayName']=nempty($info['contact_account']['display_name']);
$instrow['AdmDisplayName']=nempty(trunc($info['contact_account']['display_name'],'Instances','AdmAccount'));
if (akeavinn('created_at',$info['contact_account']))
$instrow['AdmCreatedAt']=pgdatetomy($info['contact_account']['created_at']);
if (akeavinn('note',$info['contact_account']))
$instrow['AdmNote']=nempty(strip_tags($info['contact_account']['note'],'<a>'));
$instrow['AdmNote']=nempty(trunc(strip_tags($info['contact_account']['note'],'<a>'),'Instances','AdmNote'));
if (akeavinn('url',$info['contact_account']))
$instrow['AdmURL']=nempty($info['contact_account']['url']);
$instrow['AdmURL']=nempty(trunc($info['contact_account']['url'],'Instances','AdmURL'));
if (akeavinn('avatar',$info['contact_account']))
$instrow['AdmAvatar']=nempty($info['contact_account']['avatar']);
$instrow['AdmAvatar']=nempty(trunc($info['contact_account']['avatar'],'Instances','AdmAvatar'));
if (akeavinn('header',$info['contact_account']))
$instrow['AdmHeader']=nempty($info['contact_account']['header']);
$instrow['AdmHeader']=nempty(trunc($info['contact_account']['header'],'Instances','AdmHeader'));
}
if (akeavinn('x-nodeinfo',$info)) {
if (akeavinn('software',$info['x-nodeinfo']) && akeavinn('name',$info['x-nodeinfo']['software']))
$instrow['Software']=nempty($info['x-nodeinfo']['software']['name']);
$instrow['Software']=nempty(trunc($info['x-nodeinfo']['software']['name'],'Instances','Software'));
if (akeavinn('usage',$info['x-nodeinfo']) && akeavinn('users',$info['x-nodeinfo']['usage'])) {
if (akeavinn('activeMonth',$info['x-nodeinfo']['usage']['users']))
$instrow['ActiveUsersMonth']=$info['x-nodeinfo']['usage']['users']['activeMonth'];
@ -374,55 +477,85 @@ foreach ($insts as $dom=>$row) {
$instrow['ActiveUsersHalfYear']=$info['x-nodeinfo']['usage']['users']['activeHalfyear'];
}
}
$whynot=array();
if ($instrow['BlackListed']==1)
$whynot[]='è nella blacklist';
if (is_null($instrow['RegOpen'])) {
$whynot[]='non se ne conosce lo stato delle registrazioni (aperte/chiuse)';
} elseif ($instrow['RegOpen']==0) {
$whynot[]='ha le registrazioni chiuse';
}
if (is_null($instrow['UserCount'])) {
$whynot[]='non se ne conosce il numero di utenti';
} elseif ($instrow['UserCount']<10 || $instrow['UserCount']>30000) {
$whynot[]='il numero di utenti non è compreso tra 10 e 30.000';
}
if (is_null($instrow['DomainCount'])) {
$whynot[]='non se ne conosce il numero di istanze note';
} elseif ($instrow['DomainCount']<500) {
$whynot[]='il numero di istanze note è minore di 500';
}
if (!is_null($instrow['ActiveUsersMonth'])) {
if ($instrow['ActiveUsersMonth']<10)
$whynot[]='il numero di utenti attivi nellultimo mese è minore di 10';
} elseif (!is_null($instrow['StatusCount']) && $instrow['StatusCount']/$instrow['UserCount']<10) {
$whynot[]='il numero medio di toots per utente è minore di 10';
}
if (count($whynot)==0) {
$instrow['Good']=1;
lecho('Siamo in presenza di unistanza BUONA!'.N);
$qgood++;
}
$res=mysqli_query($link,'SELECT * FROM Instances WHERE URI=\''.myesc($link,$instrow['URI']).'\'')
or mexit(mysqli_error($link).N,3,true);
if (mysqli_num_rows($res)>0) {
lecho('«'.$instrow['URI'].'» è già presente nel DB, la aggiorno...'.N);
$oldinstrow=mysqli_fetch_assoc($res);
$instid=$oldinstrow['ID'];
$instrow['ID']=$oldinstrow['ID'];
$instrow['New']=$oldinstrow['New'];
if ($instrow['Good']==1 && $oldinstrow['Good']==0) {
notify('Listanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» non era papabile, ma lo è diventata!',1);
} elseif ($instrow['Good']==0 && $oldinstrow['Good']==1) {
notify('Listanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» era papabile, ma non lo è più per i seguenti motivi: '.implode('; ',$whynot),3);
}
$instrow['Chosen']=$oldinstrow['Chosen'];
$instrow['Visible']=$oldinstrow['Visible'];
if ($instrow['ShortDesc']!=$oldinstrow['ShortDesc'])
notify('<p>La «Descrizione breve» dellistanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata da...</p><div class="valdesc">'.$oldinstrow['ShortDesc'].'</div><p>...a...</p><div class="valdesc">«'.$instrow['ShortDesc'].'</div>',1);
if ($instrow['LongDesc']!=$oldinstrow['LongDesc'])
notify('<p>La «Descrizione lunga» dellistanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata da...</p><div class="valdesc">'.$oldinstrow['LongDesc'].'</div><p>...a...</p><div class="valdesc">«'.$instrow['LongDesc'].'</div>',1);
$instrow['PlaceID']=$oldinstrow['PlaceID'];
$query='UPDATE Instances SET ';
foreach ($instrow as $field=>$value) {
if (!is_null($value))
$query.=$field.'=\''.myesc($link,$value).'\', ';
else
$query.=$field.'=\'NULL\', ';
$query.=$field.'=NULL, ';
}
$query=substr($query,0,-2).' WHERE Instances.ID='.$oldinstrow['ID'];
echo('QUERONA DI UPDATE: «'.$query.'».'.N);
/* $res=mysql_query($link,'SELECT InstID, LangID, Pos, Code FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$oldinstrow['ID'].' ORDER BY Pos ASC')
$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);
$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);
$oldinstlangs=array();
while ($row=mysql_fetch_assoc($res))
while ($row=mysqli_fetch_assoc($res))
$oldinstlangs[]=$row;
if (akeavinn('languages',$info)) {
$instlangs=array();
$pos=0;
foreach ($info['languages'] as $lang) {
$res=mysqli_query($link,'SELECT * FROM Languages WHERE Code=\''.myesc($link,$lang).'\'')
$instlangs=langs(false,$instrow['ID']);
if ($instlangs!=$oldinstlangs) {
notify('La lista delle lingue utilizzate dichiarate dallistanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata da «'.subarim(', ','Code',$oldinstlangs).'» a «'.subarim(', ','Code',$instlangs).'».',1);
mysqli_query($link,'DELETE FROM InstLangs WHERE InstID='.$instrow['ID'])
or mexit(mysqli_error($link).N,3,true);
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);
if (mysqli_num_rows($res)<1) {
mysqli_query($link,'INSERT INTO Languages (ID, Code, Name) VALUES (NULL, \''.myesc($link,$lang).'\', NULL)')
or mexit(mysqli_error($link).N,3,true);
$langid=mysqli_insert_id($link);
notify('Laggiornamento dei dati relativi allistanza «<a href="editinst.php?id='.$oldinstrow['ID'].'">'.$info['URI'].'</a>» ha aggiunto un codice lingua non ancora noto, «'.$lang.'», di cui non conosco il nome per esteso. Puoi <a href="editlang.php?id='.$langid.'">editarlo qui</a>.',1);
} else {
$row=mysqli_fetch_assoc($res);
$langid=$row['ID'];
}
$pos++;
$instlangs[]=array('InstID'=>$oldinstrow['ID'],'LangID'=>$langid,'Pos'=>$pos,'Code'=>$lang);
}
print_r($instlangs);
print_r($oldinstlangs);
if ($instlangs!=$oldinstlangs) {
notify('La lista delle lingue utilizzate dichiarate dallistanza «<a href="editinst.php?id='.$oldinstrow['ID'].'">'.$info['URI'].'</a>» è cambiata da «'.subarim(', ','Code',$oldinstlangs).'» a «'.subarim(', ','Code',$oldinstlangs).'».',1);
mysqli_query($link,'DELETE FROM InstLangs WHERE InstID='.$oldinstrow['ID'])
or mexit(mysqli_error($link).N,3,true);
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);
}
}
}*/
}
} else {
lecho('«'.$info['uri'].'» non è già presente nel DB, la aggiungo...'.N);
$instrow['New']=1;
@ -437,9 +570,64 @@ foreach ($insts as $dom=>$row) {
}
$values=substr($values,0,-2);
$query='INSERT INTO Instances ('.implode(', ',$fields).') VALUES ('.$values.')';
echo('QUERONA DI INSERT: «'.$query.'»'.N);
lecho('QUERONA DI INSERT: «'.$query.'»'.N);
mysqli_query($link,$query)
or mexit(mysqli_error($link).N,3,true);
$instid=mysqli_insert_id($link);
$instlangs=langs(false,$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);
}
}
// var_dump($instrow);
if (array_key_exists('x-activity',$info) && is_array($info['x-activity'])) {
mysqli_query($link,'DELETE FROM InstActivity WHERE InstID='.$instid);
foreach ($info['x-activity'] as $buf) {
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);
}
}
}
if (array_key_exists('x-trends',$info) && is_array($info['x-trends'])) {
mysqli_query($link,'DELETE FROM InstTrends WHERE InstID='.$instid);
$trends=array();
foreach ($info['x-trends'] as $buf) {
if (akeavinn('name',$buf) && akeavinn('url',$buf) && akeavinn('history',$buf) && is_array($buf['history'])) {
$trend=0;
foreach ($buf['history'] as $row) {
if ($row['uses']>0)
$trend+=($row['accounts']/$row['uses']);
}
$trends[]=array(
'InstID'=>$instid,
'LastDay'=>$buf['history'][0]['day'],
'Name'=>myesc($link,trunc($buf['name'],'InstTrends','Name')),
'URL'=>myesc($link,trunc($buf['url'],'InstTrends','URL')),
'Pos'=>null,
'trend'=>$trend
);
}
}
mdasortbykey($trends,'trend',true);
// print_r($trends);
$pos=0;
foreach ($trends as $trend) {
$pos++;
$query='INSERT INTO InstTrends (InstID, LastDay, Name, URL, Pos) VALUES ('.$instid.', \''.myesc($link,$trend['LastDay']).'\', \''.myesc($link,trunc($trend['Name'],'InstTrends','Name')).'\', \''.myesc($link,trunc($trend['URL'],'InstTrends','URL')).'\', '.$pos.')';
mysqli_query($link,$query)
or mexit(mysqli_error($link).N,3,true);
}
}
mysqli_query($link,'INSERT INTO InstChecks (InstID, Time, Status) VALUES ('.$instid.', '.time().', 1)')
or mexit(mysqli_error($link).N,3,true);
}
}

View file

@ -2,7 +2,7 @@
$iniarr=parse_ini_file('sec/marcovaldo.ini') or muoribene(_('Impossibile aprire il file di configurazione.'),false);
$link=mysqli_connect($iniarr['myhost'],$iniarr['myuser'],$iniarr['mypassword'],$iniarr['mydb']) or muoribene(_('Impossibile connettersi al database').': '.mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
mysqli_set_charset($link,'utf8');
mysqli_set_charset($link,'utf8mb4');
$res=mysqli_query($link,'SELECT * FROM Users WHERE ID='.$_SESSION['uid']) or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($res)!=1) muoribene(_('Utente non esistente.').'<br><a href="index.php">Login</a>.',true);
$user=mysqli_fetch_assoc($res);

View file

@ -4,6 +4,6 @@ $iniarr=parse_ini_file('sec/mastostartadmin.ini')
or muoribene('Impossibile aprire il file di configurazione.<br>'.$btl,false);
$link=mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
or muoribene('Impossibile connettersi al database: '.mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
mysqli_set_charset($link,'utf8');
mysqli_set_charset($link,'utf8mb4');
?>

View file

@ -17,7 +17,7 @@ $iniarr=parse_ini_file('sec/mastostartadmin.ini')
or muoribene('Impossibile aprire il file di configurazione.<br>'.$btl,false);
$link=mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
or muoribene('Impossibile connettersi al database: '.mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
mysqli_set_charset($link,'utf8');
mysqli_set_charset($link,'utf8mb4');
$res=mysqli_query($link,'SELECT * FROM Admins WHERE Username=\''.mysqli_real_escape_string($link,$_POST['username']).'\'')
or muoribene(mysqli_error($link).'<br>'.$btl,true);
mysqli_close($link);

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="512"
height="512"
viewBox="0 0 135.46666 135.46667"
version="1.1"
id="svg8"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="icona.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="217.83103"
inkscape:cy="232.46478"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-page="true"
inkscape:snap-bbox="true"
inkscape:bbox-nodes="true"
inkscape:window-width="3840"
inkscape:window-height="2037"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-161.53331)">
<path
style="fill:#000000;stroke-width:0.60455555"
inkscape:connector-curvature="0"
d="m 132.58283,242.7442 c -1.99133,9.55598 -17.83516,20.01408 -36.031803,22.04088 -9.488764,1.0561 -18.831211,2.02679 -28.793355,1.60056 -16.292162,-0.69628 -29.147806,-3.62736 -29.147806,-3.62736 0,1.47941 0.09781,2.88803 0.293419,4.20541 2.11809,14.99778 15.943189,15.89623 29.039044,16.31517 13.217918,0.42185 24.987523,-3.03984 24.987523,-3.03984 l 0.543019,11.14633 c 0,0 -9.245422,4.63092 -25.715199,5.48265 -9.081891,0.46567 -20.358551,-0.21311 -33.492748,-3.45585 C 5.7790714,286.37929 0.88015717,258.05582 0.13057087,229.31707 -0.09790411,220.78436 0.042939,212.73843 0.042939,206.00917 c 0,-29.38685 20.641795,-38.0006 20.641795,-38.0006 10.408143,-4.45868 28.267551,-6.33367 46.834294,-6.47526 h 0.456167 c 18.566742,0.14151 36.437885,2.01658 46.845245,6.47526 0,0 20.64103,8.61375 20.64103,38.0006 0,0 0.25899,21.68178 -2.87864,36.73503"
id="path1428" />
<path
style="fill:#ffd42a;stroke-width:0.60455555"
inkscape:connector-curvature="0"
d="m 111.11398,208.28895 v 35.58258 H 96.000965 v -34.5367 c 0,-7.2803 -3.28394,-10.97554 -9.852602,-10.97554 -7.262697,0 -10.902651,4.38349 -10.902651,13.05125 V 230.3145 H 60.221901 v -18.90396 c 0,-8.66776 -3.640737,-13.05125 -10.903432,-13.05125 -6.568664,0 -9.852603,3.69524 -9.852603,10.97554 v 34.5367 H 24.352855 v -35.58258 c 0,-7.27227 1.985076,-13.05125 5.972437,-17.32675 4.111771,-4.27549 9.496588,-6.46724 16.181053,-6.46724 7.733731,0 13.590365,2.77272 17.462707,8.31888 l 3.764364,5.88627 3.765145,-5.88627 c 3.871561,-5.54616 9.728194,-8.31888 17.462708,-8.31888 6.683683,0 12.068501,2.19175 16.181051,6.46724 3.98658,4.2755 5.97166,10.05448 5.97166,17.32675"
id="path1430" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -0,0 +1,441 @@
-- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Creato il: Dic 28, 2019 alle 22:23
-- Versione del server: 10.4.11-MariaDB
-- Versione PHP: 7.4.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `mastostart`
--
-- --------------------------------------------------------
--
-- Struttura della tabella `Admins`
--
CREATE TABLE `Admins` (
`ID` int(10) UNSIGNED NOT NULL,
`Username` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`Email` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`Password` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dump dei dati per la tabella `Admins`
--
INSERT INTO `Admins` (`ID`, `Username`, `Email`, `Password`) VALUES
(1, 'pongrebio', 'pezcurrel@tiscali.it', '$2y$10$F8Q5pRwBIeZMkbf7COBYHe0HuO1EfPxegt7KPJsbCcPLZJpjXaeVO');
-- --------------------------------------------------------
--
-- Struttura della tabella `Blacklist`
--
CREATE TABLE `Blacklist` (
`ID` int(10) UNSIGNED NOT NULL,
`Domain` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL,
`CreatedAt` decimal(18,6) UNSIGNED NOT NULL,
`ModifiedAt` decimal(18,6) UNSIGNED NOT NULL,
`Severity` tinyint(3) UNSIGNED NOT NULL,
`RejectMedia` tinyint(1) UNSIGNED NOT NULL,
`RejectReports` tinyint(1) UNSIGNED NOT NULL,
`PrivateComment` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`PublicComment` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Financing`
--
CREATE TABLE `Financing` (
`ID` int(10) UNSIGNED NOT NULL,
`Type` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`Details` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstActivity`
--
CREATE TABLE `InstActivity` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`Week` int(10) UNSIGNED NOT NULL,
`Statuses` int(10) UNSIGNED NOT NULL,
`Logins` int(10) UNSIGNED NOT NULL,
`Registrations` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Instances`
--
CREATE TABLE `Instances` (
`ID` bigint(20) UNSIGNED NOT NULL,
`New` tinyint(1) UNSIGNED NOT NULL,
`Good` tinyint(1) UNSIGNED NOT NULL,
`Chosen` tinyint(1) UNSIGNED NOT NULL,
`Visible` tinyint(1) UNSIGNED NOT NULL,
`BlackListed` tinyint(1) UNSIGNED NOT NULL,
`URI` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
`Title` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ShortDesc` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LongDesc` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`OurDesc` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`PlaceID` int(10) UNSIGNED DEFAULT NULL,
`Email` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Software` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Version` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`UserCount` int(10) UNSIGNED DEFAULT NULL,
`StatusCount` bigint(20) UNSIGNED DEFAULT NULL,
`DomainCount` int(10) UNSIGNED DEFAULT NULL,
`ActiveUsersMonth` int(10) UNSIGNED DEFAULT NULL,
`ActiveUsersHalfYear` int(10) UNSIGNED DEFAULT NULL,
`Thumb` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`RegOpen` tinyint(1) UNSIGNED DEFAULT NULL,
`RegReqApproval` tinyint(1) UNSIGNED DEFAULT NULL,
`MaxTootChars` mediumint(8) UNSIGNED DEFAULT NULL,
`AdmAccount` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AdmDisplayName` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AdmCreatedAt` decimal(18,6) DEFAULT NULL,
`AdmNote` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AdmURL` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AdmAvatar` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AdmHeader` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstChecks`
--
CREATE TABLE `InstChecks` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`Time` int(10) UNSIGNED NOT NULL,
`Status` tinyint(1) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstFinancing`
--
CREATE TABLE `InstFinancing` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`FinID` int(10) UNSIGNED NOT NULL,
`Pos` tinyint(3) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstLangs`
--
CREATE TABLE `InstLangs` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`LangID` int(10) UNSIGNED NOT NULL,
`Pos` tinyint(3) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstPolicies`
--
CREATE TABLE `InstPolicies` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`PolID` int(10) UNSIGNED NOT NULL,
`Pos` tinyint(3) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstTags`
--
CREATE TABLE `InstTags` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`TagID` int(10) UNSIGNED NOT NULL,
`Pos` tinyint(3) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `InstTrends`
--
CREATE TABLE `InstTrends` (
`InstID` bigint(20) UNSIGNED NOT NULL,
`LastDay` int(10) UNSIGNED NOT NULL,
`Name` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
`URL` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
`Pos` smallint(5) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Languages`
--
CREATE TABLE `Languages` (
`ID` int(11) UNSIGNED NOT NULL,
`Code` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
`Name` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Notifications`
--
CREATE TABLE `Notifications` (
`ID` bigint(20) UNSIGNED NOT NULL,
`Notification` varchar(15000) COLLATE utf8mb4_unicode_ci NOT NULL,
`Severity` tinyint(3) UNSIGNED NOT NULL,
`Microtime` decimal(18,6) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Places`
--
CREATE TABLE `Places` (
`ID` int(10) UNSIGNED NOT NULL,
`State` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Region` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Province` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Locality` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Policies`
--
CREATE TABLE `Policies` (
`ID` int(10) UNSIGNED NOT NULL,
`Name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `StartNodes`
--
CREATE TABLE `StartNodes` (
`ID` smallint(5) UNSIGNED NOT NULL,
`Domain` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dump dei dati per la tabella `StartNodes`
--
INSERT INTO `StartNodes` (`ID`, `Domain`) VALUES
(1, 'mastodon.bida.im'),
(2, 'mastodon.cisti.org'),
(3, 'nebbia.fail'),
(4, 'stereodon.social'),
(5, 'snapj.saja.freemyip.com'),
(6, 'pantagruel.dnsup.net');
-- --------------------------------------------------------
--
-- Struttura della tabella `Tags`
--
CREATE TABLE `Tags` (
`ID` int(10) UNSIGNED NOT NULL,
`Name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Struttura della tabella `Whitelist`
--
CREATE TABLE `Whitelist` (
`ID` mediumint(8) UNSIGNED NOT NULL,
`Domain` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Indici per le tabelle scaricate
--
--
-- Indici per le tabelle `Admins`
--
ALTER TABLE `Admins`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Blacklist`
--
ALTER TABLE `Blacklist`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Financing`
--
ALTER TABLE `Financing`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Instances`
--
ALTER TABLE `Instances`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Languages`
--
ALTER TABLE `Languages`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Notifications`
--
ALTER TABLE `Notifications`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Places`
--
ALTER TABLE `Places`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Policies`
--
ALTER TABLE `Policies`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `StartNodes`
--
ALTER TABLE `StartNodes`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Tags`
--
ALTER TABLE `Tags`
ADD PRIMARY KEY (`ID`);
--
-- Indici per le tabelle `Whitelist`
--
ALTER TABLE `Whitelist`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT per le tabelle scaricate
--
--
-- AUTO_INCREMENT per la tabella `Admins`
--
ALTER TABLE `Admins`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT per la tabella `Blacklist`
--
ALTER TABLE `Blacklist`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Financing`
--
ALTER TABLE `Financing`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Instances`
--
ALTER TABLE `Instances`
MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Languages`
--
ALTER TABLE `Languages`
MODIFY `ID` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Notifications`
--
ALTER TABLE `Notifications`
MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Places`
--
ALTER TABLE `Places`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Policies`
--
ALTER TABLE `Policies`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `StartNodes`
--
ALTER TABLE `StartNodes`
MODIFY `ID` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT per la tabella `Tags`
--
ALTER TABLE `Tags`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT per la tabella `Whitelist`
--
ALTER TABLE `Whitelist`
MODIFY `ID` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -0,0 +1,5 @@
GRANT USAGE ON *.* TO 'MastoStartUser'@'%' IDENTIFIED BY PASSWORD '*694485EF4E91F43D223AED551FEBFF0FD60CEF7A';
GRANT SELECT ON `mastostart`.* TO 'MastoStartUser'@'%';
GRANT USAGE ON *.* TO 'MastoStartAdmin'@'%' IDENTIFIED BY PASSWORD '*41CCC8BF24C943401C5CBBE9F1E00F451F8C82BF';
GRANT ALL PRIVILEGES ON `mastostart`.* TO 'MastoStartAdmin'@'%' WITH GRANT OPTION;