Dateigrösse: 12.46 kb
1 <?php 2 $ok = null; 3 $nr = 100; 4 $wer = ''; 5 $email = ''; 6 $text = ''; 7 $copyText = ''; 8 $alert = array('• Bitte E-Mail-Adresse der Firma überprüfen', 9 '• Bitte eigene E-Mail-Adresse überprüfen', 10 '• Bitte Betreff überprüfen', 11 '• Bitte Mitteilung überprüfen', 12 '• Bitte alle erforderlichen Dokumente anhängen', 13 '• Bitte AGB bestätigen', 14 '• Bitte nur PDF und Word-Dateien anhängen', 15 '• Bitte Dokumente noch einmal anhängen' 16 ); 17 18 $allowed_attach = array( 'application/pdf', 19 'application/msword', 20 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 21 'application/vnd.oasis.opendocument.text' 22 ); 23 $checkEmail = true; 24 $red_bg = false; 25 //$inline = 'block'; 26 27 $tpl->setVariable('style', 'style="display:block;"'); 28 29 $tpl->setVariable('bool0', 'hidden'); 30 $tpl->setVariable('bool1', 'hidden'); 31 $tpl->setVariable('bool2', 'hidden'); 32 $tpl->setVariable('bool3', 'hidden'); 33 $tpl->setVariable('bool4', 'hidden'); 34 $tpl->setVariable('bool44', 'hidden'); 35 $tpl->setVariable('bool5', 'none'); 36 37 $tpl->setVariable('alert0', ' '); 38 $tpl->setVariable('alert1', ' '); 39 $tpl->setVariable('alert2', ' '); 40 $tpl->setVariable('alert3', ' '); 41 $tpl->setVariable('alert4', ' '); 42 $tpl->setVariable('alert44', ' '); 43 $tpl->setVariable('alert5', ' '); 44 45 $tpl->setVariable('alert55', ''); 46 $tpl->setVariable('alert66', ''); 47 /* */ 48 // Deutschsprachige Umgebung, damit regulaere Ausdruecke (regex) auch Umlaute erkennen 49 setlocale(LC_ALL, 'de_CH'); 50 51 // Erzeuge einen zufaellig aussehenden Zugangscode aus dem Datum ... 52 $code = chr((date("y") + 7) % 10 + date("m") + 68 + (date("m") % 2) * 32) . chr((date("d") + (date("d") %2)) / 2 + 66 + (37 * (date("d") %2))); 53 // ... den der Anwender mittels verborgenem Eingabefeld uebergibt. 54 // So laesst sich das Gros der Skript gesteuerten Angriffe von vornherein abblocken. 55 56 if ( isset($_POST['ok']) ) 57 { 58 if(!isset($_POST['code']) || $_POST['code'] != $code) die ('<div style="margin:2em; font-size:12pt; font-weight:bold;"><p>Mailcode fehlt!</p><br><p><a style="color:#cc0033;" href="#" onclick="self.location=\'index.php?kap=bewerbung&navid=6\';">back</a></p></div>'); 59 60 $ok = true; 61 $anhang = array(); 62 63 //print_r($_POST); 64 $data = array_map('_filterData', $_POST); 65 //print_r($data); 66 67 $wer = "msteiner2015@bluewin.ch"; //$data['wer']; 68 $email = $data['email']; 69 $betreff = $data['subject']; 70 $text = $data['text']; 71 $copy = isset($data['copy2me']); 72 $anhang = $_FILES['attach']; 73 74 $anhang0 = $anhang['name'][0].$anhang['type'][0].$anhang['tmp_name'][0].$anhang['error'][0].$anhang['size'][0]; 75 /* 76 foreach($anhang as $key => $value) { 77 echo $key .' => '. count($value); 78 print_r($value); 79 echo '<br>'; 80 foreach($value as $k => $v) { 81 echo $k .' => '. $v; 82 echo '<br>'; 83 } 84 } 85 */ 86 $agb = isset($data['agb']); 87 //print_r($anhang); //$anhang['name']['type']['tmp_name']['error']['size']; 88 //echo $anhang['error'][0]; 89 //echo $anhang['error'][1]; 90 //echo $anhang['error'][2]; 91 //echo $anhang['error'][3]; 92 93 /* */ 94 if($agb!=true) 95 { 96 $ok = false; 97 $nr = 5; 98 } 99 // $anhang['type'] != 'application/pdf' ... 100 if(!in_array($anhang['type'][0], $allowed_attach) || !in_array($anhang['type'][1], $allowed_attach)) 101 { 102 $ok = false; 103 $nr = 44; 104 $red_bg = true; 105 } 106 // $anhang['error'] 0=Ja->OK!, 4=No->KO! 107 if($anhang['error'][0] !=0 || $anhang['error'][1] !=0) 108 { 109 $ok = false; 110 $nr = 4; 111 $red_bg = true; 112 } 113 if(strlen($text) <= 5) 114 { 115 $ok = false; 116 $nr = 3; 117 $red_bg = false; 118 } 119 if(strlen($betreff) < 8) 120 { 121 $ok = false; 122 $nr = 2; 123 $red_bg = false; 124 } 125 if($checkEmail && !checkEmail($email, true)) 126 { 127 $ok = false; 128 $nr = 1; 129 $red_bg = false; 130 } 131 if($checkEmail && !checkEmail($wer, true)) 132 { 133 $ok = false; 134 $nr = 0; 135 $red_bg = false; 136 } 137 } 138 139 if($ok) 140 { 141 if (strtoupper(substr(PHP_OS,0,3)=='WIN')) { 142 $eol = "\r\n"; 143 } elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) { 144 $eol = "\r"; 145 } else { 146 $eol = "\n"; 147 } 148 149 $zeit1 = date('d.m.Y'); 150 $zeit2 = date('H:i') . ' Uhr:'; 151 152 $msgHead = '<span style="color: #000;">'. $email .' schrieb am '. $zeit1 .' um '. $zeit2 .'</span>'. $eol.$eol; 153 $msgText = utf8_decode($text); 154 $msgText = $msgText . $eol.$eol; 155 $msgMail = $email . $eol.$eol; 156 157 $toName = "Michaelis"; 158 //$to = "mistone@protonmail.com"; 159 $to = "msteiner2015@bluewin.ch"; 160 //$fromName = "Contact-Formular"; 161 //$from = "no-reply@localhost"; 162 $fromName = $wer; 163 $from = $email; 164 $subject = utf8_decode($betreff); // "Bewerbungsformular" 165 $body = $msgText; //$msgHead.$msgText; 166 167 /******** version 2.5 ********/ 168 require_once 'js/html_mime_mail_2.5/htmlMimeMail.php'; 169 170 $mail = new htmlMimeMail(); 171 $mail->setFrom($from .' <'. $from .'>'); 172 $mail->setSubject($subject); 173 174 $add = ''; //'<b>---------------------------</b><br />'; 175 $mail->setHtml($add . $body); 176 177 $msgAttach = ''; 178 $filename = array(); 179 $anlagen = 0; 180 $pre = ''; 181 $allowed_mimetypes = array( 'image/gif', 182 'image/png', 183 'image/jpg', 184 'image/jpeg', 185 'application/pdf', 186 'application/msword', 187 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 188 'application/vnd.oasis.opendocument.text', 189 'text/plain' 190 ); 191 192 for($i=0; $i < count($anhang); $i++) 193 { 194 if(is_uploaded_file($anhang['tmp_name'][$i])) 195 { 196 foreach($anhang as $key => $val) { 197 $pre .= $key.' => '.$val[$i]; 198 $pre .= '<br />'; 199 } 200 if(in_array($anhang['type'][$i], $allowed_mimetypes)) { 201 if($attach[$i] = $mail->getFile($anhang['tmp_name'][$i])) { 202 $mail->addAttachment($attach[$i], utf8_encode($anhang['name'][$i]), $anhang['type'][$i]); 203 //$filename[$anhang['type'][$i]][] = $anhang['name'][$i]; 204 $filename[$anhang['type'][$i]][] = '<span title="'. $anhang['type'][$i] .'">'. $anhang['name'][$i] .'</span>'; 205 $anlagen = 1; 206 } else { 207 $anlagen = 2; 208 } 209 } else { 210 //echo $anhang['type'][$i].'<br>'; 211 $anlagen = 3; 212 $filename[$anhang['type'][$i]][] = '<span style="color:red;" title="'. $anhang['type'][$i] .'">'. $anhang['name'][$i] .' wurde gelöscht!</span>'; // - - 213 unset($anhang[$i]); 214 } 215 } 216 } 217 $mail->send(array($toName .' <'. $to .'>')); 218 219 if($copy) { 220 $mail->send(array($fromName .' <'. $from .'>')); 221 $copyText = '<br><h4>Eine Kopie wurde an '. $from .' gesendet.</h4>'; 222 $copyText .= '<div style="width:77%; padding:0.5em 0 1em 0; margin:0px auto; border-top:1pt dashed black; text-align:center;"></div>'; 223 } 224 else { 225 $copyText .= '<br><br><div style="width:66%; padding:0.5em 0 1em 0; margin:0px auto; border-top:1pt dashed black; text-align:center;"></div>'; 226 } 227 228 $msgAttach = '<br><div style="width:55%; padding:0.5em 0 1em 0; margin:0px auto; border-top:1pt dashed black; text-align:center;"></div>'; 229 $ctr = 0; 230 231 if($anlagen==1 || $anlagen==3) { 232 $clip = '<img style="margin:0 10px -3px 0;" src="../img/paperclip.gif" alt="Attachment" width="15" height="15" border="0" />'; 233 $alarm = '<img style="margin:0 10px -3px 0;" src="../img/icon_alarm.gif" alt="Alarm" width="15" height="14" border="0" />'; 234 $error = '<img style="margin:0 8px -3px 0;" src="../img/icon_error.png" alt="Error" width="16" height="16" border="0" />'; 235 $img = '<img style="margin:0 10px -2px 0;" src="../img/icon_image.gif" alt="Bild" width="16" height="16" border="0" />'; 236 $pdf = '<img style="margin:0 10px -2px 0;" src="../img/icon_pdf.gif" alt="PDF" width="16" height="16" border="0" />'; 237 $odt = '<img style="margin:0 10px -2px 0;" src="../img/icon_odt_16x14.png" alt="ODT" width="14" height="16" border="0" />'; 238 //$odt = '<img style="margin:0 10px -2px 0;" src="../img/icon-odt-16x16.gif" alt="ODT" width="16" height="16" border="0" />'; 239 $doc = '<img style="margin:0 10px -3px 0;" src="../img/icon-word-2010_16x16.png" alt="DOC" width="16" height="16" border="0" />'; 240 $doc = '<img style="margin:0 10px -2px 0;" src="../img/icon_word.gif" alt="DOC" width="16" height="16" border="0" />'; 241 $docx = '<img style="margin:0 10px -3px 0;" src="../img/icon_docx.gif" alt="DOCX" width="16" height="16" border="0" />'; 242 $docx = '<img style="margin:0 10px -4px 0;" src="../img/icon-word-18x18.gif" alt="DOCX" width="18" height="18" border="0" />'; 243 $i=0; 244 foreach($filename as $key => $value) 245 { 246 foreach($value as $k => $v) 247 { 248 $icon = stristr($v, 'wurde gelöscht!') ? $error : $clip; 249 if($icon==$clip) { 250 $ctr++; 251 if($anhang['type'][$i]=='application/pdf') { 252 $icon = $pdf; 253 } 254 elseif($anhang['type'][$i]=='application/vnd.oasis.opendocument.text') { 255 $icon = $odt; 256 } 257 elseif($anhang['type'][$i]=='image/gif' || $anhang['type'][$i]=='image/png' || $anhang['type'][$i]=='image/jpg' || $anhang['type'][$i]=='image/jpeg') { 258 $icon = $img; 259 } 260 elseif($anhang['type'][$i]=='application/msword') { 261 $icon = $doc; 262 } 263 else { 264 $icon = $docx; 265 } 266 } 267 $i++; 268 $title = stristr($v, 'wurde gelöscht!') ? 'Sorry, falscher Dateityp' : 'Anhang '. $ctr; 269 $msgAttach .= '<span title="'. $title .'">'. $icon .'</span><span style="color:#454545;" title="OOPS">'. $v .'</span>'; 270 $msgAttach .= '<p style="padding:0.25em; margin:0; border:0pt dotted #454545;"></p>'; 271 } 272 } 273 //$msgAttach .= $pre; 274 $msgAttach .= '<div style="width:33%; padding:0.5em 0; margin:0px auto; border-bottom:1pt dashed black; text-align:center;"></div>'; 275 } 276 if($anlagen==2) { 277 $msgHead = '<span style="color:red;">Fehler beim Anhang</span>'; 278 $msgText = 'an error occured while reading attachment(s)!'; 279 } 280 281 $meldung = '<div style="text-align:center !important; width:45em !important; color:#228b22 !important; background:transparent; margin:1em 0; padding:2em 2em 1em 2em; border:1pt solid #454545; border-radius:20px; box-shadow:3pt 3pt 6pt #228b22; line-height:22px; letter-spacing:1px;"><span style="font-size:155%">Vielen Dank für deine Bewerbung.</span><br><br><span style="font-size:133%">Wir melden uns in den nächsten Tagen bei dir.</span>'.$copyText.'<p style="margin:0;padding:0;height:10px;"></p>' . $msgHead . '<br><div style="font-size:10pt; color:#353535; margin:10pt 0;"><div style="width:80%;margin:0 auto;">' . nl2br($text) . '</div> '. $msgAttach .'<br><a href="' . $_SERVER['PHP_SELF'] . '?kap=' . $_GET['kap'] . '&navid=' . $_GET['navid'] . '" class="notable" style="font-size:9pt;">weiter</a></div></div>'; 282 283 $tpl->setVariable('style', 'style="display:none;"'); 284 $tpl->setVariable('meldung', $meldung); 285 } 286 else 287 { 288 $tpl->setCurrentBlock('formular'); 289 290 $tpl->setVariable('action', $_SERVER['PHP_SELF'].'?kap='.$_GET['kap'].'&navid='.$_GET['navid']); 291 $tpl->setVariable('wer', _filterData($_POST['wer'])); 292 $tpl->setVariable('email', _filterData($_POST['email'])); 293 $tpl->setVariable('betreff', _filterData($_POST['subject'])); 294 $tpl->setVariable('text', _filterData($_POST['text'])); 295 296 $check = $copy ? 'checked="checked"' : ''; 297 $tpl->setVariable('checked', $check); 298 299 $checkAGB = $agb ? 'checked="checked"' : ''; 300 $tpl->setVariable('checkedAGB', $checkAGB); 301 302 $tpl->setVariable('code', $code); 303 304 if($nr<=3) 305 { 306 $tpl->setVariable('autofocus1', ''); 307 $tpl->setVariable('autofocus'.$nr, 'autofocus'); 308 $tpl->setVariable('bg'.$nr, 'background-color:#ffb8b8; border-color:#666;'); 309 } 310 if($nr>3 && $nr<100) 311 { 312 $tpl->setVariable('autofocus1', ''); 313 $tpl->setVariable('autofocus2', ''); 314 $tpl->setVariable('autofocus3', ''); 315 } 316 if($nr<9) 317 { 318 $tpl->setVariable('bool'.$nr, 'visible'); 319 $tpl->setVariable('alert'.$nr, $alert[$nr]); 320 } 321 if($nr==44) 322 { 323 $tpl->setVariable('bool'.$nr, 'visible'); 324 $tpl->setVariable('alert'.$nr, $alert[6]); 325 } 326 327 if($red_bg) 328 { 329 $tpl->setVariable('alert55', 'background-color:#ffb8b8;'); 330 $tpl->setVariable('alert66', 'background-color:#ffb8b8;'); 331 } 332 333 $tpl->parseCurrentBlock(); 334 } 335 336 //$_SESSION['attach'] = $_SESSION['attach']['size'][0]==$anhang['size'][0]?$_SESSION['attach']:$_FILES['attach']; 337 //unset($_SESSION['attach']); 338 ?> 339 340 341