";
throw new Exception($error);
}
$prefix = rand(111111, 999999);
$file_count = 0;
foreach ($_FILES as $key => $value)
{
if (is_array($_FILES[$key]['name']))
{
$count = count($_FILES[$key]['name']);
for ($file = 0; $file < $count; $file++)
{
if ($_FILES[$key]['name'][$file] != "" and file_exists($_FILES[$key]['tmp_name'][$file]) and $_FILES[$key]['size'][$file] > 0)
{
$upload_DstName[$file_count] = $prefix . "_" . str_replace(" ", "_", $_FILES[$key]['name'][$file]);
$upload_SrcName[$file_count] = $_FILES[$key]['name'][$file];
$upload_Size[$file_count] = $_FILES[$key]['size'][$file];
$upload_Temp[$file_count] = $_FILES[$key]['tmp_name'][$file];
$upload_URL[$file_count] = "$upload_folder/$upload_DstName[$file_count]";
$upload_FieldName[$file_count] = $key;
$file_count++;
}
}
}
else
if ($_FILES[$key]['name'] != "" and file_exists($_FILES[$key]['tmp_name']) and $_FILES[$key]['size'] > 0)
{
$upload_DstName[$file_count] = $prefix . "_" . str_replace(" ", "_", $_FILES[$key]['name']);
$upload_SrcName[$file_count] = $_FILES[$key]['name'];
$upload_Size[$file_count] = $_FILES[$key]['size'];
$upload_Temp[$file_count] = $_FILES[$key]['tmp_name'];
$upload_URL[$file_count] = "$upload_folder/$upload_DstName[$file_count]";
$upload_FieldName[$file_count] = $key;
$file_count++;
}
}
for ($i = 0; $i < $file_count; $i++)
{
if ($upload_Size[$i] >= $max_filesize)
{
$error .= "The size of $key (file: $upload_SrcName[$i]) is bigger than the allowed " . $max_filesize/1024 . " Kbytes!\n";
throw new Exception($error);
}
}
$uploadfolder = basename($upload_folder);
for ($i = 0; $i < $file_count; $i++)
{
$uploadFile = $uploadfolder . "/" . $upload_DstName[$i];
if (!is_dir($uploadfolder) || !is_writable($uploadfolder))
{
$error = 'Upload directory is not writable, or does not exist.';
throw new Exception($error);
}
move_uploaded_file($upload_Temp[$i] , $uploadFile);
$name = "$" . $upload_FieldName[$i];
$message = str_replace($name, $upload_URL[$i], $message);
$autoresponder_message = str_replace($name, $upload_URL[$i], $autoresponder_message);
}
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
}
}
if ($file_count > 0)
{
$message .= "\nThe following files have been uploaded:\n";
for ($i = 0; $i < $file_count; $i++)
{
$message .= $upload_SrcName[$i] . ": " . $upload_URL[$i] . "\n";
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
if (!ValidateEmail($autoresponder_from))
{
$error .= "The specified autoresponder email address (" . $autoresponder_from . ") is invalid!\n
";
throw new Exception($error);
}
$autoresponder_header = 'From: '.$autoresponder_name.' <'.$autoresponder_from.'>'.$eol;
$autoresponder_header .= 'Reply-To: '.$autoresponder_from.$eol;
$autoresponder_header .= 'MIME-Version: 1.0'.$eol;
$autoresponder_header .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
$autoresponder_header .= 'Content-Transfer-Encoding: 8bit'.$eol;
$autoresponder_header .= 'X-Mailer: PHP v'.phpversion().$eol;
mail($autoresponder_to, $autoresponder_subject, $autoresponder_message, $autoresponder_header);
header('Location: '.$success_url);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>