4 * welcome.TU.code Anmeldesystem.
5 * by Jan Vales <jan@jvales.net> (aka. Someone <someone@somenet.org>)
8 require_once('./settings.php');
9 require_once('./db_funcs.php');
12 // if(!isset($_SERVER['HTTPS'])){
13 // $url = 'https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
14 // header('Location: '.$url, true, 301);
15 // exit('<h1>Redirecting to: <a href="'.$url.'">'.$url.'</a></h1>');
17 $uinfo = db_get_uinfo($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
18 if($uinfo['lvl'] >= 1){
19 $GLOBALS['uname'] = $uinfo['uname'];
20 $GLOBALS['lvl'] = $uinfo['lvl'];
22 header('WWW-Authenticate: Basic realm="WelcomeTUcode login"');
23 header('HTTP/1.0 401 Unauthorized');
24 exit('Nicht eingeloggt. Falsche Anmeldedaten?');
28 function list_anmeldungen(){
29 $liste = db_list_anmeldungen();
30 $ret = '<table border=1 class="sortable"><tr><th>Aktion</th><th>id</th><th>Anmeldung bei</th><th>Nachname(n)</th><th>Vorname(n)</th><th>Geboren</th><th>Nationalität</th><th>Sprachkenntnis</th>'.
31 '<th>Vorwissen</th><th>Analphabet</th><th>fotoerlaubnis</th><th>Videoerlaubnis</th><th>Bemerkung</th></tr>'."\n";
32 foreach ($liste as &$person) {
33 $ret .='<tr id="pers_'.$person['id'].'"><td><a href="./person.php?id='.$person['id'].'">Bearbeiten</a></td><td>'.$person['id'].'</td><td>'.$person['uname'].'</td>'.
34 '<td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td>'.$person['gebdatum'].'</td><td>'.$person['nationaliaet'].'</td>'.
35 '<td>'.$person['sprachen'].'</td><td>'.$person['vorwissen'].'</td><td>'.$person['analphabet'].'</td><td>'.$person['fotoerlaubnis'].'</td>'.
36 '<td>'.$person['videoerlaubnis'].'</td><td>'.$person['bemerkungen'].'</td></tr>'."\n";
37 /* echo '<div class="person" id="pers_'.$person['id'].'" style="border:1px solid black;"><div id="pers_'.$person['id'].'_vname">'.$person['vname'].'</div>
38 <div id="pers_'.$person['id'].'_nname">'.$person['nname'].'</div> <div id="pers_'.$person['id'].'_gebdatum">'.$person['gebdatum'].'</div>
39 <div id="pers_'.$person['id'].'_nationaliaet">'.$person['nationaliaet'].'</div> <div id="pers_'.$person['id'].'_sprachen">'.$person['sprachen'].'</div>
40 <div id="pers_'.$person['id'].'_vorwissen">'.$person['vorwissen'].'</div> <div id="pers_'.$person['id'].'_analphabet">'.$person['analphabet'].'</div>
41 <div id="pers_'.$person['id'].'_fotoerlaubnis">'.$person['fotoerlaubnis'].'</div> <div id="pers_'.$person['id'].'_videoerlaubnis">'.$person['videoerlaubnis'].'</div>
42 <div class="bemerkung" id="pers_'.$person['id'].'_bemerkungen">'.$person['bemerkungen'].'</div>
45 return $ret.'</table>'."\n";
48 function store_person(){
49 if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save'])) return 0;
51 //var_export($_REQUEST);
53 if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
54 if(isset($_REQUEST['save'])){
56 if(!isset($_REQUEST['vname']))return '-vname- not set!';
57 $pdata['vname']=$_REQUEST['vname'];
59 if(!isset($_REQUEST['nname']))return '-nname- not set!';
60 $pdata['nname']=$_REQUEST['nname'];
62 if(!isset($_REQUEST['gebdatum']))return '-gebdatum- not set!';
63 $pdata['gebdatum']=$_REQUEST['gebdatum'];
65 if(!isset($_REQUEST['nationaliaet']))return '-nationaliaet- not set!';
66 $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
68 if(!isset($_REQUEST['sprachen']))return '-sprachen- not set!';
69 $pdata['sprachen']=$_REQUEST['sprachen'];
71 if(!isset($_REQUEST['vorwissen']))return '-vorwissen- not set!';
72 $pdata['vorwissen']=$_REQUEST['vorwissen'];
74 if(!isset($_REQUEST['analphabet']))return '-analphabet- not set!';
75 $pdata['analphabet']=$_REQUEST['analphabet'];
77 if(!isset($_REQUEST['fotoerlaubnis']))return '-fotoerlaubnis- not set!';
78 $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
80 if(!isset($_REQUEST['videoerlaubnis']))return '-videoerlaubnis- not set!';
81 $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
83 if(!isset($_REQUEST['bemerkungen']))return '-bemerkungen- not set!';
84 $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
86 return db_store_person($_REQUEST['id'], $pdata);
90 function get_person($id){
91 if(!is_numeric($id)) return NULL;
92 return db_get_person($id);
95 function html_top($title = ""){
98 <html lang="de" dir="ltr">
100 <meta charset="utf-8">
101 <title>$title</title>
102 <link rel="stylesheet" href="style.css">
103 <script src="sorttable.js"></script>
105 <body id="welcometucode">
109 function html_bottom(){