<?php
error_reporting(0);
#$countpages = 0;
header("Content-Type: text/html; charset=iso-8859-1");
if(is_file('../system.sys'))
{
	$file=fopen('../system.sys',"r");
	$dumpline=fgets($file, 8096);
	fclose($file);
	$setting = explode("&", $dumpline);
	$lang='de';
    $customerID = "";
    
	if(is_array($setting))
	{
		foreach($setting as $value)
		{
			preg_match("/^lg=/",$value,$regs);
			{
				switch(trim(str_replace($regs[0], "", $value)))
				{
					case 'lang_en.sys':
							$lang="en";
							break;
					default:
							$lang="de";
							break;
				}
			}
            
            $pos = strpos($value, "cn=");
            if ($pos !== false) {        
                $customerID = explode("=", $value)[1];
            } 
		}
	}
}
else
{
	$lang="de";
}

$_config['localfile']="../lang/lang_".$lang.".sys";

if(is_file($_config['localfile']))
{
	$file=fopen($_config['localfile'],"r");
	unset($_lang);
	
	while ($dumpline=fgets($file, 8096))
	{
		if( preg_match("/^&stat[a-zA-Z0-9]+=/",$dumpline,$regs))
		{
			$dumpline = str_replace("&", "", $dumpline);
			$key = str_replace("=", "", str_replace("&", "", $regs[0]));
			
			$_lang[$key] = trim(utf8_decode(urldecode(str_replace($key."=", "", $dumpline))));
			
		}
        if( preg_match("/^&saLangName=/",$dumpline,$regs))
		{
			$dumpline = str_replace("&", "", $dumpline);
			$key = str_replace("=", "", str_replace("&", "", $regs[0]));
			
			$_lang[$key] = trim(utf8_decode(urldecode(str_replace($key."=", "", $dumpline))));
			
		}
		
	}
}

session_start();

if($_REQUEST['action']=="logout")
{
    if(isset($_SESSION['customerID'])){
        unset($_SESSION['customerID']);    
    }
    session_unset();
    session_destroy();
    
    header("Location:index.php");
    exit;
    
}

