first commit
This commit is contained in:
482
admin/suche.php
Executable file
482
admin/suche.php
Executable file
@ -0,0 +1,482 @@
|
||||
<?php
|
||||
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
|
||||
$user_admin=$_COOKIE["user_admin"];
|
||||
$jahrgang=$_COOKIE["jahrgang"];
|
||||
|
||||
if ($jahrgang == ""){ require("jahrgang.php"); exit;} //Wenn man kein Jahrgang ausgewählt hat wird die Jahrgangsauswahlseite geladen
|
||||
include("kurs/datenbankanbindung.php"); // fügt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
|
||||
|
||||
// Rechteüberprü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 skik_admin_rechte, skik_admin_rechte_zuord , skik_admin where skik_admin_rechte.skik_admin_rolle = skik_admin_rechte_zuord.skik_admin_rolle AND skik_admin_rechte_zuord.faid = skik_admin.faid AND skik_admin.user = '$user_admin' AND skik_admin_rechte_zuord.skik_admin_rolle = 'a_suche'");
|
||||
$row = $result->fetch_array();
|
||||
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
|
||||
// Rechteüberprüfung ende
|
||||
|
||||
|
||||
if (isset($_GET['action']))
|
||||
$action = $_GET['action'];
|
||||
else
|
||||
$action = "";
|
||||
|
||||
switch($action){
|
||||
default:
|
||||
|
||||
echo "
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
|
||||
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
|
||||
|
||||
<style type='text/css'>
|
||||
select{
|
||||
width:250px;
|
||||
}
|
||||
|
||||
|
||||
/* (Live) Search begin */
|
||||
#LSResult {
|
||||
width: 192px;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
background: #eee;
|
||||
border-bottom: 4px solid #ddd;
|
||||
}
|
||||
|
||||
#searchcontrols {
|
||||
background: #ddd;
|
||||
text-align: right;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#searchcontrols #resultsTitle {
|
||||
float: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
#searchcontrols #resultsLegend {
|
||||
float: right;
|
||||
}
|
||||
#searchcontrols #resultsLegend a {
|
||||
font-size: 1.3em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.LSRow:hover, #LSHighlight, #LSHighlight:hover {
|
||||
background: #dde;
|
||||
}
|
||||
|
||||
#LSResult:hover #LSHighlight {
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#LSHighlight {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.LSRow {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.LSRow span a, .LSRow span a:visited {
|
||||
word-spacing: -1px;
|
||||
line-height: 1.3em;
|
||||
font-weight: normal;
|
||||
color: #bbb;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<title>Suche</title>
|
||||
</head>
|
||||
|
||||
<body onload=\"start();\">
|
||||
|
||||
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
|
||||
<tr>
|
||||
<td>
|
||||
<div align=\"center\">
|
||||
<table cellspacing=\"0\" cellpadding=\"0\" width=\"75%\" 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\">Suche</font><br>
|
||||
<img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></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>
|
||||
<form action="; echo $_SERVER['PHP_SELF'] . "?action=suche"; echo" id=\"searchform\" method=\"POST\" name=\"searchform\">
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
|
||||
|
||||
|
||||
<tr>
|
||||
<td width=\"30%\" align=\"left\" height=\"18\">
|
||||
<b>Bezeichnung:</b>
|
||||
</td>
|
||||
<td width=\"70%\" align=\"left\" height=\"18\">
|
||||
<input type=\"text\" name=\"bezeichnung\" size=\"37\">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=\"30%\" align=\"left\" height=\"18\">
|
||||
<b>Dozent:</b>
|
||||
</td>
|
||||
<td width=\"70%\" align=\"left\" height=\"18\">
|
||||
<!--[if lt IE 7]><div id=\"kategorie\"><![endif]-->
|
||||
";
|
||||
$db = dbconnect();
|
||||
$query = "SELECT distinct doz.doz_nr, doz_name, doz_vorname, doz_titel
|
||||
FROM doz, skik_doz, skik_kurs
|
||||
WHERE doz.doz_nr = skik_doz.doz_nr
|
||||
AND skik_kurs.id = skik_doz.id
|
||||
AND skik_kurs.jahr = '$jahrgang'
|
||||
ORDER BY doz_name ASC";
|
||||
$result = $db->query ($query)
|
||||
or die ("Cannot execute query");
|
||||
echo "<select id='dozent' name='dozent'>
|
||||
<option value='%'>(alle)</option>";
|
||||
while ($row = $result->fetch_array()){
|
||||
echo "<option value=\"".$row[doz_nr]."\">$row[doz_name], $row[doz_vorname] $row[doz_titel] </option>\n";
|
||||
}
|
||||
|
||||
echo"
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=\"30%\" align=\"left\" height=\"18\">
|
||||
<b>Suchart:</b>
|
||||
</td>
|
||||
<td width=\"70%\" align=\"left\" height=\"18\">
|
||||
<label for=\"r3\"><input type=\"radio\" name=\"art\" 'checked' value=\"exact\" id=\"r3\" onfocus=\"setVisibility(0);\"> Exakte Suche</label><br>
|
||||
<label for=\"r4\"><input type=\"radio\" name=\"art\" value=\"any\" id=\"r4\" onfocus=\"setVisibility(0);\"> Ähnliche Suche (bei Kurs wird auch Sprach<b>kurs</b> gefunden)</label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<input type=\"submit\" value=\"Abschicken\">
|
||||
</form>
|
||||
</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>";
|
||||
|
||||
break;
|
||||
case "suche":
|
||||
|
||||
$bezeichnung = strtoupper($_POST[bezeichnung]);
|
||||
|
||||
$dozent = strtoupper($_POST[dozent]);
|
||||
|
||||
$art = $_POST[art];
|
||||
|
||||
|
||||
//Select zusammenbauen
|
||||
if($art == 'exact' AND $bezeichnung != ''){ // wenn leer, darf kein regexp kommen, sonst würde er nichts finden
|
||||
$trenner1 = 'REGEXP ';
|
||||
$start1 = '[[:<:]]';
|
||||
$ende1 = '[[:>:]]';
|
||||
}else{
|
||||
$trenner1 = 'LIKE ';
|
||||
$start1 = '%';
|
||||
$ende1 = '%';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql1 = "SELECT count(distinct skik_kurs.id) as anz_treffer
|
||||
FROM skik_kurs, skik_doz
|
||||
WHERE ";
|
||||
|
||||
######################################################################################################
|
||||
## SQL ZUSAMMENBAUEN FÜR DIE ÜBERSCHRIFT
|
||||
######################################################################################################
|
||||
|
||||
$bezeichnung = preg_replace('/\s{2,}/sm',' ',$bezeichnung,PREG_SET_ORDER); //Mehr als zwei leerzeichen entfernen
|
||||
preg_match_all("/(\-{0,1}\+{0,1}\*{0,1}%{0,1}\"([^\"]+)\"\*{0,1}%{0,1}\+{0,1}\-{0,1}|\-{0,1}\+{0,1}\*{0,1}%{0,1}(\w+)\*{0,1}%{0,1}\+{0,1}\-{0,1})/", $bezeichnung, $Bezeichnungen);
|
||||
# Erklärung: \-{0,1} --> 0 oder 1 Minuszeichen kann string enthalten
|
||||
# \+{0,1} --> 0 oder 1 Pluszeichen kann string enthalten
|
||||
# \*{0,1} --> 0 oder 1 Asterisk kann string enthalten
|
||||
# %{0,1} --> 0 oder 1 Prozentzeichen kann string enthalten, muss nicht durch \ escaped werden
|
||||
# Vorderer Teil bis | überprüft ob "" eingegeben wurden und splittet innerhalb der "" nicht. Hinterer Teil wenn Wörter ohne "" eingegeben wurde
|
||||
|
||||
if($bezeichnung != ""){
|
||||
|
||||
$sql .= " ("; //Kein AND vor der Klammer notwendig, da direkt nach where, bei anderen muss AND davor stehen
|
||||
|
||||
for($i=0; $i < count($Bezeichnungen); $i++)
|
||||
{
|
||||
|
||||
#In der Überschrift kommen Umlaute vor, daher keine Ersetzung der Umlaute
|
||||
#$ueberschrift = str_replace (array("\\", "ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), array("", "&AUML;", "&OUML;", "&UUML;", "&SZLIG;", "&AUML;", "&OUML;", "&UUML;"), $Ueberschriften[0][$i]);
|
||||
$ueber = str_replace (array("+", "-", "\"", "\\"), array("", "", "", ""), $Bezeichnungen[0][$i]);
|
||||
|
||||
if($i == 0){
|
||||
$oper = "";
|
||||
}else{
|
||||
$oper = "AND";
|
||||
}
|
||||
|
||||
if(strpos($Bezeichnungen[0][$i],"+") === 0){
|
||||
$sql .= "UPPER(bezeichnung) $trenner1 '$start1".$ueber."$ende1' ";
|
||||
} elseif(strpos($Bezeichnungen[0][$i],"-") === 0){
|
||||
$sql .= "$oper UPPER(bezeichnung) NOT $trenner1 '$start1".$ueber."$ende1' ";
|
||||
} elseif($Bezeichnungen[0][$i] == ""){
|
||||
NULL;
|
||||
}else{
|
||||
$sql .= "$oper UPPER(bezeichnung) $trenner1 '$start1".$ueber."$ende1' ";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
}else{
|
||||
|
||||
$sql .= " UPPER(bezeichnung) LIKE '%' "; //Wenn nichts eingegeben, dann soll alles angzeigt werden. Das braucht man hier weil zusammengesetzter string sonst WHERE AND TEXTSTELLE = .... heißen könnte
|
||||
|
||||
}
|
||||
|
||||
######################################################################################################
|
||||
## SQL ZUSAMMENBAUEN FÜR DIE ÜBERSCHRIFT ENDE
|
||||
######################################################################################################
|
||||
|
||||
|
||||
|
||||
$sql .= "AND skik_kurs.jahr = '$jahrgang'
|
||||
AND skik_doz.id = skik_kurs.id
|
||||
AND skik_doz.doz_nr LIKE '$dozent'";
|
||||
|
||||
#####################################################################################################
|
||||
## SQL ZUSAMMENBAUEN FÜR DIE RESTLICHEN FELDER ENDE
|
||||
######################################################################################################
|
||||
|
||||
|
||||
######################################################################################################
|
||||
## GESAMTSELECT - SQL ZUSAMMENBAUEN
|
||||
######################################################################################################
|
||||
|
||||
$query = $sql1.$sql;
|
||||
|
||||
#echo $query;
|
||||
#exit;
|
||||
|
||||
$result = $db->query($query);
|
||||
$res = $result->fetch_array()
|
||||
or die ("Cannot execute query");
|
||||
|
||||
|
||||
|
||||
if($res[anz_treffer] == '' or $res[anz_treffer] == 0){
|
||||
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>keine Treffer</title>
|
||||
</head>
|
||||
<body>
|
||||
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
|
||||
<tr>
|
||||
<td>
|
||||
<div align=\"center\">
|
||||
<table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" 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=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
|
||||
<td width=\"95%\" background=\"../images/box_top.gif\">
|
||||
<img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
|
||||
<span class=\"sh\">keine Treffer</span><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 colspan=\"2\"><br>
|
||||
<p align=\"center\"><b>Es wurden keine Suchergebnisse gefunden</b>
|
||||
|
||||
|
||||
<p align=\"center\"><a href=".$_SERVER['PHP_SELF'] .">
|
||||
<img border=\"0\" src=\"../images/zurueck.gif\"></a>
|
||||
|
||||
</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p><br>
|
||||
</p>
|
||||
</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\" colspan=\"2\">
|
||||
<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>
|
||||
";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function kurzer_text($string,$laenge){
|
||||
$origin=strlen($string);
|
||||
$stri_arr=explode(" ",$string);
|
||||
$anzzahl=count($stri_arr);
|
||||
$gekuerzt=0;
|
||||
$string="";
|
||||
while($gekuerzt<$anzzahl){
|
||||
$string_alt=$string;
|
||||
$string=$string." ".$stri_arr[$gekuerzt];
|
||||
$gekuerzt++;
|
||||
if(strlen($string)>$laenge){
|
||||
$gekuerzt=$anzzahl;
|
||||
$string=$string_alt;
|
||||
}
|
||||
}
|
||||
if($laenge<$origin){
|
||||
$string=$string."<nobr> <b>...</b></nobr>";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
echo "
|
||||
<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>
|
||||
<style><!--
|
||||
.sl,.r{font-weight:normal;margin:0;display:inline}
|
||||
.r{font-size:1em}
|
||||
.g{margin-top:1em;margin-bottom:1em}
|
||||
.a,.a:link{color:green}
|
||||
body,td,div,.p,a{font-family:arial,sans-serif}
|
||||
--></style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=\"center\" border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" 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\">Suchergebnisse</font><br>
|
||||
<span class=\"sh\">Treffer: $res[anz_treffer]</span><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\">";
|
||||
$db = dbconnect();
|
||||
|
||||
$sql1 = "SELECT distinct skik_kurs.id, skik_kurs.FPRNr, bezeichnung, beschreibung, Ansprechpart, termine
|
||||
FROM skik_kurs, skik_doz
|
||||
WHERE ";
|
||||
|
||||
$sql2 = " ORDER BY id asc";
|
||||
$query = $sql1.$sql.$sql2;
|
||||
|
||||
$result = $db->query($query)
|
||||
or die ("Cannot execute query");
|
||||
while ($row = $result->fetch_array()){
|
||||
|
||||
$preview = kurzer_text(strip_tags($row[beschreibung]),200);
|
||||
|
||||
|
||||
|
||||
echo "<tr>
|
||||
<td>
|
||||
<h2 class=r><a class=l href=detailansicht.php?id=$row[0]><b>$row[1]) $row[bezeichnung]</b></a></h2><br>
|
||||
";if(strlen($preview) > 1){echo "$preview<br>";} echo"
|
||||
<span class=a>";if($row[Ansprechpart] != ''){ echo "<b>Ansprechpartner:</b> $row[Ansprechpart]<br>";} echo "
|
||||
";if($row[termine] != ''){ echo "<b>Termine:</b> $row[termine]<br>";} echo "</span>
|
||||
<p>
|
||||
<p>
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
echo"
|
||||
</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>
|
||||
";
|
||||
|
||||
|
||||
} // If Anweisung Action-Abfrage
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user