'.$fieldvalue[$i]."";
}
$i++;
}
}
// ------RECEIVING FILE VARIABLES--------------------
$prefix = rand(100000, 1000000);
reset ($_FILES);
$k = 0;
while (list ($key, $val) = each ($_FILES)) {
if ($_FILES[$key]['name']!="" and $_FILES[$key]['size'] > 0) {
$upload_Name[$k] = $_FILES[$key]['name'];
$filename[$k] = $_FILES[$key]['name'];
if ($add_prefix == "Yes") {
$upload_Name[$k] = $prefix."_".$upload_Name[$k];
}
$upload_Size[$k] = ($_FILES[$key]['size']);
$upload_Temp[$k] = ($_FILES[$key]['tmp_name']);
$uploadlink[$k] = $uploadfolder."/".$upload_Name[$k]."\n";
$fieldname[$i] = ucwords(str_replace("_", " ", $key));
$dbfieldname[$i+3] = ucwords(strtolower(str_replace("_", "", $fieldname[$i])));
$dbfieldname[$i+3] = str_replace("-", "_", $dbfieldname[$i+3]);
$fieldvalue[$i] = allowurls("http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$uploadlink[$k]);
$logdata[$dbfieldname[$i+3]]= "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$uploadlink[$k];
$total_attach_size += $upload_Size[$k];
$i++;
$k++;
}
}
if ($copy_in_session == "Yes") {
$_SESSION['POST'] = $POST;
}
//Captcha Verification
if ($captcha_rewrite == "Yes") {
$script = basename($_SERVER['PHP_SELF']);
rewrite_captcha($script);
}
if (isset($_POST['captcha_code'])) {
if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
{
unset($_POST['captcha_code'],$_SESSION['random_txt']);
}
else
{
$error .= $captcha_error."
";
report_error($error, $error_url);
}
}
// Recaptcha Verification
if ($force_recaptcha == "Yes") {
require_once('dbts_includes/recaptchalib.php');
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error .= $captcha_error." / reCAPTCHA Error: ". $resp->error ."
";
report_error($error, $error_url);
}
}
$includefile = $after_filedata_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Set Total size of attachments
$total_attach_size = $total_attach_size/(1024*1000);
//Finding out if there are more than one email addresses to receive the admin email
$email = $POST['email'];
$mailtos = explode(",", $mailto);
$mailfrom = !empty($email) ? $email : $from_email;
$mailfrom = !empty($mailfrom) ? $mailfrom : $mailtos[0];
// Email validation
if (!empty($email)){
if (!ValidateEmail($email))
{
$error .= "The specified email address is invalid!\n
";
}
}
// ------------CHECKING FOR MAX UPLOADED FILE SIZE ----------------------
for ($i = 0; $i < count($upload_Name); $i++) {
if ($upload_Name[$i] != "" ) {
$ext = explode(".", $filename[$i]);
$file_ext = $ext[count($ext) - 1];
if (count($allowed_extensions) > 0) {
if (!in_array($file_ext, $allowed_extensions)) {
$error .= "The file type of $filename[$i] is not allowed!\n";
}
}
if ($upload_Size[$i] >= $filesize*1024) {
$error .= "The size of $upload_Name[$i] is bigger than the allowed $filesize Kb !\n";
}
}
}
$includefile = $before_error_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
if (!empty($error))
{
report_error($error, $error_url);
}
if($csvStore == "Yes"){
WriteToFile($csvFile, $csvType, $logdata, $dbfieldname);
}
if ($dbStore == "Yes") {
WriteToMySQL($db_name, $db_host, $db_user, $db_password, $db_table, $logdata, $dbfieldname, $create_table, $add_columns);
}
//Creating the Image code
if ($logo_image_url != "") {
$image_code = '';
}
if ($logo_link != "") {
$image_code = ''.$image_code.'';
}
if ($admin_mail == "Yes") {
require_once 'dbts_includes/admin_email.php';
$includefile = $before_admin_mail_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Send email in html format
require_once 'dbts_includes/class.phpmailer.php';
// Set Generic Details
$mail = new PHPMailer();
if ($mail_engine == "Sendmail") {
$mail->IsSendmail(); // set mailer to use Sendmail
}
if ($mail_engine == "Qmail") {
$mail->IsQmail(); // set mailer to use Sendmail
}
if ($mail_engine == "SMTP") {
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $SMTPHost; // specify main and backup server
$mail->Port = $Port; // specify smtp port
if ($SMTPAuth == "Yes") {
$mail->SMTPAuth = true; // turn on SMTP authentication
}
else {
$mail->SMTPAuth = false;
}
$mail->Username = $SMTPUser; // SMTP username
$mail->Password = $SMTPPass; // SMTP password
}
$mail->Subject = stripslashes($subject);
$mail->From = $mailfrom;
$mail->FromName = stripslashes($namefrom);
for ($i = 0; $i < count($mailtos); $i++){
$mail->AddAddress($mailtos[$i],"Webmaster");
}
if ($email != "") {
$mail->AddReplyTo($mailfrom);
}
$mail->WordWrap = 70;
if ($admin_mode == "HTML") {
$mail->IsHTML(true);
$mail->AltBody = $ALTmessage;
}
else {
$mail->IsHTML(false);
} // set word wrap to 70 characters
$mail->MsgHTML($MAILbody);
// optional, comment out and test
//$mail->MsgHTML($MAILbody);
// Lets add the attachments if so set
if($attach_files =="Yes" and $total_attach_size <= $max_attach_size){
if (!empty($_FILES))
{ $k = 0;
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $filesize*1024)
{ $mail->AddAttachment($upload_Temp[$k], $filename[$k]);
$k++;
}
}
}
}
if (!$mail->Send()) {
$report .=" EMAIL FAILED Mailer Error: " . $mail->ErrorInfo." \r\n";
report_error($report,$error_url);
}
}
//--------- Move the files to destination----------------
// We cant do this earlier as we need to add the files to the email body
if ($store_uploaded == "Yes") {
$uploadfolder1 = basename($uploadfolder);
for ($i = 0; $i < count($upload_Name); $i++) {
if ($upload_Size[$i] >0)
{
$uploadFile = "$uploadfolder1/".$upload_Name[$i];
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upload_Temp[$i] , $uploadFile);
chmod($uploadFile, 0644);
}
}
}
if ($autoresponder == "Yes" and $email != "")
{
require_once 'dbts_includes/auto_email.php';
$includefile = $before_auto_mail_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Send email in html format
require_once 'dbts_includes/class.phpmailer.php';
// Set Generic Details
$mail = new PHPMailer();
if ($mail_engine == "Sendmail") {
$mail->IsSendmail(); // set mailer to use Sendmail
}
if ($mail_engine == "Qmail") {
$mail->IsQmail(); // set mailer to use Sendmail
}
if ($mail_engine == "SMTP") {
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $SMTPHost; // specify main and backup server
$mail->Port = $Port; // specify smtp port
if ($SMTPAuth == "Yes") {
$mail->SMTPAuth = true; // turn on SMTP authentication
}
else {
$mail->SMTPAuth = false;
}
if ($SMTPSecure == "Yes") {
$mail->SMTPSecure = "ssl"; // turn on SMTP authentication
}
$mail->Username = $SMTPUser; // SMTP username
$mail->Password = $SMTPPass; // SMTP password
}
$mail->Subject = stripslashes($autorespondersubject);
$mail->From = stripslashes($autoresponderfrom);
$mail->FromName = stripslashes($autorespondernamefrom);
$mail->AddAddress($mailfrom);
$mail->AddReplyTo(stripslashes($autoresponderfrom));
$mail->WordWrap = 70;
if ($auto_mode == "HTML") {
$mail->IsHTML(true);
$mail->AltBody = $ALTmessage;
}
else{
$mail->IsHTML(false);
}
// set word wrap to 70 characters
$mail->MsgHTML($MAILbody);
// Lets add the attachments if so set
foreach ($auto_attachments as $attachment)
{
if (file_exists($attachment))
{ $mail->AddAttachment($attachment);
}
}
if (!$mail->Send()) {
$report .=" EMAIL FAILED Mailer Error: " . $mail->ErrorInfo." \r\n";
report_error($report,$error_url);
}
}
extract($POST, EXTR_OVERWRITE);
$includefile = $end_of_script_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
if($afterprocessing == "Include" and file_exists($end_include)){
include $end_include;
exit;
}
if($clear_session == "Yes"){
unset($_SESSION['POST']);
}
if($afterprocessing == "Redirect"){
header("Location: $success_url");
}
}
}
?>