if($customerID!=$_POST['cid'] && $_SESSION['customerID']!=$customerID)
{
    echo '<html>';
	echo '<head>';
	echo '	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
    echo '  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />';
    echo '	<link rel="stylesheet" type="text/css" href="../sourceimg/bootstrap.min.css">';
    echo '	<link rel="stylesheet" type="text/css" href="css/css.css">';
    echo '  <script type="text/javascript" src="../sourceimg/jquery-3.7.0.min.js"></script>';
    echo '  <script src="../sourceimg/bootstrap.min.js"></script>';
	echo '</head>';
	echo '<body>';
    
    echo '<div class="fixedNav"><div class="navContent" style="justify-content: center;"><a href="https://elkat.de/" target="_blank"><img src="../sourceimg/elkat-logo.png" class="logo-img"></a></div></div>';
    
	echo "<div class='container'><div class='row'><div class='col-lg-12'>";
    
    ?>
    
    <br>
    
    <div class="jumbotron">
      
        <h2 class="text-center"><?php echo $_lang['statsum1'];?></h2>
      
        <div class='row'>
            <div class="col-lg-12">
                <div class="center-block" style="max-width:450px;margin-top:20px;">
                    <form role="form" action="index.php?login=do" method="post" id="login">
                        <div class="input-group">
                            <input type="password" name="cid" class="form-control" placeholder="<?php echo $_lang['statsum3'];?>">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button" id="lbtn"><?php echo $_lang['statsum37'];?></button>
                            </span>
                        </div>
                    </form>                
                    

                    <?php
                    if($customerID!=$_POST['cid'] && $_POST){    
                        echo '<div class="alert alert-danger" role="alert">'.$_lang['statsum38'].'</div>';
                    }
    
                    ?>
    
                </div>    
            </div>
        </div>
        
    </div>
        
    <?php    
    
    echo '</div></div></div>';
        
    echo '<script>$(function(){$(\'#lbtn\').click(function(e){e.preventDefault();$(\'#login\').submit();})});</script>';

    echo '</body>';
    echo '</html>';
} else {
    
    if(empty($_REQUEST['action']))
    {
        if(!isset($_SESSION['customerID'])){
            $_SESSION['customerID'] = $_POST['cid'];
            $_POST['cid'] = "";
        }

        $path= "./";
        $handle=opendir($path);
        echo '<html>';
        echo '<head>';
        echo '	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
        echo '  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />';
        echo '	<link rel="stylesheet" type="text/css" href="../sourceimg/bootstrap.min.css">';
        echo '	<link rel="stylesheet" type="text/css" href="css/css.css">';
        echo '  <script type="text/javascript" src="../sourceimg/jquery-3.7.0.min.js"></script>';
        echo '  <script src="../sourceimg/bootstrap.min.js"></script>';
        echo '  <script src="js/chart.umd.js"></script>';
        echo '  <script src="js/hammerjs.min.js"></script>';
        echo '  <script src="js/chartjs-plugin-zoom.min.js"></script>';
        echo '</head>';
        echo '<body>';

        echo "<div class='fixedNav'>";
        echo "<div class='navContent'>";
        echo "<a class='submit_green' href='".$_SERVER['PHP_SELF']."'><i class='glyphicon glyphicon-home'></i><span class='mobileHide'> ".$_lang['statsum35']."</a>";
        echo "<a href='https://elkat.de/' target='_blank'>";
        echo "<img src='../sourceimg/elkat-logo.png' class='logo-img'>";
        echo "</a><div>";
        echo "<a class='submit_red' href='../' target='_blank'><i class='glyphicon glyphicon-book'></i><span class='mobileHide'> ".$_lang['statsum36']."</span></a>";
        echo "<a class='submit_red logout' href='".$_SERVER['PHP_SELF']."?action=logout' data-toggle='tooltip' data-placement='bottom' title='".$_lang['statsum39']."'><i class='glyphicon glyphicon-log-out'></i></a>";
        echo "</div></div></div>";

        echo "<div class='container'><div class='row'><div class='col-lg-12'>";

        if(empty($_REQUEST['date']))
        {
            echo "<div class='mainTable'>";
            ###///JK Verhältnis Klicks zu Aufrufen im Monatsverlauf
            echo "<h2>".$_lang['statgen']."</h2>";
            echo "<p>".$_lang['statgen1']."</p><br>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='bottom' title='".$_lang['statsum19']."'></i>";
            while ($file = readdir($handle))
            {
                if(substr($file, 0, 5) =="stat_")
                {
                    $monats_arr[substr($file, 5, 4).substr($file, 9, 2)] = $file;
                }
            }
            krsort($monats_arr);
            $table = "<h3>".$_lang['statsum1']."</h3><div class='mobileScroll'><table width='100%' class='table table-striped text-center'>";###///JK Monatsauswahl Durchschnittswerte
            $table .= "<tr><td class='text-left'>";
            $table .= "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum20']."'></i>";
            $table .= "</td>";
            $table .= "<td colspan='2'><b>".$_lang['statsum40']."</b></td>";
            $table .= "<td colspan='2'><b>".$_lang['statsum41']."</b></td>";		
            $table .= "</tr><tr><td class='text-left'><b>".$_lang['statselmonth']."</b></td>";
            $table .= "<td><b>".$_lang['statsum17']."</b></td>";
            $table .= "<td><b>".$_lang['statsum18']."</b></td>";
            $table .= "<td><b>".$_lang['statsum17']."</b></td>";
            $table .= "<td><b>".$_lang['statsum18']."</b></td>";
            $table .= "</tr>";
            $tc = 0;
            $ta = 0;
            $dia = Array();
            $dia2 = Array();
            $x = Array();
            foreach($monats_arr AS $KK => $VV)
            {
                switch(substr($VV, 9, 2))
                {
                    case "02": $dm = 28;break;
                    case "04":
                    case "06":
                    case "09":
                    case "11": $dm = 30;break;
                    default: $dm = 31; break;
                }
                $table .= "<tr>";
                $table .= "<td class='text-left'><i class='glyphicon glyphicon-calendar'></i> <a href=".$_SERVER['PHP_SELF']."?date=$VV>".substr($VV, 9, 2).".".substr($VV, 5, 4)."</a></td>";
                $table .= "<td><nobr>&#216; ".number_format((get_total_count_2($VV)/$dm),2,",","")."</nobr></td>";
                $table .= "<td><nobr>&#216; ".number_format((get_kat_hits_2($VV)/$dm),2,",","")."</nobr></td>";
                $table .= "<td>".get_total_count_2($VV)."</td>";
                $table .= "<td>".get_kat_hits_2($VV)."</td>";
                $table .= "</tr>";

                $tc += get_total_count_2($VV);
                $ta += get_kat_hits_2($VV);
                $dia[] = get_total_count_2($VV);
                $dia2[] = get_kat_hits_2($VV);
                $x[]= substr($VV, 9, 2).".".substr($VV, 5, 4);
            }

            $table .= "<tr>";
            $table .= "<td colspan=3><b>".$_lang['statsum42']."</b></td>";
            $table .= "<td><b>$tc</b></td>";
            $table .= "<td><b>$ta</b></td>";
            $table .= "</tr>";
            $table .= "</table></div>";

            echo show_months($x, $dia, $dia2);
            echo '<hr><button type="button" class="submit_red" onclick="toggleChart();"><i class="glyphicon glyphicon-transfer"></i> '.$_lang["statsum43"].'</button><hr>';
            echo $table;
            echo "</div>";
        }

        if(!empty($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
        {     

            #$var_array = file("../system.sys");
            $arr = file_get_contents("../system.sys");
            $arr = str_replace("\n", "", $arr);
            $var_array = explode("&", $arr);
            $kat_var = array();
            foreach($var_array as $VALUE)
            {
                if(substr($VALUE, 0, 2)=="kn" OR substr($VALUE, 0, 2)=="cn" OR substr($VALUE, 0, 2)=="ki")
                {
                    $var_temp = explode("=", $VALUE);
                    $kat_var[$var_temp[0]] = $var_temp[1];
                }
            }

            echo "<div class='mainTable'><h2>".$_lang['statsum1']." ".substr($_REQUEST['date'], 9, 2).".".substr($_REQUEST['date'], 5, 4)."</h2>";

            echo "<ul>";
            echo "<li>".$_lang['statli1']."</li>";
            echo "<li>".$_lang['statli2']."</li>";
            echo "<li>".$_lang['statli3']."</li>";
            echo "<li>".$_lang['statli4']."</li>";
            echo "<li>".$_lang['statli5']."</li>";
            echo "<li>".$_lang['statli6']."</li>";
            echo "<li>".$_lang['statli7']."</li>";
            echo "</ul><br> ";

            echo "<table class='table table-striped'><tr><td><b>".$_lang['statsum2'].":</b></td><td>".utf8_decode(urldecode($kat_var["kn"]))."</td></tr>";
            echo "<tr><td><b>".$_lang['statsum3'].":</b></td><td>".urldecode($kat_var["cn"])."</td></tr>";
            echo "<tr><td><b>".$_lang['statsum4'].":</b></td><td>".urldecode($kat_var["ki"])."</td></tr>";
            echo "<tr><td><b>".$_lang['statsum5'].":</b></td><td>".get_total_count()."</td></tr>";
            echo "<tr><td><b>".$_lang['statsum6'].":</b></td><td>".get_kat_hits()."</td></tr>";
            echo "<tr><td><b>".$_lang['statsum7'].":</b></td><td>".date("d.m.Y H:i", filectime("../system.sys"))."</td></tr>";
            echo "</table></div>";

    ###///Seitenaufrufe

            echo "<div class='mainTable'>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum21']."'></i>";
            echo "<h3>".$_lang['statsum8']."</h3>";

            echo get_page_count();
            
            echo "<div class='row' style='margin-top:15px;'>";
            echo "<div class='col-md-5'>";
            echo '<button type="button" class="submit_red" onclick="toggleChart();" style="margin-right:15px;"><i class="glyphicon glyphicon-transfer"></i> '.$_lang["statsum43"].'</button>';
            echo "<button type='button' class='submit_red' onclick='eChart1.resetZoom();'><i class='glyphicon glyphicon-refresh'></i> ".$_lang['statsum44']."</button>";
            echo "</div>";
            echo "<div class='col-md-7 text-right'>";
            echo "<span class='badge label-default zoominfo'><i class='glyphicon glyphicon-resize-horizontal'></i> ".$_lang['statsum45']."<br>".$_lang['statsum46']."</span'>";
            echo "</div>";
            echo "</div>";
            echo "<hr>"; 
            echo "<a href='javascript:void(0);' ALT='".$_lang['statsum47']."' id='downloadCSV1'><i class='glyphicon glyphicon-save-file'></i> ".$_lang['statsum48']."</a>";   
            echo "</div><br>";

    ###///Uhrzeit		
            echo "<div class='mainTable'>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum22']."'></i>";
            echo "<h3>".$_lang['statsum9']."</h3>";

            echo get_hour_count();        
            echo "<hr>"; 
            echo "<a href='javascript:void(0);' ALT='".$_lang['statsum47']."' id='downloadCSV2'><i class='glyphicon glyphicon-save-file'></i> ".$_lang['statsum48']."</a>";   
            echo "</div><br>";

    ###///Katalogaufrufe Tagesverlauf        		
            echo "<div class='mainTable'>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum23']."'></i>";
            echo "<h3>".$_lang['statsum14']."</h3>";

            echo get_day_count_hits();

            echo "<hr>"; 
            echo "<a href='javascript:void(0);' ALT='".$_lang['statsum47']."' id='downloadCSV3'><i class='glyphicon glyphicon-save-file'></i> ".$_lang['statsum48']."</a>";
            echo "</div><br>";

    ###///Katalogaufrufe Monatsverlauf        		
            echo "<div class='mainTable'>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum24']."'></i>";
            echo "<h3>".$_lang['statsum10']."</h3>";

            echo get_day_count();

            echo "<hr>"; 
            echo "<a href='javascript:void(0);' ALT='".$_lang['statsum47']."' id='downloadCSV4'><i class='glyphicon glyphicon-save-file'></i> ".$_lang['statsum48']."</a>";
            echo "</div><br>";

    ###///Nutzung der Funktionen       		
            echo "<div class='mainTable'>";
            echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum25']."'></i>";
            echo "<h3>".$_lang['statsum11']."</h3><hr>";

            echo get_function_count();
            echo "<a href='javascript:void(0);' ALT='".$_lang['statsum47']."' id='downloadCSV5'><i class='glyphicon glyphicon-save-file'></i> ".$_lang['statsum48']."</a>";
            echo "</div><br>";

    ###/// Eingegebene Suchbegriffe     
            $searchcnt = get_search_count();
            $searchcntM = get_search_countM();
            $linkcnt = get_link_count();
            if(is_array($searchcnt))
            {
                echo "<div class='mainTable'>";
                echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum26']."'></i>";
                echo "<h3>".$_lang['statsum12']."</h3>";
                echo "<div class='collapse' id='collapse1'>";
                $it=0;
                echo "<table width=100% class='table table-striped'>";
                foreach($searchcnt as $KE => $VA)
                {
                    echo "<tr><td>".utf8_decode($KE)."</td><td class='text-right'>$VA</td></tr>";
                }
                echo "</table>"; 
                if (empty($searchcnt)) {
                    echo "<hr>";
                    echo $_lang['statsum51'];                    
                }
                echo "</div><button class='submit_red toggleHandler' data-toggle='collapse' href='#collapse1' aria-expanded='false' aria-controls='collapse1'><i class='glyphicon glyphicon-chevron-down'></i><span class='mehr'>".$_lang['statsum49']."</span><span class='weniger'>".$_lang['statsum50']."</span></button>";
                echo "</div><br>";
            }

     ###///Suchergebnis: Nicht Gefunden       
            if(is_array($searchcntM))
            {
                echo "<div class='mainTable'>";
                echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum27']."'></i>";
                echo "<h3>".$_lang['statsum12b']."</h3>";
                echo "<div class='collapse' id='collapse2'>";
                $it=0;
                echo "<table width=100% class='table table-striped'>";
                foreach($searchcntM as $KE => $VA)
                {
                    #echo "hier'".$KE."'";
                    #if(ereg("^\[[0-9]+\]", $KE, $regs))
                    if(preg_match("/^\[[0-9]+\]/", $KE, $regs))
                    {
                        $gefunden = str_replace("]", "",str_replace("[", "",$regs[0]));
                        $KE = str_replace($regs[0],"",$KE);
                    }

                    echo "<tr><td>".utf8_decode($KE)."</td><td class='text-right'>$VA</td></tr>";

                }
                echo "</table>";
                if (empty($searchcntM)) {
                    echo "<hr>";
                    echo $_lang['statsum51'];                    
                }
                echo "</div><button class='submit_red toggleHandler' data-toggle='collapse' href='#collapse2' aria-expanded='false' aria-controls='collapse2'><i class='glyphicon glyphicon-chevron-down'></i><span class='mehr'>".$_lang['statsum49']."</span><span class='weniger'>".$_lang['statsum50']."</span></button>";
                echo "</div><br>";
            }

    ###///Benutzte Verlinkungen        
            if(is_array($linkcnt))
            {
                echo "<div class='mainTable'>";
                echo "<i class='glyphicon glyphicon-stats ehelp' data-toggle='tooltip' data-placement='top' title='".$_lang['statsum28']."'></i>";
                echo "<h3>".$_lang['statsum13']."</h3>";
                echo "<div class='collapse' id='collapse3'>";
                echo "<table width=100% class='table table-striped'>";
                $GE = 0;
                foreach($linkcnt as $KE1 => $VA1)
                {
                    if(strrpos(strtolower($KE1), "mp3")>strlen($KE1)-6)
                    {
                        $pre = $_lang['statsum34'];
                    }
                    else
                    {
                        #if (substr (strtolower($KE1),-4)=="pdf")
                        if(strrpos(strtolower($KE1), "pdf")>strlen($KE1)-6)
                        {
                            $pre = $_lang['statsum33'];
                        }
                        else
                        {
                            if (strlen($KE1)<=10)
                            {
                                $pre = $_lang['statsum32'];
                            }
                            else
                            {
                                if(substr(strtolower($KE1), 0, 7)=="mailto:")
                                {
                                    $pre = $_lang['statsum31'];
                                    $KE1 = str_replace("mailto:","",$KE1);
                                }
                                else
                                {
                                    if(substr(strtolower($KE1), 0, 4)!="http")
                                    {
                                        $pre = $_lang['statsum30'];
                                    }
                                    else
                                    {
                                        $pre = $_lang['statsum29'];
                                    }
                                }
                            }	
                        }
                    }
                    echo "<tr><td>$pre $KE1</td><td class='text-right'>$VA1</td></tr>";
                    $GE = $GE+$VA1;
                }
                echo "<tr><td>".$_lang['statsum6']."</td><td class='text-right'>$GE</td></tr>";			
                echo "</table>";
                echo "</div><button class='submit_red toggleHandler' data-toggle='collapse' href='#collapse3' aria-expanded='false' aria-controls='collapse3'><i class='glyphicon glyphicon-chevron-down'></i><span class='mehr'>".$_lang['statsum49']."</span><span class='weniger'>".$_lang['statsum50']."</span></button>";
                echo "</div><br>";
            }


        }

        echo '</div></div></div>';

        ?>
    <script>

        $(document).ready(function() {
            
            $('.collapse').each(function() {
                var tableHeight = $(this).height();
                if (tableHeight < 320) {
                    $(this).next('.toggleHandler').hide();
                    $(this).addClass('min');
                } else {
                    $(this).addClass('shown');
                }
            });

             $('.toggleHandler').click(function(e) {
                $(this).toggleClass('active');
            });
                        
            $(document).keydown(function(event) {
                if (event.which === 17) {
                    $('#chart_1').css('cursor', 'ew-resize'); 
                }
            });
            
            $(document).keyup(function(event) {
                if (event.which === 17) {
                    $('#chart_1').css('cursor', 'initial'); 
                }
            });
                        
        });

    <?php

        echo '$(function(){$(\'[data-toggle="tooltip"]\').tooltip({html:true})});';
        echo '</script>';
        echo '</body>';
        echo '</html>';
    } 
}


function get_total_count()
{
	global $_REQUEST;
	$countpages = 0;
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$countpages++;
		}
	}
	return $countpages;
}

