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><th>Nationalität</th><th>Sprachkenntnis</th>'.
32 '<th>Vorwissen</th><th>Analphabet</th><th>fotoerlaubnis</th><th>Videoerlaubnis</th><th>Bemerkung</th></tr>'."\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><td>'.$person['uname'].'</td>'.
35 '<td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td>'.$person['gebdatum'].'</td><td>'.$person['nationaliaet'].'</td>'.
36 '<td>'.$person['sprachen'].'</td><td>'.$person['vorwissen'].'</td><td>'.$person['analphabet'].'</td><td>'.$person['fotoerlaubnis'].'</td>'.
37 '<td>'.$person['videoerlaubnis'].'</td><td>'.$person['bemerkungen'].'</td></tr>'."\n";
38 /* echo '<div class="person" id="pers_'.$person['id'].'" style="border:1px solid black;"><div id="pers_'.$person['id'].'_vname">'.$person['vname'].'</div>
39 <div id="pers_'.$person['id'].'_nname">'.$person['nname'].'</div> <div id="pers_'.$person['id'].'_gebdatum">'.$person['gebdatum'].'</div>
40 <div id="pers_'.$person['id'].'_nationaliaet">'.$person['nationaliaet'].'</div> <div id="pers_'.$person['id'].'_sprachen">'.$person['sprachen'].'</div>
41 <div id="pers_'.$person['id'].'_vorwissen">'.$person['vorwissen'].'</div> <div id="pers_'.$person['id'].'_analphabet">'.$person['analphabet'].'</div>
42 <div id="pers_'.$person['id'].'_fotoerlaubnis">'.$person['fotoerlaubnis'].'</div> <div id="pers_'.$person['id'].'_videoerlaubnis">'.$person['videoerlaubnis'].'</div>
43 <div class="bemerkung" id="pers_'.$person['id'].'_bemerkungen">'.$person['bemerkungen'].'</div>
46 return $ret.'</table>'."\n";
49 function store_person(){
50 if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save'])) return 0;
52 //var_export($_REQUEST);
54 if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
55 if(isset($_REQUEST['save'])){
57 if(!isset($_REQUEST['vname']))return '-vname- not set!';
58 $pdata['vname']=$_REQUEST['vname'];
60 if(!isset($_REQUEST['nname']))return '-nname- not set!';
61 $pdata['nname']=$_REQUEST['nname'];
63 if(!isset($_REQUEST['gebdatum']))return '-gebdatum- not set!';
64 $pdata['gebdatum']=$_REQUEST['gebdatum'];
66 if(!isset($_REQUEST['nationaliaet']))return '-nationaliaet- not set!';
67 $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
69 if(!isset($_REQUEST['sprachen']))return '-sprachen- not set!';
70 $pdata['sprachen']=$_REQUEST['sprachen'];
72 if(!isset($_REQUEST['vorwissen']))return '-vorwissen- not set!';
73 $pdata['vorwissen']=$_REQUEST['vorwissen'];
75 if(!isset($_REQUEST['analphabet']))return '-analphabet- not set!';
76 $pdata['analphabet']=$_REQUEST['analphabet'];
78 if(!isset($_REQUEST['fotoerlaubnis']))return '-fotoerlaubnis- not set!';
79 $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
81 if(!isset($_REQUEST['videoerlaubnis']))return '-videoerlaubnis- not set!';
82 $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
84 if(!isset($_REQUEST['bemerkungen']))return '-bemerkungen- not set!';
85 $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
87 return db_store_person($_REQUEST['id'], $pdata);
91 function get_person($id){
92 if(!is_numeric($id)) return NULL;
93 return db_get_person($id);