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');
10 require_once('./html_funcs.php');
13 if(!isset($_SERVER['HTTPS'])){
14 $url = 'https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
15 header('Location: '.$url, true, 301);
16 exit('<h1>Redirecting to: <a href="'.$url.'">'.$url.'</a></h1>');
18 $uinfo = db_get_uinfo($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
19 if($uinfo['lvl'] >= 1){
20 $GLOBALS['uname'] = $uinfo['uname'];
21 $GLOBALS['lvl'] = $uinfo['lvl'];
23 header('WWW-Authenticate: Basic realm="WelcomeTUcode login"');
24 header('HTTP/1.0 401 Unauthorized');
25 exit('Nicht eingeloggt. Falsche Anmeldedaten?');
29 function list_anmeldungen(){
30 $liste = db_list_anmeldungen();
31 $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>'.
32 '<th>Nationalität</th><th>Sprachkenntnis</th><th>Vorwissen</th><th>Analphabet</th><th>fotoerlaubnis</th><th>Videoerlaubnis</th>'.
33 '<th>Status</th><th>Bemerkung</th><th>Termin</th></tr>'."\n";
34 foreach ($liste as &$person) {
35 $ret .='<tr id="pers_'.$person['id'].'"><td><a href="./person.php?id='.$person['id'].'">Bearbeiten</a></td><td>'.$person['id'].'</td>';
36 $ret .='<td>'.$person['uname'].'</td><td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td><nobr>'.$person['gebdatum'].'</nobr></td>';
37 $ret .='<td>'.$person['nationaliaet'].'</td><td>'.$person['sprachen'].'</td><td>'.$person['vorwissen'].'</td><td>'.$person['analphabet'].'</td>';
38 $ret .='<td>'.$person['fotoerlaubnis'].'</td><td>'.$person['videoerlaubnis'].'</td><td>'.$person['status'].'</td><td>'.$person['bemerkungen'].'</td>';
39 $ret .='<td>'.$person['termin'].'</td></tr>'."\n";
41 return $ret.'</table>'."\n";
44 function store_person(){
45 if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save']))return;
47 //var_export($_REQUEST);
49 if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
50 if(isset($_REQUEST['save'])){
52 if(!isset($_REQUEST['vname']))throw new Exception('NOT_SET vname');
53 $pdata['vname']=$_REQUEST['vname'];
55 if(!isset($_REQUEST['nname']))throw new Exception('NOT_SET nname');
56 $pdata['nname']=$_REQUEST['nname'];
58 if($pdata['vname'] == '' && $pdata['nname'] == '')throw new Exception('NO_NAME');
60 if(!isset($_REQUEST['gebdatum']))throw new Exception('NOT_SET gebdatum');
61 $pdata['gebdatum']=$_REQUEST['gebdatum'];
63 if(!isset($_REQUEST['nationaliaet']))throw new Exception('NOT_SET nationalitaet');
64 $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
66 if(!isset($_REQUEST['sprachen']))throw new Exception('NOT_SET sprachen');
67 $pdata['sprachen']=$_REQUEST['sprachen'];
69 if(!isset($_REQUEST['vorwissen']))throw new Exception('NOT_SET vorwissen');
70 $pdata['vorwissen']=$_REQUEST['vorwissen'];
72 if(!isset($_REQUEST['analphabet']))$_REQUEST['analphabet'] = '0';
73 $pdata['analphabet']=$_REQUEST['analphabet'];
75 if(!isset($_REQUEST['fotoerlaubnis']))$_REQUEST['fotoerlaubnis'] = '0';
76 $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
78 if(!isset($_REQUEST['videoerlaubnis']))$_REQUEST['videoerlaubnis'] = '0';
79 $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
81 if(!isset($_REQUEST['bemerkungen']))throw new Exception('NOT_SET bemerkungen');
82 $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
84 if(!isset($_REQUEST['termin']))throw new Exception('NOT_SET termin');
85 $pdata['termin']=$_REQUEST['termin'];
87 if(!isset($_REQUEST['status']))throw new Exception('NOT_SET status');
88 $pdata['status']=$_REQUEST['status'];
90 return db_store_person($_REQUEST['id'], $pdata);
94 function get_person($id){
95 if(!is_numeric($id)) return NULL;
96 return db_get_person($id);