1 <?php define('FUNCS_PATH', __DIR__);
3 * welcome.TU.code Anmeldesystem.
4 * by Jan Vales <jan@jvales.net> (aka. Someone <someone@somenet.org>)
7 require_once(FUNCS_PATH.'/settings.php');
8 require_once(FUNCS_PATH.'/db_funcs.php');
9 require_once(FUNCS_PATH.'/html_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(html_top("Anmeldesystem").html_linkbox().'<span class="statusERR">Nicht eingeloggt. Falsche Anmeldedaten?</span>'.html_bottom());
28 function list_anmeldungen(){
29 $liste = db_list_anmeldungen();
30 $ret = '<table id="sortable"><thead><tr><th>Aktion</th><th>id</th><th>Anmeldung bei</th><th>Nachname(n)</th><th>Vorname(n)</th><th>Geboren</th>'.
31 '<th>Nationalität</th><th>Sprachkenntnis</th><th>Vorwissen</th><th>Analphabet</th><th>Gruppen-</th><th>Foto-</th><th>Videoerlaubnis</th>'.
32 '<th>Status</th><th>Bemerkung</th><th>Termin</th></tr></thead><tbody>'."\n";
33 foreach ($liste as &$person) {
34 $ret .='<tr id="pers_'.$person['id'].'"><td><a href="./person.php?id='.$person['id'].'">Bearbeiten</a></td><td>'.$person['id'].'</td>';
35 $ret .='<td>'.$person['uname'].'</td><td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td><nobr>'.$person['gebdatum'].'</nobr></td>';
36 $ret .='<td>'.$person['nationaliaet'].'</td><td>'.$person['sprachen'].'</td><td>'.$person['vorwissen'].'</td><td>'.$person['analphabet'].'</td>';
37 $ret .='<td>'.$person['gruppenfotoerlaubnis'].'</td><td>'.$person['fotoerlaubnis'].'</td><td>'.$person['videoerlaubnis'].'</td>';
38 $ret .='<td>'.$person['status'].'</td><td>'.$person['bemerkungen'].'</td><td>'.$person['termin'].'</td></tr>'."\n";
40 return $ret.'</tbody></table>'."\n";
43 function store_person(){
44 if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save']))return;
46 //var_export($_REQUEST);
48 if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
49 if(isset($_REQUEST['save'])){
51 if(!isset($_REQUEST['vname']))throw new Exception('NOT_SET vname');
52 $pdata['vname']=$_REQUEST['vname'];
54 if(!isset($_REQUEST['nname']))throw new Exception('NOT_SET nname');
55 $pdata['nname']=$_REQUEST['nname'];
57 if($pdata['vname'] == '' && $pdata['nname'] == '')throw new Exception('NO_NAME');
59 if(!isset($_REQUEST['gebdatum']))throw new Exception('NOT_SET gebdatum');
60 $pdata['gebdatum']=$_REQUEST['gebdatum'];
62 if(!isset($_REQUEST['nationaliaet']))throw new Exception('NOT_SET nationalitaet');
63 $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
65 if(!isset($_REQUEST['sprachen']))throw new Exception('NOT_SET sprachen');
66 $pdata['sprachen']=$_REQUEST['sprachen'];
68 if(!isset($_REQUEST['vorwissen']))throw new Exception('NOT_SET vorwissen');
69 $pdata['vorwissen']=$_REQUEST['vorwissen'];
71 if(!isset($_REQUEST['analphabet']))$_REQUEST['analphabet'] = '0';
72 $pdata['analphabet']=$_REQUEST['analphabet'];
74 if(!isset($_REQUEST['fotoerlaubnis']))$_REQUEST['fotoerlaubnis'] = '0';
75 $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
77 if(!isset($_REQUEST['gruppenfotoerlaubnis']))$_REQUEST['gruppenfotoerlaubnis'] = '0';
78 $pdata['gruppenfotoerlaubnis']=$_REQUEST['gruppenfotoerlaubnis'];
80 if(!isset($_REQUEST['videoerlaubnis']))$_REQUEST['videoerlaubnis'] = '0';
81 $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
83 if(!isset($_REQUEST['bemerkungen']))throw new Exception('NOT_SET bemerkungen');
84 $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
86 if(!isset($_REQUEST['termin']))throw new Exception('NOT_SET termin');
87 $pdata['termin']=$_REQUEST['termin'];
89 if(!isset($_REQUEST['status']))throw new Exception('NOT_SET status');
90 $pdata['status']=$_REQUEST['status'];
92 return db_store_person($_REQUEST['id'], $pdata);
96 function get_person($id){
97 if(!is_numeric($id)) return NULL;
98 return db_get_person($id);