MastodonHelp/web/index.php

223 lines
6 KiB
PHP
Raw Normal View History

2019-12-01 09:07:45 +01:00
<?php
2019-12-02 20:16:26 +01:00
const N="\n";
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(
'guide'=>array('lijs'=>null, 'href'=>$instpath, 'title'=>'Guide', 'selected'=>false, 'submenu'=>null),
'instances'=>array('lijs'=>null, 'href'=>$instpath.'/instances', 'title'=>'Instances', 'selected'=>false, 'submenu'=>null),
'about'=>array('lijs'=>null, 'href'=>$instpath.'/about', 'title'=>'About', 'selected'=>false, 'submenu'=>null),
'language'=>array('lijs'=>null, 'href'=>null, 'title'=>'Language', 'selected'=>false, 'submenu'=>array(
'inglese'=>array('lijs'=>'onclick=golang("en")', 'href'=>null, 'title'=>'English', 'selected'=>false, 'submenu'=>null),
'italiano'=>array('lijs'=>'onclick=golang("it")', 'href'=>null, 'title'=>'Italiano', 'selected'=>false, 'submenu'=>null)
)
)
);
function tradmenu($lang) {
global $menu;
switch ($lang) {
case 'it':
$menu['guide']['title']='Guida';
$menu['guide']['href'].='/it';
$menu['instances']['title']='Istanza';
$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',
'js'=>array('shsum','guideanchors','scrolltrack')
2019-12-01 09:07:45 +01:00
);
2019-12-02 20:16:26 +01:00
$menu['guide']['lijs']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
$menu['language']['submenu']['inglese']['lijs']=null;
$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',
'js'=>array('shsum','guideanchors','scrolltrack')
);
tradmenu('it');
$menu['guide']['lijs']='onclick="shsum()" onmouseover="this.style.cursor=\'pointer\'"';
$menu['guide']['href']=null;
$menu['guide']['selected']=true;
$menu['language']['submenu']['italiano']['lijs']=null;
$menu['language']['submenu']['italiano']['selected']=true;
break;
case '/instances':
$cont=array(
'fp'=>'instances_en.php',
'lang'=>'en',
'atit'=>' - Instances',
'js'=>array()
);
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
$menu['language']['submenu']['inglese']['lijs']=null;
$menu['language']['submenu']['inglese']['selected']=true;
break;
case '/instances/it':
$cont=array(
'fp'=>'instances_it.php',
'lang'=>'it',
'atit'=>' - Istanze',
'js'=>array()
);
tradmenu('it');
$menu['instances']['href']=null;
$menu['instances']['selected']=true;
$menu['language']['submenu']['italiano']['lijs']=null;
$menu['language']['submenu']['italiano']['selected']=true;
break;
case '/about':
$cont=array(
'fp'=>'about_en.php',
'lang'=>'en',
'atit'=>' - About us',
'js'=>array()
);
$menu['about']['href']=null;
$menu['about']['selected']=true;
$menu['language']['submenu']['inglese']['lijs']=null;
$menu['language']['submenu']['inglese']['selected']=true;
break;
case '/about/it':
$cont=array(
'fp'=>'about_it.php',
'lang'=>'it',
'atit'=>' - Info',
'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;
$menu['language']['submenu']['italiano']['lijs']=null;
$menu['language']['submenu']['italiano']['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
default:
$cont=array(
'fp'=>'404.php',
'lang'=>'en',
2019-12-02 20:16:26 +01:00
'atit'=>' - 404',
'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';
if (!is_null($arr['lijs'])) $menuout.=' '.$arr['lijs'];
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'])) {
$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-02 20:16:26 +01:00
<meta name="description" content="A thorough introduction to Mastodon">
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">
<link rel="shortcut icon" href="<?php echo($prepath); ?>favicon.ico">
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>