This commit is contained in:
pezcurrel 2020-04-07 19:39:06 +02:00
parent 3c631ccf7e
commit 3d8db9340e
13 changed files with 676 additions and 532 deletions

View file

@ -535,26 +535,8 @@ function get_instance_langs($host) {
$languages = get_languages($summary);
return $languages;
}
/** </LANGUAGE MANAGEMENT> */
/**
* ucfirst UTF-8 aware function
*
* @param string $string
* @return string
* @see http://ca.php.net/ucfirst
*/
function my_ucfirst($string, $e ='utf-8') {
if (function_exists('mb_strtoupper') && function_exists('mb_substr') && !empty($string)) {
$string = mb_strtolower($string, $e);
$upper = mb_strtoupper($string, $e);
preg_match('#(.)#us', $upper, $matches);
$string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e);
} else {
$string = ucfirst($string);
}
return $string;
}
require(__DIR__.'/../include/mb_ucfirst.php');
function langs($instid, $uri, $auto) {
global $info, $instrow, $link;
@ -575,11 +557,11 @@ function langs($instid, $uri, $auto) {
or mexit(__LINE__.': '.mysqli_error($link).N,3);
if (mysqli_num_rows($res)<1) {
$code=myesc($link,truncs($lang,'Languages','Code','«'.$instrow['URI'].'»'));
$NameIt=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'it')),'Languages','NameIT','«'.$instrow['URI'].'»'));
$NameEn=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'en')),'Languages','NameEN','«'.$instrow['URI'].'»'));
$NameEs=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'es')),'Languages','NameES','«'.$instrow['URI'].'»'));
$NameFr=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'fr')),'Languages','NameFR','«'.$instrow['URI'].'»'));
$NameOrig=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameOrig','«'.$instrow['URI'].'»'));
$NameIt=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'it')),'Languages','NameIT','«'.$instrow['URI'].'»'));
$NameEn=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'en')),'Languages','NameEN','«'.$instrow['URI'].'»'));
$NameEs=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'es')),'Languages','NameES','«'.$instrow['URI'].'»'));
$NameFr=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'fr')),'Languages','NameFR','«'.$instrow['URI'].'»'));
$NameOrig=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameOrig','«'.$instrow['URI'].'»'));
$q = 'INSERT INTO Languages (ID, Code, NameIT, NameEN, NameES, NameFR, NameOrig) VALUES (NULL, \''.$code.'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameEs.'\', \''.$NameFr.'\', \''.$NameOrig.'\')';
mysqli_query($link, $q)
or mexit(__LINE__.': '.mysqli_error($link).N,3);

View file

@ -1,28 +1,32 @@
- dafa
? dafa?
* fatto
~ più o meno
# in corso
- troncare tabella languages e far rigirare tools/popudb.php per ricrearla: my_ucfirst metteva in minuscolo tutta la stringa, a parte il primo carattere maiuscolo
? edinst.php: su languages non mostrare "lock this list" se account "Level" è "guest", e fare che viene settato il lock automaticamente se il guest admin lo cambia (lasciare agli admin non "guest" possibilità di cambiarlo)
- index.php: lunghezza automatica di username
- tutto: notifiche
- crawler.php: ricorsivizzarlo?
- crawler.php: deve controllare se nella tabella Instances OurAdmID è definito; se è definito deve aggiornare l'account "guest" corrispettivo in Admins con la mail e il nome utente attuali
- instances.php: tradurre tutto in inglese
* instances.php: icona della lente in qualche modo diversa se è attivo un filtro/ordinamento
* instances.php: i criteri di ricerca e ordinamento "volanti" vanno salvati sempre in un preset "di battaglia" (uno per ogni admin) in modo da poter slegare il cambio pagina dal submittare i filtri/ordinamenti e in modo che, per esempio, al ritorno da edinst*.php si possa vedere ciò che si vedeva prima (forse la cosa più agevole è fare due tabelle ad-hoc uguali a PresFiltConds e PresOrdConds dove invece di PresID si ha AdminID)
* instances.php, edinst*.php: implementare la faccenda della lingua del browser: se è tra quelle supportate (o una variante delle stesse) impostare la ricerca e la visualizzazione dei campi multilingua nella lingua supportata; altrimenti in inglese
- tutto: possibilità di *scegliere* la lingua da usare tra quelle supportate
- instances.php: rendere funzione il codice che crea una tabella-istanza; usare la funzione in edinst.php (?) e in edinstres.php
* edinst.php: aggiungere colonna flag bool in Instances che viene settata a 1 quando qualcuno edita la lista delle lingue "nostre", così che il crawler al giro successivo non la sovrascriva con quelle autorilevate
- edinsth.php: caso particolare di edaddrem() per "Languages": usare locale_get_display_name() per determinare le lingue supportate e controllare che la lingua esista (mi pare che se la lingua non esiste, ritorni valore uguale per tutte le lingue)
- edinsth.php: finire Localities
- implementare la faccenda dell'invio di mail preformattate agli admin con invito a editare i propri dati (quindi implementare "livelli di admin" e relative restrizioni: admin invitat* può vedere solo la pagina relativa alla propria istanza, solo aggiungere valori - non in tutti i casi, editare ed eliminare solo valori che ha aggiunto e solo se non sono già stati linkati da altr*)
* instances.php: eliminare il riferimento a "stato", aggiungere "OurDescEN"
? instances.php: bottoni per pagina precedente-successiva
- instances.php: alerta su cambio pagina quando è stato modificato filtro/ordinamento
- instances.php: possibilità di vedere solo le istanze che non rispondono da tot giorni (o forse farla a parte?)
- instances.php: notifiche
- instances.php: scomparsa-comparsa div di debug
- instances.php: ckf: controllare che non venga eseguito ordinamento su una stessa colonna più volte (non rompe query ma è ridondante)
* instances.php: invece di rifare la querona con LIMIT, usare il $res che c'è ritornando solo le istanze giuste per la pagina
* instances.php: icona della lente in qualche modo diversa se è attivo un filtro/ordinamento
* instances.php: i criteri di ricerca e ordinamento "volanti" vanno salvati sempre in un preset "di battaglia" (uno per ogni admin) in modo da poter slegare il cambio pagina dal submittare i filtri/ordinamenti e in modo che, per esempio, al ritorno da edinst*.php si possa vedere ciò che si vedeva prima (forse la cosa più agevole è fare due tabelle ad-hoc uguali a PresFiltConds e PresOrdConds dove invece di PresID si ha AdminID)
* instances.php, edinst*.php: implementare la faccenda della lingua del browser: se è tra quelle supportate (o una variante delle stesse) impostare la ricerca e la visualizzazione dei campi multilingua nella lingua supportata; altrimenti in inglese
* instances.php: rendere funzione il codice che crea una tabella-istanza; usare la funzione in guestinsts.php
* edinst.php: aggiungere colonna flag bool in Instances che viene settata a 1 quando qualcuno edita la lista delle lingue "nostre", così che il crawler al giro successivo non la sovrascriva con quelle autorilevate
* edinsth.php: caso particolare di edaddrem() per "Languages": usare locale_get_display_name() per determinare le lingue supportate e controllare che la lingua esista (se la lingua non esiste ritorna valore uguale al codice lingua passato, per tutte le lingue)
* instances.php: eliminare il riferimento a "stato", aggiungere "OurDescEN"
* instances.php: quando ordinamento è su una "1 a molti", eseguirlo su "GROUP_CONCAT" di questi molti ordinati per "Pos" della joinosa tabella
* ripristinare le colonne descrittive in Languages: una per la locale impostata (it), una per en, una per fr, una per es...
* instancesh.php: ritornare di tutte solo quelle che effettivamente sono usate, magari con un count tra ()

View file