function get_total_count_2($date)
{
	$countpages = 0;
	if(!empty($date) AND is_file($date) AND substr($date, 0, 5) =="stat_")
	{
		$filearray = file($date);
		foreach($filearray as $KEY => $VALUE)
		{
			$countpages++;
		}
	}
	return $countpages;
}


function show_months($x, $dia, $dia2)
{
    global $_REQUEST, $_lang;

    echo "<div><canvas id='overviewCh'></canvas></div>";

    echo "<script>";
    echo "var _labels = ".json_encode($x).";";
    echo "\n";
    echo "var _titleF = '".$_lang['statsum17']."';";
    echo "\n";
    echo "var _titleG = '".$_lang['statsum18']."';";
    echo "\n";
    echo "var _dataA = ".json_encode($dia).";";
    echo "\n";
    echo "var _dataB = ".json_encode($dia2).";";
    echo "\n";
    echo "</script>";
    ?>

    <script>
        const data = {
          labels: _labels,
          datasets: [
            {
              label: _titleF,
                data: _dataA,
                backgroundColor: [
                    'rgba(221, 145, 4, 0.7)'
                ],
                borderColor: [
                    'rgb(221, 145, 4)'
                ],
                borderWidth: 1
            },
            {
              label: _titleG,
                data: _dataB,
                backgroundColor: [
                    'rgba(29, 71, 84, 0.7)'
                ],
                borderColor: [
                    'rgb(29, 71, 84)'
                ],
                borderWidth: 1
            }
          ]
        };

        const config = {
            type: 'bar',
            data: data,
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true,
                        display: true,
                        type: 'logarithmic'
                    }
                },
                plugins: {
                  title: {
                    display: false,
                    text: _titleF
                  },
                },
            },
        };
        var eChart = "";
        function init() {
          eChart = new Chart(document.getElementById('overviewCh'), config);
        }
        function toggleChart() {
            eChart.destroy();
            config.type = (config.type == 'bar') ? 'line' : 'bar';
            init();
        }
        init();
    </script>

    <?php
}


