";
}
if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$message .= $eol;
$logdata = '';
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
$search = array("ä", "Ä", "ö", "Ö", "ü", "Ü", "ß", "!", "§", "$", "%", "&", "/", "\x00", "^", "°", "\x1a", "-", "\"", " ", "\\", "\0", "\x0B", "\t", "\n", "\r", "(", ")", "=", "?", "`", "*", "'", ":", ";", ">", "<", "{", "}", "[", "]", "~", "²", "³", "~", "µ", "@", "|", "<", "+", "#", ".", "´", "+", ",");
$replace = array("ae", "Ae", "oe", "Oe", "ue", "Ue", "ss");
foreach($_POST as $name=>$value)
{
$name = str_replace($search, $replace, $name);
$name = strtoupper($name);
$form_data[$name] = $value;
}
$db = mysqli_connect($mysql_server, $mysql_username, $mysql_password) or die('Failed to connect to database server!
'.mysqli_error($db));
mysqli_query($db, "CREATE DATABASE IF NOT EXISTS $mysql_database");
mysqli_select_db($db, $mysql_database) or die('Failed to select database
'.mysqli_error($db));
mysqli_query($db, "CREATE TABLE IF NOT EXISTS $mysql_table (ID int(9) NOT NULL auto_increment, `DATESTAMP` DATE, `TIME` VARCHAR(8), `IP` VARCHAR(15), `BROWSER` TINYTEXT, PRIMARY KEY (id))");
foreach($form_data as $name=>$value)
{
mysqli_query($db ,"ALTER TABLE $mysql_table ADD $name VARCHAR(255)");
}
mysqli_query($db, "INSERT INTO $mysql_table (`DATESTAMP`, `TIME`, `BROWSER`)
VALUES ('".date("Y-m-d")."',
'".date("G:i:s")."',
'".$_SERVER['HTTP_USER_AGENT']."')")or die('Failed to insert data into table!
'.mysqli_error($db));
$id = mysqli_insert_id($db);
foreach($form_data as $name=>$value)
{
mysqli_query($db, "UPDATE $mysql_table SET $name='".mysqli_real_escape_string($db, $value)."' WHERE ID=$id") or die('Failed to update table!
'.mysqli_error($db));
}
mysqli_close($db);
header('Location: '.$success_url);
exit;
}
?>