149 lines
4.5 KiB
PHP
Executable File
149 lines
4.5 KiB
PHP
Executable File
<?php
|
|
$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 stan_admin_rechte, stan_admin_rechte_zuord , stan_admin where stan_admin_rechte.stan_admin_rolle = stan_admin_rechte_zuord.stan_admin_rolle AND stan_admin_rechte_zuord.said = stan_admin.said AND stan_admin.user = '$user_admin' AND stan_admin_rechte_zuord.stan_admin_rolle = 'a_exausl'");
|
|
$row = $result->fetch_array();
|
|
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
|
|
// Rechteüberprüfung ende
|
|
|
|
|
|
|
|
$Use_Title = 0;
|
|
$now_date = date('m-d-Y H:i');
|
|
$title = "Dump For Table $DB_TBLName from Database $DB_DBName on $now_date";
|
|
|
|
|
|
$sql = "
|
|
SELECT t1.saaid
|
|
, w.bezeichnung
|
|
, t1.uid
|
|
, x.vorname
|
|
, x.nachname
|
|
, t1.beginn
|
|
, t1.ende
|
|
, t1.abteilung
|
|
, x.hs
|
|
, y.bez
|
|
, y.str
|
|
, y.plz
|
|
, y.postfach
|
|
, y.plz_postfach
|
|
, y.ort
|
|
, y.bundesland
|
|
, y.staat
|
|
, y.mail
|
|
FROM stan_antrag t1, stan_vertiefungsbereich w, stud x, stan_dienststellen y, stan_stellenart z
|
|
WHERE t1.uid=x.uid
|
|
AND t1.dst_id=y.dst_id
|
|
AND t1.vert_bereich=w.vbid
|
|
AND z.artid=t1.art
|
|
AND z.artid=6
|
|
AND x.Jahrgang='$jahrgang'
|
|
AND t1.status = (
|
|
SELECT MAX(t2.status)
|
|
FROM stan_antrag t2
|
|
WHERE t1.aendid = t2.aendid
|
|
AND t2.status !='2'
|
|
)
|
|
AND (t1.zuweisung is NULL OR t1.zuweisung='Z')
|
|
union
|
|
SELECT t1.saaid
|
|
, w.bezeichnung
|
|
, t1.uid
|
|
, x.vorname
|
|
, x.nachname
|
|
, t1.beginn
|
|
, t1.ende
|
|
, t1.abteilung
|
|
, x.hs
|
|
, y.bez
|
|
, y.str
|
|
, y.plz
|
|
, y.postfach
|
|
, y.plz_postfach
|
|
, y.ort
|
|
, y.bundesland
|
|
, y.staat
|
|
, NULL mail
|
|
FROM stan_antrag t1, stud x, stan_vertiefungsbereich w, stan_dienststellen_tmp y, stan_stellenart z
|
|
WHERE t1.uid=x.uid
|
|
AND t1.dst_id=y.dst_id
|
|
AND t1.vert_bereich=w.vbid
|
|
AND z.artid=t1.art
|
|
AND z.artid=6
|
|
AND x.Jahrgang='$jahrgang'
|
|
AND t1.status = (
|
|
SELECT MAX(t2.status)
|
|
FROM stan_antrag t2
|
|
WHERE t1.aendid = t2.aendid
|
|
AND t2.status !='2'
|
|
)
|
|
AND (t1.zuweisung is NULL OR t1.zuweisung='Z')
|
|
ORDER BY hs, uid, beginn
|
|
";
|
|
|
|
$result = @$db->query($sql)
|
|
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
|
|
|
|
|
|
|
|
//header info for browser
|
|
#header("Content-Type: text/comma-separated-values");
|
|
header('Content-Encoding: UTF-8');
|
|
header("Content-type: text/csv; charset=UTF-8");
|
|
echo "\xEF\xBB\xBF";
|
|
header("Content-Disposition: attachment; filename=zugew_Auslandsadressen_$jahrgang.csv"); //header("Content-Disposition: attachment; filename=database_dump.$file_ending");
|
|
header("Pragma: no-cache");
|
|
header("Expires: 0");
|
|
|
|
|
|
if ($Use_Title == 1){
|
|
echo("$title\n");
|
|
}
|
|
|
|
|
|
//define separator (defines columns in excel & tabs in word)
|
|
$sep = ";"; //tabbed character
|
|
|
|
//start of printing column names as names of MySQL fields
|
|
for ($i = 0; $i < mysqli_num_fields($result); $i++) {
|
|
echo mysqli_fetch_field_direct($result,$i)->name . ";";
|
|
}
|
|
print("\n");
|
|
//end of printing column names
|
|
|
|
//start while loop to get data
|
|
/*
|
|
note: the following while-loop was taken from phpMyAdmin 2.1.0.
|
|
--from the file "lib.inc.php".
|
|
*/
|
|
while($row = $result->fetch_array())
|
|
{
|
|
//set_time_limit(60); // HaRa
|
|
$schema_insert = "";
|
|
for($j=0; $j<mysqli_num_fields($result);$j++)
|
|
{
|
|
if(!isset($row[$j]))
|
|
$schema_insert .= "NULL".$sep;
|
|
elseif ($row[$j] != "")
|
|
$schema_insert .= "$row[$j]".$sep;
|
|
else
|
|
$schema_insert .= "".$sep;
|
|
}
|
|
$schema_insert = str_replace($sep."$", "", $schema_insert);
|
|
//following fix suggested by Josue (thanks, Josue!)
|
|
//this corrects output in excel when table fields contain \n or \r
|
|
//these two characters are now replaced with a space
|
|
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
|
|
$schema_insert .= "\t";
|
|
print(trim($schema_insert));
|
|
print "\n";
|
|
}
|
|
?>
|