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 0;
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']))return '-vname- not set!';
53 $pdata['vname']=$_REQUEST['vname'];
55 if(!isset($_REQUEST['nname']))return '-nname- not set!';
56 $pdata['nname']=$_REQUEST['nname'];
58 if(!isset($_REQUEST['gebdatum']))return '-gebdatum- not set!';
59 $pdata['gebdatum']=$_REQUEST['gebdatum'];
61 if(!isset($_REQUEST['nationaliaet']))return '-nationaliaet- not set!';
62 $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
64 if(!isset($_REQUEST['sprachen']))return '-sprachen- not set!';
65 $pdata['sprachen']=$_REQUEST['sprachen'];
67 if(!isset($_REQUEST['vorwissen']))return '-vorwissen- not set!';
68 $pdata['vorwissen']=$_REQUEST['vorwissen'];
70 if(!isset($_REQUEST['analphabet']))return '-analphabet- not set!';
71 $pdata['analphabet']=$_REQUEST['analphabet'];
73 if(!isset($_REQUEST['fotoerlaubnis']))return '-fotoerlaubnis- not set!';
74 $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
76 if(!isset($_REQUEST['videoerlaubnis']))return '-videoerlaubnis- not set!';
77 $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
79 if(!isset($_REQUEST['bemerkungen']))return '-bemerkungen- not set!';
80 $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
82 if(!isset($_REQUEST['termin']))return '-termin- not set!';
83 $pdata['termin']=$_REQUEST['termin'];
85 if(!isset($_REQUEST['status']))return '-status- not set!';
86 $pdata['status']=$_REQUEST['status'];
88 return db_store_person($_REQUEST['id'], $pdata);
92 function get_person($id){
93 if(!is_numeric($id)) return NULL;
94 return db_get_person($id);