Skip to content
Snippets Groups Projects
Commit 439c93d8 authored by Tim Repke's avatar Tim Repke
Browse files

now registrationform is working, some bugfixes needed, no proper functionality test yet

parent 7e43e962
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
// https://repke.eu:8443
// passwort manu:kuzerPenis666!
$config_verbose_level = 2; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose
$config_verbose_level = 3; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose
$config_db = array(
"name" => "fsfahrt",
......
......@@ -20,4 +20,24 @@ function comm_format_date($date){
function comm_get_possible_dates($fid){
return array("12.03.2014","13.03.2014","14.03.2014");
}
function comm_isopen_fid($db_handle, $fid){
comm_verbose(3,"checking if fid ". $fid . " is open");
return $db_handle->has("fahrten", array(
"AND" => array(
"fahrt_id"=>$fid,
"regopen"=>1)));
}
function comm_generate_key($db_handle, $table, $col, $conditions){
again:
$bytes = openssl_random_pseudo_bytes(8);
$hex = bin2hex($bytes);
comm_verbose(3,"generated hex for test: ".$hex);
$conditions[$col] = $hex;
if($db_handle->has($table, array("AND"=>$conditions))) goto again;
comm_verbose(2,"generated hex: ".$hex);
return $hex;
}
\ No newline at end of file
......@@ -43,10 +43,12 @@ function index_show_content(){
// --- Formular
if(isset($_REQUEST['submit'])){ // Formular auswerten
comm_verbose(1,"Formular bekommen");
index_check_form();
} elseif(isset($_REQUEST['bid'])){ // Änderungsformular anzeigen TODO: Anmeldung noch offen?
$data = index_check_form();
if(!is_null($data))
index_form_to_db($data);
} /*elseif(isset($_REQUEST['bid'])){ // Änderungsformular anzeigen, Anmeldung noch offen?
index_show_formular($fid, $_REQUEST['bid']);
} else { // leeres Formular anzeigen
} */ else { // leeres Formular anzeigen
index_show_formular($fid);
}
......@@ -61,6 +63,13 @@ function index_show_content(){
}
function index_form_to_db($data){
global $index_db;
$data['version'] = 1;
$data['bachelor_id'] = comm_generate_key($index_db, "bachelor", "bachelor_id", array('fahrt_id'=>$data['fahrt_id']));
$index_db->insert("bachelor", $data);
}
/**
* validates the sent form
* on failure: repost form with prefilled data and errors
......@@ -68,10 +77,17 @@ function index_show_content(){
*
*/
function index_check_form(){
global $config_studitypen, $config_essen, $config_reisearten;
global $config_studitypen, $config_essen, $config_reisearten, $index_db;
$errors = array();
$data = array();
$fid = $_REQUEST['fid'];
$data = array();
$data['fahrt_id'] = $fid;
if(!comm_isopen_fid($index_db, $fid)){
$errors = array("Ungültige Fahrt!");
goto index_check_form_skip;
}
$possible_dates = comm_get_possible_dates($fid);
index_check_field('forname', '/^[a-zA-Z]{2,50}$/', $data, $errors, "Fehlerhafter oder fehlender Vorname!");
......@@ -88,12 +104,13 @@ function index_check_form(){
index_check_field('virgin', array("Ja","Nein"), $data, $errors, 'Bitte Altersbereich wählen!');
index_check_field('comment', "comment", $data, $errors, 'Trollololol');
index_check_form_skip:
if(count($errors)>0){
index_show_errors($errors);
index_show_formular($fid, NULL, $data);
return NULL;
} else {
// put in DB
return $data;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment