} elseif (empty($input->p['message'])) { $show_error = true; $error_msg = $LANG['ONE_REQUIRED_FIELD_EMPTY']; } else { if ($settings['ticket_attachment'] == 1) { $uploaddir = UPLOAD_DIR . 'tickets/'; if ($_FILES['attachment']['error'] == 0) { $ext = pathinfo($_FILES['attachment']['name'], PATHINFO_EXTENSION); $filename = md5($_FILES['attachment']['name'] . time()) . "." . $ext; $fileuploaded = array('name' => $_FILES['attachment']['name'], 'enc' => $filename, 'size' => formatBytes($_FILES['attachment']['size']), 'filetype' => $_FILES['attachment']['type']); $uploadedfile = $uploaddir . $filename; if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadedfile)) { $show_error = true; $error_msg = $LANG['ERROR_UPLOADING_A_FILE']; } else { $fileverification = verifyAttachment($_FILES['attachment']); switch ($fileverification['msg_code']) { case '1': $show_error = true; $error_msg = $LANG['INVALID_FILE_EXTENSION']; break; case '2': $show_error = true; $error_msg = $LANG['FILE_NOT_ALLOWED']; break; case '3': $show_error = true; $error_msg = str_replace("%size%", $fileverification['msg_extra'], $LANG['FILE_IS_BIG']); break; } }
if (is_array($attachments)) { $save_dir = UPLOAD_DIR; foreach ($attachments as $attachment) { // get the attachment name $filename = $attachment->filename; // write the file to the directory you want to save it in if ($fp = fopen($save_dir . $filename, 'w')) { while ($bytes = $attachment->read()) { fwrite($fp, $bytes); } fclose($fp); } $filesize = @filesize(UPLOAD_DIR . $filename); if ($filesize) { $fileinfo = array('name' => $filename, 'size' => $filesize); $fileverification = verifyAttachment($fileinfo); if ($fileverification['msg_code'] == 0) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $filename_encoded = md5($filename . time()) . "." . $ext; $data = array('name' => $filename, 'enc' => $filename_encoded, 'filesize' => $filesize, 'ticket_id' => $ticket['id'], 'msg_id' => $message_id, 'filetype' => $attachment->content_type); $db->insert(TABLE_PREFIX . "attachments", $data); rename(UPLOAD_DIR . $filename, UPLOAD_DIR . 'tickets/' . $filename_encoded); } else { unlink(UPLOAD_DIR . $filename); } } } } /* Mailer */ $fullname = $from_name; $email = $from_email;