Page 1 of 1

how to disable attachments for piping

Posted: Mon Jun 02, 2014 6:41 pm
by dr_patso
Hesk 2.5.1.

How do I disable attachments for email piping but keep them for tickets and KB? I have commented out all the process attachments function in my pipe_functions.inc.php, but my attachments folder has piled up to 10GB.. looks like a bunch of temp files in folders with the generated random file name.

I have done this. This makes it so there is no attachment in the attachment table, or on the ticket, but the temp files are not being deleted.

What is the best way to delete all these temp folders with the $useChars='AEUYBDGHJLMNPQRSTVWXZ123456789'; name that have piled up??

Code: Select all

	// Process attachments
//    $tmpvar['attachmment_notices'] = '';
//	$tmpvar['attachments'] = '';
//	$num = 0;
//	if ($hesk_settings['attachments']['use'] && isset($results['attachments'][0]))
//	{
//    	#print_r($results['attachments']);

//	    foreach ($results['attachments'] as $k => $v)
//	    {

			// Clean attachment names
//			$myatt['real_name'] = hesk_cleanFileName($v['orig_name']);

	    	// Check number of attachments, delete any over max number
//	        if ($num >= $hesk_settings['attachments']['max_number'])
//	        {
//            	$tmpvar['attachmment_notices'] .= sprintf($hesklang['attnum'], $myatt['real_name']) . "\n";
//	        }

	        // Check file extension
//			$ext = strtolower(strrchr($myatt['real_name'], "."));
//			if (!in_array($ext,$hesk_settings['attachments']['allowed_types']))
//			{
 //           	$tmpvar['attachmment_notices'] .= sprintf($hesklang['atttyp'], $myatt['real_name']) . "\n";
//				continue;
//			}

	        // Check file size
//	        $myatt['size'] = $v['size'];
//			if ($myatt['size'] > ($hesk_settings['attachments']['max_size']))
//			{
//            	$tmpvar['attachmment_notices'] .= sprintf($hesklang['attsiz'], $myatt['real_name']) . "\n";
//				continue;
//			}

			// Generate a random file name
//			$useChars='AEUYBDGHJLMNPQRSTVWXZ123456789';
//			$tmp = $useChars{mt_rand(0,29)};
//			for($j=1;$j<10;$j++)
//			{
//			    $tmp .= $useChars{mt_rand(0,29)};
//			}
//		    $myatt['saved_name'] = substr($tmpvar['trackid'] . '_' . md5($tmp . $myatt['real_name']), 0, 200) . $ext;

	        // Rename the temporary file
//	        rename($v['stored_name'],HESK_PATH.$hesk_settings['attach_dir'].'/'.$myatt['saved_name']);

	        // Insert into database
//	        hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` (`ticket_id`,`saved_name`,`real_name`,`size`) VALUES ('".hesk_dbEscape($tmpvar['trackid'])."','".hesk_dbEscape($myatt['saved_name'])."','".hesk_dbEscape($myatt['real_name'])."','".intval($myatt['size'])."')");
//	        $tmpvar['attachments'] .= hesk_dbInsertID() . '#' . $myatt['real_name'] .',';
//
//	        $num++;
//	    }

 //       if (strlen($tmpvar['attachmment_notices']))
 //       {
 //       	$tmpvar['message'] .= "<br /><br />" . hesk_input($hesklang['attrem'],'','',1) . "<br />" . nl2br(hesk_input($tmpvar['attachmment_notices'],'','',1));
 //       }
//	}

	// Delete the temporary files
	deleteAll($results['tempdir']);

Re: how to disable attachments for piping

Posted: Mon Jun 02, 2014 7:44 pm
by Klemen
If you have undeleted random named folders with objects inside attachments, these are probably left-over email parts from email piping.

HESK should delete these files, if they are staying behind (and you didn't modify any file cleanup logics) it's most likely a permissions error.

The best way to delete subfolders would be over SSH, if you have access to it. Something like (BACKUP FIRST, of course)

Code: Select all

rm -rf /home/USERNAME/hesk/attachments/*/
If you don't have SSH access, asking your hosting company to run that command for you would be the easiest and fastest solution.

Re: how to disable attachments for piping

Posted: Mon Jun 02, 2014 8:25 pm
by dr_patso
I have a wamp server. I'm sure i can translate that to command prompt. I don't know if I have modified cleanup logistics. I commented out all the process attachments lines except

Code: Select all

   deleteAll($results['tempdir']);
That should work right? I have checked windows and the "user" CREATOR OWNER now has full control to the attachments folder. Hesk did say /attachments exists and was writeable. I am hoping this fixes that.

Re: how to disable attachments for piping

Posted: Tue Jun 03, 2014 5:58 pm
by Klemen
Try cleaning up everything, sending a new email and see if a temporary folder remains after ticket is created - that's the only sure way to see if the files are getting deleted or not.