@ -41,6 +41,7 @@ if (array_key_exists('id',$_GET) && preg_match('/^[0-9]+$/',$_GET['id'])===1) {
} else {
muoribene('Malformed input.',true);
}
$dbg.='<pre>'.print_r($inst,1).'</pre>'.N;
function check($row,$col) {
if ($row[$col]>0)
@ -272,6 +273,7 @@ function ckf() {
<ul>
<?php echo($menuout); ?>
</ul>
<div class="mtit">Editing «<?php echo($inst['URI']); ?>»</div>
<div id="rightdiv">
<a href="logout.php" class="rlinks"><img src="imgs/esci.svg" title="Sign out"></a>
</div>
@ -403,7 +405,7 @@ selbox(array(
'valcol'=>'ID',
'txtcol'=>'Name'.$dlang));
selbox(array(
$o=array(
'multi'=>true,
'dispselid'=>'DispLangs',
'title'=>'Languages',
@ -411,21 +413,24 @@ selbox(array(
'searchtit'=>'Filter available languages',
'disparr'=>'langselarr',
'regexcbid'=>'langselre',
'dispque'=>'SELECT * FROM Languages WHERE ID NOT IN (SELECT OurLangID FROM InstOurLangs WHERE InstID='.$inst['ID'].') ORDER BY Name'.$dlang.' ASC',
'dispque'=>'SELECT ID, CONCAT(Name'.$dlang.'," [",Code,"]") AS Txt FROM Languages WHERE ID NOT IN (SELECT OurLangID FROM InstOurLangs WHERE InstID='.$inst['ID'].') ORDER BY Name'.$dlang.' ASC',
'valcol'=>'ID',
'txtcol'=>'Name'.$dlang,
'txtcol'=>'Txt',
'dida'=>'Above: available languages; below: chosen languages',
'chosenselid'=>'ChosenLangs[]',
'chosenque'=>'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'OurLangID',
'edavail'=>false,
'addavail'=>false,
'remavail'=>false));
'chosenque'=>'SELECT OurLangID, CONCAT(Name'.$dlang.'," [",Code,"]") AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'OurLangID');
if ($account['Level']=='guest') {
$o['edavail']=false;
$o['addavail']=false;
$o['remavail']=false;
}
selbox($o);
?>
<table class="cbtab">
<tr><td><label for="OurLangsLock" title="Prevent languages from being overwritten on next crawler run">Lock this list:&nbsp;</label></td><td><input type="checkbox" id="OurLangsLock" name="OurLangsLock" title="Prevent languages from being overwritten on next crawler run"<?php check($inst,'OurLangsLock'); ?>></td></tr>
<tr><td><label for="OurLangsLock" title="Prevent languages from being overwritten on next crawler run">Lock this list:&nbsp;</label></td><td><input type="checkbox" id="OurLangsLock" name="OurLangsLock" title="Prevent languages from being overwritten on next crawler run"<?php if ($account['Level']=='guest') echo(' checked'); else echo(check($inst,'OurLangsLock')); ?>></td></tr>
</table>
<?php

View file

@ -3,11 +3,11 @@
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/myconn.php');
require('include/getadmacc.php');
require('include/tables.php');
$tables=tables($link);
require('include/mb_ucfirst.php');
$dbg='';
@ -35,11 +35,48 @@ $morejs='';
$dbg.='<pre>GET:'.N.print_r($_GET,1).'POST:'.N.print_r($_POST,1).'</pre>';
function edaddrem(&$link,&$morejs,&$id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$dispselid,$recbid) {
if ($_POST['m']=='add') {
mysqli_query($link,'INSERT INTO '.$table.' (ID, '.$column.') VALUES (NULL, \''.myesc($link,$_POST['v']).'\')')
or muoribene(__LINE__.': '.mysqli_error($link),true);
$newid=mysqli_insert_id($link);
function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$dispselid,$recbid) {
global $link, $morejs, $account, $dlang;
if ($_POST['m']=='edit') {
if ($table!='Languages') {
mysqli_query($link,'UPDATE '.$table.' SET '.$column.'=\''.myesc($link,$_POST['v']).'\' WHERE ID='.$id)
or muoribene(__LINE__.': '.mysqli_error($link),true);
} else {
$langs=array('NameOrig'=>mb_ucfirst(locale_get_display_name($_POST['v'],$_POST['v'])),
'NameEN'=>mb_ucfirst(locale_get_display_name($_POST['v'],'en')),
'NameES'=>mb_ucfirst(locale_get_display_name($_POST['v'],'es')),
'NameFR'=>mb_ucfirst(locale_get_display_name($_POST['v'],'fr')),
'NameIT'=>mb_ucfirst(locale_get_display_name($_POST['v'],'it')));
if ($_POST['v']==$langs['NameOrig']) {
muoribene('«'.$_POST['v'].'»: unknown language identifier.',true);
} else {
mysqli_query($link,'UPDATE '.$table.' SET Code=\''.myesc($link,$_POST['v']).'\', NameOrig=\''.myesc($link,$langs['NameOrig']).'\', NameEN=\''.myesc($link,$langs['NameEN']).'\', NameES=\''.myesc($link,$langs['NameES']).'\', NameFR=\''.myesc($link,$langs['NameFR']).'\', NameIT=\''.myesc($link,$langs['NameIT']).'\' WHERE ID='.$id)
or muoribene(__LINE__.': '.mysqli_error($link),true);
$_POST['v']=$langs['Name'.$dlang].' ['.$_POST['v'].']';
}
}
$morejs.='parent.'.$dispselarr.'=parent.cheltxtbyval(parent.'.$dispselarr.','.$id.',"'.jsencode($_POST['v']).'");'.N;
$morejs.='parent.'.$dispselarr.'=parent.sortByKey(parent.'.$dispselarr.',0);'.N;
} elseif ($_POST['m']=='add') {
if ($table!='Languages') {
mysqli_query($link,'INSERT INTO '.$table.' (ID, '.$column.', AddedBy) VALUES (NULL, \''.myesc($link,$_POST['v']).'\', \''.$account['ID'].'\')')
or muoribene(__LINE__.': '.mysqli_error($link),true);
$newid=mysqli_insert_id($link);
} else {
$langs=array('NameOrig'=>mb_ucfirst(locale_get_display_name($_POST['v'],$_POST['v'])),
'NameEN'=>mb_ucfirst(locale_get_display_name($_POST['v'],'en')),
'NameES'=>mb_ucfirst(locale_get_display_name($_POST['v'],'es')),
'NameFR'=>mb_ucfirst(locale_get_display_name($_POST['v'],'fr')),
'NameIT'=>mb_ucfirst(locale_get_display_name($_POST['v'],'it')));
if ($_POST['v']==$langs['NameOrig']) {
muoribene('«'.$_POST['v'].'»: unknown language identifier.',true);
} else {
mysqli_query($link,'INSERT INTO '.$table.' (ID, Code, NameOrig, NameEN, NameES, NameFR, NameIT, AddedBy) VALUES (NULL, \''.myesc($link,$_POST['v']).'\', \''.myesc($link,$langs['NameOrig']).'\', \''.myesc($link,$langs['NameEN']).'\', \''.myesc($link,$langs['NameES']).'\', \''.myesc($link,$langs['NameFR']).'\', \''.myesc($link,$langs['NameIT']).'\', '.$account['ID'].')')
or muoribene(__LINE__.': '.mysqli_error($link),true);
$newid=mysqli_insert_id($link);
$_POST['v']=$langs['Name'.$dlang].' ['.$_POST['v'].']';
}
}
$morejs.='parent.'.$dispselarr.'.push(["'.jsencode($_POST['v']).'",'.$newid.',true]);'.N;
$morejs.='parent.'.$dispselarr.'=parent.sortByKey(parent.'.$dispselarr.',0);'.N;
} elseif ($_POST['m']=='remove') {
@ -83,11 +120,6 @@ function edaddrem(&$link,&$morejs,&$id,$table,$column,$dispselarr,$lntable,$lnco
}
}
$morejs.='parent.'.$dispselarr.'=parent.rmelbyval(parent.'.$dispselarr.','.$id.');'.N;
} elseif ($_POST['m']=='edit') {
mysqli_query($link,'UPDATE '.$table.' SET '.$column.'=\''.myesc($link,$_POST['v']).'\' WHERE ID='.$id)
or muoribene(__LINE__.': '.mysqli_error($link),true);
$morejs.='parent.'.$dispselarr.'=parent.cheltxtbyval(parent.'.$dispselarr.','.$id.',"'.jsencode($_POST['v']).'");'.N;
$morejs.='parent.'.$dispselarr.'=parent.sortByKey(parent.'.$dispselarr.',0);'.N;
}
$morejs.='parent.filtsel (parent.'.$dispselarr.', parent.document.getElementById("'.$searchid.'").value, "'.$dispselid.'", "'.$recbid.'", "'.$searchid.'", "white", "#ff8080");'.N;
}
@ -96,32 +128,32 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^
$id=$_GET['i']+0;
switch ($_GET['w']) {
case 'LocalityID':
$fout=buildform($id,'Localities','Name'.$dlang,'Locality name','Instances','LocalityID');
$out=buildform($id,'Localities','Name'.$dlang,'Locality name','Instances','LocalityID');
$exvalsjsarr=setjsarr('Localities','Name'.$dlang);
break;
/*case 'DispLangs':
$fout=buildform($id,'Languages','Name'.$dlang,'Language','InstOurLangs','OurLangID');
$exvalsjsarr=setjsarr('Languages','Name'.$dlang);
break;*/
case 'DispLangs':
$out=buildform($id,'Languages','Code','Language code','InstOurLangs','OurLangID');
$exvalsjsarr=setjsarr('Languages','Code');
break;
case 'DispFinModes':
$fout=buildform($id,'Financing','Type','Financing method','InstFinancing','FinID');
$out=buildform($id,'Financing','Type','Financing method','InstFinancing','FinID');
$exvalsjsarr=setjsarr('Financing','Type');
break;
case 'DispPolicies':
$fout=buildform($id,'Policies','Name','Policy','InstPolicies','PolID');
$out=buildform($id,'Policies','Name','Policy','InstPolicies','PolID');
$exvalsjsarr=setjsarr('Policies','Name');
break;
case 'DispTags':
$fout=buildform($id,'Tags','Name','Tag','InstTags','TagID');
$out=buildform($id,'Tags','Name','Tag','InstTags','TagID');
$exvalsjsarr=setjsarr('Tags','Name');
break;
default:
muoribene(__LINE__.': Malformed input.',true);
break;
}
} elseif (array_key_exists('m',$_POST) && in_array($_POST['m'],array('edit','add','remove')) && array_key_exists('t',$_POST) && in_array($_POST['t'],array('Localities','Financing','Policies','Tags')) && array_key_exists('i',$_POST) && preg_match('/^[0-9]+$/',$_POST['i'])===1) {
} elseif (array_key_exists('m',$_POST) && in_array($_POST['m'],array('edit','add','remove')) && array_key_exists('t',$_POST) && in_array($_POST['t'],array('Localities','Languages','Financing','Policies','Tags')) && array_key_exists('i',$_POST) && preg_match('/^[0-9]+$/',$_POST['i'])===1) {
if (array_key_exists('v',$_POST)) {
$fout='';
$out='';
$id=$_POST['i']+0;
if ($_POST['t']=='Localities') {
//https://nominatim.openstreetmap.org/search?q=bresso,+milano&format=json&accept-language=fr&email=pezcurrel@tiscali.it
@ -129,16 +161,16 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^
$url='https://nominatim.openstreetmap.org/search?q='.urlencode($_POST['v']).'&format=json&email='.$email;
$osmd=@file_get_contents($url,false,$context);
if ($osmd!==false) {
$fout.='<form action="edinsth.php" method="post" id="f">'.N;
$out.='<form action="edinsth.php" method="post" id="f">'.N;
$addrkeys=array('suburb','city','county','state','country');
$osmd=json_decode($osmd,true);
if (count($osmd)>0) {
$some=false;
$fout.='<p><strong>Please choose the most detailed appropriate entry</strong></p>'.N;
$out.='<p><strong>Please choose the most detailed appropriate entry</strong></p>'.N;
foreach ($osmd as $loc) {
if (array_key_exists('osm_id',$loc) && array_key_exists('osm_type',$loc) && $loc['osm_type']=='relation') {
$fout.='<div class="hifloc" onclick="subosmd(\''.$loc['osm_id'].'\');">'.N;
$fout.='<ul class="hiful">'.N;
$out.='<div class="hifloc" onclick="subosmd(\''.$loc['osm_id'].'\');">'.N;
$out.='<ul class="hiful">'.N;
foreach ($langs as $code=>$lang) {
$url='https://nominatim.openstreetmap.org/lookup?osm_ids=R'.$loc['osm_id'].'&format=json&accept-language='.$code.'&addressdetails=1&email='.$email;
$osmdil=@file_get_contents($url,false,$context);
@ -151,49 +183,52 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^
if (array_key_exists($addrkey,$osmdil[0]['address']))
$dispname.=$osmdil[0]['address'][$addrkey].', ';
$dispname=substr($dispname,0,-2);
$fout.='<li><strong>'.$lang.':</strong> '.hspech($dispname).'</li>'.N;
$fout.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="'.jsencode($dispname).'">'.N;
$out.='<li><strong>'.$lang.':</strong> '.hspech($dispname).'</li>'.N;
$out.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="'.jsencode($dispname).'">'.N;
} else {
$fout.='<li class="hiferr"><strong>'.$lang.':</strong> Couldnt parse OpenStreetMap lookup data.</li>'.N;
$fout.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="">'.N;
$out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldnt parse OpenStreetMap lookup data.</li>'.N;
$out.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="">'.N;
}
} else {
$fout.='<li class="hiferr"><strong>'.$lang.':</strong> Couldnt fetch OpenStreetMap lookup data.</li>'.N;
$out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldnt fetch OpenStreetMap lookup data.</li>'.N;
}
}
$fout.='</ul>'.N.'</div>'.N;
$out.='</ul>'.N.'</div>'.N;
}
}
if ($some) {
$fout.='<input type="hidden" id="i" name="i" value="'.$_POST['i'].'">'.N;
$fout.='<input type="hidden" id="t" name="t" value="'.$_POST['t'].'">'.N;
$fout.='<input type="hidden" id="m" name="m" value="'.$_POST['m'].'">'.N;
$fout.='<input type="hidden" id="LocXx" name="LocXx" value="">'.N;
$fout.='<input type="hidden" id="LocEn" name="LocEn" value="">'.N;
$fout.='<input type="hidden" id="LocEs" name="LocEs" value="">'.N;
$fout.='<input type="hidden" id="LocFr" name="LocFr" value="">'.N;
$fout.='<input type="hidden" id="LocIt" name="LocIt" value="">'.N;
$fout.='</form>'.N;
$out.='<input type="hidden" id="i" name="i" value="'.$_POST['i'].'">'.N;
$out.='<input type="hidden" id="t" name="t" value="'.$_POST['t'].'">'.N;
$out.='<input type="hidden" id="m" name="m" value="'.$_POST['m'].'">'.N;
$out.='<input type="hidden" id="LocXx" name="LocXx" value="">'.N;
$out.='<input type="hidden" id="LocEn" name="LocEn" value="">'.N;
$out.='<input type="hidden" id="LocEs" name="LocEs" value="">'.N;
$out.='<input type="hidden" id="LocFr" name="LocFr" value="">'.N;
$out.='<input type="hidden" id="LocIt" name="LocIt" value="">'.N;
$out.='</form>'.N;
} else {
$fout='<p class="hiferr">Couldnt find localized OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
$out='<p class="hiferr">Couldnt find localized OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
}
} else {
$fout='<p class="hiferr">Couldnt find OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
$out='<p class="hiferr">Couldnt find OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
}
} else {
$fout='<p class="hiferr">Couldnt fetch OpenStreetMap search data.</p>'.N;
$out='<p class="hiferr">Couldnt fetch OpenStreetMap search data.</p>'.N;
}
/*} elseif ($_POST['t']=='Languagues') {
edaddrem($link,$morejs,$id,'Languages','Name'.$langd,'langselarr','InstOurLangs','OurLangID','langsearch','DispLangs','langselre');*/
} elseif ($_POST['t']=='Languages') {
edaddrem($id,'Languages','Name'.$dlang,'langselarr','InstOurLangs','OurLangID','langsearch','DispLangs','langselre');
} elseif ($_POST['t']=='Financing') {
edaddrem($link,$morejs,$id,'Financing','Type','finselarr','InstFinancing','FinID','finsearch','DispFinModes','finselre');
edaddrem($id,'Financing','Type','finselarr','InstFinancing','FinID','finsearch','DispFinModes','finselre');
} elseif ($_POST['t']=='Policies') {
edaddrem($link,$morejs,$id,'Policies','Name','polselarr','InstPolicies','PolID','polsearch','DispPolicies','polselre');
edaddrem($id,'Policies','Name','polselarr','InstPolicies','PolID','polsearch','DispPolicies','polselre');
} elseif ($_POST['t']=='Tags') {
edaddrem($link,$morejs,$id,'Tags','Name','tagselarr','InstTags','TagID','tagsearch','DispTags','tagselre');
edaddrem($id,'Tags','Name','tagselarr','InstTags','TagID','tagsearch','DispTags','tagselre');
} else {
// questo è ridondante ma fa niente
muoribene(__LINE__.': Malformed input.',true);
}
} elseif (array_key_exists('LocEn',$_POST) && array_key_exists('LocEs',$_POST) && array_key_exists('LocFr',$_POST) && array_key_exists('LocIt',$_POST)) {
$fout='CIAO!';
$out='CIAO!';
} else {
muoribene(__LINE__.': Malformed input.',true);
}
@ -203,68 +238,71 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^
function buildform($id,$table,$column,$title,$lntable,$lncolumn) {
global $account, $tables, $link;
$fout='';
$out='';
if ($_GET['m']=='edit' || $_GET['m']=='remove') {
$res=mysqli_query($link,'SELECT * FROM '.$table.' WHERE ID='.$id)
or muoribene(__LINE__.': '.mysqli_error($link),true);
if (mysqli_num_rows($res)==1) {
$row=mysqli_fetch_assoc($res);
/*if ($account['Level']=='guest') {
if ($row['AddedBy']!=$account['ID']
$rres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id.' AND InstID!='.$account['OwnInstID']) or muoribene(__LINE__.': '.mysqli_error($link),true);
if ($
if ($account['Level']=='guest') {
if ($row['AddedBy']!=$account['ID'])
muoribene('You cant modify an entry you didnt add.',true);
$rres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id.' AND AddedBy!='.$account['ID'])
or muoribene(__LINE__.': '.mysqli_error($link),true);
if (mysqli_num_rows($rres)>0)
muoribene('You cant modify an entry that has already been linked by others.',true);
}
$rres='SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id.' AND InstID!=
if ($account['Level']!='guest' || ($row['AddedBy']==$account['ID']*/
if ($_GET['m']=='edit') {
$fout.='<div class="hiflab"><label for="v">'.$title.'</label></div>'.N;
$fout.='<input type="text" class="hifinp" name="v" id="v" maxlength="'.$tables[$table][$column].'" value="'.hspech($row[$column]).'">'.N;
$fout.='<script language="JavaScript">'.N;
$fout.='<!--'.N;
$fout.='document.getElementById(\'v\').focus();'.N;
$fout.='document.getElementById(\'v\').select();'.N;
$fout.='//-->'.N;
$fout.='</script>'.N;
$out.='<div class="hiflab"><label for="v">'.$title.'</label></div>'.N;
$out.='<input type="text" class="hifinp" name="v" id="v" maxlength="'.$tables[$table][$column].'" value="'.hspech($row[$column]).'">'.N;
$out.='<script language="JavaScript">'.N;
$out.='<!--'.N;
$out.='document.getElementById(\'v\').focus();'.N;
$out.='document.getElementById(\'v\').select();'.N;
$out.='//-->'.N;
$out.='</script>'.N;
} elseif ($_GET['m']=='remove') {
$lnres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id)
or muoribene(__LINE__.': '.mysqli_error($link),true);
$nlinking=mysqli_num_rows($lnres);
if ($nlinking>0) {
$fout.='<div class="hiflab">«'.hspech($row[$column]).'» is referenced by '.$nlinking.' '.(($nlinking==1) ? 'instance' : 'instances').'!</div>'.N;
$fout.='<div class="hifdiv">What do you want to do with '.(($nlinking==1) ? 'this reference' : 'those '.$nlinking.' references').'?<br>If you choose “Delete” '.(($nlinking==1) ? 'it' : 'they').' will be removed; otherwise you can select a substitution record.</div>'.N;
$fout.='<select id="subst" name="subst" class="hifinp">'.N;
$fout.='<option value="0">Delete</option>'.N;
$out.='<div class="hiflab">«'.hspech($row[$column]).'» is referenced by '.$nlinking.' '.(($nlinking==1) ? 'instance' : 'instances').'!</div>'.N;
$out.='<div class="hifdiv">What do you want to do with '.(($nlinking==1) ? 'this reference' : 'those '.$nlinking.' references').'?<br>If you choose “Delete” '.(($nlinking==1) ? 'it' : 'they').' will be removed; otherwise you can select a substitution record.</div>'.N;
$out.='<select id="subst" name="subst" class="hifinp">'.N;
$out.='<option value="0">Delete</option>'.N;
$lnres=mysqli_query($link,'SELECT * FROM '.$table.' WHERE ID!='.$id.' ORDER BY '.$column.' ASC')
or muoribene(__LINE__.': '.mysqli_error($link),true);
while ($lnrow=mysqli_fetch_assoc($lnres)) {
$fout.='<option value="'.$lnrow['ID'].'">Subst. with «'.hspech($lnrow[$column]).'»</option>'.N;
$out.='<option value="'.$lnrow['ID'].'">Subst. with «'.hspech($lnrow[$column]).'»</option>'.N;
}
$fout.='</select>'.N;
$out.='</select>'.N;
} else {
$out.='<input type="hidden" name="subst" value="0">'.N;
}
$fout.='<div class="hiflab">Are you sure you want to remove «'.$row[$column].'»?</div>'.N;
$fout.='<input type="hidden" name="v" value="IGNORAMI">'.N;
$out.='<div class="hiflab">Are you sure you want to remove «'.$row[$column].'»?</div>'.N;
$out.='<input type="hidden" name="v" value="IGNORAMI">'.N;
}
$fout.='<input type="hidden" name="i" value="'.$id.'">'.N;
$out.='<input type="hidden" name="i" value="'.$id.'">'.N;
} else {
$fout.='<p>There is no '.$title.' with ID='.$id.'</p>'.N;
$out.='<p>There is no '.$title.' with ID='.$id.'</p>'.N;
}
} elseif ($_GET['m']=='add') {
$fout.='<div class="hiflab"><label for="v">'.$title.'</label></div>'.N;
$fout.='<input type="text" class="hifinp" name="v" id="v" maxlength="'.$tables[$table][$column].'" value="">'.N;
$fout.='<script language="JavaScript">'.N;
$fout.='<!--'.N;
$fout.='document.getElementById(\'v\').focus();'.N;
$fout.='document.getElementById(\'v\').select();'.N;
$fout.='//-->'.N;
$fout.='</script>'.N;
$fout.='<input type="hidden" name="i" value="0">'.N;
$out.='<div class="hiflab"><label for="v">'.$title.'</label></div>'.N;
$out.='<input type="text" class="hifinp" name="v" id="v" maxlength="'.$tables[$table][$column].'" value="">'.N;
$out.='<script language="JavaScript">'.N;
$out.='<!--'.N;
$out.='document.getElementById(\'v\').focus();'.N;
$out.='document.getElementById(\'v\').select();'.N;
$out.='//-->'.N;
$out.='</script>'.N;
$out.='<input type="hidden" name="i" value="0">'.N;
}
$fout.='<input type="hidden" name="m" value="'.$_GET['m'].'">'.N;
$fout.='<input type="hidden" name="t" value="'.$table.'">'.N;
$fout.='<div id="errmsg"></div>'.N;
$fout.='<table class="hiftab"><tr><td style="width:50%"><input type="button" value="Cancel" class="hifbut" onclick="parent.closeinpup()"></td><td style="width:50%"><input type="button" value="Ok" class="hifbut" onclick="ckf(\''.$_GET['m'].'\',\''.$table.'\')"></td></tr></table>'.N;
$fout='<form action="edinsth.php" method="post" id="f" onsubmit="return ckf(\''.$_GET['m'].'\',\''.$table.'\');">'.N.$fout.'</form>'.N;
return($fout);
$out.='<input type="hidden" name="m" value="'.$_GET['m'].'">'.N;
$out.='<input type="hidden" name="t" value="'.$table.'">'.N;
$out.='<div id="errmsg"></div>'.N;
$out.='<table class="hiftab"><tr><td style="width:50%"><input type="button" value="Cancel" class="hifbut" onclick="parent.closeinpup()"></td><td style="width:50%"><input type="button" value="Ok" class="hifbut" onclick="ckf(\''.$_GET['m'].'\',\''.$table.'\')"></td></tr></table>'.N;
$out='<form action="edinsth.php" method="post" id="f" onsubmit="return ckf(\''.$_GET['m'].'\',\''.$table.'\');">'.N.$out.'</form>'.N;
return($out);
}
function jsencode($str) {
@ -356,7 +394,7 @@ function subosmd(osmid) {
<body class="hifbody">
<div id="fullscreen">
<div id="middlerow">
<?php echo($fout); ?>
<?php echo($out); ?>
</div>
</div>
<?php echo($dbg); ?>

89
web/admin/guestinsts.php Normal file
View file

@ -0,0 +1,89 @@
<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/myconn.php');
require('include/getadmacc.php');
$dbg='';
use function mysqli_real_escape_string as myesc;
// praticamente una macro
function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Mastodon Startpage Admin - Your instances</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript">
<!--
//-->
</script>
</head>
<body>
<nav>
<div id="hmenu">
<div class="mtit">Your instances</div>
<div id="rightdiv">
<a href="logout.php" class="rlinks"><img src="imgs/esci.svg" title="Sign out"></a>
</div>
</div>
</nav>
<div id="popup">
<div id="inpopup">
<div id="popupcont">
...
</div>
</div>
</div>
<!-- <div id="footer">
</div> -->
<div id="fullscreen">
<div id="middlerow">
<?php
$res=mysqli_query($link,'SELECT *, ID AS IID FROM Instances WHERE OurAdmID='.$account['ID'])
or muoribene(__LINE__.': '.mysqli_error($link),true);
$cinsts=mysqli_num_rows($res);
if ($cinsts>0) {
// $out='<p>Your instances</p>'.N;
require('include/columns.php');
require('include/dispinst.php');
$i=0;
while ($row=mysqli_fetch_assoc($res)) {
$i++;
echo(dispinst($row,$cols,$link,$dlang,true,$i,$cinsts));
}
} else {
$out='<p>No instances to show.</p>'.N;
}
mysqli_close($link);
?>
</div>
</div>
<div id="debug">
<?php echo($dbg); ?>
</div>
</body>
</html>

View file

@ -0,0 +1,122 @@
<?php
/*SELECT *, Instances.ID AS IID, GROUP_CONCAT(OrdOurLanguages.NameIt ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR '; ') AS OrdOurLangs FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID LEFT JOIN InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID WHERE OurLanguages.NameIT LIKE '%italiano%' GROUP BY IID LIMIT 50*/
$cols=array(
'Instances.New'=>array('field'=>'Instances.New','name'=>'[Nuova]','type'=>'bool'),
'Instances.Good'=>array('field'=>'Instances.Good','name'=>'[Papabile]','type'=>'bool'),
'Instances.Chosen'=>array('field'=>'Instances.Chosen','name'=>'[Scelta]','type'=>'bool'),
'Instances.Visible'=>array('field'=>'Instances.Visible','name'=>'[Visibile]','type'=>'bool'),
'Instances.Blacklisted'=>array('field'=>'Instances.Blacklisted','name'=>'[Blacklistata]','type'=>'bool'),
'Instances.URI'=>array('field'=>'Instances.URI','name'=>'URI','type'=>'text'),
'Instances.Title'=>array('field'=>'Instances.Title','name'=>'Titolo','type'=>'text'),
'Instances.ShortDesc'=>array('field'=>'Instances.ShortDesc','name'=>'Descrizione breve','type'=>'text'),
'Instances.LongDesc'=>array('field'=>'Instances.LongDesc','name'=>'Descrizione lunga','type'=>'text'),
'Instances.OurDesc'=>array('field'=>'Instances.OurDesc','name'=>'[Descrizione nostra (in lingua originale)]','type'=>'text'),
'Instances.OurDescEN'=>array('field'=>'Instances.OurDescEN','name'=>'[Descrizione nostra (in inglese)]','type'=>'text'),
//--------------------------------
'Instances.LocalityID'=>array('field'=>'Instances.LocalityID','name'=>'[Località] ⮞','type'=>'join','join'=>array(),'ord'=>false),
'Localities.Name'=>array('field'=>'Localities.Name'.$dlang,'name'=>'[Località]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID'),'subtype'=>'text'),
//--------------------------------
'Instances.Email'=>array('field'=>'Instances.Email','name'=>'Email di contatto','type'=>'text'),
'Instances.Software'=>array('field'=>'Instances.Software','name'=>'Software','type'=>'text'),
'Instances.Version'=>array('field'=>'Instances.Version','name'=>'Versione','type'=>'text'),
'Instances.UserCount'=>array('field'=>'Instances.UserCount','name'=>'Numero utenti','type'=>'int'),
'Instances.StatusCount'=>array('field'=>'Instances.StatusCount','name'=>'Numero stati','type'=>'int'),
'Instances.DomainCount'=>array('field'=>'Instances.DomainCount','name'=>'Numero istanze note','type'=>'int'),
'Instances.ActiveUsersMonth'=>array('field'=>'Instances.ActiveUsersMonth','name'=>'Numero utenti attivi (mese)','type'=>'int'),
'Instances.ActiveUsersHalfYear'=>array('field'=>'Instances.ActiveUsersHalfYear','name'=>'Numero utenti attivi (6 mesi)','type'=>'int'),
'Instances.Thumb'=>array('field'=>'Instances.Thumb','name'=>'Logo','type'=>'text','search'=>false,'ord'=>false),
'Instances.RegOpen'=>array('field'=>'Instances.RegOpen','name'=>'Registrazioni aperte','type'=>'bool'),
'Instances.RegReqApproval'=>array('field'=>'Instances.RegReqApproval','name'=>'Approvazione registrazioni','type'=>'bool'),
'Instances.MaxTootChars'=>array('field'=>'Instances.MaxTootChars','name'=>'Limite caratteri','type'=>'int'),
'Instances.AdmAccount'=>array('field'=>'Instances.AdmAccount','name'=>'Account admin','type'=>'text'),
'Instances.AdmDisplayName'=>array('field'=>'Instances.AdmDisplayName','name'=>'Nome account admin','type'=>'text'),
'Instances.AdmCreatedAt'=>array('field'=>'Instances.AdmCreatedAt','name'=>'Data creazione account admin','type'=>'time'),
'Instances.AdmURL'=>array('field'=>'Instances.AdmURL','name'=>'Pagina delladmin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmAvatar'=>array('field'=>'Instances.AdmAvatar','name'=>'Avatar admin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmNote'=>array('field'=>'Instances.AdmNote','name'=>'Note delladmin','type'=>'text'),
//--------------------------------
'InstLangs'=>array('name'=>'Lingue dichiarate','search'=>false,'ord'=>false),
'InstLangs.LangID'=>array('field'=>'InstLangs%.LangID','name'=>'Una lingua dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID'),'ord'=>false),
'Languages.NameXX'=>array('field'=>'Languages%.Name'.$dlang,'name'=>'Una lingua dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID','Languages AS Languages% ON Languages%.ID=InstLangs%.LangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue dichiarate','ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.Name'.$dlang.' ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),
'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1'),'ord'=>false),
'Languages.NameXX.First'=>array('field'=>'Languages.Name'.$dlang,'name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1','Languages AS Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstOurLangs'=>array('name'=>'[Lingue impostate da noi]','search'=>false,'ord'=>false),
'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs%.OurLangID','name'=>'[Una lingua impostata da noi] ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID'),'ord'=>false),
'OurLanguages.NameXX'=>array('field'=>'OurLanguages%.Name'.$dlang,'name'=>'[Una lingua impostata da noi]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID','Languages AS OurLanguages% ON OurLanguages%.ID=InstOurLangs%.OurLangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue impostate da noi','ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.Name'.$dlang.' ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),
'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'[Lingua primaria impostata da noi] ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1'),'ord'=>false),
'OurLanguages.NameXX.First'=>array('field'=>'OurLanguages.Name'.$dlang,'name'=>'[Lingua primaria impostata da noi]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstFinancing'=>array('name'=>'[Modalità di finanziamento]','search'=>false,'ord'=>false),
'InstFinancing.FinID'=>array('field'=>'InstFinancing%.FinID','name'=>'[Una modalità di finanziamento] ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID'),'ord'=>false),
'Financing.Type'=>array('field'=>'Financing%.Type','name'=>'[Una modalità di finanziamento]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID','Financing AS Financing% ON Financing%.ID=InstFinancing%.FinID'),'subtype'=>'text','ord'=>true,'ordname'=>'Modalità di finanziamento','ordjoin'=>array('InstFinancing AS OrdInstFinancing ON OrdInstFinancing.InstID=Instances.ID','Financing AS OrdFinancing ON OrdFinancing.ID=OrdInstFinancing.FinID'),'ordselmore'=>'GROUP_CONCAT(OrdFinancing.Type ORDER BY OrdInstFinancing.Pos ASC SEPARATOR \'\') AS xOrdFinancing','ordby'=>'xOrdFinancing'),
'InstFinancing.FinID.First'=>array('field'=>'InstFinancing.FinID','name'=>'[Modalità di finanziamento primaria] ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1'),'ord'=>false),
'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'[Modalità di finanziamento primaria]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1','Financing AS Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstPolicies'=>array('name'=>'[Policies]','search'=>false,'ord'=>false),
'InstPolicies.PolID'=>array('field'=>'InstPolicies%.PolID','name'=>'[Una policy] ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID'),'ord'=>false),
'Policies.Name'=>array('field'=>'Policies%.Name','name'=>'[Una policy]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID','Policies AS Policies% ON Policies%.ID=InstPolicies%.PolID'),'subtype'=>'text','ord'=>true,'ordname'=>'Policies','ordjoin'=>array('InstPolicies AS OrdInstPolicies ON OrdInstPolicies.InstID=Instances.ID','Policies AS OrdPolicies ON OrdPolicies.ID=OrdInstPolicies.PolID'),'ordselmore'=>'GROUP_CONCAT(OrdPolicies.Name ORDER BY OrdInstPolicies.Pos ASC SEPARATOR \'\') AS xOrdPolicies','ordby'=>'xOrdPolicies'),
// Questi qui sotto sono disabilitati perché le policy non sono "pesate"
/*'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'[Policy primaria] ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1'),'ord'=>false),
'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'[Policy primaria]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1','Policies AS Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>false),*/
//--------------------------------
'InstTags'=>array('name'=>'[Tags]','search'=>false,'ord'=>false),
'InstTags.TagID'=>array('field'=>'InstTags%.TagID','name'=>'[Una tag] ⮞','type'=>'join','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID'),'ord'=>false),
'Tags.Name'=>array('field'=>'Tags%.Name','name'=>'[Una tag]','type'=>'joini','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID','Tags AS Tags% ON Tags%.ID=InstTags%.TagID'),'subtype'=>'text','ord'=>true,'ordname'=>'Tags','ordjoin'=>array('InstTags AS OrdInstTags ON OrdInstTags.InstID=Instances.ID','Tags AS OrdTags ON OrdTags.ID=OrdInstTags.TagID'),'ordselmore'=>'GROUP_CONCAT(OrdTags.Name ORDER BY OrdInstTags.Pos ASC SEPARATOR \'\') AS xOrdTags','ordby'=>'xOrdTags'),
'InstTags.TagID.First'=>array('field'=>'InstTags.TagID','name'=>'[Tag primaria] ⮞','type'=>'join','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1'),'ord'=>false),
'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'[Tag primaria]','type'=>'joini','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1','Tags AS Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstActivity.Statuses.First'=>array('field'=>'InstActivity.Statuses','name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Statuses'),
'InstActivity.Logins.First'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Logins'),
'IntstActivity.Registrations.First'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Registrations'),
//--------------------------------
/*'InstActivity.Statuses.AVG'=>array('field'=>'InstActivity.Statuses','name'=>'Media stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID'),'ordselmore'=>'AVG(InstActivity.Statuses) AS avgstatuses'),
'InstActivity.Logins.AVG'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),
'IntstActivity.Registrations.AVG'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),*/
);
?>