function get_page_count()
{
	global $_REQUEST, $_lang;
        
	$countpages = array();
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if($fields[2]!="" AND $fields[3]=="N")
			{
				if($fields[2]=="0")
				{
					$pgnr=1;
				}
				else{
					$pgnr=$fields[2];
				}
				$countpages[$pgnr]++;
			}
		}
		
		ksort($countpages);
		$cnt_all = count($countpages);
        
		if($cnt_all>30)
		{
			$multi = $cnt_all / 50;
		}
		else
		{
			$multi=1;
		}
		$multi=0;
        
		foreach($countpages as $K => $V)
		{
			if($iii>=$multi)
			{
				
				$datay[] = $V;
                $datax[] = $_lang['saLangName']." ".$K;
				$iii=0;
			}
			$iii++;
		}
	}
        
	if(!empty($datax) and is_array($datax) and count($datax)>0)
	{
		echo "<div><canvas id='chart_1'></canvas></div>";
		
        echo "<script>";
        echo "var _labelsA = ".json_encode($datax).";";
        echo "\n";
        echo "var _titleA = '".$_lang['statsum6']."';";
        echo "\n";
        echo "var _dataA = ".json_encode($datay).";";
        echo "\n";
        echo "</script>";
        ?>

        <script>
            const data1 = {
              labels: _labelsA,
              datasets: [
                {
                    label: _titleA,
		            data: _dataA,
		            backgroundColor: [
		                'rgba(221, 145, 4, 0.7)'
		            ],
		            borderColor: [
		                'rgb(221, 145, 4)'
		            ],
		            borderWidth: 1
                }
              ]
            };
    
            const config1 = {
                type: 'bar',
                data: data1,
                options: {
                    responsive: true,
                    plugins: {
                        zoom: {
                            pan: {
                                enabled: true,
                                mode: 'x',
                                modifierKey: 'ctrl',
                            },
                            zoom: {
                                wheel: {
                                    enabled: true,
                                },
                                pinch: {
                                    enabled: true
                                },
                                drag: {
                                    enabled: true
                                },
                                mode: 'x',
                            },
                            limits: {
                                y: {
                                    min: 0
                                },
                            },
                        },
                        legend: {
                            display: false
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            display: true,
                            ticks: {
                                callback: function(value) {
                                    if (Math.floor(value) === value) {
                                        return value
                                    }
                                }
                            }
                        },
                    },
                },
            };
		    var eChart1 = ""; 
            function init() {
              eChart1 = new Chart(document.getElementById('chart_1'), config1);
            }
            function toggleChart() {
                eChart1.resetZoom();
                eChart1.destroy();
                config1.type = (config1.type == 'bar') ? 'line' : 'bar';
                init();
            }
            init();
            
            $(document).ready(function() {
                $("#downloadCSV1").click(function(e) {
                    e.preventDefault();
                    downloadCSV1({
                        filename: "chart-data-1.csv"
                    });
                });
            });

            function convertChartDataToCSV(args) {
                let result, columnDelimiter, lineDelimiter, labels, data, desc1, desc2;

                data = args.data.data || null;
                if (data == null || !data.length) {
                    return null;
                }

                labels = args.labels || null;
                if (labels == null || !labels.length) {
                    return null;
                }
                
                desc1 = args.desc1 || null;
                if (desc1 == null || !desc1.length) {
                    return null;
                }
                
                desc2 = args.desc2 || null;
                if (desc2 == null || !desc2.length) {
                    return null;
                }

                columnDelimiter = args.columnDelimiter || ';';
                lineDelimiter = args.lineDelimiter || '\n';

                result = desc1;
                result += columnDelimiter;
                result += desc2;
                result += lineDelimiter;    

                for (let i = 0; i < data.length; i++) {
                    result += labels[i];
                    result += columnDelimiter;
                    result += data[i];
                    result += lineDelimiter;
                }
                result += lineDelimiter;

                return result;
            }

            function downloadCSV1(args) {
                var data, filename, link;                
                var csv = "";
                for (var i = 0; i < eChart1.data.datasets.length; i++) {
                    csv += convertChartDataToCSV({
                        data: eChart1.data.datasets[i],
                        labels: _labelsA,
                        desc1: "Seite",
                        desc2: "Zugriffe"
                    });
                }
                if (csv == null) return;

                filename = args.filename || 'chart-data.csv';
                if (!csv.match(/^data:text\/csv/i)) {
                    csv = 'data:text/csv;charset=utf-8,' + csv;
                }

                data = encodeURI(csv);
                link = document.createElement('a');
                link.setAttribute('href', data);
                link.setAttribute('download', filename);
                document.body.appendChild(link); 
                link.click();
                document.body.removeChild(link);
            }
            
		</script>

        <?php
	}
	else
	{
		echo $_lang['statsum51'];
	}
}
function get_hour_count()
{
	global $_REQUEST, $_lang;
    $countpages = array();
	if(!empty($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if(!empty($fields[0]) AND $fields[3]=="N")
			{
				$countpages[substr($fields[0], 11, 2)]++;
			}
		}
		for($i=0;$i<=24;$i++)
		{
			if(empty($countpages[str_pad($i, 2, "0", STR_PAD_LEFT)]))
			{
				$hrcnt = "0";
			}
			else
			{
				$hrcnt = $countpages[str_pad($i, 2, "0", STR_PAD_LEFT)];
			}
			
			$datay[] = $hrcnt;
			if($i<=23)
			{
				$hour = str_pad($i, 2, "0", STR_PAD_LEFT).":00";
			}
			else
			{
				$hour = "00:00";
			}
			$datax[] = $hour;
		}
		
		if(!empty($datax) and is_array($datax) and count($datax)>0)
		{
            
            echo "<div><canvas id='chart_2'></canvas></div>";
		
            echo "<script>";
            echo "var _labelsB = ".json_encode($datax).";";
            echo "\n";
            echo "var _titleB = '".$_lang['statsum5']."';";
            echo "\n";
            echo "var _dataB = ".json_encode($datay).";";
            echo "\n";
            echo "</script>";
            ?>

            <script>
                const data2 = {
                  labels: _labelsB,
                  datasets: [
                    {
                        label: _titleB,
                        data: _dataB,
                        backgroundColor: [
                            'rgba(221, 145, 4, 0.7)'
                        ],
                        borderColor: [
                            'rgb(221, 145, 4)'
                        ],
                        borderWidth: 1
                    }
                  ]
                };

                const config2 = {
                    type: 'line',
                    data: data2,
                    options: {
                        responsive: true,
                        plugins: {
                            legend:{
                                display: false
                            }
                        },
                        scales: {
                            y: {
                                beginAtZero: true,
                                display: true
                            }
                        },
                    },
                };
                const eChart2 = new Chart(document.getElementById('chart_2'), config2);
                
                
                $(document).ready(function() {
                    $("#downloadCSV2").click(function(e) {
                        e.preventDefault();
                        downloadCSV2({
                            filename: "chart-data-2.csv"
                        });
                    });
                });
                function downloadCSV2(args) {
                    var data, filename, link;
                    var csv = "";
                    for (var i = 0; i < eChart2.data.datasets.length; i++) {
                        csv += convertChartDataToCSV({
                            data: eChart2.data.datasets[i],
                            labels: _labelsB,
                            desc1: "Uhrzeit",
                            desc2: "Zugriffe"
                        });
                    }
                    if (csv == null) return;

                    filename = args.filename || 'chart-data.csv';
                    if (!csv.match(/^data:text\/csv/i)) {
                        csv = 'data:text/csv;charset=utf-8,' + csv;
                    }

                    data = encodeURI(csv);
                    link = document.createElement('a');
                    link.setAttribute('href', data);
                    link.setAttribute('download', filename);
                    document.body.appendChild(link); 
                    link.click();
                    document.body.removeChild(link);
                }
                
            </script>

            <?php
		}
		else
		{
			echo $_lang['statsum51'];
		}
	}
}


