public function faqAttachment($id, $s, $admin = false) { $q = mysql_query("SELECT *,DATE(FROM_UNIXTIME(`ts`)) AS `addDate` FROM `" . DB_PREFIX . "faqattach`\n WHERE `id` = '{$id}'\n ") or die(mswMysqlErrMsg(mysql_errno(), mysql_error(), __LINE__, __FILE__)); $F = mysql_fetch_object($q); if (isset($F->id)) { $base = $s->attachpathfaq . '/'; // Remote or not.. if ($F->remote) { header("Location: " . $F->remote); exit; } else { if (file_exists($base . $F->path)) { $m = msDownload::mime($base . $F->path, $F->mimeType); msDownload::dl($base . $F->path, $m, 'no'); } else { $H = new htmlHeaders(); $H->err404($admin); } } } else { $H = new htmlHeaders(); $H->err403($admin); } }
$ext = $ticketData['tickets'][$i]['attachments'][$a]['ext']; $file = $ticketData['tickets'][$i]['attachments'][$a]['data']; // The API always renames incoming files as no file name is required.. $n = $MSTICKET->rename($ID . '.' . $ext, $ID, 0, $a + 1); // At this point we must upload the file to get file size.. // Replace any spaces in data with + symbol to maintain incoming data modified by urldecode.. $folder = $MSAPI->uploadEmailAttachment($n, strtr($file, ' ', '+')); if ($folder && file_exists($SETTINGS->attachpath . '/' . $folder . $n)) { $fSize = filesize($SETTINGS->attachpath . '/' . $folder . $n); if ($fSize > 0) { if (!$MSTICKET->size($fSize)) { $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Size (' . mswFileSizeConversion($fSize) . ') too big and attachment ignored/deleted'); @unlink($SETTINGS->attachpath . '/' . $folder . $n); } else { // Try and determine mime type.. $mime = $DL->mime($SETTINGS->attachpath . '/' . $folder . $n, ''); $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Mime type determined as ' . $mime); // Add attachment data to database.. $atID = $MSAPI->addAttachmentToDB($ID, 0, $n, $fSize, $deptID, $mime); if ($atID > 0) { $attString[] = $SETTINGS->scriptpath . '/?attachment=' . $atID; $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Attachment (' . basename($n) . ') accepted. ID: ' . $atID . ' @ ' . mswFileSizeConversion($fSize)); } else { $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Fatal error, attachment could not be added: ' . mysql_error()); } } } else { $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] File size of attachment 0 bytes. Ignored. Maybe permissions or error reading file.'); } } }
$MSIMAP->log('Check Attachment: ' . $attachments[$aCount]['file']); // Check for valid file type.. if ($MSTICKET->type($attachments[$aCount]['file'])) { $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.'); } }