MastodonHelp/web/index.php

405 lines
12 KiB
PHP
Raw Normal View History

2019-12-01 09:07:45 +01:00
<?php
2019-12-26 21:57:36 +01:00
define('N',"\n");
2019-12-02 20:16:26 +01:00
2019-12-01 09:07:45 +01:00
$instpath='/mastostart';
$path=preg_replace('/^'.preg_quote($instpath,'/').'/','',$_SERVER['REQUEST_URI']);
$ndir=preg_match_all('/\//',$path)-1;
$prepath='';
for ($i=0; $i<$ndir; $i++)
$prepath.='../';
2019-12-02 20:16:26 +01:00
$menu=array(
2019-12-26 21:57:36 +01:00
'guide'=>array('liadd'=>null, 'href'=>$instpath.'/', 'title'=>'Guide', 'selected'=>false, 'submenu'=>null),
2019-12-03 21:35:02 +01:00
'instances'=>array('liadd'=>null, 'href'=>$instpath.'/instances', 'title'=>'Instances', 'selected'=>false, 'submenu'=>null),
'about'=>array('liadd'=>null, 'href'=>$instpath.'/about', 'title'=>'About', 'selected'=>false, 'submenu'=>null),
'language'=>array('liadd'=>null, 'href'=>null, 'title'=>'Language', 'selected'=>false, 'submenu'=>array(
2020-04-13 18:43:00 +02:00
'catalano'=>array('liadd'=>'onclick="golang(\'ca\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'Català', 'selected'=>false, 'submenu'=>null),
2019-12-03 21:35:02 +01:00
'inglese'=>array('liadd'=>'onclick="golang(\'en\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'English', 'selected'=>false, 'submenu'=>null),
2020-04-11 06:56:24 +02:00
'spagnolo'=>array('liadd'=>'onclick="golang(\'es\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'Español', 'selected'=>false, 'submenu'=>null),
'francese'=>array('liadd'=>'onclick="golang(\'fr\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'Français', 'selected'=>false, 'submenu'=>null),
'italiano'=>array('liadd'=>'onclick="golang(\'it\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'Italiano', 'selected'=>false, 'submenu'=>null)
2019-12-02 20:16:26 +01:00
)
)
);
function tradmenu($lang) {
global $menu;
switch ($lang) {
2020-04-13 18:43:00 +02:00
case 'ca':
$menu['guide']['title']='Guia';
$menu['guide']['href'].='ca';
$menu['instances']['title']='Instàncies';
$menu['instances']['href'].='/ca';
$menu['about']['title']='Info';
$menu['about']['href'].='/ca';
$menu['language']['title']='Idioma';
2020-04-11 06:56:24 +02:00
break;
case 'es':
$menu['guide']['title']='Guía';
$menu['guide']['href'].='es';
$menu['instances']['title']='Instancias';
$menu['instances']['href'].='/es';
$menu['about']['title']='Info';
$menu['about']['href'].='/es';
$menu['language']['title']='Idioma';
break;
2020-04-13 18:43:00 +02:00
case 'fr':
$menu['guide']['title']='Guide';
$menu['guide']['href'].='fr';
$menu['instances']['title']='Instances';
$menu['instances']['href'].='/fr';
$menu['about']['title']='Infos';
$menu['about']['href'].='/fr';
$menu['language']['title']='Langue';
break;
2019-12-02 20:16:26 +01:00
case 'it':
$menu['guide']['title']='Guida';
2019-12-26 21:57:36 +01:00
$menu['guide']['href'].='it';
2019-12-10 21:14:45 +01:00
$menu['instances']['title']='Istanze';
2019-12-02 20:16:26 +01:00
$menu['instances']['href'].='/it';
$menu['about']['title']='Info';
$menu['about']['href'].='/it';
$menu['language']['title']='Lingua';
break;
}
}
2019-12-01 09:07:45 +01:00
switch($path) {
2019-12-02 20:16:26 +01:00
2019-12-01 09:07:45 +01:00
case '/':
$cont=array(
'fp'=>'home_en.php',
'lang'=>'en',
2019-12-02 20:16:26 +01:00
'atit'=>' - Guide',
2019-12-26 21:57:36 +01:00
'desc'=>'A thorough introduction to Mastodon',
2019-12-02 20:16:26 +01:00
'js'=>array('shsum','guideanchors','scrolltrack')
2019-12-01 09:07:45 +01:00
);
2019-12-10 21:14:45 +01:00
$menu['guide']['liadd']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'"';
2019-12-02 20:16:26 +01:00
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['inglese']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['inglese']['selected']=true;
2019-12-01 09:07:45 +01:00
break;
2019-12-02 20:16:26 +01:00
2019-12-01 09:07:45 +01:00
case '/it':
$cont=array(
'fp'=>'home_it.php',
'lang'=>'it',
2019-12-02 20:16:26 +01:00
'atit'=>' - Guida',
2019-12-26 21:57:36 +01:00
'desc'=>'Una approfondita introduzione a Mastodon',
2019-12-02 20:16:26 +01:00
'js'=>array('shsum','guideanchors','scrolltrack')
);
tradmenu('it');
2019-12-03 21:35:02 +01:00
$menu['guide']['liadd']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
2019-12-02 20:16:26 +01:00
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['italiano']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['italiano']['selected']=true;
break;
2020-03-03 15:19:22 +01:00
case '/fr':
$cont=array(
'fp'=>'home_fr.php',
'lang'=>'fr',
'atit'=>' - Guide',
2020-04-13 18:43:00 +02:00
'desc'=>'A thorough introduction to Mastodon', //needs translation
2020-03-03 15:19:22 +01:00
'js'=>array('shsum','guideanchors','scrolltrack')
);
tradmenu('fr');
$menu['guide']['liadd']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
$menu['language']['submenu']['francese']['liadd']=null;
$menu['language']['submenu']['francese']['selected']=true;
break;
2020-04-11 06:56:24 +02:00
case '/es':
$cont=array(
'fp'=>'home_es.php',
'lang'=>'es',
'atit'=>' - Guía',
2020-04-13 18:43:00 +02:00
'desc'=>'A thorough introduction to Mastodon', //needs translation
2020-04-11 06:56:24 +02:00
'js'=>array('shsum','guideanchors','scrolltrack')
);
tradmenu('es');
$menu['guide']['liadd']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
$menu['language']['submenu']['spagnolo']['liadd']=null;
$menu['language']['submenu']['spagnolo']['selected']=true;
break;
2020-03-03 15:19:22 +01:00
2020-04-13 18:43:00 +02:00
case '/ca':
$cont=array(
'fp'=>'home_ca.php',
'lang'=>'ca',
'atit'=>' - Guia',
'desc'=>'A thorough introduction to Mastodon', //needs translation
'js'=>array('shsum','guideanchors','scrolltrack')
);
tradmenu('ca');
$menu['guide']['liadd']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
$menu['language']['submenu']['catalano']['liadd']=null;
$menu['language']['submenu']['catalano']['selected']=true;
break;
2019-12-02 20:16:26 +01:00
case '/instances':
$cont=array(
'fp'=>'instances_en.php',
'lang'=>'en',
'atit'=>' - Instances',
2019-12-26 21:57:36 +01:00
'desc'=>'Recommended Mastodon Instances',
2019-12-02 20:16:26 +01:00
'js'=>array()
);
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['inglese']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['inglese']['selected']=true;
break;
case '/instances/it':
$cont=array(
'fp'=>'instances_it.php',
'lang'=>'it',
'atit'=>' - Istanze',
2019-12-26 21:57:36 +01:00
'desc'=>'Istanze Mastodon consigliate',
2019-12-02 20:16:26 +01:00
'js'=>array()
);
tradmenu('it');
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['italiano']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['italiano']['selected']=true;
break;
2020-03-03 15:19:22 +01:00
case '/instances/fr':
$cont=array(
'fp'=>'instances_fr.php',
'lang'=>'fr',
'atit'=>' - Instances',
2020-04-13 18:43:00 +02:00
'desc'=>'Recommended Mastodon Instances', // needs translation
2020-03-03 15:19:22 +01:00
'js'=>array()
);
tradmenu('fr');
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
$menu['language']['submenu']['francese']['liadd']=null;
$menu['language']['submenu']['francese']['selected']=true;
break;
2020-04-11 06:56:24 +02:00
case '/instances/es':
$cont=array(
'fp'=>'instances_es.php',
'lang'=>'es',
'atit'=>' - Instancias',
2020-04-13 18:43:00 +02:00
'desc'=>'Recommended Mastodon Instances', // needs translation
2020-04-11 06:56:24 +02:00
'js'=>array()
);
tradmenu('es');
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
$menu['language']['submenu']['spagnolo']['liadd']=null;
$menu['language']['submenu']['spagnolo']['selected']=true;
break;
2020-03-03 15:19:22 +01:00
2020-04-13 18:43:00 +02:00
case '/instances/ca':
$cont=array(
'fp'=>'instances_ca.php',
'lang'=>'ca',
'atit'=>' - Instàncies',
'desc'=>'Recommended Mastodon Instances', // needs translation
'js'=>array()
);
tradmenu('ca');
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
$menu['language']['submenu']['catalano']['liadd']=null;
$menu['language']['submenu']['catalano']['selected']=true;
break;
2019-12-02 20:16:26 +01:00
case '/about':
$cont=array(
'fp'=>'about_en.php',
'lang'=>'en',
'atit'=>' - About us',
2019-12-26 21:57:36 +01:00
'desc'=>'Infos about Mastodon Startpages authors, contributors, license',
2019-12-02 20:16:26 +01:00
'js'=>array()
);
$menu['about']['href']=null;
$menu['about']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['inglese']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['inglese']['selected']=true;
break;
case '/about/it':
$cont=array(
'fp'=>'about_it.php',
'lang'=>'it',
'atit'=>' - Info',
2019-12-26 21:57:36 +01:00
'desc'=>'Informazioni sugli autori, i collaboratori e la licenza di Mastodon Startpage',
2019-12-02 20:16:26 +01:00
'js'=>array()
2019-12-01 09:07:45 +01:00
);
2019-12-02 20:16:26 +01:00
tradmenu('it');
$menu['about']['href']=null;
$menu['about']['selected']=true;
2019-12-03 21:35:02 +01:00
$menu['language']['submenu']['italiano']['liadd']=null;
2019-12-02 20:16:26 +01:00
$menu['language']['submenu']['italiano']['selected']=true;
2019-12-01 09:07:45 +01:00
break;
2019-12-02 20:16:26 +01:00
2020-03-03 15:19:22 +01:00
case '/about/fr':
$cont=array(
'fp'=>'about_fr.php',
'lang'=>'fr',
'atit'=>' - Infos',
2020-04-13 18:43:00 +02:00
'desc'=>'Infos about Mastodon Startpages authors, contributors, license', // needs translation
2020-03-03 15:19:22 +01:00
'js'=>array()
);
tradmenu('fr');
$menu['about']['href']=null;
$menu['about']['selected']=true;
$menu['language']['submenu']['francese']['liadd']=null;
$menu['language']['submenu']['francese']['selected']=true;
break;
2020-04-11 06:56:24 +02:00
case '/about/es':
$cont=array(
'fp'=>'about_es.php',
'lang'=>'es',
'atit'=>' - Infos',
2020-04-13 18:43:00 +02:00
'desc'=>'Infos about Mastodon Startpages authors, contributors, license', // needs translation
2020-04-11 06:56:24 +02:00
'js'=>array()
);
tradmenu('es');
$menu['about']['href']=null;
$menu['about']['selected']=true;
$menu['language']['submenu']['spagnolo']['liadd']=null;
$menu['language']['submenu']['spagnolo']['selected']=true;
break;
2020-03-03 15:19:22 +01:00
2020-04-13 18:43:00 +02:00
case '/about/ca':
$cont=array(
'fp'=>'about_ca.php',
'lang'=>'ca',
'atit'=>' - Info',
'desc'=>'Infos about Mastodon Startpages authors, contributors, license', // needs translation
'js'=>array()
);
tradmenu('ca');
$menu['about']['href']=null;
$menu['about']['selected']=true;
$menu['language']['submenu']['catalano']['liadd']=null;
$menu['language']['submenu']['catalano']['selected']=true;
break;
2019-12-01 09:07:45 +01:00
default:
$cont=array(
'fp'=>'404.php',
'lang'=>'en',
2019-12-02 20:16:26 +01:00
'atit'=>' - 404',
2019-12-26 21:57:36 +01:00
'desc'=>'Page not found',
2019-12-02 20:16:26 +01:00
'js'=>array()
2019-12-01 09:07:45 +01:00
);
break;
}
2019-12-02 20:16:26 +01:00
/*
<li><a href="<?php echo($instpath); ?>">Guide</a></li>
<li><a href="instances">Instances</a></li>
<li><a href="about">About us</a></li>
<li onmouseover="chulsh(this,true)" onmouseout="chulsh(this,false)">Language
<ul class="ula" onmouseover="ulsh(this,true)" onmouseout="ulsh(this,false)">
<li><a href="#">English</a></li>
<li><a href="#">Italiano</a></li>
</ul>
</li>
*/
$menuout='';
function buildmenu($menu) {
global $menuout;
foreach ($menu as $key=>$arr) {
$menuout.='<li';
2019-12-03 21:35:02 +01:00
if (!is_null($arr['liadd'])) $menuout.=' '.$arr['liadd'];
2019-12-02 20:16:26 +01:00
if (!is_null($arr['submenu'])) $menuout.=' onmouseover="chulsh(this,true)" onmouseout="chulsh(this,false)"';
if ($arr['selected']) $menuout.=' class="hil"';
$menuout.='>';
if (!is_null($arr['href']))
$menuout.='<a href="'.$arr['href'].'">'.$arr['title'].'</a>';
else
$menuout.=$arr['title'];
if (!is_null($arr['submenu'])) {
2019-12-10 21:14:45 +01:00
// qui bisognerebbe aggiungere che a seconda del "livello" imposta class giusta: ula, oppure ulb per livello > 1
2019-12-02 20:16:26 +01:00
$menuout.=N.'<ul class="ula" onmouseover="ulsh(this,true)" onmouseout="ulsh(this,false)">'.N;
buildmenu($arr['submenu']);
$menuout.='</ul>'.N;
}
$menuout.='</li>'.N;
}
}
buildmenu($menu);
//echo(htmlentities($menuout));
$cjrand=rand(0,999999);
2019-12-01 09:07:45 +01:00
?>
<!DOCTYPE HTML>
<html lang="<?php echo($cont['lang']); ?>">
<head>
<title>Mastodon Startpage<?php echo($cont['atit']); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2019-12-26 21:57:36 +01:00
<meta name="description" content="<?php echo($cont['desc']); ?>">
2019-12-01 09:07:45 +01:00
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
2019-12-26 21:57:36 +01:00
<link rel="icon" type="image/png" href="<?php echo($prepath); ?>imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="<?php echo($prepath); ?>imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="<?php echo($prepath); ?>imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="<?php echo($prepath); ?>imgs/icona-180.png">
2019-12-02 20:16:26 +01:00
<link rel="stylesheet" type="text/css" href="<?php echo($prepath); ?>theme.css?v=<?php echo($cjrand); ?>">
<?php
foreach ($cont['js'] as $val)
echo('<script language="JavaScript" src="js/'.$val.'.js?v='.$cjrand.'"></script>'.N);
?>
2019-12-01 09:07:45 +01:00
<script language="JavaScript">
<!--
2019-12-02 20:16:26 +01:00
function chulsh(el,sh) {
if (sh)
el.querySelector('ul').style='display:block';
else
el.querySelector('ul').style='display:none';
2019-12-01 09:07:45 +01:00
}
2019-12-02 20:16:26 +01:00
function ulsh(el,sh) {
if (sh)
el.style='display:block';
else
el.style='display:none';
}
function golang(lang) {
var loc=document.location.href;
loc=loc.replace(/#.*$/,'');
loc=loc.replace(/\/$/,'');
if (document.documentElement.lang=='en') {
if (lang!='en')
document.location.href=loc+'/'+lang;
2019-12-01 09:07:45 +01:00
} else {
2019-12-02 20:16:26 +01:00
if (lang!='en')
document.location.href=loc.substr(0,loc.length-3)+'/'+lang;
else
document.location.href=loc.substr(0,loc.length-3);
2019-12-01 09:07:45 +01:00
}
}
//-->
</script>
</head>
2019-12-02 20:16:26 +01:00
<?php
require($cont['fp']);
?>
2019-12-01 09:07:45 +01:00
</html>