}
+
+ function serveOnly($type=false, $filename =false, $delete_after = false)
+ {
+ $this->target = $this->fn;
+ $this->to = $this->mimetype;
+ $this->serve($type, $filename , $delete_after );
+ }
+
+
/**
* Serve the file to a browser so it can be downloaded, or viewed.
*
*/
function serve($type=false, $filename =false, $delete_after = false) // may die **/
{
- if (empty($this->target)) {
+ if (empty($this->target)) {
// broken image? for images...
$cmd = isset($this->lastaction->cmd) ? $this->lastaction->cmd : "No Method";
die("not available in this format was: {$this->mimetype}, request: {$this->to}<BR>
function targetName($fn,$x,$y)
{
- return $fn .'.'. $this->ext;
+ return $fn .'.'. $this->ext;
}
function deleteOnExitAdd($name)
{
if (self::$deleteOnExit === false) {
- register_shutdown_function(array('Pman','deleteOnExit'));
self::$deleteOnExit = array();
+ register_shutdown_function(array('File_Convert_Solution','deleteOnExit'));
+
}
self::$deleteOnExit[] = $name;
}
}
- static function deleteOnExit()
+ static function deleteOnExit()
{
-
+ if (count(func_get_args())) {
+ trigger_error("Call deleteOnExitAdd ?!?");
+ }
foreach(self::$deleteOnExit as $fn) {
if (file_exists($fn)) {
unlink($fn);
* /usr/bin/xvfb-run --auto /usr/bin/wine dp.exe /InFile C:\\KNT1431-BO-TP-001.dwg /OutFile C:\\KNT1431-BO-TP-001.pdf /OutMode AlltoOne /Overwrite /OutLayout Paper /OutArea ZoomExtends
*/
-class File_Convert_Solution_anydwgtopdf {
+class File_Convert_Solution_anydwgtopdf extends File_Convert_Solution
+{
static $rules = array(
array(
'drawing/dwg'
),
'to' => array( //target
- 'application/pdf'
+ 'application/pdf'
)
),
//b) run the conversion
//c) copy (link) out the files (and delete)
+ $tn = $this->targetName($fn, $x,$y);
+ if (file_exists($tn)) {
+ return $tn;
+ }
+
$wine = $this->which('wine');
$xvfb = $this->which('xvfb-run');
$dir = '/var/www/.wine/drive_c/';
$wfrom = $dir . $fromb;
$wto = $dir . $tob;
- $this->deleteOnExit($wfrom);
- $this->deleteOnExit($wto);
+ $this->deleteOnExitAdd($wfrom);
+ $this->deleteOnExitAdd($wto);
+ link($fn,$wfrom);
- link($wfrom, $fn);
-
- $cmd = "{$xvfb} --auto {$wine} /InFile C:\\{$fromb} /OutFile C:\\{$tob}" .
+ $cmd = "{$xvfb} --auto {$wine} \"/var/www/.wine/drive_c/Program Files (x86)/Any DWG to PDF Converter Pro/dp.exe\" /InFile C:\\\\{$fromb} /OutFile C:\\\\{$tob}" .
"/OutMode AlltoOne /Overwrite /OutLayout Paper /OutArea ZoomExtends";
$this->exec($cmd);
if (!file_Exists($wto)) {
// failed.
return false;
}
- $tn = $this->targetName();
- link($tn, $wto);
+
+ link( $wto,$tn);
clearstatcache();
return file_exists($tn) ? $tn : false;