View file

@ -0,0 +1,263 @@
<?php
use function mysqli_real_escape_string as myesc;
function nully($val,$fem,$filter,$ntext=null) {
if (!is_null($val)) {
if ($filter=='strip') {
return(strip_tags($val,'<a><br><ol><ul><li><p><i><b><strong><em><small>'));
} elseif ($filter=='htmlchars') {
return(hspech($val));
} elseif ($filter=='timestamp') {
return(strftime('%a %d %b %Y, %T',$val));
} elseif ($filter=='email') {
return('<a href="mailto:'.strip_tags($val).'">'.strip_tags($val).'</a>');
} elseif ($filter=='url') {
return('<a href="'.strip_tags($val).'" target="_blank">'.strip_tags($val).'</a>');
} elseif ($filter=='image') {
return('<img src="'.str_replace('"','\\"',strip_tags($val)).'">');
} elseif ($filter=='boolt') {
if ($val)
return('<span class="good">Si</span>');
else
return('<span class="bad">No</span>');
} elseif ($filter=='boolf') {
if ($val)
return('<span class="bad">Si</span>');
else
return('<span class="good">No</span>');
} else {
return($val);
}
} else {
if (is_null($ntext)) {
if ($fem)
return('<span class="nully">Non definita</span>');
else
return('<span class="nully">Non definito</span>');
}
else {
return('<span class="nully">'.$ntext.'</span>');
}
}
}
function booly($pre,$val,$nottoobad=false,$invcol=false) {
if ($val) {
if (!$invcol) {
$p='<p class="good">';
} else {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
}
return($p.$pre.'SI</p>');
} else {
if (!$invcol) {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
} else {
$p='<p class="good">';
}
return($p.$pre.'NO</p>');
}
}
function trimname($str) {
return(substr($str,1,strlen($str)-2));
}
// $row deve essere una riga ritornata da una query tipo "SELECT *, ID AS IID FROM Instances WHERE ..."
function dispinst(&$row,&$cols,&$link,&$dlang,$showcount,$finst,$cinsts) {
$out='';
$out.='<table class="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'];
if ($showcount) $out.=' ('.$finst.'/'.$cinsts.')';
$out.=' - <a href="edinst.php?id='.$row['IID'].'">Modifica</a></td></tr>'.N;
$attr=booly(trimname($cols['Instances.Blacklisted']['name']).': ',$row['Blacklisted'],false,true).N;
$attr.=booly(trimname($cols['Instances.New']['name']).': ',$row['New'],true).N;
$attr.=booly(trimname($cols['Instances.Good']['name']).': ',$row['Good']).N;
$attr.=booly(trimname($cols['Instances.Chosen']['name']).': ',$row['Chosen']).N;
$attr.=booly(trimname($cols['Instances.Visible']['name']).': ',$row['Visible']).N;
/* $attr.=booly($cols['Instances.RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['Instances.RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
or muoribene(mysqli_error($link),true);
$csres=mysqli_num_rows($sres);
if ($csres>0) {
$bene=0;
while ($srow=mysqli_fetch_assoc($sres)) {
if ($srow['Status']==1)
$bene++;
}
$width=str_replace(',','.',100/$csres*$bene);
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check ('.$csres.'): '.round($width,1).'%</div>';
$attr.='<div class="percbg"><div class="percfg" style="width:'.$width.'%;"></div></div>'.N;
mysqli_data_seek($sres,0);
$srow=mysqli_fetch_assoc($sres);
$attr.='<div class="colsectcont">Ultimo check '.strftime('%e %b %Y, %T',$srow['Time']).': '.(($srow['Status']) ? '<span class="good">OK</span>' : '<span class="bad">KO</span>').'</div>';
} else {
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check</div>'.N;
$attr.='<div class="colsectcont nully">Non disponibile (?!?!?!)</div>'.N;
}
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
or muoribene(mysqli_error($link),true);
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont">Stati: '.$tot['tstatuses'].'<br>Accessi: '.$tot['tlogins'].'<br>Registrazioni: '.$tot['tregs'].'</div>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcontb">'.strftime('%e %b %Y',$srow['Week']).'</div>'.N;
($tot['tstatuses']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tstatuses']*$srow['Statuses']);
$attr.='<div class="percstatuses" style="width:'.$width.'%;">'.$srow['Statuses'].'&nbsp;stati</div>'.N;
($tot['tlogins']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tlogins']*$srow['Logins']);
$attr.='<div class="perclogins" style="width:'.$width.'%;">'.$srow['Logins'].'&nbsp;accessi</div>'.N;
($tot['tregs']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tregs']*$srow['Registrations']);
$attr.='<div class="percregs" style="width:'.$width.'%;">'.$srow['Registrations'].'&nbsp;registrazioni</div>'.N;
}
} else {
$attr.='<div class="colsectcont nully">Non disponibile</div>'.N;
}
$attr.='<div class="colsectheader">Hashtags più usati durante lultima settimana</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstTrends WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont"><ol>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<li><a href="'.$srow['URL'].'">'.hspech($srow['Name']).'</a></li>'.N;
}
$attr.='</ol></div>'.N;
} else {
$attr.='<div class="colsectcont nully">Non disponibili</div>'.N;
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
if ($row['Blacklisted']>0) {
$sres=mysqli_query($link,'SELECT * FROM Blacklist WHERE Domain=\''.myesc($link,$row['URI']).'\'')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$srow=mysqli_fetch_assoc($sres);
if (!is_null($srow['PublicComment']) && preg_match('/^\s*$/',$srow['PublicComment'])!==1) {
$out.='<div class="baloo">Questa istanza è blacklistata per questo motivo: '.hspech($srow['PublicComment']).'</div>'.N;
} else {
$out.='<div class="baloo">Questa istanza è blacklistata, ma nella blacklist non è specificato il motivo.</div>'.N;
}
} else {
$out.='<div class="baloo">Questa istanza risulta blacklistata nella tabella delle istanze, ma nella tabella “Blacklist” non è presente: probabilmente è stata rimossa dalla tabella “Blacklist” e il crawler non lha ancora aggiornata.</div>'.N;
}
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</div>'.N;
// 'strip' o 'htmlent' per la descrizione nostra?
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Instances.OurDesc']['name']).':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Localities.Name']['name']).':</span> ';
if (!is_null($row['LocalityID'])) {
$sres=mysqli_query($link,'SELECT * FROM Localities WHERE Localities.ID='.$row['LocalityID'])
or muoribene(mysqli_error($link),true);
$srow=mysqli_fetch_assoc($sres);
$out.=hspech($srow['NameOrig']).'</div>'.N;
} else {
$out.='<span class="nully">Non definita</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name'.$dlang].' ['.$srow['Code'].']');
}
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name'.$dlang].' ['.$srow['Code'].']');
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> '.implode('; ',$buf);
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> <span class="nully">Non definite</span>';
}
($row['OurLangsLock']>0) ? $out.=' <strong>(bloccate)</strong>' : $out.=' <strong>(non bloccate)</strong>';
$out.='</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Type']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Email']['name'].':</span> '.nully($row['Email'],true,'email').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],false,'image').'</div>'.N;
$out.='<div><span class="field">'.$cols['Instances.AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</div>'.N;
$out.='</td></tr>'.N;
$out.='</tbody>'.N;
$out.='</table>'.N;
return($out);
}
?>

View file

@ -24,194 +24,7 @@ function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
function nully($val,$fem,$filter,$ntext=null) {
if (!is_null($val)) {
if ($filter=='strip') {
return(strip_tags($val,'<a><br><ol><ul><li><p><i><b><strong><em><small>'));
} elseif ($filter=='htmlchars') {
return(hspech($val));
} elseif ($filter=='timestamp') {
return(strftime('%a %d %b %Y, %T',$val));
} elseif ($filter=='email') {
return('<a href="mailto:'.strip_tags($val).'">'.strip_tags($val).'</a>');
} elseif ($filter=='url') {
return('<a href="'.strip_tags($val).'" target="_blank">'.strip_tags($val).'</a>');
} elseif ($filter=='image') {
return('<img src="'.str_replace('"','\\"',strip_tags($val)).'">');
} elseif ($filter=='boolt') {
if ($val)
return('<span class="good">Si</span>');
else
return('<span class="bad">No</span>');
} elseif ($filter=='boolf') {
if ($val)
return('<span class="bad">Si</span>');
else
return('<span class="good">No</span>');
} else {
return($val);
}
} else {
if (is_null($ntext)) {
if ($fem)
return('<span class="nully">Non definita</span>');
else
return('<span class="nully">Non definito</span>');
}
else {
return('<span class="nully">'.$ntext.'</span>');
}
}
}
function booly($pre,$val,$nottoobad=false,$invcol=false) {
if ($val) {
if (!$invcol) {
$p='<p class="good">';
} else {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
}
return($p.$pre.'SI</p>');
} else {
if (!$invcol) {
if (!$nottoobad) {
$p='<p class="bad">';
} else {
$p='<p class="neut">';
}
} else {
$p='<p class="good">';
}
return($p.$pre.'NO</p>');
}
}
function trimname($str) {
return(substr($str,1,strlen($str)-2));
}
/*SELECT *, Instances.ID AS IID, GROUP_CONCAT(OrdOurLanguages.NameIt ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR '; ') AS OrdOurLangs FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID LEFT JOIN InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID WHERE OurLanguages.NameIT LIKE '%italiano%' GROUP BY IID LIMIT 50*/
$cols=array(
'Instances.New'=>array('field'=>'Instances.New','name'=>'[Nuova]','type'=>'bool'),
'Instances.Good'=>array('field'=>'Instances.Good','name'=>'[Papabile]','type'=>'bool'),
'Instances.Chosen'=>array('field'=>'Instances.Chosen','name'=>'[Scelta]','type'=>'bool'),
'Instances.Visible'=>array('field'=>'Instances.Visible','name'=>'[Visibile]','type'=>'bool'),
'Instances.Blacklisted'=>array('field'=>'Instances.Blacklisted','name'=>'[Blacklistata]','type'=>'bool'),
'Instances.URI'=>array('field'=>'Instances.URI','name'=>'URI','type'=>'text'),
'Instances.Title'=>array('field'=>'Instances.Title','name'=>'Titolo','type'=>'text'),
'Instances.ShortDesc'=>array('field'=>'Instances.ShortDesc','name'=>'Descrizione breve','type'=>'text'),
'Instances.LongDesc'=>array('field'=>'Instances.LongDesc','name'=>'Descrizione lunga','type'=>'text'),
'Instances.OurDesc'=>array('field'=>'Instances.OurDesc','name'=>'[Descrizione nostra (in lingua originale)]','type'=>'text'),
'Instances.OurDescEN'=>array('field'=>'Instances.OurDescEN','name'=>'[Descrizione nostra (in inglese)]','type'=>'text'),
//--------------------------------
'Instances.LocalityID'=>array('field'=>'Instances.LocalityID','name'=>'[Località] ⮞','type'=>'join','join'=>array(),'ord'=>false),
'Localities.Name'=>array('field'=>'Localities.Name'.$dlang,'name'=>'[Località]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID'),'subtype'=>'text'),
//--------------------------------
'Instances.Email'=>array('field'=>'Instances.Email','name'=>'Email di contatto','type'=>'text'),
'Instances.Software'=>array('field'=>'Instances.Software','name'=>'Software','type'=>'text'),
'Instances.Version'=>array('field'=>'Instances.Version','name'=>'Versione','type'=>'text'),
'Instances.UserCount'=>array('field'=>'Instances.UserCount','name'=>'Numero utenti','type'=>'int'),
'Instances.StatusCount'=>array('field'=>'Instances.StatusCount','name'=>'Numero stati','type'=>'int'),
'Instances.DomainCount'=>array('field'=>'Instances.DomainCount','name'=>'Numero istanze note','type'=>'int'),
'Instances.ActiveUsersMonth'=>array('field'=>'Instances.ActiveUsersMonth','name'=>'Numero utenti attivi (mese)','type'=>'int'),
'Instances.ActiveUsersHalfYear'=>array('field'=>'Instances.ActiveUsersHalfYear','name'=>'Numero utenti attivi (6 mesi)','type'=>'int'),
'Instances.Thumb'=>array('field'=>'Instances.Thumb','name'=>'Logo','type'=>'text','search'=>false,'ord'=>false),
'Instances.RegOpen'=>array('field'=>'Instances.RegOpen','name'=>'Registrazioni aperte','type'=>'bool'),
'Instances.RegReqApproval'=>array('field'=>'Instances.RegReqApproval','name'=>'Approvazione registrazioni','type'=>'bool'),
'Instances.MaxTootChars'=>array('field'=>'Instances.MaxTootChars','name'=>'Limite caratteri','type'=>'int'),
'Instances.AdmAccount'=>array('field'=>'Instances.AdmAccount','name'=>'Account admin','type'=>'text'),
'Instances.AdmDisplayName'=>array('field'=>'Instances.AdmDisplayName','name'=>'Nome account admin','type'=>'text'),
'Instances.AdmCreatedAt'=>array('field'=>'Instances.AdmCreatedAt','name'=>'Data creazione account admin','type'=>'time'),
'Instances.AdmURL'=>array('field'=>'Instances.AdmURL','name'=>'Pagina delladmin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmAvatar'=>array('field'=>'Instances.AdmAvatar','name'=>'Avatar admin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmNote'=>array('field'=>'Instances.AdmNote','name'=>'Note delladmin','type'=>'text'),
//--------------------------------
'InstLangs'=>array('name'=>'Lingue dichiarate','search'=>false,'ord'=>false),
'InstLangs.LangID'=>array('field'=>'InstLangs%.LangID','name'=>'Una lingua dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID'),'ord'=>false),
'Languages.NameXX'=>array('field'=>'Languages%.Name'.$dlang,'name'=>'Una lingua dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID','Languages AS Languages% ON Languages%.ID=InstLangs%.LangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue dichiarate','ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.Name'.$dlang.' ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),
'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1'),'ord'=>false),
'Languages.NameXX.First'=>array('field'=>'Languages.Name'.$dlang,'name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1','Languages AS Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstOurLangs'=>array('name'=>'[Lingue impostate da noi]','search'=>false,'ord'=>false),
'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs%.OurLangID','name'=>'[Una lingua impostata da noi] ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID'),'ord'=>false),
'OurLanguages.NameXX'=>array('field'=>'OurLanguages%.Name'.$dlang,'name'=>'[Una lingua impostata da noi]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID','Languages AS OurLanguages% ON OurLanguages%.ID=InstOurLangs%.OurLangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue impostate da noi','ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.Name'.$dlang.' ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),
'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'[Lingua primaria impostata da noi] ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1'),'ord'=>false),
'OurLanguages.NameXX.First'=>array('field'=>'OurLanguages.Name'.$dlang,'name'=>'[Lingua primaria impostata da noi]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstFinancing'=>array('name'=>'[Modalità di finanziamento]','search'=>false,'ord'=>false),
'InstFinancing.FinID'=>array('field'=>'InstFinancing%.FinID','name'=>'[Una modalità di finanziamento] ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID'),'ord'=>false),
'Financing.Type'=>array('field'=>'Financing%.Type','name'=>'[Una modalità di finanziamento]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID','Financing AS Financing% ON Financing%.ID=InstFinancing%.FinID'),'subtype'=>'text','ord'=>true,'ordname'=>'Modalità di finanziamento','ordjoin'=>array('InstFinancing AS OrdInstFinancing ON OrdInstFinancing.InstID=Instances.ID','Financing AS OrdFinancing ON OrdFinancing.ID=OrdInstFinancing.FinID'),'ordselmore'=>'GROUP_CONCAT(OrdFinancing.Type ORDER BY OrdInstFinancing.Pos ASC SEPARATOR \'\') AS xOrdFinancing','ordby'=>'xOrdFinancing'),
'InstFinancing.FinID.First'=>array('field'=>'InstFinancing.FinID','name'=>'[Modalità di finanziamento primaria] ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1'),'ord'=>false),
'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'[Modalità di finanziamento primaria]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1','Financing AS Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstPolicies'=>array('name'=>'[Policies]','search'=>false,'ord'=>false),
'InstPolicies.PolID'=>array('field'=>'InstPolicies%.PolID','name'=>'[Una policy] ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID'),'ord'=>false),
'Policies.Name'=>array('field'=>'Policies%.Name','name'=>'[Una policy]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID','Policies AS Policies% ON Policies%.ID=InstPolicies%.PolID'),'subtype'=>'text','ord'=>true,'ordname'=>'Policies','ordjoin'=>array('InstPolicies AS OrdInstPolicies ON OrdInstPolicies.InstID=Instances.ID','Policies AS OrdPolicies ON OrdPolicies.ID=OrdInstPolicies.PolID'),'ordselmore'=>'GROUP_CONCAT(OrdPolicies.Name ORDER BY OrdInstPolicies.Pos ASC SEPARATOR \'\') AS xOrdPolicies','ordby'=>'xOrdPolicies'),
// Questi qui sotto sono disabilitati perché le policy non sono "pesate"
/*'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'[Policy primaria] ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1'),'ord'=>false),
'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'[Policy primaria]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1','Policies AS Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>false),*/
//--------------------------------
'InstTags'=>array('name'=>'[Tags]','search'=>false,'ord'=>false),
'InstTags.TagID'=>array('field'=>'InstTags%.TagID','name'=>'[Una tag] ⮞','type'=>'join','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID'),'ord'=>false),
'Tags.Name'=>array('field'=>'Tags%.Name','name'=>'[Una tag]','type'=>'joini','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID','Tags AS Tags% ON Tags%.ID=InstTags%.TagID'),'subtype'=>'text','ord'=>true,'ordname'=>'Tags','ordjoin'=>array('InstTags AS OrdInstTags ON OrdInstTags.InstID=Instances.ID','Tags AS OrdTags ON OrdTags.ID=OrdInstTags.TagID'),'ordselmore'=>'GROUP_CONCAT(OrdTags.Name ORDER BY OrdInstTags.Pos ASC SEPARATOR \'\') AS xOrdTags','ordby'=>'xOrdTags'),
'InstTags.TagID.First'=>array('field'=>'InstTags.TagID','name'=>'[Tag primaria] ⮞','type'=>'join','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1'),'ord'=>false),
'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'[Tag primaria]','type'=>'joini','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1','Tags AS Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstActivity.Statuses.First'=>array('field'=>'InstActivity.Statuses','name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Statuses'),
'InstActivity.Logins.First'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Logins'),
'IntstActivity.Registrations.First'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Registrations'),
//--------------------------------
/*'InstActivity.Statuses.AVG'=>array('field'=>'InstActivity.Statuses','name'=>'Media stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID'),'ordselmore'=>'AVG(InstActivity.Statuses) AS avgstatuses'),
'InstActivity.Logins.AVG'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),
'IntstActivity.Registrations.AVG'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),*/
);
require('include/columns.php');
$types=array('bool','int','time','text','join','joini');
@ -475,24 +288,19 @@ if (count($havings)>0)
else
$havings='';
$query='SELECT Instances.ID AS IID '.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings;
$query='SELECT *, Instances.ID AS IID '.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order;
$dbg.='QUERONA: '.$query.'<br>'.N;
$tini=microtime(true);
$res=mysqli_query($link,$query)
or muoribene($dbg.'<br>'.$query.': '.mysqli_error($link).'<br>'.'La query è fallita. <a href="instances.php">Resetta</a>.',true);
$dbg.='Durata esecuzione query: '.round(microtime(true)-$tini,4).' sec.<br>'.N;
$cinsts=mysqli_num_rows($res);
$iperp=25;
if ($page*$iperp>$cinsts)
$page=0;
$finst=$page*$iperp;
$query='SELECT *, Instances.ID AS IID '.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order.' LIMIT '.$finst.','.$iperp;
$dbg.='QUERONA: '.$query.'<br>'.N;
$tini=microtime(true);
$res=mysqli_query($link,$query)
or muoribene($dbg.'<br>'.$query.': '.mysqli_error($link).'<br>'.'La query è fallita. <a href="instances.php">Resetta</a>.',true);
$dbg.='Durata esecuzione query: '.round(microtime(true)-$tini,4).' sec.<br>'.N;
$cinstsp=mysqli_num_rows($res);
if ($cinstsp<1) {
if (mysqli_num_rows($res)<1) {
$pgout='';
$out='<p>Nessuna istanza da mostrare.</p>'.N;
} else {
@ -509,192 +317,18 @@ if ($cinstsp<1) {
$pgout.='</select>'.N;
$pgout.='</form>';
// ---
$ci=0;
mysqli_data_seek($res,$finst);
$out='';
$i=$finst;
$ii=0;
require('include/dispinst.php');
while ($row=mysqli_fetch_assoc($res)) {
$ci++;
$out.='<table class="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].' ('.($finst+$ci).'/'.$cinsts.') - <a href="edinst.php?id='.$row['IID'].'">Modifica</a></td></tr>'.N;
$attr=booly(trimname($cols['Instances.Blacklisted']['name']).': ',$row['Blacklisted'],false,true).N;
$attr.=booly(trimname($cols['Instances.New']['name']).': ',$row['New'],true).N;
$attr.=booly(trimname($cols['Instances.Good']['name']).': ',$row['Good']).N;
$attr.=booly(trimname($cols['Instances.Chosen']['name']).': ',$row['Chosen']).N;
$attr.=booly(trimname($cols['Instances.Visible']['name']).': ',$row['Visible']).N;
/* $attr.=booly($cols['Instances.RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['Instances.RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
or muoribene(mysqli_error($link),true);
$csres=mysqli_num_rows($sres);
if ($csres>0) {
$bene=0;
while ($srow=mysqli_fetch_assoc($sres)) {
if ($srow['Status']==1)
$bene++;
}
$width=str_replace(',','.',100/$csres*$bene);
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check ('.$csres.'): '.round($width,1).'%</div>';
$attr.='<div class="percbg"><div class="percfg" style="width:'.$width.'%;"></div></div>'.N;
mysqli_data_seek($sres,0);
$srow=mysqli_fetch_assoc($sres);
$attr.='<div class="colsectcont">Ultimo check '.strftime('%e %b %Y, %T',$srow['Time']).': '.(($srow['Status']) ? '<span class="good">OK</span>' : '<span class="bad">KO</span>').'</div>';
} else {
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check</div>'.N;
$attr.='<div class="colsectcont nully">Non disponibile (?!?!?!)</div>'.N;
}
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
or muoribene(mysqli_error($link),true);
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont">Stati: '.$tot['tstatuses'].'<br>Accessi: '.$tot['tlogins'].'<br>Registrazioni: '.$tot['tregs'].'</div>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcontb">'.strftime('%e %b %Y',$srow['Week']).'</div>'.N;
($tot['tstatuses']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tstatuses']*$srow['Statuses']);
$attr.='<div class="percstatuses" style="width:'.$width.'%;">'.$srow['Statuses'].'&nbsp;stati</div>'.N;
($tot['tlogins']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tlogins']*$srow['Logins']);
$attr.='<div class="perclogins" style="width:'.$width.'%;">'.$srow['Logins'].'&nbsp;accessi</div>'.N;
($tot['tregs']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tregs']*$srow['Registrations']);
$attr.='<div class="percregs" style="width:'.$width.'%;">'.$srow['Registrations'].'&nbsp;registrazioni</div>'.N;
}
} else {
$attr.='<div class="colsectcont nully">Non disponibile</div>'.N;
}
$attr.='<div class="colsectheader">Hashtags più usati durante lultima settimana</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstTrends WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont"><ol>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<li><a href="'.$srow['URL'].'">'.hspech($srow['Name']).'</a></li>'.N;
}
$attr.='</ol></div>'.N;
} else {
$attr.='<div class="colsectcont nully">Non disponibili</div>'.N;
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
if ($row['Blacklisted']>0) {
$sres=mysqli_query($link,'SELECT * FROM Blacklist WHERE Domain=\''.myesc($link,$row['URI']).'\'')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$srow=mysqli_fetch_assoc($sres);
if (!is_null($srow['PublicComment']) && preg_match('/^\s*$/',$srow['PublicComment'])!==1) {
$out.='<div class="baloo">Questa istanza è blacklistata per questo motivo: '.hspech($srow['PublicComment']).'</div>'.N;
} else {
$out.='<div class="baloo">Questa istanza è blacklistata, ma nella blacklist non è specificato il motivo.</div>'.N;
}
} else {
$out.='<div class="baloo">Questa istanza risulta blacklistata nella tabella delle istanze, ma nella tabella “Blacklist” non è presente: probabilmente è stata rimossa dalla tabella “Blacklist” e il crawler non lha ancora aggiornata.</div>'.N;
}
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</div>'.N;
// 'strip' o 'htmlent' per la descrizione nostra?
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Instances.OurDesc']['name']).':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Localities.Name']['name']).':</span> ';
if (!is_null($row['LocalityID'])) {
$sres=mysqli_query($link,'SELECT * FROM Localities WHERE Localities.ID='.$row['LocalityID'])
or muoribene(mysqli_error($link),true);
$srow=mysqli_fetch_assoc($sres);
$out.=hspech($srow['NameOrig']).'</div>'.N;
} else {
$out.='<span class="nully">Non definita</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name'.$dlang].' ['.$srow['Code'].']');
}
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name'.$dlang].' ['.$srow['Code'].']');
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> '.implode('; ',$buf);
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> <span class="nully">Non definite</span>';
}
($row['OurLangsLock']>0) ? $out.=' <strong>(bloccate)</strong>' : $out.=' <strong>(non bloccate)</strong>';
$out.='</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Type']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Email']['name'].':</span> '.nully($row['Email'],true,'email').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],false,'image').'</div>'.N;
$out.='<div><span class="field">'.$cols['Instances.AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</div>'.N;
$out.='</td></tr>'.N;
$out.='</tbody>'.N;
$out.='</table>'.N;
$i++;
$ii++;
if ($ii>$iperp) break;
$out.=dispinst($row,$cols,$link,$dlang,true,$i,$cinsts);
}
$out.='<div class="bigtabfoot"></div>';
$out.='<div class="bigtabfoot"></div>'.N;
}
$presid=0;
@ -1295,6 +929,7 @@ function pupoff() {
<ul>
<?php echo($menuout); ?>
</ul>
<div class="mtit">Elenco istanze</div>
<div id="rightdiv">
<img src="<?php echo($filtordimgoff); ?>" id="lente" class="rlinks" title="Mostra il pannello di ricerca e ordinamento" onclick="shideplancia();">
<a href="logout.php" class="rlinks"><img src="imgs/esci.svg" title="Esci"></a>

View file

@ -31,6 +31,9 @@ session_name('mastostartadmin');
session_start();
$_SESSION['AdmID']=$row['ID'];
header('Location: instances.php');
if ($row['Level']=='guest')
header('Location: guestinsts.php');
else
header('Location: instances.php');
?>

View file

@ -36,6 +36,7 @@ p {
}
.bigtabfoot {
height: 32px;
background-color: red;
}
.bigtab {
background-color: white;
@ -416,6 +417,17 @@ input {
background-color: rgba(255,255,255,0.10);
}
.mtit {
position: fixed;
top: 0;
left: 50%;
transform: translateX(-50%);
line-height: 32px;
font-size: 14pt;
font-weight: bold;
color: #78b1e2;
}
#plancia {
position: fixed;
left: 50%;
@ -583,6 +595,7 @@ input {
}
.hiframe {
background-color: lightgrey;
border-radius: 6px;
border: 1px solid darkgrey;
width: 400px;

View file

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require(__DIR__.'/../include/mb_ucfirst.php');
define('N',"\n");
use function mysqli_real_escape_string as myesc;
@ -117,11 +119,11 @@ $locales=json_decode($locales,true);
print_r($locales);
foreach ($locales as $key=>$val) {
$code=myesc($link,$key);
$NameIt=myesc($link,my_ucfirst(locale_get_display_name($key,'it')));
$NameEn=myesc($link,my_ucfirst(locale_get_display_name($key,'en')));
$NameEs=myesc($link,my_ucfirst(locale_get_display_name($key,'es')));
$NameFr=myesc($link,my_ucfirst(locale_get_display_name($key,'fr')));
$NameOrig=myesc($link,my_ucfirst(locale_get_display_name($key,$key)));
$NameIt=myesc($link,mb_ucfirst(locale_get_display_name($key,'it')));
$NameEn=myesc($link,mb_ucfirst(locale_get_display_name($key,'en')));
$NameEs=myesc($link,mb_ucfirst(locale_get_display_name($key,'es')));
$NameFr=myesc($link,mb_ucfirst(locale_get_display_name($key,'fr')));
$NameOrig=myesc($link,mb_ucfirst(locale_get_display_name($key,$key)));
$que='INSERT INTO Languages (ID, Code, NameIT, NameEN, NameES, NameFR, NameOrig) VALUES (NULL, \''.$code.'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameEs.'\', \''.$NameFr.'\', \''.$NameOrig.'\')';
echo($que.N);
mysqli_query($link,$que)
@ -172,16 +174,4 @@ function truncn($num,$tab,$col,$ctx) {
return($num);
}
function my_ucfirst($string, $e ='utf-8') {
if (function_exists('mb_strtoupper') && function_exists('mb_substr') && !empty($string)) {
$string = mb_strtolower($string, $e);
$upper = mb_strtoupper($string, $e);
preg_match('#(.)#us', $upper, $matches);
$string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e);
} else {
$string = ucfirst($string);
}
return $string;
}
?>