diff --git a/registration-system/config.inc.php b/registration-system/config.inc.php index 680d71c0e9cff155cacb1b4f387a3ad082dee218..c0cf9292c350728e3cdaf2868e8f554448349824 100644 --- a/registration-system/config.inc.php +++ b/registration-system/config.inc.php @@ -46,4 +46,7 @@ $config_admins = array( "manu" => '{SHA-256}12c9b021c42741545f9f01e2afd67aa2$7112be28c0c11f987de4401798a2ba041e518bb3f22bcb8cf4f3bf3f590b65b9' // mepmepmep ); +$config_mailtag = "[FS-Fahrt] - "; +$config_baseurl = "http://fsfahrt.repke.eu/anmeldung/registration-system/"; + $config_current_fahrt_id = 2; diff --git a/registration-system/frameworks/commons.php b/registration-system/frameworks/commons.php index 98ea7ea53795d536a967e7bdd4de38c03b797f42..23c874da0dfd8b64cfd13a07fe0410e160dec1c9 100644 --- a/registration-system/frameworks/commons.php +++ b/registration-system/frameworks/commons.php @@ -40,4 +40,37 @@ function comm_generate_key($db_handle, $table, $col, $conditions){ if($db_handle->has($table, array("AND"=>$conditions))) goto again; comm_verbose(2,"generated hex: ".$hex); return $hex; +} + +/* + * sends mail + * + * first line of $cont is used as subject iff terminated by double backslash (\\) + * note that there should be no "\\" anywhere else in the string!!! + * + * returns true/false depending on success + */ +function comm_send_mail($db_handle, $addr, $cont, $from = NULL){ + global $config_current_fahrt_id, $config_mailtag; + if(is_null($from)) + $from = $db_handle->get("fahrten", "kontakt", array("fahrt_id"=>$config_current_fahrt_id)); + + $subj = "Wichtige Information"; + $mess = $cont; + $tmp = explode("\\\\", $cont); + if(count($tmp)>1){ + $subj = $tmp[0]; + $mess = $tmp[1]; + } + + $headers = 'From: ' . $from . "\r\n" . + 'Reply-To: ' . $from. "\r\n" . + 'X-Mailer: PHP/' . phpversion(); + + return mail($addr, $config_mailtag.$subj, $mess, $headers); +} + +function comm_get_lang($lang, $replace){ + global $$lang; + return str_replace(array_keys($replace), array_values($replace), $$lang); } \ No newline at end of file diff --git a/registration-system/index.php b/registration-system/index.php index 2d5930b35cc3f4733f0980cc24aef71e855cd535..154e431643e6bfba23103cced870065eb73e8abd 100644 --- a/registration-system/index.php +++ b/registration-system/index.php @@ -4,6 +4,7 @@ error_reporting(E_ALL || E_STRICT); require 'config.inc.php'; require 'frameworks/medoo.php'; require 'frameworks/commons.php'; +require 'lang.php'; $index_db = new medoo(array( @@ -69,10 +70,14 @@ function index_show_content(){ * @param $data */ function index_form_to_db($data){ - global $index_db; + global $index_db, $config_baseurl, $lang_regmail, $config_current_fahrt_id; $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); + $from = $index_db->get("fahrten", array("kontakt","leiter"), array("fahrt_id"=>$config_current_fahrt_id)); + $mail = comm_get_lang("lang_regmail", array( "{{url}}" => $config_baseurl."status.php?hash=".$data['bachelor_id'], + "{{organisator}}" => $from['leiter'])); + comm_send_mail($index_db, $data['mehl'], $mail, $from['kontakt']); } /** diff --git a/registration-system/lang.php b/registration-system/lang.php new file mode 100644 index 0000000000000000000000000000000000000000..e945633b26693d6756f9f09c7563d6df85f0d2eb --- /dev/null +++ b/registration-system/lang.php @@ -0,0 +1,21 @@ +<?php +/** + * Created by PhpStorm. + * User: tim + * Date: 8/16/14 + * Time: 5:02 PM + */ + +$lang_regmail = " +Deine Anmeldung zur Fachschaftsfahrt\\\\ +Hallo! +Vielen Dank für die Anmeldung bei der Fachschaftsfahrt. Den Status der Anmeldung kannst Du jederzeit auf folgender Seite überprüfen: +{{url}} + +Weitere Informationen werden wir an diese E-Mail-Adresse senden, also bitte regelmäßig lesen und bei Fragen einfach fragen :-) + +Viele Grüße, +{{organisator}}! +"; + +?> \ No newline at end of file