<?php
$user_admin=$_COOKIE["user_admin"];
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php

// Rechte&uuml;berpr&uuml;fung
$db = dbconnect();
if ($user_admin == ""){ require("index.php"); exit;} //Wenn man nicht angemeldet ist, darf man nicht auf die Seite
$result = $db->query("SELECT 1 FROM pros_admin_rechte, pros_admin_rechte_zuord , pros_admin where pros_admin_rechte.pros_admin_rolle = pros_admin_rechte_zuord.pros_admin_rolle AND pros_admin_rechte_zuord.faid = pros_admin.faid AND pros_admin.user = '$user_admin' AND pros_admin_rechte_zuord.pros_admin_rolle = 'a_stat'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende


$sql = "SELECT COUNT(*) as Anzahl FROM pros_studlog";
$result = $db->query($sql) OR die(mysql_error());
$studlog = $result->fetch_array();

$result2 = $db->query("SELECT datum as datsort, DATE_Format(datum, '%d.%m.%Y') as datum FROM pros_studlog ORDER BY datsort ASC limit 1");
$firststud = $result2->fetch_array();


$sql = "SELECT COUNT(*) as Anzahl FROM pros_dozlog";
$result = $db->query($sql) OR die(mysql_error());
$dozlog = $result->fetch_array();

$result2 = $db->query("SELECT datum as datsort, DATE_Format(datum, '%d.%m.%Y') as datum FROM pros_dozlog ORDER BY datsort ASC limit 1");
$firstdoz = $result2->fetch_array();


$result = $db->query("SELECT anzahl, DATE_Format(datum, '%d.%m.%Y') as datum, DATE_Format(datum, '%H:%i:%s')AS zeit FROM pros_online_max");
$rowdba = $result->fetch_array();


echo"
<html>

<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Statistik</title>
</head>

<body>
<table align=\"center\" border=\"0\" style=\"border-collapse: collapse\" width=\"60%\" cellpadding=\"0\" height=\"95%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table valign=\"top\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_top.gif\" valign=\"top\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Statistik</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td>
                    <table valign=\"top\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
                      <tr>
                        <td width=\"10%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          <p align=\"right\">
                          $aktonline</p>
                        </td>
                        <td width=\"90%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          Benutzer aktuell online im Studentenbereich
                        </td>
                      </tr>
                      <tr>
                        <td width=\"5%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          <p align=\"right\">
                          $studlog[Anzahl]</p>
                        </td>
                        <td width=\"9095\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          Logins im Studentenbereich seit dem $firststud[datum]
                        </td>
                      </tr>
                      <tr>
                        <td width=\"5%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          <p align=\"right\">
                          $dozlog[Anzahl]</p>
                        </td>
                        <td width=\"95%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          Logins im Dozentenbereich seit dem $firstdoz[datum]
                        </td>
                      </tr>
                      <tr>
                        <td colspan='2' width=\"10%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
                          <p>
                            Mit $rowdba[0] Benutzern waren die meisten Studenten gleichzeitig online ($rowdba[1] um $rowdba[2])
                          </p>
                        </td>
                      </tr>

                     </table>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";


?>