Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- function getRealIp() {
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
- $ip=$_SERVER['HTTP_CLIENT_IP'];
- } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
- $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ip=$_SERVER['REMOTE_ADDR'];
- }
- return $ip;
- }
- function writeLog($where) {
- $ip = getRealIp(); // Get the IP from superglobal
- $host = gethostbyaddr($ip); // Try to locate the host of the attack
- $date = date("d M Y");
- // create a logging message with php heredoc syntax
- $logging = <<<LOG
- \n
- << Start of Message >>
- There was a hacking attempt on your form. \n
- Date of Attack: {$date}
- IP-Adress: {$ip} \n
- Host of Attacker: {$host}
- Point of Attack: {$where}
- << End of Message >>
- LOG;
- // Awkward but LOG must be flush left
- // open log file
- if($handle = fopen('hacklog.log', 'a')) {
- fputs($handle, $logging); // write the Data to file
- fclose($handle); // close the file
- } else { // if first method is not working, for example because of wrong file permissions, email the data
- $to = 'tromano@mbcinteractive.com';
- $subject = 'HACK ATTEMPT';
- $header = 'From: tromano@mbcinteractive.com';
- if (mail($to, $subject, $logging, $header)) {
- echo "Sent notice to admin.";
- }
- }
- }
- // PREPARE THE BODY OF THE MESSAGE
- $message = '<html><body>';
- $message .= '<h1>ICES Employment Application</h1>';
- $message .= '<table width="623" align="center" cellpadding="2" rules="all" style="border-color: #000; border="1">';
- $message .= '<tr align="center" bgcolor="#eee" ><td width="265"><strong><h2>Question</h2></strong></td><td width="304"><strong><h2>Answer</h2></strong></td></tr>';
- $message .= "<tr>
- <td><strong>Name:</strong> </td>
- <td>" . strip_tags($_POST['name']) . "</td></tr>";
- $message .= "<tr>
- <td><strong>Other Names:</strong> </td>
- <td>" . htmlentities($_POST['otherNames']) . "</td></tr>";
- $message .= "<tr><td><strong>Address:</strong> </td><td>" . strip_tags($_POST['address']) . "</td></tr>";
- $message .= "<tr><td><strong>City/State/Zip:</strong> </td><td>" . htmlentities($_POST['citystatezip']) . "</td></tr>";
- $message .= "<tr><td><strong>Home Phone:</strong> </td><td>" . $_POST['homePhone'] . "</td></tr>";
- $message .= "<tr><td><strong>Cell Phone:</strong> </td><td>" . strip_tags($_POST['cellPhone']) . "</td></tr>";
- $message .= "<tr><td><strong>Email:</strong> </td><td>" . $_POST['email'] . "</td></tr>";
- $message .= "<tr><td><strong>1. Which ICES job are you applying for?</strong> </td><td>" . $_POST['which'] . "</td></tr>";
- $message .= "<tr><td><strong>2. Have you ever applied or provided services for ICES, Inc. at any other time?</strong> </td>
- <td>" . htmlentities($_POST['have'] ). "</td></tr>";
- $message .= "<tr><td><strong>3. Do any of your relatives presently work for ICES, Inc.?</strong> </td><td>" . $_POST['do'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>If so, List their name(s)</strong> </p>
- </blockquote></td>
- <td>" . $_POST['ifSo'] . "</td></tr>";
- $message .= "<tr><td><strong>4. Have you ever been terminated from a position for abuse or neglect?</strong> </td><td>" . $_POST['term'] . "</td></tr>";
- $message .= "<tr><td><strong>5. Have you ever been convicted of a felony crime, imprisioned, or on probation for any violation of any law?</strong> </td><td>" . $_POST['convict'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>If so, explain:</strong> </p>
- </blockquote></td>
- <td>" . htmlentities($_POST['convict_ifSo']) . "</td></tr>";
- $message .= "<tr><td><strong>6. Do you hold a valid driver's license?</strong> </td><td>" . $_POST['dl'] . "</td></tr>";
- $message .= "<tr><td><strong>7. Do you have reliable transportation?</strong> </td><td>" . $_POST['trans'] . "</td></tr>";
- $message .= "<tr><td><strong>8. Do you have automobile insurance?</strong> </td><td>" . $_POST['autoIns'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Insurance Company Name:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['insCo'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Policy Number:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['polNum'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Expiration Date:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['expDate'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Insurance Phone Number:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['insPh'] . "</td></tr>";
- $message .= "<tr><td><strong>Elementary/High School:</strong> </td><td>" . $_POST['k12'] . "</td></tr>";
- $message .= "<tr><td><strong>College:</strong> </td><td>" . $_POST['college'] . "</td></tr>";
- $message .= "<tr><td><strong>Graduate School:</strong> </td><td>" . $_POST['gradSch'] . "</td></tr>";
- $message .= "<tr><td><strong>List, in reverse chronological order, Colleges/Universities/High Schools attened (i.e.) Name of School, Address, Years Completed, Major, Degree):</strong> </td>
- <td>" .htmlentities( $_POST['listIn']) . "</td></tr>";
- $message .= "<tr><td><strong>Do you speak any languages besides English?</strong> </td><td>" . $_POST['land'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>If so, please list:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['lang_ifSo'] . "</td></tr>";
- $message .= "<tr><td><strong>List any certifications, licenses, applicable courses, etc:</strong> </td><td>" . $_POST['listAny'] . "</td></tr>";
- $message .= "<tr><td><strong>Professional references (list name & phone number):</strong> </td><td>" . $_POST['profRef'] . "</td></tr>";
- $message .= "<tr><td><strong>1st Company:</strong> </td><td>" . $_POST['company1'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Address:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1Add'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Supervisor:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1Super'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Phone #:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1Ph'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Employed From:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1_empFrom'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>To:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1_empTo'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Duties:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co1Dut'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Reason for Leaving:</strong> </p>
- </blockquote></td>
- <td>" . htmlentities($_POST['co1Reason']) . "</td></tr>";
- $message .= "<tr><td><strong>2nd Company:</strong> </td><td>" . $_POST['company2'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Address:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2Add'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Supervisor:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2Super'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Phone #:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2Ph'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Employed From:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2_empFrom'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>To:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2_empTo'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Duties:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co2Dut'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Reason for Leaving:</strong> </p>
- </blockquote></td>
- <td>" . htmlentities($_POST['co2Reason']) . "</td></tr>";
- $message .= "<tr><td><strong>3rd Company:</strong> </td><td>" . $_POST['company3'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Address:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3Add'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Supervisor:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3Super'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Phone #:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3Ph'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Employed From:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3_empFrom'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>To:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3_empTo'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Duties:</strong> </p>
- </blockquote></td>
- <td>" . $_POST['co3Dut'] . "</td></tr>";
- $message .= "<tr><td><blockquote>
- <p><strong>Reason for Leaving:</strong> </p>
- </blockquote></td>
- <td>" .htmlentities( $_POST['co3Reason']) . "</td></tr>";
- $message .= "<tr><td><strong>What are your goals and how does this position fit in with your goals?</strong> </td><td>" . $_POST['whatAre'] . "</td></tr>";
- $message .= "<tr><td><strong>Signature:</strong> </td><td>" . $_POST['sign'] . "</td></tr>";
- $message .= "<tr><td><strong>Date:</strong> </td><td>" . $_POST['date'] . "</td></tr>";
- $message .= "</table>";
- $message .= "</body></html>";
- // MAKE SURE THE "FROM" EMAIL ADDRESS DOESN'T HAVE ANY NASTY STUFF IN IT
- $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";
- if (preg_match($pattern, trim(strip_tags($_POST['email'])))) {
- $cleanedFrom = trim(strip_tags($_POST['email']));
- } else {
- return "The email address you entered was invalid. Please try again!";
- }
- // CHANGE THE BELOW VARIABLES TO YOUR NEEDS
- ini_set('SMTP', '172.16.4.18');
- ini_set('smtp_port', 25);
- $to = 'DPolletta@mbcinteractive.com' . ', ';
- $to = 'tromano@mbcinteractive.com';
- $subject = 'ICES Employment Application';
- $headers = "From: " . $cleanedFrom . "\r\n";
- $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
- if (mail($to, $subject, $message, $headers)) {
- echo 'Your message has been sent.';
- } else {
- echo 'There was a problem sending the email.';
- }
- /* Redirects to thank you page*/
- header('Location: http://www.cthealthcarejobs.com/icesthankyou.html');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement