Skip to content

Commit

Permalink
Create and remove temp dir. fixes splitbrain#24, maybe splitbrain#25
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed May 19, 2012
1 parent 7a5bffa commit 1c9fae9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion DokuPDF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,42 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/

if(!defined('_MPDF_TEMP_PATH')) define('_MPDF_TEMP_PATH', $conf['tmpdir'].'/dwpdf/'.rand(1,1000));
if(!defined('_MPDF_TEMP_PATH')) define('_MPDF_TEMP_PATH', $conf['tmpdir'].'/dwpdf/'.rand(1,1000).'/');
if(!defined('_MPDF_TTFONTDATAPATH')) define('_MPDF_TTFONTDATAPATH',$conf['cachedir'].'/mpdf_ttf/');
require_once(dirname(__FILE__)."/mpdf/mpdf.php");

class DokuPDF extends mpdf {

function __construct(){
io_mkdir_p(_MPDF_TTFONTDATAPATH);
io_mkdir_p(_MPDF_TEMP_PATH);

// we're always UTF-8
parent::__construct('UTF-8-s');
$this->SetAutoFont(AUTOFONT_ALL);
$this->ignore_invalid_utf8 = true;
}

/**
* Cleanup temp dir
*/
function __destruct(){
$this->deletedir(_MPDF_TEMP_PATH);
}

/**
* Recursively delete a directory and its contents
*
* @link http://de3.php.net/manual/en/function.rmdir.php#108113
*/
function deletedir($dir){
foreach(glob($dir . '/*') as $file) {
if(is_dir($file))
$this->deletedir($file);
else
@unlink($file);
}
@rmdir($dir);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion plugin.info.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
base dw2pdf
author Luigi Micco
email l.micco@tiscali.it
date 2012-05-11
date 2012-05-19
name Dw2Pdf plugin
desc DokuWiki to PDF converter
url http://www.dokuwiki.org/plugin:dw2pdf
Expand Down

0 comments on commit 1c9fae9

Please sign in to comment.