Exemple #1
0
 public static function processemail($infile, $outfile, $coverfile)
 {
     #Generate an intermediate file name for the pdf file
     $intmpname = (string) abs((int) (microtime(true) * 100000));
     # Create a temporary file name for the pdf and tiff file
     $pdffile = sys_get_temp_dir() . '/' . $intmpname . '.pdf';
     $tiffile = sys_get_temp_dir() . '/' . $intmpname . '.tiff';
     emailtopdf::processemail($infile, $pdffile, $coverfile);
     $convcom = str_replace(array('PDFFILE', 'OUTFILE'), array($pdffile, $tiffile), self::$convdriver);
     exec($convcom);
     # Write the intermediate file to the final destination
     $intfileres = fopen($tiffile, 'rb');
     $outfileres = fopen($outfile, 'ab');
     while (!feof($intfileres)) {
         fwrite($outfileres, fread($intfileres, 8192));
     }
     fclose($intfileres);
     fclose($outfileres);
     # Remove the intermediate files
     unlink($pdffile);
     unlink($tiffile);
 }
Exemple #2
0
        default:
            if ($infile == '') {
                $infile = $args[$i];
            } else {
                $outfile = $args[$i];
            }
            break;
    }
}
if ($infile == '') {
    printusage('No input file specified.');
}
if ($outfile == '') {
    if ($infile != 'php://stdin') {
        $outfile = $infile . '.pdf';
    } else {
        printusage('No output file specified.');
    }
}
# Check to see if the output file exists
if (file_exists($outfile)) {
    # If it exists, check to see if we are to overwrite it.
    if ($force) {
        unlink($outfile);
    } else {
        printusage('Output file already exists.  Use -f to overwrite.');
    }
}
touch($outfile);
emailtopdf::processemail($infile, $outfile, $coverfile);