<?php /** ****************************************** ** * @CONTACT FORM V1.0.0 * @AUTHOR Dorin Grigoras * @DATE Saturday, November 23, 2013 ** ****************************************** **/ @ini_set('display_errors', 0); @ini_set('track_errors', 0); @date_default_timezone_set('Europe/Bucharest'); // Used only to avoid annoying warnings. if ($_REQUEST['action'] = 'email_send') { $array['name'] = isset($_REQUEST['contact_name']) ? strip_tags(trim($_REQUEST['contact_name'])) : ''; $array['email'] = isset($_REQUEST['contact_email']) ? ckmail($_REQUEST['contact_email']) : ''; $array['subject'] = isset($_REQUEST['contact_subject']) ? strip_tags(trim($_REQUEST['contact_subject'])) : '-'; $array['message'] = isset($_REQUEST['contact_comment']) ? trim(strip_tags($_REQUEST['contact_comment'], '<b><a><strong>')) : ''; // Check required fields if ($array['name'] == '' || $array['email'] == '' || $array['message'] == '') { die('_required_'); } // Check email if ($array['email'] === false) { die('_invalid_email_'); } // Visitor IP: $ip = ip(); // DATE $date = date('l, d F Y , H:i:s'); // BEGIN require 'config.inc.php'; require 'phpmailer/5.1/class.phpmailer.php';
<?php /** * @version v1.0.0 * @author Dorin Grigoras [www.stepofweb.com] * @date Thursday, May 21, 2015 **/ date_default_timezone_set('Etc/UTC'); @ini_set('display_errors', 0); @ini_set('track_errors', 0); $array['email'] = isset($_REQUEST['email']) ? ckmail($_REQUEST['email']) : false; if ($array['email'] !== false) { $fh = fopen('_newsletter.txt', 'a+'); fwrite($fh, "\r\n" . $array['email']); fclose($fh); unset($fh, $array); } /** ********************************** @CHECK EMAIL /** ******************************* **/ function ckmail($email) { $email = trim(strtolower($email)); if (preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$/', trim($email))) { return $email; } else { return false; } }
$email_body .= "<b>{$key_title}:</b> {$post_data[$key]} <br>"; } } // Check for required! Redirect if something found empty! foreach ($required as $req) { if (strlen(trim($post_data[$req]['required'])) < 2) { if ($is_ajax === false) { _redirect('#alert_mandatory'); exit; } else { die('_mandatory_'); } } } // Check Email $array['email'] = ckmail($array['email']); if ($array['email'] === false) { if ($is_ajax === false) { _redirect('#alert_mandatory'); exit; } else { die('_mandatory_'); } } // ATTACHMENT if (isset($_FILES['contact']['name']['attachment']) && $_FILES['contact']['name']['attachment'] != '') { // name|type|tmp_name|error|size| $target_file = UPLOAD_FOLDER . basename($_FILES['contact']['name']['attachment']); $rename = time() . '_' . basename($_FILES['contact']['name']['attachment']); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);