function get_day_count_hits()
{
    global $_REQUEST, $_lang;
    $countpages = array();
	if(!empty($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$add_date = substr($_REQUEST['date'], 9, 2).".".substr($_REQUEST['date'], 7, 2);
		$filearray = file($_REQUEST['date']);
		
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if(!empty($fields[0]) AND $fields[3]=="N" AND $fields[2]==0)
			{
				$countpages[substr($fields[0], 8, 2)]++;
				$month =substr($fields[0], 5, 2);
				$year =substr($fields[0], 0, 4);
			}
		}
        
        $p1 = substr($_REQUEST['date'], 9, 2);
        $p2 = substr($_REQUEST['date'], 5, 4);
        
		for($i=1;$i<= date("t", mktime(0, 0, 0, $p1, 1, $p2));$i++)
		{
			if(empty($countpages[str_pad($i, 2, "0", STR_PAD_LEFT)]))
			{
				$hrcnt = "0";
			}
			else
			{
				$hrcnt = $countpages[str_pad($i, 2, "0", STR_PAD_LEFT)];
			}

			$datay[] = $hrcnt;
			$datax[] = str_pad($i, 2, "0", STR_PAD_LEFT).".".$add_date;
		}
		
		if(!empty($datax) and is_array($datax) and count($datax)>0)
		{
            
            echo "<div><canvas id='chart_3'></canvas></div>";
		
            echo "<script>";
            echo "var _labelsC = ".json_encode($datax).";";
            echo "\n";
            echo "var _titleC = '".$_lang['statsum6']."';";
            echo "\n";
            echo "var _dataC = ".json_encode($datay).";";
            echo "\n";
            echo "</script>";
            ?>

            <script>
                const data3 = {
                  labels: _labelsC,
                  datasets: [
                    {
                        label: _titleC,
                        data: _dataC,
                        backgroundColor: [
                            'rgba(221, 145, 4, 0.7)'
                        ],
                        borderColor: [
                            'rgb(221, 145, 4)'
                        ],
                        borderWidth: 1
                    }
                  ]
                };

                const config3 = {
                    type: 'line',
                    data: data3,
                    options: {
                        responsive: true,
                        plugins: {
                            legend:{
                                display: false
                            }
                        },
                        scales: {
                            y: {
                                beginAtZero: true,
                                display: true
                            }
                        },
                    },
                };
                const eChart3 = new Chart(document.getElementById('chart_3'), config3);
                
                $(document).ready(function() {
                    $("#downloadCSV3").click(function(e) {
                        e.preventDefault();
                        downloadCSV3({
                            filename: "chart-data-3.csv"
                        });
                    });
                });
                function downloadCSV3(args) {
                    var data, filename, link;
                    var csv = "";
                    for (var i = 0; i < eChart3.data.datasets.length; i++) {
                        csv += convertChartDataToCSV({
                            data: eChart3.data.datasets[i],
                            labels: _labelsC,
                            desc1: "Datum",
                            desc2: "Aufrufe"
                        });
                    }
                    if (csv == null) return;

                    filename = args.filename || 'chart-data.csv';
                    if (!csv.match(/^data:text\/csv/i)) {
                        csv = 'data:text/csv;charset=utf-8,' + csv;
                    }

                    data = encodeURI(csv);
                    link = document.createElement('a');
                    link.setAttribute('href', data);
                    link.setAttribute('download', filename);
                    document.body.appendChild(link); 
                    link.click();
                    document.body.removeChild(link);
                }
                
            </script>

            <?php

		}
		else
		{
			echo $_lang['statsum51'];
		}
	}
}


