diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..a11e04f Binary files /dev/null and b/favicon.ico differ diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..958090a --- /dev/null +++ b/footer.php @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..317f792 --- /dev/null +++ b/functions.php @@ -0,0 +1,69 @@ +"buffered")); + $row_count = sqlsrv_num_rows( $stmtMitarbeiter ); + #return $row_count; + if ($row_count == 1) + { + return true; + }else{ + return false; + } +} + +function checkKaffeelisteAdmin($conn, $mail) +{ + // Mitarbeiter aus der Datenbank abrufen und nach Namen sortieren + $sqlMitarbeiter = "SELECT MitarbeiterID FROM kl_Mitarbeiter WHERE Email like '" . strtolower($mail) . "' AND admin='1'"; + + $stmtMitarbeiter = sqlsrv_query($conn, $sqlMitarbeiter, array(), array("Scrollable"=>"buffered")); + $row_count = sqlsrv_num_rows( $stmtMitarbeiter ); + #return $row_count; + if ($row_count == 1) + { + return true; + }else{ + return false; + } +} + + +?> \ No newline at end of file diff --git a/functionsLDAP.php b/functionsLDAP.php new file mode 100644 index 0000000..e4df15e --- /dev/null +++ b/functionsLDAP.php @@ -0,0 +1,166 @@ + 0) + { + return $entries[0]['dn']; + } + + return ''; +} + +function getADMail($ad, $samaccountname, $basedn) +{ + $attributes = array('mail'); + $resultz = ldap_search($ad, $basedn, "(samaccountname={$samaccountname})", $attributes); + $entriesz = ldap_get_entries($ad, $resultz); + + #return $entriesz[0]['mail']; + # $entries = ldap_get_entries($ad, $result); + if ($entriesz['count'] > 0) + { + return $entriesz[0]['mail'][0]; + } + + return 'nichts gefunden'; +} + + +/** + * This function retrieves and returns Common Name from a given Distinguished + * Name. + * + * @param string $dn + * The Distinguished Name. + * @return string The Common Name. + */ +function getCN($dn) +{ + preg_match('/[^,]*/', $dn, $matchs, PREG_OFFSET_CAPTURE, 3); + return $matchs[0][0]; +} + +/** + * This function checks group membership of the user, searching only in + * specified group (not recursively). + * + * @param resource $ad + * An LDAP link identifier, returned by ldap_connect(). + * @param string $userdn + * The user Distinguished Name. + * @param string $groupdn + * The group Distinguished Name. + * @return boolean Return true if user is a member of group, and false if not + * a member. + */ +function checkGroup($ad, $userdn, $groupdn) +{ + $result = ldap_read($ad, $userdn, "(memberof={$groupdn})", array( + 'members' + )); + if (! $result) + { + return false; + } + + $entries = ldap_get_entries($ad, $result); + + return ($entries['count'] > 0); +} + +/** + * This function checks group membership of the user, searching in specified + * group and groups which is its members (recursively). + * + * @param resource $ad + * An LDAP link identifier, returned by ldap_connect(). + * @param string $userdn + * The user Distinguished Name. + * @param string $groupdn + * The group Distinguished Name. + * @return boolean Return true if user is a member of group, and false if not + * a member. + */ +function checkGroupEx($ad, $userdn, $groupdn) +{ + if ($groupdn == "") + { + return false; + } + + $result = ldap_read($ad, $userdn, '(objectclass=*)', array( + 'memberof' + )); + if (! $result) + { + return false; + } + + $entries = ldap_get_entries($ad, $result); + if ($entries['count'] <= 0) + { + return false; + } + + if (empty($entries[0]['memberof'])) + { + return false; + } + + for ($i = 0; $i < $entries[0]['memberof']['count']; $i ++) + { + if ($entries[0]['memberof'][$i] == $groupdn) + { + return true; + } + elseif (checkGroupEx($ad, $entries[0]['memberof'][$i], $groupdn)) + { + return true; + } + } + + return false; +} + +?> \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..4b20ac5 --- /dev/null +++ b/header.php @@ -0,0 +1,38 @@ + + + + + Kaffeeliste + + + + + +1"; +// Aktuelle Hinweise abrufen +$sql = "SELECT nachricht FROM kl_hinweise WHERE gueltig_bis >= SYSDATETIME() ORDER BY gueltig_bis ASC"; +$stmt = sqlsrv_query($conn, $sql); + +if ($stmt === false) { + die(print_r(sqlsrv_errors(), true)); +} + +if ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { + echo "
" + . htmlspecialchars($row['nachricht']) . + "
"; +} + +?> + +
+ + +
+
\ No newline at end of file