0) { while ($path[strlen($path)-1]=='/') { $path=substr($path,0,-1); if (strlen($path)<1) break; } } $supplangs=['ca','en','es','fr','it']; if (preg_match('#/('.implode('|',$supplangs).')$#',$path,$lang)===1) { $dlang=$lang[1]; $path=substr($path,0,-3); } elseif (array_key_exists('HTTP_ACCEPT_LANGUAGE',$_SERVER)) { $dlang=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); $dlang=in_array($dlang,$supplangs) ? $dlang : 'en'; } else { $dlang='en'; } $locale=$dlang; // il blocale è per non dover avere installate tutte le locale corrispondenti $blocale='en_US.UTF-8'; //putenv('LC_ALL='.$blocale); setlocale(LC_ALL,$blocale); bindtextdomain('masthelp','./locale/'.$locale); textdomain('masthelp'); $menu=array( 'guide'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/'.$dlang, 'title'=>_('Guide'), 'selected'=>false, 'submenu'=>null), 'instances'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/instances/'.$dlang, 'title'=>_('Instances'), 'selected'=>false, 'submenu'=>null), 'about'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/about/'.$dlang, 'title'=>_('About'), 'selected'=>false, 'submenu'=>array( 'stats'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/stats/'.$dlang, 'title'=>_('Statistics'), 'selected'=>false, 'submenu'=>null), 'contribute'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/contribute/'.$dlang, 'title'=>_('Contribute'), 'selected'=>false, 'submenu'=>null) ) ), 'language'=>array('liadd'=>null, 'href'=>null, 'title'=>_('Language'), 'selected'=>false, 'submenu'=>array( 'ca'=>array('liadd'=>null, 'href'=>null, 'title'=>'Català', 'selected'=>false, 'submenu'=>null), 'en'=>array('liadd'=>null, 'href'=>null, 'title'=>'English', 'selected'=>false, 'submenu'=>null), /* 'aa'=>array('liadd'=>null, 'href'=>null, 'title'=>'Prova', 'selected'=>false, 'submenu'=>array( 'bb'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/stats/'.$dlang, 'title'=>'Statistics', 'selected'=>false, 'submenu'=>null), 'cc'=>array('liadd'=>null, 'href'=>$conf['instpath'].'/contribute/'.$dlang, 'title'=>'Contribute', 'selected'=>false, 'submenu'=>null) ) ),*/ 'es'=>array('liadd'=>null, 'href'=>null, 'title'=>'Español', 'selected'=>false, 'submenu'=>null), 'fr'=>array('liadd'=>null, 'href'=>null, 'title'=>'Français', 'selected'=>false, 'submenu'=>null), 'it'=>array('liadd'=>null, 'href'=>null, 'title'=>'Italiano', 'selected'=>false, 'submenu'=>null) ) ) ); foreach ($supplangs as $lang) $menu['language']['submenu'][$lang]['href']=$conf['instpath'].$path.'/'.$lang; $menu['language']['submenu'][$dlang]['href']=null; $menu['language']['submenu'][$dlang]['liadd']=null; $menu['language']['submenu'][$dlang]['selected']=true; $cont=array(); $cont['css']=array('theme.css','menu.css'); $cont['js']=array('menu.js'); $cont['bodyadd']=''; switch($path) { case '': $cont['fp']='home_'.$dlang.'.php'; $cont['atit']=' - '._('Guide'); $cont['desc']=_('A thorough introduction to Mastodon'); $cont['js'][]='shsum.js'; $cont['js'][]='guideanchors.js'; $cont['js'][]='scrolltrack.js'; $cont['bodyadd']=' onscroll="scrolltrack()"'; $menu['guide']['href']=null; $menu['guide']['selected']=true; $url='home'; break; case '/instances': $cont['fp']='instances.php'; $cont['atit']=' - '._('Instances'); $cont['desc']=_('Recommended Mastodon instances'); $cont['css'][]='instances.css'; $menu['instances']['href']=null; $menu['instances']['selected']=true; $url='instances'; break; case '/about': $cont['fp']='about.php'; $cont['atit']=' - '._('About'); $cont['desc']=_('Info about Mastodon Help’s authors, contributors, license'); $menu['about']['href']=null; $menu['about']['selected']=true; $url='about'; break; case '/stats': $cont['fp']='stats.php'; $cont['atit']=' - '._('Statistics'); $cont['desc']=_('Statistics about Mastodon Help'); $cont['css'][]='stats.css'; $menu['about']['selected']=true; $menu['about']['submenu']['stats']['href']=null; $menu['about']['submenu']['stats']['selected']=true; $url='stats'; break; case '/contribute': $cont['fp']='contribute.php'; $cont['atit']=' - '._('Contribute'); $cont['desc']=_('Contribute to Mastodon Help development'); $menu['about']['selected']=true; $menu['about']['submenu']['contribute']['href']=null; $menu['about']['submenu']['contribute']['selected']=true; $url='contribute'; break; default: http_response_code(404); $cont['fp']='404.php'; $cont['atit']=' - '._('Not found'); $cont['desc']=_('Page not found'); $url='404'; /*$nffp='404.log'; $nff=@fopen($nffp,'a'); if ($nff) { fwrite($nff,$_SERVER['REQUEST_URI'].N); fclose($nff); } else { echo('Mannaggia!'); }*/ break; } $cont['mtit']=substr($cont['atit'],3); $uid[]=$_SERVER['REMOTE_ADDR']; if (array_key_exists('HTTP_USER_AGENT',$_SERVER)) $uid[]=$_SERVER['HTTP_USER_AGENT']; if (array_key_exists('HTTP_ACCEPT',$_SERVER)) $uid[]=$_SERVER['HTTP_ACCEPT']; if (array_key_exists('HTTP_ACCEPT_LANGUAGE',$_SERVER)) $uid[]=$_SERVER['HTTP_ACCEPT_LANGUAGE']; if (array_key_exists('HTTP_ACCEPT_ENCODING',$_SERVER)) $uid[]=$_SERVER['HTTP_ACCEPT_ENCODING']; $uid=md5(implode('|',$uid)); $link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muoribene(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',2,false); mysqli_set_charset($link,'utf8mb4'); $now=time(); $res=mysqli_query($link,'SELECT * FROM ZHits WHERE UID="'.$uid.'" ORDER BY TS DESC') or muoribene(__LINE__.': '.mysqli_error($link),2,true); if (mysqli_num_rows($res)>0) { $row=mysqli_fetch_assoc($res); if ($now-$row['TS']<2) sleep(1); } mysqli_query($link,'INSERT INTO ZHits (UID,URL,Lang,TS) VALUES ("'.$uid.'","'.$url.'","'.$dlang.'",'.$now.')') or muoribene(__LINE__.': '.mysqli_error($link),2,true); mysqli_close($link); $menuout=''; function buildmenu($menu,$submenu=false) { global $menuout; foreach ($menu as $key=>$arr) { $liclasses=array(); $menuout.='