- by admin
There is an error while sending mail in Mac OS X Mountain Lion 10.8:send-mail: fatal: chdir /Library/Server/Mail/Data/spool: No such file or directory
sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start
- by admin
Here what I found and like most.// Set the allowed types for reading and upload.
$types = array ('jpg', 'jpeg', 'txt');
// Start a variable.
$dir_files = array();
// If it is a directory add all the files.
if (is_dir ($dir)) {
// Open the directory.
if ($handle = opendir($dir)) {
// Read the file names of all the files available.
while (false !== ($file = readdir($handle))) {
// Make sure the file is not this directory or its parent and not the .DS_Store file.
if ($file != "." && $file != ".." && $file != '.DS_Store') {
// Get the file parts.
$file_parts = pathinfo($file);
// Make sure the extension is allowed.
if (in_array(strtolower ($file_parts['extension']),$types)) {
// Add the file to the array.
$dir_files[] = array ('original_name'=>$file, 'type'=>$file_parts['extension']);
}
}
}
// Close the handle.
closedir ($handle);
}
}
// If any files exist in the upload directory check them for viruses.
if (count ($dir_files) > 0) {
// Get the dir and prepare it for the command line.
$real_path = realpath ($dir);
$safe_path = escapeshellarg($real_path);
// Set the variables for the cmd.
$return = -1;
$out ='';
$cmd = '/usr/local/clamXav/bin/clamscan ' . $safe_path;
// Execute the cmd.
exec ($cmd, $out, $return);
// If a virus is found loop through each of the files and delete the virus, write the user a message, and add them to a db table.
if ($return != 0) {
// Loop through the files.
foreach ($dir_files as $k=>$v) {
// Get the dir and prepare it for the command line.
$real_path = realpath ($dir . $v['original_name']);
$safe_path = escapeshellarg($real_path);
// Reset the values.
$return = -1;
$out ='';
$cmd = '/usr/local/clamXav/bin/clamscan ' . $safe_path;
// Execute the command.
exec ($cmd, $out, $return);
// If the file is clean do nothing.
if ($return == 0){}
// If the file contains a virus remove it and add a note to the db.
else if ($return == 1) {
// Delete the file.
unlink ($dir . $v['original_name']);
// Unset the file from the records.
unset ($dir_files[$k]);
// Notify the user.
$message .= "The file {$v['original_name']} contained a known virus. It has been deleted from the server.<br />";
$message_class = 'error';
// Add the user who uploaded the file to the db and a time and date.
// Query the db to record who uploaded the file, not necessary but fun info to have.
}
else {
// Delete the file.
unlink ($dir . $v['original_name']);
// Unset the file from the records.
unset ($dir_files[$k]);
// Notify the user.
$message .= "The file {$v['original_name']} caused an unknown error and was removed from the server.<br />";
$message_class = 'minor_error';
}
}
}
}