$value) { $str_value .= $key." = '".$value."'".$newline; } return $str_value; } function SendEmail($to,$from,$subject) { //$to = "email@site.net"; //$subject = "subject"; //$from = "webmaster@site.net"; $message = prepareVars(); $headers = 'From: '.$from. "\r\n" . 'Reply-To: '.$from . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail ($to,$subject, $message,$headers); } function Redirect($location) { if (strpos($location,"://") === FALSE) $location = "http://".$location; Header("Location: ".$location); echo (""); } function WriteToLog ($action,$id, $meta_data) { // timestamp // action // id // metatdata // ip // post // $log = date("Y/m/d H:i:s")." - IP = '".$_SERVER["REMOTE_ADDR"]."' Action='".$action."' ID='".$id."' Metadata='".serialize($meta_data) ."' POST = '".serialize($_POST)."' GET = '".serialize($_GET)."'\r\n"; file_put_contents(LOG_FILENAME,$log, FILE_APPEND | LOCK_EX ); } function GetSiteURL() { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; $uri .= $_SERVER["PHP_SELF"]; return $uri; } $action = $_GET["action"]; $id = $_GET["id"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($action == "submit") { $filename = DIR_NAME.$id.".dat"; if (false == file_exists($filename)) die ("invalid ID."); $data = file_get_contents($filename); $meta_data = unserialize($data); // // write log // WriteToLog($action,$id, $meta_data); // // send email // SendEmail($meta_data["TO"],$meta_data["FROM"],$meta_data["SUBJECT"]); // // redirect // Redirect ($meta_data["REDIRECT"]); die(); } if ($action == "add_id") { $id = md5(rand()); $meta_data["TO"] = $_POST["to"]; $meta_data["FROM"] = $_POST["from"]; $meta_data["SUBJECT"] = $_POST["subject"]; $meta_data["REDIRECT"] = $_POST["redirect"]; WriteToLog($action,$id, $meta_data); $filename = DIR_NAME.$id.".dat"; file_put_contents($filename ,serialize($meta_data)); $target_url = GetSiteURL()."?action=submit&id=".$id; $form_code = '
'; } } ?>
Thank you for using the service, a new page was created for you :
upon posting to this page, an email will be send to
for your convienence, here is a predefined form :
click Here to return to the main page
This Site goal is to let the user quickly add a "contact me" form to its site.
upon filling the details below, a special page will be created. any submit to that page will send the user an email.
To get started fill up the details below, and click submit: