loadTpl) { return ''; } class Request { var $tplsDir = 'tpl/request/tpl'; function getTpls() { if(!is_dir($this->tplsDir)) return array(); $R = array(); foreach(scandir($this->tplsDir) as $v) { $V = $this->tplsDir.'/'.$v; if($v[0]=='.' OR !is_dir($V)) continue; $R[$v] = $v; } return $R; } function isSpam() { $ok = true; // referer check if(substr($_SERVER['HTTP_REFERER'],7,strlen($_SERVER['HTTP_HOST']))!=$_SERVER['HTTP_HOST']) { $ok = false; } // js set field if($this->Mizu->GP['checksum']!=$_SERVER['HTTP_HOST']) { $ok = false; } if(!$ok) { echo '---'; return true; } return false; } function getFormConf() { $FormConf = $this->Mizu->get('lng/formConf'); if($this->Mizu->get('cnt/reqFields')) { $Fields = ''; $tmp = $this->Mizu->getList('cnt/reqFields',array('order'=>array('sort'=>'+0 ASC'))); foreach($tmp as $k => $v) { if(!$v['lng'][$this->Mizu->GP['L']]['name']) continue; switch($v['cnt']['reqFieldType']) { case 'textarea' : default : $Fields.='Mizu->GP['L']]['answ1']) { $Fields.=' answ1="'.$v['lng'][$this->Mizu->GP['L']]['answ1'].'" '; } if($v['lng'][$this->Mizu->GP['L']]['answ2']) { $Fields.=' answ2="'.$v['lng'][$this->Mizu->GP['L']]['answ2'].'" '; } $Fields.='/>'; break; } } #print_rf(htmlentities($Fields));exit; } if($this->Mizu->get('cnt/formFile') AND !$FormConf) { $file = $this->tplsDir.'/'.$this->Mizu->get('cnt/formFile').'/'.$this->Mizu->GP['L'].'.php'; if(file_exists($file)) { $file = substr($file,4,-4); $FormConf = $this->Mizu->getTpl($file,array('forceTpl'=>true,'Fields'=>$Fields),true); } } return $FormConf; } function exportAction() { // get Entries $timeFilter =''; if($this->Mizu->GP['from']) { $timeFilter.= ' AND createDate >= '.strtotime($this->Mizu->GP['from']); } if($this->Mizu->GP['until']) { $timeFilter.= ' AND createDate <= '.strtotime($this->Mizu->GP['until']); } $A = $this->Mizu->_DB->getRows('SELECT * FROM %%%requests WHERE pid = '.$this->Mizu->GP['id'].' '.$timeFilter.' ORDER BY id'); // calc Data $Data = array(); $Header = array('createDate'=>'Eingetragen am'); foreach($A as $k => $v) { $d = unserialize($v['mailData']); $Data[$k]['createDate'] =date('d.m.Y H:i:s',$v['createDate']); if(is_array($d)) { foreach($d as $field => $value) { if($value['attr']['type']=='title' OR $value['attr']['type']=='submit' OR $value['attr']['type']=='privacyCheckbox' OR $value['attr']['type']=='caption') continue; if($value['valueF']) { $Data[$k][$field] = strip_tags(strtr($value['valueF'],array('
'=>' '))); } elseif(is_array($value['value'])) { foreach($value['value'] as $yy) { $Data[$k][$field] = '-'.$yy.' '; } } else { $Data[$k][$field] = $value['value']; } $Header[$field] = $value['attr']['name']; } } } $sep = ','; $out = '"'.implode('"'.$sep.'"',$Header).'"'."\n"; if($Data) { foreach($Data as $k => $v) { $o = ''; foreach($Header as $field => $xx) { $o.='"'.$v[$field].'"'.$sep.''; } $out.=substr($o,0,-1)."\n"; } } header("Content-type: application/octet-stream; charset=utf-8"); header("Content-length: ".strlen($out)); header("Content-Disposition: attachment; filename=".$this->Mizu->get('lng/nav')." - ".date('d.m.Y',strtotime($this->Mizu->GP['from']))." - ".date('d.m.Y',strtotime($this->Mizu->GP['until'])).".csv"); ob_end_clean(); echo $out; exit; exit; } function init() { global $Mizu; $Mizu = $this->Mizu; $tplID = basename(dirname(__FILE__)); if($this->Mizu->GP['a']=='export' AND $this->Mizu->isAdmin) { $this->exportAction(); } // set includes #echo $Mizu->getCssInc('tpl/'.$tplID.'/screen.css'); ////////////////////////////////////////////////////////////////////// // BUILD FORM $this->Form = array(); $this->FormOut = ''; $Error = array(); $Mail = array(); if($Mizu->GP['formSend']) { $this->FormSended = true; } $FormConf = $this->getFormConf(); if($FormConf) { $this->Form = $Mizu->_Helper->getAfX(simplexml_load_string($FormConf)); #print_rf($Mizu->GP); foreach($this->Form['field'] as $v) { $El = $v; $El['id'] = $v['attr']['id']; if(!$El['id']) { $El['id'] = $Mizu->_Url->nameEncode($v['attr']['name']); if($this->Elements[$El['id']]) $El['id'].='x'; if($this->Elements[$El['id']]) $El['id'].='x'; if($this->Elements[$El['id']]) $El['id'].='x'; } if(!$El['id'] OR $v['attr']['type']=='captcha' OR $v['attr']['type']=='privacyCheckbox') { $El['id'] = $v['attr']['type']; } $El['name'] = $v['attr']['name']; # $EL['formName'] = urlencode($EL['name']); $El['value'] = $Mizu->GP[$El['id']]; if(is_string($El['value'])) { $El['value'] = trim($El['value']); } ///////////////////////////////////////////////////////////////// // valid if($this->FormSended) { if($El['attr']['reqIf']) { $T = explode('==',$El['attr']['reqIf']); if($Mizu->GP[$T[0]]==$T[1]) { $El['attr']['req'] = true; } } $valid_ok = true; if($El['attr']['req'] AND !$El['value']) { $valid_ok = false; } switch($El['attr']['valid']) { case 'email' : if($El['value']) { if (!$Mizu->_Helper->isValidEmail($El['value'])) { $valid_ok = false; } else { $absendermail = $El['value']; } } break; case 'captcha' : if($El['value']!=$_SESSION['kcode']) { $valid_ok = false; } break; } if(!$valid_ok) { $Error[] = true; $El['class'] = ' Ierror '; } } ///////////////////////////////////////////////////////////////// // build form if($El['attr']['req']) { $El['name'].='*'; } $this->FormOut.='
'; switch($v['attr']['type']) { case 'ShopCart' : $Shop = $Mizu->getClass('Shop',dirname(__FILE__).'/../shop/Shop.class.php'); $this->FormOut.= $Shop->getRequestFormField(); if($this->FormSended) { $this->FormSended = $Shop->inAction(); } break; case 'captcha' : $this->FormOut.='
'.$El['attr']['descr'].'
'; break; case 'privacyCheckbox' : if($El['value']) { $El['check'] = 'checked="checked"'; } $this->FormOut.='
'.nl2br($v['txt']).'
'; break; case 'label' : case 'caption' : $this->FormOut.='
'.$Mizu->parseHtmlTextField(nl2br($v['txt'])).'
'; break; case 'title' : $this->FormOut.='
'.$El['name'].'
'; break; case 'textarea' : $this->FormOut.= ' '; break; case 'submit' : $this->FormOut.=' '; break; case 'checkbox' : if($El['value']) { $El['check'] = 'checked="checked"'; } $this->FormOut.= '
'.$El['name'].'
'; break; case 'day' : #print_rf($El); $this->FormOut.= '
'; $A = array(); for($i=1;$i<=31;$i++) { $A[$i] = $i;} $this->FormOut.= Html::getSelect($A,array('name'=>$El['id'].'[0]','value'=>$El['value'][0])).' '; $A = array(); for($i=1;$i<=12;$i++) { $A[$i] = $i;} $this->FormOut.= Html::getSelect($A,array('name'=>$El['id'].'[1]','value'=>$El['value'][1])).' '; $A = array(); for($i=date('Y');$i<=date('Y')+3;$i++) { $A[$i] = $i;} $this->FormOut.= Html::getSelect($A,array('name'=>$El['id'].'[2]','value'=>$El['value'][2])); $this->FormOut.=' 
'; break; case 'checkboxGroup' : $opts = ''; $El['valueF'] = ''; $El['options']['option'] = Helper::getArrayAsRows($El['options']['option']); if(is_array($El['options']['option'])) { foreach($El['options']['option'] as $v) { $v = $v['attr']; $s = ''; if(!isset($v['value'])) $v['value'] = $Mizu->_Url->nameEncode($v['name']); if($El['value'][$v['value']]) { $s = 'checked="checked"'; $El['valueF'].= '-'.$v['name']."
"; } $v['id'] = $El['id'].'-'.$v['value']; $opts.= '
'; } } $this->FormOut.= '
'.$opts.'
'; break; case 'select' : $opts = ''; if(is_array($El['options']['option'])) { foreach($El['options']['option'] as $v) { $v = $v['attr']; $s = ''; if(!isset($v['value'])) $v['value'] = $Mizu->_Url->nameEncode($v['name']); if($v['value']==$El['value']) { $s = 'selected="selected"'; $El['valueF'] = $v['name']; } $opts.= ''; } } $this->FormOut.= ' '; break; case 'survey' : foreach(range(1,5) as $xx) { $El['options']['option'][]['attr'] = array( 'name' => $xx, ); } $El['spc'][5] = ''.$El['attr']['answ1'].''; $El['spc'][10] = ''.$El['attr']['answ2'].''; case 'radio' : $opts = ''; if(is_array($El['options']['option'])) { foreach($El['options']['option'] as $v) { $v = $v['attr']; if(!isset($v['value'])) $v['value'] = $Mizu->_Url->nameEncode($v['name']); $s = ''; if($v['value']==$El['value']) { $s = 'checked="checked"'; $El['valueF'] = $v['name']; } $opts.= ''.$v['name'].''; } } $this->FormOut.= '
'.$El['spc'][5].$opts.$El['spc'][10].'
'; break; case 'spacer' : $this->FormOut.= '
 
'; break; case 'file' : if($_FILES[$El['id']] AND !$_FILES[$El['id']]['error']) { if(!preg_match('/\.(php|php3|php4|php5)$/iU', $_FILES[$El['id']]['name'])) { $fileTmp = 'uploads/' . date('Y-m-d-H-i-s') . '_' . $_FILES[$El['id']]['name']; if (move_uploaded_file($_FILES[$El['id']]['tmp_name'], $fileTmp)) { $Mizu->GP[$El['id']] = $fileTmp; $El['value'] = $fileTmp; } } } $this->FormOut.= ''; if($Mizu->GP[$El['id']]) { $this->FormOut.= ''; $this->FormOut.= basename($Mizu->GP[$El['id']]); } else { $this->FormOut.= ''; } break; default : $this->FormOut.= ' '; break; } ///////////////////////////////////////////////////////////////// // build mail if($El['value']) { switch($v['attr']['type']) { case 'day' : $El['value'] = implode('.',$El['value']); break; default : break; } if(!$El['valueF']) { $El['valueF'] = $El['value']; } } $Mail[] = $El; $V[$El['id']] = $El['valueF']; $RV[$El['id']] = $El['value']; $this->Elements[$El['id']] = $El; $this->FormOut.='
'; } // send if($this->FormSended AND !count($Error)) { if($this->isSpam()) return false; $mails = explode(';',$Mizu->getC('email')); if(!$absendermail) { $absendermail = $mails[0]; } // save to Asa if($Mizu->get('cnt/saveAsa')) { $V['id'] = mktime().rand(1,200); ob_start(); require_once('services/mo-asa.xml.php'); $XML = ob_get_contents(); ob_end_clean(); if(file_exists($Mizu->get('cnt/saveAsa'))) { file_put_contents($Mizu->get('cnt/saveAsa').$V['id'].'.xml',$XML); } } if($Mizu->get('cnt/sendThxPage')) { $this->sendThx =true; } if($RV['sendType']=='1') { $this->sendThx =true; } else if($V['sendType']=='2') { $this->sendThx =false; } // send danke page if($Mizu->get('lng/thxMail')) { $mail = $this->Mizu->getHelperClass('Mailer'); $mail->CharSet = 'utf-8'; $mail->IsHTML(true); $mail->AddAddress($absendermail,$absendermail); $mail->Subject = $Mizu->get('lng/betreff'); $mail->From = $mails[0]; $mail->FromName = $mails[0]; $mailToClient = ''; $mail->Body = $this->setAbsoluteUrls($Mizu->get('lng/thxMail')); if($absendermail!=$mails[0]) { $mail->Send(); } } $mail = $this->Mizu->getHelperClass('Mailer'); $mail->CharSet = 'utf-8'; $mail->IsHTML(true); foreach($mails as $e) { if($e) { $mail->AddAddress($e,$e); } } $mail->From = $absendermail; $mail->FromName = $absendermail; $mail->Subject = $Mizu->get('betreff'); $mailbody = ''; $TypesNotInMail = array('submit','captcha','privacyCheckbox','caption'); foreach($Mail as $k=>$v){ if(in_array($v['attr']['type'],$TypesNotInMail)) { continue; } $t = 0; $mailbody.=''; switch($v['attr']['type']) { case 'ShopCart' : $Shop = $Mizu->getClass('Shop',dirname(__FILE__).'/../shop/Shop.class.php'); $mailbody.= $Shop->getRequestMailField(); break; case 'label' : case 'caption' : case 'title' : $t = 1; default : $mailbody.= ''; $mailbody.= '"; }elseif($v['value']) { $mailbody.='"; } else { $mailbody.=""; } } $mailbody.= ''; break; } } $mailbody.= '
"; if(!$t) { if($v['attr']['type']=='file') { $mailbody.=''.$v['valueF']."'.stripslashes($v['valueF'])." 
'; if($this->Mizu->devMode) { ob_clean(); echo 'MAIL --------------------------
'.($mailbody).'
---------------------------';exit; } $mail->Body = $mailbody; if($mailToClient) { # $mail->Body.='

------------------------------------------------------------
'; $mail->Body.=$mailToClient; } if($mail->Send()) { $I = array(); $I['i']['pid'] = $this->Mizu->GP['id']; $I['i']['createDate'] = mktime(); $I['i']['lng'] = $Mizu->GP['L']; $I['i']['fromMail'] = $absendermail; $I['i']['mailRaw'] = $mailbody; $I['i']['mailData'] = serialize($this->Elements); $this->Mizu->_DB->IU($I,'%%%requests'); $this->SendOk = 1; if($RV['sendType']=='2') { $this->SendOk = 2; } } else { } if($this->SendOk) { header('Location:'.$this->Mizu->getUrl(false,false,array('page'=>'thx'))); exit; } unset($_SESSION["kcode"]); //Captcha-Variable zurücksetzen } } } function setAbsoluteUrls($v) { $s = ' $x) { if(substr($x,0,strlen($s))!=$s) { $toChange[$x] = $this->Mizu->_Url->BaseHref.$x; } } } if($toChange) { $v = strtr($v,$toChange); } return $v; } }