function get_day_count()
{
    global $_REQUEST, $_lang;
    $countpages = array();
	if(!empty($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$add_date = substr($_REQUEST['date'], 9, 2).".".substr($_REQUEST['date'], 7, 2);
		$filearray = file($_REQUEST['date']);
		
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if(!empty($fields[0]) AND $fields[3]=="N")
			{
				$countpages[substr($fields[0], 8, 2)]++;
				$month =substr($fields[0], 5, 2);
				$year =substr($fields[0], 0, 4);
			}
		}

                
		$p1 = substr($_REQUEST['date'], 9, 2);
        $p2 = substr($_REQUEST['date'], 5, 4);
        
		for($i=1;$i<= date("t", mktime(0, 0, 0, $p1, 1, $p2));$i++)
		{
			if(empty($countpages[str_pad($i, 2, "0", STR_PAD_LEFT)]))
			{
				$hrcnt = "0";
			}
			else
			{
				$hrcnt = $countpages[str_pad($i, 2, "0", STR_PAD_LEFT)];
			}

			$datay[] = $hrcnt;
			$datax[] = str_pad($i, 2, "0", STR_PAD_LEFT).".".$add_date;
		}
		
		if(!empty($datax) and is_array($datax) and count($datax)>0)
		{
            echo "<div><canvas id='chart_4'></canvas></div>";
		
            echo "<script>";
            echo "var _labelsD = ".json_encode($datax).";";
            echo "\n";
            echo "var _titleD = '".$_lang['statsum5']."';";
            echo "\n";
            echo "var _dataD = ".json_encode($datay).";";
            echo "\n";
            echo "</script>";
            ?>

            <script>
                const data4 = {
                  labels: _labelsD,
                  datasets: [
                    {
                        label: _titleD,
                        data: _dataD,
                        backgroundColor: [
                            'rgba(221, 145, 4, 0.7)'
                        ],
                        borderColor: [
                            'rgb(221, 145, 4)'
                        ],
                        borderWidth: 1
                    }
                  ]
                };

                const config4 = {
                    type: 'line',
                    data: data4,
                    options: {
                        responsive: true,
                        plugins: {
                            legend:{
                                display: false
                            }
                        },
                        scales: {
                            y: {
                                beginAtZero: true,
                                display: true
                            }
                        },
                    },
                };
                const eChart4 = new Chart(document.getElementById('chart_4'), config4);
                
                $(document).ready(function() {
                    $("#downloadCSV4").click(function(e) {
                        e.preventDefault();
                        downloadCSV4({
                            filename: "chart-data-4.csv"
                        });
                    });
                });
                function downloadCSV4(args) {
                    var data, filename, link;
                    var csv = "";
                    for (var i = 0; i < eChart4.data.datasets.length; i++) {
                        csv += convertChartDataToCSV({
                            data: eChart4.data.datasets[i],
                            labels: _labelsD,
                            desc1: "Datum",
                            desc2: "Zugriffe"
                        });
                    }
                    if (csv == null) return;

                    filename = args.filename || 'chart-data.csv';
                    if (!csv.match(/^data:text\/csv/i)) {
                        csv = 'data:text/csv;charset=utf-8,' + csv;
                    }

                    data = encodeURI(csv);
                    link = document.createElement('a');
                    link.setAttribute('href', data);
                    link.setAttribute('download', filename);
                    document.body.appendChild(link); 
                    link.click();
                    document.body.removeChild(link);
                }
                
            </script>
			
		  <?php

		}
		else
		{
			echo $_lang['statsum51'];
		}
	}
}

