$n = $SETTINGS->rename == 'yes' ? $MSTICKET->rename($attachments[$aCount]['file'], $ID, $replyID, $j + 1) : $attachments[$aCount]['file']; // At this point we must upload the file to get file size.. $folder = $MSIMAP->uploadEmailAttachment($n, $attachments[$aCount]['attachment']); // If file upload now exists, check file size.. if ($folder && file_exists($SETTINGS->attachpath . '/' . $folder . $n)) { $fSize = filesize($SETTINGS->attachpath . '/' . $folder . $n); if ($fSize > 0) { if (!$MSTICKET->size($fSize)) { $MSIMAP->log('Size (' . mswFileSizeConversion($fSize) . ') too big and attachment ignored/deleted'); @unlink($SETTINGS->attachpath . '/' . $folder . $n); } else { // Try and determine mime type.. $mime = $DL->mime($attachments[$aCount]['file'], ''); $MSIMAP->log('Mime type determined as ' . $mime); // Add attachment data to database.. $atID = $MSIMAP->addAttachmentToDB($ID, $replyID, $n, $fSize, $mime); if ($atID > 0) { $pipes[3] = ++$pipes[3]; $attString[] = $SETTINGS->scriptpath . '/?attachment=' . $atID; $MSIMAP->log('Attachment (' . basename($n) . ') accepted. ID: ' . $atID . ' @ ' . mswFileSizeConversion($fSize)); } else { $MSIMAP->log('Fatal error, attachment could not be added: ' . mysql_error()); } } } else { $MSIMAP->log('File size 0 bytes, ignored.'); } } } else { $MSIMAP->log('Type (' . strrchr(strtolower($attachments[$aCount]['file']), '.') . ') invalid and attachment ignored.'); }