Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : form_generator_sd - Con 4.10
* Author(s) : Seamless-Design Markus Hübner
* Copyright : Markus Hübner
* Created : 03/2019
* modified : 09/2019: improved behaviour of form if it is a multipage one: button to send form and anti-spam will only be shown on last page
* modified : 04/2020: added functionality for choosing send_from_name and send_from_email from information in form, if name of variable in article configuration is set to send_from_name and send_from_email
************************************************/
/*
######## README ########
# fieldtypes:
if you want to add new fieldtypes, you will have to look at ########## checking for errors begin ########## and ########## displaying form begin ##########
# sending mails:
some hosters don't allow sending mails with "from-adresses" that are not located on the same server to provide spam. in this case, make your changes in variable $send_from_name and $send_from_email within settings
# smtp
if you want to use smtp as sendmethod instead of mail(), you have to set $use_smtp="true"; within settings. contenido then will check for the information within the "mailserver"-section you'll find in contenido backend via "administration -> system -> configuration". ask your provider for the needed data. at the current state of development, the entered data for the name and email of the sender is not read. therefor you'll have to fill in this information within the settings section of this module!
# send_from_name and send_from_email
for sending the email normally the data you set via $send_from_name and $send_from_email at the beginning of the settings-section in module output will be taken. if you prefer that the information that is given within form from your users is taken, you just have to change the name for the variables in article configuration tab from name to send_from_name and email to send_from_email. please be aware, that not all providers allow to use this option due to spam protection.
########################
*/
/********** settings begin **********/
$send_from_name=""; // if this is set to =""; the original name entered in form by the user will be taken
$send_from_email=""; // if this is set to =""; the original mail-address entered in form by the user will be taken
$use_smtp="true"; // set to "false" to use old mail()-function.
$content_type="text/html"; // 'text/html' or 'text/plain' - only used when $use_smtp is set to "true"
$attachment_allowed="CMS_VALUE[300]";
$html5_functions="CMS_VALUE[700]";
$show_page_steps="CMS_VALUE[800]";
$show_data_in_success_note="CMS_VALUE[900]";
$separator_page_step_info=mi18n("output separator page step info");
/*
jpg: jpg
jpeg: jpeg
bmp: bmp
zip: octet-stream
doc: msword
docx: vnd.openxmlformats-officedocument.wordprocessingml.document
xls: plain
xlsx: vnd.openxmlformats-officedocument.spreadsheetml.sheet
*/
$array_allowed_filetypes=array('jpg','jpeg','gif','png','bmp','pdf','octet-stream','doc','plain');
$array_allowed_filetypes_hint=array('jpg','jpeg','gif','png','bmp','pdf','zip','doc','xls');
$allowed_filetypes_hint_form="";
foreach($array_allowed_filetypes_hint AS $element) $allowed_filetypes_hint_form.='<span class="allowed_filetypes">'.$element.'</span> ';
$filesize_max="CMS_VALUE[400]"*1;
$max_attach_size_hint=$filesize_max/1000000;
$anti_spam="CMS_VALUE[500]";
$amount_countchas=8;
$countcha_1="upload/module/form_generator_sd/countcha_1.png";
$countcha_2="upload/module/form_generator_sd/countcha_2.png";
$countcha_3="upload/module/form_generator_sd/countcha_3.png";
$name_countcha_1=mi18n("output form countcha 1 name");
$name_countcha_2=mi18n("output form countcha 2 name");
$name_countcha_3=mi18n("output form countcha 3 name");
$placeholder_select_something="--- ? ---";
$arr_search=array('ä','ö','ü','Ä','Ö','Ü','ß');
$arr_replace=array('ä','ö','ü','Ä','Ö','Ü','ß');
/********** settings end **********/
/*
###0 type***1 fieldname***2 mandatory***3 name***4 class***5 value***6 size***7 beschreibung***8 additional***9 error message
maximum 1 attachment possible, name hast to be "attachment"
*/
$fields="CMS_VALUE[600]";
echo '<a name="startform"></a>';
if(isset($_POST['form_submitted']) && !empty($_POST['form_submitted']))
{
$form_submitted=htmlspecialchars(strip_tags($_POST['form_submitted']));
}
else $form_submitted="";
$array_fields=explode('###',$fields);
unset($array_fields[0]);
//print_r($array_fields);
$array_field_names=array();
$array_field_names_mail_body_success_info=array();
$amount_of_pages=0;
$array_considered_form_fields=array();
foreach($array_fields AS $field)
{
$array_field_parts=explode('+++',$field);
foreach($array_field_parts AS $part)
{
$array_field_parts_elements=explode('***',$part);
if($array_field_parts_elements[0]=="type_page_begin") $amount_of_pages++;
//0: type / 1: fieldname / 2: mandatory / 3: name / 4: class / 5: value / 6: size / 7: description / 8: additional / 9: error message
if(!in_array($array_field_parts_elements[3],$array_considered_form_fields) OR $array_field_parts_elements[3]=="none")
{
$array_considered_form_fields[]=$array_field_parts_elements[3];
$array_field_names[]=array($array_field_parts_elements[3],$array_field_parts_elements[0],$array_field_parts_elements[2],$array_field_parts_elements[9],$array_field_parts_elements[1],$array_field_parts_elements[8],$array_field_parts_elements[5]);
$array_field_names_mail_body_success_info[]=$array_field_parts_elements[1];
}
}
}
$field_content_counter=1;
if($form_submitted!="")
{
/*########## checking for errors begin ##########*/
$mail_body='<table>';
$mail_body_plain_text="";
$success_info='<div class="box_success_info">';
$i=1;
$amount_of_fields=count($array_field_names);
foreach($array_field_names AS $field)
{
/* formatting and adding data for mail_body and success_info after sending form successfully begin */
if(is_array($_POST[$field[0]]))
{
${'value_'.$field[0]}=$_POST[$field[0]];
if(${'value_'.$field[0]}[0]==$placeholder_select_something) ${'value_'.$field[0]}="";
$array_temp=array();
foreach(${'value_'.$field[0]} AS $element) $array_temp[]=htmlspecialchars(strip_tags($element));
${'value_'.$field[0]}=$array_temp;
}
else ${'value_'.$field[0]}=htmlspecialchars(strip_tags($_POST[$field[0]]));
if(${'value_'.$field[0]}==$placeholder_select_something) ${'value_'.$field[0]}="";
if(is_array(${'value_'.$field[0]}))
{
$field_value="";
foreach(${'value_'.$field[0]} AS $field_value_part) $field_value.="* ".$field_value_part.'<br/>';
}
else $field_value=str_replace($arr_search,$arr_replace,${'value_'.$field[0]});
if($field[1]=="type_file")
{
$field_value=$_FILES[$field[0]]['name'];
}
if(${'value_'.$field[0]}!="" OR $field[1]=="type_file")
{
$mail_body.='<tr><td><b>'.str_replace($arr_search,$arr_replace,$field[4]).'</b></td><td>'.nl2br($field_value).'</td></tr>';
$mail_body_plain_text.=str_replace($arr_search,$arr_replace,$field[4]).': '.nl2br($field_value).'\r\n';
if($field[1]=="type_password") $field_value='*********';
$success_info.='<div class="box_success_info_row"><div';
if($i==1) $success_info.=' class="box_success_info_row_s1_z1_ueb"';
if($i!=1 AND $i<$amount_of_fields) $success_info.=' class="box_success_info_row_s1_zx_ueb"';
if($i==$amount_of_fields) $success_info.=' class="box_success_info_row_s1_zende_ueb"';
$success_info.='>'.str_replace($arr_search,$arr_replace,$field[4]).'</div><div class="box_success_info_data">'.nl2br($field_value).'</div></div>';
}
if($field[1]=="type_separator")
{
$mail_body.='<tr><td colspan="2"><b>'.str_replace($arr_search,$arr_replace,$field[4]).'</b></td></tr>';
$mail_body_plain_text.='\r\n'.str_replace($arr_search,$arr_replace,$field[4]).'\r\n';
$success_info.='<div class="box_success_info_row"><div';
if($i==1) $success_info.=' class="box_success_info_row_separator"';
if($i!=1 AND $i<$amount_of_fields) $success_info.=' class="box_success_info_row_separator"';
if($i==$amount_of_fields) $success_info.=' class="box_success_info_row_separator"';
$success_info.='>'.str_replace($arr_search,$arr_replace,$field[4]).'</div></div>';
}
/* formatting and adding data for mail_body and success_info after sending form successfully end */
// RADIO
if($field[1]=="type_radio" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
// CHECKBOX
if($field[1]=="type_checkbox" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
// SELECT SINGLE
if($field[1]=="type_select_single" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
// SELECT MULTI
if($field[1]=="type_select_multi" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
// TEXT
if($field[1]=="type_text" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
if($field[1]=="type_text" AND $field[0]=="send_from_name") $send_from_name=${'value_'.$field[0]};
// NUMBER
if($field[1]=="type_number")
{
if(${'value_'.$field[0]}=="" AND $field[2]=="true")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
if(!empty(${'value_'.$field[0]}))
{
if(!is_numeric(${'value_'.$field[0]}))
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
else
{
if($field[5]!="none")
{
$array_min_max=explode('|',$field[5]);
if(${'value_'.$field[0]}*1<$array_min_max[0] OR ${'value_'.$field[0]}*1>$array_min_max[1])
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
}
}
}
// DATE
if($field[1]=="type_date" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
if(!empty(${'value_'.$field[0]}))
{
$timestamp=strtotime(${'value_'.$field[0]});
if($timestamp=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
}
// EMAIL
if($field[1]=="type_email")
{
if(${'value_'.$field[0]}=="" AND $field[2]=="true")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
if(!empty(${'value_'.$field[0]}))
{
$mail_expr = "/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/";
if (!preg_match($mail_expr, ${'value_'.$field[0]}) )
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
else
{
if($field[0]=="send_from_email") $send_from_email=${'value_'.$field[0]};
}
}
}
// PASSWORD
if($field[1]=="type_password" AND $field[2]=="true")
{
if(${'value_'.$field[0]}=="")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
if($field[1]=="type_password")
{
if(!empty(${'value_'.$field[0]}))
{
if(strlen(${'value_'.$field[0]}) < 6)
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
}
// TEXTAREA
if($field[1]=="type_textarea")
{
if(${'value_'.$field[0]}=="" AND $field[2]=="true")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
// FILE
if($field[1]=="type_file")
{
$array_filetype=explode('/',$_FILES[$field[0]]['type']);
$filetype=strtolower($array_filetype[1]);
$filesize=$_FILES[$field[0]]['size'];
if($filetype=="" AND $field[2]=="true")
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
if($filetype!="")
{
if(!in_array($filetype,$array_allowed_filetypes))
{
$string_allowed_filetypes="";
foreach($array_allowed_filetypes_hint AS $element) $string_allowed_filetypes.=$element." "; // building error hint from array of allowed filetypes
$array_errors[]=mi18n("output em filetype not allowed")." ".$string_allowed_filetypes;
$string_error_ids.="attachment;";
}
if($filesize>$filesize_max)
{
$array_errors[]=mi18n("output em filesize too big");
$string_error_ids.="attachment;";
}
}
}
// RANGE
if($field[1]=="type_range" AND $field[2]=="true")
{
if(${'value_'.$field[0]}<$field[6])
{
$array_errors[]=$field[3];
$string_error_ids.=$field[0].';';
}
}
$i++;
}
$mail_body.='</table>';
$success_info.='</div>';
// ANTI SPAM
if($anti_spam=="true")
{
if($countcha!=$countcha_to_prove_amount)
{
$array_errors[]=mi18n("output em amount of countchas not correct");
$string_error_ids.="countcha;";
}
}
/* showing error messages begin */
if(count($array_errors)>1) $array_errors=array_unique($array_errors);
if(count($array_errors)==0) $no_errors="true";
else
{
$no_errors="false";
echo '<p class="formular_fehlermeldungen">'.mi18n("output em there are errors");
echo '<ul class="formular_fehlermeldungen">';
foreach($array_errors AS $element) echo '<li>'.$element.'</li>';
echo '</ul></p>';
}
/* showing error messages end */
/*########## checking for errors end ##########*/
}
/*################################*/
/*########## displaying form begin ##########*/
/*################################*/
if($form_submitted=="" OR $no_errors=="false")
{
echo '<form method="post" action="front_content.php?idart='.$idart.'#startform" enctype="multipart/form-data">';
echo '<div class="box_form">';
$row_counter=1;
$rows_overall=count($array_fields);
foreach($array_fields AS $field)
{
$class_td_separator="box_form_row_separator";
if($row_counter==1)
{
$class_td_head="box_form_row_s1_z1_ueb";// nowrap";
}
elseif($row_counter<$rows_overall)
{
$class_td_head="box_form_row_s1_zx_ueb";// nowrap";
}
if($row_counter==$rows_overall)
{
$class_td_head="box_form_row_s1_zende_ueb";// nowrap";
}
//PAGE BEGIN
if (strpos($field, 'type_page_begin***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_page" id="form_page_'.$array_field_to_show[5].'">';
echo '<div class="box_form_row"><div class="box_form_row_page_begin">';
echo $array_field_to_show[1];
if($show_page_steps=="true") echo '<span class="page_step_info">'.$array_field_to_show[5].$separator_page_step_info.$amount_of_pages.'</span>';
echo '</div></div>';
echo '<script type="text/javascript">show_hide_form_page("initial",'.$array_field_to_show[5].','.$amount_of_pages.',"form_page_'.$array_field_to_show[5].'");</script>';
}
//PAGE END
if (strpos($field, 'type_page_end***') !== false)
{
$array_field_to_show=explode('***',$field);
$array_buttons=explode('|',$array_field_to_show[8]);
echo '<div class="box_form_row"><div class="box_form_row_page_end">';
if($array_field_to_show[5]==$amount_of_pages)
{
if($array_buttons[0]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[0].'" onclick="document.getElementById(\'anti_spam_and_submit\').style.display=\'none\';show_hide_form_page(\'previous\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
if($array_buttons[1]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[1].'" onclick="show_hide_form_page(\'next\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
}
if($array_field_to_show[5]==$amount_of_pages-1)
{
if($array_buttons[0]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[0].'" onclick="show_hide_form_page(\'previous\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
if($array_buttons[1]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[1].'" onclick="document.getElementById(\'anti_spam_and_submit\').style.display=\'block\';show_hide_form_page(\'next\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
}
if($array_field_to_show[5]<$amount_of_pages-1)
{
if($array_buttons[0]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[0].'" onclick="show_hide_form_page(\'previous\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
if($array_buttons[1]!="-") echo '<input type="button" class="submit paging" value="'.$array_buttons[1].'" onclick="show_hide_form_page(\'next\','.$array_field_to_show[5].','.$amount_of_pages.',\'form_page_'.$array_field_to_show[5].'\');"/>';
}
echo '</div></div>';
echo '</div>';
}
//RADIO
if (strpos($field, 'type_radio***') !== false)
{
$array_radios=explode('+++',$field);
$amount_of_radios=count($array_radios);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
$i=1;
foreach($array_radios AS $radio)
{
$array_field_to_show=explode('***',$radio);
if($i==1)
{
echo $array_field_to_show[1].' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
}
echo '<input id="input_id_'.$array_field_to_show[3].'_'.htmlspecialchars_decode($array_field_to_show[7]).'" type="radio" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if($array_field_to_show[5]!="none") echo ' value="'.$array_field_to_show[5].'"';
if(${'value_'.$array_field_to_show[3]}==$array_field_to_show[5]) echo ' checked="checked"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' <label for="input_id_'.$array_field_to_show[3].'_'.htmlspecialchars_decode($array_field_to_show[7]).'">'.htmlspecialchars_decode($array_field_to_show[7]);
if($i==$amount_of_radios) echo '</label></div></div>';
else
{
echo '</label>';
if($array_field_to_show[8]!="horizontal") echo '<br/>';
else echo ' ';
}
$i++;
}
}
//CHECKBOX
if (strpos($field, 'type_checkbox***') !== false)
{
$array_checkboxes=explode('+++',$field);
$amount_of_checkboxes=count($array_checkboxes);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
$i=1;
foreach($array_checkboxes AS $checkbox)
{
$array_field_to_show=explode('***',$checkbox);
if($i==1)
{
echo $array_field_to_show[1].' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data">';
}
echo '<input id="input_id_'.$array_field_to_show[3].'" type="checkbox" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if($array_field_to_show[5]!="none") echo ' value="'.$array_field_to_show[5].'"';
if(${'value_'.$array_field_to_show[3]}==$array_field_to_show[5]) echo ' checked="checked"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' <span id="'.$array_field_to_show[3].'"><label for="input_id_'.$array_field_to_show[3].'">'.htmlspecialchars_decode($array_field_to_show[7]).'</span>';
if($i==$amount_of_checkboxes) echo '</label></div></div>';
else
{
echo '</label>';
if($array_field_to_show[8]!="horizontal") echo '<br/>';
else echo ' ';
}
$i++;
}
}
//SELECT SINGLE
if (strpos($field, 'type_select_single***') !== false)
{
$array_options=explode('+++',$field);
$amount_of_options=count($array_options);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
$i=1;
foreach($array_options AS $option)
{
$array_field_to_show=explode('***',$option);
if($i==1)
{
echo $array_field_to_show[1].' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
if($array_field_to_show[7]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[7].'</label><br/>';
echo '<select id="input_id_'.$array_field_to_show[3].'" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if($array_field_to_show[6]!="none") echo ' size="'.$array_field_to_show[6].'"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
}
echo '<option value="'.$array_field_to_show[5].'"';
if(${'value_'.$array_field_to_show[3]}==$array_field_to_show[5]) echo ' selected';
echo '>'.$array_field_to_show[5].'</option>';
if($i==$amount_of_options) echo '</select></div></div>';
$i++;
}
}
//SELECT MULTI
if (strpos($field, 'type_select_multi***') !== false)
{
$array_options=explode('+++',$field);
$amount_of_options=count($array_options);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
$i=1;
foreach($array_options AS $option)
{
$array_field_to_show=explode('***',$option);
if($i==1)
{
echo $array_field_to_show[1].' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
if($array_field_to_show[7]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[7].'</label><br/>';
echo '<select id="input_id_'.$array_field_to_show[3].'" name="'.$array_field_to_show[3].'[]" multiple="multiple"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if($array_field_to_show[6]!="none") echo ' size="'.$array_field_to_show[6].'"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
}
echo '<option value="'.$array_field_to_show[5].'"';
if(in_array($array_field_to_show[5],${'value_'.$array_field_to_show[3]})) echo ' selected';
echo '>'.$array_field_to_show[5].'</option>';
if($i==$amount_of_options) echo '</select></div></div>';
$i++;
}
}
//TEXT
if (strpos($field, 'type_text***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="text" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
echo ' value="'.${'value_'.$array_field_to_show[3]}.'"';
if($array_field_to_show[6]!="none") echo ' style="width: '.$array_field_to_show[6].'%;"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//NUMBER
if (strpos($field, 'type_number***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="';
if($html5_functions=="true") echo 'number';
else echo 'text';
echo '" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
echo ' value="'.${'value_'.$array_field_to_show[3]}.'"';
if($array_field_to_show[6]!="none") echo ' style="width: '.$array_field_to_show[6].'%;"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//DATE
if (strpos($field, 'type_date***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="';
if($html5_functions=="true") echo 'date';
else echo 'text';
echo '" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
echo ' value="'.${'value_'.$array_field_to_show[3]}.'"';
if($array_field_to_show[6]!="none") echo ' style="width: '.$array_field_to_show[6].'%;"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//EMAIL
if (strpos($field, 'type_email***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="email" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
echo ' value="'.${'value_'.$array_field_to_show[3]}.'"';
if($array_field_to_show[6]!="none") echo ' style="width: '.$array_field_to_show[6].'%;"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//PASSWORD
if (strpos($field, 'type_password***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="password" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
echo ' value="'.${'value_'.$array_field_to_show[3]}.'"';
if($array_field_to_show[6]!="none") echo ' style="width: '.$array_field_to_show[6].'%;"';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//TEXTAREA
if (strpos($field, 'type_textarea***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]).'<br/>';
echo '<textarea id="input_id_'.$array_field_to_show[3].'" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if($array_field_to_show[6]!="none")
{
$array_dimensions=explode('x',$array_field_to_show[6]);
echo ' rows="'.$array_dimensions[0].'" style="width:'.$array_dimensions[1].'%;"';
}
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
echo ${'value_'.$array_field_to_show[3]};
echo '</textarea>';
echo '</div></div>';
}
//FILE
if (strpos($field, 'type_file***') !== false AND $attachment_allowed=="true")
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '<br/><p class="formular_hinweis">'.$allowed_filetypes_hint_form.'</p>';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
echo '<input id="input_id_'.$array_field_to_show[3].'" type="file" name="'.$array_field_to_show[3].'"';
if($array_field_to_show[4]!="none") echo ' class="'.$array_field_to_show[4].'"';
if (isset($_FILES[$array_field_to_show[3]]['name'])) echo $_FILES['attachment']['name']; else echo '-';
if($array_field_to_show[2]=="true" AND $html5_functions=="true") echo ' required';
echo '/>';
if($array_field_to_show[7]!="none") echo '<br/>'.htmlspecialchars_decode($array_field_to_show[7]);
echo '</div></div>';
}
//RANGE
if (strpos($field, 'type_range***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_head.'">';
if($array_field_to_show[1]!="none") echo '<label for="input_id_'.$array_field_to_show[3].'">'.$array_field_to_show[1].'</label> ';
else echo ' ';
if($array_field_to_show[2]=="true" AND $array_field_to_show[1]!="none") echo '*';
echo '</div><div class="box_form_data" id="'.$array_field_to_show[3].'">';
if($array_field_to_show[7]!="none") echo ' '.htmlspecialchars_decode($array_field_to_show[7]).'<br/>';
if($array_field_to_show[6]!="none") // individual configuration is given
{
$array_range_min_max_step_start_width=explode('|',$array_field_to_show[6]);
echo $array_range_min_max_step_start_width[0].'<input id="input_id_'.$array_field_to_show[3].'" type="range" name="'.$array_field_to_show[3].'" min="'.$array_range_min_max_step_start_width[0].'" max="'.$array_range_min_max_step_start_width[1].'" step="'.$array_range_min_max_step_start_width[2].'"';
if(${'value_'.$array_field_to_show[3]}=="") echo ' value="'.$array_range_min_max_step_start_width[3].'" ';
else echo ' value="'.${'value_'.$array_field_to_show[3]}.'" ';
echo 'style="width: '.$array_range_min_max_step_start_width[4].'%;"';
if($array_field_to_show[8]!="none") echo ' list="tickmarks_input_id_'.$array_field_to_show[3].'"';
echo '/>'.$array_range_min_max_step_start_width[1];
}
else // individual configuration is not given
{
echo '0<input id="input_id_'.$array_field_to_show[3].'" type="range" name="'.$array_field_to_show[3].'" min="0" max="10" step="1"';
if(${'value_'.$array_field_to_show[3]}=="") echo ' value="0" ';
else echo ' value="'.${'value_'.$array_field_to_show[3]}.'" ';
if($array_field_to_show[8]!="none") echo ' list="tickmarks_input_id_'.$array_field_to_show[3].'"';
echo '/>10';
}
if($array_field_to_show[8]!="none")
{
$array_range_tickmarks=explode('|',$array_field_to_show[8]);
echo '<datalist id="tickmarks_input_id_'.$array_field_to_show[3].'">';
foreach($array_range_tickmarks AS $tickmark) echo '<option value="'.$tickmark.'">';
echo '</datalist>';
}
echo '</div></div>';
}
//SEPARATOR
if (strpos($field, 'type_separator***') !== false)
{
$array_field_to_show=explode('***',$field);
echo '<div class="box_form_row"><div class="'.$class_td_separator;
if($array_field_to_show[4]!="none") echo ' '.$array_field_to_show[4];
echo '">';
echo $array_field_to_show[1].' ';
echo '</div></div>';
}
$row_counter++;
}
echo '</div>';
echo '<p class="hint_mandatory_fields">'.mi18n("output form * fields have to be filled").'</p>';
echo '<div id="anti_spam_and_submit">';
/********** anti_spam begin **********/
if($anti_spam=="true")
{
$amount_countcha_1=rand(1,$amount_countchas);
$amount_countcha_2=rand(1,$amount_countchas-$amount_countcha_1);
$amount_countcha_3=rand(1,$amount_countchas-$amount_countcha_1-$amount_countcha_2);
$countcha_chosen=rand(1,3);
$countcha_chosen_hint=${'name_countcha_'.$countcha_chosen};
$countcha_to_prove_amount=${'amount_countcha_'.$countcha_chosen};
echo '<div class="formular_anti_spam">';
echo '<input type="hidden" name="countcha_to_prove_amount" value="'.$countcha_to_prove_amount.'"/>';
$c=1;
while($c<=3)
{
$i=0;
while($i<${'amount_countcha_'.$c})
{
echo '<img class="countcha" src="'.${'countcha_'.$c}.'" title="" alt=""/>';
$i++;
}
$c++;
}
echo '<br/>'.mi18n("output form anti_spam_hint_1");
echo ' '.$countcha_chosen_hint.' ';
echo mi18n("output form anti_spam_hint_2");
echo ' <input id="countcha" type="text" class="text" style="width: 5em;" name="countcha" value="';
if (isset($countcha)) echo $countcha; else echo '';
echo '"/>';
echo '</div>';
}
/********** anti_spam end **********/
echo '<input class="submit" type="submit" name="form_submitted" value="'.mi18n("output form send").'"/>';
echo '</div>';
echo '</form>';
}
/********** hiding submit and antispam if form has more than one page begin **********/
if($amount_of_pages>0) echo '
<script type="text/javascript">
document.getElementById(\'anti_spam_and_submit\').style.display="none";
</script>';
/********** hiding submit and antispam if form has more than one page end **********/
/********** marking errors begin **********/
// this part has to run after the form is fully displayed. otherwise the ids would not be present for js
if($form_submitted!="" AND $no_errors=="false")
{
?>
<script type="text/javascript">
var var_string_error_ids="<?php echo $string_error_ids;?>";
var array_error_ids=var_string_error_ids.split(";");
var a=0;
while(a!=array_error_ids.length)
{
document.getElementById(array_error_ids[a]).style.backgroundColor="#ff0000";
a=a+1;
}
</script>
<?php
}
/********** marking errors end **********/
/*###############################*/
/*########## displaying form end ##########*/
/*###############################*/
/*##############################################*/
/*########## sending mail and displaying mailed data begin ##########*/
/*#############################################*/
/********** sending mail begin **********/
if($use_smtp=="false")
{
if($form_submitted!="" AND $no_errors=="true")
{
$ip = htmlspecialchars(strip_tags($_SERVER["REMOTE_ADDR"]));
if($gender=="female") $gender_mail=mi18n("output email female");
else $gender_mail=mi18n("output email male");
//building array with recipients
$recipients = "CMS_VALUE[100]";
$array_recipients=array_filter(explode("//",$recipients));
$recipients_in_array=explode("//",$recipients);
//formatting subject of email
$mail_subject="CMS_VALUE[200]";
$mail_subject_variables="CMS_VALUE[210]";
if($mail_subject_variables!="")
{
$array_mail_subject_variables=explode("###",$mail_subject_variables);
foreach($array_mail_subject_variables AS $subject_variable) $mail_subject.=utf8_decode(' '.${$subject_variable});
}
// mail_body ist build within checking for errors section
if($send_from_name!="" AND $send_from_email!="")
{
$name=$send_from_name;
$email=$send_from_email;
}
if($filetype=="")
{
$random_hash = md5(date('r', time()));
$headers = "From: ".$send_from_email."\r\nReply-To: ".$send_from_email;
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
ob_start(); //Turn on output buffering, IMPORTANT: DO NOT REMOVE ANY OF THE FOLLOWING EMPTY LINES OR ADD BLANKSPACES BEFORE THE CODELINES TILL $message = ob_get_clean();!!! OTHERWISE THE CODE WON'T WORK BECAUSE OF WRONG BUFFER-CONTENTS!!!
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php echo $mail_body_plain_text."\n"; ?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php echo nl2br($mail_body)."\n"; ?>
--PHP-alt-<?php echo $random_hash; ?>--
<?php
$message = ob_get_clean();//copy current buffer contents into $message variable and delete current output buffer
}
else
{
$random_hash = md5(date('r', time()));
$headers = "From: ".$send_from_email."\r\nReply-To: ".$send_from_email;
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['attachment']['tmp_name'])));
ob_start(); //Turn on output buffering, IMPORTANT: DO NOT REMOVE ANY OF THE FOLLOWING EMPTY LINES OR ADD BLANKSPACES BEFORE THE CODELINES TILL $message = ob_get_clean();!!! OTHERWISE THE CODE WON'T WORK BECAUSE OF WRONG BUFFER-CONTENTS!!!
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php echo $mail_body_plain_text."\n"; ?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php echo nl2br($mail_body)."\n"; ?>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: <?php echo $_FILES['attachment']['type']; ?>; name="<?php echo $_FILES['attachment']['name']; ?>"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
$message = ob_get_clean();//copy current buffer contents into $message variable and delete current output buffer
}
if($use_smtp=="false")
{
foreach($recipients_in_array as $recipient)
{
if (@mail($recipient,$mail_subject,$message,$headers)) $sent = true;
else echo "<br/>keine Verbindung zum Mailserver - bitte nochmal versuchen";
}
}
/********** sending mail end **********/
/********** displaying mailed data begin **********/
if($show_data_in_success_note=="true")
{
echo '<p>'.mi18n("output form following information was mailed").'</p>';
echo $success_info; // build within checking for errors section
}
else echo '<p>'.mi18n("output form simple success info").'</p>';
/********** displaying mailed data end **********/
}
}
else
{
if($form_submitted!="" AND $no_errors=="true")
{
$ip = htmlspecialchars(strip_tags($_SERVER["REMOTE_ADDR"]));
if($gender=="female") $gender_mail=mi18n("output email female");
else $gender_mail=mi18n("output email male");
//building array with recipients
$recipients = "CMS_VALUE[100]";
$array_recipients=array_filter(explode("//",$recipients));
$recipients_in_array=explode("//",$recipients);
//formatting subject of email
$mail_subject="CMS_VALUE[200]";
$mail_subject_variables="CMS_VALUE[210]";
if($mail_subject_variables!="")
{
$array_mail_subject_variables=explode("###",$mail_subject_variables);
foreach($array_mail_subject_variables AS $subject_variable) $mail_subject.=utf8_decode(' '.${$subject_variable});
}
// mail_body is build within checking for errors section
$mailer = new cMailer();
$message = Swift_Message::newInstance();
$message->setFrom($send_from_email);
$message->setSubject($mail_subject);
$message->setContentType($content_type);
if($content_type=="text/html") $message->setBody($mail_body);
else $message->setBody($mail_body_plain_text);
if($filetype!="")
{
$message->attach(Swift_Attachment::fromPath($_FILES['attachment']['tmp_name'])->setFilename($_FILES['attachment']['name']));
}
foreach($recipients_in_array as $recipient)
{
$message->setTo($recipient);
$mailer->send($message);
}
if($show_data_in_success_note=="true")
{
echo '<p>'.mi18n("output form following information was mailed").'</p>';
echo $success_info; // build within checking for errors section
}
else echo '<p>'.mi18n("output form simple success info").'</p>';
}
}
/*############################################*/
/*########## sending mail and displaying mailed data end ##########*/
/*############################################*/
?>