function get_function_count()
{
    global $_REQUEST, $_lang;
    $countpages = array();
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if(!empty($fields[3]))
			{
				$countpages[$fields[3]]++;
			}
		}
		foreach($countpages as $K => $V)
		{
			if($K != "N")
			{
				$data[] = $V;
				$datax[] = translate_function($K);
                #." (".$V.")"
			}
		}
		
		if(!empty($datax) and is_array($datax) and count($datax)>0)
		{
		
            echo "<div><canvas id='chart_5' style='max-height:500px;'></canvas></div>";
		
            echo "<script>";
            echo "var _labelsE = ".json_encode($datax).";";
            echo "\n";
            echo "var _titleE = '".$_lang['statsum10']."';";
            echo "\n";
            echo "var _dataE = ".json_encode($data).";";
            echo "\n";
            echo "</script>";
            ?>

            <script>
                var currentPalette = "neon";
                const data5 = {
                  labels: _labelsE,
                  datasets: [
                    {
                        label: _titleE,
                        data: _dataE,
                    }
                  ]
                };

                const config5 = {
                    type: 'pie',
                    data: data5,
                    options: {
                        responsive: true,
                        plugins: {
                            legend: {
                                position: 'top',
                                onHover: (evt, item, legend) => {
                                  const chart = legend.chart;
                                  const tooltip = chart.tooltip;
                                  const chartArea = chart.chartArea;
                                  tooltip.setActiveElements([{
                                    datasetIndex: 0,
                                    index: item.index,
                                  }], {
                                    x: (chartArea.left + chartArea.right) / 2,
                                    y: (chartArea.top + chartArea.bottom) / 2,
                                  });
                                  chart.update();
                                },
                            },
                            
                        },    
                    },
                };
                const eChart5 = new Chart(document.getElementById('chart_5'), config5);
                chartColors();
                
                $(document).ready(function() {
                    $("#downloadCSV5").click(function(e) {
                        e.preventDefault();
                        downloadCSV5({
                            filename: "chart-data-5.csv"
                        });
                    });
                });
                function downloadCSV5(args) {
                    var data, filename, link;
                    var csv = "";
                    for (var i = 0; i < eChart5.data.datasets.length; i++) {
                        csv += convertChartDataToCSV({
                            data: eChart5.data.datasets[i],
                            labels: _labelsE,
                            desc1: "Funktion",
                            desc2: "Anzahl"
                        });
                    }
                    if (csv == null) return;

                    filename = args.filename || 'chart-data.csv';
                    if (!csv.match(/^data:text\/csv/i)) {
                        csv = 'data:text/csv;charset=utf-8,' + csv;
                    }

                    data = encodeURI(csv);
                    link = document.createElement('a');
                    link.setAttribute('href', data);
                    link.setAttribute('download', filename);
                    document.body.appendChild(link); 
                    link.click();
                    document.body.removeChild(link);
                }
                
                function chartColors(palette){if(!palette)palette=currentPalette;currentPalette=palette;var gradient;switch(palette){case'cool':gradient={0:[255,255,255,1],20:[220,237,200,1],45:[66,179,213,1],65:[26,39,62,1],100:[0,0,0,1]};break;case'warm':gradient={0:[255,255,255,1],20:[254,235,101,1],45:[228,82,27,1],65:[77,52,47,1],100:[0,0,0,1]};break;case'neon':gradient={0:[255,255,255,1],20:[255,236,179,1],45:[232,82,133,1],65:[106,27,154,1],100:[0,0,0,1]};break}var gradientKeys=Object.keys(gradient);gradientKeys.sort(function(a,b){return+a- +b});var chartType=eChart5.config.type;switch(chartType){case"pie":case"doughnut":var datasets=eChart5.config.data.datasets[0];var setsCount=datasets.data.length;break;case"bar":case"line":var datasets=eChart5.config.data.datasets;var setsCount=datasets.length;break}var chartColors=[];for(i=0;i<setsCount;i++){var gradientIndex=(i+1)*(100/(setsCount+1));for(j=0;j<gradientKeys.length;j++){var gradientKey=gradientKeys[j];if(gradientIndex===+gradientKey){chartColors[i]='rgba('+gradient[gradientKey].toString()+')';break}else if(gradientIndex<+gradientKey){var prevKey=gradientKeys[j-1];var gradientPartIndex=(gradientIndex-prevKey)/(gradientKey-prevKey);var color=[];for(k=0;k<4;k++){color[k]=gradient[prevKey][k]-((gradient[prevKey][k]-gradient[gradientKey][k])*gradientPartIndex);if(k<3)color[k]=Math.round(color[k])}chartColors[i]='rgba('+color.toString()+')';break}}}for(i=0;i<setsCount;i++){switch(chartType){case"pie":case"doughnut":if(!datasets.backgroundColor)datasets.backgroundColor=[];datasets.backgroundColor[i]=chartColors[i];if(!datasets.borderColor)datasets.borderColor=[];datasets.borderColor[i]="rgba(255,255,255,1)";break;case"bar":datasets[i].backgroundColor=chartColors[i];datasets[i].borderColor="rgba(255,255,255,0)";break;case"line":datasets[i].borderColor=chartColors[i];datasets[i].backgroundColor="rgba(255,255,255,0)";break}}eChart5.update()}
            </script>
          
            <?php
		}
		else
		{
			echo $_lang['statsum51'];
		}
	}
}

function get_kat_hits()
{
	global $_REQUEST;
	$countpages = 0;
	
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if($fields[2]=="0")
			{
				$countpages++;
			}
		}
	}
	return $countpages;
}

function get_kat_hits_2($date)
{
	$countpages = 0;
	if(!empty($date) AND is_file($date) AND substr($date, 0, 5) =="stat_")
	{
		$filearray = file($date);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if($fields[2]=="0")
			{
				$countpages++;
			}
		}
	}
	return $countpages;
}
#Gefundene Suchbegriffe
function get_search_count()
{
	global $_REQUEST;
	$countpages = array();
	
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			#if($fields[4]!="" AND $fields[3]=="F" AND (!isset($fields[5]) OR $field[5] != "NOTFOUND"))
			#if($fields[4]!="" AND $fields[3]=="F" AND !isset($fields[5]))
			if($fields[4]!="" AND $fields[3]=="F" AND $fields[5] != "NOTFOUND")
			{
				$countpages[strtolower($fields[4])]++;
			}
		}
	}
	if(is_array($countpages))
	{
		arsort($countpages);
	}
	return $countpages;
}
#Nicht gefunden Suchbegriffe
function get_search_countM()
{
	global $_REQUEST;
	$countpages = array();
	
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			#if($fields[4]!="" AND $fields[3]=="F" and isset($fields[5]))
			
			if($fields[4]!="" AND $fields[3]=="F" and $fields[5] == "NOTFOUND")
			{
				$countpages[strtolower($fields[4])]++;
			}
		}
	}
	if(is_array($countpages))
	{
		arsort($countpages);
	}    
	return $countpages;
}

function get_pagename_fromfile($str, $page)
{
	if(!empty($str)){$return ="";$str1 = explode("&", $str);foreach($str1 AS $K => $V){if(!empty($V)){$string = "name".$page."=";if(substr($V, 0, strlen($string))==$string){$replaced = str_replace("name".$page."=", "", $V);$return = $replaced;}}}}if(!empty($return)){return $return;}else{	return "";}
}
	
function get_link_count()
{
	global $_REQUEST;
	$countpages = array();
	
	if(!empty($_REQUEST['date']) AND is_file($_REQUEST['date']) AND substr($_REQUEST['date'], 0, 5) =="stat_")
	{
		$filearray = file($_REQUEST['date']);
		foreach($filearray as $KEY => $VALUE)
		{
			$fields = explode("\t", $VALUE);
			if($fields[4]!="" AND ($fields[3]=="L" OR $fields[3]=="H"))
			{
				$countpages[strtolower($fields[4])]++;
			}
		}
	}
	if(is_array($countpages))
	{
		arsort($countpages);
	}
	return $countpages;
}

function translate_function($func)
{
	global $lang;
	
	switch($lang)
	{
		case 'en' :
			if($func=="N") return "Navigation";
			elseif($func=="Z") return "Zoom";
			elseif($func=="F") return "Search";
			elseif($func=="H") return "Homelink";
			elseif($func=="L") return "Link";
			elseif($func=="S") return "Save single page";
			elseif($func=="P") return "Print single page";
			elseif($func=="E") return "Single page";
			elseif($func=="V") return "Fullscreen";
			elseif($func=="G") return "Help";
			elseif($func=="M") return "Thumbview";
			elseif($func=="T") return "Table of contents";
			elseif($func=="W") return "Shopping cart";
			elseif($func=="K") return "Added to shopping cart";
			elseif($func=="A") return "AutoFlip";
			elseif($func=="B") return "Favorites";
			elseif($func=="C") return "Notes";
			elseif($func=="Y") return "Order sheet";
			elseif($func=="J") return "Tabs";
			elseif($func=="X") return "Magnifying glass";
			elseif($func=="D") return "Choose language";
			elseif($func=="I") return "Recommend page";
			else{return $func;}
			break;
		default:
			if($func=="N") return "Navigation";
			elseif($func=="Z") return "Zoom";
			elseif($func=="F") return "Suchen";
			elseif($func=="H") return "Homelink";
			elseif($func=="L") return "Link";
			elseif($func=="S") return "Seite Speichern";
			elseif($func=="P") return "Seite Drucken";
			elseif($func=="E") return "Einzelseite";
			elseif($func=="V") return "Vollbild";
			elseif($func=="G") return "Hilfe";
			elseif($func=="M") return "Miniatur Ansicht";
			elseif($func=="T") return "Inhaltsverzeichnis";
			elseif($func=="W") return "Warenkorb";
			elseif($func=="K") return "in Warenkorb gelegt";
			elseif($func=="A") return "AutoFlip";
			elseif($func=="B") return "Favoriten";
			elseif($func=="C") return "Notizen";
			elseif($func=="Y") return "Bestellschein";
			elseif($func=="J") return "Tabs";
			elseif($func=="X") return "Lupe";
			elseif($func=="D") return "Sprachwahl";
			elseif($func=="I") return "Weiterempfehlen";
			else{return $func;}
			break;
	}
	
}

?>